diff --git a/client/src/gui/button.c b/client/src/gui/button.c index 20deb45..f13bd97 100644 --- a/client/src/gui/button.c +++ b/client/src/gui/button.c @@ -23,7 +23,7 @@ static void buttonDel(WidgetT **widget); static void buttonMouseEvent(WidgetT *widget, MouseT *mouse, uint16_t x, uint16_t y, uint8_t event); -static void buttonPaint(WidgetT *widget, RectT pos); +static void buttonPaint(WidgetT *widget, uint8_t enabled, RectT pos); void buttonClickHandlerSet(ButtonT *button, widgetCallback callback) { @@ -103,18 +103,30 @@ ButtonT *buttonNew(uint16_t x, uint16_t y, char *title, widgetCallback callback) } -static void buttonPaint(WidgetT *widget, RectT pos) { +static void buttonPaint(WidgetT *widget, uint8_t enabled, RectT pos) { ButtonT *b; int16_t i; int8_t active; ColorT highlight; ColorT shadow; + ColorT background; + ColorT text; if (GUI_GET_FLAG(widget, WIDGET_FLAG_DIRTY)) { b = (ButtonT *)widget; active = GUI_GET_FLAG(widget, WIDGET_FLAG_ACTIVE); - highlight = active ? _guiColor[COLOR_BUTTON_SHADOW] : _guiColor[COLOR_BUTTON_HIGHLIGHT]; - shadow = active ? _guiColor[COLOR_BUTTON_HIGHLIGHT] : _guiColor[COLOR_BUTTON_SHADOW]; + + if (enabled) { + highlight = active ? _guiColor[COLOR_BUTTON_SHADOW] : _guiColor[COLOR_BUTTON_HIGHLIGHT]; + shadow = active ? _guiColor[COLOR_BUTTON_HIGHLIGHT] : _guiColor[COLOR_BUTTON_SHADOW]; + background = _guiColor[COLOR_BUTTON_BACKGROUND]; + text = _guiColor[COLOR_BUTTON_TEXT]; + } else { + highlight = active ? _guiColor[COLOR_BUTTON_SHADOW_DISABLED] : _guiColor[COLOR_BUTTON_HIGHLIGHT_DISABLED]; + shadow = active ? _guiColor[COLOR_BUTTON_HIGHLIGHT_DISABLED] : _guiColor[COLOR_BUTTON_SHADOW_DISABLED]; + background = _guiColor[COLOR_BUTTON_BACKGROUND_DISABLED]; + text = _guiColor[COLOR_BUTTON_TEXT_DISABLED]; + } // Draw bezel. for (i=0; i<_guiMetric[METRIC_BUTTON_BEZEL_SIZE]; i++) { @@ -122,10 +134,10 @@ static void buttonPaint(WidgetT *widget, RectT pos) { } // Draw background (depends on x from above). - surfaceRectangleFilledDraw(pos.x + i, pos.y + i, pos.x + pos.w - i, pos.y + pos.h - i, _guiColor[COLOR_BUTTON_BACKGROUND]); + surfaceRectangleFilledDraw(pos.x + i, pos.y + i, pos.x + pos.w - i, pos.y + pos.h - i, background); // Draw title (depends on x from above). - fontRender(_guiFont, b->title, _guiColor[COLOR_BUTTON_TEXT], _guiColor[COLOR_BUTTON_BACKGROUND], pos.x + i + _guiMetric[METRIC_BUTTON_HORIZONTAL_PADDING] + active, pos.y + i + _guiMetric[METRIC_BUTTON_VERTICAL_PADDING] + active); + fontRender(_guiFont, b->title, text, background, pos.x + i + _guiMetric[METRIC_BUTTON_HORIZONTAL_PADDING] + active, pos.y + i + _guiMetric[METRIC_BUTTON_VERTICAL_PADDING] + active); GUI_CLEAR_FLAG(widget, WIDGET_FLAG_DIRTY); } diff --git a/client/src/gui/checkbox.c b/client/src/gui/checkbox.c index 05886af..47a495d 100644 --- a/client/src/gui/checkbox.c +++ b/client/src/gui/checkbox.c @@ -23,7 +23,7 @@ static void checkboxDel(WidgetT **widget); static void checkboxMouseEvent(WidgetT *widget, MouseT *mouse, uint16_t x, uint16_t y, uint8_t event); -static void checkboxPaint(WidgetT *widget, RectT pos); +static void checkboxPaint(WidgetT *widget, uint8_t enabled, RectT pos); void checkboxClickHandlerSet(CheckboxT *checkbox, widgetCallback callback) { @@ -89,19 +89,31 @@ CheckboxT *checkboxNew(uint16_t x, uint16_t y, char *title) { } -static void checkboxPaint(WidgetT *widget, RectT pos) { +static void checkboxPaint(WidgetT *widget, uint8_t enabled, RectT pos) { CheckboxT *c = (CheckboxT *)widget; int16_t o; int8_t active; ColorT highlight; ColorT shadow; ColorT fill; + ColorT text; + ColorT background; if (GUI_GET_FLAG(widget, WIDGET_FLAG_DIRTY)) { active = checkboxValueGet(c); - highlight = active ? _guiColor[COLOR_CHECKBOX_SHADOW] : _guiColor[COLOR_CHECKBOX_HIGHLIGHT]; - shadow = active ? _guiColor[COLOR_CHECKBOX_HIGHLIGHT] : _guiColor[COLOR_CHECKBOX_SHADOW]; - fill = active ? _guiColor[COLOR_CHECKBOX_ACTIVE] : _guiColor[COLOR_CHECKBOX_INACTIVE]; + if (enabled) { + highlight = active ? _guiColor[COLOR_CHECKBOX_SHADOW] : _guiColor[COLOR_CHECKBOX_HIGHLIGHT]; + shadow = active ? _guiColor[COLOR_CHECKBOX_HIGHLIGHT] : _guiColor[COLOR_CHECKBOX_SHADOW]; + fill = active ? _guiColor[COLOR_CHECKBOX_ACTIVE] : _guiColor[COLOR_CHECKBOX_INACTIVE]; + text = _guiColor[COLOR_CHECKBOX_TEXT]; + background = _guiColor[COLOR_WINDOW_BACKGROUND]; + } else { + highlight = active ? _guiColor[COLOR_CHECKBOX_SHADOW_DISABLED] : _guiColor[COLOR_CHECKBOX_HIGHLIGHT_DISABLED]; + shadow = active ? _guiColor[COLOR_CHECKBOX_HIGHLIGHT_DISABLED] : _guiColor[COLOR_CHECKBOX_SHADOW_DISABLED]; + fill = active ? _guiColor[COLOR_CHECKBOX_ACTIVE_DISABLED] : _guiColor[COLOR_CHECKBOX_INACTIVE_DISABLED]; + text = _guiColor[COLOR_CHECKBOX_TEXT_DISABLED]; + background = _guiColor[COLOR_WINDOW_BACKGROUND]; + } // Checkbox is 10x10 pixels. Find offset based on font height. o = (_guiFont->height - 10) * 0.5; @@ -113,7 +125,7 @@ static void checkboxPaint(WidgetT *widget, RectT pos) { surfaceRectangleFilledDraw(pos.x + 1, pos.y + o + 1, pos.x + 9, pos.y + + o + 9, fill); // Draw title. - fontRender(_guiFont, c->title, _guiColor[COLOR_CHECKBOX_TEXT], _guiColor[COLOR_WINDOW_BACKGROUND], pos.x + 10 + _guiMetric[METRIC_CHECKBOX_PADDING], pos.y); + fontRender(_guiFont, c->title, text, background, pos.x + 10 + _guiMetric[METRIC_CHECKBOX_PADDING], pos.y); GUI_CLEAR_FLAG(widget, WIDGET_FLAG_DIRTY); } diff --git a/client/src/gui/desktop.c b/client/src/gui/desktop.c index fb5bd15..70dc566 100644 --- a/client/src/gui/desktop.c +++ b/client/src/gui/desktop.c @@ -22,7 +22,7 @@ #include "window.h" -static void desktopPaint(WidgetT *desktop, RectT pos); +static void desktopPaint(WidgetT *desktop, uint8_t enabled, RectT pos); WidgetT *desktopInit(WidgetT *desktop) { @@ -60,8 +60,9 @@ DesktopT *desktopNew(void) { } -static void desktopPaint(WidgetT *desktop, RectT pos) { +static void desktopPaint(WidgetT *desktop, uint8_t enabled, RectT pos) { (void)pos; + (void)enabled; if (GUI_GET_FLAG(desktop, WIDGET_FLAG_DIRTY)) { surfaceClear(_guiColor[COLOR_DESKTOP]); diff --git a/client/src/gui/frame.c b/client/src/gui/frame.c index 16e8199..7c6bf5f 100644 --- a/client/src/gui/frame.c +++ b/client/src/gui/frame.c @@ -22,7 +22,7 @@ static void frameDel(WidgetT **widget); -static void framePaint(WidgetT *widget, RectT pos); +static void framePaint(WidgetT *widget, uint8_t enabled, RectT pos); static void frameDel(WidgetT **widget) { @@ -63,7 +63,7 @@ FrameT *frameNew(uint16_t x, uint16_t y, uint16_t w, uint16_t h, char *title) { } -static void framePaint(WidgetT *widget, RectT pos) { +static void framePaint(WidgetT *widget, uint8_t enabled, RectT pos) { FrameT *f = (FrameT *)widget; if (GUI_GET_FLAG(widget, WIDGET_FLAG_DIRTY)) { diff --git a/client/src/gui/gui.c b/client/src/gui/gui.c index f370ce9..ab487aa 100644 --- a/client/src/gui/gui.c +++ b/client/src/gui/gui.c @@ -47,7 +47,7 @@ static uint8_t _guiHasStopped = 0; static WidgetT ***_guiDeleteList = NULL; -// Widget Magic Debug Info +// Widget Magic Debug Info. Don't forget to change MagicE! static char *_magicDebugNames[MAGIC_COUNT] = { "Unknown", "Desktop", @@ -309,7 +309,9 @@ static void guiKeyboardChildrenProcess(WidgetT *widget, uint8_t ascii, uint8_t e // Does this widget want events? Check for global keyboard so it doesn't get double events. if (widget) { if (widget->keyboardEventMethod && GUI_GET_FLAG(widget, WIDGET_FLAG_ALWAYS_RECEIVE_KEYBOARD_EVENTS)) { - widget->keyboardEventMethod(widget, ascii, extended, scancode, shift, control, alt); + if (!GUI_GET_FLAG(widget, WIDGET_FLAG_DISABLED)) { + widget->keyboardEventMethod(widget, ascii, extended, scancode, shift, control, alt); + } } } } @@ -319,7 +321,9 @@ void guiKeyboardProcess(uint8_t ascii, uint8_t extended, uint8_t scancode, uint8 // Does the focused widget want events? Check for global keyboard so it doesn't get double events. if (_guiFocused) { if (_guiFocused->keyboardEventMethod && !GUI_GET_FLAG(_guiFocused, WIDGET_FLAG_ALWAYS_RECEIVE_KEYBOARD_EVENTS)) { - _guiFocused->keyboardEventMethod(_guiFocused, ascii, extended, scancode, shift, control, alt); + if (!GUI_GET_FLAG(_guiFocused, WIDGET_FLAG_DISABLED)) { + _guiFocused->keyboardEventMethod(_guiFocused, ascii, extended, scancode, shift, control, alt); + } } } @@ -411,8 +415,10 @@ static uint8_t guiMouseChildrenProcess(WidgetT *widget, MouseT *mouse) { if (widget->window == _guiActiveWindow || widget->magic == MAGIC_WINDOW || widget->magic == MAGIC_DESKTOP) { // Is there a mouse handler? if (widget->mouseEventMethod) { - // Ask child to handle event. - widget->mouseEventMethod(widget, mouse, mx, my, event); + if (!GUI_GET_FLAG(widget, WIDGET_FLAG_DISABLED)) { + // Ask child to handle event. + widget->mouseEventMethod(widget, mouse, mx, my, event); + } } } } @@ -443,7 +449,7 @@ void guiPaint(WidgetT *widget) { if (widget->paintMethod) { surfaceSet(widget->surface); guiPaintBoundsGet(widget, &pos); - widget->paintMethod(widget, pos); + widget->paintMethod(widget, !GUI_GET_FLAG(widget, WIDGET_FLAG_DISABLED), pos); } // Paint all children. @@ -493,68 +499,99 @@ DesktopT *guiStartup(void) { _guiMetric[METRIC_BUTTON_BEZEL_SIZE] = 2; _guiMetric[METRIC_BUTTON_HORIZONTAL_PADDING] = 8; _guiMetric[METRIC_BUTTON_VERTICAL_PADDING] = 2; + _guiMetric[METRIC_WINDOW_BORDER_WIDTH] = 4; // Does not include highlight or shadow lines. _guiMetric[METRIC_WINDOW_TITLE_HEIGHT] = 17; // Does not include highlight or shadow lines. _guiMetric[METRIC_WINDOW_TITLE_GRAB_HEIGHT] = _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + _guiMetric[METRIC_WINDOW_TITLE_HEIGHT] + 5; // Border, highlights, titlebar. + _guiMetric[METRIC_CHECKBOX_PADDING] = 6; // Makes the 10 wide checkbox fill two character cells by padding it out to 16. + _guiMetric[METRIC_RADIOBUTTON_PADDING] = 6; // Makes the 10 wide radio button fill two character cells by padding it out to 16. + _guiMetric[METRIC_TEXTBOX_HORIZONTAL_PADDING] = 2; _guiMetric[METRIC_TEXTBOX_VERTICAL_PADDING] = 2; _guiMetric[METRIC_TEXTBOX_PADDING] = 6; // Matches other label / widget padding. + _guiMetric[METRIC_UPDOWN_HORIZONTAL_PADDING] = 2; _guiMetric[METRIC_UPDOWN_VERTICAL_PADDING] = 2; _guiMetric[METRIC_UPDOWN_PADDING] = 6; // Matches other label / widget padding. _guiMetric[METRIC_UPDOWN_ARROW_PADDING] = 2; + _guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING] = 2; _guiMetric[METRIC_LISTBOX_VERTICAL_PADDING] = 2; - _guiColor[COLOR_BUTTON_BACKGROUND] = vbeColorMake(168, 168, 168); - _guiColor[COLOR_BUTTON_HIGHLIGHT] = vbeColorMake(248, 252, 248); - _guiColor[COLOR_BUTTON_SHADOW] = vbeColorMake( 80, 84, 80); - _guiColor[COLOR_BUTTON_TEXT] = vbeColorMake( 0, 0, 0); - _guiColor[COLOR_DESKTOP] = vbeColorMake( 51, 153, 255); - _guiColor[COLOR_WINDOW_BACKGROUND] = vbeColorMake(168, 168, 168); - _guiColor[COLOR_WINDOW_HIGHLIGHT] = vbeColorMake(248, 252, 248); - _guiColor[COLOR_WINDOW_SHADOW] = vbeColorMake( 80, 84, 80); - _guiColor[COLOR_WINDOW_TITLE_ACTIVE] = vbeColorMake( 80, 84, 80); - _guiColor[COLOR_WINDOW_TITLE_INACTIVE] = vbeColorMake(168, 168, 168); - _guiColor[COLOR_WINDOW_TITLE_TEXT_ACTIVE] = vbeColorMake(248, 252, 248); - _guiColor[COLOR_WINDOW_TITLE_TEXT_INACTIVE] = vbeColorMake( 0, 0, 0); - _guiColor[COLOR_LABEL_TEXT_INACTIVE] = vbeColorMake(248, 252, 248); - _guiColor[COLOR_LABEL_TEXT_INACTIVE] = vbeColorMake( 0, 0, 0); - _guiColor[COLOR_CHECKBOX_HIGHLIGHT] = vbeColorMake(248, 252, 248); - _guiColor[COLOR_CHECKBOX_SHADOW] = vbeColorMake( 0, 0, 0); - _guiColor[COLOR_CHECKBOX_ACTIVE] = vbeColorMake( 80, 84, 80); - _guiColor[COLOR_CHECKBOX_INACTIVE] = vbeColorMake(168, 168, 168); - _guiColor[COLOR_CHECKBOX_TEXT] = vbeColorMake( 0, 0, 0); - _guiColor[COLOR_RADIOBUTTON_HIGHLIGHT] = vbeColorMake(248, 252, 248); - _guiColor[COLOR_RADIOBUTTON_SHADOW] = vbeColorMake( 0, 0, 0); - _guiColor[COLOR_RADIOBUTTON_ACTIVE] = vbeColorMake( 80, 84, 80); - _guiColor[COLOR_RADIOBUTTON_INACTIVE] = vbeColorMake(168, 168, 168); - _guiColor[COLOR_RADIOBUTTON_TEXT] = vbeColorMake( 0, 0, 0); - _guiColor[COLOR_FRAME_HIGHLIGHT] = vbeColorMake(248, 252, 248); - _guiColor[COLOR_FRAME_SHADOW] = vbeColorMake( 0, 0, 0); - _guiColor[COLOR_FRAME_TEXT] = vbeColorMake( 0, 0, 0); - _guiColor[COLOR_TEXTBOX_HIGHLIGHT] = vbeColorMake(248, 252, 248); - _guiColor[COLOR_TEXTBOX_SHADOW] = vbeColorMake( 0, 0, 0); - _guiColor[COLOR_TEXTBOX_TEXT] = vbeColorMake( 0, 0, 0); - _guiColor[COLOR_TEXTBOX_BACKGROUND] = vbeColorMake(248, 252, 248); - _guiColor[COLOR_UPDOWN_HIGHLIGHT] = vbeColorMake(248, 252, 248); - _guiColor[COLOR_UPDOWN_SHADOW] = vbeColorMake( 0, 0, 0); - _guiColor[COLOR_UPDOWN_TEXT] = vbeColorMake( 0, 0, 0); - _guiColor[COLOR_UPDOWN_BACKGROUND] = vbeColorMake(248, 252, 248); - _guiColor[COLOR_UPDOWN_ARROWS_BACKGROUND] = vbeColorMake(124, 126, 124); - _guiColor[COLOR_UPDOWN_ARROWS_ACTIVE] = vbeColorMake(168, 168, 168); - _guiColor[COLOR_UPDOWN_ARROWS_INACTIVE] = vbeColorMake( 80, 84, 80); - _guiColor[COLOR_LISTBOX_HIGHLIGHT] = vbeColorMake(248, 252, 248); - _guiColor[COLOR_LISTBOX_SHADOW] = vbeColorMake( 0, 0, 0); - _guiColor[COLOR_LISTBOX_TEXT] = vbeColorMake( 0, 0, 0); - _guiColor[COLOR_LISTBOX_BACKGROUND] = vbeColorMake(248, 252, 248); - _guiColor[COLOR_LISTBOX_SELECTED_TEXT] = vbeColorMake(248, 252, 248); - _guiColor[COLOR_LISTBOX_SELECTED_BACKGROUND] = vbeColorMake( 0, 0, 0); - _guiColor[COLOR_LISTBOX_ARROWS_BACKGROUND] = vbeColorMake(124, 126, 124); - _guiColor[COLOR_LISTBOX_ARROWS_ACTIVE] = vbeColorMake(168, 168, 168); - _guiColor[COLOR_LISTBOX_ARROWS_INACTIVE] = vbeColorMake( 80, 84, 80); + + _guiColor[COLOR_BUTTON_BACKGROUND] = vbeColorMake(168, 168, 168); + _guiColor[COLOR_BUTTON_HIGHLIGHT] = vbeColorMake(248, 252, 248); + _guiColor[COLOR_BUTTON_SHADOW] = vbeColorMake( 80, 84, 80); + _guiColor[COLOR_BUTTON_TEXT] = vbeColorMake( 0, 0, 0); + + _guiColor[COLOR_BUTTON_BACKGROUND_DISABLED] = vbeColorMake(124, 126, 124); + _guiColor[COLOR_BUTTON_HIGHLIGHT_DISABLED] = vbeColorMake(200, 200, 200); + _guiColor[COLOR_BUTTON_SHADOW_DISABLED] = vbeColorMake( 80, 84, 80); + _guiColor[COLOR_BUTTON_TEXT_DISABLED] = vbeColorMake( 84, 84, 84); + + _guiColor[COLOR_DESKTOP] = vbeColorMake( 51, 153, 255); + + _guiColor[COLOR_WINDOW_BACKGROUND] = vbeColorMake(168, 168, 168); + _guiColor[COLOR_WINDOW_HIGHLIGHT] = vbeColorMake(248, 252, 248); + _guiColor[COLOR_WINDOW_SHADOW] = vbeColorMake( 80, 84, 80); + _guiColor[COLOR_WINDOW_TITLE_ACTIVE] = vbeColorMake( 80, 84, 80); + _guiColor[COLOR_WINDOW_TITLE_INACTIVE] = vbeColorMake(168, 168, 168); + _guiColor[COLOR_WINDOW_TITLE_TEXT_ACTIVE] = vbeColorMake(248, 252, 248); + _guiColor[COLOR_WINDOW_TITLE_TEXT_INACTIVE] = vbeColorMake( 0, 0, 0); + + _guiColor[COLOR_LABEL_TEXT_INACTIVE] = vbeColorMake(248, 252, 248); + _guiColor[COLOR_LABEL_TEXT_INACTIVE] = vbeColorMake( 0, 0, 0); + + _guiColor[COLOR_CHECKBOX_HIGHLIGHT] = vbeColorMake(248, 252, 248); + _guiColor[COLOR_CHECKBOX_SHADOW] = vbeColorMake( 0, 0, 0); + _guiColor[COLOR_CHECKBOX_ACTIVE] = vbeColorMake( 80, 84, 80); + _guiColor[COLOR_CHECKBOX_INACTIVE] = vbeColorMake(168, 168, 168); + _guiColor[COLOR_CHECKBOX_TEXT] = vbeColorMake( 0, 0, 0); + _guiColor[COLOR_CHECKBOX_HIGHLIGHT_DISABLED] = vbeColorMake(200, 200, 200); + _guiColor[COLOR_CHECKBOX_SHADOW_DISABLED] = vbeColorMake( 80, 84, 80); + _guiColor[COLOR_CHECKBOX_ACTIVE_DISABLED] = vbeColorMake( 80, 84, 80); + _guiColor[COLOR_CHECKBOX_INACTIVE_DISABLED] = vbeColorMake(124, 126, 124); + _guiColor[COLOR_CHECKBOX_TEXT_DISABLED] = vbeColorMake( 84, 84, 84); + + _guiColor[COLOR_RADIOBUTTON_HIGHLIGHT] = vbeColorMake(248, 252, 248); + _guiColor[COLOR_RADIOBUTTON_SHADOW] = vbeColorMake( 0, 0, 0); + _guiColor[COLOR_RADIOBUTTON_ACTIVE] = vbeColorMake( 80, 84, 80); + _guiColor[COLOR_RADIOBUTTON_INACTIVE] = vbeColorMake(168, 168, 168); + _guiColor[COLOR_RADIOBUTTON_TEXT] = vbeColorMake( 0, 0, 0); + _guiColor[COLOR_RADIOBUTTON_HIGHLIGHT_DISABLED] = vbeColorMake(200, 200, 200); + _guiColor[COLOR_RADIOBUTTON_SHADOW_DISABLED] = vbeColorMake( 80, 84, 80); + _guiColor[COLOR_RADIOBUTTON_ACTIVE_DISABLED] = vbeColorMake( 80, 84, 80); + _guiColor[COLOR_RADIOBUTTON_INACTIVE_DISABLED] = vbeColorMake(124, 126, 124); + _guiColor[COLOR_RADIOBUTTON_TEXT_DISABLED] = vbeColorMake( 84, 84, 84); + + _guiColor[COLOR_FRAME_HIGHLIGHT] = vbeColorMake(248, 252, 248); + _guiColor[COLOR_FRAME_SHADOW] = vbeColorMake( 0, 0, 0); + _guiColor[COLOR_FRAME_TEXT] = vbeColorMake( 0, 0, 0); + + _guiColor[COLOR_TEXTBOX_HIGHLIGHT] = vbeColorMake(248, 252, 248); + _guiColor[COLOR_TEXTBOX_SHADOW] = vbeColorMake( 0, 0, 0); + _guiColor[COLOR_TEXTBOX_TEXT] = vbeColorMake( 0, 0, 0); + _guiColor[COLOR_TEXTBOX_BACKGROUND] = vbeColorMake(248, 252, 248); + + _guiColor[COLOR_UPDOWN_HIGHLIGHT] = vbeColorMake(248, 252, 248); + _guiColor[COLOR_UPDOWN_SHADOW] = vbeColorMake( 0, 0, 0); + _guiColor[COLOR_UPDOWN_TEXT] = vbeColorMake( 0, 0, 0); + _guiColor[COLOR_UPDOWN_BACKGROUND] = vbeColorMake(248, 252, 248); + _guiColor[COLOR_UPDOWN_ARROWS_BACKGROUND] = vbeColorMake(124, 126, 124); + _guiColor[COLOR_UPDOWN_ARROWS_ACTIVE] = vbeColorMake(168, 168, 168); + _guiColor[COLOR_UPDOWN_ARROWS_INACTIVE] = vbeColorMake( 80, 84, 80); + + _guiColor[COLOR_LISTBOX_HIGHLIGHT] = vbeColorMake(248, 252, 248); + _guiColor[COLOR_LISTBOX_SHADOW] = vbeColorMake( 0, 0, 0); + _guiColor[COLOR_LISTBOX_TEXT] = vbeColorMake( 0, 0, 0); + _guiColor[COLOR_LISTBOX_BACKGROUND] = vbeColorMake(248, 252, 248); + _guiColor[COLOR_LISTBOX_SELECTED_TEXT] = vbeColorMake(248, 252, 248); + _guiColor[COLOR_LISTBOX_SELECTED_BACKGROUND] = vbeColorMake( 0, 0, 0); + _guiColor[COLOR_LISTBOX_ARROWS_BACKGROUND] = vbeColorMake(124, 126, 124); + _guiColor[COLOR_LISTBOX_ARROWS_ACTIVE] = vbeColorMake(168, 168, 168); + _guiColor[COLOR_LISTBOX_ARROWS_INACTIVE] = vbeColorMake( 80, 84, 80); // Load all font sizes. _guiFont8 = fontLoad("vga8x8.dat"); diff --git a/client/src/gui/gui.h b/client/src/gui/gui.h index 96062f2..784c262 100644 --- a/client/src/gui/gui.h +++ b/client/src/gui/gui.h @@ -39,7 +39,7 @@ #define D(w) ((WidgetT **)&w) -// Widget Magics +// Widget Magics. Don't forget to change _magicDebugNames! enum MagicE { MAGIC_UNKNOWN = 0, MAGIC_DESKTOP, @@ -63,20 +63,27 @@ enum MetricE { METRIC_BUTTON_BEZEL_SIZE = 0, METRIC_BUTTON_HORIZONTAL_PADDING, METRIC_BUTTON_VERTICAL_PADDING, + METRIC_WINDOW_BORDER_WIDTH, METRIC_WINDOW_TITLE_HEIGHT, METRIC_WINDOW_TITLE_GRAB_HEIGHT, + METRIC_CHECKBOX_PADDING, + METRIC_RADIOBUTTON_PADDING, + METRIC_TEXTBOX_HORIZONTAL_PADDING, METRIC_TEXTBOX_VERTICAL_PADDING, METRIC_TEXTBOX_PADDING, + METRIC_UPDOWN_PADDING, METRIC_UPDOWN_ARROW_PADDING, METRIC_UPDOWN_HORIZONTAL_PADDING, METRIC_UPDOWN_VERTICAL_PADDING, + METRIC_LISTBOX_HORIZONTAL_PADDING, METRIC_LISTBOX_VERTICAL_PADDING, + METRIC_COUNT }; @@ -86,7 +93,13 @@ enum ColorE { COLOR_BUTTON_HIGHLIGHT, COLOR_BUTTON_SHADOW, COLOR_BUTTON_TEXT, + COLOR_BUTTON_BACKGROUND_DISABLED, + COLOR_BUTTON_HIGHLIGHT_DISABLED, + COLOR_BUTTON_SHADOW_DISABLED, + COLOR_BUTTON_TEXT_DISABLED, + COLOR_DESKTOP, + COLOR_WINDOW_BACKGROUND, COLOR_WINDOW_HIGHLIGHT, COLOR_WINDOW_SHADOW, @@ -94,25 +107,41 @@ enum ColorE { COLOR_WINDOW_TITLE_INACTIVE, COLOR_WINDOW_TITLE_TEXT_ACTIVE, COLOR_WINDOW_TITLE_TEXT_INACTIVE, + COLOR_LABEL_TEXT_ACTIVE, COLOR_LABEL_TEXT_INACTIVE, + COLOR_CHECKBOX_HIGHLIGHT, COLOR_CHECKBOX_SHADOW, COLOR_CHECKBOX_ACTIVE, COLOR_CHECKBOX_INACTIVE, COLOR_CHECKBOX_TEXT, + COLOR_CHECKBOX_HIGHLIGHT_DISABLED, + COLOR_CHECKBOX_SHADOW_DISABLED, + COLOR_CHECKBOX_ACTIVE_DISABLED, + COLOR_CHECKBOX_INACTIVE_DISABLED, + COLOR_CHECKBOX_TEXT_DISABLED, + COLOR_RADIOBUTTON_HIGHLIGHT, COLOR_RADIOBUTTON_SHADOW, COLOR_RADIOBUTTON_ACTIVE, COLOR_RADIOBUTTON_INACTIVE, COLOR_RADIOBUTTON_TEXT, + COLOR_RADIOBUTTON_HIGHLIGHT_DISABLED, + COLOR_RADIOBUTTON_SHADOW_DISABLED, + COLOR_RADIOBUTTON_ACTIVE_DISABLED, + COLOR_RADIOBUTTON_INACTIVE_DISABLED, + COLOR_RADIOBUTTON_TEXT_DISABLED, + COLOR_FRAME_HIGHLIGHT, COLOR_FRAME_SHADOW, COLOR_FRAME_TEXT, + COLOR_TEXTBOX_HIGHLIGHT, COLOR_TEXTBOX_SHADOW, COLOR_TEXTBOX_TEXT, COLOR_TEXTBOX_BACKGROUND, + COLOR_UPDOWN_HIGHLIGHT, COLOR_UPDOWN_SHADOW, COLOR_UPDOWN_TEXT, @@ -120,6 +149,7 @@ enum ColorE { COLOR_UPDOWN_ARROWS_BACKGROUND, COLOR_UPDOWN_ARROWS_ACTIVE, COLOR_UPDOWN_ARROWS_INACTIVE, + COLOR_LISTBOX_HIGHLIGHT, COLOR_LISTBOX_SHADOW, COLOR_LISTBOX_TEXT, @@ -129,6 +159,7 @@ enum ColorE { COLOR_LISTBOX_ARROWS_BACKGROUND, COLOR_LISTBOX_ARROWS_ACTIVE, COLOR_LISTBOX_ARROWS_INACTIVE, + COLOR_COUNT }; diff --git a/client/src/gui/label.c b/client/src/gui/label.c index 19c28d8..38fa3fc 100644 --- a/client/src/gui/label.c +++ b/client/src/gui/label.c @@ -23,7 +23,7 @@ static void labelDel(WidgetT **widget); static void labelMouseEvent(WidgetT *widget, MouseT *mouse, uint16_t x, uint16_t y, uint8_t event); -static void labelPaint(WidgetT *widget, RectT pos); +static void labelPaint(WidgetT *widget, uint8_t enabled, RectT pos); void labelClickHandlerSet(LabelT *label, widgetCallback callback) { @@ -120,7 +120,7 @@ LabelT *labelNew(uint16_t x, uint16_t y, char *title) { } -static void labelPaint(WidgetT *widget, RectT pos) { +static void labelPaint(WidgetT *widget, uint8_t enabled, RectT pos) { LabelT *l = (LabelT *)widget; ColorT text = GUI_GET_FLAG(widget, WIDGET_FLAG_ACTIVE) ? l->active : l->foreground; diff --git a/client/src/gui/listbox.c b/client/src/gui/listbox.c index 9a6a6c4..6732549 100644 --- a/client/src/gui/listbox.c +++ b/client/src/gui/listbox.c @@ -35,7 +35,7 @@ static uint16_t _arrowStart = 0; static void listboxDel(WidgetT **widget); static void listboxMouseEvent(WidgetT *widget, MouseT *mouse, uint16_t x, uint16_t y, uint8_t event); static void listboxKeyboardEvent(WidgetT *widget, uint8_t ascii, uint8_t extended, uint8_t scancode, uint8_t shift, uint8_t control, uint8_t alt); -static void listboxPaint(WidgetT *widget, RectT pos); +static void listboxPaint(WidgetT *widget, uint8_t enabled, RectT pos); static void listboxScrollDown(ListboxT *listbox); static void listboxScrollUp(ListboxT *listbox); static void listboxSizesRecalculate(ListboxT *listbox); @@ -229,7 +229,7 @@ ListboxT *listboxNew(uint16_t x, uint16_t y, uint16_t w, uint16_t h, char *title } -static void listboxPaint(WidgetT *widget, RectT pos) { +static void listboxPaint(WidgetT *widget, uint8_t enabled, RectT pos) { ListboxT *l = (ListboxT *)widget; uint16_t items; uint16_t o; diff --git a/client/src/gui/picture.c b/client/src/gui/picture.c index 19f0718..67617cb 100644 --- a/client/src/gui/picture.c +++ b/client/src/gui/picture.c @@ -23,7 +23,7 @@ static void pictureDel(WidgetT **widget); static void pictureMouseEvent(WidgetT *widget, MouseT *mouse, uint16_t x, uint16_t y, uint8_t event); -static void picturePaint(WidgetT *widget, RectT pos); +static void picturePaint(WidgetT *widget, uint8_t enabled, RectT pos); void pictureClickHandlerSet(PictureT *picture, widgetCallback callback) { @@ -101,7 +101,7 @@ PictureT *pictureNew(uint16_t x, uint16_t y, char *filename) { } -static void picturePaint(WidgetT *widget, RectT pos) { +static void picturePaint(WidgetT *widget, uint8_t enabled, RectT pos) { PictureT *p = (PictureT *)widget; if (GUI_GET_FLAG(widget, WIDGET_FLAG_DIRTY)) { diff --git a/client/src/gui/radio.c b/client/src/gui/radio.c index 638540b..4e6120d 100644 --- a/client/src/gui/radio.c +++ b/client/src/gui/radio.c @@ -23,7 +23,7 @@ static void radioDel(WidgetT **widget); static void radioMouseEvent(WidgetT *widget, MouseT *mouse, uint16_t x, uint16_t y, uint8_t event); -static void radioPaint(WidgetT *widget, RectT pos); +static void radioPaint(WidgetT *widget, uint8_t enabled, RectT pos); static void radioSelectedInGroupClear(WidgetT *widget, uint32_t group); static RadioT *radioSelectedInGroupFind(WidgetT *widget, uint32_t group); @@ -94,7 +94,7 @@ RadioT *radioNew(uint16_t x, uint16_t y, char *title, uint16_t group) { } -static void radioPaint(WidgetT *widget, RectT pos) { +static void radioPaint(WidgetT *widget, uint8_t enabled, RectT pos) { RadioT *r = (RadioT *)widget; int16_t i; int16_t o; @@ -102,12 +102,24 @@ static void radioPaint(WidgetT *widget, RectT pos) { ColorT highlight; ColorT shadow; ColorT fill; + ColorT text; + ColorT background; if (GUI_GET_FLAG(widget, WIDGET_FLAG_DIRTY)) { - active = (radioSelectedGet(r) == r); - highlight = active ? _guiColor[COLOR_RADIOBUTTON_SHADOW] : _guiColor[COLOR_RADIOBUTTON_HIGHLIGHT]; - shadow = active ? _guiColor[COLOR_RADIOBUTTON_HIGHLIGHT] : _guiColor[COLOR_RADIOBUTTON_SHADOW]; - fill = active ? _guiColor[COLOR_RADIOBUTTON_ACTIVE] : _guiColor[COLOR_RADIOBUTTON_INACTIVE]; + active = (radioSelectedGet(r) == r); + if (enabled) { + highlight = active ? _guiColor[COLOR_RADIOBUTTON_SHADOW] : _guiColor[COLOR_RADIOBUTTON_HIGHLIGHT]; + shadow = active ? _guiColor[COLOR_RADIOBUTTON_HIGHLIGHT] : _guiColor[COLOR_RADIOBUTTON_SHADOW]; + fill = active ? _guiColor[COLOR_RADIOBUTTON_ACTIVE] : _guiColor[COLOR_RADIOBUTTON_INACTIVE]; + text = _guiColor[COLOR_CHECKBOX_TEXT]; + background = _guiColor[COLOR_WINDOW_BACKGROUND]; + } else { + highlight = active ? _guiColor[COLOR_RADIOBUTTON_SHADOW_DISABLED] : _guiColor[COLOR_RADIOBUTTON_HIGHLIGHT_DISABLED]; + shadow = active ? _guiColor[COLOR_RADIOBUTTON_HIGHLIGHT_DISABLED] : _guiColor[COLOR_RADIOBUTTON_SHADOW_DISABLED]; + fill = active ? _guiColor[COLOR_RADIOBUTTON_ACTIVE_DISABLED] : _guiColor[COLOR_RADIOBUTTON_INACTIVE_DISABLED]; + text = _guiColor[COLOR_CHECKBOX_TEXT_DISABLED]; + background = _guiColor[COLOR_WINDOW_BACKGROUND]; + } // Radio button is 10x10 pixels. Find offset based on font height. o = (_guiFont->height - 10) * 0.5; @@ -125,7 +137,7 @@ static void radioPaint(WidgetT *widget, RectT pos) { } // Draw title. - fontRender(_guiFont, r->title, _guiColor[COLOR_RADIOBUTTON_TEXT], _guiColor[COLOR_WINDOW_BACKGROUND], pos.x + 10 + _guiMetric[METRIC_RADIOBUTTON_PADDING], pos.y); + fontRender(_guiFont, r->title, text, background, pos.x + 10 + _guiMetric[METRIC_RADIOBUTTON_PADDING], pos.y); GUI_CLEAR_FLAG(widget, WIDGET_FLAG_DIRTY); } diff --git a/client/src/gui/terminal.c b/client/src/gui/terminal.c index 9133dd7..eb5a796 100644 --- a/client/src/gui/terminal.c +++ b/client/src/gui/terminal.c @@ -39,7 +39,7 @@ static void terminalFocusEvent(WidgetT *widget, uint8_t focused); static int16_t terminalIntConvert(char *number, int16_t defaultValue); static void terminalMouseEvent(WidgetT *widget, MouseT *mouse, uint16_t x, uint16_t y, uint8_t event); static void terminalKeyboardEvent(WidgetT *widget, uint8_t ascii, uint8_t extended, uint8_t scancode, uint8_t shift, uint8_t control, uint8_t alt); -static void terminalPaint(WidgetT *widget, RectT pos); +static void terminalPaint(WidgetT *widget, uint8_t enabled, RectT pos); static void terminalSequenceReset(TerminalT *terminal); @@ -660,7 +660,7 @@ TerminalT *terminalNew(uint16_t x, uint16_t y, uint16_t cols, uint16_t rows) { } -static void terminalPaint(WidgetT *widget, RectT pos) { +static void terminalPaint(WidgetT *widget, uint8_t enabled, RectT pos) { TerminalT *t = (TerminalT *)widget; uint16_t x; uint16_t y; diff --git a/client/src/gui/textbox.c b/client/src/gui/textbox.c index 66f7f78..77d040a 100644 --- a/client/src/gui/textbox.c +++ b/client/src/gui/textbox.c @@ -26,7 +26,7 @@ static void textboxDel(WidgetT **widget); static void textboxFocusEvent(WidgetT *widget, uint8_t focused); static void textboxMouseEvent(WidgetT *widget, MouseT *mouse, uint16_t x, uint16_t y, uint8_t event); static void textboxKeyboardEvent(WidgetT *widget, uint8_t ascii, uint8_t extended, uint8_t scancode, uint8_t shift, uint8_t control, uint8_t alt); -static void textboxPaint(WidgetT *widget, RectT pos); +static void textboxPaint(WidgetT *widget, uint8_t enabled, RectT pos); static void textboxDel(WidgetT **widget) { @@ -254,7 +254,7 @@ TextboxT *textboxNew(uint16_t x, uint16_t y, uint16_t w, char *title) { } -static void textboxPaint(WidgetT *widget, RectT pos) { +static void textboxPaint(WidgetT *widget, uint8_t enabled, RectT pos) { TextboxT *t = (TextboxT *)widget; char *draw = NULL; uint16_t labelWidth; diff --git a/client/src/gui/updown.c b/client/src/gui/updown.c index a53b982..8a98991 100644 --- a/client/src/gui/updown.c +++ b/client/src/gui/updown.c @@ -39,7 +39,7 @@ static void updownDel(WidgetT **widget); static void updownFocusEvent(WidgetT *widget, uint8_t focused); static void updownMouseEvent(WidgetT *widget, MouseT *mouse, uint16_t x, uint16_t y, uint8_t event); static void updownKeyboardEvent(WidgetT *widget, uint8_t ascii, uint8_t extended, uint8_t scancode, uint8_t shift, uint8_t control, uint8_t alt); -static void updownPaint(WidgetT *widget, RectT pos); +static void updownPaint(WidgetT *widget, uint8_t enabled, RectT pos); static void updownSizesRecalculate(UpdownT *updown); static void updownVisibleSet(UpdownT *updown); @@ -244,7 +244,7 @@ UpdownT *updownNew(uint16_t x, uint16_t y, int32_t min, int32_t max, int32_t ste } -static void updownPaint(WidgetT *widget, RectT pos) { +static void updownPaint(WidgetT *widget, uint8_t enabled, RectT pos) { UpdownT *u = (UpdownT *)widget; uint8_t i; uint16_t textX; diff --git a/client/src/gui/widget.c b/client/src/gui/widget.c index b403321..1aea2f6 100644 --- a/client/src/gui/widget.c +++ b/client/src/gui/widget.c @@ -22,6 +22,16 @@ #include "window.h" +void widgetEnableSet(WidgetT *widget, uint8_t enabled) { + // We did "DISABLED" for the flag so that "flags = 0" (the default) would enable widgets. + if (enabled) { + GUI_CLEAR_FLAG(widget, WIDGET_FLAG_DISABLED); + } else { + GUI_SET_FLAG(widget, WIDGET_FLAG_DISABLED); + } +} + + uint16_t widgetHeightGet(WidgetT *widget) { return widget->pos.h; } diff --git a/client/src/gui/widget.h b/client/src/gui/widget.h index cf75abe..913a60f 100644 --- a/client/src/gui/widget.h +++ b/client/src/gui/widget.h @@ -29,7 +29,8 @@ enum WidgetE { WIDGET_FLAG_DIRTY = 0, WIDGET_FLAG_ACTIVE, WIDGET_FLAG_OWNS_SURFACE, - WIDGET_FLAG_ALWAYS_RECEIVE_KEYBOARD_EVENTS + WIDGET_FLAG_ALWAYS_RECEIVE_KEYBOARD_EVENTS, + WIDGET_FLAG_DISABLED }; @@ -41,7 +42,7 @@ typedef void (*widgetCallback)(struct WidgetS *widget); typedef void (*widgetDelMethod)(struct WidgetS **widget); typedef void (*widgetFocusMethod)(struct WidgetS *widget, uint8_t focused); typedef void (*widgetKeyboardEventMethod)(struct WidgetS *widget, uint8_t ascii, uint8_t extended, uint8_t scancode, uint8_t shift, uint8_t control, uint8_t alt); -typedef void (*widgetPaintMethod)(struct WidgetS *widget, RectT pos); +typedef void (*widgetPaintMethod)(struct WidgetS *widget, uint8_t enabled, RectT pos); typedef void (*widgetMouseEventMethod)(struct WidgetS *widget, MouseT *mouse, uint16_t x, uint16_t y, uint8_t event); @@ -64,6 +65,7 @@ typedef struct WidgetS { } WidgetT; +void widgetEnableSet(WidgetT *widget, uint8_t enabled); uint16_t widgetHeightGet(WidgetT *widget); WidgetT *widgetInit(WidgetT *widget, uint8_t magic, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t marginX, uint16_t marginY, uint16_t marginX2, uint16_t marginY2); WidgetT *widgetNew(uint8_t magic, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t marginX, uint16_t marginY, uint16_t marginX2, uint16_t marginY2); diff --git a/client/src/gui/window.c b/client/src/gui/window.c index bee67ed..80ade69 100644 --- a/client/src/gui/window.c +++ b/client/src/gui/window.c @@ -24,7 +24,7 @@ static void windowAllDeactivate(WidgetT *widget); static void windowDel(WidgetT **widget); static void windowMouseEvent(WidgetT *widget, MouseT *mouse, uint16_t x, uint16_t y, uint8_t event); -static void windowPaint(WidgetT *widget, RectT pos); +static void windowPaint(WidgetT *widget, uint8_t enabled, RectT pos); void windowActiveSet(WindowT *window) { @@ -167,7 +167,7 @@ WindowT *windowNew(uint16_t x, uint16_t y, uint16_t w, uint16_t h, char *title) } -static void windowPaint(WidgetT *widget, RectT pos) { +static void windowPaint(WidgetT *widget, uint8_t enabled, RectT pos) { WindowT *w = (WindowT *)widget; uint16_t x2; uint16_t y2; diff --git a/client/src/settings.c b/client/src/settings.c index 413be04..59f62ea 100644 --- a/client/src/settings.c +++ b/client/src/settings.c @@ -41,6 +41,16 @@ #define PORT_BAD 1 #define PORT_GOOD 2 +#define TITLE_LEN 80 + + +typedef struct PortS { + uint8_t status; + char title[TITLE_LEN]; + uint8_t selected; + uint8_t enabled; +} PortT; + static WindowT *winDetecting; static LabelT *lblOneMoment; @@ -49,10 +59,7 @@ static WindowT *winSettings; static FrameT *frmComPorts; static FrameT *frmServer; static ButtonT *btnOkay; -static RadioT *rdoCOM1; -static RadioT *rdoCOM2; -static RadioT *rdoCOM3; -static RadioT *rdoCOM4; +static RadioT *rdoCOM[4]; static TextboxT *txtServer; static UpdownT *updPort; @@ -73,7 +80,8 @@ void taskSettings(void *data) { uint32_t len; char buffer[1024]; uint8_t quarterSeconds = 0; - uint8_t ports[4] = { PORT_NONE, PORT_NONE, PORT_NONE, PORT_NONE }; // 0 = No port. 1 = No modem. 2 = Valid. + PortT port[4]; + uint8_t selected = 1; (void)data; @@ -99,6 +107,7 @@ void taskSettings(void *data) { snprintf(buffer, 1024, "%s%c", "AT+SOCK1", 13); comWrite(x, buffer, strlen(buffer)); // Wait a second. + quarterSeconds = 0; while (quarterSeconds < 5) { taskYield(); if (timerQuarterSecondTick) quarterSeconds++; @@ -106,11 +115,23 @@ void taskSettings(void *data) { len = comRead(x, buffer, 1024); buffer[len] = 0; if (strstr(buffer, "OK")) { - ports[x] = PORT_GOOD; + snprintf(port[x].title, TITLE_LEN - 1, "COM%d - SoftModem Found!", x + 1); + port[x].status = PORT_GOOD; + port[x].selected = selected; + port[x].enabled = 1; + selected = 0; } else { - ports[x] = PORT_BAD; + snprintf(port[x].title, TITLE_LEN - 1, "COM%d - Incompatable Modem", x + 1); + port[x].status = PORT_BAD; + port[x].selected = 0; + port[x].enabled = 0; } comClose(x); + } else { + snprintf(port[x].title, TITLE_LEN - 1, "COM%d - Not Present", x + 1); + port[x].status = PORT_NONE; + port[x].selected = 0; + port[x].enabled = 0; } } @@ -125,26 +146,6 @@ void taskSettings(void *data) { T_FRAME, O(frmComPorts), T_X, 10, T_Y, 5, T_WIDTH, 266, T_HEIGHT, 100, T_TITLE, P("COM Ports"), - T_RADIOBUTTON, O(rdoCOM1), - T_X, 5, - T_TITLE, P((ports[0] == PORT_NONE ? "COM1 - Not Present" : (ports[0] == PORT_BAD ? "COM1 - Incompatable Modem" : "COM1 - SoftModem Found!"))), - T_GROUP, GROUP_COM, - T_RADIOBUTTON, T_DONE, - T_RADIOBUTTON, O(rdoCOM2), - T_X, 5, T_Y, 20, - T_TITLE, P((ports[1] == PORT_NONE ? "COM2 - Not Present" : (ports[1] == PORT_BAD ? "COM2 - Incompatable Modem" : "COM2 - SoftModem Found!"))), - T_GROUP, GROUP_COM, - T_RADIOBUTTON, T_DONE, - T_RADIOBUTTON, O(rdoCOM3), - T_X, 5, T_Y, 40, - T_TITLE, P((ports[2] == PORT_NONE ? "COM3 - Not Present" : (ports[2] == PORT_BAD ? "COM3 - Incompatable Modem" : "COM3 - SoftModem Found!"))), - T_GROUP, GROUP_COM, - T_RADIOBUTTON, T_DONE, - T_RADIOBUTTON, O(rdoCOM4), - T_X, 5, T_Y, 60, - T_TITLE, P((ports[3] == PORT_NONE ? "COM4 - Not Present" : (ports[3] == PORT_BAD ? "COM4 - Incompatable Modem" : "COM4 - SoftModem Found!"))), - T_GROUP, GROUP_COM, - T_RADIOBUTTON, T_DONE, T_FRAME, T_DONE, T_FRAME, O(frmServer), @@ -176,7 +177,12 @@ void taskSettings(void *data) { tagListRun(uiSettings); - guiDebugAreaShow(W(winSettings)); - guiDebugAreaShow(W(frmComPorts)); - guiDebugAreaShow(W(btnOkay)); + rc = 0; + for (len=0; len<4; len++) { + rdoCOM[len] = radioNew(5, rc, port[len].title, GROUP_COM); + if (port[len].selected) radioSelectedSet(rdoCOM[len]); + widgetEnableSet(W(rdoCOM[len]), port[len].enabled); + guiAttach(W(frmComPorts), W(rdoCOM[len])); + rc += 20; + } } diff --git a/client/src/system/taglist.c b/client/src/system/taglist.c index 0cb096f..d11ffe5 100644 --- a/client/src/system/taglist.c +++ b/client/src/system/taglist.c @@ -104,6 +104,7 @@ static void tagListWidgetAttributeHandle(void) { char **items; uint32_t indexAttribute; uint8_t hasIndex; + uint8_t enabled; // Process generated lists in reverse. while (arrlen(_widgetList) > 0) { @@ -136,6 +137,7 @@ static void tagListWidgetAttributeHandle(void) { items = NULL; indexAttribute = 0; hasIndex = 0; + enabled = 1; // Parse provided attributes. for (i=0; itagList); i+=2) { @@ -163,6 +165,10 @@ static void tagListWidgetAttributeHandle(void) { click = (widgetCallback)v; break; + case T_ENABLED: + enabled = (v != 0 ? 1 : 0); + break; + case T_FILENAME: filename = (char *)v; break; @@ -324,6 +330,8 @@ static void tagListWidgetAttributeHandle(void) { if (userdata != NULL) guiUserDataSet(widget, userdata); + widgetEnableSet(widget, enabled); + // Store everything we did. *w->widget = widget; diff --git a/client/src/system/taglist.h b/client/src/system/taglist.h index 23cbd9f..7a8dc25 100644 --- a/client/src/system/taglist.h +++ b/client/src/system/taglist.h @@ -34,6 +34,9 @@ typedef uint32_t TagItemT; #define O(x) ((TagItemT)&x) // Widget Objects #define P(x) ((TagItemT)x) // Pointers +#define T_FALSE 0 +#define T_TRUE 1 + enum TagItemsE { T_END = 0, @@ -61,6 +64,7 @@ enum TagItemsE { T_COLOR_ACTIVE, T_COLOR_BACKGROUND, T_COLOR_FOREGROUND, + T_ENABLED, T_FILENAME, T_GROUP, T_HEIGHT, diff --git a/client/src/welcome.c b/client/src/welcome.c index fad8b55..36ba852 100644 --- a/client/src/welcome.c +++ b/client/src/welcome.c @@ -88,6 +88,7 @@ void taskWelcome(void *data) { T_TITLE, P("Connect"), T_X, 379, T_Y, 157, T_CLICK, P(btnConnectClick), + T_ENABLED, T_FALSE, T_BUTTON, T_DONE, T_WINDOW, T_DONE, T_END