Public Member Functions | Protected Member Functions | Protected Attributes

events::mouse_handler_base Class Reference

#include <mouse_handler_base.hpp>

Inheritance diagram for events::mouse_handler_base:
Inheritance graph
[legend]
Collaboration diagram for events::mouse_handler_base:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 mouse_handler_base ()
virtual ~mouse_handler_base ()
virtual displaygui ()=0
 Reference to the used display objects.
virtual const displaygui () const =0
 Const version.
bool is_dragging () const
virtual int drag_threshold () const
void mouse_motion_event (const SDL_MouseMotionEvent &event, const bool browse)
void mouse_update (const bool browse, map_location loc)
 update the mouse with a fake mouse motion
bool get_show_menu () const
bool mouse_motion_default (int x, int y, bool update)
 This handles minimap scrolling and click-drag.
virtual void mouse_motion (int x, int y, const bool browse, bool update=false, map_location new_loc=map_location::null_location)=0
 Called when a mouse motion event takes place.
virtual void mouse_press (const SDL_MouseButtonEvent &event, const bool browse)
bool is_left_click (const SDL_MouseButtonEvent &event) const
bool is_middle_click (const SDL_MouseButtonEvent &event) const
bool is_right_click (const SDL_MouseButtonEvent &event) const
virtual bool allow_mouse_wheel_scroll (int x, int y)
 Derived classes can overrid this to disable mousewheel scrolling under some circumstances, e.g.
virtual bool left_click (int x, int y, const bool browse)
 Overridden in derived classes, called on a left click (mousedown).
virtual void left_drag_end (int x, int y, const bool browse)
 Called whenever the left mouse drag has "ended".
virtual void left_mouse_up (int x, int y, const bool browse)
 Called when the left mouse button is up.
virtual bool right_click (int x, int y, const bool browse)
 Overridden in derived classes, called on a right click (mousedown).
virtual bool right_click_show_menu (int x, int y, const bool browse)
 Called in the default right_click when the context menu is about to be shown, can be used for preprocessing and preventing the menu from being displayed without rewriting the right click function.
virtual void right_drag_end (int x, int y, const bool browse)
 Called whenever the right mouse drag has "ended".
virtual void right_mouse_up (int x, int y, const bool browse)
 Called when the right mouse button is up.

Protected Member Functions

void cancel_dragging ()
void clear_dragging (const SDL_MouseButtonEvent &event, bool browse)
void init_dragging (bool &dragging_flag)

Protected Attributes

bool simple_warp_
 MMB click (on game map) state flag.
bool minimap_scrolling_
 minimap scrolling (scroll-drag) state flag
bool dragging_left_
 LMB drag init flag.
bool dragging_started_
 Actual drag flag.
bool dragging_right_
 RMB drag init flag.
int drag_from_x_
 Drag start position x.
int drag_from_y_
 Drag start position y.
map_location drag_from_hex_
 Drag start map location.
map_location last_hex_
 last highlighted hex
bool show_menu_
 Show context menu flag.

Detailed Description

Definition at line 35 of file mouse_handler_base.hpp.


Constructor & Destructor Documentation

events::mouse_handler_base::mouse_handler_base (  ) 

Definition at line 51 of file mouse_handler_base.cpp.

virtual events::mouse_handler_base::~mouse_handler_base (  )  [inline, virtual]

Definition at line 38 of file mouse_handler_base.hpp.


Member Function Documentation

bool events::mouse_handler_base::allow_mouse_wheel_scroll ( int  x,
int  y 
) [virtual]

Derived classes can overrid this to disable mousewheel scrolling under some circumstances, e.g.

when the mouse wheel controls something else, but the event is also received by this class

Reimplemented in editor::editor_controller.

Definition at line 226 of file mouse_handler_base.cpp.

Referenced by mouse_press().

Here is the caller graph for this function:

void events::mouse_handler_base::cancel_dragging (  )  [protected]

Definition at line 294 of file mouse_handler_base.cpp.

References dragging_left_, dragging_right_, dragging_started_, and cursor::set_dragging().

Referenced by mouse_press().

Here is the call graph for this function:

Here is the caller graph for this function:

void events::mouse_handler_base::clear_dragging ( const SDL_MouseButtonEvent &  event,
bool  browse 
) [protected]

Definition at line 302 of file mouse_handler_base.cpp.

References dragging_left_, dragging_right_, dragging_started_, left_drag_end(), right_drag_end(), and cursor::set_dragging().

