+ if (GetId() == -2)
+ {
+ ; // Nothing
+
+ }
+ else if ((!m_strName.IsNull() && (m_strName != "")) && !m_pSubMenu)
+ {
+ if (m_buttonWidget)
+ {
+ if (IsCheckable())
+ XtRemoveCallback ((Widget) m_buttonWidget, XmNvalueChangedCallback,
+ wxMenuItemCallback, (XtPointer) this);
+ else
+ XtRemoveCallback ((Widget) m_buttonWidget, XmNactivateCallback,
+ wxMenuItemCallback, (XtPointer) this);
+ XtRemoveCallback ((Widget) m_buttonWidget, XmNarmCallback,
+ wxMenuItemArmCallback, (XtPointer) this);
+ XtRemoveCallback ((Widget) m_buttonWidget, XmNdisarmCallback,
+ wxMenuItemDisarmCallback, (XtPointer) this);
+ }
+ }
+ else if (GetId() == -1)
+ {
+ ; // Nothing
+
+ }
+ else if (GetSubMenu())
+ {
+ if (m_buttonWidget)
+ {
+ XtRemoveCallback ((Widget) m_buttonWidget, XmNcascadingCallback,
+ wxMenuItemArmCallback, (XtPointer) this);
+ }
+ m_pSubMenu->DestroyMenu(full);
+ if (full)
+ m_buttonWidget = NULL;
+ }
+
+ if (m_buttonWidget && full)
+ {
+ XtDestroyWidget ((Widget) m_buttonWidget);
+ m_buttonWidget = (WXWidget) 0;
+ }
+}
+
+void wxMenuItem::SetLabel(const wxString& label)
+{
+ char mnem = wxFindMnemonic (label);
+ wxStripMenuCodes ((char*) (const char*) label, wxBuffer);
+
+ m_strName = label;
+
+ if (m_buttonWidget)
+ {
+ XmString label_str = XmStringCreateSimple (wxBuffer);
+ XtVaSetValues ((Widget) m_buttonWidget,
+ XmNlabelString, label_str,
+ NULL);
+ XmStringFree (label_str);
+ if (mnem != 0)
+ XtVaSetValues ((Widget) m_buttonWidget, XmNmnemonic, mnem, NULL);
+ strcpy(wxBuffer, (char*) (const char*) label);
+ char *accel = wxFindAccelerator (wxBuffer);
+ if (accel)
+ XtVaSetValues ((Widget) m_buttonWidget, XmNaccelerator, accel, NULL);
+
+ strcpy(wxBuffer, (char*) (const char*) label);
+ XmString accel_str = wxFindAcceleratorText (wxBuffer);
+ if (accel_str)
+ {
+ XtVaSetValues ((Widget) m_buttonWidget, XmNacceleratorText, accel_str, NULL);
+ XmStringFree (accel_str);
+ }
+ }
+}
+
+void wxMenuItemCallback (Widget w, XtPointer clientData,
+ XtPointer ptr)
+{
+ wxMenuItem *item = (wxMenuItem *) clientData;
+ if (item)
+ {
+ if (item->IsCheckable())
+ {
+ Boolean isChecked = FALSE;
+ XtVaGetValues ((Widget) item->GetButtonWidget(), XmNset, & isChecked, NULL);
+ item->SetChecked(isChecked);
+ }
+ if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame())
+ {
+ wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, item->GetId());
+ commandEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
+ commandEvent.SetInt( item->GetId() );
+
+ item->GetMenuBar()->GetMenuBarFrame()->GetEventHandler()->ProcessEvent(commandEvent);
+ }
+ else if (item->GetTopMenu())
+ {
+ wxCommandEvent event (wxEVT_COMMAND_MENU_SELECTED, item->GetId());
+ event.SetEventObject(item->GetTopMenu());
+ event.SetInt( item->GetId() );
+
+ item->GetTopMenu()->ProcessCommand (event);
+ }
+ }
+}
+
+void wxMenuItemArmCallback (Widget w, XtPointer clientData,
+ XtPointer 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 w, XtPointer clientData,
+ XtPointer 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);
+ }
+ }
+}