Qt 4.8
Macros | Typedefs | Enumerations | Functions | Variables
qmacstyle_mac.mm File Reference
#include "qmacstyle_mac.h"
#include <private/qapplication_p.h>
#include <private/qcombobox_p.h>
#include <private/qmacstylepixmaps_mac_p.h>
#include <private/qpaintengine_mac_p.h>
#include <private/qpainter_p.h>
#include <private/qprintengine_mac_p.h>
#include <qapplication.h>
#include <qbitmap.h>
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qdialogbuttonbox.h>
#include <qdockwidget.h>
#include <qevent.h>
#include <qfocusframe.h>
#include <qformlayout.h>
#include <qgroupbox.h>
#include <qhash.h>
#include <qheaderview.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qlistview.h>
#include <qmainwindow.h>
#include <qmap.h>
#include <qmenubar.h>
#include <qpaintdevice.h>
#include <qpainter.h>
#include <qpixmapcache.h>
#include <qpointer.h>
#include <qprogressbar.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qrubberband.h>
#include <qsizegrip.h>
#include <qspinbox.h>
#include <qsplitter.h>
#include <qstyleoption.h>
#include <qtextedit.h>
#include <qtextstream.h>
#include <qtoolbar.h>
#include <qtoolbutton.h>
#include <qtreeview.h>
#include <qtableview.h>
#include <qwizard.h>
#include <qdebug.h>
#include <qlibrary.h>
#include <qdatetimeedit.h>
#include <qmath.h>
#include <QtGui/qgraphicsproxywidget.h>
#include <QtGui/qgraphicsview.h>
#include <private/qt_cocoa_helpers_mac_p.h>
#include "qmacstyle_mac_p.h"
#include <private/qstylehelper_p.h>
#include "moc_qmacstyle_mac.cpp"
#include "moc_qmacstyle_mac_p.cpp"

Go to the source code of this file.

Macros

#define QMAC_QAQUASTYLE_SIZE_CONSTRAIN
 

Typedefs

typedef HIRect *(* PtrHIShapeGetBounds) (HIShapeRef, HIRect *)
 

Enumerations

enum  ScrollBarCutoffType { thumbIndicatorCutoff = 0, scrollButtonsCutoff = 1 }
 

Functions

static QPixmap darkenPixmap (const QPixmap &pixmap)
 
void drawTabBase (QPainter *p, const QStyleOptionTabBarBaseV2 *tbb, const QWidget *w)
 
void drawTabCloseButton (QPainter *p, bool hover, bool active, bool selected)
 
void drawTabShape (QPainter *p, const QStyleOptionTabV3 *tabOpt)
 
static void drawToolbarButtonArrow (const QRect &toolButtonRect, ThemeDrawState tds, CGContextRef cg)
 
static int getControlSize (const QStyleOption *option, const QWidget *widget)
 
static ThemeTabDirection getTabDirection (QTabBar::Shape shape)
 
static bool isTreeView (const QWidget *widget)
 
static bool isVerticalTabs (const QTabBar::Shape shape)
 
static QSize qt_aqua_get_known_size (QStyle::ContentsType ct, const QWidget *widg, QSize szHint, QAquaWidgetSize sz)
 
static QAquaWidgetSize qt_aqua_guess_size (const QWidget *widg, QSize large, QSize small, QSize mini)
 
static HIRect qt_hirectForQRect (const QRect &convertRect, const QRect &rect=QRect())
 
static int qt_mac_aqua_get_metric (ThemeMetric met)
 
bool qt_mac_buttonIsRenderedFlat (const QPushButton *pushButton, const QStyleOptionButton *option)
 
CGContextRef qt_mac_cg_context (const QPaintDevice *)
 Returns the CoreGraphics CGContextRef of the paint device. More...
 
QRegion qt_mac_convert_mac_region (RgnHandle)
 
QRegion qt_mac_convert_mac_region (HIShapeRef)
 
void qt_mac_dispose_rgn (RgnHandle r)
 
void qt_mac_fill_background (QPainter *painter, const QRegion &rgn, const QBrush &brush)
 
static int qt_mac_hitheme_tab_version ()
 
bool qt_mac_is_metal (const QWidget *w)
 
QString qt_mac_removeMnemonics (const QString &original)
 
static const QRect qt_qrectForHIRect (const HIRect &hirect)
 
QRect rotateTabPainter (QPainter *p, QTabBar::Shape shape, QRect tabRect)
 
static int scrollButtonsCutoffSize (ScrollBarCutoffType cutoffType, QMacStyle::WidgetSizePolicy widgetSize)
 
static void setLayoutItemMargins (int left, int top, int right, int bottom, QRect *rect, Qt::LayoutDirection dir)
 

Variables

static int closeButtonSize = 12
 
static const int DisclosureOffset = 4
 
const int macItemFrame = 2
 
const int macItemHMargin = 3
 
const int macItemVMargin = 2
 
const int macRightBorder = 12
 
static const QColor mainWindowGradientBegin (240, 240, 240)
 
static const QColor mainWindowGradientEnd (200, 200, 200)
 
static PtrHIShapeGetBounds ptrHIShapeGetBounds = 0
 
QPixmapqt_mac_backgroundPattern = 0
 
const int qt_mac_hitheme_version = 0
 
QPaintDeviceqt_mac_safe_pdev
 
const ThemeWindowType QtWinType = kThemeDocumentWindow
 
static const QColor titlebarGradientActiveBegin (220, 220, 220)
 
static const QColor titlebarGradientActiveEnd (151, 151, 151)
 
static const QColor titlebarGradientInactiveBegin (241, 241, 241)
 
static const QColor titlebarGradientInactiveEnd (207, 207, 207)
 
static const QColor titlebarSeparatorLineActive (111, 111, 111)
 
static const QColor titlebarSeparatorLineInactive (131, 131, 131)
 

Macro Definition Documentation

◆ QMAC_QAQUASTYLE_SIZE_CONSTRAIN

#define QMAC_QAQUASTYLE_SIZE_CONSTRAIN

Definition at line 50 of file qmacstyle_mac.mm.

Typedef Documentation

◆ PtrHIShapeGetBounds

typedef HIRect*(* PtrHIShapeGetBounds) (HIShapeRef, HIRect *)

Definition at line 137 of file qmacstyle_mac.mm.

Enumeration Type Documentation

◆ ScrollBarCutoffType

Enumerator
thumbIndicatorCutoff 
scrollButtonsCutoff 

Definition at line 1344 of file qmacstyle_mac.mm.

Function Documentation

◆ darkenPixmap()

static QPixmap darkenPixmap ( const QPixmap pixmap)
inlinestatic

Definition at line 3142 of file qmacstyle_mac.mm.

Referenced by QMacStyle::drawControl().

