Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes

editor::mouse_action Class Reference

A mouse action receives events from the controller, and responds to them by creating an appropriate editor_action object. More...

#include <mouse_action.hpp>

Inheritance diagram for editor::mouse_action:
Inheritance graph
[legend]
Collaboration diagram for editor::mouse_action:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 mouse_action (common_palette &palette, const CKey &key)
virtual ~mouse_action ()
virtual bool has_context_menu () const
void move (editor_display &disp, const map_location &hex)
 Mouse move (not a drag).
void update_brush_highlights (editor_display &disp, const map_location &hex)
 Unconditionally update the brush highlights for the current tool when hex is the center location.
virtual std::set< map_locationaffected_hexes (editor_display &disp, const map_location &hex)
 Locations that would be affected by a click, used by move to update highlights.
virtual editor_actionclick_left (editor_display &disp, int x, int y)=0
 A click, possibly the beginning of a drag.
virtual editor_actionclick_right (editor_display &disp, int x, int y)=0
 A click, possibly the beginning of a drag.
virtual editor_actiondrag_left (editor_display &disp, int x, int y, bool &partial, editor_action *last_undo)
 Drag operation.
virtual editor_actiondrag_right (editor_display &disp, int x, int y, bool &partial, editor_action *last_undo)
 Drag operation.
virtual editor_actiondrag_end (editor_display &disp, int x, int y)
 The end of dragging.
virtual editor_actionup_left (editor_display &disp, int x, int y)
virtual editor_actionup_right (editor_display &disp, int x, int y)
virtual editor_actionkey_event (editor_display &disp, const SDL_Event &e)
 Function called by the controller on a key event for the current mouse action.
void set_toolbar_button (const theme::menu *value)
 Helper variable setter - pointer to a toolbar menu/button used for highlighting the current action.
const theme::menutoolbar_button () const
 Getter for the (possibly NULL) associated menu/button.
common_paletteget_palette ()
 Getter for the associated palette.
virtual void set_mouse_overlay (editor_display &disp)
 Set the mouse overlay for this action.

Protected Member Functions

bool has_alt_modifier () const
bool has_shift_modifier () const
bool has_ctrl_modifier () const
void set_terrain_mouse_overlay (editor_display &disp, t_translation::t_terrain fg, t_translation::t_terrain bg)
 Helper function for derived classes that need a active-terrain mouse overlay.

Protected Attributes

map_location previous_move_hex_
 The hex previously used in move operations.
const CKeykey_
 Key presses, used for modifiers (alt, shift) in some operations.

Private Attributes

const theme::menutoolbar_button_
 Pointer to an associated menu/button, if such exists.
common_palettepalette_
 Pointer to an associated palette, if such exists.

Detailed Description

A mouse action receives events from the controller, and responds to them by creating an appropriate editor_action object.

Mouse actions may store some temporary data such as the last clicked hex for better handling of click-drag. They should *not* modify the map or trigger refreshes, but may set brush locations and similar overlays that should be visible around the mouse cursor, hence the display references are not const.

Definition at line 37 of file mouse_action.hpp.


Constructor & Destructor Documentation

editor::mouse_action::mouse_action ( common_palette palette,
const CKey key 
) [inline]

Definition at line 40 of file mouse_action.hpp.

virtual editor::mouse_action::~mouse_action (  )  [inline, virtual]

Definition at line 48 of file mouse_action.hpp.


Member Function Documentation

std::set< map_location > editor::mouse_action::affected_hexes ( editor_display disp,
const map_location hex 
) [virtual]

Locations that would be affected by a click, used by move to update highlights.

Defauts to higlight the mouseover hex. Maybe also used for actually performing the action in click() or drag().

Reimplemented in editor::brush_drag_mouse_action, editor::mouse_action_select, editor::mouse_action_paste, and editor::mouse_action_fill.

Definition at line 45 of file mouse_action.cpp.

virtual editor_action* editor::mouse_action::click_left ( editor_display disp,
int  x,
int  y 
) [pure virtual]
virtual editor_action* editor::mouse_action::click_right ( editor_display disp,
int  x,
int  y 
) [pure virtual]
editor_action * editor::mouse_action::drag_end ( editor_display disp,
int  x,
int  y 
) [virtual]

The end of dragging.

Defaults to no action.

Reimplemented in editor::brush_drag_mouse_action.

Definition at line 65 of file mouse_action.cpp.

editor_action * editor::mouse_action::drag_left ( editor_display disp,
int  x,
int  y,
bool &  partial,
editor_action last_undo 
) [virtual]

Drag operation.

A click should have occurred earlier. Defaults to no action.

