summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qt_mac.cpp
diff options
context:
space:
mode:
authorNorwegian Rock Cat <qt-info@nokia.com>2009-04-06 08:20:56 (GMT)
committerNorwegian Rock Cat <qt-info@nokia.com>2009-04-06 08:20:56 (GMT)
commitc350892f55a1d8633be54f09e6e4596f4687bc89 (patch)
treea4bb8a5ea183abeb669909bad4e17209660c7835 /src/gui/kernel/qt_mac.cpp
parentb11659ba9ea4532583398f6e539e78ed79a0c600 (diff)
downloadQt-c350892f55a1d8633be54f09e6e4596f4687bc89.zip
Qt-c350892f55a1d8633be54f09e6e4596f4687bc89.tar.gz
Qt-c350892f55a1d8633be54f09e6e4596f4687bc89.tar.bz2
Fix up color matching on 64-bit Cocoa.
It seems that GetThemeTextColor is not available at all for 64-bit versions of the operating system and there is no good equivalent. We were using a technique where we would create a small pixmap and then use HIThemeSetTextFillColor() with the proper enum. However, this function will silently set a black color if it doesn't know about the enum. So, we get black when we really shouldn't. It also seems to produce colors that are a bit different from the Carbon function. So, in the meantime, just hard code the values in. It might break if you are hacking the resources in Mac OS X, but we'll have to live with that until we get a real function. Task-number: 248918 Reviewed-by: Prasanth Ullattil
Diffstat (limited to 'src/gui/kernel/qt_mac.cpp')
-rw-r--r--src/gui/kernel/qt_mac.cpp45
1 files changed, 38 insertions, 7 deletions
diff --git a/src/gui/kernel/qt_mac.cpp b/src/gui/kernel/qt_mac.cpp
index 4703475..b1247e8 100644
--- a/src/gui/kernel/qt_mac.cpp
+++ b/src/gui/kernel/qt_mac.cpp
@@ -131,16 +131,47 @@ QColor qcolorForTheme(ThemeBrush brush)
QColor qcolorForThemeTextColor(ThemeTextColor themeColor)
{
-#ifndef QT_MAC_USE_COCOA
+#ifdef QT_OS_MAC32
RGBColor c;
GetThemeTextColor(themeColor, 32, true, &c);
- return QColor(c.red / 265, c.green / 256, c.blue / 256);
+ QColor color = QColor(c.red / 265, c.green / 256, c.blue / 256);
+ return color;
#else
- QNativeImage nativeImage(16,16, QNativeImage::systemFormat());
- CGRect cgrect = CGRectMake(0, 0, 16, 16);
- HIThemeSetTextFill(themeColor, 0, nativeImage.cg, kHIThemeOrientationNormal);
- CGContextFillRect(nativeImage.cg, cgrect);
- return QColor(nativeImage.image.pixel(0 , 0));
+ // There is no equivalent to GetThemeTextColor in 64-bit and it was rather bad that
+ // I didn't file a request to implement this for Snow Leopard. So, in the meantime
+ // I've encoded the values from the GetThemeTextColor. This is not exactly ideal
+ // as if someone really wants to mess with themeing, these colors will be wrong.
+ // It also means that we need to make sure the values for differences between
+ // OS releases (and it will be likely that we are a step behind.)
+ switch (themeColor) {
+ case kThemeTextColorAlertActive:
+ case kThemeTextColorTabFrontActive:
+ case kThemeTextColorBevelButtonActive:
+ case kThemeTextColorListView:
+ case kThemeTextColorPlacardActive:
+ case kThemeTextColorPopupButtonActive:
+ case kThemeTextColorPopupLabelActive:
+ case kThemeTextColorPushButtonActive:
+ return Qt::black;
+ case kThemeTextColorAlertInactive:
+ case kThemeTextColorDialogInactive:
+ case kThemeTextColorPlacardInactive:
+ return QColor(67, 69, 69, 255);
+ case kThemeTextColorPopupButtonInactive:
+ case kThemeTextColorPopupLabelInactive:
+ case kThemeTextColorPushButtonInactive:
+ case kThemeTextColorTabFrontInactive:
+ case kThemeTextColorBevelButtonInactive:
+ return QColor(123, 127, 127, 255);
+ default: {
+ QNativeImage nativeImage(16,16, QNativeImage::systemFormat());
+ CGRect cgrect = CGRectMake(0, 0, 16, 16);
+ HIThemeSetTextFill(themeColor, 0, nativeImage.cg, kHIThemeOrientationNormal);
+ CGContextFillRect(nativeImage.cg, cgrect);
+ QColor color = nativeImage.image.pixel(0,0);
+ return QColor(nativeImage.image.pixel(0 , 0));
+ }
+ }
#endif
}
QT_END_NAMESPACE