]>
Commit | Line | Data |
---|---|---|
1e6feb95 VZ |
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 | |
6 | // Modified by: | |
7 | // Created: 18.08.00 | |
442b35b5 | 8 | // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com) |
65571936 | 9 | // Licence: wxWindows licence |
1e6feb95 VZ |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_UNIV_INPHAND_H_ | |
13 | #define _WX_UNIV_INPHAND_H_ | |
14 | ||
23645bfa | 15 | #include "wx/univ/inpcons.h" // for wxControlAction(s) |
1e6feb95 VZ |
16 | |
17 | // ---------------------------------------------------------------------------- | |
18 | // types of the standard input handlers which can be passed to | |
19 | // wxTheme::GetInputHandler() | |
20 | // ---------------------------------------------------------------------------- | |
21 | ||
9a83f860 VZ |
22 | #define wxINP_HANDLER_DEFAULT wxT("") |
23 | #define wxINP_HANDLER_BUTTON wxT("button") | |
24 | #define wxINP_HANDLER_CHECKBOX wxT("checkbox") | |
25 | #define wxINP_HANDLER_CHECKLISTBOX wxT("checklistbox") | |
26 | #define wxINP_HANDLER_COMBOBOX wxT("combobox") | |
27 | #define wxINP_HANDLER_LISTBOX wxT("listbox") | |
28 | #define wxINP_HANDLER_NOTEBOOK wxT("notebook") | |
29 | #define wxINP_HANDLER_RADIOBTN wxT("radiobtn") | |
30 | #define wxINP_HANDLER_SCROLLBAR wxT("scrollbar") | |
31 | #define wxINP_HANDLER_SLIDER wxT("slider") | |
32 | #define wxINP_HANDLER_SPINBTN wxT("spinbtn") | |
33 | #define wxINP_HANDLER_STATUSBAR wxT("statusbar") | |
34 | #define wxINP_HANDLER_TEXTCTRL wxT("textctrl") | |
35 | #define wxINP_HANDLER_TOOLBAR wxT("toolbar") | |
36 | #define wxINP_HANDLER_TOPLEVEL wxT("toplevel") | |
1e6feb95 VZ |
37 | |
38 | // ---------------------------------------------------------------------------- | |
39 | // wxInputHandler: maps the events to the actions | |
40 | // ---------------------------------------------------------------------------- | |
41 | ||
53a2db12 | 42 | class WXDLLIMPEXP_CORE wxInputHandler : public wxObject |
1e6feb95 VZ |
43 | { |
44 | public: | |
a290fa5a WS |
45 | // map a keyboard event to one or more actions (pressed == true if the key |
46 | // was pressed, false if released), returns true if something was done | |
23645bfa | 47 | virtual bool HandleKey(wxInputConsumer *consumer, |
1e6feb95 VZ |
48 | const wxKeyEvent& event, |
49 | bool pressed) = 0; | |
50 | ||
51 | // map a mouse (click) event to one or more actions | |
23645bfa | 52 | virtual bool HandleMouse(wxInputConsumer *consumer, |
1e6feb95 VZ |
53 | const wxMouseEvent& event) = 0; |
54 | ||
55 | // handle mouse movement (or enter/leave) event: it is separated from | |
56 | // HandleMouse() for convenience as many controls don't care about mouse | |
57 | // movements at all | |
23645bfa | 58 | virtual bool HandleMouseMove(wxInputConsumer *consumer, |
1e6feb95 VZ |
59 | const wxMouseEvent& event); |
60 | ||
61 | // do something with focus set/kill event: this is different from | |
62 | // HandleMouseMove() as the mouse maybe over the control without it having | |
63 | // focus | |
64 | // | |
a290fa5a | 65 | // return true to refresh the control, false otherwise |
23645bfa | 66 | virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event); |
1e6feb95 VZ |
67 | |
68 | // react to the app getting/losing activation | |
69 | // | |
a290fa5a | 70 | // return true to refresh the control, false otherwise |
23645bfa | 71 | virtual bool HandleActivation(wxInputConsumer *consumer, bool activated); |
1e6feb95 VZ |
72 | |
73 | // virtual dtor for any base class | |
74 | virtual ~wxInputHandler(); | |
75 | }; | |
76 | ||
77 | // ---------------------------------------------------------------------------- | |
78 | // wxStdInputHandler is just a base class for all other "standard" handlers | |
79 | // and also provides the way to chain input handlers together | |
80 | // ---------------------------------------------------------------------------- | |
81 | ||
53a2db12 | 82 | class WXDLLIMPEXP_CORE wxStdInputHandler : public wxInputHandler |
1e6feb95 VZ |
83 | { |
84 | public: | |
85 | wxStdInputHandler(wxInputHandler *handler) : m_handler(handler) { } | |
86 | ||
23645bfa | 87 | virtual bool HandleKey(wxInputConsumer *consumer, |
1e6feb95 VZ |
88 | const wxKeyEvent& event, |
89 | bool pressed) | |
90 | { | |
23645bfa | 91 | return m_handler ? m_handler->HandleKey(consumer, event, pressed) |
a290fa5a | 92 | : false; |
1e6feb95 VZ |
93 | } |
94 | ||
23645bfa | 95 | virtual bool HandleMouse(wxInputConsumer *consumer, |
1e6feb95 VZ |
96 | const wxMouseEvent& event) |
97 | { | |
a290fa5a | 98 | return m_handler ? m_handler->HandleMouse(consumer, event) : false; |
1e6feb95 VZ |
99 | } |
100 | ||
23645bfa | 101 | virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event) |
1e6feb95 | 102 | { |
a290fa5a | 103 | return m_handler ? m_handler->HandleMouseMove(consumer, event) : false; |
1e6feb95 VZ |
104 | } |
105 | ||
23645bfa | 106 | virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event) |
1e6feb95 | 107 | { |
a290fa5a | 108 | return m_handler ? m_handler->HandleFocus(consumer, event) : false; |
1e6feb95 VZ |
109 | } |
110 | ||
111 | private: | |
112 | wxInputHandler *m_handler; | |
113 | }; | |
114 | ||
115 | #endif // _WX_UNIV_INPHAND_H_ |