Referenced by mouse_press().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual int events::mouse_handler_base::drag_threshold (  )  const [inline, virtual]

Reimplemented in events::mouse_handler.

Definition at line 57 of file mouse_handler_base.hpp.

Referenced by mouse_motion_default().

Here is the caller graph for this function:

bool events::mouse_handler_base::get_show_menu (  )  const [inline]

Definition at line 64 of file mouse_handler_base.hpp.

References show_menu_.

virtual const display& events::mouse_handler_base::gui (  )  const [pure virtual]

Const version.

Implemented in editor::editor_controller, and events::mouse_handler.

virtual display& events::mouse_handler_base::gui (  )  [pure virtual]

Reference to the used display objects.

Derived classes should ensure this is always valid. Note the constructor of this class cannot use this.

Implemented in editor::editor_controller, and events::mouse_handler.

Referenced by init_dragging(), left_click(), mouse_motion_default(), mouse_press(), and right_click().

Here is the caller graph for this function:

void events::mouse_handler_base::init_dragging ( bool &  dragging_flag  )  [protected]

Definition at line 287 of file mouse_handler_base.cpp.

References drag_from_hex_, drag_from_x_, drag_from_y_, gui(), and display::hex_clicked_on().

Referenced by mouse_press().

Here is the call graph for this function:

Here is the caller graph for this function:

bool events::mouse_handler_base::is_dragging (  )  const
Returns:
true when the class in the "dragging" state.

Definition at line 65 of file mouse_handler_base.cpp.

References dragging_left_, and dragging_right_.

Referenced by editor::editor_controller::mouse_motion(), and mouse_motion_default().

Here is the caller graph for this function:

bool events::mouse_handler_base::is_left_click ( const SDL_MouseButtonEvent &  event  )  const

Definition at line 207 of file mouse_handler_base.cpp.

References events::command_active().

Referenced by mouse_press().

Here is the call graph for this function:

Here is the caller graph for this function:

bool events::mouse_handler_base::is_middle_click ( const SDL_MouseButtonEvent &  event  )  const

Definition at line 213 of file mouse_handler_base.cpp.

Referenced by mouse_press().

Here is the caller graph for this function:

bool events::mouse_handler_base::is_right_click ( const SDL_MouseButtonEvent &  event  )  const

Definition at line 219 of file mouse_handler_base.cpp.

References events::command_active().

Referenced by mouse_press().

Here is the call graph for this function:

Here is the caller graph for this function:

bool events::mouse_handler_base::left_click ( int  x,
int  y,
const bool  browse 
) [virtual]

Overridden in derived classes, called on a left click (mousedown).

Defaults to process (initiate) minimap scrolling.

Returns:
true when the click should not process the event further. This means do not treat the call as a start of drag movement. FIXME: This return value is currently ignored

Reimplemented in editor::editor_controller, and events::mouse_handler.

Definition at line 236 of file mouse_handler_base.cpp.

References tooltips::click(), gui(), last_hex_, display::minimap_location_on(), minimap_scrolling_, display::scroll_to_tile(), map_location::valid(), and display::WARP.

Referenced by events::mouse_handler::left_click(), left_drag_end(), and mouse_press().

Here is the call graph for this function:

Here is the caller graph for this function:

void events::mouse_handler_base::left_drag_end ( int  x,
int  y,
const bool  browse 
) [virtual]

Called whenever the left mouse drag has "ended".

Reimplemented in editor::editor_controller.

Definition at line 253 of file mouse_handler_base.cpp.

References left_click().

Referenced by clear_dragging().

Here is the call graph for this function:

Here is the caller graph for this function:

void events::mouse_handler_base::left_mouse_up ( int  x,
int  y,
const bool  browse 
) [virtual]

Called when the left mouse button is up.

Reimplemented in editor::editor_controller.

Definition at line 258 of file mouse_handler_base.cpp.

Referenced by mouse_press().

Here is the caller graph for this function:

virtual void events::mouse_handler_base::mouse_motion ( int  x,
int  y,
const bool  browse,
bool  update = false,
map_location  new_loc = map_location::null_location 
) [pure virtual]

Called when a mouse motion event takes place.

Derived classes mustprovide an implementation, possibly using mouse_motion_default().

Implemented in editor::editor_controller, and events::mouse_handler.

Referenced by mouse_motion_event(), mouse_update(), and controller_base::play_slice().

