Icon command is now really processed and icons are rendered.

Also updated icon code in curses_drv a bit.
This commit is contained in:
robijn
2002-05-20 21:25:17 +00:00
parent d3cf1569eb
commit 78d8886c47
7 changed files with 113 additions and 20 deletions
+11 -5
View File
@@ -314,7 +314,7 @@ widget_set_func (Client * c, int argc, char **argv)
sock_send_string(c->sock, "success\n");
}
break;
case WID_ICON: /* Icon takes "x y binary_data"*/
case WID_ICON: /* Icon takes "x y icon"*/
if (argc != i + 3)
sock_send_string (c->sock, "huh? Wrong number of arguments\n");
else {
@@ -322,14 +322,20 @@ widget_set_func (Client * c, int argc, char **argv)
(!isdigit ((unsigned int) argv[i + 1][0]))) {
sock_send_string (c->sock, "huh? Invalid coordinates\n");
} else {
int icon;
x = atoi (argv[i]);
y = atoi (argv[i + 1]);
w->x = x;
w->y = y;
/* TODO: Parse binary data and copy it to widget's data...*/
icon = widget_iconname_to_icon (argv[i + 2]);
if (icon == -1) {
sock_send_string (c->sock, "huh? Invalid icon name\n");
} else {
w->x = x;
w->y = y;
w->length = icon;
sock_send_string(c->sock, "success\n");
}
}
}
sock_send_string (c->sock, "huh? Widget type not yet implemented\n");
break;
case WID_TITLE: /* title takes "text"*/
if (argc != i + 1)
+12
View File
@@ -29,6 +29,7 @@
#include "shared/report.h"
#include "configfile.h"
#include "widget.h"
#include "driver.h"
#include "drivers.h"
#include "drivers/lcd.h"
@@ -311,6 +312,8 @@ driver_alt_vbar( Driver * drv, int x, int y, int len, int promille, int pattern
{
int pos;
debug (RPT_DEBUG, "%s( drv=[%.40s], x=%d, y=%d, len=%d, promille=%d, pattern=%d", __FILE__, drv->name, x, y, len, promille, pattern);
if (!drv->chr)
return;
for ( pos=0; pos<len; pos++ ) {
@@ -327,6 +330,8 @@ driver_alt_hbar( Driver * drv, int x, int y, int len, int promille, int pattern
{
int pos;
debug (RPT_DEBUG, "%s( drv=[%.40s], x=%d, y=%d, len=%d, promille=%d, pattern=%d", __FILE__, drv->name, x, y, len, promille, pattern);
if (!drv->chr)
return;
@@ -401,6 +406,8 @@ driver_alt_num( Driver * drv, int x, int num )
int y, dx;
debug (RPT_DEBUG, "%s( drv=[%.40s], x=%d, num=%d", __FILE__, drv->name, x, num);
if (!drv->chr)
return;
@@ -414,6 +421,7 @@ driver_alt_heartbeat( Driver * drv, int state )
{
int icon;
debug (RPT_DEBUG, "%s( drv=[%.40s], state=%d", __FILE__, drv->name, state);
if (state == HEARTBEAT_OFF)
return;
@@ -439,6 +447,8 @@ driver_alt_icon( Driver * drv, int x, int y, int icon )
char ch1 = '?';
char ch2 = 0;
debug (RPT_DEBUG, "%s( drv=[%.40s], x=%d, y=%d, icon=ICON_%s", __FILE__, drv->name, x, y, widget_icon_to_iconname (icon) );
if (!drv->chr)
return;
@@ -469,6 +479,8 @@ void driver_alt_cursor( Driver * drv, int x, int y, int state )
{
/* Same question about timer in this function... */
debug (RPT_DEBUG, "%s( drv=[%.40s], x=%d, y=%d, state=%d", __FILE__, drv->name, x, y, state);
switch( state ) {
case CURSOR_BLOCK:
case CURSOR_DEFAULT_ON:
+1 -1
View File
@@ -294,7 +294,7 @@ drivers_icon( int x, int y, int icon )
{
Driver *drv;
report( RPT_INFO, "drivers_icon( x=%d, y=%d, icon=%d )", x, y, icon );
report( RPT_INFO, "drivers_icon( x=%d, y=%d, icon=ICON_%s )", x, y, widget_icon_to_iconname (icon) );
ForAllDrivers(drv) {
if( drv->icon )
+24 -9
View File
@@ -543,17 +543,32 @@ curses_drv_hbar (Driver *drvthis, int x, int y, int len, int promille, int optio
MODULE_EXPORT void
curses_drv_icon (Driver *drvthis, int x, int y, int icon)
{
char ch1 = '?';
char ch2 = 0;
switch (icon) {
case ICON_HEART_OPEN:
curses_drv_chr( drvthis, x, y, '+');
break;
case ICON_HEART_FILLED:
curses_drv_chr( drvthis, x, y, '*');
break;
case ICON_BLOCK_FILLED:
curses_drv_chr( drvthis, x, y, ACS_BLOCK);
break;
case ICON_BLOCK_FILLED: ch1 = ACS_BLOCK; break;
case ICON_HEART_OPEN: ch1 = '-'; break;
case ICON_HEART_FILLED: ch1 = '+'; break;
case ICON_ARROW_UP: ch1 = '^'; break; /* or does curses do real arrows ? */
case ICON_ARROW_DOWN: ch1 = 'v'; break;
case ICON_ARROW_LEFT: ch1 = '<'; break;
case ICON_ARROW_RIGHT: ch1 = '>'; break;
case ICON_STOP: ch1 = '['; ch2 = ']'; break;
case ICON_PAUSE: ch1 = '|'; ch2 = '|'; break;
case ICON_PLAY: ch1 = '>'; ch2 = ' '; break;
case ICON_PLAYR: ch1 = '<'; ch2 = ' '; break;
case ICON_FF: ch1 = '>'; ch2 = '>'; break;
case ICON_FR: ch1 = '<'; ch2 = '<'; break;
case ICON_NEXT: ch1 = '>'; ch2 = '|'; break;
case ICON_PREV: ch1 = '|'; ch2 = '<'; break;
case ICON_REC: ch1 = '('; ch2 = ')'; break;
}
curses_drv_chr( drvthis, x, y, ch1);
if (ch2) {
curses_drv_chr( drvthis, x+1, y, ch2);
}
/* There was something with placing PAD
* What wasthat ever for ?
*/
+7 -5
View File
@@ -305,7 +305,9 @@ draw_frame (LinkedList * list,
}
}
break;
case WID_ICON: /* FIXME: Not implemented*/
case WID_ICON:
drivers_icon (w->x, w->y, w->length);
break;
case WID_TITLE: /* FIXME: Doesn't work quite right in frames...*/
if (!w->text)
@@ -313,8 +315,8 @@ draw_frame (LinkedList * list,
if (vis_width < 8)
break;
drivers_icon (w->x, w->y, ICON_BLOCK_FILLED);
drivers_icon (w->x+1, w->y, ICON_BLOCK_FILLED);
drivers_icon (w->x + left, w->y + top, ICON_BLOCK_FILLED);
drivers_icon (w->x + 1 + left, w->y + top, ICON_BLOCK_FILLED);
str[0] = ' ';
length = strlen (w->text);
@@ -353,10 +355,10 @@ draw_frame (LinkedList * list,
}
str[vis_width-4] = 0;
drivers_string (3 + left, 1 + top, str);
drivers_string (w->x + 2 + left, w->y + top, str);
for (; x<vis_width; x++) {
drivers_icon (w->x+x, w->y, ICON_BLOCK_FILLED);
drivers_icon (w->x + x + left, w->y + top, ICON_BLOCK_FILLED);
}
break;
+52
View File
@@ -22,6 +22,7 @@
#include "screen.h"
#include "widget.h"
#include "render.h"
#include "drivers/lcd.h"
char *typenames[] = {
"none",
@@ -36,9 +37,33 @@ char *typenames[] = {
NULL,
};
struct icontable {
int icon;
char *iconname;
} icontable[] = {
{ICON_BLOCK_FILLED, "BLOCK_FILLED"},
{ICON_HEART_OPEN, "HEART_OPEN"},
{ICON_HEART_FILLED, "HEART_FILLED"},
{ICON_ARROW_UP, "ARROW_UP"},
{ICON_ARROW_DOWN, "ARROW_DOWN"},
{ICON_ARROW_LEFT, "ARROW_LEFT"},
{ICON_ARROW_RIGHT, "ARROW_RIGHT"},
{ICON_STOP, "STOP"},
{ICON_PAUSE, "PAUSE"},
{ICON_PLAY, "PLAY"},
{ICON_PLAYR, "PLAYR"},
{ICON_FF, "FF"},
{ICON_FR, "FR"},
{ICON_NEXT, "NEXT"},
{ICON_PREV, "PREV"},
{ICON_REC, "REC"},
{0,NULL}
};
//static widget *widget_finder (LinkedList * list, char *id);
//static int widget_remover (LinkedList * list, widget * w);
Widget *
widget_create (char *id, WidgetType type, Screen * screen)
{
@@ -148,3 +173,30 @@ widget_search_subs (Widget * w, char * id)
return NULL; /* no kids */
}
}
char *widget_icon_to_iconname (int icon)
{
int i;
for (i=0; icontable[i].iconname; i++) {
if (icontable[i].icon == icon) {
return icontable[i].iconname;
}
}
return NULL;
}
int widget_iconname_to_icon (char *iconname)
{
int i;
for (i=0; icontable[i].iconname; i++) {
if (strcasecmp( icontable[i].iconname, iconname) == 0) {
return icontable[i].icon;
}
}
return -1;
}
+6
View File
@@ -60,4 +60,10 @@ char *widget_type_to_typename (WidgetType t);
/* Search subwidgets of a widget */
Widget * widget_search_subs (Widget * w, char * id);
/* Convert icon number to icon name */
char *widget_icon_to_iconname (int icon);
/* Convert iconname to icon number */
int widget_iconname_to_icon (char *iconname);
#endif