3143 {
3145  int imgh = img.height();
3146  int imgw = img.width();
3147  int h, s, v, a;
3148  QRgb pixel;
3149  for (int y = 0; y < imgh; ++y) {
3150  for (int x = 0; x < imgw; ++x) {
3151  pixel = img.pixel(x, y);
3152  a = qAlpha(pixel);
3153  QColor hsvColor(pixel);
3154  hsvColor.getHsv(&h, &s, &v);
3155  s = qMin(100, s * 2);
3156  v = v / 2;
3157  hsvColor.setHsv(h, s, v);
3158  pixel = hsvColor.rgb();
3159  img.setPixel(x, y, qRgba(qRed(pixel), qGreen(pixel), qBlue(pixel), a));
3160  }
3161  }
3162  return QPixmap::fromImage(img);
3163 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
QImage toImage() const
Converts the pixmap to a QImage.
Definition: qpixmap.cpp:542
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition: qpixmap.cpp:2197
unsigned int QRgb
Definition: qrgb.h:53
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
long ASN1_INTEGER_get ASN1_INTEGER * a
QRgb pixel(int x, int y) const
Returns the color of the pixel at coordinates (x, y).
Definition: qimage.cpp:4240
int qRed(QRgb rgb)
Returns the red component of the ARGB quadruplet rgb.
Definition: qrgb.h:57
int qAlpha(QRgb rgba)
Returns the alpha component of the ARGB quadruplet rgba.
Definition: qrgb.h:66
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
void setPixel(int x, int y, uint index_or_rgb)
Sets the pixel index or color at (x, y) to index_or_rgb.
Definition: qimage.cpp:4311
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
Returns a copy of the image in the given format.
Definition: qimage.cpp:3966
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
int qGreen(QRgb rgb)
Returns the green component of the ARGB quadruplet rgb.
Definition: qrgb.h:60
int qBlue(QRgb rgb)
Returns the blue component of the ARGB quadruplet rgb.
Definition: qrgb.h:63
QRgb qRgba(int r, int g, int b, int a)
Returns the ARGB quadruplet ({a}, {r}, {g}, {b}).
Definition: qrgb.h:72

◆ drawTabBase()

void drawTabBase ( QPainter p,
const QStyleOptionTabBarBaseV2 tbb,
const QWidget w 
)

Definition at line 312 of file qmacstyle_mac.mm.

Referenced by QMacStyle::drawPrimitive().

313 {
314  QRect r = tbb->rect;
315  if (isVerticalTabs(tbb->shape)) {
316  r.setWidth(w->width());
317  } else {
318  r.setHeight(w->height());
319  }
320  QRect tabRect = rotateTabPainter(p, tbb->shape, r);
321  int width = tabRect.width();
322  int height = tabRect.height();
323  bool active = (tbb->state & QStyle::State_Active);
324 
325  // top border lines
326  QColor borderHighlightTop;
327  QColor borderTop;
328  if (active) {
329  borderTop = QColor(64, 64, 64);
330  borderHighlightTop = QColor(174, 174, 174);
331  } else {
332  borderTop = QColor(135, 135, 135);
333  borderHighlightTop = QColor(207, 207, 207);
334  }
335  p->setPen(borderHighlightTop);
336  p->drawLine(tabRect.x(), 0, width, 0);
337  p->setPen(borderTop);
338  p->drawLine(tabRect.x(), 1, width, 1);
339 
340  // center block
341  QRect centralRect(tabRect.x(), 2, width, height - 2);
342  if (active) {
343  QColor mainColor = QColor(120, 120, 120);
344  p->fillRect(centralRect, mainColor);
345  } else {
346  QLinearGradient gradient(centralRect.topLeft(), centralRect.bottomLeft());
347  gradient.setColorAt(0, QColor(165, 165, 165));
348  gradient.setColorAt(0.5, QColor(164, 164, 164));
349  gradient.setColorAt(1, QColor(158, 158, 158));
350  p->fillRect(centralRect, gradient);
351  }
352 
353  // bottom border lines
354  QColor borderHighlightBottom;
355  QColor borderBottom;
356  if (active) {
357  borderHighlightBottom = QColor(153, 153, 153);
358  borderBottom = QColor(64, 64, 64);
359  } else {
360  borderHighlightBottom = QColor(177, 177, 177);
361  borderBottom = QColor(127, 127, 127);
362  }
363  p->setPen(borderHighlightBottom);
364  p->drawLine(tabRect.x(), height - 2, width, height - 2);
365  p->setPen(borderBottom);
366  p->drawLine(tabRect.x(), height - 1, width, height - 1);
367 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
QRect rotateTabPainter(QPainter *p, QTabBar::Shape shape, QRect tabRect)
void setColorAt(qreal pos, const QColor &color)
Creates a stop point at the given position with the given color.
Definition: qbrush.cpp:1475
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
The QLinearGradient class is used in combination with QBrush to specify a linear gradient brush...
Definition: qbrush.h:280
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
void setWidth(int w)
Sets the width of the rectangle to the given width.
Definition: qrect.h:442
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QTabBar::Shape shape
the shape of the tab bar
Definition: qstyleoption.h:224
static bool isVerticalTabs(const QTabBar::Shape shape)
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420

◆ drawTabCloseButton()

void drawTabCloseButton ( QPainter p,
bool  hover,
bool  active,
bool  selected 
)

Definition at line 151 of file qmacstyle_mac.mm.

Referenced by QMacStyle::drawPrimitive().

152 {
153  // draw background circle
156  QColor background;
157  if (hover) {
158  background = QColor(124, 124, 124);
159  } else {
160  if (active) {
161  if (selected)
162  background = QColor(104, 104, 104);
163  else
164  background = QColor(83, 83, 83);
165  } else {
166  if (selected)
167  background = QColor(144, 144, 144);
168  else
169  background = QColor(114, 114, 114);
170  }
171  }
173  p->setBrush(background);
174  p->drawEllipse(rect);
175 
176  // draw cross
177  int min = 3;
178  int max = 9;
179  QPen crossPen;
180  crossPen.setColor(QColor(194, 194, 194));
181  crossPen.setWidthF(1.3);
182  crossPen.setCapStyle(Qt::FlatCap);
183  p->setPen(crossPen);
184  p->drawLine(min, min, max, max);
185  p->drawLine(min, max, max, min);
186 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
static int closeButtonSize
void setCapStyle(Qt::PenCapStyle pcs)
Sets the pen&#39;s cap style to the given style.
Definition: qpen.cpp:723
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
void setColor(const QColor &color)
Sets the color of this pen&#39;s brush to the given color.
Definition: qpen.cpp:787
void drawEllipse(const QRectF &r)
Draws the ellipse defined by the given rectangle.
Definition: qpainter.cpp:4464
void setRenderHints(RenderHints hints, bool on=true)
Sets the given render hints on the painter if on is true; otherwise clears the render hints...
Definition: qpainter.cpp:7649
void setWidthF(qreal width)
Sets the pen width to the given width in pixels with floating point precision.
Definition: qpen.cpp:690
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ drawTabShape()

void drawTabShape ( QPainter p,
const QStyleOptionTabV3 tabOpt 
)

Definition at line 211 of file qmacstyle_mac.mm.

Referenced by QMacStyle::drawControl().

212 {
213  QRect r = tabOpt->rect;
214  p->translate(tabOpt->rect.x(), tabOpt->rect.y());
215  r.moveLeft(0);
216  r.moveTop(0);
217  QRect tabRect = rotateTabPainter(p, tabOpt->shape, r);
218 
219  int width = tabRect.width();
220  int height = 20;
221  bool active = (tabOpt->state & QStyle::State_Active);
222  bool selected = (tabOpt->state & QStyle::State_Selected);
223 
224  if (selected) {
225  QRect rect(1, 0, width - 2, height);
226 
227  // fill body
228  if (active) {
229  int d = (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) ? 16 : 0;
230  p->fillRect(rect, QColor(151 + d, 151 + d, 151 + d));
231  } else {
232  int d = (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) ? 9 : 0;
233  QLinearGradient gradient(rect.topLeft(), rect.bottomLeft());
234  gradient.setColorAt(0, QColor(207 + d, 207 + d, 207 + d));
235  gradient.setColorAt(0.5, QColor(206 + d, 206 + d, 206 + d));
236  gradient.setColorAt(1, QColor(201 + d, 201 + d, 201 + d));
237  p->fillRect(rect, gradient);
238  }
239 
240  // draw border
241  QColor borderSides;
242  QColor borderBottom;
243  if (active) {
244  borderSides = QColor(88, 88, 88);
245  borderBottom = QColor(88, 88, 88);
246  } else {
247  borderSides = QColor(121, 121, 121);
248  borderBottom = QColor(116, 116, 116);
249  }
250 
251  p->setPen(borderSides);
252 
253  int bottom = height;
254  // left line
255  p->drawLine(0, 1, 0, bottom-2);
256  // right line
257  p->drawLine(width-1, 1, width-1, bottom-2);
258 
259  // bottom line
260  if (active) {
261  p->setPen(QColor(168, 168, 168));
262  p->drawLine(3, bottom-1, width-3, bottom-1);
263  }
264  p->setPen(borderBottom);
265  p->drawLine(2, bottom, width-2, bottom);
266 
267  int w = 3;
268  QRectF rectangleLeft(1, height - w, w, w);
269  QRectF rectangleRight(width - 2, height - 1, w, w);
270  int startAngle = 180 * 16;
271  int spanAngle = 90 * 16;
273  p->drawArc(rectangleLeft, startAngle, spanAngle);
274  p->drawArc(rectangleRight, startAngle, -spanAngle);
275  } else {
276  // when the mouse is over non selected tabs they get a new color
277  bool hover = (tabOpt->state & QStyle::State_MouseOver);
278  if (hover) {
279  QRect rect(1, 2, width - 1, height - 1);
280  p->fillRect(rect, QColor(110, 110, 110));
281  }
282 
283  // seperator lines between tabs
284  bool west = (tabOpt->shape == QTabBar::RoundedWest || tabOpt->shape == QTabBar::TriangularWest);
285  bool drawOnRight = !west;
286  if ((!drawOnRight && tabOpt->selectedPosition != QStyleOptionTab::NextIsSelected)
287  || (drawOnRight && tabOpt->selectedPosition != QStyleOptionTab::NextIsSelected)) {
288  QColor borderColor;
289  QColor borderHighlightColor;
290  if (active) {
291  borderColor = QColor(64, 64, 64);
292  borderHighlightColor = QColor(140, 140, 140);
293  } else {
294  borderColor = QColor(135, 135, 135);
295  borderHighlightColor = QColor(178, 178, 178);
296  }
297 
298  int x = drawOnRight ? width : 0;
299 
300  // tab seperator line
301  p->setPen(borderColor);
302  p->drawLine(x, 2, x, height + 1);
303 
304  // tab seperator highlight
305  p->setPen(borderHighlightColor);
306  p->drawLine(x-1, 2, x-1, height + 1);
307  p->drawLine(x+1, 2, x+1, height + 1);
308  }
309  }
310 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
void drawArc(const QRectF &rect, int a, int alen)
Draws the arc defined by the given rectangle, startAngle and spanAngle.
Definition: qpainter.cpp:4602
QRect rotateTabPainter(QPainter *p, QTabBar::Shape shape, QRect tabRect)
void setColorAt(qreal pos, const QColor &color)
Creates a stop point at the given position with the given color.
Definition: qbrush.cpp:1475
void moveLeft(int pos)
Moves the rectangle horizontally, leaving the rectangle&#39;s left edge at the given x coordinate...
Definition: qrect.h:350
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
QTabBar::Shape shape
the tab shape used to draw the tab; by default QTabBar::RoundedNorth
Definition: qstyleoption.h:316
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
Definition: qpainter.cpp:7620
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
SelectedPosition selectedPosition
the position of the selected tab in relation to this tab
Definition: qstyleoption.h:321
The QLinearGradient class is used in combination with QBrush to specify a linear gradient brush...
Definition: qbrush.h:280
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
Definition: qglobal.h:1646
void moveTop(int pos)
Moves the rectangle vertically, leaving the rectangle&#39;s top edge at the given y coordinate.
Definition: qrect.h:353
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
Definition: qpainter.cpp:3311

◆ drawToolbarButtonArrow()

static void drawToolbarButtonArrow ( const QRect toolButtonRect,
ThemeDrawState  tds,
CGContextRef  cg 
)
inlinestatic

Definition at line 4650 of file qmacstyle_mac.mm.

Referenced by QMacStyle::drawComplexControl().

4651 {
4652  QRect arrowRect = QRect(toolButtonRect.right() - 9, toolButtonRect.bottom() - 9, 7, 5);
4653  HIThemePopupArrowDrawInfo padi;
4654  padi.version = qt_mac_hitheme_version;
4655  padi.state = tds;
4656  padi.orientation = kThemeArrowDown;
4657  padi.size = kThemeArrow7pt;
4658  HIRect hirect = qt_hirectForQRect(arrowRect);
4659  HIThemeDrawPopupArrow(&hirect, &padi, cg, kHIThemeOrientationNormal);
4660 }
const int qt_mac_hitheme_version
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
static HIRect qt_hirectForQRect(const QRect &convertRect, const QRect &rect=QRect())
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ getControlSize()

static int getControlSize ( const QStyleOption option,
const QWidget widget 
)
static

Definition at line 369 of file qmacstyle_mac.mm.

Referenced by QMacStyle::layoutSpacingImplementation(), QMacStyle::pixelMetric(), and QMacStyle::subElementRect().

370 {
371  if (option) {
372  if (option->state & (QStyle::State_Small | QStyle::State_Mini))
373  return (option->state & QStyle::State_Mini) ? QAquaSizeMini : QAquaSizeSmall;
374  } else if (widget) {
375  switch (QMacStyle::widgetSizePolicy(widget)) {
377  return QAquaSizeSmall;
378  case QMacStyle::SizeMini:
379  return QAquaSizeMini;
380  default:
381  break;
382  }
383  }
384  return QAquaSizeLarge;
385 }
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
static WidgetSizePolicy widgetSizePolicy(const QWidget *w)

◆ getTabDirection()

static ThemeTabDirection getTabDirection ( QTabBar::Shape  shape)
inlinestatic

Definition at line 421 of file qmacstyle_mac.mm.

Referenced by QMacStyle::drawControl(), QMacStyle::drawPrimitive(), QMacStyle::sizeFromContents(), and QMacStyle::subElementRect().

422 {
423  ThemeTabDirection ttd;
424  switch (shape) {
427  ttd = kThemeTabSouth;
428  break;
429  default: // Added to remove the warning, since all values are taken care of, really!
432  ttd = kThemeTabNorth;
433  break;
436  ttd = kThemeTabWest;
437  break;
440  ttd = kThemeTabEast;
441  break;
442  }
443  return ttd;
444 }

◆ isTreeView()

static bool isTreeView ( const QWidget widget)
inlinestatic

Definition at line 388 of file qmacstyle_mac.mm.

Referenced by qt_aqua_get_known_size().

389 {
390  return (widget && widget->parentWidget() &&
391  (qobject_cast<const QTreeView *>(widget->parentWidget())
392 #ifdef QT3_SUPPORT
393  || widget->parentWidget()->inherits("Q3ListView")
394 #endif
395  ));
396 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
T * qobject_cast(QObject *object)
Definition: qobject.h:375
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition: qobject.h:275

◆ isVerticalTabs()

static bool isVerticalTabs ( const QTabBar::Shape  shape)
static

Definition at line 144 of file qmacstyle_mac.mm.

Referenced by drawTabBase(), and rotateTabPainter().

144  {
145  return (shape == QTabBar::RoundedEast
146  || shape == QTabBar::TriangularEast
147  || shape == QTabBar::RoundedWest
148  || shape == QTabBar::TriangularWest);
149 }

◆ qt_aqua_get_known_size()

static QSize qt_aqua_get_known_size ( QStyle::ContentsType  ct,
const QWidget widg,
QSize  szHint,
QAquaWidgetSize  sz 
)
static

Definition at line 511 of file qmacstyle_mac.mm.

Referenced by QMacStylePrivate::aquaSizeConstrain(), and QMacStyle::pixelMetric().

513 {
514  QSize ret(-1, -1);
515  if (sz != QAquaSizeSmall && sz != QAquaSizeLarge && sz != QAquaSizeMini) {
516  qDebug("Not sure how to return this...");
517  return ret;
518  }
520  // If you're using a custom font and it's bigger than the default font,
521  // then no constraints for you. If you are smaller, we can try to help you out
522  QFont font = qt_app_fonts_hash()->value(widg->metaObject()->className(), QFont());
523  if (widg->font().pointSize() > font.pointSize())
524  return ret;
525  }
526 
527  if (ct == QStyle::CT_CustomBase && widg) {
528  if (qobject_cast<const QPushButton *>(widg))
530  else if (qobject_cast<const QRadioButton *>(widg))
532  else if (qobject_cast<const QCheckBox *>(widg))
533  ct = QStyle::CT_CheckBox;
534  else if (qobject_cast<const QComboBox *>(widg))
535  ct = QStyle::CT_ComboBox;
536  else if (qobject_cast<const QToolButton *>(widg))
538  else if (qobject_cast<const QSlider *>(widg))
539  ct = QStyle::CT_Slider;
540  else if (qobject_cast<const QProgressBar *>(widg))
542  else if (qobject_cast<const QLineEdit *>(widg))
543  ct = QStyle::CT_LineEdit;
544  else if (qobject_cast<const QHeaderView *>(widg)
545 #ifdef QT3_SUPPORT
546  || widg->inherits("Q3Header")
547 #endif
548  )
550  else if (qobject_cast<const QMenuBar *>(widg)
551 #ifdef QT3_SUPPORT
552  || widg->inherits("Q3MenuBar")
553 #endif
554  )
555  ct = QStyle::CT_MenuBar;
556  else if (qobject_cast<const QSizeGrip *>(widg))
557  ct = QStyle::CT_SizeGrip;
558  else
559  return ret;
560  }
561 
562  switch (ct) {
563  case QStyle::CT_PushButton: {
564  const QPushButton *psh = qobject_cast<const QPushButton *>(widg);
565  // If this comparison is false, then the widget was not a push button.
566  // This is bad and there's very little we can do since we were requested to find a
567  // sensible size for a widget that pretends to be a QPushButton but is not.
568  if(psh) {
569  QString buttonText = qt_mac_removeMnemonics(psh->text());
570  if (buttonText.contains(QLatin1Char('\n')))
571  ret = QSize(-1, -1);
572  else if (sz == QAquaSizeLarge)
573  ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricPushButtonHeight));
574  else if (sz == QAquaSizeSmall)
575  ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricSmallPushButtonHeight));
576  else if (sz == QAquaSizeMini)
577  ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricMiniPushButtonHeight));
578 
579  if (!psh->icon().isNull()){
580  // If the button got an icon, and the icon is larger than the
581  // button, we can't decide on a default size
582  ret.setWidth(-1);
583  if (ret.height() < psh->iconSize().height())
584  ret.setHeight(-1);
585  }
586  else if (buttonText == QLatin1String("OK") || buttonText == QLatin1String("Cancel")){
587  // Aqua Style guidelines restrict the size of OK and Cancel buttons to 68 pixels.
588  // However, this doesn't work for German, therefore only do it for English,
589  // I suppose it would be better to do some sort of lookups for languages
590  // that like to have really long words.
591  ret.setWidth(77 - 8);
592  }
593  } else {
594  // The only sensible thing to do is to return whatever the style suggests...
595  if (sz == QAquaSizeLarge)
596  ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricPushButtonHeight));
597  else if (sz == QAquaSizeSmall)
598  ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricSmallPushButtonHeight));
599  else if (sz == QAquaSizeMini)
600  ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricMiniPushButtonHeight));
601  else
602  // Since there's no default size we return the large size...
603  ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricPushButtonHeight));
604  }
605 #if 0 //Not sure we are applying the rules correctly for RadioButtons/CheckBoxes --Sam
606  } else if (ct == QStyle::CT_RadioButton) {
607  QRadioButton *rdo = static_cast<QRadioButton *>(widg);
608  // Exception for case where multiline radio button text requires no size constrainment
609  if (rdo->text().find('\n') != -1)
610  return ret;
611  if (sz == QAquaSizeLarge)
612  ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricRadioButtonHeight));
613  else if (sz == QAquaSizeSmall)
614  ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricSmallRadioButtonHeight));
615  else if (sz == QAquaSizeMini)
616  ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricMiniRadioButtonHeight));
617  } else if (ct == QStyle::CT_CheckBox) {
618  if (sz == QAquaSizeLarge)
619  ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricCheckBoxHeight));
620  else if (sz == QAquaSizeSmall)
621  ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricSmallCheckBoxHeight));
622  else if (sz == QAquaSizeMini)
623  ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricMiniCheckBoxHeight));
624 #endif
625  break;
626  }
627  case QStyle::CT_SizeGrip:
628  if (sz == QAquaSizeLarge || sz == QAquaSizeSmall) {
629  HIRect r;
630  HIPoint p = { 0, 0 };
631  HIThemeGrowBoxDrawInfo gbi;
632  gbi.version = 0;
633  gbi.state = kThemeStateActive;
634  gbi.kind = kHIThemeGrowBoxKindNormal;
635  gbi.direction = QApplication::isRightToLeft() ? kThemeGrowLeft | kThemeGrowDown
636  : kThemeGrowRight | kThemeGrowDown;
637  gbi.size = sz == QAquaSizeSmall ? kHIThemeGrowBoxSizeSmall : kHIThemeGrowBoxSizeNormal;
638  if (HIThemeGetGrowBoxBounds(&p, &gbi, &r) == noErr)
639  ret = QSize(r.size.width, r.size.height);
640  }
641  break;
642  case QStyle::CT_ComboBox:
643  switch (sz) {
644  case QAquaSizeLarge:
645  ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricPopupButtonHeight));
646  break;
647  case QAquaSizeSmall:
648  ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricSmallPopupButtonHeight));
649  break;
650  case QAquaSizeMini:
651  ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricMiniPopupButtonHeight));
652  break;
653  default:
654  break;
655  }
656  break;
658  if (sz == QAquaSizeSmall) {
659  int width = 0, height = 0;
660  if (szHint == QSize(-1, -1)) { //just 'guess'..
661  const QToolButton *bt = qobject_cast<const QToolButton *>(widg);
662  // If this conversion fails then the widget was not what it claimed to be.
663  if(bt) {
664  if (!bt->icon().isNull()) {
665  QSize iconSize = bt->iconSize();
666  QSize pmSize = bt->icon().actualSize(QSize(32, 32), QIcon::Normal);
667  width = qMax(width, qMax(iconSize.width(), pmSize.width()));
668  height = qMax(height, qMax(iconSize.height(), pmSize.height()));
669  }
670  if (!bt->text().isNull() && bt->toolButtonStyle() != Qt::ToolButtonIconOnly) {
671  int text_width = bt->fontMetrics().width(bt->text()),
672  text_height = bt->fontMetrics().height();
674  width = qMax(width, text_width);
675  height += text_height;
676  } else {
677  width += text_width;
678  width = qMax(height, text_height);
679  }
680  }
681  } else {
682  // Let's return the size hint...
683  width = szHint.width();
684  height = szHint.height();
685  }
686  } else {
687  width = szHint.width();
688  height = szHint.height();
689  }
690  width = qMax(20, width + 5); //border
691  height = qMax(20, height + 5); //border
692  ret = QSize(width, height);
693  }
694  break;
695  case QStyle::CT_Slider: {
696  int w = -1;
697  const QSlider *sld = qobject_cast<const QSlider *>(widg);
698  // If this conversion fails then the widget was not what it claimed to be.
699  if(sld) {
700  if (sz == QAquaSizeLarge) {
701  if (sld->orientation() == Qt::Horizontal) {
702  w = qt_mac_aqua_get_metric(kThemeMetricHSliderHeight);
703  if (sld->tickPosition() != QSlider::NoTicks)
704  w += qt_mac_aqua_get_metric(kThemeMetricHSliderTickHeight);
705  } else {
706  w = qt_mac_aqua_get_metric(kThemeMetricVSliderWidth);
707  if (sld->tickPosition() != QSlider::NoTicks)
708  w += qt_mac_aqua_get_metric(kThemeMetricVSliderTickWidth);
709  }
710  } else if (sz == QAquaSizeSmall) {
711  if (sld->orientation() == Qt::Horizontal) {
712  w = qt_mac_aqua_get_metric(kThemeMetricSmallHSliderHeight);
713  if (sld->tickPosition() != QSlider::NoTicks)
714  w += qt_mac_aqua_get_metric(kThemeMetricSmallHSliderTickHeight);
715  } else {
716  w = qt_mac_aqua_get_metric(kThemeMetricSmallVSliderWidth);
717  if (sld->tickPosition() != QSlider::NoTicks)
718  w += qt_mac_aqua_get_metric(kThemeMetricSmallVSliderTickWidth);
719  }
720  } else if (sz == QAquaSizeMini) {
721  if (sld->orientation() == Qt::Horizontal) {
722  w = qt_mac_aqua_get_metric(kThemeMetricMiniHSliderHeight);
723  if (sld->tickPosition() != QSlider::NoTicks)
724  w += qt_mac_aqua_get_metric(kThemeMetricMiniHSliderTickHeight);
725  } else {
726  w = qt_mac_aqua_get_metric(kThemeMetricMiniVSliderWidth);
727  if (sld->tickPosition() != QSlider::NoTicks)
728  w += qt_mac_aqua_get_metric(kThemeMetricMiniVSliderTickWidth);
729  }
730  }
731  } else {
732  // This is tricky, we were requested to find a size for a slider which is not
733  // a slider. We don't know if this is vertical or horizontal or if we need to
734  // have tick marks or not.
735  // For this case we will return an horizontal slider without tick marks.
736  w = qt_mac_aqua_get_metric(kThemeMetricHSliderHeight);
737  w += qt_mac_aqua_get_metric(kThemeMetricHSliderTickHeight);
738  }
739  if (sld->orientation() == Qt::Horizontal)
740  ret.setHeight(w);
741  else
742  ret.setWidth(w);
743  break;
744  }
745  case QStyle::CT_ProgressBar: {
746  int finalValue = -1;
748  if (const QProgressBar *pb = qobject_cast<const QProgressBar *>(widg))
749  orient = pb->orientation();
750 
751  if (sz == QAquaSizeLarge)
752  finalValue = qt_mac_aqua_get_metric(kThemeMetricLargeProgressBarThickness)
753  + qt_mac_aqua_get_metric(kThemeMetricProgressBarShadowOutset);
754  else
755  finalValue = qt_mac_aqua_get_metric(kThemeMetricNormalProgressBarThickness)
756  + qt_mac_aqua_get_metric(kThemeMetricSmallProgressBarShadowOutset);
757  if (orient == Qt::Horizontal)
758  ret.setHeight(finalValue);
759  else
760  ret.setWidth(finalValue);
761  break;
762  }
763  case QStyle::CT_LineEdit:
764  if (!widg || !qobject_cast<QComboBox *>(widg->parentWidget())) {
765  //should I take into account the font dimentions of the lineedit? -Sam
766  if (sz == QAquaSizeLarge)
767  ret = QSize(-1, 21);
768  else
769  ret = QSize(-1, 19);
770  }
771  break;
773  if (isTreeView(widg))
774  ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricListHeaderHeight));
775  break;
776  case QStyle::CT_MenuBar:
777  if (sz == QAquaSizeLarge) {
778 #ifndef QT_MAC_USE_COCOA
779  SInt16 size;
780  if (!GetThemeMenuBarHeight(&size))
781  ret = QSize(-1, size);
782 #else
783  ret = QSize(-1, [[NSApp mainMenu] menuBarHeight]);
784  // In the qt_mac_set_native_menubar(false) case,
785  // we come it here with a zero-height main menu,
786  // preventing the in-window menu from displaying.
787  // Use 22 pixels for the height, by observation.
788  if (ret.height() <= 0)
789  ret.setHeight(22);
790 #endif
791  }
792  break;
793  default:
794  break;
795  }
796  return ret;
797 }
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
QString qt_mac_removeMnemonics(const QString &original)
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
int width(const QString &, int len=-1) const
Returns the width in pixels of the first len characters of text.
Qt::ToolButtonStyle toolButtonStyle
whether the tool button displays an icon only, text only, or text beside/below the icon...
Definition: qtoolbutton.h:66
QString text() const
QFont font
the font currently set for the widget
Definition: qwidget.h:181
The QPushButton widget provides a command button.
Definition: qpushbutton.h:57
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QProgressBar widget provides a horizontal or vertical progress bar.
Definition: qprogressbar.h:58
The QString class provides a Unicode character string.
Definition: qstring.h:83
TickPosition tickPosition
the tickmark position for this slider
Definition: qslider.h:62
T * qobject_cast(QObject *object)
Definition: qobject.h:375
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
Q_CORE_EXPORT void qDebug(const char *,...)
int width() const
Returns the width.
Definition: qsize.h:126
The QRadioButton widget provides a radio button with a text label.
Definition: qradiobutton.h:56
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Definition: qicon.cpp:769
QFontMetrics fontMetrics() const
Returns the font metrics for the widget&#39;s current font.
Definition: qwidget.h:984
static int qt_mac_aqua_get_metric(ThemeMetric met)
Qt::Orientation orientation() const
FontHash * qt_app_fonts_hash()
The QSlider widget provides a vertical or horizontal slider.
Definition: qslider.h:57
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition: qobject.h:275
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
QSize iconSize() const
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
QSize actualSize(const QSize &size, Mode mode=Normal, State state=Off) const
Returns the actual size of the icon for the requested size, mode, and state.
Definition: qicon.cpp:730
static bool desktopSettingsAware()
Returns true if Qt is set to use the system&#39;s standard colors, fonts, etc.
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
int height() const
Returns the height.
Definition: qsize.h:129
int pointSize() const
Returns the point size of the font.
Definition: qfont.cpp:981
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
static bool isTreeView(const QWidget *widget)
The QToolButton class provides a quick-access button to commands or options, usually used inside a QT...
Definition: qtoolbutton.h:59
int height() const
Returns the height of the font.
Orientation
Definition: qnamespace.h:174
static bool isRightToLeft()
Returns true if the application&#39;s layout direction is Qt::RightToLeft; otherwise returns false...
Definition: qapplication.h:233
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
QIcon icon() const

