Freeciv-3.3: /fast/freeciv/nightly/main/client/gui-sdl3/widget.c File Reference

Freeciv-3.3

Loading...
Searching...
No Matches
Functions | Variables
widget.c File Reference
`#include <SDL3/SDL.h>`
`#include "log.h"`
`#include "colors.h"`
`#include "graphics.h"`
`#include "gui_id.h"`
`#include "gui_main.h"`
`#include "gui_tilespec.h"`
`#include "mapview.h"`
`#include "themespec.h"`
`#include "widget.h"`
`#include "widget_p.h"`

Go to the source code of this file.

## Functions

void | correct_size_bcgnd_surf (SDL_Surface *ptheme, int *width, int *height)
SDL_Surface * | create_bcgnd_surf (SDL_Surface *ptheme, enum widget_state state, Uint16 width, Uint16 height)
struct widget * | find_next_widget_at_pos (struct widget *start_widget, int x, int y)
struct widget * | find_next_widget_for_key (struct widget *start_widget, SDL_Keysym key)
Uint16 | widget_pressed_action (struct widget *pwidget)
void | unselect_widget_action (void)
void | widget_selected_action (struct widget *pwidget)
void | redraw_widget_info_label (SDL_Rect *rect)
struct widget * | get_widget_pointer_from_id (const struct widget *gui_list, Uint16 id, enum scan_direction direction)
struct widget * | get_widget_pointer_from_main_list (Uint16 id)
void | add_to_gui_list (Uint16 id, struct widget *gui)
void | widget_add_as_prev (struct widget *new_widget, struct widget *add_dock)
void | del_widget_pointer_from_gui_list (struct widget *gui)
bool | is_this_widget_first_on_list (struct widget *gui)
void | move_widget_to_front_of_gui_list (struct widget *gui)
void | del_main_list (void)
void | del_gui_list (struct widget *gui_list)
Uint16 | redraw_group (const struct widget *begin_group_widget_list, const struct widget *end_group_widget_list, int add_to_update)
void | undraw_group (struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
void | set_new_group_start_pos (const struct widget *begin_group_widget_list, const struct widget *end_group_widget_list, Sint16 Xrel, Sint16 Yrel)
void | move_group_to_front_of_gui_list (struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
void | del_group_of_widgets_from_gui_list (struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
void | set_group_state (struct widget *begin_group_widget_list, struct widget *end_group_widget_list, enum widget_state state)
void | hide_group (struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
void | show_group (struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
void | group_set_area (struct widget *begin_group_widget_list, struct widget *end_group_widget_list, SDL_Rect area)
void | popdown_window_group_dialog (struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
bool | select_window_group_dialog (struct widget *begin_widget_list, struct widget *pwindow)
bool | move_window_group_dialog (struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
void | move_window_group (struct widget *begin_widget_list, struct widget *pwindow)
int | setup_vertical_widgets_position (int step, Sint16 start_x, Sint16 start_y, Uint16 w, Uint16 h, struct widget *begin, struct widget *end)
void | draw_frame (SDL_Surface *pdest, Sint16 start_x, Sint16 start_y, Uint16 w, Uint16 h)
void | refresh_widget_background (struct widget *pwidget)

## Variables

struct widget * | selected_widget
SDL_Rect * | info_area = NULL
Uint32 | widget_info_counter
static struct widget * | begin_main_widget_list
static SDL_Surface * | info_label = NULL

## Function Documentation

## ◆ add_to_gui_list()

void add_to_gui_list | ( | Uint16 | id,
|  | struct widget * | gui
| ) |  |

Add Widget to Main widgets list ( begin_widget_list )

Definition at line 582 of file widget.c.

## ◆ correct_size_bcgnd_surf()

void correct_size_bcgnd_surf | ( | SDL_Surface * | ptheme,
|  | int * | width,
|  | int * | height
| ) |  |

Correct background size ( set min size ). Used in create widget functions.

Definition at line 59 of file widget.c.

## ◆ create_bcgnd_surf()

SDL_Surface * create_bcgnd_surf | ( | SDL_Surface * | ptheme,
|  | enum widget_state | state,
|  | Uint16 | width,
|  | Uint16 | height
| ) |  |

Create background image for buttons, iconbuttons and edit fields then return pointer to this image.

Graphic is taken from ptheme surface and blit to new created image.

Type of image depend of "state" parameter.

Definition at line 74 of file widget.c.

## ◆ del_group_of_widgets_from_gui_list()

void del_group_of_widgets_from_gui_list | ( | struct widget * | begin_group_widget_list,
|  | struct widget * | end_group_widget_list
| ) |  |

Remove all widgets of the group from the list of displayed widgets. Does not free widget memory.

Definition at line 859 of file widget.c.

## ◆ del_gui_list()

void del_gui_list | ( | struct widget * | gui_list | ) |

Delete Wideget's List ('gui_list').

Definition at line 695 of file widget.c.

## ◆ del_main_list()

void del_main_list | ( | void |  | ) |

Delete Main widgets list.

Definition at line 687 of file widget.c.

## ◆ del_widget_pointer_from_gui_list()

void del_widget_pointer_from_gui_list | ( | struct widget * | gui | ) |

Delete Widget from Main widgets list ( begin_widget_list )

NOTE: This function does not destroy Widget, only remove its pointer from list. To destroy this Widget totaly ( free mem... ) call macro: del_widget_from_gui_list( pwidget ). This macro call this function.

Definition at line 618 of file widget.c.

## ◆ draw_frame()

void draw_frame | ( | SDL_Surface * | pdest,
|  | Sint16 | start_x,
|  | Sint16 | start_y,
|  | Uint16 | w,
|  | Uint16 | h
| ) |  |

Draw Themed Frame.

Definition at line 1110 of file widget.c.

## ◆ find_next_widget_at_pos()

struct widget * find_next_widget_at_pos | ( | struct widget * | start_widget,
|  | int | x,
|  | int | y
| ) |  |

Find the next visible widget in the widget list starting with start_widget that is drawn at position (x, y). If start_widget is NULL, the search starts with the first entry of the main widget list.

Definition at line 218 of file widget.c.

## ◆ find_next_widget_for_key()

struct widget * find_next_widget_for_key | ( | struct widget * | start_widget,
|  | SDL_Keysym | key
| ) |  |

Find the next enabled and visible widget in the widget list starting with start_widget that handles the given key. If start_widget is NULL, the search starts with the first entry of the main widget list. NOTE: This function ignores CapsLock and NumLock Keys.

Definition at line 248 of file widget.c.

## ◆ get_widget_pointer_from_id()

struct widget * get_widget_pointer_from_id | ( | const struct widget * | gui_list,
|  | Uint16 | id,
|  | enum scan_direction | direction
| ) |  |

Find ID in widgets list ('gui_list') and return pointer to this Widget.

Definition at line 548 of file widget.c.

## ◆ get_widget_pointer_from_main_list()

struct widget * get_widget_pointer_from_main_list | ( | Uint16 | id | ) |

Find ID in MAIN widgets list ( begin_widget_list ) and return pointer to this Widgets.

Definition at line 574 of file widget.c.

## ◆ group_set_area()

void group_set_area | ( | struct widget * | begin_group_widget_list,
|  | struct widget * | end_group_widget_list,
|  | SDL_Rect | area
| ) |  |

Set area for all widgets in the group.

Definition at line 949 of file widget.c.

## ◆ hide_group()

void hide_group | ( | struct widget * | begin_group_widget_list,
|  | struct widget * | end_group_widget_list
| ) |  |

Hide all widgets in the group.

Definition at line 911 of file widget.c.

## ◆ is_this_widget_first_on_list()

bool is_this_widget_first_on_list | ( | struct widget * | gui | ) |

Determinate if 'gui' is first on WidgetList

NOTE: This is used by My (move) GUI Window mechanism. Return TRUE if is first.

Definition at line 653 of file widget.c.

## ◆ move_group_to_front_of_gui_list()

void move_group_to_front_of_gui_list | ( | struct widget * | begin_group_widget_list,
|  | struct widget * | end_group_widget_list
| ) |  |

Move group of Widget's pointers to begin of main list. Move group destination buffer to end of buffer array. NOTE: This is used by My GUI Window(group) mechanism.

Definition at line 808 of file widget.c.

## ◆ move_widget_to_front_of_gui_list()

void move_widget_to_front_of_gui_list | ( | struct widget * | gui | ) |

Move pointer to Widget to list begin.

NOTE: This is used by My GUI Window mechanism.

Definition at line 663 of file widget.c.

## ◆ move_window_group()

void move_window_group | ( | struct widget * | begin_widget_list,
|  | struct widget * | pwindow
| ) |  |

Standart Window Group Widget Callback (window) When Pressed check mouse move; if move then move window and redraw else if not on front then move window up to list and redraw.

Definition at line 1035 of file widget.c.

## ◆ move_window_group_dialog()

bool move_window_group_dialog | ( | struct widget * | begin_group_widget_list,
|  | struct widget * | end_group_widget_list
| ) |  |

Move Window Group. The Trick is simple. We move only last member of group: the window , and then set new position to all members of group.

Function return 1 when group was moved.

Definition at line 1012 of file widget.c.

## ◆ popdown_window_group_dialog()

void popdown_window_group_dialog | ( | struct widget * | begin_group_widget_list,
|  | struct widget * | end_group_widget_list
| ) |  |

Undraw and destroy Window Group The Trick is simple. We undraw only last member of group: the window.

Definition at line 979 of file widget.c.

## ◆ redraw_group()

Uint16 redraw_group | ( | const struct widget * | begin_group_widget_list,
|  | const struct widget * | end_group_widget_list,
|  | int | add_to_update
| ) |  |

Universal redraw Group of Widget function. Function is optimized to WindowGroup: start draw from 'end' and stop on 'begin', in theory 'end' is window widget;

Definition at line 716 of file widget.c.

## ◆ redraw_widget_info_label()

void redraw_widget_info_label | ( | SDL_Rect * | rect | ) |

Draw or redraw info label to screen.

Definition at line 463 of file widget.c.

## ◆ refresh_widget_background()

void refresh_widget_background | ( | struct widget * | pwidget | ) |

Redraw background of the widget.

Definition at line 1147 of file widget.c.

## ◆ select_window_group_dialog()

bool select_window_group_dialog | ( | struct widget * | begin_widget_list,
|  | struct widget * | pwindow
| ) |  |

Select Window Group. (move widget group up the widgets list) Function return TRUE when group was selected.

Definition at line 994 of file widget.c.

## ◆ set_group_state()

void set_group_state | ( | struct widget * | begin_group_widget_list,
|  | struct widget * | end_group_widget_list,
|  | enum widget_state | state
| ) |  |

Set state for all the widgets in the group.

Definition at line 894 of file widget.c.

## ◆ set_new_group_start_pos()

void set_new_group_start_pos | ( | const struct widget * | begin_group_widget_list,
|  | const struct widget * | end_group_widget_list,
|  | Sint16 | Xrel,
|  | Sint16 | Yrel
| ) |  |

Move all widgets in the group by the given amounts.

Definition at line 770 of file widget.c.

## ◆ setup_vertical_widgets_position()

int setup_vertical_widgets_position | ( | int | step,
|  | Sint16 | start_x,
|  | Sint16 | start_y,
|  | Uint16 | w,
|  | Uint16 | h,
|  | struct widget * | begin,
|  | struct widget * | end
| ) |  |

Setup widgets vertically.

Definition at line 1047 of file widget.c.

## ◆ show_group()

void show_group | ( | struct widget * | begin_group_widget_list,
|  | struct widget * | end_group_widget_list
| ) |  |

Show all widgets in the group.

Definition at line 930 of file widget.c.

## ◆ undraw_group()

void undraw_group | ( | struct widget * | begin_group_widget_list,
|  | struct widget * | end_group_widget_list
| ) |  |

Undraw all widgets in the group.

Definition at line 750 of file widget.c.

## ◆ unselect_widget_action()

void unselect_widget_action | ( | void |  | ) |

Unselect (selected) widget and redraw this widget;

Definition at line 414 of file widget.c.

## ◆ widget_add_as_prev()

void widget_add_as_prev | ( | struct widget * | new_widget,
|  | struct widget * | add_dock
| ) |  |

Add Widget to widgets list at add_dock position on 'prev' slot.

Definition at line 598 of file widget.c.

## ◆ widget_pressed_action()

Uint16 widget_pressed_action | ( | struct widget * | pwidget | ) |

Do default Widget action when pressed, and then call widget callback function.

example for Button: set flags FW_Pressed redraw button ( pressed ) refresh screen ( to see result ) wait 300 ms ( to see result :) If exist (button callback function) then call (button callback function)

Function normal return Widget ID. NOTE: NOZERO return of this function determinate exit of MAIN_SDL_GAME_LOOP if ( pwidget->action ) if ( pwidget->action(pwidget) ) ID = 0; if widget callback function return = 0 then return NOZERO I default return (-1) from Widget callback functions.

Definition at line 292 of file widget.c.

## ◆ widget_selected_action()

void widget_selected_action | ( | struct widget * | pwidget | ) |

Select widget. Redraw this widget;

Definition at line 439 of file widget.c.

## Variable Documentation

## ◆ begin_main_widget_list

struct widget* begin_main_widget_list

static

Definition at line 51 of file widget.c.

## ◆ info_area

SDL_Rect* info_area = NULL

Definition at line 45 of file widget.c.

Referenced by flush_dirty().

## ◆ info_label

SDL_Surface* info_label = NULL

static

Definition at line 53 of file widget.c.

## ◆ selected_widget

struct widget* selected_widget

Definition at line 44 of file widget.c.

Referenced by add_new_worklist_callback(), change_sex_callback(), connect_callback(), factor_horiz_cma_callback(), horiz_taxrate_callback(), main_key_up_handler(), main_mouse_motion_handler(), min_horiz_cma_callback(), nation_button_callback(), next_name_callback(), popup_change_research_dialog_callback(), popup_change_research_goal_dialog_callback(), popup_hurry_production_dialog(), popup_sell_impr_callback(), popup_upgrade_unit_callback(), prev_name_callback(), races_dialog_ok_callback(), std_down_advanced_dlg_callback(), std_up_advanced_dlg_callback(), std_vscroll_advanced_dlg_callback(), style_callback(), toggle_map_window_callback(), toggle_msg_window_callback(), toggle_unit_info_window_callback(), and unit_order_callback().

## ◆ widget_info_counter

Uint32 widget_info_counter

extern

Definition at line 103 of file gui_main.c.

Referenced by gui_event_loop().