]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/utils_osx.cpp
notify the event loop that synthesized events are on the queue, wait for them to...
[wxWidgets.git] / src / osx / utils_osx.cpp
index 0cd8cda71339cbad392d44fb57fa47c7b49bf37e..438f7ddbf0bdb094b005ca4dd96dca45d34e6b8b 100644 (file)
@@ -35,9 +35,7 @@
 
 // #include "MoreFilesX.h"
 
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
-    #include <AudioToolbox/AudioServices.h>
-#endif
+#include <AudioToolbox/AudioServices.h>
 
 #include "wx/osx/private.h"
 #include "wx/osx/private/timer.h"
@@ -248,9 +246,26 @@ CGColorSpaceRef wxMacGetGenericRGBColorSpace()
 
 CGColorRef wxMacCreateCGColorFromHITheme( ThemeBrush brush )
 {
-    CGColorRef color ;
-    HIThemeBrushCreateCGColor( brush, &color );
-    return color;
+    const int maxcachedbrush = 58+5; // negative indices are for metabrushes, cache down to -5)
+    int brushindex = brush+5;
+    if ( brushindex < 0 || brushindex > maxcachedbrush )
+    {
+        CGColorRef color ;
+        HIThemeBrushCreateCGColor( brush, &color );
+        return color;
+    }
+    else
+    {
+        static bool inited = false;
+        static CGColorRef themecolors[maxcachedbrush+1];
+        if ( !inited )
+        {
+            for ( int i = 0 ; i <= maxcachedbrush ; ++i )
+                HIThemeBrushCreateCGColor( i-5, &themecolors[i] );
+            inited = true;
+        }
+        return CGColorRetain(themecolors[brushindex ]);
+    }
 }
 
 //---------------------------------------------------------------------------