◆ qt_aqua_guess_size()

static QAquaWidgetSize qt_aqua_guess_size ( const QWidget widg,
QSize  large,
QSize  small,
QSize  mini 
)
static

Definition at line 801 of file qmacstyle_mac.mm.

Referenced by QMacStylePrivate::aquaSizeConstrain().

802 {
803  if (large == QSize(-1, -1)) {
804  if (small != QSize(-1, -1))
805  return QAquaSizeSmall;
806  if (mini != QSize(-1, -1))
807  return QAquaSizeMini;
808  return QAquaSizeUnknown;
809  } else if (small == QSize(-1, -1)) {
810  if (mini != QSize(-1, -1))
811  return QAquaSizeMini;
812  return QAquaSizeLarge;
813  } else if (mini == QSize(-1, -1)) {
814  return QAquaSizeLarge;
815  }
816 
817 #ifndef QT_NO_MAINWINDOW
818  if (qobject_cast<QDockWidget *>(widg->window()) || !qgetenv("QWIDGET_ALL_SMALL").isNull()) {
819  //if (small.width() != -1 || small.height() != -1)
820  return QAquaSizeSmall;
821  } else if (!qgetenv("QWIDGET_ALL_MINI").isNull()) {
822  return QAquaSizeMini;
823  }
824 #endif
825 
826 #if 0
827  /* Figure out which size we're closer to, I just hacked this in, I haven't
828  tested it as it would probably look pretty strange to have some widgets
829  big and some widgets small in the same window?? -Sam */
830  int large_delta=0;
831  if (large.width() != -1) {
832  int delta = large.width() - widg->width();
833  large_delta += delta * delta;
834  }
835  if (large.height() != -1) {
836  int delta = large.height() - widg->height();
837  large_delta += delta * delta;
838  }
839  int small_delta=0;
840  if (small.width() != -1) {
841  int delta = small.width() - widg->width();
842  small_delta += delta * delta;
843  }
844  if (small.height() != -1) {
845  int delta = small.height() - widg->height();
846  small_delta += delta * delta;
847  }
848  int mini_delta=0;
849  if (mini.width() != -1) {
850  int delta = mini.width() - widg->width();
851  mini_delta += delta * delta;
852  }
853  if (mini.height() != -1) {
854  int delta = mini.height() - widg->height();
855  mini_delta += delta * delta;
856  }
857  if (mini_delta < small_delta && mini_delta < large_delta)
858  return QAquaSizeMini;
859  else if (small_delta < large_delta)
860  return QAquaSizeSmall;
861 #endif
862  return QAquaSizeLarge;
863 }
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
int width() const
Returns the width.
Definition: qsize.h:126
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
bool isNull() const
Returns true if this byte array is null; otherwise returns false.
int height() const
Returns the height.
Definition: qsize.h:129
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ qt_hirectForQRect()

