]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/mousemanager.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mousemanager.h
3 // Purpose: documentation of wxMouseEventsManager class
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
12 @class wxMouseEventsManager
14 Helper for handling mouse input events in windows containing multiple
17 This class handles mouse events and synthesizes high-level notifications
18 such as clicks and drag events from low level mouse button presses and
19 mouse movement events. It is useful because handling the mouse events is
20 less obvious than might seem at a first glance: for example, clicks on an
21 object should only be generated if the mouse was both pressed and released
22 over it and not just released (so it requires storing the previous state)
23 and dragging shouldn't start before the mouse moves away far enough.
25 This class encapsulates all these dull details for controls containing
26 multiple items which can be identified by a positive integer index and you
27 just need to implement its pure virtual functions to use it.
29 Notice that this class supposes that all items can be identified by an
30 integer "index" but it doesn't need to be an ordinal index of the item
31 (although this is the most common case) -- it can be any value which can
32 be used to uniquely identify an item.
37 class wxMouseEventsManager
: public wxEvtHandler
41 Constructor creates the manager for the window.
43 A mouse event manager is always associated with a window and must be
44 destroyed by the window when it is destroyed (it doesn't need to be
45 allocated on the heap however).
47 wxMouseEventsManager(wxWindow
*win
);
51 Must be overridden to return the item at the given position.
54 The position to test, in physical coordinates.
56 The index of the item at the given position or wxNOT_FOUND if there
59 virtual int MouseHitTest(const wxPoint
& pos
) = 0;
62 Must be overridden to react to mouse clicks.
64 This method is called when the user clicked (i.e. pressed and released
65 mouse over the @e same item) and should normally generate a
66 notification about this click and return true if it was handled or
67 false otherwise, determining whether the original mouse event is
71 The item which was clicked.
73 @true if the mouse event was processed and @false otherwise.
75 virtual bool MouseClicked(int item
) = 0;
78 Must be overridden to allow or deny dragging of the item.
80 This method is called when the user attempts to start dragging the
84 The item which is going to be dragged.
86 The position from where it is being dragged.
88 @true to allow the item to be dragged (in which case
89 MouseDragging() and MouseDragEnd() will be called later, unless
90 MouseDragCancelled() is called instead) or @false to forbid it.
92 virtual bool MouseDragBegin(int item
, const wxPoint
& pos
) = 0;
95 Must be overridden to provide feed back while an item is being dragged.
97 This method is called while the item is being dragged and should
98 normally update the feedback shown on screen (usually this is done
101 Notice that this method will never be called for the items for which
102 MouseDragBegin() returns @false. Consequently, if MouseDragBegin()
103 always returns @false you can do nothing in this method.
106 The item being dragged.
108 The current position of the item.
112 virtual void MouseDragging(int item
, const wxPoint
& pos
) = 0;
115 Must be overridden to handle item drop.
117 This method is called when the mouse is released after dragging the
118 item. Normally the item should be positioned at the new location.
121 The item which was dragged and now dropped.
123 The position at which the item was dropped.
125 @see MouseDragBegin(), MouseDragging()
127 virtual void MouseDragEnd(int item
, const wxPoint
& pos
) = 0;
130 Must be overridden to handle cancellation of mouse dragging.
132 This method is called when mouse capture is lost while dragging the
133 item and normally should remove the visual feedback drawn by
134 MouseDragging() as well as reset any internal variables set in
137 @see wxMouseCaptureLostEvent
139 virtual void MouseDragCancelled(int item
) = 0;
143 May be overridden to update the state of an item when it is pressed.
145 This method is called when the item is becomes pressed and can be used
146 to change its appearance when this happens. It is mostly useful for
147 button-like items and doesn't need to be overridden if the items
148 shouldn't change their appearance when pressed.
151 The item being pressed.
153 virtual void MouseClickBegin(int item
);
156 Must be overridden to reset the item appearance changed by
159 This method is called if the mouse capture was lost while the item was
160 pressed and must be overridden to restore the default item appearance
161 if it was changed in MouseClickBegin().
163 @see MouseDragCancelled(), wxMouseCaptureLostEvent
165 virtual void MouseClickCancelled(int item
);