CopperSpice API  1.9.2
QMacStyle Class Reference

Provides a Max OS X style using the Apple Appearance Manager. More...

Inheritance diagram for QMacStyle:
QCommonStyle QStyle QObject

Public Types

enum  FocusRectPolicy
 
enum  WidgetSizePolicy
 
- Public Types inherited from QStyle
enum  ComplexControl
 
enum  ContentsType
 
enum  ControlElement
 
enum  PixelMetric
 
enum  PrimitiveElement
 
enum  RequestSoftwareInputPanel
 
enum  StandardPixmap
 
enum  StateFlag
 
enum  StyleHint
 
enum  SubControl
 
enum  SubElement
 

Public Methods

 QMacStyle ()
 
virtual ~QMacStyle ()
 
void drawComplexControl (ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget=nullptr) const override
 
void drawControl (ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget=nullptr) const override
 
void drawItemText (QPainter *painter, const QRect &rect, int flags, const QPalette &palette, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const override
 
void drawPrimitive (PrimitiveElement pe, const QStyleOption *option, QPainter *painter, const QWidget *widget=nullptr) const override
 
bool event (QEvent *event) override
 
QPixmap generatedIconPixmap (QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *option) const override
 
SubControl hitTestComplexControl (ComplexControl control, const QStyleOptionComplex *option, const QPoint &point, const QWidget *widget=nullptr) const override
 
int layoutSpacing (QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override
 
int pixelMetric (PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override
 
void polish (QApplication *app) override
 
void polish (QPalette &palette) override
 
void polish (QWidget *widget) override
 
QSize sizeFromContents (ContentsType ct, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget=nullptr) const override
 
QIcon standardIcon (StandardPixmap standardIcon, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override
 
QPalette standardPalette () const override
 
QPixmap standardPixmap (StandardPixmap standardPixmap, const QStyleOption *option, const QWidget *widget=nullptr) const override
 
int styleHint (StyleHint styleHint, const QStyleOption *option=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *styleHintReturn=nullptr) const override
 
QRect subControlRect (ComplexControl control, const QStyleOptionComplex *option, SubControl subControl, const QWidget *widget=nullptr) const override
 
QRect subElementRect (SubElement subElement, const QStyleOption *option, const QWidget *widget=nullptr) const override
 
void unpolish (QApplication *app) override
 
void unpolish (QWidget *widget) override
 
- Public Methods inherited from QCommonStyle
 QCommonStyle ()
 
 ~QCommonStyle ()
 
- Public Methods inherited from QStyle
 QStyle ()
 
virtual ~QStyle ()
 
int combinedLayoutSpacing (QSizePolicy::ControlTypes controls1, QSizePolicy::ControlTypes controls2, Qt::Orientation orientation, QStyleOption *option=nullptr, QWidget *widget=nullptr) const
 
virtual void drawItemPixmap (QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
 
virtual QRect itemPixmapRect (const QRect &rect, int alignment, const QPixmap &pixmap) const
 
virtual QRect itemTextRect (const QFontMetrics &metrics, const QRect &rect, int alignment, bool enabled, const QString &text) const
 
const QStyle * proxy () const
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 

Static Public Methods

static FocusRectPolicy focusRectPolicy (const QWidget *widget)
 
static void setFocusRectPolicy (QWidget *widget, FocusRectPolicy policy)
 
static void setWidgetSizePolicy (const QWidget *widget, WidgetSizePolicy policy)
 
static WidgetSizePolicy widgetSizePolicy (const QWidget *widget, const QStyleOption *option=nullptr)
 
- Static Public Methods inherited from QStyle
static QRect alignedRect (Qt::LayoutDirection direction, Qt::Alignment alignment, const QSize &size, const QRect &rect)
 
static int sliderPositionFromValue (int min, int max, int logicalValue, int span, bool upsideDown=false)
 
static int sliderValueFromPosition (int min, int max, int position, int span, bool upsideDown=false)
 
static Qt::Alignment visualAlignment (Qt::LayoutDirection direction, Qt::Alignment alignment)
 
static QPoint visualPos (Qt::LayoutDirection direction, const QRect &boundingRect, const QPoint &logicalPosition)
 
static QRect visualRect (Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
 
- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 

Additional Inherited Members

- Public Typedefs inherited from QStyle
using State = QFlags< StateFlag >
 
using SubControls = QFlags< SubControl >
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 
- Public Slots inherited from QObject
void deleteLater ()
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

The QMacStyle class provides a OS X style using the Apple Appearance Manager.

This class is implemented as a wrapper to the HITheme APIs, allowing applications to be styled according to the current theme in use on Mac OS X. This is done by having primitives in QStyle implemented in terms of what Mac OS X would normally theme.

Warning
This style is only available on Mac OS X because it relies on the HITheme APIs.

There are additional issues that should be taken into consideration to make an application compatible with the Apple Human Interface Guidelines. Some of these issues are outlined below.

  • Layout - The restrictions on window layout are such that some aspects of layout that are style-dependent can not be achieved using QLayout. Changes are being considered (and feedback would be appreciated) to make layouts QStyle-able. Some of the restrictions involve horizontal and vertical widget alignment and widget size (covered below).
  • Widget size - Mac OS X allows widgets to have specific fixed sizes. CopperSpice does not fully implement this behavior so as to maintain cross-platform compatibility. As a result some widgets sizes may be inappropriate (and subsequently not rendered correctly by the HITheme APIs).The QWidget::sizeHint() will return the appropriate size for many managed widgets (widgets enumerated in QStyle::ContentsType).
  • Effects - QMacStyle uses HITheme for performing most of the drawing, but also uses emulation in a few cases where HITheme does not provide the required functionality (for example, tab bars on Panther, the toolbar separator, etc). We tried to make the emulation as close to the original as possible. Please report any issues you see in effects or non-standard widgets.

There are other issues that need to be considered in the feel of your application (including the general color scheme to match the Aqua colors). The Guidelines mentioned above will remain current with new advances and design suggestions for Mac OS X.

Note that the functions provided by QMacStyle are reimplementations of QStyle functions; see QStyle for their documentation.

See also
QWindowsXPStyle, QWindowsStyle, QWindowsVistaStyle, QGtkStyle, QFusionStyle

Member Enumeration Documentation

This type is used to signify a widget's focus rectangle policy.

ConstantValueDescription
QMacStyle::FocusEnabled0 show a focus rectangle when the widget has focus.
QMacStyle::FocusDisabled1never show a focus rectangle for the widget.
QMacStyle::FocusDefault2 show a focus rectangle when the widget has focus and the widget is a QSpinWidget, QDateTimeEdit, QLineEdit, QListBox, QListView, editable QTextEdit, or one of their subclasses.
ConstantValue
QMacStyle::SizeSmall0
QMacStyle::SizeLarge1
QMacStyle::SizeMini2
QMacStyle::SizeDefault3

Constructor & Destructor Documentation

QMacStyle::QMacStyle ( )

Constructs a QMacStyle object.

QMacStyle::~QMacStyle ( )
virtual

Destructs a QMacStyle object.

Method Documentation

void QMacStyle::drawComplexControl ( ComplexControl  control,
const QStyleOptionComplex option,
QPainter painter,
const QWidget widget = nullptr 
) const
overridevirtual
void QMacStyle::drawControl ( ControlElement  element,
const QStyleOption option,
QPainter painter,
const QWidget widget = nullptr 
) const
overridevirtual

Reimplemented from QCommonStyle::drawControl()

void QMacStyle::drawItemText ( QPainter painter,
const QRect rect,
int  flags,
const QPalette palette,
bool  enabled,
const QString text,
QPalette::ColorRole  textRole = QPalette::NoRole 
) const
overridevirtual

Reimplemented from QStyle::drawItemText()

void QMacStyle::drawPrimitive ( PrimitiveElement  pe,
const QStyleOption option,
QPainter painter,
const QWidget widget = nullptr 
) const
overridevirtual

Reimplemented from QCommonStyle::drawPrimitive()

bool QMacStyle::event ( QEvent event)
overridevirtual

Reimplemented from QObject::event()

FocusRectPolicy QMacStyle::focusRectPolicy ( const QWidget widget)
deprecatedstatic
Deprecated:
Returns the focus rectangle policy for the widget.

The focus rectangle policy can be one of QMacStyle::FocusRectPolicy. This function will simply test for the Qt::WA_MacShowFocusRect attribute and will never return QMacStyle::FocusDefault.

See also
setFocusRectPolicy(), QWidget::testAttribute()
QPixmap QMacStyle::generatedIconPixmap ( QIcon::Mode  iconMode,
const QPixmap pixmap,
const QStyleOption option 
) const
overridevirtual
SubControl QMacStyle::hitTestComplexControl ( ComplexControl  control,
const QStyleOptionComplex option,
const QPoint point,
const QWidget widget = nullptr 
) const
overridevirtual
int QMacStyle::layoutSpacing ( QSizePolicy::ControlType  control1,
QSizePolicy::ControlType  control2,
Qt::Orientation  orientation,
const QStyleOption option = nullptr,
const QWidget widget = nullptr 
) const
overridevirtual

Returns the spacing that should be used between control1 and control2 in a layout. The orientation specifies whether the controls are laid out side by side or stacked vertically. The option parameter can be used to pass extra information about the parent widget. The widget parameter is optional and can also be used if option is 0.

This function is called by the layout system. It is used only if PM_LayoutHorizontalSpacing or PM_LayoutVerticalSpacing returns a negative value.

See also
combinedLayoutSpacing()

Reimplemented from QCommonStyle::layoutSpacing()

int QMacStyle::pixelMetric ( PixelMetric  metric,
const QStyleOption option = nullptr,
const QWidget widget = nullptr 
) const
overridevirtual

Reimplemented from QCommonStyle::pixelMetric()

void QMacStyle::polish ( QApplication app)
overridevirtual

Reimplemented from QCommonStyle::polish()

void QMacStyle::polish ( QPalette palette)
overridevirtual

Reimplemented from QCommonStyle::polish()

void QMacStyle::polish ( QWidget widget)
overridevirtual

Reimplemented from QCommonStyle::polish()

void QMacStyle::setFocusRectPolicy ( QWidget widget,
FocusRectPolicy  policy 
)
deprecatedstatic
Deprecated:
Sets the focus rectangle policy of widget. The policy can be one of QMacStyle::FocusRectPolicy.

This is now simply an interface to the Qt::WA_MacShowFocusRect attribute and the FocusDefault value does nothing anymore. If you want to set a widget back to its default value, you must save the old value of the attribute before you change it.

See also
focusRectPolicy(), QWidget::setAttribute()
void QMacStyle::setWidgetSizePolicy ( const QWidget widget,
WidgetSizePolicy  policy 
)
deprecatedstatic
Deprecated:
Call QWidget::setAttribute() with Qt::WA_MacMiniSize, Qt::WA_MacSmallSize, or Qt::WA_MacNormalSize instead.
See also
widgetSizePolicy()
QSize QMacStyle::sizeFromContents ( ContentsType  ct,
const QStyleOption option,
const QSize contentsSize,
const QWidget widget = nullptr 
) const
overridevirtual
QIcon QMacStyle::standardIcon ( StandardPixmap  standardIcon,
const QStyleOption option = nullptr,
const QWidget widget = nullptr 
) const
overridevirtual

Returns an icon for the given standardIcon.

The standardIcon is a standard pixmap which can follow some existing GUI style or guideline. The option argument can be used to pass extra information required when defining the appropriate icon. The widget argument is optional and can also be used to aid the determination of the icon.

Reimplemented from QCommonStyle::standardIcon()

QPalette QMacStyle::standardPalette ( ) const
overridevirtual

Reimplemented from QStyle::standardPalette()

QPixmap QMacStyle::standardPixmap ( StandardPixmap  standardPixmap,
const QStyleOption option,
const QWidget widget = nullptr 
) const
overridevirtual

Reimplemented from QCommonStyle::standardPixmap()

int QMacStyle::styleHint ( StyleHint  styleHint,
const QStyleOption option = nullptr,
const QWidget widget = nullptr,
QStyleHintReturn styleHintReturn = nullptr 
) const
overridevirtual

Reimplemented from QCommonStyle::styleHint()

QRect QMacStyle::subControlRect ( ComplexControl  control,
const QStyleOptionComplex option,
SubControl  subControl,
const QWidget widget = nullptr 
) const
overridevirtual

Reimplemented from QCommonStyle::subControlRect()

QRect QMacStyle::subElementRect ( SubElement  subElement,
const QStyleOption option,
const QWidget widget = nullptr 
) const
overridevirtual

Reimplemented from QCommonStyle::subElementRect()

void QMacStyle::unpolish ( QApplication app)
overridevirtual

Reimplemented from QCommonStyle::unpolish()

void QMacStyle::unpolish ( QWidget widget)
overridevirtual

Reimplemented from QCommonStyle::unpolish()

WidgetSizePolicy QMacStyle::widgetSizePolicy ( const QWidget widget,
const QStyleOption option = nullptr 
)
deprecatedstatic
Deprecated:
Call QWidget::testAttribute() with Qt::WA_MacMiniSize, Qt::WA_MacSmallSize, or Qt::WA_MacNormalSize instead.
See also
setWidgetSizePolicy()

Returns the size policy for the given widget and option.