inphand.h 4.6 KB

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