// create the menubar
wxMenu *fileMenu = new wxMenu;
+ wxMenu *stockSubMenu = new wxMenu;
+ stockSubMenu->Append(wxID_ADD, "wxID_ADD");
+ stockSubMenu->Append(wxID_APPLY, "wxID_APPLY");
+ stockSubMenu->Append(wxID_BOLD, "wxID_BOLD");
+ stockSubMenu->Append(wxID_CANCEL, "wxID_CANCEL");
+ stockSubMenu->Append(wxID_CLEAR, "wxID_CLEAR");
+ stockSubMenu->Append(wxID_CLOSE, "wxID_CLOSE");
+ stockSubMenu->Append(wxID_COPY, "wxID_COPY");
+ stockSubMenu->Append(wxID_CUT, "wxID_CUT");
+ stockSubMenu->Append(wxID_DELETE, "wxID_DELETE");
+ stockSubMenu->Append(wxID_FIND, "wxID_FIND");
+ stockSubMenu->Append(wxID_REPLACE, "wxID_REPLACE");
+ stockSubMenu->Append(wxID_BACKWARD, "wxID_BACKWARD");
+ stockSubMenu->Append(wxID_DOWN, "wxID_DOWN");
+ stockSubMenu->Append(wxID_FORWARD, "wxID_FORWARD");
+ stockSubMenu->Append(wxID_UP, "wxID_UP");
+ stockSubMenu->Append(wxID_HELP, "wxID_HELP");
+ stockSubMenu->Append(wxID_HOME, "wxID_HOME");
+ stockSubMenu->Append(wxID_INDENT, "wxID_INDENT");
+ stockSubMenu->Append(wxID_INDEX, "wxID_INDEX");
+ stockSubMenu->Append(wxID_ITALIC, "wxID_ITALIC");
+ stockSubMenu->Append(wxID_JUSTIFY_CENTER, "wxID_JUSTIFY_CENTER");
+ stockSubMenu->Append(wxID_JUSTIFY_FILL, "wxID_JUSTIFY_FILL");
+ stockSubMenu->Append(wxID_JUSTIFY_LEFT, "wxID_JUSTIFY_LEFT");
+ stockSubMenu->Append(wxID_JUSTIFY_RIGHT, "wxID_JUSTIFY_RIGHT");
+ stockSubMenu->Append(wxID_NEW, "wxID_NEW");
+ stockSubMenu->Append(wxID_NO, "wxID_NO");
+ stockSubMenu->Append(wxID_OK, "wxID_OK");
+ stockSubMenu->Append(wxID_OPEN, "wxID_OPEN");
+ stockSubMenu->Append(wxID_PASTE, "wxID_PASTE");
+ stockSubMenu->Append(wxID_PREFERENCES, "wxID_PREFERENCES");
+ stockSubMenu->Append(wxID_PRINT, "wxID_PRINT");
+ stockSubMenu->Append(wxID_PREVIEW, "wxID_PREVIEW");
+ stockSubMenu->Append(wxID_PROPERTIES, "wxID_PROPERTIES");
+ stockSubMenu->Append(wxID_EXIT, "wxID_EXIT");
+ stockSubMenu->Append(wxID_REDO, "wxID_REDO");
+ stockSubMenu->Append(wxID_REFRESH, "wxID_REFRESH");
+ stockSubMenu->Append(wxID_REMOVE, "wxID_REMOVE");
+ stockSubMenu->Append(wxID_REVERT_TO_SAVED, "wxID_REVERT_TO_SAVED");
+ stockSubMenu->Append(wxID_SAVE, "wxID_SAVE");
+ stockSubMenu->Append(wxID_SAVEAS, "wxID_SAVEAS");
+ stockSubMenu->Append(wxID_STOP, "wxID_STOP");
+ stockSubMenu->Append(wxID_UNDELETE, "wxID_UNDELETE");
+ stockSubMenu->Append(wxID_UNDERLINE, "wxID_UNDERLINE");
+ stockSubMenu->Append(wxID_UNDO, "wxID_UNDO");
+ stockSubMenu->Append(wxID_UNINDENT, "wxID_UNINDENT");
+ stockSubMenu->Append(wxID_YES, "wxID_YES");
+ stockSubMenu->Append(wxID_ZOOM_100, "wxID_ZOOM_100");
+ stockSubMenu->Append(wxID_ZOOM_FIT, "wxID_ZOOM_FIT");
+ stockSubMenu->Append(wxID_ZOOM_IN, "wxID_ZOOM_IN");
+ stockSubMenu->Append(wxID_ZOOM_OUT, "wxID_ZOOM_OUT");
+ fileMenu->AppendSubMenu(stockSubMenu, _T("&Standard items demo"));
+
#if USE_LOG_WINDOW
wxMenuItem *item = new wxMenuItem(fileMenu, Menu_File_ClearLog,
_T("Clear &log\tCtrl-L"));
#endif
fileMenu->Append(item);
fileMenu->AppendSeparator();
-#endif
+#endif // USE_LOG_WINDOW
+
fileMenu->Append(Menu_File_Quit, _T("E&xit\tAlt-X"), _T("Quit menu sample"));
wxMenu *menubarMenu = new wxMenu;
#include "wx/accel.h"
#endif // wxUSE_ACCEL
+#include "wx/stockitem.h"
#include "wx/gtk/private.h"
#include <gdk/gdkkeysyms.h>
{
menuItem = gtk_separator_menu_item_new();
}
- else if (mitem->GetBitmap().Ok())
+ else if ( mitem->GetBitmap().Ok() ||
+ (mitem->GetKind() == wxITEM_NORMAL &&
+ wxIsStockID(mitem->GetId())) )
{
text = mitem->GetText();
- const wxBitmap *bitmap = &mitem->GetBitmap();
+ wxBitmap bitmap(mitem->GetBitmap());
menuItem = gtk_image_menu_item_new_with_mnemonic( wxGTK_CONV_SYS( text ) );
GtkWidget *image;
- if (bitmap->HasPixbuf())
+ if ( !bitmap.Ok() )
{
- image = gtk_image_new_from_pixbuf(bitmap->GetPixbuf());
+ // use stock bitmap for this item if available on the assumption
+ // that it never hurts to follow GTK+ conventions more closely
+ const char *stock = wxGetStockGtkID(mitem->GetId());
+ image = stock ? gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU)
+ : NULL;
}
- else
+ else // we have a custom bitmap
{
- GdkPixmap *gdk_pixmap = bitmap->GetPixmap();
- GdkBitmap *gdk_bitmap = bitmap->GetMask() ?
- bitmap->GetMask()->GetBitmap() :
- (GdkBitmap*) NULL;
- image = gtk_image_new_from_pixmap( gdk_pixmap, gdk_bitmap );
+ wxASSERT_MSG( mitem->GetKind() == wxITEM_NORMAL,
+ _T("only normal menu items can have bitmaps") );
+
+ if ( bitmap.HasPixbuf() )
+ {
+ image = gtk_image_new_from_pixbuf(bitmap.GetPixbuf());
+ }
+ else
+ {
+ GdkPixmap *gdk_pixmap = bitmap.GetPixmap();
+ GdkBitmap *gdk_bitmap = bitmap.GetMask() ?
+ bitmap.GetMask()->GetBitmap() :
+ (GdkBitmap*) NULL;
+ image = gtk_image_new_from_pixmap( gdk_pixmap, gdk_bitmap );
+ }
}
- gtk_widget_show(image);
+ if ( image )
+ {
+ gtk_widget_show(image);
- gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(menuItem), image );
+ gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(menuItem), image );
+ }
m_prevRadio = NULL;
}
else // a normal item
{
// text has "_" instead of "&" after mitem->SetText() so don't use it
- text = mitem->GetText() ;
+ text = mitem->GetText() ;
switch ( mitem->GetKind() )
{