+ 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);
+ }
+ }
+}
+
+// ----------------------------------------------------------------------------
+// Motif callbacks
+// ----------------------------------------------------------------------------
+
+void wxMenuItemCallback (Widget WXUNUSED(w), XtPointer clientData,
+ XtPointer WXUNUSED(ptr))
+{
+ wxMenuItem *item = (wxMenuItem *) clientData;
+ if (item)
+ {
+ wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, item->GetId());
+ event.SetInt( item->GetId() );
+
+ if (item->IsCheckable())
+ {
+ Boolean isChecked = false;
+ XtVaGetValues ((Widget) item->GetButtonWidget(),
+ XmNset, & isChecked,
+ NULL);
+
+ // only set the flag, don't actually check anything
+ item->wxMenuItemBase::Check(isChecked);
+ event.SetInt(isChecked);
+ }
+
+ if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame())
+ {
+ event.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
+
+ item->GetMenuBar()->GetMenuBarFrame()
+ ->GetEventHandler()->ProcessEvent(event);
+ }
+ // this is the child of a popup menu
+ else if (item->GetTopMenu())
+ {
+ event.SetEventObject(item->GetTopMenu());
+
+ item->GetTopMenu()->ProcessCommand (event);
+
+ // Since PopupMenu under Motif still grab right mouse
+ // button events after it was closed, we need to delete
+ // the associated widgets to allow next PopUpMenu to
+ // appear; this needs to be done there because doing it in
+ // a WorkProc as before may cause crashes if a menu item causes
+ // the parent window of the menu to be destroyed
+ item->GetTopMenu()->DestroyWidgetAndDetach();
+ }
+ }
+}
+
+void wxMenuItemArmCallback (Widget WXUNUSED(w), XtPointer clientData,
+ XtPointer WXUNUSED(ptr))
+{
+ wxMenuItem *item = (wxMenuItem *) clientData;
+ if (item)
+ {
+ if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame())
+ {
+ wxMenuEvent menuEvent(wxEVT_MENU_HIGHLIGHT, item->GetId());
+ menuEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
+
+ item->GetMenuBar()->GetMenuBarFrame()
+ ->GetEventHandler()->ProcessEvent(menuEvent);
+ }
+ }
+}
+
+void
+wxMenuItemDisarmCallback (Widget WXUNUSED(w), XtPointer clientData,
+ XtPointer WXUNUSED(ptr))
+{
+ wxMenuItem *item = (wxMenuItem *) clientData;
+ if (item)
+ {
+ if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame())
+ {
+ // TODO: not sure this is correct, since -1 means something
+ // special to event system
+ wxMenuEvent menuEvent(wxEVT_MENU_HIGHLIGHT, -1);
+ menuEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
+
+ item->GetMenuBar()->GetMenuBarFrame()
+ ->GetEventHandler()->ProcessEvent(menuEvent);
+ }
+ }
+}