]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/utils_osx.cpp
Update copyright year in the version information resource.
[wxWidgets.git] / src / osx / utils_osx.cpp
index 7eb431ad8660ca5f12c82e7ce1c57733ce4942ed..438f7ddbf0bdb094b005ca4dd96dca45d34e6b8b 100644 (file)
@@ -246,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 ]);
+    }
 }
 
 //---------------------------------------------------------------------------