1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/inphand.h
3 // Purpose: wxInputHandler class maps the keyboard and mouse events to the
4 // actions which then are performed by the control
5 // Author: Vadim Zeitlin
9 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
10 // Licence: wxWindows licence
11 ///////////////////////////////////////////////////////////////////////////////
13 #ifndef _WX_UNIV_INPHAND_H_
14 #define _WX_UNIV_INPHAND_H_
16 #include "wx/univ/inpcons.h" // for wxControlAction(s)
18 // ----------------------------------------------------------------------------
19 // types of the standard input handlers which can be passed to
20 // wxTheme::GetInputHandler()
21 // ----------------------------------------------------------------------------
23 #define wxINP_HANDLER_DEFAULT _T("")
24 #define wxINP_HANDLER_BUTTON _T("button")
25 #define wxINP_HANDLER_CHECKBOX _T("checkbox")
26 #define wxINP_HANDLER_CHECKLISTBOX _T("checklistbox")
27 #define wxINP_HANDLER_COMBOBOX _T("combobox")
28 #define wxINP_HANDLER_LISTBOX _T("listbox")
29 #define wxINP_HANDLER_NOTEBOOK _T("notebook")
30 #define wxINP_HANDLER_RADIOBTN _T("radiobtn")
31 #define wxINP_HANDLER_SCROLLBAR _T("scrollbar")
32 #define wxINP_HANDLER_SLIDER _T("slider")
33 #define wxINP_HANDLER_SPINBTN _T("spinbtn")
34 #define wxINP_HANDLER_STATUSBAR _T("statusbar")
35 #define wxINP_HANDLER_TEXTCTRL _T("textctrl")
36 #define wxINP_HANDLER_TOOLBAR _T("toolbar")
37 #define wxINP_HANDLER_TOPLEVEL _T("toplevel")
39 // ----------------------------------------------------------------------------
40 // wxInputHandler: maps the events to the actions
41 // ----------------------------------------------------------------------------
43 class WXDLLIMPEXP_CORE wxInputHandler
: public wxObject
46 // map a keyboard event to one or more actions (pressed == true if the key
47 // was pressed, false if released), returns true if something was done
48 virtual bool HandleKey(wxInputConsumer
*consumer
,
49 const wxKeyEvent
& event
,
52 // map a mouse (click) event to one or more actions
53 virtual bool HandleMouse(wxInputConsumer
*consumer
,
54 const wxMouseEvent
& event
) = 0;
56 // handle mouse movement (or enter/leave) event: it is separated from
57 // HandleMouse() for convenience as many controls don't care about mouse
59 virtual bool HandleMouseMove(wxInputConsumer
*consumer
,
60 const wxMouseEvent
& event
);
62 // do something with focus set/kill event: this is different from
63 // HandleMouseMove() as the mouse maybe over the control without it having
66 // return true to refresh the control, false otherwise
67 virtual bool HandleFocus(wxInputConsumer
*consumer
, const wxFocusEvent
& event
);
69 // react to the app getting/losing activation
71 // return true to refresh the control, false otherwise
72 virtual bool HandleActivation(wxInputConsumer
*consumer
, bool activated
);
74 // virtual dtor for any base class
75 virtual ~wxInputHandler();
78 // ----------------------------------------------------------------------------
79 // wxStdInputHandler is just a base class for all other "standard" handlers
80 // and also provides the way to chain input handlers together
81 // ----------------------------------------------------------------------------
83 class WXDLLIMPEXP_CORE wxStdInputHandler
: public wxInputHandler
86 wxStdInputHandler(wxInputHandler
*handler
) : m_handler(handler
) { }
88 virtual bool HandleKey(wxInputConsumer
*consumer
,
89 const wxKeyEvent
& event
,
92 return m_handler
? m_handler
->HandleKey(consumer
, event
, pressed
)
96 virtual bool HandleMouse(wxInputConsumer
*consumer
,
97 const wxMouseEvent
& event
)
99 return m_handler
? m_handler
->HandleMouse(consumer
, event
) : false;
102 virtual bool HandleMouseMove(wxInputConsumer
*consumer
, const wxMouseEvent
& event
)
104 return m_handler
? m_handler
->HandleMouseMove(consumer
, event
) : false;
107 virtual bool HandleFocus(wxInputConsumer
*consumer
, const wxFocusEvent
& event
)
109 return m_handler
? m_handler
->HandleFocus(consumer
, event
) : false;
113 wxInputHandler
*m_handler
;
116 #endif // _WX_UNIV_INPHAND_H_