diff options
| author | Jason Rumney | 2000-03-22 23:15:30 +0000 |
|---|---|---|
| committer | Jason Rumney | 2000-03-22 23:15:30 +0000 |
| commit | 7d8e57dac87eba53a79e1338b70958c0d68fc85f (patch) | |
| tree | 4519200f589cec9f6ce0d7d924d22addabeed1df /src | |
| parent | 01f975608a89cf8dcde99d6665fa5294190f8495 (diff) | |
| download | emacs-7d8e57dac87eba53a79e1338b70958c0d68fc85f.tar.gz emacs-7d8e57dac87eba53a79e1338b70958c0d68fc85f.zip | |
(single_submenu): Set help string to NULL if none.
(w32_menu_show): Set help string correctly.
(add-menu-item): Set help string in MIIM_DATA for menu item.
Load SetMenuItemInfoA explicitly.
(w32_menu_display_help): New function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32menu.c | 117 |
1 files changed, 77 insertions, 40 deletions
diff --git a/src/w32menu.c b/src/w32menu.c index 73a2af6a5e4..6ca1aa755a0 100644 --- a/src/w32menu.c +++ b/src/w32menu.c | |||
| @@ -54,16 +54,6 @@ typedef char Boolean; | |||
| 54 | #define True 1 | 54 | #define True 1 |
| 55 | #define False 0 | 55 | #define False 0 |
| 56 | 56 | ||
| 57 | #if 0 /* Not used below. */ | ||
| 58 | typedef enum _change_type | ||
| 59 | { | ||
| 60 | NO_CHANGE = 0, | ||
| 61 | INVISIBLE_CHANGE = 1, | ||
| 62 | VISIBLE_CHANGE = 2, | ||
| 63 | STRUCTURAL_CHANGE = 3 | ||
| 64 | } change_type; | ||
| 65 | #endif | ||
| 66 | |||
| 67 | enum button_type | 57 | enum button_type |
| 68 | { | 58 | { |
| 69 | BUTTON_TYPE_NONE, | 59 | BUTTON_TYPE_NONE, |
| @@ -79,8 +69,8 @@ typedef struct _widget_value | |||
| 79 | char* value; | 69 | char* value; |
| 80 | /* keyboard equivalent. no implications for XtTranslations */ | 70 | /* keyboard equivalent. no implications for XtTranslations */ |
| 81 | char* key; | 71 | char* key; |
| 82 | /* Help string or null if none. */ | 72 | /* Help string. */ |
| 83 | char *help; | 73 | char* help; |
| 84 | /* true if enabled */ | 74 | /* true if enabled */ |
| 85 | Boolean enabled; | 75 | Boolean enabled; |
| 86 | /* true if selected */ | 76 | /* true if selected */ |
| @@ -1219,6 +1209,7 @@ single_submenu (item_key, item_name, maps) | |||
| 1219 | /* Create a new item within current pane. */ | 1209 | /* Create a new item within current pane. */ |
| 1220 | Lisp_Object item_name, enable, descrip, def, type, selected; | 1210 | Lisp_Object item_name, enable, descrip, def, type, selected; |
| 1221 | Lisp_Object help; | 1211 | Lisp_Object help; |
| 1212 | |||
| 1222 | /* NTEMACS_TODO: implement popup/modeline help for menus. */ | 1213 | /* NTEMACS_TODO: implement popup/modeline help for menus. */ |
| 1223 | 1214 | ||
| 1224 | item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; | 1215 | item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; |
| @@ -1263,8 +1254,10 @@ single_submenu (item_key, item_name, maps) | |||
| 1263 | 1254 | ||
| 1264 | wv->selected = !NILP (selected); | 1255 | wv->selected = !NILP (selected); |
| 1265 | if (STRINGP (help)) | 1256 | if (STRINGP (help)) |
| 1266 | wv->help = XSTRING (help)->data; | 1257 | wv->help = (char *) XSTRING (help)->data; |
| 1267 | 1258 | else | |
| 1259 | wv->help = NULL; | ||
| 1260 | |||
| 1268 | prev_wv = wv; | 1261 | prev_wv = wv; |
| 1269 | 1262 | ||
| 1270 | i += MENU_ITEMS_ITEM_LENGTH; | 1263 | i += MENU_ITEMS_ITEM_LENGTH; |
| @@ -1666,7 +1659,6 @@ w32_menu_show (f, x, y, for_click, keymaps, title, error) | |||
| 1666 | { | 1659 | { |
| 1667 | /* Create a new item within current pane. */ | 1660 | /* Create a new item within current pane. */ |
| 1668 | Lisp_Object item_name, enable, descrip, def, type, selected, help; | 1661 | Lisp_Object item_name, enable, descrip, def, type, selected, help; |
| 1669 | char *help_string; | ||
| 1670 | 1662 | ||
| 1671 | item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; | 1663 | item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; |
| 1672 | enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; | 1664 | enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; |
| @@ -1682,12 +1674,8 @@ w32_menu_show (f, x, y, for_click, keymaps, title, error) | |||
| 1682 | item_name = string_make_unibyte (item_name); | 1674 | item_name = string_make_unibyte (item_name); |
| 1683 | if (STRINGP (descrip) && STRING_MULTIBYTE (descrip)) | 1675 | if (STRINGP (descrip) && STRING_MULTIBYTE (descrip)) |
| 1684 | descrip = string_make_unibyte (descrip); | 1676 | descrip = string_make_unibyte (descrip); |
| 1685 | if (STRINGP (help) && STRING_MULTIBYTE (help)) | ||
| 1686 | help = string_make_unibyte (help); | ||
| 1687 | #endif | 1677 | #endif |
| 1688 | 1678 | ||
| 1689 | help_string = STRINGP (help) ? XSTRING (help)->data : NULL; | ||
| 1690 | |||
| 1691 | wv = xmalloc_widget_value (); | 1679 | wv = xmalloc_widget_value (); |
| 1692 | if (prev_wv) | 1680 | if (prev_wv) |
| 1693 | prev_wv->next = wv; | 1681 | prev_wv->next = wv; |
| @@ -1712,7 +1700,12 @@ w32_menu_show (f, x, y, for_click, keymaps, title, error) | |||
| 1712 | abort (); | 1700 | abort (); |
| 1713 | 1701 | ||
| 1714 | wv->selected = !NILP (selected); | 1702 | wv->selected = !NILP (selected); |
| 1715 | 1703 | ||
| 1704 | if (STRINGP (help)) | ||
| 1705 | wv->help = (char *) XSTRING (help)->data; | ||
| 1706 | else | ||
| 1707 | wv->help = NULL; | ||
| 1708 | |||
| 1716 | prev_wv = wv; | 1709 | prev_wv = wv; |
| 1717 | 1710 | ||
| 1718 | i += MENU_ITEMS_ITEM_LENGTH; | 1711 | i += MENU_ITEMS_ITEM_LENGTH; |
| @@ -1880,14 +1873,12 @@ w32_dialog_show (f, keymaps, title, error) | |||
| 1880 | 1873 | ||
| 1881 | /* Create a new item within current pane. */ | 1874 | /* Create a new item within current pane. */ |
| 1882 | Lisp_Object item_name, enable, descrip, help; | 1875 | Lisp_Object item_name, enable, descrip, help; |
| 1883 | char *help_string; | ||
| 1884 | 1876 | ||
| 1885 | item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; | 1877 | item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; |
| 1886 | enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; | 1878 | enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; |
| 1887 | descrip | 1879 | descrip |
| 1888 | = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; | 1880 | = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; |
| 1889 | help = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_HELP]; | 1881 | help = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_HELP]; |
| 1890 | help_string = STRINGP (help) ? XSTRING (help)->data : NULL; | ||
| 1891 | 1882 | ||
| 1892 | if (NILP (item_name)) | 1883 | if (NILP (item_name)) |
| 1893 | { | 1884 | { |
| @@ -2089,25 +2080,32 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item) | |||
| 2089 | (fuFlags == MF_SEPARATOR) ? NULL: out_string ); | 2080 | (fuFlags == MF_SEPARATOR) ? NULL: out_string ); |
| 2090 | 2081 | ||
| 2091 | /* This must be done after the menu item is created. */ | 2082 | /* This must be done after the menu item is created. */ |
| 2092 | if (wv->button_type == BUTTON_TYPE_RADIO) | 2083 | { |
| 2093 | { | 2084 | HMODULE user32 = GetModuleHandle ("user32.dll"); |
| 2094 | /* CheckMenuRadioItem allows us to differentiate TOGGLE and | 2085 | FARPROC set_menu_item_info = GetProcAddress (user32, "SetMenuItemInfoA"); |
| 2095 | RADIO items, but is not available on NT 3.51 and earlier. */ | ||
| 2096 | HMODULE user32 = GetModuleHandle ("user32.dll"); | ||
| 2097 | FARPROC set_menu_item_info = GetProcAddress (user32, "SetMenuItemInfo"); | ||
| 2098 | |||
| 2099 | if (set_menu_item_info) | ||
| 2100 | { | ||
| 2101 | MENUITEMINFO info; | ||
| 2102 | bzero (&info, sizeof (info)); | ||
| 2103 | info.cbSize = sizeof (info); | ||
| 2104 | info.fMask = MIIM_TYPE | MIIM_STATE; | ||
| 2105 | info.fType = MFT_RADIOCHECK; | ||
| 2106 | info.fState = wv->selected ? MFS_CHECKED : MFS_UNCHECKED; | ||
| 2107 | set_menu_item_info (menu, item, FALSE, &info); | ||
| 2108 | } | ||
| 2109 | } | ||
| 2110 | 2086 | ||
| 2087 | if (set_menu_item_info) | ||
| 2088 | { | ||
| 2089 | MENUITEMINFO info; | ||
| 2090 | bzero (&info, sizeof (info)); | ||
| 2091 | info.cbSize = sizeof (info); | ||
| 2092 | info.fMask = MIIM_DATA; | ||
| 2093 | /* Set help string for menu item. */ | ||
| 2094 | info.dwItemData = (DWORD)wv->help; | ||
| 2095 | |||
| 2096 | if (wv->button_type == BUTTON_TYPE_RADIO) | ||
| 2097 | { | ||
| 2098 | /* CheckMenuRadioItem allows us to differentiate TOGGLE and | ||
| 2099 | RADIO items, but is not available on NT 3.51 and earlier. */ | ||
| 2100 | info.fMask |= MIIM_TYPE | MIIM_STATE; | ||
| 2101 | info.fType = MFT_RADIOCHECK; | ||
| 2102 | info.fState = wv->selected ? MFS_CHECKED : MFS_UNCHECKED; | ||
| 2103 | } | ||
| 2104 | set_menu_item_info (menu, | ||
| 2105 | item != NULL ? (UINT) item : (UINT) wv->call_data, | ||
| 2106 | FALSE, &info); | ||
| 2107 | } | ||
| 2108 | } | ||
| 2111 | return return_value; | 2109 | return return_value; |
| 2112 | } | 2110 | } |
| 2113 | 2111 | ||
| @@ -2149,6 +2147,45 @@ popup_activated () | |||
| 2149 | return 0; | 2147 | return 0; |
| 2150 | } | 2148 | } |
| 2151 | 2149 | ||
| 2150 | /* Display help string for currently pointed to menu item. Not | ||
| 2151 | supported on NT 3.51 and earlier, as GetMenuItemInfo is not | ||
| 2152 | available. */ | ||
| 2153 | void | ||
| 2154 | w32_menu_display_help (HMENU menu, UINT item, UINT flags) | ||
| 2155 | { | ||
| 2156 | HMODULE user32 = GetModuleHandle ("user32.dll"); | ||
| 2157 | FARPROC get_menu_item_info = GetProcAddress (user32, "GetMenuItemInfoA"); | ||
| 2158 | |||
| 2159 | if (get_menu_item_info) | ||
| 2160 | { | ||
| 2161 | struct gcpro gcpro1; | ||
| 2162 | extern Lisp_Object Vshow_help_function; | ||
| 2163 | Lisp_Object msg; | ||
| 2164 | MENUITEMINFO info; | ||
| 2165 | |||
| 2166 | bzero (&info, sizeof (info)); | ||
| 2167 | info.cbSize = sizeof (info); | ||
| 2168 | info.fMask = MIIM_DATA; | ||
| 2169 | get_menu_item_info (menu, item, FALSE, &info); | ||
| 2170 | |||
| 2171 | msg = info.dwItemData ? build_string ((char *) info.dwItemData) : Qnil; | ||
| 2172 | GCPRO1 (msg); | ||
| 2173 | |||
| 2174 | if (!NILP (Vshow_help_function)) | ||
| 2175 | call1 (Vshow_help_function, msg); | ||
| 2176 | else if (!MINI_WINDOW_P (XWINDOW (selected_window))) | ||
| 2177 | { | ||
| 2178 | if (STRINGP(msg)) | ||
| 2179 | message3_nolog (msg, XSTRING (msg)->size, STRING_MULTIBYTE (msg)); | ||
| 2180 | else | ||
| 2181 | message (0); | ||
| 2182 | } | ||
| 2183 | UNGCPRO; | ||
| 2184 | } | ||
| 2185 | } | ||
| 2186 | |||
| 2187 | |||
| 2188 | |||
| 2152 | #endif /* HAVE_MENUS */ | 2189 | #endif /* HAVE_MENUS */ |
| 2153 | 2190 | ||
| 2154 | syms_of_w32menu () | 2191 | syms_of_w32menu () |