Icon command is now really processed and icons are rendered.
Also updated icon code in curses_drv a bit.
This commit is contained in:
@@ -314,7 +314,7 @@ widget_set_func (Client * c, int argc, char **argv)
|
|||||||
sock_send_string(c->sock, "success\n");
|
sock_send_string(c->sock, "success\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WID_ICON: /* Icon takes "x y binary_data"*/
|
case WID_ICON: /* Icon takes "x y icon"*/
|
||||||
if (argc != i + 3)
|
if (argc != i + 3)
|
||||||
sock_send_string (c->sock, "huh? Wrong number of arguments\n");
|
sock_send_string (c->sock, "huh? Wrong number of arguments\n");
|
||||||
else {
|
else {
|
||||||
@@ -322,14 +322,20 @@ widget_set_func (Client * c, int argc, char **argv)
|
|||||||
(!isdigit ((unsigned int) argv[i + 1][0]))) {
|
(!isdigit ((unsigned int) argv[i + 1][0]))) {
|
||||||
sock_send_string (c->sock, "huh? Invalid coordinates\n");
|
sock_send_string (c->sock, "huh? Invalid coordinates\n");
|
||||||
} else {
|
} else {
|
||||||
|
int icon;
|
||||||
x = atoi (argv[i]);
|
x = atoi (argv[i]);
|
||||||
y = atoi (argv[i + 1]);
|
y = atoi (argv[i + 1]);
|
||||||
|
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->x = x;
|
||||||
w->y = y;
|
w->y = y;
|
||||||
/* TODO: Parse binary data and copy it to widget's data...*/
|
w->length = icon;
|
||||||
|
sock_send_string(c->sock, "success\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sock_send_string (c->sock, "huh? Widget type not yet implemented\n");
|
|
||||||
break;
|
break;
|
||||||
case WID_TITLE: /* title takes "text"*/
|
case WID_TITLE: /* title takes "text"*/
|
||||||
if (argc != i + 1)
|
if (argc != i + 1)
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include "shared/report.h"
|
#include "shared/report.h"
|
||||||
#include "configfile.h"
|
#include "configfile.h"
|
||||||
|
|
||||||
|
#include "widget.h"
|
||||||
#include "driver.h"
|
#include "driver.h"
|
||||||
#include "drivers.h"
|
#include "drivers.h"
|
||||||
#include "drivers/lcd.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;
|
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)
|
if (!drv->chr)
|
||||||
return;
|
return;
|
||||||
for ( pos=0; pos<len; pos++ ) {
|
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;
|
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)
|
if (!drv->chr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -401,6 +406,8 @@ driver_alt_num( Driver * drv, int x, int num )
|
|||||||
|
|
||||||
int y, dx;
|
int y, dx;
|
||||||
|
|
||||||
|
debug (RPT_DEBUG, "%s( drv=[%.40s], x=%d, num=%d", __FILE__, drv->name, x, num);
|
||||||
|
|
||||||
if (!drv->chr)
|
if (!drv->chr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -414,6 +421,7 @@ driver_alt_heartbeat( Driver * drv, int state )
|
|||||||
{
|
{
|
||||||
int icon;
|
int icon;
|
||||||
|
|
||||||
|
debug (RPT_DEBUG, "%s( drv=[%.40s], state=%d", __FILE__, drv->name, state);
|
||||||
|
|
||||||
if (state == HEARTBEAT_OFF)
|
if (state == HEARTBEAT_OFF)
|
||||||
return;
|
return;
|
||||||
@@ -439,6 +447,8 @@ driver_alt_icon( Driver * drv, int x, int y, int icon )
|
|||||||
char ch1 = '?';
|
char ch1 = '?';
|
||||||
char ch2 = 0;
|
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)
|
if (!drv->chr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -469,6 +479,8 @@ void driver_alt_cursor( Driver * drv, int x, int y, int state )
|
|||||||
{
|
{
|
||||||
/* Same question about timer in this function... */
|
/* 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 ) {
|
switch( state ) {
|
||||||
case CURSOR_BLOCK:
|
case CURSOR_BLOCK:
|
||||||
case CURSOR_DEFAULT_ON:
|
case CURSOR_DEFAULT_ON:
|
||||||
|
|||||||
+1
-1
@@ -294,7 +294,7 @@ drivers_icon( int x, int y, int icon )
|
|||||||
{
|
{
|
||||||
Driver *drv;
|
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) {
|
ForAllDrivers(drv) {
|
||||||
if( drv->icon )
|
if( drv->icon )
|
||||||
|
|||||||
@@ -543,17 +543,32 @@ curses_drv_hbar (Driver *drvthis, int x, int y, int len, int promille, int optio
|
|||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
curses_drv_icon (Driver *drvthis, int x, int y, int icon)
|
curses_drv_icon (Driver *drvthis, int x, int y, int icon)
|
||||||
{
|
{
|
||||||
|
char ch1 = '?';
|
||||||
|
char ch2 = 0;
|
||||||
|
|
||||||
switch (icon) {
|
switch (icon) {
|
||||||
case ICON_HEART_OPEN:
|
case ICON_BLOCK_FILLED: ch1 = ACS_BLOCK; break;
|
||||||
curses_drv_chr( drvthis, x, y, '+');
|
case ICON_HEART_OPEN: ch1 = '-'; break;
|
||||||
break;
|
case ICON_HEART_FILLED: ch1 = '+'; break;
|
||||||
case ICON_HEART_FILLED:
|
case ICON_ARROW_UP: ch1 = '^'; break; /* or does curses do real arrows ? */
|
||||||
curses_drv_chr( drvthis, x, y, '*');
|
case ICON_ARROW_DOWN: ch1 = 'v'; break;
|
||||||
break;
|
case ICON_ARROW_LEFT: ch1 = '<'; break;
|
||||||
case ICON_BLOCK_FILLED:
|
case ICON_ARROW_RIGHT: ch1 = '>'; break;
|
||||||
curses_drv_chr( drvthis, x, y, ACS_BLOCK);
|
case ICON_STOP: ch1 = '['; ch2 = ']'; break;
|
||||||
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
|
/* There was something with placing PAD
|
||||||
* What wasthat ever for ?
|
* What wasthat ever for ?
|
||||||
*/
|
*/
|
||||||
|
|||||||
+7
-5
@@ -305,7 +305,9 @@ draw_frame (LinkedList * list,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WID_ICON: /* FIXME: Not implemented*/
|
case WID_ICON:
|
||||||
|
drivers_icon (w->x, w->y, w->length);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case WID_TITLE: /* FIXME: Doesn't work quite right in frames...*/
|
case WID_TITLE: /* FIXME: Doesn't work quite right in frames...*/
|
||||||
if (!w->text)
|
if (!w->text)
|
||||||
@@ -313,8 +315,8 @@ draw_frame (LinkedList * list,
|
|||||||
if (vis_width < 8)
|
if (vis_width < 8)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
drivers_icon (w->x, w->y, ICON_BLOCK_FILLED);
|
drivers_icon (w->x + left, w->y + top, ICON_BLOCK_FILLED);
|
||||||
drivers_icon (w->x+1, w->y, ICON_BLOCK_FILLED);
|
drivers_icon (w->x + 1 + left, w->y + top, ICON_BLOCK_FILLED);
|
||||||
|
|
||||||
str[0] = ' ';
|
str[0] = ' ';
|
||||||
length = strlen (w->text);
|
length = strlen (w->text);
|
||||||
@@ -353,10 +355,10 @@ draw_frame (LinkedList * list,
|
|||||||
}
|
}
|
||||||
str[vis_width-4] = 0;
|
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++) {
|
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;
|
break;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
|
#include "drivers/lcd.h"
|
||||||
|
|
||||||
char *typenames[] = {
|
char *typenames[] = {
|
||||||
"none",
|
"none",
|
||||||
@@ -36,9 +37,33 @@ char *typenames[] = {
|
|||||||
NULL,
|
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 widget *widget_finder (LinkedList * list, char *id);
|
||||||
//static int widget_remover (LinkedList * list, widget * w);
|
//static int widget_remover (LinkedList * list, widget * w);
|
||||||
|
|
||||||
|
|
||||||
Widget *
|
Widget *
|
||||||
widget_create (char *id, WidgetType type, Screen * screen)
|
widget_create (char *id, WidgetType type, Screen * screen)
|
||||||
{
|
{
|
||||||
@@ -148,3 +173,30 @@ widget_search_subs (Widget * w, char * id)
|
|||||||
return NULL; /* no kids */
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,4 +60,10 @@ char *widget_type_to_typename (WidgetType t);
|
|||||||
/* Search subwidgets of a widget */
|
/* Search subwidgets of a widget */
|
||||||
Widget * widget_search_subs (Widget * w, char * id);
|
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
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user