Freeciv-3.1
|
#include <SDL2/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 |
void add_to_gui_list | ( | Uint16 | id, |
struct widget * | gui | ||
) |
Add Widget to Main widgets list ( begin_widget_list )
Definition at line 585 of file widget.c.
Referenced by action_entry(), combo_popup(), create_city_options_widget_list(), create_present_supported_units_widget_list(), create_units_order_widgets(), economy_report_dialog_popup(), init_options_button(), meswin_dialog_popup(), nation_button_callback(), notify_goto_dialog_new(), notify_goto_dialog_update(), option_dialog_new(), option_dialog_optset(), option_dialog_optset_category(), option_dialog_worklist(), option_widget_new(), popup_action_selection(), popup_advanced_terrain_dialog(), popup_bribe_dialog(), popup_change_research_dialog(), popup_change_research_goal_dialog(), popup_city_cma_dialog(), popup_conn_list_dialog(), popup_connection_dialog(), popup_diplomacy_dialog(), popup_diplomatic_objects(), popup_find_dialog(), popup_goto_airlift_dialog(), popup_government_dialog(), popup_hurry_production_dialog(), popup_impr_info(), popup_incite_dialog(), popup_join_game_dialog(), popup_load_del_presets_dialog(), popup_load_game_dialog(), popup_minimap_window(), popup_new_user_passwd_dialog(), popup_newcity_dialog(), popup_notify_dialog(), popup_pillage_dialog(), popup_players_dialog(), popup_players_nations_dialog(), popup_races_dialog(), popup_sabotage_dialog(), popup_sell_impr_callback(), popup_spaceship_dialog(), popup_tech_info(), popup_terrain_info_dialog(), popup_unit_disband_dlg(), popup_unit_info(), popup_unit_upgrade_dlg(), popup_unitinfo_window(), popup_upgrade_unit_callback(), popup_user_passwd_dialog(), popup_war_dialog(), popup_worklist_editor(), real_activeunits_report_dialog_update(), real_city_dialog_popup(), real_info_city_report_dialog_update(), save_cma_callback(), science_report_dialog_popup(), sell_imprvm_dlg_callback(), show_game_page(), show_main_page(), spy_steal_popup_shared(), unit_select_dialog_popup(), units_orders_city_dlg_callback(), update_diplomacy_dialog(), and update_intel_dialog().
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 63 of file widget.c.
Referenced by combo_new(), create_edit(), and create_icon_button().
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 78 of file widget.c.
Referenced by combo_redraw(), edit_field(), get_progress_icon(), redraw_edit(), and redraw_ibutton().
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 862 of file widget.c.
Referenced by back_callback(), del_city_dialog(), economy_report_dialog_popdown(), exit_economy_dialog_callback(), exit_units_dlg_callback(), free_city_units_lists(), ok_save_cma_callback(), popdown_city_cma_dialog(), popup_impr_info(), popup_tech_info(), popup_unit_info(), real_meswin_dialog_update(), rebuild_imprm_list(), redraw_army_city_dialog(), redraw_supported_units_city_dialog(), and units_report_dialog_popdown().
void del_gui_list | ( | struct widget * | gui_list | ) |
Delete Wideget's List ('gui_list').
Definition at line 698 of file widget.c.
Referenced by del_main_list().
void del_main_list | ( | void | ) |
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 621 of file widget.c.
Referenced by notify_goto_dialog_destroy(), notify_goto_dialog_update(), and popup_load_game_dialog().
void draw_frame | ( | SDL_Surface * | pdest, |
Sint16 | start_x, | ||
Sint16 | start_y, | ||
Uint16 | w, | ||
Uint16 | h | ||
) |
Draw Themed Frame.
Definition at line 1113 of file widget.c.
Referenced by popup_conn_list_dialog(), popup_minimap_window(), and popup_unitinfo_window().
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 222 of file widget.c.
Referenced by main_finger_down_handler(), main_finger_up_handler(), main_mouse_button_down_handler(), main_mouse_button_up_handler(), and main_mouse_motion_handler().
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 251 of file widget.c.
Referenced by main_key_down_handler().
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 551 of file widget.c.
Referenced by 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 577 of file widget.c.
Referenced by add_target_to_worklist(), close_game_page(), races_toggles_set_sensitive(), real_resize_window_callback(), remove_item_from_worklist(), set_indicator_icons(), and style_callback().
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 952 of file widget.c.
Referenced by show_main_page().
Hide all widgets in the group.
Definition at line 914 of file widget.c.
Referenced by option_dialog_optset(), option_dialog_optset_category(), option_dialog_worklist(), popup_tech_info(), and real_menus_update().
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 656 of file widget.c.
Referenced by select_window_group_dialog().
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 811 of file widget.c.
Referenced by select_window_group_dialog().
void move_widget_to_front_of_gui_list | ( | struct widget * | gui | ) |
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 1038 of file widget.c.
Referenced by advanced_terrain_window_dlg_callback(), bribe_dlg_window_callback(), city_report_windows_callback(), combo_menu_callback(), diplomat_dlg_window_callback(), disband_unit_window_callback(), economy_dialog_callback(), find_city_window_dlg_callback(), goto_dialog_window_callback(), hurry_production_window_callback(), incite_dlg_window_callback(), intel_window_dlg_callback(), main_optiondlg_callback(), move_government_dlg_callback(), move_load_game_dlg_callback(), move_msg_window_callback(), move_new_city_dlg_callback(), notify_dialog_window_callback(), notify_goto_dialog_callback(), pillage_window_callback(), sdip_window_callback(), sell_impr_window_callback(), space_dialog_window_callback(), spy_steal_dlg_window_callback(), terrain_info_window_dlg_callback(), unit_select_window_callback(), units_dialog_callback(), upgrade_unit_window_callback(), and upgrade_unit_window_callback().
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 1015 of file widget.c.
Referenced by move_window_group(), players_window_dlg_callback(), and science_dialog_callback().
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 982 of file widget.c.
Referenced by activate_and_exit_units_orders_city_dlg_callback(), cancel_help_dlg_callback(), cancel_sell_impr_callback(), cancel_sld_cma_callback(), cancel_units_orders_city_dlg_callback(), cancel_upgrade_unit_callback(), city_report_dialog_popdown(), close_connection_dialog(), combo_popdown(), del_city_dialog(), economy_report_dialog_popdown(), exit_change_tech_dlg_callback(), exit_economy_dialog_callback(), exit_notify_dialog_callback(), exit_units_dlg_callback(), ld_cma_callback(), meswin_dialog_popdown(), newcity_cancel_callback(), newcity_ok_callback(), ok_sell_impr_callback(), ok_upgrade_unit_window_callback(), option_dialog_destroy(), popdown_advanced_terrain_dialog(), popdown_bribe_dialog(), popdown_city_cma_dialog(), popdown_city_menu_dlg(), popdown_conn_list_dialog(), popdown_connect_dialog(), popdown_diplomacy_dialog(), popdown_diplomat_dialog(), popdown_find_dialog(), popdown_goto_airlift_dialog(), popdown_government_dialog(), popdown_help_dialog(), popdown_hurry_production_dialog(), popdown_incite_dialog(), popdown_intel_dialog(), popdown_load_game_dialog(), popdown_minimap_window(), popdown_newcity_dialog(), popdown_pillage_dialog(), popdown_players_dialog(), popdown_players_nations_dialog(), popdown_races_dialog(), popdown_sdip_dialog(), popdown_spaceship_dialog(), popdown_start_menu(), popdown_terrain_info_dialog(), popdown_unit_disband_dlg(), popdown_unit_upgrade_dlg(), popdown_unitinfo_window(), popdown_worklist_editor(), popup_connection_dialog(), real_activeunits_report_dialog_update(), real_info_city_report_dialog_update(), science_report_dialog_popdown(), science_report_dialogs_popdown_all(), sell_imprvm_dlg_cancel_callback(), sell_imprvm_dlg_ok_callback(), unit_select_dialog_popdown(), units_report_dialog_popdown(), update_diplomacy_dialog(), and update_intel_dialog().
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 719 of file widget.c.
Referenced by add_global_worklist(), add_new_worklist_callback(), add_target_to_worklist(), add_to_chat_list(), arrange_widgets(), combo_popup(), combo_redraw(), disable_minimap_widgets(), disable_unitinfo_widgets(), economy_report_dialog_popup(), edit_worklist_callback(), enable_minimap_widgets(), enable_unitinfo_widgets(), inside_scroll_down_loop(), inside_scroll_up_loop(), nation_button_callback(), option_dialog_optset_category(), option_dialog_worklist(), popup_action_selection(), popup_advanced_terrain_dialog(), popup_bribe_dialog(), popup_change_research_dialog(), popup_change_research_goal_dialog(), popup_connection_dialog(), popup_diplomacy_dialog(), popup_find_dialog(), popup_government_dialog(), popup_hurry_production_dialog(), popup_incite_dialog(), popup_join_game_dialog(), popup_load_del_presets_dialog(), popup_load_game_dialog(), popup_new_user_passwd_dialog(), popup_newcity_dialog(), popup_notify_dialog(), popup_pillage_dialog(), popup_players_nations_dialog(), popup_races_dialog(), popup_sabotage_dialog(), popup_sell_impr_callback(), popup_terrain_info_dialog(), popup_unit_disband_dlg(), popup_unit_upgrade_dlg(), popup_upgrade_unit_callback(), popup_user_passwd_dialog(), popup_war_dialog(), popup_worklist_editor(), races_toggles_set_sensitive(), real_activeunits_report_dialog_update(), real_city_report_dialog_update(), real_city_report_update_city(), real_conn_list_dialog_update(), real_economy_report_dialog_update(), real_info_city_report_dialog_update(), real_meswin_dialog_update(), real_players_dialog_update(), real_science_report_dialog_update(), real_units_report_dialog_update(), redraw_army_city_dialog(), redraw_city_dialog(), redraw_impr_info_dlg(), redraw_misc_city_dialog(), redraw_supported_units_city_dialog(), redraw_tech_info_dlg(), redraw_tech_tree_dlg(), redraw_unit_info_dlg(), redraw_unit_info_label(), refresh_spaceship_dialog(), remove_item_from_worklist(), save_cma_callback(), scroll_mouse_motion_handler(), sell_imprvm_dlg_callback(), set_global_worklist(), show_main_page(), spy_steal_popup_shared(), swap_item_down_from_worklist(), swap_item_up_from_worklist(), unit_select_dialog_popup(), units_orders_city_dlg_callback(), update_city_cma_dialog(), update_clauses_list(), update_diplomacy_dialog(), update_goto_dialog(), update_intel_dialog(), and update_worklist_report_dialog().
void redraw_widget_info_label | ( | SDL_Rect * | rect | ) |
Draw or redraw info label to screen.
Definition at line 466 of file widget.c.
Referenced by flush_dirty().
void refresh_widget_background | ( | struct widget * | pwidget | ) |
Redraw background of the widget.
Definition at line 1150 of file widget.c.
Referenced by add_new_worklist_callback(), add_widget_to_vertical_scroll_widget_list(), del_widget_from_vertical_scroll_widget_list(), draw_edit(), draw_icon(), inside_scroll_down_loop(), inside_scroll_up_loop(), redraw_order_widgets(), refresh_production_label(), refresh_worklist_count_label(), report_scroll_mouse_motion_handler(), resize_window(), scroll_mouse_motion_handler(), scroll_mouse_motion_handler(), vertical_scroll_widget_list(), and widget_core_redraw().
Select Window Group. (move widget group up the widgets list) Function return TRUE when group was selected.
Definition at line 997 of file widget.c.
Referenced by change_research_goal_dialog_callback(), city_dlg_callback(), handle_diplomacy_init_meeting(), move_window_group(), nations_dialog_callback(), players_window_dlg_callback(), popup_intel_dialog(), popup_spaceship_dialog(), and science_dialog_callback().
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 897 of file widget.c.
Referenced by disable_city_dlg_widgets(), disable_economy_dlg(), disable_science_dialog(), disable_unitinfo_widgets(), enable_city_dlg_widgets(), enable_economy_dlg(), enable_science_dialog(), enable_unitinfo_widgets(), and sell_imprvm_dlg_ok_callback().
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 773 of file widget.c.
Referenced by move_window_group_dialog().
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 1050 of file widget.c.
Referenced by add_target_to_worklist(), create_present_supported_units_widget_list(), economy_report_dialog_popup(), option_dialog_worklist(), popup_action_selection(), popup_bribe_dialog(), popup_change_research_dialog(), popup_change_research_goal_dialog(), popup_diplomatic_objects(), popup_find_dialog(), popup_impr_info(), popup_incite_dialog(), popup_load_del_presets_dialog(), popup_pillage_dialog(), popup_players_nations_dialog(), popup_races_dialog(), popup_tech_info(), popup_unit_info(), popup_worklist_editor(), redraw_unit_info_label(), remove_item_from_worklist(), show_main_page(), spy_steal_popup_shared(), unit_select_dialog_popup(), update_goto_dialog(), and update_intel_dialog().
Show all widgets in the group.
Definition at line 933 of file widget.c.
Referenced by back_callback(), and popup_tech_info().
void undraw_group | ( | struct widget * | begin_group_widget_list, |
struct widget * | end_group_widget_list | ||
) |
Undraw all widgets in the group.
Definition at line 753 of file widget.c.
Referenced by real_meswin_dialog_update().
void unselect_widget_action | ( | void | ) |
Unselect (selected) widget and redraw this widget;
Definition at line 417 of file widget.c.
Referenced by connect_callback(), horiz_taxrate_callback(), main_key_up_handler(), main_mouse_motion_handler(), msg_callback(), sell_imprvm_dlg_callback(), std_down_advanced_dlg_callback(), std_up_advanced_dlg_callback(), std_vscroll_advanced_dlg_callback(), units_orders_city_dlg_callback(), and widget_selected_action().
Add Widget to widgets list at add_dock position on 'prev' slot.
Definition at line 601 of file widget.c.
Referenced by add_widget_to_vertical_scroll_widget_list(), create_horizontal_scrollbar(), create_tech_info(), create_tech_tree(), create_vertical_scrollbar(), popup_advanced_terrain_dialog(), popup_impr_info(), popup_unit_info(), rebuild_imprm_list(), redraw_unit_info_label(), and update_goto_dialog().
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 295 of file widget.c.
Referenced by main_finger_down_handler(), main_key_down_handler(), and main_mouse_button_down_handler().
void widget_selected_action | ( | struct widget * | pwidget | ) |
Select widget. Redraw this widget;
Definition at line 442 of file widget.c.
Referenced by main_mouse_motion_handler().
|
static |
Definition at line 55 of file widget.c.
Referenced by add_to_gui_list(), del_main_list(), del_widget_pointer_from_gui_list(), find_next_widget_at_pos(), find_next_widget_for_key(), get_widget_pointer_from_main_list(), is_this_widget_first_on_list(), move_group_to_front_of_gui_list(), move_widget_to_front_of_gui_list(), and widget_add_as_prev().
SDL_Rect* info_area = NULL |
Definition at line 49 of file widget.c.
Referenced by flush_dirty(), redraw_widget_info_label(), unselect_widget_action(), and widget_pressed_action().
|
static |
Definition at line 57 of file widget.c.
Referenced by city_dialog_update_information(), city_dialog_update_information(), create_city_info_table(), create_city_info_table(), redraw_widget_info_label(), unselect_widget_action(), and widget_pressed_action().
struct widget* selected_widget |
Definition at line 48 of file widget.c.
Referenced by add_new_worklist_callback(), change_sex_callback(), connect_callback(), del_widget_pointer_from_gui_list(), 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(), redraw_widget_info_label(), 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(), unit_order_callback(), unselect_widget_action(), and widget_selected_action().
|
extern |
Definition at line 99 of file gui_main.c.
Referenced by gui_event_loop(), unselect_widget_action(), widget_pressed_action(), and widget_selected_action().