#include "qcommonstyle.h"
#include "qcommonstyle_p.h"
#include <qapplication.h>
#include <qbitmap.h>
#include <qcache.h>
#include <qdockwidget.h>
#include <qdrawutil.h>
#include <qdialogbuttonbox.h>
#include <qgroupbox.h>
#include <qmenu.h>
#include <qpainter.h>
#include <qpaintengine.h>
#include <qpainterpath.h>
#include <qslider.h>
#include <qstyleoption.h>
#include <qtabbar.h>
#include <qtoolbar.h>
#include <qtoolbutton.h>
#include <qrubberband.h>
#include <private/qcommonstylepixmaps_p.h>
#include <private/qmath_p.h>
#include <qdebug.h>
#include <qtextformat.h>
#include <limits.h>
Include dependency graph for qcommonstyle.cpp:

Go to the source code of this file.
Functions | |
| static void | drawArrow (const QStyle *style, const QStyleOptionToolButton *toolbutton, const QRect &rect, QPainter *painter, const QWidget *widget=0) |
| static qreal | angle (const QPointF &p1, const QPointF &p2) |
| static int | calcBigLineSize (int radius) |
| static QPolygonF | calcArrow (const QStyleOptionSlider *dial, qreal &a) |
| static QPolygonF | calcLines (const QStyleOptionSlider *dial, const QWidget *) |
| static uint | qt_intensity (uint r, uint g, uint b) |
Definition at line 1965 of file qcommonstyle.cpp.
References m, Q_PI, QPointF::x(), and QPointF::y().
Referenced by adapted_angle_on_x(), calcLines(), QCommonStyle::drawComplexControl(), fetchConicalGradient(), GameBoard::GameBoard(), PieView::indexAt(), PieView::itemRegion(), GLWidget::makeGear(), qdesigner_internal::QtGradientWidget::mouseMoveEvent(), qdesigner_internal::QtGradientWidget::mousePressEvent(), MyWidget::MyWidget(), operator<<(), operator>>(), Edge::paint(), GradientRenderer::paint(), PieView::paintEvent(), and KAsteroidsView::processShip().
01966 { 01967 static const qreal rad_factor = 180.0 / Q_PI; 01968 qreal _angle = 0.0; 01969 01970 if (p1.x() == p2.x()) { 01971 if (p1.y() < p2.y()) 01972 _angle = 270.0; 01973 else 01974 _angle = 90.0; 01975 } else { 01976 qreal x1, x2, y1, y2; 01977 01978 if (p1.x() <= p2.x()) { 01979 x1 = p1.x(); y1 = p1.y(); 01980 x2 = p2.x(); y2 = p2.y(); 01981 } else { 01982 x2 = p1.x(); y2 = p1.y(); 01983 x1 = p2.x(); y1 = p2.y(); 01984 } 01985 01986 qreal m = -(y2 - y1) / (x2 - x1); 01987 _angle = atan(m) * rad_factor; 01988 01989 if (p1.x() < p2.x()) 01990 _angle = 180.0 - _angle; 01991 else 01992 _angle = -_angle; 01993 } 01994 return _angle; 01995 }
Here is the call graph for this function:

| static QPolygonF calcArrow | ( | const QStyleOptionSlider * | dial, | |
| qreal & | a | |||
| ) | [static] |
Definition at line 2007 of file qcommonstyle.cpp.
References calcBigLineSize(), QStyleOptionSlider::dialWrapping, height, QRect::height(), len, QStyleOptionSlider::maximum, QStyleOptionSlider::minimum, Q_PI, qCos, qMin(), qSin, QStyleOption::rect, QStyleOptionSlider::sliderValue, QRect::width(), and width.
Referenced by QCommonStyle::drawComplexControl().
02008 { 02009 int width = dial->rect.width(); 02010 int height = dial->rect.height(); 02011 int r = qMin(width, height) / 2; 02012 if (dial->maximum == dial->minimum) 02013 a = Q_PI / 2; 02014 else if (dial->dialWrapping) 02015 a = Q_PI * 3 / 2 - (dial->sliderValue - dial->minimum) * 2 * Q_PI 02016 / (dial->maximum - dial->minimum); 02017 else 02018 a = (Q_PI * 8 - (dial->sliderValue - dial->minimum) * 10 * Q_PI 02019 / (dial->maximum - dial->minimum)) / 6; 02020 02021 int xc = width / 2; 02022 int yc = height / 2; 02023 02024 int len = r - calcBigLineSize(r) - 5; 02025 if (len < 5) 02026 len = 5; 02027 int back = len / 2; 02028 02029 QPolygonF arrow(3); 02030 arrow[0] = QPointF(0.5 + xc + len * qCos(a), 02031 0.5 + yc - len * qSin(a)); 02032 arrow[1] = QPointF(0.5 + xc + back * qCos(a + Q_PI * 5 / 6), 02033 0.5 + yc - back * qSin(a + Q_PI * 5 / 6)); 02034 arrow[2] = QPointF(0.5 + xc + back * qCos(a - Q_PI * 5 / 6), 02035 0.5 + yc - back * qSin(a - Q_PI * 5 / 6)); 02036 return arrow; 02037 }
Here is the call graph for this function:

