6#include "QskStandardSymbol.h"
10#include <qpainterpath.h>
12static void qskOkGraphic( QPainter* painter )
16 path.moveTo( 14, 43 );
17 path.cubicTo( 13.5, 43, 12.25, 42.5, 11.75, 41.5 );
19 path.lineTo( 0, 20.5 );
21 path.cubicTo( 0, 19, 0, 17.25, 1.5, 16.5 );
22 path.cubicTo( 3, 15.75, 4.75, 16.25, 5.5, 17.75 );
24 path.lineTo( 14.75, 34 );
26 path.cubicTo( 17.25, 28.25, 20, 23.25, 22.75, 18.5 );
27 path.cubicTo( 26.75, 12.25, 31.25, 6.5, 38.25, 0.75 );
29 path.cubicTo( 39.5, 0, 41.25, 0, 42.25, 1 );
30 path.cubicTo( 43.25, 2.25, 43.25, 4, 42, 5.25 );
31 path.cubicTo( 35.50, 10.75, 31.5, 15.75, 27.75, 21.5 );
32 path.cubicTo( 24.25, 27.25, 21.25, 33.75, 16.75, 41.5 );
33 path.cubicTo( 16.25, 42.5, 15.25, 43, 14.25, 43 );
35 painter->setPen( Qt::NoPen );
37 painter->setBrush( QColor( 76, 175, 80 ) );
38 painter->drawPath( path );
41static void qskCancelGraphic( QPainter* painter )
46 path.lineTo( 20, 15 );
49 path.lineTo( 25, 20 );
50 path.lineTo( 40, 35 );
51 path.lineTo( 35, 40 );
52 path.lineTo( 20, 25 );
55 path.lineTo( 15, 20 );
58 painter->setPen( Qt::NoPen );
60 painter->setBrush( QColor( Qt::red ) );
61 painter->drawPath( path );
64static void qskCheckMarkGraphic( QPainter* painter )
68 path.moveTo( 0.0, 0.5 );
69 path.lineTo( 0.33, 1.0 );
70 path.lineTo( 1.0, 0.0 );
72 painter->setPen( QPen( Qt::black, 0.2 ) );
73 painter->drawPath( path );
76static void qskCrossMarkGraphic( QPainter* painter )
78 painter->setPen( QPen( Qt::black, 0.2 ) );
79 painter->drawLine( 0.0, 0.0, 1.0, 1.0 );
80 painter->drawLine( 0.0, 1.0, 1.0, 0.0 );
83static void qskBulletGraphic( QPainter* painter )
85 painter->setPen( QPen( Qt::black, 1.0 ) );
86 painter->drawEllipse( QRectF( 0.0, 0.0, 1.0, 1.0 ) );
89static void qskTriangleGraphic( QPainter* painter,
90 qreal width, qreal height,
int type )
92 const QRectF rect( 0.0, 0.0, width, height );
100 case QskStandardSymbol::TriangleUp:
102 triangle += rect.bottomLeft();
103 triangle += QPointF( rect.center().x(), rect.top() );
104 triangle += rect.bottomRight();
108 case QskStandardSymbol::TriangleDown:
110 triangle += rect.topLeft();
111 triangle += QPointF( rect.center().x(), rect.bottom() );
112 triangle += rect.topRight();
116 case QskStandardSymbol::TriangleRight:
118 triangle += rect.bottomLeft();
119 triangle += QPointF( rect.right(), rect.center().y() );
120 triangle += rect.topLeft();
124 case QskStandardSymbol::TriangleLeft:
126 triangle += rect.bottomRight();
127 triangle += QPointF( rect.left(), rect.center().y() );
128 triangle += rect.topRight();
134 path.addPolygon( triangle );
136 painter->setPen( Qt::NoPen );
137 painter->setBrush( QColor( Qt::black ) );
138 painter->drawPath( path );
141QskGraphic QskStandardSymbol::graphic( Type symbolType )
143 static QskGraphic graphics[ SymbolTypeCount ];
145 if ( symbolType < 0 || symbolType >= SymbolTypeCount )
148 if ( graphics[ symbolType ].isNull() )
150 QPainter painter( &graphics[ symbolType ] );
151 painter.setRenderHint( QPainter::Antialiasing,
true );
153 switch ( symbolType )
155 case QskStandardSymbol::Ok:
157 qskOkGraphic( &painter );
160 case QskStandardSymbol::Cancel:
162 qskCancelGraphic( &painter );
165 case QskStandardSymbol::CheckMark:
167 qskCheckMarkGraphic( &painter );
170 case QskStandardSymbol::CrossMark:
172 qskCrossMarkGraphic( &painter );
175 case QskStandardSymbol::SegmentedBarCheckMark:
177 qskCheckMarkGraphic( &painter );
180 case QskStandardSymbol::TriangleUp:
181 case QskStandardSymbol::TriangleDown:
183 qskTriangleGraphic( &painter, 2.0, 1.0, symbolType );
186 case QskStandardSymbol::TriangleLeft:
187 case QskStandardSymbol::TriangleRight:
189 qskTriangleGraphic( &painter, 1.0, 2.0, symbolType );
192 case QskStandardSymbol::Bullet:
194 qskBulletGraphic( &painter );
197 case QskStandardSymbol::NoSymbol:
198 case QskStandardSymbol::SymbolTypeCount:
205 return graphics[ symbolType ];
208#include "moc_QskStandardSymbol.cpp"
A paint device for scalable graphics.