#include <styled_widget.hpp>
Public Member Functions | |
styled_widget (const implementation::builder_styled_widget &builder, const std::string &control_type) | |
Constructor. More... | |
virtual void | set_members (const widget_item &data) |
Sets the members of the styled_widget. More... | |
virtual void | set_active (const bool active)=0 |
Sets the styled_widget's state. More... | |
virtual bool | get_active () const =0 |
Gets the active state of the styled_widget. More... | |
bool | disable_click_dismiss () const override |
See widget::disable_click_dismiss. More... | |
virtual iteration::walker_ptr | create_walker () override |
See widget::create_walker. More... | |
point | get_config_minimum_size () const |
Gets the minimum size as defined in the config. More... | |
point | get_config_default_size () const |
Gets the default size as defined in the config. More... | |
point | 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 color_t | get_link_color () const |
Returns the color string to be used with links. More... | |
virtual void | layout_initialize (const bool full_initialization) override |
See widget::layout_initialize. More... | |
virtual void | request_reduce_width (const unsigned maximum_width) override |
See widget::request_reduce_width. More... | |
virtual void | request_reduce_height (const unsigned maximum_height) override |
See widget::request_reduce_height. More... | |
virtual void | place (const point &origin, const point &size) override |
See widget::place. More... | |
virtual widget * | find_at (const point &coordinate, const bool must_be_active) override |
See widget::find_at. More... | |
virtual const widget * | find_at (const point &coordinate, const bool must_be_active) const override |
See widget::find_at. More... | |
widget * | find (const std::string &id, const bool must_be_active) override |
See widget::find. More... | |
const widget * | find (const std::string &id, const bool must_be_active) const override |
See widget::find. More... | |
bool | get_use_tooltip_on_label_overflow () const |
void | set_use_tooltip_on_label_overflow (const bool use_tooltip=true) |
const t_string & | get_label () const |
virtual void | set_label (const t_string &text) |
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< canvas > & | get_canvases () |
canvas & | get_canvas (const unsigned index) |
virtual void | set_text_alignment (const PangoAlignment text_alignment) |
PangoAlignment | get_text_alignment () const |
void | set_text_ellipse_mode (const PangoEllipsizeMode ellipse_mode) |
PangoEllipsizeMode | get_text_ellipse_mode () const |
Get the text's ellipsize mode. More... | |
void | set_text_maximum_width (int max_width) |
Set how wide the text can become. More... | |
virtual const std::string & | get_control_type () const =0 |
Returns the type of this styled_widget. More... | |
Public Member Functions inherited from gui2::widget | |
widget (const widget &)=delete | |
widget & | operator= (const widget &)=delete |
widget () | |
widget (const builder_widget &builder) | |
Constructor. More... | |
virtual | ~widget () override |
void | set_id (const std::string &id) |
const std::string & | id () const |
window * | get_window () |
Get the parent window. More... | |
const window * | get_window () const |
The constant version of get_window. More... | |
grid * | get_parent_grid () |
Get the parent grid. More... | |
const grid * | get_parent_grid () const |
void | set_parent (widget *parent) |
widget * | parent () |
virtual void | demand_reduce_width (const unsigned maximum_width) |
Tries to reduce the width of a widget. More... | |
virtual void | demand_reduce_height (const unsigned maximum_height) |
Tries to reduce the height of a widget. More... | |
point | 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 point &origin) |
Sets the origin of the widget. More... | |
virtual void | set_size (const point &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 | set_horizontal_alignment (const std::string &alignment) |
Sets the horizontal alignment of the widget within its parent grid. More... | |
virtual void | set_vertical_alignment (const std::string &alignment) |
Sets the horizontal alignment of the widget within its parent grid. More... | |
virtual void | layout_children () |
Allows a widget to update its children. More... | |
point | get_origin () const |
Returns the screen origin of the widget. More... | |
point | get_size () const |
Returns the size of the widget. More... | |
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 |
Calculates the blitting rectangle of the widget. More... | |
SDL_Rect | calculate_clipping_rectangle () const |
Calculates the clipping rectangle of the widget. More... | |
bool | draw_background () |
Draws the background of a widget. More... | |
void | draw_children () |
Draws the children of a widget. More... | |
bool | draw_foreground () |
Draws the foreground of the widget. 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 | queue_redraw () |
Indicates that this widget should be redrawn. More... | |
void | queue_redraw (const rect ®ion) |
Indicate that specific region of the screen should be redrawn. More... | |
void | set_visible (const visibility visible) |
visibility | get_visible () const |
redraw_action | get_drawing_action () const |
void | set_debug_border_mode (const debug_border debug_border_mode) |
void | set_debug_border_color (const color_t debug_border_color) |
virtual bool | has_widget (const widget &widget) const |
Does the widget contain the widget. More... | |
template<class T > | |
NOT_DANGLING T * | find_widget (const std::string &id, const bool must_be_active, const bool must_exist) |
Gets a widget with the wanted id. More... | |
template<class T > | |
NOT_DANGLING const T * | find_widget (const std::string &id, const bool must_be_active, const bool must_exist) const |
template<class T > | |
NOT_DANGLING T & | find_widget (const std::string &id, const bool must_be_active=false) |
Gets a widget with the wanted id. More... | |
template<class T > | |
NOT_DANGLING const T & | find_widget (const std::string &id, const bool must_be_active=false) const |
Public Member Functions inherited from gui2::event_executor | |
event_executor () | |
virtual | ~event_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 |
event_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::dispatcher | |
dispatcher () | |
virtual | ~dispatcher () |
void | connect () |
Connects the dispatcher to the event handler. More... | |
void | disconnect () |
Disconnects the dispatcher from the event handler. More... | |
bool | is_connected () const |
Return whether the dispatcher is currently connected. More... | |
bool | has_event (const ui_event event, const event_queue_type event_type) |
bool | fire (const ui_event event, widget &target) |
Fires an event which has no extra parameters. More... | |
bool | fire (const ui_event event, widget &target, const point &coordinate) |
Fires an event which takes a coordinate parameter. More... | |
bool | fire (const ui_event event, widget &target, const SDL_Keycode key, const SDL_Keymod modifier, const std::string &unicode) |
Fires an event which takes keyboard parameters. More... | |
bool | fire (const ui_event event, widget &target, const point &pos, const point &distance) |
Fires an event which takes touch-motion parameters. More... | |
bool | fire (const ui_event event, widget &target, const point ¢er, float dTheta, float dDist, uint8_t numFingers) |
Fires an event which takes touch-gesture parameters. More... | |
bool | fire (const ui_event event, widget &target, void *) |
Fires an event which takes notification parameters. More... | |
bool | fire (const ui_event event, widget &target, const message &msg) |
Fires an event which takes message parameters. More... | |
bool | fire (const ui_event event, widget &target, const SDL_Event &sdlevent) |
Fires an event that's a raw SDL event. More... | |
bool | fire (const ui_event event, widget &target, const std::string &text, int32_t start, int32_t len) |
Fires an event which takes text input parameters. More... | |
template<ui_event E, typename F > | |
void | connect_signal (const F &func, const queue_position position=back_child) |
Adds a callback to the appropriate queue based on event type. More... | |
template<ui_event E, typename F > | |
void | disconnect_signal (const F &func, const queue_position position=back_child) |
Removes a callback from the appropriate queue based on event type. More... | |
void | capture_mouse () |
Captures the mouse. More... | |
void | release_mouse () |
Releases the mouse capture. More... | |
void | set_mouse_behavior (const mouse_behavior mouse_behavior) |
mouse_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 hotkey_function &function) |
Registers a hotkey. More... | |
bool | execute_hotkey (const hotkey::HOTKEY_COMMAND id) |
Executes a hotkey. More... | |
Public Member Functions inherited from enable_lua_ptr< widget > | |
enable_lua_ptr (widget *tp) | |
Protected Member Functions | |
virtual unsigned | get_state () const =0 |
Returns the id of the state. More... | |
virtual point | calculate_best_size () const override |
See widget::calculate_best_size. More... | |
resolution_definition_ptr | get_config () |
resolution_definition_const_ptr | get_config () const |
template<typename T > | |
std::shared_ptr< const typename T::resolution > | cast_config_to () const |
Casts the current resolution definition config to the respective type of a derived widget. More... | |
void | set_config (resolution_definition_ptr config) |
virtual void | update_canvas () |
Updates the canvas(ses). More... | |
unsigned int | get_text_font_size () const |
Resolves and returns the text_font_size. 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 bool | impl_draw_background () override |
See widget::impl_draw_background. More... | |
virtual bool | impl_draw_foreground () override |
See widget::impl_draw_foreground. More... | |
std::string | get_label_token (const point &position, const char *delimiters=" \n\r\t") const |
Exposes font::pango_text::get_token, for the text label of this styled_widget. More... | |
std::string | get_label_link (const point &position) const |
Protected Member Functions inherited from gui2::widget | |
void | set_layout_size (const point &size) |
const point & | layout_size () const |
void | clear_layout_size () |
Throws away layout_size_. More... | |
Private Member Functions | |
point | get_best_text_size (point minimum_size, point maximum_size={0, 0}) const |
Gets the best size for a text. More... | |
virtual bool | text_can_shrink () |
Gets whether a widget can shrink past its optimal size even if it's text-based (such as labels);. More... | |
void | signal_handler_show_tooltip (const event::ui_event event, bool &handled, const point &location) |
void | signal_handler_show_helptip (const event::ui_event event, bool &handled, const point &location) |
void | signal_handler_notify_remove_tooltip (const event::ui_event 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 styled_widget. 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... | |
resolution_definition_ptr | config_ |
Contains the pointer to the configuration. More... | |
unsigned int | cached_text_font_size_ = 0 |
Contains the evaluated text_font_size from the configuration. More... | |
std::vector< canvas > | canvases_ |
Holds all canvas objects for a styled_widget. More... | |
font::pango_text | renderer_ |
Text renderer object used for size calculations. More... | |
int | text_maximum_width_ |
The maximum width for the text in a styled_widget. More... | |
PangoAlignment | text_alignment_ |
The alignment of the text in a styled_widget. More... | |
PangoEllipsizeMode | text_ellipse_mode_ |
The ellipsize mode of the text in a styled_widget. More... | |
bool | shrunken_ |
Is the widget smaller as it's best size? More... | |
Friends | |
class | debug_layout_graph |
Additional Inherited Members | |
Public Types inherited from gui2::widget | |
enum class | visibility { visible , hidden , invisible } |
Visibility settings done by the user. More... | |
enum class | redraw_action { full , partly , none } |
Visibility set by the engine. More... | |
enum class | debug_border { none , outline , fill } |
Public Types inherited from gui2::event::dispatcher | |
enum | event_queue_type { pre = 1 , child = 2 , post = 4 } |
enum | queue_position { 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 class | mouse_behavior { all , hit , none } |
The behavior of the mouse events. More... | |
Definition at line 34 of file styled_widget.hpp.
gui2::styled_widget::styled_widget | ( | const implementation::builder_styled_widget & | builder, |
const std::string & | control_type | ||
) |
Constructor.
builder | The builder object with the settings for the object. |
control_type | The type of control to be built. |
Definition at line 46 of file styled_widget.cpp.
References canvases_, config_, t_string::empty(), i, gui2::event_executor::set_wants_mouse_hover(), signal_handler_notify_remove_tooltip(), signal_handler_show_helptip(), signal_handler_show_tooltip(), tooltip_, and update_canvas().
|
overrideprotectedvirtual |
See widget::calculate_best_size.
Implements gui2::widget.
Reimplemented in gui2::spacer, gui2::slider, gui2::size_lock, gui2::scrollbar_container, gui2::scroll_text, gui2::rich_label, gui2::matrix, gui2::listbox, gui2::image, gui2::drawing, and gui2::container_base.
Definition at line 243 of file styled_widget.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_, LOG_HEADER, and t_string::str().
Referenced by gui2::drawing::calculate_best_size(), gui2::rich_label::calculate_best_size(), gui2::slider::calculate_best_size(), and gui2::spacer::calculate_best_size().
|
inlineprotected |
Casts the current resolution definition config to the respective type of a derived widget.
T | The definition type to cast to. Should have a resolution subclass or struct derived from resolution_definition. |
Definition at line 301 of file styled_widget.hpp.
References get_config().
Referenced by gui2::implementation::builder_scrollbar_panel::build().
|
overridevirtual |
Implements gui2::widget.
Reimplemented in gui2::scrollbar_container, gui2::matrix, and gui2::container_base.
Definition at line 134 of file styled_widget.cpp.
|
overridevirtual |
See widget::disable_click_dismiss.
The default behavior is that a widget blocks easy close, if not it should override this function.
Implements gui2::widget.
Definition at line 129 of file styled_widget.cpp.
References get_active(), gui2::widget::get_visible(), and gui2::widget::visible.
Referenced by gui2::container_base::disable_click_dismiss().
|
overridevirtual |
See widget::find.
Reimplemented from gui2::widget.
Reimplemented in gui2::window.
Definition at line 312 of file styled_widget.cpp.
References gui2::widget::find(), and get_active().
|
overridevirtual |
See widget::find.
Reimplemented from gui2::widget.
Reimplemented in gui2::window.
Definition at line 304 of file styled_widget.cpp.
References gui2::widget::find(), and get_active().
Referenced by gui2::container_base::find().
|
overridevirtual |
See widget::find_at.
Reimplemented from gui2::widget.
Reimplemented in gui2::window, gui2::toggle_panel, gui2::scrollbar_container, gui2::matrix, and gui2::container_base.
Definition at line 295 of file styled_widget.cpp.
References gui2::widget::find_at(), and get_active().
|
overridevirtual |
See widget::find_at.
Reimplemented from gui2::widget.
Reimplemented in gui2::window, gui2::toggle_panel, gui2::scrollbar_container, gui2::matrix, and gui2::container_base.
Definition at line 287 of file styled_widget.cpp.
References gui2::widget::find_at(), and get_active().
Referenced by gui2::toggle_panel::find_at().
|
pure virtual |
Gets the active state of the styled_widget.
Implemented in gui2::unit_preview_pane, gui2::toggle_panel, gui2::toggle_button, gui2::text_box_base, gui2::tab_container, gui2::stacked_widget, gui2::spinner, gui2::spacer, gui2::slider_base, gui2::size_lock, gui2::scrollbar_panel, gui2::scrollbar_container, gui2::scrollbar_base, gui2::scroll_text, gui2::scroll_label, gui2::rich_label, gui2::repeating_button, gui2::progress_bar, gui2::panel, gui2::multimenu_button, gui2::multi_page, gui2::minimap, gui2::menu_button, gui2::control_NEW< STATE >, gui2::label, gui2::image, gui2::drawing, gui2::chatbox, gui2::button, and gui2::addon_list.
Referenced by disable_click_dismiss(), find(), find_at(), gui2::policy::placement::vertical_list::handle_key_down_arrow(), gui2::policy::placement::table::handle_key_down_arrow(), gui2::policy::placement::horizontal_list::handle_key_left_arrow(), gui2::policy::placement::table::handle_key_left_arrow(), gui2::policy::placement::horizontal_list::handle_key_right_arrow(), gui2::policy::placement::table::handle_key_right_arrow(), gui2::policy::placement::vertical_list::handle_key_up_arrow(), gui2::policy::placement::table::handle_key_up_arrow(), gui2::event::mouse_motion::mouse_leave(), gui2::container_base::set_active(), gui2::event::distributor::signal_handler_keyboard_internal(), and gui2::field_base::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 450 of file styled_widget.cpp.
References border, gui2::widget::can_wrap(), config_, DBG_GUI_L, gui2::debug_truncate(), t_string::empty(), get_characters_per_line(), get_link_aware(), get_link_color(), font::pango_text::get_size(), get_text_ellipse_mode(), get_text_font_size(), font::pango_text::is_truncated(), label_, gui2::log_gui_layout, LOG_HEADER, log_scope2, LOG_SCOPE_HEADER, draw::point(), renderer_, font::pango_text::set_alignment(), font::pango_text::set_characters_per_line(), font::pango_text::set_ellipse_mode(), font::pango_text::set_family_class(), font::pango_text::set_font_size(), font::pango_text::set_font_style(), font::pango_text::set_link_aware(), font::pango_text::set_link_color(), font::pango_text::set_maximum_width(), font::pango_text::set_text(), utf8::size(), t_string::str(), text_alignment_, text_maximum_width_, use_markup_, and WRN_GUI_L.
Referenced by calculate_best_size(), and request_reduce_width().
|
inline |
Definition at line 255 of file styled_widget.hpp.
References canvases_, and utf8::index().
Referenced by gui2::dialogs::story_viewer::display_part(), gui2::dialogs::story_viewer::draw_floating_image(), gui2::drawing::get_drawing_canvas(), gui2::panel::impl_draw_background(), impl_draw_background(), gui2::panel::impl_draw_foreground(), gui2::dialogs::title_screen::init_callbacks(), gui2::dialogs::end_credits::pre_show(), gui2::dialogs::outro::pre_show(), gui2::dialogs::wml_message_base::pre_show(), gui2::dialogs::wml_message_double::pre_show(), gui2::dialogs::achievements_dialog::set_achievements_row(), gui2::dialogs::title_screen::show_preferences(), gui2::dialogs::outro::update(), and gui2::dialogs::title_screen::update_static_labels().
|
inline |
Definition at line 250 of file styled_widget.hpp.
References canvases_.
Referenced by gui2::text_box_base::cursor_timer_callback(), gui2::scrollbar_base::finalize_setup(), gui2::slider_base::finalize_setup(), gui2::text_box_base::reset_cursor_state(), gui2::progress_bar::set_percentage(), gui2::combobox::update_canvas(), gui2::label::update_canvas(), gui2::multiline_text::update_canvas(), gui2::rich_label::update_canvas(), gui2::scrollbar_base::update_canvas(), gui2::slider::update_canvas(), gui2::slider_base::update_canvas(), gui2::text_box::update_canvas(), gui2::toggle_button::update_canvas(), gui2::combobox::update_offsets(), gui2::multiline_text::update_offsets(), gui2::text_box::update_offsets(), and gui2::dialogs::debug_clock::update_time().
|
virtual |
Returns the number of characters per line.
This value is used to call pango_text::set_characters_per_line (indirectly).
Reimplemented in gui2::rich_label, and gui2::label.
Definition at line 169 of file styled_widget.cpp.
Referenced by get_best_text_size(), and update_canvas().
|
inlineprotected |
Definition at line 281 of file styled_widget.hpp.
References config_.
Referenced by cast_config_to(), gui2::container_base::inject_linked_groups(), gui2::toggle_button::num_states(), and gui2::toggle_panel::num_states().
|
inlineprotected |
Definition at line 286 of file styled_widget.hpp.
References config_.
point gui2::styled_widget::get_config_default_size | ( | ) | const |
Gets the default size as defined in the config.
Definition at line 149 of file styled_widget.cpp.
References config_, DBG_GUI_L, and LOG_HEADER.
Referenced by gui2::container_base::calculate_best_size(), gui2::image::calculate_best_size(), and calculate_best_size().
point gui2::styled_widget::get_config_maximum_size | ( | ) | const |
Gets the best size as defined in the config.
Definition at line 159 of file styled_widget.cpp.
References config_, DBG_GUI_L, and LOG_HEADER.
Referenced by gui2::image::calculate_best_size(), calculate_best_size(), and gui2::grid::child::place().
point gui2::styled_widget::get_config_minimum_size | ( | ) | const |
Gets the minimum size as defined in the config.
Definition at line 139 of file styled_widget.cpp.
References config_, DBG_GUI_L, and LOG_HEADER.
Referenced by request_reduce_height(), and request_reduce_width().
|
pure virtual |
Returns the type of this styled_widget.
This is used as the control_type parameter for get_control.
Do note that each widget also must have a public static type() function; it's use to implement this function. The reason for this system is twofold:
1) Due to an oddity in C++, one technically may not call a virtual function in a derived class's initializer list, which we do liberally. Calling it in the constructor body is fine, but doing so in the initializer list is technically undefined behavior and will give "invalid vptr" errors under UBSanitizer.
2) Having a static type getter allows the type string to be fetched without constructing an instance of the widget. A good example of this usecase is in build_single_widget_instance.
Implemented in gui2::window, gui2::vertical_scrollbar, gui2::unit_preview_pane, gui2::tree_view, gui2::toggle_panel, gui2::toggle_button, gui2::text_box, gui2::tab_container, gui2::stacked_widget, gui2::spinner, gui2::spacer, gui2::slider, gui2::size_lock, gui2::scrollbar_panel, gui2::scrollbar_container, gui2::scroll_text, gui2::scroll_label, gui2::rich_label, gui2::repeating_button, gui2::progress_bar, gui2::password_box, gui2::panel, gui2::multimenu_button, gui2::multiline_text, gui2::multi_page, gui2::minimap, gui2::menu_button, gui2::matrix, gui2::listbox, gui2::label, gui2::image, gui2::horizontal_scrollbar, gui2::drawing, gui2::combobox, gui2::chatbox, gui2::button, and gui2::addon_list.
Referenced by gui2::widget::set_id().
|
inline |
Definition at line 212 of file styled_widget.hpp.
References label_.
Referenced by gui2::dialogs::preferences_dialog::add_friend_list_entry(), gui2::image::calculate_best_size(), gui2::dialogs::editor_edit_pbl::create_cfg(), gui2::dialogs::unit_create::filter_text_changed(), gui2::scroll_label::finalize_subclass(), gui2::scroll_text::finalize_subclass(), gui2::image::get_image(), gui2::rich_label::get_label(), gui2::dialogs::editor_choose_addon::post_show(), gui2::dialogs::statistics_dialog::pre_show(), gui2::dialogs::unit_recall::pre_show(), and gui2::addon_list::select_addon().
|
protected |
Definition at line 581 of file styled_widget.cpp.
References font::pango_text::get_link(), and renderer_.
Referenced by gui2::label::signal_handler_left_button_click(), gui2::multiline_text::signal_handler_left_button_down(), gui2::label::signal_handler_mouse_motion(), gui2::multiline_text::signal_handler_mouse_motion(), and gui2::label::signal_handler_right_button_click().
|
protected |
Exposes font::pango_text::get_token, for the text label of this styled_widget.
Definition at line 576 of file styled_widget.cpp.
References font::pango_text::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 pango_text::set_link_aware (indirectly).
Reimplemented in gui2::scroll_text, gui2::rich_label, gui2::multiline_text, and gui2::label.
Definition at line 174 of file styled_widget.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 pango_text::set_link_color (indirectly).
Reimplemented in gui2::rich_label, and gui2::label.
Definition at line 179 of file styled_widget.cpp.
References color_t::from_hex_string().
Referenced by get_best_text_size(), and update_canvas().
|
protectedpure virtual |
Returns the id of the state.
The current state is also the index canvases_.
Implemented in gui2::unit_preview_pane, gui2::toggle_panel, gui2::toggle_button, gui2::text_box_base, gui2::tab_container, gui2::stacked_widget, gui2::spinner, gui2::spacer, gui2::slider_base, gui2::size_lock, gui2::scrollbar_panel, gui2::scrollbar_container, gui2::scrollbar_base, gui2::scroll_text, gui2::scroll_label, gui2::rich_label, gui2::repeating_button, gui2::progress_bar, gui2::panel, gui2::multimenu_button, gui2::multi_page, gui2::minimap, gui2::menu_button, gui2::control_NEW< STATE >, gui2::label, gui2::image, gui2::drawing, gui2::chatbox, gui2::button, and gui2::addon_list.
Referenced by impl_draw_background().
|
inline |
Definition at line 263 of file styled_widget.hpp.
References text_alignment_.
Referenced by gui2::rich_label::default_text_config().
|
inline |
Get the text's ellipsize mode.
Note that if can_wrap is true, it override the manual setting.
Definition at line 275 of file styled_widget.hpp.
References gui2::widget::can_wrap(), and text_ellipse_mode_.
Referenced by get_best_text_size(), and update_canvas().
|
protected |
Resolves and returns the text_font_size.
To allow the text_font_size in the widget definition to be a formula, call this function which will evaluate the formula (caching the result) and return the value.
Definition at line 407 of file styled_widget.cpp.
References cached_text_font_size_, config_, and gui2::get_screen_size_variables().
Referenced by get_best_text_size(), gui2::text_box::text_box(), gui2::combobox::update_offsets(), gui2::multiline_text::update_offsets(), and gui2::text_box::update_offsets().
|
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 425 of file styled_widget.cpp.
References config_, and gui2::widget::get_height().
Referenced by gui2::combobox::place(), gui2::multiline_text::place(), gui2::text_box::place(), update_canvas(), gui2::combobox::update_canvas(), gui2::multiline_text::update_canvas(), and gui2::text_box::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 417 of file styled_widget.cpp.
References config_, gui2::widget::get_width(), and text_maximum_width_.
Referenced by gui2::combobox::place(), gui2::multiline_text::place(), gui2::text_box::place(), update_canvas(), gui2::combobox::update_canvas(), gui2::multiline_text::update_canvas(), and gui2::text_box::update_canvas().
|
inline |
Definition at line 221 of file styled_widget.hpp.
References use_markup_.
Referenced by gui2::text_box_base::copy_selection(), gui2::scroll_label::finalize_subclass(), gui2::scroll_text::finalize_subclass(), gui2::text_box_base::handle_editing(), gui2::text_box_base::handle_key_right_arrow(), gui2::text_box_base::insert_char(), gui2::text_box_base::paste_selection(), gui2::text_box_base::set_value(), and gui2::multiline_text::update_canvas().
|
inline |
Definition at line 202 of file styled_widget.hpp.
References use_tooltip_on_label_overflow_.
|
inline |
Definition at line 238 of file styled_widget.hpp.
References help_message_.
Referenced by set_help_message().
|
overrideprotectedvirtual |
See widget::impl_draw_background.
Reimplemented from gui2::widget.
Reimplemented in gui2::toggle_panel, gui2::spacer, gui2::panel, gui2::multi_page, and gui2::minimap.
Definition at line 432 of file styled_widget.cpp.
References DBG_GUI_D, gui2::debug_truncate(), gui2::canvas::draw(), get_canvas(), gui2::widget::get_rectangle(), get_state(), label_, LOG_HEADER, and t_string::str().
Referenced by gui2::toggle_panel::impl_draw_background().
|
overrideprotectedvirtual |
See widget::impl_draw_foreground.
Reimplemented from gui2::widget.
Reimplemented in gui2::toggle_panel, and gui2::panel.
Definition at line 444 of file styled_widget.cpp.
Referenced by gui2::toggle_panel::impl_draw_foreground().
|
overridevirtual |
See widget::layout_initialize.
Reimplemented from gui2::widget.
Reimplemented in gui2::scrollbar_container, gui2::matrix, and gui2::container_base.
Definition at line 184 of file styled_widget.cpp.
References gui2::widget::layout_initialize(), and shrunken_.
Referenced by gui2::container_base::layout_initialize().
See widget::place.
Reimplemented from gui2::widget.
Reimplemented in gui2::text_box, gui2::slider_base, gui2::size_lock, gui2::scrollbar_container, gui2::scrollbar_base, gui2::scroll_text, gui2::multiline_text, gui2::matrix, gui2::listbox, gui2::container_base, and gui2::combobox.
Definition at line 264 of file styled_widget.cpp.
References canvases_, t_string::empty(), font::pango_text::is_truncated(), label_, gui2::widget::place(), renderer_, gui2::canvas::set_size(), set_tooltip(), utf8::size(), tooltip_, update_canvas(), and use_tooltip_on_label_overflow_.
Referenced by gui2::combobox::place(), gui2::container_base::place(), gui2::multiline_text::place(), gui2::scrollbar_base::place(), gui2::slider_base::place(), and gui2::text_box::place().
|
overridevirtual |
See widget::request_reduce_height.
Reimplemented from gui2::widget.
Reimplemented in gui2::spacer, gui2::scrollbar_container, gui2::drawing, and gui2::container_base.
Definition at line 227 of file styled_widget.cpp.
References DBG_GUI_L, t_string::empty(), gui2::widget::get_best_size(), get_config_minimum_size(), gui2::widget::id(), label_, LOG_HEADER, gui2::dialogs::min_size, gui2::widget::set_layout_size(), and utf8::size().
Referenced by gui2::drawing::request_reduce_height(), and gui2::spacer::request_reduce_height().
|
overridevirtual |
See widget::request_reduce_width.
Implements gui2::widget.
Reimplemented in gui2::spacer, gui2::scrollbar_container, gui2::matrix, gui2::drawing, and gui2::container_base.
Definition at line 194 of file styled_widget.cpp.
References gui2::widget::can_wrap(), config_, DBG_GUI_L, gui2::debug_truncate(), t_string::empty(), gui2::widget::get_best_size(), get_best_text_size(), get_config_minimum_size(), gui2::widget::id(), label_, LOG_HEADER, gui2::dialogs::min_size, draw::point(), gui2::widget::set_layout_size(), utf8::size(), t_string::str(), and text_can_shrink().
Referenced by gui2::drawing::request_reduce_width(), and gui2::spacer::request_reduce_width().
|
pure virtual |
Sets the styled_widget's state.
Sets the styled_widget in the active state, when inactive a styled_widget can't be used and doesn't react to events. (Note read-only for a text_box_base is a different state.)
Implemented in gui2::chatbox, gui2::addon_list, gui2::unit_preview_pane, gui2::toggle_panel, gui2::toggle_button, gui2::text_box_base, gui2::spacer, gui2::slider_base, gui2::scrollbar_base, gui2::rich_label, gui2::repeating_button, gui2::progress_bar, gui2::multimenu_button, gui2::minimap, gui2::menu_button, gui2::control_NEW< STATE >, gui2::label, gui2::image, gui2::drawing, gui2::container_base, and gui2::button.
Referenced by gui2::grid::set_active(), gui2::dialogs::gamestate_inspector::view::update(), and gui2::field_base::widget_set_enabled().
|
inlineprotected |
Definition at line 310 of file styled_widget.hpp.
References config_.
|
inline |
Definition at line 244 of file styled_widget.hpp.
References help_message(), and help_message_.
Referenced by set_members().
|
virtual |
Reimplemented in gui2::rich_label, gui2::scroll_text, and gui2::scroll_label.
Definition at line 321 of file styled_widget.cpp.
References label, label_, draw::point(), gui2::widget::queue_redraw(), renderer_, gui2::widget::set_layout_size(), font::pango_text::set_text(), update_canvas(), and use_markup_.
Referenced by gui2::dialogs::statistics_dialog::add_damage_row(), gui2::dialogs::statistics_dialog::add_hits_row(), gui2::dialogs::preferences_dialog::add_hotkey_callback(), gui2::dialogs::mp_lobby::adjust_game_row_contents(), gui2::bind_status_label(), gui2::dialogs::campaign_selection::campaign_selected(), gui2::dialogs::file_dialog::check_filename(), gui2::dialogs::chat_log::model::clear_chat_msg_list(), gui2::dialogs::gamestate_inspector::view::clear_stuff_list(), gui2::dialogs::story_viewer::display_part(), gui2::dialogs::game_load::display_savegame(), gui2::dialogs::editor_edit_pbl::editor_edit_pbl(), gui2::dialogs::file_progress::file_progress(), gui2::scroll_label::finalize_subclass(), gui2::scroll_text::finalize_subclass(), gui2::dialogs::synched_choice_wait::handle_generic_event(), gui2::dialogs::mp_change_control::highlight_side_nick(), gui2::dialogs::message_implementation::init_button(), gui2::dialogs::preferences_dialog::initialize_callbacks(), gui2::dialogs::loading_screen::layout(), gui2::dialogs::mp_match_history::new_search(), gui2::dialogs::addon_manager::on_addon_select(), gui2::dialogs::mp_create_game::on_game_select(), gui2::dialogs::chat_log::model::populate_chat_message_list(), gui2::dialogs::install_dependencies::pre_show(), gui2::dialogs::campaign_selection::pre_show(), gui2::dialogs::file_dialog::pre_show(), gui2::dialogs::lua_interpreter::pre_show(), gui2::dialogs::message::pre_show(), gui2::dialogs::mp_lobby::pre_show(), gui2::dialogs::mp_join_game::pre_show(), gui2::dialogs::mp_staging::pre_show(), gui2::dialogs::synched_choice_wait::pre_show(), gui2::dialogs::network_transmission::pre_show(), gui2::dialogs::simple_item_selector::pre_show(), gui2::dialogs::statistics_dialog::pre_show(), gui2::dialogs::unit_recall::pre_show(), gui2::dialogs::wml_message_base::pre_show(), gui2::dialogs::preferences_dialog::remove_hotkey_callback(), gui2::dialogs::unit_recall::rename_unit(), gui2::dialogs::achievements_dialog::set_achievements_row(), gui2::dialogs::attack_predictions::set_data(), gui2::unit_preview_pane::set_displayed_type(), gui2::unit_preview_pane::set_displayed_unit(), gui2::image::set_image(), gui2::scroll_label::set_label(), gui2::rich_label::set_label(), set_members(), gui2::menu_button::set_selected(), gui2::rich_label::set_topic(), gui2::multimenu_button::set_values(), gui2::menu_button::set_values(), gui2::dialogs::mp_create_game::show_description(), gui2::dialogs::addon_manager::toggle_details(), gui2::dialogs::tooltip::tooltip(), gui2::dialogs::gamestate_inspector::view::update(), gui2::dialogs::game_cache_options::update_cache_size_display(), gui2::dialogs::mp_create_game::update_details(), gui2::dialogs::mp_match_history::update_display(), gui2::multimenu_button::update_label(), gui2::multiline_text::update_layout(), gui2::dialogs::mp_staging::update_leader_display(), gui2::dialogs::lobby_player_info::update_relation(), gui2::dialogs::chat_log::controller::update_view_from_model(), and gui2::dialogs::mp_lobby::update_visible_games().
|
virtual |
Sets the members of the styled_widget.
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::toggle_button.
Definition at line 89 of file styled_widget.cpp.
References data, gui2::decode_text_alignment(), set_help_message(), gui2::widget::set_id(), set_label(), gui2::widget::set_linked_group(), set_text_alignment(), set_tooltip(), set_use_markup(), and utils::string_bool().
Referenced by gui2::pane::create_item(), gui2::policy::select_action::show::init(), gui2::toggle_panel::set_child_members(), and gui2::toggle_button::set_members().
|
virtual |
Reimplemented in gui2::scroll_text, and gui2::scroll_label.
Definition at line 353 of file styled_widget.cpp.
References gui2::widget::queue_redraw(), text_alignment_, and update_canvas().
Referenced by gui2::dialogs::story_viewer::display_part(), gui2::scroll_label::finalize_subclass(), gui2::scroll_text::finalize_subclass(), set_members(), gui2::scroll_label::set_text_alignment(), and gui2::scroll_text::set_text_alignment().
void gui2::styled_widget::set_text_ellipse_mode | ( | const PangoEllipsizeMode | ellipse_mode | ) |
Definition at line 364 of file styled_widget.cpp.
References gui2::widget::queue_redraw(), text_ellipse_mode_, and update_canvas().
|
inline |
Set how wide the text can become.
If the text is bigger than this limit, it gets wrapped
Definition at line 355 of file styled_widget.hpp.
References text_maximum_width_.
Referenced by gui2::scroll_label::set_text_max_width().
|
inline |
Definition at line 232 of file styled_widget.hpp.
References t_string::empty(), gui2::event_executor::set_wants_mouse_hover(), tooltip(), and tooltip_.
Referenced by gui2::add_name_tree_node(), gui2::dialogs::mp_lobby::adjust_game_row_contents(), gui2::dialogs::mp_create_game::on_era_select(), place(), gui2::dialogs::drop_down_menu::pre_show(), gui2::dialogs::file_dialog::pre_show(), gui2::dialogs::mp_alerts_options::pre_show(), gui2::dialogs::mp_create_game::pre_show(), gui2::unit_preview_pane::print_attack_details(), gui2::unit_preview_pane::set_displayed_type(), gui2::unit_preview_pane::set_displayed_unit(), and set_members().
|
virtual |
Reimplemented in gui2::scroll_label.
Definition at line 342 of file styled_widget.cpp.
References gui2::widget::queue_redraw(), update_canvas(), and use_markup_.
Referenced by gui2::dialogs::mp_staging::add_side_node(), gui2::dialogs::mp_lobby::adjust_game_row_contents(), gui2::chatbox::append_to_chatbox(), gui2::dialogs::editor_edit_pbl::editor_edit_pbl(), gui2::scroll_label::finalize_subclass(), gui2::scroll_text::finalize_subclass(), gui2::field_label::init_specialized(), gui2::dialogs::preferences_dialog::initialize_callbacks(), gui2::dialogs::addon_manager::pre_show(), gui2::dialogs::campaign_selection::pre_show(), gui2::dialogs::file_dialog::pre_show(), gui2::dialogs::game_load::pre_show(), gui2::dialogs::label_settings::pre_show(), gui2::dialogs::message::pre_show(), gui2::dialogs::network_transmission::pre_show(), gui2::dialogs::wml_message_base::pre_show(), gui2::unit_preview_pane::set_displayed_type(), gui2::unit_preview_pane::set_displayed_unit(), set_members(), gui2::scroll_label::set_use_markup(), gui2::dialogs::mp_create_game::show_description(), and gui2::dialogs::chat_log::controller::update_view_from_model().
|
inline |
Definition at line 207 of file styled_widget.hpp.
References use_tooltip_on_label_overflow_.
|
private |
Definition at line 561 of file styled_widget.cpp.
References DBG_GUI_E, LOG_HEADER, and gui2::dialogs::tip::remove().
Referenced by styled_widget().
|
private |
Definition at line 549 of file styled_widget.cpp.
References DBG_GUI_E, t_string::empty(), gui2::event::dispatcher::fire(), gui2::widget::get_rectangle(), help_message_, LOG_HEADER, and gui2::event::MESSAGE_SHOW_HELPTIP.
Referenced by styled_widget().
|
private |
Definition at line 526 of file styled_widget.cpp.
References DBG_GUI_E, t_string::empty(), hotkey::hotkey_command::get_command_by_command(), hotkey::get_names(), hotkey::GLOBAL__HELPTIP, help_message_, LOG_HEADER, gui2::dialogs::tip::tip, and tooltip_.
Referenced by styled_widget().
|
inlineprivatevirtual |
Gets whether a widget can shrink past its optimal size even if it's text-based (such as labels);.
Reimplemented in gui2::rich_label, and gui2::label.
Definition at line 481 of file styled_widget.hpp.
Referenced by request_reduce_width().
|
inline |
Definition at line 226 of file styled_widget.hpp.
References tooltip_.
Referenced by gui2::image::can_mouse_focus(), gui2::label::can_mouse_focus(), gui2::rich_label::can_mouse_focus(), gui2::dialogs::editor_edit_unit::pre_show(), gui2::dialogs::mp_staging::pre_show(), and set_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::toggle_button, gui2::text_box, gui2::slider_base, gui2::slider, gui2::scrollbar_base, gui2::rich_label, gui2::multiline_text, gui2::label, and gui2::combobox.
Definition at line 375 of file styled_widget.cpp.
References canvases_, gui2::encode_text_alignment(), get_characters_per_line(), get_link_aware(), get_link_color(), get_text_ellipse_mode(), get_text_maximum_height(), get_text_maximum_width(), label_, gui2::canvas::set_variable(), text_alignment_, and use_markup_.
Referenced by gui2::text_box_base::handle_editing(), gui2::text_box_base::insert_char(), gui2::text_box_base::paste_selection(), place(), gui2::text_box_base::set_cursor(), gui2::text_box_base::set_editable(), set_label(), gui2::text_box_base::set_maximum_length(), gui2::text_box_base::set_selection(), set_text_alignment(), set_text_ellipse_mode(), set_use_markup(), gui2::text_box_base::set_value(), styled_widget(), gui2::label::update_canvas(), and gui2::toggle_button::update_canvas().
|
friend |
Definition at line 36 of file styled_widget.hpp.
|
mutableprivate |
Contains the evaluated text_font_size from the configuration.
We want to allow formulas in the value of text_font_size, since the desired font size can depend on parameters of the screen and window. But we don't want to have to recompute the value of the formula all the time. This member variable is the cache for the evaluated font size.
Definition at line 419 of file styled_widget.hpp.
Referenced by get_text_font_size().
|
private |
Holds all canvas objects for a styled_widget.
A styled_widget 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 429 of file styled_widget.hpp.
Referenced by get_canvas(), get_canvases(), place(), styled_widget(), and update_canvas().
|
private |
Contains the pointer to the configuration.
Every styled_widget 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 409 of file styled_widget.hpp.
Referenced by calculate_best_size(), get_best_text_size(), get_config(), get_config_default_size(), get_config_maximum_size(), get_config_minimum_size(), get_text_font_size(), get_text_maximum_height(), get_text_maximum_width(), request_reduce_width(), set_config(), and styled_widget().
|
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 369 of file styled_widget.hpp.
|
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 398 of file styled_widget.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 styled_widget.
Definition at line 372 of file styled_widget.hpp.
Referenced by calculate_best_size(), get_best_text_size(), get_label(), impl_draw_background(), place(), request_reduce_height(), request_reduce_width(), gui2::tree_view_node::select_node(), set_label(), gui2::tree_view_node::signal_handler_label_left_button_click(), and update_canvas().
|
mutableprivate |
Text renderer object used for size calculations.
Note this is not used to actually render any text, only to get the dimensions of the text for layout purposes. The actual text rendering happens in the canvas. This is kept as a class member since creating a pango_text object is quite expensive.
Definition at line 498 of file styled_widget.hpp.
Referenced by get_best_text_size(), get_label_link(), get_label_token(), place(), and set_label().
|
private |
Is the widget smaller as it's best size?
Definition at line 510 of file styled_widget.hpp.
Referenced by layout_initialize().
|
private |
The alignment of the text in a styled_widget.
Definition at line 504 of file styled_widget.hpp.
Referenced by get_best_text_size(), get_text_alignment(), set_text_alignment(), and update_canvas().
|
private |
The ellipsize mode of the text in a styled_widget.
Definition at line 507 of file styled_widget.hpp.
Referenced by get_text_ellipse_mode(), and set_text_ellipse_mode().
|
private |
The maximum width for the text in a styled_widget.
Definition at line 501 of file styled_widget.hpp.
Referenced by get_best_text_size(), get_text_maximum_width(), and set_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 390 of file styled_widget.hpp.
Referenced by place(), set_tooltip(), signal_handler_show_tooltip(), styled_widget(), and tooltip().
|
private |
Use markup for the label?
Definition at line 375 of file styled_widget.hpp.
Referenced by get_best_text_size(), get_use_markup(), set_label(), 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 382 of file styled_widget.hpp.
Referenced by get_use_tooltip_on_label_overflow(), place(), and set_use_tooltip_on_label_overflow().