]>
Commit | Line | Data |
---|---|---|
0e320a79 | 1 | ///////////////////////////////////////////////////////////////////////////// |
80fdcdb9 | 2 | // Name: wx/os2/menu.h |
0e320a79 | 3 | // Purpose: wxMenu, wxMenuBar classes |
75f11ad7 | 4 | // Author: David Webster |
0e320a79 | 5 | // Modified by: |
75f11ad7 | 6 | // Created: 10/10/99 |
75f11ad7 | 7 | // Copyright: (c) David Webster |
65571936 | 8 | // Licence: wxWindows licence |
0e320a79 DW |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
11 | #ifndef _WX_MENU_H_ | |
12 | #define _WX_MENU_H_ | |
13 | ||
75f11ad7 | 14 | #if wxUSE_ACCEL |
598d8cac DW |
15 | #include "wx/accel.h" |
16 | #include "wx/list.h" // for "template" list classes | |
17 | #include "wx/dynarray.h" | |
e92f266c | 18 | |
7e1e6965 | 19 | WX_DEFINE_EXPORTED_ARRAY_PTR(wxAcceleratorEntry *, wxAcceleratorArray); |
75f11ad7 | 20 | #endif // wxUSE_ACCEL |
0e320a79 | 21 | |
b5dbe15d | 22 | class WXDLLIMPEXP_FWD_CORE wxFrame; |
0e320a79 | 23 | |
8c5907ce DW |
24 | void wxSetShortCutKey(wxChar* zText); |
25 | ||
0e320a79 DW |
26 | // ---------------------------------------------------------------------------- |
27 | // Menu | |
28 | // ---------------------------------------------------------------------------- | |
0e320a79 | 29 | |
53a2db12 | 30 | class WXDLLIMPEXP_CORE wxMenu : public wxMenuBase |
e92f266c | 31 | { |
0e320a79 | 32 | public: |
61243a51 DW |
33 | // |
34 | // Ctors & dtor | |
35 | // | |
36 | wxMenu( const wxString& rTitle | |
37 | ,long lStyle = 0 | |
38 | ) | |
39 | : wxMenuBase( rTitle | |
40 | ,lStyle | |
41 | ) | |
42 | { | |
43 | Init(); | |
44 | } | |
75f11ad7 | 45 | |
61243a51 DW |
46 | wxMenu(long lStyle = 0) |
47 | : wxMenuBase(lStyle) | |
48 | { | |
49 | Init(); | |
50 | } | |
75f11ad7 DW |
51 | |
52 | virtual ~wxMenu(); | |
53 | ||
61243a51 DW |
54 | // |
55 | // Implement base class virtuals | |
56 | // | |
9add9367 RD |
57 | virtual wxMenuItem* DoAppend(wxMenuItem* pItem); |
58 | virtual wxMenuItem* DoInsert( size_t nPos | |
61243a51 DW |
59 | ,wxMenuItem* pItem |
60 | ); | |
61 | virtual wxMenuItem* DoRemove(wxMenuItem* pItem); | |
62 | virtual void Break(void); | |
63 | virtual void SetTitle(const wxString& rTitle); | |
64 | ||
61243a51 DW |
65 | // |
66 | // Implementation only from now on | |
67 | // ------------------------------- | |
68 | // | |
598d8cac DW |
69 | virtual void Attach(wxMenuBarBase* pMenubar); |
70 | ||
61243a51 DW |
71 | bool OS2Command( WXUINT uParam |
72 | ,WXWORD wId | |
73 | ); | |
74 | ||
75 | // | |
76 | // Semi-private accessors | |
77 | // | |
78 | ||
79 | // | |
80 | // Get the window which contains this menu | |
81 | // | |
82 | wxWindow* GetWindow(void) const; | |
83 | ||
84 | // | |
85 | // Get the menu handle | |
86 | // | |
e92f266c | 87 | WXHMENU GetHMenu() const { return m_hMenu; } |
75f11ad7 | 88 | |
75f11ad7 | 89 | #if wxUSE_ACCEL |
61243a51 DW |
90 | // |
91 | // Called by wxMenuBar to build its accel table from the accels of all menus | |
92 | // | |
598d8cac DW |
93 | bool HasAccels(void) const { return m_vAccels.IsEmpty(); } |
94 | size_t GetAccelCount(void) const { return m_vAccels.GetCount(); } | |
61243a51 DW |
95 | size_t CopyAccels(wxAcceleratorEntry* pAccels) const; |
96 | ||
97 | // | |
98 | // Called by wxMenuItem when its accels changes | |
99 | // | |
100 | void UpdateAccel(wxMenuItem* pItem); | |
101 | ||
102 | // | |
103 | // Helper used by wxMenu itself (returns the index in m_accels) | |
104 | // | |
105 | int FindAccel(int nId) const; | |
e92f266c | 106 | #endif // wxUSE_ACCEL |
45bedfdd DW |
107 | // |
108 | // OS/2 specific Find | |
109 | // | |
110 | wxMenuItem* FindItem(int id, ULONG hItem, wxMenu **menu = NULL) const; | |
111 | //virtual function hiding suppression | |
112 | int FindItem(const wxString& rsString) const | |
113 | { return wxMenuBase::FindItem(rsString); } | |
114 | wxMenuItem* FindItem(int id, wxMenu **menu = NULL) const | |
115 | { return wxMenuBase::FindItem(id, menu); } | |
75f11ad7 | 116 | |
61243a51 DW |
117 | // |
118 | // All OS/2PM Menu's have one of these | |
119 | // | |
120 | MENUITEM m_vMenuData; | |
121 | ||
75f11ad7 | 122 | private: |
61243a51 DW |
123 | // |
124 | // Common part of all ctors | |
125 | // | |
e92f266c DW |
126 | void Init(); |
127 | ||
61243a51 DW |
128 | // |
129 | // Common part of Append/Insert (behaves as Append is pos == (size_t)-1) | |
130 | // | |
131 | bool DoInsertOrAppend( wxMenuItem* pItem | |
132 | ,size_t nPos = (size_t)-1 | |
133 | ); | |
134 | ||
ab4fece8 DW |
135 | // |
136 | // Terminate the current radio group, if any | |
137 | // | |
138 | void EndRadioGroup(void); | |
139 | ||
61243a51 | 140 | // |
7e1e6965 | 141 | // If true, insert a breal before appending the next item |
61243a51 | 142 | // |
7e1e6965 | 143 | bool m_bDoBreak; |
61243a51 DW |
144 | |
145 | // | |
146 | // The menu handle of this menu | |
147 | // | |
148 | WXHMENU m_hMenu; | |
75f11ad7 | 149 | |
f6bcfd97 BP |
150 | // |
151 | // The helper variable for creating unique IDs. | |
152 | // | |
598d8cac | 153 | static USHORT m_nextMenuId; |
f6bcfd97 | 154 | |
ab4fece8 DW |
155 | // |
156 | // The position of the first item in the current radio group or -1 | |
157 | // | |
158 | int m_nStartRadioGroup; | |
159 | ||
75f11ad7 | 160 | #if wxUSE_ACCEL |
61243a51 DW |
161 | // |
162 | // The accelerators for our menu items | |
163 | // | |
598d8cac | 164 | wxAcceleratorArray m_vAccels; |
75f11ad7 | 165 | #endif // wxUSE_ACCEL |
e92f266c DW |
166 | |
167 | DECLARE_DYNAMIC_CLASS(wxMenu) | |
61243a51 | 168 | }; // end of wxMenu |
0e320a79 DW |
169 | |
170 | // ---------------------------------------------------------------------------- | |
171 | // Menu Bar (a la Windows) | |
172 | // ---------------------------------------------------------------------------- | |
75f11ad7 | 173 | |
53a2db12 | 174 | class WXDLLIMPEXP_CORE wxMenuBar : public wxMenuBarBase |
0e320a79 | 175 | { |
75f11ad7 | 176 | public: |
61243a51 DW |
177 | // |
178 | // Ctors & dtor | |
179 | // | |
e92f266c | 180 | |
61243a51 DW |
181 | // |
182 | // Default constructor | |
183 | // | |
184 | wxMenuBar(); | |
75f11ad7 | 185 | |
61243a51 DW |
186 | // |
187 | // Unused under OS2 | |
188 | wxMenuBar(long lStyle); | |
189 | ||
190 | // | |
191 | // Menubar takes ownership of the menus arrays but copies the titles | |
192 | // | |
193 | wxMenuBar( int n | |
194 | ,wxMenu* vMenus[] | |
195 | ,const wxString sTitles[] | |
294ea16d | 196 | ,long lStyle = 0 |
61243a51 DW |
197 | ); |
198 | virtual ~wxMenuBar(); | |
75f11ad7 | 199 | |
61243a51 DW |
200 | // |
201 | // Menubar construction | |
202 | // | |
203 | virtual bool Append( wxMenu* pMenu | |
204 | ,const wxString& rTitle | |
205 | ); | |
206 | virtual bool Insert( size_t nPos | |
207 | ,wxMenu* pMenu | |
208 | ,const wxString& rTitle | |
209 | ); | |
210 | virtual wxMenu* Replace( size_t nPos | |
211 | ,wxMenu* pMenu | |
212 | ,const wxString& rTitle | |
213 | ); | |
214 | virtual wxMenu* Remove(size_t nPos); | |
215 | virtual int FindMenuItem( const wxString& rMenuString | |
216 | ,const wxString& rItemString | |
217 | ) const; | |
218 | virtual wxMenuItem* FindItem( int nId | |
219 | ,wxMenu** ppMenu = NULL | |
220 | ) const; | |
45bedfdd DW |
221 | virtual wxMenuItem* FindItem( int nId |
222 | ,ULONG hItem | |
223 | ,wxMenu** ppMenu = NULL | |
224 | ) const; | |
61243a51 DW |
225 | virtual void EnableTop( size_t nPos |
226 | ,bool bFlag | |
227 | ); | |
52af3158 | 228 | virtual void SetMenuLabel( size_t nPos |
61243a51 DW |
229 | ,const wxString& rLabel |
230 | ); | |
52af3158 | 231 | virtual wxString GetMenuLabel(size_t nPos) const; |
61243a51 | 232 | |
61243a51 DW |
233 | // |
234 | // Implementation from now on | |
235 | // | |
236 | WXHMENU Create(void); | |
210a651b DW |
237 | virtual void Detach(void); |
238 | virtual void Attach(wxFrame* pFrame); | |
61243a51 DW |
239 | |
240 | #if wxUSE_ACCEL | |
241 | // | |
242 | // Get the accel table for all the menus | |
243 | // | |
244 | const wxAcceleratorTable& GetAccelTable(void) const { return m_vAccelTable; } | |
245 | ||
246 | // | |
3103e8a9 | 247 | // Update the accel table (must be called after adding/deleting a menu) |
61243a51 DW |
248 | // |
249 | void RebuildAccelTable(void); | |
75f11ad7 DW |
250 | #endif // wxUSE_ACCEL |
251 | ||
61243a51 DW |
252 | // |
253 | // Get the menu handle | |
254 | WXHMENU GetHMenu(void) const { return m_hMenu; } | |
75f11ad7 | 255 | |
61243a51 DW |
256 | // |
257 | // If the menubar is modified, the display is not updated automatically, | |
75f11ad7 | 258 | // call this function to update it (m_menuBarFrame should be !NULL) |
61243a51 DW |
259 | // |
260 | void Refresh(void); | |
75f11ad7 DW |
261 | |
262 | protected: | |
61243a51 DW |
263 | // |
264 | // Common part of all ctors | |
265 | // | |
266 | void Init(void); | |
75f11ad7 | 267 | |
e92f266c DW |
268 | wxArrayString m_titles; |
269 | ||
0fe536e3 | 270 | WXHMENU m_hMenu; |
75f11ad7 DW |
271 | |
272 | #if wxUSE_ACCEL | |
61243a51 DW |
273 | // |
274 | // The accelerator table for all accelerators in all our menus | |
275 | // | |
276 | wxAcceleratorTable m_vAccelTable; | |
75f11ad7 | 277 | #endif // wxUSE_ACCEL |
e92f266c DW |
278 | |
279 | private: | |
61243a51 DW |
280 | // |
281 | // Virtual function hiding suppression | |
282 | // | |
283 | void Refresh( bool bErase | |
284 | ,const wxRect* pRect | |
285 | ) | |
286 | { wxWindow::Refresh(bErase, pRect); } | |
287 | ||
e92f266c | 288 | DECLARE_DYNAMIC_CLASS(wxMenuBar) |
0e320a79 DW |
289 | }; |
290 | ||
291 | #endif // _WX_MENU_H_ |