comparison src/w32menu.c @ 36677:eb7af01c7f27

(add_menu_item): Fix problems with using ownerdraw for menu titles.
author Andrew Innes <andrewi@gnu.org>
date Thu, 08 Mar 2001 21:20:43 +0000
parents 77093a87f2de
children eb915f0b1d6e
comparison
equal deleted inserted replaced
36676:3697f81943d8 36677:eb7af01c7f27
2052 strcat (out_string, wv->key); 2052 strcat (out_string, wv->key);
2053 } 2053 }
2054 else 2054 else
2055 out_string = wv->name; 2055 out_string = wv->name;
2056 2056
2057 if (wv->title) 2057 if (wv->title || wv->call_data == 0)
2058 { 2058 {
2059 #if 0 /* no GC while popup menu is active */ 2059 #if 0 /* no GC while popup menu is active */
2060 out_string = LocalAlloc (0, strlen (wv->name) + 1); 2060 out_string = LocalAlloc (0, strlen (wv->name) + 1);
2061 strcpy (out_string, wv->name); 2061 strcpy (out_string, wv->name);
2062 #endif 2062 #endif
2063 /* TODO: Why has owner-draw stopped working? */ 2063 fuFlags = MF_OWNERDRAW | MF_DISABLED;
2064 fuFlags |= /*MF_OWNERDRAW |*/ MF_DISABLED; 2064 }
2065 }
2066
2067 /* Draw radio buttons and tickboxes. */ 2065 /* Draw radio buttons and tickboxes. */
2068 { 2066 else if (wv->selected && (wv->button_type == BUTTON_TYPE_TOGGLE ||
2069 if (wv->selected && (wv->button_type == BUTTON_TYPE_TOGGLE ||
2070 wv->button_type == BUTTON_TYPE_RADIO)) 2067 wv->button_type == BUTTON_TYPE_RADIO))
2071 fuFlags |= MF_CHECKED; 2068 fuFlags |= MF_CHECKED;
2072 else 2069 else
2073 fuFlags |= MF_UNCHECKED; 2070 fuFlags |= MF_UNCHECKED;
2074 } 2071 }
2075 } 2072
2076 if (item != NULL) 2073 if (item != NULL)
2077 fuFlags = MF_POPUP; 2074 fuFlags = MF_POPUP;
2078 2075
2079 return_value = 2076 return_value =
2080 AppendMenu (menu, 2077 AppendMenu (menu,
2081 fuFlags, 2078 fuFlags,
2082 item != NULL ? (UINT) item : (UINT) wv->call_data, 2079 item != NULL ? (UINT) item : (UINT) wv->call_data,
2083 out_string ); 2080 out_string );
2084 2081
2085 /* This must be done after the menu item is created. */ 2082 /* This must be done after the menu item is created. */
2086 { 2083 if ((fuFlags & MF_STRING) != 0)
2087 HMODULE user32 = GetModuleHandle ("user32.dll"); 2084 {
2088 FARPROC set_menu_item_info = GetProcAddress (user32, "SetMenuItemInfoA"); 2085 HMODULE user32 = GetModuleHandle ("user32.dll");
2089 2086 FARPROC set_menu_item_info = GetProcAddress (user32, "SetMenuItemInfoA");
2090 if (set_menu_item_info) 2087
2091 { 2088 if (set_menu_item_info)
2092 MENUITEMINFO info; 2089 {
2093 bzero (&info, sizeof (info)); 2090 MENUITEMINFO info;
2094 info.cbSize = sizeof (info); 2091 bzero (&info, sizeof (info));
2095 info.fMask = MIIM_DATA; 2092 info.cbSize = sizeof (info);
2096 2093 info.fMask = MIIM_DATA;
2097 /* Set help string for menu item. */ 2094
2098 info.dwItemData = (DWORD)wv->help; 2095 /* Set help string for menu item. */
2099 2096 info.dwItemData = (DWORD)wv->help;
2100 if (wv->button_type == BUTTON_TYPE_RADIO) 2097
2101 { 2098 if (wv->button_type == BUTTON_TYPE_RADIO)
2102 /* CheckMenuRadioItem allows us to differentiate TOGGLE and 2099 {
2103 RADIO items, but is not available on NT 3.51 and earlier. */ 2100 /* CheckMenuRadioItem allows us to differentiate TOGGLE and
2104 info.fMask |= MIIM_TYPE | MIIM_STATE; 2101 RADIO items, but is not available on NT 3.51 and earlier. */
2105 info.fType = MFT_RADIOCHECK | MFT_STRING; 2102 info.fMask |= MIIM_TYPE | MIIM_STATE;
2106 info.dwTypeData = out_string; 2103 info.fType = MFT_RADIOCHECK | MFT_STRING;
2107 info.fState = wv->selected ? MFS_CHECKED : MFS_UNCHECKED; 2104 info.dwTypeData = out_string;
2108 } 2105 info.fState = wv->selected ? MFS_CHECKED : MFS_UNCHECKED;
2109 2106 }
2110 set_menu_item_info (menu, 2107
2111 item != NULL ? (UINT) item : (UINT) wv->call_data, 2108 set_menu_item_info (menu,
2112 FALSE, &info); 2109 item != NULL ? (UINT) item : (UINT) wv->call_data,
2113 } 2110 FALSE, &info);
2114 } 2111 }
2112 }
2115 return return_value; 2113 return return_value;
2116 } 2114 }
2117 2115
2118 /* Construct native Windows menu(bar) based on widget_value tree. */ 2116 /* Construct native Windows menu(bar) based on widget_value tree. */
2119 int 2117 int