Qt 4.8
Classes | Enumerations | Functions | Variables
qt_mac_p.h File Reference
#include "qmacdefines_mac.h"
#include <CoreServices/CoreServices.h>
#include "QtCore/qglobal.h"
#include "QtCore/qvariant.h"
#include "QtCore/qmimedata.h"
#include "QtCore/qpointer.h"
#include "private/qcore_mac_p.h"
#include "QtGui/qpainter.h"
#include <Carbon/Carbon.h>

Go to the source code of this file.

Classes

class  QMacCGContext
 
class  QMacCocoaAutoReleasePool
 
struct  QMacDndAnswerRecord
 
class  QMacPasteboard
 
struct  QMacPasteboard::Promise
 
class  QMacSmartQuickDrawRegion
 
class  QMacWindowChangeEvent
 
class  QMacWindowFader
 

Enumerations

enum  {
  typeAEClipboardChanged = 1, typeQWidget = 1, kEventParamQWidget = 'qwid', kEventQtRequestContext = 13,
  kEventQtRequestMenubarUpdate = 14, kEventQtRequestShowSheet = 17, kEventQtRequestActivate = 18, kEventQtRequestWindowChange = 20
}
 

Functions

QColor qcolorForTheme (ThemeBrush brush)
 
QColor qcolorForThemeTextColor (ThemeTextColor themeColor)
 
QFont qfontForThemeFont (ThemeFontID themeID)
 
void qt_mac_copy_answer_rect (const QDragMoveEvent &event)
 
bool qt_mac_mouse_inside_answer_rect (QPoint mouse)
 
QPoint qt_mac_nativeMapFromParent (const QWidget *child, const QPoint &pt)
 
OSViewRef qt_mac_nativeview_for (const QWidget *)
 
QString qt_mac_removeMnemonics (const QString &original)
 
OSWindowRef qt_mac_window_for (const QWidget *)
 

Variables

const UInt32 kEventClassQt = 'Cute'
 
QMacDndAnswerRecord qt_mac_dnd_answer_rec
 
QPaintDeviceqt_mac_safe_pdev
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
typeAEClipboardChanged 
typeQWidget 
kEventParamQWidget 
kEventQtRequestContext 
kEventQtRequestMenubarUpdate 
kEventQtRequestShowSheet 
kEventQtRequestActivate 
kEventQtRequestWindowChange 

Definition at line 95 of file qt_mac_p.h.

95  {
96  //AE types
98  //types
99  typeQWidget = 1, /* QWidget * */
100  //params
101  kEventParamQWidget = 'qwid', /* typeQWidget */
102  //events
108 };

Function Documentation

◆ qcolorForTheme()

QColor qcolorForTheme ( ThemeBrush  brush)

Definition at line 110 of file qt_mac.cpp.

Referenced by QApplicationPrivate::initializeWidgetPaletteHash(), and QMacStyle::polish().

111 {
112 #ifndef QT_MAC_USE_COCOA
113 # if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
115  return leopardBrush(brush);
116  } else
117 # endif
118  {
119  RGBColor rgbcolor;
120  GetThemeBrushAsColor(brush, 32, true, &rgbcolor);
121  return QColor(rgbcolor.red / 256, rgbcolor.green / 256, rgbcolor.blue / 256);
122  }
123 #else
124  return leopardBrush(brush);
125 #endif
126 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
static QColor leopardBrush(ThemeBrush brush)
Definition: qt_mac.cpp:102
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
Definition: qglobal.h:1646

◆ qcolorForThemeTextColor()

QColor qcolorForThemeTextColor ( ThemeTextColor  themeColor)

Definition at line 128 of file qt_mac.cpp.

Referenced by QApplicationPrivate::initializeWidgetPaletteHash().

