base class of top level items, the only item which needs to store the final canvases to draw on More...
#include <window.hpp>
Classes | |
class | tinvalidate_layout_blocker |
Helper class to block invalidate_layout. More... | |
struct | tlinked_size |
Helper struct to force widgets the have the same size. More... | |
Public Types | |
enum | tretval { NONE = 0, OK = -1, CANCEL = -2, AUTO_CLOSE = -3 } |
Default return values. More... | |
enum | tstatus { NEW, SHOWING, REQUEST_CLOSE, CLOSED } |
The status of the window. More... | |
Public Types inherited from gui2::event::tdispatcher | |
enum | tevent_type { pre = 1, child = 2, post = 4 } |
enum | tposition { front_pre_child, back_pre_child, front_child, back_child, front_post_child, back_post_child } |
The position where to add a new callback in the signal handler. More... | |
enum | tmouse_behavior { all, hit, none } |
The behavior of the mouse events. More... | |
Public Member Functions | |
twindow (CVideo &video, tformula< unsigned > x, tformula< unsigned > y, tformula< unsigned > w, tformula< unsigned > h, tformula< bool > reevaluate_best_size, const game_logic::function_symbol_table &functions, const bool automatic_placement, const unsigned horizontal_placement, const unsigned vertical_placement, const unsigned maximum_width, const unsigned maximum_height, const std::string &definition, const twindow_builder::tresolution::ttip &tooltip, const twindow_builder::tresolution::ttip &helptip) | |
< Needs to be initialised in show. More... | |
~twindow () | |
int | show (const bool restore=true, const unsigned auto_close_timeout=0) |
Shows the window. More... | |
void | show_tooltip () |
Shows the window as a tooltip. More... | |
void | show_non_modal () |
Shows the window non modal. More... | |
void | draw () |
Draws the window. More... | |
void | undraw () |
Undraws the window. More... | |
void | add_to_dirty_list (const std::vector< twidget * > &call_stack) |
Adds an item to the dirty_list_. More... | |
void | close () |
Requests to close the window. More... | |
void | invalidate_layout () |
Updates the size of the window. More... | |
twindow & | get_window () |
Inherited from tevent_handler. More... | |
const twindow & | get_window () const |
Inherited from tevent_handler. More... | |
virtual twidget * | find_at (const tpoint &coordinate, const bool must_be_active) override |
See twidget::find_at. More... | |
virtual const twidget * | find_at (const tpoint &coordinate, const bool must_be_active) const override |
See twidget::find_at. More... | |
tdialog * | dialog () |
Inherited from twidget. More... | |
twidget * | find (const std::string &id, const bool must_be_active) override |
See twidget::find. More... | |
const twidget * | find (const std::string &id, const bool must_be_active) const override |
See twidget::find. More... | |
bool | does_click_dismiss () const |
Does the window close easily? More... | |
void | set_enter_disabled (const bool enter_disabled) |
Disable the enter key. More... | |
void | set_escape_disabled (const bool escape_disabled) |
Disable the escape key. More... | |
void | init_linked_size_group (const std::string &id, const bool fixed_width, const bool fixed_height) |
Initializes a linked size group. More... | |
bool | has_linked_size_group (const std::string &id) |
Is the linked size group defined for this window? More... | |
void | add_linked_widget (const std::string &id, twidget *widget) |
Adds a widget to a linked size group. More... | |
void | remove_linked_widget (const std::string &id, const twidget *widget) |
Removes a widget from a linked size group. More... | |
CVideo & | video () |
void | set_retval (const int retval, const bool close_window=true) |
Sets there return value of the window. More... | |
void | set_owner (tdialog *owner) |
void | set_click_dismiss (const bool click_dismiss) |
bool | get_need_layout () const |
void | set_variable (const std::string &key, const variant &value) |
tpoint | get_linked_size (const std::string &linked_group_id) const |
void | mouse_capture (const bool capture=true) |
void | keyboard_capture (twidget *widget) |
void | add_to_keyboard_chain (twidget *widget) |
Adds the widget to the keyboard chain. More... | |
void | remove_from_keyboard_chain (twidget *widget) |
Remove the widget from the keyboard chain. More... | |
Public Member Functions inherited from gui2::tpanel | |
tpanel (const unsigned canvas_count=2) | |
Constructor. More... | |
virtual SDL_Rect | get_client_rect () const override |
See tcontainer_::get_client_rect. More... | |
virtual bool | get_active () const override |
See tcontrol::get_active. More... | |
virtual unsigned | get_state () const override |
See tcontrol::get_state. More... | |
Public Member Functions inherited from gui2::tcontainer_ | |
tcontainer_ (const unsigned canvas_count) | |
virtual void | layout_initialise (const bool full_initialisation) override |
See twidget::layout_initialise. More... | |
void | reduce_width (const unsigned maximum_width) |
Tries to reduce the width of a container. More... | |
virtual void | request_reduce_width (const unsigned maximum_width) override |
See twidget::request_reduce_width. More... | |
virtual void | demand_reduce_width (const unsigned maximum_width) override |
See twidget::demand_reduce_width. More... | |
void | reduce_height (const unsigned maximum_height) |
Tries to reduce the height of a container. More... | |
virtual void | request_reduce_height (const unsigned maximum_height) override |
See twidget::request_reduce_height. More... | |
virtual void | demand_reduce_height (const unsigned maximum_height) override |
See twidget::demand_reduce_height. More... | |
virtual bool | can_wrap () const override |
See twidget::can_wrap. More... | |
virtual void | place (const tpoint &origin, const tpoint &size) override |
See twidget::place. More... | |
virtual bool | has_widget (const twidget &widget) const override |
See twidget::has_widget. More... | |
virtual void | set_origin (const tpoint &origin) override |
See twidget::set_origin. More... | |
virtual void | set_visible_rectangle (const SDL_Rect &rectangle) override |
See twidget::set_visible_rectangle. More... | |
virtual void | impl_draw_children (surface &frame_buffer, int x_offset, int y_offset) override |
See twidget::impl_draw_children. More... | |
virtual void | set_active (const bool active) override |
See tcontrol::set_active. More... | |
bool | disable_click_dismiss () const override |
See twidget::disable_click_dismiss. More... | |
virtual iterator::twalker_ * | create_walker () override |
See twidget::create_walker. More... | |
void | init_grid (const boost::intrusive_ptr< tbuilder_grid > &grid_builder) |
Initializes and builds the grid. More... | |
tgrid::iterator | begin () |
tgrid::iterator | end () |
unsigned | add_row (const unsigned count=1) |
void | set_rows (const unsigned rows) |
unsigned int | get_rows () const |
void | set_cols (const unsigned cols) |
unsigned int | get_cols () const |
void | set_rows_cols (const unsigned rows, const unsigned cols) |
void | set_child (twidget *widget, const unsigned row, const unsigned col, const unsigned flags, const unsigned border_size) |
void | set_row_grow_factor (const unsigned row, const unsigned factor) |
void | set_column_grow_factor (const unsigned column, const unsigned factor) |
const tgrid & | grid () const |
tgrid & | grid () |
Public Member Functions inherited from gui2::tcontrol | |
tcontrol (const unsigned canvas_count) | |
tcontrol (const implementation::tbuilder_control &builder, const unsigned canvas_count, const std::string &control_type) | |
Constructor. More... | |
virtual void | set_members (const string_map &data) |
Sets the members of the control. More... | |
bool | disable_click_dismiss () const override |
See twidget::disable_click_dismiss. More... | |
tpoint | get_config_minimum_size () const |
Gets the minimum size as defined in the config. More... | |
tpoint | get_config_default_size () const |
Gets the default size as defined in the config. More... | |
tpoint | get_config_maximum_size () const |
Gets the best size as defined in the config. More... | |
virtual unsigned | get_characters_per_line () const |
Returns the number of characters per line. More... | |
virtual bool | get_link_aware () const |
Returns whether the label should be link_aware, in in rendering and in searching for links with get_link. More... | |
virtual std::string | get_link_color () const |
Returns the color string to be used with links. More... | |
void | set_definition (const std::string &definition) |
Sets the definition. More... | |
bool | get_use_tooltip_on_label_overflow () const |
void | set_use_tooltip_on_label_overflow (const bool use_tooltip=true) |
const t_string & | label () const |
virtual void | set_label (const t_string &label) |
virtual void | set_use_markup (bool use_markup) |
bool | get_use_markup () const |
const t_string & | tooltip () const |
void | set_tooltip (const t_string &tooltip) |
const t_string & | help_message () const |
void | set_help_message (const t_string &help_message) |
std::vector< tcanvas > & | canvas () |
tcanvas & | canvas (const unsigned index) |
void | set_text_alignment (const PangoAlignment text_alignment) |
PangoAlignment | get_text_alignment () const |
Public Member Functions inherited from gui2::twidget | |
twidget () | |
twidget (const tbuilder_widget &builder) | |
Constructor. More... | |
virtual | ~twidget () override |
void | set_id (const std::string &id) |
const std::string & | id () const |
twindow * | get_window () |
Get the parent window. More... | |
const twindow * | get_window () const |
The constant version of get_window. More... | |
tdialog * | dialog () |
Returns the top-level dialogue. More... | |
void | set_parent (twidget *parent) |
twidget * | parent () |
tpoint | get_best_size () const |
Gets the best size for the widget. More... | |
virtual bool | can_mouse_focus () const |
Whether the mouse move/click event go 'through' this widget. More... | |
virtual void | set_size (const tpoint &size) |
Sets the size of the widget. More... | |
virtual void | move (const int x_offset, const int y_offset) |
Moves a widget. More... | |
tpoint | get_origin () const |
Returns the screen origin of the widget. More... | |
tpoint | get_size () const |
Returns the size of the widget. More... | |
SDL_Rect | get_rectangle () const |
Gets the bounding rectangle of the widget on the screen. More... | |
int | get_x () const |
int | get_y () const |
unsigned | get_width () const |
unsigned | get_height () const |
void | set_linked_group (const std::string &linked_group) |
SDL_Rect | calculate_blitting_rectangle (const int x_offset, const int y_offset) |
Calculates the blitting rectangle of the widget. More... | |
SDL_Rect | calculate_clipping_rectangle (const int x_offset, const int y_offset) |
Calculates the clipping rectangle of the widget. More... | |
void | draw_background (surface &frame_buffer, int x_offset, int y_offset) |
Draws the background of a widget. More... | |
void | draw_children (surface &frame_buffer, int x_offset, int y_offset) |
Draws the children of a widget. More... | |
void | draw_foreground (surface &frame_buffer, int x_offset, int y_offset) |
Draws the foreground of the widget. More... | |
void | populate_dirty_list (twindow &caller, std::vector< twidget * > &call_stack) |
Adds a widget to the dirty list if it is dirty. More... | |
SDL_Rect | get_dirty_rectangle () const |
Gets the dirty rectangle of the widget. More... | |
void | set_is_dirty (const bool is_dirty) |
bool | get_is_dirty () const |
void | set_visible (const tvisible::scoped_enum visible) |
tvisible::scoped_enum | get_visible () const |
tredraw_action::scoped_enum | get_drawing_action () const |
void | set_debug_border_mode (const unsigned debug_border_mode) |
void | set_debug_border_colour (const unsigned debug_border_colour) |
Public Member Functions inherited from gui2::tevent_executor | |
tevent_executor () | |
virtual | ~tevent_executor () |
void | set_wants_mouse_hover (const bool hover=true) |
bool | wants_mouse_hover () const |
void | set_wants_mouse_left_double_click (const bool click=true) |
bool | wants_mouse_left_double_click () const |
void | set_wants_mouse_middle_double_click (const bool click=true) |
bool | wants_mouse_middle_double_click () const |
tevent_executor & | set_wants_mouse_right_double_click (const bool click=true) |
bool | wants_mouse_right_double_click () const |
Public Member Functions inherited from gui2::event::tdispatcher | |
tdispatcher () | |
virtual | ~tdispatcher () |
void | connect () |
Connects the dispatcher to the event handler. More... | |
bool | has_event (const tevent event, const tevent_type event_type) |
bool | fire (const tevent event, twidget &target) |
Fires an event which has no extra parameters. More... | |
bool | fire (const tevent event, twidget &target, const tpoint &coordinate) |
Fires an event which takes a coordinate parameter. More... | |
bool | fire (const tevent event, twidget &target, const SDLKey key, const SDLMod modifier, const utf8::string &unicode) |
Fires an event which takes keyboard parameters. More... | |
bool | fire (const tevent event, twidget &target, void *) |
Fires an event which takes notification parameters. More... | |
bool | fire (const tevent event, twidget &target, tmessage &message) |
Fires an event which takes message parameters. More... | |
template<tevent E> | |
boost::enable_if < boost::mpl::has_key < tset_event, boost::mpl::int_ < E > > >::type | connect_signal (const tsignal_function &signal, const tposition position=back_child) |
Connect a signal for callback in tset_event. More... | |
template<tevent E> | |
boost::enable_if < boost::mpl::has_key < tset_event, boost::mpl::int_ < E > > >::type | disconnect_signal (const tsignal_function &signal, const tposition position=back_child) |
Disconnect a signal for callback in tset_event. More... | |
template<tevent E> | |
boost::enable_if < boost::mpl::has_key < tset_event_mouse, boost::mpl::int_< E > > >::type | connect_signal (const tsignal_mouse_function &signal, const tposition position=back_child) |
Connect a signal for callback in tset_event_mouse. More... | |
template<tevent E> | |
boost::enable_if < boost::mpl::has_key < tset_event_mouse, boost::mpl::int_< E > > >::type | disconnect_signal (const tsignal_mouse_function &signal, const tposition position=back_child) |
Disconnect a signal for callback in tset_event_mouse. More... | |
template<tevent E> | |
boost::enable_if < boost::mpl::has_key < tset_event_keyboard, boost::mpl::int_< E > > >::type | connect_signal (const tsignal_keyboard_function &signal, const tposition position=back_child) |
Connect a signal for callback in tset_event_keyboard. More... | |
template<tevent E> | |
boost::enable_if < boost::mpl::has_key < tset_event_keyboard, boost::mpl::int_< E > > >::type | disconnect_signal (const tsignal_keyboard_function &signal, const tposition position=back_child) |
Disconnect a signal for callback in tset_event_keyboard. More... | |
template<tevent E> | |
boost::enable_if < boost::mpl::has_key < tset_event_notification, boost::mpl::int_< E > > >::type | connect_signal (const tsignal_notification_function &signal, const tposition position=back_child) |
Connect a signal for callback in tset_event_notification. More... | |
template<tevent E> | |
boost::enable_if < boost::mpl::has_key < tset_event_notification, boost::mpl::int_< E > > >::type | disconnect_signal (const tsignal_notification_function &signal, const tposition position=back_child) |
Disconnect a signal for callback in tset_event_notification. More... | |
template<tevent E> | |
boost::enable_if < boost::mpl::has_key < tset_event_message, boost::mpl::int_< E > > >::type | connect_signal (const tsignal_message_function &signal, const tposition position=back_child) |
Connect a signal for callback in tset_event_message. More... | |
template<tevent E> | |
boost::enable_if < boost::mpl::has_key < tset_event_message, boost::mpl::int_< E > > >::type | disconnect_signal (const tsignal_message_function &signal, const tposition position=back_child) |
Disconnect a signal for callback in tset_event_message. More... | |
void | capture_mouse () |
Captures the mouse. More... | |
void | release_mouse () |
Releases the mouse capture. More... | |
void | set_mouse_behavior (const tmouse_behavior mouse_behavior) |
tmouse_behavior | get_mouse_behavior () const |
void | set_want_keyboard_input (const bool want_keyboard_input) |
bool | get_want_keyboard_input () const |
void | register_hotkey (const hotkey::HOTKEY_COMMAND id, const thotkey_function &function) |
Registers a hotkey. More... | |
bool | execute_hotkey (const hotkey::HOTKEY_COMMAND id) |
Executes a hotkey. More... | |
Public Member Functions inherited from cursor::setter | |
setter (CURSOR_TYPE type) | |
~setter () | |
Static Public Member Functions | |
static void | update_screen_size () |
Update the size of the screen variables in settings. More... | |
static twindow * | window_instance (const unsigned handle) |
Returns the instance of a window. More... | |
static tretval | get_retval_by_id (const std::string &id) |
Gets the retval for the default buttons. More... | |
static void | set_sunset (const unsigned interval) |
Private Types | |
enum | tshow_mode { none, modal, tooltip } |
Private Member Functions | |
void | layout () |
Layouts the window. More... | |
void | layout_linked_widgets () |
Layouts the linked widgets. More... | |
bool | click_dismiss (const Uint8 mouse_button_mask) |
Handles a mouse click event for dismissing the dialogue. More... | |
virtual const std::string & | get_control_type () const override |
See tcontrol::get_control_type. More... | |
void | finalize (const boost::intrusive_ptr< tbuilder_grid > &content_grid) |
Finishes the initialization of the grid. More... | |
void | generate_dot_file (const std::string &, const unsigned) |
void | signal_handler_sdl_video_resize (const event::tevent event, bool &handled, const tpoint &new_size) |
void | signal_handler_click_dismiss (const event::tevent event, bool &handled, bool &halt, const Uint8 mouse_button_mask) |
The handler for the click dismiss mouse 'event'. More... | |
void | signal_handler_sdl_key_down (const event::tevent event, bool &handled, const SDLKey key) |
void | signal_handler_message_show_tooltip (const event::tevent event, bool &handled, event::tmessage &message) |
void | signal_handler_message_show_helptip (const event::tevent event, bool &handled, event::tmessage &message) |
void | signal_handler_request_placement (const event::tevent event, bool &handled) |
Private Attributes | |
CVideo & | video_ |
Needed so we can change what's drawn on the screen. More... | |
tstatus | status_ |
The status of the window. More... | |
tshow_mode | show_mode_ |
The mode in which the window is shown. More... | |
int | retval_ |
tdialog * | owner_ |
The dialog that owns the window. More... | |
bool | need_layout_ |
When set the form needs a full layout redraw cycle. More... | |
game_logic::map_formula_callable | variables_ |
The variables of the canvas. More... | |
bool | invalidate_layout_blocked_ |
Is invalidate layout blocked see tinvalidate_layout_blocker. More... | |
bool | suspend_drawing_ |
Avoid drawing the window. More... | |
bool | restore_ |
Whether the window should undraw the window using restorer_. More... | |
surface | restorer_ |
When the window closes this surface is used to undraw the window. More... | |
const bool | automatic_placement_ |
Do we wish to place the widget automatically? More... | |
const unsigned | horizontal_placement_ |
Sets the horizontal placement. More... | |
const unsigned | vertical_placement_ |
Sets the vertical placement. More... | |
unsigned | maximum_width_ |
The maximum width if automatic_placement_ is true. More... | |
unsigned | maximum_height_ |
The maximum height if automatic_placement_ is true. More... | |
tformula< unsigned > | x_ |
The formula to calulate the x value of the dialog. More... | |
tformula< unsigned > | y_ |
The formula to calulate the y value of the dialog. More... | |
tformula< unsigned > | w_ |
The formula to calulate the width of the dialog. More... | |
tformula< unsigned > | h_ |
The formula to calulate the height of the dialog. More... | |
tformula< bool > | reevaluate_best_size_ |
The formula to determine whether the size is good. More... | |
game_logic::function_symbol_table | functions_ |
The formula definitions available for the calulation formulas. More... | |
twindow_builder::tresolution::ttip | tooltip_ |
The settings for the tooltip. More... | |
twindow_builder::tresolution::ttip | helptip_ |
The settings for the helptip. More... | |
bool | click_dismiss_ |
Do we want to have easy close behavior? More... | |
bool | enter_disabled_ |
Disable the enter key see our setter for more info. More... | |
bool | escape_disabled_ |
Disable the escape key see our setter for more info. More... | |
std::map< std::string, tlinked_size > | linked_size_ |
List of the widgets, whose size are linked together. More... | |
Uint8 | mouse_button_state_ |
The state of the mouse button. More... | |
std::vector< std::vector < twidget * > > | dirty_list_ |
The list with dirty items in the window. More... | |
event::tdistributor * | event_distributor_ |
Static Private Attributes | |
static unsigned | sunset_ = 0 |
Controls the sunset feature. More... | |
Friends | |
class | tdebug_layout_graph |
struct | twindow_implementation |
class | tinvalidate_layout_blocker |
class | tpane |
twindow * | build (CVideo &, const twindow_builder::tresolution *) |
Builds a window. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from gui2::tcontainer_ | |
virtual void | layout_children () override |
See twidget::layout_children. More... | |
virtual void | child_populate_dirty_list (twindow &caller, const std::vector< twidget * > &call_stack) override |
See twidget::child_populate_dirty_list. More... | |
Protected Member Functions inherited from gui2::tcontrol | |
tresolution_definition_ptr | config () |
tresolution_definition_const_ptr | config () const |
void | set_config (tresolution_definition_ptr config) |
virtual void | update_canvas () |
Updates the canvas(ses). More... | |
int | get_text_maximum_width () const |
Returns the maximum width available for the text. More... | |
int | get_text_maximum_height () const |
Returns the maximum height available for the text. More... | |
std::string | get_label_token (const gui2::tpoint &position, const char *delimiters=" \n\r\t") const |
Exposes font::ttext::get_token, for the text label of this control. More... | |
std::string | get_label_link (const gui2::tpoint &position) const |
Protected Member Functions inherited from gui2::twidget | |
void | set_layout_size (const tpoint &size) |
const tpoint & | layout_size () const |
base class of top level items, the only item which needs to store the final canvases to draw on
Definition at line 62 of file window.hpp.
Default return values.
These values are named return values and most are assigned to a widget automatically when using a certain id for that widget. The automatic return values are always a negative number.
Note this might be moved somewhere else since it will force people to include the button, while it should be and implementation detail for most callers.
Definition at line 119 of file window.hpp.
|
private |
Enumerator | |
---|---|
none | |
modal | |
tooltip |
Definition at line 471 of file window.hpp.
The status of the window.
Definition at line 219 of file window.hpp.
gui2::twindow::twindow | ( | CVideo & | video, |
tformula< unsigned > | x, | ||
tformula< unsigned > | y, | ||
tformula< unsigned > | w, | ||
tformula< unsigned > | h, | ||
tformula< bool > | reevaluate_best_size, | ||
const game_logic::function_symbol_table & | functions, | ||
const bool | automatic_placement, | ||
const unsigned | horizontal_placement, | ||
const unsigned | vertical_placement, | ||
const unsigned | maximum_width, | ||
const unsigned | maximum_height, | ||
const std::string & | definition, | ||
const twindow_builder::tresolution::ttip & | tooltip, | ||
const twindow_builder::tresolution::ttip & | helptip | ||
) |
< Needs to be initialised in show.
Definition at line 292 of file window.cpp.
References gui2::event::tdispatcher::back_pre_child, gui2::event::tdispatcher::connect(), draw(), event_distributor_, gui2::event::tdispatcher::front_child, hotkey::GLOBAL__HELPTIP, gui2::event::tdistributor::initialize_state(), gui2::tcontrol::load_config(), gui2::event::tdispatcher::register_hotkey(), gui2::tcontrol::set_definition(), signal_handler_click_dismiss(), signal_handler_message_show_helptip(), signal_handler_message_show_tooltip(), signal_handler_request_placement(), signal_handler_sdl_key_down(), and signal_handler_sdl_video_resize().
gui2::twindow::~twindow | ( | ) |
Definition at line 418 of file window.cpp.
References event_distributor_, gui2::tgrid::get_cols(), gui2::tgrid::get_rows(), gui2::tcontainer_::grid(), modal, gui2::tip::remove(), gui2::tgrid::remove_child(), and show_mode_.
void gui2::twindow::add_linked_widget | ( | const std::string & | id, |
twidget * | widget | ||
) |
Adds a widget to a linked size group.
The group needs to exist, which is done by calling init_linked_size_group. A widget may only be member of one group.
id | The id of the group. |
widget | The widget to add to the group. |
Definition at line 984 of file window.cpp.
References gui2::event::find(), has_linked_size_group(), gui2::twidget::id(), and linked_size_.
Referenced by gui2::twidget::layout_initialise().
Adds an item to the dirty_list_.
call_stack | The list of widgets traversed to get to the dirty widget. |
Definition at line 213 of file window.hpp.
References dirty_list_.
Referenced by gui2::twidget::populate_dirty_list().
Adds the widget to the keyboard chain.
widget | The widget to add to the chain. The widget should be valid widget, which hasn't been added to the chain yet. |
Definition at line 1400 of file window.cpp.
References event_distributor_.
Referenced by gui2::build().
|
private |
Handles a mouse click event for dismissing the dialogue.
mouse_button_mask | The SDL_BUTTON mask for the button used to dismiss the click. If the caller is from the keyboard code the value should be 0. |
Definition at line 1240 of file window.cpp.
References does_click_dismiss(), mouse_button_state_, OK, and set_retval().
Referenced by set_click_dismiss(), signal_handler_click_dismiss(), and signal_handler_sdl_key_down().
|
inline |
Requests to close the window.
At the moment the request is always honored but that might change in the future.
Definition at line 235 of file window.hpp.
References REQUEST_CLOSE, and status_.
Referenced by gui2::tlobby_player_info::check_status_button_callback(), gui2::tlobby_main::create_button_callback(), gui2::tsynced_choice_wait::handle_generic_event(), gui2::tdrop_down_list::item_change_callback(), gui2::tlobby_main::join_global_button_callback(), gui2::tlobby_main::join_or_observe(), gui2::tlobby_player_info::kick_ban_button_callback(), gui2::tlobby_player_info::kick_button_callback(), gui2::tlobby_main::observe_global_button_callback(), gui2::tsynced_choice_wait::pre_show(), set_retval(), gui2::tlobby_player_info::start_whisper_button_callback(), and gui2::tloadscreen::timer_callback().
|
inline |
Inherited from twidget.
Definition at line 290 of file window.hpp.
References owner_.
Referenced by gui2::twidget::dialog().
|
inline |
Does the window close easily?
The behavior can change at run-time, but that might cause oddities with the easy close button (when one is needed).
Definition at line 332 of file window.hpp.
References click_dismiss_, and gui2::tcontainer_::disable_click_dismiss().
Referenced by click_dismiss().
void gui2::twindow::draw | ( | ) |
Draws the window.
This routine draws the window if needed, it's called from the event handler. This is done by a drawing event. When a window is shown it manages an SDL timer which fires a drawing event every X milliseconds, that event calls this routine. Don't call it manually.
Definition at line 738 of file window.cpp.
References sdl::create_rect(), dirty_list_, font::draw_floating_labels(), sdl::fill_rect_alpha(), gui2::twidget::get_rectangle(), get_surface_portion(), get_video_surface(), CVideo::getSurface(), i, itor, layout(), gui2::tcontainer_::layout_children(), need_layout_, gui2::new_widgets, gui2::twidget::tredraw_action::none, gui2::twidget::populate_dirty_list(), restore_, restorer_, screen_area(), sdl_blit(), sunset_, suspend_drawing_, update_rect(), preferences::use_color_cursors(), video_, and gui2::twidget::tvisible::visible.
|
private |
Finishes the initialization of the grid.
content_grid | The new contents for the content grid. |
Definition at line 1301 of file window.cpp.
References gui2::tcontainer_::grid().
Referenced by gui2::build().
|
overridevirtual |
See twidget::find.
Reimplemented from gui2::tcontainer_.
Definition at line 958 of file window.cpp.
References gui2::tcontainer_::find().
Referenced by gui2::tfield_text::finalize_specialized(), gui2::tdialog::init_fields(), gui2::tfield_bool::init_specialized(), and gui2::tfield_::widget_set_enabled().
|
overridevirtual |
See twidget::find.
Reimplemented from gui2::tcontainer_.
Definition at line 963 of file window.cpp.
References gui2::tcontainer_::find().
|
overridevirtual |
See twidget::find_at.
Reimplemented from gui2::tcontainer_.
Definition at line 947 of file window.cpp.
References gui2::tcontainer_::find_at().
|
overridevirtual |
See twidget::find_at.
Reimplemented from gui2::tcontainer_.
Definition at line 952 of file window.cpp.
References gui2::tcontainer_::find_at().
|
inlineprivate |
Definition at line 697 of file window.hpp.
Referenced by layout(), show(), show_non_modal(), and show_tooltip().
|
overrideprivatevirtual |
See tcontrol::get_control_type.
Reimplemented from gui2::tpanel.
Definition at line 1253 of file window.cpp.
|
inline |
Definition at line 454 of file window.hpp.
References linked_size_.
Referenced by gui2::twidget::get_best_size().
|
inline |
Definition at line 444 of file window.hpp.
References need_layout_.
Referenced by gui2::tscrollbar_container::content_resize_request().
|
static |
Gets the retval for the default buttons.
The ones for the title screen.
This is a kind of hack, but the values are hardcoded in the titlescreen and don't want to change them at the moment. It would be a good idea to add some namespaces to avoid names clashing.
The hacks which are here so the old engine can handle the event. The new engine can't handle all dialogs yet, so it needs to fall back to the old engine to make certain things happen.
Definition at line 493 of file window.cpp.
References CANCEL, gui2::ttitle_screen::CHANGE_LANGUAGE, gui2::ttitle_screen::CORES, gui2::ttitle_screen::EDIT_PREFERENCES, gui2::ttitle_screen::GET_ADDONS, gui2::ttitle_screen::LOAD_GAME, gui2::ttitle_screen::MULTIPLAYER, gui2::ttitle_screen::NEW_CAMPAIGN, NONE, OK, gui2::ttitle_screen::QUIT_GAME, gui2::ttitle_screen::SHOW_ABOUT, gui2::ttitle_screen::SHOW_HELP, gui2::ttitle_screen::START_MAP_EDITOR, and gui2::ttitle_screen::TUTORIAL.
Referenced by gui2::implementation::get_retval().
|
inline |
Inherited from tevent_handler.
Definition at line 270 of file window.hpp.
|
inline |
Inherited from tevent_handler.
Definition at line 276 of file window.hpp.
bool gui2::twindow::has_linked_size_group | ( | const std::string & | id | ) |
Is the linked size group defined for this window?
id | The id of the group. |
Definition at line 979 of file window.cpp.
References linked_size_.
Referenced by add_linked_widget(), gui2::build(), init_linked_size_group(), and remove_linked_widget().
void gui2::twindow::init_linked_size_group | ( | const std::string & | id, |
const bool | fixed_width, | ||
const bool | fixed_height | ||
) |
Initializes a linked size group.
Note at least one of fixed_width or fixed_height must be true.
id | The id of the group. |
fixed_width | Does the group have a fixed width? |
fixed_height | Does the group have a fixed height? |
Definition at line 969 of file window.cpp.
References has_linked_size_group(), gui2::twidget::id(), and linked_size_.
Referenced by gui2::build().
void gui2::twindow::invalidate_layout | ( | ) |
Updates the size of the window.
If the window has automatic placement set this function recalculates the window. To be used after creation and after modification or items which can have different sizes eg listboxes.
Definition at line 941 of file window.cpp.
References invalidate_layout_blocked_, and need_layout_.
Referenced by gui2::tscrollbar_container::content_resize_height(), gui2::tscrollbar_container::content_resize_request(), gui2::tscrollbar_container::content_resize_width(), gui2::tpreferences::default_hotkey_callback(), gui2::tchat_log::view::filter(), gui2::tmp_change_control::view::handle_nicks_list_item_clicked(), gui2::tchat_log::view::handle_page_number_changed(), gui2::tmp_change_control::view::handle_sides_list_item_clicked(), gui2::tchat_log::view::next_page(), gui2::tmp_change_control::view::pre_show(), gui2::tchat_log::view::pre_show(), gui2::tchat_log::view::previous_page(), gui2::tscrollbar_::recalculate(), gui2::tlistbox::set_row_shown(), gui2::twidget::set_visible(), show(), show_non_modal(), gui2::tlobby_main::show_preferences_button_callback(), show_tooltip(), signal_handler_request_placement(), signal_handler_sdl_video_resize(), gui2::tlobby_player_info::update_relation(), gui2::tcustom_tod::update_tod_display(), and gui2::tlobby_main::user_dialog_callback().
Definition at line 1394 of file window.cpp.
References event_distributor_.
Referenced by gui2::tdialog::init_fields(), gui2::tlistbox::list_item_clicked(), gui2::tscroll_label::signal_handler_left_button_down(), gui2::ttree_view::signal_handler_left_button_down(), gui2::ttext_box::signal_handler_left_button_down(), and gui2::tslider::signal_handler_left_button_up().
|
private |
Layouts the window.
This part does the pre and post processing for the actual layout algorithm.
See Layout algorithm for more information.
Definition at line 1013 of file window.cpp.
References _(), game_logic::map_formula_callable::add(), automatic_placement_, click_dismiss_, gui2::tcontrol::config(), gui2::event::connect_signal_mouse_left_click(), gui2::tcontainer_::disable_click_dismiss(), functions_, generate_dot_file(), gui2::twidget::get_best_size(), gui2::get_mouse_position(), gui2::get_screen_size_variables(), h_, gui2::tgrid::HORIZONTAL_ALIGN_CENTER, gui2::tgrid::HORIZONTAL_ALIGN_LEFT, gui2::tgrid::HORIZONTAL_ALIGN_RIGHT, horizontal_placement_, gui2::event::init_mouse_location(), gui2::twidget::tvisible::invisible, gui2::twindow_implementation::layout(), gui2::tcontainer_::layout_initialise(), layout_linked_widgets(), gui2::log_gui_layout, log_scope2, LOG_SCOPE_HEADER, maximum_height_, maximum_width_, need_layout_, OK, gui2::tcontainer_::place(), reevaluate_best_size_, gui2::settings::screen_height, gui2::settings::screen_width, set_retval(), gui2::twidget::set_visible(), VALIDATE, variables_, gui2::tgrid::VERTICAL_ALIGN_BOTTOM, gui2::tgrid::VERTICAL_ALIGN_CENTER, gui2::tgrid::VERTICAL_ALIGN_TOP, vertical_placement_, gui2::twidget::tvisible::visible, w_, gui2::tpoint::x, x_, gui2::tpoint::y, and y_.
Referenced by draw(), and gui2::twindow_implementation::layout().
|
private |
Layouts the linked widgets.
See Layout algorithm for more information.
Definition at line 1194 of file window.cpp.
References linked_size_, gui2::tpoint::x, and gui2::tpoint::y.
Referenced by gui2::twindow_implementation::layout(), layout(), and gui2::tpane::signal_handler_request_placement().
void gui2::twindow::mouse_capture | ( | const bool | capture = true | ) |
Definition at line 1388 of file window.cpp.
References event_distributor_.
Referenced by gui2::tbutton::signal_handler_left_button_down(), gui2::trepeating_button::signal_handler_left_button_down(), gui2::tcombobox::signal_handler_left_button_down(), gui2::ttext_box::signal_handler_left_button_down(), gui2::tscrollbar_::signal_handler_left_button_down(), and gui2::tscrollbar_::signal_handler_left_button_up().
Remove the widget from the keyboard chain.
widget | The widget to be removed from the chain. |
Definition at line 1406 of file window.cpp.
References event_distributor_.
void gui2::twindow::remove_linked_widget | ( | const std::string & | id, |
const twidget * | widget | ||
) |
Removes a widget from a linked size group.
The group needs to exist, which is done by calling init_linked_size_group. If the widget is no member of the group the function does nothing.
id | The id of the group. |
widget | The widget to remove from the group. |
Definition at line 995 of file window.cpp.
References gui2::event::find(), has_linked_size_group(), gui2::twidget::id(), and linked_size_.
|
inline |
Definition at line 434 of file window.hpp.
References click_dismiss(), and click_dismiss_.
Referenced by gui2::build(), and gui2::ttitle_screen::pre_show().
|
inline |
Disable the enter key.
This is added to block dialogs from being closed automatically.
Definition at line 345 of file window.hpp.
References enter_disabled_.
Referenced by gui2::ttitle_screen::pre_show().
|
inline |
Disable the escape key.
This is added to block dialogs from being closed automatically.
Definition at line 358 of file window.hpp.
References escape_disabled_.
Referenced by gui2::ttitle_screen::pre_show().
Definition at line 429 of file window.hpp.
References owner_.
Sets there return value of the window.
retval | The return value for the window. |
close_window | Close the window after setting the value. |
Definition at line 422 of file window.hpp.
References close(), and retval_.
Referenced by gui2::tformula_debugger::callback_continue_button(), gui2::tformula_debugger::callback_next_button(), gui2::tformula_debugger::callback_step_button(), gui2::tformula_debugger::callback_stepout_button(), click_dismiss(), gui2::event::thandler::handle_event(), gui2::tdrop_down_list::item_change_callback(), layout(), gui2::tbutton::signal_handler_left_button_click(), gui2::tcombobox::signal_handler_left_button_click(), gui2::ttoggle_button::signal_handler_left_button_double_click(), gui2::ttoggle_panel::signal_handler_left_button_double_click(), and signal_handler_sdl_key_down().
|
inlinestatic |
Definition at line 439 of file window.hpp.
References sunset_.
Referenced by events::console_handler::do_sunset().
|
inline |
Definition at line 449 of file window.hpp.
References game_logic::map_formula_callable::add(), gui2::twidget::set_is_dirty(), and variables_.
Referenced by gui2::tdrop_down_list::pre_show().
int gui2::twindow::show | ( | const bool | restore = true , |
const unsigned | auto_close_timeout = 0 |
||
) |
Shows the window.
the show functions are a bit messy and can use a proper cleanup.
restore | Restore the screenarea the window was on after closing it? |
auto_close_timeout | The time in ms after which the window will automatically close, if 0 it doesn't close. |
Helper class to set and restore the drawing interval.
We need to make sure we restore the value when the function ends, be it normally or due to an exception.
In the future the restoring shouldn't be needed so the duplication doesn't hurt too much but keep this todo as a reminder.
Definition at line 592 of file window.cpp.
References CLOSE_WINDOW_EVENT, draw(), generate_dot_file(), gui2::twidget::get_rectangle(), CVideo::getSurface(), invalidate_layout(), gui2::log_gui_draw, log_scope2, LOG_SCOPE_HEADER, modal, mouse_button_state_, NEW, events::pump(), gui2::tip::remove(), REQUEST_CLOSE, restore_, restorer_, retval_, sdl_blit(), show_mode_, SHOWING, status_, suspend_drawing_, font::undraw_floating_labels(), update_rect(), update_screen_size(), and video_.
void gui2::twindow::show_non_modal | ( | ) |
Shows the window non modal.
A tooltip can be interacted with unlike the tooltip.
auto_close_timeout
.auto_close_timeout
The time in ms after which the window will automatically close, if 0 it doesn't close.
Definition at line 569 of file window.cpp.
References generate_dot_file(), gui2::event::tdispatcher::hit, invalidate_layout(), gui2::log_gui_draw, log_scope2, modal, NEW, events::pump(), gui2::event::tdispatcher::set_mouse_behavior(), show_mode_, status_, and suspend_drawing_.
Referenced by gui2::tpopup::show().
void gui2::twindow::show_tooltip | ( | ) |
Shows the window as a tooltip.
A tooltip can't be interacted with and is just shown.
auto_close_timeout
.auto_close_timeout
The time in ms after which the window will automatically close, if 0 it doesn't close.
Definition at line 547 of file window.cpp.
References generate_dot_file(), invalidate_layout(), gui2::log_gui_draw, log_scope2, NEW, gui2::event::tdispatcher::none, gui2::event::tdispatcher::set_mouse_behavior(), gui2::event::tdispatcher::set_want_keyboard_input(), show_mode_, status_, suspend_drawing_, and gui2::tcontrol::tooltip().
Referenced by gui2::tpopup::show().
|
private |
The handler for the click dismiss mouse 'event'.
event | See event::tdispatcher::fire. |
handled | See event::tdispatcher::fire. |
halt | See event::tdispatcher::fire. |
mouse_button_mask | Forwared to click_dismiss. |
Definition at line 1427 of file window.cpp.
References click_dismiss(), DBG_GUI_E, and LOG_HEADER.
Referenced by twindow().
|
private |
Definition at line 1475 of file window.cpp.
References DBG_GUI_E, helptip_, gui2::twindow_builder::tresolution::ttip::id, LOG_HEADER, gui2::tip::show(), and video_.
Referenced by twindow().
|
private |
Definition at line 1461 of file window.cpp.
References DBG_GUI_E, gui2::twindow_builder::tresolution::ttip::id, LOG_HEADER, gui2::tip::show(), tooltip_, and video_.
Referenced by twindow().
|
private |
Definition at line 1489 of file window.cpp.
References DBG_GUI_E, invalidate_layout(), and LOG_HEADER.
Referenced by twindow().
|
private |
Definition at line 1438 of file window.cpp.
References CANCEL, click_dismiss(), DBG_GUI_E, enter_disabled_, escape_disabled_, LOG_HEADER, OK, and set_retval().
Referenced by twindow().
|
private |
Definition at line 1412 of file window.cpp.
References DBG_GUI_E, gui2::settings::gamemap_height, gui2::settings::gamemap_width, invalidate_layout(), LOG_HEADER, gui2::settings::screen_height, gui2::settings::screen_width, gui2::tpoint::x, and gui2::tpoint::y.
Referenced by twindow().
void gui2::twindow::undraw | ( | ) |
Undraws the window.
Definition at line 917 of file window.cpp.
References gui2::twidget::get_rectangle(), CVideo::getSurface(), restore_, restorer_, sdl_blit(), update_rect(), and video_.
Referenced by gui2::tloadscreen::close(), gui2::tpopup::hide(), and gui2::tcustom_tod::update_tod_display().
|
static |
Update the size of the screen variables in settings.
Before a window gets build the screen sizes need to be updated. This function does that. It's only done when no other window is active, if another window is active it already updates the sizes with it's resize event.
Definition at line 459 of file window.cpp.
References gui2::settings::gamemap_height, gui2::settings::gamemap_width, gui2::settings::gamemap_x_offset, display::get_singleton(), display::map_outside_area(), screen_area(), gui2::settings::screen_height, and gui2::settings::screen_width.
Referenced by gui2::get_window_builder(), gui2::load_settings(), and show().
|
inline |
Definition at line 411 of file window.hpp.
References video_.
Referenced by gui2::tpreferences::add_friend_list_entry(), gui2::tpreferences::add_hotkey_callback(), gui2::tpreferences::default_hotkey_callback(), gui2::teditor_generate_map::do_settings(), gui2::tgamestate_inspector::view::handle_lua_button_clicked(), gui2::taddon_connect::help_button_callback(), gui2::launch_lua_console(), gui2::tpreferences::on_advanced_prefs_list_select(), gui2::ttitle_screen::post_build(), gui2::tlobby_main::post_build(), gui2::tmp_connect::pre_show(), gui2::tunit_attack::profile_button_callback(), gui2::tpreferences::remove_friend_list_entry(), gui2::tunit_recruit::show_help(), gui2::taddon_list::show_help(), and gui2::tlobby_main::user_dialog_callback().
|
static |
Returns the instance of a window.
handle | The instance id of the window. |
Definition at line 454 of file window.cpp.
Referenced by gui2::event::thandler::handle_event().
|
friend |
Builds a window.
Definition at line 74 of file window_builder.cpp.
|
friend |
Definition at line 64 of file window.hpp.
|
friend |
Definition at line 67 of file window.hpp.
|
friend |
Definition at line 68 of file window.hpp.
|
friend |
Definition at line 66 of file window.hpp.
|
private |
Do we wish to place the widget automatically?
Definition at line 514 of file window.hpp.
Referenced by layout().
|
private |
Do we want to have easy close behavior?
Easy closing means that whenever a mouse click is done the dialog will be closed. The widgets in the window may override this behavior by registering themselves as blockers. This is tested by the function disable_click_dismiss().
The handling of easy close is done in the window, in order to do so a window either needs a click_dismiss or an ok button. Both will be hidden when not needed and when needed first the ok is tried and then the click_dismiss button. this allows adding a click_dismiss button to the window definition and use the ok from the window instance.
Definition at line 579 of file window.hpp.
Referenced by does_click_dismiss(), layout(), and set_click_dismiss().
|
private |
The list with dirty items in the window.
When drawing only the widgets that are dirty are updated. The draw() function has more information about the dirty_list_.
Definition at line 679 of file window.hpp.
Referenced by add_to_dirty_list(), and draw().
|
private |
Disable the enter key see our setter for more info.
Definition at line 582 of file window.hpp.
Referenced by set_enter_disabled(), and signal_handler_sdl_key_down().
|
private |
Disable the escape key see our setter for more info.
Definition at line 585 of file window.hpp.
Referenced by set_escape_disabled(), and signal_handler_sdl_key_down().
|
private |
Definition at line 702 of file window.hpp.
Referenced by add_to_keyboard_chain(), keyboard_capture(), mouse_capture(), remove_from_keyboard_chain(), twindow(), and ~twindow().
|
private |
The formula definitions available for the calulation formulas.
Definition at line 554 of file window.hpp.
Referenced by layout().
|
private |
The formula to calulate the height of the dialog.
Definition at line 548 of file window.hpp.
Referenced by layout().
|
private |
The settings for the helptip.
Definition at line 560 of file window.hpp.
Referenced by signal_handler_message_show_helptip().
|
private |
Sets the horizontal placement.
Only used if automatic_placement_ is true. The value should be a tgrid placement flag.
Definition at line 522 of file window.hpp.
Referenced by layout().
|
private |
Is invalidate layout blocked see tinvalidate_layout_blocker.
Definition at line 502 of file window.hpp.
Referenced by invalidate_layout(), and gui2::twindow::tinvalidate_layout_blocker::tinvalidate_layout_blocker().
|
private |
List of the widgets, whose size are linked together.
Definition at line 621 of file window.hpp.
Referenced by add_linked_widget(), get_linked_size(), has_linked_size_group(), init_linked_size_group(), layout_linked_widgets(), and remove_linked_widget().
|
private |
The maximum height if automatic_placement_ is true.
Definition at line 536 of file window.hpp.
Referenced by layout().
|
private |
The maximum width if automatic_placement_ is true.
Definition at line 533 of file window.hpp.
Referenced by layout().
|
private |
The state of the mouse button.
When click dismissing a dialogue in the past the DOWN event was used. This lead to a bug [1]. The obvious change was to switch to the UP event, this lead to another bug; the dialogue was directly dismissed. Since the game map code uses the UP and DOWN event to select a unit there is no simple solution.
Upon entry this value stores the mouse button state at entry. When a button is DOWN and goes UP that button does not trigger a dismissal of the dialogue, instead that button's down state is removed from this variable. Therefore the next UP event does dismiss the dialogue.
[1] https://gna.org/bugs/index.php?18970
Definition at line 668 of file window.hpp.
Referenced by click_dismiss(), and show().
|
private |
When set the form needs a full layout redraw cycle.
This happens when either a widget changes it's size or visibility or the window is resized.
Definition at line 496 of file window.hpp.
Referenced by draw(), get_need_layout(), invalidate_layout(), and layout().
|
private |
The dialog that owns the window.
Definition at line 488 of file window.hpp.
Referenced by dialog(), and set_owner().
|
private |
The formula to determine whether the size is good.
Definition at line 551 of file window.hpp.
Referenced by layout().
|
private |
Whether the window should undraw the window using restorer_.
Definition at line 508 of file window.hpp.
|
private |
When the window closes this surface is used to undraw the window.
Definition at line 511 of file window.hpp.
|
private |
Definition at line 485 of file window.hpp.
Referenced by set_retval(), and show().
|
private |
The mode in which the window is shown.
This is used to determine whether or not to remove the tip.
Definition at line 482 of file window.hpp.
Referenced by show(), show_non_modal(), show_tooltip(), and ~twindow().
|
private |
The status of the window.
Definition at line 469 of file window.hpp.
Referenced by close(), show(), show_non_modal(), and show_tooltip().
|
staticprivate |
Controls the sunset feature.
If this value is not 0 it will darken the entire screen every sunset_th drawing request that nothing has been modified. It's a debug feature.
Definition at line 594 of file window.hpp.
Referenced by draw(), and set_sunset().
|
private |
Avoid drawing the window.
Definition at line 505 of file window.hpp.
Referenced by draw(), show(), show_non_modal(), and show_tooltip().
|
private |
The settings for the tooltip.
Definition at line 557 of file window.hpp.
Referenced by signal_handler_message_show_tooltip().
|
private |
The variables of the canvas.
Definition at line 499 of file window.hpp.
Referenced by layout(), and set_variable().
|
private |
Sets the vertical placement.
Only used if automatic_placement_ is true. The value should be a tgrid placement flag.
Definition at line 530 of file window.hpp.
Referenced by layout().
|
private |
Needed so we can change what's drawn on the screen.
Definition at line 466 of file window.hpp.
Referenced by draw(), show(), signal_handler_message_show_helptip(), signal_handler_message_show_tooltip(), undraw(), and video().
|
private |
The formula to calulate the width of the dialog.
Definition at line 545 of file window.hpp.
Referenced by layout().
|
private |
The formula to calulate the x value of the dialog.
Definition at line 539 of file window.hpp.
Referenced by layout().
|
private |
The formula to calulate the y value of the dialog.
Definition at line 542 of file window.hpp.
Referenced by layout().