X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ca5e5bad86564bf71c095b755291f6997844b10a..8140eec95a05a0a56ea7f79d6d78e5e92669f26e:/src/mac/carbon/uma.cpp

diff --git a/src/mac/carbon/uma.cpp b/src/mac/carbon/uma.cpp
index dbdb59341f..7f12124698 100644
--- a/src/mac/carbon/uma.cpp
+++ b/src/mac/carbon/uma.cpp
@@ -21,9 +21,6 @@
 // windows manager, control manager, navigation services etc. are 
 // present
 
-#define wxUSE_MLTE 0
-
-
 static bool	sUMAHasAppearance = false ;
 static long sUMAAppearanceVersion = 0 ;
 static bool sUMAHasAquaLayout = false ;
@@ -51,9 +48,8 @@ void UMACleanupToolbox()
 	{
 		NavUnload() ;
 	}
-#if wxUSE_MLTE
-	TXNTerminateTextension( ) ;
-#endif
+  if ( TXNTerminateTextension != (void*) kUnresolvedCFragSymbolAddress )
+	  TXNTerminateTextension( ) ;
 }
 void UMAInitToolbox( UInt16 inMoreMastersCalls )
 {
@@ -94,7 +90,6 @@ void UMAInitToolbox( UInt16 inMoreMastersCalls )
 		sUMAHasWindowManager = sUMAWindowManagerAttr & gestaltWindowMgrPresent ;
 	}
 		
-#ifndef __DARWIN__
 #if TARGET_CARBON
 // Call currently implicitely done :		InitFloatingWindows() ;
 #else
@@ -102,7 +97,6 @@ void UMAInitToolbox( UInt16 inMoreMastersCalls )
 		InitFloatingWindows() ;
 	else
 		InitWindows();
-#endif
 #endif
 
 	if ( NavServicesAvailable() )
@@ -110,18 +104,40 @@ void UMAInitToolbox( UInt16 inMoreMastersCalls )
 		NavLoad() ;
 	}
 
-#if wxUSE_MLTE
-  TXNMacOSPreferredFontDescription defaults;
-  defaults.fontID = kFontIDGeneva ;
-  defaults.pointSize = (10 << 16) ;
-  defaults.fontStyle = kTXNDefaultFontStyle;
-  defaults.encoding = kTXNSystemDefaultEncoding;
-	TXNInitTextension(&defaults,  1, (kTXNAlwaysUseQuickDrawTextMask | kTXNWantMoviesMask | kTXNWantSoundMask | kTXNWantGraphicsMask));
-#endif
   long menuMgrAttr ;
   Gestalt( gestaltMenuMgrAttr , &menuMgrAttr ) ;
   if ( menuMgrAttr & gestaltMenuMgrAquaLayoutMask )
     sUMAHasAquaLayout = true ;
+
+  if ( TXNInitTextension != (void*) kUnresolvedCFragSymbolAddress )
+  { 
+    FontFamilyID fontId ;
+	Str255 fontName ;
+	SInt16 fontSize ;
+	Style fontStyle ;
+	GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
+    GetFNum( fontName, &fontId );
+
+    TXNMacOSPreferredFontDescription fontDescriptions[] =
+    {
+        { fontId , (fontSize << 16) ,kTXNDefaultFontStyle, kTXNSystemDefaultEncoding } ,
+    } ;
+    int noOfFontDescriptions = sizeof( fontDescriptions ) / sizeof(TXNMacOSPreferredFontDescription) ;
+#if 0 // TARGET_CARBON  
+    --noOfFontDescriptions ;
+#endif
+  	// kTXNAlwaysUseQuickDrawTextMask might be desirable because of speed increases but it crashes the app under OS X upon key stroke
+  	OptionBits options = kTXNWantMoviesMask | kTXNWantSoundMask | kTXNWantGraphicsMask ;
+#if TARGET_CARBON
+    if ( !UMAHasAquaLayout() )
+#endif
+    {
+        options |= kTXNAlwaysUseQuickDrawTextMask ;
+    }
+  	TXNInitTextension(fontDescriptions,  noOfFontDescriptions, options );
+  }
+
+
   sUMASystemInitialized = true ;
 
 }
@@ -206,40 +222,17 @@ void 			UMADisableMenuItem( MenuRef inMenu , MenuItemIndex inItem )
 
 void UMAAppendSubMenuItem( MenuRef menu , StringPtr l , SInt16 id ) 
 {
-	Str255 label ;
-	memcpy( label , l , l[0]+1 ) ;
-	// hardcoded adding of the submenu combination for mac
-
-	int theEnd = label[0] + 1; 
-	if (theEnd > 251) 
-		theEnd = 251; // mac allows only 255 characters
-	label[theEnd++] = '/';
-	label[theEnd++] = hMenuCmd; 
-	label[theEnd++] = '!';
-	label[theEnd++] = id ; 
-	label[theEnd] = 0x00;
-	label[0] = theEnd;
-	MacAppendMenu(menu, label);
+	MacAppendMenu(menu, l);
+	SetMenuItemHierarchicalID( menu , CountMenuItems( menu ) , id ) ;
 }
 
 void UMAInsertSubMenuItem( MenuRef menu , StringPtr l , MenuItemIndex item , SInt16 id  ) 
 {
-	Str255 label ;
-	memcpy( label , l , l[0]+1 ) ;
-	// hardcoded adding of the submenu combination for mac
-
-	int theEnd = label[0] + 1; 
-	if (theEnd > 251) 
-		theEnd = 251; // mac allows only 255 characters
-	label[theEnd++] = '/';
-	label[theEnd++] = hMenuCmd; 
-	label[theEnd++] = '!';
-	label[theEnd++] = id; 
-	label[theEnd] = 0x00;
-	label[0] = theEnd;
-	MacInsertMenuItem(menu, label , item);
+	MacInsertMenuItem(menu, l , item);
+	SetMenuItemHierarchicalID( menu , item , id ) ;
 }
 
+
 void UMAAppendMenuItem( MenuRef menu , StringPtr l , SInt16 key, UInt8 modifiers ) 
 {
 	Str255 label ;
@@ -588,8 +581,10 @@ OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState )
   return ::DrawThemePlacard( inRect , inState ) ;
 }
 
+#if !TARGET_CARBON
 static OSStatus helpMenuStatus = noErr ;
 static MenuItemIndex firstCustomItemIndex = 0 ;
+#endif
 
 OSStatus UMAGetHelpMenu(
   MenuRef *        outHelpMenu,