-
- // cache some data used later
- wxString text = mitem->wxMenuItemBase::GetItemLabel();
- int id = mitem->GetId();
- bool isstock = wxIsStockID(id);
- const char *stockid = NULL;
- if (isstock)
- stockid = wxGetStockGtkID(mitem->GetId());
-
- // stock menu items can have an empty label
- if (text.IsEmpty() && !mitem->IsSeparator())
- {
- wxASSERT_MSG(isstock, wxT("A non-stock menu item with an empty label?"));
- text = wxGetStockLabel(id);
-
- // need & => _ conversion
- text = wxMenuItem::GTKProcessMenuItemLabel(text, NULL);
- }
-
- if ( mitem->IsSeparator() )
- {
- menuItem = gtk_separator_menu_item_new();
- m_prevRadio = NULL;
- }
- else if ( mitem->GetBitmap().Ok() ||
- (mitem->GetKind() == wxITEM_NORMAL && isstock) )
- {
- wxBitmap bitmap(mitem->GetBitmap());
-
- menuItem = gtk_image_menu_item_new_with_mnemonic( wxGTK_CONV_SYS( text ) );
-
- GtkWidget *image;
- if ( !bitmap.Ok() )
- {
- // use stock bitmap for this item if available on the assumption
- // that it never hurts to follow GTK+ conventions more closely
- image = stockid ? gtk_image_new_from_stock(stockid, GTK_ICON_SIZE_MENU)
- : NULL;
- }
- else // we have a custom 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 );
- }
- }
-
- if ( image )
- {
- gtk_widget_show(image);
-
- gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(menuItem), image );
- }
-
- m_prevRadio = NULL;
- }
- else // a normal item