static HIRect qt_hirectForQRect ( const QRect convertRect,
const QRect rect = QRect() 
)
inlinestatic

Definition at line 478 of file qmacstyle_mac.mm.

Referenced by QMacStyle::drawComplexControl(), QMacStyle::drawControl(), QMacStyle::drawPrimitive(), drawToolbarButtonArrow(), QMacStylePrivate::getSliderInfo(), QMacStyle::hitTestComplexControl(), QMacStyle::pixelMetric(), QMacStylePrivate::pushButtonContentBounds(), and QMacStyle::subControlRect().

479 {
480  return CGRectMake(convertRect.x() + rect.x(), convertRect.y() + rect.y(),
481  convertRect.width() - rect.width(), convertRect.height() - rect.height());
482 }
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252

◆ qt_mac_aqua_get_metric()

static int qt_mac_aqua_get_metric ( ThemeMetric  met)
static

Definition at line 504 of file qmacstyle_mac.mm.

Referenced by qt_aqua_get_known_size().

505 {
506  SInt32 ret;
507  GetThemeMetric(met, &ret);
508  return ret;
509 }

◆ qt_mac_buttonIsRenderedFlat()

bool qt_mac_buttonIsRenderedFlat ( const QPushButton pushButton,
const QStyleOptionButton option 
)

