Better fix for avoiding warnings from Ubuntu libdbusmenu
[wxWidgets.git] / src / gtk / menu.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/menu.cpp
3 // Purpose: implementation of wxMenuBar and wxMenu classes for wxGTK
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
12
13 #if wxUSE_MENUS
14
15 #include "wx/menu.h"
16
17 #ifndef WX_PRECOMP
18 #include "wx/intl.h"
19 #include "wx/log.h"
20 #include "wx/frame.h"
21 #include "wx/bitmap.h"
22 #include "wx/app.h"
23 #endif
24
25 #include "wx/accel.h"
26 #include "wx/stockitem.h"
27
28 #include <gtk/gtk.h>
29 #include "wx/gtk/private.h"
30 #include "wx/gtk/private/gtk2-compat.h"
31 #include "wx/gtk/private/mnemonics.h"
32
33 // Number of currently open modal dialogs, defined in src/gtk/toplevel.cpp.
34 extern int wxOpenModalDialogsCount;
35
36 // we use normal item but with a special id for the menu title
37 static const int wxGTK_TITLE_ID = -3;
38
39 // forward declare it as it's used by wxMenuBar too when using Hildon
40 extern "C"
41 {
42 static void menuitem_activate(GtkWidget*, wxMenuItem* item);
43 }
44
45 #if wxUSE_ACCEL
46 static void wxGetGtkAccel(const wxMenuItem*, guint*, GdkModifierType*);
47 #endif
48
49 static void DoCommonMenuCallbackCode(wxMenu *menu, wxMenuEvent& event)
50 {
51 // See the comment about Ubuntu Unity in menuitem_activate().
52 if ( wxOpenModalDialogsCount )
53 return;
54
55 event.SetEventObject( menu );
56
57 wxEvtHandler* handler = menu->GetEventHandler();
58 if (handler && handler->SafelyProcessEvent(event))
59 return;
60
61 wxWindow *win = menu->GetWindow();
62 wxCHECK_RET( win, "event for a menu without associated window?" );
63
64 win->HandleWindowEvent( event );
65 }
66
67 //-----------------------------------------------------------------------------
68 // wxMenuBar
69 //-----------------------------------------------------------------------------
70
71 wxMenuBar::~wxMenuBar()
72 {
73 }
74
75 void wxMenuBar::Init(size_t n, wxMenu *menus[], const wxString titles[], long style)
76 {
77 #if wxUSE_LIBHILDON || wxUSE_LIBHILDON2
78 // Hildon window uses a single menu instead of a menu bar, so wxMenuBar is
79 // the same as menu in this case
80 m_widget =
81 m_menubar = gtk_menu_new();
82 #else // !wxUSE_LIBHILDON && !wxUSE_LIBHILDON2
83 if (!PreCreation( NULL, wxDefaultPosition, wxDefaultSize ) ||
84 !CreateBase( NULL, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("menubar") ))
85 {
86 wxFAIL_MSG( wxT("wxMenuBar creation failed") );
87 return;
88 }
89
90 m_menubar = gtk_menu_bar_new();
91
92 if (style & wxMB_DOCKABLE)
93 {
94 m_widget = gtk_handle_box_new();
95 gtk_container_add(GTK_CONTAINER(m_widget), m_menubar);
96 gtk_widget_show(m_menubar);
97 }
98 else
99 {
100 m_widget = m_menubar;
101 }
102
103 PostCreation();
104
105 GTKApplyWidgetStyle();
106 #endif // wxUSE_LIBHILDON || wxUSE_LIBHILDON2/!wxUSE_LIBHILDON && !wxUSE_LIBHILDON2
107
108 g_object_ref_sink(m_widget);
109
110 for (size_t i = 0; i < n; ++i )
111 Append(menus[i], titles[i]);
112 }
113
114 wxMenuBar::wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style)
115 {
116 Init(n, menus, titles, style);
117 }
118
119 wxMenuBar::wxMenuBar(long style)
120 {
121 Init(0, NULL, NULL, style);
122 }
123
124 wxMenuBar::wxMenuBar()
125 {
126 Init(0, NULL, NULL, 0);
127 }
128
129 // recursive helpers for wxMenuBar::Attach() and Detach(): they are called to
130 // associate the menus with the frame they belong to or dissociate them from it
131 namespace
132 {
133
134 void
135 DetachFromFrame(wxMenu* menu, wxFrame* frame)
136 {
137 // support for native hot keys
138 if (menu->m_accel)
139 {
140 // Note that wxGetTopLevelParent() is really needed because this frame
141 // can be an MDI child frame which is a fake frame and not a TLW at all
142 GtkWindow * const tlw = GTK_WINDOW(wxGetTopLevelParent(frame)->m_widget);
143 if (g_slist_find(gtk_accel_groups_from_object(G_OBJECT(tlw)), menu->m_accel))
144 gtk_window_remove_accel_group(tlw, menu->m_accel);
145 }
146
147 wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst();
148 while (node)
149 {
150 wxMenuItem *menuitem = node->GetData();
151 if (menuitem->IsSubMenu())
152 DetachFromFrame(menuitem->GetSubMenu(), frame);
153 node = node->GetNext();
154 }
155 }
156
157 void
158 AttachToFrame(wxMenu* menu, wxFrame* frame)
159 {
160 // support for native hot keys
161 if (menu->m_accel)
162 {
163 GtkWindow * const tlw = GTK_WINDOW(wxGetTopLevelParent(frame)->m_widget);
164 if (!g_slist_find(gtk_accel_groups_from_object(G_OBJECT(tlw)), menu->m_accel))
165 gtk_window_add_accel_group(tlw, menu->m_accel);
166 }
167
168 wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst();
169 while (node)
170 {
171 wxMenuItem *menuitem = node->GetData();
172 if (menuitem->IsSubMenu())
173 AttachToFrame(menuitem->GetSubMenu(), frame);
174 node = node->GetNext();
175 }
176 }
177
178 } // anonymous namespace
179
180 void wxMenuBar::SetLayoutDirection(wxLayoutDirection dir)
181 {
182 if ( dir == wxLayout_Default )
183 {
184 const wxWindow *const frame = GetFrame();
185 if ( frame )
186 {
187 // inherit layout from frame.
188 dir = frame->GetLayoutDirection();
189 }
190 else // use global layout
191 {
192 dir = wxTheApp->GetLayoutDirection();
193 }
194 }
195
196 if ( dir == wxLayout_Default )
197 return;
198
199 GTKSetLayout(m_menubar, dir);
200
201 // also set the layout of all menus we already have (new ones will inherit
202 // the current layout)
203 for ( wxMenuList::compatibility_iterator node = m_menus.GetFirst();
204 node;
205 node = node->GetNext() )
206 {
207 wxMenu *const menu = node->GetData();
208 menu->SetLayoutDirection(dir);
209 }
210 }
211
212 wxLayoutDirection wxMenuBar::GetLayoutDirection() const
213 {
214 return GTKGetLayout(m_menubar);
215 }
216
217 void wxMenuBar::Attach(wxFrame *frame)
218 {
219 wxMenuBarBase::Attach(frame);
220
221 wxMenuList::compatibility_iterator node = m_menus.GetFirst();
222 while (node)
223 {
224 wxMenu *menu = node->GetData();
225 AttachToFrame( menu, frame );
226 node = node->GetNext();
227 }
228
229 SetLayoutDirection(wxLayout_Default);
230 }
231
232 void wxMenuBar::Detach()
233 {
234 wxMenuList::compatibility_iterator node = m_menus.GetFirst();
235 while (node)
236 {
237 wxMenu *menu = node->GetData();
238 DetachFromFrame( menu, m_menuBarFrame );
239 node = node->GetNext();
240 }
241
242 wxMenuBarBase::Detach();
243 }
244
245 bool wxMenuBar::Append( wxMenu *menu, const wxString &title )
246 {
247 if (wxMenuBarBase::Append(menu, title))
248 {
249 GtkAppend(menu, title);
250 return true;
251 }
252 return false;
253 }
254
255 void wxMenuBar::GtkAppend(wxMenu* menu, const wxString& title, int pos)
256 {
257 menu->SetLayoutDirection(GetLayoutDirection());
258
259 #if wxUSE_LIBHILDON || wxUSE_LIBHILDON2
260 // if the menu has only one item, append it directly to the top level menu
261 // instead of inserting a useless submenu
262 if ( menu->GetMenuItemCount() == 1 )
263 {
264 wxMenuItem * const item = menu->FindItemByPosition(0);
265
266 // remove both mnemonics and accelerator: neither is useful under Maemo
267 const wxString str(wxStripMenuCodes(item->GetItemLabel()));
268
269 if ( item->IsSubMenu() )
270 {
271 GtkAppend(item->GetSubMenu(), str, pos);
272 return;
273 }
274
275 menu->m_owner = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( str ) );
276
277 g_signal_connect(menu->m_owner, "activate",
278 G_CALLBACK(menuitem_activate), item);
279 item->SetMenuItem(menu->m_owner);
280 }
281 else
282 #endif // wxUSE_LIBHILDON || wxUSE_LIBHILDON2 /!wxUSE_LIBHILDON && !wxUSE_LIBHILDON2
283 {
284 const wxString str(wxConvertMnemonicsToGTK(title));
285
286 // This doesn't have much effect right now.
287 menu->SetTitle( str );
288
289 // The "m_owner" is the "menu item"
290 menu->m_owner = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( str ) );
291
292 gtk_menu_item_set_submenu( GTK_MENU_ITEM(menu->m_owner), menu->m_menu );
293 }
294
295 gtk_widget_show( menu->m_owner );
296
297 if (pos == -1)
298 gtk_menu_shell_append( GTK_MENU_SHELL(m_menubar), menu->m_owner );
299 else
300 gtk_menu_shell_insert( GTK_MENU_SHELL(m_menubar), menu->m_owner, pos );
301
302 if ( m_menuBarFrame )
303 AttachToFrame( menu, m_menuBarFrame );
304 }
305
306 bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
307 {
308 if (wxMenuBarBase::Insert(pos, menu, title))
309 {
310 GtkAppend(menu, title, int(pos));
311 return true;
312 }
313 return false;
314 }
315
316 wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
317 {
318 // remove the old item and insert a new one
319 wxMenu *menuOld = Remove(pos);
320 if ( menuOld && !Insert(pos, menu, title) )
321 {
322 return NULL;
323 }
324
325 // either Insert() succeeded or Remove() failed and menuOld is NULL
326 return menuOld;
327 }
328
329 wxMenu *wxMenuBar::Remove(size_t pos)
330 {
331 wxMenu *menu = wxMenuBarBase::Remove(pos);
332 if ( !menu )
333 return NULL;
334
335 // remove item from menubar before destroying item to avoid spurious
336 // warnings from Ubuntu libdbusmenu
337 gtk_container_remove(GTK_CONTAINER(m_menubar), menu->m_owner);
338 // remove submenu to avoid destroying it when item is destroyed
339 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu->m_owner), NULL);
340
341 gtk_widget_destroy( menu->m_owner );
342 menu->m_owner = NULL;
343
344 if ( m_menuBarFrame )
345 DetachFromFrame( menu, m_menuBarFrame );
346
347 return menu;
348 }
349
350 static int FindMenuItemRecursive( const wxMenu *menu, const wxString &menuString, const wxString &itemString )
351 {
352 if (wxMenuItem::GetLabelText(menu->GetTitle()) == wxMenuItem::GetLabelText(menuString))
353 {
354 int res = menu->FindItem( itemString );
355 if (res != wxNOT_FOUND)
356 return res;
357 }
358
359 wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst();
360 while (node)
361 {
362 wxMenuItem *item = node->GetData();
363 if (item->IsSubMenu())
364 return FindMenuItemRecursive(item->GetSubMenu(), menuString, itemString);
365
366 node = node->GetNext();
367 }
368
369 return wxNOT_FOUND;
370 }
371
372 int wxMenuBar::FindMenuItem( const wxString &menuString, const wxString &itemString ) const
373 {
374 wxMenuList::compatibility_iterator node = m_menus.GetFirst();
375 while (node)
376 {
377 wxMenu *menu = node->GetData();
378 int res = FindMenuItemRecursive( menu, menuString, itemString);
379 if (res != -1)
380 return res;
381 node = node->GetNext();
382 }
383
384 return wxNOT_FOUND;
385 }
386
387 // Find a wxMenuItem using its id. Recurses down into sub-menus
388 static wxMenuItem* FindMenuItemByIdRecursive(const wxMenu* menu, int id)
389 {
390 wxMenuItem* result = menu->FindChildItem(id);
391
392 wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst();
393 while ( node && result == NULL )
394 {
395 wxMenuItem *item = node->GetData();
396 if (item->IsSubMenu())
397 {
398 result = FindMenuItemByIdRecursive( item->GetSubMenu(), id );
399 }
400 node = node->GetNext();
401 }
402
403 return result;
404 }
405
406 wxMenuItem* wxMenuBar::FindItem( int id, wxMenu **menuForItem ) const
407 {
408 wxMenuItem* result = 0;
409 wxMenuList::compatibility_iterator node = m_menus.GetFirst();
410 while (node && result == 0)
411 {
412 wxMenu *menu = node->GetData();
413 result = FindMenuItemByIdRecursive( menu, id );
414 node = node->GetNext();
415 }
416
417 if ( menuForItem )
418 {
419 *menuForItem = result ? result->GetMenu() : NULL;
420 }
421
422 return result;
423 }
424
425 void wxMenuBar::EnableTop( size_t pos, bool flag )
426 {
427 wxMenuList::compatibility_iterator node = m_menus.Item( pos );
428
429 wxCHECK_RET( node, wxT("menu not found") );
430
431 wxMenu* menu = node->GetData();
432
433 if (menu->m_owner)
434 gtk_widget_set_sensitive( menu->m_owner, flag );
435 }
436
437 bool wxMenuBar::IsEnabledTop(size_t pos) const
438 {
439 wxMenuList::compatibility_iterator node = m_menus.Item( pos );
440 wxCHECK_MSG( node, false, wxS("invalid index in IsEnabledTop") );
441 wxMenu* const menu = node->GetData();
442 wxCHECK_MSG( menu->m_owner, true, wxS("no menu owner?") );
443 return gtk_widget_get_sensitive( menu->m_owner ) != 0;
444 }
445
446 wxString wxMenuBar::GetMenuLabel( size_t pos ) const
447 {
448 wxMenuList::compatibility_iterator node = m_menus.Item( pos );
449
450 wxCHECK_MSG( node, wxT("invalid"), wxT("menu not found") );
451
452 wxMenu* menu = node->GetData();
453
454 return menu->GetTitle();
455 }
456
457 void wxMenuBar::SetMenuLabel( size_t pos, const wxString& label )
458 {
459 wxMenuList::compatibility_iterator node = m_menus.Item( pos );
460
461 wxCHECK_RET( node, wxT("menu not found") );
462
463 wxMenu* menu = node->GetData();
464
465 const wxString str(wxConvertMnemonicsToGTK(label));
466
467 menu->SetTitle( str );
468
469 if (menu->m_owner)
470 gtk_label_set_text_with_mnemonic(GTK_LABEL(gtk_bin_get_child(GTK_BIN(menu->m_owner))), wxGTK_CONV(str));
471 }
472
473 //-----------------------------------------------------------------------------
474 // "activate"
475 //-----------------------------------------------------------------------------
476
477 extern "C" {
478 static void menuitem_activate(GtkWidget*, wxMenuItem* item)
479 {
480 if (!item->IsEnabled())
481 return;
482
483 // Unity hack: under Ubuntu Unity the global menu bar is not affected by a
484 // modal dialog being shown, so the user can select a menu item before
485 // hiding the dialog and, in particular, a new instance of the same dialog
486 // can be shown again, breaking a lot of programs not expecting this.
487 //
488 // So explicitly ignore any menu events generated while any modal dialogs
489 // are opened.
490 if ( wxOpenModalDialogsCount )
491 return;
492
493 int id = item->GetId();
494 if (id == wxGTK_TITLE_ID)
495 {
496 // ignore events from the menu title
497 return;
498 }
499
500 if (item->IsCheckable())
501 {
502 bool isReallyChecked = item->IsChecked(),
503 isInternallyChecked = item->wxMenuItemBase::IsChecked();
504
505 // ensure that the internal state is always consistent with what is
506 // shown on the screen
507 item->wxMenuItemBase::Check(isReallyChecked);
508
509 // we must not report the events for the radio button going up nor the
510 // events resulting from the calls to wxMenuItem::Check()
511 if ( (item->GetKind() == wxITEM_RADIO && !isReallyChecked) ||
512 (isInternallyChecked == isReallyChecked) )
513 {
514 return;
515 }
516 }
517
518 wxMenu* menu = item->GetMenu();
519 menu->SendEvent(id, item->IsCheckable() ? item->IsChecked() : -1);
520 }
521 }
522
523 //-----------------------------------------------------------------------------
524 // "select"
525 //-----------------------------------------------------------------------------
526
527 extern "C" {
528 static void menuitem_select(GtkWidget*, wxMenuItem* item)
529 {
530 if (!item->IsEnabled())
531 return;
532
533 wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, item->GetId());
534 DoCommonMenuCallbackCode(item->GetMenu(), event);
535 }
536 }
537
538 //-----------------------------------------------------------------------------
539 // "deselect"
540 //-----------------------------------------------------------------------------
541
542 extern "C" {
543 static void menuitem_deselect(GtkWidget*, wxMenuItem* item)
544 {
545 if (!item->IsEnabled())
546 return;
547
548 wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, -1 );
549 DoCommonMenuCallbackCode(item->GetMenu(), event);
550 }
551 }
552
553 //-----------------------------------------------------------------------------
554 // wxMenuItem
555 //-----------------------------------------------------------------------------
556
557 wxMenuItem *wxMenuItemBase::New(wxMenu *parentMenu,
558 int id,
559 const wxString& name,
560 const wxString& help,
561 wxItemKind kind,
562 wxMenu *subMenu)
563 {
564 return new wxMenuItem(parentMenu, id, name, help, kind, subMenu);
565 }
566
567 wxMenuItem::wxMenuItem(wxMenu *parentMenu,
568 int id,
569 const wxString& text,
570 const wxString& help,
571 wxItemKind kind,
572 wxMenu *subMenu)
573 : wxMenuItemBase(parentMenu, id, text, help, kind, subMenu)
574 {
575 m_menuItem = NULL;
576 }
577
578 #if WXWIN_COMPATIBILITY_2_8
579 wxMenuItem::wxMenuItem(wxMenu *parentMenu,
580 int id,
581 const wxString& text,
582 const wxString& help,
583 bool isCheckable,
584 wxMenu *subMenu)
585 : wxMenuItemBase(parentMenu, id, text, help,
586 isCheckable ? wxITEM_CHECK : wxITEM_NORMAL, subMenu)
587 {
588 m_menuItem = NULL;
589 }
590 #endif
591
592 wxMenuItem::~wxMenuItem()
593 {
594 // don't delete menu items, the menus take care of that
595 }
596
597 void wxMenuItem::SetItemLabel( const wxString& str )
598 {
599 #if wxUSE_ACCEL
600 if (m_menuItem)
601 {
602 // remove old accelerator
603 guint accel_key;
604 GdkModifierType accel_mods;
605 wxGetGtkAccel(this, &accel_key, &accel_mods);
606 if (accel_key)
607 {
608 gtk_widget_remove_accelerator(
609 m_menuItem, m_parentMenu->m_accel, accel_key, accel_mods);
610 }
611 }
612 #endif // wxUSE_ACCEL
613 wxMenuItemBase::SetItemLabel(str);
614 if (m_menuItem)
615 SetGtkLabel();
616 }
617
618 void wxMenuItem::SetGtkLabel()
619 {
620 const wxString text = wxConvertMnemonicsToGTK(m_text.BeforeFirst('\t'));
621 GtkLabel* label = GTK_LABEL(gtk_bin_get_child(GTK_BIN(m_menuItem)));
622 gtk_label_set_text_with_mnemonic(label, wxGTK_CONV_SYS(text));
623 #if wxUSE_ACCEL
624 guint accel_key;
625 GdkModifierType accel_mods;
626 wxGetGtkAccel(this, &accel_key, &accel_mods);
627 if (accel_key)
628 {
629 gtk_widget_add_accelerator(
630 m_menuItem, "activate", m_parentMenu->m_accel,
631 accel_key, accel_mods, GTK_ACCEL_VISIBLE);
632 }
633 #endif // wxUSE_ACCEL
634 }
635
636 void wxMenuItem::SetBitmap(const wxBitmap& bitmap)
637 {
638 if (m_kind == wxITEM_NORMAL)
639 m_bitmap = bitmap;
640 else
641 {
642 wxFAIL_MSG("only normal menu items can have bitmaps");
643 }
644 }
645
646 void wxMenuItem::Check( bool check )
647 {
648 wxCHECK_RET( m_menuItem, wxT("invalid menu item") );
649
650 if (check == m_isChecked)
651 return;
652
653 wxMenuItemBase::Check( check );
654
655 switch ( GetKind() )
656 {
657 case wxITEM_CHECK:
658 case wxITEM_RADIO:
659 gtk_check_menu_item_set_active( (GtkCheckMenuItem*)m_menuItem, (gint)check );
660 break;
661
662 default:
663 wxFAIL_MSG( wxT("can't check this item") );
664 }
665 }
666
667 void wxMenuItem::Enable( bool enable )
668 {
669 wxCHECK_RET( m_menuItem, wxT("invalid menu item") );
670
671 gtk_widget_set_sensitive( m_menuItem, enable );
672 wxMenuItemBase::Enable( enable );
673 }
674
675 bool wxMenuItem::IsChecked() const
676 {
677 wxCHECK_MSG( m_menuItem, false, wxT("invalid menu item") );
678
679 wxCHECK_MSG( IsCheckable(), false,
680 wxT("can't get state of uncheckable item!") );
681
682 return gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(m_menuItem)) != 0;
683 }
684
685 //-----------------------------------------------------------------------------
686 // wxMenu
687 //-----------------------------------------------------------------------------
688
689 extern "C" {
690 // "map" from m_menu
691 static void menu_map(GtkWidget*, wxMenu* menu)
692 {
693 wxMenuEvent event(wxEVT_MENU_OPEN, menu->m_popupShown ? -1 : 0, menu);
694 DoCommonMenuCallbackCode(menu, event);
695 }
696
697 // "hide" from m_menu
698 static void menu_hide(GtkWidget*, wxMenu* menu)
699 {
700 // When using Ubuntu Unity desktop environment we get "hide" signal even
701 // when the window is not shown yet because Unity hides all the menus to
702 // show them only in the global menu bar. Just ignore this even instead of
703 // crashing in DoCommonMenuCallbackCode().
704 if ( !menu->GetWindow() )
705 return;
706
707 wxMenuEvent event(wxEVT_MENU_CLOSE, menu->m_popupShown ? -1 : 0, menu);
708 menu->m_popupShown = false;
709 DoCommonMenuCallbackCode(menu, event);
710 }
711 }
712
713 // "can_activate_accel" from menu item
714 extern "C" {
715 static gboolean can_activate_accel(GtkWidget*, guint, wxMenu* menu)
716 {
717 menu->UpdateUI();
718 // always allow our "activate" handler to be called
719 return true;
720 }
721 }
722
723 void wxMenu::Init()
724 {
725 m_popupShown = false;
726
727 m_accel = gtk_accel_group_new();
728 m_menu = gtk_menu_new();
729 // NB: keep reference to the menu so that it is not destroyed behind
730 // our back by GTK+ e.g. when it is removed from menubar:
731 g_object_ref_sink(m_menu);
732
733 m_owner = NULL;
734
735 // Tearoffs are entries, just like separators. So if we want this
736 // menu to be a tear-off one, we just append a tearoff entry
737 // immediately.
738 if ( m_style & wxMENU_TEAROFF )
739 {
740 GtkWidget *tearoff = gtk_tearoff_menu_item_new();
741
742 gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), tearoff);
743 }
744
745 // append the title as the very first entry if we have it
746 if ( !m_title.empty() )
747 {
748 Append(wxGTK_TITLE_ID, m_title);
749 AppendSeparator();
750 }
751
752 // "show" occurs for sub-menus which are not showing, so use "map" instead
753 g_signal_connect(m_menu, "map", G_CALLBACK(menu_map), this);
754 g_signal_connect(m_menu, "hide", G_CALLBACK(menu_hide), this);
755 }
756
757 wxMenu::~wxMenu()
758 {
759 // Destroying a menu generates a "hide" signal even if it's not shown
760 // currently, so disconnect it to avoid dummy wxEVT_MENU_CLOSE events
761 // generation.
762 g_signal_handlers_disconnect_matched(m_menu,
763 GSignalMatchType(G_SIGNAL_MATCH_DATA), 0, 0, NULL, NULL, this);
764
765 // see wxMenu::Init
766 g_object_unref(m_menu);
767
768 // if the menu is inserted in another menu at this time, there was
769 // one more reference to it:
770 if (m_owner)
771 gtk_widget_destroy(m_owner);
772
773 g_object_unref(m_accel);
774 }
775
776 void wxMenu::SetLayoutDirection(const wxLayoutDirection dir)
777 {
778 if ( m_owner )
779 wxWindow::GTKSetLayout(m_owner, dir);
780 //else: will be called later by wxMenuBar again
781 }
782
783 wxLayoutDirection wxMenu::GetLayoutDirection() const
784 {
785 return wxWindow::GTKGetLayout(m_owner);
786 }
787
788 wxString wxMenu::GetTitle() const
789 {
790 return wxConvertMnemonicsFromGTK(wxMenuBase::GetTitle());
791 }
792
793 void wxMenu::GtkAppend(wxMenuItem* mitem, int pos)
794 {
795 GtkWidget *menuItem;
796 switch (mitem->GetKind())
797 {
798 case wxITEM_SEPARATOR:
799 menuItem = gtk_separator_menu_item_new();
800 break;
801 case wxITEM_CHECK:
802 menuItem = gtk_check_menu_item_new_with_label("");
803 break;
804 case wxITEM_RADIO:
805 {
806 // See if we need to create a new radio group for this item or
807 // add it to an existing one.
808 wxMenuItem* radioGroupItem = NULL;
809
810 const size_t numItems = GetMenuItemCount();
811 const size_t n = pos == -1 ? numItems - 1 : size_t(pos);
812
813 if (n != 0)
814 {
815 wxMenuItem* const itemPrev = FindItemByPosition(n - 1);
816 if ( itemPrev->GetKind() == wxITEM_RADIO )
817 {
818 // Appending an item after an existing radio item puts
819 // it into the same radio group.
820 radioGroupItem = itemPrev;
821 }
822 }
823
824 if (radioGroupItem == NULL && n != numItems - 1)
825 {
826 wxMenuItem* const itemNext = FindItemByPosition(n + 1);
827 if ( itemNext->GetKind() == wxITEM_RADIO )
828 {
829 // Inserting an item before an existing radio item
830 // also puts it into the existing radio group.
831 radioGroupItem = itemNext;
832 }
833 }
834
835 GSList* group = NULL;
836 if ( radioGroupItem )
837 {
838 group = gtk_radio_menu_item_get_group(
839 GTK_RADIO_MENU_ITEM(radioGroupItem->GetMenuItem())
840 );
841 }
842
843 menuItem = gtk_radio_menu_item_new_with_label(group, "");
844 }
845 break;
846 default:
847 wxFAIL_MSG("unexpected menu item kind");
848 // fall through
849 case wxITEM_NORMAL:
850 const wxBitmap& bitmap = mitem->GetBitmap();
851 const char* stockid;
852 if (bitmap.IsOk())
853 {
854 // always use pixbuf, because pixmap mask does not
855 // work with disabled images in some themes
856 GtkWidget* image = gtk_image_new_from_pixbuf(bitmap.GetPixbuf());
857 menuItem = gtk_image_menu_item_new_with_label("");
858 gtk_widget_show(image);
859 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuItem), image);
860 }
861 else if ((stockid = wxGetStockGtkID(mitem->GetId())) != NULL)
862 // use stock bitmap for this item if available on the assumption
863 // that it never hurts to follow GTK+ conventions more closely
864 menuItem = gtk_image_menu_item_new_from_stock(stockid, NULL);
865 else
866 menuItem = gtk_menu_item_new_with_label("");
867 break;
868 }
869 mitem->SetMenuItem(menuItem);
870
871 gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos);
872
873 gtk_widget_show( menuItem );
874
875 if ( !mitem->IsSeparator() )
876 {
877 mitem->SetGtkLabel();
878 g_signal_connect (menuItem, "select",
879 G_CALLBACK(menuitem_select), mitem);
880 g_signal_connect (menuItem, "deselect",
881 G_CALLBACK(menuitem_deselect), mitem);
882
883 if ( mitem->IsSubMenu() && mitem->GetKind() != wxITEM_RADIO && mitem->GetKind() != wxITEM_CHECK )
884 {
885 gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem), mitem->GetSubMenu()->m_menu );
886
887 gtk_widget_show( mitem->GetSubMenu()->m_menu );
888 }
889 else
890 {
891 g_signal_connect(menuItem, "can_activate_accel",
892 G_CALLBACK(can_activate_accel), this);
893 g_signal_connect (menuItem, "activate",
894 G_CALLBACK(menuitem_activate),
895 mitem);
896 }
897 }
898 }
899
900 wxMenuItem* wxMenu::DoAppend(wxMenuItem *mitem)
901 {
902 if (wxMenuBase::DoAppend(mitem))
903 {
904 GtkAppend(mitem);
905 return mitem;
906 }
907 return NULL;
908 }
909
910 wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item)
911 {
912 if (wxMenuBase::DoInsert(pos, item))
913 {
914 GtkAppend(item, int(pos));
915 return item;
916 }
917 return NULL;
918 }
919
920 wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
921 {
922 if ( !wxMenuBase::DoRemove(item) )
923 return NULL;
924
925 GtkWidget * const mitem = item->GetMenuItem();
926
927 g_signal_handlers_disconnect_matched(mitem,
928 GSignalMatchType(G_SIGNAL_MATCH_DATA), 0, 0, NULL, NULL, item);
929
930 #ifdef __WXGTK3__
931 gtk_menu_item_set_submenu(GTK_MENU_ITEM(mitem), NULL);
932 #else
933 if (!gtk_check_version(2,12,0))
934 {
935 // gtk_menu_item_remove_submenu() is deprecated since 2.12, but
936 // gtk_menu_item_set_submenu() can now be used with NULL submenu now so
937 // just do use it.
938 gtk_menu_item_set_submenu(GTK_MENU_ITEM(mitem), NULL);
939 }
940 else // GTK+ < 2.12
941 {
942 // In 2.10 calling gtk_menu_item_set_submenu() with NULL submenu
943 // results in critical GTK+ error messages so use the old function
944 // instead.
945 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(mitem));
946 }
947 #endif
948
949 gtk_widget_destroy(mitem);
950 item->SetMenuItem(NULL);
951
952 return item;
953 }
954
955 void wxMenu::Attach(wxMenuBarBase *menubar)
956 {
957 wxMenuBase::Attach(menubar);
958
959 // inherit layout direction from menubar.
960 SetLayoutDirection(menubar->GetLayoutDirection());
961 }
962
963 // ----------------------------------------------------------------------------
964 // helpers
965 // ----------------------------------------------------------------------------
966
967 #if wxUSE_ACCEL
968
969 static wxString GetGtkHotKey( const wxMenuItem& item )
970 {
971 wxString hotkey;
972
973 wxAcceleratorEntry *accel = item.GetAccel();
974 if ( accel )
975 {
976 int flags = accel->GetFlags();
977 if ( flags & wxACCEL_ALT )
978 hotkey += wxT("<alt>");
979 if ( flags & wxACCEL_CTRL )
980 hotkey += wxT("<control>");
981 if ( flags & wxACCEL_SHIFT )
982 hotkey += wxT("<shift>");
983
984 int code = accel->GetKeyCode();
985 switch ( code )
986 {
987 case WXK_F1:
988 case WXK_F2:
989 case WXK_F3:
990 case WXK_F4:
991 case WXK_F5:
992 case WXK_F6:
993 case WXK_F7:
994 case WXK_F8:
995 case WXK_F9:
996 case WXK_F10:
997 case WXK_F11:
998 case WXK_F12:
999 case WXK_F13:
1000 case WXK_F14:
1001 case WXK_F15:
1002 case WXK_F16:
1003 case WXK_F17:
1004 case WXK_F18:
1005 case WXK_F19:
1006 case WXK_F20:
1007 case WXK_F21:
1008 case WXK_F22:
1009 case WXK_F23:
1010 case WXK_F24:
1011 hotkey += wxString::Format(wxT("F%d"), code - WXK_F1 + 1);
1012 break;
1013
1014 // TODO: we should use gdk_keyval_name() (a.k.a.
1015 // XKeysymToString) here as well as hardcoding the keysym
1016 // names this might be not portable
1017 case WXK_INSERT:
1018 hotkey << wxT("Insert" );
1019 break;
1020 case WXK_DELETE:
1021 hotkey << wxT("Delete" );
1022 break;
1023 case WXK_UP:
1024 hotkey << wxT("Up" );
1025 break;
1026 case WXK_DOWN:
1027 hotkey << wxT("Down" );
1028 break;
1029 case WXK_PAGEUP:
1030 hotkey << wxT("Page_Up" );
1031 break;
1032 case WXK_PAGEDOWN:
1033 hotkey << wxT("Page_Down" );
1034 break;
1035 case WXK_LEFT:
1036 hotkey << wxT("Left" );
1037 break;
1038 case WXK_RIGHT:
1039 hotkey << wxT("Right" );
1040 break;
1041 case WXK_HOME:
1042 hotkey << wxT("Home" );
1043 break;
1044 case WXK_END:
1045 hotkey << wxT("End" );
1046 break;
1047 case WXK_RETURN:
1048 hotkey << wxT("Return" );
1049 break;
1050 case WXK_BACK:
1051 hotkey << wxT("BackSpace" );
1052 break;
1053 case WXK_TAB:
1054 hotkey << wxT("Tab" );
1055 break;
1056 case WXK_ESCAPE:
1057 hotkey << wxT("Esc" );
1058 break;
1059 case WXK_SPACE:
1060 hotkey << wxT("space" );
1061 break;
1062 case WXK_MULTIPLY:
1063 hotkey << wxT("Multiply" );
1064 break;
1065 case WXK_ADD:
1066 hotkey << wxT("Add" );
1067 break;
1068 case WXK_SEPARATOR:
1069 hotkey << wxT("Separator" );
1070 break;
1071 case WXK_SUBTRACT:
1072 hotkey << wxT("Subtract" );
1073 break;
1074 case WXK_DECIMAL:
1075 hotkey << wxT("Decimal" );
1076 break;
1077 case WXK_DIVIDE:
1078 hotkey << wxT("Divide" );
1079 break;
1080 case WXK_CANCEL:
1081 hotkey << wxT("Cancel" );
1082 break;
1083 case WXK_CLEAR:
1084 hotkey << wxT("Clear" );
1085 break;
1086 case WXK_MENU:
1087 hotkey << wxT("Menu" );
1088 break;
1089 case WXK_PAUSE:
1090 hotkey << wxT("Pause" );
1091 break;
1092 case WXK_CAPITAL:
1093 hotkey << wxT("Capital" );
1094 break;
1095 case WXK_SELECT:
1096 hotkey << wxT("Select" );
1097 break;
1098 case WXK_PRINT:
1099 hotkey << wxT("Print" );
1100 break;
1101 case WXK_EXECUTE:
1102 hotkey << wxT("Execute" );
1103 break;
1104 case WXK_SNAPSHOT:
1105 hotkey << wxT("Snapshot" );
1106 break;
1107 case WXK_HELP:
1108 hotkey << wxT("Help" );
1109 break;
1110 case WXK_NUMLOCK:
1111 hotkey << wxT("Num_Lock" );
1112 break;
1113 case WXK_SCROLL:
1114 hotkey << wxT("Scroll_Lock" );
1115 break;
1116 case WXK_NUMPAD_INSERT:
1117 hotkey << wxT("KP_Insert" );
1118 break;
1119 case WXK_NUMPAD_DELETE:
1120 hotkey << wxT("KP_Delete" );
1121 break;
1122 case WXK_NUMPAD_SPACE:
1123 hotkey << wxT("KP_Space" );
1124 break;
1125 case WXK_NUMPAD_TAB:
1126 hotkey << wxT("KP_Tab" );
1127 break;
1128 case WXK_NUMPAD_ENTER:
1129 hotkey << wxT("KP_Enter" );
1130 break;
1131 case WXK_NUMPAD_F1: case WXK_NUMPAD_F2: case WXK_NUMPAD_F3:
1132 case WXK_NUMPAD_F4:
1133 hotkey += wxString::Format(wxT("KP_F%d"), code - WXK_NUMPAD_F1 + 1);
1134 break;
1135 case WXK_NUMPAD_HOME:
1136 hotkey << wxT("KP_Home" );
1137 break;
1138 case WXK_NUMPAD_LEFT:
1139 hotkey << wxT("KP_Left" );
1140 break;
1141 case WXK_NUMPAD_UP:
1142 hotkey << wxT("KP_Up" );
1143 break;
1144 case WXK_NUMPAD_RIGHT:
1145 hotkey << wxT("KP_Right" );
1146 break;
1147 case WXK_NUMPAD_DOWN:
1148 hotkey << wxT("KP_Down" );
1149 break;
1150 case WXK_NUMPAD_PAGEUP:
1151 hotkey << wxT("KP_Page_Up" );
1152 break;
1153 case WXK_NUMPAD_PAGEDOWN:
1154 hotkey << wxT("KP_Page_Down" );
1155 break;
1156 case WXK_NUMPAD_END:
1157 hotkey << wxT("KP_End" );
1158 break;
1159 case WXK_NUMPAD_BEGIN:
1160 hotkey << wxT("KP_Begin" );
1161 break;
1162 case WXK_NUMPAD_EQUAL:
1163 hotkey << wxT("KP_Equal" );
1164 break;
1165 case WXK_NUMPAD_MULTIPLY:
1166 hotkey << wxT("KP_Multiply" );
1167 break;
1168 case WXK_NUMPAD_ADD:
1169 hotkey << wxT("KP_Add" );
1170 break;
1171 case WXK_NUMPAD_SEPARATOR:
1172 hotkey << wxT("KP_Separator" );
1173 break;
1174 case WXK_NUMPAD_SUBTRACT:
1175 hotkey << wxT("KP_Subtract" );
1176 break;
1177 case WXK_NUMPAD_DECIMAL:
1178 hotkey << wxT("KP_Decimal" );
1179 break;
1180 case WXK_NUMPAD_DIVIDE:
1181 hotkey << wxT("KP_Divide" );
1182 break;
1183 case WXK_NUMPAD0: case WXK_NUMPAD1: case WXK_NUMPAD2:
1184 case WXK_NUMPAD3: case WXK_NUMPAD4: case WXK_NUMPAD5:
1185 case WXK_NUMPAD6: case WXK_NUMPAD7: case WXK_NUMPAD8: case WXK_NUMPAD9:
1186 hotkey += wxString::Format(wxT("KP_%d"), code - WXK_NUMPAD0);
1187 break;
1188 case WXK_WINDOWS_LEFT:
1189 hotkey << wxT("Super_L" );
1190 break;
1191 case WXK_WINDOWS_RIGHT:
1192 hotkey << wxT("Super_R" );
1193 break;
1194 case WXK_WINDOWS_MENU:
1195 hotkey << wxT("Menu" );
1196 break;
1197 case WXK_COMMAND:
1198 hotkey << wxT("Command" );
1199 break;
1200 /* These probably wouldn't work as there is no SpecialX in gdk/keynames.txt
1201 case WXK_SPECIAL1: case WXK_SPECIAL2: case WXK_SPECIAL3: case WXK_SPECIAL4:
1202 case WXK_SPECIAL5: case WXK_SPECIAL6: case WXK_SPECIAL7: case WXK_SPECIAL8:
1203 case WXK_SPECIAL9: case WXK_SPECIAL10: case WXK_SPECIAL11: case WXK_SPECIAL12:
1204 case WXK_SPECIAL13: case WXK_SPECIAL14: case WXK_SPECIAL15: case WXK_SPECIAL16:
1205 case WXK_SPECIAL17: case WXK_SPECIAL18: case WXK_SPECIAL19: case WXK_SPECIAL20:
1206 hotkey += wxString::Format(wxT("Special%d"), code - WXK_SPECIAL1 + 1);
1207 break;
1208 */
1209 // if there are any other keys wxAcceleratorEntry::Create() may
1210 // return, we should process them here
1211
1212 default:
1213 if ( code < 127 )
1214 {
1215 const wxString
1216 name = wxGTK_CONV_BACK_SYS(gdk_keyval_name((guint)code));
1217 if ( !name.empty() )
1218 {
1219 hotkey << name;
1220 break;
1221 }
1222 }
1223
1224 wxFAIL_MSG( wxT("unknown keyboard accel") );
1225 }
1226
1227 delete accel;
1228 }
1229
1230 return hotkey;
1231 }
1232
1233 static void
1234 wxGetGtkAccel(const wxMenuItem* item, guint* accel_key, GdkModifierType* accel_mods)
1235 {
1236 *accel_key = 0;
1237 const wxString string = GetGtkHotKey(*item);
1238 if (!string.empty())
1239 gtk_accelerator_parse(wxGTK_CONV_SYS(string), accel_key, accel_mods);
1240 else
1241 {
1242 GtkStockItem stock_item;
1243 const char* stockid = wxGetStockGtkID(item->GetId());
1244 if (stockid && gtk_stock_lookup(stockid, &stock_item))
1245 {
1246 *accel_key = stock_item.keyval;
1247 *accel_mods = stock_item.modifier;
1248 }
1249 }
1250 }
1251 #endif // wxUSE_ACCEL
1252
1253 const char *wxGetStockGtkID(wxWindowID id)
1254 {
1255 #define STOCKITEM(wx,gtk) \
1256 case wx: \
1257 return gtk;
1258
1259 #if GTK_CHECK_VERSION(2,8,0)
1260 #define STOCKITEM_28(wx,gtk) STOCKITEM(wx,gtk)
1261 #else
1262 #define STOCKITEM_28(wx,gtk)
1263 #endif
1264
1265 #if GTK_CHECK_VERSION(2,10,0)
1266 #define STOCKITEM_210(wx,gtk) STOCKITEM(wx,gtk)
1267 #else
1268 #define STOCKITEM_210(wx,gtk)
1269 #endif
1270
1271
1272 switch (id)
1273 {
1274 STOCKITEM(wxID_ABOUT, GTK_STOCK_ABOUT)
1275 STOCKITEM(wxID_ADD, GTK_STOCK_ADD)
1276 STOCKITEM(wxID_APPLY, GTK_STOCK_APPLY)
1277 STOCKITEM(wxID_BACKWARD, GTK_STOCK_GO_BACK)
1278 STOCKITEM(wxID_BOLD, GTK_STOCK_BOLD)
1279 STOCKITEM(wxID_BOTTOM, GTK_STOCK_GOTO_BOTTOM)
1280 STOCKITEM(wxID_CANCEL, GTK_STOCK_CANCEL)
1281 STOCKITEM(wxID_CDROM, GTK_STOCK_CDROM)
1282 STOCKITEM(wxID_CLEAR, GTK_STOCK_CLEAR)
1283 STOCKITEM(wxID_CLOSE, GTK_STOCK_CLOSE)
1284 STOCKITEM(wxID_CONVERT, GTK_STOCK_CONVERT)
1285 STOCKITEM(wxID_COPY, GTK_STOCK_COPY)
1286 STOCKITEM(wxID_CUT, GTK_STOCK_CUT)
1287 STOCKITEM(wxID_DELETE, GTK_STOCK_DELETE)
1288 STOCKITEM(wxID_DOWN, GTK_STOCK_GO_DOWN)
1289 STOCKITEM(wxID_EDIT, GTK_STOCK_EDIT)
1290 STOCKITEM(wxID_EXECUTE, GTK_STOCK_EXECUTE)
1291 STOCKITEM(wxID_EXIT, GTK_STOCK_QUIT)
1292 STOCKITEM(wxID_FILE, GTK_STOCK_FILE)
1293 STOCKITEM(wxID_FIND, GTK_STOCK_FIND)
1294 STOCKITEM(wxID_FIRST, GTK_STOCK_GOTO_FIRST)
1295 STOCKITEM(wxID_FLOPPY, GTK_STOCK_FLOPPY)
1296 STOCKITEM(wxID_FORWARD, GTK_STOCK_GO_FORWARD)
1297 STOCKITEM(wxID_HARDDISK, GTK_STOCK_HARDDISK)
1298 STOCKITEM(wxID_HELP, GTK_STOCK_HELP)
1299 STOCKITEM(wxID_HOME, GTK_STOCK_HOME)
1300 STOCKITEM(wxID_INDENT, GTK_STOCK_INDENT)
1301 STOCKITEM(wxID_INDEX, GTK_STOCK_INDEX)
1302 STOCKITEM_28(wxID_INFO, GTK_STOCK_INFO)
1303 STOCKITEM(wxID_ITALIC, GTK_STOCK_ITALIC)
1304 STOCKITEM(wxID_JUMP_TO, GTK_STOCK_JUMP_TO)
1305 STOCKITEM(wxID_JUSTIFY_CENTER, GTK_STOCK_JUSTIFY_CENTER)
1306 STOCKITEM(wxID_JUSTIFY_FILL, GTK_STOCK_JUSTIFY_FILL)
1307 STOCKITEM(wxID_JUSTIFY_LEFT, GTK_STOCK_JUSTIFY_LEFT)
1308 STOCKITEM(wxID_JUSTIFY_RIGHT, GTK_STOCK_JUSTIFY_RIGHT)
1309 STOCKITEM(wxID_LAST, GTK_STOCK_GOTO_LAST)
1310 STOCKITEM(wxID_NETWORK, GTK_STOCK_NETWORK)
1311 STOCKITEM(wxID_NEW, GTK_STOCK_NEW)
1312 STOCKITEM(wxID_NO, GTK_STOCK_NO)
1313 STOCKITEM(wxID_OK, GTK_STOCK_OK)
1314 STOCKITEM(wxID_OPEN, GTK_STOCK_OPEN)
1315 STOCKITEM(wxID_PASTE, GTK_STOCK_PASTE)
1316 STOCKITEM(wxID_PREFERENCES, GTK_STOCK_PREFERENCES)
1317 STOCKITEM(wxID_PREVIEW, GTK_STOCK_PRINT_PREVIEW)
1318 STOCKITEM(wxID_PRINT, GTK_STOCK_PRINT)
1319 STOCKITEM(wxID_PROPERTIES, GTK_STOCK_PROPERTIES)
1320 STOCKITEM(wxID_REDO, GTK_STOCK_REDO)
1321 STOCKITEM(wxID_REFRESH, GTK_STOCK_REFRESH)
1322 STOCKITEM(wxID_REMOVE, GTK_STOCK_REMOVE)
1323 STOCKITEM(wxID_REPLACE, GTK_STOCK_FIND_AND_REPLACE)
1324 STOCKITEM(wxID_REVERT_TO_SAVED, GTK_STOCK_REVERT_TO_SAVED)
1325 STOCKITEM(wxID_SAVE, GTK_STOCK_SAVE)
1326 STOCKITEM(wxID_SAVEAS, GTK_STOCK_SAVE_AS)
1327 STOCKITEM_210(wxID_SELECTALL, GTK_STOCK_SELECT_ALL)
1328 STOCKITEM(wxID_SELECT_COLOR, GTK_STOCK_SELECT_COLOR)
1329 STOCKITEM(wxID_SELECT_FONT, GTK_STOCK_SELECT_FONT)
1330 STOCKITEM(wxID_SORT_ASCENDING, GTK_STOCK_SORT_ASCENDING)
1331 STOCKITEM(wxID_SORT_DESCENDING, GTK_STOCK_SORT_DESCENDING)
1332 STOCKITEM(wxID_SPELL_CHECK, GTK_STOCK_SPELL_CHECK)
1333 STOCKITEM(wxID_STOP, GTK_STOCK_STOP)
1334 STOCKITEM(wxID_STRIKETHROUGH, GTK_STOCK_STRIKETHROUGH)
1335 STOCKITEM(wxID_TOP, GTK_STOCK_GOTO_TOP)
1336 STOCKITEM(wxID_UNDELETE, GTK_STOCK_UNDELETE)
1337 STOCKITEM(wxID_UNDERLINE, GTK_STOCK_UNDERLINE)
1338 STOCKITEM(wxID_UNDO, GTK_STOCK_UNDO)
1339 STOCKITEM(wxID_UNINDENT, GTK_STOCK_UNINDENT)
1340 STOCKITEM(wxID_UP, GTK_STOCK_GO_UP)
1341 STOCKITEM(wxID_YES, GTK_STOCK_YES)
1342 STOCKITEM(wxID_ZOOM_100, GTK_STOCK_ZOOM_100)
1343 STOCKITEM(wxID_ZOOM_FIT, GTK_STOCK_ZOOM_FIT)
1344 STOCKITEM(wxID_ZOOM_IN, GTK_STOCK_ZOOM_IN)
1345 STOCKITEM(wxID_ZOOM_OUT, GTK_STOCK_ZOOM_OUT)
1346
1347 default:
1348 break;
1349 };
1350
1351 #undef STOCKITEM
1352
1353 return NULL;
1354 }
1355
1356 #endif // wxUSE_MENUS