Author: manolo
Date: 2011-02-01 13:31:57 -0800 (Tue, 01 Feb 2011)
New Revision: 8357
Log:
Mac OS only: added class Fl_Mac_App_Menu to support localization
of the application menu. Added corresponding Doxygen doc.

Modified:
   branches/branch-1.3/FL/mac.H
   branches/branch-1.3/documentation/src/osissues.dox
   branches/branch-1.3/src/Fl_cocoa.mm

Modified: branches/branch-1.3/FL/mac.H
===================================================================
--- branches/branch-1.3/FL/mac.H        2011-02-01 19:10:13 UTC (rev 8356)
+++ branches/branch-1.3/FL/mac.H        2011-02-01 21:31:57 UTC (rev 8357)
@@ -185,11 +185,13 @@
 
 #endif // FL_DOXYGEN
 
-/** \defgroup group_macosx Mac OS X-specific functions
- Mac OS X-specific functions declared in <FL/x.H> or <FL/gl.h>
+/** \defgroup group_macosx Mac OS X-specific symbols
+ Mac OS X-specific symbols declared in <FL/x.H> or <FL/gl.h>
  @{ */
 
-/** @brief Register a function called for each file dropped onto an 
application icon 
+/** @brief Register a function called for each file dropped onto an 
application icon.
+ \e cb will be called with a single Unix-style file name and path.
+ If multiple files were dropped, \e cb will be called multiple times.
  */
 extern void fl_open_callback(void (*cb)(const char *));
 
@@ -205,8 +207,39 @@
 
 /** \brief The version number of the running Mac OS X (e.g., 0x1064 for 10.6.4)
  */
-extern int fl_mac_os_version;          
+extern int fl_mac_os_version;
 
+/** To localize the application menu.
+ 
+ These character strings are used to build the application menu. They can be 
localized
+ at run time to any UTF-8 text by placing instructions such as these \e very 
+ early in the program:
+ \verbatim
+ #include <FL/x.H>
+ Fl_Mac_App_Menu::print = "Imprimer la fenĂȘtre";
+ \endverbatim
+ */
+class Fl_Mac_App_Menu {
+public:
+  /** Localizable text for the "About xxx" application menu item */
+  static const char *about;
+  /** Localizable text for the "Print Front Window" application menu item.
+   This menu item won't be displayed if Fl_Mac_App_Menu::print 
+   is set to an empty string.
+   */
+  static const char *print;
+  /** Localizable text for the "Services" application menu item */
+  static const char *services;
+  /** Localizable text for the "Hide xxx" application menu item */
+  static const char *hide;
+  /** Localizable text for the "Hide Others" application menu item */
+  static const char *hide_others;
+  /** Localizable text for the "Show All" application menu item */
+  static const char *show;
+  /** Localizable text for the "Quit xxx" application menu item */
+  static const char *quit;
+};
+
 /** @} */
 
 //

Modified: branches/branch-1.3/documentation/src/osissues.dox
===================================================================
--- branches/branch-1.3/documentation/src/osissues.dox  2011-02-01 19:10:13 UTC 
(rev 8356)
+++ branches/branch-1.3/documentation/src/osissues.dox  2011-02-01 21:31:57 UTC 
(rev 8357)
@@ -2,7 +2,11 @@
 
  \page osissues        Operating System Issues
 
-This appendix describes the operating system specific interfaces in FLTK.
+This appendix describes the operating system specific interfaces in FLTK:
+\li \ref osissues_accessing
+\li \ref osissues_unit
+\li \ref osissues_win32
+\li \ref osissues_macos
 
 \section osissues_accessing Accessing the OS Interfaces
 
@@ -676,7 +680,8 @@
 \par
 Whenever the user drops a file onto an application icon, OS X
 generates an Apple Event of the type "Open". You can have FLTK
-notify you of an Open event by setting the \c fl_open_callback
+notify you of an Open event by calling the \ref fl_open_callback 
+function.
 
 void fl_open_display()
 
@@ -699,19 +704,16 @@
 or \c NULL if not found. FLTK windows that are children of top-level
 windows share the \c Window of the top-level window.
 
-void \ref fl_open_callback(void (*cb)(const char *))
-
-\par
-\c cb will be called with a single Unix-style file name and path.
-If multiple files were dropped, \c fl_open_callback() will be called
-multiple times.
-
 void fl_mac_set_about( Fl_Callback *cb, void *user_data, int shortcut) 
 
 \par
 Attaches the callback \c cb to the "About myprog" item of the system 
application menu.
 \c cb will be called with NULL first argument and \c user_data second argument.
 
+Fl_Mac_App_Menu class
+\par 
+The Fl_Mac_App_Menu class allows to localize the application menu.
+
 Fl_Sys_Menu_Bar class
 
 \par

Modified: branches/branch-1.3/src/Fl_cocoa.mm
===================================================================
--- branches/branch-1.3/src/Fl_cocoa.mm 2011-02-01 19:10:13 UTC (rev 8356)
+++ branches/branch-1.3/src/Fl_cocoa.mm 2011-02-01 21:31:57 UTC (rev 8357)
@@ -2789,6 +2789,7 @@
     if ((float)h/win->h() < scale) scale = (float)h/win->h();
     printer.scale(scale, scale);
   }
+//#define ROTATE 1
 #ifdef ROTATE
   printer.scale(scale * 0.8, scale * 0.8);
   printer.printable_rect(&w, &h);