Definition at line 1062 of file qmacstyle_mac.mm.

Referenced by QPushButton::hitButton().

1063 {
1064  QMacStyle *macStyle = qobject_cast<QMacStyle *>(pushButton->style());
1065  if (!macStyle)
1066  return true; // revert to 'flat' behavior if not Mac style
1067  HIThemeButtonDrawInfo bdi;
1068  macStyle->d->initHIThemePushButton(option, pushButton, kThemeStateActive, &bdi);
1069  return bdi.kind == kThemeBevelButton;
1070 }
T * qobject_cast(QObject *object)
Definition: qobject.h:375
QMacStylePrivate * d
QStyle * style() const
Definition: qwidget.cpp:2742
void initHIThemePushButton(const QStyleOptionButton *btn, const QWidget *widget, const ThemeDrawState tds, HIThemeButtonDrawInfo *bdi) const

◆ qt_mac_cg_context()

CGContextRef qt_mac_cg_context ( const QPaintDevice pdev)

Returns the CoreGraphics CGContextRef of the paint device.

Warning
This function is not part of the public interface.

0 is returned if it can't be obtained. It is the caller's responsiblity to CGContextRelease the context when finished using it.

Warning
This function is only available on Mac OS X.

Definition at line 118 of file qpaintdevice_mac.cpp.

