summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/dialogs/qfontdialog.cpp17
-rw-r--r--src/widgets/dialogs/qfontdialog_p.h16
-rw-r--r--src/widgets/dialogs/qwizard.cpp7
-rw-r--r--src/widgets/dialogs/qwizard.h3
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/styles.qdoc856
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp27
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.h49
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget.cpp8
-rw-r--r--src/widgets/itemviews/qheaderview.cpp14
-rw-r--r--src/widgets/itemviews/qheaderview.h3
-rw-r--r--src/widgets/itemviews/qheaderview_p.h6
-rw-r--r--src/widgets/itemviews/qtableview.cpp3
-rw-r--r--src/widgets/itemviews/qtreeview.cpp2
-rw-r--r--src/widgets/kernel/qapplication.cpp48
-rw-r--r--src/widgets/kernel/qapplication_p.h2
-rw-r--r--src/widgets/kernel/qapplication_qpa.cpp6
-rw-r--r--src/widgets/kernel/qgesture.cpp34
-rw-r--r--src/widgets/kernel/qgesture.h16
-rw-r--r--src/widgets/kernel/qgesturemanager.cpp8
-rw-r--r--src/widgets/kernel/qlayoutitem.cpp10
-rw-r--r--src/widgets/kernel/qlayoutitem.h4
-rw-r--r--src/widgets/kernel/qwidget.cpp4
-rw-r--r--src/widgets/kernel/qwidget_qpa.cpp18
-rw-r--r--src/widgets/kernel/qwidgetbackingstore_p.h2
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp26
-rw-r--r--src/widgets/styles/qcommonstyle.cpp3
-rw-r--r--src/widgets/styles/qfusionstyle.cpp2
-rw-r--r--src/widgets/styles/qfusionstyle_p.h28
-rw-r--r--src/widgets/styles/qgtk2painter.cpp705
-rw-r--r--src/widgets/styles/qgtk2painter_p.h108
-rw-r--r--src/widgets/styles/qgtkglobal_p.h90
-rw-r--r--src/widgets/styles/qgtkpainter.cpp665
-rw-r--r--src/widgets/styles/qgtkpainter_p.h83
-rw-r--r--src/widgets/styles/qgtkstyle.cpp504
-rw-r--r--src/widgets/styles/qgtkstyle_p.cpp102
-rw-r--r--src/widgets/styles/qgtkstyle_p.h88
-rw-r--r--src/widgets/styles/qmacstyle_mac.h6
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm335
-rw-r--r--src/widgets/styles/qmacstyle_mac_p.h54
-rw-r--r--src/widgets/styles/qstyle.cpp3
-rw-r--r--src/widgets/styles/qstyle.h1
-rw-r--r--src/widgets/styles/qstyleanimation.cpp105
-rw-r--r--src/widgets/styles/qstyleanimation_p.h28
-rw-r--r--src/widgets/styles/qstylehelper.cpp3
-rw-r--r--src/widgets/styles/qstyleoption.cpp14
-rw-r--r--src/widgets/styles/qstyleoption.h5
-rw-r--r--src/widgets/styles/qstyleplugin.cpp2
-rw-r--r--src/widgets/styles/qwindowscestyle.cpp4
-rw-r--r--src/widgets/styles/qwindowscestyle.h1
-rw-r--r--src/widgets/styles/qwindowsmobilestyle.cpp4
-rw-r--r--src/widgets/styles/qwindowsmobilestyle.h1
-rw-r--r--src/widgets/styles/qwindowsvistastyle.cpp120
-rw-r--r--src/widgets/styles/qwindowsvistastyle.h1
-rw-r--r--src/widgets/styles/qwindowsvistastyle_p.h30
-rw-r--r--src/widgets/styles/styles.pri3
-rw-r--r--src/widgets/util/qsystemtrayicon_x11.cpp19
-rw-r--r--src/widgets/widgets/qabstractscrollarea.cpp41
-rw-r--r--src/widgets/widgets/qabstractscrollarea.h1
-rw-r--r--src/widgets/widgets/qabstractscrollarea_p.h3
-rw-r--r--src/widgets/widgets/qabstractspinbox.cpp13
-rw-r--r--src/widgets/widgets/qcheckbox.cpp7
-rw-r--r--src/widgets/widgets/qcheckbox.h2
-rw-r--r--src/widgets/widgets/qcommandlinkbutton.cpp7
-rw-r--r--src/widgets/widgets/qcommandlinkbutton.h4
-rw-r--r--src/widgets/widgets/qdatetimeedit.cpp21
-rw-r--r--src/widgets/widgets/qdatetimeedit.h11
-rw-r--r--src/widgets/widgets/qlineedit.cpp3
-rw-r--r--src/widgets/widgets/qmainwindow.cpp16
-rw-r--r--src/widgets/widgets/qmenu.cpp10
-rw-r--r--src/widgets/widgets/qprogressbar.cpp7
-rw-r--r--src/widgets/widgets/qprogressbar.h1
-rw-r--r--src/widgets/widgets/qradiobutton.cpp7
-rw-r--r--src/widgets/widgets/qradiobutton.h1
-rw-r--r--src/widgets/widgets/qscrollarea.cpp2
-rw-r--r--src/widgets/widgets/qscrollbar.cpp56
-rw-r--r--src/widgets/widgets/qscrollbar.h1
-rw-r--r--src/widgets/widgets/qscrollbar_p.h89
-rw-r--r--src/widgets/widgets/qspinbox.cpp9
-rw-r--r--src/widgets/widgets/qspinbox.h2
-rw-r--r--src/widgets/widgets/qsplitter.cpp18
-rw-r--r--src/widgets/widgets/qsplitter.h4
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp12
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol_p.h2
-rw-r--r--src/widgets/widgets/widgets.pri1
84 files changed, 2612 insertions, 2045 deletions
diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp
index 30004df1a7..2a68d29bda 100644
--- a/src/widgets/dialogs/qfontdialog.cpp
+++ b/src/widgets/dialogs/qfontdialog.cpp
@@ -333,13 +333,6 @@ void QFontDialogPrivate::init()
QFontDialog::~QFontDialog()
{
-#ifdef Q_WS_MAC
- Q_D(QFontDialog);
- if (d->delegate) {
- d->closeCocoaFontPanel();
- return;
- }
-#endif
}
/*!
@@ -804,11 +797,6 @@ void QFontDialog::setCurrentFont(const QFont &font)
if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper())
helper->setCurrentFont(font);
}
-
-#ifdef Q_WS_MAC
- if (d->delegate)
- QFontDialogPrivate::setFont(d->delegate, font);
-#endif
}
/*!
@@ -911,11 +899,6 @@ QFontDialog::FontDialogOptions QFontDialog::options() const
return QFontDialog::FontDialogOptions(int(d->options->options()));
}
-#ifdef Q_WS_MAC
-// can only have one Cocoa font panel active
-bool QFontDialogPrivate::sharedFontPanelAvailable = true;
-#endif
-
/*!
\since 4.5
\overload
diff --git a/src/widgets/dialogs/qfontdialog_p.h b/src/widgets/dialogs/qfontdialog_p.h
index 015a605af0..93d12010d8 100644
--- a/src/widgets/dialogs/qfontdialog_p.h
+++ b/src/widgets/dialogs/qfontdialog_p.h
@@ -145,22 +145,6 @@ public:
bool canBeNativeDialog() const;
void _q_runNativeAppModalPanel();
-#ifdef Q_WS_MAC
- static void setFont(void *delegate, const QFont &font);
-
- inline void done(int result) { q_func()->done(result); }
- inline QFontDialog *fontDialog() { return q_func(); }
-
- void *delegate;
- void closeCocoaFontPanel();
-
- bool setVisible_sys(bool visible);
- void createNSFontPanelDelegate();
- bool showCocoaFontPanel();
- bool hideCocoaFontPanel();
-
- static bool sharedFontPanelAvailable;
-#endif
private:
virtual void initHelper(QPlatformDialogHelper *);
diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp
index 7f1cb09225..44518ec7d5 100644
--- a/src/widgets/dialogs/qwizard.cpp
+++ b/src/widgets/dialogs/qwizard.cpp
@@ -3384,6 +3384,13 @@ QWizardPage::QWizardPage(QWidget *parent)
}
/*!
+ Destructor.
+*/
+QWizardPage::~QWizardPage()
+{
+}
+
+/*!
\property QWizardPage::title
\brief the title of the page
diff --git a/src/widgets/dialogs/qwizard.h b/src/widgets/dialogs/qwizard.h
index 9d7f28dc41..9101162620 100644
--- a/src/widgets/dialogs/qwizard.h
+++ b/src/widgets/dialogs/qwizard.h
@@ -217,7 +217,8 @@ class Q_WIDGETS_EXPORT QWizardPage : public QWidget
Q_PROPERTY(QString subTitle READ subTitle WRITE setSubTitle)
public:
- QWizardPage(QWidget *parent = 0);
+ explicit QWizardPage(QWidget *parent = 0);
+ ~QWizardPage();
void setTitle(const QString &title);
QString title() const;
diff --git a/src/widgets/doc/src/widgets-and-layouts/styles.qdoc b/src/widgets/doc/src/widgets-and-layouts/styles.qdoc
index 56801bc1d9..80b7eb9987 100644
--- a/src/widgets/doc/src/widgets-and-layouts/styles.qdoc
+++ b/src/widgets/doc/src/widgets-and-layouts/styles.qdoc
@@ -44,9 +44,9 @@
drawing, ensuring that they look exactly like the equivalent
native widgets.
- Several styles are built into Qt (e.g., windows style and motif style).
+ Several styles are built into Qt (e.g., Windows style and motif style).
Other styles are only available on specific platforms (such as
- the windows XP style). Custom styles are made available as plugins
+ the Windows XP style). Custom styles are made available as plugins
or by creating an instance of the style class in an application and
setting it with QApplication::setStyle().
@@ -84,7 +84,7 @@
helper functions to do common and difficult tasks (e.g.,
calculating the position of slider handles) and functions to do
the various calculations necessary while drawing (e.g., for the
- widgets to calculate their size hints). The style also help some
+ widgets to calculate their size hints). The style also helps some
widgets with the layout of their contents. In addition, it creates
a QPalette that contains \l{QBrush}es to draw with.
@@ -111,15 +111,15 @@
it to perform special effects (such as animated default buttons on
Mac OS X), but it isn't mandatory.
- We will in the course of this section look at the style elements,
+ In the course of this section, we will look at the style elements,
the style options, and the functions of QStyle. Finally, we describe
how the palette is used.
- Items in item views is drawn by \l{Delegate Classes}{delegates} in
+ Items in item views are drawn by \l{Delegate Classes}{delegates} in
Qt. The item view headers are still drawn by the style. Qt's
default delegate, QStyledItemDelegate, draws its items partially
through the current style; it draws the check box indicators and
- calculate bounding rectangles for the elements of which the item
+ calculates bounding rectangles for the elements of which the item
consists. In this document, we only describe how to implement a
QStyle subclass. If you wish to add support for other datatypes
than those supported by the QStyledItemDelegate, you need to
@@ -181,17 +181,17 @@
the user. Controls that consist of several elements often use the
style to calculate the bounding rectangles of the elements. The
available sub elements are defined by the \l{QStyle::}{SubElement}
- enum. This enum is only used for calculating bounding rectangles,
- and sub elements are as such not graphical elements to be drawn
- like primitive, control, and complex elements.
+ enum. This enum is only used for calculating bounding rectangles;
+ sub elements are not graphical elements to be drawn like primitive,
+ control, and complex elements.
\section3 Complex Control Elements
Complex control elements contain sub controls. Complex controls
behave differently depending on where the user handles them with
the mouse and which keyboard keys are pressed. This is dependent
- on which sub control (if any) that the mouse is over or received a
- mouse press. Examples of complex controls are scroll bars and
+ on which sub control (if any) the mouse is over or pressed on.
+ Examples of complex controls are scroll bars and
combo boxes. With a scroll bar, you can use the mouse to move the
slider and press the line up and line down buttons. The available
sub controls are defined by the \l{QStyle}{SubControl} enum.
@@ -210,22 +210,22 @@
frequently used by the built-in styles in Qt and also the Java
style. For instance, the Java style uses PE_IndicatorCheckBox to
draw the check box in group boxes (which is a sub control of
- CC_GroupBox). Some sub controls have an equivalent control element,
- e.g., the scroll bar slider (SC_SCrollBarSlider and
- CE_ScrollBarSlider).
+ \c CC_GroupBox). Some sub controls have an equivalent control element,
+ e.g., the scroll bar slider (\c SC_SCrollBarSlider and
+ \c CE_ScrollBarSlider).
\section3 Other QStyle Tasks
The style elements and widgets, as mentioned, use the style to
- calculate bounding rectangles of sub elements and sub controls,
- and pixel metrics, which is a style dependent size in screen
- pixels, for measures when drawing. The available rectangles and
- pixel metrics are represented by three enums in QStyle:
- \l{QStyle::}{SubElement}, \l{QStyle::}{SubControl}, and
+ calculate bounding rectangles of sub elements and sub controls.
+ Pixel metrics, which are style-dependent sizes in screen
+ pixels, are also used for measurements when drawing. The available
+ rectangles and pixel metrics are represented by three enums in
+ QStyle: \l{QStyle::}{SubElement}, \l{QStyle::}{SubControl}, and
\l{QStyle::}{PixelMetric}. Values of the enums can easily by
identified as they start with SE_, SC_ and PM_.
- The style also contain a set of style hints, which is
+ The style also contains a set of style hints, which is
represented as values in the \l{QStyle::}{StyleHint} enum. All
widgets do not have the same functionality and look in the
different styles. For instance, when the menu items in a menu do not
@@ -241,8 +241,8 @@
The style calculates the spacing between widgets in layouts. There
are two ways the style can handle these calculations. You can set
- the PM_LayoutHorizontalSpacing and PM_LayoutVerticalSpacing, which
- is the way the java style does it (through QCommonStyle).
+ the \c PM_LayoutHorizontalSpacing and \c PM_LayoutVerticalSpacing, which
+ is the way the Java style does it (through QCommonStyle).
Alternatively, you can implement QStyle::layoutSpacing() and
QStyle::layoutSpacingImplementation() if you need more control over
this part of the layout. In these functions you can calculate the
@@ -257,7 +257,7 @@
usually on the stack - and filled out by the caller of the QStyle
function. Depending on what is drawn the style will expect
different a different style option class. For example, the
- QStyle::PE_FrameFocusRect element expects a QStyleOptionFocusRect
+ \c QStyle::PE_FrameFocusRect element expects a QStyleOptionFocusRect
argument, and it's possible to create custom subclasses that a
custom style can use. The style options keep public variables
for performance reasons.
@@ -265,16 +265,16 @@
The widgets can be in a number of different states, which are
defined by the \l{QStyle::}{State} enum. Some of the state flags have
different meanings depending on the widget, but others are common
- for all widgets like State_Disabled. It is QStyleOption that sets
+ for all widgets like \c State_Disabled. It is QStyleOption that sets
the common states with QStyleOption::initFrom(); the rest of the
states are set by the individual widgets.
Most notably, the style options contain the palette and bounding
rectangles of the widgets to be drawn. Most widgets have
specialized style options. QPushButton and QCheckBox, for
- instance, use QStyleOptionButton as style option, which contain
+ instance, use QStyleOptionButton as their style option, which contains
the text, icon, and the size of their icon. The exact contents of
- all options are described when we go through individual widgets.
+ all options are described when we go through the individual widgets.
When reimplementing QStyle functions that take a
QStyleOption parameter, you often need to cast the
@@ -309,7 +309,7 @@
following parameters:
\list
- \li the enum value of the element to draw
+ \li the enum value of the element to draw.
\li a QStyleOption which contains the information needed to
draw the element.
\li a QPainter with which to draw the element.
@@ -324,24 +324,23 @@
The QStyle class also provides helper functions that are used
when drawing the elements. The \l{QStyle::}{drawItemText()}
- function draws text within a specified rectangle and taking a
+ function draws text within a specified rectangle, taking a
QPalette as a parameter. The \l{QStyle::}{drawItemPixmap()}
function helps to align a pixmap within a specified bounding
rectangle.
Other QStyle functions do various calculations for the
- functions that draw. The widgets also use these functions for
- calculating size hints and also for bounding rectangle
- calculations if they draw several style elements themselves.
- As with the functions that draw elements the helper functions
- typically takes the same arguments.
+ functions that do drawing. The widgets also use these functions for
+ calculating size hints and bounding rectangles if they draw several
+ style elements themselves. As with the functions that draw elements,
+ the helper functions typically take the same arguments.
\list
\li The \l{QStyle::}{subElementRect()} function takes a
- \l{QStyle::}{SubElement} enum value, and calculates a bounding
+ \l{QStyle::}{SubElement} enum value and calculates a bounding
rectangle for a sub element. The style uses this function to
know where to draw the different parts of an element. This is
- mainly done for reuse. If you create a new style, you can use
+ mainly done for reuse; if you create a new style, you can use
the same location of sub elements as the super class.
\li The \l{QStyle::}{subControlRect()} function is used to
@@ -351,28 +350,28 @@
from the super class.
\li The \l{QStyle::}{pixelMetric()} function returns a pixel
- metric, which is a style dependent size given in screen
+ metric, which is a style-dependent size given in screen
pixels. It takes a value of the \l{QStyle::}{PixelMetric} enum
- and returns the correct measure. Note that pixel metrics do
- not necessarily have to be static measures, but can be
+ and returns the correct measurement. Note that pixel metrics do
+ not necessarily have to be static measurements, but can be
calculated with, for example, the style option.
\li The \l{QStyle::}{hitTestComplexControl()} function returns the
sub control that the mouse pointer is over in a complex control.
Usually, this is simply a matter of using
\l{QStyle::}{subControlRect()} to get the bounding rectangles of
- the sub controls, and see which rectangle contains the position of
- the cursor.
+ the sub controls, and then seeing which rectangle contains the
+ position of the cursor.
\endlist
- QStyle also have the functions \l{QStyle::}{polish()} and
+ QStyle also has the functions \l{QStyle::}{polish()} and
\l{QStyle::}{unpolish()}. All widgets are sent to the \c polish()
function before being shown and to \c unpolish() when they
are hidden. You can use these functions to set attributes on the
widgets or do other work that is required by your style. For
instance, if you need to know when the mouse is hovering over the
widget, you need to set the \l{Qt::}{WA_Hover} widget attribute.
- The State_MouseOver state flag will then be set in the widget's
+ The \c State_MouseOver state flag will then be set in the widget's
style options.
QStyle has a few static helper functions that do some common and
@@ -391,10 +390,10 @@
Each style provides a color - that is, QBrush - palette that
should be used for drawing the widgets. There is one set of colors
for the different widget states (QPalette::ColorGroup): active
- (widgets in the window that has keyboard focus), inactive (widgets
- used for other windows), and disabled (widgets that are set
- disabled). The states can be found by querying the State_Active
- and State_Enabled state flags. Each set contains color certain
+ (widgets in the window that have keyboard focus), inactive (widgets
+ used for other windows), and disabled (widgets that are disabled).
+ The states can be found by querying the \c State_Active
+ and \c State_Enabled state flags. Each set contains certain color
roles given by the QPalette::ColorRole enum. The roles describe in
which situations the colors should be used (e.g., for painting
widget backgrounds, text, or buttons).
@@ -413,12 +412,12 @@
(QWidget::setStyle()), so you must set the palette yourself
with (QApplication::setPalette()) or (QWidget::setPalette()).
- It is not recommended to hard code colors as applications and
- individual widgets can set their own palette and also use the
- styles palette for drawing. Note that none of Qt's widgets set
- their own palette. The java style does hard code some colors, but
- its author looks past this in silence. Of course, it is not
- intended that the style should look good with any palette.
+ It is not recommended to hard-code colors, as applications and
+ individual widgets can set their own palette and also use their
+ style's palette for drawing. Note that none of Qt's widgets set
+ their own palette. The Java style does hard-code some colors, but
+ only as a decision of the author; it is not advised. Of course,
+ it is not intended that the style should look good with any palette.
\section2 Implementation Issues
@@ -429,42 +428,31 @@
When implementing styles, it is necessary to look through the
code of the widgets and code of the base class and its ancestors.
This is because the widgets use the style differently, because the
- implementation in the different styles virtual functions can
+ implementation in the different styles' virtual functions can
affect the state of the drawing (e.g., by altering the QPainter
state without restoring it and drawing some elements without using
the appropriate pixel metrics and sub elements).
It is recommended that the styles do not alter the proposed size
- of widgets with the QStyle::sizeFromContents() function but let
- the QCommonStyle implementation handle it. If changes need to be
- made, you should try to keep them small; application development
+ of widgets with the QStyle::sizeFromContents() function, but let
+ the QCommonStyle implementation handle it instead. If changes need
+ to be made, you should try to keep them small; application development
may be difficult if the layout of widgets looks considerably
different in the various styles.
- We recommend using the QPainter directly for drawing, i.e., not
- use pixmaps or images. This makes it easier for the style conform
- to the palette (although you can set your own color table on a
- QImage with \l{QImage::}{setColorTable()}).
-
- It is, naturally, possible to draw elements without using the
- style to draw the sub elements as intended by Qt. This is
- discouraged as custom widgets may depend on these sub elements to
- be implemented correctly. The widget walkthrough shows how Qt
- uses the sub elements.
-
\section1 Java Style
We have implemented a style that resembles the Java default look
and feel (previously known as Metal). We have done this as it is
relatively simple to implement and we wanted to build a style for
- this overview document. To keep it simple and not to extensive, we
+ this overview document. To keep it simple and not too extensive, we
have simplified the style somewhat, but Qt is perfectly able to
make an exact copy of the style. However, there are no concrete
plans to implement the style as a part of Qt.
In this section we will have a look at some implementation
issues. Finally, we will see a complete example on the styling of
- a Java widget. We will continue to use the java style
+ a Java widget. We will continue to use the Java style
throughout the document for examples and widget images. The
implementation itself is somewhat involved, and it is not
intended that you should read through it.
@@ -473,8 +461,8 @@
The first step in designing the style was to select the base
class. We chose to subclass QWindowsStyle. This class implements
- most of the functionality we need other than performing the actual
- drawing. Also, windows and java share layout of sub controls for
+ most of the functionality we need, other than performing the actual
+ drawing. Also, Windows and Java share the layout of sub controls for
several of the complex controls (which reduces the amount of code
required considerably).
@@ -496,19 +484,19 @@
itself.
Not all widgets have every state implemented. This goes for
- states that are common, e.g., State_Disabled. Each state is,
+ states that are common, e.g., \c State_Disabled. Each state is,
however, implemented for at least one widget.
We have only implemented ticks below the slider. Flat push
buttons are also left out. We do not handle the case where the
- title bars and dock window titles grows to small for their
+ title bars and dock window titles grow too small for their
contents, but simply draw sub controls over each other.
We have not tried to emulate the Java fonts. Java and Qt use very
different font engines, so we don't consider it worth the effort
as we only use the style as an example for this overview.
- We have hardcoded the colors (we don't use the QPalette) for
+ We have hard-coded the colors (we don't use the QPalette) for
the linear gradients, which are used, for example, for button
bevels, tool bars, and check boxes. This is because the Java
palette cannot produce these colors. Java does not change these
@@ -525,13 +513,13 @@
layout direction is left to right. QWindowsStyle handles reverse
widgets; if we implemented reverse layouts, widgets that we change
the position of sub elements, or handle text alignment in labels
- our selves would need to be updated.
+ ourselves would need to be updated.
\section2 Styling Java Check Boxes
As an example, we will examine the styling of check boxes in the
- java style. We describe the complete process and print all code in
- both the java style and Qt classes involved. In the rest of this
+ Java style. We describe the complete process and print all code in
+ both the Java style and Qt classes involved. In the rest of this
document, we will not examine the source code of the individual
widgets. Hopefully, this will give you an idea on how to search
through the code if you need to check specific implementation
@@ -539,7 +527,7 @@
boxes. We have edited the QCommonStyle code somewhat to remove
code that is not directly relevant for check box styling.
- We start with a look at how QCheckBox builds it style option,
+ We start with a look at how QCheckBox builds its style option,
which is QStyleOptionButton for checkboxes:
\snippet code/doc_src_styles.cpp 0
@@ -548,12 +536,12 @@
that is common for all widgets with \c initFrom(). We will look at
this shortly.
- The down boolean is true when the user press the box down; this is
- true whether the box is checked or not of the checkbox. The
- State_NoChange state is set when we have a tristate checkbox and
- it is partially checked. It has State_On if the box is checked and
- State_Off if it is unchecked. State_MouseOver is set if the mouse
- hovers over the checkbox and the widget has attribute Qt::WA_Hover
+ QStyleOption's \c down variable is \c true when the user presses the box down;
+ this is true of the checkbox whether the box is checked or not. The
+ \c State_NoChange state is set when we have a tri-state checkbox and
+ it is partially checked. It has \c State_On if the box is checked and
+ \c State_Off if it is unchecked. \c State_MouseOver is set if the mouse
+ hovers over the checkbox and the widget has attribute \c Qt::WA_Hover
set - you set this in QStyle::polish(). In addition, the style
option also contains the text, icon, and icon size of the button.
@@ -563,12 +551,12 @@
\snippet code/doc_src_styles.cpp 1
- The State_Enabled is set when the widget is enabled. When the
- widget has focus the State_HasFocus flag is set. Equally, the
- State_Active flag is set when the widget is a child of the active
- window. The State_MouseOver will only be set if the widget has
- the WA_HoverEnabled windows flag set. Notice that keypad
- navigation must be enabled in Qt for the State_HasEditFocus to
+ The \c State_Enabled is set when the widget is enabled. When the
+ widget has focus the \c State_HasFocus flag is set. Equally, the
+ \c State_Active flag is set when the widget is a child of the active
+ window. The \c State_MouseOver will only be set if the widget has
+ the \c WA_HoverEnabled windows flag set. Notice that keypad
+ navigation must be enabled in Qt for the \c State_HasEditFocus to
be included; it is not included by default.
In addition to setting state flags the QStyleOption contains
@@ -581,7 +569,7 @@
We give an image of a checkbox and the style option to match
it.
- \image javastyle/checkboxexample.png A java style checkbox
+ \image javastyle/checkboxexample.png A Java style checkbox
The above checkbox will have the following state flags in its
style option:
@@ -591,31 +579,31 @@
\li State flag
\li Set
\row
- \li State_Sunken
+ \li \c State_Sunken
\li Yes
\row
- \li State_NoChange
+ \li \c State_NoChange
\li No
\row
- \li State_On
+ \li \c State_On
\li Yes
\row
- \li State_Off
+ \li \c State_Off
\li No
\row
- \li State_MouseOver
+ \li \c State_MouseOver
\li Yes
\row
- \li State_Enabled
+ \li \c State_Enabled
\li Yes
\row
- \li State_HasFocus
+ \li \c State_HasFocus
\li Yes
\row
- \li State_KeyboardFocusChange
+ \li \c State_KeyboardFocusChange
\li No
\row
- \li State_Active
+ \li \c State_Active
\li Yes
\endtable
@@ -629,9 +617,9 @@
QCommonStyle handles the CE_CheckBox element. The QCheckBox
has two sub elements: SE_CheckBoxIndicator (the checked indicator)
- and SE_CheckBoxContents (the contents, which is used for the
+ and SE_CheckBoxContents (the contents, which are used for the
checkbox label). QCommonStyle also implements these sub element
- bounding rectangles. We have a look at the QCommonStyle code:
+ bounding rectangles. Next, we'll have a look at the QCommonStyle code:
\snippet code/doc_src_styles.cpp 3
@@ -640,7 +628,7 @@
CE_CheckBox, and then draws them. If the checkbox has focus,
the focus frame is also drawn.
- The java style draws CE_CheckBoxIndicator, while QCommonStyle
+ The Java style draws CE_CheckBoxIndicator, while QCommonStyle
handles CE_CheckboxLabel. We will examine each implementation and
start with CE_CheckBoxLabel:
@@ -649,81 +637,81 @@
\l{QStyle::}{visualAlignment()} adjusts the alignment of text
according to the layout direction. We then draw an icon if it
exists, and adjust the space left for the text.
- \l{QStyle::}{drawItemText()} draws the text taking alignment,
+ \l{QStyle::}{drawItemText()} draws the text, taking alignment,
layout direction, and the mnemonic into account. It also uses the
palette to draw the text in the right color.
- The drawing of labels often get somewhat involved. Luckily, it
- can usually be handled by the base class. The java style
- implements its own push button label since Java-contrary to
- windows-center button contents also when the button has an icon.
+ The drawing of labels often gets somewhat involved. Luckily, it
+ can usually be handled by the base class. The Java style
+ implements its own push button label, since Java - contrary to
+ Windows - centers button contents also when the button has an icon.
You can examine that implementation if you need an example of
reimplementing label drawing.
- We take a look at the java implementation
+ We'll now take a look at the Java implementation
of CE_CheckBoxIndicator in \c drawControl():
\snippet javastyle.cpp 0
We first save the state of the painter. This is not always
- necessary but in this case the QWindowsStyle needs the painter in
+ necessary, but in this case the QWindowsStyle needs the painter in
the same state as it was when PE_IndicatorCheckBox was called (We
could also set the state with function calls, of course). We then
use \c drawButtonBackground() to draw the background of the check
box indicator. This is a helper function that draws the background
and also the frame of push buttons and check boxes. We take a look
at that function below. We then check if the mouse is hovering
- over the checkbox. If it is, we draw the frame java checkboxes
+ over the checkbox. If it is, we draw the frame that Java checkboxes
have when the box is not pressed down and the mouse is over it.
- You may note that java does not handle tristate boxes, so we have
+ You may note that Java does not handle tri-state boxes, so we have
not implemented it.
- Here we use a png image for our indicator. We could also check
- here if the widget is disabled. We would then have to use
+ Here we use a PNG image for our indicator. We could also check
+ if the widget is disabled. We would then have to use
another image with the indicator in the disabled color.
\snippet javastyle.cpp 1
- We have seen how check boxes are styled in the java style from the
- widget gets a paint request to the style is finished painting. To
- learn in detail how each widget is painted, you need to go through
- the code step-by-step as we have done here. However, it is
- usually enough to know which style elements the widgets draw. The
- widget builds a style option and calls on the style one or more
- times to draw the style elements of which it consists. Usually,
- it is also sufficient to know the states a widget can be in and the
- other contents of the style option, i.e., what we list in the next
- section.
+ We have seen how check boxes are styled in the Java style from the
+ time the widget gets a paint request to the time the style is
+ finished painting. To learn in detail how each widget is painted,
+ you need to go through the code step-by-step as we have done here.
+ However, it is usually enough to know which style elements the
+ widgets draw. The widget builds a style option and calls on the
+ style one or more times to draw the style elements of which it
+ consists. Usually, it is also sufficient to know the states a widget
+ can be in and the other contents of the style option, i.e., what we
+ list in the next section.
\section1 Widget Walkthrough
In this section, we will examine how most of Qt's widgets are
- styled. Hopefully, this will save you some time and effort while
+ styled. Hopefully, this will save you some time and effort while
developing your own styles and widgets. You will not find
information here that is not attainable elsewhere (i.e., by
examining the source code or the class descriptions for the style
related classes).
- We mostly use java style widgets as examples. The java style does not
+ We mostly use Java style widgets as examples. The Java style does not
draw every element in the element trees. This is because they are
- not visible for that widget in the java style. We still make sure
+ not visible for that widget in the Java style. We still make sure
that all elements are implemented in a way that conforms with the
- java style as custom widgets might need them (this does not
+ Java style, as custom widgets might need them (this does not
exclude leaving implementations to QWindowsStyle though).
The following is given for each widget:
\list
\li A table with the members (variables, etc.) of its style option.
- \li A table over the state flags (QStyle::StateFlag) that
+ \li A table of the state flags (QStyle::StateFlag) that
can be set on the widget and when the states are set.
\li Its element tree (see section \l{The Style Elements}).
\li An image of the widget in which the elements are outlined.
\omit This is not written yet - probably never will be
either
- \li List of style hints that should be checked for the
+ \li A list of style hints that should be checked for the
widget.
- \li List of standard pixmaps that could be used by the
+ \li A list of standard pixmaps that could be used by the
elements.
\endomit
\endlist
@@ -735,7 +723,7 @@
elements, and pixel metrics that should be considered when drawing
the element of the node.
- Our approach on styling center on the drawing of the widgets. The
+ Our approach on styling centers on the drawing of the widgets. The
calculations of sub elements rectangles, sub controls, and pixel
metrics used \b during drawing is only listed as contents in
the element trees. Note that there are rectangles and pixel
@@ -781,25 +769,25 @@
\li State
\li State Set When
\row
- \li State_Enabled
+ \li \c State_Enabled
\li Set if the widget is not disabled (see
QWidget::setEnabled())
\row
- \li State_Focus
+ \li \c State_Focus
\li Set if the widget has focus (see
QWidget::hasFocus())
\row
- \li State_KeyobordFocusChange
+ \li \c State_KeyobordFocusChange
\li Set when the user changes focus with the keyboard
(see Qt::WA_KeyboardFocusChange)
\row
- \li State_MouseOver
+ \li \c State_MouseOver
\li Set if the mouse cursor is over the widget
\row
- \li State_Active
+ \li \c State_Active
\li Set if the widget is a child of the active window.
\row
- \li State_HasEditFocus
+ \li \c State_HasEditFocus
\li Set if the widget has the edit focus
\endtable
@@ -836,7 +824,7 @@
indicate which sub controls the complex control consists of and
which of these controls are currently active.
- As mentioned, the style calculates the size of the widgets
+ As mentioned, the style calculates the size of the widget's
contents, which the widgets calculate their size hints from. In
addition, complex controls also use the style to test which
sub-controls the mouse is over.
@@ -854,18 +842,18 @@
\image javastyle/pushbutton.png The style structure for push buttons
- The layout of the buttons, with regard element bounds, varies from
+ The layout of the buttons, with regard to element bounds, varies from
style to style. This makes it difficult to show conceptual images
of this. Also, elements may - even be intended to - have the same
- bounds; the PE_PushButtonBevel, for instance, is used in
- QCommonStyle to draw the elements that contains it:
- PE_FrameDefaultButton, PE_FrameButtonBevel, and
- PE_PanelButtonCommand, all of which have the same bounds in common
- and windows style. PE_PushButtonBevel is also responsible for
+ bounds; the \c PE_PushButtonBevel, for instance, is used in
+ QCommonStyle to draw the elements that it contains:
+ \c PE_FrameDefaultButton, \c PE_FrameButtonBevel, and
+ \c PE_PanelButtonCommand, all of which have the same bounds in common
+ and Windows style. \c PE_PushButtonBevel is also responsible for
drawing the menu indicator (QCommonStyle draws
- PE_IndicatorArrowDown).
+ \c PE_IndicatorArrowDown).
- An image of a push button in the java style that show the bounding
+ An image of a push button in the Java style that shows the bounding
rectangles of the elements is given below. Colors are used to
separate the bounding rectangles in the image; they do not fill
any other purpose. This is also true for similar images for the
@@ -873,11 +861,11 @@
\image javastyle/button.png
- The java style, as well as all other styles implemented in Qt,
- does not use PE_FrameButtonBevel. It is usual that a button
- with a PE_DefaultFrame adjusts the PE_PanelButtonCommand's
- rectangle by PM_ButtonDefaultIndicator. The CE_PushButtonLabel
- is found by adjusting the rect by PM_DefaultFrameWidth.
+ The Java style, as well as all other styles implemented in Qt,
+ does not use \c PE_FrameButtonBevel. It is usual that a button
+ with a \c PE_DefaultFrame adjusts the \c PE_PanelButtonCommand's
+ rectangle by \c PM_ButtonDefaultIndicator. The \c CE_PushButtonLabel
+ is found by adjusting the rect by \c PM_DefaultFrameWidth.
We will now examine the style option for push
buttons - QStyleOptionButton. A table for the states that
@@ -888,13 +876,13 @@
\li State
\li State Set When
\row
- \li State_Sunken
+ \li \c State_Sunken
\li Button is down or menu is pressed shown
\row
- \li State_On
+ \li \c State_On
\li Button is checked
\row
- \li State_Raised
+ \li \c State_Raised
\li Button is not flat and not pressed down
\endtable
@@ -936,17 +924,17 @@
\li State
\li State Set When
\row
- \li State_sunken
+ \li \c State_sunken
\li The box is pressed down
\row
- \li State_NoChange
- \li The box is partially checked (for tristate
+ \li \c State_NoChange
+ \li The box is partially checked (for tri-state
checkboxes.)
\row
- \li State_On
+ \li \c State_On
\li The box is checked
\row
- \li State_Off
+ \li \c State_Off
\li The box is unchecked
\endtable
@@ -961,13 +949,13 @@
QTabBar lays out the tabs, so the style does not have control over
tab placement. However, while laying out its tabs, the bar asks
- the style for PM_TabBarTabHSpace and PM_TabBarTabVSpace, which is
+ the style for \c PM_TabBarTabHSpace and \c PM_TabBarTabVSpace, which is
extra width and height over the minimum size of the tab bar tab
label (icon and text). The style can also further influence the
tab size before it is laid out, as the tab bar asks for
- CT_TabBarTab. The bounding rectangle of the bar is decided by the
+ \c CT_TabBarTab. The bounding rectangle of the bar is decided by the
tab widget when it is part of the widget (still considering
- CT_TabBarTab).
+ \c CT_TabBarTab).
The tab bar is responsible for drawing the buttons that appear on
the tab bar when all tabs do not fit. Their placement is not
@@ -979,33 +967,33 @@
\image javastyle/tab.png
The dotted lines indicate that the QTabWidget contains a tab bar,
- but does not draw it itself, that QTabBar only draws its base line
- when not part of a tab widget, and that the tab bar keeps two tool
+ but does not draw it itself. QTabBar only draws its base line
+ when not part of a tab widget, and it keeps two tool
buttons that scroll the bar when all tabs do not fit; see \l{Tool
Buttons} for their element tree. Also note that since the buttons
are children of the tab bar, they are drawn after the bar. The
- tabs bounding rectangles overlap the base by PM_TabBarBaseOverlap.
+ tabs' bounding rectangles overlap the base by \c PM_TabBarBaseOverlap.
- Here is a tab widget in the java style:
+ Here is a tab widget in the Java style:
\image javastyle/tabwidget.png
- In the java style (and also windows), the tab bar shape and label
- have the same bounding rectangle as CE_TabBarTab. Notice that the
+ In the Java style (and also Windows), the tab bar shape and label
+ have the same bounding rectangle as \c CE_TabBarTab. Notice that the
tabs overlap with the tab widget frame. The base of the tab bar
(if drawn) is the area where the tabs and frame overlap.
The style option for tabs (QStyleOptionTab) contains the necessary
information for drawing tabs. The option contains the position of
the tab in the tab bar, the position of the selected tab, the
- shape of the tab, the text, and icon. After Qt 4.1 the option
+ shape of the tab, the text, and the icon. After Qt 4.1, the option
should be cast to a QStyleOptionTabV2, which also contains the
- icons size.
+ icon's size.
- As the java style tabs don't overlap, we also present an image of
- a tab widget in the windows style. Note that if you want the tabs
+ As the Java style tabs don't overlap, we also present an image of
+ a tab widget in the Windows style. Note that if you want the tabs
to overlap horizontally, you do that when drawing the tabs in
- CE_TabBarTabShape; the tabs bounding rectangles will not be
+ \c CE_TabBarTabShape; the tabs bounding rectangles will not be
altered by the tab bar. The tabs are drawn from left to right in a
north tab bar shape, top to bottom in an east tab bar shape, etc.
The selected tab is drawn last, so that it is easy to draw it over
@@ -1020,14 +1008,14 @@
\li State
\li State Set When
\row
- \li State_Sunken
+ \li \c State_Sunken
\li The tab is pressed on with the mouse.
\row
- \li State_Selected
+ \li \c State_Selected
\li If it is the current tab.
\row
- \li State_HasFocus
- \li The tab bar has focus and the tab is selected
+ \li \c State_HasFocus
+ \li The tab bar has focus and the tab is selected.
\endtable
Note that individual tabs may be disabled even if the tab bar
@@ -1041,21 +1029,21 @@
\li Content
\row
\li cornerWidgets
- \li Is flags of the CornerWidget enum, which indicate
+ \li Flags of the CornerWidget enum, which indicate
if and which corner widgets the tab bar has.
\row
\li icon
- \li The QIcon of the tab
+ \li The QIcon of the tab.
\row
\li iconSize
- \li The QSize of the icon
+ \li The QSize of the icon.
\row
\li position
- \li A TabPosition enum value that indicates the tabs
+ \li A TabPosition enum value that indicates the tab's
position on the bar relative to the other tabs.
\row
\li row
- \li holds which row the tab is in
+ \li Holds which row the tab is in.
\row
\li selectedPosition
\li A value of the SelectedPosition enum that indicates
@@ -1063,12 +1051,12 @@
tab.
\row
\li shape
- \li A value of the QTabBar::Shape enum indication
+ \li A value of the QTabBar::Shape enum indicating
whether the tab has rounded or triangular corners
and the orientation of the tab.
\row
\li text
- \li The tab text
+ \li The tab text.
\endtable
The frame for tab widgets use QStyleOptionTabWidgetFrame as
@@ -1087,10 +1075,10 @@
\li The QSize of the right corner widget (if any).
\row
\li lineWidth
- \li holds the line with for drawing the panel.
+ \li Holds the line with for drawing the panel.
\row
\li midLineWith
- \li this value is currently always 0.
+ \li This value is currently always 0.
\row
\li shape
\li The shape of the tabs on the tab bar.
@@ -1101,28 +1089,28 @@
\section3 Scroll Bars
- Here is the style structure for scrollBars:
+ Here is the style structure for scrollbars:
\image javastyle/scrollbar.png
QScrollBar simply creates its style option and then draws
- CC_ScrollBar. Some styles draw the background of add page and sub
- page with PE_PanelButtonBevel and also use indicator arrows to
- draw the arrows in the nest and previous line indicators; we have
+ \c CC_ScrollBar. Some styles draw the background of add page and sub
+ page with \c PE_PanelButtonBevel, and also use indicator arrows to
+ draw the arrows in the next and previous line indicators; we have
not included these in the tree as their use is up to the
- individual style. The style's PM_MaximumDragDistance is the
+ individual style. The style's \c PM_MaximumDragDistance is the
maximum distance in pixels the mouse can move from the bounds
of the scroll bar and still move the handle.
- Here is an image of a scrollbar in the java style:
+ Here is an image of a scrollbar in the Java style:
\image javastyle/scrollbarimage.png
You may notice that the scrollbar is slightly different from
- Java's as it has two line up indicators. We have done this to show
- how that you can have two separate bounding rectangles for a
+ Java's, as it has two line up indicators. We have done this to show
+ that you can have two separate bounding rectangles for a
single sub control. The scroll bar is an example of a widget that
- is entirely implemented by the java style - neither QWindowsStyle
+ is entirely implemented by the Java style - neither QWindowsStyle
nor QCommonStyle are involved in the drawing.
We have a look at the different states a scroll bar can set on
@@ -1133,8 +1121,8 @@
\li State
\li State Set When
\row
- \li State_Horizontal
- \li The scroll bar is horizontal
+ \li \c State_Horizontal
+ \li The scroll bar is horizontal.
\endtable
The style option of QScrollBar is QStyleOptionSlider. Its
@@ -1148,57 +1136,57 @@
\li Content
\row
\li maximum
- \li the maximum value of the scroll bar
+ \li The maximum value of the scroll bar.
\row
\li minimum
- \li the minimum value of the scroll bar
+ \li The minimum value of the scroll bar.
\row
\li notchTarget
- \li the number of pixels between notches
+ \li The number of pixels between notches.
\row
\li orientation
- \li a value of the Qt::Orientation enum that specifies
- whether the scroll bar is vertical or horizontal
+ \li A value of the Qt::Orientation enum that specifies
+ whether the scroll bar is vertical or horizontal.
\row
\li pageStep
- \li the number to increase or decrease the sliders
+ \li The number by which to increase or decrease the slider's
value (relative to the size of the slider and its value
range) on page steps.
\row
\li singleStep
- \li the number to increase or decrease the sliders
- value on single (or line) steps
+ \li The number by which to increase or decrease the slider's
+ value on single (or line) steps.
\row
\li sliderValue
- \li The value of the slider
+ \li The value of the slider.
\row
\li sliderPosition
- \li the position of the slider handle. This is the same
+ \li The position of the slider handle. This is the same
as \c sliderValue if the scroll bar is
QAbstractSlider::tracking. If not, the scroll
bar does not update its value before the mouse
releases the handle.
\row
\li upsideDown
- \li holds the direction in which the scroll bar
+ \li Holds the direction in which the scroll bar
increases its value. This is used instead of
QStyleOption::direction for all abstract sliders.
\endtable
\section3 Sliders
- When calculating the sliders size hint, PM_SliderTickness and
- PM_SliderLength is queried from the style. As with scroll bars,
+ When calculating the slider's size hint, \c PM_SliderThickness and
+ \c PM_SliderLength are queried from the style. As with scroll bars,
the QSlider only lets the user move the handle if the mouse is
- within PM_MaximumDragDistance from the slider bounds. When it
- draws itself it creates the style option and calls \c
- drawComplexControl() with CC_Slider:
+ within \c PM_MaximumDragDistance from the slider bounds. When it
+ draws itself, it creates the style option and calls \c
+ drawComplexControl() with \c CC_Slider:
\image javastyle/slider.png
- We also show a picture of a slider in the java style. We show
- the bounding rectangles of the sub elements as all drawing is done
- in CC_Slider.
+ We also show a picture of a slider in the Java style. We show
+ the bounding rectangles of the sub elements, as all drawing is done
+ in \c CC_Slider.
\image javastyle/sliderimage.png
@@ -1211,38 +1199,38 @@
\li Content
\row
\li maximum
- \li the maximum value of the slider
+ \li The maximum value of the slider.
\row
\li minimum
- \li the minimum value of the slider
+ \li The minimum value of the slider.
\row
\li notchTarget
- \li this is the number of pixels between each notch
+ \li This is the number of pixels between each notch.
\row
\li orientation
- \li a Qt::Orientation enum value that gives whether the
+ \li A Qt::Orientation enum value that indicates whether the
slider is vertical or horizontal.
\row
\li pageStep
- \li a number in slider value to increase or decrease
- for page steps
+ \li The number by which to increase or decrease the slider's
+ value on page steps.
\row
\li singleStep
- \li the number to increase or decrease the sliders
+ \li The number by which to increase or decrease the slider's
value on single (or line) steps.
\row
\li sliderValue
- \li the value of the slider.
+ \li The value of the slider.
\row
\li sliderPosition
- \li the position of the slider given as a slider value.
+ \li The position of the slider given as a slider value.
This will be equal to the \c sliderValue if the
slider is \l{QAbstractSlider::}{tracking}; if
- not, the sliders value will not change until the handle is
+ not, the slider's value will not change until the handle is
released with the mouse.
\row
- \li upsideDown
- \li this member is used instead of QStyleOption::direction
+ \li upsideDown
+ \li This member is used instead of QStyleOption::direction
for all abstract sliders.
\endtable
@@ -1251,34 +1239,34 @@
\section3 Spin Boxes
- When QSpinBox paints itself it creates a QStyleOptionSpinBox and
- asks the style to draw CC_SpinBox. The edit field is a line
+ When QSpinBox paints itself, it creates a QStyleOptionSpinBox and
+ asks the style to draw \c CC_SpinBox. The edit field is a line
edit that is a child of the spin box. The dimensions of the
- field is calculated by the style with SC_SpinBoxEditField.
+ field are calculated by the style with \c SC_SpinBoxEditField.
Here follows the style tree for spin boxes. It is not
required that a style uses the button panel primitive to paint
the indicator backgrounds. You can see an image below the tree
- showing the sub elements in QSpinBox in the java style.
+ showing the sub elements in QSpinBox in the Java style.
\image javastyle/spinbox.png
\image javastyle/spinboximage.png
The QStyleOptionSpinBox, which is the style option for spin
- boxes. It can set the following states on the spin box.:
+ boxes. It can set the following states on the spin box:
\table 90%
\header
\li State
\li State Set When
\row
- \li State_Sunken
- \li Is set if one of the sub controls CC_SpinUp or
- CC_SpinDown is pressed on with the mouse.
+ \li \c State_Sunken
+ \li Is set if one of the sub controls \c CC_SpinUp or
+ \c CC_SpinDown is pressed on with the mouse.
\endtable
- The rest of the members in the spin boxes style options are:
+ The rest of the members in the spin box style options are:
\table 90%
\header
@@ -1286,7 +1274,7 @@
\li Function
\row
\li frame
- \li boolean that is true if the spin box is to draw a
+ \li Boolean that is \c true if the spin box is to draw a
frame.
\row
\li buttonSymbols
@@ -1294,34 +1282,34 @@
symbol on the up/down buttons.
\row
\li stepEnabled
- \li A value of the StepEnabled indication which of the
+ \li A value of the StepEnabled enum, indicating which of the
spin box buttons are pressed down.
\endtable
\section3 Title Bar
- The title bar complex control, CC_TitleBar, is used to draw
+ The title bar complex control, \c CC_TitleBar, is used to draw
the title bars of internal windows in QMdiArea. It typically
- consists of a window title and close, minimize, system menu, and
+ consists of a window title, and close, minimize, system menu, and
maximize buttons. Some styles also provide buttons for shading
- the window, and a button for context sensitive help.
+ the window, as well as a button for context sensitive help.
- The bar is drawn in CC_TitleBar without using any sub elements.
- How the individual styles draw their buttons is individual, but
+ The bar is drawn in \c CC_TitleBar without using any sub elements.
+ How the individual styles draw their buttons is up to them, but
there are standard pixmaps for the buttons that the style should
provide.
\image javastyle/titlebar.png
- In an image over a title bar in the java style, we show the
- bounding rectangles of the sub elements supported by the java style
+ In an image over a title bar in the Java style, we show the
+ bounding rectangles of the sub elements supported by the Java style
(all of which are drawn with standard pixmaps). It is usual to
- draw the button backgrounds using PE_PanelButtonTool, but it's no
- rule.
+ draw the button backgrounds using \c PE_PanelButtonTool, but it's not
+ mandatory.
\image javastyle/titlebarimage.png
- The style option for title bars is QStyleOptionTitleBar. It's
+ The style option for title bars is QStyleOptionTitleBar. Its
members are:
\table 90%
@@ -1330,42 +1318,42 @@
\li Content
\row
\li icon
- \li The title bars icon
+ \li The title bar's icon.
\row
\li text
- \li the text for the title bar's label
+ \li The text for the title bar's label.
\row
\li windowFlags
- \li flags of the Qt::WindowFlag enum. The window flags
+ \li Flags of the Qt::WindowFlag enum. The window flags
used by QMdiArea for window management.
\row
\li titleBarState
- \li this is the QWidget::windowState() of the window
+ \li This is the QWidget::windowState() of the window
that contains the title bar.
\endtable
\section3 Combo Box
A QComboBox uses the style to draw the button and label of
- non-editable boxes with CC_ComboBox and CE_ComboBoxLabel.
+ non-editable boxes with \c CC_ComboBox and \c CE_ComboBoxLabel.
The list that pops up when the user clicks on the combo box is
drawn by a \l{Delegate Classes}{delegate}, which we do not cover
in this overview. You can, however, use the style to control the
list's size and position with the sub element
- SC_ComboBoxListBoxPopup. The style also decides where the edit
- field for editable boxes should be with SC_ComboBoxEditField; the
+ \c SC_ComboBoxListBoxPopup. The style also decides where the edit
+ field for editable boxes should be with \c SC_ComboBoxEditField; the
field itself is a QLineEdit that is a child of the combo box.
\image javastyle/combobox.png
- We show an image over a java style combo box in which we have
+ We show an image over a Java style combo box in which we have
outlined its sub elements and sub element rectangles:
\image javastyle/comboboximage.png
Java combo boxes do not use the focus rect; it changes its
- background color when it has focus. The SC_ComboBoxEdit field is
+ background color when it has focus. The \c SC_ComboBoxEdit field is
used both by QComboBox to calculate the size of the edit field and
the style for calculating the size of the combo box label.
@@ -1377,14 +1365,14 @@
\li State
\li Set When
\row
- \li State_Selected
- \li The box is not editable and has focus
+ \li \c State_Selected
+ \li The box is not editable and has focus.
\row
- \li State_Sunken
- \li SC_ComboBoxArrow is active
+ \li \c State_Sunken
+ \li \c SC_ComboBoxArrow is active.
\row
- \li State_on
- \li The container (list) of the box is visible
+ \li \c State_on
+ \li The container (list) of the box is visible.
\endtable
The style options other members are:
@@ -1395,37 +1383,37 @@
\li Content
\row
\li currentIcon
- \li the icon of the current (selected) item of the
+ \li The icon of the current (selected) item of the
combo box.
\row
\li currentText
- \li the text of the current item in the box.
+ \li The text of the current item in the box.
\row
\li editable
- \li holds whether the combo box is editable or not
+ \li Holds whether the combo box is editable or not.
\row
\li frame
- \li holds whether the combo box has a frame or not
+ \li Holds whether the combo box has a frame or not.
\row
\li iconSize
- \li the size of the current items icon.
+ \li The size of the current items icon.
\row
\li popupRect
- \li the bounding rectangle of the combo box's popup
+ \li The bounding rectangle of the combo box's popup
list.
\endtable
\section3 Group Boxes
When calculating the size hint, QGroupBox fetches three pixel
- metrics from the style: PM_IndicatorWidth,
- PM_CheckBoxLabelSpacing, and PM_IndicatorHeight. QGroupBox has
+ metrics from the style: \c PM_IndicatorWidth,
+ \c PM_CheckBoxLabelSpacing, and \c PM_IndicatorHeight. QGroupBox has
the following style element tree:
\image javastyle/groupbox.png
Qt does not impose restrictions on how the check box is drawn; the
- java style draws it with CE_IndicatorCheckBox. See \l{Check and
+ Java style draws it with \c CE_IndicatorCheckBox. See \l{Check and
Radio Buttons} for the complete tree.
We also give an image of the widget with the sub controls and
@@ -1433,7 +1421,7 @@
\image javastyle/groupboximage.png
- The style option for group boxes are QStyleOptionGroupBox. The
+ The style option for group boxes is QStyleOptionGroupBox. The
following states can be set on it:
\table 90%
@@ -1441,14 +1429,14 @@
\li State
\li Set When
\row
- \li State_On
- \li The check box is checked
+ \li \c State_On
+ \li The check box is checked.
\row
- \li State_Sunken
- \li The checkbox is pressed down
+ \li \c State_Sunken
+ \li The check box is pressed down.
\row
- \li State_Off
- \li The check box is unchecked (or there is no check box)
+ \li \c State_Off
+ \li The check box is unchecked (or there is no check box).
\endtable
The remaining members of QStyleOptionGroupBox are:
@@ -1459,30 +1447,30 @@
\li Content
\row
\li features
- \li flags of the QStyleOptionFrameV2::FrameFeatures
+ \li Flags of the QStyleOptionFrameV2::FrameFeatures
enum describing the frame of the group box.
\row
\li lineWidth
- \li the line width with which to draw the panel. This
+ \li The line width with which to draw the panel. This
is always 1.
\row
\li text
- \li the text of the group box.
+ \li The text of the group box.
\row
\li textAlignment
- \li the alignment of the group box title
+ \li The alignment of the group box title.
\row
\li textColor
- \li the QColor of the text
+ \li The QColor of the text.
\endtable
\section3 Splitters
As the structure of splitters are simple and do not contain any
- sub elements, we do not include image of splitters. CE_Splitter
+ sub elements, we do not include any images of splitters. \c CE_Splitter
does not use any other elements or metrics.
- For its style option, Splitters uses the base class QStyleOption.
+ For its style option, the splitter uses the base class QStyleOption.
It can set the following state flags on it:
\table 90%
@@ -1490,23 +1478,22 @@
\li State
\li Set When
\row
- \li State_Horizontal
- \li Set if it is a horizontal splitter
+ \li \c State_Horizontal
+ \li Set if it is a horizontal splitter.
\endtable
QSplitter does not use \l{QStyleOption::}{initFrom()} to set up its
- option; it sets the State_MouseOver and State_Disabled flags
+ option; it sets the \c State_MouseOver and \c State_Disabled flags
itself.
\section3 Progress Bar
- The CE_ProgressBar element is used by QProgressBar, and it is the
- only element used by this widget. We start with looking at the
- style structure:
+ The \c CE_ProgressBar element is used by QProgressBar, and it is the
+ only element used by this widget. We start with the style structure:
\image javastyle/progressbar.png
- Here is a progress bar in the windows style (the java style
+ Here is a progress bar in the Windows style (the Java style
bounding rectangles are equal):
\image javastyle/progressbarimage.png
@@ -1521,32 +1508,32 @@
\li Content
\row
\li minimum
- \li The minimum value of the bar
+ \li The minimum value of the bar.
\row
\li maximum
- \li The maximum value of the bar
+ \li The maximum value of the bar.
\row
\li progress
- \li The current value of the bar
+ \li The current value of the bar.
\row
\li textAlignment
- \li How the text is aligned in the label
+ \li How the text is aligned in the label.
\row
\li textVisible
- \li Whether the label is drawn
+ \li Whether the label is drawn.
\row
\li text
- \li The label text
+ \li The label text.
\row
\li orientation
- \li Progress bars can be vertical or horizontal
+ \li Progress bars can be vertical or horizontal.
\row
\li invertedAppearance
\li The progress is inverted (i.e., right to left in a
- horizontal bar)
+ horizontal bar).
\row
\li bottomToTop
- \li Boolean that if true, turns the label of vertical
+ \li Boolean, that, if \c true, turns the label of vertical
progress bars 90 degrees.
\endtable
@@ -1554,20 +1541,18 @@
Tool buttons exist either independently or as part of tool bars.
They are drawn equally either way. The QToolButton draws only one
- style element: CC_ToolButton.
+ style element: \c CC_ToolButton.
- As you must be used to by now (at least if you have read this
- document sequentially), we have a tree of the widget's style
- structure:
+ Below is a tree of the widget's style structure:
\image javastyle/toolbutton.png
- Note that PE_FrameButtonTool and PE_IndicatorArrowDown are
- included in the tree as the java style draws them, but they can
+ Note that \c PE_FrameButtonTool and \c PE_IndicatorArrowDown are
+ included in the tree as the Java style draws them, but they can
safely be omitted if you prefer it. The structure may also be
different. QWindowsStyle, for instance, draws both
- PE_IndicatorButtonDropDown and PE_IndicatorArrowDown in
- CE_ToolButton.
+ \c PE_IndicatorButtonDropDown and \c PE_IndicatorArrowDown in
+ \c CE_ToolButton.
We also have an image of a tool button where we have outlined
the sub element bounding rectangles and sub controls.
@@ -1581,18 +1566,18 @@
\li State
\li Set When
\row
- \li State_AutoRise
- \li the tool button has the autoRise property set
+ \li \c State_AutoRise
+ \li The tool button has the autoRise property set.
\row
- \li State_raised
- \li the button is not sunken (i.e., by being checked or
+ \li \c State_Raised
+ \li The button is not sunken (i.e., by being checked or
pressed on with the mouse).
\row
- \li State_Sunken
- \li the button is down
+ \li \c State_Sunken
+ \li The button is down.
\row
- \li State_On
- \li the button is checkable and checked.
+ \li \c State_On
+ \li The button is checkable and checked.
\endtable
QStyleOptionToolButton also contains the following members:
@@ -1603,50 +1588,50 @@
\li Content
\row
\li arrowType
- \li a Qt::ArrowType enum value, which contains the
+ \li A Qt::ArrowType enum value, which contains the
direction of the buttons arrow (if an arrow is to
- be used in place of an icon)
+ be used in place of an icon).
\row
\li features
- \li flags of the QStyleOptionToolButton::ButtonFeature
+ \li Flags of the QStyleOptionToolButton::ButtonFeature
enum describing if the button has an arrow, a menu,
and/or has a popup-delay.
\row
\li font
- \li the QFont of the buttons label
+ \li The QFont of the buttons label.
\row
\li icon
- \li the QIcon of the tool button
+ \li The QIcon of the tool button.
\row
\li iconSize
- \li the icon size of the button's icon
+ \li The icon size of the button's icon.
\row
\li pos
- \li the position of the button, as given by
+ \li The position of the button, as given by
QWidget::pos()
\row
\li text
- \li the text of the button
+ \li The text of the button.
\row
\li toolButtonStyle
- \li a Qt::ToolButtonStyle enum value which decides
+ \li A Qt::ToolButtonStyle enum value which decides
whether the button shows the icon, the text, or both.
\endtable
\section3 Toolbars
- Toolbars are part of the \l{QMainWindow}{main window framework}
- and cooperates with the QMainWindow to which it belongs while it
+ Toolbars are part of the \l{QMainWindow}{main window framework},
+ and cooperate with the QMainWindow to which they belong while it
builds its style option. A main window has 4 areas that toolbars
can be placed in. They are positioned next to the four sides of
- the window (i.e., north, south, west, and east). Within each area
+ the window (i.e., north, south, east and west). Within each area
there can be more than one line of toolbars; a line consists of
toolbars with equal orientation (vertical or horizontal) placed
next to each other.
- \l{QToolbar}{QToolbar}s in Qt consists of three elements
- CE_ToolBar, PE_IndicatorToolBarHandle, and
- PE_IndicatorToolBarSeparator. It is QMainWindowLayout that
+ \l{QToolbar}{QToolbar}s in Qt consist of three elements:
+ \c CE_ToolBar, \c PE_IndicatorToolBarHandle, and
+ \c PE_IndicatorToolBarSeparator. It is QMainWindowLayout that
calculates the bounding rectangles (i.e., position and size of the
toolbars and their contents. The main window also uses the \c
sizeHint() of the items in the toolbars when calculating the size
@@ -1659,19 +1644,19 @@
The dotted lines indicate that the QToolBar keeps an instance of
QToolBarLayout and that QToolBarSeparators are kept by
QToolBarLayout. When the toolbar is floating (i.e., has its own
- window) the PE_FrameMenu element is drawn, else QToolbar draws
- CE_ToolBar.
+ window) the \c PE_FrameMenu element is drawn, else QToolbar draws
+ \c CE_ToolBar.
- Here is an image of a toolbar in the java style:
+ Here is an image of a toolbar in the Java style:
\image javastyle/toolbarimage.png
- QToolBarSaparator uses QStyleOption for their style option. It
- sets the State_horizontal flag if the toolbar they live in is
+ QToolBarSaparator uses QStyleOption for its style option. It
+ sets the \c State_Horizontal flag if the toolbar it lives in is
horizontal. Other than that, they use \l{QStyleOption::}{initFrom()}.
The style option for QToolBar is QStyleOptionToolBar. The only
- state flag set (besides the common flags) is State_Horizontal
+ state flag set (besides the common flags) is \c State_Horizontal
if the bar is horizontal (i.e., in the north or south toolbar area).
The member variables of the style option are:
@@ -1688,8 +1673,7 @@
\li The width of the tool bar frame.
\row
\li midLineWidth
- \li This variable is currently not used and is always
- 0.
+ \li This variable is currently not used and is always 0.
\row
\li positionOfLine
\li The position of the toolbar line within the toolbar
@@ -1705,31 +1689,31 @@
\section3 Menus
Menus in Qt are implemented in QMenu. The QMenu keeps a list of
- action, which it draws as menu items. When QMenu receives paint
- events ,it calculates the size of each menu item and draws them
- individually with CE_MenuItem. (Menu items do not have a separate
+ actions, which it draws as menu items. When QMenu receives paint
+ events, it calculates the size of each menu item and draws them
+ individually with \c CE_MenuItem. Menu items do not have a separate
element for their label (contents), so all drawing is done in
- CE_MenuItem. The menu also draws the frame of the menu with
- PE_FrameMenu. It also draws CE_MenuScroller if the style supports
- scrolling. CE_MenuTearOff is drawn if the menu is to large for its
+ \c CE_MenuItem. The menu also draws the frame of the menu with
+ \c PE_FrameMenu. It also draws \c CE_MenuScroller if the style supports
+ scrolling. \c CE_MenuTearOff is drawn if the menu is too large for its
bounding rectangle.
In the style structure tree, we also include QMenu as it also does
styling related work. The bounding rectangles of menu items are
- calculated for the menus size hint and when the menu is displayed
+ calculated for the menu's size hint and when the menu is displayed
or resized.
\image javastyle/menu.png
- The CE_MenuScroller and CE_MenuTearOff elements are handled by
- QCommonStyle and are not shown unless the menu is to large to fit
- on the screen. PE_FrameMenu is only drawn for pop-up menus.
+ The \c CE_MenuScroller and \c CE_MenuTearOff elements are handled by
+ QCommonStyle and are not shown unless the menu is too large to fit
+ on the screen. \c PE_FrameMenu is only drawn for pop-up menus.
QMenu calculates rectangles based on its actions and calls
- CE_MenuItem and CE_MenuScroller if the style supports that.
+ \c CE_MenuItem and \c CE_MenuScroller if the style supports that.
- It is also usual to use PE_IndicatorCheckBox (instead of using
- PE_IndicatorMenuCheckMark) and PE_IndicatorRadioButton for drawing
+ It is also usual to use \c PE_IndicatorCheckBox (instead of using
+ \c PE_IndicatorMenuCheckMark) and \c PE_IndicatorRadioButton for drawing
checkable menu items; we have not included them in the style tree
as this is optional and varies from style to style.
@@ -1743,14 +1727,14 @@
\li State
\li Set When
\row
- \li State_Selected
+ \li \c State_Selected
\li The mouse is over the action and the action is not
a separator.
\row
- \li State_Sunken
+ \li \c State_Sunken
\li The mouse is pressed down on the menu item.
\row
- \li State_DownArrow
+ \li \c State_DownArrow
\li Set if the menu item is a menu scroller and it scrolls
the menu downwards.
\endtable
@@ -1766,19 +1750,19 @@
NonExclusive.
\row
\li checked
- \li Boolean that is true if the menu item is checked.
+ \li Boolean that is \c true if the menu item is checked.
\row
\li font
\li The QFont to use for the menu item's text.
\row
\li icon
- \li the QIcon of the menu item.
+ \li The QIcon of the menu item.
\row
\li maxIconWidth
- \li The maximum width allowed for the icon
+ \li The maximum width allowed for the icon.
\row
\li menuHasChecableItem
- \li Boolean which is true if at least one item in the
+ \li Boolean which is \c true if at least one item in the
menu is checkable.
\row
\li menuItemType
@@ -1797,8 +1781,8 @@
\li The text of the menu item.
\endtable
- The setup of the style option for CE_MenuTearOff and
- CE_MenuScroller also uses QStyleOptionMenuItem; they only set the
+ The setup of the style option for \c CE_MenuTearOff and
+ \c CE_MenuScroller also uses QStyleOptionMenuItem; they only set the
\c menuRect variable in addition to the common settings with
QStyleOption's \l{QStyleOption::}{initFrom()}.
@@ -1811,17 +1795,17 @@
\image javastyle/menubar.png
- The panel and empty area is drawn after the menu items. The
+ The panel and empty area are drawn after the menu items. The
QPainter that the QMenuBar sends to the style has the bounding
rectangles of the items clipped out (i.e., clip region), so you
don't need to worry about drawing over the items. The pixel
- metrics in QMenuBar is used when the bounding rectangles of the
+ metrics in QMenuBar are used when the bounding rectangles of the
menu bar items are calculated.
\image javastyle/menubarimage.png
QStyleOptionMenuItem is used for menu bar items. The members that
- are used by QMenuBar is described in the following table:
+ are used by QMenuBar are described in the following table:
\table
\header
@@ -1829,31 +1813,31 @@
\li Content
\row
\li menuRect
- \li the bounding rectangle of the entire menu bar to
+ \li The bounding rectangle of the entire menu bar to
which the item belongs.
\row
\li text
- \li the text of the item
+ \li The text of the item.
\row
\li icon
- \li the icon of the menu item (it is not common that
- styles draw this icon)
+ \li The icon of the menu item (it is not common that
+ styles draw this icon).
\endtable
- QStyleOptionMenuItem is also used for drawing CE_EmptyMenuBarArea.
+ QStyleOptionMenuItem is also used for drawing \c CE_EmptyMenuBarArea.
- QStyleOptionFrame is used for drawing the panel frame The
- \l{QStyleOptionFrame::}{lineWidth} is set to PM_MenuBarPanelWidth.
+ QStyleOptionFrame is used for drawing the panel frame. The
+ \l{QStyleOptionFrame::}{lineWidth} is set to \c PM_MenuBarPanelWidth.
The \l{QStyleOptionFrame::}{midLineWidth} is currently always set
to 0.
\section3 Item View Headers
It is the style that draws the headers of Qt's item views. The
- item views keeps the dimensions on individual sections. Also
+ item views keep the dimensions on individual sections. Also
note that the delegates may use the style to paint decorations
and frames around items. QItemDelegate, for instance, draws
- PE_FrameFocusRect and PE_IndicatorViewItemCheck.
+ \c PE_FrameFocusRect and \c PE_IndicatorViewItemCheck.
\image javastyle/header.png
@@ -1862,11 +1846,11 @@
\image javastyle/headerimage.png
- The QHeaderView uses CT_HeaderSection, PM_HeaderMargin and
- PM_HeaderGripMargin for size and hit test calculations. The
- PM_HeaderMarkSize is currently not used by Qt. QTableView draws
+ The QHeaderView uses \c CT_HeaderSection, \c PM_HeaderMargin and
+ \c PM_HeaderGripMargin for size and hit test calculations. The
+ \c PM_HeaderMarkSize is currently not used by Qt. QTableView draws
the button in the top-left corner (i.e., the area where the
- vertical and horizontal headers intersect) as a CE_Header.
+ vertical and horizontal headers intersect) as a \c CE_Header.
The style option for header views is QStyleOptionHeader. The view
paints one header section at a time, so the data is for the
@@ -1878,51 +1862,49 @@
\li Content
\row
\li icon
- \li the icon of the header (for section that is being
- drawn).
+ \li The icon of the header (for section that is being drawn).
\row
\li iconAlignment
- \li the alignment (Qt::Alignment) of the icon in the header.
+ \li The alignment (Qt::Alignment) of the icon in the header.
\row
\li orientation
- \li a Qt::Orientation value deciding whether the header
+ \li A Qt::Orientation value deciding whether the header
is the horizontal header above the view or the
vertical header on the left.
\row
\li position
- \li a QStyleOptionHeader::SectionPosition value
+ \li A QStyleOptionHeader::SectionPosition value
giving the header section's position relative to
the other sections.
\row
\li section
- \li holds the section that is being drawn.
+ \li Holds the section that is being drawn.
\row
\li selectedPosition
- \li a QStyleOptionHeader::SelectedPosition value giving
+ \li A QStyleOptionHeader::SelectedPosition value giving
the selected section's position relative to the
section that is being painted.
\row
\li sortIndicator
- \li a QStyleOptionHeader::SortIndicator value that
+ \li A QStyleOptionHeader::SortIndicator value that
describes the direction in which the section's sort
indicator should be drawn.
\row
\li text
- \li the text of the currently drawn section.
+ \li The text of the currently drawn section.
\row
\li textAlignment
- \li the Qt::Alignment of the text within the
- headersection.
+ \li The Qt::Alignment of the text within the header section.
\endtable
\section3 Tree Branch Indicators
- The branch indicators in a tree view is drawn by the style with
- PE_IndicatorBranch. We think of indicators here as the indicators
+ The branch indicators in a tree view are drawn by the style with
+ \c PE_IndicatorBranch. We think of indicators here as the indicators
that describe the relationship of the nodes in the tree. The
- generic QStyleOption is sent to the style for drawing this
+ generic QStyleOption is sent to the style for drawing these
elements. The various branch types are described by states. Since
- there are no specific style option, we simply present the states
+ there is no specific style option, we simply present the states
table:
\table 90%
@@ -1930,30 +1912,30 @@
\li State
\li Set When
\row
- \li State_Sibling
- \li the node in the tree has a sibling (i.e., there is
+ \li \c State_Sibling
+ \li The node in the tree has a sibling (i.e., there is
another node in the same column).
\row
- \li State_Item
- \li this branch indicator has an item.
+ \li \c State_Item
+ \li This branch indicator has an item.
\row
- \li State_Children
- \li the branch has children (i.e., a new sub-tree can
+ \li \c State_Children
+ \li The branch has children (i.e., a new sub-tree can
be opened at the branch).
\row
- \li State_Open
- \li the branch indicator has an opened sub-tree.
+ \li \c State_Open
+ \li The branch indicator has an opened sub-tree.
\endtable
The tree view (and tree widget) use the style to draw the branches
- (or nodes if you will) of the tree.
+ (nodes) of the tree.
- QStyleOption is used as the style for PE_IndicatorBranch has state
+ QStyleOption is used as the style for \c PE_IndicatorBranch has state
flags set depending on what type of branch it is.
Since there is no tree structure for branch indicators, we only
- present an image of a tree in the java style. Each state is marked
- in the image with a rectangle in a specific color (i.e., these
+ present an image of a tree in the Java style. Each state is marked
+ in the image with a rectangle in a specific color (i.e., the
rectangles are not bounding rectangles). All combinations of
states you must be aware of are represented in the image.
@@ -1961,10 +1943,10 @@
\section3 Tool Boxes
- PM_SmallIconSize for sizeHints.
+ \c PM_SmallIconSize for sizeHints.
QToolBox is a container that keeps a collection of widgets. It has
- one tab for each widget and display one of them at a time. The
+ one tab for each widget and displays one of them at a time. The
tool box lays the components it displays (the tool box buttons
and selected widget) in a QVBoxLayout. The style tree for tool
boxes looks like this:
@@ -1976,11 +1958,11 @@
\image javastyle/toolboximage.png
All elements have the same bounding rectangles in the
- Plastique as well as the other Qt built-in styles.
+ Plastique style as well as the other built-in Qt styles.
The style option for tool boxes is QStyleOptionToolBox. It
contains the text and icon of the tool box contents. The only
- state set by QToolBox is State_Sunken, which is set when the user
+ state set by QToolBox is \c State_Sunken, which is set when the user
presses a tab down with the mouse. The rest of the
QStyleOptionToolBox members are:
@@ -1990,27 +1972,27 @@
\li Content
\row
\li icon
- \li the icon on the toolbox tab
+ \li The icon on the toolbox tab.
\row
\li text
- \li the text on the toolbox tab
+ \li The text on the toolbox tab.
\endtable
\section3 Size Grip
- The size grip calculates its size hint with CT_SizeGrip. The pixel
- metric PM_SizeGripSize is currently unused by Qt. The element tree
- for and an image in the Plastique style of QSizeGrip follows:
+ The size grip calculates its size hint with \c CT_SizeGrip. The pixel
+ metric \c PM_SizeGripSize is currently unused by Qt. The element tree
+ for an image in the Plastique style of QSizeGrip follows:
\image javastyle/sizegrip.png
\image javastyle/sizegripimage.png
- We show the size grip in a \l{QMainWindow}'s bottom right
+ We show the size grip in \l{QMainWindow}'s bottom right
corner.
- The size grip style option, QStyleOptionSizeGrip, have one
- member except the common members from QStyleOption:
+ The size grip style option, QStyleOptionSizeGrip, has one
+ member besides the common members from QStyleOption:
\table 90%
\header
@@ -2018,7 +2000,7 @@
\li Content
\row
\li corner
- \li a Qt::Corner value that describe which corner in a
+ \li A Qt::Corner value that describes which corner in a
window (or equivalent) the grip is located.
\endtable
@@ -2042,29 +2024,29 @@
\li Content
\row
\li opaque
- \li boolean that is true if the rubber band must be
- drawn in an opaque style (i.e., color)
+ \li Boolean that is \c true if the rubber band must be
+ drawn in an opaque style (i.e., color).
\row
\li shape
- \li a QRubberBand::Shape enum value that holds the
+ \li A QRubberBand::Shape enum value that holds the
shape of the band (which is either a rectangle or a
- line)
+ line).
\endtable
\section3 Dock Widgets
When the dock widget lays out its contents it asks the style for
- these pixel metrics: PM_DockWidgetSeparatorExtent,
- PM_DockWidgetTitleBarButtonMargin, PM_DockWidgetFrameWidth, and
- PM_DockWidgetTitleMargin. It also calculates the bounding
+ these pixel metrics: \c PM_DockWidgetSeparatorExtent,
+ \c PM_DockWidgetTitleBarButtonMargin, \c PM_DockWidgetFrameWidth, and
+ \c PM_DockWidgetTitleMargin. It also calculates the bounding
rectangles of the float and close buttons with
- SE_DockWidgetCloseButton and SE_DockWidgetFloatButton.
+ \c SE_DockWidgetCloseButton and \c SE_DockWidgetFloatButton.
\image javastyle/dockwidget.png
The dotted lines indicate that the sender keeps instances of the
recipient of the arrow (i.e., it is not a style element to draw).
- The dock widget only draws PE_frameDockWidget when it is detached
+ The dock widget only draws \c PE_frameDockWidget when it is detached
from its main window (i.e., it is a top level window). If it is
docked it draws the indicator dock widget resize handle. We show a
dock widget in both docked and floating state in the plastique
@@ -2080,20 +2062,20 @@
\li Content
\row
\li closeable
- \li boolean that holds whether the dock window can be
- closed
+ \li Boolean that holds whether the dock window can be
+ closed.
\row
\li floatable
- \li boolean that holds whether the dock window can
+ \li Boolean that holds whether the dock window can
float (i.e., detach from the main window in which
- it lives)
+ it lives).
\row
\li movable
- \li boolean that holds whether the window is movable
- (i.e., can move to other dock widget areas)
+ \li Boolean that holds whether the window is movable
+ (i.e., can move to other dock widget areas).
\row
\li title
- \li the title text of the dock window
+ \li The title text of the dock window.
\endtable
For the buttons, QStyleOptionButton is used (see \l{Tool Buttons}
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index c432902fc2..95244b8534 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -2405,7 +2405,7 @@ void QGraphicsItem::setVisible(bool visible)
/*!
\fn void QGraphicsItem::hide()
- Hides the item. (Items are visible by default.)
+ Hides the item (items are visible by default).
This convenience function is equivalent to calling \c setVisible(false).
@@ -2415,7 +2415,7 @@ void QGraphicsItem::setVisible(bool visible)
/*!
\fn void QGraphicsItem::show()
- Shows the item. (Items are visible by default.)
+ Shows the item (items are visible by default).
This convenience function is equivalent to calling \c setVisible(true).
@@ -3742,7 +3742,7 @@ void QGraphicsItem::ensureVisible(const QRectF &rect, int xmargin, int ymargin)
int xmargin = 50, int ymargin = 50)
This convenience function is equivalent to calling
- ensureVisible(QRectF(\a x, \a y, \a w, \a h), \a xmargin, \a ymargin):
+ ensureVisible(QRectF(\a x, \a y, \a w, \a h), \a xmargin, \a ymargin).
*/
/*!
@@ -4709,9 +4709,9 @@ QRectF QGraphicsItem::childrenBoundingRect() const
If you want to change the item's bounding rectangle, you must first call
prepareGeometryChange(). This notifies the scene of the imminent change,
- so that its can update its item geometry index; otherwise, the scene will
+ so that it can update its item geometry index; otherwise, the scene will
be unaware of the item's new geometry, and the results are undefined
- (typically, rendering artifacts are left around in the view).
+ (typically, rendering artifacts are left within the view).
Reimplement this function to let QGraphicsView determine what
parts of the widget, if any, need to be redrawn.
@@ -4810,8 +4810,8 @@ bool QGraphicsItem::isClipped() const
Returns this item's clip path, or an empty QPainterPath if this item is
not clipped. The clip path constrains the item's appearance and
- interaction (i.e., restricts the area the item can draw, and it also
- restricts the area that the item receives events).
+ interaction (i.e., restricts the area the item can draw within and receive
+ events for).
You can enable clipping by setting the ItemClipsToShape or
ItemClipsChildrenToShape flags. The item's clip path is calculated by
@@ -6716,9 +6716,9 @@ bool QGraphicsItem::sceneEvent(QEvent *event)
menu events. The \a event parameter contains details about the event to
be handled.
- If you ignore the event, (i.e., by calling QEvent::ignore(),) \a event
+ If you ignore the event (i.e., by calling QEvent::ignore()), \a event
will propagate to any item beneath this item. If no items accept the
- event, it will be ignored by the scene, and propagate to the view.
+ event, it will be ignored by the scene and propagate to the view.
It's common to open a QMenu in response to receiving a context menu
event. Example:
@@ -6739,7 +6739,7 @@ void QGraphicsItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
drag enter events for this item. Drag enter events are generated as the
cursor enters the item's area.
- By accepting the event, (i.e., by calling QEvent::accept(),) the item will
+ By accepting the event (i.e., by calling QEvent::accept()), the item will
accept drop events, in addition to receiving drag move and drag
leave. Otherwise, the event will be ignored and propagate to the item
beneath. If the event is accepted, the item will receive a drag move event
@@ -7576,6 +7576,13 @@ QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent
}
/*!
+ Destructor.
+*/
+QGraphicsObject::~QGraphicsObject()
+{
+}
+
+/*!
\reimp
*/
bool QGraphicsObject::event(QEvent *ev)
diff --git a/src/widgets/graphicsview/qgraphicsitem.h b/src/widgets/graphicsview/qgraphicsitem.h
index ce7adfcfad..0cb936bebb 100644
--- a/src/widgets/graphicsview/qgraphicsitem.h
+++ b/src/widgets/graphicsview/qgraphicsitem.h
@@ -162,7 +162,7 @@ public:
SceneModal
};
- QGraphicsItem(QGraphicsItem *parent = 0);
+ explicit QGraphicsItem(QGraphicsItem *parent = 0);
virtual ~QGraphicsItem();
QGraphicsScene *scene() const;
@@ -562,7 +562,8 @@ class Q_WIDGETS_EXPORT QGraphicsObject : public QObject, public QGraphicsItem
Q_CLASSINFO("DefaultProperty", "children")
Q_INTERFACES(QGraphicsItem)
public:
- QGraphicsObject(QGraphicsItem *parent = 0);
+ explicit QGraphicsObject(QGraphicsItem *parent = 0);
+ ~QGraphicsObject();
#ifdef Q_NO_USING_KEYWORD
const QObjectList &children() const { return QObject::children(); }
@@ -607,7 +608,7 @@ class QAbstractGraphicsShapeItemPrivate;
class Q_WIDGETS_EXPORT QAbstractGraphicsShapeItem : public QGraphicsItem
{
public:
- QAbstractGraphicsShapeItem(QGraphicsItem *parent = 0);
+ explicit QAbstractGraphicsShapeItem(QGraphicsItem *parent = 0);
~QAbstractGraphicsShapeItem();
QPen pen() const;
@@ -632,8 +633,8 @@ class QGraphicsPathItemPrivate;
class Q_WIDGETS_EXPORT QGraphicsPathItem : public QAbstractGraphicsShapeItem
{
public:
- QGraphicsPathItem(QGraphicsItem *parent = 0);
- QGraphicsPathItem(const QPainterPath &path, QGraphicsItem *parent = 0);
+ explicit QGraphicsPathItem(QGraphicsItem *parent = 0);
+ explicit QGraphicsPathItem(const QPainterPath &path, QGraphicsItem *parent = 0);
~QGraphicsPathItem();
QPainterPath path() const;
@@ -665,9 +666,9 @@ class QGraphicsRectItemPrivate;
class Q_WIDGETS_EXPORT QGraphicsRectItem : public QAbstractGraphicsShapeItem
{
public:
- QGraphicsRectItem(QGraphicsItem *parent = 0);
- QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent = 0);
- QGraphicsRectItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = 0);
+ explicit QGraphicsRectItem(QGraphicsItem *parent = 0);
+ explicit QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent = 0);
+ explicit QGraphicsRectItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = 0);
~QGraphicsRectItem();
QRectF rect() const;
@@ -703,9 +704,9 @@ class QGraphicsEllipseItemPrivate;
class Q_WIDGETS_EXPORT QGraphicsEllipseItem : public QAbstractGraphicsShapeItem
{
public:
- QGraphicsEllipseItem(QGraphicsItem *parent = 0);
- QGraphicsEllipseItem(const QRectF &rect, QGraphicsItem *parent = 0);
- QGraphicsEllipseItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = 0);
+ explicit QGraphicsEllipseItem(QGraphicsItem *parent = 0);
+ explicit QGraphicsEllipseItem(const QRectF &rect, QGraphicsItem *parent = 0);
+ explicit QGraphicsEllipseItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = 0);
~QGraphicsEllipseItem();
QRectF rect() const;
@@ -747,9 +748,9 @@ class QGraphicsPolygonItemPrivate;
class Q_WIDGETS_EXPORT QGraphicsPolygonItem : public QAbstractGraphicsShapeItem
{
public:
- QGraphicsPolygonItem(QGraphicsItem *parent = 0);
- QGraphicsPolygonItem(const QPolygonF &polygon,
- QGraphicsItem *parent = 0);
+ explicit QGraphicsPolygonItem(QGraphicsItem *parent = 0);
+ explicit QGraphicsPolygonItem(const QPolygonF &polygon,
+ QGraphicsItem *parent = 0);
~QGraphicsPolygonItem();
QPolygonF polygon() const;
@@ -784,9 +785,9 @@ class QGraphicsLineItemPrivate;
class Q_WIDGETS_EXPORT QGraphicsLineItem : public QGraphicsItem
{
public:
- QGraphicsLineItem(QGraphicsItem *parent = 0);
- QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent = 0);
- QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent = 0);
+ explicit QGraphicsLineItem(QGraphicsItem *parent = 0);
+ explicit QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent = 0);
+ explicit QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent = 0);
~QGraphicsLineItem();
QPen pen() const;
@@ -829,8 +830,8 @@ public:
HeuristicMaskShape
};
- QGraphicsPixmapItem(QGraphicsItem *parent = 0);
- QGraphicsPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent = 0);
+ explicit QGraphicsPixmapItem(QGraphicsItem *parent = 0);
+ explicit QGraphicsPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent = 0);
~QGraphicsPixmapItem();
QPixmap pixmap() const;
@@ -881,8 +882,8 @@ class Q_WIDGETS_EXPORT QGraphicsTextItem : public QGraphicsObject
QDOC_PROPERTY(QTextCursor textCursor READ textCursor WRITE setTextCursor)
public:
- QGraphicsTextItem(QGraphicsItem *parent = 0);
- QGraphicsTextItem(const QString &text, QGraphicsItem *parent = 0);
+ explicit QGraphicsTextItem(QGraphicsItem *parent = 0);
+ explicit QGraphicsTextItem(const QString &text, QGraphicsItem *parent = 0);
~QGraphicsTextItem();
QString toHtml() const;
@@ -972,8 +973,8 @@ class QGraphicsSimpleTextItemPrivate;
class Q_WIDGETS_EXPORT QGraphicsSimpleTextItem : public QAbstractGraphicsShapeItem
{
public:
- QGraphicsSimpleTextItem(QGraphicsItem *parent = 0);
- QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent = 0);
+ explicit QGraphicsSimpleTextItem(QGraphicsItem *parent = 0);
+ explicit QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent = 0);
~QGraphicsSimpleTextItem();
void setText(const QString &text);
@@ -1008,7 +1009,7 @@ class QGraphicsItemGroupPrivate;
class Q_WIDGETS_EXPORT QGraphicsItemGroup : public QGraphicsItem
{
public:
- QGraphicsItemGroup(QGraphicsItem *parent = 0);
+ explicit QGraphicsItemGroup(QGraphicsItem *parent = 0);
~QGraphicsItemGroup();
void addToGroup(QGraphicsItem *item);
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
index 762f93f55b..289f9919ef 100644
--- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
@@ -267,7 +267,7 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent
}
if (!lastWidgetUnderMouse) {
- QApplicationPrivate::dispatchEnterLeave(embeddedMouseGrabber ? embeddedMouseGrabber : receiver, 0);
+ QApplicationPrivate::dispatchEnterLeave(embeddedMouseGrabber ? embeddedMouseGrabber : receiver, 0, event->screenPos());
lastWidgetUnderMouse = receiver;
}
@@ -293,7 +293,7 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent
else // released on the frame our outside the item, or doesn't accept hover events.
lastWidgetUnderMouse = 0;
- QApplicationPrivate::dispatchEnterLeave(lastWidgetUnderMouse, embeddedMouseGrabber);
+ QApplicationPrivate::dispatchEnterLeave(lastWidgetUnderMouse, embeddedMouseGrabber, event->screenPos());
embeddedMouseGrabber = 0;
#ifndef QT_NO_CURSOR
@@ -1142,7 +1142,7 @@ void QGraphicsProxyWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
Q_D(QGraphicsProxyWidget);
// If hoverMove was compressed away, make sure we update properly here.
if (d->lastWidgetUnderMouse) {
- QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse);
+ QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse, event->screenPos());
d->lastWidgetUnderMouse = 0;
}
}
@@ -1159,7 +1159,7 @@ void QGraphicsProxyWidget::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
// Ignore events on the window frame.
if (!d->widget || !rect().contains(event->pos())) {
if (d->lastWidgetUnderMouse) {
- QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse);
+ QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse, event->screenPos());
d->lastWidgetUnderMouse = 0;
}
return;
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
index e7e3a58670..21c2e9050c 100644
--- a/src/widgets/itemviews/qheaderview.cpp
+++ b/src/widgets/itemviews/qheaderview.cpp
@@ -2268,7 +2268,12 @@ void QHeaderView::mousePressEvent(QMouseEvent *e)
d->pressed = logicalIndexAt(pos);
if (d->clickableSections)
emit sectionPressed(d->pressed);
- if (d->movableSections) {
+
+ bool acceptMoveSection = d->movableSections;
+ if (acceptMoveSection && d->pressed == 0 && !d->allowUserMoveOfSection0)
+ acceptMoveSection = false; // Do not allow moving the tree nod
+
+ if (acceptMoveSection) {
d->section = d->target = d->pressed;
if (d->section == -1)
return;
@@ -2332,7 +2337,10 @@ void QHeaderView::mouseMoveEvent(QMouseEvent *e)
int visual = visualIndexAt(pos);
if (visual == -1)
return;
- int posThreshold = d->headerSectionPosition(visual) + d->headerSectionSize(visual) / 2;
+ if (visual == 0 && logicalIndex(0) == 0 && !d->allowUserMoveOfSection0)
+ return;
+
+ int posThreshold = d->headerSectionPosition(visual) - d->offset + d->headerSectionSize(visual) / 2;
int moving = visualIndex(d->section);
if (visual < moving) {
if (pos < posThreshold)
@@ -3230,6 +3238,7 @@ void QHeaderViewPrivate::clear()
sectionHidden.clear();
hiddenSectionSize.clear();
sectionItems.clear();
+ invalidateCachedSizeHint();
}
}
@@ -3373,6 +3382,7 @@ void QHeaderViewPrivate::setDefaultSectionSize(int size)
}
}
}
+ sectionStartposRecalc = true;
}
void QHeaderViewPrivate::recalcSectionStartPos() const // linear (but fast)
diff --git a/src/widgets/itemviews/qheaderview.h b/src/widgets/itemviews/qheaderview.h
index 1054e10ba1..847758aa12 100644
--- a/src/widgets/itemviews/qheaderview.h
+++ b/src/widgets/itemviews/qheaderview.h
@@ -240,6 +240,9 @@ protected:
QRegion visualRegionForSelection(const QItemSelection &selection) const;
void initStyleOption(QStyleOptionHeader *option) const;
+ friend class QTableView;
+ friend class QTreeView;
+
private:
Q_PRIVATE_SLOT(d_func(), void _q_sectionsRemoved(const QModelIndex &parent, int logicalFirst, int logicalLast))
Q_PRIVATE_SLOT(d_func(), void _q_layoutAboutToBeChanged())
diff --git a/src/widgets/itemviews/qheaderview_p.h b/src/widgets/itemviews/qheaderview_p.h
index 4d9d0b8c93..7dcfcad01b 100644
--- a/src/widgets/itemviews/qheaderview_p.h
+++ b/src/widgets/itemviews/qheaderview_p.h
@@ -91,6 +91,7 @@ public:
stretchLastSection(false),
cascadingResizing(false),
resizeRecursionBlock(false),
+ allowUserMoveOfSection0(true), // will be false for QTreeView and true for QTableView
stretchSections(0),
contentsSections(0),
minimumSectionSize(-1),
@@ -234,6 +235,10 @@ public:
}
}
+ inline void setAllowUserMoveOfSection0(bool b) {
+ allowUserMoveOfSection0 = b;
+ }
+
void clear();
void flipSortIndicator(int section);
void cascadingResize(int visual, int newSize);
@@ -274,6 +279,7 @@ public:
bool stretchLastSection;
bool cascadingResizing;
bool resizeRecursionBlock;
+ bool allowUserMoveOfSection0;
int stretchSections;
int contentsSections;
int defaultSectionSize;
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp
index d84dc608b9..32869ad292 100644
--- a/src/widgets/itemviews/qtableview.cpp
+++ b/src/widgets/itemviews/qtableview.cpp
@@ -53,6 +53,7 @@
#include <qscrollbar.h>
#include <qabstractbutton.h>
#include <private/qtableview_p.h>
+#include <private/qheaderview_p.h>
#ifndef QT_NO_ACCESSIBILITY
#include <qaccessible.h>
#endif
@@ -1181,6 +1182,7 @@ void QTableView::setHorizontalHeader(QHeaderView *header)
delete d->horizontalHeader;
d->horizontalHeader = header;
d->horizontalHeader->setParent(this);
+ d->horizontalHeader->d_func()->setAllowUserMoveOfSection0(true);
if (!d->horizontalHeader->model()) {
d->horizontalHeader->setModel(d->model);
if (d->selectionModel)
@@ -1218,6 +1220,7 @@ void QTableView::setVerticalHeader(QHeaderView *header)
delete d->verticalHeader;
d->verticalHeader = header;
d->verticalHeader->setParent(this);
+ d->verticalHeader->d_func()->setAllowUserMoveOfSection0(true);
if (!d->verticalHeader->model()) {
d->verticalHeader->setModel(d->model);
if (d->selectionModel)
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index bcaf8dc2c3..cf3d7155c1 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -58,6 +58,7 @@
#endif
#include <private/qtreeview_p.h>
+#include <private/qheaderview_p.h>
QT_BEGIN_NAMESPACE
@@ -313,6 +314,7 @@ void QTreeView::setHeader(QHeaderView *header)
delete d->header;
d->header = header;
d->header->setParent(this);
+ d->header->d_func()->setAllowUserMoveOfSection0(false);
if (!d->header->model()) {
d->header->setModel(d->model);
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index efa52456e8..d62b8ef146 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -2114,20 +2114,23 @@ QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool
}
/*!
- \fn void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave)
+ \fn void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, const QPointF &globalPosF)
\internal
Creates the proper Enter/Leave event when widget \a enter is entered and
widget \a leave is left.
*/
-void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) {
+void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, const QPointF &globalPosF)
+{
+ const QPoint globalPos = globalPosF.toPoint();
#if 0
if (leave) {
QEvent e(QEvent::Leave);
QApplication::sendEvent(leave, & e);
}
if (enter) {
- QEvent e(QEvent::Enter);
+ const QPoint windowPos = enter->window()->mapFromGlobal(globalPos);
+ QEnterEvent e(enter->mapFromGlobal(globalPos), windowPos, globalPos);
QApplication::sendEvent(enter, & e);
}
return;
@@ -2205,17 +2208,20 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) {
}
}
}
- QPoint posEnter = QCursor::pos();
- QEvent enterEvent(QEvent::Enter);
- for (int i = 0; i < enterList.size(); ++i) {
- w = enterList.at(i);
- if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) {
- QApplication::sendEvent(w, &enterEvent);
- if (w->testAttribute(Qt::WA_Hover) &&
- (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) {
- QHoverEvent he(QEvent::HoverEnter, w->mapFromGlobal(posEnter), QPoint(-1, -1),
- QApplication::keyboardModifiers());
- qApp->d_func()->notify_helper(w, &he);
+ if (!enterList.isEmpty()) {
+ const QPoint windowPos = enterList.front()->window()->mapFromGlobal(globalPos);
+ for (int i = 0; i < enterList.size(); ++i) {
+ w = enterList.at(i);
+ if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) {
+ const QPointF localPos = w->mapFromGlobal(globalPos);
+ QEnterEvent enterEvent(localPos, windowPos, globalPosF);
+ QApplication::sendEvent(w, &enterEvent);
+ if (w->testAttribute(Qt::WA_Hover) &&
+ (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) {
+ QHoverEvent he(QEvent::HoverEnter, localPos, QPoint(-1, -1),
+ QApplication::keyboardModifiers());
+ qApp->d_func()->notify_helper(w, &he);
+ }
}
}
}
@@ -2331,7 +2337,7 @@ bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWin
return false;
}
- Qt::WindowModality windowModality = modalWindow->windowModality();
+ Qt::WindowModality windowModality = modalWindow->modality();
QWidgetWindow *modalWidgetWindow = qobject_cast<QWidgetWindow *>(modalWindow);
if (windowModality == Qt::NonModal) {
// determine the modality type if it hasn't been set on the
@@ -2482,6 +2488,12 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
bool widgetUnderMouse = QRectF(receiver->rect()).contains(event->localPos());
+ // Clear the obsolete leaveAfterRelease value, if mouse button has been released but
+ // leaveAfterRelease has not been updated.
+ // This happens e.g. when modal dialog or popup is shown as a response to button click.
+ if (leaveAfterRelease && !*buttonDown && !event->buttons())
+ leaveAfterRelease = 0;
+
if (*buttonDown) {
if (!graphicsWidget) {
// Register the widget that shall receive a leave event
@@ -2500,9 +2512,9 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
|| (isAlien(lastMouseReceiver) && !alienWidget)) {
if (activePopupWidget) {
if (!QWidget::mouseGrabber())
- dispatchEnterLeave(alienWidget ? alienWidget : nativeWidget, lastMouseReceiver);
+ dispatchEnterLeave(alienWidget ? alienWidget : nativeWidget, lastMouseReceiver, event->screenPos());
} else {
- dispatchEnterLeave(receiver, lastMouseReceiver);
+ dispatchEnterLeave(receiver, lastMouseReceiver, event->screenPos());
}
}
@@ -2534,7 +2546,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
enter = alienGuard ? alienWidget : nativeWidget;
else // The receiver is typically deleted on mouse release with drag'n'drop.
enter = QApplication::widgetAt(event->globalPos());
- dispatchEnterLeave(enter, leaveAfterRelease);
+ dispatchEnterLeave(enter, leaveAfterRelease, event->screenPos());
leaveAfterRelease = 0;
lastMouseReceiver = enter;
} else if (!wasLeaveAfterRelease) {
diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h
index 5682d794cf..5b3493f478 100644
--- a/src/widgets/kernel/qapplication_p.h
+++ b/src/widgets/kernel/qapplication_p.h
@@ -135,7 +135,7 @@ public:
void createEventDispatcher();
- static void dispatchEnterLeave(QWidget *enter, QWidget *leave);
+ static void dispatchEnterLeave(QWidget *enter, QWidget *leave, const QPointF &globalPosF);
//modality
bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = 0) const Q_DECL_OVERRIDE;
diff --git a/src/widgets/kernel/qapplication_qpa.cpp b/src/widgets/kernel/qapplication_qpa.cpp
index 5dc68e47e0..21bc9506d4 100644
--- a/src/widgets/kernel/qapplication_qpa.cpp
+++ b/src/widgets/kernel/qapplication_qpa.cpp
@@ -250,12 +250,6 @@ void QApplicationPrivate::openPopup(QWidget *popup)
QApplication::sendEvent(fw, &e);
}
}
-
- // Dispatch leave for last mouse receiver to update undermouse states
- if (qt_last_mouse_receiver && !QWidget::mouseGrabber()) {
- QApplicationPrivate::dispatchEnterLeave(0, qt_last_mouse_receiver.data());
- qt_last_mouse_receiver = 0;
- }
}
void QApplicationPrivate::initializeMultitouch_sys()
diff --git a/src/widgets/kernel/qgesture.cpp b/src/widgets/kernel/qgesture.cpp
index 28e3213c83..1f12d1a60d 100644
--- a/src/widgets/kernel/qgesture.cpp
+++ b/src/widgets/kernel/qgesture.cpp
@@ -295,6 +295,12 @@ QPanGesture::QPanGesture(QObject *parent)
d_func()->gestureType = Qt::PanGesture;
}
+/*!
+ Destructor.
+*/
+QPanGesture::~QPanGesture()
+{
+}
QPointF QPanGesture::lastOffset() const
{
@@ -486,6 +492,13 @@ QPinchGesture::QPinchGesture(QObject *parent)
d_func()->gestureType = Qt::PinchGesture;
}
+/*!
+ Destructor.
+*/
+QPinchGesture::~QPinchGesture()
+{
+}
+
QPinchGesture::ChangeFlags QPinchGesture::totalChangeFlags() const
{
return d_func()->totalChangeFlags;
@@ -673,6 +686,13 @@ QSwipeGesture::QSwipeGesture(QObject *parent)
d_func()->gestureType = Qt::SwipeGesture;
}
+/*!
+ Destructor.
+*/
+QSwipeGesture::~QSwipeGesture()
+{
+}
+
QSwipeGesture::SwipeDirection QSwipeGesture::horizontalDirection() const
{
Q_D(const QSwipeGesture);
@@ -732,6 +752,13 @@ QTapGesture::QTapGesture(QObject *parent)
d_func()->gestureType = Qt::TapGesture;
}
+/*!
+ Destructor.
+*/
+QTapGesture::~QTapGesture()
+{
+}
+
QPointF QTapGesture::position() const
{
return d_func()->position;
@@ -769,6 +796,13 @@ QTapAndHoldGesture::QTapAndHoldGesture(QObject *parent)
d_func()->gestureType = Qt::TapAndHoldGesture;
}
+/*!
+ Destructor.
+*/
+QTapAndHoldGesture::~QTapAndHoldGesture()
+{
+}
+
QPointF QTapAndHoldGesture::position() const
{
return d_func()->position;
diff --git a/src/widgets/kernel/qgesture.h b/src/widgets/kernel/qgesture.h
index a289622276..0f09f209c0 100644
--- a/src/widgets/kernel/qgesture.h
+++ b/src/widgets/kernel/qgesture.h
@@ -117,7 +117,8 @@ class Q_WIDGETS_EXPORT QPanGesture : public QGesture
Q_PRIVATE_PROPERTY(QPanGesture::d_func(), qreal verticalVelocity READ verticalVelocity WRITE setVerticalVelocity)
public:
- QPanGesture(QObject *parent = 0);
+ explicit QPanGesture(QObject *parent = 0);
+ ~QPanGesture();
QPointF lastOffset() const;
QPointF offset() const;
@@ -163,7 +164,8 @@ public:
Q_PROPERTY(QPointF centerPoint READ centerPoint WRITE setCenterPoint)
public:
- QPinchGesture(QObject *parent = 0);
+ explicit QPinchGesture(QObject *parent = 0);
+ ~QPinchGesture();
ChangeFlags totalChangeFlags() const;
void setTotalChangeFlags(ChangeFlags value);
@@ -217,7 +219,9 @@ class Q_WIDGETS_EXPORT QSwipeGesture : public QGesture
public:
enum SwipeDirection { NoDirection, Left, Right, Up, Down };
- QSwipeGesture(QObject *parent = 0);
+
+ explicit QSwipeGesture(QObject *parent = 0);
+ ~QSwipeGesture();
SwipeDirection horizontalDirection() const;
SwipeDirection verticalDirection() const;
@@ -237,7 +241,8 @@ class Q_WIDGETS_EXPORT QTapGesture : public QGesture
Q_PROPERTY(QPointF position READ position WRITE setPosition)
public:
- QTapGesture(QObject *parent = 0);
+ explicit QTapGesture(QObject *parent = 0);
+ ~QTapGesture();
QPointF position() const;
void setPosition(const QPointF &pos);
@@ -254,7 +259,8 @@ class Q_WIDGETS_EXPORT QTapAndHoldGesture : public QGesture
Q_PROPERTY(QPointF position READ position WRITE setPosition)
public:
- QTapAndHoldGesture(QObject *parent = 0);
+ explicit QTapAndHoldGesture(QObject *parent = 0);
+ ~QTapAndHoldGesture();
QPointF position() const;
void setPosition(const QPointF &pos);
diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp
index 806bfcefb7..72a2469f23 100644
--- a/src/widgets/kernel/qgesturemanager.cpp
+++ b/src/widgets/kernel/qgesturemanager.cpp
@@ -46,6 +46,7 @@
#include "private/qgraphicsitem_p.h"
#include "private/qevent_p.h"
#include "private/qapplication_p.h"
+#include "private/qwidgetwindow_qpa_p.h"
#include "qgesture.h"
#include "qevent.h"
#include "qgraphicsitem.h"
@@ -531,6 +532,13 @@ bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event)
bool QGestureManager::filterEvent(QObject *receiver, QEvent *event)
{
+ // if the receiver is actually a widget, we need to call the correct event
+ // filter method.
+ QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(receiver);
+
+ if (widgetWindow)
+ return filterEvent(widgetWindow->widget(), event);
+
if (!m_gestureToRecognizer.contains(static_cast<QGesture *>(receiver)))
return false;
QGesture *state = static_cast<QGesture *>(receiver);
diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp
index 5ef3c17454..7de3f47c5b 100644
--- a/src/widgets/kernel/qlayoutitem.cpp
+++ b/src/widgets/kernel/qlayoutitem.cpp
@@ -263,6 +263,11 @@ void QLayoutItem::setAlignment(Qt::Alignment alignment)
*/
/*!
+ Destructor.
+*/
+QSpacerItem::~QSpacerItem() {}
+
+/*!
Changes this spacer item to have preferred width \a w, preferred
height \a h, horizontal size policy \a hPolicy and vertical size
policy \a vPolicy.
@@ -291,6 +296,11 @@ void QSpacerItem::changeSize(int w, int h, QSizePolicy::Policy hPolicy,
*/
/*!
+ Destructor.
+*/
+QWidgetItem::~QWidgetItem() {}
+
+/*!
Destroys the QLayoutItem.
*/
QLayoutItem::~QLayoutItem()
diff --git a/src/widgets/kernel/qlayoutitem.h b/src/widgets/kernel/qlayoutitem.h
index a2f60b1696..093e7fe61b 100644
--- a/src/widgets/kernel/qlayoutitem.h
+++ b/src/widgets/kernel/qlayoutitem.h
@@ -99,6 +99,8 @@ public:
QSizePolicy::Policy hData = QSizePolicy::Minimum,
QSizePolicy::Policy vData = QSizePolicy::Minimum)
: width(w), height(h), sizeP(hData, vData) { }
+ ~QSpacerItem();
+
void changeSize(int w, int h,
QSizePolicy::Policy hData = QSizePolicy::Minimum,
QSizePolicy::Policy vData = QSizePolicy::Minimum);
@@ -124,6 +126,8 @@ class Q_WIDGETS_EXPORT QWidgetItem : public QLayoutItem
public:
explicit QWidgetItem(QWidget *w) : wid(w) { }
+ ~QWidgetItem();
+
QSize sizeHint() const;
QSize minimumSize() const;
QSize maximumSize() const;
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 2feb797985..243ba93f5e 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -7907,8 +7907,8 @@ bool QWidget::event(QEvent *event)
}
}
query->accept();
- break;
}
+ break;
case QEvent::PolishRequest:
ensurePolished();
@@ -8563,6 +8563,8 @@ void QWidget::enterEvent(QEvent *)
{
}
+// ### Qt 6: void QWidget::enterEvent(QEnterEvent *).
+
/*!
\fn void QWidget::leaveEvent(QEvent *event)
diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp
index 2950c19768..b4d9b9d2e3 100644
--- a/src/widgets/kernel/qwidget_qpa.cpp
+++ b/src/widgets/kernel/qwidget_qpa.cpp
@@ -107,7 +107,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
win = topData()->window;
}
- win->setWindowFlags(data.window_flags);
+ win->setFlags(data.window_flags);
fixPosIncludesFrame();
win->setGeometry(q->geometry());
win->setScreen(QGuiApplication::screens().value(topData()->screenIndex, 0));
@@ -134,7 +134,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
QWindowPrivate::WindowFrameInclusive : QWindowPrivate::WindowFrameExclusive;
win->create();
- data.window_flags = win->windowFlags();
+ data.window_flags = win->flags();
QBackingStore *store = q->backingStore();
@@ -227,7 +227,7 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
if (parent != newparent) {
QObjectPrivate::setParent_helper(newparent); //### why does this have to be done in the _sys function???
if (q->windowHandle()) {
- q->windowHandle()->setWindowFlags(f);
+ q->windowHandle()->setFlags(f);
QWidget *parentWithWindow =
newparent ? (newparent->windowHandle() ? newparent : newparent->nativeParentWidget()) : 0;
if (parentWithWindow) {
@@ -342,7 +342,7 @@ void QWidgetPrivate::setWindowTitle_sys(const QString &caption)
return;
if (QWindow *window = q->windowHandle())
- window->setWindowTitle(caption);
+ window->setTitle(caption);
}
@@ -353,14 +353,14 @@ void QWidgetPrivate::setWindowFilePath_sys(const QString &filePath)
return;
if (QWindow *window = q->windowHandle())
- window->setWindowFilePath(filePath);
+ window->setFilePath(filePath);
}
void QWidgetPrivate::setWindowIcon_sys()
{
Q_Q(QWidget);
if (QWindow *window = q->windowHandle())
- window->setWindowIcon(q->windowIcon());
+ window->setIcon(q->windowIcon());
}
void QWidgetPrivate::setWindowIconText_sys(const QString &iconText)
@@ -463,7 +463,7 @@ void QWidget::activateWindow()
QWindow *const wnd = window()->windowHandle();
if (wnd)
- wnd->requestActivateWindow();
+ wnd->requestActivate();
}
// Position top level windows at the center, avoid showing
@@ -640,7 +640,7 @@ void QWidgetPrivate::setFocus_sys()
if (QWindow *nativeWindow = q->window()->windowHandle()) {
if (nativeWindow != QGuiApplication::focusWindow()
&& q->testAttribute(Qt::WA_WState_Created)) {
- nativeWindow->requestActivateWindow();
+ nativeWindow->requestActivate();
}
}
}
@@ -987,7 +987,7 @@ void QWidgetPrivate::setModal_sys()
{
Q_Q(QWidget);
if (q->windowHandle())
- q->windowHandle()->setWindowModality(q->windowModality());
+ q->windowHandle()->setModality(q->windowModality());
}
#ifndef QT_NO_CURSOR
diff --git a/src/widgets/kernel/qwidgetbackingstore_p.h b/src/widgets/kernel/qwidgetbackingstore_p.h
index 69f8a0708e..a4d4ee2f71 100644
--- a/src/widgets/kernel/qwidgetbackingstore_p.h
+++ b/src/widgets/kernel/qwidgetbackingstore_p.h
@@ -240,7 +240,7 @@ private:
}
inline bool hasStaticContents() const
- { return !staticWidgets.isEmpty(); }
+ { return !staticWidgets.isEmpty() && false; }
friend QRegion qt_dirtyRegion(QWidget *);
friend class QWidgetPrivate;
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index b49441beba..b700d33f52 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -205,6 +205,12 @@ bool QWidgetWindow::event(QEvent *event)
handleContextMenuEvent(static_cast<QContextMenuEvent *>(event));
return true;
#endif
+
+ // Handing show events to widgets (see below) here would cause them to be triggered twice
+ case QEvent::Show:
+ case QEvent::Hide:
+ return QWindow::event(event);
+
default:
break;
}
@@ -224,6 +230,7 @@ void QWidgetWindow::handleEnterLeaveEvent(QEvent *event)
QWindowSystemInterfacePrivate::EnterEvent *systemEvent =
static_cast<QWindowSystemInterfacePrivate::EnterEvent *>
(QWindowSystemInterfacePrivate::peekWindowSystemEvent(QWindowSystemInterfacePrivate::Enter));
+ const QPointF globalPosF = systemEvent ? systemEvent->globalPos : QGuiApplicationPrivate::lastCursorPosition;
if (systemEvent) {
if (QWidgetWindow *enterWindow = qobject_cast<QWidgetWindow *>(systemEvent->enter))
{
@@ -244,13 +251,20 @@ void QWidgetWindow::handleEnterLeaveEvent(QEvent *event)
// both native and non-native widgets work similarly.
// When mousegrabbing, leaves are only generated if leaving the parent window.
if (!enter || !QWidget::mouseGrabber()) {
- QWidget *leave = qt_last_mouse_receiver ? qt_last_mouse_receiver.data() : m_widget;
- QApplicationPrivate::dispatchEnterLeave(enter, leave);
+ // Preferred leave target is the last mouse receiver, unless it has native window,
+ // in which case it is assumed to receive it's own leave event when relevant.
+ QWidget *leave = m_widget;
+ if (qt_last_mouse_receiver && !qt_last_mouse_receiver->internalWinId())
+ leave = qt_last_mouse_receiver.data();
+ QApplicationPrivate::dispatchEnterLeave(enter, leave, globalPosF);
qt_last_mouse_receiver = enter;
}
} else {
- QApplicationPrivate::dispatchEnterLeave(m_widget, 0);
- qt_last_mouse_receiver = m_widget;
+ const QEnterEvent *ee = static_cast<QEnterEvent *>(event);
+ QWidget *child = m_widget->childAt(ee->pos());
+ QWidget *receiver = child ? child : m_widget;
+ QApplicationPrivate::dispatchEnterLeave(receiver, 0, ee->screenPos());
+ qt_last_mouse_receiver = receiver;
}
}
@@ -485,6 +499,10 @@ void QWidgetWindow::handleDragEnterMoveEvent(QDragMoveEvent *event)
const QPoint mapped = widget->mapFromGlobal(m_widget->mapToGlobal(event->pos()));
QDragMoveEvent translated(mapped, event->possibleActions(), event->mimeData(), event->mouseButtons(), event->keyboardModifiers());
translated.setDropAction(event->dropAction());
+ if (event->isAccepted()) { // Handling 'DragEnter' should suffice for the application.
+ translated.accept();
+ translated.setDropAction(event->dropAction());
+ }
QGuiApplication::sendSpontaneousEvent(widget, &translated);
if (translated.isAccepted()) {
event->accept();
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 2b6d843723..96a2078905 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -5016,6 +5016,9 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget
case SH_RequestSoftwareInputPanel:
ret = RSIP_OnMouseClickAndAlreadyFocused;
break;
+ case SH_ScrollBar_Transient:
+ ret = false;
+ break;
default:
ret = 0;
break;
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index 8e52a4b425..4121292cc7 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -1417,7 +1417,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
QRect leftRect;
QRect rect = bar->rect;
QColor textColor = option->palette.text().color();
- QColor alternateTextColor = option->palette.highlightedText().color();
+ QColor alternateTextColor = d->highlightedText(option->palette);
painter->save();
bool vertical = false, inverted = false;
diff --git a/src/widgets/styles/qfusionstyle_p.h b/src/widgets/styles/qfusionstyle_p.h
index 1c8089e736..affb85bbb1 100644
--- a/src/widgets/styles/qfusionstyle_p.h
+++ b/src/widgets/styles/qfusionstyle_p.h
@@ -55,6 +55,8 @@
#include "qcommonstyle.h"
#include "qcommonstyle_p.h"
+#include <qpa/qplatformtheme.h>
+#include "private/qguiapplication_p.h"
#ifndef QT_NO_STYLE_FUSION
@@ -83,10 +85,32 @@ public:
return QColor(255, 255, 255, 30);
}
+ // On mac we want a standard blue color used when the system palette is used
+ bool isMacSystemPalette(const QPalette &pal) const {
+ Q_UNUSED(pal);
+#ifdef Q_OS_MAC
+ const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette();
+ if (themePalette->color(QPalette::Normal, QPalette::Highlight) ==
+ pal.color(QPalette::Normal, QPalette::Highlight) &&
+ themePalette->color(QPalette::Normal, QPalette::HighlightedText) ==
+ pal.color(QPalette::Normal, QPalette::HighlightedText))
+ return true;
+#endif
+ return false;
+ }
+
QColor highlight(const QPalette &pal) const {
+ if (isMacSystemPalette(pal))
+ return QColor(60, 140, 230);
return pal.color(QPalette::Active, QPalette::Highlight);
}
+ QColor highlightedText(const QPalette &pal) const {
+ if (isMacSystemPalette(pal))
+ return Qt::white;
+ return pal.color(QPalette::Active, QPalette::HighlightedText);
+ }
+
QColor outline(const QPalette &pal) const {
if (!pal.window().texture().isNull())
return QColor(0, 0, 0, 160);
@@ -94,7 +118,7 @@ public:
}
QColor highlightedOutline(const QPalette &pal) const {
- QColor highlightedOutline = pal.highlight().color().darker(125);
+ QColor highlightedOutline = highlight(pal).darker(125);
if (highlightedOutline.value() > 160)
highlightedOutline.setHsl(highlightedOutline.hue(), highlightedOutline.saturation(), 160);
return highlightedOutline;
@@ -109,7 +133,7 @@ public:
QColor buttonColor(const QPalette &pal) const {
QColor buttonColor = pal.button().color();
int val = qGray(buttonColor.rgb());
- buttonColor = buttonColor.lighter(100 + qMax(0, (180- val)/6));
+ buttonColor = buttonColor.lighter(100 + qMax(1, (180 - val)/6));
buttonColor.setHsv(buttonColor.hue(), buttonColor.saturation() * 0.75, buttonColor.value());
return buttonColor;
}
diff --git a/src/widgets/styles/qgtk2painter.cpp b/src/widgets/styles/qgtk2painter.cpp
new file mode 100644
index 0000000000..427041ac76
--- /dev/null
+++ b/src/widgets/styles/qgtk2painter.cpp
@@ -0,0 +1,705 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgtk2painter_p.h"
+
+#include <QtCore/qglobal.h>
+#if !defined(QT_NO_STYLE_GTK)
+
+// This class is primarily a wrapper around the gtk painter functions
+// and takes care of converting all such calls into cached Qt pixmaps.
+
+#include <private/qgtkstyle_p.h>
+#include <private/qhexstring_p.h>
+#include <QtWidgets/QWidget>
+#include <QtGui/QPixmapCache>
+#include <QtCore/QLibrary>
+
+QT_BEGIN_NAMESPACE
+
+typedef GdkPixbuf* (*Ptr_gdk_pixbuf_get_from_drawable) (GdkPixbuf *, GdkDrawable *, GdkColormap *, int, int, int, int, int, int);
+typedef GdkPixmap* (*Ptr_gdk_pixmap_new) (GdkDrawable *, gint, gint, gint);
+typedef void (*Ptr_gdk_draw_rectangle) (GdkDrawable *, GdkGC *, gboolean, gint, gint, gint, gint);
+typedef void (*Ptr_gdk_drawable_unref)(GdkDrawable *);
+
+typedef void (*Ptr_gtk_paint_check) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
+typedef void (*Ptr_gtk_paint_box) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
+typedef void (*Ptr_gtk_paint_box_gap) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint , gint, GtkPositionType, gint, gint);
+typedef void (*Ptr_gtk_paint_resize_grip) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, GdkWindowEdge, gint , gint , gint , gint);
+typedef void (*Ptr_gtk_paint_focus) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
+typedef void (*Ptr_gtk_paint_shadow) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
+typedef void (*Ptr_gtk_paint_slider) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint, GtkOrientation);
+typedef void (*Ptr_gtk_paint_expander) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , GtkExpanderStyle );
+typedef void (*Ptr_gtk_paint_handle) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint, GtkOrientation);
+typedef void (*Ptr_gtk_paint_arrow) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, GtkArrowType, gboolean, gint , gint , gint , gint);
+typedef void (*Ptr_gtk_paint_option) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
+typedef void (*Ptr_gtk_paint_flat_box) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
+typedef void (*Ptr_gtk_paint_extension) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint, gint, GtkPositionType);
+typedef void (*Ptr_gtk_paint_hline) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint y);
+typedef void (*Ptr_gtk_paint_vline) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint);
+
+namespace QGtk2PainterPrivate {
+ static Ptr_gdk_pixmap_new gdk_pixmap_new = 0;
+ static Ptr_gdk_pixbuf_get_from_drawable gdk_pixbuf_get_from_drawable = 0;
+ static Ptr_gdk_draw_rectangle gdk_draw_rectangle = 0;
+ static Ptr_gdk_drawable_unref gdk_drawable_unref = 0;
+
+ static Ptr_gtk_paint_check gtk_paint_check = 0;
+ static Ptr_gtk_paint_box gtk_paint_box = 0;
+ static Ptr_gtk_paint_box_gap gtk_paint_box_gap = 0;
+ static Ptr_gtk_paint_flat_box gtk_paint_flat_box = 0;
+ static Ptr_gtk_paint_option gtk_paint_option = 0;
+ static Ptr_gtk_paint_extension gtk_paint_extension = 0;
+ static Ptr_gtk_paint_slider gtk_paint_slider = 0;
+ static Ptr_gtk_paint_shadow gtk_paint_shadow = 0;
+ static Ptr_gtk_paint_resize_grip gtk_paint_resize_grip = 0;
+ static Ptr_gtk_paint_focus gtk_paint_focus = 0;
+ static Ptr_gtk_paint_arrow gtk_paint_arrow = 0;
+ static Ptr_gtk_paint_handle gtk_paint_handle = 0;
+ static Ptr_gtk_paint_expander gtk_paint_expander = 0;
+ static Ptr_gtk_paint_vline gtk_paint_vline = 0;
+ static Ptr_gtk_paint_hline gtk_paint_hline = 0;
+}
+
+static void initGtk()
+{
+ static bool initialized = false;
+ if (!initialized) {
+ // enforce the "0" suffix, so we'll open libgtk-x11-2.0.so.0
+ QLibrary libgtk(QLS("gtk-x11-2.0"), 0, 0);
+
+ QGtk2PainterPrivate::gdk_pixmap_new = (Ptr_gdk_pixmap_new)libgtk.resolve("gdk_pixmap_new");
+ QGtk2PainterPrivate::gdk_pixbuf_get_from_drawable = (Ptr_gdk_pixbuf_get_from_drawable)libgtk.resolve("gdk_pixbuf_get_from_drawable");
+ QGtk2PainterPrivate::gdk_draw_rectangle = (Ptr_gdk_draw_rectangle)libgtk.resolve("gdk_draw_rectangle");
+ QGtk2PainterPrivate::gdk_drawable_unref = (Ptr_gdk_drawable_unref)libgtk.resolve("gdk_drawable_unref");
+
+ QGtk2PainterPrivate::gtk_paint_check = (Ptr_gtk_paint_check)libgtk.resolve("gtk_paint_check");
+ QGtk2PainterPrivate::gtk_paint_box = (Ptr_gtk_paint_box)libgtk.resolve("gtk_paint_box");
+ QGtk2PainterPrivate::gtk_paint_flat_box = (Ptr_gtk_paint_flat_box)libgtk.resolve("gtk_paint_flat_box");
+ QGtk2PainterPrivate::gtk_paint_check = (Ptr_gtk_paint_check)libgtk.resolve("gtk_paint_check");
+ QGtk2PainterPrivate::gtk_paint_box = (Ptr_gtk_paint_box)libgtk.resolve("gtk_paint_box");
+ QGtk2PainterPrivate::gtk_paint_resize_grip = (Ptr_gtk_paint_resize_grip)libgtk.resolve("gtk_paint_resize_grip");
+ QGtk2PainterPrivate::gtk_paint_focus = (Ptr_gtk_paint_focus)libgtk.resolve("gtk_paint_focus");
+ QGtk2PainterPrivate::gtk_paint_shadow = (Ptr_gtk_paint_shadow)libgtk.resolve("gtk_paint_shadow");
+ QGtk2PainterPrivate::gtk_paint_slider = (Ptr_gtk_paint_slider)libgtk.resolve("gtk_paint_slider");
+ QGtk2PainterPrivate::gtk_paint_expander = (Ptr_gtk_paint_expander)libgtk.resolve("gtk_paint_expander");
+ QGtk2PainterPrivate::gtk_paint_handle = (Ptr_gtk_paint_handle)libgtk.resolve("gtk_paint_handle");
+ QGtk2PainterPrivate::gtk_paint_option = (Ptr_gtk_paint_option)libgtk.resolve("gtk_paint_option");
+ QGtk2PainterPrivate::gtk_paint_arrow = (Ptr_gtk_paint_arrow)libgtk.resolve("gtk_paint_arrow");
+ QGtk2PainterPrivate::gtk_paint_box_gap = (Ptr_gtk_paint_box_gap)libgtk.resolve("gtk_paint_box_gap");
+ QGtk2PainterPrivate::gtk_paint_extension = (Ptr_gtk_paint_extension)libgtk.resolve("gtk_paint_extension");
+ QGtk2PainterPrivate::gtk_paint_hline = (Ptr_gtk_paint_hline)libgtk.resolve("gtk_paint_hline");
+ QGtk2PainterPrivate::gtk_paint_vline = (Ptr_gtk_paint_vline)libgtk.resolve("gtk_paint_vline");
+
+ initialized = true;
+ }
+}
+
+// To recover alpha we apply the gtk painting function two times to
+// white, and black window backgrounds. This can be used to
+// recover the premultiplied alpha channel
+QPixmap QGtk2Painter::renderTheme(uchar *bdata, uchar *wdata, const QRect &rect) const
+{
+ const int bytecount = rect.width() * rect.height() * 4;
+ for (int index = 0; index < bytecount ; index += 4) {
+ uchar val = bdata[index + GTK_BLUE];
+ if (m_alpha) {
+ int alphaval = qMax(bdata[index + GTK_BLUE] - wdata[index + GTK_BLUE],
+ bdata[index + GTK_GREEN] - wdata[index + GTK_GREEN]);
+ alphaval = qMax(alphaval, bdata[index + GTK_RED] - wdata[index + GTK_RED]) + 255;
+ bdata[index + QT_ALPHA] = alphaval;
+ }
+ bdata[index + QT_RED] = bdata[index + GTK_RED];
+ bdata[index + QT_GREEN] = bdata[index + GTK_GREEN];
+ bdata[index + QT_BLUE] = val;
+ }
+ QImage converted((const uchar*)bdata, rect.width(), rect.height(), m_alpha ?
+ QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32);
+
+ if (m_hflipped || m_vflipped) {
+ return QPixmap::fromImage(converted.mirrored(m_hflipped, m_vflipped));
+ } else {
+ // on raster graphicssystem we need to do a copy here, because
+ // we intend to deallocate the qimage bits shortly after...
+ return QPixmap::fromImage(converted.copy());
+ }
+}
+
+// This macro is responsible for painting any GtkStyle painting function onto a QPixmap
+#define DRAW_TO_CACHE(draw_func) \
+ if (rect.width() > QWIDGETSIZE_MAX || rect.height() > QWIDGETSIZE_MAX) \
+ return; \
+ QRect pixmapRect(0, 0, rect.width(), rect.height()); \
+ { \
+ GdkPixmap *pixmap = QGtk2PainterPrivate::gdk_pixmap_new((GdkDrawable*)(m_window->window), \
+ rect.width(), rect.height(), -1); \
+ if (!pixmap) \
+ return; \
+ style = QGtkStylePrivate::gtk_style_attach (style, m_window->window); \
+ QGtk2PainterPrivate::gdk_draw_rectangle(pixmap, m_alpha ? style->black_gc : *style->bg_gc, \
+ true, 0, 0, rect.width(), rect.height()); \
+ draw_func; \
+ GdkPixbuf *imgb = QGtkStylePrivate::gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, \
+ rect.width(), rect.height()); \
+ if (!imgb) \
+ return; \
+ imgb = QGtk2PainterPrivate::gdk_pixbuf_get_from_drawable(imgb, pixmap, NULL, 0, 0, 0, 0, \
+ rect.width(), rect.height()); \
+ uchar* bdata = (uchar*)QGtkStylePrivate::gdk_pixbuf_get_pixels(imgb); \
+ if (m_alpha) { \
+ QGtk2PainterPrivate::gdk_draw_rectangle(pixmap, style->white_gc, true, 0, 0, \
+ rect.width(), rect.height()); \
+ draw_func; \
+ GdkPixbuf *imgw = QGtkStylePrivate::gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, \
+ rect.width(), rect.height()); \
+ if (!imgw) \
+ return; \
+ imgw = QGtk2PainterPrivate::gdk_pixbuf_get_from_drawable(imgw, pixmap, NULL, 0, 0, 0, 0,\
+ rect.width(), rect.height()); \
+ uchar* wdata = (uchar*)QGtkStylePrivate::gdk_pixbuf_get_pixels(imgw); \
+ cache = renderTheme(bdata, wdata, rect); \
+ QGtkStylePrivate::gdk_pixbuf_unref(imgw); \
+ } else { \
+ cache = renderTheme(bdata, 0, rect); \
+ } \
+ QGtk2PainterPrivate::gdk_drawable_unref(pixmap); \
+ QGtkStylePrivate::gdk_pixbuf_unref(imgb); \
+ }
+
+QGtk2Painter::QGtk2Painter() : QGtkPainter(), m_window(QGtkStylePrivate::gtkWidget("GtkWindow"))
+{
+ initGtk();
+}
+
+// Note currently painted without alpha for performance reasons
+void QGtk2Painter::paintBoxGap(GtkWidget *gtkWidget, const gchar* part,
+ const QRect &paintRect, GtkStateType state,
+ GtkShadowType shadow, GtkPositionType gap_side,
+ gint x, gint width,
+ GtkStyle *style)
+{
+ if (!paintRect.isValid())
+ return;
+
+ QPixmap cache;
+ QRect rect = paintRect;
+
+ // To avoid exhausting cache on large tabframes we cheat a bit by
+ // tiling the center part.
+
+ const int maxHeight = 256;
+ const int border = 16;
+ if (rect.height() > maxHeight && (gap_side == GTK_POS_TOP || gap_side == GTK_POS_BOTTOM))
+ rect.setHeight(2 * border + 1);
+
+ QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget)
+ % HexString<uchar>(gap_side)
+ % HexString<gint>(width)
+ % HexString<gint>(x);
+
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_box_gap (style,
+ pixmap,
+ state,
+ shadow,
+ NULL,
+ gtkWidget,
+ (gchar*)part,
+ 0, 0,
+ rect.width(),
+ rect.height(),
+ gap_side,
+ x,
+ width));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+ if (rect.size() != paintRect.size()) {
+ // We assume we can stretch the middle tab part
+ // Note: the side effect of this is that pinstripe patterns will get fuzzy
+ const QSize size = cache.size();
+ // top part
+ m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top(),
+ paintRect.width(), border), cache,
+ QRect(0, 0, size.width(), border));
+
+ // tiled center part
+ QPixmap tilePart(cache.width(), 1);
+ QPainter scanLinePainter(&tilePart);
+ scanLinePainter.drawPixmap(QRect(0, 0, tilePart.width(), tilePart.height()), cache, QRect(0, border, size.width(), 1));
+ scanLinePainter.end();
+ m_painter->drawTiledPixmap(QRect(paintRect.left(), paintRect.top() + border,
+ paintRect.width(), paintRect.height() - 2*border), tilePart);
+
+ // bottom part
+ m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top() + paintRect.height() - border,
+ paintRect.width(), border), cache,
+ QRect(0, size.height() - border, size.width(), border));
+ } else
+ m_painter->drawPixmap(paintRect.topLeft(), cache);
+}
+
+void QGtk2Painter::paintBox(GtkWidget *gtkWidget, const gchar* part,
+ const QRect &paintRect, GtkStateType state,
+ GtkShadowType shadow, GtkStyle *style,
+ const QString &pmKey)
+{
+ if (!paintRect.isValid())
+ return;
+
+ QPixmap cache;
+ QRect rect = paintRect;
+
+ // To avoid exhausting cache on large tabframes we cheat a bit by
+ // tiling the center part.
+
+ const int maxHeight = 256;
+ const int maxArea = 256*512;
+ const int border = 32;
+ if (rect.height() > maxHeight && (rect.width()*rect.height() > maxArea))
+ rect.setHeight(2 * border + 1);
+
+ QString pixmapName = uniqueName(QLS(part), state, shadow,
+ rect.size(), gtkWidget) % pmKey;
+
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_box (style,
+ pixmap,
+ state,
+ shadow,
+ NULL,
+ gtkWidget,
+ part,
+ 0, 0,
+ rect.width(),
+ rect.height()));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+ if (rect.size() != paintRect.size()) {
+ // We assume we can stretch the middle tab part
+ // Note: the side effect of this is that pinstripe patterns will get fuzzy
+ const QSize size = cache.size();
+ // top part
+ m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top(),
+ paintRect.width(), border), cache,
+ QRect(0, 0, size.width(), border));
+
+ // tiled center part
+ QPixmap tilePart(cache.width(), 1);
+ QPainter scanLinePainter(&tilePart);
+ scanLinePainter.drawPixmap(QRect(0, 0, tilePart.width(), tilePart.height()), cache, QRect(0, border, size.width(), 1));
+ scanLinePainter.end();
+ m_painter->drawTiledPixmap(QRect(paintRect.left(), paintRect.top() + border,
+ paintRect.width(), paintRect.height() - 2*border), tilePart);
+
+ // bottom part
+ m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top() + paintRect.height() - border,
+ paintRect.width(), border), cache,
+ QRect(0, size.height() - border, size.width(), border));
+ } else
+ m_painter->drawPixmap(paintRect.topLeft(), cache);
+}
+
+void QGtk2Painter::paintHline(GtkWidget *gtkWidget, const gchar* part,
+ const QRect &rect, GtkStateType state,
+ GtkStyle *style, int x1, int x2, int y,
+ const QString &pmKey)
+{
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
+ % HexString<int>(x1)
+ % HexString<int>(x2)
+ % HexString<int>(y)
+ % pmKey;
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_hline (style,
+ pixmap,
+ state,
+ NULL,
+ gtkWidget,
+ part,
+ x1, x2, y));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+void QGtk2Painter::paintVline(GtkWidget *gtkWidget, const gchar* part,
+ const QRect &rect, GtkStateType state,
+ GtkStyle *style, int y1, int y2, int x,
+ const QString &pmKey)
+{
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
+ % HexString<int>(y1)
+ % HexString<int>(y2)
+ % HexString<int>(x)
+ % pmKey;
+
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_vline (style,
+ pixmap,
+ state,
+ NULL,
+ gtkWidget,
+ part,
+ y1, y2,
+ x));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+
+void QGtk2Painter::paintExpander(GtkWidget *gtkWidget,
+ const gchar* part, const QRect &rect,
+ GtkStateType state, GtkExpanderStyle expander_state,
+ GtkStyle *style, const QString &pmKey)
+{
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
+ % HexString<uchar>(expander_state)
+ % pmKey;
+
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_expander (style, pixmap,
+ state, NULL,
+ gtkWidget, part,
+ rect.width()/2,
+ rect.height()/2,
+ expander_state));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+void QGtk2Painter::paintFocus(GtkWidget *gtkWidget, const gchar* part,
+ const QRect &rect, GtkStateType state,
+ GtkStyle *style, const QString &pmKey)
+{
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget) % pmKey;
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_focus (style, pixmap, state, NULL,
+ gtkWidget,
+ part,
+ 0, 0,
+ rect.width(),
+ rect.height()));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+
+void QGtk2Painter::paintResizeGrip(GtkWidget *gtkWidget, const gchar* part,
+ const QRect &rect, GtkStateType state,
+ GtkShadowType shadow, GdkWindowEdge edge,
+ GtkStyle *style, const QString &pmKey)
+{
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) % pmKey;
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_resize_grip (style, pixmap, state,
+ NULL, gtkWidget,
+ part, edge, 0, 0,
+ rect.width(),
+ rect.height()));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+
+void QGtk2Painter::paintArrow(GtkWidget *gtkWidget, const gchar* part,
+ const QRect &arrowrect, GtkArrowType arrow_type,
+ GtkStateType state, GtkShadowType shadow,
+ gboolean fill, GtkStyle *style, const QString &pmKey)
+{
+ QRect rect = m_cliprect.isValid() ? m_cliprect : arrowrect;
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size())
+ % HexString<uchar>(arrow_type)
+ % pmKey;
+
+ GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
+ int xOffset = m_cliprect.isValid() ? arrowrect.x() - m_cliprect.x() : 0;
+ int yOffset = m_cliprect.isValid() ? arrowrect.y() - m_cliprect.y() : 0;
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_arrow (style, pixmap, state, shadow,
+ &gtkCliprect,
+ gtkWidget,
+ part,
+ arrow_type, fill,
+ xOffset, yOffset,
+ arrowrect.width(),
+ arrowrect.height()))
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+
+void QGtk2Painter::paintHandle(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
+ GtkStateType state, GtkShadowType shadow,
+ GtkOrientation orientation, GtkStyle *style)
+{
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size())
+ % HexString<uchar>(orientation);
+
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_handle (style,
+ pixmap,
+ state,
+ shadow,
+ NULL,
+ gtkWidget,
+ part, 0, 0,
+ rect.width(),
+ rect.height(),
+ orientation));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+
+void QGtk2Painter::paintSlider(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
+ GtkStateType state, GtkShadowType shadow,
+ GtkStyle *style, GtkOrientation orientation,
+ const QString &pmKey)
+{
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) % pmKey;
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_slider (style,
+ pixmap,
+ state,
+ shadow,
+ NULL,
+ gtkWidget,
+ part,
+ 0, 0,
+ rect.width(),
+ rect.height(),
+ orientation));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+
+void QGtk2Painter::paintShadow(GtkWidget *gtkWidget, const gchar* part,
+ const QRect &rect, GtkStateType state,
+ GtkShadowType shadow, GtkStyle *style,
+ const QString &pmKey)
+
+{
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) % pmKey;
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_shadow(style, pixmap, state, shadow, NULL,
+ gtkWidget, part, 0, 0, rect.width(), rect.height()));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+void QGtk2Painter::paintFlatBox(GtkWidget *gtkWidget, const gchar* part,
+ const QRect &rect, GtkStateType state,
+ GtkShadowType shadow, GtkStyle *style,
+ const QString &pmKey)
+{
+ if (!rect.isValid())
+ return;
+ QPixmap cache;
+ QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) % pmKey;
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_flat_box (style,
+ pixmap,
+ state,
+ shadow,
+ NULL,
+ gtkWidget,
+ part, 0, 0,
+ rect.width(),
+ rect.height()));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+void QGtk2Painter::paintExtention(GtkWidget *gtkWidget,
+ const gchar *part, const QRect &rect,
+ GtkStateType state, GtkShadowType shadow,
+ GtkPositionType gap_pos, GtkStyle *style)
+{
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget)
+ % HexString<uchar>(gap_pos);
+
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_extension (style, pixmap, state, shadow,
+ NULL, gtkWidget,
+ (gchar*)part, 0, 0,
+ rect.width(),
+ rect.height(),
+ gap_pos));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+void QGtk2Painter::paintOption(GtkWidget *gtkWidget, const QRect &radiorect,
+ GtkStateType state, GtkShadowType shadow,
+ GtkStyle *style, const QString &detail)
+
+{
+ QRect rect = m_cliprect.isValid() ? m_cliprect : radiorect;
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(detail, state, shadow, rect.size());
+ GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
+ int xOffset = m_cliprect.isValid() ? radiorect.x() - m_cliprect.x() : 0;
+ int yOffset = m_cliprect.isValid() ? radiorect.y() - m_cliprect.y() : 0;
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_option(style, pixmap,
+ state, shadow,
+ &gtkCliprect,
+ gtkWidget,
+ detail.toLatin1(),
+ xOffset, yOffset,
+ radiorect.width(),
+ radiorect.height()));
+
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+void QGtk2Painter::paintCheckbox(GtkWidget *gtkWidget, const QRect &checkrect,
+ GtkStateType state, GtkShadowType shadow,
+ GtkStyle *style, const QString &detail)
+
+{
+ QRect rect = m_cliprect.isValid() ? m_cliprect : checkrect;
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(detail, state, shadow, rect.size());
+ GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
+ int xOffset = m_cliprect.isValid() ? checkrect.x() - m_cliprect.x() : 0;
+ int yOffset = m_cliprect.isValid() ? checkrect.y() - m_cliprect.y() : 0;
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_check (style,
+ pixmap,
+ state,
+ shadow,
+ &gtkCliprect,
+ gtkWidget,
+ detail.toLatin1(),
+ xOffset, yOffset,
+ checkrect.width(),
+ checkrect.height()));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+QT_END_NAMESPACE
+
+#endif //!defined(QT_NO_STYLE_GTK)
diff --git a/src/widgets/styles/qgtk2painter_p.h b/src/widgets/styles/qgtk2painter_p.h
new file mode 100644
index 0000000000..cbb49bf89d
--- /dev/null
+++ b/src/widgets/styles/qgtk2painter_p.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGTK2PAINTER_P_H
+#define QGTK2PAINTER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qglobal.h>
+#if !defined(QT_NO_STYLE_GTK)
+
+#include <private/qgtkpainter_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QGtk2Painter : public QGtkPainter
+{
+public:
+ QGtk2Painter();
+
+ void paintBoxGap(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
+ GtkStateType state, GtkShadowType shadow, GtkPositionType gap_side, gint x,
+ gint width, GtkStyle *style);
+ void paintBox(GtkWidget *gtkWidget, const gchar* part,
+ const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style,
+ const QString &pmKey = QString());
+ void paintHline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
+ int x1, int x2, int y, const QString &pmKey = QString());
+ void paintVline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
+ int y1, int y2, int x, const QString &pmKey = QString());
+ void paintExpander(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state,
+ GtkExpanderStyle expander_state, GtkStyle *style, const QString &pmKey = QString());
+ void paintFocus(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
+ const QString &pmKey = QString());
+ void paintResizeGrip(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
+ GdkWindowEdge edge, GtkStyle *style, const QString &pmKey = QString());
+ void paintArrow(GtkWidget *gtkWidget, const gchar* part, const QRect &arrowrect, GtkArrowType arrow_type, GtkStateType state, GtkShadowType shadow,
+ gboolean fill, GtkStyle *style, const QString &pmKey = QString());
+ void paintHandle(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
+ GtkStateType state, GtkShadowType shadow, GtkOrientation orientation, GtkStyle *style);
+ void paintSlider(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
+ GtkStyle *style, GtkOrientation orientation, const QString &pmKey = QString());
+ void paintShadow(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
+ GtkStyle *style, const QString &pmKey = QString());
+ void paintFlatBox(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString & = QString());
+ void paintExtention(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
+ GtkPositionType gap_pos, GtkStyle *style);
+ void paintOption(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail);
+ void paintCheckbox(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail);
+
+private:
+ QPixmap renderTheme(uchar *bdata, uchar *wdata, const QRect &rect) const;
+
+ GtkWidget *m_window;
+};
+
+QT_END_NAMESPACE
+
+#endif //!defined(QT_NO_STYLE_QGTK)
+
+#endif // QGTK2PAINTER_P_H
diff --git a/src/widgets/styles/qgtkglobal_p.h b/src/widgets/styles/qgtkglobal_p.h
new file mode 100644
index 0000000000..6f693ec22d
--- /dev/null
+++ b/src/widgets/styles/qgtkglobal_p.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGTKGLOBAL_P_H
+#define QGTKGLOBAL_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qglobal.h>
+#if !defined(QT_NO_STYLE_GTK)
+
+#undef signals // Collides with GTK symbols
+#include <gtk/gtk.h>
+
+typedef unsigned long XID;
+
+#undef GTK_OBJECT_FLAGS
+#define GTK_OBJECT_FLAGS(obj)(((GtkObject*)(obj))->flags)
+
+#define QLS(x) QLatin1String(x)
+
+QT_BEGIN_NAMESPACE
+
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+# define QT_RED 3
+# define QT_GREEN 2
+# define QT_BLUE 1
+# define QT_ALPHA 0
+#else
+# define QT_RED 0
+# define QT_GREEN 1
+# define QT_BLUE 2
+# define QT_ALPHA 3
+#endif
+# define GTK_RED 2
+# define GTK_GREEN 1
+# define GTK_BLUE 0
+# define GTK_ALPHA 3
+
+QT_END_NAMESPACE
+
+#endif // !QT_NO_STYLE_GTK
+#endif // QGTKGLOBAL_P_H
diff --git a/src/widgets/styles/qgtkpainter.cpp b/src/widgets/styles/qgtkpainter.cpp
index 55430a72e7..a5c408f20d 100644
--- a/src/widgets/styles/qgtkpainter.cpp
+++ b/src/widgets/styles/qgtkpainter.cpp
@@ -41,119 +41,32 @@
#include "qgtkpainter_p.h"
-#include <QtCore/qglobal.h>
#if !defined(QT_NO_STYLE_GTK)
-// This class is primarily a wrapper around the gtk painter functions
-// and takes care of converting all such calls into cached Qt pixmaps.
-
-#include <private/qstylehelper_p.h>
-#include <QtWidgets/QWidget>
-#include <QtWidgets/QStyleOption>
-#include <QtGui/QPixmapCache>
+#include <private/qhexstring_p.h>
QT_BEGIN_NAMESPACE
-#undef GTK_OBJECT_FLAGS
-#define GTK_OBJECT_FLAGS(obj)(((GtkObject*)(obj))->flags)
-
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
-# define QT_RED 3
-# define QT_GREEN 2
-# define QT_BLUE 1
-# define QT_ALPHA 0
-#else
-# define QT_RED 0
-# define QT_GREEN 1
-# define QT_BLUE 2
-# define QT_ALPHA 3
-#endif
-# define GTK_RED 2
-# define GTK_GREEN 1
-# define GTK_BLUE 0
-# define GTK_ALPHA 3
-
-// To recover alpha we apply the gtk painting function two times to
-// white, and black window backgrounds. This can be used to
-// recover the premultiplied alpha channel
-QPixmap QGtkPainter::renderTheme(uchar *bdata, uchar *wdata, const QRect &rect)
+QGtkPainter::QGtkPainter()
{
- const int bytecount = rect.width() * rect.height() * 4;
- for (int index = 0; index < bytecount ; index += 4) {
- uchar val = bdata[index + GTK_BLUE];
- if (m_alpha) {
- int alphaval = qMax(bdata[index + GTK_BLUE] - wdata[index + GTK_BLUE],
- bdata[index + GTK_GREEN] - wdata[index + GTK_GREEN]);
- alphaval = qMax(alphaval, bdata[index + GTK_RED] - wdata[index + GTK_RED]) + 255;
- bdata[index + QT_ALPHA] = alphaval;
- }
- bdata[index + QT_RED] = bdata[index + GTK_RED];
- bdata[index + QT_GREEN] = bdata[index + GTK_GREEN];
- bdata[index + QT_BLUE] = val;
- }
- QImage converted((const uchar*)bdata, rect.width(), rect.height(), m_alpha ?
- QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32);
-
- if (m_hflipped || m_vflipped) {
- return QPixmap::fromImage(converted.mirrored(m_hflipped, m_vflipped));
- } else {
- // on raster graphicssystem we need to do a copy here, because
- // we intend to deallocate the qimage bits shortly after...
- return QPixmap::fromImage(converted.copy());
- }
+ reset(0);
}
-// This macro is responsible for painting any GtkStyle painting function onto a QPixmap
-#define DRAW_TO_CACHE(draw_func) \
- if (rect.width() > QWIDGETSIZE_MAX || rect.height() > QWIDGETSIZE_MAX) \
- return; \
- QRect pixmapRect(0, 0, rect.width(), rect.height()); \
- { \
- GdkPixmap *pixmap = QGtkStylePrivate::gdk_pixmap_new((GdkDrawable*)(m_window->window), \
- rect.width(), rect.height(), -1); \
- if (!pixmap) \
- return; \
- style = QGtkStylePrivate::gtk_style_attach (style, m_window->window); \
- QGtkStylePrivate::gdk_draw_rectangle(pixmap, m_alpha ? style->black_gc : *style->bg_gc, true, \
- 0, 0, rect.width(), rect.height()); \
- draw_func; \
- GdkPixbuf *imgb = QGtkStylePrivate::gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, rect.width(), rect.height());\
- if (!imgb) \
- return; \
- imgb = QGtkStylePrivate::gdk_pixbuf_get_from_drawable(imgb, pixmap, NULL, 0, 0, 0, 0, \
- rect.width(), rect.height()); \
- uchar* bdata = (uchar*)QGtkStylePrivate::gdk_pixbuf_get_pixels(imgb); \
- if (m_alpha) { \
- QGtkStylePrivate::gdk_draw_rectangle(pixmap, style->white_gc, true, 0, 0, rect.width(), rect.height()); \
- draw_func; \
- GdkPixbuf *imgw = QGtkStylePrivate::gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, rect. \
- width(), rect.height()); \
- if (!imgw) \
- return; \
- imgw = QGtkStylePrivate::gdk_pixbuf_get_from_drawable(imgw, pixmap, NULL, 0, 0, 0, 0, \
- rect.width(), rect.height()); \
- uchar* wdata = (uchar*)QGtkStylePrivate::gdk_pixbuf_get_pixels(imgw); \
- cache = renderTheme(bdata, wdata, rect); \
- QGtkStylePrivate::gdk_pixbuf_unref(imgw); \
- } else { \
- cache = renderTheme(bdata, 0, rect); \
- } \
- QGtkStylePrivate::gdk_drawable_unref(pixmap); \
- QGtkStylePrivate::gdk_pixbuf_unref(imgb); \
- }
-
-QGtkPainter::QGtkPainter(QPainter *_painter)
- : m_window(QGtkStylePrivate::gtkWidget("GtkWindow"))
- , m_painter(_painter)
- , m_alpha(true)
- , m_hflipped(false)
- , m_vflipped(false)
- , m_usePixmapCache(true)
-{}
+QGtkPainter::~QGtkPainter()
+{
+}
+void QGtkPainter::reset(QPainter *painter)
+{
+ m_painter = painter;
+ m_alpha = true;
+ m_hflipped = false;
+ m_vflipped = false;
+ m_usePixmapCache = true;
+}
-static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow,
- const QSize &size, GtkWidget *widget = 0)
+QString QGtkPainter::uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow,
+ const QSize &size, GtkWidget *widget)
{
// Note the widget arg should ideally use the widget path, though would compromise performance
QString tmp = key
@@ -165,552 +78,6 @@ static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType
return tmp;
}
-
-GtkStateType QGtkPainter::gtkState(const QStyleOption *option)
-
-{
- GtkStateType state = GTK_STATE_NORMAL;
- if (!(option->state & QStyle::State_Enabled))
- state = GTK_STATE_INSENSITIVE;
- else if (option->state & QStyle::State_MouseOver)
- state = GTK_STATE_PRELIGHT;
-
- return state;
-}
-
-
-GtkStyle* QGtkPainter::getStyle(GtkWidget *gtkWidget)
-
-{
- Q_ASSERT(gtkWidget);
- GtkStyle* style = gtkWidget->style;
- Q_ASSERT(style);
- return style;
-}
-
-QPixmap QGtkPainter::getIcon(const char* iconName, GtkIconSize size)
-{
- GtkStyle *style = QGtkStylePrivate::gtkStyle();
- GtkIconSet* iconSet = QGtkStylePrivate::gtk_icon_factory_lookup_default (iconName);
- GdkPixbuf* icon = QGtkStylePrivate::gtk_icon_set_render_icon(iconSet,
- style,
- GTK_TEXT_DIR_LTR,
- GTK_STATE_NORMAL,
- size,
- NULL,
- "button");
- uchar* data = (uchar*)QGtkStylePrivate::gdk_pixbuf_get_pixels(icon);
- int width = QGtkStylePrivate::gdk_pixbuf_get_width(icon);
- int height = QGtkStylePrivate::gdk_pixbuf_get_height(icon);
- QImage converted(width, height, QImage::Format_ARGB32);
- uchar* tdata = (uchar*)converted.bits();
-
- for ( int index = 0 ; index < height * width*4 ; index +=4 ) {
- //int index = y * rowstride + x;
- tdata[index + QT_RED] = data[index + GTK_RED];
- tdata[index + QT_GREEN] = data[index + GTK_GREEN];
- tdata[index + QT_BLUE] = data[index + GTK_BLUE];
- tdata[index + QT_ALPHA] = data[index + GTK_ALPHA];
- }
-
- QGtkStylePrivate::gdk_pixbuf_unref(icon);
-
- // should we free iconset?
- return QPixmap::fromImage(converted);
-
-}
-
-// Note currently painted without alpha for performance reasons
-void QGtkPainter::paintBoxGap(GtkWidget *gtkWidget, const gchar* part,
- const QRect &paintRect, GtkStateType state,
- GtkShadowType shadow, GtkPositionType gap_side,
- gint x, gint width,
- GtkStyle *style)
-{
- if (!paintRect.isValid())
- return;
-
- QPixmap cache;
- QRect rect = paintRect;
-
- // To avoid exhausting cache on large tabframes we cheat a bit by
- // tiling the center part.
-
- const int maxHeight = 256;
- const int border = 16;
- if (rect.height() > maxHeight && (gap_side == GTK_POS_TOP || gap_side == GTK_POS_BOTTOM))
- rect.setHeight(2 * border + 1);
-
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget)
- % HexString<uchar>(gap_side)
- % HexString<gint>(width)
- % HexString<gint>(x);
-
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_box_gap (style,
- pixmap,
- state,
- shadow,
- NULL,
- gtkWidget,
- (gchar*)part,
- 0, 0,
- rect.width(),
- rect.height(),
- gap_side,
- x,
- width));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
- if (rect.size() != paintRect.size()) {
- // We assume we can stretch the middle tab part
- // Note: the side effect of this is that pinstripe patterns will get fuzzy
- const QSize size = cache.size();
- // top part
- m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top(),
- paintRect.width(), border), cache,
- QRect(0, 0, size.width(), border));
-
- // tiled center part
- QPixmap tilePart(cache.width(), 1);
- QPainter scanLinePainter(&tilePart);
- scanLinePainter.drawPixmap(QRect(0, 0, tilePart.width(), tilePart.height()), cache, QRect(0, border, size.width(), 1));
- scanLinePainter.end();
- m_painter->drawTiledPixmap(QRect(paintRect.left(), paintRect.top() + border,
- paintRect.width(), paintRect.height() - 2*border), tilePart);
-
- // bottom part
- m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top() + paintRect.height() - border,
- paintRect.width(), border), cache,
- QRect(0, size.height() - border, size.width(), border));
- } else
- m_painter->drawPixmap(paintRect.topLeft(), cache);
-}
-
-void QGtkPainter::paintBox(GtkWidget *gtkWidget, const gchar* part,
- const QRect &paintRect, GtkStateType state,
- GtkShadowType shadow, GtkStyle *style,
- const QString &pmKey)
-{
- if (!paintRect.isValid())
- return;
-
- QPixmap cache;
- QRect rect = paintRect;
-
- // To avoid exhausting cache on large tabframes we cheat a bit by
- // tiling the center part.
-
- const int maxHeight = 256;
- const int maxArea = 256*512;
- const int border = 32;
- if (rect.height() > maxHeight && (rect.width()*rect.height() > maxArea))
- rect.setHeight(2 * border + 1);
-
- QString pixmapName = uniqueName(QLS(part), state, shadow,
- rect.size(), gtkWidget) % pmKey;
-
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_box (style,
- pixmap,
- state,
- shadow,
- NULL,
- gtkWidget,
- part,
- 0, 0,
- rect.width(),
- rect.height()));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
- if (rect.size() != paintRect.size()) {
- // We assume we can stretch the middle tab part
- // Note: the side effect of this is that pinstripe patterns will get fuzzy
- const QSize size = cache.size();
- // top part
- m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top(),
- paintRect.width(), border), cache,
- QRect(0, 0, size.width(), border));
-
- // tiled center part
- QPixmap tilePart(cache.width(), 1);
- QPainter scanLinePainter(&tilePart);
- scanLinePainter.drawPixmap(QRect(0, 0, tilePart.width(), tilePart.height()), cache, QRect(0, border, size.width(), 1));
- scanLinePainter.end();
- m_painter->drawTiledPixmap(QRect(paintRect.left(), paintRect.top() + border,
- paintRect.width(), paintRect.height() - 2*border), tilePart);
-
- // bottom part
- m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top() + paintRect.height() - border,
- paintRect.width(), border), cache,
- QRect(0, size.height() - border, size.width(), border));
- } else
- m_painter->drawPixmap(paintRect.topLeft(), cache);
-}
-
-void QGtkPainter::paintHline(GtkWidget *gtkWidget, const gchar* part,
- const QRect &rect, GtkStateType state,
- GtkStyle *style, int x1, int x2, int y,
- const QString &pmKey)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
- % HexString<int>(x1)
- % HexString<int>(x2)
- % HexString<int>(y)
- % pmKey;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_hline (style,
- pixmap,
- state,
- NULL,
- gtkWidget,
- part,
- x1, x2, y));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-void QGtkPainter::paintVline(GtkWidget *gtkWidget, const gchar* part,
- const QRect &rect, GtkStateType state,
- GtkStyle *style, int y1, int y2, int x,
- const QString &pmKey)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
- % HexString<int>(y1)
- % HexString<int>(y2)
- % HexString<int>(x)
- % pmKey;
-
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_vline (style,
- pixmap,
- state,
- NULL,
- gtkWidget,
- part,
- y1, y2,
- x));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-
-void QGtkPainter::paintExpander(GtkWidget *gtkWidget,
- const gchar* part, const QRect &rect,
- GtkStateType state, GtkExpanderStyle expander_state,
- GtkStyle *style, const QString &pmKey)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
- % HexString<uchar>(expander_state)
- % pmKey;
-
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_expander (style, pixmap,
- state, NULL,
- gtkWidget, part,
- rect.width()/2,
- rect.height()/2,
- expander_state));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-void QGtkPainter::paintFocus(GtkWidget *gtkWidget, const gchar* part,
- const QRect &rect, GtkStateType state,
- GtkStyle *style, const QString &pmKey)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget) % pmKey;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_focus (style, pixmap, state, NULL,
- gtkWidget,
- part,
- 0, 0,
- rect.width(),
- rect.height()));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-
-void QGtkPainter::paintResizeGrip(GtkWidget *gtkWidget, const gchar* part,
- const QRect &rect, GtkStateType state,
- GtkShadowType shadow, GdkWindowEdge edge,
- GtkStyle *style, const QString &pmKey)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) % pmKey;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_resize_grip (style, pixmap, state,
- NULL, gtkWidget,
- part, edge, 0, 0,
- rect.width(),
- rect.height()));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-
-void QGtkPainter::paintArrow(GtkWidget *gtkWidget, const gchar* part,
- const QRect &arrowrect, GtkArrowType arrow_type,
- GtkStateType state, GtkShadowType shadow,
- gboolean fill, GtkStyle *style, const QString &pmKey)
-{
- QRect rect = m_cliprect.isValid() ? m_cliprect : arrowrect;
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size())
- % HexString<uchar>(arrow_type)
- % pmKey;
-
- GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
- int xOffset = m_cliprect.isValid() ? arrowrect.x() - m_cliprect.x() : 0;
- int yOffset = m_cliprect.isValid() ? arrowrect.y() - m_cliprect.y() : 0;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_arrow (style, pixmap, state, shadow,
- &gtkCliprect,
- gtkWidget,
- part,
- arrow_type, fill,
- xOffset, yOffset,
- arrowrect.width(),
- arrowrect.height()))
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-
-void QGtkPainter::paintHandle(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
- GtkStateType state, GtkShadowType shadow,
- GtkOrientation orientation, GtkStyle *style)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size())
- % HexString<uchar>(orientation);
-
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_handle (style,
- pixmap,
- state,
- shadow,
- NULL,
- gtkWidget,
- part, 0, 0,
- rect.width(),
- rect.height(),
- orientation));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-
-void QGtkPainter::paintSlider(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
- GtkStateType state, GtkShadowType shadow,
- GtkStyle *style, GtkOrientation orientation,
- const QString &pmKey)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) % pmKey;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_slider (style,
- pixmap,
- state,
- shadow,
- NULL,
- gtkWidget,
- part,
- 0, 0,
- rect.width(),
- rect.height(),
- orientation));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-
-void QGtkPainter::paintShadow(GtkWidget *gtkWidget, const gchar* part,
- const QRect &rect, GtkStateType state,
- GtkShadowType shadow, GtkStyle *style,
- const QString &pmKey)
-
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) % pmKey;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_shadow(style, pixmap, state, shadow, NULL,
- gtkWidget, part, 0, 0, rect.width(), rect.height()));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-void QGtkPainter::paintFlatBox(GtkWidget *gtkWidget, const gchar* part,
- const QRect &rect, GtkStateType state,
- GtkShadowType shadow, GtkStyle *style,
- const QString &pmKey)
-{
- if (!rect.isValid())
- return;
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) % pmKey;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_flat_box (style,
- pixmap,
- state,
- shadow,
- NULL,
- gtkWidget,
- part, 0, 0,
- rect.width(),
- rect.height()));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-void QGtkPainter::paintExtention(GtkWidget *gtkWidget,
- const gchar *part, const QRect &rect,
- GtkStateType state, GtkShadowType shadow,
- GtkPositionType gap_pos, GtkStyle *style)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget)
- % HexString<uchar>(gap_pos);
-
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_extension (style, pixmap, state, shadow,
- NULL, gtkWidget,
- (gchar*)part, 0, 0,
- rect.width(),
- rect.height(),
- gap_pos));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-void QGtkPainter::paintOption(GtkWidget *gtkWidget, const QRect &radiorect,
- GtkStateType state, GtkShadowType shadow,
- GtkStyle *style, const QString &detail)
-
-{
- QRect rect = m_cliprect.isValid() ? m_cliprect : radiorect;
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(detail, state, shadow, rect.size());
- GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
- int xOffset = m_cliprect.isValid() ? radiorect.x() - m_cliprect.x() : 0;
- int yOffset = m_cliprect.isValid() ? radiorect.y() - m_cliprect.y() : 0;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_option(style, pixmap,
- state, shadow,
- &gtkCliprect,
- gtkWidget,
- detail.toLatin1(),
- xOffset, yOffset,
- radiorect.width(),
- radiorect.height()));
-
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-void QGtkPainter::paintCheckbox(GtkWidget *gtkWidget, const QRect &checkrect,
- GtkStateType state, GtkShadowType shadow,
- GtkStyle *style, const QString &detail)
-
-{
- QRect rect = m_cliprect.isValid() ? m_cliprect : checkrect;
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(detail, state, shadow, rect.size());
- GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
- int xOffset = m_cliprect.isValid() ? checkrect.x() - m_cliprect.x() : 0;
- int yOffset = m_cliprect.isValid() ? checkrect.y() - m_cliprect.y() : 0;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_check (style,
- pixmap,
- state,
- shadow,
- &gtkCliprect,
- gtkWidget,
- detail.toLatin1(),
- xOffset, yOffset,
- checkrect.width(),
- checkrect.height()));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
QT_END_NAMESPACE
#endif //!defined(QT_NO_STYLE_GTK)
diff --git a/src/widgets/styles/qgtkpainter_p.h b/src/widgets/styles/qgtkpainter_p.h
index 90b8dd276b..8dc9391902 100644
--- a/src/widgets/styles/qgtkpainter_p.h
+++ b/src/widgets/styles/qgtkpainter_p.h
@@ -56,20 +56,22 @@
#include <QtCore/qglobal.h>
#if !defined(QT_NO_STYLE_GTK)
-#include <QtGui/QPainter>
-#include <QtGui/QPalette>
-#include <QtGui/QFont>
-#include <private/qgtkstyle_p.h>
+#include <private/qgtkglobal_p.h>
+#include <QtCore/qsize.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qpoint.h>
+#include <QtGui/qpixmap.h>
+#include <QtGui/qpainter.h>
QT_BEGIN_NAMESPACE
class QGtkPainter
{
-
public:
- QGtkPainter(QPainter *painter);
- GtkStyle *getStyle(GtkWidget *gtkWidget);
- GtkStateType gtkState(const QStyleOption *option);
+ QGtkPainter();
+ virtual ~QGtkPainter();
+
+ void reset(QPainter *painter = 0);
void setAlphaSupport(bool value) { m_alpha = value; }
void setClipRect(const QRect &rect) { m_cliprect = rect; }
@@ -77,48 +79,45 @@ public:
void setFlipVertical(bool value) { m_vflipped = value; }
void setUsePixmapCache(bool value) { m_usePixmapCache = value; }
- void paintBoxGap(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
- GtkStateType state, GtkShadowType shadow, GtkPositionType gap_side, gint x,
- gint width, GtkStyle *style);
- void paintBox(GtkWidget *gtkWidget, const gchar* part,
- const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style,
- const QString &pmKey = QString());
- void paintHline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
- int x1, int x2, int y, const QString &pmKey = QString());
- void paintVline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
- int y1, int y2, int x, const QString &pmKey = QString());
- void paintExpander(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state,
- GtkExpanderStyle expander_state, GtkStyle *style, const QString &pmKey = QString());
- void paintFocus(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
- const QString &pmKey = QString());
- void paintResizeGrip(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
- GdkWindowEdge edge, GtkStyle *style, const QString &pmKey = QString());
- void paintArrow(GtkWidget *gtkWidget, const gchar* part, const QRect &arrowrect, GtkArrowType arrow_type, GtkStateType state, GtkShadowType shadow,
- gboolean fill, GtkStyle *style, const QString &pmKey = QString());
- void paintHandle(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
- GtkStateType state, GtkShadowType shadow, GtkOrientation orientation, GtkStyle *style);
- void paintSlider(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
- GtkStyle *style, GtkOrientation orientation, const QString &pmKey = QString());
- void paintShadow(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
- GtkStyle *style, const QString &pmKey = QString());
- void paintFlatBox(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString & = QString());
- void paintExtention(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
- GtkPositionType gap_pos, GtkStyle *style);
- void paintOption(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail);
- void paintCheckbox(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail);
+ virtual void paintBoxGap(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
+ GtkStateType state, GtkShadowType shadow, GtkPositionType gap_side, gint x,
+ gint width, GtkStyle *style) = 0;
+ virtual void paintBox(GtkWidget *gtkWidget, const gchar* part,
+ const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style,
+ const QString &pmKey = QString()) = 0;
+ virtual void paintHline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
+ int x1, int x2, int y, const QString &pmKey = QString()) = 0;
+ virtual void paintVline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
+ int y1, int y2, int x, const QString &pmKey = QString()) = 0;
+ virtual void paintExpander(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state,
+ GtkExpanderStyle expander_state, GtkStyle *style, const QString &pmKey = QString()) = 0;
+ virtual void paintFocus(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
+ const QString &pmKey = QString()) = 0;
+ virtual void paintResizeGrip(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
+ GdkWindowEdge edge, GtkStyle *style, const QString &pmKey = QString()) = 0;
+ virtual void paintArrow(GtkWidget *gtkWidget, const gchar* part, const QRect &arrowrect, GtkArrowType arrow_type, GtkStateType state, GtkShadowType shadow,
+ gboolean fill, GtkStyle *style, const QString &pmKey = QString()) = 0;
+ virtual void paintHandle(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
+ GtkStateType state, GtkShadowType shadow, GtkOrientation orientation, GtkStyle *style) = 0;
+ virtual void paintSlider(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
+ GtkStyle *style, GtkOrientation orientation, const QString &pmKey = QString()) = 0;
+ virtual void paintShadow(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
+ GtkStyle *style, const QString &pmKey = QString()) = 0;
+ virtual void paintFlatBox(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString & = QString()) = 0;
+ virtual void paintExtention(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
+ GtkPositionType gap_pos, GtkStyle *style) = 0;
+ virtual void paintOption(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail) = 0;
+ virtual void paintCheckbox(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail) = 0;
- static QPixmap getIcon(const char* iconName, GtkIconSize size = GTK_ICON_SIZE_BUTTON);
-private:
- QPixmap renderTheme(uchar *bdata, uchar *wdata, const QRect&);
+protected:
+ static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget = 0);
- GtkWidget *m_window;
QPainter *m_painter;
bool m_alpha;
bool m_hflipped;
bool m_vflipped;
bool m_usePixmapCache;
QRect m_cliprect;
-
};
QT_END_NAMESPACE
diff --git a/src/widgets/styles/qgtkstyle.cpp b/src/widgets/styles/qgtkstyle.cpp
index 4a7f972436..6aaa3234d6 100644
--- a/src/widgets/styles/qgtkstyle.cpp
+++ b/src/widgets/styles/qgtkstyle.cpp
@@ -79,6 +79,48 @@
QT_BEGIN_NAMESPACE
+static GtkStateType qt_gtk_state(const QStyleOption *option)
+{
+ GtkStateType state = GTK_STATE_NORMAL;
+ if (!(option->state & QStyle::State_Enabled))
+ state = GTK_STATE_INSENSITIVE;
+ else if (option->state & QStyle::State_MouseOver)
+ state = GTK_STATE_PRELIGHT;
+
+ return state;
+}
+
+static QPixmap qt_gtk_get_icon(const char* iconName, GtkIconSize size = GTK_ICON_SIZE_BUTTON)
+{
+ GtkStyle *style = QGtkStylePrivate::gtkStyle();
+ GtkIconSet* iconSet = QGtkStylePrivate::gtk_icon_factory_lookup_default (iconName);
+ GdkPixbuf* icon = QGtkStylePrivate::gtk_icon_set_render_icon(iconSet,
+ style,
+ GTK_TEXT_DIR_LTR,
+ GTK_STATE_NORMAL,
+ size,
+ NULL,
+ "button");
+ uchar* data = (uchar*)QGtkStylePrivate::gdk_pixbuf_get_pixels(icon);
+ int width = QGtkStylePrivate::gdk_pixbuf_get_width(icon);
+ int height = QGtkStylePrivate::gdk_pixbuf_get_height(icon);
+ QImage converted(width, height, QImage::Format_ARGB32);
+ uchar* tdata = (uchar*)converted.bits();
+
+ for ( int index = 0 ; index < height * width*4 ; index +=4 ) {
+ //int index = y * rowstride + x;
+ tdata[index + QT_RED] = data[index + GTK_RED];
+ tdata[index + QT_GREEN] = data[index + GTK_GREEN];
+ tdata[index + QT_BLUE] = data[index + GTK_BLUE];
+ tdata[index + QT_ALPHA] = data[index + GTK_ALPHA];
+ }
+
+ QGtkStylePrivate::gdk_pixbuf_unref(icon);
+
+ // should we free iconset?
+ return QPixmap::fromImage(converted);
+}
+
static void qt_gtk_draw_mdibutton(QPainter *painter, const QStyleOptionTitleBar *option, const QRect &tmp, bool hover, bool sunken)
{
QColor dark;
@@ -861,7 +903,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
}
GtkStyle* style = d->gtkStyle();
- QGtkPainter gtkPainter(painter);
+ QGtkPainter* gtkPainter = d->gtkPainter(painter);
switch (element) {
case PE_Frame: {
@@ -886,8 +928,8 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
pixmap = QPixmap(pmSize, pmSize);
pixmap.fill(Qt::transparent);
QPainter pmPainter(&pixmap);
- QGtkPainter gtkFramePainter(&pmPainter);
- gtkFramePainter.setUsePixmapCache(false); // Don't cache twice
+ gtkPainter->reset(&pmPainter);
+ gtkPainter->setUsePixmapCache(false); // Don't cache twice
GtkShadowType shadow_type = GTK_SHADOW_NONE;
if (option->state & State_Sunken)
@@ -898,10 +940,11 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
GtkStyle *style = d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(),
"*.GtkScrolledWindow", "*.GtkScrolledWindow", d->gtk_window_get_type());
if (style)
- gtkFramePainter.paintShadow(d->gtkWidget("GtkFrame"), "viewport", pmRect,
- option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
- shadow_type, style);
+ gtkPainter->paintShadow(d->gtkWidget("GtkFrame"), "viewport", pmRect,
+ option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
+ shadow_type, style);
QPixmapCache::insert(pmKey, pixmap);
+ gtkPainter->reset(painter);
}
QRect rect = option->rect;
@@ -945,7 +988,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
GtkWidget *gtkWindow = d->gtkWidget("GtkWindow"); // The Murrine Engine currently assumes a widget is passed
style = d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(), "gtk-tooltips", "GtkWindow",
d->gtk_window_get_type());
- gtkPainter.paintFlatBox(gtkWindow, "tooltip", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, style);
+ gtkPainter->paintFlatBox(gtkWindow, "tooltip", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, style);
}
break;
@@ -959,15 +1002,15 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
GtkShadowType shadow_type;
GtkWidget *gtkStatusbarFrame = d->gtkWidget("GtkStatusbar.GtkFrame");
d->gtk_widget_style_get(d->gtk_widget_get_parent(gtkStatusbarFrame), "shadow-type", &shadow_type, NULL);
- gtkPainter.paintShadow(gtkStatusbarFrame, "frame", option->rect, GTK_STATE_NORMAL,
- shadow_type, d->gtk_widget_get_style(gtkStatusbarFrame));
+ gtkPainter->paintShadow(gtkStatusbarFrame, "frame", option->rect, GTK_STATE_NORMAL,
+ shadow_type, d->gtk_widget_get_style(gtkStatusbarFrame));
}
break;
case PE_IndicatorHeaderArrow:
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
GtkWidget *gtkTreeHeader = d->gtkWidget("GtkTreeView.GtkButton");
- GtkStateType state = gtkPainter.gtkState(option);
+ GtkStateType state = qt_gtk_state(option);
style = d->gtk_widget_get_style(gtkTreeHeader);
GtkArrowType type = GTK_ARROW_UP;
// This sorting indicator inversion is intentional, and follows the GNOME HIG.
@@ -977,8 +1020,8 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
else if (header->sortIndicator & QStyleOptionHeader::SortDown)
type = GTK_ARROW_DOWN;
- gtkPainter.paintArrow(gtkTreeHeader, "button", option->rect.adjusted(1, 1, -1, -1), type, state,
- GTK_SHADOW_NONE, false, style);
+ gtkPainter->paintArrow(gtkTreeHeader, "button", option->rect.adjusted(1, 1, -1, -1), type, state,
+ GTK_SHADOW_NONE, false, style);
}
break;
@@ -989,11 +1032,11 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
// Dont draw anything
} else if (qobject_cast<const QTabBar*>(widget)) {
GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook");
- style = gtkPainter.getStyle(gtkNotebook);
- gtkPainter.paintFocus(gtkNotebook, "tab", frameRect.adjusted(-1, 1, 1, 1), GTK_STATE_ACTIVE, style);
+ style = d->gtk_widget_get_style(gtkNotebook);
+ gtkPainter->paintFocus(gtkNotebook, "tab", frameRect.adjusted(-1, 1, 1, 1), GTK_STATE_ACTIVE, style);
} else {
GtkWidget *gtkRadioButton = d->gtkWidget("GtkRadioButton");
- gtkPainter.paintFocus(gtkRadioButton, "radiobutton", frameRect, GTK_STATE_ACTIVE, style);
+ gtkPainter->paintFocus(gtkRadioButton, "radiobutton", frameRect, GTK_STATE_ACTIVE, style);
}
}
break;
@@ -1014,8 +1057,8 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
else if (option->state & State_MouseOver)
state = GTK_STATE_PRELIGHT;
- gtkPainter.paintExpander(gtkTreeView, "treeview", rect, state,
- option->state & State_Open ? openState : closedState , d->gtk_widget_get_style(gtkTreeView));
+ gtkPainter->paintExpander(gtkTreeView, "treeview", rect, state,
+ option->state & State_Open ? openState : closedState , d->gtk_widget_get_style(gtkTreeView));
}
break;
@@ -1056,15 +1099,15 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
if (isActive ) {
// Required for active/non-active window appearance
key = QLS("a");
- GTK_WIDGET_SET_FLAGS(gtkTreeView, GTK_HAS_FOCUS);
+ QGtkStylePrivate::gtkWidgetSetFocus(gtkTreeView, true);
}
bool isEnabled = (widget ? widget->isEnabled() : (vopt->state & QStyle::State_Enabled));
- gtkPainter.paintFlatBox(gtkTreeView, detail, option->rect,
- option->state & State_Selected ? GTK_STATE_SELECTED :
- isEnabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
- GTK_SHADOW_OUT, d->gtk_widget_get_style(gtkTreeView), key);
+ gtkPainter->paintFlatBox(gtkTreeView, detail, option->rect,
+ option->state & State_Selected ? GTK_STATE_SELECTED :
+ isEnabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
+ GTK_SHADOW_OUT, d->gtk_widget_get_style(gtkTreeView), key);
if (isActive )
- GTK_WIDGET_UNSET_FLAGS(gtkTreeView, GTK_HAS_FOCUS);
+ QGtkStylePrivate::gtkWidgetSetFocus(gtkTreeView, false);
}
}
break;
@@ -1076,14 +1119,14 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
const int offset = option->rect.width()/2;
QRect rect = option->rect.adjusted(offset, margin, 0, -margin);
painter->setPen(QPen(option->palette.background().color().darker(110)));
- gtkPainter.paintVline( gtkSeparator, "vseparator",
+ gtkPainter->paintVline(gtkSeparator, "vseparator",
rect, GTK_STATE_NORMAL, d->gtk_widget_get_style(gtkSeparator),
0, rect.height(), 0);
} else { //Draw vertical separator
const int offset = option->rect.height()/2;
QRect rect = option->rect.adjusted(margin, offset, -margin, 0);
painter->setPen(QPen(option->palette.background().color().darker(110)));
- gtkPainter.paintHline( gtkSeparator, "hseparator",
+ gtkPainter->paintHline(gtkSeparator, "hseparator",
rect, GTK_STATE_NORMAL, d->gtk_widget_get_style(gtkSeparator),
0, rect.width(), 0);
}
@@ -1096,9 +1139,9 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
d->gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL);
//Note when the toolbar is horizontal, the handle is vertical
painter->setClipRect(option->rect);
- gtkPainter.paintHandle(gtkToolbar, "toolbar", option->rect.adjusted(-1, -1 ,0 ,1),
- GTK_STATE_NORMAL, shadow_type, !(option->state & State_Horizontal) ?
- GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, d->gtk_widget_get_style(gtkToolbar));
+ gtkPainter->paintHandle(gtkToolbar, "toolbar", option->rect.adjusted(-1, -1 ,0 ,1),
+ GTK_STATE_NORMAL, shadow_type, !(option->state & State_Horizontal) ?
+ GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, d->gtk_widget_get_style(gtkToolbar));
}
break;
@@ -1136,15 +1179,15 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
}
QRect arrowRect = option->rect.adjusted(border + bsx, border + bsy, -border + bsx, -border + bsy);
GtkShadowType shadow = option->state & State_Sunken ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
- GtkStateType state = gtkPainter.gtkState(option);
+ GtkStateType state = qt_gtk_state(option);
QColor arrowColor = option->palette.buttonText().color();
GtkWidget *gtkArrow = d->gtkWidget("GtkArrow");
GdkColor color = fromQColor(arrowColor);
d->gtk_widget_modify_fg (gtkArrow, state, &color);
- gtkPainter.paintArrow(gtkArrow, "button", arrowRect,
- type, state, shadow, false, d->gtk_widget_get_style(gtkArrow),
- QString::number(arrowColor.rgba(), 16));
+ gtkPainter->paintArrow(gtkArrow, "button", arrowRect,
+ type, state, shadow, false, d->gtk_widget_get_style(gtkArrow),
+ QString::number(arrowColor.rgba(), 16));
// Passing NULL will revert the color change
d->gtk_widget_modify_fg (gtkArrow, state, NULL);
}
@@ -1156,8 +1199,8 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
case PE_PanelMenu: {
GtkWidget *gtkMenu = d->gtkWidget("GtkMenu");
- gtkPainter.setAlphaSupport(false); // Note, alpha disabled for performance reasons
- gtkPainter.paintBox(gtkMenu, "menu", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, d->gtk_widget_get_style(gtkMenu), QString());
+ gtkPainter->setAlphaSupport(false); // Note, alpha disabled for performance reasons
+ gtkPainter->paintBox(gtkMenu, "menu", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, d->gtk_widget_get_style(gtkMenu), QString());
}
break;
@@ -1168,9 +1211,9 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
// This is only used by floating tool bars
if (qobject_cast<const QToolBar *>(widget)) {
GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
- gtkPainter.paintBox( gtkMenubar, "toolbar", option->rect,
+ gtkPainter->paintBox(gtkMenubar, "toolbar", option->rect,
GTK_STATE_NORMAL, GTK_SHADOW_OUT, style);
- gtkPainter.paintBox( gtkMenubar, "menu", option->rect,
+ gtkPainter->paintBox(gtkMenubar, "menu", option->rect,
GTK_STATE_NORMAL, GTK_SHADOW_OUT, style);
}
break;
@@ -1193,18 +1236,18 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
rect.adjust(focus_line_width, focus_line_width, -focus_line_width, -focus_line_width);
if (option->state & State_HasFocus)
- GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
- gtkPainter.paintShadow(gtkEntry, "entry", rect, option->state & State_Enabled ?
- GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
- GTK_SHADOW_IN, d->gtk_widget_get_style(gtkEntry),
- option->state & State_HasFocus ? QLS("focus") : QString());
+ QGtkStylePrivate::gtkWidgetSetFocus(gtkEntry, true);
+ gtkPainter->paintShadow(gtkEntry, "entry", rect, option->state & State_Enabled ?
+ GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
+ GTK_SHADOW_IN, d->gtk_widget_get_style(gtkEntry),
+ option->state & State_HasFocus ? QLS("focus") : QString());
if (!interior_focus && option->state & State_HasFocus)
- gtkPainter.paintShadow(gtkEntry, "entry", option->rect, option->state & State_Enabled ?
- GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
- GTK_SHADOW_IN, d->gtk_widget_get_style(gtkEntry), QLS("GtkEntryShadowIn"));
+ gtkPainter->paintShadow(gtkEntry, "entry", option->rect, option->state & State_Enabled ?
+ GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
+ GTK_SHADOW_IN, d->gtk_widget_get_style(gtkEntry), QLS("GtkEntryShadowIn"));
if (option->state & State_HasFocus)
- GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
+ QGtkStylePrivate::gtkWidgetSetFocus(gtkEntry, false);
}
break;
@@ -1222,7 +1265,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
resolve_mask & (1 << QPalette::Base)) // Palette overridden by user
painter->fillRect(textRect, option->palette.base());
else
- gtkPainter.paintFlatBox( gtkEntry, "entry_bg", textRect,
+ gtkPainter->paintFlatBox(gtkEntry, "entry_bg", textRect,
option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, GTK_SHADOW_NONE, gtkEntryStyle);
}
break;
@@ -1230,8 +1273,8 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
case PE_FrameTabWidget:
if (const QStyleOptionTabWidgetFrame *frame = qstyleoption_cast<const QStyleOptionTabWidgetFrame*>(option)) {
GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook");
- style = gtkPainter.getStyle(gtkNotebook);
- gtkPainter.setAlphaSupport(false);
+ style = d->gtk_widget_get_style(gtkNotebook);
+ gtkPainter->setAlphaSupport(false);
GtkShadowType shadow = GTK_SHADOW_OUT;
GtkStateType state = GTK_STATE_NORMAL; // Only state supported by gtknotebook
bool reverse = (option->direction == Qt::RightToLeft);
@@ -1250,13 +1293,13 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
gapStart = tabframe->selectedTabRect.y();
gapSize = tabframe->selectedTabRect.height();
}
- gtkPainter.paintBoxGap(gtkNotebook, "notebook", option->rect, state, shadow, frameType,
+ gtkPainter->paintBoxGap(gtkNotebook, "notebook", option->rect, state, shadow, frameType,
gapStart, gapSize, style);
break; // done
}
// Note this is only the fallback option
- gtkPainter.paintBox(gtkNotebook, "notebook", option->rect, state, shadow, style);
+ gtkPainter->paintBox(gtkNotebook, "notebook", option->rect, state, shadow, style);
}
break;
@@ -1274,7 +1317,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
if (widget && widget->inherits("QDockWidgetTitleButton") && !(option->state & State_MouseOver))
break;
- GtkStateType state = gtkPainter.gtkState(option);
+ GtkStateType state = qt_gtk_state(option);
if (option->state & State_On || option->state & State_Sunken)
state = GTK_STATE_ACTIVE;
GtkWidget *gtkButton = isTool ? d->gtkWidget("GtkToolButton.GtkButton") : d->gtkWidget("GtkButton");
@@ -1292,16 +1335,17 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
QString key;
if (isDefault) {
key += QLS("def");
- GTK_WIDGET_SET_FLAGS(gtkButton, GTK_HAS_DEFAULT);
- gtkPainter.paintBox(gtkButton, "buttondefault", buttonRect, state, GTK_SHADOW_IN,
- style, isDefault ? QLS("d") : QString());
+ QGtkStylePrivate::gtk_widget_set_can_default(gtkButton, true);
+ QGtkStylePrivate::gtk_window_set_default((GtkWindow*)QGtkStylePrivate::gtk_widget_get_toplevel(gtkButton), gtkButton);
+ gtkPainter->paintBox(gtkButton, "buttondefault", buttonRect, state, GTK_SHADOW_IN,
+ style, isDefault ? QLS("d") : QString());
}
bool hasFocus = option->state & State_HasFocus;
if (hasFocus) {
key += QLS("def");
- GTK_WIDGET_SET_FLAGS(gtkButton, GTK_HAS_FOCUS);
+ QGtkStylePrivate::gtkWidgetSetFocus(gtkButton, true);
}
if (!interiorFocus)
@@ -1310,18 +1354,18 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
GtkShadowType shadow = (option->state & State_Sunken || option->state & State_On ) ?
GTK_SHADOW_IN : GTK_SHADOW_OUT;
- gtkPainter.paintBox(gtkButton, "button", buttonRect, state, shadow,
- style, key);
+ gtkPainter->paintBox(gtkButton, "button", buttonRect, state, shadow,
+ style, key);
if (isDefault)
- GTK_WIDGET_UNSET_FLAGS(gtkButton, GTK_HAS_DEFAULT);
+ QGtkStylePrivate::gtk_window_set_default((GtkWindow*)QGtkStylePrivate::gtk_widget_get_toplevel(gtkButton), 0);
if (hasFocus)
- GTK_WIDGET_UNSET_FLAGS(gtkButton, GTK_HAS_FOCUS);
+ QGtkStylePrivate::gtkWidgetSetFocus(gtkButton, false);
}
break;
case PE_IndicatorRadioButton: {
GtkShadowType shadow = GTK_SHADOW_OUT;
- GtkStateType state = gtkPainter.gtkState(option);
+ GtkStateType state = qt_gtk_state(option);
if (option->state & State_Sunken)
state = GTK_STATE_ACTIVE;
@@ -1337,24 +1381,24 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
gint spacing;
d->gtk_widget_style_get(gtkRadioButton, "indicator-spacing", &spacing, NULL);
QRect buttonRect = option->rect.adjusted(spacing, spacing, -spacing, -spacing);
- gtkPainter.setClipRect(option->rect);
+ gtkPainter->setClipRect(option->rect);
// ### Note: Ubuntulooks breaks when the proper widget is passed
// Murrine engine requires a widget not to get RGBA check - warnings
GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton");
QString key(QLS("radiobutton"));
if (option->state & State_HasFocus) { // Themes such as Nodoka check this flag
key += QLatin1Char('f');
- GTK_WIDGET_SET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS);
+ QGtkStylePrivate::gtkWidgetSetFocus(gtkCheckButton, true);
}
- gtkPainter.paintOption(gtkCheckButton , buttonRect, state, shadow, d->gtk_widget_get_style(gtkRadioButton), key);
+ gtkPainter->paintOption(gtkCheckButton , buttonRect, state, shadow, d->gtk_widget_get_style(gtkRadioButton), key);
if (option->state & State_HasFocus)
- GTK_WIDGET_UNSET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS);
+ QGtkStylePrivate::gtkWidgetSetFocus(gtkCheckButton, false);
}
break;
case PE_IndicatorCheckBox: {
GtkShadowType shadow = GTK_SHADOW_OUT;
- GtkStateType state = gtkPainter.gtkState(option);
+ GtkStateType state = qt_gtk_state(option);
if (option->state & State_Sunken)
state = GTK_STATE_ACTIVE;
@@ -1372,20 +1416,20 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
QString key(QLS("checkbutton"));
if (option->state & State_HasFocus) { // Themes such as Nodoka checks this flag
key += QLatin1Char('f');
- GTK_WIDGET_SET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS);
+ QGtkStylePrivate::gtkWidgetSetFocus(gtkCheckButton, true);
}
// Some styles such as aero-clone assume they can paint in the spacing area
- gtkPainter.setClipRect(option->rect);
+ gtkPainter->setClipRect(option->rect);
d->gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, NULL);
QRect checkRect = option->rect.adjusted(spacing, spacing, -spacing, -spacing);
- gtkPainter.paintCheckbox(gtkCheckButton, checkRect, state, shadow, d->gtk_widget_get_style(gtkCheckButton),
- key);
+ gtkPainter->paintCheckbox(gtkCheckButton, checkRect, state, shadow, d->gtk_widget_get_style(gtkCheckButton),
+ key);
if (option->state & State_HasFocus)
- GTK_WIDGET_UNSET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS);
+ QGtkStylePrivate::gtkWidgetSetFocus(gtkCheckButton, false);
}
break;
@@ -1455,7 +1499,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
}
GtkStyle* style = d->gtkStyle();
- QGtkPainter gtkPainter(painter);
+ QGtkPainter* gtkPainter = d->gtkPainter(painter);
QColor button = option->palette.button().color();
QColor dark;
QColor grooveColor;
@@ -1770,8 +1814,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
if (option->state & State_MouseOver) {
QRect bgRect = textRect | checkBoxRect;
- gtkPainter.paintFlatBox(gtkCheckButton, "checkbutton", bgRect.adjusted(0, 0, 0, -2),
- GTK_STATE_PRELIGHT, GTK_SHADOW_ETCHED_OUT, d->gtk_widget_get_style(gtkCheckButton));
+ gtkPainter->paintFlatBox(gtkCheckButton, "checkbutton", bgRect.adjusted(0, 0, 0, -2),
+ GTK_STATE_PRELIGHT, GTK_SHADOW_ETCHED_OUT, d->gtk_widget_get_style(gtkCheckButton));
}
if (!groupBox->text.isEmpty()) {
@@ -1793,7 +1837,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
painter->drawText(textRect, Qt::TextShowMnemonic | Qt::AlignLeft| alignment, groupBox->text);
if (option->state & State_HasFocus)
- gtkPainter.paintFocus(gtkCheckButton, "checkbutton", textRect.adjusted(-4, -1, 0, -3), GTK_STATE_ACTIVE, style);
+ gtkPainter->paintFocus(gtkCheckButton, "checkbutton", textRect.adjusted(-4, -1, 0, -3), GTK_STATE_ACTIVE, style);
}
}
@@ -1817,12 +1861,12 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
if (const QStyleOptionComboBox *comboBox = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
bool sunken = comboBox->state & State_On; // play dead, if combobox has no items
BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("cb-%0-%1").arg(sunken).arg(comboBox->editable));
- QGtkPainter gtkCachedPainter(p);
- gtkCachedPainter.setUsePixmapCache(false); // cached externally
+ gtkPainter->reset(p);
+ gtkPainter->setUsePixmapCache(false); // cached externally
bool isEnabled = (comboBox->state & State_Enabled);
bool focus = isEnabled && (comboBox->state & State_HasFocus);
- GtkStateType state = gtkPainter.gtkState(option);
+ GtkStateType state = qt_gtk_state(option);
int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, comboBox, widget);
QStyleOptionComboBox comboBoxCopy = *comboBox;
comboBoxCopy.rect = option->rect;
@@ -1834,7 +1878,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
GtkShadowType shadow = (option->state & State_Sunken || option->state & State_On ) ?
GTK_SHADOW_IN : GTK_SHADOW_OUT;
- const QHashableLatin1Literal comboBoxPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry") : QHashableLatin1Literal("GtkComboBox");
+ const QHashableLatin1Literal comboBoxPath = comboBox->editable && QGtkStylePrivate::gtk_combo_box_entry_new ?
+ QHashableLatin1Literal("GtkComboBoxEntry") : QHashableLatin1Literal("GtkComboBox");
// We use the gtk widget to position arrows and separators for us
GtkWidget *gtkCombo = d->gtkWidget(comboBoxPath);
@@ -1842,17 +1887,18 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
d->gtk_widget_set_direction(gtkCombo, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
d->gtk_widget_size_allocate(gtkCombo, &geometry);
- QHashableLatin1Literal buttonPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton")
- : QHashableLatin1Literal("GtkComboBox.GtkToggleButton");
+ QHashableLatin1Literal buttonPath = comboBox->editable && QGtkStylePrivate::gtk_combo_box_entry_new ?
+ QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton") : QHashableLatin1Literal("GtkComboBox.GtkToggleButton");
GtkWidget *gtkToggleButton = d->gtkWidget(buttonPath);
d->gtk_widget_set_direction(gtkToggleButton, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
if (gtkToggleButton && (appears_as_list || comboBox->editable)) {
if (focus)
- GTK_WIDGET_SET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
+ QGtkStylePrivate::gtkWidgetSetFocus(gtkToggleButton, true);
// Draw the combo box as a line edit with a button next to it
if (comboBox->editable || appears_as_list) {
GtkStateType frameState = (state == GTK_STATE_PRELIGHT) ? GTK_STATE_NORMAL : state;
- QHashableLatin1Literal entryPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry.GtkEntry") : QHashableLatin1Literal("GtkComboBox.GtkFrame");
+ QHashableLatin1Literal entryPath = comboBox->editable && QGtkStylePrivate::gtk_combo_box_entry_new ? QHashableLatin1Literal("GtkComboBoxEntry.GtkEntry")
+ : comboBox->editable ? QHashableLatin1Literal("GtkComboBox.GtkEntry") : QHashableLatin1Literal("GtkComboBox.GtkFrame");
GtkWidget *gtkEntry = d->gtkWidget(entryPath);
d->gtk_widget_set_direction(gtkEntry, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
QRect frameRect = option->rect;
@@ -1870,23 +1916,23 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
-gtkEntryStyle->xthickness, -gtkEntryStyle->ythickness);
// Required for inner blue highlight with clearlooks
if (focus)
- GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
+ QGtkStylePrivate::gtkWidgetSetFocus(gtkEntry, true);
if (widget && widget->testAttribute(Qt::WA_SetPalette) &&
resolve_mask & (1 << QPalette::Base)) // Palette overridden by user
p->fillRect(contentRect, option->palette.base().color());
else {
- gtkCachedPainter.paintFlatBox(gtkEntry, "entry_bg", contentRect,
- option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
- GTK_SHADOW_NONE, gtkEntryStyle, entryPath.toString() + QString::number(focus));
+ gtkPainter->paintFlatBox(gtkEntry, "entry_bg", contentRect,
+ option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
+ GTK_SHADOW_NONE, gtkEntryStyle, entryPath.toString() + QString::number(focus));
}
- gtkCachedPainter.paintShadow(gtkEntry, comboBox->editable ? "entry" : "frame", frameRect, frameState,
- GTK_SHADOW_IN, gtkEntryStyle, entryPath.toString() +
- QString::number(focus) + QString::number(comboBox->editable) +
- QString::number(option->direction));
+ gtkPainter->paintShadow(gtkEntry, comboBox->editable ? "entry" : "frame", frameRect, frameState,
+ GTK_SHADOW_IN, gtkEntryStyle, entryPath.toString() +
+ QString::number(focus) + QString::number(comboBox->editable) +
+ QString::number(option->direction));
if (focus)
- GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
+ QGtkStylePrivate::gtkWidgetSetFocus(gtkEntry, false);
}
GtkStateType buttonState = GTK_STATE_NORMAL;
@@ -1899,28 +1945,28 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
buttonState = GTK_STATE_PRELIGHT;
Q_ASSERT(gtkToggleButton);
- gtkCachedPainter.paintBox( gtkToggleButton, "button", arrowButtonRect, buttonState,
+ gtkPainter->paintBox(gtkToggleButton, "button", arrowButtonRect, buttonState,
shadow, d->gtk_widget_get_style(gtkToggleButton), buttonPath.toString() +
QString::number(focus) + QString::number(option->direction));
if (focus)
- GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
+ QGtkStylePrivate::gtkWidgetSetFocus(gtkToggleButton, false);
} else {
// Draw combo box as a button
QRect buttonRect = option->rect;
GtkStyle *gtkToggleButtonStyle = d->gtk_widget_get_style(gtkToggleButton);
if (focus) // Clearlooks actually check the widget for the default state
- GTK_WIDGET_SET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
- gtkCachedPainter.paintBox(gtkToggleButton, "button",
- buttonRect, state,
- shadow, gtkToggleButtonStyle,
- buttonPath.toString() + QString::number(focus));
+ QGtkStylePrivate::gtkWidgetSetFocus(gtkToggleButton, true);
+ gtkPainter->paintBox(gtkToggleButton, "button",
+ buttonRect, state,
+ shadow, gtkToggleButtonStyle,
+ buttonPath.toString() + QString::number(focus));
if (focus)
- GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
+ QGtkStylePrivate::gtkWidgetSetFocus(gtkToggleButton, false);
// Draw the separator between label and arrows
- QHashableLatin1Literal vSeparatorPath = comboBox->editable
+ QHashableLatin1Literal vSeparatorPath = comboBox->editable && QGtkStylePrivate::gtk_combo_box_entry_new
? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkHBox.GtkVSeparator")
: QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkHBox.GtkVSeparator");
@@ -1929,9 +1975,9 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
d->gtk_widget_get_allocation(gtkVSeparator, &allocation);
QRect vLineRect(allocation.x, allocation.y, allocation.width, allocation.height);
- gtkCachedPainter.paintVline( gtkVSeparator, "vseparator",
+ gtkPainter->paintVline(gtkVSeparator, "vseparator",
vLineRect, state, d->gtk_widget_get_style(gtkVSeparator),
- 0, vLineRect.height(), 0, vSeparatorPath.toString());
+ 0, vLineRect.height(), 0, vSeparatorPath.toString());
gint interiorFocus = true;
@@ -1939,10 +1985,10 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
int xt = interiorFocus ? gtkToggleButtonStyle->xthickness : 0;
int yt = interiorFocus ? gtkToggleButtonStyle->ythickness : 0;
if (focus && ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget)))
- gtkCachedPainter.paintFocus(gtkToggleButton, "button",
- option->rect.adjusted(xt, yt, -xt, -yt),
- option->state & State_Sunken ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL,
- gtkToggleButtonStyle);
+ gtkPainter->paintFocus(gtkToggleButton, "button",
+ option->rect.adjusted(xt, yt, -xt, -yt),
+ option->state & State_Sunken ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL,
+ gtkToggleButtonStyle);
}
}
@@ -1957,7 +2003,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
state = GTK_STATE_NORMAL;
QHashableLatin1Literal arrowPath("");
- if (comboBox->editable) {
+ if (comboBox->editable && QGtkStylePrivate::gtk_combo_box_entry_new) {
if (appears_as_list)
arrowPath = QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkArrow");
else
@@ -1995,7 +2041,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
if (sunken) {
int xoff, yoff;
- const QHashableLatin1Literal toggleButtonPath = comboBox->editable
+ const QHashableLatin1Literal toggleButtonPath = comboBox->editable && QGtkStylePrivate::gtk_combo_box_entry_new
? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton")
: QHashableLatin1Literal("GtkComboBox.GtkToggleButton");
@@ -2008,8 +2054,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
// Some styles such as Nimbus paint outside the arrowRect
// hence we have provide the whole widget as the cliprect
if (gtkArrow) {
- gtkCachedPainter.setClipRect(option->rect);
- gtkCachedPainter.paintArrow( gtkArrow, "arrow", arrowRect,
+ gtkPainter->setClipRect(option->rect);
+ gtkPainter->paintArrow(gtkArrow, "arrow", arrowRect,
GTK_ARROW_DOWN, state, GTK_SHADOW_NONE, true,
style, arrowPath.toString() + QString::number(option->direction));
}
@@ -2128,7 +2174,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
gint trough_border = 1;
if (!d->gtk_check_version(2, 10, 0)) {
d->gtk_widget_style_get((GtkWidget*)(scrollbarWidget),
- "trough-border", &trough_border,
+ "trough-border", &trough_border,
"trough-side-details", &trough_side_details,
"trough-under-steppers", &trough_under_steppers,
"activate-slider", &activate_slider,
@@ -2173,7 +2219,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
if (trough_under_steppers)
grooveRect = option->rect;
- gtkPainter.paintBox( scrollbarWidget, "trough", grooveRect, state, GTK_SHADOW_IN, style);
+ gtkPainter->paintBox(scrollbarWidget, "trough", grooveRect, state, GTK_SHADOW_IN, style);
}
//paint slider
@@ -2197,8 +2243,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
scrollBarSlider.adjust(0, trough_border, 0, -trough_border);
}
- gtkPainter.paintSlider( scrollbarWidget, "slider", scrollBarSlider, state, shadow, style,
-
+ gtkPainter->paintSlider(scrollbarWidget, "slider", scrollBarSlider, state, shadow, style,
horizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, QString(QLS("%0%1")).arg(fakePos).arg(maximum));
}
@@ -2225,11 +2270,11 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
} else if (option->state & State_MouseOver && (scrollBar->activeSubControls & SC_ScrollBarAddLine))
state = GTK_STATE_PRELIGHT;
- gtkPainter.paintBox( scrollbarWidget,
+ gtkPainter->paintBox(scrollbarWidget,
horizontal ? "hscrollbar" : "vscrollbar", scrollBarAddLine,
state, shadow, style, QLS("add"));
- gtkPainter.paintArrow( scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarAddLine.adjusted(4, 4, -4, -4),
+ gtkPainter->paintArrow(scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarAddLine.adjusted(4, 4, -4, -4),
horizontal ? (reverse ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT) :
GTK_ARROW_DOWN, state, GTK_SHADOW_NONE, false, style);
}
@@ -2257,12 +2302,12 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
} else if (option->state & State_MouseOver && (scrollBar->activeSubControls & SC_ScrollBarSubLine))
state = GTK_STATE_PRELIGHT;
- gtkPainter.paintBox(scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarSubLine,
- state, shadow, style, QLS("sub"));
+ gtkPainter->paintBox(scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarSubLine,
+ state, shadow, style, QLS("sub"));
- gtkPainter.paintArrow(scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarSubLine.adjusted(4, 4, -4, -4),
- horizontal ? (reverse ? GTK_ARROW_RIGHT : GTK_ARROW_LEFT) :
- GTK_ARROW_UP, state, GTK_SHADOW_NONE, false, style);
+ gtkPainter->paintArrow(scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarSubLine.adjusted(4, 4, -4, -4),
+ horizontal ? (reverse ? GTK_ARROW_RIGHT : GTK_ARROW_LEFT) :
+ GTK_ARROW_UP, state, GTK_SHADOW_NONE, false, style);
}
}
break;
@@ -2313,7 +2358,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
editArea.setRight(upRect.left());
}
if (spinBox->frame) {
- GtkStateType state = gtkPainter.gtkState(option);
+ GtkStateType state = qt_gtk_state(option);
if (!(option->state & State_Enabled))
state = GTK_STATE_INSENSITIVE;
@@ -2322,14 +2367,14 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
else if (state == GTK_STATE_PRELIGHT)
state = GTK_STATE_NORMAL;
- style = gtkPainter.getStyle(gtkSpinButton);
+ style = d->gtk_widget_get_style(gtkSpinButton);
QString key;
if (option->state & State_HasFocus) {
key += QLatin1Char('f');
- GTK_WIDGET_SET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS);
+ QGtkStylePrivate::gtkWidgetSetFocus(gtkSpinButton, true);
}
uint resolve_mask = option->palette.resolve();
@@ -2337,36 +2382,36 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
if (resolve_mask & (1 << QPalette::Base)) // Palette overridden by user
painter->fillRect(editRect, option->palette.base().color());
else
- gtkPainter.paintFlatBox(gtkSpinButton, "entry_bg", editArea.adjusted(style->xthickness, style->ythickness,
- -style->xthickness, -style->ythickness),
- option->state & State_Enabled ?
- GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, GTK_SHADOW_NONE, style, key);
+ gtkPainter->paintFlatBox(gtkSpinButton, "entry_bg", editArea.adjusted(style->xthickness, style->ythickness,
+ -style->xthickness, -style->ythickness),
+ option->state & State_Enabled ?
+ GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, GTK_SHADOW_NONE, style, key);
- gtkPainter.paintShadow(gtkSpinButton, "entry", editArea, state, GTK_SHADOW_IN, d->gtk_widget_get_style(gtkSpinButton), key);
+ gtkPainter->paintShadow(gtkSpinButton, "entry", editArea, state, GTK_SHADOW_IN, d->gtk_widget_get_style(gtkSpinButton), key);
if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) {
- gtkPainter.paintBox(gtkSpinButton, "spinbutton", buttonRect, state, GTK_SHADOW_IN, style, key);
+ gtkPainter->paintBox(gtkSpinButton, "spinbutton", buttonRect, state, GTK_SHADOW_IN, style, key);
upRect.setSize(downRect.size());
if (!(option->state & State_Enabled))
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key);
+ gtkPainter->paintBox(gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key);
else if (upIsActive && sunken)
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key);
+ gtkPainter->paintBox(gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key);
else if (upIsActive && hover)
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key);
+ gtkPainter->paintBox(gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key);
else
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key);
+ gtkPainter->paintBox(gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key);
if (!(option->state & State_Enabled))
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key);
+ gtkPainter->paintBox(gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key);
else if (downIsActive && sunken)
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key);
+ gtkPainter->paintBox(gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key);
else if (downIsActive && hover)
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key);
+ gtkPainter->paintBox(gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key);
else
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key);
+ gtkPainter->paintBox(gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key);
if (option->state & State_HasFocus)
- GTK_WIDGET_UNSET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS);
+ QGtkStylePrivate::gtkWidgetSetFocus(gtkSpinButton, false);
}
}
@@ -2405,7 +2450,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
if (!(option->state & State_Enabled) || !(spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled))
state = GTK_STATE_INSENSITIVE;
- gtkPainter.paintArrow( gtkSpinButton, "spinbutton", arrowRect, GTK_ARROW_UP, state,
+ gtkPainter->paintArrow(gtkSpinButton, "spinbutton", arrowRect, GTK_ARROW_UP, state,
GTK_SHADOW_NONE, false, style);
arrowRect.moveCenter(downRect.center());
@@ -2413,7 +2458,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
if (!(option->state & State_Enabled) || !(spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled))
state = GTK_STATE_INSENSITIVE;
- gtkPainter.paintArrow( gtkSpinButton, "spinbutton", arrowRect, GTK_ARROW_DOWN, state,
+ gtkPainter->paintArrow(gtkSpinButton, "spinbutton", arrowRect, GTK_ARROW_DOWN, state,
GTK_SHADOW_NONE, false, style);
}
}
@@ -2475,17 +2520,17 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
d->gtk_widget_style_get(scaleWidget, "trough-border", &outerSize, NULL);
outerSize++;
- GtkStateType state = gtkPainter.gtkState(option);
+ GtkStateType state = qt_gtk_state(option);
int focusFrameMargin = 2;
QRect grooveRect = option->rect.adjusted(focusFrameMargin, outerSize + focusFrameMargin,
-focusFrameMargin, -outerSize - focusFrameMargin);
gboolean trough_side_details = false; // Indicates if the upper or lower scale background differs
if (!d->gtk_check_version(2, 10, 0))
- d->gtk_widget_style_get((GtkWidget*)(scaleWidget), "trough-side-details", &trough_side_details, NULL);
+ d->gtk_widget_style_get((GtkWidget*)(scaleWidget), "trough-side-details", &trough_side_details, NULL);
if (!trough_side_details) {
- gtkPainter.paintBox( scaleWidget, "trough", grooveRect, state,
+ gtkPainter->paintBox(scaleWidget, "trough", grooveRect, state,
GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));
} else {
QRect upperGroove = grooveRect;
@@ -2509,9 +2554,9 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
}
}
- gtkPainter.paintBox( scaleWidget, "trough-upper", upperGroove, state,
+ gtkPainter->paintBox(scaleWidget, "trough-upper", upperGroove, state,
GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));
- gtkPainter.paintBox( scaleWidget, "trough-lower", lowerGroove, state,
+ gtkPainter->paintBox(scaleWidget, "trough-lower", lowerGroove, state,
GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));
}
}
@@ -2599,8 +2644,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
}
proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
}
- gtkPainter.paintSlider( scaleWidget, horizontal ? "hscale" : "vscale", handle, state, shadow, style,
-
+ gtkPainter->paintSlider(scaleWidget, horizontal ? "hscale" : "vscale", handle, state, shadow, style,
horizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
}
painter->setBrush(oldBrush);
@@ -2638,7 +2682,7 @@ void QGtkStyle::drawControl(ControlElement element,
}
GtkStyle* style = d->gtkStyle();
- QGtkPainter gtkPainter(painter);
+ QGtkPainter* gtkPainter = d->gtkPainter(painter);
switch (element) {
case CE_ProgressBarLabel:
@@ -2771,8 +2815,8 @@ void QGtkStyle::drawControl(ControlElement element,
GtkWidget *gtkRadioButton = d->gtkWidget("GtkRadioButton");
if (option->state & State_MouseOver) {
- gtkPainter.paintFlatBox(gtkRadioButton, "checkbutton", option->rect,
- GTK_STATE_PRELIGHT, GTK_SHADOW_ETCHED_OUT, d->gtk_widget_get_style(gtkRadioButton));
+ gtkPainter->paintFlatBox(gtkRadioButton, "checkbutton", option->rect,
+ GTK_STATE_PRELIGHT, GTK_SHADOW_ETCHED_OUT, d->gtk_widget_get_style(gtkRadioButton));
}
QStyleOptionButton subopt = *btn;
@@ -2919,13 +2963,13 @@ void QGtkStyle::drawControl(ControlElement element,
Q_ASSERT(column);
GtkWidget *gtkTreeHeader = column->button;
- GtkStateType state = gtkPainter.gtkState(option);
+ GtkStateType state = qt_gtk_state(option);
GtkShadowType shadow = GTK_SHADOW_OUT;
if (option->state & State_Sunken)
shadow = GTK_SHADOW_IN;
- gtkPainter.paintBox(gtkTreeHeader, "button", option->rect.adjusted(-1, 0, 0, 0), state, shadow, d->gtk_widget_get_style(gtkTreeHeader));
+ gtkPainter->paintBox(gtkTreeHeader, "button", option->rect.adjusted(-1, 0, 0, 0), state, shadow, d->gtk_widget_get_style(gtkTreeHeader));
}
painter->restore();
@@ -2937,9 +2981,9 @@ void QGtkStyle::drawControl(ControlElement element,
GtkWidget *gtkStatusbar = d->gtkWidget("GtkStatusbar.GtkFrame");
GtkStyle *gtkStatusbarStyle = d->gtk_widget_get_style(gtkStatusbar);
QRect gripRect = option->rect.adjusted(0, 0, -gtkStatusbarStyle->xthickness, -gtkStatusbarStyle->ythickness);
- gtkPainter.paintResizeGrip( gtkStatusbar, "statusbar", gripRect, GTK_STATE_NORMAL,
+ gtkPainter->paintResizeGrip(gtkStatusbar, "statusbar", gripRect, GTK_STATE_NORMAL,
GTK_SHADOW_OUT, QApplication::isRightToLeft() ?
- GDK_WINDOW_EDGE_SOUTH_WEST : GDK_WINDOW_EDGE_SOUTH_EAST,
+ GDK_WINDOW_EDGE_SOUTH_WEST : GDK_WINDOW_EDGE_SOUTH_EAST,
gtkStatusbarStyle);
}
break;
@@ -2955,13 +2999,14 @@ void QGtkStyle::drawControl(ControlElement element,
QPixmap pixmap(menuBarRect.size());
pixmap.fill(Qt::transparent);
QPainter pmPainter(&pixmap);
- QGtkPainter gtkMenuBarPainter(&pmPainter);
+ gtkPainter->reset(&pmPainter);
GtkShadowType shadow_type;
d->gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL);
- gtkMenuBarPainter.paintBox( gtkMenubar, "menubar", menuBarRect,
- GTK_STATE_NORMAL, shadow_type, d->gtk_widget_get_style(gtkMenubar));
+ gtkPainter->paintBox(gtkMenubar, "menubar", menuBarRect,
+ GTK_STATE_NORMAL, shadow_type, d->gtk_widget_get_style(gtkMenubar));
pmPainter.end();
painter->drawPixmap(option->rect, pixmap, option->rect);
+ gtkPainter->reset(painter);
}
}
break;
@@ -2984,15 +3029,16 @@ void QGtkStyle::drawControl(ControlElement element,
QPixmap pixmap(menuBarRect.size());
pixmap.fill(Qt::transparent);
QPainter pmPainter(&pixmap);
- QGtkPainter menubarPainter(&pmPainter);
+ gtkPainter->reset(&pmPainter);
GtkShadowType shadow_type;
d->gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL);
GdkColor gdkBg = d->gtk_widget_get_style(gtkMenubar)->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency
painter->fillRect(option->rect, QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8));
- menubarPainter.paintBox(gtkMenubar, "menubar", menuBarRect,
- GTK_STATE_NORMAL, shadow_type, d->gtk_widget_get_style(gtkMenubar));
+ gtkPainter->paintBox(gtkMenubar, "menubar", menuBarRect,
+ GTK_STATE_NORMAL, shadow_type, d->gtk_widget_get_style(gtkMenubar));
pmPainter.end();
painter->drawPixmap(option->rect, pixmap, option->rect);
+ gtkPainter->reset(painter);
}
QStyleOptionMenuItem item = *mbi;
@@ -3011,8 +3057,8 @@ void QGtkStyle::drawControl(ControlElement element,
if (act) {
GtkShadowType shadowType = GTK_SHADOW_NONE;
d->gtk_widget_style_get (gtkMenubarItem, "selected-shadow-type", &shadowType, NULL);
- gtkPainter.paintBox(gtkMenubarItem, "menuitem", option->rect.adjusted(0, 0, 0, 3),
- GTK_STATE_PRELIGHT, shadowType, style);
+ gtkPainter->paintBox(gtkMenubarItem, "menuitem", option->rect.adjusted(0, 0, 0, 3),
+ GTK_STATE_PRELIGHT, shadowType, style);
//draw text
QPalette::ColorRole textRole = dis ? QPalette::Text : QPalette::HighlightedText;
uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
@@ -3028,7 +3074,7 @@ void QGtkStyle::drawControl(ControlElement element,
case CE_Splitter: {
GtkWidget *gtkWindow = d->gtkWidget("GtkWindow"); // The Murrine Engine currently assumes a widget is passed
- gtkPainter.paintHandle(gtkWindow, "splitter", option->rect, gtkPainter.gtkState(option), GTK_SHADOW_NONE,
+ gtkPainter->paintHandle(gtkWindow, "splitter", option->rect, qt_gtk_state(option), GTK_SHADOW_NONE,
!(option->state & State_Horizontal) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL,
style);
}
@@ -3050,7 +3096,7 @@ void QGtkStyle::drawControl(ControlElement element,
GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar");
GtkShadowType shadow_type = GTK_SHADOW_NONE;
d->gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL);
- gtkPainter.paintBox( gtkToolbar, "toolbar", rect,
+ gtkPainter->paintBox(gtkToolbar, "toolbar", rect,
GTK_STATE_NORMAL, shadow_type, d->gtk_widget_get_style(gtkToolbar));
}
break;
@@ -3067,7 +3113,7 @@ void QGtkStyle::drawControl(ControlElement element,
GtkWidget *gtkMenuItem = menuItem->checked ? d->gtkWidget("GtkMenu.GtkCheckMenuItem") :
d->gtkWidget("GtkMenu.GtkMenuItem");
- style = gtkPainter.getStyle(gtkMenuItem);
+ style = d->gtk_widget_get_style(gtkMenuItem);
QColor shadow = option->palette.dark().color();
if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
@@ -3089,10 +3135,10 @@ void QGtkStyle::drawControl(ControlElement element,
separatorRect.setWidth(option->rect.width() - 2 * (horizontal_padding + gtkMenuSeparatorStyle->xthickness));
separatorRect.moveCenter(option->rect.center());
if (wide_separators)
- gtkPainter.paintBox( gtkMenuSeparator, "hseparator",
+ gtkPainter->paintBox(gtkMenuSeparator, "hseparator",
separatorRect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, gtkMenuSeparatorStyle);
else
- gtkPainter.paintHline( gtkMenuSeparator, "hseparator",
+ gtkPainter->paintHline(gtkMenuSeparator, "hseparator",
separatorRect, GTK_STATE_NORMAL, gtkMenuSeparatorStyle,
0, option->rect.right() - 1, 1);
painter->restore();
@@ -3107,7 +3153,7 @@ void QGtkStyle::drawControl(ControlElement element,
if (qobject_cast<const QComboBox*>(widget))
rect = option->rect;
#endif
- gtkPainter.paintBox( gtkMenuItem, "menuitem", rect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style);
+ gtkPainter->paintBox(gtkMenuItem, "menuitem", rect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style);
}
bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable;
@@ -3138,33 +3184,33 @@ void QGtkStyle::drawControl(ControlElement element,
if (menuItem->checkType & QStyleOptionMenuItem::Exclusive) {
// Radio button
GtkShadowType shadow = GTK_SHADOW_OUT;
- GtkStateType state = gtkPainter.gtkState(option);
+ GtkStateType state = qt_gtk_state(option);
if (selected)
state = GTK_STATE_PRELIGHT;
if (checked)
shadow = GTK_SHADOW_IN;
- gtkPainter.setClipRect(checkRect.adjusted(-spacing, -spacing, spacing, spacing));
- gtkPainter.paintOption(gtkMenuItem, checkRect.translated(-spacing, -spacing), state, shadow,
- style, QLS("option"));
- gtkPainter.setClipRect(QRect());
+ gtkPainter->setClipRect(checkRect.adjusted(-spacing, -spacing, spacing, spacing));
+ gtkPainter->paintOption(gtkMenuItem, checkRect.translated(-spacing, -spacing), state, shadow,
+ style, QLS("option"));
+ gtkPainter->setClipRect(QRect());
} else {
// Check box
if (menuItem->icon.isNull()) {
GtkShadowType shadow = GTK_SHADOW_OUT;
- GtkStateType state = gtkPainter.gtkState(option);
+ GtkStateType state = qt_gtk_state(option);
if (selected)
state = GTK_STATE_PRELIGHT;
if (checked)
shadow = GTK_SHADOW_IN;
- gtkPainter.setClipRect(checkRect.adjusted(-spacing, -spacing, -spacing, -spacing));
- gtkPainter.paintCheckbox(gtkMenuItem, checkRect.translated(-spacing, -spacing), state, shadow,
- style, QLS("check"));
- gtkPainter.setClipRect(QRect());
+ gtkPainter->setClipRect(checkRect.adjusted(-spacing, -spacing, -spacing, -spacing));
+ gtkPainter->paintCheckbox(gtkMenuItem, checkRect.translated(-spacing, -spacing), state, shadow,
+ style, QLS("check"));
+ gtkPainter->setClipRect(QRect());
}
}
}
@@ -3316,8 +3362,8 @@ void QGtkStyle::drawControl(ControlElement element,
menuItem->rect.height() / 2 - dim / 2, dim, dim));
GtkStateType state = enabled ? (act ? GTK_STATE_PRELIGHT: GTK_STATE_NORMAL) : GTK_STATE_INSENSITIVE;
GtkShadowType shadowType = (state == GTK_STATE_PRELIGHT) ? GTK_SHADOW_OUT : GTK_SHADOW_IN;
- gtkPainter.paintArrow(gtkMenuItem, "menuitem", vSubMenuRect, QApplication::isRightToLeft() ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT, state,
- shadowType, false, style);
+ gtkPainter->paintArrow(gtkMenuItem, "menuitem", vSubMenuRect, QApplication::isRightToLeft() ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT, state,
+ shadowType, false, style);
}
}
painter->restore();
@@ -3339,10 +3385,10 @@ void QGtkStyle::drawControl(ControlElement element,
// The normal button focus rect does not work well for flat buttons in Clearlooks
proxy()->drawPrimitive(PE_FrameFocusRect, option, painter, widget);
else if (btn->state & State_HasFocus)
- gtkPainter.paintFocus(gtkButton, "button",
- option->rect.adjusted(xt, yt, -xt, -yt),
- btn->state & State_Sunken ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL,
- gtkButtonStyle);
+ gtkPainter->paintFocus(gtkButton, "button",
+ option->rect.adjusted(xt, yt, -xt, -yt),
+ btn->state & State_Sunken ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL,
+ gtkButtonStyle);
proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
}
@@ -3353,7 +3399,7 @@ void QGtkStyle::drawControl(ControlElement element,
case CE_TabBarTabShape:
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook");
- style = gtkPainter.getStyle(gtkNotebook);
+ style = d->gtk_widget_get_style(gtkNotebook);
QRect rect = option->rect;
GtkShadowType shadow = GTK_SHADOW_OUT;
@@ -3381,27 +3427,27 @@ void QGtkStyle::drawControl(ControlElement element,
case QTabBar::RoundedNorth:
if (!selected)
rect.adjust(first ? 0 : -tabOverlap, topIndent, last ? 0 : tabOverlap, -bottomIndent);
- gtkPainter.paintExtention( gtkNotebook, "tab", rect,
+ gtkPainter->paintExtention(gtkNotebook, "tab", rect,
state, shadow, GTK_POS_BOTTOM, style);
break;
case QTabBar::RoundedSouth:
if (!selected)
rect.adjust(first ? 0 : -tabOverlap, 0, last ? 0 : tabOverlap, -topIndent);
- gtkPainter.paintExtention( gtkNotebook, "tab", rect.adjusted(0, 1, 0, 0),
+ gtkPainter->paintExtention(gtkNotebook, "tab", rect.adjusted(0, 1, 0, 0),
state, shadow, GTK_POS_TOP, style);
break;
case QTabBar::RoundedWest:
if (!selected)
rect.adjust(topIndent, 0, -bottomIndent, 0);
- gtkPainter.paintExtention( gtkNotebook, "tab", rect, state, shadow, GTK_POS_RIGHT, style);
+ gtkPainter->paintExtention(gtkNotebook, "tab", rect, state, shadow, GTK_POS_RIGHT, style);
break;
case QTabBar::RoundedEast:
if (!selected)
rect.adjust(bottomIndent, 0, -topIndent, 0);
- gtkPainter.paintExtention( gtkNotebook, "tab", rect, state, shadow, GTK_POS_LEFT, style);
+ gtkPainter->paintExtention(gtkNotebook, "tab", rect, state, shadow, GTK_POS_LEFT, style);
break;
default:
@@ -3420,8 +3466,8 @@ void QGtkStyle::drawControl(ControlElement element,
if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
Q_UNUSED(bar);
GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar");
- GtkStateType state = gtkPainter.gtkState(option);
- gtkPainter.paintBox( gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, d->gtk_widget_get_style(gtkProgressBar));
+ GtkStateType state = qt_gtk_state(option);
+ gtkPainter->paintBox(gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, d->gtk_widget_get_style(gtkProgressBar));
}
break;
@@ -3431,7 +3477,7 @@ void QGtkStyle::drawControl(ControlElement element,
GtkStateType state = option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE;
GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar");
style = d->gtk_widget_get_style(gtkProgressBar);
- gtkPainter.paintBox( gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, style);
+ gtkPainter->paintBox(gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, style);
int xt = style->xthickness;
int yt = style->ythickness;
QRect rect = bar->rect.adjusted(xt, yt, -xt, -yt);
@@ -3477,8 +3523,6 @@ void QGtkStyle::drawControl(ControlElement element,
else if (bar->progress > bar->minimum)
fakePos = maximum - 1;
- d->gtk_progress_configure((GtkProgress*)gtkProgressBar, fakePos, 0, maximum);
-
QRect progressBar;
if (!indeterminate) {
@@ -3501,9 +3545,9 @@ void QGtkStyle::drawControl(ControlElement element,
QString key = QString(QLS("%0")).arg(fakePos);
if (inverted) {
key += QLatin1String("inv");
- gtkPainter.setFlipHorizontal(true);
+ gtkPainter->setFlipHorizontal(true);
}
- gtkPainter.paintBox( gtkProgressBar, "bar", progressBar, GTK_STATE_SELECTED, GTK_SHADOW_OUT, style, key);
+ gtkPainter->paintBox(gtkProgressBar, "bar", progressBar, GTK_STATE_SELECTED, GTK_SHADOW_OUT, style, key);
}
break;
@@ -3762,19 +3806,15 @@ QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComple
case CC_ComboBox:
if (const QStyleOptionComboBox *box = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
// We employ the gtk widget to position arrows and separators for us
- GtkWidget *gtkCombo = box->editable ? d->gtkWidget("GtkComboBoxEntry")
- : d->gtkWidget("GtkComboBox");
+ GtkWidget *gtkCombo = box->editable && QGtkStylePrivate::gtk_combo_box_entry_new ?
+ d->gtkWidget("GtkComboBoxEntry") : d->gtkWidget("GtkComboBox");
d->gtk_widget_set_direction(gtkCombo, (option->direction == Qt::RightToLeft) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
GtkAllocation geometry = {0, 0, qMax(0, option->rect.width()), qMax(0, option->rect.height())};
d->gtk_widget_size_allocate(gtkCombo, &geometry);
int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, option, widget);
- QHashableLatin1Literal arrowPath("GtkComboBoxEntry.GtkToggleButton");
- if (!box->editable) {
- if (appears_as_list)
- arrowPath = "GtkComboBox.GtkToggleButton";
- else
- arrowPath = "GtkComboBox.GtkToggleButton.GtkHBox.GtkArrow";
- }
+ QHashableLatin1Literal arrowPath = box->editable && QGtkStylePrivate::gtk_combo_box_entry_new ?
+ QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton") : box->editable || appears_as_list ?
+ QHashableLatin1Literal("GtkComboBox.GtkToggleButton") : QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkHBox.GtkArrow");
GtkWidget *arrowWidget = d->gtkWidget(arrowPath);
if (!arrowWidget)
@@ -4039,31 +4079,31 @@ QPixmap QGtkStyle::standardPixmap(StandardPixmap sp, const QStyleOption *option,
break;
case SP_DialogDiscardButton:
- return QGtkPainter::getIcon(GTK_STOCK_DELETE);
+ return qt_gtk_get_icon(GTK_STOCK_DELETE);
case SP_DialogOkButton:
- return QGtkPainter::getIcon(GTK_STOCK_OK);
+ return qt_gtk_get_icon(GTK_STOCK_OK);
case SP_DialogCancelButton:
- return QGtkPainter::getIcon(GTK_STOCK_CANCEL);
+ return qt_gtk_get_icon(GTK_STOCK_CANCEL);
case SP_DialogYesButton:
- return QGtkPainter::getIcon(GTK_STOCK_YES);
+ return qt_gtk_get_icon(GTK_STOCK_YES);
case SP_DialogNoButton:
- return QGtkPainter::getIcon(GTK_STOCK_NO);
+ return qt_gtk_get_icon(GTK_STOCK_NO);
case SP_DialogOpenButton:
- return QGtkPainter::getIcon(GTK_STOCK_OPEN);
+ return qt_gtk_get_icon(GTK_STOCK_OPEN);
case SP_DialogCloseButton:
- return QGtkPainter::getIcon(GTK_STOCK_CLOSE);
+ return qt_gtk_get_icon(GTK_STOCK_CLOSE);
case SP_DialogApplyButton:
- return QGtkPainter::getIcon(GTK_STOCK_APPLY);
+ return qt_gtk_get_icon(GTK_STOCK_APPLY);
case SP_DialogSaveButton:
- return QGtkPainter::getIcon(GTK_STOCK_SAVE);
+ return qt_gtk_get_icon(GTK_STOCK_SAVE);
case SP_MessageBoxWarning:
- return QGtkPainter::getIcon(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
+ return qt_gtk_get_icon(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
case SP_MessageBoxQuestion:
- return QGtkPainter::getIcon(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
+ return qt_gtk_get_icon(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
case SP_MessageBoxInformation:
- return QGtkPainter::getIcon(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
+ return qt_gtk_get_icon(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
case SP_MessageBoxCritical:
- return QGtkPainter::getIcon(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
+ return qt_gtk_get_icon(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
default:
return QCommonStyle::standardPixmap(sp, option, widget);
}
@@ -4083,31 +4123,31 @@ QIcon QGtkStyle::standardIcon(StandardPixmap standardIcon,
return QCommonStyle::standardIcon(standardIcon, option, widget);
switch (standardIcon) {
case SP_DialogDiscardButton:
- return QGtkPainter::getIcon(GTK_STOCK_DELETE);
+ return qt_gtk_get_icon(GTK_STOCK_DELETE);
case SP_DialogOkButton:
- return QGtkPainter::getIcon(GTK_STOCK_OK);
+ return qt_gtk_get_icon(GTK_STOCK_OK);
case SP_DialogCancelButton:
- return QGtkPainter::getIcon(GTK_STOCK_CANCEL);
+ return qt_gtk_get_icon(GTK_STOCK_CANCEL);
case SP_DialogYesButton:
- return QGtkPainter::getIcon(GTK_STOCK_YES);
+ return qt_gtk_get_icon(GTK_STOCK_YES);
case SP_DialogNoButton:
- return QGtkPainter::getIcon(GTK_STOCK_NO);
+ return qt_gtk_get_icon(GTK_STOCK_NO);
case SP_DialogOpenButton:
- return QGtkPainter::getIcon(GTK_STOCK_OPEN);
+ return qt_gtk_get_icon(GTK_STOCK_OPEN);
case SP_DialogCloseButton:
- return QGtkPainter::getIcon(GTK_STOCK_CLOSE);
+ return qt_gtk_get_icon(GTK_STOCK_CLOSE);
case SP_DialogApplyButton:
- return QGtkPainter::getIcon(GTK_STOCK_APPLY);
+ return qt_gtk_get_icon(GTK_STOCK_APPLY);
case SP_DialogSaveButton:
- return QGtkPainter::getIcon(GTK_STOCK_SAVE);
+ return qt_gtk_get_icon(GTK_STOCK_SAVE);
case SP_MessageBoxWarning:
- return QGtkPainter::getIcon(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
+ return qt_gtk_get_icon(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
case SP_MessageBoxQuestion:
- return QGtkPainter::getIcon(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
+ return qt_gtk_get_icon(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
case SP_MessageBoxInformation:
- return QGtkPainter::getIcon(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
+ return qt_gtk_get_icon(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
case SP_MessageBoxCritical:
- return QGtkPainter::getIcon(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
+ return qt_gtk_get_icon(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
default:
return QCommonStyle::standardIcon(standardIcon, option, widget);
}
diff --git a/src/widgets/styles/qgtkstyle_p.cpp b/src/widgets/styles/qgtkstyle_p.cpp
index 3bd5688f31..57f0ee0161 100644
--- a/src/widgets/styles/qgtkstyle_p.cpp
+++ b/src/widgets/styles/qgtkstyle_p.cpp
@@ -62,6 +62,7 @@
#include <QtCore/QLibrary>
#include <QtCore/QDebug>
+#include <private/qgtk2painter_p.h>
#include <private/qapplication_p.h>
#include <private/qiconloader_p.h>
@@ -130,10 +131,10 @@ Ptr_gtk_separator_tool_item_new QGtkStylePrivate::gtk_separator_tool_item_new =
Ptr_gtk_tree_view_new QGtkStylePrivate::gtk_tree_view_new = 0;
Ptr_gtk_combo_box_new QGtkStylePrivate::gtk_combo_box_new = 0;
Ptr_gtk_combo_box_entry_new QGtkStylePrivate::gtk_combo_box_entry_new = 0;
+Ptr_gtk_combo_box_new_with_entry QGtkStylePrivate::gtk_combo_box_new_with_entry = 0;
Ptr_gtk_progress_bar_new QGtkStylePrivate::gtk_progress_bar_new = 0;
Ptr_gtk_container_add QGtkStylePrivate::gtk_container_add = 0;
Ptr_gtk_menu_shell_append QGtkStylePrivate::gtk_menu_shell_append = 0;
-Ptr_gtk_progress_configure QGtkStylePrivate::gtk_progress_configure = 0;
Ptr_gtk_range_get_adjustment QGtkStylePrivate::gtk_range_get_adjustment = 0;
Ptr_gtk_range_set_adjustment QGtkStylePrivate::gtk_range_set_adjustment = 0;
Ptr_gtk_range_set_inverted QGtkStylePrivate::gtk_range_set_inverted = 0;
@@ -146,23 +147,8 @@ Ptr_gtk_fixed_new QGtkStylePrivate::gtk_fixed_new = 0;
Ptr_gtk_tree_view_column_new QGtkStylePrivate::gtk_tree_view_column_new = 0;
Ptr_gtk_tree_view_get_column QGtkStylePrivate::gtk_tree_view_get_column = 0;
Ptr_gtk_tree_view_append_column QGtkStylePrivate::gtk_tree_view_append_column = 0;
-Ptr_gtk_paint_check QGtkStylePrivate::gtk_paint_check = 0;
-Ptr_gtk_paint_box QGtkStylePrivate::gtk_paint_box = 0;
-Ptr_gtk_paint_box_gap QGtkStylePrivate::gtk_paint_box_gap = 0;
-Ptr_gtk_paint_flat_box QGtkStylePrivate::gtk_paint_flat_box = 0;
-Ptr_gtk_paint_option QGtkStylePrivate::gtk_paint_option = 0;
-Ptr_gtk_paint_extension QGtkStylePrivate::gtk_paint_extension = 0;
-Ptr_gtk_paint_slider QGtkStylePrivate::gtk_paint_slider = 0;
-Ptr_gtk_paint_shadow QGtkStylePrivate::gtk_paint_shadow = 0;
-Ptr_gtk_paint_resize_grip QGtkStylePrivate::gtk_paint_resize_grip = 0;
-Ptr_gtk_paint_focus QGtkStylePrivate::gtk_paint_focus = 0;
-Ptr_gtk_paint_arrow QGtkStylePrivate::gtk_paint_arrow = 0;
-Ptr_gtk_paint_handle QGtkStylePrivate::gtk_paint_handle = 0;
-Ptr_gtk_paint_expander QGtkStylePrivate::gtk_paint_expander = 0;
Ptr_gtk_adjustment_configure QGtkStylePrivate::gtk_adjustment_configure = 0;
Ptr_gtk_adjustment_new QGtkStylePrivate::gtk_adjustment_new = 0;
-Ptr_gtk_paint_hline QGtkStylePrivate::gtk_paint_hline = 0;
-Ptr_gtk_paint_vline QGtkStylePrivate::gtk_paint_vline = 0;
Ptr_gtk_menu_item_set_submenu QGtkStylePrivate::gtk_menu_item_set_submenu = 0;
Ptr_gtk_settings_get_default QGtkStylePrivate::gtk_settings_get_default = 0;
Ptr_gtk_separator_menu_item_new QGtkStylePrivate::gtk_separator_menu_item_new = 0;
@@ -175,11 +161,18 @@ Ptr_gtk_window_get_type QGtkStylePrivate::gtk_window_get_type = 0;
Ptr_gtk_widget_get_type QGtkStylePrivate::gtk_widget_get_type = 0;
Ptr_gtk_widget_get_parent QGtkStylePrivate::gtk_widget_get_parent = 0;
Ptr_gtk_widget_is_toplevel QGtkStylePrivate::gtk_widget_is_toplevel = 0;
+Ptr_gtk_widget_get_toplevel QGtkStylePrivate::gtk_widget_get_toplevel = 0;
Ptr_gtk_rc_get_style_by_paths QGtkStylePrivate::gtk_rc_get_style_by_paths = 0;
Ptr_gtk_check_version QGtkStylePrivate::gtk_check_version = 0;
Ptr_gtk_border_free QGtkStylePrivate::gtk_border_free = 0;
Ptr_gtk_widget_get_allocation QGtkStylePrivate::gtk_widget_get_allocation = 0;
Ptr_gtk_widget_set_allocation QGtkStylePrivate::gtk_widget_set_allocation = 0;
+Ptr_gtk_widget_set_can_default QGtkStylePrivate::gtk_widget_set_can_default = 0;
+Ptr_gtk_window_set_default QGtkStylePrivate::gtk_window_set_default = 0;
+
+Ptr_gdk_event_new QGtkStylePrivate::gdk_event_new = 0;
+Ptr_gdk_event_free QGtkStylePrivate::gdk_event_free = 0;
+Ptr_gtk_widget_send_focus_change QGtkStylePrivate::gtk_widget_send_focus_change = 0;
Ptr_pango_font_description_get_size QGtkStylePrivate::pango_font_description_get_size = 0;
Ptr_pango_font_description_get_weight QGtkStylePrivate::pango_font_description_get_weight = 0;
@@ -203,12 +196,8 @@ Ptr_gtk_file_chooser_set_filename QGtkStylePrivate::gtk_file_chooser_set_filenam
Ptr_gdk_pixbuf_get_pixels QGtkStylePrivate::gdk_pixbuf_get_pixels = 0;
Ptr_gdk_pixbuf_get_width QGtkStylePrivate::gdk_pixbuf_get_width = 0;
Ptr_gdk_pixbuf_get_height QGtkStylePrivate::gdk_pixbuf_get_height = 0;
-Ptr_gdk_pixmap_new QGtkStylePrivate::gdk_pixmap_new = 0;
Ptr_gdk_pixbuf_new QGtkStylePrivate::gdk_pixbuf_new = 0;
-Ptr_gdk_pixbuf_get_from_drawable QGtkStylePrivate::gdk_pixbuf_get_from_drawable = 0;
-Ptr_gdk_draw_rectangle QGtkStylePrivate::gdk_draw_rectangle = 0;
Ptr_gdk_pixbuf_unref QGtkStylePrivate::gdk_pixbuf_unref = 0;
-Ptr_gdk_drawable_unref QGtkStylePrivate::gdk_drawable_unref = 0;
Ptr_gdk_color_free QGtkStylePrivate::gdk_color_free = 0;
Ptr_gdk_x11_window_set_user_time QGtkStylePrivate::gdk_x11_window_set_user_time = 0;
Ptr_gdk_x11_drawable_get_xid QGtkStylePrivate::gdk_x11_drawable_get_xid = 0;
@@ -307,6 +296,14 @@ void QGtkStylePrivate::init()
initGtkWidgets();
}
+QGtkPainter* QGtkStylePrivate::gtkPainter(QPainter *painter)
+{
+ // TODO: choose between gtk2 and gtk3
+ static QGtk2Painter instance;
+ instance.reset(painter);
+ return &instance;
+}
+
GtkWidget* QGtkStylePrivate::gtkWidget(const QHashableLatin1Literal &path)
{
GtkWidget *widget = gtkWidgetMap()->value(path);
@@ -324,6 +321,24 @@ GtkStyle* QGtkStylePrivate::gtkStyle(const QHashableLatin1Literal &path)
return 0;
}
+void QGtkStylePrivate::gtkWidgetSetFocus(GtkWidget *widget, bool focus)
+{
+ if (QGtkStylePrivate::gtk_widget_send_focus_change) {
+ GdkEvent *event = QGtkStylePrivate::gdk_event_new(GDK_FOCUS_CHANGE);
+ event->focus_change.type = GDK_FOCUS_CHANGE;
+ event->focus_change.in = focus;
+ QGtkStylePrivate::gtk_widget_send_focus_change(widget, event);
+ QGtkStylePrivate::gdk_event_free(event);
+ } else {
+#if defined(GTK_WIDGET_SET_FLAGS) && defined(GTK_WIDGET_UNSET_FLAGS)
+ if (focus)
+ GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS);
+ else
+ GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS);
+#endif
+ }
+}
+
/*! \internal
* Get references to gtk functions after we dynamically load the library.
*/
@@ -356,12 +371,8 @@ void QGtkStylePrivate::resolveGtk() const
gdk_pixbuf_get_pixels = (Ptr_gdk_pixbuf_get_pixels)libgtk.resolve("gdk_pixbuf_get_pixels");
gdk_pixbuf_get_width = (Ptr_gdk_pixbuf_get_width)libgtk.resolve("gdk_pixbuf_get_width");
gdk_pixbuf_get_height = (Ptr_gdk_pixbuf_get_height)libgtk.resolve("gdk_pixbuf_get_height");
- gdk_pixmap_new = (Ptr_gdk_pixmap_new)libgtk.resolve("gdk_pixmap_new");
gdk_pixbuf_new = (Ptr_gdk_pixbuf_new)libgtk.resolve("gdk_pixbuf_new");
- gdk_pixbuf_get_from_drawable = (Ptr_gdk_pixbuf_get_from_drawable)libgtk.resolve("gdk_pixbuf_get_from_drawable");
- gdk_draw_rectangle = (Ptr_gdk_draw_rectangle)libgtk.resolve("gdk_draw_rectangle");
gdk_pixbuf_unref = (Ptr_gdk_pixbuf_unref)libgtk.resolve("gdk_pixbuf_unref");
- gdk_drawable_unref = (Ptr_gdk_drawable_unref)libgtk.resolve("gdk_drawable_unref");
gdk_color_free = (Ptr_gdk_color_free)libgtk.resolve("gdk_color_free");
gdk_x11_window_set_user_time = (Ptr_gdk_x11_window_set_user_time)libgtk.resolve("gdk_x11_window_set_user_time");
gdk_x11_drawable_get_xid = (Ptr_gdk_x11_drawable_get_xid)libgtk.resolve("gdk_x11_drawable_get_xid");
@@ -395,7 +406,8 @@ void QGtkStylePrivate::resolveGtk() const
gtk_entry_new = (Ptr_gtk_entry_new)libgtk.resolve("gtk_entry_new");
gtk_tree_view_new = (Ptr_gtk_tree_view_new)libgtk.resolve("gtk_tree_view_new");
gtk_combo_box_new = (Ptr_gtk_combo_box_new)libgtk.resolve("gtk_combo_box_new");
- gtk_progress_configure = (Ptr_gtk_progress_configure)libgtk.resolve("gtk_progress_configure");
+ gtk_combo_box_entry_new = (Ptr_gtk_combo_box_entry_new)libgtk.resolve("gtk_combo_box_entry_new");
+ gtk_combo_box_new_with_entry = (Ptr_gtk_combo_box_entry_new)libgtk.resolve("gtk_combo_box_new_with_entry");
gtk_range_get_adjustment = (Ptr_gtk_range_get_adjustment)libgtk.resolve("gtk_range_get_adjustment");
gtk_range_set_adjustment = (Ptr_gtk_range_set_adjustment)libgtk.resolve("gtk_range_set_adjustment");
gtk_range_set_inverted = (Ptr_gtk_range_set_inverted)libgtk.resolve("gtk_range_set_inverted");
@@ -409,23 +421,6 @@ void QGtkStylePrivate::resolveGtk() const
gtk_tree_view_column_new = (Ptr_gtk_tree_view_column_new)libgtk.resolve("gtk_tree_view_column_new");
gtk_tree_view_append_column= (Ptr_gtk_tree_view_append_column )libgtk.resolve("gtk_tree_view_append_column");
gtk_tree_view_get_column = (Ptr_gtk_tree_view_get_column )libgtk.resolve("gtk_tree_view_get_column");
- gtk_paint_check = (Ptr_gtk_paint_check)libgtk.resolve("gtk_paint_check");
- gtk_paint_box = (Ptr_gtk_paint_box)libgtk.resolve("gtk_paint_box");
- gtk_paint_flat_box = (Ptr_gtk_paint_flat_box)libgtk.resolve("gtk_paint_flat_box");
- gtk_paint_check = (Ptr_gtk_paint_check)libgtk.resolve("gtk_paint_check");
- gtk_paint_box = (Ptr_gtk_paint_box)libgtk.resolve("gtk_paint_box");
- gtk_paint_resize_grip = (Ptr_gtk_paint_resize_grip)libgtk.resolve("gtk_paint_resize_grip");
- gtk_paint_focus = (Ptr_gtk_paint_focus)libgtk.resolve("gtk_paint_focus");
- gtk_paint_shadow = (Ptr_gtk_paint_shadow)libgtk.resolve("gtk_paint_shadow");
- gtk_paint_slider = (Ptr_gtk_paint_slider)libgtk.resolve("gtk_paint_slider");
- gtk_paint_expander = (Ptr_gtk_paint_expander)libgtk.resolve("gtk_paint_expander");
- gtk_paint_handle = (Ptr_gtk_paint_handle)libgtk.resolve("gtk_paint_handle");
- gtk_paint_option = (Ptr_gtk_paint_option)libgtk.resolve("gtk_paint_option");
- gtk_paint_arrow = (Ptr_gtk_paint_arrow)libgtk.resolve("gtk_paint_arrow");
- gtk_paint_box_gap = (Ptr_gtk_paint_box_gap)libgtk.resolve("gtk_paint_box_gap");
- gtk_paint_extension = (Ptr_gtk_paint_extension)libgtk.resolve("gtk_paint_extension");
- gtk_paint_hline = (Ptr_gtk_paint_hline)libgtk.resolve("gtk_paint_hline");
- gtk_paint_vline = (Ptr_gtk_paint_vline)libgtk.resolve("gtk_paint_vline");
gtk_adjustment_configure = (Ptr_gtk_adjustment_configure)libgtk.resolve("gtk_adjustment_configure");
gtk_adjustment_new = (Ptr_gtk_adjustment_new)libgtk.resolve("gtk_adjustment_new");
gtk_menu_item_set_submenu = (Ptr_gtk_menu_item_set_submenu)libgtk.resolve("gtk_menu_item_set_submenu");
@@ -434,7 +429,6 @@ void QGtkStylePrivate::resolveGtk() const
gtk_frame_new = (Ptr_gtk_frame_new)libgtk.resolve("gtk_frame_new");
gtk_expander_new = (Ptr_gtk_expander_new)libgtk.resolve("gtk_expander_new");
gtk_statusbar_new = (Ptr_gtk_statusbar_new)libgtk.resolve("gtk_statusbar_new");
- gtk_combo_box_entry_new = (Ptr_gtk_combo_box_entry_new)libgtk.resolve("gtk_combo_box_entry_new");
gtk_container_forall = (Ptr_gtk_container_forall)libgtk.resolve("gtk_container_forall");
gtk_widget_size_allocate =(Ptr_gtk_widget_size_allocate)libgtk.resolve("gtk_widget_size_allocate");
gtk_widget_size_request =(Ptr_gtk_widget_size_request)libgtk.resolve("gtk_widget_size_request");
@@ -445,6 +439,7 @@ void QGtkStylePrivate::resolveGtk() const
gtk_widget_get_type =(Ptr_gtk_widget_get_type)libgtk.resolve("gtk_widget_get_type");
gtk_widget_get_parent =(Ptr_gtk_widget_get_parent)libgtk.resolve("gtk_widget_get_parent");
gtk_widget_is_toplevel =(Ptr_gtk_widget_is_toplevel)libgtk.resolve("gtk_widget_is_toplevel");
+ gtk_widget_get_toplevel =(Ptr_gtk_widget_get_toplevel)libgtk.resolve("gtk_widget_get_toplevel");
gtk_rc_get_style_by_paths =(Ptr_gtk_rc_get_style_by_paths)libgtk.resolve("gtk_rc_get_style_by_paths");
gtk_check_version =(Ptr_gtk_check_version)libgtk.resolve("gtk_check_version");
@@ -452,6 +447,13 @@ void QGtkStylePrivate::resolveGtk() const
gtk_widget_get_allocation = (Ptr_gtk_widget_get_allocation)libgtk.resolve("gtk_widget_get_allocation");
gtk_widget_set_allocation = (Ptr_gtk_widget_set_allocation)libgtk.resolve("gtk_widget_set_allocation");
+ gtk_widget_set_can_default = (Ptr_gtk_widget_set_can_default)libgtk.resolve("gtk_widget_set_can_default");
+ gtk_window_set_default = (Ptr_gtk_window_set_default)libgtk.resolve("gtk_window_set_default");
+
+ gdk_event_new = (Ptr_gdk_event_new)libgtk.resolve("gdk_event_new");
+ gdk_event_free = (Ptr_gdk_event_free)libgtk.resolve("gdk_event_free");
+ gtk_widget_send_focus_change = (Ptr_gtk_widget_send_focus_change)libgtk.resolve("gtk_widget_send_focus_change");
+
pango_font_description_get_size = (Ptr_pango_font_description_get_size)libgtk.resolve("pango_font_description_get_size");
pango_font_description_get_weight = (Ptr_pango_font_description_get_weight)libgtk.resolve("pango_font_description_get_weight");
pango_font_description_get_family = (Ptr_pango_font_description_get_family)libgtk.resolve("pango_font_description_get_family");
@@ -565,26 +567,28 @@ void QGtkStylePrivate::initGtkWidgets() const
addWidget(QGtkStylePrivate::gtk_check_button_new());
addWidget(QGtkStylePrivate::gtk_radio_button_new(NULL));
addWidget(QGtkStylePrivate::gtk_combo_box_new());
- addWidget(QGtkStylePrivate::gtk_combo_box_entry_new());
+ if (gtk_combo_box_entry_new)
+ addWidget(QGtkStylePrivate::gtk_combo_box_entry_new());
+ if (gtk_combo_box_new_with_entry)
+ addWidget(QGtkStylePrivate::gtk_combo_box_new_with_entry());
addWidget(QGtkStylePrivate::gtk_entry_new());
addWidget(QGtkStylePrivate::gtk_frame_new(NULL));
addWidget(QGtkStylePrivate::gtk_expander_new(""));
addWidget(QGtkStylePrivate::gtk_statusbar_new());
- addWidget(QGtkStylePrivate::gtk_hscale_new((GtkAdjustment*)(QGtkStylePrivate::gtk_adjustment_new(1, 0, 1, 0, 0, 0))));
+ addWidget(QGtkStylePrivate::gtk_hscale_new((QGtkStylePrivate::gtk_adjustment_new(1, 0, 1, 0, 0, 0))));
addWidget(QGtkStylePrivate::gtk_hscrollbar_new(NULL));
addWidget(QGtkStylePrivate::gtk_scrolled_window_new(NULL, NULL));
initGtkMenu();
addWidget(QGtkStylePrivate::gtk_notebook_new());
addWidget(QGtkStylePrivate::gtk_progress_bar_new());
- addWidget(QGtkStylePrivate::gtk_spin_button_new((GtkAdjustment*)
- (QGtkStylePrivate::gtk_adjustment_new(1, 0, 1, 0, 0, 0)), 0.1, 3));
+ addWidget(QGtkStylePrivate::gtk_spin_button_new((QGtkStylePrivate::gtk_adjustment_new(1, 0, 1, 0, 0, 0)), 0.1, 3));
GtkWidget *toolbar = gtk_toolbar_new();
g_signal_connect (toolbar, "notify::toolbar-style", G_CALLBACK (update_toolbar_style), toolbar);
gtk_toolbar_insert((GtkToolbar*)toolbar, gtk_separator_tool_item_new(), -1);
addWidget(toolbar);
initGtkTreeview();
- addWidget(gtk_vscale_new((GtkAdjustment*)(QGtkStylePrivate::gtk_adjustment_new(1, 0, 1, 0, 0, 0))));
+ addWidget(gtk_vscale_new((QGtkStylePrivate::gtk_adjustment_new(1, 0, 1, 0, 0, 0))));
addWidget(gtk_vscrollbar_new(NULL));
}
else // Rebuild map
@@ -796,7 +800,7 @@ void QGtkStylePrivate::addAllSubWidgets(GtkWidget *widget, gpointer v)
{
Q_UNUSED(v);
addWidgetToMap(widget);
- if (GTK_CHECK_TYPE ((widget), gtk_container_get_type()))
+ if (G_TYPE_CHECK_INSTANCE_TYPE ((widget), gtk_container_get_type()))
gtk_container_forall((GtkContainer*)widget, addAllSubWidgets, NULL);
}
diff --git a/src/widgets/styles/qgtkstyle_p.h b/src/widgets/styles/qgtkstyle_p.h
index 71c70c41f1..fc911f68a5 100644
--- a/src/widgets/styles/qgtkstyle_p.h
+++ b/src/widgets/styles/qgtkstyle_p.h
@@ -64,17 +64,9 @@
#include <QtWidgets/QGtkStyle>
#include <private/qcommonstyle_p.h>
+#include <private/qgtkglobal_p.h>
-#undef signals // Collides with GTK symbols
-#include <gtk/gtk.h>
-
-typedef unsigned long XID;
-
-#undef GTK_OBJECT_FLAGS
-#define GTK_OBJECT_FLAGS(obj)(((GtkObject*)(obj))->flags)
-#define Q_GTK_IS_WIDGET(widget) widget && GTK_CHECK_TYPE ((widget), QGtkStylePrivate::gtk_widget_get_type())
-
-#define QLS(x) QLatin1String(x)
+#define Q_GTK_IS_WIDGET(widget) widget && G_TYPE_CHECK_INSTANCE_TYPE ((widget), QGtkStylePrivate::gtk_widget_get_type())
QT_BEGIN_NAMESPACE
@@ -149,7 +141,9 @@ typedef GtkWidget* (*Ptr_gtk_separator_menu_item_new)(void);
typedef GtkWidget* (*Ptr_gtk_check_menu_item_new_with_label)(const gchar *);
typedef GtkWidget* (*Ptr_gtk_menu_bar_new)(void);
typedef GtkWidget* (*Ptr_gtk_menu_new)(void);
+typedef GtkWidget* (*Ptr_gtk_combo_box_new)(void);
typedef GtkWidget* (*Ptr_gtk_combo_box_entry_new)(void);
+typedef GtkWidget* (*Ptr_gtk_combo_box_new_with_entry)(void);
typedef GtkWidget* (*Ptr_gtk_toolbar_new)(void);
typedef GtkWidget* (*Ptr_gtk_spin_button_new)(GtkAdjustment*, double, int);
typedef GtkWidget* (*Ptr_gtk_button_new)(void);
@@ -169,14 +163,12 @@ typedef GtkToolItem* (*Ptr_gtk_separator_tool_item_new) (void);
typedef GtkWidget* (*Ptr_gtk_entry_new)(void);
typedef GtkWidget* (*Ptr_gtk_tree_view_new)(void);
typedef GtkTreeViewColumn* (*Ptr_gtk_tree_view_get_column)(GtkTreeView *, gint);
-typedef GtkWidget* (*Ptr_gtk_combo_box_new)(void);
typedef GtkWidget* (*Ptr_gtk_frame_new)(const gchar *);
typedef GtkWidget* (*Ptr_gtk_expander_new)(const gchar*);
typedef GtkWidget* (*Ptr_gtk_statusbar_new)(void);
typedef GtkSettings* (*Ptr_gtk_settings_get_default)(void);
typedef GtkAdjustment* (*Ptr_gtk_range_get_adjustment)(GtkRange *);
typedef void (*Ptr_gtk_range_set_adjustment)(GtkRange *, GtkAdjustment *);
-typedef void (*Ptr_gtk_progress_configure)(GtkProgress *, double, double, double);
typedef void (*Ptr_gtk_range_set_inverted)(GtkRange*, bool);
typedef void (*Ptr_gtk_container_add)(GtkContainer *container, GtkWidget *widget);
typedef GtkIconSet* (*Ptr_gtk_icon_factory_lookup_default) (const gchar*);
@@ -187,23 +179,8 @@ typedef GtkTreeViewColumn* (*Ptr_gtk_tree_view_column_new)(void);
typedef GtkWidget* (*Ptr_gtk_fixed_new)(void);
typedef GdkPixbuf* (*Ptr_gtk_icon_set_render_icon)(GtkIconSet *, GtkStyle *, GtkTextDirection, GtkStateType, GtkIconSize, GtkWidget *,const char *);
typedef void (*Ptr_gtk_tree_view_append_column) (GtkTreeView*, GtkTreeViewColumn*);
-typedef void (*Ptr_gtk_paint_check) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_box) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_box_gap) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint , gint, GtkPositionType, gint gap_x, gint gap_width);
-typedef void (*Ptr_gtk_paint_resize_grip) (GtkStyle*,GdkWindow*, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, GdkWindowEdge, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_focus) (GtkStyle*,GdkWindow*, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_shadow) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_slider) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint, GtkOrientation);
-typedef void (*Ptr_gtk_paint_expander) (GtkStyle*,GdkWindow*, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , GtkExpanderStyle );
-typedef void (*Ptr_gtk_paint_handle) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint, GtkOrientation);
-typedef void (*Ptr_gtk_paint_arrow) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, GtkArrowType, gboolean, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_option) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_flat_box) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_extension) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint, gint, GtkPositionType);
typedef void (*Ptr_gtk_adjustment_configure) (GtkAdjustment *, double, double, double, double, double, double);
-typedef GtkObject* (*Ptr_gtk_adjustment_new) (double, double, double, double, double, double);
-typedef void (*Ptr_gtk_paint_hline) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint y);
-typedef void (*Ptr_gtk_paint_vline) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint);
+typedef GtkAdjustment* (*Ptr_gtk_adjustment_new) (double, double, double, double, double, double);
typedef void (*Ptr_gtk_menu_item_set_submenu) (GtkMenuItem *, GtkWidget *);
typedef void (*Ptr_gtk_container_forall) (GtkContainer *, GtkCallback, gpointer);
typedef void (*Ptr_gtk_widget_size_allocate) (GtkWidget *, GtkAllocation*);
@@ -213,11 +190,12 @@ typedef void (*Ptr_gtk_widget_path) (GtkWidget *, guint *, gchar **, gchar**);
typedef void (*Ptr_gtk_toolbar_insert) (GtkToolbar *toolbar, GtkToolItem *item, int pos);
typedef void (*Ptr_gtk_menu_shell_append)(GtkMenuShell *, GtkWidget *);
-typedef GtkType (*Ptr_gtk_container_get_type) (void);
-typedef GtkType (*Ptr_gtk_window_get_type) (void);
-typedef GtkType (*Ptr_gtk_widget_get_type) (void);
+typedef GType (*Ptr_gtk_container_get_type) (void);
+typedef GType (*Ptr_gtk_window_get_type) (void);
+typedef GType (*Ptr_gtk_widget_get_type) (void);
typedef GtkWidget* (*Ptr_gtk_widget_get_parent) (GtkWidget *);
typedef gboolean (*Ptr_gtk_widget_is_toplevel) (GtkWidget *);
+typedef GtkWidget* (*Ptr_gtk_widget_get_toplevel) (GtkWidget *);
typedef GtkStyle* (*Ptr_gtk_rc_get_style_by_paths) (GtkSettings *, const char *, const char *, GType);
typedef gint (*Ptr_pango_font_description_get_size) (const PangoFontDescription *);
typedef PangoWeight (*Ptr_pango_font_description_get_weight) (const PangoFontDescription *);
@@ -244,21 +222,20 @@ typedef void (*Ptr_gtk_border_free)(GtkBorder *);
typedef void (*Ptr_gtk_widget_get_allocation) (GtkWidget*, GtkAllocation*);
typedef void (*Ptr_gtk_widget_set_allocation) (GtkWidget*, const GtkAllocation*);
+typedef void (*Ptr_gtk_widget_set_can_default) (GtkWidget*, gboolean);
+typedef void (*Ptr_gtk_window_set_default) (GtkWindow*, GtkWidget*);
+
+typedef GdkEvent* (*Ptr_gdk_event_new) (GdkEventType);
+typedef void (*Ptr_gdk_event_free) (GdkEvent*);
+typedef void (*Ptr_gtk_widget_send_focus_change) (GtkWidget*, GdkEvent*);
+
typedef guchar* (*Ptr_gdk_pixbuf_get_pixels) (const GdkPixbuf *pixbuf);
typedef int (*Ptr_gdk_pixbuf_get_width) (const GdkPixbuf *pixbuf);
typedef void (*Ptr_gdk_color_free) (const GdkColor *);
typedef int (*Ptr_gdk_pixbuf_get_height) (const GdkPixbuf *pixbuf);
-typedef GdkPixbuf* (*Ptr_gdk_pixbuf_get_from_drawable) (GdkPixbuf *dest, GdkDrawable *src,
- GdkColormap *cmap, int src_x,
- int src_y, int dest_x, int dest_y,
- int width, int height);
-typedef GdkPixmap* (*Ptr_gdk_pixmap_new) (GdkDrawable *drawable, gint width, gint height, gint depth);
typedef GdkPixbuf* (*Ptr_gdk_pixbuf_new) (GdkColorspace colorspace, gboolean has_alpha,
- int bits_per_sample, int width, int height);
-typedef void (*Ptr_gdk_draw_rectangle) (GdkDrawable *drawable, GdkGC *gc,
- gboolean filled, gint x, gint y, gint width, gint height);
+ int bits_per_sample, int width, int height);
typedef void (*Ptr_gdk_pixbuf_unref)(GdkPixbuf *);
-typedef void (*Ptr_gdk_drawable_unref)(GdkDrawable *);
typedef void (*Ptr_gdk_x11_window_set_user_time) (GdkWindow *window, guint32);
typedef XID (*Ptr_gdk_x11_drawable_get_xid) (GdkDrawable *);
typedef Display* (*Ptr_gdk_x11_drawable_get_xdisplay) ( GdkDrawable *);
@@ -282,6 +259,7 @@ extern Q_WIDGETS_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_fil
extern Q_WIDGETS_EXPORT _qt_filedialog_existing_directory_hook qt_filedialog_existing_directory_hook;
#endif //!QT_NO_FILEDIALOG
+class QGtkPainter;
class QGtkStylePrivate;
class QGtkStyleFilter : public QObject
@@ -326,8 +304,10 @@ public:
QGtkStyleFilter filter;
+ static QGtkPainter* gtkPainter(QPainter *painter = 0);
static GtkWidget* gtkWidget(const QHashableLatin1Literal &path);
static GtkStyle* gtkStyle(const QHashableLatin1Literal &path = QHashableLatin1Literal("GtkWindow"));
+ static void gtkWidgetSetFocus(GtkWidget *widget, bool focus);
virtual void resolveGtk() const;
virtual void initGtkMenu() const;
@@ -400,10 +380,10 @@ public:
static Ptr_gtk_tree_view_get_column gtk_tree_view_get_column;
static Ptr_gtk_combo_box_new gtk_combo_box_new;
static Ptr_gtk_combo_box_entry_new gtk_combo_box_entry_new;
+ static Ptr_gtk_combo_box_new_with_entry gtk_combo_box_new_with_entry;
static Ptr_gtk_progress_bar_new gtk_progress_bar_new;
static Ptr_gtk_container_add gtk_container_add;
static Ptr_gtk_menu_shell_append gtk_menu_shell_append;
- static Ptr_gtk_progress_configure gtk_progress_configure;
static Ptr_gtk_range_get_adjustment gtk_range_get_adjustment;
static Ptr_gtk_range_set_adjustment gtk_range_set_adjustment;
static Ptr_gtk_range_set_inverted gtk_range_set_inverted;
@@ -415,23 +395,8 @@ public:
static Ptr_gtk_fixed_new gtk_fixed_new;
static Ptr_gtk_tree_view_column_new gtk_tree_view_column_new;
static Ptr_gtk_tree_view_append_column gtk_tree_view_append_column;
- static Ptr_gtk_paint_check gtk_paint_check;
- static Ptr_gtk_paint_box gtk_paint_box;
- static Ptr_gtk_paint_box_gap gtk_paint_box_gap;
- static Ptr_gtk_paint_flat_box gtk_paint_flat_box;
- static Ptr_gtk_paint_option gtk_paint_option;
- static Ptr_gtk_paint_extension gtk_paint_extension;
- static Ptr_gtk_paint_slider gtk_paint_slider;
- static Ptr_gtk_paint_shadow gtk_paint_shadow;
- static Ptr_gtk_paint_resize_grip gtk_paint_resize_grip;
- static Ptr_gtk_paint_focus gtk_paint_focus;
- static Ptr_gtk_paint_arrow gtk_paint_arrow;
- static Ptr_gtk_paint_handle gtk_paint_handle;
- static Ptr_gtk_paint_expander gtk_paint_expander;
static Ptr_gtk_adjustment_configure gtk_adjustment_configure;
static Ptr_gtk_adjustment_new gtk_adjustment_new;
- static Ptr_gtk_paint_vline gtk_paint_vline;
- static Ptr_gtk_paint_hline gtk_paint_hline;
static Ptr_gtk_menu_item_set_submenu gtk_menu_item_set_submenu;
static Ptr_gtk_settings_get_default gtk_settings_get_default;
static Ptr_gtk_separator_menu_item_new gtk_separator_menu_item_new;
@@ -444,11 +409,18 @@ public:
static Ptr_gtk_widget_get_type gtk_widget_get_type;
static Ptr_gtk_widget_get_parent gtk_widget_get_parent;
static Ptr_gtk_widget_is_toplevel gtk_widget_is_toplevel;
+ static Ptr_gtk_widget_get_toplevel gtk_widget_get_toplevel;
static Ptr_gtk_rc_get_style_by_paths gtk_rc_get_style_by_paths;
static Ptr_gtk_check_version gtk_check_version;
static Ptr_gtk_border_free gtk_border_free;
static Ptr_gtk_widget_get_allocation gtk_widget_get_allocation;
static Ptr_gtk_widget_set_allocation gtk_widget_set_allocation;
+ static Ptr_gtk_widget_set_can_default gtk_widget_set_can_default;
+ static Ptr_gtk_window_set_default gtk_window_set_default;
+
+ static Ptr_gdk_event_new gdk_event_new;
+ static Ptr_gdk_event_free gdk_event_free;
+ static Ptr_gtk_widget_send_focus_change gtk_widget_send_focus_change;
static Ptr_pango_font_description_get_size pango_font_description_get_size;
static Ptr_pango_font_description_get_weight pango_font_description_get_weight;
@@ -472,12 +444,8 @@ public:
static Ptr_gdk_pixbuf_get_pixels gdk_pixbuf_get_pixels;
static Ptr_gdk_pixbuf_get_width gdk_pixbuf_get_width;
static Ptr_gdk_pixbuf_get_height gdk_pixbuf_get_height;
- static Ptr_gdk_pixmap_new gdk_pixmap_new;
static Ptr_gdk_pixbuf_new gdk_pixbuf_new;
- static Ptr_gdk_pixbuf_get_from_drawable gdk_pixbuf_get_from_drawable;
- static Ptr_gdk_draw_rectangle gdk_draw_rectangle;
static Ptr_gdk_pixbuf_unref gdk_pixbuf_unref;
- static Ptr_gdk_drawable_unref gdk_drawable_unref;
static Ptr_gdk_color_free gdk_color_free;
static Ptr_gdk_x11_window_set_user_time gdk_x11_window_set_user_time;
static Ptr_gdk_x11_drawable_get_xid gdk_x11_drawable_get_xid;
diff --git a/src/widgets/styles/qmacstyle_mac.h b/src/widgets/styles/qmacstyle_mac.h
index 60d5ec21eb..1de1dbbdd8 100644
--- a/src/widgets/styles/qmacstyle_mac.h
+++ b/src/widgets/styles/qmacstyle_mac.h
@@ -104,8 +104,9 @@ public:
enum WidgetSizePolicy { SizeSmall, SizeLarge, SizeMini, SizeDefault
};
+
static void setWidgetSizePolicy(const QWidget *w, WidgetSizePolicy policy);
- static WidgetSizePolicy widgetSizePolicy(const QWidget *w);
+ static WidgetSizePolicy widgetSizePolicy(const QWidget *w, const QStyleOption *opt = 0);
QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *opt,
const QWidget *widget = 0) const;
@@ -124,9 +125,6 @@ public:
Qt::Orientation orientation, const QStyleOption *option = 0,
const QWidget *widget = 0) const;
-protected:
- bool eventFilter(QObject *, QEvent *);
-
private:
Q_DISABLE_COPY(QMacStyle)
Q_DECLARE_PRIVATE(QMacStyle)
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index 83895b64b0..baeda89642 100644
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -127,9 +127,9 @@ QMacStylePrivate *mPrivate;
{
Q_UNUSED(notification);
QEvent event(QEvent::StyleChange);
- Q_FOREACH (const QObject* target, mPrivate->animationTargets()) {
- if (target)
- QCoreApplication::sendEvent(const_cast<QObject*>(target), &event);
+ foreach (QWidget *widget, QApplication::allWidgets()) {
+ if (QScrollBar *scrollBar = qobject_cast<QScrollBar *>(widget))
+ QCoreApplication::sendEvent(scrollBar, &event);
}
}
@end
@@ -178,38 +178,6 @@ static bool isVerticalTabs(const QTabBar::Shape shape) {
|| shape == QTabBar::TriangularWest);
}
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
-/*!
- Returns the QAbstractScrollArea the scroll bar \a sb is in. If \a sb is not
- inside of a QAbstractScrollArea, this returns 0.
- \internal
- */
-static const QAbstractScrollArea *scrollBarsScrollArea(const QScrollBar *sb)
-{
- const QWidget *w = sb;
- const QAbstractScrollArea *sa = 0;
- while (w != 0 && sa == 0) {
- sa = qobject_cast<const QAbstractScrollArea *>(w);
- w = w->parentWidget();
- }
- return sa;
-}
-
-/*!
- For a scroll bar \a sb within a scroll area, this function returns all other scroll
- bars within the same scroll area.
- \internal
- */
-static QList<const QScrollBar *> scrollBarsSiblings(const QScrollBar *sb)
-{
- const QAbstractScrollArea *sa = scrollBarsScrollArea(sb);
- Q_ASSERT(sa != 0);
- QList<const QScrollBar *> list = sa->findChildren<const QScrollBar *>();
- list.removeOne(sb);
- return list;
-}
-#endif
-
void drawTabCloseButton(QPainter *p, bool hover, bool active, bool selected)
{
// draw background circle
@@ -430,18 +398,13 @@ void drawTabBase(QPainter *p, const QStyleOptionTabBarBaseV2 *tbb, const QWidget
static int getControlSize(const QStyleOption *option, const QWidget *widget)
{
- if (option) {
- if (option->state & (QStyle::State_Small | QStyle::State_Mini))
- return (option->state & QStyle::State_Mini) ? QAquaSizeMini : QAquaSizeSmall;
- } else if (widget) {
- switch (QMacStyle::widgetSizePolicy(widget)) {
- case QMacStyle::SizeSmall:
- return QAquaSizeSmall;
- case QMacStyle::SizeMini:
- return QAquaSizeMini;
- default:
- break;
- }
+ switch (QMacStyle::widgetSizePolicy(widget, option)) {
+ case QMacStyle::SizeSmall:
+ return QAquaSizeSmall;
+ case QMacStyle::SizeMini:
+ return QAquaSizeMini;
+ default:
+ break;
}
return QAquaSizeLarge;
}
@@ -1607,7 +1570,7 @@ void QMacStylePrivate::getSliderInfo(QStyle::ComplexControl cc, const QStyleOpti
tdi->reserved = 0;
tdi->filler1 = 0;
bool isScrollbar = (cc == QStyle::CC_ScrollBar);
- switch (aquaSizeConstrain(0, needToRemoveMe)) {
+ switch (aquaSizeConstrain(slider, needToRemoveMe)) {
case QAquaSizeUnknown:
case QAquaSizeLarge:
if (isScrollbar)
@@ -1683,24 +1646,6 @@ QMacStylePrivate::QMacStylePrivate()
}
-bool QMacStylePrivate::addWidget(QWidget *w)
-{
- //already knew of it
- if (w == defaultButton || animation(w))
- return false;
-
- Q_Q(QMacStyle);
- if (qobject_cast<QScrollBar *>(w)) {
- w->installEventFilter(q);
- return true;
- }
- if (w->isWindow()) {
- w->installEventFilter(q);
- return true;
- }
- return false;
-}
-
ThemeDrawState QMacStylePrivate::getDrawState(QStyle::State flags)
{
ThemeDrawState tds = kThemeStateActive;
@@ -1718,73 +1663,6 @@ ThemeDrawState QMacStylePrivate::getDrawState(QStyle::State flags)
return tds;
}
-/*! \reimp */
-bool QMacStyle::eventFilter(QObject *o, QEvent *e)
-{
- //animate
- Q_D(QMacStyle);
- if (QScrollBar *sb = qobject_cast<QScrollBar *>(o)) {
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- // take care of fading out overlaying scrollbars (and only those!) when inactive
- const QAbstractScrollArea *scrollArea = scrollBarsScrollArea(sb);
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7 &&
- [NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay && scrollArea) {
- QMacStylePrivate::OverlayScrollBarInfo& info = d->scrollBarInfos[sb];
- const qint64 dt = QDateTime::currentMSecsSinceEpoch();
- const qreal elapsed = dt - info.lastUpdate;
- const CGFloat opacity = 1.0 - qMax(0.0, (elapsed - QMacStylePrivate::ScrollBarFadeOutDelay)
- / QMacStylePrivate::ScrollBarFadeOutDuration);
- switch (e->type()) {
- case QEvent::MouseMove:
- // whenever the mouse moves on a not 100% transparent scroll bar,
- // the fade out is stopped and it's set to 100% opaque
- if (opacity > 0.0) {
- info.hovered = true;
- info.lastUpdate = dt;
- info.lastHovered = info.lastUpdate;
- sb->update();
- break;
- }
-
- // fall through
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonRelease:
- case QEvent::MouseButtonDblClick:
- // all mouse events which happens on a transparent scroll bar are
- // translated and passed to the scroll area's viewport
- if (opacity <= 0.0) {
- QMouseEvent* mouse = static_cast<QMouseEvent *>(e);
- QWidget* viewport = scrollArea->viewport();
- const QPoint scrollAreaPos = sb->mapTo(scrollArea, mouse->pos());
- const QPoint viewportPos = viewport->mapFromParent(scrollAreaPos);
- QMouseEvent me(mouse->type(), viewportPos, mouse->windowPos(),
- mouse->globalPos(), mouse->button(), mouse->buttons(),
- mouse->modifiers());
- QCoreApplication::sendEvent(viewport, &me);
- mouse->setAccepted(me.isAccepted());
- return true;
- }
- break;
- case QEvent::Leave:
- case QEvent::WindowDeactivate:
- // mouse leave and window deactivate sets the scrollbar to not-hovered
- // -> triggers fade out
- info.hovered = false;
- break;
- if (!info.hovered) {
- e->setAccepted(false);
- return true;
- }
- break;
- default:
- break;
- }
- }
-#endif
- }
- return false;
-}
-
void QMacStylePrivate::drawColorlessButton(const HIRect &macRect, HIThemeButtonDrawInfo *bdi,
QPainter *p, const QStyleOption *opt) const
{
@@ -2011,8 +1889,6 @@ void QMacStyle::unpolish(QApplication *)
void QMacStyle::polish(QWidget* w)
{
- Q_D(QMacStyle);
- d->addWidget(w);
if (qt_mac_is_metal(w) && !w->testAttribute(Qt::WA_SetPalette)) {
// Set a clear brush so that the metal shines through.
QPalette pal = w->palette();
@@ -2064,13 +1940,13 @@ void QMacStyle::polish(QWidget* w)
if (qobject_cast<QScrollBar*>(w)) {
w->setAttribute(Qt::WA_OpaquePaintEvent, false);
+ w->setAttribute(Qt::WA_Hover, true);
w->setMouseTracking(true);
}
}
void QMacStyle::unpolish(QWidget* w)
{
- Q_D(QMacStyle);
if ((qobject_cast<QMenu*>(w) || qt_mac_is_metal(w)) && !w->testAttribute(Qt::WA_SetPalette)) {
QPalette pal = qApp->palette(w);
w->setPalette(pal);
@@ -2098,8 +1974,8 @@ void QMacStyle::unpolish(QWidget* w)
if (qobject_cast<QScrollBar*>(w)) {
w->setAttribute(Qt::WA_OpaquePaintEvent, true);
+ w->setAttribute(Qt::WA_Hover, false);
w->setMouseTracking(false);
- d->scrollBarInfos.remove(w);
}
}
@@ -2308,8 +2184,7 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW
case PM_ScrollBarExtent: {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7 &&
- [NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay &&
- scrollBarsScrollArea(qobject_cast<const QScrollBar *>(widget))) {
+ [NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay) {
switch (d->aquaSizeConstrain(opt, widget)) {
case QAquaSizeUnknown:
case QAquaSizeLarge:
@@ -2710,10 +2585,11 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w
srow = sptr+((y*sbpl)/4);
drow = dptr+((y*dbpl)/4);
for (int x = 0; x < w; ++x) {
- const int diff = (((qRed(*srow)-fillR)*(qRed(*srow)-fillR)) +
- ((qGreen(*srow)-fillG)*((qGreen(*srow)-fillG))) +
- ((qBlue(*srow)-fillB)*((qBlue(*srow)-fillB))));
- (*drow++) = (diff < 100) ? 0xffffffff : 0xff000000;
+ const int redDiff = qRed(*srow) - fillR;
+ const int greenDiff = qGreen(*srow) - fillG;
+ const int blueDiff = qBlue(*srow) - fillB;
+ const int diff = (redDiff * redDiff) + (greenDiff * greenDiff) + (blueDiff * blueDiff);
+ (*drow++) = (diff < 10) ? 0xffffffff : 0xff000000;
++srow;
}
}
@@ -2836,6 +2712,13 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w
case SH_DockWidget_ButtonsHaveFrame:
ret = false;
break;
+ case SH_ScrollBar_Transient:
+ ret = QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7;
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
+ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7)
+ ret &= [NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay;
+#endif
+ break;
default:
ret = QCommonStyle::styleHint(sh, opt, w, hret);
break;
@@ -2924,7 +2807,7 @@ void QMacStyle::setWidgetSizePolicy(const QWidget *widget, WidgetSizePolicy poli
wadget->setAttribute(Qt::WA_MacMiniSize, policy == SizeMini);
}
-QMacStyle::WidgetSizePolicy QMacStyle::widgetSizePolicy(const QWidget *widget)
+QMacStyle::WidgetSizePolicy QMacStyle::widgetSizePolicy(const QWidget *widget, const QStyleOption *opt)
{
while (widget) {
if (widget->testAttribute(Qt::WA_MacMiniSize)) {
@@ -2936,6 +2819,12 @@ QMacStyle::WidgetSizePolicy QMacStyle::widgetSizePolicy(const QWidget *widget)
}
widget = widget->parentWidget();
}
+
+ if (opt && opt->state & State_Mini)
+ return SizeMini;
+ else if (opt && opt->state & State_Small)
+ return SizeSmall;
+
return SizeDefault;
}
@@ -3229,7 +3118,8 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
fdi.state = tds;
SInt32 frame_size;
if (pe == PE_FrameLineEdit) {
- fdi.kind = kHIThemeFrameTextFieldSquare;
+ fdi.kind = frame->features & QStyleOptionFrame::Rounded ? kHIThemeFrameTextFieldRound :
+ kHIThemeFrameTextFieldSquare;
GetThemeMetric(kThemeMetricEditTextFrameOutset, &frame_size);
if ((frame->state & State_ReadOnly) || !(frame->state & State_Enabled))
fdi.state = kThemeStateInactive;
@@ -3451,6 +3341,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
break;
case CE_HeaderLabel:
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
+ p->save();
QRect textr = header->rect;
if (!header->icon.isNull()) {
QIcon::Mode mode = QIcon::Disabled;
@@ -3464,8 +3355,10 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
textr.translate(pixmap.width() + 2, 0);
}
+ p->setFont(qt_app_fonts_hash()->value("QSmallFont", QFont()));
proxy()->drawItemText(p, textr, header->textAlignment | Qt::AlignVCenter, header->palette,
header->state & State_Enabled, header->text, QPalette::ButtonText);
+ p->restore();
}
break;
case CE_ToolButtonLabel:
@@ -4354,7 +4247,8 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
tdi.min = pb->minimum;
tdi.value = pb->progress;
tdi.attributes = vertical ? 0 : kThemeTrackHorizontal;
- if (isIndeterminate) {
+
+ if (isIndeterminate || tdi.value < tdi.max) {
if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(opt->styleObject)))
tdi.trackInfo.progress.phase = animation->animationStep();
else
@@ -4558,17 +4452,22 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt,
rect = qt_qrectForHIRect(contentRect);
}
break;
- case SE_HeaderLabel:
- if (qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
- rect = QCommonStyle::subElementRect(sr, opt, widget);
- if (widget && widget->height() <= 22){
- // We need to allow the text a bit more space when the header is
- // small, otherwise it gets clipped:
- rect.setY(0);
- rect.setHeight(widget->height());
+ case SE_HeaderLabel: {
+ int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, opt, widget);
+ rect.setRect(opt->rect.x() + margin, opt->rect.y(),
+ opt->rect.width() - margin * 2, opt->rect.height() - 2);
+ if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
+ // Subtract width needed for arrow, if there is one
+ if (header->sortIndicator != QStyleOptionHeader::None) {
+ if (opt->state & State_Horizontal)
+ rect.setWidth(rect.width() - (opt->rect.height() / 2) - (margin * 2));
+ else
+ rect.setHeight(rect.height() - (opt->rect.width() / 2) - (margin * 2));
}
}
+ rect = visualRect(opt->direction, opt->rect, rect);
break;
+ }
case SE_ProgressBarGroove:
case SE_ProgressBarLabel:
break;
@@ -4998,7 +4897,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
if (cc == CC_ScrollBar) {
const int scrollBarLength = (slider->orientation == Qt::Horizontal)
? slider->rect.width() : slider->rect.height();
- const QMacStyle::WidgetSizePolicy sizePolicy = widgetSizePolicy(widget);
+ const QMacStyle::WidgetSizePolicy sizePolicy = widgetSizePolicy(widget, opt);
if (scrollBarLength < scrollButtonsCutoffSize(thumbIndicatorCutoff, sizePolicy))
tdi.attributes &= ~kThemeTrackShowThumb;
if (scrollBarLength < scrollButtonsCutoffSize(scrollButtonsCutoff, sizePolicy))
@@ -5013,59 +4912,65 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
}
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- const qint64 dt = QDateTime::currentMSecsSinceEpoch();
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7 &&
- [NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay &&
- scrollBarsScrollArea(qobject_cast<const QScrollBar *>(widget)) &&
- cc == CC_ScrollBar) {
- QMacStylePrivate::OverlayScrollBarInfo& info = d->scrollBarInfos[widget];
- bool showSiblings = false;
- if (info.lastValue != slider->sliderPosition ||
- info.lastMinimum != slider->minimum ||
- info.lastMaximum != slider->maximum ||
- info.lastSize != slider->rect.size()) {
- info.lastValue = slider->sliderPosition;
- info.lastMinimum = slider->minimum;
- info.lastSize = slider->rect.size();
- info.lastMaximum = slider->maximum;
- info.lastUpdate = dt;
- showSiblings = true;
- }
-
- const QList<const QScrollBar *> siblings =
- scrollBarsSiblings(qobject_cast<const QScrollBar *>(widget));
- // keep last update (last change of value) time of all siblings in sync
- Q_FOREACH (const QScrollBar *sibling, siblings) {
- info.lastUpdate = qMax(info.lastUpdate,
- d->scrollBarInfos.value(sibling).lastUpdate);
- info.cleared = false;
- if (d->scrollBarInfos.value(sibling).hovered)
- info.lastUpdate = dt;
- }
-
- qreal elapsed = dt - info.lastHovered;
- CGFloat opacity = 1.0 - qMax(0.0,
- (elapsed - QMacStylePrivate::ScrollBarFadeOutDelay) /
- QMacStylePrivate::ScrollBarFadeOutDuration);
- const bool isHorizontal = slider->orientation == Qt::Horizontal;
-
- if (info.hovered) {
- info.lastHovered = dt;
- info.lastUpdate = dt;
+ if (cc == CC_ScrollBar && proxy()->styleHint(SH_ScrollBar_Transient)) {
+ QObject *styleObject = opt->styleObject;
+ int oldPos = styleObject->property("_q_stylepos").toInt();
+ int oldMin = styleObject->property("_q_stylemin").toInt();
+ int oldMax = styleObject->property("_q_stylemax").toInt();
+ QRect oldRect = styleObject->property("_q_stylerect").toRect();
+ int oldState = styleObject->property("_q_stylestate").toInt();
+ uint oldActiveControls = styleObject->property("_q_stylecontrols").toUInt();
+
+ // a scrollbar is transient when the the scrollbar itself and
+ // its sibling are both inactive (ie. not pressed/hovered/moved)
+ bool transient = !opt->activeSubControls && !(slider->state & State_On);
+
+ CGFloat opacity = 0.0;
+ if (!transient ||
+ oldPos != slider->sliderPosition ||
+ oldMin != slider->minimum ||
+ oldMax != slider->maximum ||
+ oldRect != slider->rect ||
+ oldState != slider->state ||
+ oldActiveControls != slider->activeSubControls) {
+
+ // if the scrollbar is transient or its attributes, geometry or
+ // state has changed, the opacity is reset back to 100% opaque
opacity = 1.0;
- // if the current scroll bar is hovered, none of the others might fade out
- Q_FOREACH (const QScrollBar *sibling, siblings) {
- d->scrollBarInfos[sibling].lastUpdate = info.lastUpdate;
+
+ styleObject->setProperty("_q_stylepos", slider->sliderPosition);
+ styleObject->setProperty("_q_stylemin", slider->minimum);
+ styleObject->setProperty("_q_stylemax", slider->maximum);
+ styleObject->setProperty("_q_stylerect", slider->rect);
+ styleObject->setProperty("_q_stylestate", static_cast<int>(slider->state));
+ styleObject->setProperty("_q_stylecontrols", static_cast<uint>(slider->activeSubControls));
+
+ if (transient) {
+ QFadeOutAnimation *anim = qobject_cast<QFadeOutAnimation *>(d->animation(styleObject));
+ if (!anim) {
+ anim = new QFadeOutAnimation(styleObject);
+ d->startAnimation(anim);
+ } else {
+ // the scrollbar was already fading out while the
+ // state changed -> restart the fade out animation
+ anim->setCurrentTime(0);
+ }
+ } else {
+ d->stopAnimation(styleObject);
}
}
- // when one scroll bar was changed, all its siblings need a redraw as well, since
- // either both scroll bars within a scroll area shall be visible or none
- if (showSiblings) {
- Q_FOREACH (const QScrollBar *sibling, siblings)
- const_cast<QScrollBar *>(sibling)->update();
+ QFadeOutAnimation *anim = qobject_cast<QFadeOutAnimation *>(d->animation(styleObject));
+ if (anim) {
+ // once a scrollbar was active (hovered/pressed), it retains
+ // the active look even if it's no longer active while fading out
+ if (oldActiveControls)
+ anim->setActive(true);
+ opacity = anim->currentValue();
}
+ const bool isHorizontal = slider->orientation == Qt::Horizontal;
+
CGContextSaveGState(cg);
[NSGraphicsContext saveGraphicsState];
@@ -5075,7 +4980,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
[scroller initWithFrame:NSMakeRect(0, 0, slider->rect.width(), slider->rect.height())];
// mac os behaviour: as soon as one color channel is >= 128,
// the bg is considered bright, scroller is dark
- const QColor bgColor = widget->palette().color(QPalette::Base);
+ const QColor bgColor = opt->palette.color(QPalette::Base);
const bool isDarkBg = bgColor.red() < 128 && bgColor.green() < 128 &&
bgColor.blue() < 128;
if (isDarkBg)
@@ -5092,7 +4997,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
[scroller setScrollerStyle:NSScrollerStyleOverlay];
// first we draw only the track, by using a disabled scroller
- if (opacity > 0.0) {
+ if (opt->activeSubControls || (anim && anim->wasActive())) {
CGContextBeginTransparencyLayerWithRect(cg, qt_hirectForQRect(slider->rect),
NULL);
CGContextSetAlpha(cg, opacity);
@@ -5105,21 +5010,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
CGContextEndTransparencyLayer(cg);
}
- // afterwards we draw the knob, since we cannot drow the know w/o the track,
- // we simulate a scrollbar with a knob from 0.0 to 1.0
- elapsed = dt - info.lastUpdate;
- opacity = 1.0 - qMax(0.0, (elapsed - QMacStylePrivate::ScrollBarFadeOutDelay) /
- QMacStylePrivate::ScrollBarFadeOutDuration);
- info.cleared = opacity <= 0.0;
-
- if (info.animating && info.cleared) {
- d->stopAnimation(slider->styleObject);
- info.animating = false;
- } else if (!info.animating && !info.cleared) {
- d->startAnimation(new QStyleAnimation(slider->styleObject));
- info.animating = true;
- }
-
CGContextBeginTransparencyLayerWithRect(cg, qt_hirectForQRect(slider->rect), NULL);
CGContextSetAlpha(cg, opacity);
@@ -5160,6 +5050,8 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
} else
#endif
{
+ d->stopAnimation(opt->styleObject);
+
HIThemeDrawTrack(&tdi, tracking ? 0 : &macRect, cg,
kHIThemeOrientationNormal);
if (cc == CC_Slider && slider->subControls & SC_SliderTickmarks) {
@@ -5606,7 +5498,7 @@ QStyle::SubControl QMacStyle::hitTestComplexControl(ComplexControl cc,
// exclude them from the hit test.
const int scrollBarLength = (sb->orientation == Qt::Horizontal)
? sb->rect.width() : sb->rect.height();
- if (scrollBarLength < scrollButtonsCutoffSize(scrollButtonsCutoff, widgetSizePolicy(widget)))
+ if (scrollBarLength < scrollButtonsCutoffSize(scrollButtonsCutoff, widgetSizePolicy(widget, opt)))
sbi.enableState = kThemeTrackNothingToScroll;
sbi.viewsize = sb->pageStep;
@@ -6244,6 +6136,7 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
return sz;
case CT_ComboBox:
sz.rwidth() += 50;
+ sz.rheight() += 2;
break;
case CT_Menu: {
QStyleHintReturnMask menuMask;
@@ -6262,7 +6155,7 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
case CT_ScrollBar :
// Make sure that the scroll bar is large enough to display the thumb indicator.
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
- const int minimumSize = scrollButtonsCutoffSize(thumbIndicatorCutoff, widgetSizePolicy(widget));
+ const int minimumSize = scrollButtonsCutoffSize(thumbIndicatorCutoff, widgetSizePolicy(widget, opt));
if (slider->orientation == Qt::Horizontal)
sz = sz.expandedTo(QSize(minimumSize, sz.height()));
else
diff --git a/src/widgets/styles/qmacstyle_mac_p.h b/src/widgets/styles/qmacstyle_mac_p.h
index af1c88d50d..f01d1e14c5 100644
--- a/src/widgets/styles/qmacstyle_mac_p.h
+++ b/src/widgets/styles/qmacstyle_mac_p.h
@@ -158,9 +158,6 @@ public:
static const qreal ScrollBarFadeOutDuration;
static const qreal ScrollBarFadeOutDelay;
- // Stuff from QAquaAnimate:
- bool addWidget(QWidget *);
-
enum Animates { AquaPushButton, AquaProgressBar, AquaListViewItemOpen, AquaScrollBar };
static ThemeDrawState getDrawState(QStyle::State flags);
QAquaWidgetSize aquaSizeConstrain(const QStyleOption *option, const QWidget *widg,
@@ -201,29 +198,6 @@ public:
mutable QPointer<QObject> defaultButton;
mutable QPointer<QObject> autoDefaultButton;
- struct OverlayScrollBarInfo {
- OverlayScrollBarInfo()
- : lastValue(-1),
- lastMinimum(-1),
- lastMaximum(-1),
- lastUpdate(QDateTime::currentMSecsSinceEpoch()),
- hovered(false),
- lastHovered(0),
- cleared(false),
- animating(false)
- {}
- int lastValue;
- int lastMinimum;
- int lastMaximum;
- QSize lastSize;
- qint64 lastUpdate;
- bool hovered;
- qint64 lastHovered;
- bool cleared;
- bool animating;
- };
- mutable QMap<const QWidget*, OverlayScrollBarInfo> scrollBarInfos;
-
struct ButtonState {
int frame;
enum { ButtonDark, ButtonLight } dir;
@@ -237,6 +211,34 @@ public:
#endif
};
+class QFadeOutAnimation : public QNumberStyleAnimation
+{
+ Q_OBJECT
+
+public:
+ QFadeOutAnimation(QObject *target) : QNumberStyleAnimation(target), _active(false)
+ {
+ setDuration(QMacStylePrivate::ScrollBarFadeOutDelay + QMacStylePrivate::ScrollBarFadeOutDuration);
+ setDelay(QMacStylePrivate::ScrollBarFadeOutDelay);
+ setStartValue(1.0);
+ setEndValue(0.0);
+ }
+
+ bool wasActive() const { return _active; }
+ void setActive(bool active) { _active = active; }
+
+private slots:
+ void updateCurrentTime(int time)
+ {
+ QNumberStyleAnimation::updateCurrentTime(time);
+ if (qFuzzyIsNull(currentValue()))
+ target()->setProperty("visible", false);
+ }
+
+private:
+ bool _active;
+};
+
QT_END_NAMESPACE
#endif // QMACSTYLE_MAC_P_H
diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp
index f0d1d2319c..76d6efadee 100644
--- a/src/widgets/styles/qstyle.cpp
+++ b/src/widgets/styles/qstyle.cpp
@@ -1887,6 +1887,9 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
\value SH_RequestSoftwareInputPanel Determines when a software input panel should
be requested by input widgets. Returns an enum of type QStyle::RequestSoftwareInputPanel.
+ \value SH_ScrollBar_Transient Determines if the style supports transient scroll bars. Transient
+ scroll bars appear when the content is scrolled and disappear when they are no longer needed.
+
\sa styleHint()
*/
diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h
index 48491b3e3e..387645ae11 100644
--- a/src/widgets/styles/qstyle.h
+++ b/src/widgets/styles/qstyle.h
@@ -698,6 +698,7 @@ public:
SH_DockWidget_ButtonsHaveFrame,
SH_ToolButtonStyle,
SH_RequestSoftwareInputPanel,
+ SH_ScrollBar_Transient,
// Add new style hint values here
SH_CustomBase = 0xf0000000
diff --git a/src/widgets/styles/qstyleanimation.cpp b/src/widgets/styles/qstyleanimation.cpp
index 0138996e33..9ddcbcc511 100644
--- a/src/widgets/styles/qstyleanimation.cpp
+++ b/src/widgets/styles/qstyleanimation.cpp
@@ -41,7 +41,6 @@
#include "qstyleanimation_p.h"
#include <qcoreapplication.h>
-#include <qprogressbar.h>
#include <qwidget.h>
#include <qevent.h>
@@ -208,4 +207,108 @@ bool QNumberStyleAnimation::isUpdateNeeded() const
return false;
}
+QBlendStyleAnimation::QBlendStyleAnimation(Type type, QObject *target) :
+ QStyleAnimation(target), _type(type)
+{
+ setDuration(250);
+}
+
+QImage QBlendStyleAnimation::startImage() const
+{
+ return _start;
+}
+
+void QBlendStyleAnimation::setStartImage(const QImage& image)
+{
+ _start = image;
+}
+
+QImage QBlendStyleAnimation::endImage() const
+{
+ return _end;
+}
+
+void QBlendStyleAnimation::setEndImage(const QImage& image)
+{
+ _end = image;
+}
+
+QImage QBlendStyleAnimation::currentImage() const
+{
+ return _current;
+}
+
+/*! \internal
+
+ A helper function to blend two images.
+
+ The result consists of ((alpha)*startImage) + ((1-alpha)*endImage)
+
+*/
+static QImage blendedImage(const QImage &start, const QImage &end, float alpha)
+{
+ if (start.isNull() || end.isNull())
+ return QImage();
+
+ QImage blended;
+ const int a = qRound(alpha*256);
+ const int ia = 256 - a;
+ const int sw = start.width();
+ const int sh = start.height();
+ const int bpl = start.bytesPerLine();
+ switch (start.depth()) {
+ case 32:
+ {
+ blended = QImage(sw, sh, start.format());
+ uchar *mixed_data = blended.bits();
+ const uchar *back_data = start.bits();
+ const uchar *front_data = end.bits();
+ for (int sy = 0; sy < sh; sy++) {
+ quint32* mixed = (quint32*)mixed_data;
+ const quint32* back = (const quint32*)back_data;
+ const quint32* front = (const quint32*)front_data;
+ for (int sx = 0; sx < sw; sx++) {
+ quint32 bp = back[sx];
+ quint32 fp = front[sx];
+ mixed[sx] = qRgba ((qRed(bp)*ia + qRed(fp)*a)>>8,
+ (qGreen(bp)*ia + qGreen(fp)*a)>>8,
+ (qBlue(bp)*ia + qBlue(fp)*a)>>8,
+ (qAlpha(bp)*ia + qAlpha(fp)*a)>>8);
+ }
+ mixed_data += bpl;
+ back_data += bpl;
+ front_data += bpl;
+ }
+ }
+ default:
+ break;
+ }
+ return blended;
+}
+
+void QBlendStyleAnimation::updateCurrentTime(int time)
+{
+ QStyleAnimation::updateCurrentTime(time);
+
+ float alpha = 1.0;
+ if (duration() > 0) {
+ if (_type == Pulse) {
+ time = time % duration() * 2;
+ if (time > duration())
+ time = duration() * 2 - time;
+ }
+
+ alpha = time / static_cast<float>(duration());
+
+ if (_type == Transition && time > duration()) {
+ alpha = 1.0;
+ stop();
+ }
+ } else if (time > 0) {
+ stop();
+ }
+
+ _current = blendedImage(_start, _end, alpha);
+}
+
QT_END_NAMESPACE
diff --git a/src/widgets/styles/qstyleanimation_p.h b/src/widgets/styles/qstyleanimation_p.h
index d9869533ef..9dddc7b62c 100644
--- a/src/widgets/styles/qstyleanimation_p.h
+++ b/src/widgets/styles/qstyleanimation_p.h
@@ -44,6 +44,7 @@
#include "qabstractanimation.h"
#include "qdatetime.h"
+#include "qimage.h"
QT_BEGIN_NAMESPACE
@@ -134,6 +135,33 @@ private:
mutable qreal _prev;
};
+class QBlendStyleAnimation : public QStyleAnimation
+{
+ Q_OBJECT
+
+public:
+ enum Type { Transition, Pulse };
+
+ QBlendStyleAnimation(Type type, QObject *target);
+
+ QImage startImage() const;
+ void setStartImage(const QImage& image);
+
+ QImage endImage() const;
+ void setEndImage(const QImage& image);
+
+ QImage currentImage() const;
+
+protected:
+ virtual void updateCurrentTime(int time);
+
+private:
+ Type _type;
+ QImage _start;
+ QImage _end;
+ QImage _current;
+};
+
QT_END_NAMESPACE
#endif // QSTYLEANIMATION_P_H
diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp
index 8d67683eae..c6e9a8d013 100644
--- a/src/widgets/styles/qstylehelper.cpp
+++ b/src/widgets/styles/qstylehelper.cpp
@@ -99,6 +99,9 @@ bool hasAncestor(QObject *obj, QAccessible::Role role)
delete iface;
parent = parent->parent();
}
+#else
+ Q_UNUSED(obj)
+ Q_UNUSED(role)
#endif // QT_NO_ACCESSIBILITY
return found;
}
diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp
index 53c1cf4559..3bc0c053b9 100644
--- a/src/widgets/styles/qstyleoption.cpp
+++ b/src/widgets/styles/qstyleoption.cpp
@@ -3889,6 +3889,13 @@ QStyleHintReturnMask::QStyleHintReturnMask() : QStyleHintReturn(Version, Type)
}
/*!
+ Destructor.
+*/
+QStyleHintReturnMask::~QStyleHintReturnMask()
+{
+}
+
+/*!
\enum QStyleHintReturnMask::StyleOptionType
This enum is used to hold information about the type of the style option, and
@@ -3942,6 +3949,13 @@ QStyleHintReturnVariant::QStyleHintReturnVariant() : QStyleHintReturn(Version, T
}
/*!
+ Destructor.
+*/
+QStyleHintReturnVariant::~QStyleHintReturnVariant()
+{
+}
+
+/*!
\enum QStyleHintReturnVariant::StyleOptionType
This enum is used to hold information about the type of the style option, and
diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h
index d88582a9f8..b4641f36bb 100644
--- a/src/widgets/styles/qstyleoption.h
+++ b/src/widgets/styles/qstyleoption.h
@@ -125,7 +125,8 @@ public:
int midLineWidth;
enum FrameFeature {
None = 0x00,
- Flat = 0x01
+ Flat = 0x01,
+ Rounded = 0x02
};
Q_DECLARE_FLAGS(FrameFeatures, FrameFeature)
FrameFeatures features;
@@ -709,6 +710,7 @@ public:
enum StyleOptionVersion { Version = 1 };
QStyleHintReturnMask();
+ ~QStyleHintReturnMask();
QRegion region;
};
@@ -719,6 +721,7 @@ public:
enum StyleOptionVersion { Version = 1 };
QStyleHintReturnVariant();
+ ~QStyleHintReturnVariant();
QVariant variant;
};
diff --git a/src/widgets/styles/qstyleplugin.cpp b/src/widgets/styles/qstyleplugin.cpp
index a42e1569d2..7cd44ef455 100644
--- a/src/widgets/styles/qstyleplugin.cpp
+++ b/src/widgets/styles/qstyleplugin.cpp
@@ -82,8 +82,6 @@ QT_BEGIN_NAMESPACE
style. Note that the keys are case insensitive. For example:
\snippet qstyleplugin/main.cpp 1
-
- \sa keys()
*/
/*!
diff --git a/src/widgets/styles/qwindowscestyle.cpp b/src/widgets/styles/qwindowscestyle.cpp
index 28b8e3d549..8accf18da9 100644
--- a/src/widgets/styles/qwindowscestyle.cpp
+++ b/src/widgets/styles/qwindowscestyle.cpp
@@ -80,6 +80,10 @@ QWindowsCEStyle::QWindowsCEStyle() : QWindowsStyle() {
qApp->setEffectEnabled(Qt::UI_AnimateMenu, false);
}
+QWindowsCEStyle::~QWindowsCEStyle()
+{
+}
+
void QWindowsCEStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
QPainter *painter, const QWidget *widget) const {
diff --git a/src/widgets/styles/qwindowscestyle.h b/src/widgets/styles/qwindowscestyle.h
index 37471b0206..606cbafd48 100644
--- a/src/widgets/styles/qwindowscestyle.h
+++ b/src/widgets/styles/qwindowscestyle.h
@@ -56,6 +56,7 @@ class Q_WIDGETS_EXPORT QWindowsCEStyle : public QWindowsStyle
Q_OBJECT
public:
QWindowsCEStyle();
+ ~QWindowsCEStyle();
void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
QPainter *painter, const QWidget *widget = 0) const;
diff --git a/src/widgets/styles/qwindowsmobilestyle.cpp b/src/widgets/styles/qwindowsmobilestyle.cpp
index 3242e6a35e..8ac9888659 100644
--- a/src/widgets/styles/qwindowsmobilestyle.cpp
+++ b/src/widgets/styles/qwindowsmobilestyle.cpp
@@ -4515,6 +4515,10 @@ QWindowsMobileStyle::QWindowsMobileStyle() : QWindowsStyle(*new QWindowsMobileSt
qApp->setEffectEnabled(Qt::UI_AnimateMenu, false);
}
+QWindowsMobileStyle::~QWindowsMobileStyle()
+{
+}
+
QWindowsMobileStylePrivate::QWindowsMobileStylePrivate() :QWindowsStylePrivate() {
#ifdef Q_OS_WINCE
diff --git a/src/widgets/styles/qwindowsmobilestyle.h b/src/widgets/styles/qwindowsmobilestyle.h
index 607d201a0e..7bb7d5c260 100644
--- a/src/widgets/styles/qwindowsmobilestyle.h
+++ b/src/widgets/styles/qwindowsmobilestyle.h
@@ -58,6 +58,7 @@ class Q_WIDGETS_EXPORT QWindowsMobileStyle : public QWindowsStyle
Q_OBJECT
public:
QWindowsMobileStyle();
+ ~QWindowsMobileStyle();
void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
QPainter *painter, const QWidget *widget = 0) const;
diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp
index b20e6f5ea5..093a9f7197 100644
--- a/src/widgets/styles/qwindowsvistastyle.cpp
+++ b/src/widgets/styles/qwindowsvistastyle.cpp
@@ -203,6 +203,13 @@ QWindowsVistaStyle::QWindowsVistaStyle()
{
}
+/*!
+ Destructor.
+*/
+QWindowsVistaStyle::~QWindowsVistaStyle()
+{
+}
+
//convert Qt state flags to uxtheme button states
static int buttonStateId(int flags, int partId)
{
@@ -235,119 +242,16 @@ static int buttonStateId(int flags, int partId)
return stateId;
}
-void QWindowsVistaAnimation::paint(QPainter *painter, const QStyleOption *option)
-{
- Q_UNUSED(option);
- Q_UNUSED(painter);
-}
-
bool QWindowsVistaAnimation::isUpdateNeeded() const
{
return QWindowsVistaStylePrivate::useVista();
}
-/*! \internal
-
- Helperfunction to paint the current transition state between two
- animation frames.
-
- The result is a blended image consisting of ((alpha)*_primaryImage)
- + ((1-alpha)*_secondaryImage)
-
-*/
-void QWindowsVistaAnimation::drawBlendedImage(QPainter *painter, QRect rect, float alpha) {
- if (_secondaryImage.isNull() || _primaryImage.isNull())
- return;
-
- if (_tempImage.isNull())
- _tempImage = _secondaryImage;
-
- const int a = qRound(alpha*256);
- const int ia = 256 - a;
- const int sw = _primaryImage.width();
- const int sh = _primaryImage.height();
- const int bpl = _primaryImage.bytesPerLine();
- switch(_primaryImage.depth()) {
- case 32:
- {
- uchar *mixed_data = _tempImage.bits();
- const uchar *back_data = _primaryImage.bits();
- const uchar *front_data = _secondaryImage.bits();
- for (int sy = 0; sy < sh; sy++) {
- quint32* mixed = (quint32*)mixed_data;
- const quint32* back = (const quint32*)back_data;
- const quint32* front = (const quint32*)front_data;
- for (int sx = 0; sx < sw; sx++) {
- quint32 bp = back[sx];
- quint32 fp = front[sx];
- mixed[sx] = qRgba ((qRed(bp)*ia + qRed(fp)*a)>>8,
- (qGreen(bp)*ia + qGreen(fp)*a)>>8,
- (qBlue(bp)*ia + qBlue(fp)*a)>>8,
- (qAlpha(bp)*ia + qAlpha(fp)*a)>>8);
- }
- mixed_data += bpl;
- back_data += bpl;
- front_data += bpl;
- }
- }
- default:
- break;
- }
- painter->drawImage(rect, _tempImage);
-}
-
-/*! \internal
- Paints a transition state. The result will be a mix between the
- initial and final state of the transition, depending on the time
- difference between startTime and current time.
-*/
-void QWindowsVistaTransition::paint(QPainter *painter, const QStyleOption *option)
-{
- float alpha = 1.0;
- if (_duration > 0) {
- QTime current = QTime::currentTime();
-
- if (startTime() > current)
- setStartTime(current);
-
- int timeDiff = startTime().msecsTo(current);
- alpha = timeDiff/(float)_duration;
- if (timeDiff > _duration) {
- stop();
- alpha = 1.0;
- }
- }
- else {
- stop();
- }
- drawBlendedImage(painter, option->rect, alpha);
-}
-
-/*! \internal
- Paints a pulse. The result will be a mix between the primary and
- secondary pulse images depending on the time difference between
- startTime and current time.
-*/
-void QWindowsVistaPulse::paint(QPainter *painter, const QStyleOption *option)
+void QWindowsVistaAnimation::paint(QPainter *painter, const QStyleOption *option)
{
- float alpha = 1.0;
- if (_duration > 0) {
- QTime current = QTime::currentTime();
-
- if (startTime() > current)
- setStartTime(current);
-
- int timeDiff = startTime().msecsTo(current) % _duration*2;
- if (timeDiff > _duration)
- timeDiff = _duration*2 - timeDiff;
- alpha = timeDiff/(float)_duration;
- } else {
- stop();
- }
- drawBlendedImage(painter, option->rect, alpha);
+ painter->drawImage(option->rect, currentImage());
}
-
/*!
\internal
@@ -818,8 +722,10 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
QPixmap pixmap;
if (vopt->backgroundBrush.style() != Qt::NoBrush) {
+ const QPointF oldBrushOrigin = painter->brushOrigin();
painter->setBrushOrigin(vopt->rect.topLeft());
painter->fillRect(vopt->rect, vopt->backgroundBrush);
+ painter->setBrushOrigin(oldBrushOrigin);
}
if (hover || selected) {
@@ -1088,8 +994,8 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
theme.stateId = PBS_DEFAULTED_ANIMATING;
theme.painter = &alternatePainter;
d->drawBackground(theme);
- pulse->setPrimaryImage(startImage);
- pulse->setAlternateImage(alternateImage);
+ pulse->setStartImage(startImage);
+ pulse->setEndImage(alternateImage);
pulse->setStartTime(QTime::currentTime());
pulse->setDuration(2000);
d->startAnimation(pulse);
diff --git a/src/widgets/styles/qwindowsvistastyle.h b/src/widgets/styles/qwindowsvistastyle.h
index 0b17881101..72950aa66d 100644
--- a/src/widgets/styles/qwindowsvistastyle.h
+++ b/src/widgets/styles/qwindowsvistastyle.h
@@ -57,6 +57,7 @@ class Q_WIDGETS_EXPORT QWindowsVistaStyle : public QWindowsXPStyle
Q_OBJECT
public:
QWindowsVistaStyle();
+ ~QWindowsVistaStyle();
void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
QPainter *painter, const QWidget *widget = 0) const;
diff --git a/src/widgets/styles/qwindowsvistastyle_p.h b/src/widgets/styles/qwindowsvistastyle_p.h
index 1d427fe45c..caa10454c5 100644
--- a/src/widgets/styles/qwindowsvistastyle_p.h
+++ b/src/widgets/styles/qwindowsvistastyle_p.h
@@ -135,24 +135,14 @@ QT_BEGIN_NAMESPACE
#define TDLG_SECONDARYPANEL 8
#endif
-class QWindowsVistaAnimation : public QStyleAnimation
+class QWindowsVistaAnimation : public QBlendStyleAnimation
{
Q_OBJECT
public:
- QWindowsVistaAnimation(QObject *target) : QStyleAnimation(target), _duration(-1) { }
- virtual ~QWindowsVistaAnimation() { }
- virtual void paint(QPainter *painter, const QStyleOption *option);
+ QWindowsVistaAnimation(Type type, QObject *target) : QBlendStyleAnimation(type, target) { }
+
virtual bool isUpdateNeeded() const;
- virtual int duration() const { return _duration; }
- //set time in ms to complete a state transition / pulse cycle
- void setDuration(int duration) { _duration = duration; }
-
-protected:
- void drawBlendedImage(QPainter *painter, QRect rect, float value);
- QImage _primaryImage;
- QImage _secondaryImage;
- QImage _tempImage;
- int _duration;
+ void paint(QPainter *painter, const QStyleOption *option);
};
@@ -161,11 +151,7 @@ class QWindowsVistaTransition : public QWindowsVistaAnimation
{
Q_OBJECT
public:
- QWindowsVistaTransition(QObject *target) : QWindowsVistaAnimation(target) {}
- virtual ~QWindowsVistaTransition() { }
- void setStartImage(const QImage &image) { _primaryImage = image; }
- void setEndImage(const QImage &image) { _secondaryImage = image; }
- virtual void paint(QPainter *painter, const QStyleOption *option);
+ QWindowsVistaTransition(QObject *target) : QWindowsVistaAnimation(Transition, target) {}
};
@@ -174,11 +160,7 @@ class QWindowsVistaPulse: public QWindowsVistaAnimation
{
Q_OBJECT
public:
- QWindowsVistaPulse(QObject *target) : QWindowsVistaAnimation(target) {}
- virtual ~QWindowsVistaPulse() { }
- void setPrimaryImage(const QImage &image) { _primaryImage = image; }
- void setAlternateImage(const QImage &image) { _secondaryImage = image; }
- virtual void paint(QPainter *painter, const QStyleOption *option);
+ QWindowsVistaPulse(QObject *target) : QWindowsVistaAnimation(Pulse, target) {}
};
diff --git a/src/widgets/styles/styles.pri b/src/widgets/styles/styles.pri
index 9c5a790390..af510dc107 100644
--- a/src/widgets/styles/styles.pri
+++ b/src/widgets/styles/styles.pri
@@ -99,11 +99,14 @@ contains( styles, windowsxp ) {
}
contains( styles, gtk ) {
+ HEADERS += styles/qgtkglobal_p.h
HEADERS += styles/qgtkstyle.h
HEADERS += styles/qgtkpainter_p.h
+ HEADERS += styles/qgtk2painter_p.h
HEADERS += styles/qgtkstyle_p.h
SOURCES += styles/qgtkstyle.cpp
SOURCES += styles/qgtkpainter.cpp
+ SOURCES += styles/qgtk2painter.cpp
SOURCES += styles/qgtkstyle_p.cpp
} else {
DEFINES += QT_NO_STYLE_GTK
diff --git a/src/widgets/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp
index 62dab8fa11..5fefa08f77 100644
--- a/src/widgets/util/qsystemtrayicon_x11.cpp
+++ b/src/widgets/util/qsystemtrayicon_x11.cpp
@@ -102,21 +102,14 @@ QX11SystemTrayContext::QX11SystemTrayContext() : m_display(0), m_screenNumber(0)
qWarning("%s: No screen.", Q_FUNC_INFO);
return;
}
- // Open display using screen name and retrieve screen number from "hostname:0.0"
- const QByteArray name = screen->name().toLocal8Bit();
- const int dotPos = name.lastIndexOf('.');
- if (dotPos != -1) {
- bool ok;
- const int n = name.mid(dotPos + 1).toInt(&ok);
- if (ok)
- m_screenNumber = n;
- }
- m_display = XOpenDisplay(name.constData());
- if (!m_display) {
- qWarning("%s: Cannot open display '%s'.", Q_FUNC_INFO, name.constData());
+ void *displayV = QGuiApplication::platformNativeInterface()->nativeResourceForScreen(QByteArrayLiteral("display"), screen);
+ if (!displayV) {
+ qWarning("%s: Unable to obtain X11 display of primary screen.", Q_FUNC_INFO);
return;
}
+ m_display = static_cast<Display *>(displayV);
+
const QByteArray netSysTray = "_NET_SYSTEM_TRAY_S" + QByteArray::number(m_screenNumber);
m_systemTraySelection = XInternAtom(m_display, netSysTray.constData(), False);
if (!m_systemTraySelection) {
@@ -134,8 +127,6 @@ Window QX11SystemTrayContext::locateSystemTray() const
QX11SystemTrayContext::~QX11SystemTrayContext()
{
- if (m_display)
- XCloseDisplay(m_display);
}
Q_GLOBAL_STATIC(QX11SystemTrayContext, qX11SystemTrayContext)
diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp
index 8aa5534366..3c21d767be 100644
--- a/src/widgets/widgets/qabstractscrollarea.cpp
+++ b/src/widgets/widgets/qabstractscrollarea.cpp
@@ -57,6 +57,7 @@
#include <QDebug>
#include "qabstractscrollarea_p.h"
+#include "qscrollbar_p.h"
#include <qwidget.h>
#include <private/qapplication_p.h>
@@ -183,6 +184,7 @@ QAbstractScrollAreaScrollBarContainer::QAbstractScrollAreaScrollBarContainer(Qt:
layout->setMargin(0);
layout->setSpacing(0);
layout->addWidget(scrollBar);
+ layout->setSizeConstraint(QLayout::SetMaximumSize);
}
/*! \internal
@@ -266,6 +268,8 @@ void QAbstractScrollAreaPrivate::replaceScrollBar(QScrollBar *scrollBar,
scrollBar->setSliderPosition(oldBar->sliderPosition());
scrollBar->setTracking(oldBar->hasTracking());
scrollBar->setValue(oldBar->value());
+ scrollBar->installEventFilter(q);
+ oldBar->removeEventFilter(q);
delete oldBar;
QObject::connect(scrollBar, SIGNAL(valueChanged(int)),
@@ -286,6 +290,7 @@ void QAbstractScrollAreaPrivate::init()
hbar = scrollBarContainers[Qt::Horizontal]->scrollBar;
hbar->setRange(0,0);
scrollBarContainers[Qt::Horizontal]->setVisible(false);
+ hbar->installEventFilter(q);
QObject::connect(hbar, SIGNAL(valueChanged(int)), q, SLOT(_q_hslide(int)));
QObject::connect(hbar, SIGNAL(rangeChanged(int,int)), q, SLOT(_q_showOrHideScrollBars()), Qt::QueuedConnection);
scrollBarContainers[Qt::Vertical] = new QAbstractScrollAreaScrollBarContainer(Qt::Vertical, q);
@@ -293,6 +298,7 @@ void QAbstractScrollAreaPrivate::init()
vbar = scrollBarContainers[Qt::Vertical]->scrollBar;
vbar->setRange(0,0);
scrollBarContainers[Qt::Vertical]->setVisible(false);
+ vbar->installEventFilter(q);
QObject::connect(vbar, SIGNAL(valueChanged(int)), q, SLOT(_q_vslide(int)));
QObject::connect(vbar, SIGNAL(rangeChanged(int,int)), q, SLOT(_q_showOrHideScrollBars()), Qt::QueuedConnection);
viewportFilter.reset(new QAbstractScrollAreaFilter(this));
@@ -323,10 +329,10 @@ void QAbstractScrollAreaPrivate::layoutChildren()
{
Q_Q(QAbstractScrollArea);
bool needh = (hbarpolicy == Qt::ScrollBarAlwaysOn
- || (hbarpolicy == Qt::ScrollBarAsNeeded && hbar->minimum() < hbar->maximum()));
+ || (hbarpolicy == Qt::ScrollBarAsNeeded && hbar->minimum() < hbar->maximum() && !hbar->sizeHint().isEmpty()));
bool needv = (vbarpolicy == Qt::ScrollBarAlwaysOn
- || (vbarpolicy == Qt::ScrollBarAsNeeded && vbar->minimum() < vbar->maximum()));
+ || (vbarpolicy == Qt::ScrollBarAsNeeded && vbar->minimum() < vbar->maximum() && !vbar->sizeHint().isEmpty()));
QStyleOption opt(0);
opt.init(q);
@@ -648,6 +654,7 @@ void QAbstractScrollArea::setVerticalScrollBarPolicy(Qt::ScrollBarPolicy policy)
d->layoutChildren();
if (oldPolicy != d->vbarpolicy)
d->scrollBarPolicyChanged(Qt::Vertical, d->vbarpolicy);
+ d->setScrollBarTransient(d->vbar, policy == Qt::ScrollBarAsNeeded);
}
@@ -709,6 +716,7 @@ void QAbstractScrollArea::setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy polic
d->layoutChildren();
if (oldPolicy != d->hbarpolicy)
d->scrollBarPolicyChanged(Qt::Horizontal, d->hbarpolicy);
+ d->setScrollBarTransient(d->hbar, policy == Qt::ScrollBarAsNeeded);
}
/*!
@@ -921,6 +929,20 @@ void QAbstractScrollArea::setViewportMargins(const QMargins &margins)
margins.right(), margins.bottom());
}
+/*! \internal */
+bool QAbstractScrollArea::eventFilter(QObject *o, QEvent *e)
+{
+ Q_D(QAbstractScrollArea);
+ if ((o == d->hbar || o == d->vbar) && (e->type() == QEvent::HoverEnter || e->type() == QEvent::HoverLeave)) {
+ Qt::ScrollBarPolicy policy = o == d->hbar ? d->vbarpolicy : d->hbarpolicy;
+ if (policy == Qt::ScrollBarAsNeeded) {
+ QScrollBar *sibling = o == d->hbar ? d->vbar : d->hbar;
+ d->setScrollBarTransient(sibling, e->type() == QEvent::HoverLeave);
+ }
+ }
+ return QFrame::eventFilter(o, e);
+}
+
/*!
\fn bool QAbstractScrollArea::event(QEvent *event)
@@ -1421,12 +1443,26 @@ bool QAbstractScrollAreaPrivate::canStartScrollingAt( const QPoint &startPos )
return true;
}
+void QAbstractScrollAreaPrivate::flashScrollBars()
+{
+ if (hbarpolicy == Qt::ScrollBarAsNeeded)
+ hbar->d_func()->flash();
+ if (vbarpolicy == Qt::ScrollBarAsNeeded)
+ vbar->d_func()->flash();
+}
+
+void QAbstractScrollAreaPrivate::setScrollBarTransient(QScrollBar *scrollBar, bool transient)
+{
+ scrollBar->d_func()->setTransient(transient);
+}
+
void QAbstractScrollAreaPrivate::_q_hslide(int x)
{
Q_Q(QAbstractScrollArea);
int dx = xoffset - x;
xoffset = x;
q->scrollContentsBy(dx, 0);
+ flashScrollBars();
}
void QAbstractScrollAreaPrivate::_q_vslide(int y)
@@ -1435,6 +1471,7 @@ void QAbstractScrollAreaPrivate::_q_vslide(int y)
int dy = yoffset - y;
yoffset = y;
q->scrollContentsBy(0, dy);
+ flashScrollBars();
}
void QAbstractScrollAreaPrivate::_q_showOrHideScrollBars()
diff --git a/src/widgets/widgets/qabstractscrollarea.h b/src/widgets/widgets/qabstractscrollarea.h
index 560df9dcae..5ac140241e 100644
--- a/src/widgets/widgets/qabstractscrollarea.h
+++ b/src/widgets/widgets/qabstractscrollarea.h
@@ -96,6 +96,7 @@ protected:
void setViewportMargins(int left, int top, int right, int bottom);
void setViewportMargins(const QMargins &margins);
+ bool eventFilter(QObject *, QEvent *);
bool event(QEvent *);
virtual bool viewportEvent(QEvent *);
diff --git a/src/widgets/widgets/qabstractscrollarea_p.h b/src/widgets/widgets/qabstractscrollarea_p.h
index d77d97e03f..7e2ca741b1 100644
--- a/src/widgets/widgets/qabstractscrollarea_p.h
+++ b/src/widgets/widgets/qabstractscrollarea_p.h
@@ -92,6 +92,9 @@ public:
virtual void scrollBarPolicyChanged(Qt::Orientation, Qt::ScrollBarPolicy) {}
bool canStartScrollingAt( const QPoint &startPos );
+ void flashScrollBars();
+ void setScrollBarTransient(QScrollBar *scrollBar, bool transient);
+
void _q_hslide(int);
void _q_vslide(int);
void _q_showOrHideScrollBars();
diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp
index 845cb5dbd0..c48d7172ab 100644
--- a/src/widgets/widgets/qabstractspinbox.cpp
+++ b/src/widgets/widgets/qabstractspinbox.cpp
@@ -825,7 +825,7 @@ QSize QAbstractSpinBox::sizeHint() const
ensurePolished();
const QFontMetrics fm(fontMetrics());
- int h = d->edit->sizeHint().height();
+ int h = d->edit->sizeHint().height() + 4;
int w = 0;
QString s;
s = d->prefix + d->textFromValue(d->minimum) + d->suffix + QLatin1Char(' ');
@@ -843,17 +843,6 @@ QSize QAbstractSpinBox::sizeHint() const
QStyleOptionSpinBox opt;
initStyleOption(&opt);
QSize hint(w, h);
- QSize extra(35, 6);
- opt.rect.setSize(hint + extra);
- extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt,
- QStyle::SC_SpinBoxEditField, this).size();
- // get closer to final result by repeating the calculation
- opt.rect.setSize(hint + extra);
- extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt,
- QStyle::SC_SpinBoxEditField, this).size();
- hint += extra;
-
- opt.rect = rect();
d->cachedSizeHint = style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, this)
.expandedTo(QApplication::globalStrut());
}
diff --git a/src/widgets/widgets/qcheckbox.cpp b/src/widgets/widgets/qcheckbox.cpp
index 29ac80c77d..bf6593d976 100644
--- a/src/widgets/widgets/qcheckbox.cpp
+++ b/src/widgets/widgets/qcheckbox.cpp
@@ -216,6 +216,13 @@ QCheckBox::QCheckBox(const QString &text, QWidget *parent)
setText(text);
}
+/*!
+ Destructor.
+*/
+QCheckBox::~QCheckBox()
+{
+}
+
void QCheckBox::setTristate(bool y)
{
Q_D(QCheckBox);
diff --git a/src/widgets/widgets/qcheckbox.h b/src/widgets/widgets/qcheckbox.h
index c7f33b933a..468c8717c7 100644
--- a/src/widgets/widgets/qcheckbox.h
+++ b/src/widgets/widgets/qcheckbox.h
@@ -61,7 +61,7 @@ class Q_WIDGETS_EXPORT QCheckBox : public QAbstractButton
public:
explicit QCheckBox(QWidget *parent=0);
explicit QCheckBox(const QString &text, QWidget *parent=0);
-
+ ~QCheckBox();
QSize sizeHint() const;
QSize minimumSizeHint() const;
diff --git a/src/widgets/widgets/qcommandlinkbutton.cpp b/src/widgets/widgets/qcommandlinkbutton.cpp
index 5207241b84..11c4b411f0 100644
--- a/src/widgets/widgets/qcommandlinkbutton.cpp
+++ b/src/widgets/widgets/qcommandlinkbutton.cpp
@@ -302,6 +302,13 @@ QCommandLinkButton::QCommandLinkButton(const QString &text, const QString &descr
d->init();
}
+/*!
+ Destructor.
+*/
+QCommandLinkButton::~QCommandLinkButton()
+{
+}
+
/*! \reimp */
bool QCommandLinkButton::event(QEvent *e)
{
diff --git a/src/widgets/widgets/qcommandlinkbutton.h b/src/widgets/widgets/qcommandlinkbutton.h
index 731d02a60c..ec8fd339d0 100644
--- a/src/widgets/widgets/qcommandlinkbutton.h
+++ b/src/widgets/widgets/qcommandlinkbutton.h
@@ -61,7 +61,9 @@ class Q_WIDGETS_EXPORT QCommandLinkButton: public QPushButton
public:
explicit QCommandLinkButton(QWidget *parent=0);
explicit QCommandLinkButton(const QString &text, QWidget *parent=0);
- QCommandLinkButton(const QString &text, const QString &description, QWidget *parent=0);
+ explicit QCommandLinkButton(const QString &text, const QString &description, QWidget *parent=0);
+ ~QCommandLinkButton();
+
QString description() const;
void setDescription(const QString &description);
diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp
index 8a23530283..0895c96577 100644
--- a/src/widgets/widgets/qdatetimeedit.cpp
+++ b/src/widgets/widgets/qdatetimeedit.cpp
@@ -219,6 +219,13 @@ QDateTimeEdit::QDateTimeEdit(const QVariant &var, QVariant::Type parserType, QWi
}
/*!
+ Destructor.
+*/
+QDateTimeEdit::~QDateTimeEdit()
+{
+}
+
+/*!
\property QDateTimeEdit::dateTime
\brief the QDateTime that is set in the QDateTimeEdit
@@ -1562,6 +1569,13 @@ QTimeEdit::QTimeEdit(const QTime &time, QWidget *parent)
}
/*!
+ Destructor.
+*/
+QTimeEdit::~QTimeEdit()
+{
+}
+
+/*!
\property QTimeEdit::time
\internal
\sa QDateTimeEdit::time
@@ -1631,6 +1645,13 @@ QDateEdit::QDateEdit(const QDate &date, QWidget *parent)
}
/*!
+ Destructor.
+*/
+QDateEdit::~QDateEdit()
+{
+}
+
+/*!
\property QDateEdit::date
\internal
\sa QDateTimeEdit::date
diff --git a/src/widgets/widgets/qdatetimeedit.h b/src/widgets/widgets/qdatetimeedit.h
index 7ce7037dd0..7435013bec 100644
--- a/src/widgets/widgets/qdatetimeedit.h
+++ b/src/widgets/widgets/qdatetimeedit.h
@@ -100,6 +100,7 @@ public:
explicit QDateTimeEdit(const QDateTime &dt, QWidget *parent = 0);
explicit QDateTimeEdit(const QDate &d, QWidget *parent = 0);
explicit QDateTimeEdit(const QTime &t, QWidget *parent = 0);
+ ~QDateTimeEdit();
QDateTime dateTime() const;
QDate date() const;
@@ -207,8 +208,9 @@ class Q_WIDGETS_EXPORT QTimeEdit : public QDateTimeEdit
Q_OBJECT
Q_PROPERTY(QTime time READ time WRITE setTime NOTIFY userTimeChanged USER true)
public:
- QTimeEdit(QWidget *parent = 0);
- QTimeEdit(const QTime &time, QWidget *parent = 0);
+ explicit QTimeEdit(QWidget *parent = 0);
+ explicit QTimeEdit(const QTime &time, QWidget *parent = 0);
+ ~QTimeEdit();
Q_SIGNALS:
void userTimeChanged(const QTime &time);
@@ -219,8 +221,9 @@ class Q_WIDGETS_EXPORT QDateEdit : public QDateTimeEdit
Q_OBJECT
Q_PROPERTY(QDate date READ date WRITE setDate NOTIFY userDateChanged USER true)
public:
- QDateEdit(QWidget *parent = 0);
- QDateEdit(const QDate &date, QWidget *parent = 0);
+ explicit QDateEdit(QWidget *parent = 0);
+ explicit QDateEdit(const QDate &date, QWidget *parent = 0);
+ ~QDateEdit();
Q_SIGNALS:
void userDateChanged(const QDate &date);
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index a06c8ed54c..f4539e8e4a 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -120,8 +120,7 @@ void QLineEdit::initStyleOption(QStyleOptionFrame *option) const
if (hasEditFocus())
option->state |= QStyle::State_HasEditFocus;
#endif
- if (QStyleOptionFrameV2 *optionV2 = qstyleoption_cast<QStyleOptionFrameV2 *>(option))
- optionV2->features = QStyleOptionFrameV2::None;
+ option->features = QStyleOptionFrame::None;
}
/*!
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index 93492bab61..056e2cbacc 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -100,6 +100,7 @@ public:
QCursor separatorCursor(const QList<int> &path) const;
void adjustCursor(const QPoint &pos);
QCursor oldCursor;
+ QCursor adjustedCursor;
uint hasOldCursor : 1;
uint cursorAdjusted : 1;
#endif
@@ -1300,7 +1301,7 @@ void QMainWindowPrivate::adjustCursor(const QPoint &pos)
else
q->unsetCursor();
}
- } else {
+ } else if (layout->movingSeparator.isEmpty()) { // Don't change cursor when moving separator
QList<int> pathToSeparator
= layout->layoutState.dockAreaLayout.findSeparator(pos);
@@ -1324,9 +1325,8 @@ void QMainWindowPrivate::adjustCursor(const QPoint &pos)
oldCursor = q->cursor();
hasOldCursor = q->testAttribute(Qt::WA_SetCursor);
}
- QCursor cursor = separatorCursor(hoverSeparator);
- cursorAdjusted = false; //to not reset the oldCursor in event(CursorChange)
- q->setCursor(cursor);
+ adjustedCursor = separatorCursor(hoverSeparator);
+ q->setCursor(adjustedCursor);
cursorAdjusted = true;
}
}
@@ -1452,9 +1452,15 @@ bool QMainWindow::event(QEvent *event)
#endif // Q_WS_MAC
#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR)
case QEvent::CursorChange:
- if (d->cursorAdjusted) {
+ // CursorChange events are triggered as mouse moves to new widgets even
+ // if the cursor doesn't actually change, so do not change oldCursor if
+ // the "changed" cursor has same shape as adjusted cursor.
+ if (d->cursorAdjusted && d->adjustedCursor.shape() != cursor().shape()) {
d->oldCursor = cursor();
d->hasOldCursor = testAttribute(Qt::WA_SetCursor);
+
+ // Ensure our adjusted cursor stays visible
+ setCursor(d->adjustedCursor);
}
break;
#endif
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index fe7e444e86..47ffdda3b6 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -543,6 +543,16 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason
{
Q_Q(QMenu);
tearoffHighlighted = 0;
+ // Reselect the currently active action in case mouse moved over other menu items when
+ // moving from sub menu action to sub menu (QTBUG-20094).
+ if (reason != SelectedFromKeyboard && action == currentAction && !(action && action->menu() && action->menu() != activeMenu)) {
+ if (QMenu *menu = qobject_cast<QMenu*>(causedPopup.widget)) {
+ if (causedPopup.action && menu->d_func()->activeMenu == q)
+ menu->d_func()->setCurrentAction(causedPopup.action, 0, reason, false);
+ }
+ return;
+ }
+
if (currentAction)
q->update(actionRect(currentAction));
diff --git a/src/widgets/widgets/qprogressbar.cpp b/src/widgets/widgets/qprogressbar.cpp
index b7726e7771..2bd893003d 100644
--- a/src/widgets/widgets/qprogressbar.cpp
+++ b/src/widgets/widgets/qprogressbar.cpp
@@ -244,6 +244,13 @@ QProgressBar::QProgressBar(QWidget *parent)
}
/*!
+ Destructor.
+*/
+QProgressBar::~QProgressBar()
+{
+}
+
+/*!
Reset the progress bar. The progress bar "rewinds" and shows no
progress.
*/
diff --git a/src/widgets/widgets/qprogressbar.h b/src/widgets/widgets/qprogressbar.h
index 30a4863f84..a830df7a57 100644
--- a/src/widgets/widgets/qprogressbar.h
+++ b/src/widgets/widgets/qprogressbar.h
@@ -73,6 +73,7 @@ public:
enum Direction { TopToBottom, BottomToTop };
explicit QProgressBar(QWidget *parent = 0);
+ ~QProgressBar();
int minimum() const;
int maximum() const;
diff --git a/src/widgets/widgets/qradiobutton.cpp b/src/widgets/widgets/qradiobutton.cpp
index 78d53ad0e6..d4abd3389f 100644
--- a/src/widgets/widgets/qradiobutton.cpp
+++ b/src/widgets/widgets/qradiobutton.cpp
@@ -144,6 +144,13 @@ QRadioButton::QRadioButton(QWidget *parent)
}
/*!
+ Destructor.
+*/
+QRadioButton::~QRadioButton()
+{
+}
+
+/*!
Constructs a radio button with the given \a parent and a \a text string.
The \a parent argument is passed on to the QAbstractButton constructor.
diff --git a/src/widgets/widgets/qradiobutton.h b/src/widgets/widgets/qradiobutton.h
index eeb029871c..dec49dd090 100644
--- a/src/widgets/widgets/qradiobutton.h
+++ b/src/widgets/widgets/qradiobutton.h
@@ -59,6 +59,7 @@ class Q_WIDGETS_EXPORT QRadioButton : public QAbstractButton
public:
explicit QRadioButton(QWidget *parent=0);
explicit QRadioButton(const QString &text, QWidget *parent=0);
+ ~QRadioButton();
QSize sizeHint() const;
QSize minimumSizeHint() const;
diff --git a/src/widgets/widgets/qscrollarea.cpp b/src/widgets/widgets/qscrollarea.cpp
index be7ce10c8c..576f77a7b7 100644
--- a/src/widgets/widgets/qscrollarea.cpp
+++ b/src/widgets/widgets/qscrollarea.cpp
@@ -331,7 +331,7 @@ bool QScrollArea::eventFilter(QObject *o, QEvent *e)
if (o == d->widget && e->type() == QEvent::Resize)
d->updateScrollBars();
- return false;
+ return QAbstractScrollArea::eventFilter(o, e);
}
/*!
diff --git a/src/widgets/widgets/qscrollbar.cpp b/src/widgets/widgets/qscrollbar.cpp
index aa45b4f54e..199aaf93de 100644
--- a/src/widgets/widgets/qscrollbar.cpp
+++ b/src/widgets/widgets/qscrollbar.cpp
@@ -55,7 +55,7 @@
#include "qaccessible.h"
#endif
#include <limits.h>
-#include "qabstractslider_p.h"
+#include "qscrollbar_p.h"
QT_BEGIN_NAMESPACE
@@ -201,26 +201,6 @@ QT_BEGIN_NAMESPACE
\sa QScrollArea, QSlider, QDial, QSpinBox, {fowler}{GUI Design Handbook: Scroll Bar}, {Sliders Example}
*/
-class QScrollBarPrivate : public QAbstractSliderPrivate
-{
- Q_DECLARE_PUBLIC(QScrollBar)
-public:
- QStyle::SubControl pressedControl;
- bool pointerOutsidePressedControl;
-
- int clickOffset, snapBackPosition;
-
- void activateControl(uint control, int threshold = 500);
- void stopRepeatAction();
- int pixelPosToRangeValue(int pos) const;
- void init();
- bool updateHoverControl(const QPoint &pos);
- QStyle::SubControl newHoverControl(const QPoint &pos);
-
- QStyle::SubControl hoverControl;
- QRect hoverRect;
-};
-
bool QScrollBarPrivate::updateHoverControl(const QPoint &pos)
{
Q_Q(QScrollBar);
@@ -249,6 +229,29 @@ QStyle::SubControl QScrollBarPrivate::newHoverControl(const QPoint &pos)
return hoverControl;
}
+void QScrollBarPrivate::setTransient(bool value)
+{
+ Q_Q(QScrollBar);
+ if (transient != value) {
+ transient = value;
+ if (transient) {
+ if (q->isVisible() && q->style()->styleHint(QStyle::SH_ScrollBar_Transient))
+ q->update();
+ } else if (!q->isVisible()) {
+ q->show();
+ }
+ }
+}
+
+void QScrollBarPrivate::flash()
+{
+ Q_Q(QScrollBar);
+ if (!flashed && q->style()->styleHint(QStyle::SH_ScrollBar_Transient)) {
+ flashed = true;
+ q->show();
+ }
+}
+
void QScrollBarPrivate::activateControl(uint control, int threshold)
{
QAbstractSlider::SliderAction action = QAbstractSlider::SliderNoAction;
@@ -322,6 +325,8 @@ void QScrollBar::initStyleOption(QStyleOptionSlider *option) const
option->upsideDown = d->invertedAppearance;
if (d->orientation == Qt::Horizontal)
option->state |= QStyle::State_Horizontal;
+ if (d->flashed || !d->transient)
+ option->state |= QStyle::State_On;
}
@@ -379,6 +384,8 @@ void QScrollBarPrivate::init()
invertedControls = true;
pressedControl = hoverControl = QStyle::SC_None;
pointerOutsidePressedControl = false;
+ transient = q->style()->styleHint(QStyle::SH_ScrollBar_Transient);
+ flashed = false;
q->setFocusPolicy(Qt::NoFocus);
QSizePolicy sp(QSizePolicy::Minimum, QSizePolicy::Fixed, QSizePolicy::Slider);
if (orientation == Qt::Vertical)
@@ -476,6 +483,9 @@ bool QScrollBar::event(QEvent *event)
if (const QHoverEvent *he = static_cast<const QHoverEvent *>(event))
d_func()->updateHoverControl(he->pos());
break;
+ case QEvent::StyleChange:
+ d_func()->setTransient(style()->styleHint(QStyle::SH_ScrollBar_Transient));
+ break;
default:
break;
}
@@ -521,6 +531,10 @@ void QScrollBar::paintEvent(QPaintEvent *)
opt.activeSubControls = (QStyle::SubControl)d->hoverControl;
}
style()->drawComplexControl(QStyle::CC_ScrollBar, &opt, &p, this);
+ if (d->flashed && style()->styleHint(QStyle::SH_ScrollBar_Transient)) {
+ d->flashed = false;
+ update();
+ }
}
/*!
diff --git a/src/widgets/widgets/qscrollbar.h b/src/widgets/widgets/qscrollbar.h
index 48863616ff..3e9ac8a47f 100644
--- a/src/widgets/widgets/qscrollbar.h
+++ b/src/widgets/widgets/qscrollbar.h
@@ -83,6 +83,7 @@ protected:
private:
+ friend class QAbstractScrollAreaPrivate;
friend Q_WIDGETS_EXPORT QStyleOptionSlider qt_qscrollbarStyleOption(QScrollBar *scrollBar);
Q_DISABLE_COPY(QScrollBar)
diff --git a/src/widgets/widgets/qscrollbar_p.h b/src/widgets/widgets/qscrollbar_p.h
new file mode 100644
index 0000000000..fb4f5b07da
--- /dev/null
+++ b/src/widgets/widgets/qscrollbar_p.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSCROLLBAR_P_H
+#define QSCROLLBAR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "private/qabstractslider_p.h"
+#include "qstyle.h"
+
+QT_BEGIN_NAMESPACE
+
+class QScrollBarPrivate : public QAbstractSliderPrivate
+{
+ Q_DECLARE_PUBLIC(QScrollBar)
+public:
+ QStyle::SubControl pressedControl;
+ bool pointerOutsidePressedControl;
+
+ int clickOffset, snapBackPosition;
+
+ void activateControl(uint control, int threshold = 500);
+ void stopRepeatAction();
+ int pixelPosToRangeValue(int pos) const;
+ void init();
+ bool updateHoverControl(const QPoint &pos);
+ QStyle::SubControl newHoverControl(const QPoint &pos);
+
+ QStyle::SubControl hoverControl;
+ QRect hoverRect;
+
+ bool transient;
+ void setTransient(bool value);
+
+ bool flashed;
+ void flash();
+};
+
+QT_END_NAMESPACE
+
+#endif // QSCROLLBAR_P_H
diff --git a/src/widgets/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp
index 6a11c6d88c..cb09e8bb32 100644
--- a/src/widgets/widgets/qspinbox.cpp
+++ b/src/widgets/widgets/qspinbox.cpp
@@ -209,6 +209,10 @@ QSpinBox::QSpinBox(QWidget *parent)
d->init();
}
+/*!
+ Destructor.
+*/
+QSpinBox::~QSpinBox() {}
/*!
\property QSpinBox::value
@@ -580,6 +584,11 @@ QDoubleSpinBox::QDoubleSpinBox(QWidget *parent)
}
/*!
+ Destructor.
+*/
+QDoubleSpinBox::~QDoubleSpinBox() {}
+
+/*!
\property QDoubleSpinBox::value
\brief the value of the spin box
diff --git a/src/widgets/widgets/qspinbox.h b/src/widgets/widgets/qspinbox.h
index b9475254db..889b283c2a 100644
--- a/src/widgets/widgets/qspinbox.h
+++ b/src/widgets/widgets/qspinbox.h
@@ -66,6 +66,7 @@ class Q_WIDGETS_EXPORT QSpinBox : public QAbstractSpinBox
public:
explicit QSpinBox(QWidget *parent = 0);
+ ~QSpinBox();
int value() const;
@@ -124,6 +125,7 @@ class Q_WIDGETS_EXPORT QDoubleSpinBox : public QAbstractSpinBox
Q_PROPERTY(double value READ value WRITE setValue NOTIFY valueChanged USER true)
public:
explicit QDoubleSpinBox(QWidget *parent = 0);
+ ~QDoubleSpinBox();
double value() const;
diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp
index 794a824589..70c493cedd 100644
--- a/src/widgets/widgets/qsplitter.cpp
+++ b/src/widgets/widgets/qsplitter.cpp
@@ -124,6 +124,13 @@ QSplitterHandle::QSplitterHandle(Qt::Orientation orientation, QSplitter *parent)
}
/*!
+ Destructor.
+*/
+QSplitterHandle::~QSplitterHandle()
+{
+}
+
+/*!
Sets the orientation of the splitter handle to \a orientation.
This is usually propagated from the QSplitter.
@@ -917,6 +924,10 @@ QSplitterLayoutStruct *QSplitterPrivate::insertWidget(int index, QWidget *w)
When you hide() a child its space will be distributed among the
other children. It will be reinstated when you show() it again.
+ \note Adding a QLayout to a QSplitter is not supported (either through
+ setLayout() or making the QSplitter a parent of the QLayout); use addWidget()
+ instead (see example above).
+
\sa QSplitterHandle, QHBoxLayout, QVBoxLayout, QTabWidget
*/
@@ -1207,8 +1218,11 @@ int QSplitter::count() const
void QSplitter::childEvent(QChildEvent *c)
{
Q_D(QSplitter);
- if (!c->child()->isWidgetType())
+ if (!c->child()->isWidgetType()) {
+ if (c->type() == QEvent::ChildAdded && qobject_cast<QLayout *>(c->child()))
+ qWarning("Adding a QLayout to a QSplitter is not supported.");
return;
+ }
QWidget *w = static_cast<QWidget*>(c->child());
if (c->added() && !d->blockChildAdd && !w->isWindow() && !d->findWidget(w)) {
d->insertWidget_helper(d->list.count(), w, false);
@@ -1529,7 +1543,7 @@ void QSplitter::setSizes(const QList<int> &list)
and style preferences.
If you set handleWidth to 1 or 0, the actual grab area will grow to overlap a
- few pixels of it's respective widgets.
+ few pixels of its respective widgets.
*/
int QSplitter::handleWidth() const
diff --git a/src/widgets/widgets/qsplitter.h b/src/widgets/widgets/qsplitter.h
index 18d3bae3e2..2bcdc54c0e 100644
--- a/src/widgets/widgets/qsplitter.h
+++ b/src/widgets/widgets/qsplitter.h
@@ -140,7 +140,9 @@ class Q_WIDGETS_EXPORT QSplitterHandle : public QWidget
{
Q_OBJECT
public:
- QSplitterHandle(Qt::Orientation o, QSplitter *parent);
+ explicit QSplitterHandle(Qt::Orientation o, QSplitter *parent);
+ ~QSplitterHandle();
+
void setOrientation(Qt::Orientation o);
Qt::Orientation orientation() const;
bool opaqueResize() const;
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index bed8296989..7d68e40c9f 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -1456,6 +1456,15 @@ void QWidgetLineControl::complete(int key)
}
#endif
+void QWidgetLineControl::setReadOnly(bool enable)
+{
+ m_readOnly = enable;
+ if (enable)
+ setCursorBlinkPeriod(0);
+ else
+ setCursorBlinkPeriod(QApplication::cursorFlashTime());
+}
+
void QWidgetLineControl::setCursorBlinkPeriod(int msec)
{
if (msec == m_blinkPeriod)
@@ -1463,7 +1472,7 @@ void QWidgetLineControl::setCursorBlinkPeriod(int msec)
if (m_blinkTimer) {
killTimer(m_blinkTimer);
}
- if (msec) {
+ if (msec && !m_readOnly) {
m_blinkTimer = startTimer(msec / 2);
m_blinkStatus = 1;
} else {
@@ -1474,6 +1483,7 @@ void QWidgetLineControl::setCursorBlinkPeriod(int msec)
m_blinkPeriod = msec;
}
+// This is still used by QDeclarativeTextInput in the qtquick1 repo
void QWidgetLineControl::resetCursorBlinkTimer()
{
if (m_blinkPeriod == 0 || m_blinkTimer == 0)
diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h
index 185bc117b6..13cba8baff 100644
--- a/src/widgets/widgets/qwidgetlinecontrol_p.h
+++ b/src/widgets/widgets/qwidgetlinecontrol_p.h
@@ -213,7 +213,7 @@ public:
}
bool isReadOnly() const { return m_readOnly; }
- void setReadOnly(bool enable) { m_readOnly = enable; }
+ void setReadOnly(bool enable);
QString text() const
{
diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri
index c86bc1eff7..797f3e9b76 100644
--- a/src/widgets/widgets/widgets.pri
+++ b/src/widgets/widgets/widgets.pri
@@ -46,6 +46,7 @@ HEADERS += \
widgets/qradiobutton.h \
widgets/qrubberband.h \
widgets/qscrollbar.h \
+ widgets/qscrollbar_p.h \
widgets/qscrollarea_p.h \
widgets/qsizegrip.h \
widgets/qslider.h \