X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/47d67540a017101b3e46abe9ef0f55914d8de37e..5de5db0eb14aa86b5b177050720deb0f4c210fba:/src/motif/menu.cpp diff --git a/src/motif/menu.cpp b/src/motif/menu.cpp index dcaaa94df4..1eb8e5a3c9 100644 --- a/src/motif/menu.cpp +++ b/src/motif/menu.cpp @@ -74,6 +74,7 @@ wxMenu::wxMenu(const wxString& title, const wxFunction func) m_topLevelMenu = (wxMenu*) NULL; m_ownedByMenuBar = FALSE; m_menuParent = (wxMenu*) NULL; + m_clientData = (void*) NULL; if (m_title != "") { @@ -454,6 +455,7 @@ wxMenuBar::wxMenuBar() m_menus = NULL; m_titles = NULL; m_menuBarFrame = NULL; + m_mainWidget = (WXWidget) NULL; } wxMenuBar::wxMenuBar(int n, wxMenu *menus[], const wxString titles[]) @@ -746,6 +748,74 @@ wxString wxMenuBar::GetHelpString (int id) const return wxString(""); } +// Create menubar +bool wxMenuBar::CreateMenuBar(wxFrame* parent) +{ + if (m_mainWidget) + { + XtVaSetValues((Widget) parent->GetMainWindowWidget(), 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->GetMainWindowWidget(), "MenuBar", NULL, 0); + m_mainWidget = (WXWidget) menuBarW; + + int i; + for (i = 0; i < GetMenuCount(); i++) + { + wxMenu *menu = GetMenu(i); + wxString title(m_titles[i]); + menu->SetButtonWidget(menu->CreateMenu (this, menuBarW, menu, title, TRUE)); + + /* + * COMMENT THIS OUT IF YOU DON'T LIKE A RIGHT-JUSTIFIED HELP MENU + */ + wxStripMenuCodes ((char*) (const char*) title, wxBuffer); + + if (strcmp (wxBuffer, "Help") == 0) + XtVaSetValues ((Widget) menuBarW, XmNmenuHelpWidget, (Widget) menu->GetButtonWidget(), NULL); + } + + XtVaSetValues((Widget) parent->GetMainWindowWidget(), XmNmenuBar, (Widget) m_mainWidget, NULL); + XtRealizeWidget ((Widget) menuBarW); + XtManageChild ((Widget) menuBarW); + SetMenuBarFrame(parent); + + return TRUE; +} + +// Destroy menubar, but keep data structures intact so we can recreate it. +bool wxMenuBar::DestroyMenuBar() +{ + if (!m_mainWidget) + { + SetMenuBarFrame((wxFrame*) NULL); + return FALSE; + } + + XtUnmanageChild ((Widget) m_mainWidget); + XtUnrealizeWidget ((Widget) m_mainWidget); + + int i; + for (i = 0; i < GetMenuCount(); i++) + { + wxMenu *menu = GetMenu(i); + menu->DestroyMenu(TRUE); + + } + XtDestroyWidget((Widget) m_mainWidget); + m_mainWidget = (WXWidget) 0; + + SetMenuBarFrame((wxFrame*) NULL); + + return TRUE; +} + //// Motif-specific extern wxApp *wxTheApp; @@ -762,8 +832,11 @@ int PostDeletionOfMenu( XtPointer* clientData ) wxMenu *menu = (wxMenu *)clientData; if (menu->GetMainWidget()) { - wxList& list = menu->GetParent()->GetItems(); - list.DeleteObject(menu); + if (menu->GetParent()) + { + wxList& list = menu->GetParent()->GetItems(); + list.DeleteObject(menu); + } menu->DestroyMenu(TRUE); } /* Mark as no longer popped up */