Referenced by getTabDirection(), QMacStyle::polish(), and qt_mac_fill_background().

119 {
120  if (pdev->devType() == QInternal::Pixmap) {
121  const QPixmap *pm = static_cast<const QPixmap*>(pdev);
123  uint flags = kCGImageAlphaPremultipliedFirst;
124 #ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version
125  flags |= kCGBitmapByteOrder32Host;
126 #endif
127  CGContextRef ret = 0;
128 
129  // It would make sense to put this into a mac #ifdef'ed
130  // virtual function in the QPixmapData at some point
131  if (pm->data->classId() == QPixmapData::MacClass) {
132  const QMacPixmapData *pmData = static_cast<const QMacPixmapData*>(pm->data.data());
133  ret = CGBitmapContextCreate(pmData->pixels, pmData->w, pmData->h,
134  8, pmData->bytesPerRow, colorspace,
135  flags);
136  if(!ret)
137  qWarning("QPaintDevice: Unable to create context for pixmap (%d/%d/%d)",
138  pmData->w, pmData->h, (pmData->bytesPerRow * pmData->h));
139  } else if (pm->data->classId() == QPixmapData::RasterClass) {
140  QImage *image = pm->data->buffer();
141  ret = CGBitmapContextCreate(image->bits(), image->width(), image->height(),
142  8, image->bytesPerLine(), colorspace, flags);
143  }
144 
145  CGContextTranslateCTM(ret, 0, pm->height());
146  CGContextScaleCTM(ret, 1, -1);
147  return ret;
148  } else if (pdev->devType() == QInternal::Widget) {
149  CGContextRef ret = static_cast<CGContextRef>(static_cast<const QWidget *>(pdev)->macCGHandle());
150  CGContextRetain(ret);
151  return ret;
152  } else if (pdev->devType() == QInternal::MacQuartz) {
153  return static_cast<const QMacQuartzPaintDevice *>(pdev)->cgContext();
154  }
155  return 0;
156 }
QExplicitlySharedDataPointer< QPixmapData > data
Definition: qpixmap.h:252
CGColorSpaceRef qt_mac_colorSpaceForDeviceType(const QPaintDevice *pdev)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
virtual int devType() const
Definition: qpaintdevice.h:167
T * data() const
Returns a pointer to the shared data object.
Definition: qshareddata.h:145
Q_CORE_EXPORT void qWarning(const char *,...)
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
unsigned int uint
Definition: qglobal.h:996
ClassId classId() const
uchar * bits()
Returns a pointer to the first pixel data.
Definition: qimage.cpp:1946
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
struct CGColorSpace * CGColorSpaceRef
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
virtual QImage * buffer()
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645
struct CGContext * CGContextRef
quint32 * pixels