Here is the caller graph for this function:

bool events::mouse_handler_base::mouse_motion_default ( int  x,
int  y,
bool  update 
)

This handles minimap scrolling and click-drag.

Returns:
true when the caller should not process the mouse motion further (i.e. should return), false otherwise.

Definition at line 82 of file mouse_handler_base.cpp.

References drag_from_x_, drag_from_y_, drag_threshold(), dragging_left_, dragging_right_, dragging_started_, gui(), is_dragging(), last_hex_, display::minimap_location_on(), minimap_scrolling_, tooltips::process(), display::scroll_to_tile(), cursor::set_dragging(), simple_warp_, map_location::valid(), and display::WARP.

Referenced by events::mouse_handler::mouse_motion().

Here is the call graph for this function:

Here is the caller graph for this function:

void events::mouse_handler_base::mouse_motion_event ( const SDL_MouseMotionEvent &  event,
const bool  browse 
)

Definition at line 70 of file mouse_handler_base.cpp.

References mouse_motion().

Referenced by controller_base::handle_event().

Here is the call graph for this function:

Here is the caller graph for this function:

void events::mouse_handler_base::mouse_press ( const SDL_MouseButtonEvent &  event,
const bool  browse 
) [virtual]
void events::mouse_handler_base::mouse_update ( const bool  browse,
map_location  loc 
)

update the mouse with a fake mouse motion

Definition at line 75 of file mouse_handler_base.cpp.

References mouse_motion().

Referenced by mouse_press(), and controller_base::play_slice().

Here is the call graph for this function:

Here is the caller graph for this function:

bool events::mouse_handler_base::right_click ( int  x,
int  y,
const bool  browse 
) [virtual]

Overridden in derived classes, called on a right click (mousedown).

Defaults to displaying the menu (by setting the appropriate flag) if right_click_show_menu returns true.

Returns:
true when the click should not process the event further. This means do not treat the call as a start of drag movement.

Reimplemented in editor::editor_controller.

Definition at line 262 of file mouse_handler_base.cpp.

References theme::context_menu(), display::draw(), display::get_theme(), gui(), right_click_show_menu(), show_menu_, and WRN_DP.

Referenced by mouse_press().

Here is the call graph for this function:

Here is the caller graph for this function:

bool events::mouse_handler_base::right_click_show_menu ( int  x,
int  y,
const bool  browse 
) [virtual]

Called in the default right_click when the context menu is about to be shown, can be used for preprocessing and preventing the menu from being displayed without rewriting the right click function.

Returns:
true when the menu should be displayed and false otherwise FIXME: This return value is currently ignored

Reimplemented in editor::editor_controller, and events::mouse_handler.

Definition at line 231 of file mouse_handler_base.cpp.

Referenced by right_click().

Here is the caller graph for this function:

void events::mouse_handler_base::right_drag_end ( int  x,
int  y,
const bool  browse 
) [virtual]

Called whenever the right mouse drag has "ended".

Reimplemented in editor::editor_controller.

Definition at line 277 of file mouse_handler_base.cpp.

Referenced by clear_dragging().

Here is the caller graph for this function:

void events::mouse_handler_base::right_mouse_up ( int  x,
int  y,
const bool  browse 
) [virtual]

Called when the right mouse button is up.

Reimplemented in editor::editor_controller.

Definition at line 283 of file mouse_handler_base.cpp.

Referenced by mouse_press().

Here is the caller graph for this function:


Member Data Documentation

Drag start map location.

Definition at line 158 of file mouse_handler_base.hpp.

Referenced by init_dragging(), and editor::editor_controller::mouse_motion().

Drag start position x.

Definition at line 154 of file mouse_handler_base.hpp.

Referenced by init_dragging(), and mouse_motion_default().

Drag start position y.

Definition at line 156 of file mouse_handler_base.hpp.

Referenced by init_dragging(), and mouse_motion_default().

minimap scrolling (scroll-drag) state flag

Definition at line 146 of file mouse_handler_base.hpp.

Referenced by left_click(), mouse_motion_default(), and mouse_press().

Show context menu flag.

Definition at line 164 of file mouse_handler_base.hpp.

Referenced by get_show_menu(), mouse_press(), and right_click().

MMB click (on game map) state flag.

Definition at line 144 of file mouse_handler_base.hpp.

Referenced by mouse_motion_default(), and mouse_press().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:20:36 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs