Files
wxWidgets/include/wx/univ/control.h
Vadim Zeitlin 0399bce91f 1. fixed (yet again) highlighting of buttons and checkboxes
2. wrote input handlers for the checkbox
3. fixed bug in wXMouseEvent generation in gtk/window.cpp
4. added focus rect drawing and check/radio geometry queries to wxRenderer


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxUNIVERSAL@8309 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2000-09-08 19:03:00 +00:00

118 lines
4.0 KiB
C++

/////////////////////////////////////////////////////////////////////////////
// Name: wx/univ/control.h
// Purpose: universal wxControl: adds handling of mnemonics
// Author: Vadim Zeitlin
// Modified by:
// Created: 14.08.00
// RCS-ID: $Id$
// Copyright: (c) 2000 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIV_CONTROL_H_
#define _WX_UNIV_CONTROL_H_
#ifdef __GNUG__
#pragma interface "control.h"
#endif
class WXDLLEXPORT wxControlRenderer;
class WXDLLEXPORT wxInputHandler;
class WXDLLEXPORT wxRenderer;
// ----------------------------------------------------------------------------
// wxControlAction: the action is currently just a string which identifies it,
// later it might become an atom (i.e. an opaque handler to string).
// ----------------------------------------------------------------------------
typedef wxString wxControlAction;
// the list of actions which apply to all controls (other actions are defined
// in the controls headers)
#define wxACTION_NONE _T("") // no action to perform
// ----------------------------------------------------------------------------
// wxControl: the base class for all GUI controls
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxControl : public wxControlBase
{
public:
wxControl() { Init(); }
wxControl(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxControlNameStr)
{
Init();
Create(parent, id, pos, size, style, validator, name);
}
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxControlNameStr);
// this function will filter out '&' characters and will put the
// accelerator char (the one immediately after '&') into m_chAccel
virtual void SetLabel(const wxString &label);
virtual wxString GetLabel() const;
// wxUniversal-specific methods
// return the index of the accel char in the label or -1 if none
int GetAccelIndex() const { return m_indexAccel; }
// return the accel char itself or 0 if none
wxChar GetAccelChar() const
{
return m_indexAccel == -1 ? _T('\0') : m_label[m_indexAccel];
}
// perform a control-dependent action: an action may have an optional
// numeric and another (also optional) string argument whose interpretation
// depends on the action
//
// NB: we might use ellipsis in PerformAction() declaration but this
// wouldn't be more efficient than always passing 2 unused parameters
// but would be more difficult. Another solution would be to have
// several overloaded versions but this will expose the problem of
// virtual function hiding we don't have here.
virtual bool PerformAction(const wxControlAction& action,
long numArg = -1l,
const wxString& strArg = wxEmptyString);
protected:
// get the type of event translator object for this control
virtual wxString GetInputHandlerType() const;
// event handlers
void OnMouse(wxMouseEvent& event);
void OnKeyDown(wxKeyEvent& event);
void OnKeyUp(wxKeyEvent& event);
void OnFocus(wxFocusEvent& event);
private:
// common part of all ctors
void Init();
// input processor
wxInputHandler *m_handler;
// label and accel info
wxString m_label;
int m_indexAccel;
DECLARE_DYNAMIC_CLASS(wxControl)
DECLARE_EVENT_TABLE()
};
#endif // _WX_UNIV_CONTROL_H_