129 {
130 #ifdef Q_OS_MAC32
131  RGBColor c;
132  GetThemeTextColor(themeColor, 32, true, &c);
133  QColor color = QColor(c.red / 256, c.green / 256, c.blue / 256);
134  return color;
135 #else
136  // There is no equivalent to GetThemeTextColor in 64-bit and it was rather bad that
137  // I didn't file a request to implement this for Snow Leopard. So, in the meantime
138  // I've encoded the values from the GetThemeTextColor. This is not exactly ideal
139  // as if someone really wants to mess with themeing, these colors will be wrong.
140  // It also means that we need to make sure the values for differences between
141  // OS releases (and it will be likely that we are a step behind.)
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:
151  return Qt::black;
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);
162  default: {
163  QNativeImage nativeImage(16,16, QNativeImage::systemFormat());
164  CGRect cgrect = CGRectMake(0, 0, 16, 16);
165  HIThemeSetTextFill(themeColor, 0, nativeImage.cg, kHIThemeOrientationNormal);
166  CGContextFillRect(nativeImage.cg, cgrect);
167  QColor color = nativeImage.image.pixel(0,0);
168  return QColor(nativeImage.image.pixel(0 , 0));
169  }
170  }
171 #endif
172 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
unsigned char c[8]
Definition: qnumeric_p.h:62
static QImage::Format systemFormat()
struct CGRect CGRect

◆ qfontForThemeFont()

QFont qfontForThemeFont ( ThemeFontID  themeID)

Definition at line 56 of file qt_mac.cpp.

57 {
58 #ifndef QT_MAC_USE_COCOA
59  static const ScriptCode Script = smRoman;
60  Str255 f_name;
61  SInt16 f_size;
62  Style f_style;
63  GetThemeFont(themeID, Script, f_name, &f_size, &f_style);
64  return QFont(qt_mac_from_pascal_string(f_name), f_size,
65  (f_style & ::bold) ? QFont::Bold : QFont::Normal,
66  (bool)(f_style & ::italic));
67 #else
68  QCFType<CTFontRef> ctfont = CopyCTThemeFont(themeID);
69  QString familyName = QCFString(CTFontCopyFamilyName(ctfont));
70  QCFType<CFDictionaryRef> dict = CTFontCopyTraits(ctfont);
71  CFNumberRef num = static_cast<CFNumberRef>(CFDictionaryGetValue(dict, kCTFontWeightTrait));
72  float fW;
73  CFNumberGetValue(num, kCFNumberFloat32Type, &fW);
74  QFont::Weight wght = fW > 0. ? QFont::Bold : QFont::Normal;
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);
79 #endif
80 }
Weight
Qt uses a weighting scale from 0 to 99 similar to, but not the same as, the scales used in Windows or...
Definition: qfont.h:103
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
QString qt_mac_from_pascal_string(const Str255 pstr)
Definition: qcore_mac.cpp:120

◆ qt_mac_copy_answer_rect()

void qt_mac_copy_answer_rect ( const QDragMoveEvent event)

If an answer rect has been set on the event (after being sent to the global event processor), we store that rect so we can check if the mouse is in the same area upon next drag move event.

Definition at line 318 of file qdnd_mac.mm.

Referenced by QMacDndAnswerRecord::clear(), and qt_mac_mouse_inside_answer_rect().

319 {
320  if (!event.answerRect().isEmpty()) {
321  qt_mac_dnd_answer_rec.rect = event.answerRect();
322  qt_mac_dnd_answer_rec.buttons = event.mouseButtons();
323  qt_mac_dnd_answer_rec.modifiers = event.keyboardModifiers();
324  qt_mac_dnd_answer_rec.lastAction = event.dropAction();
325  }
326 }
Qt::KeyboardModifiers modifiers
Definition: qt_mac_p.h:268
QRect answerRect() const
Returns the rectangle in the widget where the drop will occur if accepted.
Definition: qevent.h:537
Qt::MouseButtons buttons
Definition: qt_mac_p.h:269
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
QMacDndAnswerRecord qt_mac_dnd_answer_rec
Definition: qdnd_mac.mm:67
Qt::DropAction lastAction
Definition: qt_mac_p.h:270

◆ qt_mac_mouse_inside_answer_rect()

bool qt_mac_mouse_inside_answer_rect ( QPoint  mouse)

Definition at line 328 of file qdnd_mac.mm.

Referenced by QMacDndAnswerRecord::clear(), and qt_mac_mouse_inside_answer_rect().

