Base class for all visible items. More...
#include <control.hpp>
Public Member Functions | |
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... | |
virtual void | set_active (const bool active)=0 |
Sets the control's state. More... | |
virtual bool | get_active () const =0 |
Gets the active state of the control. More... | |
bool | disable_click_dismiss () const override |
See twidget::disable_click_dismiss. More... | |
virtual iterator::twalker_ * | create_walker () override |
See twidget::create_walker. 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... | |
virtual void | layout_initialise (const bool full_initialisation) override |
See twidget::layout_initialise. More... | |
virtual void | request_reduce_width (const unsigned maximum_width) override |
See twidget::request_reduce_width. More... | |
virtual void | place (const tpoint &origin, const tpoint &size) override |
See twidget::place. 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... | |
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... | |
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 |
virtual const std::string & | get_control_type () const =0 |
Returns the control_type of the control. More... | |
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 () |
virtual void | demand_reduce_width (const unsigned maximum_width) |
Tries to reduce the width of a widget. More... | |
virtual void | request_reduce_height (const unsigned maximum_height) |
Tries to reduce the height of a widget. More... | |
virtual void | demand_reduce_height (const unsigned maximum_height) |
Tries to reduce the height of a widget. More... | |
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 bool | can_wrap () const |
Can the widget wrap. More... | |
virtual void | set_origin (const tpoint &origin) |
Sets the origin of the 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... | |
virtual void | layout_children () |
Allows a widget to update its children. 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... | |
virtual void | set_visible_rectangle (const SDL_Rect &rectangle) |
Sets the visible rectangle for a 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) |
virtual bool | has_widget (const twidget &widget) const |
Does the widget contain the widget. More... | |
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... | |
Protected Member Functions | |
virtual unsigned | get_state () const =0 |
Returns the id of the state. More... | |
virtual tpoint | calculate_best_size () const override |
See twidget::calculate_best_size. More... | |
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... | |
virtual void | impl_draw_background (surface &frame_buffer, int x_offset, int y_offset) override |
See twidget::impl_draw_background. More... | |
virtual void | impl_draw_foreground (surface &frame_buffer, int x_offset, int y_offset) override |
See twidget::impl_draw_foreground. 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 |
Private Member Functions | |
void | load_config () |
Loads the configuration of the widget. More... | |
virtual void | load_config_extra () |
Load class dependent config settings. More... | |
void | definition_load_configuration (const std::string &control_type) |
Loads the configuration of the widget. More... | |
tpoint | get_best_text_size (const tpoint &minimum_size, const tpoint &maximum_size=tpoint(0, 0)) const |
Gets the best size for a text. More... | |
void | signal_handler_show_tooltip (const event::tevent event, bool &handled, const tpoint &location) |
void | signal_handler_show_helptip (const event::tevent event, bool &handled, const tpoint &location) |
void | signal_handler_notify_remove_tooltip (const event::tevent event, bool &handled) |
Private Attributes | |
std::string | definition_ |
The definition is the id of that widget class. More... | |
t_string | label_ |
Contain the non-editable text associated with control. More... | |
bool | use_markup_ |
Use markup for the label? More... | |
bool | use_tooltip_on_label_overflow_ |
If the text doesn't fit on the label should the text be used as tooltip? More... | |
t_string | tooltip_ |
Tooltip text. More... | |
t_string | help_message_ |
Tooltip text. More... | |
std::vector< tcanvas > | canvas_ |
Holds all canvas objects for a control. More... | |
tresolution_definition_ptr | config_ |
Contains the pointer to the configuration. More... | |
font::ttext | renderer_ |
Contains a helper cache for the rendering. More... | |
int | text_maximum_width_ |
The maximum width for the text in a control. More... | |
PangoAlignment | text_alignment_ |
The alignment of the text in a control. More... | |
bool | shrunken_ |
Is the widget smaller as it's best size? More... | |
Friends | |
class | tdebug_layout_graph |
class | twindow |
Uses the load function. More... | |
Additional Inherited Members | |
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... | |
Base class for all visible items.
Definition at line 34 of file control.hpp.
|
explicit |
Definition at line 46 of file control.cpp.
References signal_handler_notify_remove_tooltip(), signal_handler_show_helptip(), and signal_handler_show_tooltip().
gui2::tcontrol::tcontrol | ( | const implementation::tbuilder_control & | builder, |
const unsigned | canvas_count, | ||
const std::string & | control_type | ||
) |
Constructor.
builder | The builder object with the settings for the object. |
canvas_count | The number of canvasses in the control. |
Definition at line 70 of file control.cpp.
References definition_load_configuration(), signal_handler_notify_remove_tooltip(), signal_handler_show_helptip(), and signal_handler_show_tooltip().
|
overrideprotectedvirtual |
See twidget::calculate_best_size.
Implements gui2::twidget.
Reimplemented in gui2::tmatrix, gui2::tscrollbar_container, gui2::tcontainer_, gui2::timage, gui2::tspacer, gui2::tdrawing, and gui2::tslider.
Definition at line 229 of file control.cpp.
References config_, DBG_GUI_L, gui2::debug_truncate(), t_string::empty(), get_best_text_size(), get_config_default_size(), get_config_maximum_size(), label_, and LOG_HEADER.
Referenced by gui2::tslider::calculate_best_size(), gui2::tdrawing::calculate_best_size(), and gui2::tspacer::calculate_best_size().
|
inline |
Definition at line 282 of file control.hpp.
References canvas_.
Referenced by gui2::implementation::tbuilder_drawing::build(), definition_load_configuration(), gui2::tpanel::impl_draw_background(), impl_draw_background(), gui2::tpanel::impl_draw_foreground(), lua_gui2::intf_set_dialog_canvas(), gui2::tscrollbar_::load_config_extra(), place(), gui2::ttitle_screen::pre_show(), gui2::twml_message_::pre_show(), gui2::tprogress_bar::set_percentage(), gui2::ttoggle_button::update_canvas(), gui2::ttext_box::update_canvas(), gui2::tslider::update_canvas(), gui2::tscrollbar_::update_canvas(), update_canvas(), gui2::ttext_box::update_offsets(), and gui2::tdebug_clock::update_time().
|
inline |
Definition at line 286 of file control.hpp.
References canvas_.
|
inlineprotected |
Definition at line 299 of file control.hpp.
References config_.
Referenced by gui2::tpanel::border_space(), gui2::ttoggle_panel::border_space(), gui2::build(), gui2::implementation::tbuilder_scrollbar_panel::build(), gui2::implementation::tbuilder_unit_preview_pane::build(), gui2::implementation::tbuilder_scroll_label::build(), gui2::implementation::tbuilder_stacked_widget::build(), gui2::implementation::tbuilder_tree_view::build(), gui2::implementation::tbuilder_multi_page::build(), gui2::implementation::tbuilder_listbox::build(), gui2::implementation::tbuilder_horizontal_listbox::build(), gui2::tslider::calculate_best_size(), definition_load_configuration(), gui2::ttoggle_panel::get_client_rect(), gui2::twindow::layout(), load_config(), gui2::tlabel::load_config_extra(), gui2::ttext_box::load_config_extra(), gui2::tvertical_scrollbar::maximum_positioner_length(), gui2::thorizontal_scrollbar::maximum_positioner_length(), gui2::tslider::maximum_positioner_length(), gui2::tslider::minimum_positioner_length(), gui2::ttoggle_button::num_states(), gui2::ttoggle_panel::num_states(), gui2::tvertical_scrollbar::offset_after(), gui2::thorizontal_scrollbar::offset_after(), gui2::tslider::offset_after(), gui2::tvertical_scrollbar::offset_before(), gui2::thorizontal_scrollbar::offset_before(), gui2::tslider::offset_before(), set_config(), set_definition(), gui2::ttoggle_panel::set_state(), gui2::tmatrix::tmatrix(), and gui2::ttext_box::update_offsets().
|
inlineprotected |
Definition at line 303 of file control.hpp.
References config_.
|
overridevirtual |
Implements gui2::twidget.
Reimplemented in gui2::tmatrix, and gui2::tcontainer_.
Definition at line 144 of file control.cpp.
|
private |
Loads the configuration of the widget.
Controls have their definition stored in a definition object. In order to determine sizes and drawing the widget this definition needs to be loaded. The member definition_ contains the name of the definition and function load the proper configuration.
Definition at line 423 of file control.cpp.
References canvas(), config(), definition_, gui2::get_control(), i, LOG_GUI_L, set_config(), and update_canvas().
Referenced by load_config(), and tcontrol().
|
overridevirtual |
See twidget::disable_click_dismiss.
The default behavior is that a widget blocks easy close, if not it should override this function.
Implements gui2::twidget.
Reimplemented in gui2::tmatrix, gui2::tscrollbar_container, gui2::timage, gui2::tspacer, gui2::tdrawing, gui2::tlabel, gui2::tminimap, and gui2::tprogress_bar.
Definition at line 139 of file control.cpp.
References get_active(), gui2::twidget::get_visible(), and gui2::twidget::tvisible::visible.
Referenced by gui2::tcontainer_::disable_click_dismiss().
|
overridevirtual |
See twidget::find.
Reimplemented from gui2::twidget.
Reimplemented in gui2::twindow, gui2::tmatrix, and gui2::tscrollbar_container.
Definition at line 301 of file control.cpp.
References gui2::twidget::find(), and get_active().
Referenced by gui2::tcontainer_::find().
|
overridevirtual |
See twidget::find.
Reimplemented from gui2::twidget.
Reimplemented in gui2::twindow, gui2::tmatrix, and gui2::tscrollbar_container.
Definition at line 309 of file control.cpp.
References gui2::twidget::find(), and get_active().
|
overridevirtual |
See twidget::find_at.
Reimplemented from gui2::twidget.
Reimplemented in gui2::twindow, gui2::tmatrix, gui2::tscrollbar_container, gui2::tcontainer_, and gui2::ttoggle_panel.
Definition at line 284 of file control.cpp.
References gui2::twidget::find_at(), and get_active().
Referenced by gui2::ttoggle_panel::find_at().
|
overridevirtual |
See twidget::find_at.
Reimplemented from gui2::twidget.
Reimplemented in gui2::twindow, gui2::tmatrix, gui2::tscrollbar_container, gui2::tcontainer_, and gui2::ttoggle_panel.
Definition at line 292 of file control.cpp.
References gui2::twidget::find_at(), and get_active().
|
pure virtual |
Gets the active state of the control.
Implemented in gui2::tmulti_page, gui2::tscrollbar_container, gui2::tscrollbar_, gui2::tcontrol_NEW< STATE >, gui2::timage, gui2::tunit_preview_pane, gui2::ttoggle_panel, gui2::tscroll_label, gui2::trepeating_button, gui2::tspacer, gui2::tscrollbar_panel, gui2::tdrawing, gui2::ttext_, gui2::tpanel, gui2::tlabel, gui2::tminimap, gui2::tstacked_widget, gui2::ttoggle_button, gui2::tbutton, gui2::tprogress_bar, and gui2::tcombobox.
Referenced by disable_click_dismiss(), find(), find_at(), gui2::policy::placement::tvertical_list::handle_key_down_arrow(), gui2::policy::placement::thorizontal_list::handle_key_left_arrow(), gui2::policy::placement::thorizontal_list::handle_key_right_arrow(), gui2::policy::placement::tvertical_list::handle_key_up_arrow(), gui2::event::tmouse_motion::mouse_leave(), gui2::tcontainer_::set_active(), gui2::event::tdistributor::signal_handler_sdl_key_down(), and gui2::tfield_::widget_set_enabled().
|
private |
Gets the best size for a text.
minimum_size | The minimum size of the text. |
maximum_size | The wanted maximum size of the text, if not possible it's ignored. A value of 0 means that it's ignored as well. |
Definition at line 442 of file control.cpp.
References gui2::twidget::can_wrap(), config_, DBG_GUI_L, gui2::debug_truncate(), t_string::empty(), get_characters_per_line(), get_link_aware(), get_link_color(), font::ttext::get_size(), font::ttext::is_truncated(), label_, gui2::log_gui_layout, LOG_HEADER, log_scope2, LOG_SCOPE_HEADER, renderer_, font::ttext::set_alignment(), font::ttext::set_characters_per_line(), font::ttext::set_ellipse_mode(), font::ttext::set_family_class(), font::ttext::set_font_size(), font::ttext::set_font_style(), font::ttext::set_link_aware(), font::ttext::set_link_color(), font::ttext::set_maximum_width(), font::ttext::set_text(), text_alignment_, text_maximum_width_, use_markup_, WRN_GUI_L, gui2::tpoint::x, and gui2::tpoint::y.
Referenced by calculate_best_size(), and request_reduce_width().
|
virtual |
Returns the number of characters per line.
This value is used to call ttext::set_characters_per_line (indirectly).
Reimplemented in gui2::tlabel.
Definition at line 179 of file control.cpp.
Referenced by get_best_text_size(), and update_canvas().
tpoint gui2::tcontrol::get_config_default_size | ( | ) | const |
Gets the default size as defined in the config.
Definition at line 159 of file control.cpp.
References config_, DBG_GUI_L, and LOG_HEADER.
Referenced by calculate_best_size().
tpoint gui2::tcontrol::get_config_maximum_size | ( | ) | const |
Gets the best size as defined in the config.
Definition at line 169 of file control.cpp.
References config_, DBG_GUI_L, and LOG_HEADER.
Referenced by calculate_best_size(), and gui2::tgrid::tchild::place().
tpoint gui2::tcontrol::get_config_minimum_size | ( | ) | const |
Gets the minimum size as defined in the config.
Definition at line 149 of file control.cpp.
References config_, DBG_GUI_L, and LOG_HEADER.
Referenced by gui2::tcontainer_::calculate_best_size().
|
pure virtual |
Returns the control_type of the control.
The control_type parameter for tgui_definition::get_control() To keep the code more generic this type is required so the controls need to return the proper string here. Might be used at other parts as well the get the type of control involved.
Implemented in gui2::twindow, gui2::tscrollbar_container, gui2::tlistbox, gui2::ttext_box, gui2::tmatrix, gui2::tslider, gui2::ttoggle_panel, gui2::tmulti_page, gui2::ttree_view, gui2::ttoggle_button, gui2::tcombobox, gui2::tlabel, gui2::tminimap, gui2::tstacked_widget, gui2::trepeating_button, gui2::tbutton, gui2::tscroll_label, gui2::timage, gui2::tunit_preview_pane, gui2::tpassword_box, gui2::tdrawing, gui2::tspacer, gui2::tprogress_bar, gui2::thorizontal_scrollbar, gui2::tvertical_scrollbar, gui2::tpanel, and gui2::tscrollbar_panel.
Referenced by load_config(), and gui2::twidget::set_id().
|
protected |
Definition at line 567 of file control.cpp.
References font::ttext::get_link(), and renderer_.
Referenced by gui2::tlabel::signal_handler_left_button_click(), and gui2::tlabel::signal_handler_right_button_click().
|
protected |
Exposes font::ttext::get_token, for the text label of this control.
Definition at line 562 of file control.cpp.
References font::ttext::get_token(), and renderer_.
|
virtual |
Returns whether the label should be link_aware, in in rendering and in searching for links with get_link.
This value is used to call ttext::set_link_aware (indirectly).
Reimplemented in gui2::tlabel.
Definition at line 184 of file control.cpp.
Referenced by get_best_text_size(), and update_canvas().
|
virtual |
Returns the color string to be used with links.
This value is used to call ttext::set_link_color (indirectly).
Reimplemented in gui2::tlabel.
Definition at line 189 of file control.cpp.
Referenced by get_best_text_size(), and update_canvas().
|
protectedpure virtual |
Returns the id of the state.
The current state is also the index canvas_.
Implemented in gui2::tmulti_page, gui2::tscrollbar_container, gui2::tscrollbar_, gui2::tcontrol_NEW< STATE >, gui2::timage, gui2::tunit_preview_pane, gui2::ttoggle_panel, gui2::tscroll_label, gui2::trepeating_button, gui2::tspacer, gui2::tscrollbar_panel, gui2::tdrawing, gui2::ttext_, gui2::tpanel, gui2::tlabel, gui2::tminimap, gui2::tstacked_widget, gui2::ttoggle_button, gui2::tbutton, gui2::tprogress_bar, and gui2::tcombobox.
Referenced by impl_draw_background().
|
inline |
Definition at line 293 of file control.hpp.
References text_alignment_.
|
protected |
Returns the maximum height available for the text.
This value makes sense after the widget has been given a size, since the maximum height is based on the height of the widget.
Definition at line 396 of file control.cpp.
References config_, and gui2::twidget::get_height().
Referenced by gui2::ttext_box::place(), gui2::ttext_box::update_canvas(), and update_canvas().
|
protected |
Returns the maximum width available for the text.
This value makes sense after the widget has been given a size, since the maximum width is based on the width of the widget.
Definition at line 388 of file control.cpp.
References config_, gui2::twidget::get_width(), and text_maximum_width_.
Referenced by gui2::ttext_box::place(), gui2::ttext_box::update_canvas(), and update_canvas().
|
inline |
Definition at line 255 of file control.hpp.
References use_markup_.
Referenced by gui2::tcombobox::signal_handler_left_button_click().
|
inline |
Definition at line 239 of file control.hpp.
References use_tooltip_on_label_overflow_.
|
inline |
Definition at line 271 of file control.hpp.
References help_message_.
Referenced by set_help_message().
|
overrideprotectedvirtual |
See twidget::impl_draw_background.
Reimplemented from gui2::twidget.
Reimplemented in gui2::tmulti_page, gui2::ttoggle_panel, gui2::tminimap, gui2::tspacer, and gui2::tpanel.
Definition at line 403 of file control.cpp.
References gui2::twidget::calculate_blitting_rectangle(), canvas(), DBG_GUI_D, gui2::debug_truncate(), gui2::twidget::get_rectangle(), get_state(), label_, and LOG_HEADER.
Referenced by gui2::ttoggle_panel::impl_draw_background().
|
overrideprotectedvirtual |
See twidget::impl_draw_foreground.
Reimplemented from gui2::twidget.
Reimplemented in gui2::ttoggle_panel, and gui2::tpanel.
Definition at line 414 of file control.cpp.
Referenced by gui2::ttoggle_panel::impl_draw_foreground().
|
inline |
Definition at line 248 of file control.hpp.
References label_.
Referenced by gui2::tlobby_main::append_to_chatbox(), gui2::tsub_player_list::auto_hide(), gui2::tgame_load::filter_text_changed(), gui2::tunit_create::filter_text_changed(), gui2::tscroll_label::finalize_subclass(), gui2::timage::get_image(), gui2::tgamestate_inspector::controller::handle_copy_button_clicked(), gui2::tfield< T, W, CT >::save(), and set_label().
|
overridevirtual |
See twidget::layout_initialise.
Reimplemented from gui2::twidget.
Reimplemented in gui2::tmatrix, gui2::tscrollbar_container, and gui2::tcontainer_.
Definition at line 194 of file control.cpp.
References gui2::twidget::layout_initialise(), and shrunken_.
Referenced by gui2::tcontainer_::layout_initialise().
|
private |
Loads the configuration of the widget.
Controls have their definition stored in a definition object. In order to determine sizes and drawing the widget this definition needs to be loaded. The member definition_ contains the name of the definition and function load the proper configuration.
Definition at line 274 of file control.cpp.
References config(), definition_load_configuration(), get_control_type(), and load_config_extra().
Referenced by set_definition(), and gui2::twindow::twindow().
|
inlineprivatevirtual |
Load class dependent config settings.
load_config will call this method after loading the config, by default it does nothing but classes can override it to implement custom behavior.
Reimplemented in gui2::tscrollbar_, gui2::ttext_box, and gui2::tlabel.
Definition at line 405 of file control.hpp.
Referenced by load_config().
See twidget::place.
Reimplemented from gui2::twidget.
Reimplemented in gui2::tlistbox, gui2::ttext_box, gui2::tmatrix, gui2::tscrollbar_container, gui2::tscrollbar_, and gui2::tcontainer_.
Definition at line 250 of file control.cpp.
References canvas(), canvas_, t_string::empty(), font::ttext::is_truncated(), label_, gui2::twidget::place(), renderer_, set_tooltip(), tooltip_, update_canvas(), use_tooltip_on_label_overflow_, gui2::tpoint::x, and gui2::tpoint::y.
Referenced by gui2::tcontainer_::place(), gui2::tscrollbar_::place(), and gui2::ttext_box::place().
|
overridevirtual |
See twidget::request_reduce_width.
Implements gui2::twidget.
Reimplemented in gui2::tmatrix, gui2::tscrollbar_container, and gui2::tcontainer_.
Definition at line 204 of file control.cpp.
References gui2::twidget::can_wrap(), config_, DBG_GUI_L, gui2::debug_truncate(), t_string::empty(), get_best_text_size(), label_, LOG_HEADER, gui2::twidget::set_layout_size(), gui2::tpoint::x, and gui2::tpoint::y.
|
pure virtual |
Sets the control's state.
Sets the control in the active state, when inactive a control can't be used and doesn't react to events. (Note read-only for a ttext_ is a different state.)
Implemented in gui2::tcontainer_, gui2::tscrollbar_, gui2::tcontrol_NEW< STATE >, gui2::timage, gui2::tunit_preview_pane, gui2::ttoggle_panel, gui2::trepeating_button, gui2::tspacer, gui2::tdrawing, gui2::ttext_, gui2::tlabel, gui2::tminimap, gui2::ttoggle_button, gui2::tbutton, gui2::tprogress_bar, and gui2::tcombobox.
Referenced by lua_gui2::intf_set_dialog_active(), gui2::tgrid::set_active(), gui2::tscrollbar_container::set_scrollbar_button_status(), and gui2::tfield_::widget_set_enabled().
|
inlineprotected |
Definition at line 308 of file control.hpp.
References config(), and config_.
Referenced by definition_load_configuration().
void gui2::tcontrol::set_definition | ( | const std::string & | definition | ) |
Sets the definition.
This function sets the definition of a control and should be called soon after creating the object since a lot of internal functions depend on the definition.
This function should be called one time only!!!
Definition at line 318 of file control.cpp.
References config(), definition_, gui2::init(), and load_config().
Referenced by gui2::tscrollbar_container::finalize_setup(), gui2::implementation::tbuilder_control::init_control(), gui2::tpreferences::initialize_members(), and gui2::twindow::twindow().
Definition at line 276 of file control.hpp.
References help_message(), and help_message_.
Referenced by gui2::implementation::tbuilder_control::init_control(), and set_members().
Reimplemented in gui2::tscroll_label.
Definition at line 330 of file control.cpp.
References label(), label_, gui2::twidget::set_is_dirty(), gui2::twidget::set_layout_size(), and update_canvas().
Referenced by gui2::tsub_player_list::auto_hide(), gui2::tpreferences::bind_status_label(), gui2::tchat_log::model::clear_chat_msg_list(), gui2::tscroll_label::finalize_subclass(), gui2::tsynced_choice_wait::handle_generic_event(), gui2::tmessage_implementation::init_button(), gui2::implementation::tbuilder_control::init_control(), lua_gui2::intf_set_dialog_value(), gui2::tpreferences::max_autosaves_slider_callback(), gui2::taddon_list::on_addon_select(), gui2::tchat_log::model::populate_chat_message_list(), gui2::tsynced_choice_wait::pre_show(), gui2::tlua_interpreter::pre_show(), gui2::tcampaign_selection::pre_show(), gui2::tnetwork_transmission::pre_show(), gui2::tgame_version::pre_show(), gui2::tsimple_item_selector::pre_show(), gui2::tmessage::pre_show(), gui2::twml_message_::pre_show(), gui2::tfield< T, W, CT >::restore(), gui2::tunit_preview_pane::set_displayed_type(), gui2::tgamestate_inspector::model::set_inspect_window_text(), gui2::tscroll_label::set_label(), set_members(), gui2::tcombobox::set_selected(), gui2::tcombobox::set_values(), gui2::tgamestate_inspector::controller::show_title(), gui2::tcombobox::signal_handler_left_button_click(), gui2::tpreferences::status_label_callback(), gui2::tloadscreen::timer_callback(), gui2::tgame_cache_options::update_cache_size_display(), gui2::tlobby_player_info::update_relation(), gui2::tcustom_tod::update_selected_tod_info(), and gui2::tchat_log::controller::update_view_from_model().
|
virtual |
Sets the members of the control.
The map contains named members it can set, controls inheriting from us can add additional members to set by this function. The following members can by the following key:
data | Map with the key value pairs to set the members. |
Reimplemented in gui2::ttoggle_button.
Definition at line 99 of file control.cpp.
References gui2::decode_text_alignment(), itor, set_help_message(), gui2::twidget::set_id(), set_label(), gui2::twidget::set_linked_group(), set_text_alignment(), set_tooltip(), set_use_markup(), and utils::string_bool().
Referenced by gui2::tpane::create_item(), gui2::policy::select_action::tshow::init(), gui2::ttree_view_node::init_grid(), gui2::ttoggle_panel::set_child_members(), and gui2::ttoggle_button::set_members().
void gui2::tcontrol::set_text_alignment | ( | const PangoAlignment | text_alignment | ) |
Definition at line 353 of file control.cpp.
References gui2::twidget::set_is_dirty(), text_alignment_, and update_canvas().
Referenced by gui2::implementation::tbuilder_label::build(), and set_members().
Definition at line 265 of file control.hpp.
References t_string::empty(), gui2::tevent_executor::set_wants_mouse_hover(), tooltip(), and tooltip_.
Referenced by gui2::tchat_log::view::bind(), gui2::tgamestate_inspector::view::bind(), gui2::implementation::tbuilder_control::init_control(), place(), gui2::tmp_alerts_options::pre_show(), gui2::tscreenshot_notification::pre_show(), gui2::tgame_cache_options::pre_show(), gui2::twml_error::pre_show(), and set_members().
|
virtual |
Reimplemented in gui2::tscroll_label.
Definition at line 342 of file control.cpp.
References gui2::twidget::set_is_dirty(), update_canvas(), and use_markup_.
Referenced by gui2::tpreferences::initialize_members(), lua_gui2::intf_set_dialog_markup(), gui2::tlabel_settings::pre_show(), gui2::tnetwork_transmission::pre_show(), gui2::tmessage::pre_show(), gui2::twml_message_::pre_show(), gui2::set_attacker_info(), gui2::set_defender_info(), gui2::tunit_preview_pane::set_displayed_type(), set_members(), gui2::tscroll_label::set_use_markup(), gui2::tpreferences::setup_combobox(), and gui2::tchat_log::controller::update_view_from_model().
|
inline |
Definition at line 243 of file control.hpp.
References use_tooltip_on_label_overflow_.
Referenced by gui2::implementation::tbuilder_control::init_control().
|
private |
Definition at line 547 of file control.cpp.
References DBG_GUI_E, LOG_HEADER, and gui2::tip::remove().
Referenced by tcontrol().
|
private |
Definition at line 535 of file control.cpp.
References DBG_GUI_E, t_string::empty(), gui2::event::tdispatcher::fire(), help_message_, LOG_HEADER, and gui2::event::MESSAGE_SHOW_HELPTIP.
Referenced by tcontrol().
|
private |
Definition at line 512 of file control.cpp.
References DBG_GUI_E, t_string::empty(), gui2::event::tdispatcher::fire(), hotkey::hotkey_command::get_command_by_command(), hotkey::get_names(), hotkey::GLOBAL__HELPTIP, gui2::settings::has_helptip_message, help_message_, utils::interpolate_variables_into_string(), LOG_HEADER, gui2::event::MESSAGE_SHOW_TOOLTIP, gui2::tip::tip(), and tooltip_.
Referenced by tcontrol().
|
inline |
Definition at line 260 of file control.hpp.
References tooltip_.
Referenced by set_tooltip(), and gui2::twindow::show_tooltip().
|
protectedvirtual |
Updates the canvas(ses).
This function should be called if either the size of the widget changes or the text on the widget changes.
Reimplemented in gui2::tscrollbar_, gui2::tslider, gui2::ttext_box, and gui2::ttoggle_button.
Definition at line 364 of file control.cpp.
References gui2::twidget::can_wrap(), canvas(), canvas_, gui2::encode_text_alignment(), get_characters_per_line(), get_link_aware(), get_link_color(), get_text_maximum_height(), get_text_maximum_width(), label_, text_alignment_, and use_markup_.
Referenced by definition_load_configuration(), gui2::ttext_::insert_char(), gui2::ttext_::paste_selection(), place(), gui2::ttext_::set_cursor(), set_label(), gui2::tlabel::set_link_aware(), gui2::tlabel::set_link_color(), gui2::ttext_::set_maximum_length(), set_text_alignment(), set_use_markup(), gui2::ttext_::set_value(), and gui2::ttoggle_button::update_canvas().
|
friend |
Definition at line 36 of file control.hpp.
|
friend |
Uses the load function.
Definition at line 209 of file control.hpp.
|
private |
Holds all canvas objects for a control.
A control can have multiple states, which are defined in the classes inheriting from us. For every state there is a separate canvas, which is stored here. When drawing the state is determined and that canvas is drawn.
Definition at line 386 of file control.hpp.
Referenced by canvas(), place(), and update_canvas().
|
private |
Contains the pointer to the configuration.
Every control has a definition of how it should look, this contains a pointer to the definition. The definition is resolution dependent, where the resolution is the size of the Wesnoth application window. Depending on the resolution widgets can look different, use different fonts. Windows can use extra scrollbars use abbreviations as text etc.
Definition at line 397 of file control.hpp.
Referenced by calculate_best_size(), config(), get_best_text_size(), get_config_default_size(), get_config_maximum_size(), get_config_minimum_size(), get_text_maximum_height(), get_text_maximum_width(), request_reduce_width(), and set_config().
|
private |
The definition is the id of that widget class.
Eg for a button it [button_definition]id. A button can have multiple definitions which all look different but for the engine still is a button.
Definition at line 347 of file control.hpp.
Referenced by definition_load_configuration(), and set_definition().
|
private |
Tooltip text.
The help event can cause a tooltip to be shown, this is the text to be shown. At the moment the tooltip is a single line of text.
Definition at line 376 of file control.hpp.
Referenced by help_message(), set_help_message(), signal_handler_show_helptip(), and signal_handler_show_tooltip().
|
private |
Contain the non-editable text associated with control.
Definition at line 350 of file control.hpp.
Referenced by calculate_best_size(), get_best_text_size(), impl_draw_background(), label(), place(), request_reduce_width(), set_label(), and update_canvas().
|
mutableprivate |
Contains a helper cache for the rendering.
Creating a ttext object is quite expensive and is done on various occasions so it's cached here.
Definition at line 485 of file control.hpp.
Referenced by get_best_text_size(), get_label_link(), get_label_token(), and place().
|
private |
Is the widget smaller as it's best size?
Definition at line 494 of file control.hpp.
Referenced by layout_initialise().
|
private |
The alignment of the text in a control.
Definition at line 491 of file control.hpp.
Referenced by get_best_text_size(), get_text_alignment(), set_text_alignment(), and update_canvas().
|
private |
The maximum width for the text in a control.
Definition at line 488 of file control.hpp.
Referenced by get_best_text_size(), and get_text_maximum_width().
|
private |
Tooltip text.
The hovering event can cause a small tooltip to be shown, this is the text to be shown. At the moment the tooltip is a single line of text.
Definition at line 368 of file control.hpp.
Referenced by place(), set_tooltip(), signal_handler_show_tooltip(), and tooltip().
|
private |
Use markup for the label?
Definition at line 353 of file control.hpp.
Referenced by get_best_text_size(), get_use_markup(), set_use_markup(), and update_canvas().
|
private |
If the text doesn't fit on the label should the text be used as tooltip?
This only happens if the tooltip is empty.
Definition at line 360 of file control.hpp.
Referenced by get_use_tooltip_on_label_overflow(), place(), and set_use_tooltip_on_label_overflow().