2001-06-26 16:59:19 -04: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
|
|
|
|
// RCS-ID: $Id$
|
2001-07-02 15:42:27 -04:00
|
|
|
// Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
2001-06-26 16:59:19 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_UNIV_INPHAND_H_
|
|
|
|
#define _WX_UNIV_INPHAND_H_
|
|
|
|
|
2003-08-09 08:38:21 -04:00
|
|
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
2001-06-26 16:59:19 -04:00
|
|
|
#pragma interface "inphand.h"
|
|
|
|
#endif
|
|
|
|
|
2001-09-22 07:56:04 -04:00
|
|
|
#include "wx/univ/inpcons.h" // for wxControlAction(s)
|
2001-06-26 16:59:19 -04:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// types of the standard input handlers which can be passed to
|
|
|
|
// wxTheme::GetInputHandler()
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#define wxINP_HANDLER_DEFAULT _T("")
|
|
|
|
#define wxINP_HANDLER_BUTTON _T("button")
|
|
|
|
#define wxINP_HANDLER_CHECKBOX _T("checkbox")
|
|
|
|
#define wxINP_HANDLER_CHECKLISTBOX _T("checklistbox")
|
|
|
|
#define wxINP_HANDLER_COMBOBOX _T("combobox")
|
|
|
|
#define wxINP_HANDLER_LISTBOX _T("listbox")
|
|
|
|
#define wxINP_HANDLER_NOTEBOOK _T("notebook")
|
|
|
|
#define wxINP_HANDLER_RADIOBTN _T("radiobtn")
|
|
|
|
#define wxINP_HANDLER_SCROLLBAR _T("scrollbar")
|
|
|
|
#define wxINP_HANDLER_SLIDER _T("slider")
|
|
|
|
#define wxINP_HANDLER_SPINBTN _T("spinbtn")
|
2001-10-14 17:38:58 -04:00
|
|
|
#define wxINP_HANDLER_STATUSBAR _T("statusbar")
|
2001-06-26 16:59:19 -04:00
|
|
|
#define wxINP_HANDLER_TEXTCTRL _T("textctrl")
|
2002-02-27 16:42:48 -05:00
|
|
|
#define wxINP_HANDLER_TOOLBAR _T("toolbar")
|
2001-09-28 19:39:55 -04:00
|
|
|
#define wxINP_HANDLER_TOPLEVEL _T("toplevel")
|
2001-06-26 16:59:19 -04:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxInputHandler: maps the events to the actions
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2001-09-22 07:56:04 -04:00
|
|
|
class WXDLLEXPORT wxInputHandler : public wxObject
|
2001-06-26 16:59:19 -04:00
|
|
|
{
|
|
|
|
public:
|
2004-08-10 09:08:43 -04: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 07:56:04 -04:00
|
|
|
virtual bool HandleKey(wxInputConsumer *consumer,
|
2001-06-26 16:59:19 -04:00
|
|
|
const wxKeyEvent& event,
|
|
|
|
bool pressed) = 0;
|
|
|
|
|
|
|
|
// map a mouse (click) event to one or more actions
|
2001-09-22 07:56:04 -04:00
|
|
|
virtual bool HandleMouse(wxInputConsumer *consumer,
|
2001-06-26 16:59:19 -04: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 07:56:04 -04:00
|
|
|
virtual bool HandleMouseMove(wxInputConsumer *consumer,
|
2001-06-26 16:59:19 -04: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 09:08:43 -04:00
|
|
|
// return true to refresh the control, false otherwise
|
2001-09-22 07:56:04 -04:00
|
|
|
virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event);
|
2001-06-26 16:59:19 -04:00
|
|
|
|
|
|
|
// react to the app getting/losing activation
|
|
|
|
//
|
2004-08-10 09:08:43 -04:00
|
|
|
// return true to refresh the control, false otherwise
|
2001-09-22 07:56:04 -04:00
|
|
|
virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
|
2001-06-26 16:59:19 -04: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
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxStdInputHandler : public wxInputHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxStdInputHandler(wxInputHandler *handler) : m_handler(handler) { }
|
|
|
|
|
2001-09-22 07:56:04 -04:00
|
|
|
virtual bool HandleKey(wxInputConsumer *consumer,
|
2001-06-26 16:59:19 -04:00
|
|
|
const wxKeyEvent& event,
|
|
|
|
bool pressed)
|
|
|
|
{
|
2001-09-22 07:56:04 -04:00
|
|
|
return m_handler ? m_handler->HandleKey(consumer, event, pressed)
|
2004-08-10 09:08:43 -04:00
|
|
|
: false;
|
2001-06-26 16:59:19 -04:00
|
|
|
}
|
|
|
|
|
2001-09-22 07:56:04 -04:00
|
|
|
virtual bool HandleMouse(wxInputConsumer *consumer,
|
2001-06-26 16:59:19 -04:00
|
|
|
const wxMouseEvent& event)
|
|
|
|
{
|
2004-08-10 09:08:43 -04:00
|
|
|
return m_handler ? m_handler->HandleMouse(consumer, event) : false;
|
2001-06-26 16:59:19 -04:00
|
|
|
}
|
|
|
|
|
2001-09-22 07:56:04 -04:00
|
|
|
virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event)
|
2001-06-26 16:59:19 -04:00
|
|
|
{
|
2004-08-10 09:08:43 -04:00
|
|
|
return m_handler ? m_handler->HandleMouseMove(consumer, event) : false;
|
2001-06-26 16:59:19 -04:00
|
|
|
}
|
|
|
|
|
2001-09-22 07:56:04 -04:00
|
|
|
virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event)
|
2001-06-26 16:59:19 -04:00
|
|
|
{
|
2004-08-10 09:08:43 -04:00
|
|
|
return m_handler ? m_handler->HandleFocus(consumer, event) : false;
|
2001-06-26 16:59:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
wxInputHandler *m_handler;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _WX_UNIV_INPHAND_H_
|