X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c0b301f4e599f2d89820e87d057ae5aa2233ab43..7c60222510bc5e197b12f153c4bf05db66cb0f4a:/src/osx/utils_osx.cpp diff --git a/src/osx/utils_osx.cpp b/src/osx/utils_osx.cpp index 7eb431ad86..438f7ddbf0 100644 --- a/src/osx/utils_osx.cpp +++ b/src/osx/utils_osx.cpp @@ -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 ]); + } } //---------------------------------------------------------------------------