void ContainerItemPopupMenu::Update(ContainerItemButton* btn) { // Clear the menu of all items while(GetMenuItemCount() > 0) { wxMenuItem* m_item = FindItemByPosition(0); // If you add a submenu, this won't delete it. Delete(m_item); } wxMenuItem* addItem = nullptr; if(btn->edit_item) { Append( CONTAINER_POPUP_MENU_EDIT, wxT("&Edit Item"), wxT("Open the properties menu for this item")); addItem = Append( CONTAINER_POPUP_MENU_ADD, wxT("&Add Item"), wxT("Add a newd item to the container")); Append( CONTAINER_POPUP_MENU_REMOVE, wxT("&Remove Item"), wxT("Remove this item from the container")); } else { addItem = Append( CONTAINER_POPUP_MENU_ADD, wxT("&Add Item"), wxT("Add a newd item to the container")); } Container* parentContainer = btn->getParentContainer(); if(parentContainer->getVolume() <= (int)parentContainer->getVector().size()) addItem->Enable(false); }
void wxGISMenu::RemoveCommand(size_t nIndex) { if(m_CommandArray[nIndex]->GetKind() == enumGISCommandSeparator) Delete(FindItemByPosition(nIndex)); else Destroy(m_CommandArray[nIndex]->GetID()); wxGISCommandBar::RemoveCommand(nIndex); }
void CONTEXT_MENU::Clear() { m_titleSet = false; for( int i = GetMenuItemCount() - 1; i >= 0; --i ) Destroy( FindItemByPosition( i ) ); m_toolActions.clear(); m_submenus.clear(); m_parent = NULL; assert( GetMenuItemCount() == 0 ); }
void CONTEXT_MENU::SetTitle( const wxString& aTitle ) { // TODO handle an empty string (remove title and separator) // Unfortunately wxMenu::SetTitle() does nothing.. (at least wxGTK) if( m_titleSet ) { FindItemByPosition( 0 )->SetItemLabel( aTitle ); } else { InsertSeparator( 0 ); Insert( 0, new wxMenuItem( this, wxID_NONE, aTitle, wxEmptyString, wxITEM_NORMAL ) ); m_titleSet = true; } }
wxMenu* wxMenu::MSWGetMenu(WXHMENU hMenu) { // check self if ( GetHMenu() == hMenu ) return this; // recursively query submenus for ( size_t n = 0 ; n < GetMenuItemCount(); ++n ) { wxMenuItem* item = FindItemByPosition(n); wxMenu* submenu = item->GetSubMenu(); if ( submenu ) { submenu = submenu->MSWGetMenu(hMenu); if (submenu) return submenu; } } // unknown hMenu return NULL; }
void wxMenu::GtkAppend(wxMenuItem* mitem, int pos) { GtkWidget *menuItem; switch (mitem->GetKind()) { case wxITEM_SEPARATOR: menuItem = gtk_separator_menu_item_new(); break; case wxITEM_CHECK: menuItem = gtk_check_menu_item_new_with_label(""); break; case wxITEM_RADIO: { // See if we need to create a new radio group for this item or // add it to an existing one. wxMenuItem* radioGroupItem = NULL; const size_t numItems = GetMenuItemCount(); const size_t n = pos == -1 ? numItems - 1 : size_t(pos); if (n != 0) { wxMenuItem* const itemPrev = FindItemByPosition(n - 1); if ( itemPrev->GetKind() == wxITEM_RADIO ) { // Appending an item after an existing radio item puts // it into the same radio group. radioGroupItem = itemPrev; } } if (radioGroupItem == NULL && n != numItems - 1) { wxMenuItem* const itemNext = FindItemByPosition(n + 1); if ( itemNext->GetKind() == wxITEM_RADIO ) { // Inserting an item before an existing radio item // also puts it into the existing radio group. radioGroupItem = itemNext; } } GSList* group = NULL; if ( radioGroupItem ) { group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(radioGroupItem->GetMenuItem()) ); } menuItem = gtk_radio_menu_item_new_with_label(group, ""); } break; default: wxFAIL_MSG("unexpected menu item kind"); // fall through case wxITEM_NORMAL: const wxBitmap& bitmap = mitem->GetBitmap(); const char* stockid; if (bitmap.IsOk()) { // always use pixbuf, because pixmap mask does not // work with disabled images in some themes GtkWidget* image = gtk_image_new_from_pixbuf(bitmap.GetPixbuf()); menuItem = gtk_image_menu_item_new_with_label(""); gtk_widget_show(image); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuItem), image); } else if ((stockid = wxGetStockGtkID(mitem->GetId())) != NULL) // use stock bitmap for this item if available on the assumption // that it never hurts to follow GTK+ conventions more closely menuItem = gtk_image_menu_item_new_from_stock(stockid, NULL); else menuItem = gtk_menu_item_new_with_label(""); break; } mitem->SetMenuItem(menuItem); gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos); gtk_widget_show( menuItem ); if ( !mitem->IsSeparator() ) { mitem->SetGtkLabel(); g_signal_connect (menuItem, "select", G_CALLBACK(menuitem_select), mitem); g_signal_connect (menuItem, "deselect", G_CALLBACK(menuitem_deselect), mitem); if ( mitem->IsSubMenu() && mitem->GetKind() != wxITEM_RADIO && mitem->GetKind() != wxITEM_CHECK ) { gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem), mitem->GetSubMenu()->m_menu ); gtk_widget_show( mitem->GetSubMenu()->m_menu ); } else { g_signal_connect(menuItem, "can_activate_accel", G_CALLBACK(can_activate_accel), this); g_signal_connect (menuItem, "activate", G_CALLBACK(menuitem_activate), mitem); } } }
void wxGISMenu::MoveCommandRight(size_t nIndex) { wxMenuItem *pMenuItem = Remove(FindItemByPosition(nIndex)); Insert(nIndex + 1, pMenuItem); wxGISCommandBar::MoveCommandRight(nIndex); }
void SelectInventoryItem(DWORD x, DWORD y, DWORD dwLocation) { *(DWORD*)&p_D2CLIENT_SelectedInvItem = (DWORD)FindItemByPosition(x, y, dwLocation); }