]> git.saurik.com Git - wxWidgets.git/blob - include/wx/univ/control.h
added wxHtmlCell::Get/SetId
[wxWidgets.git] / include / wx / univ / control.h
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
7 // RCS-ID: $Id$
8 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_UNIV_CONTROL_H_
13 #define _WX_UNIV_CONTROL_H_
14
15 #ifdef __GNUG__
16 #pragma interface "control.h"
17 #endif
18
19 class WXDLLEXPORT wxControlRenderer;
20 class WXDLLEXPORT wxInputHandler;
21 class WXDLLEXPORT wxRenderer;
22
23 // we must include it as most/all control classes derive their handlers from
24 // it
25 #include "wx/univ/inphand.h"
26
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 // ----------------------------------------------------------------------------
31
32 typedef wxString wxControlAction;
33
34 // the list of actions which apply to all controls (other actions are defined
35 // in the controls headers)
36
37 #define wxACTION_NONE _T("") // no action to perform
38
39 // ----------------------------------------------------------------------------
40 // wxControl: the base class for all GUI controls
41 // ----------------------------------------------------------------------------
42
43 class WXDLLEXPORT wxControl : public wxControlBase
44 {
45 public:
46 wxControl() { Init(); }
47
48 wxControl(wxWindow *parent,
49 wxWindowID id,
50 const wxPoint& pos = wxDefaultPosition,
51 const wxSize& size = wxDefaultSize, long style = 0,
52 const wxValidator& validator = wxDefaultValidator,
53 const wxString& name = wxControlNameStr)
54 {
55 Init();
56
57 Create(parent, id, pos, size, style, validator, name);
58 }
59
60 bool Create(wxWindow *parent,
61 wxWindowID id,
62 const wxPoint& pos = wxDefaultPosition,
63 const wxSize& size = wxDefaultSize, long style = 0,
64 const wxValidator& validator = wxDefaultValidator,
65 const wxString& name = wxControlNameStr);
66
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;
71
72 // wxUniversal-specific methods
73
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);
78
79 // return the index of the accel char in the label or -1 if none
80 int GetAccelIndex() const { return m_indexAccel; }
81
82 // return the accel char itself or 0 if none
83 wxChar GetAccelChar() const
84 {
85 return m_indexAccel == -1 ? _T('\0') : m_label[m_indexAccel];
86 }
87
88 // get the input handler of this control
89 wxInputHandler *GetInputHandler() const { return m_handler; }
90
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
94 //
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,
101 long numArg = -1l,
102 const wxString& strArg = wxEmptyString);
103
104 protected:
105 // event handlers
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);
111
112 // common part of all ctors
113 void Init();
114
115 // create input handler by name
116 void CreateInputHandler(const wxString& inphandler);
117
118 // input processor (never deleted, the theme deletes it itself)
119 wxInputHandler *m_handler;
120
121 private:
122 // label and accel info
123 wxString m_label;
124 int m_indexAccel;
125
126 DECLARE_DYNAMIC_CLASS(wxControl)
127 DECLARE_EVENT_TABLE()
128 };
129
130 #endif // _WX_UNIV_CONTROL_H_