]> git.saurik.com Git - wxWidgets.git/blame - include/wx/univ/control.h
activating DrawRectangle optimization
[wxWidgets.git] / include / wx / univ / control.h
CommitLineData
1e6feb95
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/univ/control.h
3// Purpose: universal wxControl: adds handling of mnemonics
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 14.08.00
7// RCS-ID: $Id$
442b35b5 8// Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
65571936 9// Licence: wxWindows licence
1e6feb95
VZ
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_UNIV_CONTROL_H_
13#define _WX_UNIV_CONTROL_H_
14
b5dbe15d
VS
15class WXDLLIMPEXP_FWD_CORE wxControlRenderer;
16class WXDLLIMPEXP_FWD_CORE wxInputHandler;
17class WXDLLIMPEXP_FWD_CORE wxRenderer;
1e6feb95
VZ
18
19// we must include it as most/all control classes derive their handlers from
20// it
21#include "wx/univ/inphand.h"
22
23645bfa
VS
23#include "wx/univ/inpcons.h"
24
1e6feb95
VZ
25// ----------------------------------------------------------------------------
26// wxControlAction: the action is currently just a string which identifies it,
27// later it might become an atom (i.e. an opaque handler to string).
28// ----------------------------------------------------------------------------
29
30typedef wxString wxControlAction;
31
32// the list of actions which apply to all controls (other actions are defined
33// in the controls headers)
34
9a83f860 35#define wxACTION_NONE wxT("") // no action to perform
1e6feb95
VZ
36
37// ----------------------------------------------------------------------------
38// wxControl: the base class for all GUI controls
39// ----------------------------------------------------------------------------
40
53a2db12 41class WXDLLIMPEXP_CORE wxControl : public wxControlBase, public wxInputConsumer
1e6feb95
VZ
42{
43public:
6463b9f5 44 wxControl() { Init(); }
1e6feb95
VZ
45
46 wxControl(wxWindow *parent,
47 wxWindowID id,
48 const wxPoint& pos = wxDefaultPosition,
49 const wxSize& size = wxDefaultSize, long style = 0,
50 const wxValidator& validator = wxDefaultValidator,
6463b9f5
JS
51 const wxString& name = wxControlNameStr)
52 {
53 Init();
54
55 Create(parent, id, pos, size, style, validator, name);
56 }
1e6feb95
VZ
57
58 bool Create(wxWindow *parent,
59 wxWindowID id,
60 const wxPoint& pos = wxDefaultPosition,
61 const wxSize& size = wxDefaultSize, long style = 0,
62 const wxValidator& validator = wxDefaultValidator,
63 const wxString& name = wxControlNameStr);
64
65 // this function will filter out '&' characters and will put the
66 // accelerator char (the one immediately after '&') into m_chAccel
39bc0347
VZ
67 virtual void SetLabel(const wxString& label);
68
69 // return the current label
70 virtual wxString GetLabel() const { return m_label; }
1e6feb95
VZ
71
72 // wxUniversal-specific methods
73
1e6feb95
VZ
74 // return the index of the accel char in the label or -1 if none
75 int GetAccelIndex() const { return m_indexAccel; }
76
77 // return the accel char itself or 0 if none
78 wxChar GetAccelChar() const
79 {
9a83f860 80 return m_indexAccel == -1 ? wxT('\0') : (wxChar)m_label[m_indexAccel];
1e6feb95
VZ
81 }
82
23645bfa 83 virtual wxWindow *GetInputWindow() const { return (wxWindow*)this; }
1e6feb95
VZ
84
85protected:
1e6feb95
VZ
86 // common part of all ctors
87 void Init();
88
39bc0347
VZ
89 // set m_label and m_indexAccel and refresh the control to show the new
90 // label (but, unlike SetLabel(), don't call the base class SetLabel() thus
91 // avoiding to change wxControlBase::m_labelOrig)
92 void UnivDoSetLabel(const wxString& label);
93
1e6feb95
VZ
94private:
95 // label and accel info
96 wxString m_label;
97 int m_indexAccel;
98
99 DECLARE_DYNAMIC_CLASS(wxControl)
100 DECLARE_EVENT_TABLE()
23645bfa 101 WX_DECLARE_INPUT_CONSUMER()
1e6feb95
VZ
102};
103
104#endif // _WX_UNIV_CONTROL_H_