From 383418e5122ee80b530e7df96c27be7cffd8a5f1 Mon Sep 17 00:00:00 2001 From: Steven Tamm Date: Thu, 26 Aug 2004 18:43:29 +0000 Subject: [PATCH] macmenu.c (ENCODE_MENU_STRING): Added to handle multibyte strings in menu items. (single_submenu): Use ENCODE_MENU_STRING (mac_menu_show): Use ENCODE_MENU_STRING. Reset grabbed because button release isn't passed to event loop (add_menu_item): Use SetMenuItemWithCFString --- src/ChangeLog | 9 +++++++++ src/macmenu.c | 30 +++++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index fa1922c6255..aa3721d9106 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2004-08-26 YAMAMOTO Mitsuharu + + * macmenu.c (ENCODE_MENU_STRING): Added to handle multibyte + strings in menu items. + (single_submenu): Use ENCODE_MENU_STRING + (mac_menu_show): Use ENCODE_MENU_STRING. Reset grabbed because + button release isn't passed to event loop + (add_menu_item): Use SetMenuItemWithCFString + 2004-08-26 Steven Tamm * fileio.c (Fread_file_name): Call x_file_dialog on carbon on diff --git a/src/macmenu.c b/src/macmenu.c index d205ee3b877..67e18481a1b 100644 --- a/src/macmenu.c +++ b/src/macmenu.c @@ -163,6 +163,12 @@ extern Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map; extern Lisp_Object Qmenu_bar_update_hook; +#if TARGET_API_MAC_CARBON +#define ENCODE_MENU_STRING(str) ENCODE_UTF_8 (str) +#else +#define ENCODE_MENU_STRING(str) ENCODE_SYSTEM (str) +#endif + void set_frame_menubar (); static void push_menu_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object, @@ -1246,13 +1252,13 @@ single_submenu (item_key, item_name, maps) #ifndef HAVE_MULTILINGUAL_MENU if (STRING_MULTIBYTE (item_name)) { - item_name = ENCODE_SYSTEM (item_name); + item_name = ENCODE_MENU_STRING (item_name); AREF (menu_items, i + MENU_ITEMS_ITEM_NAME) = item_name; } if (STRINGP (descrip) && STRING_MULTIBYTE (descrip)) { - descrip = ENCODE_SYSTEM (descrip); + descrip = ENCODE_MENU_STRING (descrip); AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY) = descrip; } #endif /* not HAVE_MULTILINGUAL_MENU */ @@ -1705,12 +1711,12 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error) #ifndef HAVE_MULTILINGUAL_MENU if (STRINGP (item_name) && STRING_MULTIBYTE (item_name)) { - item_name = ENCODE_SYSTEM (item_name); + item_name = ENCODE_MENU_STRING (item_name); AREF (menu_items, i + MENU_ITEMS_ITEM_NAME) = item_name; } if (STRINGP (descrip) && STRING_MULTIBYTE (descrip)) { - descrip = ENCODE_SYSTEM (descrip); + descrip = ENCODE_MENU_STRING (descrip); AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY) = descrip; } #endif /* not HAVE_MULTILINGUAL_MENU */ @@ -1764,7 +1770,7 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error) #ifndef HAVE_MULTILINGUAL_MENU if (STRING_MULTIBYTE (title)) - title = ENCODE_SYSTEM (title); + title = ENCODE_MENU_STRING (title); #endif wv_title->name = (char *) SDATA (title); wv_title->enabled = TRUE; @@ -1813,6 +1819,10 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error) discard_mouse_events (); #endif + /* Must reset this manually because the button release event is not + passed to Emacs event loop. */ + FRAME_MAC_DISPLAY_INFO (f)->grabbed = 0; + /* Free the widget_value objects we used to specify the contents. */ free_menubar_widget_value_tree (first_wv); @@ -2219,8 +2229,18 @@ add_menu_item (MenuHandle menu, widget_value *wv, int submenu, strncat (item_name, wv->key, 255); } item_name[255] = 0; +#if TARGET_API_MAC_CARBON + { + CFStringRef string = + CFStringCreateWithCString (NULL, item_name, kCFStringEncodingUTF8); + + SetMenuItemTextWithCFString (menu, pos, string); + CFRelease (string); + } +#else c2pstr (item_name); SetMenuItemText (menu, pos, item_name); +#endif if (wv->enabled && !force_disable) #if TARGET_API_MAC_CARBON -- 2.39.2