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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "control.h"
19 class WXDLLEXPORT wxControlRenderer
;
20 class WXDLLEXPORT wxInputHandler
;
21 class WXDLLEXPORT wxRenderer
;
23 // we must include it as most/all control classes derive their handlers from
25 #include "wx/univ/inphand.h"
27 #include "wx/univ/inpcons.h"
29 // ----------------------------------------------------------------------------
30 // wxControlAction: the action is currently just a string which identifies it,
31 // later it might become an atom (i.e. an opaque handler to string).
32 // ----------------------------------------------------------------------------
34 typedef wxString wxControlAction
;
36 // the list of actions which apply to all controls (other actions are defined
37 // in the controls headers)
39 #define wxACTION_NONE _T("") // no action to perform
41 // ----------------------------------------------------------------------------
42 // wxControl: the base class for all GUI controls
43 // ----------------------------------------------------------------------------
45 class WXDLLEXPORT wxControl
: public wxControlBase
, public wxInputConsumer
48 wxControl() { Init(); }
50 wxControl(wxWindow
*parent
,
52 const wxPoint
& pos
= wxDefaultPosition
,
53 const wxSize
& size
= wxDefaultSize
, long style
= 0,
54 const wxValidator
& validator
= wxDefaultValidator
,
55 const wxString
& name
= wxControlNameStr
)
59 Create(parent
, id
, pos
, size
, style
, validator
, name
);
62 bool Create(wxWindow
*parent
,
64 const wxPoint
& pos
= wxDefaultPosition
,
65 const wxSize
& size
= wxDefaultSize
, long style
= 0,
66 const wxValidator
& validator
= wxDefaultValidator
,
67 const wxString
& name
= wxControlNameStr
);
69 // this function will filter out '&' characters and will put the
70 // accelerator char (the one immediately after '&') into m_chAccel
71 virtual void SetLabel(const wxString
&label
);
72 virtual wxString
GetLabel() const;
74 // wxUniversal-specific methods
76 // return the accel index in the string or -1 if none and puts the modified
77 // string intosecond parameter if non NULL
78 static int FindAccelIndex(const wxString
& label
,
79 wxString
*labelOnly
= NULL
);
81 // return the index of the accel char in the label or -1 if none
82 int GetAccelIndex() const { return m_indexAccel
; }
84 // return the accel char itself or 0 if none
85 wxChar
GetAccelChar() const
87 return m_indexAccel
== -1 ? _T('\0') : m_label
[m_indexAccel
];
90 virtual wxWindow
*GetInputWindow() const { return (wxWindow
*)this; }
93 // common part of all ctors
97 // label and accel info
101 DECLARE_DYNAMIC_CLASS(wxControl
)
102 DECLARE_EVENT_TABLE()
103 WX_DECLARE_INPUT_CONSUMER()
106 #endif // _WX_UNIV_CONTROL_H_