| static int calcBigLineSize | ( | int | radius | ) | [static] |
Definition at line 1997 of file qcommonstyle.cpp.
Referenced by calcArrow(), and calcLines().
01998 { 01999 int bigLineSize = radius / 6; 02000 if (bigLineSize < 4) 02001 bigLineSize = 4; 02002 if (bigLineSize > radius / 2) 02003 bigLineSize = radius / 2; 02004 return bigLineSize; 02005 }
| static QPolygonF calcLines | ( | const QStyleOptionSlider * | dial, | |
| const QWidget * | ||||
| ) | [static] |
Definition at line 2039 of file qcommonstyle.cpp.
References angle(), c, calcBigLineSize(), QStyleOptionSlider::dialWrapping, height, QRect::height(), i, QStyleOptionSlider::maximum, QStyleOptionSlider::minimum, ns, QStyleOptionSlider::pageStep, Q_PI, qCos, qMin(), qSin, QStyleOption::rect, QVector< T >::resize(), s, QStyleOptionSlider::tickInterval, QRect::width(), and width.
Referenced by QCommonStyle::drawComplexControl().
02040 { 02041 QPolygonF poly; 02042 int width = dial->rect.width(); 02043 int height = dial->rect.height(); 02044 qreal r = qMin(width, height) / 2.0; 02045 int bigLineSize = calcBigLineSize(int(r)); 02046 02047 qreal xc = width / 2.0; 02048 qreal yc = height / 2.0; 02049 int ns = dial->tickInterval; 02050 int notches = (dial->maximum + ns - 1 - dial->minimum) / ns; 02051 if (notches <= 0) 02052 return poly; 02053 poly.resize(2 + 2 * notches); 02054 int smallLineSize = bigLineSize / 2; 02055 for (int i = 0; i <= notches; ++i) { 02056 qreal angle = dial->dialWrapping ? Q_PI * 3 / 2 - i * 2 * Q_PI / notches 02057 : (Q_PI * 8 - i * 10 * Q_PI / notches) / 6; 02058 qreal s = qSin(angle); 02059 qreal c = qCos(angle); 02060 if (i == 0 || (((ns * i) % (dial->pageStep ? dial->pageStep : 1)) == 0)) { 02061 poly[2 * i] = QPointF(xc + (r - bigLineSize) * c, 02062 yc - (r - bigLineSize) * s); 02063 poly[2 * i + 1] = QPointF(xc + r * c, yc - r * s); 02064 } else { 02065 poly[2 * i] = QPointF(xc + (r - 1 - smallLineSize) * c, 02066 yc - (r - 1 - smallLineSize) * s); 02067 poly[2 * i + 1] = QPointF(xc + (r - 1) * c, yc -(r - 1) * s); 02068 } 02069 } 02070 return poly; 02071 }
Here is the call graph for this function:

| static void drawArrow | ( | const QStyle * | style, | |
| const QStyleOptionToolButton * | toolbutton, | |||
| const QRect & | rect, | |||
| QPainter * | painter, | |||
| const QWidget * | widget = 0 | |||
| ) | [static] |
Definition at line 640 of file qcommonstyle.cpp.
References QStyleOptionToolButton::arrowType, Qt::DownArrow, QStyle::drawPrimitive(), Qt::LeftArrow, QStyleOption::palette, QStyle::PE_IndicatorArrowDown, QStyle::PE_IndicatorArrowLeft, QStyle::PE_IndicatorArrowRight, QStyle::PE_IndicatorArrowUp, QStyleOption::rect, Qt::RightArrow, QStyleOption::state, and Qt::UpArrow.
Referenced by QCommonStyle::drawControl().
00642 { 00643 QStyle::PrimitiveElement pe; 00644 switch (toolbutton->arrowType) { 00645 case Qt::LeftArrow: 00646 pe = QStyle::PE_IndicatorArrowLeft; 00647 break; 00648 case Qt::RightArrow: 00649 pe = QStyle::PE_IndicatorArrowRight; 00650 break; 00651 case Qt::UpArrow: 00652 pe = QStyle::PE_IndicatorArrowUp; 00653 break; 00654 case Qt::DownArrow: 00655 pe = QStyle::PE_IndicatorArrowDown; 00656 break; 00657 default: 00658 return; 00659 } 00660 QStyleOption arrowOpt; 00661 arrowOpt.rect = rect; 00662 arrowOpt.palette = toolbutton->palette; 00663 arrowOpt.state = toolbutton->state; 00664 style->drawPrimitive(pe, &arrowOpt, painter, widget); 00665 }
Here is the call graph for this function:

| static uint qt_intensity | ( | uint | r, | |
| uint | g, | |||
| uint | b | |||
| ) | [inline, static] |
Definition at line 4040 of file qcommonstyle.cpp.
Referenced by QCommonStyle::generatedIconPixmap().
04041 { 04042 // 30% red, 59% green, 11% blue 04043 return (77 * r + 150 * g + 28 * b) / 255; 04044 }
1.5.1