#include <widget.hpp>
Public Member Functions | |
const SDL_Rect & | location () const |
virtual void | set_location (const SDL_Rect &rect) |
void | set_location (int x, int y) |
void | set_width (int w) |
void | set_height (int h) |
void | set_measurements (int w, int h) |
int | width () const |
int | height () const |
bool | focus (const SDL_Event *event) |
void | set_focus (bool focus) |
virtual void | hide (bool value=true) |
bool | hidden () const |
virtual void | enable (bool new_val=true) |
bool | enabled () const |
void | set_clip_rect (const SDL_Rect &rect) |
void | set_volatile (bool val=true) |
void | set_dirty (bool dirty=true) |
bool | dirty () const |
const std::string & | id () const |
void | set_id (const std::string &id) |
void | set_help_string (const std::string &str) |
void | set_tooltip_string (const std::string &str) |
virtual void | process_help_string (int mousex, int mousey) |
virtual void | process_tooltip_string (int mousex, int mousey) |
virtual void | draw () |
![]() | |
virtual void | process_event () |
virtual bool | requires_event_focus (const SDL_Event *=nullptr) const |
virtual void | join () |
virtual void | join (context &c) |
virtual void | join_same (sdl_handler *parent) |
virtual void | leave () |
virtual void | join_global () |
virtual void | leave_global () |
virtual bool | has_joined () |
virtual bool | has_joined_global () |
sdl_handler & | operator= (sdl_handler &&)=delete |
Moving would require two instances' context membership to be handled, it's simpler to delete these and require the two instances to be separately constructed / destructed. More... | |
sdl_handler (sdl_handler &&)=delete | |
Protected Member Functions | |
widget (CVideo &video, const bool auto_join=true) | |
virtual | ~widget () |
void | bg_register (const SDL_Rect &rect) |
void | bg_restore () const |
void | bg_restore (const SDL_Rect &rect) const |
void | bg_update () |
void | bg_cancel () |
CVideo & | video () const |
virtual void | draw_contents () |
virtual void | update_location (const SDL_Rect &rect) |
const SDL_Rect * | clip_rect () const |
virtual sdl_handler_vector | member_handlers () |
virtual void | handle_event (const SDL_Event &) |
virtual void | handle_window_event (const SDL_Event &event) |
bool | mouse_locked () const |
void | aquire_mouse_lock () |
void | free_mouse_lock () |
![]() | |
sdl_handler (const bool auto_join=true) | |
sdl_handler (const sdl_handler &) | |
sdl_handler & | operator= (const sdl_handler &) |
virtual | ~sdl_handler () |
virtual std::vector< sdl_handler * > | handler_members () |
Protected Attributes | |
bool | focus_ |
Private Types | |
enum | { UNINIT, HIDDEN, DIRTY, DRAWN } |
Private Member Functions | |
void | volatile_draw () |
void | volatile_undraw () |
void | hide_override (bool value=true) |
Private Attributes | |
CVideo * | video_ |
std::vector< surface_restorer > | restorer_ |
SDL_Rect | rect_ |
bool | needs_restore_ |
enum gui::widget:: { ... } | state_ |
bool | hidden_override_ |
bool | enabled_ |
bool | clip_ |
SDL_Rect | clip_rect_ |
bool | volatile_ |
std::string | help_text_ |
std::string | tooltip_text_ |
int | help_string_ |
std::string | id_ |
bool | mouse_lock_local_ |
Static Private Attributes | |
static bool | mouse_lock_ = false |
Friends | |
class | dialog |
Definition at line 26 of file widget.hpp.
|
private |
Enumerator | |
---|---|
UNINIT | |
HIDDEN | |
DIRTY | |
DRAWN |
Definition at line 113 of file widget.hpp.
|
protected |
Definition at line 33 of file widget.cpp.
|
protectedvirtual |
Definition at line 40 of file widget.cpp.
References bg_cancel(), and free_mouse_lock().
|
protected |
Definition at line 46 of file widget.cpp.
References mouse_lock_, and mouse_lock_local_.
|
protected |
Definition at line 67 of file widget.cpp.
Referenced by set_location(), gui::scrollarea::test_scrollbar(), and ~widget().
|
protected |
Definition at line 99 of file widget.cpp.
References restorer_, and video().
Referenced by editor::palette_manager::adjust_size(), help::help_text_area::set_inner_location(), gui::textbox::set_inner_location(), gui::menu::set_inner_location(), and update_location().
|
protected |
Definition at line 241 of file widget.cpp.
References clip_, clip_rect_, i, needs_restore_, restorer_, and video().
Referenced by gui::menu::clear_item(), draw(), gui::menu::draw(), gui::tristate_button::draw_contents(), help::help_text_area::draw_contents(), gui::menu::style::draw_row_bg(), hide(), hide_override(), editor::palette_manager::restore_palette_bg(), set_location(), gui::scrollarea::test_scrollbar(), and volatile_undraw().
|
protected |
Definition at line 253 of file widget.cpp.
References clip_, clip_rect_, i, restorer_, and video().
|
protected |
Definition at line 234 of file widget.cpp.
Referenced by hide(), hide_override(), and volatile_draw().
|
protected |
Definition at line 94 of file widget.cpp.
References clip_, and clip_rect_.
Referenced by gui::menu::draw(), and draw_contents().
bool gui::widget::dirty | ( | ) | const |
Definition at line 217 of file widget.cpp.
Referenced by draw(), and gui::menu::draw().
|
virtual |
Reimplemented from events::sdl_handler.
Reimplemented in gui::menu, location_palette_item, editor::editor_palette< Item >, editor::editor_palette< t_translation::terrain_code >, editor::editor_palette< const unit_type &>, editor::editor_palette< overlay >, editor::common_palette, gui::tristate_button, editor::location_palette, and editor::empty_palette.
Definition at line 269 of file widget.cpp.
References bg_restore(), clip_, clip_rect_, dirty(), draw_contents(), hidden(), set_dirty(), and video().
Referenced by gui::tristate_button::draw(), location_palette_item::draw(), handle_event(), gui::textbox::handle_event(), editor::palette_manager::scroll_down(), editor::palette_manager::scroll_up(), video(), and volatile_draw().
|
inlineprotectedvirtual |
Reimplemented in gui::menu, help::help_text_area, gui::button, gui::tristate_button, editor::editor_palette< Item >, editor::editor_palette< t_translation::terrain_code >, editor::editor_palette< const unit_type &>, editor::editor_palette< overlay >, gui::scrollbar, editor::palette_manager, location_palette_item, editor::location_palette, and gui::textbox.
Definition at line 88 of file widget.hpp.
References clip_rect(), and update_location().
Referenced by draw().
|
virtual |
Reimplemented in gui::button, and gui::tristate_button.
Definition at line 194 of file widget.cpp.
References enabled_, and set_dirty().
Referenced by gui::tristate_button::enable(), and gui::button::enable().
bool gui::widget::enabled | ( | ) | const |
Definition at line 202 of file widget.cpp.
References enabled_.
Referenced by gui::textbox::draw_contents(), gui::button::draw_contents(), gui::textbox::draw_cursor(), gui::tristate_button::enable(), gui::button::enable(), gui::tristate_button::handle_event(), gui::button::handle_event(), location_palette_item::handle_event(), gui::textbox::handle_event(), and gui::textbox::requires_event_focus().
bool gui::widget::focus | ( | const SDL_Event * | event | ) |
Definition at line 147 of file widget.cpp.
References focus_, and events::has_focus().
Referenced by gui::textbox::draw_contents(), editor::palette_manager::handle_event(), gui::textbox::handle_event(), gui::menu::handle_event(), and set_focus().
|
protected |
Definition at line 53 of file widget.cpp.
References mouse_lock_, and mouse_lock_local_.
Referenced by ~widget().
|
protectedvirtual |
Implements events::sdl_handler.
Reimplemented in gui::menu, gui::textbox, location_palette_item, gui::button, gui::tristate_button, gui::scrollbar, editor::palette_manager, help::help_browser, and gui::scrollarea.
Definition at line 330 of file widget.cpp.
References draw(), DRAW_ALL_EVENT, and set_dirty().
Referenced by gui::scrollarea::handle_event(), help::help_browser::handle_event(), editor::palette_manager::handle_event(), gui::scrollbar::handle_event(), gui::tristate_button::handle_event(), gui::button::handle_event(), location_palette_item::handle_event(), gui::textbox::handle_event(), and member_handlers().
|
protectedvirtual |
Implements events::sdl_handler.
Definition at line 337 of file widget.cpp.
References set_dirty().
Referenced by member_handlers().
int gui::widget::height | ( | ) | const |
Definition at line 129 of file widget.cpp.
References rect_.
Referenced by help::help_browser::adjust_layout(), gui::scrollarea::handle_event(), gui::menu::handle_event(), gui::menu::hit_heading(), help::help_text_area::ref_at(), gui::menu::requires_event_focus(), help::help_text_area::set_items(), and gui::menu::update_size().
bool gui::widget::hidden | ( | ) | const |
Definition at line 188 of file widget.cpp.
References clip_, clip_rect_, HIDDEN, hidden_override_, rect_, sdl::rects_overlap(), state_, and UNINIT.
Referenced by draw(), gui::menu::draw(), gui::scrollarea::handle_event(), help::help_browser::handle_event(), gui::scrollbar::handle_event(), gui::tristate_button::handle_event(), gui::button::handle_event(), location_palette_item::handle_event(), gui::textbox::handle_event(), gui::menu::handle_event(), process_help_string(), gui::menu::process_help_string(), process_tooltip_string(), gui::textbox::requires_event_focus(), gui::menu::requires_event_focus(), editor::location_palette::selected_item(), and gui::scrollarea::update_location().
|
virtual |
Reimplemented in editor::editor_palette< Item >, editor::editor_palette< t_translation::terrain_code >, editor::editor_palette< const unit_type &>, editor::editor_palette< overlay >, editor::location_palette, editor::empty_palette, and gui::scrollarea.
Definition at line 152 of file widget.cpp.
References bg_restore(), bg_update(), DIRTY, DRAWN, HIDDEN, hidden_override_, set_dirty(), and state_.
Referenced by editor::location_palette::draw_contents(), editor::palette_manager::draw_contents(), editor::editor_palette< overlay >::draw_contents(), help::help_browser::handle_event(), help::help_browser::help_browser(), gui::scrollarea::hide(), editor::location_palette::hide(), location_palette_button::location_palette_button(), help::help_browser::process_event(), gui::scrollarea::scrollarea(), and gui::scrollarea::update_location().
|
private |
Definition at line 167 of file widget.cpp.
References bg_restore(), bg_update(), DIRTY, DRAWN, hidden_override_, set_dirty(), and state_.
const std::string & gui::widget::id | ( | ) | const |
Definition at line 222 of file widget.cpp.
References id_.
Referenced by editor::location_palette::add_item(), gui::menu::fill_items(), editor::location_palette::is_selected_item(), set_id(), gui::tristate_button::set_item_id(), and location_palette_item::set_item_id().
const SDL_Rect & gui::widget::location | ( | ) | const |
Definition at line 134 of file widget.cpp.
References rect_.
Referenced by editor::location_palette::add_item(), help::help_browser::adjust_layout(), gui::button::calculate_size(), editor::location_palette::draw_contents(), location_palette_item::draw_contents(), editor::palette_manager::draw_contents(), gui::scrollbar::draw_contents(), gui::tristate_button::draw_contents(), gui::button::draw_contents(), gui::textbox::draw_cursor(), gui::scrollbar::grip_area(), editor::palette_manager::handle_event(), gui::scrollbar::handle_event(), gui::tristate_button::hit(), location_palette_item::hit(), gui::button::hit(), gui::menu::hit_column(), gui::scrollarea::inner_location(), gui::button::load_images(), help::help_browser::process_event(), help::help_text_area::ref_at(), gui::scrollarea::test_scrollbar(), and gui::textbox::update_text_cache().
|
inlineprotectedvirtual |
Definition at line 92 of file widget.hpp.
References handle_event(), and handle_window_event().
|
protected |
Definition at line 62 of file widget.cpp.
References mouse_lock_, and mouse_lock_local_.
Referenced by gui::scrollarea::handle_event(), gui::scrollbar::handle_event(), gui::tristate_button::handle_event(), gui::button::handle_event(), location_palette_item::handle_event(), gui::textbox::handle_event(), and gui::menu::handle_event().
|
virtual |
Reimplemented from events::sdl_handler.
Reimplemented in gui::menu.
Definition at line 309 of file widget.cpp.
References CVideo::clear_help_string(), help_string_, help_text_, hidden(), sdl::point_in_rect(), rect_, CVideo::set_help_string(), and video().
|
virtual |
Reimplemented from events::sdl_handler.
Definition at line 322 of file widget.cpp.
References tooltips::add_tooltip(), hidden(), sdl::point_in_rect(), rect_, and tooltip_text_.
void gui::widget::set_clip_rect | ( | const SDL_Rect & | rect | ) |
Definition at line 181 of file widget.cpp.
References clip_, clip_rect_, and set_dirty().
void gui::widget::set_dirty | ( | bool | dirty = true | ) |
Definition at line 207 of file widget.cpp.
References DIRTY, DRAWN, hidden_override_, needs_restore_, state_, and volatile_.
Referenced by help::help_browser::adjust_layout(), editor::palette_manager::adjust_size(), editor::location_palette::adjust_size(), gui::textbox::append_text(), gui::menu::change_item(), gui::textbox::clear(), gui::menu::do_sort(), draw(), gui::menu::draw(), editor::location_palette::draw_contents(), editor::palette_manager::draw_contents(), editor::editor_palette< overlay >::draw_contents(), enable(), gui::menu::erase_item(), gui::scrollbar::handle_event(), gui::tristate_button::handle_event(), gui::button::handle_event(), location_palette_item::handle_event(), handle_event(), gui::textbox::handle_event(), handle_window_event(), hide(), hide_override(), editor::palette_manager::restore_palette_bg(), help::help_text_area::scroll(), gui::textbox::scroll(), gui::menu::scroll(), editor::palette_manager::scroll_down(), editor::location_palette::scroll_down(), editor::palette_manager::scroll_up(), editor::unit_palette::select_bg_item(), editor::location_palette::select_item(), gui::button::set_active(), gui::button::set_check(), set_clip_rect(), gui::textbox::set_cursor_pos(), set_focus(), gui::scrollbar::set_full_size(), gui::menu::set_heading(), gui::button::set_image(), gui::menu::set_items(), gui::button::set_label(), set_location(), gui::button::set_overlay(), gui::scrollbar::set_position(), gui::tristate_button::set_pressed(), gui::textbox::set_selection(), gui::scrollbar::set_shown_size(), gui::textbox::set_text(), gui::textbox::set_wrap(), help::show_help(), help::help_text_area::show_topic(), gui::menu::sort_by(), and gui::textbox::update_location().
void gui::widget::set_focus | ( | bool | focus | ) |
Definition at line 139 of file widget.cpp.
References focus(), focus_, events::focus_handler(), and set_dirty().
Referenced by editor::palette_manager::handle_event(), gui::textbox::handle_event(), and gui::menu::handle_event().
void gui::widget::set_height | ( | int | h | ) |
Definition at line 114 of file widget.cpp.
References rect_, and set_location().
Referenced by help::help_browser::adjust_layout(), gui::button::calculate_size(), and help::show_help().
void gui::widget::set_help_string | ( | const std::string & | str | ) |
Definition at line 299 of file widget.cpp.
References help_text_.
void gui::widget::set_id | ( | const std::string & | id | ) |
Definition at line 227 of file widget.cpp.
|
virtual |
Definition at line 75 of file widget.cpp.
References bg_cancel(), bg_restore(), DRAWN, rect_, set_dirty(), state_, UNINIT, and update_location().
Referenced by help::help_browser::adjust_layout(), editor::palette_manager::adjust_size(), editor::location_palette::adjust_size(), gui::button::calculate_size(), gui::dialog_frame::draw(), editor::location_palette::draw_contents(), editor::editor_palette< overlay >::draw_contents(), location_palette_button::location_palette_button(), set_height(), set_location(), set_measurements(), set_width(), help::show_help(), and gui::scrollarea::update_location().
void gui::widget::set_location | ( | int | x, |
int | y | ||
) |
Definition at line 104 of file widget.cpp.
References rect_, and set_location().
void gui::widget::set_measurements | ( | int | w, |
int | h | ||
) |
Definition at line 119 of file widget.cpp.
References rect_, set_location(), and w.
Referenced by help::help_browser::help_browser(), gui::textbox::textbox(), and gui::menu::update_size().
void gui::widget::set_tooltip_string | ( | const std::string & | str | ) |
Definition at line 304 of file widget.cpp.
References tooltip_text_.
Referenced by editor::location_palette::draw_contents(), and editor::editor_palette< overlay >::draw_contents().
void gui::widget::set_volatile | ( | bool | val = true | ) |
void gui::widget::set_width | ( | int | w | ) |
Definition at line 109 of file widget.cpp.
References rect_, set_location(), and w.
Referenced by help::help_browser::adjust_layout(), gui::button::calculate_size(), gui::scrollbar::scrollbar(), and help::show_help().
|
protectedvirtual |
Reimplemented in gui::textbox, help::help_browser, and gui::scrollarea.
Definition at line 89 of file widget.cpp.
References bg_register().
Referenced by draw_contents(), and set_location().
|
inlineprotected |
Definition at line 83 of file widget.hpp.
References draw(), and video_.
Referenced by editor::location_palette::adjust_size(), bg_register(), bg_restore(), gui::button::calculate_size(), draw(), gui::menu::draw(), gui::textbox::draw_contents(), location_palette_item::draw_contents(), gui::scrollbar::draw_contents(), gui::tristate_button::draw_contents(), gui::button::draw_contents(), help::help_text_area::draw_contents(), gui::menu::imgsel_style::draw_row(), gui::menu::draw_row(), gui::menu::imgsel_style::draw_row_bg(), gui::menu::get_item_rect_internal(), gui::scrollarea::handle_event(), gui::menu::max_items_onscreen(), process_help_string(), and gui::menu::process_help_string().
|
privatevirtual |
Reimplemented from events::sdl_handler.
Definition at line 283 of file widget.cpp.
References bg_update(), DIRTY, draw(), DRAWN, hidden_override_, state_, and volatile_.
|
privatevirtual |
Reimplemented from events::sdl_handler.
Definition at line 292 of file widget.cpp.
References bg_restore(), and volatile_.
int gui::widget::width | ( | ) | const |
Definition at line 124 of file widget.cpp.
References rect_.
Referenced by help::help_text_area::add_img_item(), help::help_browser::adjust_layout(), help::help_text_area::get_y_for_floating_img(), gui::scrollarea::inner_location(), gui::dialog_frame::layout(), gui::scrollarea::scrollbar_width(), gui::scrollarea::update_location(), and gui::menu::update_size().
|
friend |
Definition at line 129 of file widget.hpp.
|
private |
Definition at line 116 of file widget.hpp.
Referenced by bg_restore(), clip_rect(), draw(), hidden(), and set_clip_rect().
|
private |
Definition at line 117 of file widget.hpp.
Referenced by bg_restore(), clip_rect(), draw(), hidden(), and set_clip_rect().
|
private |
Definition at line 115 of file widget.hpp.
|
protected |
Definition at line 96 of file widget.hpp.
Referenced by focus(), gui::textbox::requires_event_focus(), gui::menu::requires_event_focus(), and set_focus().
|
private |
Definition at line 123 of file widget.hpp.
Referenced by process_help_string().
|
private |
Definition at line 121 of file widget.hpp.
Referenced by process_help_string(), and set_help_string().
|
private |
Definition at line 114 of file widget.hpp.
Referenced by hidden(), hide(), hide_override(), set_dirty(), and volatile_draw().
|
private |
Definition at line 124 of file widget.hpp.
|
staticprivate |
Definition at line 127 of file widget.hpp.
Referenced by aquire_mouse_lock(), free_mouse_lock(), and mouse_locked().
|
private |
Definition at line 126 of file widget.hpp.
Referenced by aquire_mouse_lock(), free_mouse_lock(), and mouse_locked().
|
mutableprivate |
Definition at line 111 of file widget.hpp.
Referenced by bg_restore(), and set_dirty().
|
private |
Definition at line 110 of file widget.hpp.
Referenced by height(), hidden(), location(), process_help_string(), process_tooltip_string(), set_height(), set_location(), set_measurements(), set_width(), and width().
|
private |
Definition at line 109 of file widget.hpp.
Referenced by bg_cancel(), bg_register(), bg_restore(), and bg_update().
enum { ... } gui::widget::state_ |
Referenced by dirty(), hidden(), hide(), hide_override(), set_dirty(), set_location(), set_volatile(), and volatile_draw().
|
private |
Definition at line 122 of file widget.hpp.
Referenced by process_tooltip_string(), and set_tooltip_string().
|
private |
Definition at line 108 of file widget.hpp.
Referenced by video().
|
private |
Definition at line 119 of file widget.hpp.
Referenced by set_dirty(), set_volatile(), volatile_draw(), and volatile_undraw().