The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
gui::scrollbar Class Reference

Scrollbar. More...

#include <scrollbar.hpp>

Inheritance diagram for gui::scrollbar:
Inheritance graph

Public Member Functions

 scrollbar (CVideo &video)
 Create a scrollbar. More...
 
virtual void hide (bool value=true)
 
unsigned get_position () const
 Determine where the scrollbar is. More...
 
unsigned get_max_position () const
 
void set_position (unsigned pos)
 Manually update the scrollbar. More...
 
void adjust_position (unsigned pos)
 Ensure the viewport contains the position. More...
 
void move_position (int dep)
 Move the scrollbar. More...
 
void set_shown_size (unsigned h)
 Set the relative size of the grip. More...
 
void set_full_size (unsigned h)
 Set the relative size of the scrollbar. More...
 
void set_scroll_rate (unsigned r)
 Set scroll rate. More...
 
bool is_valid_height (int height) const
 Return true if the scrollbar has a valid size. More...
 
void scroll_down ()
 Scrolls down one step. More...
 
void scroll_up ()
 Scrolls up one step. More...
 
- Public Member Functions inherited from gui::widget
SDL_Rect const & location () const
 
virtual void set_location (SDL_Rect const &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)
 
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::stringid () 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)
 
- Public Member Functions inherited from events::sdl_handler
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 ()
 

Protected Member Functions

virtual sdl_handler_vector handler_members ()
 
virtual void update_location (SDL_Rect const &rect)
 
virtual void handle_event (const SDL_Event &event)
 
virtual void process_event ()
 
virtual void draw_contents ()
 
- Protected Member Functions inherited from gui::widget
 widget (widget const &o)
 
 widget (CVideo &video, const bool auto_join=true)
 
virtual ~widget ()
 
void bg_register (SDL_Rect const &rect)
 
void bg_restore () const
 
void bg_restore (SDL_Rect const &rect) const
 
void bg_update ()
 
void bg_cancel ()
 
CVideovideo () const
 
virtual void draw ()
 
const SDL_Rect * clip_rect () const
 
virtual sdl_handler_vector member_handlers ()
 
virtual void handle_window_event (SDL_Event const &event)
 
bool mouse_locked () const
 
void aquire_mouse_lock ()
 
void free_mouse_lock ()
 
- Protected Member Functions inherited from events::sdl_handler
 sdl_handler (const bool auto_join=true)
 
virtual ~sdl_handler ()
 

Private Types

enum  STATE { UNINIT, NORMAL, ACTIVE, DRAGGED }
 

Private Member Functions

SDL_Rect grip_area () const
 
SDL_Rect groove_area () const
 

Private Attributes

surface mid_scaled_
 
surface groove_scaled_
 
button uparrow_
 
button downarrow_
 
STATE state_
 
int minimum_grip_height_
 
int mousey_on_grip_
 
unsigned int grip_position_
 
unsigned int grip_height_
 
unsigned int full_height_
 
int scroll_rate_
 

Additional Inherited Members

- Protected Attributes inherited from gui::widget
bool focus_
 

Detailed Description

Scrollbar.

Definition at line 28 of file scrollbar.hpp.

Member Enumeration Documentation

enum gui::scrollbar::STATE
private
Enumerator
UNINIT 
NORMAL 
ACTIVE 
DRAGGED 

Definition at line 94 of file scrollbar.hpp.

Constructor & Destructor Documentation

gui::scrollbar::scrollbar ( CVideo video)

Create a scrollbar.

Todo:
FIXME: parameterlist ??

Definition at line 50 of file scrollbar.cpp.

References downarrow_, gui::button::enable(), image::get_image(), minimum_grip_height_, gui::widget::set_width(), and uparrow_.

Member Function Documentation

void gui::scrollbar::adjust_position ( unsigned  pos)

Ensure the viewport contains the position.

Definition at line 129 of file scrollbar.cpp.

References grip_height_, grip_position_, and set_position().

Referenced by gui::scrollarea::adjust_position().

void gui::scrollbar::draw_contents ( )
protectedvirtual
unsigned gui::scrollbar::get_max_position ( ) const

Definition at line 112 of file scrollbar.cpp.

References full_height_, and grip_height_.

Referenced by gui::scrollarea::get_max_position(), set_full_size(), and set_shown_size().