329 {
334  return true;
335  else
336  return false;
337 }
Qt::KeyboardModifiers modifiers
Definition: qt_mac_p.h:268
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
Qt::MouseButtons buttons
Definition: qt_mac_p.h:269
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
QMacDndAnswerRecord qt_mac_dnd_answer_rec
Definition: qdnd_mac.mm:67
static Qt::KeyboardModifiers keyboardModifiers()
Returns the current state of the modifier keys on the keyboard.
static Qt::MouseButtons mouseButtons()
Returns the current state of the buttons on the mouse.

◆ qt_mac_nativeMapFromParent()

QPoint qt_mac_nativeMapFromParent ( const QWidget child,
const QPoint pt 
)

Definition at line 3576 of file qwidget_mac.mm.

Referenced by QWidgetPrivate::childAtRecursiveHelper().

3577 {
3578 #ifndef QT_MAC_USE_COCOA
3579  CGPoint nativePoint = CGPointMake(pt.x(), pt.y());
3580  HIViewConvertPoint(&nativePoint, qt_mac_nativeview_for(child->parentWidget()),
3581  qt_mac_nativeview_for(child));
3582 #else
3583  NSPoint nativePoint = [qt_mac_nativeview_for(child) convertPoint:NSMakePoint(pt.x(), pt.y()) fromView:qt_mac_nativeview_for(child->parentWidget())];
3584 #endif
3585  return QPoint(nativePoint.x, nativePoint.y);
3586 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
Q_GUI_EXPORT OSViewRef qt_mac_nativeview_for(const QWidget *w)
Definition: qwidget_mac.mm:419
struct CGPoint NSPoint
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128

◆ qt_mac_nativeview_for()

OSViewRef qt_mac_nativeview_for ( const QWidget )

◆ 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_mac_window_for()

OSWindowRef qt_mac_window_for ( const QWidget )

Definition at line 484 of file qwidget_mac.mm.

485 {
486  if (OSViewRef hiview = qt_mac_effectiveview_for(w)) {
488  if (window)
489  return window;
490 
491  if (qt_isGenuineQWidget(hiview)) {
492  // This is a workaround for NSToolbar. When a widget is hidden
493  // by clicking the toolbar button, Cocoa reparents the widgets
494  // to another window (but Qt doesn't know about it).
495  // When we start showing them, it reparents back,
496  // but at this point it's window is nil, but the window it's being brought
497  // into (the Qt one) is for sure created.
498  // This stops the hierarchy moving under our feet.
499  QWidget *toplevel = w->window();
500  if (toplevel != w) {
501  hiview = qt_mac_nativeview_for(toplevel);
502  if (OSWindowRef w = qt_mac_window_for(hiview))
503  return w;
504  }
505 
506  toplevel->d_func()->createWindow_sys();
507  // Reget the hiview since "create window" could potentially move the view (I guess).
508  hiview = qt_mac_nativeview_for(toplevel);
509  return qt_mac_window_for(hiview);
510  }
511  }
512  return 0;
513 }
Q_GUI_EXPORT OSWindowRef qt_mac_window_for(OSViewRef view)
Definition: qwidget_mac.mm:453
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
NSWindow * window
static bool qt_isGenuineQWidget(OSViewRef ref)
Definition: qwidget_mac.mm:464
WindowRef OSWindowRef
Q_GUI_EXPORT OSViewRef qt_mac_nativeview_for(const QWidget *w)
Definition: qwidget_mac.mm:419
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
HIViewRef OSViewRef
Q_GUI_EXPORT OSViewRef qt_mac_effectiveview_for(const QWidget *w)
Definition: qwidget_mac.mm:424

Variable Documentation

◆ kEventClassQt

const UInt32 kEventClassQt = 'Cute'

◆ qt_mac_dnd_answer_rec

QMacDndAnswerRecord qt_mac_dnd_answer_rec

Definition at line 67 of file qdnd_mac.mm.

Referenced by QMacDndAnswerRecord::clear().

◆ qt_mac_safe_pdev

QPaintDevice* qt_mac_safe_pdev

Definition at line 166 of file qapplication_mac.mm.