@@ -2804,6 +2805,14 @@
 }
 @end
 
+const char *Fl_Mac_App_Menu::about = "About ";
+const char *Fl_Mac_App_Menu::print = "Print Front Window";
+const char *Fl_Mac_App_Menu::services = "Services";
+const char *Fl_Mac_App_Menu::hide = "Hide ";
+const char *Fl_Mac_App_Menu::hide_others = "Hide Others";
+const char *Fl_Mac_App_Menu::show = "Show All";
+const char *Fl_Mac_App_Menu::quit = "Quit ";
+
 static NSMenu *appleMenu;
 static void createAppleMenu(void)
 {
@@ -2813,41 +2822,55 @@
   NSMenu *mainmenu, *services;
   NSMenuItem *menuItem;
   NSString *title;
-  CFStringRef nsappname;
-  
-  ProcessSerialNumber psn;
-  GetCurrentProcess(&psn);
-  CopyProcessName(&psn, &nsappname);
+
+  NSString *nsappname = [[NSProcessInfo processInfo] processName];
   appleMenu = [[NSMenu alloc] initWithTitle:@""];
   /* Add menu items */
-  title = [@"About " stringByAppendingString:(NSString*)nsappname];
+  title = [[NSString stringWithUTF8String:Fl_Mac_App_Menu::about] 
stringByAppendingString:nsappname];
   menuItem = [appleMenu addItemWithTitle:title action:@selector(showPanel) 
keyEquivalent:@""];
   FLaboutItemTarget *about = [[FLaboutItemTarget alloc] init];
   [menuItem setTarget:about];
   [appleMenu addItem:[NSMenuItem separatorItem]];
   // Print front window
-  menuItem = [appleMenu addItemWithTitle:@"Print front window" 
action:@selector(printPanel) keyEquivalent:@""];
-  [menuItem setTarget:about];
-  [appleMenu setAutoenablesItems:NO];
-  [menuItem setEnabled:YES];
-  [appleMenu addItem:[NSMenuItem separatorItem]];
+  if (strlen(Fl_Mac_App_Menu::print) > 0) {
+    menuItem = [appleMenu 
+               addItemWithTitle:[NSString 
stringWithUTF8String:Fl_Mac_App_Menu::print] 
+               action:@selector(printPanel) 
+               keyEquivalent:@""];
+    [menuItem setTarget:about];
+    [appleMenu setAutoenablesItems:NO];
+    [menuItem setEnabled:YES];
+    [appleMenu addItem:[NSMenuItem separatorItem]];
+    }
   // Services Menu
   services = [[NSMenu alloc] init];
-  [appleMenu addItemWithTitle:@"Services" action:nil keyEquivalent:@""];
-  [appleMenu setSubmenu: services forItem: [appleMenu itemWithTitle: 
@"Services"]];
+  menuItem = [appleMenu 
+             addItemWithTitle:[NSString 
stringWithUTF8String:Fl_Mac_App_Menu::services] 
+             action:nil 
+             keyEquivalent:@""];
+  [appleMenu setSubmenu:services forItem:menuItem];
+  [appleMenu addItem:[NSMenuItem separatorItem]];
   // Hide AppName
-  title = [@"Hide " stringByAppendingString:(NSString*)nsappname];
-  [appleMenu addItemWithTitle:title action:@selector(hide:) 
keyEquivalent:@"h"];
+  title = [[NSString stringWithUTF8String:Fl_Mac_App_Menu::hide] 
stringByAppendingString:nsappname];
+  [appleMenu addItemWithTitle:title 
+                      action:@selector(hide:) 
+               keyEquivalent:@"h"];
   // Hide Others
-  menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" 
action:@selector(hideOtherApplications:) 
-                                         keyEquivalent:@"h"];
+  menuItem = [appleMenu 
+             addItemWithTitle:[NSString 
stringWithUTF8String:Fl_Mac_App_Menu::hide_others] 
+             action:@selector(hideOtherApplications:) 
+             keyEquivalent:@"h"];
   [menuItem 
setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
   // Show All
-  [appleMenu addItemWithTitle:@"Show All" 
action:@selector(unhideAllApplications:) keyEquivalent:@""];
+  [appleMenu addItemWithTitle:[NSString 
stringWithUTF8String:Fl_Mac_App_Menu::show] 
+                      action:@selector(unhideAllApplications:) 
keyEquivalent:@""];
   [appleMenu addItem:[NSMenuItem separatorItem]];
   // Quit AppName
-  title = [@"Quit " stringByAppendingString:(NSString*)nsappname];
-  [appleMenu addItemWithTitle:title action:@selector(terminate:) 
keyEquivalent:@"q"];
+  title = [[NSString stringWithUTF8String:Fl_Mac_App_Menu::quit] 
+          stringByAppendingString:nsappname];
+  [appleMenu addItemWithTitle:title 
+                      action:@selector(terminate:) 
+               keyEquivalent:@"q"];
   /* Put menu into the menubar */
   menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil 
keyEquivalent:@""];
   [menuItem setSubmenu:appleMenu];
@@ -2860,7 +2883,6 @@
   }
   [NSApp setServicesMenu:services];
   [NSApp setMainMenu:mainmenu];
-  CFRelease(nsappname);
   [services release];
   [mainmenu release];
   [appleMenu release];

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to