diff options
| author | Jason Rumney | 2000-03-01 20:49:16 +0000 |
|---|---|---|
| committer | Jason Rumney | 2000-03-01 20:49:16 +0000 |
| commit | 37ad8b63556957c9ce2579096c1970f25d04f0bb (patch) | |
| tree | f600c77d384de248c4627fd477875e07910d0257 /src | |
| parent | d77dae5c405ca87a46c3cb00cba3a2b3f19919eb (diff) | |
| download | emacs-37ad8b63556957c9ce2579096c1970f25d04f0bb.tar.gz emacs-37ad8b63556957c9ce2579096c1970f25d04f0bb.zip | |
[HAVE_BOXES]: Remove #undef.
(single_keymap_panes): Remove code for simulating checkmarks.
(single_menu_item): Remove notbuttons_ptr argument. Callers changed.
Remove code for drawing simulated checkmarks.
(w32_menu_show): make unibyte help string correctly.
(add_menu_item): draw standard Windows checkmarks. Draw radio buttons
as radio buttons if possible.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32menu.c | 173 |
1 files changed, 39 insertions, 134 deletions
diff --git a/src/w32menu.c b/src/w32menu.c index 3f7edcad050..73a2af6a5e4 100644 --- a/src/w32menu.c +++ b/src/w32menu.c | |||
| @@ -43,8 +43,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 43 | #include "dispextern.h" | 43 | #include "dispextern.h" |
| 44 | 44 | ||
| 45 | #undef HAVE_MULTILINGUAL_MENU | 45 | #undef HAVE_MULTILINGUAL_MENU |
| 46 | #undef HAVE_BOXES /* NTEMACS_TODO: Fix native checkmarks and radios. */ | 46 | #undef HAVE_DIALOGS /* NTEMACS_TODO: Implement native dialogs. */ |
| 47 | #undef HAVE_DIALOGS /* NTEMACS_TODO: Fix native dialogs. */ | ||
| 48 | 47 | ||
| 49 | /******************************************************************/ | 48 | /******************************************************************/ |
| 50 | /* Definitions copied from lwlib.h */ | 49 | /* Definitions copied from lwlib.h */ |
| @@ -433,21 +432,12 @@ single_keymap_panes (keymap, pane_name, prefix, notreal, maxdepth) | |||
| 433 | Lisp_Object pending_maps = Qnil; | 432 | Lisp_Object pending_maps = Qnil; |
| 434 | Lisp_Object tail, item; | 433 | Lisp_Object tail, item; |
| 435 | struct gcpro gcpro1, gcpro2; | 434 | struct gcpro gcpro1, gcpro2; |
| 436 | int notbuttons = 0; | ||
| 437 | 435 | ||
| 438 | if (maxdepth <= 0) | 436 | if (maxdepth <= 0) |
| 439 | return; | 437 | return; |
| 440 | 438 | ||
| 441 | push_menu_pane (pane_name, prefix); | 439 | push_menu_pane (pane_name, prefix); |
| 442 | 440 | ||
| 443 | #ifndef HAVE_BOXES | ||
| 444 | /* Remember index for first item in this pane so we can go back and | ||
| 445 | add a prefix when (if) we see the first button. After that, notbuttons | ||
| 446 | is set to 0, to mark that we have seen a button and all non button | ||
| 447 | items need a prefix. */ | ||
| 448 | notbuttons = menu_items_used; | ||
| 449 | #endif | ||
| 450 | |||
| 451 | for (tail = keymap; CONSP (tail); tail = XCDR (tail)) | 441 | for (tail = keymap; CONSP (tail); tail = XCDR (tail)) |
| 452 | { | 442 | { |
| 453 | GCPRO2 (keymap, pending_maps); | 443 | GCPRO2 (keymap, pending_maps); |
| @@ -456,7 +446,7 @@ single_keymap_panes (keymap, pane_name, prefix, notreal, maxdepth) | |||
| 456 | item = XCAR (tail); | 446 | item = XCAR (tail); |
| 457 | if (CONSP (item)) | 447 | if (CONSP (item)) |
| 458 | single_menu_item (XCAR (item), XCDR (item), | 448 | single_menu_item (XCAR (item), XCDR (item), |
| 459 | &pending_maps, notreal, maxdepth, ¬buttons); | 449 | &pending_maps, notreal, maxdepth); |
| 460 | else if (VECTORP (item)) | 450 | else if (VECTORP (item)) |
| 461 | { | 451 | { |
| 462 | /* Loop over the char values represented in the vector. */ | 452 | /* Loop over the char values represented in the vector. */ |
| @@ -467,7 +457,7 @@ single_keymap_panes (keymap, pane_name, prefix, notreal, maxdepth) | |||
| 467 | Lisp_Object character; | 457 | Lisp_Object character; |
| 468 | XSETFASTINT (character, c); | 458 | XSETFASTINT (character, c); |
| 469 | single_menu_item (character, XVECTOR (item)->contents[c], | 459 | single_menu_item (character, XVECTOR (item)->contents[c], |
| 470 | &pending_maps, notreal, maxdepth, ¬buttons); | 460 | &pending_maps, notreal, maxdepth); |
| 471 | } | 461 | } |
| 472 | } | 462 | } |
| 473 | UNGCPRO; | 463 | UNGCPRO; |
| @@ -495,18 +485,13 @@ single_keymap_panes (keymap, pane_name, prefix, notreal, maxdepth) | |||
| 495 | separate panes. | 485 | separate panes. |
| 496 | If NOTREAL is nonzero, only check for equivalent key bindings, don't | 486 | If NOTREAL is nonzero, only check for equivalent key bindings, don't |
| 497 | evaluate expressions in menu items and don't make any menu. | 487 | evaluate expressions in menu items and don't make any menu. |
| 498 | If we encounter submenus deeper than MAXDEPTH levels, ignore them. | 488 | If we encounter submenus deeper than MAXDEPTH levels, ignore them. */ |
| 499 | NOTBUTTONS_PTR is only used when simulating toggle boxes and radio | ||
| 500 | buttons. It points to variable notbuttons in single_keymap_panes, | ||
| 501 | which keeps track of if we have seen a button in this menu or not. */ | ||
| 502 | 489 | ||
| 503 | static void | 490 | static void |
| 504 | single_menu_item (key, item, pending_maps_ptr, notreal, maxdepth, | 491 | single_menu_item (key, item, pending_maps_ptr, notreal, maxdepth) |
| 505 | notbuttons_ptr) | ||
| 506 | Lisp_Object key, item; | 492 | Lisp_Object key, item; |
| 507 | Lisp_Object *pending_maps_ptr; | 493 | Lisp_Object *pending_maps_ptr; |
| 508 | int maxdepth, notreal; | 494 | int maxdepth, notreal; |
| 509 | int *notbuttons_ptr; | ||
| 510 | { | 495 | { |
| 511 | Lisp_Object map, item_string, enabled; | 496 | Lisp_Object map, item_string, enabled; |
| 512 | struct gcpro gcpro1, gcpro2; | 497 | struct gcpro gcpro1, gcpro2; |
| @@ -542,75 +527,6 @@ single_menu_item (key, item, pending_maps_ptr, notreal, maxdepth, | |||
| 542 | return; | 527 | return; |
| 543 | } | 528 | } |
| 544 | 529 | ||
| 545 | #ifndef HAVE_BOXES | ||
| 546 | /* Simulate radio buttons and toggle boxes by putting a prefix in | ||
| 547 | front of them. */ | ||
| 548 | { | ||
| 549 | Lisp_Object prefix = Qnil; | ||
| 550 | Lisp_Object type = XVECTOR (item_properties)->contents[ITEM_PROPERTY_TYPE]; | ||
| 551 | if (!NILP (type)) | ||
| 552 | { | ||
| 553 | Lisp_Object selected | ||
| 554 | = XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED]; | ||
| 555 | |||
| 556 | if (*notbuttons_ptr) | ||
| 557 | /* The first button. Line up previous items in this menu. */ | ||
| 558 | { | ||
| 559 | int index = *notbuttons_ptr; /* Index for first item this menu. */ | ||
| 560 | int submenu = 0; | ||
| 561 | Lisp_Object tem; | ||
| 562 | while (index < menu_items_used) | ||
| 563 | { | ||
| 564 | tem | ||
| 565 | = XVECTOR (menu_items)->contents[index + MENU_ITEMS_ITEM_NAME]; | ||
| 566 | if (NILP (tem)) | ||
| 567 | { | ||
| 568 | index++; | ||
| 569 | submenu++; /* Skip sub menu. */ | ||
| 570 | } | ||
| 571 | else if (EQ (tem, Qlambda)) | ||
| 572 | { | ||
| 573 | index++; | ||
| 574 | submenu--; /* End sub menu. */ | ||
| 575 | } | ||
| 576 | else if (EQ (tem, Qt)) | ||
| 577 | index += 3; /* Skip new pane marker. */ | ||
| 578 | else if (EQ (tem, Qquote)) | ||
| 579 | index++; /* Skip a left, right divider. */ | ||
| 580 | else | ||
| 581 | { | ||
| 582 | if (!submenu && XSTRING (tem)->data[0] != '\0' | ||
| 583 | && XSTRING (tem)->data[0] != '-') | ||
| 584 | XVECTOR (menu_items)->contents[index + MENU_ITEMS_ITEM_NAME] | ||
| 585 | = concat2 (build_string (" "), tem); | ||
| 586 | index += MENU_ITEMS_ITEM_LENGTH; | ||
| 587 | } | ||
| 588 | } | ||
| 589 | *notbuttons_ptr = 0; | ||
| 590 | } | ||
| 591 | |||
| 592 | /* Calculate prefix, if any, for this item. */ | ||
| 593 | if (EQ (type, QCtoggle)) | ||
| 594 | prefix = build_string (NILP (selected) ? "[ ] " : "[X] "); | ||
| 595 | else if (EQ (type, QCradio)) | ||
| 596 | prefix = build_string (NILP (selected) ? "( ) " : "(*) "); | ||
| 597 | } | ||
| 598 | /* Not a button. If we have earlier buttons, then we need a prefix. */ | ||
| 599 | else if (!*notbuttons_ptr && XSTRING (item_string)->data[0] != '\0' | ||
| 600 | && XSTRING (item_string)->data[0] != '-') | ||
| 601 | prefix = build_string (" "); | ||
| 602 | |||
| 603 | if (!NILP (prefix)) | ||
| 604 | item_string = concat2 (prefix, item_string); | ||
| 605 | } | ||
| 606 | #endif /* HAVE_BOXES */ | ||
| 607 | |||
| 608 | #if 0 | ||
| 609 | if (!NILP(map)) | ||
| 610 | /* Indicate visually that this is a submenu. */ | ||
| 611 | item_string = concat2 (item_string, build_string (" >")); | ||
| 612 | #endif | ||
| 613 | |||
| 614 | push_menu_item (item_string, enabled, key, | 530 | push_menu_item (item_string, enabled, key, |
| 615 | XVECTOR (item_properties)->contents[ITEM_PROPERTY_DEF], | 531 | XVECTOR (item_properties)->contents[ITEM_PROPERTY_DEF], |
| 616 | XVECTOR (item_properties)->contents[ITEM_PROPERTY_KEYEQ], | 532 | XVECTOR (item_properties)->contents[ITEM_PROPERTY_KEYEQ], |
| @@ -618,7 +534,6 @@ single_menu_item (key, item, pending_maps_ptr, notreal, maxdepth, | |||
| 618 | XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED], | 534 | XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED], |
| 619 | XVECTOR (item_properties)->contents[ITEM_PROPERTY_HELP]); | 535 | XVECTOR (item_properties)->contents[ITEM_PROPERTY_HELP]); |
| 620 | 536 | ||
| 621 | #if 1 | ||
| 622 | /* Display a submenu using the toolkit. */ | 537 | /* Display a submenu using the toolkit. */ |
| 623 | if (! (NILP (map) || NILP (enabled))) | 538 | if (! (NILP (map) || NILP (enabled))) |
| 624 | { | 539 | { |
| @@ -626,7 +541,6 @@ single_menu_item (key, item, pending_maps_ptr, notreal, maxdepth, | |||
| 626 | single_keymap_panes (map, Qnil, key, 0, maxdepth - 1); | 541 | single_keymap_panes (map, Qnil, key, 0, maxdepth - 1); |
| 627 | push_submenu_end (); | 542 | push_submenu_end (); |
| 628 | } | 543 | } |
| 629 | #endif | ||
| 630 | } | 544 | } |
| 631 | 545 | ||
| 632 | /* Push all the panes and items of a menu described by the | 546 | /* Push all the panes and items of a menu described by the |
| @@ -1769,7 +1683,7 @@ w32_menu_show (f, x, y, for_click, keymaps, title, error) | |||
| 1769 | if (STRINGP (descrip) && STRING_MULTIBYTE (descrip)) | 1683 | if (STRINGP (descrip) && STRING_MULTIBYTE (descrip)) |
| 1770 | descrip = string_make_unibyte (descrip); | 1684 | descrip = string_make_unibyte (descrip); |
| 1771 | if (STRINGP (help) && STRING_MULTIBYTE (help)) | 1685 | if (STRINGP (help) && STRING_MULTIBYTE (help)) |
| 1772 | help_string = string_make_unibyte (help); | 1686 | help = string_make_unibyte (help); |
| 1773 | #endif | 1687 | #endif |
| 1774 | 1688 | ||
| 1775 | help_string = STRINGP (help) ? XSTRING (help)->data : NULL; | 1689 | help_string = STRINGP (help) ? XSTRING (help)->data : NULL; |
| @@ -2126,6 +2040,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item) | |||
| 2126 | { | 2040 | { |
| 2127 | UINT fuFlags; | 2041 | UINT fuFlags; |
| 2128 | char *out_string; | 2042 | char *out_string; |
| 2043 | int return_value; | ||
| 2129 | 2044 | ||
| 2130 | if (name_is_separator (wv->name)) | 2045 | if (name_is_separator (wv->name)) |
| 2131 | fuFlags = MF_SEPARATOR; | 2046 | fuFlags = MF_SEPARATOR; |
| @@ -2155,55 +2070,45 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item) | |||
| 2155 | fuFlags = MF_OWNERDRAW | MF_DISABLED; | 2070 | fuFlags = MF_OWNERDRAW | MF_DISABLED; |
| 2156 | } | 2071 | } |
| 2157 | 2072 | ||
| 2158 | #ifdef HAVE_BOXES | ||
| 2159 | /* Draw radio buttons and tickboxes. */ | 2073 | /* Draw radio buttons and tickboxes. */ |
| 2160 | { | 2074 | { |
| 2161 | switch (wv->button_type) | 2075 | if (wv->selected && (wv->button_type == BUTTON_TYPE_TOGGLE || |
| 2162 | { | 2076 | wv->button_type == BUTTON_TYPE_RADIO)) |
| 2163 | case BUTTON_TYPE_TOGGLE: | 2077 | fuFlags |= MF_CHECKED; |
| 2164 | CheckMenuItem (menu, (UINT)item, | 2078 | else |
| 2165 | wv->selected ? MF_CHECKED : MF_UNCHECKED); | 2079 | fuFlags |= MF_UNCHECKED; |
| 2166 | break; | ||
| 2167 | |||
| 2168 | case BUTTON_TYPE_RADIO: | ||
| 2169 | /* CheckMenuRadioItem does not exist on NT 3.51 and | ||
| 2170 | earlier. Fallback on CheckMenuItem. */ | ||
| 2171 | { | ||
| 2172 | HMODULE user32 = GetModuleHandle ("user32.dll"); | ||
| 2173 | FARPROC set_menu_item_info | ||
| 2174 | = GetProcAddress (user32, "SetMenuItemInfo"); | ||
| 2175 | if (set_menu_item_info) | ||
| 2176 | { | ||
| 2177 | MENUITEMINFO info; | ||
| 2178 | bzero (&info, sizeof (info)); | ||
| 2179 | info.cbSize = sizeof (info); | ||
| 2180 | info.fMask = MIIM_TYPE | MIIM_STATE; | ||
| 2181 | info.fType = MFT_RADIOCHECK; | ||
| 2182 | info.fState = wv->selected ? MFS_CHECKED : MFS_UNCHECKED; | ||
| 2183 | |||
| 2184 | set_menu_item_info (menu, item, FALSE, &info); | ||
| 2185 | } | ||
| 2186 | else | ||
| 2187 | CheckMenuItem (menu, (UINT)item, wv->selected ? | ||
| 2188 | MF_CHECKED : MF_UNCHECKED); | ||
| 2189 | } | ||
| 2190 | break; | ||
| 2191 | |||
| 2192 | default: | ||
| 2193 | CheckMenuItem (menu, (UINT)item, MF_UNCHECKED); | ||
| 2194 | break; | ||
| 2195 | } | ||
| 2196 | } | 2080 | } |
| 2197 | #endif | ||
| 2198 | } | 2081 | } |
| 2199 | |||
| 2200 | if (item != NULL) | 2082 | if (item != NULL) |
| 2201 | fuFlags = MF_POPUP; | 2083 | fuFlags = MF_POPUP; |
| 2202 | 2084 | ||
| 2203 | return AppendMenu (menu, | 2085 | return_value = |
| 2204 | fuFlags, | 2086 | AppendMenu (menu, |
| 2205 | item != NULL ? (UINT) item : (UINT) wv->call_data, | 2087 | fuFlags, |
| 2206 | (fuFlags == MF_SEPARATOR) ? NULL: out_string ); | 2088 | item != NULL ? (UINT) item : (UINT) wv->call_data, |
| 2089 | (fuFlags == MF_SEPARATOR) ? NULL: out_string ); | ||
| 2090 | |||
| 2091 | /* This must be done after the menu item is created. */ | ||
| 2092 | if (wv->button_type == BUTTON_TYPE_RADIO) | ||
| 2093 | { | ||
| 2094 | /* CheckMenuRadioItem allows us to differentiate TOGGLE and | ||
| 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 | |||
| 2111 | return return_value; | ||
| 2207 | } | 2112 | } |
| 2208 | 2113 | ||
| 2209 | /* Construct native Windows menu(bar) based on widget_value tree. */ | 2114 | /* Construct native Windows menu(bar) based on widget_value tree. */ |