BUTTON_TYPE_RADIO
};
+/* This structure is based on the one in ../lwlib/lwlib.h, modified
+ for Windows. */
typedef struct _widget_value
{
/* name of widget */
char* value;
/* keyboard equivalent. no implications for XtTranslations */
char* key;
- /* Help string or null if none. */
- char *help;
+ /* Help string or nil if none.
+ GC finds this string through the frame's menu_bar_vector
+ or through menu_items. */
+ Lisp_Object help;
/* true if enabled */
Boolean enabled;
/* true if selected */
abort ();
wv->selected = !NILP (selected);
- if (STRINGP (help))
- wv->help = (char *) XSTRING (help)->data;
- else
- wv->help = NULL;
+ if (!STRINGP (help))
+ help = Qnil;
+
+ wv->help = help;
prev_wv = wv;
abort ();
wv->selected = !NILP (selected);
- if (STRINGP (help))
- wv->help = XSTRING (help)->data;
+ if (!STRINGP (help))
+ help = Qnil;
+
+ wv->help = help;
prev_wv = wv;
else
out_string = wv->name;
- if (wv->title || wv->call_data == 0)
+ if (item != NULL)
+ fuFlags = MF_POPUP;
+ else if (wv->title || wv->call_data == 0)
{
/* Only use MF_OWNERDRAW if GetMenuItemInfo is usable, since
we can't deallocate the memory otherwise. */
if (get_menu_item_info)
{
- out_string = LocalAlloc (LPTR, strlen (wv->name) + 1);
+ out_string = (char *) LocalAlloc (LPTR, strlen (wv->name) + 1);
+#ifdef MENU_DEBUG
+ DebPrint ("Menu: allocing %ld for owner-draw", info.dwItemData);
+#endif
strcpy (out_string, wv->name);
fuFlags = MF_OWNERDRAW | MF_DISABLED;
}
fuFlags |= MF_UNCHECKED;
}
- if (item != NULL)
- fuFlags = MF_POPUP;
-
return_value =
AppendMenu (menu,
fuFlags,
info.cbSize = sizeof (info);
info.fMask = MIIM_DATA;
- /* Set help string for menu item. Allocate new memory
- from the heap for it, since garbage collection can
- occur while menus are active. */
+ /* Set help string for menu item. Leave it as a Lisp_Object
+ until it is ready to be displayed, since GC can happen while
+ menus are active. */
if (wv->help)
- {
- info.dwItemData
- = (DWORD) LocalAlloc (LPTR, strlen(wv->help) + 1);
- strcpy (info.dwItemData, wv->help);
- }
+ info.dwItemData = (DWORD) wv->help;
if (wv->button_type == BUTTON_TYPE_RADIO)
{
info.fMask = MIIM_DATA;
get_menu_item_info (menu, item, FALSE, &info);
- help = info.dwItemData ? build_string ((char *)info.dwItemData) : Qnil;
+ help = info.dwItemData ? (Lisp_Object) info.dwItemData : Qnil;
}
/* Store the help echo in the keyboard buffer as the X toolkit
}
}
-/* Free memory used by owner-drawn and help_echo strings. */
+/* Free memory used by owner-drawn strings. */
static void
w32_free_submenu_strings (menu)
HMENU menu;
MENUITEMINFO info;
info.cbSize = sizeof (info);
- info.fMask = MIIM_DATA | MIIM_SUBMENU;
+ info.fMask = MIIM_DATA | MIIM_TYPE | MIIM_SUBMENU;
get_menu_item_info (menu, i, TRUE, &info);
- /* Both owner-drawn names and help strings are held in dwItemData. */
- if (info.dwItemData)
- LocalFree (info.dwItemData);
+ /* Owner-drawn names are held in dwItemData. */
+ if ((info.fType & MF_OWNERDRAW) && info.dwItemData)
+ {
+#ifdef MENU_DEBUG
+ DebPrint ("Menu: freeing %ld for owner-draw", info.dwItemData);
+#endif
+ LocalFree (info.dwItemData);
+ }
/* Recurse down submenus. */
if (info.hSubMenu)