45 #include <private/qmath_p.h> 46 #include <private/qstyle_p.h> 51 #elif defined(Q_WS_MAC) 52 #include <private/qt_cocoa_helpers_mac_p.h> 73 if (
const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
78 #endif // QT_NO_SPINBOX 84 static qreal scale = -1;
89 HDC hdcScreen = GetDC(0);
90 int dpi = GetDeviceCaps(hdcScreen, LOGPIXELSX);
91 ReleaseDC(0, hdcScreen);
94 #elif defined(Q_WS_MAC) 106 int bigLineSize = radius / 6;
109 if (bigLineSize > radius / 2)
110 bigLineSize = radius / 2;
118 const int r =
qMin(width, height) / 2;
129 qreal xc = width / 2.0;
130 qreal yc = height / 2.0;
132 qreal back = offset * len;
139 static const qreal rad_factor = 180 /
Q_PI;
142 if (p1.
x() == p2.
x()) {
148 qreal x1, x2, y1, y2;
150 if (p1.
x() <= p2.
x()) {
151 x1 = p1.
x(); y1 = p1.
y();
152 x2 = p2.
x(); y2 = p2.
y();
154 x2 = p1.
x(); y2 = p1.
y();
155 x1 = p2.
x(); y1 = p2.
y();
158 qreal m = -(y2 - y1) / (x2 - x1);
159 _angle =
qAtan(m) * rad_factor;
162 _angle = 180 - _angle;
177 qreal xc = width / 2 + 0.5;
178 qreal yc = height / 2 + 0.5;
186 int maximum = dial->
minimum + 1000;
187 notches = (maximum + ns - 1 - dial->
minimum) / ns;
190 poly.
resize(2 + 2 * notches);
191 int smallLineSize = bigLineSize / 2;
192 for (
int i = 0; i <= notches; ++i) {
194 : (
Q_PI * 8 - i * 10 *
Q_PI / notches) / 6;
198 poly[2 * i] =
QPointF(xc + (r - bigLineSize) * c,
199 yc - (r - bigLineSize) * s);
200 poly[2 * i + 1] =
QPointF(xc + r * c, yc - r * s);
202 poly[2 * i] =
QPointF(xc + (r - 1 - smallLineSize) * c,
203 yc - (r - 1 - smallLineSize) * s);
204 poly[2 * i + 1] =
QPointF(xc + (r - 1) * c, yc -(r - 1) * s);
222 const qreal penSize = r/20.0;
237 const qreal d_ = r / 6;
238 const qreal dx = option->
rect.
x() + d_ + (width - 2 * r) / 2 + 1;
239 const qreal dy = option->
rect.
y() + d_ + (height - 2 * r) / 2 + 1;
242 int(r * 2 - 2 * d_ - 2),
243 int(r * 2 - 2 * d_ - 2));
244 buttonColor.
setHsv(buttonColor .hue(),
245 qMin(140, buttonColor .saturation()),
247 QColor shadowColor(0, 0, 0, 20);
251 qreal shadowSize =
qMax(1.0, penSize/2.0);
253 2*shadowSize, 2*shadowSize);
259 p->setBrush(shadowGradient);
261 p->translate(shadowSize, shadowSize);
262 p->drawEllipse(shadowRect);
263 p->translate(-shadowSize, -shadowSize);
267 br.width()*1.3, br.center().x(),
268 br.center().y() - br.height()/2);
270 gradient.setColorAt(
qreal(0.5), buttonColor);
271 gradient.setColorAt(
qreal(0.501), buttonColor.
darker(102));
272 gradient.setColorAt(1, buttonColor.
darker(115));
273 p->setBrush(gradient);
281 p->setPen(buttonColor.
lighter(110));
282 p->drawEllipse(br.adjusted(1, 1, -1, -1));
290 p->setPen(
QPen(highlight, 2.0));
292 p->drawEllipse(br.adjusted(-1, -1, 1, 1));
298 buttonColor = buttonColor.
lighter(104);
301 QRectF dialRect(dp.x() - ds, dp.y() - ds, 2*ds, 2*ds);
302 QRadialGradient dialGradient(dialRect.center().x() + dialRect.width()/2,
303 dialRect.center().y() + dialRect.width(),
305 dialRect.center().x(), dialRect.center().y());
307 dialGradient.setColorAt(
qreal(0.4), buttonColor.
darker(120));
308 dialGradient.setColorAt(0, buttonColor.
darker(110));
316 painter->
drawEllipse(dialRect.adjusted(-1, -1, 1, 1));
338 QRect(0, 0, left, top));
349 QRect(0, top, left, size.
height() - bottom - top));
353 rect.
height() - bottom - top), pixmap,
355 size.
height() - bottom - top));
364 rect.
width() - right -
left, bottom), pixmap,
#define BEGIN_STYLE_PIXMAPCACHE(a)
The QPainter class performs low-level painting on widgets and other paint devices.
The QColor class provides colors based on RGB, HSV or CMYK values.
const QBrush & highlight() const
Returns the highlight brush of the current color group.
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
void setColorAt(qreal pos, const QColor &color)
Creates a stop point at the given position with the given color.
#define QT_END_NAMESPACE
This macro expands to.
const QColor & color() const
Returns the brush color.
ushort hue
Returns the hue color component of this color.
QSize size() const
Returns the size of the pixmap.
const QBrush & dark() const
Returns the dark brush of the current color group.
static QPointF calcRadialPos(const QStyleOptionSlider *dial, qreal offset)
QStyle::State state
the style flags that are used when drawing the control
QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size)
CGFloat qt_mac_get_scalefactor()
The QPointF class defines a point in the plane using floating point precision.
qint64 cacheKey() const
Returns a number that identifies the contents of this QPalette object.
void restore()
Restores the current painter state (pops a saved state off the stack).
int tickInterval
the interval that should be drawn between tick marks
int left() const
Returns the x-coordinate of the rectangle's left edge.
#define END_STYLE_PIXMAPCACHE
int width() const
Returns the width of the rectangle.
long ASN1_INTEGER_get ASN1_INTEGER * a
QStyle::SubControls activeSubControls
This variable holds a bitwise OR of the sub-controls that are active for the complex control...
void drawLine(const QLineF &line)
Draws a line defined by line.
int height() const
Returns the height of the rectangle.
The QRadialGradient class is used in combination with QBrush to specify a radial gradient brush...
The QString class provides a Unicode character string.
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
void save()
Saves the current painter state (pushes the state onto a stack).
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
qreal x() const
Returns the x-coordinate of this point.
void resize(int size)
Sets the size of the vector to size.
void setHsv(int h, int s, int v, int a=255)
Sets a HSV color value; h is the hue, s is the saturation, v is the value and a is the alpha componen...
bool dialWrapping
whether the dial should wrap or not
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
bool upsideDown
the slider control orientation
int width() const
Returns the width.
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
#define QT_BEGIN_NAMESPACE
This macro expands to.
void drawEllipse(const QRectF &r)
Draws the ellipse defined by the given rectangle.
ushort value
Returns the value color component of this color.
void drawDial(const QStyleOptionSlider *option, QPainter *painter)
The QRectF class defines a rectangle in the plane using floating point precision. ...
int calcBigLineSize(int radius)
void drawLines(const QLineF *lines, int lineCount)
Draws the first lineCount lines in the array lines using the current pen.
The QStyleOption class stores the parameters used by QStyle functions.
ushort saturation
Returns the saturation color component of this color.
The QStyleOptionSpinBox class is used to describe the parameters necessary for drawing a spin box...
The QPolygonF class provides a vector of points using floating point precision.
qreal width() const
Returns the width of the rectangle.
int sliderPosition
the position of the slider handle
QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
qreal dpiScaled(qreal value)
QPalette palette
the palette that should be used when painting the control
int top() const
Returns the y-coordinate of the rectangle's top edge.
qreal angle(const QPointF &p1, const QPointF &p2)
int maximum
the maximum value for the slider
QPolygonF calcLines(const QStyleOptionSlider *dial)
void setAlphaF(qreal alpha)
Sets the alpha of this color to alpha.
int y() const
Returns the y-coordinate of the rectangle's top edge.
T qstyleoption_cast(const QStyleOption *opt)
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
int minimum
the minimum value for the slider
int x() const
Returns the x-coordinate of the rectangle's left edge.
void setBrush(const QBrush &brush)
Sets the painter's brush to the given brush.
void setAlpha(int alpha)
Sets the alpha of this color to alpha.
void setPen(const QColor &color)
Sets the painter's pen to have style Qt::SolidLine, width 0 and the specified color.
int height() const
Returns the height.
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
The QRect class defines a rectangle in the plane using integer precision.
qreal y() const
Returns the y-coordinate of this point.
The QPixmap class is an off-screen image representation that can be used as a paint device...
void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rect, int left, int top, int right, int bottom)
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
int pageStep
the size of the page step of the slider
The QSize class defines the size of a two-dimensional object using integer point precision.
The QStyleOptionComplex class is used to hold parameters that are common to all complex controls...
QColor lighter(int f=150) const
Returns a lighter (or darker) color, but does not change this object.
const QBrush & button() const
Returns the button brush of the current color group.
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
QPointF center() const
Returns the center point of the rectangle.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
QRect rect
the area that should be used for various calculations and painting
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
The QPalette class contains color groups for each widget state.