1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/menu.cpp
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"
19 #include "wx/bitmap.h"
24 #include "wx/stockitem.h"
25 #include "wx/gtk/private.h"
28 #include <gdk/gdktypes.h>
31 // FIXME: is this right? somehow I don't think so (VZ)
33 #define gtk_accel_group_attach(g, o) gtk_window_add_accel_group((o), (g))
34 //#define gtk_accel_group_detach(g, o) gtk_window_remove_accel_group((o), (g))
35 //#define gtk_menu_ensure_uline_accel_group(m) gtk_menu_get_accel_group(m)
37 #define ACCEL_OBJECT GtkWindow
38 #define ACCEL_OBJECTS(a) (a)->acceleratables
39 #define ACCEL_OBJ_CAST(obj) ((GtkWindow*) obj)
41 // we use normal item but with a special id for the menu title
42 static const int wxGTK_TITLE_ID
= -3;
44 //-----------------------------------------------------------------------------
46 //-----------------------------------------------------------------------------
49 static wxString
GetGtkHotKey( const wxMenuItem
& item
);
52 //-----------------------------------------------------------------------------
54 //-----------------------------------------------------------------------------
56 static wxString
wxReplaceUnderscore( const wxString
& title
)
58 // GTK 1.2 wants to have "_" instead of "&" for accelerators
61 for ( wxString::const_iterator pc
= title
.begin(); pc
!= title
.end(); ++pc
)
63 if ((*pc
== wxT('&')) && (pc
+1 != title
.end()) && (*(pc
+1) == wxT('&')))
65 // "&" is doubled to indicate "&" instead of accelerator
69 else if (*pc
== wxT('&'))
75 if ( *pc
== wxT('_') )
77 // underscores must be doubled to prevent them from being
78 // interpreted as accelerator character prefix by GTK
86 // wxPrintf( wxT("before %s after %s\n"), title.c_str(), str.c_str() );
91 //-----------------------------------------------------------------------------
92 // activate message from GTK
93 //-----------------------------------------------------------------------------
95 static void DoCommonMenuCallbackCode(wxMenu
*menu
, wxMenuEvent
& event
)
97 event
.SetEventObject( menu
);
99 wxEvtHandler
* handler
= menu
->GetEventHandler();
100 if (handler
&& handler
->ProcessEvent(event
))
103 wxWindow
*win
= menu
->GetInvokingWindow();
105 win
->GetEventHandler()->ProcessEvent( event
);
110 static void gtk_menu_open_callback( GtkWidget
*widget
, wxMenu
*menu
)
112 wxMenuEvent
event(wxEVT_MENU_OPEN
, -1, menu
);
114 DoCommonMenuCallbackCode(menu
, event
);
117 static void gtk_menu_close_callback( GtkWidget
*widget
, wxMenuBar
*menubar
)
119 if ( !menubar
->GetMenuCount() )
121 // if menubar is empty we can't call GetMenu(0) below
125 wxMenuEvent
event( wxEVT_MENU_CLOSE
, -1, NULL
);
127 DoCommonMenuCallbackCode(menubar
->GetMenu(0), event
);
132 //-----------------------------------------------------------------------------
134 //-----------------------------------------------------------------------------
136 IMPLEMENT_DYNAMIC_CLASS(wxMenuBar
,wxWindow
)
138 void wxMenuBar::Init(size_t n
, wxMenu
*menus
[], const wxString titles
[], long style
)
141 m_invokingWindow
= NULL
;
143 if (!PreCreation( NULL
, wxDefaultPosition
, wxDefaultSize
) ||
144 !CreateBase( NULL
, -1, wxDefaultPosition
, wxDefaultSize
, style
, wxDefaultValidator
, wxT("menubar") ))
146 wxFAIL_MSG( wxT("wxMenuBar creation failed") );
150 m_menubar
= gtk_menu_bar_new();
152 if (style
& wxMB_DOCKABLE
)
154 m_widget
= gtk_handle_box_new();
155 gtk_container_add(GTK_CONTAINER(m_widget
), m_menubar
);
156 gtk_widget_show(m_menubar
);
160 m_widget
= m_menubar
;
167 for (size_t i
= 0; i
< n
; ++i
)
168 Append(menus
[i
], titles
[i
]);
170 // VZ: for some reason connecting to menus "deactivate" doesn't work (we
171 // don't get it when the menu is dismissed by clicking outside the
172 // toolbar) so we connect to the global one, even if it means that we
173 // can't pass the menu which was closed in wxMenuEvent object
174 g_signal_connect (m_menubar
, "deactivate",
175 G_CALLBACK (gtk_menu_close_callback
), this);
179 wxMenuBar::wxMenuBar(size_t n
, wxMenu
*menus
[], const wxString titles
[], long style
)
181 Init(n
, menus
, titles
, style
);
184 wxMenuBar::wxMenuBar(long style
)
186 Init(0, NULL
, NULL
, style
);
189 wxMenuBar::wxMenuBar()
191 Init(0, NULL
, NULL
, 0);
194 wxMenuBar::~wxMenuBar()
198 static void wxMenubarUnsetInvokingWindow( wxMenu
*menu
, wxWindow
*win
)
200 menu
->SetInvokingWindow( (wxWindow
*) NULL
);
202 wxWindow
*top_frame
= win
;
203 while (top_frame
->GetParent() && !(top_frame
->IsTopLevel()))
204 top_frame
= top_frame
->GetParent();
206 wxMenuItemList::compatibility_iterator node
= menu
->GetMenuItems().GetFirst();
209 wxMenuItem
*menuitem
= node
->GetData();
210 if (menuitem
->IsSubMenu())
211 wxMenubarUnsetInvokingWindow( menuitem
->GetSubMenu(), win
);
212 node
= node
->GetNext();
216 static void wxMenubarSetInvokingWindow( wxMenu
*menu
, wxWindow
*win
)
218 menu
->SetInvokingWindow( win
);
220 wxWindow
*top_frame
= win
;
221 while (top_frame
->GetParent() && !(top_frame
->IsTopLevel()))
222 top_frame
= top_frame
->GetParent();
224 // support for native hot keys
225 ACCEL_OBJECT
*obj
= ACCEL_OBJ_CAST(top_frame
->m_widget
);
226 if ( !g_slist_find( ACCEL_OBJECTS(menu
->m_accel
), obj
) )
227 gtk_accel_group_attach( menu
->m_accel
, obj
);
229 wxMenuItemList::compatibility_iterator node
= menu
->GetMenuItems().GetFirst();
232 wxMenuItem
*menuitem
= node
->GetData();
233 if (menuitem
->IsSubMenu())
234 wxMenubarSetInvokingWindow( menuitem
->GetSubMenu(), win
);
235 node
= node
->GetNext();
239 void wxMenuBar::SetInvokingWindow( wxWindow
*win
)
241 m_invokingWindow
= win
;
242 wxWindow
*top_frame
= win
;
243 while (top_frame
->GetParent() && !(top_frame
->IsTopLevel()))
244 top_frame
= top_frame
->GetParent();
246 wxMenuList::compatibility_iterator node
= m_menus
.GetFirst();
249 wxMenu
*menu
= node
->GetData();
250 wxMenubarSetInvokingWindow( menu
, win
);
251 node
= node
->GetNext();
255 void wxMenuBar::SetLayoutDirection(wxLayoutDirection dir
)
257 if ( dir
== wxLayout_Default
)
259 const wxWindow
*const frame
= GetFrame();
262 // inherit layout from frame.
263 dir
= frame
->GetLayoutDirection();
265 else // use global layout
267 dir
= wxTheApp
->GetLayoutDirection();
271 if ( dir
== wxLayout_Default
)
274 GTKSetLayout(m_menubar
, dir
);
276 // also set the layout of all menus we already have (new ones will inherit
277 // the current layout)
278 for ( wxMenuList::compatibility_iterator node
= m_menus
.GetFirst();
280 node
= node
->GetNext() )
282 wxMenu
*const menu
= node
->GetData();
283 menu
->SetLayoutDirection(dir
);
287 wxLayoutDirection
wxMenuBar::GetLayoutDirection() const
289 return GTKGetLayout(m_menubar
);
292 void wxMenuBar::Attach(wxFrame
*frame
)
294 wxMenuBarBase::Attach(frame
);
296 SetLayoutDirection(wxLayout_Default
);
299 void wxMenuBar::UnsetInvokingWindow( wxWindow
*win
)
301 m_invokingWindow
= (wxWindow
*) NULL
;
302 wxWindow
*top_frame
= win
;
303 while (top_frame
->GetParent() && !(top_frame
->IsTopLevel()))
304 top_frame
= top_frame
->GetParent();
306 wxMenuList::compatibility_iterator node
= m_menus
.GetFirst();
309 wxMenu
*menu
= node
->GetData();
310 wxMenubarUnsetInvokingWindow( menu
, win
);
311 node
= node
->GetNext();
315 bool wxMenuBar::Append( wxMenu
*menu
, const wxString
&title
)
317 if ( !wxMenuBarBase::Append( menu
, title
) )
320 return GtkAppend(menu
, title
);
323 bool wxMenuBar::GtkAppend(wxMenu
*menu
, const wxString
& title
, int pos
)
325 wxString
str( wxReplaceUnderscore( title
) );
327 // This doesn't have much effect right now.
328 menu
->SetTitle( str
);
330 // The "m_owner" is the "menu item"
331 menu
->m_owner
= gtk_menu_item_new_with_mnemonic( wxGTK_CONV( str
) );
332 menu
->SetLayoutDirection(GetLayoutDirection());
334 gtk_widget_show( menu
->m_owner
);
336 gtk_menu_item_set_submenu( GTK_MENU_ITEM(menu
->m_owner
), menu
->m_menu
);
339 gtk_menu_shell_append( GTK_MENU_SHELL(m_menubar
), menu
->m_owner
);
341 gtk_menu_shell_insert( GTK_MENU_SHELL(m_menubar
), menu
->m_owner
, pos
);
343 g_signal_connect (menu
->m_owner
, "activate",
344 G_CALLBACK (gtk_menu_open_callback
),
347 // m_invokingWindow is set after wxFrame::SetMenuBar(). This call enables
348 // addings menu later on.
349 if (m_invokingWindow
)
351 wxMenubarSetInvokingWindow( menu
, m_invokingWindow
);
353 // OPTIMISE ME: we should probably cache this, or pass it
354 // directly, but for now this is a minimal
355 // change to validate the new dynamic sizing.
356 // see (and refactor :) similar code in Remove
359 wxFrame
*frame
= wxDynamicCast( m_invokingWindow
, wxFrame
);
362 frame
->UpdateMenuBarSize();
368 bool wxMenuBar::Insert(size_t pos
, wxMenu
*menu
, const wxString
& title
)
370 if ( !wxMenuBarBase::Insert(pos
, menu
, title
) )
375 if ( !GtkAppend(menu
, title
, (int)pos
) )
381 wxMenu
*wxMenuBar::Replace(size_t pos
, wxMenu
*menu
, const wxString
& title
)
383 // remove the old item and insert a new one
384 wxMenu
*menuOld
= Remove(pos
);
385 if ( menuOld
&& !Insert(pos
, menu
, title
) )
387 return (wxMenu
*) NULL
;
390 // either Insert() succeeded or Remove() failed and menuOld is NULL
394 wxMenu
*wxMenuBar::Remove(size_t pos
)
396 wxMenu
*menu
= wxMenuBarBase::Remove(pos
);
398 return (wxMenu
*) NULL
;
400 gtk_menu_item_remove_submenu( GTK_MENU_ITEM(menu
->m_owner
) );
401 gtk_container_remove(GTK_CONTAINER(m_menubar
), menu
->m_owner
);
403 gtk_widget_destroy( menu
->m_owner
);
404 menu
->m_owner
= NULL
;
406 if (m_invokingWindow
)
408 // OPTIMISE ME: see comment in GtkAppend
409 wxFrame
*frame
= wxDynamicCast( m_invokingWindow
, wxFrame
);
412 frame
->UpdateMenuBarSize();
418 static int FindMenuItemRecursive( const wxMenu
*menu
, const wxString
&menuString
, const wxString
&itemString
)
420 if (wxMenuItem::GetLabelFromText(menu
->GetTitle()) == wxMenuItem::GetLabelFromText(menuString
))
422 int res
= menu
->FindItem( itemString
);
423 if (res
!= wxNOT_FOUND
)
427 wxMenuItemList::compatibility_iterator node
= menu
->GetMenuItems().GetFirst();
430 wxMenuItem
*item
= node
->GetData();
431 if (item
->IsSubMenu())
432 return FindMenuItemRecursive(item
->GetSubMenu(), menuString
, itemString
);
434 node
= node
->GetNext();
440 int wxMenuBar::FindMenuItem( const wxString
&menuString
, const wxString
&itemString
) const
442 wxMenuList::compatibility_iterator node
= m_menus
.GetFirst();
445 wxMenu
*menu
= node
->GetData();
446 int res
= FindMenuItemRecursive( menu
, menuString
, itemString
);
449 node
= node
->GetNext();
455 // Find a wxMenuItem using its id. Recurses down into sub-menus
456 static wxMenuItem
* FindMenuItemByIdRecursive(const wxMenu
* menu
, int id
)
458 wxMenuItem
* result
= menu
->FindChildItem(id
);
460 wxMenuItemList::compatibility_iterator node
= menu
->GetMenuItems().GetFirst();
461 while ( node
&& result
== NULL
)
463 wxMenuItem
*item
= node
->GetData();
464 if (item
->IsSubMenu())
466 result
= FindMenuItemByIdRecursive( item
->GetSubMenu(), id
);
468 node
= node
->GetNext();
474 wxMenuItem
* wxMenuBar::FindItem( int id
, wxMenu
**menuForItem
) const
476 wxMenuItem
* result
= 0;
477 wxMenuList::compatibility_iterator node
= m_menus
.GetFirst();
478 while (node
&& result
== 0)
480 wxMenu
*menu
= node
->GetData();
481 result
= FindMenuItemByIdRecursive( menu
, id
);
482 node
= node
->GetNext();
487 *menuForItem
= result
? result
->GetMenu() : (wxMenu
*)NULL
;
493 void wxMenuBar::EnableTop( size_t pos
, bool flag
)
495 wxMenuList::compatibility_iterator node
= m_menus
.Item( pos
);
497 wxCHECK_RET( node
, wxT("menu not found") );
499 wxMenu
* menu
= node
->GetData();
502 gtk_widget_set_sensitive( menu
->m_owner
, flag
);
505 wxString
wxMenuBar::GetLabelTop( size_t pos
) const
507 wxMenuList::compatibility_iterator node
= m_menus
.Item( pos
);
509 wxCHECK_MSG( node
, wxT("invalid"), wxT("menu not found") );
511 wxMenu
* menu
= node
->GetData();
514 wxString
text( menu
->GetTitle() );
515 for ( const wxChar
*pc
= text
.c_str(); *pc
; pc
++ )
517 if ( *pc
== wxT('_') )
519 // '_' is the escape character for GTK+
523 // don't remove ampersands '&' since if we have them in the menu title
524 // it means that they were doubled to indicate "&" instead of accelerator
532 void wxMenuBar::SetLabelTop( size_t pos
, const wxString
& label
)
534 wxMenuList::compatibility_iterator node
= m_menus
.Item( pos
);
536 wxCHECK_RET( node
, wxT("menu not found") );
538 wxMenu
* menu
= node
->GetData();
540 const wxString
str( wxReplaceUnderscore( label
) );
542 menu
->SetTitle( str
);
545 gtk_label_set_text_with_mnemonic( GTK_LABEL( GTK_BIN(menu
->m_owner
)->child
), wxGTK_CONV(str
) );
548 //-----------------------------------------------------------------------------
550 //-----------------------------------------------------------------------------
553 static void gtk_menu_clicked_callback( GtkWidget
*widget
, wxMenu
*menu
)
555 int id
= menu
->FindMenuIdByMenuItem(widget
);
557 /* should find it for normal (not popup) menu */
558 wxASSERT_MSG( (id
!= -1) || (menu
->GetInvokingWindow() != NULL
),
559 _T("menu item not found in gtk_menu_clicked_callback") );
561 if (!menu
->IsEnabled(id
))
564 wxMenuItem
* item
= menu
->FindChildItem( id
);
565 wxCHECK_RET( item
, wxT("error in menu item callback") );
567 if ( item
->GetId() == wxGTK_TITLE_ID
)
569 // ignore events from the menu title
573 if (item
->IsCheckable())
575 bool isReallyChecked
= item
->IsChecked(),
576 isInternallyChecked
= item
->wxMenuItemBase::IsChecked();
578 // ensure that the internal state is always consistent with what is
579 // shown on the screen
580 item
->wxMenuItemBase::Check(isReallyChecked
);
582 // we must not report the events for the radio button going up nor the
583 // events resulting from the calls to wxMenuItem::Check()
584 if ( (item
->GetKind() == wxITEM_RADIO
&& !isReallyChecked
) ||
585 (isInternallyChecked
== isReallyChecked
) )
592 // Is this menu on a menubar? (possibly nested)
593 wxFrame
* frame
= NULL
;
594 if(menu
->IsAttached())
595 frame
= menu
->GetMenuBar()->GetFrame();
597 // FIXME: why do we have to call wxFrame::GetEventHandler() directly here?
598 // normally wxMenu::SendEvent() should be enough, if it doesn't work
599 // in wxGTK then we have a bug in wxMenu::GetInvokingWindow() which
600 // should be fixed instead of working around it here...
603 // If it is attached then let the frame send the event.
604 // Don't call frame->ProcessCommand(id) because it toggles
605 // checkable items and we've already done that above.
606 wxCommandEvent
commandEvent(wxEVT_COMMAND_MENU_SELECTED
, id
);
607 commandEvent
.SetEventObject(frame
);
608 if (item
->IsCheckable())
609 commandEvent
.SetInt(item
->IsChecked());
610 commandEvent
.SetEventObject(menu
);
612 frame
->GetEventHandler()->ProcessEvent(commandEvent
);
616 // otherwise let the menu have it
617 menu
->SendEvent(id
, item
->IsCheckable() ? item
->IsChecked() : -1);
622 //-----------------------------------------------------------------------------
624 //-----------------------------------------------------------------------------
627 static void gtk_menu_hilight_callback( GtkWidget
*widget
, wxMenu
*menu
)
629 int id
= menu
->FindMenuIdByMenuItem(widget
);
631 wxASSERT( id
!= -1 ); // should find it!
633 if (!menu
->IsEnabled(id
))
636 wxMenuEvent
event( wxEVT_MENU_HIGHLIGHT
, id
);
637 event
.SetEventObject( menu
);
639 wxEvtHandler
* handler
= menu
->GetEventHandler();
640 if (handler
&& handler
->ProcessEvent(event
))
643 wxWindow
*win
= menu
->GetInvokingWindow();
644 if (win
) win
->GetEventHandler()->ProcessEvent( event
);
648 //-----------------------------------------------------------------------------
650 //-----------------------------------------------------------------------------
653 static void gtk_menu_nolight_callback( GtkWidget
*widget
, wxMenu
*menu
)
655 int id
= menu
->FindMenuIdByMenuItem(widget
);
657 wxASSERT( id
!= -1 ); // should find it!
659 if (!menu
->IsEnabled(id
))
662 wxMenuEvent
event( wxEVT_MENU_HIGHLIGHT
, -1 );
663 event
.SetEventObject( menu
);
665 wxEvtHandler
* handler
= menu
->GetEventHandler();
666 if (handler
&& handler
->ProcessEvent(event
))
669 wxWindow
*win
= menu
->GetInvokingWindow();
671 win
->GetEventHandler()->ProcessEvent( event
);
675 //-----------------------------------------------------------------------------
677 //-----------------------------------------------------------------------------
679 IMPLEMENT_DYNAMIC_CLASS(wxMenuItem
, wxObject
)
681 wxMenuItem
*wxMenuItemBase::New(wxMenu
*parentMenu
,
683 const wxString
& name
,
684 const wxString
& help
,
688 return new wxMenuItem(parentMenu
, id
, name
, help
, kind
, subMenu
);
691 wxMenuItem::wxMenuItem(wxMenu
*parentMenu
,
693 const wxString
& text
,
694 const wxString
& help
,
697 : wxMenuItemBase(parentMenu
, id
, text
, help
, kind
, subMenu
)
702 wxMenuItem::wxMenuItem(wxMenu
*parentMenu
,
704 const wxString
& text
,
705 const wxString
& help
,
708 : wxMenuItemBase(parentMenu
, id
, text
, help
,
709 isCheckable
? wxITEM_CHECK
: wxITEM_NORMAL
, subMenu
)
714 void wxMenuItem::Init(const wxString
& text
)
716 m_labelWidget
= (GtkWidget
*) NULL
;
717 m_menuItem
= (GtkWidget
*) NULL
;
722 wxMenuItem::~wxMenuItem()
724 // don't delete menu items, the menus take care of that
727 // return the menu item text without any menu accels
729 wxString
wxMenuItemBase::GetLabelFromText(const wxString
& text
)
733 for ( const wxChar
*pc
= text
.c_str(); *pc
; pc
++ )
735 if ( *pc
== wxT('\t'))
738 if ( *pc
== wxT('_') )
740 // GTK 1.2 escapes "xxx_xxx" to "xxx__xxx"
746 if ( *pc
== wxT('\\') )
748 // GTK 2.0 escapes "xxx/xxx" to "xxx\/xxx"
754 if ( (*pc
== wxT('&')) && (*(pc
+1) != wxT('&')) )
757 // "&" is doubled to indicate "&" instead of accelerator
764 // wxPrintf( wxT("GetLabelFromText(): text %s label %s\n"), text.c_str(), label.c_str() );
769 void wxMenuItem::SetText( const wxString
& str
)
771 // cache some data which must be used later
772 bool isstock
= wxIsStockID(GetId());
773 const char *stockid
= NULL
;
775 stockid
= wxGetStockGtkID(GetId());
777 // Some optimization to avoid flicker
778 wxString oldLabel
= m_text
;
779 oldLabel
= wxStripMenuCodes(oldLabel
);
780 oldLabel
.Replace(wxT("_"), wxT(""));
781 wxString label1
= wxStripMenuCodes(str
);
782 wxString oldhotkey
= GetHotKey(); // Store the old hotkey in Ctrl-foo format
783 wxCharBuffer oldbuf
= wxGTK_CONV_SYS( GetGtkHotKey(*this) ); // and as <control>foo
787 if (oldLabel
== label1
&&
788 oldhotkey
== GetHotKey()) // Make sure we can change a hotkey even if the label is unaltered
795 label
= (GtkLabel
*) m_labelWidget
;
797 label
= GTK_LABEL( GTK_BIN(m_menuItem
)->child
);
799 // stock menu items can have empty labels:
800 wxString text
= m_text
;
801 if (text
.IsEmpty() && !IsSeparator())
803 wxASSERT_MSG(isstock
, wxT("A non-stock menu item with an empty label?"));
804 text
= wxGetStockLabel(GetId());
806 // need & => _ conversion
807 text
= GTKProcessMenuItemLabel(text
, NULL
);
810 gtk_label_set_text_with_mnemonic( GTK_LABEL(label
), wxGTK_CONV_SYS(text
) );
813 // remove old accelerator from our parent's accelerator group, if present
815 GdkModifierType accel_mods
;
816 if (oldbuf
[(size_t)0] != '\0')
818 gtk_accelerator_parse( (const char*) oldbuf
, &accel_key
, &accel_mods
);
821 gtk_widget_remove_accelerator(m_menuItem
,
822 m_parentMenu
->m_accel
,
829 // if the accelerator was taken from a stock ID, just get it back from GTK+ stock
830 if (wxGetStockGtkAccelerator(stockid
, &accel_mods
, &accel_key
))
831 gtk_widget_remove_accelerator( m_menuItem
,
832 m_parentMenu
->m_accel
,
837 // add new accelerator to our parent's accelerator group
838 wxCharBuffer buf
= wxGTK_CONV_SYS( GetGtkHotKey(*this) );
839 if (buf
[(size_t)0] != '\0')
841 gtk_accelerator_parse( (const char*) buf
, &accel_key
, &accel_mods
);
844 gtk_widget_add_accelerator( m_menuItem
,
846 m_parentMenu
->m_accel
,
854 // if the accelerator was taken from a stock ID, just get it back from GTK+ stock
855 if (wxGetStockGtkAccelerator(stockid
, &accel_mods
, &accel_key
))
856 gtk_widget_remove_accelerator( m_menuItem
,
857 m_parentMenu
->m_accel
,
863 // NOTE: this function is different from the similar functions GTKProcessMnemonics()
864 // implemented in control.cpp and from wxMenuItemBase::GetLabelFromText...
865 // so there's no real code duplication
866 wxString
wxMenuItem::GTKProcessMenuItemLabel(const wxString
& str
, wxString
*hotKey
)
870 // '\t' is the deliminator indicating a hot key
871 const wxChar
*pc
= str
;
872 while ( (*pc
!= wxT('\0')) && (*pc
!= wxT('\t')) )
874 if ((*pc
== wxT('&')) && (*(pc
+1) == wxT('&')))
876 // "&" is doubled to indicate "&" instead of accelerator
880 else if (*pc
== wxT('&'))
884 else if ( *pc
== wxT('_') ) // escape underscores
908 // it's valid for this function to be called even if m_menuItem == NULL
909 void wxMenuItem::DoSetText( const wxString
& str
)
912 m_text
= GTKProcessMenuItemLabel(str
, &m_hotKey
);
917 wxAcceleratorEntry
*wxMenuItem::GetAccel() const
925 // accelerator parsing code looks for them after a TAB, so insert a dummy
928 label
<< wxT('\t') << GetHotKey();
930 return wxAcceleratorEntry::Create(label
);
933 #endif // wxUSE_ACCEL
935 void wxMenuItem::Check( bool check
)
937 wxCHECK_RET( m_menuItem
, wxT("invalid menu item") );
939 if (check
== m_isChecked
)
942 wxMenuItemBase::Check( check
);
948 gtk_check_menu_item_set_active( (GtkCheckMenuItem
*)m_menuItem
, (gint
)check
);
952 wxFAIL_MSG( _T("can't check this item") );
956 void wxMenuItem::Enable( bool enable
)
958 wxCHECK_RET( m_menuItem
, wxT("invalid menu item") );
960 gtk_widget_set_sensitive( m_menuItem
, enable
);
961 wxMenuItemBase::Enable( enable
);
964 bool wxMenuItem::IsChecked() const
966 wxCHECK_MSG( m_menuItem
, false, wxT("invalid menu item") );
968 wxCHECK_MSG( IsCheckable(), false,
969 wxT("can't get state of uncheckable item!") );
971 return ((GtkCheckMenuItem
*)m_menuItem
)->active
!= 0;
974 //-----------------------------------------------------------------------------
976 //-----------------------------------------------------------------------------
978 IMPLEMENT_DYNAMIC_CLASS(wxMenu
,wxEvtHandler
)
982 m_accel
= gtk_accel_group_new();
983 m_menu
= gtk_menu_new();
984 // NB: keep reference to the menu so that it is not destroyed behind
985 // our back by GTK+ e.g. when it is removed from menubar:
986 gtk_widget_ref(m_menu
);
988 m_owner
= (GtkWidget
*) NULL
;
990 // Tearoffs are entries, just like separators. So if we want this
991 // menu to be a tear-off one, we just append a tearoff entry
993 if ( m_style
& wxMENU_TEAROFF
)
995 GtkWidget
*tearoff
= gtk_tearoff_menu_item_new();
997 gtk_menu_shell_append(GTK_MENU_SHELL(m_menu
), tearoff
);
1002 // append the title as the very first entry if we have it
1003 if ( !m_title
.empty() )
1005 Append(wxGTK_TITLE_ID
, m_title
);
1012 WX_CLEAR_LIST(wxMenuItemList
, m_items
);
1014 if ( GTK_IS_WIDGET( m_menu
))
1017 gtk_widget_unref( m_menu
);
1018 g_object_unref( m_accel
);
1020 // if the menu is inserted in another menu at this time, there was
1021 // one more reference to it:
1023 gtk_widget_destroy( m_menu
);
1027 void wxMenu::SetLayoutDirection(const wxLayoutDirection dir
)
1030 wxWindow::GTKSetLayout(m_owner
, dir
);
1031 //else: will be called later by wxMenuBar again
1034 wxLayoutDirection
wxMenu::GetLayoutDirection() const
1036 return wxWindow::GTKGetLayout(m_owner
);
1039 bool wxMenu::GtkAppend(wxMenuItem
*mitem
, int pos
)
1041 GtkWidget
*menuItem
;
1043 // cache some data used later
1044 wxString text
= mitem
->GetText();
1045 int id
= mitem
->GetId();
1046 bool isstock
= wxIsStockID(id
);
1047 const char *stockid
= NULL
;
1049 stockid
= wxGetStockGtkID(mitem
->GetId());
1051 // stock menu items can have an empty label
1052 if (text
.IsEmpty() && !mitem
->IsSeparator())
1054 wxASSERT_MSG(isstock
, wxT("A non-stock menu item with an empty label?"));
1055 text
= wxGetStockLabel(id
);
1057 // need & => _ conversion
1058 text
= wxMenuItem::GTKProcessMenuItemLabel(text
, NULL
);
1061 if ( mitem
->IsSeparator() )
1063 menuItem
= gtk_separator_menu_item_new();
1065 else if ( mitem
->GetBitmap().Ok() ||
1066 (mitem
->GetKind() == wxITEM_NORMAL
&& isstock
) )
1068 wxBitmap
bitmap(mitem
->GetBitmap());
1070 menuItem
= gtk_image_menu_item_new_with_mnemonic( wxGTK_CONV_SYS( text
) );
1075 // use stock bitmap for this item if available on the assumption
1076 // that it never hurts to follow GTK+ conventions more closely
1077 image
= stockid
? gtk_image_new_from_stock(stockid
, GTK_ICON_SIZE_MENU
)
1080 else // we have a custom bitmap
1082 wxASSERT_MSG( mitem
->GetKind() == wxITEM_NORMAL
,
1083 _T("only normal menu items can have bitmaps") );
1085 if ( bitmap
.HasPixbuf() )
1087 image
= gtk_image_new_from_pixbuf(bitmap
.GetPixbuf());
1091 GdkPixmap
*gdk_pixmap
= bitmap
.GetPixmap();
1092 GdkBitmap
*gdk_bitmap
= bitmap
.GetMask() ?
1093 bitmap
.GetMask()->GetBitmap() :
1095 image
= gtk_image_new_from_pixmap( gdk_pixmap
, gdk_bitmap
);
1101 gtk_widget_show(image
);
1103 gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(menuItem
), image
);
1108 else // a normal item
1110 // NB: 'text' variable has "_" instead of "&" after mitem->SetText()
1113 switch ( mitem
->GetKind() )
1117 menuItem
= gtk_check_menu_item_new_with_mnemonic( wxGTK_CONV_SYS( text
) );
1124 GSList
*group
= NULL
;
1125 if ( m_prevRadio
== NULL
)
1127 // start of a new radio group
1128 m_prevRadio
= menuItem
=
1129 gtk_radio_menu_item_new_with_mnemonic( group
, wxGTK_CONV_SYS( text
) );
1131 else // continue the radio group
1133 group
= gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (m_prevRadio
));
1134 m_prevRadio
= menuItem
=
1135 gtk_radio_menu_item_new_with_mnemonic( group
, wxGTK_CONV_SYS( text
) );
1141 wxFAIL_MSG( _T("unexpected menu item kind") );
1146 menuItem
= gtk_menu_item_new_with_mnemonic( wxGTK_CONV_SYS( text
) );
1155 GdkModifierType accel_mods
;
1156 wxCharBuffer buf
= wxGTK_CONV_SYS( GetGtkHotKey(*mitem
) );
1158 // wxPrintf( wxT("item: %s hotkey %s\n"), mitem->GetText().c_str(), GetGtkHotKey(*mitem).c_str() );
1159 if (buf
[(size_t)0] != '\0')
1161 gtk_accelerator_parse( (const char*) buf
, &accel_key
, &accel_mods
);
1164 gtk_widget_add_accelerator (menuItem
,
1174 // if the accelerator was taken from a stock ID, just get it back from GTK+ stock
1175 if (wxGetStockGtkAccelerator(stockid
, &accel_mods
, &accel_key
))
1176 gtk_widget_add_accelerator( menuItem
,
1185 gtk_menu_shell_append(GTK_MENU_SHELL(m_menu
), menuItem
);
1187 gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu
), menuItem
, pos
);
1189 gtk_widget_show( menuItem
);
1191 if ( !mitem
->IsSeparator() )
1193 wxASSERT_MSG( menuItem
, wxT("invalid menuitem") );
1195 g_signal_connect (menuItem
, "select",
1196 G_CALLBACK (gtk_menu_hilight_callback
), this);
1197 g_signal_connect (menuItem
, "deselect",
1198 G_CALLBACK (gtk_menu_nolight_callback
), this);
1200 if ( mitem
->IsSubMenu() && mitem
->GetKind() != wxITEM_RADIO
&& mitem
->GetKind() != wxITEM_CHECK
)
1202 gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem
), mitem
->GetSubMenu()->m_menu
);
1204 gtk_widget_show( mitem
->GetSubMenu()->m_menu
);
1206 // if adding a submenu to a menu already existing in the menu bar, we
1207 // must set invoking window to allow processing events from this
1209 if ( m_invokingWindow
)
1210 wxMenubarSetInvokingWindow(mitem
->GetSubMenu(), m_invokingWindow
);
1214 g_signal_connect (menuItem
, "activate",
1215 G_CALLBACK (gtk_menu_clicked_callback
),
1220 mitem
->SetMenuItem(menuItem
);
1224 // This doesn't even exist!
1225 // gtk_widget_lock_accelerators(mitem->GetMenuItem());
1231 wxMenuItem
* wxMenu::DoAppend(wxMenuItem
*mitem
)
1233 if (!GtkAppend(mitem
))
1236 return wxMenuBase::DoAppend(mitem
);
1239 wxMenuItem
* wxMenu::DoInsert(size_t pos
, wxMenuItem
*item
)
1241 if ( !wxMenuBase::DoInsert(pos
, item
) )
1245 if ( !GtkAppend(item
, (int)pos
) )
1251 wxMenuItem
*wxMenu::DoRemove(wxMenuItem
*item
)
1253 if ( !wxMenuBase::DoRemove(item
) )
1254 return (wxMenuItem
*)NULL
;
1256 // TODO: this code doesn't delete the item factory item and this seems
1257 // impossible as of GTK 1.2.6.
1258 gtk_widget_destroy( item
->GetMenuItem() );
1263 int wxMenu::FindMenuIdByMenuItem( GtkWidget
*menuItem
) const
1265 wxMenuItemList::compatibility_iterator node
= m_items
.GetFirst();
1268 wxMenuItem
*item
= node
->GetData();
1269 if (item
->GetMenuItem() == menuItem
)
1270 return item
->GetId();
1271 node
= node
->GetNext();
1277 void wxMenu::Attach(wxMenuBarBase
*menubar
)
1279 wxMenuBase::Attach(menubar
);
1281 // inherit layout direction from menubar.
1282 SetLayoutDirection(menubar
->GetLayoutDirection());
1285 // ----------------------------------------------------------------------------
1287 // ----------------------------------------------------------------------------
1291 static wxString
GetGtkHotKey( const wxMenuItem
& item
)
1295 wxAcceleratorEntry
*accel
= item
.GetAccel();
1298 int flags
= accel
->GetFlags();
1299 if ( flags
& wxACCEL_ALT
)
1300 hotkey
+= wxT("<alt>");
1301 if ( flags
& wxACCEL_CTRL
)
1302 hotkey
+= wxT("<control>");
1303 if ( flags
& wxACCEL_SHIFT
)
1304 hotkey
+= wxT("<shift>");
1306 int code
= accel
->GetKeyCode();
1333 hotkey
+= wxString::Format(wxT("F%d"), code
- WXK_F1
+ 1);
1336 // TODO: we should use gdk_keyval_name() (a.k.a.
1337 // XKeysymToString) here as well as hardcoding the keysym
1338 // names this might be not portable
1340 hotkey
<< wxT("Insert" );
1343 hotkey
<< wxT("Delete" );
1346 hotkey
<< wxT("Up" );
1349 hotkey
<< wxT("Down" );
1352 hotkey
<< wxT("Page_Up" );
1355 hotkey
<< wxT("Page_Down" );
1358 hotkey
<< wxT("Left" );
1361 hotkey
<< wxT("Right" );
1364 hotkey
<< wxT("Home" );
1367 hotkey
<< wxT("End" );
1370 hotkey
<< wxT("Return" );
1373 hotkey
<< wxT("BackSpace" );
1376 hotkey
<< wxT("Tab" );
1379 hotkey
<< wxT("Esc" );
1382 hotkey
<< wxT("space" );
1385 hotkey
<< wxT("Multiply" );
1388 hotkey
<< wxT("Add" );
1391 hotkey
<< wxT("Separator" );
1394 hotkey
<< wxT("Subtract" );
1397 hotkey
<< wxT("Decimal" );
1400 hotkey
<< wxT("Divide" );
1403 hotkey
<< wxT("Cancel" );
1406 hotkey
<< wxT("Clear" );
1409 hotkey
<< wxT("Menu" );
1412 hotkey
<< wxT("Pause" );
1415 hotkey
<< wxT("Capital" );
1418 hotkey
<< wxT("Select" );
1421 hotkey
<< wxT("Print" );
1424 hotkey
<< wxT("Execute" );
1427 hotkey
<< wxT("Snapshot" );
1430 hotkey
<< wxT("Help" );
1433 hotkey
<< wxT("Num_Lock" );
1436 hotkey
<< wxT("Scroll_Lock" );
1438 case WXK_NUMPAD_INSERT
:
1439 hotkey
<< wxT("KP_Insert" );
1441 case WXK_NUMPAD_DELETE
:
1442 hotkey
<< wxT("KP_Delete" );
1444 case WXK_NUMPAD_SPACE
:
1445 hotkey
<< wxT("KP_Space" );
1447 case WXK_NUMPAD_TAB
:
1448 hotkey
<< wxT("KP_Tab" );
1450 case WXK_NUMPAD_ENTER
:
1451 hotkey
<< wxT("KP_Enter" );
1453 case WXK_NUMPAD_F1
: case WXK_NUMPAD_F2
: case WXK_NUMPAD_F3
:
1455 hotkey
+= wxString::Format(wxT("KP_F%d"), code
- WXK_NUMPAD_F1
+ 1);
1457 case WXK_NUMPAD_HOME
:
1458 hotkey
<< wxT("KP_Home" );
1460 case WXK_NUMPAD_LEFT
:
1461 hotkey
<< wxT("KP_Left" );
1464 hotkey
<< wxT("KP_Up" );
1466 case WXK_NUMPAD_RIGHT
:
1467 hotkey
<< wxT("KP_Right" );
1469 case WXK_NUMPAD_DOWN
:
1470 hotkey
<< wxT("KP_Down" );
1472 case WXK_NUMPAD_PAGEUP
:
1473 hotkey
<< wxT("KP_Page_Up" );
1475 case WXK_NUMPAD_PAGEDOWN
:
1476 hotkey
<< wxT("KP_Page_Down" );
1478 case WXK_NUMPAD_END
:
1479 hotkey
<< wxT("KP_End" );
1481 case WXK_NUMPAD_BEGIN
:
1482 hotkey
<< wxT("KP_Begin" );
1484 case WXK_NUMPAD_EQUAL
:
1485 hotkey
<< wxT("KP_Equal" );
1487 case WXK_NUMPAD_MULTIPLY
:
1488 hotkey
<< wxT("KP_Multiply" );
1490 case WXK_NUMPAD_ADD
:
1491 hotkey
<< wxT("KP_Add" );
1493 case WXK_NUMPAD_SEPARATOR
:
1494 hotkey
<< wxT("KP_Separator" );
1496 case WXK_NUMPAD_SUBTRACT
:
1497 hotkey
<< wxT("KP_Subtract" );
1499 case WXK_NUMPAD_DECIMAL
:
1500 hotkey
<< wxT("KP_Decimal" );
1502 case WXK_NUMPAD_DIVIDE
:
1503 hotkey
<< wxT("KP_Divide" );
1505 case WXK_NUMPAD0
: case WXK_NUMPAD1
: case WXK_NUMPAD2
:
1506 case WXK_NUMPAD3
: case WXK_NUMPAD4
: case WXK_NUMPAD5
:
1507 case WXK_NUMPAD6
: case WXK_NUMPAD7
: case WXK_NUMPAD8
: case WXK_NUMPAD9
:
1508 hotkey
+= wxString::Format(wxT("KP_%d"), code
- WXK_NUMPAD0
);
1510 case WXK_WINDOWS_LEFT
:
1511 hotkey
<< wxT("Super_L" );
1513 case WXK_WINDOWS_RIGHT
:
1514 hotkey
<< wxT("Super_R" );
1516 case WXK_WINDOWS_MENU
:
1517 hotkey
<< wxT("Menu" );
1520 hotkey
<< wxT("Command" );
1522 /* These probably wouldn't work as there is no SpecialX in gdk/keynames.txt
1523 case WXK_SPECIAL1: case WXK_SPECIAL2: case WXK_SPECIAL3: case WXK_SPECIAL4:
1524 case WXK_SPECIAL5: case WXK_SPECIAL6: case WXK_SPECIAL7: case WXK_SPECIAL8:
1525 case WXK_SPECIAL9: case WXK_SPECIAL10: case WXK_SPECIAL11: case WXK_SPECIAL12:
1526 case WXK_SPECIAL13: case WXK_SPECIAL14: case WXK_SPECIAL15: case WXK_SPECIAL16:
1527 case WXK_SPECIAL17: case WXK_SPECIAL18: case WXK_SPECIAL19: case WXK_SPECIAL20:
1528 hotkey += wxString::Format(wxT("Special%d"), code - WXK_SPECIAL1 + 1);
1531 // if there are any other keys wxAcceleratorEntry::Create() may
1532 // return, we should process them here
1538 name
= wxGTK_CONV_BACK_SYS(gdk_keyval_name((guint
)code
));
1539 if ( !name
.empty() )
1546 wxFAIL_MSG( wxT("unknown keyboard accel") );
1555 #endif // wxUSE_ACCEL
1557 // ----------------------------------------------------------------------------
1558 // Pop-up menu stuff
1559 // ----------------------------------------------------------------------------
1561 #if wxUSE_MENUS_NATIVE
1563 extern "C" WXDLLIMPEXP_CORE
1564 void gtk_pop_hide_callback( GtkWidget
*WXUNUSED(widget
), bool* is_waiting
)
1566 *is_waiting
= false;
1569 WXDLLIMPEXP_CORE
void SetInvokingWindow( wxMenu
*menu
, wxWindow
* win
)
1571 menu
->SetInvokingWindow( win
);
1573 wxMenuItemList::compatibility_iterator node
= menu
->GetMenuItems().GetFirst();
1576 wxMenuItem
*menuitem
= node
->GetData();
1577 if (menuitem
->IsSubMenu())
1579 SetInvokingWindow( menuitem
->GetSubMenu(), win
);
1582 node
= node
->GetNext();
1586 extern "C" WXDLLIMPEXP_CORE
1587 void wxPopupMenuPositionCallback( GtkMenu
*menu
,
1589 gboolean
* WXUNUSED(whatever
),
1590 gpointer user_data
)
1592 // ensure that the menu appears entirely on screen
1594 gtk_widget_get_child_requisition(GTK_WIDGET(menu
), &req
);
1596 wxSize sizeScreen
= wxGetDisplaySize();
1597 wxPoint
*pos
= (wxPoint
*)user_data
;
1599 gint xmax
= sizeScreen
.x
- req
.width
,
1600 ymax
= sizeScreen
.y
- req
.height
;
1602 *x
= pos
->x
< xmax
? pos
->x
: xmax
;
1603 *y
= pos
->y
< ymax
? pos
->y
: ymax
;
1606 bool wxWindowGTK::DoPopupMenu( wxMenu
*menu
, int x
, int y
)
1608 wxCHECK_MSG( m_widget
!= NULL
, false, wxT("invalid window") );
1610 wxCHECK_MSG( menu
!= NULL
, false, wxT("invalid popup-menu") );
1612 // NOTE: if you change this code, you need to update
1613 // the same code in taskbar.cpp as well. This
1614 // is ugly code duplication, I know.
1616 SetInvokingWindow( menu
, this );
1620 bool is_waiting
= true;
1622 gulong handler
= g_signal_connect (menu
->m_menu
, "hide",
1623 G_CALLBACK (gtk_pop_hide_callback
),
1628 GtkMenuPositionFunc posfunc
;
1629 if ( x
== -1 && y
== -1 )
1631 // use GTK's default positioning algorithm
1637 pos
= ClientToScreen(wxPoint(x
, y
));
1639 posfunc
= wxPopupMenuPositionCallback
;
1642 wxMenuEvent
eventOpen(wxEVT_MENU_OPEN
, -1, menu
);
1643 DoCommonMenuCallbackCode(menu
, eventOpen
);
1646 GTK_MENU(menu
->m_menu
),
1647 (GtkWidget
*) NULL
, // parent menu shell
1648 (GtkWidget
*) NULL
, // parent menu item
1649 posfunc
, // function to position it
1650 userdata
, // client data
1651 0, // button used to activate it
1652 gtk_get_current_event_time()
1657 gtk_main_iteration();
1660 g_signal_handler_disconnect (menu
->m_menu
, handler
);
1662 wxMenuEvent
eventClose(wxEVT_MENU_CLOSE
, -1, menu
);
1663 DoCommonMenuCallbackCode(menu
, eventClose
);
1668 #endif // wxUSE_MENUS_NATIVE
1672 #include <gtk/gtk.h>
1674 const char *wxGetStockGtkID(wxWindowID id
)
1676 #define STOCKITEM(wx,gtk) \
1680 #define STOCKITEM_MISSING(wx) \
1684 #if GTK_CHECK_VERSION(2,4,0)
1685 #define STOCKITEM_24(wx,gtk) STOCKITEM(wx,gtk)
1687 #define STOCKITEM_24(wx,gtk) STOCKITEM_MISSING(wx)
1690 #if GTK_CHECK_VERSION(2,6,0)
1691 #define STOCKITEM_26(wx,gtk) STOCKITEM(wx,gtk)
1693 #define STOCKITEM_26(wx,gtk) STOCKITEM_MISSING(wx)
1696 #if GTK_CHECK_VERSION(2,10,0)
1697 #define STOCKITEM_210(wx,gtk) STOCKITEM(wx,gtk)
1699 #define STOCKITEM_210(wx,gtk) STOCKITEM_MISSING(wx)
1705 STOCKITEM_26(wxID_ABOUT
, GTK_STOCK_ABOUT
)
1706 STOCKITEM(wxID_ADD
, GTK_STOCK_ADD
)
1707 STOCKITEM(wxID_APPLY
, GTK_STOCK_APPLY
)
1708 STOCKITEM(wxID_BOLD
, GTK_STOCK_BOLD
)
1709 STOCKITEM(wxID_CANCEL
, GTK_STOCK_CANCEL
)
1710 STOCKITEM(wxID_CLEAR
, GTK_STOCK_CLEAR
)
1711 STOCKITEM(wxID_CLOSE
, GTK_STOCK_CLOSE
)
1712 STOCKITEM(wxID_COPY
, GTK_STOCK_COPY
)
1713 STOCKITEM(wxID_CUT
, GTK_STOCK_CUT
)
1714 STOCKITEM(wxID_DELETE
, GTK_STOCK_DELETE
)
1715 STOCKITEM_26(wxID_EDIT
, GTK_STOCK_EDIT
)
1716 STOCKITEM(wxID_FIND
, GTK_STOCK_FIND
)
1717 STOCKITEM_26(wxID_FILE
, GTK_STOCK_FILE
)
1718 STOCKITEM(wxID_REPLACE
, GTK_STOCK_FIND_AND_REPLACE
)
1719 STOCKITEM(wxID_BACKWARD
, GTK_STOCK_GO_BACK
)
1720 STOCKITEM(wxID_DOWN
, GTK_STOCK_GO_DOWN
)
1721 STOCKITEM(wxID_FORWARD
, GTK_STOCK_GO_FORWARD
)
1722 STOCKITEM(wxID_UP
, GTK_STOCK_GO_UP
)
1723 STOCKITEM(wxID_HELP
, GTK_STOCK_HELP
)
1724 STOCKITEM(wxID_HOME
, GTK_STOCK_HOME
)
1725 STOCKITEM_24(wxID_INDENT
, GTK_STOCK_INDENT
)
1726 STOCKITEM(wxID_INDEX
, GTK_STOCK_INDEX
)
1727 STOCKITEM(wxID_ITALIC
, GTK_STOCK_ITALIC
)
1728 STOCKITEM(wxID_JUSTIFY_CENTER
, GTK_STOCK_JUSTIFY_CENTER
)
1729 STOCKITEM(wxID_JUSTIFY_FILL
, GTK_STOCK_JUSTIFY_FILL
)
1730 STOCKITEM(wxID_JUSTIFY_LEFT
, GTK_STOCK_JUSTIFY_LEFT
)
1731 STOCKITEM(wxID_JUSTIFY_RIGHT
, GTK_STOCK_JUSTIFY_RIGHT
)
1732 STOCKITEM(wxID_NEW
, GTK_STOCK_NEW
)
1733 STOCKITEM(wxID_NO
, GTK_STOCK_NO
)
1734 STOCKITEM(wxID_OK
, GTK_STOCK_OK
)
1735 STOCKITEM(wxID_OPEN
, GTK_STOCK_OPEN
)
1736 STOCKITEM(wxID_PASTE
, GTK_STOCK_PASTE
)
1737 STOCKITEM(wxID_PREFERENCES
, GTK_STOCK_PREFERENCES
)
1738 STOCKITEM(wxID_PRINT
, GTK_STOCK_PRINT
)
1739 STOCKITEM(wxID_PREVIEW
, GTK_STOCK_PRINT_PREVIEW
)
1740 STOCKITEM(wxID_PROPERTIES
, GTK_STOCK_PROPERTIES
)
1741 STOCKITEM(wxID_EXIT
, GTK_STOCK_QUIT
)
1742 STOCKITEM(wxID_REDO
, GTK_STOCK_REDO
)
1743 STOCKITEM(wxID_REFRESH
, GTK_STOCK_REFRESH
)
1744 STOCKITEM(wxID_REMOVE
, GTK_STOCK_REMOVE
)
1745 STOCKITEM(wxID_REVERT_TO_SAVED
, GTK_STOCK_REVERT_TO_SAVED
)
1746 STOCKITEM(wxID_SAVE
, GTK_STOCK_SAVE
)
1747 STOCKITEM(wxID_SAVEAS
, GTK_STOCK_SAVE_AS
)
1748 STOCKITEM_210(wxID_SELECTALL
, GTK_STOCK_SELECT_ALL
)
1749 STOCKITEM(wxID_STOP
, GTK_STOCK_STOP
)
1750 STOCKITEM(wxID_UNDELETE
, GTK_STOCK_UNDELETE
)
1751 STOCKITEM(wxID_UNDERLINE
, GTK_STOCK_UNDERLINE
)
1752 STOCKITEM(wxID_UNDO
, GTK_STOCK_UNDO
)
1753 STOCKITEM_24(wxID_UNINDENT
, GTK_STOCK_UNINDENT
)
1754 STOCKITEM(wxID_YES
, GTK_STOCK_YES
)
1755 STOCKITEM(wxID_ZOOM_100
, GTK_STOCK_ZOOM_100
)
1756 STOCKITEM(wxID_ZOOM_FIT
, GTK_STOCK_ZOOM_FIT
)
1757 STOCKITEM(wxID_ZOOM_IN
, GTK_STOCK_ZOOM_IN
)
1758 STOCKITEM(wxID_ZOOM_OUT
, GTK_STOCK_ZOOM_OUT
)
1761 wxFAIL_MSG( _T("invalid stock item ID") );
1770 bool wxGetStockGtkAccelerator(const char *id
, GdkModifierType
*mod
, guint
*key
)
1775 GtkStockItem stock_item
;
1776 if (gtk_stock_lookup (id
, &stock_item
))
1778 if (key
) *key
= stock_item
.keyval
;
1779 if (mod
) *mod
= stock_item
.modifier
;
1781 // some GTK stock items have zero values for the keyval;
1782 // it means that they do not have an accelerator...
1783 if (stock_item
.keyval
)
1790 #endif // __WXGTK20__