]> git.saurik.com Git - wxWidgets.git/blob - include/wx/univ/control.h
Common code for the same handling of wxSL_INVERSE.
[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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
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 #include "wx/univ/inpcons.h"
28
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 // ----------------------------------------------------------------------------
33
34 typedef wxString wxControlAction;
35
36 // the list of actions which apply to all controls (other actions are defined
37 // in the controls headers)
38
39 #define wxACTION_NONE _T("") // no action to perform
40
41 // ----------------------------------------------------------------------------
42 // wxControl: the base class for all GUI controls
43 // ----------------------------------------------------------------------------
44
45 class WXDLLEXPORT wxControl : public wxControlBase, public wxInputConsumer
46 {
47 public:
48 wxControl() { Init(); }
49
50 wxControl(wxWindow *parent,
51 wxWindowID id,
52 const wxPoint& pos = wxDefaultPosition,
53 const wxSize& size = wxDefaultSize, long style = 0,
54 const wxValidator& validator = wxDefaultValidator,
55 const wxString& name = wxControlNameStr)
56 {
57 Init();
58
59 Create(parent, id, pos, size, style, validator, name);
60 }
61
62 bool Create(wxWindow *parent,
63 wxWindowID id,
64 const wxPoint& pos = wxDefaultPosition,
65 const wxSize& size = wxDefaultSize, long style = 0,
66 const wxValidator& validator = wxDefaultValidator,
67 const wxString& name = wxControlNameStr);
68
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;
73
74 // wxUniversal-specific methods
75
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);
80
81 // return the index of the accel char in the label or -1 if none
82 int GetAccelIndex() const { return m_indexAccel; }
83
84 // return the accel char itself or 0 if none
85 wxChar GetAccelChar() const
86 {
87 return m_indexAccel == -1 ? _T('\0') : m_label[m_indexAccel];
88 }
89
90 virtual wxWindow *GetInputWindow() const { return (wxWindow*)this; }
91
92 protected:
93 // common part of all ctors
94 void Init();
95
96 private:
97 // label and accel info
98 wxString m_label;
99 int m_indexAccel;
100
101 DECLARE_DYNAMIC_CLASS(wxControl)
102 DECLARE_EVENT_TABLE()
103 WX_DECLARE_INPUT_CONSUMER()
104 };
105
106 #endif // _WX_UNIV_CONTROL_H_