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 | Static Protected Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
gui::drop_target Class Reference

Handles droping for drag able ui items. More...

#include <drop_target.hpp>

Inheritance diagram for gui::drop_target:
Inheritance graph

Public Member Functions

 drop_target (const drop_group_manager_ptr group, const SDL_Rect &loc)
 Registers drop target and saves reference to location. More...
 
 ~drop_target ()
 
int get_id () const
 
bool is_this_id (const int id) const
 Checks if id matches id for this object. More...
 

Protected Member Functions

int handle_drop ()
 Called by widget object when droping happens. More...
 

Static Protected Member Functions

static bool empty ()
 Used to check if static storages are empty. More...
 

Private Types

typedef std::multimap
< drop_target_group,
drop_target * > 
drop_groups
 
typedef std::map
< drop_target_group, int
target_id
 

Private Member Functions

int next_free_id (const drop_target_group &group) const
 
bool hit_rect (const SDL_Rect &hit_loc, const int not_id) const
 
drop_groups::iterator find_this () const
 

Static Private Member Functions

static drop_target_group create_group ()
 
static void delete_group (const drop_target_group id)
 

Private Attributes

const SDL_Rect & loc_
 
const int id_
 
drop_group_manager_ptr group_
 

Static Private Attributes

static drop_groups groups_
 
static target_id next_id_
 
static drop_target_group next_group_ = 0
 

Friends

class drop_group_manager
 

Detailed Description

Handles droping for drag able ui items.

Widget class just has to inherit from drop_target, call constructor and handle_drop.

Definition at line 38 of file drop_target.hpp.

Member Typedef Documentation

Definition at line 39 of file drop_target.hpp.

Definition at line 40 of file drop_target.hpp.

Constructor & Destructor Documentation

gui::drop_target::drop_target ( const drop_group_manager_ptr  group,
const SDL_Rect &  loc 
)

Registers drop target and saves reference to location.

Definition at line 33 of file drop_target.cpp.

References group_, and groups_.

gui::drop_target::~drop_target ( )

Definition at line 50 of file drop_target.cpp.

References find_this(), and groups_.

Member Function Documentation

drop_target_group gui::drop_target::create_group ( )
staticprivate

Definition at line 82 of file drop_target.cpp.

References next_group_.

void gui::drop_target::delete_group ( const drop_target_group  id)
staticprivate

Definition at line 76 of file drop_target.cpp.

References groups_, and next_id_.

Referenced by gui::drop_group_manager::~drop_group_manager().

static bool gui::drop_target::empty ( )
inlinestaticprotected

Used to check if static storages are empty.

Only for testing.

Definition at line 61 of file drop_target.hpp.

Referenced by test_drop_target::empty().

drop_target::drop_groups::iterator gui::drop_target::find_this ( ) const
private

Definition at line 43 of file drop_target.cpp.

References group_, groups_, id_, and is_this_id().

Referenced by ~drop_target().

int gui::drop_target::get_id ( ) const

Definition at line 55 of file drop_target.cpp.

References id_.

int gui::drop_target::handle_drop ( )
protected

Called by widget object when droping happens.

Droping over multiple widget objects in same group is undefined.

Returns
: id which widget was hit when droping

Definition at line 60 of file drop_target.cpp.

References group_, groups_, hit_rect(), id_, itor, and loc_.

Referenced by test_drop_target::handle_drop(), and gui::combo_drag::handle_drop().

bool gui::drop_target::hit_rect ( const SDL_Rect &  hit_loc,
const int  not_id 
) const
private

Definition at line 87 of file drop_target.cpp.

References id_, and loc_.

Referenced by handle_drop().

bool gui::drop_target::is_this_id ( const int  id) const

Checks if id matches id for this object.

Used by for_each/boost:bind

Definition at line 38 of file drop_target.cpp.

References id_.

Referenced by find_this().

int gui::drop_target::next_free_id ( const drop_target_group group) const
private

Definition at line 27 of file drop_target.cpp.

References next_id_.

Friends And Related Function Documentation

friend class drop_group_manager
friend

Definition at line 86 of file drop_target.hpp.

Member Data Documentation

drop_group_manager_ptr gui::drop_target::group_
private

Definition at line 51 of file drop_target.hpp.

Referenced by drop_target(), find_this(), and handle_drop().

drop_target::drop_groups gui::drop_target::groups_
staticprivate

Definition at line 41 of file drop_target.hpp.

Referenced by delete_group(), drop_target(), find_this(), handle_drop(), and ~drop_target().

const int gui::drop_target::id_
private

Definition at line 50 of file drop_target.hpp.

Referenced by find_this(), get_id(), handle_drop(), hit_rect(), and is_this_id().

const SDL_Rect& gui::drop_target::loc_
private

Definition at line 49 of file drop_target.hpp.

Referenced by handle_drop(), and hit_rect().

drop_target_group gui::drop_target::next_group_ = 0
staticprivate

Definition at line 43 of file drop_target.hpp.

Referenced by create_group().

drop_target::target_id gui::drop_target::next_id_
staticprivate

Definition at line 42 of file drop_target.hpp.

Referenced by delete_group(), and next_free_id().


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