/[pcsx2_0.9.7]/branch/r3113_0.9.7_beta/3rdparty/wxWidgets/include/wx/menuitem.h
ViewVC logotype

Contents of /branch/r3113_0.9.7_beta/3rdparty/wxWidgets/include/wx/menuitem.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 32 - (show annotations) (download)
Tue Sep 7 03:29:01 2010 UTC (9 years, 5 months ago) by william
File MIME type: text/plain
File size: 7815 byte(s)
branching from upstream revision (http://pcsx2.googlecode.com/svn/trunk
): r3113 to
https://svn.netsolutions.dnsalias.com/websvn/ps2/pcsx2/pcsx2_0.9.7/branch/r3113_0.9.7_beta
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/menuitem.h
3 // Purpose: wxMenuItem class
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 25.10.99
7 // RCS-ID: $Id: menuitem.h 49563 2007-10-31 20:46:21Z VZ $
8 // Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_MENUITEM_H_BASE_
13 #define _WX_MENUITEM_H_BASE_
14
15 #include "wx/defs.h"
16
17 #if wxUSE_MENUS
18
19 // ----------------------------------------------------------------------------
20 // headers
21 // ----------------------------------------------------------------------------
22
23 #include "wx/object.h" // base class
24
25 // ----------------------------------------------------------------------------
26 // forward declarations
27 // ----------------------------------------------------------------------------
28
29 class WXDLLIMPEXP_FWD_CORE wxAcceleratorEntry;
30 class WXDLLIMPEXP_FWD_CORE wxMenuItem;
31 class WXDLLIMPEXP_FWD_CORE wxMenu;
32
33 // ----------------------------------------------------------------------------
34 // wxMenuItem is an item in the menu which may be either a normal item, a sub
35 // menu or a separator
36 // ----------------------------------------------------------------------------
37
38 class WXDLLEXPORT wxMenuItemBase : public wxObject
39 {
40 public:
41 // creation
42 static wxMenuItem *New(wxMenu *parentMenu = (wxMenu *)NULL,
43 int itemid = wxID_SEPARATOR,
44 const wxString& text = wxEmptyString,
45 const wxString& help = wxEmptyString,
46 wxItemKind kind = wxITEM_NORMAL,
47 wxMenu *subMenu = (wxMenu *)NULL);
48
49 // destruction: wxMenuItem will delete its submenu
50 virtual ~wxMenuItemBase();
51
52 // the menu we're in
53 wxMenu *GetMenu() const { return m_parentMenu; }
54 void SetMenu(wxMenu* menu) { m_parentMenu = menu; }
55
56 // get/set id
57 void SetId(int itemid) { m_id = itemid; }
58 int GetId() const { return m_id; }
59 bool IsSeparator() const { return m_id == wxID_SEPARATOR; }
60
61 // the item's text (or name)
62 //
63 // NB: the item's text includes the accelerators and mnemonics info (if
64 // any), i.e. it may contain '&' or '_' or "\t..." and thus is
65 // different from the item's label which only contains the text shown
66 // in the menu
67 virtual void SetText(const wxString& str);
68
69 wxString GetLabel() const { return GetLabelFromText(m_text); }
70 const wxString& GetText() const { return m_text; }
71
72 // get the label from text (implemented in platform-specific code)
73 static wxString GetLabelFromText(const wxString& text);
74
75 // what kind of menu item we are
76 wxItemKind GetKind() const { return m_kind; }
77 void SetKind(wxItemKind kind) { m_kind = kind; }
78
79 virtual void SetCheckable(bool checkable) { m_kind = checkable ? wxITEM_CHECK : wxITEM_NORMAL; }
80 bool IsCheckable() const
81 { return m_kind == wxITEM_CHECK || m_kind == wxITEM_RADIO; }
82
83 bool IsSubMenu() const { return m_subMenu != NULL; }
84 void SetSubMenu(wxMenu *menu) { m_subMenu = menu; }
85 wxMenu *GetSubMenu() const { return m_subMenu; }
86
87 // state
88 virtual void Enable(bool enable = true) { m_isEnabled = enable; }
89 virtual bool IsEnabled() const { return m_isEnabled; }
90
91 virtual void Check(bool check = true) { m_isChecked = check; }
92 virtual bool IsChecked() const { return m_isChecked; }
93 void Toggle() { Check(!m_isChecked); }
94
95 // help string (displayed in the status bar by default)
96 void SetHelp(const wxString& str);
97 const wxString& GetHelp() const { return m_help; }
98
99 #if wxUSE_ACCEL
100 // extract the accelerator from the given menu string, return NULL if none
101 // found
102 static wxAcceleratorEntry *GetAccelFromString(const wxString& label);
103
104 // get our accelerator or NULL (caller must delete the pointer)
105 virtual wxAcceleratorEntry *GetAccel() const;
106
107 // set the accel for this item - this may also be done indirectly with
108 // SetText()
109 virtual void SetAccel(wxAcceleratorEntry *accel);
110 #endif // wxUSE_ACCEL
111
112 // compatibility only, use new functions in the new code
113 void SetName(const wxString& str) { SetText(str); }
114 const wxString& GetName() const { return GetText(); }
115
116 static wxMenuItem *New(wxMenu *parentMenu,
117 int itemid,
118 const wxString& text,
119 const wxString& help,
120 bool isCheckable,
121 wxMenu *subMenu = (wxMenu *)NULL)
122 {
123 return New(parentMenu, itemid, text, help,
124 isCheckable ? wxITEM_CHECK : wxITEM_NORMAL, subMenu);
125 }
126
127 protected:
128 int m_id; // numeric id of the item >= 0 or wxID_ANY or wxID_SEPARATOR
129 wxMenu *m_parentMenu, // the menu we belong to
130 *m_subMenu; // our sub menu or NULL
131 wxString m_text, // label of the item
132 m_help; // the help string for the item
133 wxItemKind m_kind; // separator/normal/check/radio item?
134 bool m_isChecked; // is checked?
135 bool m_isEnabled; // is enabled?
136
137 // this ctor is for the derived classes only, we're never created directly
138 wxMenuItemBase(wxMenu *parentMenu = (wxMenu *)NULL,
139 int itemid = wxID_SEPARATOR,
140 const wxString& text = wxEmptyString,
141 const wxString& help = wxEmptyString,
142 wxItemKind kind = wxITEM_NORMAL,
143 wxMenu *subMenu = (wxMenu *)NULL);
144
145 private:
146 // and, if we have one ctor, compiler won't generate a default copy one, so
147 // declare them ourselves - but don't implement as they shouldn't be used
148 wxMenuItemBase(const wxMenuItemBase& item);
149 wxMenuItemBase& operator=(const wxMenuItemBase& item);
150
151 public:
152
153 #if wxABI_VERSION >= 20805
154 // Sets the label. This function replaces SetText.
155 void SetItemLabel(const wxString& str) { SetText(str); }
156
157 // return the item label including any mnemonics and accelerators.
158 // This used to be called GetText.
159 // We can't implement this in the base class (no new virtuals in stable branch)
160 // wxString GetItemLabel() const;
161
162 // return just the text of the item label, without any mnemonics
163 // This used to be called GetLabel.
164 wxString GetItemLabelText() const { return GetLabelText(m_text); }
165
166 // return just the text part of the given label. In 2.9 and up, this is implemented in
167 // platform-specific code, but is now implemented in terms of GetLabelFromText.
168 static wxString GetLabelText(const wxString& label);
169 #endif
170 };
171
172 // ----------------------------------------------------------------------------
173 // include the real class declaration
174 // ----------------------------------------------------------------------------
175
176 #ifdef wxUSE_BASE_CLASSES_ONLY
177 #define wxMenuItem wxMenuItemBase
178 #else // !wxUSE_BASE_CLASSES_ONLY
179 #if defined(__WXUNIVERSAL__)
180 #include "wx/univ/menuitem.h"
181 #elif defined(__WXPALMOS__)
182 #include "wx/palmos/menuitem.h"
183 #elif defined(__WXMSW__)
184 #include "wx/msw/menuitem.h"
185 #elif defined(__WXMOTIF__)
186 #include "wx/motif/menuitem.h"
187 #elif defined(__WXGTK20__)
188 #include "wx/gtk/menuitem.h"
189 #elif defined(__WXGTK__)
190 #include "wx/gtk1/menuitem.h"
191 #elif defined(__WXMAC__)
192 #include "wx/mac/menuitem.h"
193 #elif defined(__WXCOCOA__)
194 #include "wx/cocoa/menuitem.h"
195 #elif defined(__WXPM__)
196 #include "wx/os2/menuitem.h"
197 #endif
198 #endif // wxUSE_BASE_CLASSES_ONLY/!wxUSE_BASE_CLASSES_ONLY
199
200 #endif // wxUSE_MENUS
201
202 #endif
203 // _WX_MENUITEM_H_BASE_

  ViewVC Help
Powered by ViewVC 1.1.22