1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/control.h
3 // Purpose: universal wxControl: adds handling of mnemonics
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_UNIV_CONTROL_H_
13 #define _WX_UNIV_CONTROL_H_
15 class WXDLLIMPEXP_FWD_CORE wxControlRenderer
;
16 class WXDLLIMPEXP_FWD_CORE wxInputHandler
;
17 class WXDLLIMPEXP_FWD_CORE wxRenderer
;
19 // we must include it as most/all control classes derive their handlers from
21 #include "wx/univ/inphand.h"
23 #include "wx/univ/inpcons.h"
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 // ----------------------------------------------------------------------------
30 typedef wxString wxControlAction
;
32 // the list of actions which apply to all controls (other actions are defined
33 // in the controls headers)
35 #define wxACTION_NONE _T("") // no action to perform
37 // ----------------------------------------------------------------------------
38 // wxControl: the base class for all GUI controls
39 // ----------------------------------------------------------------------------
41 class WXDLLIMPEXP_CORE wxControl
: public wxControlBase
, public wxInputConsumer
44 wxControl() { Init(); }
46 wxControl(wxWindow
*parent
,
48 const wxPoint
& pos
= wxDefaultPosition
,
49 const wxSize
& size
= wxDefaultSize
, long style
= 0,
50 const wxValidator
& validator
= wxDefaultValidator
,
51 const wxString
& name
= wxControlNameStr
)
55 Create(parent
, id
, pos
, size
, style
, validator
, name
);
58 bool Create(wxWindow
*parent
,
60 const wxPoint
& pos
= wxDefaultPosition
,
61 const wxSize
& size
= wxDefaultSize
, long style
= 0,
62 const wxValidator
& validator
= wxDefaultValidator
,
63 const wxString
& name
= wxControlNameStr
);
65 // this function will filter out '&' characters and will put the
66 // accelerator char (the one immediately after '&') into m_chAccel
67 virtual void SetLabel(const wxString
& label
);
69 // return the current label
70 virtual wxString
GetLabel() const { return m_label
; }
72 // wxUniversal-specific methods
74 // return the accel index in the string or -1 if none and puts the modified
75 // string into second parameter if non NULL
76 static int FindAccelIndex(const wxString
& label
,
77 wxString
*labelOnly
= NULL
);
79 // return the index of the accel char in the label or -1 if none
80 int GetAccelIndex() const { return m_indexAccel
; }
82 // return the accel char itself or 0 if none
83 wxChar
GetAccelChar() const
85 return m_indexAccel
== -1 ? _T('\0') : (wxChar
)m_label
[m_indexAccel
];
88 virtual wxWindow
*GetInputWindow() const { return (wxWindow
*)this; }
91 // common part of all ctors
94 // set m_label and m_indexAccel and refresh the control to show the new
95 // label (but, unlike SetLabel(), don't call the base class SetLabel() thus
96 // avoiding to change wxControlBase::m_labelOrig)
97 void UnivDoSetLabel(const wxString
& label
);
100 // label and accel info
104 DECLARE_DYNAMIC_CLASS(wxControl
)
105 DECLARE_EVENT_TABLE()
106 WX_DECLARE_INPUT_CONSUMER()
109 #endif // _WX_UNIV_CONTROL_H_