X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2b5f62a0b2db198609b45dec622a018dae37008e..4a6e4a46a356e9abf0760e2d481bbec321cc3adf:/src/motif/menu.cpp diff --git a/src/motif/menu.cpp b/src/motif/menu.cpp index b7e9194893..06ad86e72d 100644 --- a/src/motif/menu.cpp +++ b/src/motif/menu.cpp @@ -247,8 +247,6 @@ void wxMenuBar::SetLabelTop(size_t pos, const wxString& label) wxString wxMenuBar::GetLabelTop(size_t pos) const { - wxString str; - wxMenu *menu = GetMenu(pos); if ( menu ) { @@ -260,17 +258,11 @@ wxString wxMenuBar::GetLabelTop(size_t pos) const XmNlabelString, &text, NULL); - char *s; - if ( XmStringGetLtoR(text, XmSTRING_DEFAULT_CHARSET, &s) ) - { - str = s; - - XtFree(s); - } + return wxXmStringToString( text ); } } - return str; + return wxEmptyString; } bool wxMenuBar::Append(wxMenu * menu, const wxString& title) @@ -335,12 +327,12 @@ int wxMenuBar::FindMenuItem (const wxString& menuString, const wxString& itemStr { char buf1[200]; char buf2[200]; - wxStripMenuCodes ((char *)(const char *)menuString, buf1); + wxStripMenuCodes (wxConstCast(menuString.c_str(), char), buf1); size_t menuCount = GetMenuCount(); for (size_t i = 0; i < menuCount; i++) { - wxStripMenuCodes ((char *)(const char *)m_titles[i], buf2); + wxStripMenuCodes (wxConstCast(m_titles[i].c_str(), char), buf2); if (strcmp (buf1, buf2) == 0) return m_menus[i]->FindItem (itemString); } @@ -440,28 +432,20 @@ bool wxMenuBar::DestroyMenuBar() return TRUE; } -//// Motif-specific -static XtWorkProcId WorkProcMenuId; - -/* Since PopupMenu under Motif stills grab right mouse button events -* after it was closed, we need to delete the associated widgets to -* allow next PopUpMenu to appear... -*/ - -int PostDeletionOfMenu( XtPointer* clientData ) +// Since PopupMenu under Motif stills grab right mouse button events +// after it was closed, we need to delete the associated widgets to +// allow next PopUpMenu to appear... +void wxMenu::DestroyWidgetAndDetach() { - XtRemoveWorkProc(WorkProcMenuId); - wxMenu *menu = (wxMenu *)clientData; - - if (menu->GetMainWidget()) + if (GetMainWidget()) { - wxMenu *menuParent = menu->GetParent(); + wxMenu *menuParent = GetParent(); if ( menuParent ) { wxMenuItemList::Node *node = menuParent->GetMenuItems().GetFirst(); while ( node ) { - if ( node->GetData()->GetSubMenu() == menu ) + if ( node->GetData()->GetSubMenu() == this ) { menuParent->GetMenuItems().DeleteNode(node); @@ -472,33 +456,11 @@ int PostDeletionOfMenu( XtPointer* clientData ) } } - menu->DestroyMenu(TRUE); + DestroyMenu(TRUE); } // Mark as no longer popped up - menu->m_menuId = -1; - - return TRUE; -} - -void -wxMenuPopdownCallback(Widget WXUNUSED(w), XtPointer clientData, - XtPointer WXUNUSED(ptr)) -{ - wxMenu *menu = (wxMenu *)clientData; - - // Added by JOREL Jean-Charles - /* Since Callbacks of MenuItems are not yet processed, we put a - * background job which will be done when system will be idle. - * What awful hack!! :( - */ - - WorkProcMenuId = XtAppAddWorkProc( - (XtAppContext) wxTheApp->GetAppContext(), - (XtWorkProc) PostDeletionOfMenu, - (XtPointer) menu ); - // Apparently not found in Motif headers - // XtVaSetValues( w, XmNpopupEnabled, XmPOPUP_DISABLED, NULL ); + m_menuId = -1; } /* @@ -518,10 +480,12 @@ WXWidget wxMenu::CreateMenu (wxMenuBar * menuBar, WXWidget parent, wxMenu * topM if (!pullDown) { menu = XmCreatePopupMenu ((Widget) parent, "popup", args, 2); +#if 0 XtAddCallback(menu, XmNunmapCallback, (XtCallbackProc)wxMenuPopdownCallback, (XtPointer)this); +#endif } else { @@ -680,21 +644,21 @@ void wxMenu::SetForegroundColour(const wxColour& col) void wxMenu::ChangeFont(bool keepOriginalSize) { - // lesstif 0.87 hangs when setting XmNfontList -#ifndef LESSTIF_VERSION + // Lesstif 0.87 hangs here, but 0.93 does not +#if !wxCHECK_LESSTIF() || wxCHECK_LESSTIF_VERSION( 0, 93 ) if (!m_font.Ok() || !m_menuWidget) return; - XmFontList fontList = (XmFontList) m_font.GetFontList(1.0, XtDisplay((Widget) m_menuWidget)); + WXFontType fontType = m_font.GetFontType(XtDisplay((Widget) m_menuWidget)); XtVaSetValues ((Widget) m_menuWidget, - XmNfontList, fontList, - NULL); + wxFont::GetFontTag(), fontType, + NULL); if (m_buttonWidget) { XtVaSetValues ((Widget) m_buttonWidget, - XmNfontList, fontList, - NULL); + wxFont::GetFontTag(), fontType, + NULL); } for ( wxMenuItemList::Node *node = GetMenuItems().GetFirst(); @@ -705,8 +669,8 @@ void wxMenu::ChangeFont(bool keepOriginalSize) if (m_menuWidget && item->GetButtonWidget() && m_font.Ok()) { XtVaSetValues ((Widget) item->GetButtonWidget(), - XmNfontList, fontList, - NULL); + wxFont::GetFontTag(), fontType, + NULL); } if (item->GetSubMenu()) item->GetSubMenu()->ChangeFont(keepOriginalSize);