2001-06-26 20:59:19 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/univ/inphand.h
|
|
|
|
// Purpose: wxInputHandler class maps the keyboard and mouse events to the
|
|
|
|
// actions which then are performed by the control
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 18.08.00
|
2001-07-02 19:42:27 +00:00
|
|
|
// Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
2001-06-26 20:59:19 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_UNIV_INPHAND_H_
|
|
|
|
#define _WX_UNIV_INPHAND_H_
|
|
|
|
|
2001-09-22 11:56:04 +00:00
|
|
|
#include "wx/univ/inpcons.h" // for wxControlAction(s)
|
2001-06-26 20:59:19 +00:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// types of the standard input handlers which can be passed to
|
|
|
|
// wxTheme::GetInputHandler()
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2009-07-23 20:30:22 +00:00
|
|
|
#define wxINP_HANDLER_DEFAULT wxT("")
|
|
|
|
#define wxINP_HANDLER_BUTTON wxT("button")
|
|
|
|
#define wxINP_HANDLER_CHECKBOX wxT("checkbox")
|
|
|
|
#define wxINP_HANDLER_CHECKLISTBOX wxT("checklistbox")
|
|
|
|
#define wxINP_HANDLER_COMBOBOX wxT("combobox")
|
|
|
|
#define wxINP_HANDLER_LISTBOX wxT("listbox")
|
|
|
|
#define wxINP_HANDLER_NOTEBOOK wxT("notebook")
|
|
|
|
#define wxINP_HANDLER_RADIOBTN wxT("radiobtn")
|
|
|
|
#define wxINP_HANDLER_SCROLLBAR wxT("scrollbar")
|
|
|
|
#define wxINP_HANDLER_SLIDER wxT("slider")
|
|
|
|
#define wxINP_HANDLER_SPINBTN wxT("spinbtn")
|
|
|
|
#define wxINP_HANDLER_STATUSBAR wxT("statusbar")
|
|
|
|
#define wxINP_HANDLER_TEXTCTRL wxT("textctrl")
|
|
|
|
#define wxINP_HANDLER_TOOLBAR wxT("toolbar")
|
|
|
|
#define wxINP_HANDLER_TOPLEVEL wxT("toplevel")
|
2001-06-26 20:59:19 +00:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxInputHandler: maps the events to the actions
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxInputHandler : public wxObject
|
2001-06-26 20:59:19 +00:00
|
|
|
{
|
|
|
|
public:
|
2004-08-10 13:08:43 +00:00
|
|
|
// map a keyboard event to one or more actions (pressed == true if the key
|
|
|
|
// was pressed, false if released), returns true if something was done
|
2001-09-22 11:56:04 +00:00
|
|
|
virtual bool HandleKey(wxInputConsumer *consumer,
|
2001-06-26 20:59:19 +00:00
|
|
|
const wxKeyEvent& event,
|
|
|
|
bool pressed) = 0;
|
|
|
|
|
|
|
|
// map a mouse (click) event to one or more actions
|
2001-09-22 11:56:04 +00:00
|
|
|
virtual bool HandleMouse(wxInputConsumer *consumer,
|
2001-06-26 20:59:19 +00:00
|
|
|
const wxMouseEvent& event) = 0;
|
|
|
|
|
|
|
|
// handle mouse movement (or enter/leave) event: it is separated from
|
|
|
|
// HandleMouse() for convenience as many controls don't care about mouse
|
|
|
|
// movements at all
|
2001-09-22 11:56:04 +00:00
|
|
|
virtual bool HandleMouseMove(wxInputConsumer *consumer,
|
2001-06-26 20:59:19 +00:00
|
|
|
const wxMouseEvent& event);
|
|
|
|
|
|
|
|
// do something with focus set/kill event: this is different from
|
|
|
|
// HandleMouseMove() as the mouse maybe over the control without it having
|
|
|
|
// focus
|
|
|
|
//
|
2004-08-10 13:08:43 +00:00
|
|
|
// return true to refresh the control, false otherwise
|
2001-09-22 11:56:04 +00:00
|
|
|
virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event);
|
2001-06-26 20:59:19 +00:00
|
|
|
|
|
|
|
// react to the app getting/losing activation
|
|
|
|
//
|
2004-08-10 13:08:43 +00:00
|
|
|
// return true to refresh the control, false otherwise
|
2001-09-22 11:56:04 +00:00
|
|
|
virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
|
2001-06-26 20:59:19 +00:00
|
|
|
|
|
|
|
// virtual dtor for any base class
|
|
|
|
virtual ~wxInputHandler();
|
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxStdInputHandler is just a base class for all other "standard" handlers
|
|
|
|
// and also provides the way to chain input handlers together
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxStdInputHandler : public wxInputHandler
|
2001-06-26 20:59:19 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxStdInputHandler(wxInputHandler *handler) : m_handler(handler) { }
|
|
|
|
|
2001-09-22 11:56:04 +00:00
|
|
|
virtual bool HandleKey(wxInputConsumer *consumer,
|
2001-06-26 20:59:19 +00:00
|
|
|
const wxKeyEvent& event,
|
2014-03-30 00:02:23 +00:00
|
|
|
bool pressed) wxOVERRIDE
|
2001-06-26 20:59:19 +00:00
|
|
|
{
|
2001-09-22 11:56:04 +00:00
|
|
|
return m_handler ? m_handler->HandleKey(consumer, event, pressed)
|
2004-08-10 13:08:43 +00:00
|
|
|
: false;
|
2001-06-26 20:59:19 +00:00
|
|
|
}
|
|
|
|
|
2001-09-22 11:56:04 +00:00
|
|
|
virtual bool HandleMouse(wxInputConsumer *consumer,
|
2014-03-30 00:02:23 +00:00
|
|
|
const wxMouseEvent& event) wxOVERRIDE
|
2001-06-26 20:59:19 +00:00
|
|
|
{
|
2004-08-10 13:08:43 +00:00
|
|
|
return m_handler ? m_handler->HandleMouse(consumer, event) : false;
|
2001-06-26 20:59:19 +00:00
|
|
|
}
|
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event) wxOVERRIDE
|
2001-06-26 20:59:19 +00:00
|
|
|
{
|
2004-08-10 13:08:43 +00:00
|
|
|
return m_handler ? m_handler->HandleMouseMove(consumer, event) : false;
|
2001-06-26 20:59:19 +00:00
|
|
|
}
|
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event) wxOVERRIDE
|
2001-06-26 20:59:19 +00:00
|
|
|
{
|
2004-08-10 13:08:43 +00:00
|
|
|
return m_handler ? m_handler->HandleFocus(consumer, event) : false;
|
2001-06-26 20:59:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
wxInputHandler *m_handler;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _WX_UNIV_INPHAND_H_
|