changeset 56799:d2348e1fa995

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
author Steven Tamm <steventamm@mac.com>
date Thu, 26 Aug 2004 18:43:29 +0000
parents df3c9bb112b3
children 752ef76fcc08
files src/ChangeLog src/macmenu.c
diffstat 2 files changed, 34 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Thu Aug 26 18:28:44 2004 +0000
+++ b/src/ChangeLog	Thu Aug 26 18:43:29 2004 +0000
@@ -1,3 +1,12 @@
+2004-08-26  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* 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  <steventamm@mac.com>
 
 	* fileio.c (Fread_file_name): Call x_file_dialog on carbon on
--- a/src/macmenu.c	Thu Aug 26 18:28:44 2004 +0000
+++ b/src/macmenu.c	Thu Aug 26 18:43:29 2004 +0000
@@ -163,6 +163,12 @@
 
 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 @@
 #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 @@
 #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 @@
 
 #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 @@
   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 @@
 	  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