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