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