Reimplemented in editor::brush_drag_mouse_action, editor::mouse_action_map_label, and editor::mouse_action_unit.

Definition at line 53 of file mouse_action.cpp.

editor_action * editor::mouse_action::drag_right ( editor_display disp,
int  x,
int  y,
bool &  partial,
editor_action last_undo 
) [virtual]

Drag operation.

A click should have occurred earlier. Defaults to no action.

Reimplemented in editor::brush_drag_mouse_action, and editor::mouse_action_unit.

Definition at line 59 of file mouse_action.cpp.

common_palette& editor::mouse_action::get_palette (  )  [inline]

Getter for the associated palette.

Definition at line 118 of file mouse_action.hpp.

References palette_.

bool editor::mouse_action::has_alt_modifier (  )  const [protected]

Definition at line 119 of file mouse_action.cpp.

bool editor::mouse_action::has_context_menu (  )  const [virtual]

Reimplemented in editor::mouse_action_paste.

Definition at line 27 of file mouse_action.cpp.

bool editor::mouse_action::has_ctrl_modifier (  )  const [protected]

Definition at line 129 of file mouse_action.cpp.

Referenced by editor::mouse_action_paint::click_left().

Here is the caller graph for this function:

bool editor::mouse_action::has_shift_modifier (  )  const [protected]

Definition at line 124 of file mouse_action.cpp.

Referenced by editor::mouse_action_select::affected_hexes().

Here is the caller graph for this function:

editor_action * editor::mouse_action::key_event ( editor_display disp,
const SDL_Event &  e 
) [virtual]

Function called by the controller on a key event for the current mouse action.

Defaults to starting position processing.

Reimplemented in editor::mouse_action_select.

Definition at line 83 of file mouse_action.cpp.

void editor::mouse_action::move ( editor_display disp,
const map_location hex 
)

Mouse move (not a drag).

Never changes anything (other than temporary highlihts and similar)

Definition at line 32 of file mouse_action.cpp.

Referenced by editor::brush_drag_mouse_action::drag_generic().

Here is the caller graph for this function:

void editor::mouse_action::set_mouse_overlay ( editor_display disp  )  [virtual]

Set the mouse overlay for this action.

Defaults to an empty overlay.

Reimplemented in editor::mouse_action_paint, editor::mouse_action_select, editor::mouse_action_paste, editor::mouse_action_fill, editor::mouse_action_starting_position, editor::mouse_action_map_label, and editor::mouse_action_unit.

Definition at line 114 of file mouse_action.cpp.

Referenced by editor::editor_toolkit::set_mouseover_overlay().

Here is the caller graph for this function:

void editor::mouse_action::set_terrain_mouse_overlay ( editor_display disp,
t_translation::t_terrain  fg,
t_translation::t_terrain  bg 
) [protected]

Helper function for derived classes that need a active-terrain mouse overlay.

Definition at line 138 of file mouse_action.cpp.

void editor::mouse_action::set_toolbar_button ( const theme::menu value  )  [inline]

Helper variable setter - pointer to a toolbar menu/button used for highlighting the current action.

Should always be NULL or point to a valid menu.

Definition at line 108 of file mouse_action.hpp.

References toolbar_button_.

const theme::menu* editor::mouse_action::toolbar_button (  )  const [inline]

Getter for the (possibly NULL) associated menu/button.

Definition at line 113 of file mouse_action.hpp.

References toolbar_button_.

editor_action * editor::mouse_action::up_left ( editor_display disp,
int  x,
int  y 
) [virtual]
editor_action * editor::mouse_action::up_right ( editor_display disp,
int  x,
int  y 
) [virtual]
void editor::mouse_action::update_brush_highlights ( editor_display disp,
const map_location hex 
)

Unconditionally update the brush highlights for the current tool when hex is the center location.

Definition at line 40 of file mouse_action.cpp.

Referenced by editor::mouse_action_map_label::up_left(), and editor::editor_toolkit::update_mouse_action_highlights().

Here is the caller graph for this function:


Member Data Documentation

const CKey& editor::mouse_action::key_ [protected]

Key presses, used for modifiers (alt, shift) in some operations.

Definition at line 145 of file mouse_action.hpp.

Pointer to an associated palette, if such exists.

Definition at line 156 of file mouse_action.hpp.

Referenced by get_palette().

The hex previously used in move operations.

Definition at line 140 of file mouse_action.hpp.

Pointer to an associated menu/button, if such exists.

Definition at line 151 of file mouse_action.hpp.

Referenced by set_toolbar_button(), and toolbar_button().


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:19:31 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs