wxMenuItem::wxMenuItem(wxMenu *pParentMenu, int id, const wxString& t, const wxString& strHelp, wxItemKind kind, wxMenu *pSubMenu) :wxMenuItemBase(pParentMenu, id, t, strHelp, kind, pSubMenu) { wxASSERT_MSG( id != 0 || pSubMenu != NULL , wxT("A MenuItem ID of Zero does not work under Mac") ) ; // In other languages there is no difference in naming the Exit/Quit menu item between MacOS and Windows guidelines // therefore these item must not be translated if (pParentMenu != NULL && !pParentMenu->GetNoEventsMode()) if ( wxStripMenuCodes(m_text).Upper() == wxT("EXIT") ) m_text = wxT("Quit\tCtrl+Q") ; m_radioGroup.start = -1; m_isRadioGroupStart = false; wxString text = wxStripMenuCodes(m_text, (pParentMenu != NULL && pParentMenu->GetNoEventsMode()) ? wxStrip_Accel : wxStrip_All); if (text.IsEmpty() && !IsSeparator()) { wxASSERT_MSG(wxIsStockID(GetId()), wxT("A non-stock menu item with an empty label?")); text = wxGetStockLabel(GetId(), wxSTOCK_WITH_ACCELERATOR|wxSTOCK_WITH_MNEMONIC); } wxAcceleratorEntry *entry = wxAcceleratorEntry::Create( m_text ) ; // use accessors for ID and Kind because they might have been changed in the base constructor m_peer = wxMenuItemImpl::Create( this, pParentMenu, GetId(), text, entry, strHelp, GetKind(), pSubMenu ); delete entry; }
// // Find the itemString in menuString, and return the item id or wxNOT_FOUND // int wxMenuBar::FindMenuItem( const wxString& rMenuString , const wxString& rItemString ) const { wxString sMenuLabel = wxStripMenuCodes(rMenuString); size_t nCount = GetMenuCount(), i; wxMenuList::const_iterator it; #if defined(__INTEL_COMPILER) && 1 // VDM auto patch # pragma ivdep # pragma swp # pragma unroll #endif #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for (i = 0, it = m_menus.begin(); i < nCount; i++, it++) { wxString sTitle = wxStripMenuCodes(m_titles[i]); if (rMenuString == sTitle) return (*it)->FindItem(rItemString); } return wxNOT_FOUND; } // end of wxMenuBar::FindMenuItem
void wxGISToolBar::AddCommand(wxGISCommand* pCmd) { switch(pCmd->GetKind()) { case enumGISCommandMenu: return; case enumGISCommandSeparator: case enumGISCommandCheck: case enumGISCommandRadio: case enumGISCommandNormal: { wxBitmap Bitmap = pCmd->GetBitmap(); if(!Bitmap.IsOk()) Bitmap = wxBitmap(tool_16_xpm); AddTool(pCmd->GetID(), wxStripMenuCodes(pCmd->GetCaption()), Bitmap, wxBitmap(), (wxItemKind)pCmd->GetKind(), pCmd->GetTooltip(), pCmd->GetMessage(), NULL); } break; case enumGISCommandDropDown: { wxBitmap Bitmap = pCmd->GetBitmap(); if(!Bitmap.IsOk()) Bitmap = wxBitmap(tool_16_xpm); AddTool(pCmd->GetID(), wxStripMenuCodes(pCmd->GetCaption()), Bitmap, wxBitmap(), (wxItemKind)enumGISCommandNormal, pCmd->GetTooltip(), pCmd->GetMessage(), NULL); SetToolDropDown(pCmd->GetID(), true); } break; case enumGISCommandControl: { IToolControl* pToolCtrl = dynamic_cast<IToolControl*>(pCmd); if(pToolCtrl) { IToolBarControl* pToolBarControl = pToolCtrl->GetControl(); wxControl* pControl = dynamic_cast<wxControl*>(pToolBarControl); if(pControl) { if(pToolCtrl->HasToolLabel()) { wxString sToolLabel = pToolCtrl->GetToolLabel(); AddLabel(wxID_ANY, sToolLabel, sToolLabel.Len() * 5); } pControl->Reparent(this); AddControl(pControl); //add ctrl to remove map m_RemControlMap[m_CommandArray.size()] = pToolBarControl; } else return; } else return; } break; default: return; } wxGISCommandBar::AddCommand(pCmd); Realize(); }
// Find the menu menuString, item itemString, and return the item id. // Returns -1 if none found. int wxMenuBar::FindMenuItem(const wxString& menuString, const wxString& itemString) const { const wxString stripped = wxStripMenuCodes(menuString); size_t menuCount = GetMenuCount(); for (size_t i = 0; i < menuCount; i++) { if ( wxStripMenuCodes(m_titles[i]) == stripped ) return m_menus.Item(i)->GetData()->FindItem (itemString); } return wxNOT_FOUND; }
// Find the itemString in menuString, and return the item id or wxNOT_FOUND int wxMenuBar::FindMenuItem(const wxString& menuString, const wxString& itemString) const { wxString menuLabel = wxStripMenuCodes(menuString); size_t count = GetMenuCount(); for ( size_t i = 0; i < count; i++ ) { wxString title = wxStripMenuCodes(m_titles[i]); if ( menuLabel == title ) return _wxMenuAt(m_menus, i)->FindItem(itemString); } return wxNOT_FOUND; }
int wxMenuBar::FindMenu(const wxString& title) { wxString menuTitle = wxStripMenuCodes(title); size_t count = GetMenuCount(); for ( size_t i = 0; i < count; i++ ) { wxString title = wxStripMenuCodes(m_titles[i]); if ( menuTitle == title ) return i; } return wxNOT_FOUND; }
bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], int majorDim, long style, const wxValidator& val, const wxString& name) { if ( !wxControl::Create(parent, id, pos, size, style, val, name) ) return false; int i; m_noItems = n; m_noRowsOrCols = majorDim; m_radioButtonCycle = NULL; if (majorDim==0) m_majorDim = n ; else m_majorDim = majorDim ; Rect bounds ; Str255 title ; MacPreControlCreate( parent , id , wxStripMenuCodes(label) , pos , size ,style, val , name , &bounds , title ) ; m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, kControlGroupBoxTextTitleProc , (long) this ) ; for (i = 0; i < n; i++) { wxRadioButton *radBtn = new wxRadioButton ( this, wxID_ANY, wxStripMenuCodes(choices[i]), wxPoint(5,20*i+10), wxDefaultSize, i == 0 ? wxRB_GROUP : 0 ); if ( i == 0 ) m_radioButtonCycle = radBtn ; // m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle); } SetSelection(0); MacPostControlCreate() ; return true; }
void wxMenuItem::SetItemLabel(const wxString& label) { char mnem = wxFindMnemonic (label); wxString label2 = wxStripMenuCodes(label); m_text = label; if (m_buttonWidget) { wxXmString label_str(label2); XtVaSetValues ((Widget) m_buttonWidget, XmNlabelString, label_str(), NULL); if (mnem != 0) XtVaSetValues ((Widget) m_buttonWidget, XmNmnemonic, mnem, NULL); char *accel = wxFindAccelerator (label2); if (accel) XtVaSetValues ((Widget) m_buttonWidget, XmNaccelerator, accel, NULL); XmString accel_str = wxFindAcceleratorText (label2); if (accel_str) { XtVaSetValues ((Widget) m_buttonWidget, XmNacceleratorText, accel_str, NULL); XmStringFree (accel_str); } } }
wxSize wxRadioBox::GetMaxButtonSize() const { // calculate the max button size int widthMax = 0, heightMax = 0; const int count = GetCount(); for ( int i = 0 ; i < count; i++ ) { int width, height; if ( m_radioWidth[i] < 0 ) { GetTextExtent(wxStripMenuCodes(wxGetWindowText((*m_radioButtons)[i])), &width, &height); // adjust the size to take into account the radio box itself // FIXME this is totally bogus! width += RADIO_SIZE; height *= 3; height /= 2; } else { width = m_radioWidth[i]; height = m_radioHeight[i]; } if ( widthMax < width ) widthMax = width; if ( heightMax < height ) heightMax = height; } return wxSize(widthMax, heightMax); }
wxString wxMenuBar::GetLabelTop(size_t pos) const { wxCHECK_MSG( pos < GetMenuCount(), wxEmptyString, wxT("invalid menu index in wxMenuBar::GetLabelTop") ); return wxStripMenuCodes(m_titles[pos]); }
bool wxStaticText::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { m_macIsUserPane = FALSE ; m_label = wxStripMenuCodes(label) ; if ( !wxControl::Create( parent, id, pos, size, style, wxDefaultValidator , name ) ) { return false; } Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; wxMacCFStringHolder str(m_label,m_font.GetEncoding() ) ; m_peer = new wxMacControl(this) ; verify_noerr(CreateStaticTextControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, str , NULL , m_peer->GetControlRefAddr() ) ) ; MacPostControlCreate(pos,size) ; return true; }
wxSize wxToggleButton::DoGetBestSize() const { wxString label = wxGetWindowText(GetHWND()); int wBtn; GetTextExtent(wxStripMenuCodes(label), &wBtn, NULL); int wChar, hChar; wxGetCharSize(GetHWND(), &wChar, &hChar, GetFont()); // add a margin - the button is wider than just its label wBtn += 3*wChar; // the button height is proportional to the height of the font used int hBtn = BUTTON_HEIGHT_FROM_CHAR_HEIGHT(hChar); #if wxUSE_BUTTON wxSize sz = wxButton::GetDefaultSize(); if (wBtn > sz.x) sz.x = wBtn; if (hBtn > sz.y) sz.y = hBtn; #else wxSize sz(wBtn, hBtn); #endif CacheBestSize(sz); return sz; }
bool wxOwnerDrawnBase::OnMeasureItem(size_t *width, size_t *height) { if ( IsOwnerDrawn() ) { wxMemoryDC dc; wxFont font; GetFontToUse(font); dc.SetFont(font); // item name/text without mnemonics wxString name = wxStripMenuCodes(GetName(), wxStrip_Mnemonics); wxCoord w, h; dc.GetTextExtent(name, &w, &h); *width = w + m_margin; *height = h; } else { *width = 0; *height = 0; } return true; }
bool wxMenuBar::Append(wxMenu *menu, const wxString& title) { WXHMENU submenu = menu ? menu->GetHMenu() : 0; wxCHECK_MSG( submenu, false, wxT("can't append invalid menu to menubar") ); if ( !wxMenuBarBase::Append(menu, title) ) return false; menu->wxMenuBase::SetTitle(title); #if defined(WINCE_WITHOUT_COMMANDBAR) if (IsAttached()) #else if (GetHmenu()) #endif { #if defined(WINCE_WITHOUT_COMMANDBAR) if (!GetToolBar()) return false; TBBUTTON tbButton; memset(&tbButton, 0, sizeof(TBBUTTON)); tbButton.iBitmap = I_IMAGENONE; tbButton.fsState = TBSTATE_ENABLED; tbButton.fsStyle = TBSTYLE_DROPDOWN | TBSTYLE_NO_DROPDOWN_ARROW | TBSTYLE_AUTOSIZE; size_t pos = GetMenuCount(); HMENU hPopupMenu = (HMENU) menu->GetHMenu() ; tbButton.dwData = (DWORD)hPopupMenu; wxString label = wxStripMenuCodes(title); tbButton.iString = (int) label.wx_str(); tbButton.idCommand = NewControlId(); if (!::SendMessage((HWND) GetToolBar()->GetHWND(), TB_INSERTBUTTON, pos, (LPARAM)&tbButton)) { wxLogLastError(wxT("TB_INSERTBUTTON")); return false; } #else if ( !::AppendMenu(GetHmenu(), MF_POPUP | MF_STRING, (UINT_PTR)submenu, title.wx_str()) ) { wxLogLastError(wxT("AppendMenu")); } #endif #if wxUSE_ACCEL if ( menu->HasAccels() ) { // need to rebuild accelerator table RebuildAccelTable(); } #endif // wxUSE_ACCEL if (IsAttached()) Refresh(); } return true; }
// // Find the itemString in menuString, and return the item id or wxNOT_FOUND // int wxMenuBar::FindMenuItem( const wxString& rMenuString , const wxString& rItemString ) const { wxString sMenuLabel = wxStripMenuCodes(rMenuString); size_t nCount = GetMenuCount(), i; wxMenuList::const_iterator it; for (i = 0, it = m_menus.begin(); i < nCount; i++, it++) { wxString sTitle = wxStripMenuCodes(m_titles[i]); if (rMenuString == sTitle) return (*it)->FindItem(rItemString); } return wxNOT_FOUND; } // end of wxMenuBar::FindMenuItem
bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], int majorDim, long style, const wxValidator& val, const wxString& name) { m_macIsUserPane = false ; if ( !wxControl::Create(parent, id, pos, size, style, val, name) ) return false; int i; m_noItems = n; m_noRowsOrCols = majorDim; m_radioButtonCycle = NULL; if (majorDim==0) m_majorDim = n ; else m_majorDim = majorDim ; m_label = label ; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; if( bounds.right <= bounds.left ) bounds.right = bounds.left + 100 ; if ( bounds.bottom <= bounds.top ) bounds.bottom = bounds.top + 100 ; m_peer = new wxMacControl(this) ; verify_noerr(CreateGroupBoxControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, CFSTR("") , true /*primary*/ , m_peer->GetControlRefAddr() ) ) ; for (i = 0; i < n; i++) { wxRadioButton *radBtn = new wxRadioButton ( this, wxID_ANY, wxStripMenuCodes(choices[i]), wxPoint(5,20*i+10), wxDefaultSize, i == 0 ? wxRB_GROUP : 0 ); if ( i == 0 ) m_radioButtonCycle = radBtn ; // m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle); } SetSelection(0); MacPostControlCreate(pos,size) ; return true; }
bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title) { // Find out which MSW item before which we'll be inserting before // wxMenuBarBase::Insert is called and GetMenu(pos) is the new menu. // If IsAttached() is false this won't be used anyway int mswpos = (!IsAttached() || (pos == m_menus.GetCount())) ? -1 // append the menu : MSWPositionForWxMenu(GetMenu(pos),pos); if ( !wxMenuBarBase::Insert(pos, menu, title) ) return false; m_titles.Insert(title, pos); if ( IsAttached() ) { #if defined(WINCE_WITHOUT_COMMANDAR) if (!GetToolBar()) return false; TBBUTTON tbButton; memset(&tbButton, 0, sizeof(TBBUTTON)); tbButton.iBitmap = I_IMAGENONE; tbButton.fsState = TBSTATE_ENABLED; tbButton.fsStyle = TBSTYLE_DROPDOWN | TBSTYLE_NO_DROPDOWN_ARROW | TBSTYLE_AUTOSIZE; HMENU hPopupMenu = (HMENU) menu->GetHMenu() ; tbButton.dwData = (DWORD)hPopupMenu; wxString label = wxStripMenuCodes(title); tbButton.iString = (int) label.c_str(); tbButton.idCommand = NewControlId(); if (!::SendMessage((HWND) GetToolBar()->GetHWND(), TB_INSERTBUTTON, pos, (LPARAM)&tbButton)) { wxLogLastError(wxT("TB_INSERTBUTTON")); return false; } #else if ( !::InsertMenu(GetHmenu(), mswpos, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT)GetHmenuOf(menu), title) ) { wxLogLastError(wxT("InsertMenu")); } #endif #if wxUSE_ACCEL if ( menu->HasAccels() ) { // need to rebuild accell table RebuildAccelTable(); } #endif // wxUSE_ACCEL Refresh(); } return true; }
MenuRef UMANewMenu( SInt16 id , const wxString& title , wxFontEncoding encoding ) { wxString str = wxStripMenuCodes( title ) ; MenuRef menu ; CreateNewMenu( id , 0 , &menu ) ; SetMenuTitleWithCFString( menu , wxCFStringRef(str , encoding ) ) ; return menu ; }
void wxControl::SetLabel(const wxString& title) { m_label = wxStripMenuCodes(title) ; if ( m_macControl ) { UMASetControlTitle( (ControlHandle) m_macControl , m_label , m_font.GetEncoding() ) ; } Refresh() ; }
bool wxNotebook::SetPageText(size_t nPage, const wxString& strText) { wxCHECK_MSG( IS_VALID_PAGE(nPage), false, wxT("SetPageText: invalid notebook page") ); wxNotebookPage *page = m_pages[nPage]; page->SetLabel(wxStripMenuCodes(strText)); MacSetupTabs(); return true; }
// Create menubar bool wxMenuBar::CreateMenuBar(wxFrame* parent) { m_parent = parent; // bleach... override it! PreCreation(); m_parent = NULL; if (m_mainWidget) { XtVaSetValues((Widget) parent->GetMainWidget(), XmNmenuBar, (Widget) m_mainWidget, NULL); /* if (!XtIsManaged((Widget) m_mainWidget)) XtManageChild((Widget) m_mainWidget); */ XtMapWidget((Widget) m_mainWidget); return true; } Widget menuBarW = XmCreateMenuBar ((Widget) parent->GetMainWidget(), wxMOTIF_STR("MenuBar"), NULL, 0); m_mainWidget = (WXWidget) menuBarW; size_t menuCount = GetMenuCount(); for (size_t i = 0; i < menuCount; i++) { wxMenu *menu = GetMenu(i); wxString title(m_titles[i]); menu->SetButtonWidget(menu->CreateMenu (this, menuBarW, menu, i, title, true)); if (strcmp (wxStripMenuCodes(title), "Help") == 0) XtVaSetValues ((Widget) menuBarW, XmNmenuHelpWidget, (Widget) menu->GetButtonWidget(), NULL); // tear off menu support #if (XmVersion >= 1002) if ( menu->IsTearOff() ) { XtVaSetValues(GetWidget(menu), XmNtearOffModel, XmTEAR_OFF_ENABLED, NULL); Widget tearOff = XmGetTearOffControl(GetWidget(menu)); wxDoChangeForegroundColour((Widget) tearOff, m_foregroundColour); wxDoChangeBackgroundColour((Widget) tearOff, m_backgroundColour, true); } #endif } PostCreation(); XtVaSetValues((Widget) parent->GetMainWidget(), XmNmenuBar, (Widget) m_mainWidget, NULL); XtRealizeWidget ((Widget) menuBarW); XtManageChild ((Widget) menuBarW); SetMenuBarFrame(parent); return true; }
void UMASetMenuItemText( MenuRef menu, MenuItemIndex item, const wxString& title , wxFontEncoding encoding) { wxString str = wxStripMenuCodes( title ) ; #if TARGET_CARBON SetMenuItemTextWithCFString( menu , item , wxMacCFStringHolder(str , encoding) ) ; #else Str255 ptitle ; wxMacStringToPascal( str , ptitle ) ; SetMenuItemText( menu , item , ptitle ) ; #endif }
// same as AddPage() but does it at given position bool wxNotebook::InsertPage(size_t nPage, wxNotebookPage *pPage, const wxString& strText, bool bSelect, int imageId ) { if ( !wxNotebookBase::InsertPage( nPage, pPage, strText, bSelect, imageId ) ) return false; wxASSERT_MSG( pPage->GetParent() == this, wxT("notebook pages must have notebook as parent") ); // don't show pages by default (we'll need to adjust their size first) pPage->Show( false ) ; pPage->SetLabel( wxStripMenuCodes(strText) ); m_images.Insert( imageId, nPage ); MacSetupTabs(); wxRect rect = GetPageRect() ; pPage->SetSize( rect ); if ( pPage->GetAutoLayout() ) pPage->Layout(); // now deal with the selection // --------------------------- // if the inserted page is before the selected one, we must update the // index of the selected page if ( int(nPage) <= m_nSelection ) { m_nSelection++; // while this still is the same page showing, we need to update the tabs m_peer->SetValue( m_nSelection + 1 ) ; } // some page should be selected: either this one or the first one if there // is still no selection int selNew = -1; if ( bSelect ) selNew = nPage; else if ( m_nSelection == -1 ) selNew = 0; if ( selNew != -1 ) SetSelection( selNew ); InvalidateBestSize(); return true; }
void MenuTestCase::TranslatedMnemonics() { // Check that appended mnemonics are correctly stripped; // see https://trac.wxwidgets.org/ticket/16736 wxTranslations trans; trans.SetLanguage(wxLANGUAGE_JAPANESE); wxFileTranslationsLoader::AddCatalogLookupPathPrefix("./intl"); CPPUNIT_ASSERT( trans.AddCatalog("internat") ); // Check the translation is being used: CPPUNIT_ASSERT( wxString("&File") != GetTranslatedString(trans, "&File") ); wxString filemenu = m_frame->GetMenuBar()->GetMenuLabel(0); CPPUNIT_ASSERT_EQUAL ( wxStripMenuCodes(GetTranslatedString(trans, "&File")), wxStripMenuCodes(GetTranslatedString(trans, filemenu)) ); // Test strings that have shortcuts. Duplicate non-mnemonic translations // exist for both "Edit" and "View", for ease of comparison CPPUNIT_ASSERT_EQUAL ( GetTranslatedString(trans, "Edit"), wxStripMenuCodes(GetTranslatedString(trans, "E&dit\tCtrl+E")) ); // "Vie&w" also has a space before the (&W) CPPUNIT_ASSERT_EQUAL ( GetTranslatedString(trans, "View"), wxStripMenuCodes(GetTranslatedString(trans, "Vie&w\tCtrl+V")) ); // Test a 'normal' mnemonic too: the translation is "Preten&d" CPPUNIT_ASSERT_EQUAL ( "Pretend", wxStripMenuCodes(GetTranslatedString(trans, "B&ogus")) ); }
// Find the menu menuString, item itemString, and return the item id. // Returns -1 if none found. int wxMenuBar::FindMenuItem(const wxString& menuString, const wxString& itemString) const { const wxString stripped = wxStripMenuCodes(menuString); size_t menuCount = GetMenuCount(); #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for (size_t i = 0; i < menuCount; i++) { if ( wxStripMenuCodes(m_titles[i]) == stripped ) return m_menus.Item(i)->GetData()->FindItem (itemString); } return wxNOT_FOUND; }
void MacroCommandDialog::PopulateOrExchange(ShuttleGui &S) { S.StartVerticalLay(true); { S.StartMultiColumn(4, wxEXPAND); { S.SetStretchyCol(1); mCommand = S.AddTextBox(_("&Command"), wxT(""), 20); mCommand->SetEditable(false); mEditParams = S.Id(EditParamsButtonID).AddButton(_("&Edit Parameters")); mEditParams->Enable(false); // disable button as box is empty mUsePreset = S.Id(UsePresetButtonID).AddButton(_("&Use Preset")); mUsePreset->Enable(false); // disable button as box is empty } S.EndMultiColumn(); S.StartMultiColumn(2, wxEXPAND); { S.SetStretchyCol(1); mParameters = S.AddTextBox(_("&Parameters"), wxT(""), 0); mParameters->SetEditable(false); wxString prompt{_("&Details")}; S.Prop(0).AddPrompt(prompt); mDetails = S.AddTextWindow( wxT("")); mDetails->SetEditable(false); mDetails->SetName(wxStripMenuCodes(prompt)); } S.EndMultiColumn(); S.Prop(10).StartStatic(_("Choose command"), true); { S.SetStyle(wxSUNKEN_BORDER | wxLC_LIST | wxLC_SINGLE_SEL); mChoices = S.Id(CommandsListID).AddListControl(); } S.EndStatic(); } S.EndVerticalLay(); S.AddStandardButtons( eOkButton | eCancelButton | eHelpButton); PopulateCommandList(); if (mChoices->GetItemCount() > 0) { // set first item to be selected (and the focus when the // list first becomes the focus) mChoices->SetItemState(0, wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED, wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED); } SetMinSize(wxSize(780, 560)); Fit(); Center(); }
void wxMenuBar::GtkAppend(wxMenu* menu, const wxString& title, int pos) { menu->SetLayoutDirection(GetLayoutDirection()); #if wxUSE_LIBHILDON || wxUSE_LIBHILDON2 // if the menu has only one item, append it directly to the top level menu // instead of inserting a useless submenu if ( menu->GetMenuItemCount() == 1 ) { wxMenuItem * const item = menu->FindItemByPosition(0); // remove both mnemonics and accelerator: neither is useful under Maemo const wxString str(wxStripMenuCodes(item->GetItemLabel())); if ( item->IsSubMenu() ) { GtkAppend(item->GetSubMenu(), str, pos); return; } menu->m_owner = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( str ) ); g_signal_connect(menu->m_owner, "activate", G_CALLBACK(menuitem_activate), item); item->SetMenuItem(menu->m_owner); } else #endif // wxUSE_LIBHILDON || wxUSE_LIBHILDON2 /!wxUSE_LIBHILDON && !wxUSE_LIBHILDON2 { const wxString str(wxConvertMnemonicsToGTK(title)); // This doesn't have much effect right now. menu->SetTitle( str ); // The "m_owner" is the "menu item" menu->m_owner = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( str ) ); gtk_menu_item_set_submenu( GTK_MENU_ITEM(menu->m_owner), menu->m_menu ); } g_object_ref(menu->m_owner); gtk_widget_show( menu->m_owner ); if (pos == -1) gtk_menu_shell_append( GTK_MENU_SHELL(m_menubar), menu->m_owner ); else gtk_menu_shell_insert( GTK_MENU_SHELL(m_menubar), menu->m_owner, pos ); if ( m_menuBarFrame ) AttachToFrame( menu, m_menuBarFrame ); }
void wxMenuBar::SetLabelTop(size_t pos, const wxString& label) { wxCHECK_RET( pos < GetMenuCount(), wxT("invalid menu index") ); m_titles[pos]=wxStripMenuCodes(label); if ( !IsAttached() ) { return; } // Regenerate the menu resource Refresh(); }
MenuRef UMANewMenu( SInt16 id , const wxString& title , wxFontEncoding encoding ) { wxString str = wxStripMenuCodes( title ) ; MenuRef menu ; #if TARGET_CARBON CreateNewMenu( id , 0 , &menu ) ; SetMenuTitleWithCFString( menu , wxMacCFStringHolder(str , encoding ) ) ; #else Str255 ptitle ; wxMacStringToPascal( str , ptitle ) ; menu = ::NewMenu( id , ptitle ) ; #endif return menu ; }
bool wxMenuBar::Append(wxMenu *menu, const wxString& title) { if ( !wxMenuBarBase::Append(menu, title) ) return false; m_titles.Add(wxStripMenuCodes(title)); if(IsAttached()) { // Regenerate the menu resource Refresh(); } return true; }