◆ qt_mac_convert_mac_region() [1/2]

QRegion qt_mac_convert_mac_region ( RgnHandle  )

Referenced by getTabDirection().

◆ qt_mac_convert_mac_region() [2/2]

QRegion qt_mac_convert_mac_region ( HIShapeRef  )

◆ qt_mac_dispose_rgn()

void qt_mac_dispose_rgn ( RgnHandle  r)

Referenced by getTabDirection().

◆ qt_mac_fill_background()

void qt_mac_fill_background ( QPainter painter,
const QRegion rgn,
const QBrush brush 
)
Warning
This function is not part of the public interface. Fills the given rect with the pattern stored in brush. As an optimization, HIThemeSetFill us used directly if we are filling with the standard background.

Definition at line 1811 of file qmacstyle_mac.mm.

Referenced by fillRegion().

1812 {
1813  QPoint dummy;
1814  const QPaintDevice *target = painter->device();
1815  const QPaintDevice *redirected = QPainter::redirected(target, &dummy);
1816  const bool usePainter = redirected && redirected != target;
1817 
1818  if (!usePainter && qt_mac_backgroundPattern
1819  && qt_mac_backgroundPattern->cacheKey() == brush.texture().cacheKey()) {
1820 
1821  painter->setClipRegion(rgn);
1822 
1824  CGContextSaveGState(cg);
1825  HIThemeSetFill(kThemeBrushDialogBackgroundActive, 0, cg, kHIThemeOrientationInverted);
1826 
1827  const QVector<QRect> &rects = rgn.rects();
1828  for (int i = 0; i < rects.size(); ++i) {
1829  const QRect rect(rects.at(i));
1830  // Anchor the pattern to the top so it stays put when the window is resized.
1831  CGContextSetPatternPhase(cg, CGSizeMake(rect.width(), rect.height()));
1832  CGRect mac_rect = CGRectMake(rect.x(), rect.y(), rect.width(), rect.height());
1833  CGContextFillRect(cg, mac_rect);
1834  }
1835 
1836  CGContextRestoreGState(cg);
1837  } else {
1838  const QRect rect(rgn.boundingRect());
1839  painter->setClipRegion(rgn);
1840  painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft());
1841  }
1842 }
QPaintDevice * device() const
Returns the paint device on which this painter is currently painting, or 0 if the painter is not acti...
Definition: qpainter.cpp:1530
QRect boundingRect() const
Returns the bounding rectangle of this region.
Definition: qregion.cpp:4363
QPixmap texture() const
Returns the custom brush pattern, or a null pixmap if no custom brush pattern has been set...
Definition: qbrush.cpp:785
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
void drawTiledPixmap(const QRectF &rect, const QPixmap &pm, const QPointF &offset=QPointF())
Draws a tiled pixmap, inside the given rectangle with its origin at the given position.
Definition: qpainter.cpp:7146
struct CGRect CGRect
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
Definition: qpainter.cpp:2917
QPixmap * qt_mac_backgroundPattern
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
Definition: qregion.cpp:4412
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
qint64 cacheKey() const
Returns a number that identifies this QPixmap.
Definition: qpixmap.cpp:1136
CGContextRef qt_mac_cg_context(const QPaintDevice *)
Returns the CoreGraphics CGContextRef of the paint device.
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
static QPaintDevice * redirected(const QPaintDevice *device, QPoint *offset=0)
Using QWidget::render() obsoletes the use of this function.
Definition: qpainter.cpp:8391

◆ qt_mac_hitheme_tab_version()

static int qt_mac_hitheme_tab_version ( )
inlinestatic

Definition at line 473 of file qmacstyle_mac.mm.

Referenced by QMacStyle::drawPrimitive().

474 {
475  return 1;
476 }

◆ qt_mac_is_metal()

bool qt_mac_is_metal ( const QWidget w)
inline

Definition at line 490 of file qmacstyle_mac.mm.

Referenced by QMacStyle::drawComplexControl(), QMacStyle::drawControl(), QMacStyle::polish(), and QMacStyle::unpolish().

