+ wxString strName = wxStripMenuCodes(m_text);
+ if (IsCheckable())
+ {
+ m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (strName,
+ xmToggleButtonGadgetClass, (Widget) menu,
+#ifdef XmNpositionIndex
+ XmNpositionIndex, index,
+#endif
+ NULL);
+ XtVaSetValues ((Widget) m_buttonWidget, XmNset, (Boolean) IsChecked(), NULL);
+ }
+ else
+ m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (strName,
+ xmPushButtonGadgetClass, (Widget) menu,
+#ifdef XmNpositionIndex
+ XmNpositionIndex, index,
+#endif
+ NULL);
+ char mnem = wxFindMnemonic (m_text);
+ if (mnem != 0)
+ XtVaSetValues ((Widget) m_buttonWidget, XmNmnemonic, mnem, NULL);
+
+ //// TODO: proper accelerator treatment. What does wxFindAccelerator
+ //// look for?
+ strName = m_text;
+ char *accel = wxFindAccelerator (strName);
+ if (accel)
+ XtVaSetValues ((Widget) m_buttonWidget, XmNaccelerator, accel, NULL);
+
+ // TODO: What does this do?
+ XmString accel_str = wxFindAcceleratorText (strName);
+ if (accel_str)
+ {
+ XtVaSetValues ((Widget) m_buttonWidget, XmNacceleratorText, accel_str, NULL);
+ XmStringFree (accel_str);
+ }
+
+ if (IsCheckable())
+ XtAddCallback ((Widget) m_buttonWidget,
+ XmNvalueChangedCallback,
+ (XtCallbackProc) wxMenuItemCallback,
+ (XtPointer) this);
+ else
+ XtAddCallback ((Widget) m_buttonWidget,
+ XmNactivateCallback,
+ (XtCallbackProc) wxMenuItemCallback,
+ (XtPointer) this);
+ XtAddCallback ((Widget) m_buttonWidget,
+ XmNarmCallback,
+ (XtCallbackProc) wxMenuItemArmCallback,
+ (XtPointer) this);
+ XtAddCallback ((Widget) m_buttonWidget,
+ XmNdisarmCallback,
+ (XtCallbackProc) wxMenuItemDisarmCallback,
+ (XtPointer) this);
+ }
+ else if (GetId() == wxID_SEPARATOR)
+ {
+ m_buttonWidget = (WXWidget) XtVaCreateManagedWidget ("separator",
+ xmSeparatorGadgetClass, (Widget) menu,
+#ifndef XmNpositionIndex
+ XmNpositionIndex, index,
+#endif
+ NULL);
+ }
+ else if (m_subMenu)
+ {
+ m_buttonWidget = m_subMenu->CreateMenu (menuBar, menu, topMenu, index, m_text, true);
+ m_subMenu->SetButtonWidget(m_buttonWidget);
+ XtAddCallback ((Widget) m_buttonWidget,
+ XmNcascadingCallback,
+ (XtCallbackProc) wxMenuItemArmCallback,
+ (XtPointer) this);
+ }
+ if (m_buttonWidget)
+ XtSetSensitive ((Widget) m_buttonWidget, (Boolean) IsEnabled());
+}
+
+void wxMenuItem::DestroyItem(bool full)
+{
+ if (GetId() == -3)
+ {
+ ; // Nothing
+
+ }
+ else if (!m_text.empty() && !m_subMenu)
+ {
+ 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() == wxID_SEPARATOR)
+ {
+ ; // Nothing
+
+ }
+ else if (GetSubMenu())
+ {
+ if (m_buttonWidget)
+ {
+ XtRemoveCallback ((Widget) m_buttonWidget, XmNcascadingCallback,
+ wxMenuItemArmCallback, (XtPointer) this);
+ }
+ m_subMenu->DestroyMenu(full);
+ if (full)
+ m_buttonWidget = NULL;