]>
Commit | Line | Data |
---|---|---|
717a57c2 VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: samples/menu.cpp | |
3 | // Purpose: wxMenu/wxMenuBar sample | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 01.11.99 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1999 Vadim Zeitlin | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
20 | // For compilers that support precompilation, includes "wx/wx.h". | |
92a19c2e | 21 | #include "wx/wxprec.h" |
717a57c2 VZ |
22 | |
23 | #ifdef __BORLANDC__ | |
24 | #pragma hdrstop | |
25 | #endif | |
26 | ||
27 | #ifndef WX_PRECOMP | |
f91bf72f GD |
28 | #include "wx/app.h" |
29 | #include "wx/frame.h" | |
30 | #include "wx/menu.h" | |
31 | #include "wx/msgdlg.h" | |
32 | #include "wx/log.h" | |
33 | #include "wx/textctrl.h" | |
5c7766de | 34 | #include "wx/textdlg.h" |
717a57c2 VZ |
35 | #endif |
36 | ||
6d5b2a57 VZ |
37 | #if !wxUSE_MENUS |
38 | // nice try... | |
39 | #error "menu sample requires wxUSE_MENUS=1" | |
40 | #endif // wxUSE_MENUS | |
41 | ||
62ad15a5 VZ |
42 | // not all ports have support for EVT_CONTEXT_MENU yet, don't define |
43 | // USE_CONTEXT_MENU for those which don't | |
f2012fa6 | 44 | #if defined(__WXMOTIF__) || defined(__WXPM__) || defined(__WXX11__) |
51a9eb73 VZ |
45 | #define USE_CONTEXT_MENU 0 |
46 | #else | |
47 | #define USE_CONTEXT_MENU 1 | |
62ad15a5 VZ |
48 | #endif |
49 | ||
d13b34d3 DS |
50 | // this sample is useful when a new port is developed |
51 | // and usually a new port has majority of flags turned off | |
1242c2d9 WS |
52 | #if wxUSE_LOG && wxUSE_TEXTCTRL |
53 | #define USE_LOG_WINDOW 1 | |
54 | #else | |
55 | #define USE_LOG_WINDOW 0 | |
56 | #endif | |
57 | ||
fcaf9e70 RR |
58 | #include "copy.xpm" |
59 | ||
e7092398 | 60 | #ifndef wxHAS_IMAGES_IN_RESOURCES |
41f02b9a FM |
61 | #include "../sample.xpm" |
62 | #endif | |
63 | ||
717a57c2 VZ |
64 | // ---------------------------------------------------------------------------- |
65 | // classes | |
66 | // ---------------------------------------------------------------------------- | |
67 | ||
68 | // Define a new application | |
69 | class MyApp: public wxApp | |
70 | { | |
71 | public: | |
72 | bool OnInit(); | |
73 | }; | |
74 | ||
75 | // Define a new frame | |
76 | class MyFrame: public wxFrame | |
77 | { | |
78 | public: | |
79 | MyFrame(); | |
80 | ||
3ca6a5f0 BP |
81 | virtual ~MyFrame(); |
82 | ||
83 | void LogMenuEvent(const wxCommandEvent& event); | |
717a57c2 | 84 | |
e421922f | 85 | protected: |
717a57c2 | 86 | void OnQuit(wxCommandEvent& event); |
1242c2d9 | 87 | #if USE_LOG_WINDOW |
e421922f | 88 | void OnClearLog(wxCommandEvent& event); |
cfbf301d VZ |
89 | void OnClearLogUpdateUI(wxUpdateUIEvent& event); |
90 | #endif // USE_LOG_WINDOW | |
95316a3f | 91 | void OnShowDialog(wxCommandEvent& event); |
e421922f | 92 | |
717a57c2 VZ |
93 | void OnAbout(wxCommandEvent& event); |
94 | ||
95 | void OnDummy(wxCommandEvent& event); | |
96 | ||
97 | void OnAppendMenuItem(wxCommandEvent& event); | |
98 | void OnAppendSubMenu(wxCommandEvent& event); | |
99 | void OnDeleteMenuItem(wxCommandEvent& event); | |
08e78a54 | 100 | void OnDeleteSubMenu(wxCommandEvent& event); |
717a57c2 VZ |
101 | void OnInsertMenuItem(wxCommandEvent& event); |
102 | void OnCheckMenuItem(wxCommandEvent& event); | |
103 | void OnEnableMenuItem(wxCommandEvent& event); | |
104 | void OnGetLabelMenuItem(wxCommandEvent& event); | |
1242c2d9 | 105 | #if wxUSE_TEXTDLG |
717a57c2 | 106 | void OnSetLabelMenuItem(wxCommandEvent& event); |
1242c2d9 | 107 | #endif |
a80c322c | 108 | void OnGetMenuItemInfo(wxCommandEvent& event); |
1242c2d9 | 109 | #if wxUSE_TEXTDLG |
f6d90fb9 | 110 | void OnFindMenuItem(wxCommandEvent& event); |
1242c2d9 | 111 | #endif |
717a57c2 VZ |
112 | |
113 | void OnAppendMenu(wxCommandEvent& event); | |
f03ec224 | 114 | void OnInsertMenu(wxCommandEvent& event); |
717a57c2 VZ |
115 | void OnDeleteMenu(wxCommandEvent& event); |
116 | void OnToggleMenu(wxCommandEvent& event); | |
117 | void OnEnableMenu(wxCommandEvent& event); | |
118 | void OnGetLabelMenu(wxCommandEvent& event); | |
119 | void OnSetLabelMenu(wxCommandEvent& event); | |
1242c2d9 | 120 | #if wxUSE_TEXTDLG |
f6d90fb9 | 121 | void OnFindMenu(wxCommandEvent& event); |
1242c2d9 | 122 | #endif |
717a57c2 | 123 | |
d65c269b VZ |
124 | void OnTestNormal(wxCommandEvent& event); |
125 | void OnTestCheck(wxCommandEvent& event); | |
126 | void OnTestRadio(wxCommandEvent& event); | |
127 | ||
c377f1be JS |
128 | void OnUpdateSubMenuNormal(wxUpdateUIEvent& event); |
129 | void OnUpdateSubMenuCheck(wxUpdateUIEvent& event); | |
130 | void OnUpdateSubMenuRadio(wxUpdateUIEvent& event); | |
131 | ||
62ad15a5 | 132 | #if USE_CONTEXT_MENU |
ac103441 | 133 | void OnContextMenu(wxContextMenuEvent& event); |
ccef86c7 VZ |
134 | #else |
135 | void OnRightUp(wxMouseEvent& event) | |
136 | { ShowContextMenu(event.GetPosition()); } | |
137 | #endif | |
138 | ||
139 | void OnMenuOpen(wxMenuEvent& event) | |
1242c2d9 WS |
140 | { |
141 | #if USE_LOG_WINDOW | |
95316a3f | 142 | LogMenuOpenCloseOrHighlight(event, wxT("opened")); event.Skip(); |
1242c2d9 WS |
143 | #endif |
144 | } | |
ccef86c7 | 145 | void OnMenuClose(wxMenuEvent& event) |
1242c2d9 WS |
146 | { |
147 | #if USE_LOG_WINDOW | |
95316a3f VZ |
148 | LogMenuOpenCloseOrHighlight(event, wxT("closed")); event.Skip(); |
149 | #endif | |
150 | } | |
151 | void OnMenuHighlight(wxMenuEvent& event) | |
152 | { | |
153 | #if USE_LOG_WINDOW | |
154 | LogMenuOpenCloseOrHighlight(event, wxT("highlighted")); event.Skip(); | |
1242c2d9 WS |
155 | #endif |
156 | } | |
717a57c2 VZ |
157 | |
158 | void OnUpdateCheckMenuItemUI(wxUpdateUIEvent& event); | |
159 | ||
e421922f VZ |
160 | void OnSize(wxSizeEvent& event); |
161 | ||
717a57c2 | 162 | private: |
95316a3f VZ |
163 | #if USE_LOG_WINDOW |
164 | void LogMenuOpenCloseOrHighlight(const wxMenuEvent& event, const wxChar *what); | |
165 | #endif | |
ccef86c7 VZ |
166 | void ShowContextMenu(const wxPoint& pos); |
167 | ||
f03ec224 | 168 | wxMenu *CreateDummyMenu(wxString *title); |
717a57c2 VZ |
169 | |
170 | wxMenuItem *GetLastMenuItem() const; | |
171 | ||
e421922f VZ |
172 | // the menu previously detached from the menubar (may be NULL) |
173 | wxMenu *m_menu; | |
717a57c2 | 174 | |
e421922f | 175 | // the count of dummy menus already created |
f03ec224 VZ |
176 | size_t m_countDummy; |
177 | ||
1242c2d9 | 178 | #if USE_LOG_WINDOW |
e421922f VZ |
179 | // the control used for logging |
180 | wxTextCtrl *m_textctrl; | |
1242c2d9 | 181 | #endif |
e421922f VZ |
182 | |
183 | // the previous log target | |
184 | wxLog *m_logOld; | |
185 | ||
717a57c2 VZ |
186 | DECLARE_EVENT_TABLE() |
187 | }; | |
188 | ||
95316a3f VZ |
189 | class MyDialog : public wxDialog |
190 | { | |
191 | public: | |
192 | MyDialog(wxWindow* parent); | |
193 | ||
194 | #if USE_CONTEXT_MENU | |
195 | void OnContextMenu(wxContextMenuEvent& event); | |
196 | #else | |
197 | void OnRightUp(wxMouseEvent& event) | |
198 | { ShowContextMenu(event.GetPosition()); } | |
199 | #endif | |
200 | ||
201 | void OnMenuOpen(wxMenuEvent& event) | |
202 | { | |
203 | #if USE_LOG_WINDOW | |
204 | LogMenuOpenCloseOrHighlight(event, wxT("opened")); event.Skip(); | |
205 | #endif | |
206 | } | |
207 | void OnMenuClose(wxMenuEvent& event) | |
208 | { | |
209 | #if USE_LOG_WINDOW | |
210 | LogMenuOpenCloseOrHighlight(event, wxT("closed")); event.Skip(); | |
211 | #endif | |
212 | } | |
213 | void OnMenuHighlight(wxMenuEvent& event) | |
214 | { | |
215 | #if USE_LOG_WINDOW | |
216 | LogMenuOpenCloseOrHighlight(event, wxT("highlighted")); event.Skip(); | |
217 | #endif | |
218 | } | |
219 | ||
220 | private: | |
221 | #if USE_LOG_WINDOW | |
222 | void LogMenuOpenCloseOrHighlight(const wxMenuEvent& event, const wxChar *what); | |
223 | #endif | |
224 | void ShowContextMenu(const wxPoint& pos); | |
225 | ||
226 | #if USE_LOG_WINDOW | |
227 | // the control used for logging | |
228 | wxTextCtrl *m_textctrl; | |
229 | #endif | |
230 | ||
231 | DECLARE_EVENT_TABLE() | |
232 | }; | |
233 | ||
3ca6a5f0 BP |
234 | // A small helper class which intercepts all menu events and logs them |
235 | class MyEvtHandler : public wxEvtHandler | |
236 | { | |
237 | public: | |
238 | MyEvtHandler(MyFrame *frame) { m_frame = frame; } | |
239 | ||
240 | void OnMenuEvent(wxCommandEvent& event) | |
241 | { | |
242 | m_frame->LogMenuEvent(event); | |
243 | ||
244 | event.Skip(); | |
245 | } | |
246 | ||
247 | private: | |
248 | MyFrame *m_frame; | |
249 | ||
250 | DECLARE_EVENT_TABLE() | |
251 | }; | |
252 | ||
717a57c2 VZ |
253 | // ---------------------------------------------------------------------------- |
254 | // constants | |
255 | // ---------------------------------------------------------------------------- | |
256 | ||
257 | enum | |
258 | { | |
1242c2d9 WS |
259 | Menu_File_Quit = wxID_EXIT, |
260 | #if USE_LOG_WINDOW | |
cfbf301d | 261 | Menu_File_ClearLog = 100, |
1242c2d9 | 262 | #endif |
95316a3f | 263 | Menu_File_ShowDialog, |
717a57c2 VZ |
264 | |
265 | Menu_MenuBar_Toggle = 200, | |
266 | Menu_MenuBar_Append, | |
f03ec224 | 267 | Menu_MenuBar_Insert, |
717a57c2 VZ |
268 | Menu_MenuBar_Delete, |
269 | Menu_MenuBar_Enable, | |
270 | Menu_MenuBar_GetLabel, | |
1242c2d9 | 271 | #if wxUSE_TEXTDLG |
717a57c2 | 272 | Menu_MenuBar_SetLabel, |
f6d90fb9 | 273 | Menu_MenuBar_FindMenu, |
1242c2d9 | 274 | #endif |
717a57c2 VZ |
275 | |
276 | Menu_Menu_Append = 300, | |
277 | Menu_Menu_AppendSub, | |
278 | Menu_Menu_Insert, | |
279 | Menu_Menu_Delete, | |
08e78a54 | 280 | Menu_Menu_DeleteSub, |
717a57c2 VZ |
281 | Menu_Menu_Enable, |
282 | Menu_Menu_Check, | |
283 | Menu_Menu_GetLabel, | |
1242c2d9 | 284 | #if wxUSE_TEXTDLG |
717a57c2 | 285 | Menu_Menu_SetLabel, |
1242c2d9 | 286 | #endif |
a80c322c | 287 | Menu_Menu_GetInfo, |
1242c2d9 | 288 | #if wxUSE_TEXTDLG |
f6d90fb9 | 289 | Menu_Menu_FindItem, |
1242c2d9 | 290 | #endif |
717a57c2 | 291 | |
d65c269b VZ |
292 | Menu_Test_Normal = 400, |
293 | Menu_Test_Check, | |
294 | Menu_Test_Radio1, | |
295 | Menu_Test_Radio2, | |
296 | Menu_Test_Radio3, | |
297 | ||
c377f1be JS |
298 | Menu_SubMenu = 450, |
299 | Menu_SubMenu_Normal, | |
300 | Menu_SubMenu_Check, | |
301 | Menu_SubMenu_Radio1, | |
302 | Menu_SubMenu_Radio2, | |
303 | Menu_SubMenu_Radio3, | |
304 | ||
d65c269b | 305 | Menu_Dummy_First = 500, |
717a57c2 VZ |
306 | Menu_Dummy_Second, |
307 | Menu_Dummy_Third, | |
308 | Menu_Dummy_Fourth, | |
309 | Menu_Dummy_Last, | |
310 | ||
1242c2d9 | 311 | Menu_Help_About = wxID_ABOUT, |
717a57c2 VZ |
312 | |
313 | Menu_Popup_ToBeDeleted = 2000, | |
314 | Menu_Popup_ToBeGreyed, | |
315 | Menu_Popup_ToBeChecked, | |
316 | Menu_Popup_Submenu, | |
317 | ||
00a77b7c VZ |
318 | Menu_PopupChoice, |
319 | ||
717a57c2 VZ |
320 | Menu_Max |
321 | }; | |
322 | ||
323 | // ---------------------------------------------------------------------------- | |
324 | // event tables | |
325 | // ---------------------------------------------------------------------------- | |
326 | ||
327 | BEGIN_EVENT_TABLE(MyFrame, wxFrame) | |
e421922f | 328 | EVT_MENU(Menu_File_Quit, MyFrame::OnQuit) |
1242c2d9 | 329 | #if USE_LOG_WINDOW |
e421922f | 330 | EVT_MENU(Menu_File_ClearLog, MyFrame::OnClearLog) |
cfbf301d | 331 | EVT_UPDATE_UI(Menu_File_ClearLog, MyFrame::OnClearLogUpdateUI) |
1242c2d9 | 332 | #endif |
95316a3f | 333 | EVT_MENU(Menu_File_ShowDialog, MyFrame::OnShowDialog) |
717a57c2 VZ |
334 | |
335 | EVT_MENU(Menu_Help_About, MyFrame::OnAbout) | |
336 | ||
337 | EVT_MENU(Menu_MenuBar_Toggle, MyFrame::OnToggleMenu) | |
338 | EVT_MENU(Menu_MenuBar_Append, MyFrame::OnAppendMenu) | |
f03ec224 | 339 | EVT_MENU(Menu_MenuBar_Insert, MyFrame::OnInsertMenu) |
717a57c2 VZ |
340 | EVT_MENU(Menu_MenuBar_Delete, MyFrame::OnDeleteMenu) |
341 | EVT_MENU(Menu_MenuBar_Enable, MyFrame::OnEnableMenu) | |
342 | EVT_MENU(Menu_MenuBar_GetLabel, MyFrame::OnGetLabelMenu) | |
1242c2d9 | 343 | #if wxUSE_TEXTDLG |
717a57c2 | 344 | EVT_MENU(Menu_MenuBar_SetLabel, MyFrame::OnSetLabelMenu) |
f6d90fb9 | 345 | EVT_MENU(Menu_MenuBar_FindMenu, MyFrame::OnFindMenu) |
1242c2d9 | 346 | #endif |
717a57c2 VZ |
347 | |
348 | EVT_MENU(Menu_Menu_Append, MyFrame::OnAppendMenuItem) | |
349 | EVT_MENU(Menu_Menu_AppendSub, MyFrame::OnAppendSubMenu) | |
350 | EVT_MENU(Menu_Menu_Insert, MyFrame::OnInsertMenuItem) | |
351 | EVT_MENU(Menu_Menu_Delete, MyFrame::OnDeleteMenuItem) | |
08e78a54 | 352 | EVT_MENU(Menu_Menu_DeleteSub, MyFrame::OnDeleteSubMenu) |
717a57c2 | 353 | EVT_MENU(Menu_Menu_Enable, MyFrame::OnEnableMenuItem) |
a80c322c | 354 | EVT_MENU(Menu_Menu_Check, MyFrame::OnCheckMenuItem) |
717a57c2 | 355 | EVT_MENU(Menu_Menu_GetLabel, MyFrame::OnGetLabelMenuItem) |
1242c2d9 | 356 | #if wxUSE_TEXTDLG |
717a57c2 | 357 | EVT_MENU(Menu_Menu_SetLabel, MyFrame::OnSetLabelMenuItem) |
1242c2d9 | 358 | #endif |
a80c322c | 359 | EVT_MENU(Menu_Menu_GetInfo, MyFrame::OnGetMenuItemInfo) |
1242c2d9 | 360 | #if wxUSE_TEXTDLG |
f6d90fb9 | 361 | EVT_MENU(Menu_Menu_FindItem, MyFrame::OnFindMenuItem) |
1242c2d9 | 362 | #endif |
717a57c2 | 363 | |
d65c269b VZ |
364 | EVT_MENU(Menu_Test_Normal, MyFrame::OnTestNormal) |
365 | EVT_MENU(Menu_Test_Check, MyFrame::OnTestCheck) | |
366 | EVT_MENU(Menu_Test_Radio1, MyFrame::OnTestRadio) | |
367 | EVT_MENU(Menu_Test_Radio2, MyFrame::OnTestRadio) | |
368 | EVT_MENU(Menu_Test_Radio3, MyFrame::OnTestRadio) | |
369 | ||
c377f1be JS |
370 | EVT_UPDATE_UI(Menu_SubMenu_Normal, MyFrame::OnUpdateSubMenuNormal) |
371 | EVT_UPDATE_UI(Menu_SubMenu_Check, MyFrame::OnUpdateSubMenuCheck) | |
372 | EVT_UPDATE_UI(Menu_SubMenu_Radio1, MyFrame::OnUpdateSubMenuRadio) | |
373 | EVT_UPDATE_UI(Menu_SubMenu_Radio2, MyFrame::OnUpdateSubMenuRadio) | |
374 | EVT_UPDATE_UI(Menu_SubMenu_Radio3, MyFrame::OnUpdateSubMenuRadio) | |
375 | ||
717a57c2 VZ |
376 | EVT_MENU_RANGE(Menu_Dummy_First, Menu_Dummy_Last, MyFrame::OnDummy) |
377 | ||
378 | EVT_UPDATE_UI(Menu_Menu_Check, MyFrame::OnUpdateCheckMenuItemUI) | |
379 | ||
62ad15a5 | 380 | #if USE_CONTEXT_MENU |
ccef86c7 VZ |
381 | EVT_CONTEXT_MENU(MyFrame::OnContextMenu) |
382 | #else | |
e421922f | 383 | EVT_RIGHT_UP(MyFrame::OnRightUp) |
ccef86c7 VZ |
384 | #endif |
385 | ||
386 | EVT_MENU_OPEN(MyFrame::OnMenuOpen) | |
387 | EVT_MENU_CLOSE(MyFrame::OnMenuClose) | |
95316a3f | 388 | EVT_MENU_HIGHLIGHT_ALL(MyFrame::OnMenuHighlight) |
e421922f VZ |
389 | |
390 | EVT_SIZE(MyFrame::OnSize) | |
717a57c2 VZ |
391 | END_EVENT_TABLE() |
392 | ||
95316a3f VZ |
393 | BEGIN_EVENT_TABLE(MyDialog, wxDialog) |
394 | #if USE_CONTEXT_MENU | |
395 | EVT_CONTEXT_MENU(MyDialog::OnContextMenu) | |
396 | #else | |
397 | EVT_RIGHT_UP(MyDialog::OnRightUp) | |
398 | #endif | |
399 | EVT_MENU_OPEN(MyDialog::OnMenuOpen) | |
400 | EVT_MENU_CLOSE(MyDialog::OnMenuClose) | |
401 | EVT_MENU_HIGHLIGHT_ALL(MyDialog::OnMenuHighlight) | |
402 | END_EVENT_TABLE() | |
403 | ||
3ca6a5f0 | 404 | BEGIN_EVENT_TABLE(MyEvtHandler, wxEvtHandler) |
1242c2d9 | 405 | EVT_MENU(wxID_ANY, MyEvtHandler::OnMenuEvent) |
3ca6a5f0 BP |
406 | END_EVENT_TABLE() |
407 | ||
717a57c2 VZ |
408 | // ============================================================================ |
409 | // implementation | |
410 | // ============================================================================ | |
411 | ||
412 | // ---------------------------------------------------------------------------- | |
413 | // MyApp | |
414 | // ---------------------------------------------------------------------------- | |
415 | ||
416 | IMPLEMENT_APP(MyApp) | |
417 | ||
418 | // The `main program' equivalent, creating the windows and returning the | |
419 | // main frame | |
420 | bool MyApp::OnInit() | |
421 | { | |
45e6e6f8 VZ |
422 | if ( !wxApp::OnInit() ) |
423 | return false; | |
424 | ||
717a57c2 VZ |
425 | // Create the main frame window |
426 | MyFrame* frame = new MyFrame; | |
427 | ||
6ee9b7b5 | 428 | frame->Show(true); |
717a57c2 | 429 | |
6d5b2a57 | 430 | #if wxUSE_STATUSBAR |
9a83f860 | 431 | frame->SetStatusText(wxT("Welcome to wxWidgets menu sample")); |
6d5b2a57 | 432 | #endif // wxUSE_STATUSBAR |
717a57c2 | 433 | |
6ee9b7b5 | 434 | return true; |
717a57c2 VZ |
435 | } |
436 | ||
437 | // ---------------------------------------------------------------------------- | |
438 | // MyFrame | |
439 | // ---------------------------------------------------------------------------- | |
440 | ||
441 | // Define my frame constructor | |
442 | MyFrame::MyFrame() | |
9a83f860 | 443 | : wxFrame((wxFrame *)NULL, wxID_ANY, wxT("wxWidgets menu sample")) |
717a57c2 | 444 | { |
41f02b9a FM |
445 | SetIcon(wxICON(sample)); |
446 | ||
1242c2d9 | 447 | #if USE_LOG_WINDOW |
268766dd | 448 | m_textctrl = NULL; |
1242c2d9 | 449 | #endif |
717a57c2 | 450 | m_menu = NULL; |
f03ec224 | 451 | m_countDummy = 0; |
e421922f | 452 | m_logOld = NULL; |
717a57c2 | 453 | |
6d5b2a57 | 454 | #if wxUSE_STATUSBAR |
e421922f | 455 | CreateStatusBar(); |
6d5b2a57 | 456 | #endif // wxUSE_STATUSBAR |
717a57c2 VZ |
457 | |
458 | // create the menubar | |
459 | wxMenu *fileMenu = new wxMenu; | |
6d5b2a57 | 460 | |
ab73fe8d | 461 | wxMenu *stockSubMenu = new wxMenu; |
ee0a94cf RR |
462 | stockSubMenu->Append(wxID_ADD); |
463 | stockSubMenu->Append(wxID_APPLY); | |
6b1eedc1 | 464 | stockSubMenu->Append(wxID_BACKWARD); |
ee0a94cf | 465 | stockSubMenu->Append(wxID_BOLD); |
6b1eedc1 | 466 | stockSubMenu->Append(wxID_BOTTOM); |
ee0a94cf | 467 | stockSubMenu->Append(wxID_CANCEL); |
6b1eedc1 | 468 | stockSubMenu->Append(wxID_CDROM); |
ee0a94cf RR |
469 | stockSubMenu->Append(wxID_CLEAR); |
470 | stockSubMenu->Append(wxID_CLOSE); | |
6b1eedc1 | 471 | stockSubMenu->Append(wxID_CONVERT); |
ee0a94cf RR |
472 | stockSubMenu->Append(wxID_COPY); |
473 | stockSubMenu->Append(wxID_CUT); | |
474 | stockSubMenu->Append(wxID_DELETE); | |
ee0a94cf | 475 | stockSubMenu->Append(wxID_DOWN); |
6b1eedc1 VZ |
476 | stockSubMenu->Append(wxID_EXECUTE); |
477 | stockSubMenu->Append(wxID_EXIT); | |
478 | stockSubMenu->Append(wxID_FIND); | |
479 | stockSubMenu->Append(wxID_FIRST); | |
480 | stockSubMenu->Append(wxID_FLOPPY); | |
ee0a94cf | 481 | stockSubMenu->Append(wxID_FORWARD); |
6b1eedc1 | 482 | stockSubMenu->Append(wxID_HARDDISK); |
ee0a94cf RR |
483 | stockSubMenu->Append(wxID_HELP); |
484 | stockSubMenu->Append(wxID_HOME); | |
485 | stockSubMenu->Append(wxID_INDENT); | |
486 | stockSubMenu->Append(wxID_INDEX); | |
6b1eedc1 | 487 | stockSubMenu->Append(wxID_INFO); |
ee0a94cf | 488 | stockSubMenu->Append(wxID_ITALIC); |
6b1eedc1 | 489 | stockSubMenu->Append(wxID_JUMP_TO); |
ee0a94cf RR |
490 | stockSubMenu->Append(wxID_JUSTIFY_CENTER); |
491 | stockSubMenu->Append(wxID_JUSTIFY_FILL); | |
492 | stockSubMenu->Append(wxID_JUSTIFY_LEFT); | |
493 | stockSubMenu->Append(wxID_JUSTIFY_RIGHT); | |
6b1eedc1 VZ |
494 | stockSubMenu->Append(wxID_LAST); |
495 | stockSubMenu->Append(wxID_NETWORK); | |
ee0a94cf RR |
496 | stockSubMenu->Append(wxID_NEW); |
497 | stockSubMenu->Append(wxID_NO); | |
498 | stockSubMenu->Append(wxID_OK); | |
499 | stockSubMenu->Append(wxID_OPEN); | |
500 | stockSubMenu->Append(wxID_PASTE); | |
501 | stockSubMenu->Append(wxID_PREFERENCES); | |
ee0a94cf | 502 | stockSubMenu->Append(wxID_PREVIEW); |
6b1eedc1 | 503 | stockSubMenu->Append(wxID_PRINT); |
ee0a94cf | 504 | stockSubMenu->Append(wxID_PROPERTIES); |
ee0a94cf RR |
505 | stockSubMenu->Append(wxID_REDO); |
506 | stockSubMenu->Append(wxID_REFRESH); | |
507 | stockSubMenu->Append(wxID_REMOVE); | |
6b1eedc1 | 508 | stockSubMenu->Append(wxID_REPLACE); |
ee0a94cf RR |
509 | stockSubMenu->Append(wxID_REVERT_TO_SAVED); |
510 | stockSubMenu->Append(wxID_SAVE); | |
511 | stockSubMenu->Append(wxID_SAVEAS); | |
6b1eedc1 VZ |
512 | stockSubMenu->Append(wxID_SELECT_COLOR); |
513 | stockSubMenu->Append(wxID_SELECT_FONT); | |
514 | stockSubMenu->Append(wxID_SORT_ASCENDING); | |
515 | stockSubMenu->Append(wxID_SORT_DESCENDING); | |
516 | stockSubMenu->Append(wxID_SPELL_CHECK); | |
ee0a94cf | 517 | stockSubMenu->Append(wxID_STOP); |
6b1eedc1 VZ |
518 | stockSubMenu->Append(wxID_STRIKETHROUGH); |
519 | stockSubMenu->Append(wxID_TOP); | |
ee0a94cf RR |
520 | stockSubMenu->Append(wxID_UNDELETE); |
521 | stockSubMenu->Append(wxID_UNDERLINE); | |
522 | stockSubMenu->Append(wxID_UNDO); | |
523 | stockSubMenu->Append(wxID_UNINDENT); | |
6b1eedc1 | 524 | stockSubMenu->Append(wxID_UP); |
ee0a94cf RR |
525 | stockSubMenu->Append(wxID_YES); |
526 | stockSubMenu->Append(wxID_ZOOM_100); | |
527 | stockSubMenu->Append(wxID_ZOOM_FIT); | |
528 | stockSubMenu->Append(wxID_ZOOM_IN); | |
529 | stockSubMenu->Append(wxID_ZOOM_OUT); | |
9a83f860 | 530 | fileMenu->AppendSubMenu(stockSubMenu, wxT("&Standard items demo")); |
ab73fe8d | 531 | |
1242c2d9 | 532 | #if USE_LOG_WINDOW |
e421922f | 533 | wxMenuItem *item = new wxMenuItem(fileMenu, Menu_File_ClearLog, |
9a83f860 | 534 | wxT("Clear &log\tCtrl-L")); |
e421922f VZ |
535 | item->SetBitmap(copy_xpm); |
536 | fileMenu->Append(item); | |
537 | fileMenu->AppendSeparator(); | |
ab73fe8d VZ |
538 | #endif // USE_LOG_WINDOW |
539 | ||
95316a3f VZ |
540 | fileMenu->Append(Menu_File_ShowDialog, wxT("Show &Dialog\tCtrl-D"), |
541 | wxT("Show a dialog")); | |
542 | fileMenu->AppendSeparator(); | |
543 | ||
9a83f860 | 544 | fileMenu->Append(Menu_File_Quit, wxT("E&xit\tAlt-X"), wxT("Quit menu sample")); |
717a57c2 VZ |
545 | |
546 | wxMenu *menubarMenu = new wxMenu; | |
9a83f860 VZ |
547 | menubarMenu->Append(Menu_MenuBar_Append, wxT("&Append menu\tCtrl-A"), |
548 | wxT("Append a menu to the menubar")); | |
549 | menubarMenu->Append(Menu_MenuBar_Insert, wxT("&Insert menu\tCtrl-I"), | |
550 | wxT("Insert a menu into the menubar")); | |
551 | menubarMenu->Append(Menu_MenuBar_Delete, wxT("&Delete menu\tCtrl-D"), | |
552 | wxT("Delete the last menu from the menubar")); | |
553 | menubarMenu->Append(Menu_MenuBar_Toggle, wxT("&Toggle menu\tCtrl-T"), | |
554 | wxT("Toggle the first menu in the menubar"), true); | |
717a57c2 | 555 | menubarMenu->AppendSeparator(); |
9a83f860 VZ |
556 | menubarMenu->Append(Menu_MenuBar_Enable, wxT("&Enable menu\tCtrl-E"), |
557 | wxT("Enable or disable the last menu"), true); | |
717a57c2 | 558 | menubarMenu->AppendSeparator(); |
9a83f860 VZ |
559 | menubarMenu->Append(Menu_MenuBar_GetLabel, wxT("&Get menu label\tCtrl-G"), |
560 | wxT("Get the label of the last menu")); | |
1242c2d9 | 561 | #if wxUSE_TEXTDLG |
9a83f860 VZ |
562 | menubarMenu->Append(Menu_MenuBar_SetLabel, wxT("&Set menu label\tCtrl-S"), |
563 | wxT("Change the label of the last menu")); | |
f6d90fb9 | 564 | menubarMenu->AppendSeparator(); |
9a83f860 VZ |
565 | menubarMenu->Append(Menu_MenuBar_FindMenu, wxT("&Find menu from label\tCtrl-F"), |
566 | wxT("Find a menu by searching for its label")); | |
1242c2d9 | 567 | #endif |
717a57c2 | 568 | |
c377f1be | 569 | wxMenu* subMenu = new wxMenu; |
9a83f860 VZ |
570 | subMenu->Append(Menu_SubMenu_Normal, wxT("&Normal submenu item"), wxT("Disabled submenu item")); |
571 | subMenu->AppendCheckItem(Menu_SubMenu_Check, wxT("&Check submenu item"), wxT("Check submenu item")); | |
572 | subMenu->AppendRadioItem(Menu_SubMenu_Radio1, wxT("Radio item &1"), wxT("Radio item")); | |
573 | subMenu->AppendRadioItem(Menu_SubMenu_Radio2, wxT("Radio item &2"), wxT("Radio item")); | |
574 | subMenu->AppendRadioItem(Menu_SubMenu_Radio3, wxT("Radio item &3"), wxT("Radio item")); | |
c377f1be | 575 | |
9a83f860 | 576 | menubarMenu->Append(Menu_SubMenu, wxT("Submenu"), subMenu); |
c377f1be | 577 | |
717a57c2 | 578 | wxMenu *menuMenu = new wxMenu; |
9a83f860 | 579 | menuMenu->Append(Menu_Menu_Append, wxT("&Append menu item\tAlt-A"), |
553d6728 | 580 | wxT("Append a menu item to the 'Test' menu")); |
9a83f860 | 581 | menuMenu->Append(Menu_Menu_AppendSub, wxT("&Append sub menu\tAlt-S"), |
553d6728 | 582 | wxT("Append a sub menu to the 'Test' menu")); |
9a83f860 | 583 | menuMenu->Append(Menu_Menu_Insert, wxT("&Insert menu item\tAlt-I"), |
553d6728 | 584 | wxT("Insert a menu item in head of the 'Test' menu")); |
9a83f860 | 585 | menuMenu->Append(Menu_Menu_Delete, wxT("&Delete menu item\tAlt-D"), |
553d6728 | 586 | wxT("Delete the last menu item from the 'Test' menu")); |
08e78a54 | 587 | menuMenu->Append(Menu_Menu_DeleteSub, wxT("Delete last &submenu\tAlt-K"), |
553d6728 | 588 | wxT("Delete the last submenu from the 'Test' menu")); |
717a57c2 | 589 | menuMenu->AppendSeparator(); |
9a83f860 VZ |
590 | menuMenu->Append(Menu_Menu_Enable, wxT("&Enable menu item\tAlt-E"), |
591 | wxT("Enable or disable the last menu item"), true); | |
592 | menuMenu->Append(Menu_Menu_Check, wxT("&Check menu item\tAlt-C"), | |
593 | wxT("Check or uncheck the last menu item"), true); | |
717a57c2 | 594 | menuMenu->AppendSeparator(); |
9a83f860 VZ |
595 | menuMenu->Append(Menu_Menu_GetInfo, wxT("Get menu item in&fo\tAlt-F"), |
596 | wxT("Show the state of the last menu item")); | |
532d575b | 597 | #if wxUSE_TEXTDLG |
9a83f860 VZ |
598 | menuMenu->Append(Menu_Menu_SetLabel, wxT("Set menu item label\tAlt-L"), |
599 | wxT("Set the label of a menu item")); | |
532d575b | 600 | #endif |
1242c2d9 | 601 | #if wxUSE_TEXTDLG |
a80c322c | 602 | menuMenu->AppendSeparator(); |
9a83f860 VZ |
603 | menuMenu->Append(Menu_Menu_FindItem, wxT("Find menu item from label"), |
604 | wxT("Find a menu item by searching for its label")); | |
1242c2d9 | 605 | #endif |
717a57c2 | 606 | |
d65c269b | 607 | wxMenu *testMenu = new wxMenu; |
9a83f860 | 608 | testMenu->Append(Menu_Test_Normal, wxT("&Normal item")); |
d65c269b | 609 | testMenu->AppendSeparator(); |
9a83f860 | 610 | testMenu->AppendCheckItem(Menu_Test_Check, wxT("&Check item")); |
d65c269b | 611 | testMenu->AppendSeparator(); |
9a83f860 VZ |
612 | testMenu->AppendRadioItem(Menu_Test_Radio1, wxT("Radio item &1")); |
613 | testMenu->AppendRadioItem(Menu_Test_Radio2, wxT("Radio item &2")); | |
614 | testMenu->AppendRadioItem(Menu_Test_Radio3, wxT("Radio item &3")); | |
d65c269b | 615 | |
717a57c2 | 616 | wxMenu *helpMenu = new wxMenu; |
9a83f860 | 617 | helpMenu->Append(Menu_Help_About, wxT("&About\tF1"), wxT("About menu sample")); |
717a57c2 VZ |
618 | |
619 | wxMenuBar* menuBar = new wxMenuBar( wxMB_DOCKABLE ); | |
620 | ||
9a83f860 VZ |
621 | menuBar->Append(fileMenu, wxT("&File")); |
622 | menuBar->Append(menubarMenu, wxT("Menu&bar")); | |
623 | menuBar->Append(menuMenu, wxT("&Menu")); | |
624 | menuBar->Append(testMenu, wxT("&Test")); | |
625 | menuBar->Append(helpMenu, wxT("&Help")); | |
717a57c2 VZ |
626 | |
627 | // these items should be initially checked | |
6ee9b7b5 JS |
628 | menuBar->Check(Menu_MenuBar_Toggle, true); |
629 | menuBar->Check(Menu_MenuBar_Enable, true); | |
630 | menuBar->Check(Menu_Menu_Enable, true); | |
631 | menuBar->Check(Menu_Menu_Check, false); | |
717a57c2 VZ |
632 | |
633 | // associate the menu bar with the frame | |
634 | SetMenuBar(menuBar); | |
3ca6a5f0 BP |
635 | |
636 | // intercept all menu events and log them in this custom event handler | |
637 | PushEventHandler(new MyEvtHandler(this)); | |
e421922f | 638 | |
1242c2d9 | 639 | #if USE_LOG_WINDOW |
e421922f | 640 | // create the log text window |
532d575b | 641 | m_textctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, |
e421922f VZ |
642 | wxDefaultPosition, wxDefaultSize, |
643 | wxTE_MULTILINE); | |
6ee9b7b5 | 644 | m_textctrl->SetEditable(false); |
5c7766de | 645 | |
7f2bcd06 | 646 | wxLog::DisableTimestamp(); |
e421922f VZ |
647 | m_logOld = wxLog::SetActiveTarget(new wxLogTextCtrl(m_textctrl)); |
648 | ||
08e78a54 | 649 | wxLogMessage(wxT("Brief explanations: the commands in the \"Menu\" menu ") |
553d6728 | 650 | wxT("append/insert/delete items to/from the \"Test\" menu.\n") |
08e78a54 | 651 | wxT("The commands in the \"Menubar\" menu work with the ") |
9a83f860 VZ |
652 | wxT("menubar itself.\n\n") |
653 | wxT("Right click the band below to test popup menus.\n")); | |
1242c2d9 | 654 | #endif |
92f07cf8 JS |
655 | #ifdef __POCKETPC__ |
656 | EnableContextMenu(); | |
657 | #endif | |
3ca6a5f0 BP |
658 | } |
659 | ||
660 | MyFrame::~MyFrame() | |
661 | { | |
662 | delete m_menu; | |
663 | ||
664 | // delete the event handler installed in ctor | |
6ee9b7b5 | 665 | PopEventHandler(true); |
e421922f | 666 | |
1242c2d9 | 667 | #if USE_LOG_WINDOW |
e421922f VZ |
668 | // restore old logger |
669 | delete wxLog::SetActiveTarget(m_logOld); | |
1242c2d9 | 670 | #endif |
717a57c2 VZ |
671 | } |
672 | ||
f03ec224 | 673 | wxMenu *MyFrame::CreateDummyMenu(wxString *title) |
717a57c2 VZ |
674 | { |
675 | wxMenu *menu = new wxMenu; | |
9a83f860 | 676 | menu->Append(Menu_Dummy_First, wxT("&First item\tCtrl-F1")); |
717a57c2 | 677 | menu->AppendSeparator(); |
9a83f860 | 678 | menu->AppendCheckItem(Menu_Dummy_Second, wxT("&Second item\tCtrl-F2")); |
717a57c2 | 679 | |
f03ec224 VZ |
680 | if ( title ) |
681 | { | |
9a83f860 | 682 | title->Printf(wxT("Dummy menu &%u"), (unsigned)++m_countDummy); |
f03ec224 VZ |
683 | } |
684 | ||
717a57c2 VZ |
685 | return menu; |
686 | } | |
687 | ||
688 | wxMenuItem *MyFrame::GetLastMenuItem() const | |
689 | { | |
690 | wxMenuBar *menubar = GetMenuBar(); | |
553d6728 VZ |
691 | wxMenu *menu = menubar->GetMenu(menubar->FindMenu("Test")); |
692 | wxCHECK_MSG( menu, NULL, wxT("no 'Test' menu?") ); | |
717a57c2 | 693 | |
65c0217e | 694 | wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetLast(); |
717a57c2 VZ |
695 | if ( !node ) |
696 | { | |
553d6728 | 697 | wxLogWarning(wxT("No last item in the 'Test' menu!")); |
717a57c2 VZ |
698 | |
699 | return NULL; | |
700 | } | |
701 | else | |
702 | { | |
703 | return node->GetData(); | |
704 | } | |
705 | } | |
706 | ||
3ca6a5f0 BP |
707 | void MyFrame::LogMenuEvent(const wxCommandEvent& event) |
708 | { | |
709 | int id = event.GetId(); | |
e421922f | 710 | |
9a83f860 | 711 | wxString msg = wxString::Format(wxT("Menu command %d"), id); |
030f50ef VZ |
712 | |
713 | // catch all checkable menubar items and also the check item from the popup | |
714 | // menu | |
715 | wxMenuItem *item = GetMenuBar()->FindItem(id); | |
716 | if ( (item && item->IsCheckable()) || id == Menu_Popup_ToBeChecked ) | |
3ca6a5f0 | 717 | { |
9a83f860 VZ |
718 | msg += wxString::Format(wxT(" (the item is currently %schecked)"), |
719 | event.IsChecked() ? wxT("") : wxT("not ")); | |
3ca6a5f0 BP |
720 | } |
721 | ||
e421922f | 722 | wxLogMessage(msg); |
3ca6a5f0 BP |
723 | } |
724 | ||
725 | // ---------------------------------------------------------------------------- | |
726 | // menu callbacks | |
727 | // ---------------------------------------------------------------------------- | |
728 | ||
717a57c2 VZ |
729 | void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) |
730 | { | |
6ee9b7b5 | 731 | Close(true); |
717a57c2 VZ |
732 | } |
733 | ||
1242c2d9 | 734 | #if USE_LOG_WINDOW |
cfbf301d | 735 | |
e421922f VZ |
736 | void MyFrame::OnClearLog(wxCommandEvent& WXUNUSED(event)) |
737 | { | |
738 | m_textctrl->Clear(); | |
739 | } | |
cfbf301d VZ |
740 | |
741 | void MyFrame::OnClearLogUpdateUI(wxUpdateUIEvent& event) | |
742 | { | |
743 | // if we only enable this item when the log window is empty, we never see | |
744 | // it in the disable state as a message is logged whenever the menu is | |
745 | // opened, so we disable it if there is not "much" text in the window | |
746 | event.Enable( m_textctrl->GetNumberOfLines() > 5 ); | |
747 | } | |
748 | ||
749 | #endif // USE_LOG_WINDOW | |
e421922f | 750 | |
95316a3f VZ |
751 | void MyFrame::OnShowDialog(wxCommandEvent& WXUNUSED(event)) |
752 | { | |
753 | MyDialog dlg(this); | |
754 | dlg.ShowModal(); | |
755 | } | |
756 | ||
717a57c2 VZ |
757 | void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) |
758 | { | |
9a83f860 VZ |
759 | (void)wxMessageBox(wxT("wxWidgets menu sample\n(c) 1999-2001 Vadim Zeitlin"), |
760 | wxT("About wxWidgets menu sample"), | |
e8c0d573 | 761 | wxOK | wxICON_INFORMATION); |
717a57c2 VZ |
762 | } |
763 | ||
764 | void MyFrame::OnDeleteMenu(wxCommandEvent& WXUNUSED(event)) | |
765 | { | |
766 | wxMenuBar *mbar = GetMenuBar(); | |
767 | ||
768 | size_t count = mbar->GetMenuCount(); | |
553d6728 | 769 | if ( count == 4 ) |
717a57c2 | 770 | { |
553d6728 | 771 | // don't let delete the first 4 menus |
9a83f860 | 772 | wxLogError(wxT("Can't delete any more menus")); |
717a57c2 VZ |
773 | } |
774 | else | |
775 | { | |
776 | delete mbar->Remove(count - 1); | |
777 | } | |
778 | } | |
779 | ||
f03ec224 | 780 | void MyFrame::OnInsertMenu(wxCommandEvent& WXUNUSED(event)) |
717a57c2 | 781 | { |
717a57c2 | 782 | wxString title; |
f03ec224 | 783 | wxMenu *menu = CreateDummyMenu(&title); |
553d6728 | 784 | // Insert before the 'Help' menu |
4c51a665 | 785 | // Otherwise repeated Deletes will remove the 'Test' menu |
553d6728 | 786 | GetMenuBar()->Insert(4, menu, title); |
f03ec224 | 787 | } |
717a57c2 | 788 | |
f03ec224 VZ |
789 | void MyFrame::OnAppendMenu(wxCommandEvent& WXUNUSED(event)) |
790 | { | |
791 | wxString title; | |
792 | wxMenu *menu = CreateDummyMenu(&title); | |
793 | GetMenuBar()->Append(menu, title); | |
717a57c2 VZ |
794 | } |
795 | ||
796 | void MyFrame::OnToggleMenu(wxCommandEvent& WXUNUSED(event)) | |
797 | { | |
798 | wxMenuBar *mbar = GetMenuBar(); | |
799 | if ( !m_menu ) | |
800 | { | |
801 | // hide the menu | |
802 | m_menu = mbar->Remove(0); | |
803 | } | |
804 | else | |
805 | { | |
806 | // restore it | |
9a83f860 | 807 | mbar->Insert(0, m_menu, wxT("&File")); |
717a57c2 VZ |
808 | m_menu = NULL; |
809 | } | |
810 | } | |
811 | ||
e421922f | 812 | void MyFrame::OnEnableMenu(wxCommandEvent& event) |
717a57c2 VZ |
813 | { |
814 | wxMenuBar *mbar = GetMenuBar(); | |
815 | size_t count = mbar->GetMenuCount(); | |
816 | ||
e421922f | 817 | mbar->EnableTop(count - 1, event.IsChecked()); |
717a57c2 VZ |
818 | } |
819 | ||
820 | void MyFrame::OnGetLabelMenu(wxCommandEvent& WXUNUSED(event)) | |
821 | { | |
822 | wxMenuBar *mbar = GetMenuBar(); | |
823 | size_t count = mbar->GetMenuCount(); | |
824 | ||
9a83f860 | 825 | wxCHECK_RET( count, wxT("no last menu?") ); |
5c7766de | 826 | |
9a83f860 | 827 | wxLogMessage(wxT("The label of the last menu item is '%s'"), |
52af3158 | 828 | mbar->GetMenuLabel(count - 1).c_str()); |
717a57c2 VZ |
829 | } |
830 | ||
1242c2d9 | 831 | #if wxUSE_TEXTDLG |
717a57c2 VZ |
832 | void MyFrame::OnSetLabelMenu(wxCommandEvent& WXUNUSED(event)) |
833 | { | |
834 | wxMenuBar *mbar = GetMenuBar(); | |
835 | size_t count = mbar->GetMenuCount(); | |
836 | ||
9a83f860 | 837 | wxCHECK_RET( count, wxT("no last menu?") ); |
5c7766de VZ |
838 | |
839 | wxString label = wxGetTextFromUser | |
840 | ( | |
9a83f860 VZ |
841 | wxT("Enter new label: "), |
842 | wxT("Change last menu text"), | |
52af3158 | 843 | mbar->GetMenuLabel(count - 1), |
5c7766de VZ |
844 | this |
845 | ); | |
846 | ||
847 | if ( !label.empty() ) | |
848 | { | |
52af3158 | 849 | mbar->SetMenuLabel(count - 1, label); |
5c7766de | 850 | } |
717a57c2 VZ |
851 | } |
852 | ||
f6d90fb9 GD |
853 | void MyFrame::OnFindMenu(wxCommandEvent& WXUNUSED(event)) |
854 | { | |
855 | wxMenuBar *mbar = GetMenuBar(); | |
856 | size_t count = mbar->GetMenuCount(); | |
857 | ||
9a83f860 | 858 | wxCHECK_RET( count, wxT("no last menu?") ); |
f6d90fb9 GD |
859 | |
860 | wxString label = wxGetTextFromUser | |
861 | ( | |
9a83f860 VZ |
862 | wxT("Enter label to search for: "), |
863 | wxT("Find menu"), | |
532d575b | 864 | wxEmptyString, |
f6d90fb9 GD |
865 | this |
866 | ); | |
867 | ||
868 | if ( !label.empty() ) | |
869 | { | |
870 | int index = mbar->FindMenu(label); | |
871 | ||
872 | if (index == wxNOT_FOUND) | |
873 | { | |
9a83f860 | 874 | wxLogWarning(wxT("No menu with label '%s'"), label.c_str()); |
f6d90fb9 GD |
875 | } |
876 | else | |
877 | { | |
9a83f860 | 878 | wxLogMessage(wxT("Menu %d has label '%s'"), index, label.c_str()); |
f6d90fb9 GD |
879 | } |
880 | } | |
881 | } | |
1242c2d9 | 882 | #endif |
f6d90fb9 | 883 | |
717a57c2 VZ |
884 | void MyFrame::OnDummy(wxCommandEvent& event) |
885 | { | |
9a83f860 | 886 | wxLogMessage(wxT("Dummy item #%d"), event.GetId() - Menu_Dummy_First + 1); |
717a57c2 VZ |
887 | } |
888 | ||
889 | void MyFrame::OnAppendMenuItem(wxCommandEvent& WXUNUSED(event)) | |
890 | { | |
891 | wxMenuBar *menubar = GetMenuBar(); | |
553d6728 VZ |
892 | wxMenu *menu = menubar->GetMenu(menubar->FindMenu("Test")); |
893 | wxCHECK_RET( menu, wxT("no 'Test' menu?") ); | |
717a57c2 VZ |
894 | |
895 | menu->AppendSeparator(); | |
9a83f860 VZ |
896 | menu->Append(Menu_Dummy_Third, wxT("&Third dummy item\tCtrl-F3"), |
897 | wxT("Checkable item"), true); | |
717a57c2 VZ |
898 | } |
899 | ||
900 | void MyFrame::OnAppendSubMenu(wxCommandEvent& WXUNUSED(event)) | |
901 | { | |
902 | wxMenuBar *menubar = GetMenuBar(); | |
553d6728 VZ |
903 | wxMenu *menu = menubar->GetMenu(menubar->FindMenu("Test")); |
904 | wxCHECK_RET( menu, wxT("no 'Test' menu?") ); | |
f6bcfd97 | 905 | |
9a83f860 VZ |
906 | menu->Append(Menu_Dummy_Last, wxT("&Dummy sub menu"), |
907 | CreateDummyMenu(NULL), wxT("Dummy sub menu help")); | |
717a57c2 VZ |
908 | } |
909 | ||
910 | void MyFrame::OnDeleteMenuItem(wxCommandEvent& WXUNUSED(event)) | |
911 | { | |
912 | wxMenuBar *menubar = GetMenuBar(); | |
553d6728 VZ |
913 | wxMenu *menu = menubar->GetMenu(menubar->FindMenu("Test")); |
914 | wxCHECK_RET( menu, wxT("no 'Test' menu?") ); | |
717a57c2 VZ |
915 | |
916 | size_t count = menu->GetMenuItemCount(); | |
917 | if ( !count ) | |
918 | { | |
9a83f860 | 919 | wxLogWarning(wxT("No items to delete!")); |
717a57c2 VZ |
920 | } |
921 | else | |
922 | { | |
923 | menu->Destroy(menu->GetMenuItems().Item(count - 1)->GetData()); | |
924 | } | |
925 | } | |
926 | ||
08e78a54 VZ |
927 | void MyFrame::OnDeleteSubMenu(wxCommandEvent& WXUNUSED(event)) |
928 | { | |
929 | wxMenuBar *menubar = GetMenuBar(); | |
553d6728 VZ |
930 | wxMenu *menu = menubar->GetMenu(menubar->FindMenu("Test")); |
931 | wxCHECK_RET( menu, wxT("no 'Test' menu?") ); | |
08e78a54 VZ |
932 | |
933 | for ( int n = menu->GetMenuItemCount() - 1; n >=0 ; --n ) | |
934 | { | |
935 | wxMenuItem* item = menu->FindItemByPosition(n); | |
936 | if (item->IsSubMenu()) | |
937 | { | |
938 | menu->Destroy(item); | |
939 | return; | |
940 | } | |
941 | } | |
942 | ||
943 | wxLogWarning(wxT("No submenu to delete!")); | |
944 | } | |
945 | ||
717a57c2 VZ |
946 | void MyFrame::OnInsertMenuItem(wxCommandEvent& WXUNUSED(event)) |
947 | { | |
948 | wxMenuBar *menubar = GetMenuBar(); | |
553d6728 VZ |
949 | wxMenu *menu = menubar->GetMenu(menubar->FindMenu("Test")); |
950 | wxCHECK_RET( menu, wxT("no 'Test' menu?") ); | |
717a57c2 VZ |
951 | |
952 | menu->Insert(0, wxMenuItem::New(menu, Menu_Dummy_Fourth, | |
9a83f860 | 953 | wxT("Fourth dummy item\tCtrl-F4"))); |
532d575b | 954 | menu->Insert(1, wxMenuItem::New(menu, wxID_SEPARATOR)); |
717a57c2 VZ |
955 | } |
956 | ||
957 | void MyFrame::OnEnableMenuItem(wxCommandEvent& WXUNUSED(event)) | |
958 | { | |
959 | wxMenuItem *item = GetLastMenuItem(); | |
960 | ||
961 | if ( item ) | |
962 | { | |
963 | item->Enable(!item->IsEnabled()); | |
964 | } | |
965 | } | |
966 | ||
967 | void MyFrame::OnCheckMenuItem(wxCommandEvent& WXUNUSED(event)) | |
968 | { | |
969 | wxMenuItem *item = GetLastMenuItem(); | |
970 | ||
553d6728 VZ |
971 | if (item && item->IsCheckable()) |
972 | { | |
717a57c2 VZ |
973 | item->Toggle(); |
974 | } | |
553d6728 | 975 | } |
717a57c2 VZ |
976 | |
977 | void MyFrame::OnUpdateCheckMenuItemUI(wxUpdateUIEvent& event) | |
978 | { | |
32db328c VZ |
979 | wxLogNull nolog; |
980 | ||
717a57c2 VZ |
981 | wxMenuItem *item = GetLastMenuItem(); |
982 | ||
983 | event.Enable(item && item->IsCheckable()); | |
984 | } | |
985 | ||
986 | void MyFrame::OnGetLabelMenuItem(wxCommandEvent& WXUNUSED(event)) | |
987 | { | |
988 | wxMenuItem *item = GetLastMenuItem(); | |
989 | ||
990 | if ( item ) | |
991 | { | |
68bc148c | 992 | wxString label = item->GetItemLabel(); |
9a83f860 | 993 | wxLogMessage(wxT("The label of the last menu item is '%s'"), |
68bc148c | 994 | label.c_str()); |
717a57c2 VZ |
995 | } |
996 | } | |
997 | ||
1242c2d9 | 998 | #if wxUSE_TEXTDLG |
717a57c2 VZ |
999 | void MyFrame::OnSetLabelMenuItem(wxCommandEvent& WXUNUSED(event)) |
1000 | { | |
1001 | wxMenuItem *item = GetLastMenuItem(); | |
1002 | ||
1003 | if ( item ) | |
1004 | { | |
5c7766de VZ |
1005 | wxString label = wxGetTextFromUser |
1006 | ( | |
9a83f860 VZ |
1007 | wxT("Enter new label: "), |
1008 | wxT("Change last menu item text"), | |
52af3158 | 1009 | item->GetItemLabel(), |
5c7766de VZ |
1010 | this |
1011 | ); | |
9a83f860 | 1012 | label.Replace( wxT("\\t"), wxT("\t") ); |
5c7766de VZ |
1013 | |
1014 | if ( !label.empty() ) | |
1015 | { | |
52af3158 | 1016 | item->SetItemLabel(label); |
5c7766de | 1017 | } |
717a57c2 VZ |
1018 | } |
1019 | } | |
1242c2d9 | 1020 | #endif |
717a57c2 | 1021 | |
a80c322c VZ |
1022 | void MyFrame::OnGetMenuItemInfo(wxCommandEvent& WXUNUSED(event)) |
1023 | { | |
1024 | wxMenuItem *item = GetLastMenuItem(); | |
1025 | ||
1026 | if ( item ) | |
1027 | { | |
1028 | wxString msg; | |
9a83f860 VZ |
1029 | msg << wxT("The item is ") << (item->IsEnabled() ? wxT("enabled") |
1030 | : wxT("disabled")) | |
1031 | << wxT('\n'); | |
f6bcfd97 | 1032 | |
a80c322c VZ |
1033 | if ( item->IsCheckable() ) |
1034 | { | |
9a83f860 VZ |
1035 | msg << wxT("It is checkable and ") << (item->IsChecked() ? wxT("") : wxT("un")) |
1036 | << wxT("checked\n"); | |
a80c322c VZ |
1037 | } |
1038 | ||
1039 | #if wxUSE_ACCEL | |
1040 | wxAcceleratorEntry *accel = item->GetAccel(); | |
1041 | if ( accel ) | |
1042 | { | |
9a83f860 | 1043 | msg << wxT("Its accelerator is "); |
a80c322c VZ |
1044 | |
1045 | int flags = accel->GetFlags(); | |
1046 | if ( flags & wxACCEL_ALT ) | |
9a83f860 | 1047 | msg << wxT("Alt-"); |
a80c322c | 1048 | if ( flags & wxACCEL_CTRL ) |
9a83f860 | 1049 | msg << wxT("Ctrl-"); |
a80c322c | 1050 | if ( flags & wxACCEL_SHIFT ) |
9a83f860 | 1051 | msg << wxT("Shift-"); |
a80c322c VZ |
1052 | |
1053 | int code = accel->GetKeyCode(); | |
1054 | switch ( code ) | |
1055 | { | |
1056 | case WXK_F1: | |
1057 | case WXK_F2: | |
1058 | case WXK_F3: | |
1059 | case WXK_F4: | |
1060 | case WXK_F5: | |
1061 | case WXK_F6: | |
1062 | case WXK_F7: | |
1063 | case WXK_F8: | |
1064 | case WXK_F9: | |
1065 | case WXK_F10: | |
1066 | case WXK_F11: | |
1067 | case WXK_F12: | |
9a83f860 | 1068 | msg << wxT('F') << code - WXK_F1 + 1; |
a80c322c VZ |
1069 | break; |
1070 | ||
1071 | // if there are any other keys wxGetAccelFromString() may return, | |
1072 | // we should process them here | |
1073 | ||
1074 | default: | |
1075 | if ( wxIsalnum(code) ) | |
1076 | { | |
1077 | msg << (wxChar)code; | |
1078 | ||
1079 | break; | |
1080 | } | |
1081 | ||
9a83f860 | 1082 | wxFAIL_MSG( wxT("unknown keyboard accel") ); |
a80c322c VZ |
1083 | } |
1084 | ||
1085 | delete accel; | |
1086 | } | |
1087 | else | |
1088 | { | |
9a83f860 | 1089 | msg << wxT("It doesn't have an accelerator"); |
a80c322c VZ |
1090 | } |
1091 | #endif // wxUSE_ACCEL | |
1092 | ||
1093 | wxLogMessage(msg); | |
1094 | } | |
1095 | } | |
1096 | ||
1242c2d9 | 1097 | #if wxUSE_TEXTDLG |
f6d90fb9 GD |
1098 | void MyFrame::OnFindMenuItem(wxCommandEvent& WXUNUSED(event)) |
1099 | { | |
1100 | wxMenuBar *mbar = GetMenuBar(); | |
1101 | size_t count = mbar->GetMenuCount(); | |
1102 | ||
9a83f860 | 1103 | wxCHECK_RET( count, wxT("no last menu?") ); |
f6d90fb9 GD |
1104 | |
1105 | wxString label = wxGetTextFromUser | |
1106 | ( | |
9a83f860 VZ |
1107 | wxT("Enter label to search for: "), |
1108 | wxT("Find menu item"), | |
532d575b | 1109 | wxEmptyString, |
f6d90fb9 GD |
1110 | this |
1111 | ); | |
1112 | ||
1113 | if ( !label.empty() ) | |
1114 | { | |
6ee9b7b5 | 1115 | size_t menuindex; |
f6d90fb9 | 1116 | int index = wxNOT_FOUND; |
62ad15a5 | 1117 | |
f6d90fb9 GD |
1118 | for (menuindex = 0; (menuindex < count) && (index == wxNOT_FOUND); ++menuindex) |
1119 | { | |
1120 | index = mbar->FindMenuItem(mbar->GetMenu(menuindex)->GetTitle(), label); | |
1121 | } | |
1122 | if (index == wxNOT_FOUND) | |
1123 | { | |
9a83f860 | 1124 | wxLogWarning(wxT("No menu item with label '%s'"), label.c_str()); |
f6d90fb9 GD |
1125 | } |
1126 | else | |
1127 | { | |
9a83f860 | 1128 | wxLogMessage(wxT("Menu item %d in menu %lu has label '%s'"), |
2e491df9 | 1129 | index, (unsigned long)menuindex, label.c_str()); |
f6d90fb9 GD |
1130 | } |
1131 | } | |
1132 | } | |
1242c2d9 | 1133 | #endif |
f6d90fb9 | 1134 | |
ccef86c7 | 1135 | void MyFrame::ShowContextMenu(const wxPoint& pos) |
717a57c2 | 1136 | { |
42b16af4 | 1137 | wxMenu menu; |
717a57c2 | 1138 | |
00a77b7c VZ |
1139 | if ( wxGetKeyState(WXK_SHIFT) ) |
1140 | { | |
1141 | // when Shift is pressed, demonstrate the use of a simple function | |
1142 | // returning the id of the item selected in the popup menu | |
1143 | menu.SetTitle("Choose one of:"); | |
1144 | static const char *choices[] = { "Apple", "Banana", "Cherry" }; | |
1145 | for ( size_t n = 0; n < WXSIZEOF(choices); n++ ) | |
1146 | menu.Append(Menu_PopupChoice + n, choices[n]); | |
1147 | ||
1148 | const int rc = GetPopupMenuSelectionFromUser(menu, pos); | |
1149 | if ( rc == wxID_NONE ) | |
1150 | { | |
1151 | wxLogMessage("No selection"); | |
1152 | } | |
1153 | else | |
1154 | { | |
1155 | wxLogMessage("You have selected \"%s\"", | |
1156 | choices[rc - Menu_PopupChoice]); | |
1157 | } | |
1158 | } | |
1159 | else // normal case, shift not pressed | |
1160 | { | |
9a83f860 VZ |
1161 | menu.Append(Menu_Help_About, wxT("&About")); |
1162 | menu.Append(Menu_Popup_Submenu, wxT("&Submenu"), CreateDummyMenu(NULL)); | |
1163 | menu.Append(Menu_Popup_ToBeDeleted, wxT("To be &deleted")); | |
1164 | menu.AppendCheckItem(Menu_Popup_ToBeChecked, wxT("To be &checked")); | |
1165 | menu.Append(Menu_Popup_ToBeGreyed, wxT("To be &greyed"), | |
1166 | wxT("This menu item should be initially greyed out")); | |
00a77b7c | 1167 | menu.AppendSeparator(); |
9a83f860 | 1168 | menu.Append(Menu_File_Quit, wxT("E&xit")); |
00a77b7c VZ |
1169 | |
1170 | menu.Delete(Menu_Popup_ToBeDeleted); | |
1171 | menu.Check(Menu_Popup_ToBeChecked, true); | |
1172 | menu.Enable(Menu_Popup_ToBeGreyed, false); | |
1173 | ||
1174 | PopupMenu(&menu, pos); | |
1175 | ||
1176 | // test for destroying items in popup menus | |
e421922f | 1177 | #if 0 // doesn't work in wxGTK! |
00a77b7c | 1178 | menu.Destroy(Menu_Popup_Submenu); |
f6bcfd97 | 1179 | |
00a77b7c | 1180 | PopupMenu( &menu, event.GetX(), event.GetY() ); |
f6bcfd97 | 1181 | #endif // 0 |
00a77b7c | 1182 | } |
717a57c2 | 1183 | } |
e421922f | 1184 | |
256b8649 | 1185 | void MyFrame::OnTestNormal(wxCommandEvent& WXUNUSED(event)) |
d65c269b | 1186 | { |
9a83f860 | 1187 | wxLogMessage(wxT("Normal item selected")); |
d65c269b VZ |
1188 | } |
1189 | ||
1190 | void MyFrame::OnTestCheck(wxCommandEvent& event) | |
1191 | { | |
9a83f860 VZ |
1192 | wxLogMessage(wxT("Check item %schecked"), |
1193 | event.IsChecked() ? wxT("") : wxT("un")); | |
d65c269b VZ |
1194 | } |
1195 | ||
1196 | void MyFrame::OnTestRadio(wxCommandEvent& event) | |
1197 | { | |
9a83f860 | 1198 | wxLogMessage(wxT("Radio item %d selected"), |
d65c269b VZ |
1199 | event.GetId() - Menu_Test_Radio1 + 1); |
1200 | } | |
1201 | ||
1242c2d9 | 1202 | #if USE_LOG_WINDOW |
95316a3f | 1203 | void MyFrame::LogMenuOpenCloseOrHighlight(const wxMenuEvent& event, const wxChar *what) |
ccef86c7 | 1204 | { |
6ee9b7b5 | 1205 | wxString msg; |
9a83f860 VZ |
1206 | msg << wxT("A ") |
1207 | << ( event.IsPopup() ? wxT("popup ") : wxT("") ) | |
1208 | << wxT("menu has been ") | |
95316a3f VZ |
1209 | << what; |
1210 | ||
1211 | if ( event.GetEventType() == wxEVT_MENU_HIGHLIGHT ) | |
1212 | { | |
1213 | msg << wxT(" (id=") << event.GetId() << wxT(")"); | |
1214 | } | |
1215 | ||
1216 | msg << wxT("."); | |
62ad15a5 | 1217 | |
6ee9b7b5 | 1218 | wxLogStatus(this, msg.c_str()); |
ccef86c7 | 1219 | } |
1242c2d9 | 1220 | #endif |
ccef86c7 | 1221 | |
c377f1be JS |
1222 | void MyFrame::OnUpdateSubMenuNormal(wxUpdateUIEvent& event) |
1223 | { | |
6ee9b7b5 | 1224 | event.Enable(false); |
c377f1be JS |
1225 | } |
1226 | ||
1227 | void MyFrame::OnUpdateSubMenuCheck(wxUpdateUIEvent& event) | |
1228 | { | |
6ee9b7b5 | 1229 | event.Enable(true); |
c377f1be JS |
1230 | } |
1231 | ||
1232 | void MyFrame::OnUpdateSubMenuRadio(wxUpdateUIEvent& event) | |
1233 | { | |
1234 | int which = (event.GetId() - Menu_SubMenu_Radio1 + 1); | |
1235 | if (which == 2) | |
6ee9b7b5 | 1236 | event.Check(true); |
c377f1be | 1237 | else |
6ee9b7b5 | 1238 | event.Check(false); |
c377f1be JS |
1239 | } |
1240 | ||
ac103441 RR |
1241 | #if USE_CONTEXT_MENU |
1242 | void MyFrame::OnContextMenu(wxContextMenuEvent& event) | |
1243 | { | |
1244 | wxPoint point = event.GetPosition(); | |
1245 | // If from keyboard | |
1246 | if (point.x == -1 && point.y == -1) { | |
1247 | wxSize size = GetSize(); | |
1248 | point.x = size.x / 2; | |
1249 | point.y = size.y / 2; | |
1250 | } else { | |
1251 | point = ScreenToClient(point); | |
1252 | } | |
1253 | ShowContextMenu(point); | |
1254 | } | |
1255 | #endif | |
1256 | ||
256b8649 | 1257 | void MyFrame::OnSize(wxSizeEvent& WXUNUSED(event)) |
e421922f | 1258 | { |
1242c2d9 | 1259 | #if USE_LOG_WINDOW |
268766dd VZ |
1260 | if ( !m_textctrl ) |
1261 | return; | |
1262 | ||
e421922f VZ |
1263 | // leave a band below for popup menu testing |
1264 | wxSize size = GetClientSize(); | |
1265 | m_textctrl->SetSize(0, 0, size.x, (3*size.y)/4); | |
1242c2d9 | 1266 | #endif |
e421922f VZ |
1267 | |
1268 | // this is really ugly but we have to do it as we can't just call | |
1269 | // event.Skip() because wxFrameBase would make the text control fill the | |
1270 | // entire frame then | |
1271 | #ifdef __WXUNIVERSAL__ | |
1272 | PositionMenuBar(); | |
1273 | #endif // __WXUNIVERSAL__ | |
1274 | } | |
1275 | ||
95316a3f VZ |
1276 | // ---------------------------------------------------------------------------- |
1277 | // MyDialog | |
1278 | // ---------------------------------------------------------------------------- | |
1279 | ||
1280 | MyDialog::MyDialog(wxWindow* parent) | |
1281 | : wxDialog(parent, wxID_ANY, "Test Dialog") | |
1282 | { | |
1283 | #if USE_LOG_WINDOW | |
1284 | // create the log text window | |
1285 | m_textctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, | |
1286 | wxDefaultPosition, wxDefaultSize, | |
1287 | wxTE_MULTILINE); | |
1288 | m_textctrl->SetEditable(false); | |
1289 | ||
1290 | m_textctrl->AppendText(wxT("Dialogs do not have menus, but popup menus should function the same\n\n") | |
1291 | wxT("Right click this text ctrl to test popup menus.\n")); | |
1292 | #endif | |
1293 | #ifdef __POCKETPC__ | |
1294 | EnableContextMenu(); | |
1295 | #endif | |
1296 | } | |
1297 | ||
1298 | #if USE_LOG_WINDOW | |
1299 | void MyDialog::LogMenuOpenCloseOrHighlight(const wxMenuEvent& event, const wxChar *what) | |
1300 | { | |
1301 | wxString msg; | |
1302 | msg << wxT("A ") | |
1303 | << ( event.IsPopup() ? wxT("popup ") : wxT("") ) | |
1304 | << wxT("menu has been ") | |
1305 | << what; | |
1306 | if ( event.GetEventType() == wxEVT_MENU_HIGHLIGHT ) | |
1307 | { | |
1308 | msg << wxT(" (id=") << event.GetId() << wxT(")"); | |
1309 | } | |
1310 | msg << wxT(".\n"); | |
1311 | ||
1312 | m_textctrl->AppendText(msg); | |
1313 | } | |
1314 | #endif // USE_LOG_WINDOW | |
1315 | #if USE_CONTEXT_MENU | |
1316 | void MyDialog::OnContextMenu(wxContextMenuEvent& event) | |
1317 | { | |
1318 | wxPoint point = event.GetPosition(); | |
1319 | // If from keyboard | |
1320 | if (point.x == -1 && point.y == -1) { | |
1321 | wxSize size = GetSize(); | |
1322 | point.x = size.x / 2; | |
1323 | point.y = size.y / 2; | |
1324 | } else { | |
1325 | point = ScreenToClient(point); | |
1326 | } | |
1327 | ShowContextMenu(point); | |
1328 | } | |
1329 | #endif | |
1330 | ||
1331 | void MyDialog::ShowContextMenu(const wxPoint& pos) | |
1332 | { | |
1333 | wxMenu menu; | |
1334 | ||
1335 | menu.Append(Menu_Help_About, wxT("&About")); | |
1336 | menu.Append(Menu_Popup_ToBeDeleted, wxT("To be &deleted")); | |
1337 | menu.AppendCheckItem(Menu_Popup_ToBeChecked, wxT("To be &checked")); | |
1338 | menu.Append(Menu_Popup_ToBeGreyed, wxT("To be &greyed"), | |
1339 | wxT("This menu item should be initially greyed out")); | |
1340 | menu.AppendSeparator(); | |
1341 | menu.Append(Menu_File_Quit, wxT("E&xit")); | |
1342 | ||
1343 | menu.Delete(Menu_Popup_ToBeDeleted); | |
1344 | menu.Check(Menu_Popup_ToBeChecked, true); | |
1345 | menu.Enable(Menu_Popup_ToBeGreyed, false); | |
1346 | ||
1347 | PopupMenu(&menu, pos); | |
1348 | } |