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 license
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_UNIV_CONTROL_H_
13 #define _WX_UNIV_CONTROL_H_
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 // ----------------------------------------------------------------------------
28 // wxControlAction: the action is currently just a string which identifies it,
29 // later it might become an atom (i.e. an opaque handler to string).
30 // ----------------------------------------------------------------------------
32 typedef wxString wxControlAction
;
34 // the list of actions which apply to all controls (other actions are defined
35 // in the controls headers)
37 #define wxACTION_NONE _T("") // no action to perform
39 // ----------------------------------------------------------------------------
40 // wxControl: the base class for all GUI controls
41 // ----------------------------------------------------------------------------
43 class WXDLLEXPORT wxControl
: public wxControlBase
46 wxControl() { Init(); }
48 wxControl(wxWindow
*parent
,
50 const wxPoint
& pos
= wxDefaultPosition
,
51 const wxSize
& size
= wxDefaultSize
, long style
= 0,
52 const wxValidator
& validator
= wxDefaultValidator
,
53 const wxString
& name
= wxControlNameStr
)
57 Create(parent
, id
, pos
, size
, style
, validator
, name
);
60 bool Create(wxWindow
*parent
,
62 const wxPoint
& pos
= wxDefaultPosition
,
63 const wxSize
& size
= wxDefaultSize
, long style
= 0,
64 const wxValidator
& validator
= wxDefaultValidator
,
65 const wxString
& name
= wxControlNameStr
);
67 // this function will filter out '&' characters and will put the
68 // accelerator char (the one immediately after '&') into m_chAccel
69 virtual void SetLabel(const wxString
&label
);
70 virtual wxString
GetLabel() const;
72 // wxUniversal-specific methods
74 // return the accel index in the string or -1 if none and puts the modified
75 // string intosecond 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') : m_label
[m_indexAccel
];
88 // get the input handler of this control
89 wxInputHandler
*GetInputHandler() const { return m_handler
; }
91 // perform a control-dependent action: an action may have an optional
92 // numeric and another (also optional) string argument whose interpretation
93 // depends on the action
95 // NB: we might use ellipsis in PerformAction() declaration but this
96 // wouldn't be more efficient than always passing 2 unused parameters
97 // but would be more difficult. Another solution would be to have
98 // several overloaded versions but this will expose the problem of
99 // virtual function hiding we don't have here.
100 virtual bool PerformAction(const wxControlAction
& action
,
102 const wxString
& strArg
= wxEmptyString
);
106 void OnMouse(wxMouseEvent
& event
);
107 void OnKeyDown(wxKeyEvent
& event
);
108 void OnKeyUp(wxKeyEvent
& event
);
109 void OnFocus(wxFocusEvent
& event
);
110 void OnActivate(wxActivateEvent
& event
);
112 // common part of all ctors
115 // create input handler by name
116 void CreateInputHandler(const wxString
& inphandler
);
118 // input processor (never deleted, the theme deletes it itself)
119 wxInputHandler
*m_handler
;
122 // label and accel info
126 DECLARE_DYNAMIC_CLASS(wxControl
)
127 DECLARE_EVENT_TABLE()
130 #endif // _WX_UNIV_CONTROL_H_