491 {
492  for (; w; w = w->parentWidget()) {
494  return true;
495  if (w->isWindow() && w->testAttribute(Qt::WA_WState_Created)) { // If not created will fall through to the opaque check and be fine anyway.
497  }
498  if (w->d_func()->isOpaque)
499  break;
500  }
501  return false;
502 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
OSWindowRef qt_mac_window_for(const QWidget *)
Definition: qwidget_mac.mm:484
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
bool macWindowIsTextured(void *window)

◆ qt_mac_removeMnemonics()

QString qt_mac_removeMnemonics ( const QString original)

Definition at line 398 of file qmacstyle_mac.mm.

Referenced by QMacStyle::drawComplexControl(), QMacStyle::drawControl(), QMacCocoaAutoReleasePool::handle(), qt_aqua_get_known_size(), qt_mac_menu_merge_action(), QMacStyle::subControlRect(), QMenuBarPrivate::QMacMenuBarPrivate::syncAction(), and QMenuPrivate::QMacMenuPrivate::syncAction().

399 {
400  QString returnText(original.size(), 0);
401  int finalDest = 0;
402  int currPos = 0;
403  int l = original.length();
404  while (l) {
405  if (original.at(currPos) == QLatin1Char('&')
406  && (l == 1 || original.at(currPos + 1) != QLatin1Char('&'))) {
407  ++currPos;
408  --l;
409  if (l == 0)
410  break;
411  }
412  returnText[finalDest] = original.at(currPos);
413  ++currPos;
414  ++finalDest;
415  --l;
416  }
417  returnText.truncate(finalDest);
418  return returnText;
419 }
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
The QString class provides a Unicode character string.
Definition: qstring.h:83
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
QFactoryLoader * l
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ qt_qrectForHIRect()

static const QRect qt_qrectForHIRect ( const HIRect &  hirect)
inlinestatic

Definition at line 484 of file qmacstyle_mac.mm.

Referenced by QMacStylePrivate::contentFitsInPushButton(), QMacStyle::drawComplexControl(), QMacStyle::drawControl(), QMacStyle::subControlRect(), and QMacStyle::subElementRect().

485 {
486  return QRect(QPoint(int(hirect.origin.x), int(hirect.origin.y)),
487  QSize(int(hirect.size.width), int(hirect.size.height)));
488 }
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ rotateTabPainter()

QRect rotateTabPainter ( QPainter p,
QTabBar::Shape  shape,
QRect  tabRect 
)

Definition at line 188 of file qmacstyle_mac.mm.

Referenced by QMacStyle::drawControl(), drawTabBase(), and drawTabShape().

189 {
190  if (isVerticalTabs(shape)) {
191  int newX, newY, newRot;
192  if (shape == QTabBar::RoundedEast
193  || shape == QTabBar::TriangularEast) {
194  newX = tabRect.width();
195  newY = tabRect.y();
196  newRot = 90;
197  } else {
198  newX = 0;
199  newY = tabRect.y() + tabRect.height();
200  newRot = -90;
201  }
202  tabRect.setRect(0, 0, tabRect.height(), tabRect.width());
203  QMatrix m;
204  m.translate(newX, newY);
205  m.rotate(newRot);
206  p->setMatrix(m, true);
207  }
208  return tabRect;
209 }
The QMatrix class specifies 2D transformations of a coordinate system.
Definition: qmatrix.h:61
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
QMatrix & translate(qreal dx, qreal dy)
Moves the coordinate system dx along the x axis and dy along the y axis, and returns a reference to t...
Definition: qmatrix.cpp:922
QMatrix & rotate(qreal a)
Rotates the coordinate system the given degrees counterclockwise.
Definition: qmatrix.cpp:990
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
void setRect(int x, int y, int w, int h)
Sets the coordinates of the rectangle&#39;s top-left corner to ({x}, {y}), and its size to the given widt...
Definition: qrect.h:400
void setMatrix(const QMatrix &matrix, bool combine=false)
Use setWorldTransform() instead.
Definition: qpainter.cpp:3045
static bool isVerticalTabs(const QTabBar::Shape shape)

◆ scrollButtonsCutoffSize()

static int scrollButtonsCutoffSize ( ScrollBarCutoffType  cutoffType,
QMacStyle::WidgetSizePolicy  widgetSize 
)
static

Definition at line 1345 of file qmacstyle_mac.mm.

Referenced by QMacStyle::drawComplexControl(), QMacStyle::hitTestComplexControl(), and QMacStyle::sizeFromContents().

1346 {
1347  // Mini scroll bars do not exist as of version 10.4.
1348  if (widgetSize == QMacStyle::SizeMini)
1349  return 0;
1350 
1351  const int sizeIndex = (widgetSize == QMacStyle::SizeSmall) ? 1 : 0;
1352  static const int sizeTable[2][2] = { { 61, 56 }, { 49, 44 } };
1353  return sizeTable[sizeIndex][cutoffType];
1354 }

◆ setLayoutItemMargins()

static void setLayoutItemMargins ( int  left,
int  top,
int  right,
int  bottom,
QRect rect,
Qt::LayoutDirection  dir 
)
static

Definition at line 4251 of file qmacstyle_mac.mm.

Referenced by QGroupBoxPrivate::calculateFrame(), QToolButtonPrivate::init(), QLabelPrivate::init(), QComboBoxPrivate::init(), QPushButtonPrivate::resetLayoutItemMargins(), QWidgetPrivate::setFont_helper(), QMacStyle::subElementRect(), and QFramePrivate::updateFrameWidth().

4252 {
4253  if (dir == Qt::RightToLeft) {
4254  rect->adjust(-right, top, -left, bottom);
4255  } else {
4256  rect->adjust(left, top, right, bottom);
4257  }
4258 }
QTextStream & right(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignRight) on stream and returns stream...
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
QTextStream & left(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignLeft) on stream and returns stream...

Variable Documentation

◆ closeButtonSize

int closeButtonSize = 12
static

◆ DisclosureOffset

const int DisclosureOffset = 4
static

Definition at line 134 of file qmacstyle_mac.mm.

Referenced by QMacStyle::drawPrimitive(), and QMacStyle::subElementRect().

◆ macItemFrame

const int macItemFrame = 2

Definition at line 463 of file qmacstyle_mac.mm.

Referenced by QMacStyle::drawControl().

◆ macItemHMargin

const int macItemHMargin = 3

Definition at line 464 of file qmacstyle_mac.mm.

Referenced by QMacStyle::drawControl().

◆ macItemVMargin

const int macItemVMargin = 2

Definition at line 465 of file qmacstyle_mac.mm.

◆ macRightBorder

const int macRightBorder = 12

Definition at line 466 of file qmacstyle_mac.mm.

Referenced by QMacStyle::drawControl().

◆ mainWindowGradientBegin

const QColor mainWindowGradientBegin(240, 240, 240)
static

Referenced by QMacStyle::drawControl().

◆ mainWindowGradientEnd

const QColor mainWindowGradientEnd(200, 200, 200)
static

Referenced by QMacStyle::drawControl().

◆ ptrHIShapeGetBounds

PtrHIShapeGetBounds ptrHIShapeGetBounds = 0
static

◆ qt_mac_backgroundPattern

QPixmap* qt_mac_backgroundPattern = 0

Definition at line 468 of file qmacstyle_mac.mm.

Referenced by QMacStyle::~QMacStyle().

◆ qt_mac_hitheme_version

const int qt_mac_hitheme_version = 0

◆ qt_mac_safe_pdev

QPaintDevice* qt_mac_safe_pdev

Definition at line 166 of file qapplication_mac.mm.

Referenced by getTabDirection(), and qt_cleanup().

◆ QtWinType

const ThemeWindowType QtWinType = kThemeDocumentWindow

◆ titlebarGradientActiveBegin

const QColor titlebarGradientActiveBegin(220, 220, 220)
static

◆ titlebarGradientActiveEnd

const QColor titlebarGradientActiveEnd(151, 151, 151)
static

◆ titlebarGradientInactiveBegin

const QColor titlebarGradientInactiveBegin(241, 241, 241)
static

◆ titlebarGradientInactiveEnd

const QColor titlebarGradientInactiveEnd(207, 207, 207)
static

◆ titlebarSeparatorLineActive

const QColor titlebarSeparatorLineActive(111, 111, 111)
static

◆ titlebarSeparatorLineInactive

const QColor titlebarSeparatorLineInactive(131, 131, 131)
static