#include <control.hpp>
Public Member Functions | |
tcontrol (const unsigned canvas_count) | |
virtual | ~tcontrol () |
void | mouse_hover (tevent_handler &event) |
Inherted from twidget. | |
void | help_key (tevent_handler &event) |
Inherted from twidget. | |
void | set_size (const SDL_Rect &rect) |
Inherited from twidget. | |
twidget * | find_widget (const tpoint &coordinate, const bool must_be_active) |
Inherited from twidget. | |
const twidget * | find_widget (const tpoint &coordinate, const bool must_be_active) const |
Inherited from twidget. | |
twidget * | find_widget (const std::string &id, const bool must_be_active) |
Inherited from twidget. | |
const twidget * | find_widget (const std::string &id, const bool must_be_active) const |
Inherited from twidget. | |
void | set_visible (const bool visible=true) |
bool | get_visible () const |
void | set_multiline_label (const bool multiline=true) |
void | set_label (const t_string &label) |
const t_string & | label () const |
void | set_tooltip (const t_string &tooltip) |
const t_string & | tooltip () const |
void | set_help_message (const t_string &help_message) |
const t_string & | help_message () const |
std::vector< tcanvas > & | canvas () |
tcanvas & | canvas (const unsigned index) |
void | set_definition (const std::string &definition) |
Inherited from twidget. | |
void | draw (surface &surface) |
Inherited from twidget. | |
virtual void | set_active (const bool active)=0 |
Sets the control in the active state, when inactive a control can't be used and doesn't react to events. | |
virtual bool | get_active () const =0 |
Gets the active state of the control. | |
tpoint | get_minimum_size () const |
Gets the minimum size for the object, 0,0 means no size required. | |
tpoint | get_best_size () const |
Gets the best size for the object, 0,0 means no size required. | |
tpoint | get_maximum_size () const |
Gets the best size for an object, 0,0 means no limits. | |
void | load_config () |
Inherited from twidget. | |
Protected Member Functions | |
virtual unsigned | get_state () const =0 |
Returns the id of the state, which is also the index for the canvas. | |
virtual bool | full_redraw () const |
Does the widget need to restore the surface before (re)painting? | |
virtual void | set_canvas_text () |
Sets the text variable for the canvases. | |
tresolution_definition_ * | config () |
const tresolution_definition_ * | config () const |
void | set_config (tresolution_definition_ *config) |
Private Member Functions | |
tcontrol () | |
tpoint | get_single_line_best_size (const tpoint &config_size) const |
Helpers. | |
tpoint | get_multi_line_best_size (const tpoint &config_size) const |
void | save_background (const surface &src) |
Saves the portion of the background. | |
void | restore_background (surface &dst) |
Restores a portion of the background. | |
virtual void | load_config_extra () |
Once the config is loaded this function is called. | |
virtual const std::string & | get_control_type () const =0 |
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. | |
Private Attributes | |
bool | visible_ |
Visible state of the control, invisible isn't drawn. | |
bool | multiline_label_ |
Can the label contain multiple lines. | |
std::string | wrapped_label_ |
If multiline we need to have a version of the label wrapped to fit in the widget. | |
t_string | label_ |
The label associated with a lot of widgets to show a (non editable) text. | |
t_string | tooltip_ |
When hovering a tooltip with extra information can show up. | |
t_string | help_message_ |
When the user presses help a tooltip with even more info can be shown. | |
std::vector< tcanvas > | canvas_ |
Holds all canvas objects for a control. | |
surface | restorer_ |
Holds a copy of the original background which can be used before redrawing. | |
tresolution_definition_ * | config_ |
Contains a pointer to the configuration of this button at the current resolution. |
Definition at line 28 of file control.hpp.
gui2::tcontrol::tcontrol | ( | ) | [private] |
gui2::tcontrol::tcontrol | ( | const unsigned | canvas_count | ) |
Definition at line 48 of file control.cpp.
virtual gui2::tcontrol::~tcontrol | ( | ) | [inline, virtual] |
Definition at line 35 of file control.hpp.
void gui2::tcontrol::mouse_hover | ( | tevent_handler & | event | ) | [virtual] |
Inherted from twidget.
Reimplemented from gui2::tevent_executor.
Definition at line 61 of file control.cpp.
References DBG_G_E, gui2::settings::popup_show_time, and tooltip_.
void gui2::tcontrol::help_key | ( | tevent_handler & | event | ) | [virtual] |
Inherted from twidget.
Reimplemented from gui2::tevent_executor.
Definition at line 67 of file control.cpp.
References DBG_G_E, help_message_, and gui2::settings::help_show_time.
void gui2::tcontrol::set_size | ( | const SDL_Rect & | rect | ) | [virtual] |
Inherited from twidget.
Reimplemented from gui2::twidget.
Reimplemented in gui2::tcontainer_, gui2::tlistbox, gui2::tscrollbar_, and gui2::ttext_box.
Definition at line 73 of file control.cpp.
References canvas(), canvas_, gui2::tcanvas::set_height(), gui2::twidget::set_size(), gui2::tcanvas::set_width(), and wrapped_label_.
Referenced by gui2::twindow::do_show_help_popup(), gui2::twindow::do_show_tooltip(), gui2::ttext_box::set_size(), gui2::tscrollbar_::set_size(), and gui2::tcontainer_::set_size().
twidget* gui2::tcontrol::find_widget | ( | const tpoint & | coordinate, | |
const bool | must_be_active | |||
) | [inline, virtual] |
Inherited from twidget.
Reimplemented from gui2::twidget.
Reimplemented in gui2::tcontainer_, gui2::tlistbox, gui2::tpanel, and gui2::twindow.
Definition at line 47 of file control.hpp.
References gui2::twidget::find_widget(), and get_active().
Referenced by gui2::tcontainer_::find_widget().
const twidget* gui2::tcontrol::find_widget | ( | const tpoint & | coordinate, | |
const bool | must_be_active | |||
) | const [inline, virtual] |
Inherited from twidget.
Reimplemented from gui2::twidget.
Reimplemented in gui2::tcontainer_, gui2::tlistbox, gui2::tpanel, and gui2::twindow.
Definition at line 54 of file control.hpp.
References gui2::twidget::find_widget(), and get_active().
twidget* gui2::tcontrol::find_widget | ( | const std::string & | id, | |
const bool | must_be_active | |||
) | [inline, virtual] |
Inherited from twidget.
Reimplemented from gui2::twidget.
Reimplemented in gui2::tcontainer_, gui2::tpanel, and gui2::twindow.
Definition at line 62 of file control.hpp.
References gui2::twidget::find_widget(), and get_active().
const twidget* gui2::tcontrol::find_widget | ( | const std::string & | id, | |
const bool | must_be_active | |||
) | const [inline, virtual] |
Inherited from twidget.
Reimplemented from gui2::twidget.
Reimplemented in gui2::tcontainer_, gui2::tpanel, and gui2::twindow.
Definition at line 69 of file control.hpp.
References gui2::twidget::find_widget(), and get_active().
void gui2::tcontrol::set_visible | ( | const bool | visible = true |
) | [inline] |
Definition at line 76 of file control.hpp.
References gui2::twidget::set_dirty(), and visible_.
Referenced by gui2::twindow::do_remove_help_popup(), gui2::twindow::do_remove_tooltip(), gui2::twindow::do_show_help_popup(), gui2::twindow::do_show_tooltip(), and gui2::twindow::twindow().
bool gui2::tcontrol::get_visible | ( | ) | const [inline] |
void gui2::tcontrol::set_multiline_label | ( | const bool | multiline = true |
) | [inline] |
Definition at line 80 of file control.hpp.
References multiline_label_, and gui2::twidget::set_dirty().
Referenced by gui2::ttooltip::ttooltip().
void gui2::tcontrol::set_label | ( | const t_string & | label | ) |
Definition at line 88 of file control.cpp.
References label_, set_canvas_text(), gui2::twidget::set_dirty(), and wrapped_label_.
Referenced by gui2::twindow::do_show_help_popup(), gui2::twindow::do_show_tooltip(), gui2::tbuilder_control::init_control(), and gui2::tlistbox::trow::init_in_grid().
const t_string& gui2::tcontrol::label | ( | ) | const [inline] |
void gui2::tcontrol::set_tooltip | ( | const t_string & | tooltip | ) | [inline] |
Definition at line 88 of file control.hpp.
References t_string::empty(), gui2::tevent_executor::set_wants_mouse_hover(), and tooltip_.
Referenced by gui2::tbuilder_control::init_control().
const t_string& gui2::tcontrol::tooltip | ( | ) | const [inline] |
void gui2::tcontrol::set_help_message | ( | const t_string & | help_message | ) | [inline] |
Definition at line 93 of file control.hpp.
References help_message_.
Referenced by gui2::tbuilder_control::init_control().
const t_string& gui2::tcontrol::help_message | ( | ) | const [inline] |
std::vector<tcanvas>& gui2::tcontrol::canvas | ( | ) | [inline] |
Definition at line 96 of file control.hpp.
References canvas_.
Referenced by gui2::twindow::draw(), gui2::tpanel::draw(), draw(), load_config(), gui2::tscrollbar_::load_config_extra(), gui2::ttext_box::set_canvas_text(), set_canvas_text(), set_size(), gui2::tscrollbar_::update_canvas(), and gui2::ttext_box::update_offsets().
tcanvas& gui2::tcontrol::canvas | ( | const unsigned | index | ) | [inline] |
void gui2::tcontrol::set_definition | ( | const std::string & | definition | ) | [virtual] |
Inherited from twidget.
This function sets the defintion 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!!!
Reimplemented from gui2::twidget.
Definition at line 226 of file control.cpp.
References config(), load_config(), and gui2::twidget::set_definition().
Referenced by gui2::tbuilder_control::init_control(), and gui2::twindow::twindow().
void gui2::tcontrol::draw | ( | surface & | surface | ) | [virtual] |
Inherited from twidget.
Implements gui2::twidget.
Reimplemented in gui2::tcontainer_, gui2::tlistbox, gui2::tpanel, gui2::tspacer, and gui2::twindow.
Definition at line 234 of file control.cpp.
References blit_surface(), canvas(), config_, DBG_G_D, full_redraw(), gui2::twidget::get_rect(), get_state(), gui2::twidget::get_width(), label_, multiline_label_, rect, restore_background(), restorer_, save_background(), gui2::twidget::set_dirty(), gui2::tresolution_definition_::text_font_size, visible_, font::word_wrap_text(), and wrapped_label_.
Referenced by gui2::twindow::draw().
virtual void gui2::tcontrol::set_active | ( | const bool | active | ) | [pure virtual] |
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::tbutton, gui2::tlabel, gui2::tlistbox, gui2::tpanel, gui2::tscrollbar_, gui2::tspacer, gui2::ttext_, gui2::ttoggle_button, gui2::ttooltip, and gui2::twindow.
Referenced by gui2::tgrid::set_active().
virtual bool gui2::tcontrol::get_active | ( | ) | const [pure virtual] |
Gets the active state of the control.
Implemented in gui2::tbutton, gui2::tlabel, gui2::tlistbox, gui2::tpanel, gui2::tscrollbar_, gui2::tspacer, gui2::ttext_, gui2::ttoggle_button, gui2::ttooltip, and gui2::twindow.
Referenced by find_widget().
tpoint gui2::tcontrol::get_minimum_size | ( | ) | const [virtual] |
Gets the minimum size for the object, 0,0 means no size required.
Implements gui2::twidget.
Reimplemented in gui2::tcontainer_.
Definition at line 100 of file control.cpp.
References config_, t_string::empty(), get_multi_line_best_size(), get_single_line_best_size(), label_, gui2::tresolution_definition_::min_height, gui2::tresolution_definition_::min_width, and multiline_label_.
tpoint gui2::tcontrol::get_best_size | ( | ) | const [virtual] |
Gets the best size for the object, 0,0 means no size required.
Implements gui2::twidget.
Reimplemented in gui2::tcontainer_, gui2::tlistbox, and gui2::tspacer.
Definition at line 115 of file control.cpp.
References config_, gui2::tresolution_definition_::default_height, gui2::tresolution_definition_::default_width, t_string::empty(), get_multi_line_best_size(), get_single_line_best_size(), label_, and multiline_label_.
Referenced by gui2::twindow::do_show_help_popup(), gui2::twindow::do_show_tooltip(), and gui2::tspacer::get_best_size().
tpoint gui2::tcontrol::get_maximum_size | ( | ) | const [virtual] |
Gets the best size for an object, 0,0 means no limits.
Implements gui2::twidget.
Definition at line 132 of file control.cpp.
References config_, gui2::tresolution_definition_::max_height, and gui2::tresolution_definition_::max_width.
void gui2::tcontrol::load_config | ( | ) | [virtual] |
Inherited from twidget.
This function shouldn't be called directly it's called by set_definition().
All classes which use this class as base should call this function in their constructor. Abstract classes shouldn't call this routine. The classes which call this routine should also define get_control_type().
Reimplemented from gui2::twidget.
Definition at line 300 of file control.cpp.
References canvas(), config(), gui2::twidget::definition(), gui2::get_control(), get_control_type(), load_config_extra(), set_canvas_text(), set_config(), size, and gui2::tresolution_definition_::state.
Referenced by set_definition(), and gui2::twindow::twindow().
Helpers.
Definition at line 138 of file control.cpp.
References config_, t_string::empty(), label_, font::line_size(), gui2::tresolution_definition_::max_height, gui2::tresolution_definition_::max_width, maximum(), rect, size, gui2::tresolution_definition_::text_extra_height, gui2::tresolution_definition_::text_extra_width, gui2::tresolution_definition_::text_font_size, gui2::tresolution_definition_::text_font_style, gui2::tpoint::x, and gui2::tpoint::y.
Referenced by get_best_size(), and get_minimum_size().
Definition at line 169 of file control.cpp.
References config_, t_string::empty(), ERR_G, font::get_rendered_text(), label_, gui2::tresolution_definition_::max_height, gui2::tresolution_definition_::max_width, minimum(), gui2::tresolution_definition_::text_extra_height, gui2::tresolution_definition_::text_extra_width, gui2::tresolution_definition_::text_font_size, font::word_wrap_text(), WRN_G, gui2::tpoint::x, and gui2::tpoint::y.
Referenced by get_best_size(), and get_minimum_size().
virtual unsigned gui2::tcontrol::get_state | ( | ) | const [protected, pure virtual] |
Returns the id of the state, which is also the index for the canvas.
Implemented in gui2::tbutton, gui2::tlabel, gui2::tlistbox, gui2::tpanel, gui2::tscrollbar_, gui2::tspacer, gui2::ttext_, gui2::ttoggle_button, gui2::ttooltip, and gui2::twindow.
Referenced by draw(), and full_redraw().
bool gui2::tcontrol::full_redraw | ( | ) | const [protected, virtual] |
Does the widget need to restore the surface before (re)painting?
Reimplemented in gui2::twindow.
Definition at line 211 of file control.cpp.
References config(), get_state(), and gui2::tresolution_definition_::state.
Referenced by draw().
void gui2::tcontrol::set_canvas_text | ( | ) | [protected, virtual] |
Sets the text variable for the canvases.
Reimplemented in gui2::ttext_box.
Definition at line 218 of file control.cpp.
References canvas(), canvas_, label_, and gui2::tcanvas::set_variable().
Referenced by load_config(), gui2::ttext_::paste_selection(), gui2::ttext_::set_cursor(), set_label(), and gui2::ttext_::set_text().
tresolution_definition_* gui2::tcontrol::config | ( | ) | [inline, protected] |
Definition at line 152 of file control.hpp.
References config_.
Referenced by gui2::tpanel::border_space(), gui2::tbuilder_listbox::build(), gui2::ttext_box::calculate_char_offset(), full_redraw(), gui2::twindow::get_client_rect(), gui2::tpanel::get_client_rect(), gui2::ttext_box::insert_char(), load_config(), gui2::tvertical_scrollbar::minimum_positioner_length(), gui2::tvertical_scrollbar::offset_after(), gui2::tvertical_scrollbar::offset_before(), set_definition(), and gui2::ttext_box::update_offsets().
const tresolution_definition_* gui2::tcontrol::config | ( | ) | const [inline, protected] |
void gui2::tcontrol::set_config | ( | tresolution_definition_ * | config | ) | [inline, protected] |
void gui2::tcontrol::save_background | ( | const surface & | src | ) | [private] |
Saves the portion of the background.
We expect an empty restorer and copy the part in get_rect() to the new surface. We copy the data since we want to put it back 1:1 and not a blit so can't use get_surface_portion.
src | background to save. |
Definition at line 278 of file control.cpp.
References gui2::twidget::get_rect(), restorer_, and gui2::save_background().
Referenced by draw().
void gui2::tcontrol::restore_background | ( | surface & | dst | ) | [private] |
Restores a portion of the background.
See save_background for more info.
dst | Background to restore. |
Definition at line 290 of file control.cpp.
References gui2::twidget::get_rect(), gui2::restore_background(), and restorer_.
Referenced by draw().
virtual void gui2::tcontrol::load_config_extra | ( | ) | [inline, private, virtual] |
Once the config is loaded this function is called.
Reimplemented in gui2::tscrollbar_, and gui2::ttext_box.
Definition at line 198 of file control.hpp.
Referenced by load_config().
virtual const std::string& gui2::tcontrol::get_control_type | ( | ) | const [private, pure virtual] |
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::tbutton, gui2::tlabel, gui2::tlistbox, gui2::tpanel, gui2::tspacer, gui2::ttext_box, gui2::ttoggle_button, gui2::ttooltip, gui2::tvertical_scrollbar, and gui2::twindow.
Referenced by load_config().
bool gui2::tcontrol::visible_ [private] |
Visible state of the control, invisible isn't drawn.
Definition at line 160 of file control.hpp.
Referenced by draw(), get_visible(), and set_visible().
bool gui2::tcontrol::multiline_label_ [private] |
Can the label contain multiple lines.
Definition at line 163 of file control.hpp.
Referenced by draw(), get_best_size(), get_minimum_size(), and set_multiline_label().
std::string gui2::tcontrol::wrapped_label_ [private] |
If multiline we need to have a version of the label wrapped to fit in the widget.
This value is cached so changes to the label or widget size should clear us.
Definition at line 168 of file control.hpp.
Referenced by draw(), set_label(), and set_size().
t_string gui2::tcontrol::label_ [private] |
The label associated with a lot of widgets to show a (non editable) text.
Definition at line 171 of file control.hpp.
Referenced by draw(), get_best_size(), get_minimum_size(), get_multi_line_best_size(), get_single_line_best_size(), label(), set_canvas_text(), and set_label().
t_string gui2::tcontrol::tooltip_ [private] |
When hovering a tooltip with extra information can show up.
Reimplemented in gui2::twindow.
Definition at line 174 of file control.hpp.
Referenced by mouse_hover(), set_tooltip(), and tooltip().
t_string gui2::tcontrol::help_message_ [private] |
When the user presses help a tooltip with even more info can be shown.
Definition at line 177 of file control.hpp.
Referenced by help_key(), help_message(), and set_help_message().
std::vector<tcanvas> gui2::tcontrol::canvas_ [private] |
Holds all canvas objects for a control.
Definition at line 180 of file control.hpp.
Referenced by canvas(), set_canvas_text(), and set_size().
surface gui2::tcontrol::restorer_ [private] |
Holds a copy of the original background which can be used before redrawing.
This is needed for semi-tranparent items, the user defines whether it's required or not.
Definition at line 185 of file control.hpp.
Referenced by draw(), restore_background(), and save_background().
tresolution_definition_* gui2::tcontrol::config_ [private] |
Contains a pointer to the configuration of this button at the current resolution.
Definition at line 195 of file control.hpp.
Referenced by config(), draw(), get_best_size(), get_maximum_size(), get_minimum_size(), get_multi_line_best_size(), get_single_line_best_size(), and set_config().
Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |