Qt 4.8
Functions
qcommonstyle.cpp File Reference
#include "qcommonstyle.h"
#include "qcommonstyle_p.h"
#include <qfile.h>
#include <qapplication.h>
#include <qbitmap.h>
#include <qcache.h>
#include <qdockwidget.h>
#include <qdrawutil.h>
#include <qdialogbuttonbox.h>
#include <qformlayout.h>
#include <qgroupbox.h>
#include <qmath.h>
#include <qmenu.h>
#include <qpainter.h>
#include <qpaintengine.h>
#include <qpainterpath.h>
#include <qslider.h>
#include <qstyleoption.h>
#include <qtabbar.h>
#include <qtabwidget.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 <qwizard.h>
#include <qfileinfo.h>
#include <qdir.h>
#include <qsettings.h>
#include <qpixmapcache.h>
#include <private/qguiplatformplugin_p.h>
#include <limits.h>
#include "private/qtextengine_p.h"
#include <private/qt_x11_p.h>
#include <private/qstylehelper_p.h>

Go to the source code of this file.

Functions

static QPolygonF calcArrow (const QStyleOptionSlider *dial, qreal &a)
 
static void drawArrow (const QStyle *style, const QStyleOptionToolButton *toolbutton, const QRect &rect, QPainter *painter, const QWidget *widget=0)
 
static uint qt_intensity (uint r, uint g, uint b)
 
static QSizeF viewItemTextLayout (QTextLayout &textLayout, int lineWidth)
 

Function Documentation

◆ calcArrow()

static QPolygonF calcArrow ( const QStyleOptionSlider dial,
qreal a 
)
static

Definition at line 3068 of file qcommonstyle.cpp.

Referenced by QCommonStyle::drawComplexControl().

3069 {
3070  int width = dial->rect.width();
3071  int height = dial->rect.height();
3072  int r = qMin(width, height) / 2;
3073  int currentSliderPosition = dial->upsideDown ? dial->sliderPosition : (dial->maximum - dial->sliderPosition);
3074 
3075  if (dial->maximum == dial->minimum)
3076  a = Q_PI / 2;
3077  else if (dial->dialWrapping)
3078  a = Q_PI * 3 / 2 - (currentSliderPosition - dial->minimum) * 2 * Q_PI
3079  / (dial->maximum - dial->minimum);
3080  else
3081  a = (Q_PI * 8 - (currentSliderPosition - dial->minimum) * 10 * Q_PI
3082  / (dial->maximum - dial->minimum)) / 6;
3083 
3084  int xc = width / 2;
3085  int yc = height / 2;
3086 
3087  int len = r - QStyleHelper::calcBigLineSize(r) - 5;
3088  if (len < 5)
3089  len = 5;
3090  int back = len / 2;
3091 
3092  QPolygonF arrow(3);
3093  arrow[0] = QPointF(0.5 + xc + len * qCos(a),
3094  0.5 + yc - len * qSin(a));
3095  arrow[1] = QPointF(0.5 + xc + back * qCos(a + Q_PI * 5 / 6),
3096  0.5 + yc - back * qSin(a + Q_PI * 5 / 6));
3097  arrow[2] = QPointF(0.5 + xc + back * qCos(a - Q_PI * 5 / 6),
3098  0.5 + yc - back * qSin(a - Q_PI * 5 / 6));
3099  return arrow;
3100 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
long ASN1_INTEGER_get ASN1_INTEGER * a
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
bool dialWrapping
whether the dial should wrap or not
Definition: qstyleoption.h:718
bool upsideDown
the slider control orientation
Definition: qstyleoption.h:712
int calcBigLineSize(int radius)
qreal qSin(qreal v)
Definition: qmath.h:93
The QPolygonF class provides a vector of points using floating point precision.
Definition: qpolygon.h:134
int sliderPosition
the position of the slider handle
Definition: qstyleoption.h:713
int maximum
the maximum value for the slider
Definition: qstyleoption.h:709
int minimum
the minimum value for the slider
Definition: qstyleoption.h:708
qreal qCos(qreal v)
Definition: qmath.h:109
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
static const qreal Q_PI
Definition: qmath_p.h:61

◆ drawArrow()

static void drawArrow ( const QStyle style,
const QStyleOptionToolButton toolbutton,
const QRect rect,
QPainter painter,
const QWidget widget = 0 
)
static

Definition at line 811 of file qcommonstyle.cpp.

Referenced by QCommonStyle::drawControl().

813 {
815  switch (toolbutton->arrowType) {
816  case Qt::LeftArrow:
818  break;
819  case Qt::RightArrow:
821  break;
822  case Qt::UpArrow:
824  break;
825  case Qt::DownArrow:
827  break;
828  default:
829  return;
830  }
831  QStyleOption arrowOpt;
832  arrowOpt.rect = rect;
833  arrowOpt.palette = toolbutton->palette;
834  arrowOpt.state = toolbutton->state;
835  style->drawPrimitive(pe, &arrowOpt, painter, widget);
836 }
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
Qt::ArrowType arrowType
the direction of the arrow for the tool button
Definition: qstyleoption.h:782
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
PrimitiveElement
This enum describes the various primitive elements.
Definition: qstyle.h:145
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90

◆ qt_intensity()

static uint qt_intensity ( uint  r,
uint  g,
uint  b 
)
inlinestatic

Definition at line 5974 of file qcommonstyle.cpp.

Referenced by QCommonStyle::generatedIconPixmap().

5975 {
5976  // 30% red, 59% green, 11% blue
5977  return (77 * r + 150 * g + 28 * b) / 255;
5978 }

◆ viewItemTextLayout()

static QSizeF viewItemTextLayout ( QTextLayout textLayout,
int  lineWidth 
)
static

Definition at line 905 of file qcommonstyle.cpp.

Referenced by QCommonStylePrivate::viewItemDrawText().

906 {
907  qreal height = 0;
908  qreal widthUsed = 0;
909  textLayout.beginLayout();
910  while (true) {
911  QTextLine line = textLayout.createLine();
912  if (!line.isValid())
913  break;
914  line.setLineWidth(lineWidth);
915  line.setPosition(QPointF(0, height));
916  height += line.height();
917  widthUsed = qMax(widthUsed, line.naturalTextWidth());
918  }
919  textLayout.endLayout();
920  return QSizeF(widthUsed, height);
921 }
double qreal
Definition: qglobal.h:1193
void setPosition(const QPointF &pos)
Moves the line to position pos.
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QTextLine class represents a line of text inside a QTextLayout.
Definition: qtextlayout.h:197
void setLineWidth(qreal width)
Lays out the line with the given width.
bool isValid() const
Returns true if this text line is valid; otherwise returns false.
Definition: qtextlayout.h:201
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QTextLine createLine()
Returns a new text line to be laid out if there is text to be inserted into the layout; otherwise ret...
qreal naturalTextWidth() const
Returns the width of the line that is occupied by text.
void endLayout()
Ends the layout process.
qreal height() const
Returns the line&#39;s height.
void beginLayout()
Begins the layout process.