1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/control.h
3 // Purpose: universal wxControl: adds handling of mnemonics
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_UNIV_CONTROL_H_
12 #define _WX_UNIV_CONTROL_H_
14 class WXDLLIMPEXP_FWD_CORE wxControlRenderer
;
15 class WXDLLIMPEXP_FWD_CORE wxInputHandler
;
16 class WXDLLIMPEXP_FWD_CORE wxRenderer
;
18 // we must include it as most/all control classes derive their handlers from
20 #include "wx/univ/inphand.h"
22 #include "wx/univ/inpcons.h"
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 // ----------------------------------------------------------------------------
29 typedef wxString wxControlAction
;
31 // the list of actions which apply to all controls (other actions are defined
32 // in the controls headers)
34 #define wxACTION_NONE wxT("") // no action to perform
36 // ----------------------------------------------------------------------------
37 // wxControl: the base class for all GUI controls
38 // ----------------------------------------------------------------------------
40 class WXDLLIMPEXP_CORE wxControl
: public wxControlBase
, public wxInputConsumer
43 wxControl() { Init(); }
45 wxControl(wxWindow
*parent
,
47 const wxPoint
& pos
= wxDefaultPosition
,
48 const wxSize
& size
= wxDefaultSize
, long style
= 0,
49 const wxValidator
& validator
= wxDefaultValidator
,
50 const wxString
& name
= wxControlNameStr
)
54 Create(parent
, id
, pos
, size
, style
, validator
, name
);
57 bool Create(wxWindow
*parent
,
59 const wxPoint
& pos
= wxDefaultPosition
,
60 const wxSize
& size
= wxDefaultSize
, long style
= 0,
61 const wxValidator
& validator
= wxDefaultValidator
,
62 const wxString
& name
= wxControlNameStr
);
64 // this function will filter out '&' characters and will put the
65 // accelerator char (the one immediately after '&') into m_chAccel
66 virtual void SetLabel(const wxString
& label
);
68 // return the current label
69 virtual wxString
GetLabel() const { return m_label
; }
71 // wxUniversal-specific methods
73 // return the index of the accel char in the label or -1 if none
74 int GetAccelIndex() const { return m_indexAccel
; }
76 // return the accel char itself or 0 if none
77 wxChar
GetAccelChar() const
79 return m_indexAccel
== -1 ? wxT('\0') : (wxChar
)m_label
[m_indexAccel
];
82 virtual wxWindow
*GetInputWindow() const { return (wxWindow
*)this; }
85 // common part of all ctors
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
);
94 // label and accel info
98 DECLARE_DYNAMIC_CLASS(wxControl
)
100 WX_DECLARE_INPUT_CONSUMER()
103 #endif // _WX_UNIV_CONTROL_H_