- wxStripMenuCodes ((char*) (const char*) m_strName, wxBuffer);
- if (IsCheckable())
- {
- m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer,
- xmToggleButtonGadgetClass, (Widget) menu,
- NULL);
- XtVaSetValues ((Widget) m_buttonWidget, XmNset, (Boolean) IsChecked(), NULL);
- }
- else
- m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer,
- xmPushButtonGadgetClass, (Widget) menu,
- NULL);
- char mnem = wxFindMnemonic (m_strName);
- if (mnem != 0)
- XtVaSetValues ((Widget) m_buttonWidget, XmNmnemonic, mnem, NULL);
-
- //// TODO: proper accelerator treatment. What does wxFindAccelerator
- //// look for?
- strcpy(wxBuffer, (char*) (const char*) m_strName);
- char *accel = wxFindAccelerator (wxBuffer);
- if (accel)
- XtVaSetValues ((Widget) m_buttonWidget, XmNaccelerator, accel, NULL);
-
- // TODO: What does this do?
- strcpy(wxBuffer, (char*) (const char*) m_strName);
- XmString accel_str = wxFindAcceleratorText (wxBuffer);
- 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);
+ wxString txt = m_text;
+
+ if (m_text.IsEmpty())
+ {
+ wxASSERT_MSG(wxIsStockID(GetId()), wxT("A non-stock menu item with an empty label?"));
+ txt = wxGetStockLabel(GetId(), wxSTOCK_WITH_ACCELERATOR|wxSTOCK_WITH_MNEMONIC);
+ }
+
+ wxString strName = wxStripMenuCodes(txt);
+ 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);