]> git.saurik.com Git - wxWidgets.git/blob - include/wx/univ/control.h
extracted wxFrame::MSWTranslateMessage() implementation into new MSWDoTranslateMessag...
[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 licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_UNIV_CONTROL_H_
13 #define _WX_UNIV_CONTROL_H_
14
15 class WXDLLEXPORT wxControlRenderer;
16 class WXDLLEXPORT wxInputHandler;
17 class WXDLLEXPORT wxRenderer;
18
19 // we must include it as most/all control classes derive their handlers from
20 // it
21 #include "wx/univ/inphand.h"
22
23 #include "wx/univ/inpcons.h"
24
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 // ----------------------------------------------------------------------------
29
30 typedef wxString wxControlAction;
31
32 // the list of actions which apply to all controls (other actions are defined
33 // in the controls headers)
34
35 #define wxACTION_NONE _T("") // no action to perform
36
37 // ----------------------------------------------------------------------------
38 // wxControl: the base class for all GUI controls
39 // ----------------------------------------------------------------------------
40
41 class WXDLLEXPORT wxControl : public wxControlBase, public wxInputConsumer
42 {
43 public:
44 wxControl() { Init(); }
45
46 wxControl(wxWindow *parent,
47 wxWindowID id,
48 const wxPoint& pos = wxDefaultPosition,
49 const wxSize& size = wxDefaultSize, long style = 0,
50 const wxValidator& validator = wxDefaultValidator,
51 const wxString& name = wxControlNameStr)
52 {
53 Init();
54
55 Create(parent, id, pos, size, style, validator, name);
56 }
57
58 bool Create(wxWindow *parent,
59 wxWindowID id,
60 const wxPoint& pos = wxDefaultPosition,
61 const wxSize& size = wxDefaultSize, long style = 0,
62 const wxValidator& validator = wxDefaultValidator,
63 const wxString& name = wxControlNameStr);
64
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);
68 virtual wxString GetLabel() const;
69
70 // wxUniversal-specific methods
71
72 // return the accel index in the string or -1 if none and puts the modified
73 // string intosecond parameter if non NULL
74 static int FindAccelIndex(const wxString& label,
75 wxString *labelOnly = NULL);
76
77 // return the index of the accel char in the label or -1 if none
78 int GetAccelIndex() const { return m_indexAccel; }
79
80 // return the accel char itself or 0 if none
81 wxChar GetAccelChar() const
82 {
83 return m_indexAccel == -1 ? _T('\0') : m_label[m_indexAccel];
84 }
85
86 virtual wxWindow *GetInputWindow() const { return (wxWindow*)this; }
87
88 protected:
89 // common part of all ctors
90 void Init();
91
92 private:
93 // label and accel info
94 wxString m_label;
95 int m_indexAccel;
96
97 DECLARE_DYNAMIC_CLASS(wxControl)
98 DECLARE_EVENT_TABLE()
99 WX_DECLARE_INPUT_CONSUMER()
100 };
101
102 #endif // _WX_UNIV_CONTROL_H_