unsigned gui::scrollbar::get_position ( ) const

Determine where the scrollbar is.

Returns
the position.
Return values
returns0 if the scrollbar is at the top,
returns(full_size - shown_size) if it is at the bottom.

Definition at line 107 of file scrollbar.cpp.

References grip_position_.

Referenced by gui::scrollarea::get_position(), gui::scrollarea::process_event(), set_full_size(), and set_shown_size().

SDL_Rect gui::scrollbar::grip_area ( ) const
private
SDL_Rect gui::scrollbar::groove_area ( ) const
private
void gui::scrollbar::handle_event ( const SDL_Event &  event)
protectedvirtual
sdl_handler_vector gui::scrollbar::handler_members ( )
protectedvirtual

Reimplemented from events::sdl_handler.

Definition at line 78 of file scrollbar.cpp.

References downarrow_, h, and uparrow_.

void gui::scrollbar::hide ( bool  value = true)
virtual
bool gui::scrollbar::is_valid_height ( int  height) const

Return true if the scrollbar has a valid size.

Definition at line 179 of file scrollbar.cpp.

References downarrow_, gui::widget::height(), and uparrow_.

Referenced by gui::scrollarea::has_scrollbar().

void gui::scrollbar::move_position ( int  dep)

Move the scrollbar.

Definition at line 137 of file scrollbar.cpp.

References grip_position_, pos, and set_position().

Referenced by handle_event(), gui::scrollarea::move_position(), scroll_down(), and scroll_up().

void gui::scrollbar::process_event ( )
protectedvirtual

Reimplemented from events::sdl_handler.

Definition at line 200 of file scrollbar.cpp.

References downarrow_, gui::button::pressed(), scroll_down(), scroll_up(), and uparrow_.

void gui::scrollbar::scroll_down ( )

Scrolls down one step.

Definition at line 190 of file scrollbar.cpp.

References move_position(), and scroll_rate_.

Referenced by gui::scrollarea::handle_event(), and process_event().

void gui::scrollbar::scroll_up ( )

Scrolls up one step.

Definition at line 195 of file scrollbar.cpp.

References move_position(), and scroll_rate_.

Referenced by gui::scrollarea::handle_event(), and process_event().

void gui::scrollbar::set_full_size ( unsigned  h)
void gui::scrollbar::set_position ( unsigned  pos)
void gui::scrollbar::set_scroll_rate ( unsigned  r)

Set scroll rate.

Definition at line 174 of file scrollbar.cpp.

References scroll_rate_.

Referenced by gui::scrollarea::set_scroll_rate().

void gui::scrollbar::set_shown_size ( unsigned  h)

Set the relative size of the grip.

Definition at line 146 of file scrollbar.cpp.

References full_height_, get_max_position(), get_position(), grip_height_, grip_position_, h, gui::widget::set_dirty(), and set_position().

Referenced by set_full_size(), and gui::scrollarea::set_shown_size().

void gui::scrollbar::update_location ( SDL_Rect const &  rect)
protectedvirtual

Member Data Documentation

button gui::scrollbar::downarrow_
private
unsigned int gui::scrollbar::full_height_
private
unsigned int gui::scrollbar::grip_height_
private
unsigned int gui::scrollbar::grip_position_
private
surface gui::scrollbar::groove_scaled_
private

Definition at line 90 of file scrollbar.hpp.

Referenced by draw_contents().

surface gui::scrollbar::mid_scaled_
private

Definition at line 90 of file scrollbar.hpp.

Referenced by draw_contents(), and handle_event().

int gui::scrollbar::minimum_grip_height_
private

Definition at line 97 of file scrollbar.hpp.

Referenced by grip_area(), and scrollbar().

int gui::scrollbar::mousey_on_grip_
private

Definition at line 97 of file scrollbar.hpp.

Referenced by handle_event().

int gui::scrollbar::scroll_rate_
private

Definition at line 100 of file scrollbar.hpp.

Referenced by handle_event(), scroll_down(), scroll_up(), and set_scroll_rate().

STATE gui::scrollbar::state_
private

Definition at line 95 of file scrollbar.hpp.

Referenced by draw_contents(), and handle_event().

button gui::scrollbar::uparrow_
private

The documentation for this class was generated from the following files: