42 #include <private/qt_mac_p.h> 43 #include <private/qpixmap_mac_p.h> 44 #include <private/qnativeimage_p.h> 48 #ifdef QT_MAC_USE_COCOA 49 static CTFontRef CopyCTThemeFont(ThemeFontID themeID)
51 CTFontUIFontType ctID = HIThemeGetUIFontType(themeID);
52 return CTFontCreateUIFontForLanguage(ctID, 0, 0);
58 #ifndef QT_MAC_USE_COCOA 59 static const ScriptCode
Script = smRoman;
63 GetThemeFont(themeID, Script, f_name, &f_size, &f_style);
66 (
bool)(f_style & ::italic));
71 CFNumberRef num =
static_cast<CFNumberRef
>(CFDictionaryGetValue(dict, kCTFontWeightTrait));
73 CFNumberGetValue(num, kCFNumberFloat32Type, &fW);
75 num =
static_cast<CFNumberRef
>(CFDictionaryGetValue(dict, kCTFontSlantTrait));
76 CFNumberGetValue(num, kCFNumberFloatType, &fW);
77 bool italic = (fW != 0.0);
78 return QFont(familyName, CTFontGetSize(ctfont), wght, italic);
82 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) 86 CGColorSpaceModel model = CGColorSpaceGetModel(CGColorGetColorSpace(cgcolor));
87 const CGFloat *components = CGColorGetComponents(cgcolor);
88 if (model == kCGColorSpaceModelRGB) {
89 pc.
setRgbF(components[0], components[1], components[2], components[3]);
90 }
else if (model == kCGColorSpaceModelCMYK) {
91 pc.
setCmykF(components[0], components[1], components[2], components[3]);
92 }
else if (model == kCGColorSpaceModelMonochrome) {
93 pc.
setRgbF(components[0], components[0], components[0], components[1]);
96 qWarning(
"Qt: qcolorFromCGColor: cannot convert from colorspace model: %d", model);
105 HIThemeBrushCreateCGColor(brush, &cgClr);
112 #ifndef QT_MAC_USE_COCOA 113 # if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) 120 GetThemeBrushAsColor(brush, 32,
true, &rgbcolor);
121 return QColor(rgbcolor.red / 256, rgbcolor.green / 256, rgbcolor.blue / 256);
132 GetThemeTextColor(themeColor, 32,
true, &c);
133 QColor color =
QColor(c.red / 256, c.green / 256, c.blue / 256);
142 switch (themeColor) {
143 case kThemeTextColorAlertActive:
144 case kThemeTextColorTabFrontActive:
145 case kThemeTextColorBevelButtonActive:
146 case kThemeTextColorListView:
147 case kThemeTextColorPlacardActive:
148 case kThemeTextColorPopupButtonActive:
149 case kThemeTextColorPopupLabelActive:
150 case kThemeTextColorPushButtonActive:
152 case kThemeTextColorAlertInactive:
153 case kThemeTextColorDialogInactive:
154 case kThemeTextColorPlacardInactive:
155 return QColor(69, 69, 69, 255);
156 case kThemeTextColorPopupButtonInactive:
157 case kThemeTextColorPopupLabelInactive:
158 case kThemeTextColorPushButtonInactive:
159 case kThemeTextColorTabFrontInactive:
160 case kThemeTextColorBevelButtonInactive:
161 return QColor(127, 127, 127, 255);
164 CGRect cgrect = CGRectMake(0, 0, 16, 16);
165 HIThemeSetTextFill(themeColor, 0, nativeImage.cg, kHIThemeOrientationNormal);
166 CGContextFillRect(nativeImage.cg, cgrect);
The QColor class provides colors based on RGB, HSV or CMYK values.
#define QT_END_NAMESPACE
This macro expands to.
void setRgbF(qreal r, qreal g, qreal b, qreal a=1.0)
Sets the color channels of this color to r (red), g (green), b (blue) and a (alpha, transparency).
Weight
Qt uses a weighting scale from 0 to 99 similar to, but not the same as, the scales used in Windows or...
static QImage::Format systemFormat()
static QColor qcolorFromCGColor(CGColorRef cgcolor)
The QString class provides a Unicode character string.
QRgb pixel(int x, int y) const
Returns the color of the pixel at coordinates (x, y).
#define QT_BEGIN_NAMESPACE
This macro expands to.
void setCmykF(qreal c, qreal m, qreal y, qreal k, qreal a=1.0)
Sets the color to CMYK values, c (cyan), m (magenta), y (yellow), k (black), and a (alpha-channel...
Q_CORE_EXPORT void qWarning(const char *,...)
QFont qfontForThemeFont(ThemeFontID themeID)
The QFont class specifies a font used for drawing text.
QColor qcolorForThemeTextColor(ThemeTextColor themeColor)
QString qt_mac_from_pascal_string(const Str255 pstr)
static QColor leopardBrush(ThemeBrush brush)
QColor qcolorForTheme(ThemeBrush brush)
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...