void TXT_DrawWindow(txt_window_t *window, int selected) { txt_widget_t *widgets; TXT_LayoutWindow(window); // Draw the window TXT_DrawWindowFrame(window->title, window->window_x, window->window_y, window->window_w, window->window_h); // Draw all widgets TXT_DrawWidget(window, selected); // Draw an action area, if we have one widgets = (txt_widget_t *) window; if (widgets->y + widgets->h < window->window_y + window->window_h - 1) { // Separator for action area TXT_DrawSeparator(window->window_x, widgets->y + widgets->h, window->window_w); // Action area at the window bottom DrawActionArea(window); } }
static void VKBCreateWindow(txt_inputbox_t *inputbox, int charset_index) { int i; txt_table_t *keyboard; txt_table_t *softact; txt_table_t *softact_okcancel; txt_table_t *organizer; txt_window_action_t *cancel, *caps; //Create Widgets vkb_window = TXT_NewWindow(NULL); vkb_inputbox = inputbox; vkb_charset_index = charset_index; vkb_label = TXT_NewLabel(""); keyboard = TXT_NewTable(19); organizer = TXT_NewTable(3); softact = TXT_NewTable(1); //Populate Window TXT_AddWidget(vkb_window, vkb_label); TXT_AddWidget(vkb_window, TXT_NewSeparator(NULL)); TXT_AddWidget(vkb_window, organizer); TXT_AddWidget(organizer, keyboard); TXT_AddWidget(organizer, TXT_NewStrut(1, 0)); TXT_AddWidget(organizer, softact); //Create Actions cancel = TXT_NewWindowAction(KEY_BBUTTON, "Revert"); caps = TXT_NewWindowAction(KEY_YBUTTON, "Caps"); TXT_SignalConnect(cancel, "pressed", VKBCloseWindow, 0); TXT_SignalConnect(caps, "pressed", VKBCycleCharsets, 0); TXT_AddWidget(softact, TXT_NewButton2("Backspace", VKBBackspace, NULL)); TXT_AddWidget(softact, TXT_NewButton2("Caps-Lock", VKBCycleCharsets, NULL)); TXT_AddWidget(softact, TXT_NewButton2("Revert", VKBCloseWindow, 0)); TXT_AddWidget(softact, TXT_NewButton2("Accept", VKBCloseWindow, 1)); //Create buttons and populate keyboard table for (i=0; vkb_charset[vkb_charset_index][i] != '\0'; i++) { char button[] = {vkb_charset[vkb_charset_index][i], '\0'}; TXT_AddWidget(keyboard, TXT_NewButton2(button, VKBAddCharacter, button[0])); //, VKBAddCharacter)); //Don't add padding on the last of row if ((i+1) % 10) { TXT_AddWidget(keyboard, TXT_NewStrut(1, 0)); } } //Format & Update things TXT_SetWindowAction(vkb_window, TXT_HORIZ_LEFT, cancel); TXT_SetWindowAction(vkb_window, TXT_HORIZ_RIGHT, caps); TXT_SetWidgetAlign(keyboard, TXT_HORIZ_CENTER); TXT_SetBGColor(vkb_label, TXT_COLOR_BLACK); TXT_LayoutWindow(vkb_window); VKBUpdateLabel(); inputbox->editing = 1; }
static void MouseButtonPress(txt_window_t *window, int b) { int x, y; int i; txt_widget_t *widgets; txt_widget_t *widget; // Lay out the window, set positions and sizes of all widgets TXT_LayoutWindow(window); // Get the current mouse position TXT_GetMousePosition(&x, &y); // Try the mouse button listener // This happens whether it is in the window range or not if (window->mouse_listener != NULL) { // Mouse listener can eat button presses if (window->mouse_listener(window, x, y, b, window->mouse_listener_data)) { return; } } // Is it within the table range? widgets = (txt_widget_t *) window; if (x >= widgets->x && x < (signed) (widgets->x + widgets->w) && y >= widgets->y && y < (signed) (widgets->y + widgets->h)) { TXT_WidgetMousePress(window, x, y, b); } // Was one of the action area buttons pressed? for (i=0; i<3; ++i) { widget = (txt_widget_t *) window->actions[i]; if (widget != NULL && x >= widget->x && x < (signed) (widget->x + widget->w) && y >= widget->y && y < (signed) (widget->y + widget->h)) { TXT_WidgetMousePress(widget, x, y, b); break; } } }
void TXT_DrawWindow(txt_window_t *window) { txt_widget_t *widgets; TXT_LayoutWindow(window); if (window->table.widget.focused) { TXT_BGColor(TXT_ACTIVE_WINDOW_BACKGROUND, 0); } else { TXT_BGColor(TXT_INACTIVE_WINDOW_BACKGROUND, 0); } TXT_FGColor(TXT_COLOR_BRIGHT_WHITE); // Draw the window TXT_DrawWindowFrame(window->title, window->window_x, window->window_y, window->window_w, window->window_h); // Draw all widgets TXT_DrawWidget(window); // Draw an action area, if we have one widgets = (txt_widget_t *) window; if (widgets->y + widgets->h < window->window_y + window->window_h - 1) { // Separator for action area TXT_DrawSeparator(window->window_x, widgets->y + widgets->h, window->window_w); // Action area at the window bottom DrawActionArea(window); } }
static void MouseButtonPress(txt_window_t *window, int b) { int x, y; int i; txt_widget_t *widgets; txt_widget_t *widget; // Lay out the window, set positions and sizes of all widgets TXT_LayoutWindow(window); // Get the current mouse position TXT_GetMousePosition(&x, &y); // Try the mouse button listener // This happens whether it is in the window range or not if (window->mouse_listener != NULL) { // Mouse listener can eat button presses if (window->mouse_listener(window, x, y, b, window->mouse_listener_data)) { return; } } // Is it within the table range? widgets = (txt_widget_t *) window; if (x >= widgets->x && x < (signed) (widgets->x + widgets->w) && y >= widgets->y && y < (signed) (widgets->y + widgets->h)) { TXT_WidgetMousePress(window, x, y, b); } // Was one of the action area buttons pressed? for (i=0; i<3; ++i) { widget = (txt_widget_t *) window->actions[i]; if (widget != NULL && x >= widget->x && x < (signed) (widget->x + widget->w) && y >= widget->y && y < (signed) (widget->y + widget->h)) { int was_focused; // Main table temporarily loses focus when action area button // is clicked. This way, any active input boxes that depend // on having focus will save their values before the // action is performed. was_focused = window->table.widget.focused; TXT_SetWidgetFocus(window, 0); TXT_SetWidgetFocus(window, was_focused); // Pass through mouse press. TXT_WidgetMousePress(widget, x, y, b); break; } } }