1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/menu.cpp
3 // Purpose: implementation of wxMenuBar and wxMenu classes for wxGTK
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
21 #include "wx/bitmap.h"
26 #include "wx/stockitem.h"
27 #include "wx/gtk/private.h"
28 #include "wx/gtk/private/mnemonics.h"
30 // FIXME: is this right? somehow I don't think so (VZ)
32 #define gtk_accel_group_attach(g, o) gtk_window_add_accel_group((o), (g))
33 #define gtk_accel_group_detach(g, o) gtk_window_remove_accel_group((o), (g))
34 //#define gtk_menu_ensure_uline_accel_group(m) gtk_menu_get_accel_group(m)
36 #define ACCEL_OBJECT GtkWindow
37 #define ACCEL_OBJECTS(a) (a)->acceleratables
38 #define ACCEL_OBJ_CAST(obj) ((GtkWindow*) obj)
40 // we use normal item but with a special id for the menu title
41 static const int wxGTK_TITLE_ID
= -3;
43 // forward declare it as it's used by wxMenuBar too when using Hildon
46 static void gtk_menu_clicked_callback(GtkWidget
*widget
, wxMenu
*menu
);
49 //-----------------------------------------------------------------------------
51 //-----------------------------------------------------------------------------
54 static wxString
GetGtkHotKey( const wxMenuItem
& item
);
57 //-----------------------------------------------------------------------------
58 // activate message from GTK
59 //-----------------------------------------------------------------------------
61 static void DoCommonMenuCallbackCode(wxMenu
*menu
, wxMenuEvent
& event
)
63 event
.SetEventObject( menu
);
65 wxEvtHandler
* handler
= menu
->GetEventHandler();
66 if (handler
&& handler
->ProcessEvent(event
))
69 wxWindow
*win
= menu
->GetInvokingWindow();
71 win
->GetEventHandler()->ProcessEvent( event
);
77 gtk_menu_open_callback(GtkWidget
* WXUNUSED(widget
), wxMenu
*menu
)
79 wxMenuEvent
event(wxEVT_MENU_OPEN
, -1, menu
);
81 DoCommonMenuCallbackCode(menu
, event
);
85 gtk_menu_close_callback(GtkWidget
* WXUNUSED(widget
), wxMenuBar
*menubar
)
87 if ( !menubar
->GetMenuCount() )
89 // if menubar is empty we can't call GetMenu(0) below
93 wxMenuEvent
event( wxEVT_MENU_CLOSE
, -1, NULL
);
95 DoCommonMenuCallbackCode(menubar
->GetMenu(0), event
);
100 //-----------------------------------------------------------------------------
102 //-----------------------------------------------------------------------------
104 IMPLEMENT_DYNAMIC_CLASS(wxMenuBar
,wxWindow
)
106 void wxMenuBar::Init(size_t n
, wxMenu
*menus
[], const wxString titles
[], long style
)
109 m_invokingWindow
= NULL
;
112 // Hildon window uses a single menu instead of a menu bar, so wxMenuBar is
113 // the same as menu in this case
115 m_menubar
= gtk_menu_new();
116 #else // !wxUSE_LIBHILDON
117 if (!PreCreation( NULL
, wxDefaultPosition
, wxDefaultSize
) ||
118 !CreateBase( NULL
, -1, wxDefaultPosition
, wxDefaultSize
, style
, wxDefaultValidator
, wxT("menubar") ))
120 wxFAIL_MSG( wxT("wxMenuBar creation failed") );
124 m_menubar
= gtk_menu_bar_new();
126 if (style
& wxMB_DOCKABLE
)
128 m_widget
= gtk_handle_box_new();
129 gtk_container_add(GTK_CONTAINER(m_widget
), m_menubar
);
130 gtk_widget_show(m_menubar
);
134 m_widget
= m_menubar
;
140 #endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON
142 for (size_t i
= 0; i
< n
; ++i
)
143 Append(menus
[i
], titles
[i
]);
145 // VZ: for some reason connecting to menus "deactivate" doesn't work (we
146 // don't get it when the menu is dismissed by clicking outside the
147 // toolbar) so we connect to the global one, even if it means that we
148 // can't pass the menu which was closed in wxMenuEvent object
149 g_signal_connect (m_menubar
, "deactivate",
150 G_CALLBACK (gtk_menu_close_callback
), this);
153 wxMenuBar::wxMenuBar(size_t n
, wxMenu
*menus
[], const wxString titles
[], long style
)
155 Init(n
, menus
, titles
, style
);
158 wxMenuBar::wxMenuBar(long style
)
160 Init(0, NULL
, NULL
, style
);
163 wxMenuBar::wxMenuBar()
165 Init(0, NULL
, NULL
, 0);
168 wxMenuBar::~wxMenuBar()
172 static void wxMenubarUnsetInvokingWindow( wxMenu
*menu
, wxWindow
*win
)
174 menu
->SetInvokingWindow( (wxWindow
*) NULL
);
176 wxWindow
*top_frame
= win
;
177 while (top_frame
->GetParent() && !(top_frame
->IsTopLevel()))
178 top_frame
= top_frame
->GetParent();
180 // support for native hot keys
181 ACCEL_OBJECT
*obj
= ACCEL_OBJ_CAST(top_frame
->m_widget
);
182 if ( menu
->m_accel
&& g_slist_find( ACCEL_OBJECTS(menu
->m_accel
), obj
) )
183 gtk_accel_group_detach( menu
->m_accel
, obj
);
185 wxMenuItemList::compatibility_iterator node
= menu
->GetMenuItems().GetFirst();
188 wxMenuItem
*menuitem
= node
->GetData();
189 if (menuitem
->IsSubMenu())
190 wxMenubarUnsetInvokingWindow( menuitem
->GetSubMenu(), win
);
191 node
= node
->GetNext();
195 static void wxMenubarSetInvokingWindow( wxMenu
*menu
, wxWindow
*win
)
197 menu
->SetInvokingWindow( win
);
199 wxWindow
*top_frame
= win
;
200 while (top_frame
->GetParent() && !(top_frame
->IsTopLevel()))
201 top_frame
= top_frame
->GetParent();
203 // support for native hot keys
204 ACCEL_OBJECT
*obj
= ACCEL_OBJ_CAST(top_frame
->m_widget
);
205 if ( !g_slist_find( ACCEL_OBJECTS(menu
->m_accel
), obj
) )
206 gtk_accel_group_attach( menu
->m_accel
, obj
);
208 wxMenuItemList::compatibility_iterator node
= menu
->GetMenuItems().GetFirst();
211 wxMenuItem
*menuitem
= node
->GetData();
212 if (menuitem
->IsSubMenu())
213 wxMenubarSetInvokingWindow( menuitem
->GetSubMenu(), win
);
214 node
= node
->GetNext();
218 void wxMenuBar::SetInvokingWindow( wxWindow
*win
)
220 m_invokingWindow
= win
;
221 wxWindow
*top_frame
= win
;
222 while (top_frame
->GetParent() && !(top_frame
->IsTopLevel()))
223 top_frame
= top_frame
->GetParent();
225 wxMenuList::compatibility_iterator node
= m_menus
.GetFirst();
228 wxMenu
*menu
= node
->GetData();
229 wxMenubarSetInvokingWindow( menu
, win
);
230 node
= node
->GetNext();
234 void wxMenuBar::SetLayoutDirection(wxLayoutDirection dir
)
236 if ( dir
== wxLayout_Default
)
238 const wxWindow
*const frame
= GetFrame();
241 // inherit layout from frame.
242 dir
= frame
->GetLayoutDirection();
244 else // use global layout
246 dir
= wxTheApp
->GetLayoutDirection();
250 if ( dir
== wxLayout_Default
)
253 GTKSetLayout(m_menubar
, dir
);
255 // also set the layout of all menus we already have (new ones will inherit
256 // the current layout)
257 for ( wxMenuList::compatibility_iterator node
= m_menus
.GetFirst();
259 node
= node
->GetNext() )
261 wxMenu
*const menu
= node
->GetData();
262 menu
->SetLayoutDirection(dir
);
266 wxLayoutDirection
wxMenuBar::GetLayoutDirection() const
268 return GTKGetLayout(m_menubar
);
271 void wxMenuBar::Attach(wxFrame
*frame
)
273 wxMenuBarBase::Attach(frame
);
275 SetLayoutDirection(wxLayout_Default
);
278 void wxMenuBar::UnsetInvokingWindow( wxWindow
*win
)
280 m_invokingWindow
= (wxWindow
*) NULL
;
281 wxWindow
*top_frame
= win
;
282 while (top_frame
->GetParent() && !(top_frame
->IsTopLevel()))
283 top_frame
= top_frame
->GetParent();
285 wxMenuList::compatibility_iterator node
= m_menus
.GetFirst();
288 wxMenu
*menu
= node
->GetData();
289 wxMenubarUnsetInvokingWindow( menu
, win
);
290 node
= node
->GetNext();
294 bool wxMenuBar::Append( wxMenu
*menu
, const wxString
&title
)
296 if ( !wxMenuBarBase::Append( menu
, title
) )
299 return GtkAppend(menu
, title
);
302 bool wxMenuBar::GtkAppend(wxMenu
*menu
, const wxString
& title
, int pos
)
304 menu
->SetLayoutDirection(GetLayoutDirection());
307 // if the menu has only one item, append it directly to the top level menu
308 // instead of inserting a useless submenu
309 if ( menu
->GetMenuItemCount() == 1 )
311 wxMenuItem
* const item
= menu
->FindItemByPosition(0);
313 // remove both mnemonics and accelerator: neither is useful under Maemo
314 const wxString
str(wxStripMenuCodes(item
->GetItemLabel()));
316 if ( item
->IsSubMenu() )
317 return GtkAppend(item
->GetSubMenu(), str
, pos
);
319 menu
->m_owner
= gtk_menu_item_new_with_mnemonic( wxGTK_CONV( str
) );
321 g_signal_connect(menu
->m_owner
, "activate",
322 G_CALLBACK(gtk_menu_clicked_callback
), menu
);
323 item
->SetMenuItem(menu
->m_owner
);
326 #endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON
328 const wxString
str(wxConvertMnemonicsToGTK(title
));
330 // This doesn't have much effect right now.
331 menu
->SetTitle( str
);
333 // The "m_owner" is the "menu item"
334 menu
->m_owner
= gtk_menu_item_new_with_mnemonic( wxGTK_CONV( str
) );
336 gtk_menu_item_set_submenu( GTK_MENU_ITEM(menu
->m_owner
), menu
->m_menu
);
339 gtk_widget_show( menu
->m_owner
);
342 gtk_menu_shell_append( GTK_MENU_SHELL(m_menubar
), menu
->m_owner
);
344 gtk_menu_shell_insert( GTK_MENU_SHELL(m_menubar
), menu
->m_owner
, pos
);
346 g_signal_connect (menu
->m_owner
, "activate",
347 G_CALLBACK (gtk_menu_open_callback
),
350 // m_invokingWindow is set after wxFrame::SetMenuBar(). This call enables
351 // addings menu later on.
352 if (m_invokingWindow
)
353 wxMenubarSetInvokingWindow( menu
, m_invokingWindow
);
358 bool wxMenuBar::Insert(size_t pos
, wxMenu
*menu
, const wxString
& title
)
360 if ( !wxMenuBarBase::Insert(pos
, menu
, title
) )
365 if ( !GtkAppend(menu
, title
, (int)pos
) )
371 wxMenu
*wxMenuBar::Replace(size_t pos
, wxMenu
*menu
, const wxString
& title
)
373 // remove the old item and insert a new one
374 wxMenu
*menuOld
= Remove(pos
);
375 if ( menuOld
&& !Insert(pos
, menu
, title
) )
377 return (wxMenu
*) NULL
;
380 // either Insert() succeeded or Remove() failed and menuOld is NULL
384 wxMenu
*wxMenuBar::Remove(size_t pos
)
386 wxMenu
*menu
= wxMenuBarBase::Remove(pos
);
388 return (wxMenu
*) NULL
;
390 gtk_menu_item_remove_submenu( GTK_MENU_ITEM(menu
->m_owner
) );
391 gtk_container_remove(GTK_CONTAINER(m_menubar
), menu
->m_owner
);
393 gtk_widget_destroy( menu
->m_owner
);
394 menu
->m_owner
= NULL
;
396 if (m_invokingWindow
)
397 wxMenubarUnsetInvokingWindow( menu
, m_invokingWindow
);
402 static int FindMenuItemRecursive( const wxMenu
*menu
, const wxString
&menuString
, const wxString
&itemString
)
404 if (wxMenuItem::GetLabelText(wxConvertMnemonicsFromGTK(menu
->GetTitle())) == wxMenuItem::GetLabelText(menuString
))
406 int res
= menu
->FindItem( itemString
);
407 if (res
!= wxNOT_FOUND
)
411 wxMenuItemList::compatibility_iterator node
= menu
->GetMenuItems().GetFirst();
414 wxMenuItem
*item
= node
->GetData();
415 if (item
->IsSubMenu())
416 return FindMenuItemRecursive(item
->GetSubMenu(), menuString
, itemString
);
418 node
= node
->GetNext();
424 int wxMenuBar::FindMenuItem( const wxString
&menuString
, const wxString
&itemString
) const
426 wxMenuList::compatibility_iterator node
= m_menus
.GetFirst();
429 wxMenu
*menu
= node
->GetData();
430 int res
= FindMenuItemRecursive( menu
, menuString
, itemString
);
433 node
= node
->GetNext();
439 // Find a wxMenuItem using its id. Recurses down into sub-menus
440 static wxMenuItem
* FindMenuItemByIdRecursive(const wxMenu
* menu
, int id
)
442 wxMenuItem
* result
= menu
->FindChildItem(id
);
444 wxMenuItemList::compatibility_iterator node
= menu
->GetMenuItems().GetFirst();
445 while ( node
&& result
== NULL
)
447 wxMenuItem
*item
= node
->GetData();
448 if (item
->IsSubMenu())
450 result
= FindMenuItemByIdRecursive( item
->GetSubMenu(), id
);
452 node
= node
->GetNext();
458 wxMenuItem
* wxMenuBar::FindItem( int id
, wxMenu
**menuForItem
) const
460 wxMenuItem
* result
= 0;
461 wxMenuList::compatibility_iterator node
= m_menus
.GetFirst();
462 while (node
&& result
== 0)
464 wxMenu
*menu
= node
->GetData();
465 result
= FindMenuItemByIdRecursive( menu
, id
);
466 node
= node
->GetNext();
471 *menuForItem
= result
? result
->GetMenu() : (wxMenu
*)NULL
;
477 void wxMenuBar::EnableTop( size_t pos
, bool flag
)
479 wxMenuList::compatibility_iterator node
= m_menus
.Item( pos
);
481 wxCHECK_RET( node
, wxT("menu not found") );
483 wxMenu
* menu
= node
->GetData();
486 gtk_widget_set_sensitive( menu
->m_owner
, flag
);
489 wxString
wxMenuBar::GetMenuLabel( size_t pos
) const
491 wxMenuList::compatibility_iterator node
= m_menus
.Item( pos
);
493 wxCHECK_MSG( node
, wxT("invalid"), wxT("menu not found") );
495 wxMenu
* menu
= node
->GetData();
497 return wxConvertMnemonicsFromGTK(menu
->GetTitle());
500 void wxMenuBar::SetMenuLabel( size_t pos
, const wxString
& label
)
502 wxMenuList::compatibility_iterator node
= m_menus
.Item( pos
);
504 wxCHECK_RET( node
, wxT("menu not found") );
506 wxMenu
* menu
= node
->GetData();
508 const wxString
str(wxConvertMnemonicsToGTK(label
));
510 menu
->SetTitle( str
);
513 gtk_label_set_text_with_mnemonic( GTK_LABEL( GTK_BIN(menu
->m_owner
)->child
), wxGTK_CONV(str
) );
516 //-----------------------------------------------------------------------------
518 //-----------------------------------------------------------------------------
521 static void gtk_menu_clicked_callback( GtkWidget
*widget
, wxMenu
*menu
)
523 int id
= menu
->FindMenuIdByMenuItem(widget
);
525 /* should find it for normal (not popup) menu */
526 wxASSERT_MSG( (id
!= -1) || (menu
->GetInvokingWindow() != NULL
),
527 _T("menu item not found in gtk_menu_clicked_callback") );
529 if (!menu
->IsEnabled(id
))
532 wxMenuItem
* item
= menu
->FindChildItem( id
);
533 wxCHECK_RET( item
, wxT("error in menu item callback") );
535 if ( item
->GetId() == wxGTK_TITLE_ID
)
537 // ignore events from the menu title
541 if (item
->IsCheckable())
543 bool isReallyChecked
= item
->IsChecked(),
544 isInternallyChecked
= item
->wxMenuItemBase::IsChecked();
546 // ensure that the internal state is always consistent with what is
547 // shown on the screen
548 item
->wxMenuItemBase::Check(isReallyChecked
);
550 // we must not report the events for the radio button going up nor the
551 // events resulting from the calls to wxMenuItem::Check()
552 if ( (item
->GetKind() == wxITEM_RADIO
&& !isReallyChecked
) ||
553 (isInternallyChecked
== isReallyChecked
) )
560 // Is this menu on a menubar? (possibly nested)
561 wxFrame
* frame
= NULL
;
562 if(menu
->IsAttached())
563 frame
= menu
->GetMenuBar()->GetFrame();
565 // FIXME: why do we have to call wxFrame::GetEventHandler() directly here?
566 // normally wxMenu::SendEvent() should be enough, if it doesn't work
567 // in wxGTK then we have a bug in wxMenu::GetInvokingWindow() which
568 // should be fixed instead of working around it here...
571 // If it is attached then let the frame send the event.
572 // Don't call frame->ProcessCommand(id) because it toggles
573 // checkable items and we've already done that above.
574 wxCommandEvent
commandEvent(wxEVT_COMMAND_MENU_SELECTED
, id
);
575 commandEvent
.SetEventObject(frame
);
576 if (item
->IsCheckable())
577 commandEvent
.SetInt(item
->IsChecked());
579 frame
->GetEventHandler()->ProcessEvent(commandEvent
);
583 // otherwise let the menu have it
584 menu
->SendEvent(id
, item
->IsCheckable() ? item
->IsChecked() : -1);
589 //-----------------------------------------------------------------------------
591 //-----------------------------------------------------------------------------
594 static void gtk_menu_hilight_callback( GtkWidget
*widget
, wxMenu
*menu
)
596 int id
= menu
->FindMenuIdByMenuItem(widget
);
598 wxASSERT( id
!= -1 ); // should find it!
600 if (!menu
->IsEnabled(id
))
603 wxMenuEvent
event( wxEVT_MENU_HIGHLIGHT
, id
);
604 event
.SetEventObject( menu
);
606 wxEvtHandler
* handler
= menu
->GetEventHandler();
607 if (handler
&& handler
->ProcessEvent(event
))
610 wxWindow
*win
= menu
->GetInvokingWindow();
611 if (win
) win
->GetEventHandler()->ProcessEvent( event
);
615 //-----------------------------------------------------------------------------
617 //-----------------------------------------------------------------------------
620 static void gtk_menu_nolight_callback( GtkWidget
*widget
, wxMenu
*menu
)
622 int id
= menu
->FindMenuIdByMenuItem(widget
);
624 wxASSERT( id
!= -1 ); // should find it!
626 if (!menu
->IsEnabled(id
))
629 wxMenuEvent
event( wxEVT_MENU_HIGHLIGHT
, -1 );
630 event
.SetEventObject( menu
);
632 wxEvtHandler
* handler
= menu
->GetEventHandler();
633 if (handler
&& handler
->ProcessEvent(event
))
636 wxWindow
*win
= menu
->GetInvokingWindow();
638 win
->GetEventHandler()->ProcessEvent( event
);
642 //-----------------------------------------------------------------------------
644 //-----------------------------------------------------------------------------
646 IMPLEMENT_DYNAMIC_CLASS(wxMenuItem
, wxObject
)
648 wxMenuItem
*wxMenuItemBase::New(wxMenu
*parentMenu
,
650 const wxString
& name
,
651 const wxString
& help
,
655 return new wxMenuItem(parentMenu
, id
, name
, help
, kind
, subMenu
);
658 wxMenuItem::wxMenuItem(wxMenu
*parentMenu
,
660 const wxString
& text
,
661 const wxString
& help
,
664 : wxMenuItemBase(parentMenu
, id
, text
, help
, kind
, subMenu
)
669 wxMenuItem::wxMenuItem(wxMenu
*parentMenu
,
671 const wxString
& text
,
672 const wxString
& help
,
675 : wxMenuItemBase(parentMenu
, id
, text
, help
,
676 isCheckable
? wxITEM_CHECK
: wxITEM_NORMAL
, subMenu
)
681 void wxMenuItem::Init(const wxString
& text
)
683 m_labelWidget
= (GtkWidget
*) NULL
;
684 m_menuItem
= (GtkWidget
*) NULL
;
689 wxMenuItem::~wxMenuItem()
691 // don't delete menu items, the menus take care of that
694 // return the menu item text without any menu accels
697 wxString
wxMenuItemBase::GetLabelText(const wxString
& text
)
699 // The argument to this function will now always be in wxWidgets standard label
700 // format, not GTK+ format, so we do what the other ports do.
702 return wxStripMenuCodes(text
);
707 for ( const wxChar
*pc
= text
.c_str(); *pc
; pc
++ )
709 if ( *pc
== wxT('\t'))
712 if ( *pc
== wxT('_') )
714 // GTK 1.2 escapes "xxx_xxx" to "xxx__xxx"
720 if ( *pc
== wxT('\\') )
722 // GTK 2.0 escapes "xxx/xxx" to "xxx\/xxx"
728 if ( (*pc
== wxT('&')) && (*(pc
+1) != wxT('&')) )
731 // "&" is doubled to indicate "&" instead of accelerator
738 // wxPrintf( wxT("GetLabelText(): text %s label %s\n"), text.c_str(), label.c_str() );
744 wxString
wxMenuItem::GetItemLabel() const
746 wxString label
= wxConvertMnemonicsFromGTK(m_text
);
747 if (!m_hotKey
.IsEmpty())
748 label
<< "\t" << m_hotKey
;
752 void wxMenuItem::SetItemLabel( const wxString
& str
)
754 // cache some data which must be used later
755 bool isstock
= wxIsStockID(GetId());
756 const char *stockid
= NULL
;
758 stockid
= wxGetStockGtkID(GetId());
760 // Some optimization to avoid flicker
761 wxString oldLabel
= m_text
;
762 oldLabel
= wxStripMenuCodes(oldLabel
);
763 oldLabel
.Replace(wxT("_"), wxT(""));
764 wxString label1
= wxStripMenuCodes(str
);
766 wxString oldhotkey
= GetHotKey(); // Store the old hotkey in Ctrl-foo format
767 wxCharBuffer oldbuf
= wxGTK_CONV_SYS( GetGtkHotKey(*this) ); // and as <control>foo
768 #endif // wxUSE_ACCEL
773 if (oldLabel
== label1
&&
774 oldhotkey
== GetHotKey()) // Make sure we can change a hotkey even if the label is unaltered
781 label
= (GtkLabel
*) m_labelWidget
;
783 label
= GTK_LABEL( GTK_BIN(m_menuItem
)->child
);
785 // stock menu items can have empty labels:
786 wxString text
= m_text
;
787 if (text
.IsEmpty() && !IsSeparator())
789 wxASSERT_MSG(isstock
, wxT("A non-stock menu item with an empty label?"));
790 text
= wxGetStockLabel(GetId());
792 // need & => _ conversion
793 text
= GTKProcessMenuItemLabel(text
, NULL
);
796 gtk_label_set_text_with_mnemonic( GTK_LABEL(label
), wxGTK_CONV_SYS(text
) );
799 // remove old accelerator from our parent's accelerator group, if present
801 GdkModifierType accel_mods
;
802 if (oldbuf
[(size_t)0] != '\0')
804 gtk_accelerator_parse( (const char*) oldbuf
, &accel_key
, &accel_mods
);
807 gtk_widget_remove_accelerator(m_menuItem
,
808 m_parentMenu
->m_accel
,
815 // if the accelerator was taken from a stock ID, just get it back from GTK+ stock
816 if (wxGetStockGtkAccelerator(stockid
, &accel_mods
, &accel_key
))
817 gtk_widget_remove_accelerator( m_menuItem
,
818 m_parentMenu
->m_accel
,
823 // add new accelerator to our parent's accelerator group
824 wxCharBuffer buf
= wxGTK_CONV_SYS( GetGtkHotKey(*this) );
825 if (buf
[(size_t)0] != '\0')
827 gtk_accelerator_parse( (const char*) buf
, &accel_key
, &accel_mods
);
830 gtk_widget_add_accelerator( m_menuItem
,
832 m_parentMenu
->m_accel
,
840 // if the accelerator was taken from a stock ID, just get it back from GTK+ stock
841 if (wxGetStockGtkAccelerator(stockid
, &accel_mods
, &accel_key
))
842 gtk_widget_remove_accelerator( m_menuItem
,
843 m_parentMenu
->m_accel
,
847 #endif // wxUSE_FILECTRL
850 // NOTE: this function is different from the similar functions GTKProcessMnemonics()
851 // implemented in control.cpp and from wxMenuItemBase::GetLabelText...
852 // so there's no real code duplication
853 wxString
wxMenuItem::GTKProcessMenuItemLabel(const wxString
& str
, wxString
*hotKey
)
857 // '\t' is the deliminator indicating a hot key
858 wxString::const_iterator pc
= str
.begin();
859 while ( pc
!= str
.end() && *pc
!= wxT('\t') )
863 wxString::const_iterator next
= pc
+ 1;
864 if (next
!= str
.end() && *next
== wxT('&'))
866 // "&" is doubled to indicate "&" instead of accelerator
875 else if ( *pc
== wxT('_') ) // escape underscores
892 hotKey
->assign(pc
, str
.end());
899 // it's valid for this function to be called even if m_menuItem == NULL
900 void wxMenuItem::DoSetText( const wxString
& str
)
903 m_text
= GTKProcessMenuItemLabel(str
, &m_hotKey
);
908 wxAcceleratorEntry
*wxMenuItem::GetAccel() const
916 // accelerator parsing code looks for them after a TAB, so insert a dummy
919 label
<< wxT('\t') << GetHotKey();
921 return wxAcceleratorEntry::Create(label
);
924 #endif // wxUSE_ACCEL
926 void wxMenuItem::Check( bool check
)
928 wxCHECK_RET( m_menuItem
, wxT("invalid menu item") );
930 if (check
== m_isChecked
)
933 wxMenuItemBase::Check( check
);
939 gtk_check_menu_item_set_active( (GtkCheckMenuItem
*)m_menuItem
, (gint
)check
);
943 wxFAIL_MSG( _T("can't check this item") );
947 void wxMenuItem::Enable( bool enable
)
949 wxCHECK_RET( m_menuItem
, wxT("invalid menu item") );
951 gtk_widget_set_sensitive( m_menuItem
, enable
);
952 wxMenuItemBase::Enable( enable
);
955 bool wxMenuItem::IsChecked() const
957 wxCHECK_MSG( m_menuItem
, false, wxT("invalid menu item") );
959 wxCHECK_MSG( IsCheckable(), false,
960 wxT("can't get state of uncheckable item!") );
962 return ((GtkCheckMenuItem
*)m_menuItem
)->active
!= 0;
965 //-----------------------------------------------------------------------------
967 //-----------------------------------------------------------------------------
969 IMPLEMENT_DYNAMIC_CLASS(wxMenu
,wxEvtHandler
)
973 m_accel
= gtk_accel_group_new();
974 m_menu
= gtk_menu_new();
975 // NB: keep reference to the menu so that it is not destroyed behind
976 // our back by GTK+ e.g. when it is removed from menubar:
977 gtk_widget_ref(m_menu
);
979 m_owner
= (GtkWidget
*) NULL
;
981 // Tearoffs are entries, just like separators. So if we want this
982 // menu to be a tear-off one, we just append a tearoff entry
984 if ( m_style
& wxMENU_TEAROFF
)
986 GtkWidget
*tearoff
= gtk_tearoff_menu_item_new();
988 gtk_menu_shell_append(GTK_MENU_SHELL(m_menu
), tearoff
);
993 // append the title as the very first entry if we have it
994 if ( !m_title
.empty() )
996 Append(wxGTK_TITLE_ID
, m_title
);
1003 if ( GTK_IS_WIDGET( m_menu
))
1006 gtk_widget_unref( m_menu
);
1007 g_object_unref( m_accel
);
1009 // if the menu is inserted in another menu at this time, there was
1010 // one more reference to it:
1012 gtk_widget_destroy( m_menu
);
1015 // This must come after we release GTK resources above. Otherwise, GTK will
1016 // give warnings/errors when attempting to free accelerator resources from
1017 // child items that just were destroyed (the m_menu widget can contain
1018 // references to accelerators in child items. Problem detected when removing
1019 // a menu from a wxMenuBar, and the removed menu had submenus with accelerators.)
1020 WX_CLEAR_LIST(wxMenuItemList
, m_items
);
1023 void wxMenu::SetLayoutDirection(const wxLayoutDirection dir
)
1026 wxWindow::GTKSetLayout(m_owner
, dir
);
1027 //else: will be called later by wxMenuBar again
1030 wxLayoutDirection
wxMenu::GetLayoutDirection() const
1032 return wxWindow::GTKGetLayout(m_owner
);
1035 bool wxMenu::GtkAppend(wxMenuItem
*mitem
, int pos
)
1037 GtkWidget
*menuItem
;
1039 // cache some data used later
1040 wxString text
= mitem
->wxMenuItemBase::GetItemLabel();
1041 int id
= mitem
->GetId();
1042 bool isstock
= wxIsStockID(id
);
1043 const char *stockid
= NULL
;
1045 stockid
= wxGetStockGtkID(mitem
->GetId());
1047 // stock menu items can have an empty label
1048 if (text
.IsEmpty() && !mitem
->IsSeparator())
1050 wxASSERT_MSG(isstock
, wxT("A non-stock menu item with an empty label?"));
1051 text
= wxGetStockLabel(id
);
1053 // need & => _ conversion
1054 text
= wxMenuItem::GTKProcessMenuItemLabel(text
, NULL
);
1057 if ( mitem
->IsSeparator() )
1059 menuItem
= gtk_separator_menu_item_new();
1061 else if ( mitem
->GetBitmap().Ok() ||
1062 (mitem
->GetKind() == wxITEM_NORMAL
&& isstock
) )
1064 wxBitmap
bitmap(mitem
->GetBitmap());
1066 menuItem
= gtk_image_menu_item_new_with_mnemonic( wxGTK_CONV_SYS( text
) );
1071 // use stock bitmap for this item if available on the assumption
1072 // that it never hurts to follow GTK+ conventions more closely
1073 image
= stockid
? gtk_image_new_from_stock(stockid
, GTK_ICON_SIZE_MENU
)
1076 else // we have a custom bitmap
1078 wxASSERT_MSG( mitem
->GetKind() == wxITEM_NORMAL
,
1079 _T("only normal menu items can have bitmaps") );
1081 if ( bitmap
.HasPixbuf() )
1083 image
= gtk_image_new_from_pixbuf(bitmap
.GetPixbuf());
1087 GdkPixmap
*gdk_pixmap
= bitmap
.GetPixmap();
1088 GdkBitmap
*gdk_bitmap
= bitmap
.GetMask() ?
1089 bitmap
.GetMask()->GetBitmap() :
1091 image
= gtk_image_new_from_pixmap( gdk_pixmap
, gdk_bitmap
);
1097 gtk_widget_show(image
);
1099 gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(menuItem
), image
);
1104 else // a normal item
1106 // NB: 'text' variable has "_" instead of "&" after mitem->SetItemLabel()
1109 switch ( mitem
->GetKind() )
1113 menuItem
= gtk_check_menu_item_new_with_mnemonic( wxGTK_CONV_SYS( text
) );
1120 GSList
*group
= NULL
;
1121 if ( m_prevRadio
== NULL
)
1123 // start of a new radio group
1124 m_prevRadio
= menuItem
=
1125 gtk_radio_menu_item_new_with_mnemonic( group
, wxGTK_CONV_SYS( text
) );
1127 else // continue the radio group
1129 group
= gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (m_prevRadio
));
1130 m_prevRadio
= menuItem
=
1131 gtk_radio_menu_item_new_with_mnemonic( group
, wxGTK_CONV_SYS( text
) );
1137 wxFAIL_MSG( _T("unexpected menu item kind") );
1142 menuItem
= gtk_menu_item_new_with_mnemonic( wxGTK_CONV_SYS( text
) );
1152 GdkModifierType accel_mods
;
1153 wxCharBuffer buf
= wxGTK_CONV_SYS( GetGtkHotKey(*mitem
) );
1155 if (buf
[(size_t)0] != '\0')
1157 gtk_accelerator_parse( (const char*) buf
, &accel_key
, &accel_mods
);
1160 gtk_widget_add_accelerator (menuItem
,
1170 // if the accelerator was taken from a stock ID, just get it back from GTK+ stock
1171 if (wxGetStockGtkAccelerator(stockid
, &accel_mods
, &accel_key
))
1172 gtk_widget_add_accelerator( menuItem
,
1179 #endif // wxUSE_FILECTRL
1182 gtk_menu_shell_append(GTK_MENU_SHELL(m_menu
), menuItem
);
1184 gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu
), menuItem
, pos
);
1186 gtk_widget_show( menuItem
);
1188 if ( !mitem
->IsSeparator() )
1190 wxASSERT_MSG( menuItem
, wxT("invalid menuitem") );
1192 g_signal_connect (menuItem
, "select",
1193 G_CALLBACK (gtk_menu_hilight_callback
), this);
1194 g_signal_connect (menuItem
, "deselect",
1195 G_CALLBACK (gtk_menu_nolight_callback
), this);
1197 if ( mitem
->IsSubMenu() && mitem
->GetKind() != wxITEM_RADIO
&& mitem
->GetKind() != wxITEM_CHECK
)
1199 gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem
), mitem
->GetSubMenu()->m_menu
);
1201 gtk_widget_show( mitem
->GetSubMenu()->m_menu
);
1203 // if adding a submenu to a menu already existing in the menu bar, we
1204 // must set invoking window to allow processing events from this
1206 if ( m_invokingWindow
)
1207 wxMenubarSetInvokingWindow(mitem
->GetSubMenu(), m_invokingWindow
);
1211 g_signal_connect (menuItem
, "activate",
1212 G_CALLBACK (gtk_menu_clicked_callback
),
1217 mitem
->SetMenuItem(menuItem
);
1221 // This doesn't even exist!
1222 // gtk_widget_lock_accelerators(mitem->GetMenuItem());
1228 wxMenuItem
* wxMenu::DoAppend(wxMenuItem
*mitem
)
1230 if (!GtkAppend(mitem
))
1233 return wxMenuBase::DoAppend(mitem
);
1236 wxMenuItem
* wxMenu::DoInsert(size_t pos
, wxMenuItem
*item
)
1238 if ( !wxMenuBase::DoInsert(pos
, item
) )
1242 if ( !GtkAppend(item
, (int)pos
) )
1248 wxMenuItem
*wxMenu::DoRemove(wxMenuItem
*item
)
1250 if ( !wxMenuBase::DoRemove(item
) )
1251 return (wxMenuItem
*)NULL
;
1253 // TODO: this code doesn't delete the item factory item and this seems
1254 // impossible as of GTK 1.2.6.
1255 gtk_widget_destroy( item
->GetMenuItem() );
1260 int wxMenu::FindMenuIdByMenuItem( GtkWidget
*menuItem
) const
1262 wxMenuItemList::compatibility_iterator node
= m_items
.GetFirst();
1265 wxMenuItem
*item
= node
->GetData();
1266 if (item
->GetMenuItem() == menuItem
)
1267 return item
->GetId();
1268 node
= node
->GetNext();
1274 void wxMenu::Attach(wxMenuBarBase
*menubar
)
1276 wxMenuBase::Attach(menubar
);
1278 // inherit layout direction from menubar.
1279 SetLayoutDirection(menubar
->GetLayoutDirection());
1282 // ----------------------------------------------------------------------------
1284 // ----------------------------------------------------------------------------
1288 static wxString
GetGtkHotKey( const wxMenuItem
& item
)
1292 wxAcceleratorEntry
*accel
= item
.GetAccel();
1295 int flags
= accel
->GetFlags();
1296 if ( flags
& wxACCEL_ALT
)
1297 hotkey
+= wxT("<alt>");
1298 if ( flags
& wxACCEL_CTRL
)
1299 hotkey
+= wxT("<control>");
1300 if ( flags
& wxACCEL_SHIFT
)
1301 hotkey
+= wxT("<shift>");
1303 int code
= accel
->GetKeyCode();
1330 hotkey
+= wxString::Format(wxT("F%d"), code
- WXK_F1
+ 1);
1333 // TODO: we should use gdk_keyval_name() (a.k.a.
1334 // XKeysymToString) here as well as hardcoding the keysym
1335 // names this might be not portable
1337 hotkey
<< wxT("Insert" );
1340 hotkey
<< wxT("Delete" );
1343 hotkey
<< wxT("Up" );
1346 hotkey
<< wxT("Down" );
1349 hotkey
<< wxT("Page_Up" );
1352 hotkey
<< wxT("Page_Down" );
1355 hotkey
<< wxT("Left" );
1358 hotkey
<< wxT("Right" );
1361 hotkey
<< wxT("Home" );
1364 hotkey
<< wxT("End" );
1367 hotkey
<< wxT("Return" );
1370 hotkey
<< wxT("BackSpace" );
1373 hotkey
<< wxT("Tab" );
1376 hotkey
<< wxT("Esc" );
1379 hotkey
<< wxT("space" );
1382 hotkey
<< wxT("Multiply" );
1385 hotkey
<< wxT("Add" );
1388 hotkey
<< wxT("Separator" );
1391 hotkey
<< wxT("Subtract" );
1394 hotkey
<< wxT("Decimal" );
1397 hotkey
<< wxT("Divide" );
1400 hotkey
<< wxT("Cancel" );
1403 hotkey
<< wxT("Clear" );
1406 hotkey
<< wxT("Menu" );
1409 hotkey
<< wxT("Pause" );
1412 hotkey
<< wxT("Capital" );
1415 hotkey
<< wxT("Select" );
1418 hotkey
<< wxT("Print" );
1421 hotkey
<< wxT("Execute" );
1424 hotkey
<< wxT("Snapshot" );
1427 hotkey
<< wxT("Help" );
1430 hotkey
<< wxT("Num_Lock" );
1433 hotkey
<< wxT("Scroll_Lock" );
1435 case WXK_NUMPAD_INSERT
:
1436 hotkey
<< wxT("KP_Insert" );
1438 case WXK_NUMPAD_DELETE
:
1439 hotkey
<< wxT("KP_Delete" );
1441 case WXK_NUMPAD_SPACE
:
1442 hotkey
<< wxT("KP_Space" );
1444 case WXK_NUMPAD_TAB
:
1445 hotkey
<< wxT("KP_Tab" );
1447 case WXK_NUMPAD_ENTER
:
1448 hotkey
<< wxT("KP_Enter" );
1450 case WXK_NUMPAD_F1
: case WXK_NUMPAD_F2
: case WXK_NUMPAD_F3
:
1452 hotkey
+= wxString::Format(wxT("KP_F%d"), code
- WXK_NUMPAD_F1
+ 1);
1454 case WXK_NUMPAD_HOME
:
1455 hotkey
<< wxT("KP_Home" );
1457 case WXK_NUMPAD_LEFT
:
1458 hotkey
<< wxT("KP_Left" );
1461 hotkey
<< wxT("KP_Up" );
1463 case WXK_NUMPAD_RIGHT
:
1464 hotkey
<< wxT("KP_Right" );
1466 case WXK_NUMPAD_DOWN
:
1467 hotkey
<< wxT("KP_Down" );
1469 case WXK_NUMPAD_PAGEUP
:
1470 hotkey
<< wxT("KP_Page_Up" );
1472 case WXK_NUMPAD_PAGEDOWN
:
1473 hotkey
<< wxT("KP_Page_Down" );
1475 case WXK_NUMPAD_END
:
1476 hotkey
<< wxT("KP_End" );
1478 case WXK_NUMPAD_BEGIN
:
1479 hotkey
<< wxT("KP_Begin" );
1481 case WXK_NUMPAD_EQUAL
:
1482 hotkey
<< wxT("KP_Equal" );
1484 case WXK_NUMPAD_MULTIPLY
:
1485 hotkey
<< wxT("KP_Multiply" );
1487 case WXK_NUMPAD_ADD
:
1488 hotkey
<< wxT("KP_Add" );
1490 case WXK_NUMPAD_SEPARATOR
:
1491 hotkey
<< wxT("KP_Separator" );
1493 case WXK_NUMPAD_SUBTRACT
:
1494 hotkey
<< wxT("KP_Subtract" );
1496 case WXK_NUMPAD_DECIMAL
:
1497 hotkey
<< wxT("KP_Decimal" );
1499 case WXK_NUMPAD_DIVIDE
:
1500 hotkey
<< wxT("KP_Divide" );
1502 case WXK_NUMPAD0
: case WXK_NUMPAD1
: case WXK_NUMPAD2
:
1503 case WXK_NUMPAD3
: case WXK_NUMPAD4
: case WXK_NUMPAD5
:
1504 case WXK_NUMPAD6
: case WXK_NUMPAD7
: case WXK_NUMPAD8
: case WXK_NUMPAD9
:
1505 hotkey
+= wxString::Format(wxT("KP_%d"), code
- WXK_NUMPAD0
);
1507 case WXK_WINDOWS_LEFT
:
1508 hotkey
<< wxT("Super_L" );
1510 case WXK_WINDOWS_RIGHT
:
1511 hotkey
<< wxT("Super_R" );
1513 case WXK_WINDOWS_MENU
:
1514 hotkey
<< wxT("Menu" );
1517 hotkey
<< wxT("Command" );
1519 /* These probably wouldn't work as there is no SpecialX in gdk/keynames.txt
1520 case WXK_SPECIAL1: case WXK_SPECIAL2: case WXK_SPECIAL3: case WXK_SPECIAL4:
1521 case WXK_SPECIAL5: case WXK_SPECIAL6: case WXK_SPECIAL7: case WXK_SPECIAL8:
1522 case WXK_SPECIAL9: case WXK_SPECIAL10: case WXK_SPECIAL11: case WXK_SPECIAL12:
1523 case WXK_SPECIAL13: case WXK_SPECIAL14: case WXK_SPECIAL15: case WXK_SPECIAL16:
1524 case WXK_SPECIAL17: case WXK_SPECIAL18: case WXK_SPECIAL19: case WXK_SPECIAL20:
1525 hotkey += wxString::Format(wxT("Special%d"), code - WXK_SPECIAL1 + 1);
1528 // if there are any other keys wxAcceleratorEntry::Create() may
1529 // return, we should process them here
1535 name
= wxGTK_CONV_BACK_SYS(gdk_keyval_name((guint
)code
));
1536 if ( !name
.empty() )
1543 wxFAIL_MSG( wxT("unknown keyboard accel") );
1552 #endif // wxUSE_ACCEL
1554 // ----------------------------------------------------------------------------
1555 // Pop-up menu stuff
1556 // ----------------------------------------------------------------------------
1558 #if wxUSE_MENUS_NATIVE
1560 extern "C" WXDLLIMPEXP_CORE
1561 void gtk_pop_hide_callback( GtkWidget
*WXUNUSED(widget
), bool* is_waiting
)
1563 *is_waiting
= false;
1566 WXDLLIMPEXP_CORE
void SetInvokingWindow( wxMenu
*menu
, wxWindow
* win
)
1568 menu
->SetInvokingWindow( win
);
1570 wxMenuItemList::compatibility_iterator node
= menu
->GetMenuItems().GetFirst();
1573 wxMenuItem
*menuitem
= node
->GetData();
1574 if (menuitem
->IsSubMenu())
1576 SetInvokingWindow( menuitem
->GetSubMenu(), win
);
1579 node
= node
->GetNext();
1583 extern "C" WXDLLIMPEXP_CORE
1584 void wxPopupMenuPositionCallback( GtkMenu
*menu
,
1586 gboolean
* WXUNUSED(whatever
),
1587 gpointer user_data
)
1589 // ensure that the menu appears entirely on screen
1591 gtk_widget_get_child_requisition(GTK_WIDGET(menu
), &req
);
1593 wxSize sizeScreen
= wxGetDisplaySize();
1594 wxPoint
*pos
= (wxPoint
*)user_data
;
1596 gint xmax
= sizeScreen
.x
- req
.width
,
1597 ymax
= sizeScreen
.y
- req
.height
;
1599 *x
= pos
->x
< xmax
? pos
->x
: xmax
;
1600 *y
= pos
->y
< ymax
? pos
->y
: ymax
;
1603 bool wxWindowGTK::DoPopupMenu( wxMenu
*menu
, int x
, int y
)
1605 wxCHECK_MSG( m_widget
!= NULL
, false, wxT("invalid window") );
1607 wxCHECK_MSG( menu
!= NULL
, false, wxT("invalid popup-menu") );
1609 // NOTE: if you change this code, you need to update
1610 // the same code in taskbar.cpp as well. This
1611 // is ugly code duplication, I know.
1613 SetInvokingWindow( menu
, this );
1617 bool is_waiting
= true;
1619 gulong handler
= g_signal_connect (menu
->m_menu
, "hide",
1620 G_CALLBACK (gtk_pop_hide_callback
),
1625 GtkMenuPositionFunc posfunc
;
1626 if ( x
== -1 && y
== -1 )
1628 // use GTK's default positioning algorithm
1634 pos
= ClientToScreen(wxPoint(x
, y
));
1636 posfunc
= wxPopupMenuPositionCallback
;
1639 wxMenuEvent
eventOpen(wxEVT_MENU_OPEN
, -1, menu
);
1640 DoCommonMenuCallbackCode(menu
, eventOpen
);
1643 GTK_MENU(menu
->m_menu
),
1644 (GtkWidget
*) NULL
, // parent menu shell
1645 (GtkWidget
*) NULL
, // parent menu item
1646 posfunc
, // function to position it
1647 userdata
, // client data
1648 0, // button used to activate it
1649 gtk_get_current_event_time()
1654 gtk_main_iteration();
1657 g_signal_handler_disconnect (menu
->m_menu
, handler
);
1659 wxMenuEvent
eventClose(wxEVT_MENU_CLOSE
, -1, menu
);
1660 DoCommonMenuCallbackCode(menu
, eventClose
);
1665 #endif // wxUSE_MENUS_NATIVE
1667 #include <gtk/gtk.h>
1669 const char *wxGetStockGtkID(wxWindowID id
)
1671 #define STOCKITEM(wx,gtk) \
1675 #define STOCKITEM_MISSING(wx) \
1679 #if GTK_CHECK_VERSION(2,4,0)
1680 #define STOCKITEM_24(wx,gtk) STOCKITEM(wx,gtk)
1682 #define STOCKITEM_24(wx,gtk) STOCKITEM_MISSING(wx)
1685 #if GTK_CHECK_VERSION(2,6,0)
1686 #define STOCKITEM_26(wx,gtk) STOCKITEM(wx,gtk)
1688 #define STOCKITEM_26(wx,gtk) STOCKITEM_MISSING(wx)
1691 #if GTK_CHECK_VERSION(2,10,0)
1692 #define STOCKITEM_210(wx,gtk) STOCKITEM(wx,gtk)
1694 #define STOCKITEM_210(wx,gtk) STOCKITEM_MISSING(wx)
1700 STOCKITEM_26(wxID_ABOUT
, GTK_STOCK_ABOUT
)
1701 STOCKITEM(wxID_ADD
, GTK_STOCK_ADD
)
1702 STOCKITEM(wxID_APPLY
, GTK_STOCK_APPLY
)
1703 STOCKITEM(wxID_BOLD
, GTK_STOCK_BOLD
)
1704 STOCKITEM(wxID_CANCEL
, GTK_STOCK_CANCEL
)
1705 STOCKITEM(wxID_CLEAR
, GTK_STOCK_CLEAR
)
1706 STOCKITEM(wxID_CLOSE
, GTK_STOCK_CLOSE
)
1707 STOCKITEM(wxID_COPY
, GTK_STOCK_COPY
)
1708 STOCKITEM(wxID_CUT
, GTK_STOCK_CUT
)
1709 STOCKITEM(wxID_DELETE
, GTK_STOCK_DELETE
)
1710 STOCKITEM_26(wxID_EDIT
, GTK_STOCK_EDIT
)
1711 STOCKITEM(wxID_FIND
, GTK_STOCK_FIND
)
1712 STOCKITEM_26(wxID_FILE
, GTK_STOCK_FILE
)
1713 STOCKITEM(wxID_REPLACE
, GTK_STOCK_FIND_AND_REPLACE
)
1714 STOCKITEM(wxID_BACKWARD
, GTK_STOCK_GO_BACK
)
1715 STOCKITEM(wxID_DOWN
, GTK_STOCK_GO_DOWN
)
1716 STOCKITEM(wxID_FORWARD
, GTK_STOCK_GO_FORWARD
)
1717 STOCKITEM(wxID_UP
, GTK_STOCK_GO_UP
)
1718 STOCKITEM(wxID_HELP
, GTK_STOCK_HELP
)
1719 STOCKITEM(wxID_HOME
, GTK_STOCK_HOME
)
1720 STOCKITEM_24(wxID_INDENT
, GTK_STOCK_INDENT
)
1721 STOCKITEM(wxID_INDEX
, GTK_STOCK_INDEX
)
1722 STOCKITEM(wxID_ITALIC
, GTK_STOCK_ITALIC
)
1723 STOCKITEM(wxID_JUSTIFY_CENTER
, GTK_STOCK_JUSTIFY_CENTER
)
1724 STOCKITEM(wxID_JUSTIFY_FILL
, GTK_STOCK_JUSTIFY_FILL
)
1725 STOCKITEM(wxID_JUSTIFY_LEFT
, GTK_STOCK_JUSTIFY_LEFT
)
1726 STOCKITEM(wxID_JUSTIFY_RIGHT
, GTK_STOCK_JUSTIFY_RIGHT
)
1727 STOCKITEM(wxID_NEW
, GTK_STOCK_NEW
)
1728 STOCKITEM(wxID_NO
, GTK_STOCK_NO
)
1729 STOCKITEM(wxID_OK
, GTK_STOCK_OK
)
1730 STOCKITEM(wxID_OPEN
, GTK_STOCK_OPEN
)
1731 STOCKITEM(wxID_PASTE
, GTK_STOCK_PASTE
)
1732 STOCKITEM(wxID_PREFERENCES
, GTK_STOCK_PREFERENCES
)
1733 STOCKITEM(wxID_PRINT
, GTK_STOCK_PRINT
)
1734 STOCKITEM(wxID_PREVIEW
, GTK_STOCK_PRINT_PREVIEW
)
1735 STOCKITEM(wxID_PROPERTIES
, GTK_STOCK_PROPERTIES
)
1736 STOCKITEM(wxID_EXIT
, GTK_STOCK_QUIT
)
1737 STOCKITEM(wxID_REDO
, GTK_STOCK_REDO
)
1738 STOCKITEM(wxID_REFRESH
, GTK_STOCK_REFRESH
)
1739 STOCKITEM(wxID_REMOVE
, GTK_STOCK_REMOVE
)
1740 STOCKITEM(wxID_REVERT_TO_SAVED
, GTK_STOCK_REVERT_TO_SAVED
)
1741 STOCKITEM(wxID_SAVE
, GTK_STOCK_SAVE
)
1742 STOCKITEM(wxID_SAVEAS
, GTK_STOCK_SAVE_AS
)
1743 STOCKITEM_210(wxID_SELECTALL
, GTK_STOCK_SELECT_ALL
)
1744 STOCKITEM(wxID_STOP
, GTK_STOCK_STOP
)
1745 STOCKITEM(wxID_UNDELETE
, GTK_STOCK_UNDELETE
)
1746 STOCKITEM(wxID_UNDERLINE
, GTK_STOCK_UNDERLINE
)
1747 STOCKITEM(wxID_UNDO
, GTK_STOCK_UNDO
)
1748 STOCKITEM_24(wxID_UNINDENT
, GTK_STOCK_UNINDENT
)
1749 STOCKITEM(wxID_YES
, GTK_STOCK_YES
)
1750 STOCKITEM(wxID_ZOOM_100
, GTK_STOCK_ZOOM_100
)
1751 STOCKITEM(wxID_ZOOM_FIT
, GTK_STOCK_ZOOM_FIT
)
1752 STOCKITEM(wxID_ZOOM_IN
, GTK_STOCK_ZOOM_IN
)
1753 STOCKITEM(wxID_ZOOM_OUT
, GTK_STOCK_ZOOM_OUT
)
1756 wxFAIL_MSG( _T("invalid stock item ID") );
1765 bool wxGetStockGtkAccelerator(const char *id
, GdkModifierType
*mod
, guint
*key
)
1770 GtkStockItem stock_item
;
1771 if (gtk_stock_lookup (id
, &stock_item
))
1773 if (key
) *key
= stock_item
.keyval
;
1774 if (mod
) *mod
= stock_item
.modifier
;
1776 // some GTK stock items have zero values for the keyval;
1777 // it means that they do not have an accelerator...
1778 if (stock_item
.keyval
)
1785 #endif // wxUSE_MENUS