static void TXT_ScrollPaneFocused(TXT_UNCAST_ARG(scrollpane), int focused) { TXT_CAST_ARG(txt_scrollpane_t, scrollpane); // Whether the child is focused depends only on whether the scroll pane // itself is focused. Pass through focus to the child. if (scrollpane->child != NULL) { TXT_SetWidgetFocus(scrollpane->child, focused); } }
static void ChangeSelection(txt_table_t *table, int x, int y) { txt_widget_t *cur_widget; txt_widget_t *new_widget; int i; // No change? if (x == table->selected_x && y == table->selected_y) { return; } // Unfocus current widget: i = table->selected_y * table->columns + table->selected_x; if (i < table->num_widgets) { cur_widget = table->widgets[i]; if (table->widget.focused && IsActualWidget(cur_widget)) { TXT_SetWidgetFocus(cur_widget, 0); } } // Focus new widget. new_widget = table->widgets[y * table->columns + x]; table->selected_x = x; table->selected_y = y; if (table->widget.focused && new_widget != NULL) { TXT_SetWidgetFocus(new_widget, 1); } }
static void TXT_TableFocused(TXT_UNCAST_ARG(table), int focused) { TXT_CAST_ARG(txt_table_t, table); int i; i = table->selected_y * table->columns + table->selected_x; if (i < table->num_widgets) { if (IsActualWidget(table->widgets[i])) { TXT_SetWidgetFocus(table->widgets[i], focused); } } }
void TXT_SetWindowFocus(txt_window_t *window, int focused) { TXT_SetWidgetFocus(window, focused); }
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; } } }
static void TXT_FileSelectFocused(TXT_UNCAST_ARG(fileselect), int focused) { TXT_CAST_ARG(txt_fileselect_t, fileselect); TXT_SetWidgetFocus(fileselect->inputbox, focused); }