48 #include <private/qpaintengineex_p.h> 51 #include <private/qstylehelper_p.h> 95 int lineWidth,
int midLineWidth)
97 if (!(p && lineWidth >= 0 && midLineWidth >= 0)) {
98 qWarning(
"qDrawShadeLine: Invalid parameters");
101 int tlw = lineWidth*2 + midLineWidth;
117 for (i=0; i<lineWidth; i++) {
123 if (midLineWidth > 0) {
125 for (i=0; i<midLineWidth; i++)
126 p->
drawLine(x1+lineWidth, y+lineWidth+i,
127 x2-lineWidth, y+lineWidth+i);
133 for (i=0; i<lineWidth; i++) {
148 for (i=0; i<lineWidth; i++) {
154 if (midLineWidth > 0) {
156 for (i=0; i<midLineWidth; i++)
157 p->
drawLine(x+lineWidth+i, y1+lineWidth, x+lineWidth+i, y2);
163 for (i=0; i<lineWidth; i++) {
166 x+tlw-i-1, y1+lineWidth);
206 int lineWidth,
int midLineWidth,
209 if (w == 0 || h == 0)
211 if (! (w > 0 && h > 0 && lineWidth >= 0 && midLineWidth >= 0)) {
212 qWarning(
"qDrawShadeRect: Invalid parameters");
220 int x1=x, y1=y, x2=x+w-1, y2=y+h-1;
222 if (lineWidth == 1 && midLineWidth == 0) {
229 QLineF(x1+1, y1+2, x1+1, y2-2),
234 int m = lineWidth+midLineWidth;
236 for (i=0; i<lineWidth; i++) {
238 QLineF(x1+i, y1+i, x2-i, y1+i),
239 QLineF(x1+k, y2-k, x2-k, y2-k),
240 QLineF(x2-k, y2-k, x2-k, y1+k) };
246 for (i=0; i<midLineWidth; i++) {
247 p->
drawRect(x1+lineWidth+i, y1+lineWidth+i, w-j-1, h-j-1);
255 for (i=0; i<lineWidth; i++) {
257 QLineF(x2-i, y2-i, x2-i, y1+i+1),
258 QLineF(x1+k, y2-k, x1+k, y1+k),
259 QLineF(x1+k, y1+k, x2-k, y1+k) };
266 int tlw = lineWidth + midLineWidth;
269 p->
drawRect(x+tlw, y+tlw, w-2*tlw, h-2*tlw);
305 int lineWidth,
const QBrush *fill)
307 if (w == 0 || h == 0)
309 if (!(w > 0 && h > 0 && lineWidth >= 0)) {
310 qWarning(
"qDrawShadePanel: Invalid parameters");
315 if (fill->
color() == shade)
317 if (fill->
color() == light)
333 for (i=0; i<lineWidth; i++) {
334 lines <<
QLineF(x1, y1++, x2--, y2++);
338 for (i=0; i<lineWidth; i++) {
339 lines <<
QLineF(x1++, y1, x2++, y2--);
350 for (i=0; i<lineWidth; i++) {
351 lines <<
QLineF(x1++, y1--, x2, y2--);
355 y2 = y+h-lineWidth-1;
356 for (i=0; i<lineWidth; i++) {
357 lines <<
QLineF(x1--, y1++, x2--, y2);
361 p->
fillRect(x+lineWidth, y+lineWidth, w-lineWidth*2, h-lineWidth*2, *fill);
385 int x,
int y,
int w,
int h,
399 if (w > 4 && h > 4) {
512 int lineWidth,
const QBrush *fill)
514 if (w == 0 || h == 0)
516 if (!(w > 0 && h > 0 && lineWidth >= 0)) {
517 qWarning(
"qDrawPlainRect: Invalid parameters");
523 for (
int i=0; i<lineWidth; i++)
524 p->
drawRect(x+i, y+i, w-i*2 - 1, h-i*2 - 1);
528 p->
drawRect(x+lineWidth, y+lineWidth, w-lineWidth*2, h-lineWidth*2);
570 int lineWidth,
int midLineWidth)
573 lineWidth, midLineWidth);
607 int lineWidth,
int midLineWidth,
611 lineWidth, midLineWidth, fill);
642 int lineWidth,
const QBrush *fill)
727 int lineWidth,
const QBrush *fill)
735 int x,
int y,
int w,
int h,
741 a.
setPoints(7, -3,1, 3,1, -2,0, 2,0, -1,-1, 1,-1, 0,-2);
744 a.
setPoints(7, -3,-1, 3,-1, -2,0, 2,0, -1,1, 1,1, 0,2);
747 a.
setPoints(7, 1,-3, 1,3, 0,-2, 0,2, -1,-1, -1,1, -2,0);
750 a.
setPoints(7, -1,-3, -1,3, 0,-2, 0,2, 1,-1, 1,1, 2,0);
789 #endif // QT3_SUPPORT 791 #if defined(Q_CC_MSVC) 792 #pragma warning(disable: 4244) 796 #ifndef QT_NO_STYLE_MOTIF 800 int x,
int y,
int w,
int h,
809 bool horizontal = !vertical;
810 int dim = w < h ? w : h;
811 int colspec = 0x0000;
818 bFill.
resize(dim & 1 ? 3 : 4);
820 bBot.
resize(dim & 1 ? dim + 1 : dim);
821 bLeft.
resize(dim > 4 ? 4 : 2);
825 bTop.
putPoints(0, 4, 1,0, 1,1, 2,1, 3,1);
826 bBot.
putPoints(0, 4, 1,dim-1, 1,dim-2, 2,dim-2, 3,dim-2);
828 for(
int i=0; i<dim/2-2 ; i++) {
829 bTop.
putPoints(i*2+4, 2, 2+i*2,2+i, 5+i*2, 2+i);
830 bBot.
putPoints(i*2+4, 2, 2+i*2,dim-3-i, 5+i*2,dim-3-i);
833 bBot.
putPoints(dim-1, 2, dim-3,dim/2, dim-1,dim/2);
837 bFill.
setPoint(2, dim - 3, dim / 2);
839 bFill.
putPoints(2, 2, dim-4,dim/2-1, dim-4,dim/2);
865 colspec = horizontal ? 0x2334 : 0x2343;
867 colspec = horizontal ? 0x1443 : 0x1434;
876 colspec = horizontal ? 0x2443 : 0x2434;
878 colspec = horizontal ? 0x1334 : 0x1343;
887 #define CMID *cols[(colspec>>12) & 0xf] 888 #define CLEFT *cols[(colspec>>8) & 0xf] 889 #define CTOP *cols[(colspec>>4) & 0xf] 890 #define CBOT *cols[colspec & 0xf] 920 #endif // QT_NO_STYLE_MOTIF 923 int x,
int y,
int w,
int h,
933 y += h/2 - pixmap->
height()/2;
935 y += h - pixmap->
height();
937 x += w - pixmap->
width();
939 x += w/2 - pixmap->
width()/2;
941 x += w - pixmap->
width();
943 }
else if (!text.
isNull() && p) {
945 if (gs == Qt::WindowsStyle && !
enabled) {
950 result =
QRect(x, y, w, h);
957 int x,
int y,
int w,
int h,
961 case Qt::WindowsStyle:
962 qDrawWinArrow(p,
type, down, x, y, w, h, pal, enabled);
964 #ifndef QT_NO_STYLE_MOTIF 966 qDrawMotifArrow(p,
type, down, x, y, w, h, pal, enabled);
970 qWarning(
"qDrawArrow: Requested unsupported GUI style");
974 void qDrawItem(
QPainter *p, Qt::GUIStyle gs,
975 int x,
int y,
int w,
int h,
998 x += w/2 - pm.
width()/2;
1000 x += w - pm.
width();
1005 }
else if (pm.
depth() == 1) {
1007 #ifndef QT_NO_IMAGE_HEURISTIC_MASK 1019 if (gs == Qt::WindowsStyle) {
1028 }
else if (!text.
isNull()) {
1029 if (gs == Qt::WindowsStyle && !
enabled) {
1108 const QTileRules &rules, QDrawBorderPixmap::DrawingHints hints)
1111 qWarning(
"qDrawBorderPixmap: Painter not active");
1119 const int sourceCenterTop = sourceRect.
top() + sourceMargins.
top();
1120 const int sourceCenterLeft = sourceRect.
left() + sourceMargins.
left();
1121 const int sourceCenterBottom = sourceRect.
bottom() - sourceMargins.
bottom() + 1;
1122 const int sourceCenterRight = sourceRect.
right() - sourceMargins.
right() + 1;
1123 const int sourceCenterWidth = sourceCenterRight - sourceCenterLeft;
1124 const int sourceCenterHeight = sourceCenterBottom - sourceCenterTop;
1126 const int targetCenterTop = targetRect.
top() + targetMargins.
top();
1127 const int targetCenterLeft = targetRect.
left() + targetMargins.
left();
1128 const int targetCenterBottom = targetRect.
bottom() - targetMargins.
bottom() + 1;
1129 const int targetCenterRight = targetRect.
right() - targetMargins.
right() + 1;
1130 const int targetCenterWidth = targetCenterRight - targetCenterLeft;
1131 const int targetCenterHeight = targetCenterBottom - targetCenterTop;
1139 columns =
qMax(3, 2 +
qCeil(targetCenterWidth /
qreal(sourceCenterWidth)));
1141 rows =
qMax(3, 2 +
qCeil(targetCenterHeight /
qreal(sourceCenterHeight)));
1143 xTarget.
resize(columns + 1);
1144 yTarget.
resize(rows + 1);
1153 xTarget[0] = targetRect.
left();
1154 xTarget[1] = targetCenterLeft;
1155 xTarget[columns - 1] = targetCenterRight;
1156 xTarget[columns] = targetRect.
left() + targetRect.
width();
1158 yTarget[0] = targetRect.
top();
1159 yTarget[1] = targetCenterTop;
1160 yTarget[rows - 1] = targetCenterBottom;
1161 yTarget[rows] = targetRect.
top() + targetRect.
height();
1163 qreal dx = targetCenterWidth;
1164 qreal dy = targetCenterHeight;
1168 dx = targetCenterWidth;
1171 dx = sourceCenterWidth;
1174 dx = targetCenterWidth /
qreal(columns - 2);
1178 for (
int i = 2; i < columns - 1; ++i)
1179 xTarget[i] = xTarget[i - 1] + dx;
1183 dy = targetCenterHeight;
1186 dy = sourceCenterHeight;
1189 dy = targetCenterHeight /
qreal(rows - 2);
1193 for (
int i = 2; i < rows - 1; ++i)
1194 yTarget[i] = yTarget[i - 1] + dy;
1197 if (targetMargins.
top() > 0 && targetMargins.
left() > 0 && sourceMargins.
top() > 0 && sourceMargins.
left() > 0) {
1198 int index = bool(hints & QDrawBorderPixmap::OpaqueTopLeft);
1202 if (targetMargins.
top() > 0 && targetMargins.
right() > 0 && sourceMargins.
top() > 0 && sourceMargins.
right() > 0) {
1203 int index = bool(hints & QDrawBorderPixmap::OpaqueTopRight);
1207 if (targetMargins.
bottom() > 0 && targetMargins.
left() > 0 && sourceMargins.
bottom() > 0 && sourceMargins.
left() > 0) {
1208 int index = bool(hints & QDrawBorderPixmap::OpaqueBottomLeft);
1212 if (targetMargins.
bottom() > 0 && targetMargins.
right() > 0 && sourceMargins.
bottom() > 0 && sourceMargins.
right() > 0) {
1213 int index = bool(hints & QDrawBorderPixmap::OpaqueBottomRight);
1219 if (targetCenterWidth > 0 && sourceCenterWidth > 0) {
1220 if (targetMargins.
top() > 0 && sourceMargins.
top() > 0) {
1221 int index = bool(hints & QDrawBorderPixmap::OpaqueTop);
1222 for (
int i = 1; i < columns - 1; ++i) {
1231 if (targetMargins.
bottom() > 0 && sourceMargins.
bottom() > 0) {
1232 int index = bool(hints & QDrawBorderPixmap::OpaqueBottom);
1233 for (
int i = 1; i < columns - 1; ++i) {
1245 if (targetCenterHeight > 0 && sourceCenterHeight > 0) {
1246 if (targetMargins.
left() > 0 && sourceMargins.
left() > 0) {
1247 int index = bool(hints & QDrawBorderPixmap::OpaqueLeft);
1248 for (
int i = 1; i < rows - 1; ++i) {
1257 if (targetMargins.
right() > 0 && sourceMargins.
right() > 0) {
1258 int index = bool(hints & QDrawBorderPixmap::OpaqueRight);
1259 for (
int i = 1; i < rows - 1; ++i) {
1271 if (targetCenterWidth > 0 && targetCenterHeight > 0 && sourceCenterWidth > 0 && sourceCenterHeight > 0) {
1272 int index = bool(hints & QDrawBorderPixmap::OpaqueCenter);
1273 for (
int j = 1; j < rows - 1; ++j) {
1275 for (
int i = 1; i < columns - 1; ++i) {
1283 for (
int i = 0; i < 2; ++i) {
1284 if (sourceData[i].size())
QRectF boundingRect(const QRectF &rect, int flags, const QString &text)
Returns the bounding rectangle of the text as it will appear when drawn inside the given rectangle wi...
void setTransform(const QTransform &transform, bool combine=false)
Sets the world transformation matrix.
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.
The QLatin1Literal class provides a thin wrapper around string literals used in source code...
void drawPixmapFragments(const PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, PixmapFragmentHints hints=0)
This function is used to draw pixmap, or a sub-rectangle of pixmap, at multiple positions with differ...
void setHeight(int h)
Sets the height of the rectangle to the given height.
const QTransform & transform() const
Returns the world transformation matrix.
#define QT_END_NAMESPACE
This macro expands to.
const QColor & color() const
Returns the brush color.
int width() const
Returns the width of the pixmap.
void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &c, int lineWidth, const QBrush *fill)
const QBrush & dark() const
Returns the dark brush of the current color group.
void qDrawShadeRect(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, int midLineWidth, const QBrush *fill)
void setMask(const QBitmap &)
Sets a mask bitmap.
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation...
The QPointF class defines a point in the plane using floating point precision.
int left() const
Returns the x-coordinate of the rectangle's left edge.
int width() const
Returns the width of the rectangle.
const QBrush & foreground() const
Use windowText() instead.
long ASN1_INTEGER_get ASN1_INTEGER * a
void putPoints(int index, int nPoints, const int *points)
Copies nPoints points from the points coord array into this point array, and resizes the point array ...
The QPolygon class provides a vector of points using integer precision.
void drawLine(const QLineF &line)
Draws a line defined by line.
bool testRenderHint(RenderHint hint) const
Returns true if hint is set; otherwise returns false.
int depth() const
Returns the depth of the pixmap.
int height() const
Returns the height of the rectangle.
int bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
The QString class provides a Unicode character string.
The QVector class is a template class that provides a dynamic array.
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
The QPen class defines how a QPainter should draw lines and outlines of shapes.
void setBrushOrigin(int x, int y)
Sets the brush's origin to point (x, y).
The QSizeF class defines the size of a two-dimensional object using floating point precision...
void drawPoint(const QPointF &pt)
Draws a single point at the given position using the current pen's color.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
static QPixmap * find(const QString &key)
void resize(int size)
Sets the size of the vector to size.
The QLineF class provides a two-dimensional vector using floating point precision.
int top() const
Returns the top margin.
The QBitmap class provides monochrome (1-bit depth) pixmaps.
void translate(int dx, int dy)
Translates all points in the polygon by ({dx}, {dy}).
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position...
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
const QPen & pen() const
Returns the painter's current pen.
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QRectF class defines a rectangle in the plane using floating point precision. ...
QPoint brushOrigin() const
Returns the currently set brush origin.
const QBrush & light() const
Returns the light brush of the current color group.
void drawLines(const QLineF *lines, int lineCount)
Draws the first lineCount lines in the array lines using the current pen.
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
QVarLengthArray< QRectF, 16 > QRectFArray
void qDrawWinPanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, const QBrush *fill)
bool isActive() const
Returns true if begin() has been called and end() has not yet been called; otherwise returns false...
virtual Type type() const =0
Reimplement this function to return the paint engine Type.
const QBrush & midlight() const
Returns the midlight brush of the current color group.
const QBrush & mid() const
Returns the mid brush of the current color group.
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
void qDrawWinButton(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, const QBrush *fill)
QPaintEngine * paintEngine() const
Returns the paint engine that the painter is currently operating on if the painter is active; otherwi...
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
Draws the polygon defined by the first pointCount points in the array points using the current pen an...
void qDrawShadePanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, const QBrush *fill)
QTransform combinedTransform() const
Returns the transformation matrix combining the current window/viewport and world transformation...
void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMargins, const QPixmap &pixmap, const QRect &sourceRect, const QMargins &sourceMargins, const QTileRules &rules, QDrawBorderPixmap::DrawingHints hints)
Draws the indicated sourceRect rectangle from the given pixmap into the given targetRect rectangle...
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
const T & at(int i) const
Returns the item at index position i in the vector.
const QBrush & brush() const
Returns the painter's current brush.
The QBrush class defines the fill pattern of shapes drawn by QPainter.
bool isNull() const
Returns true if this string is null; otherwise returns false.
const QBrush & shadow() const
Returns the shadow brush of the current color group.
int top() const
Returns the y-coordinate of the rectangle's top edge.
int right() const
Returns the x-coordinate of the rectangle's right edge.
QBitmap mask() const
Extracts a bitmap mask from the pixmap's alpha channel.
void setClipping(bool enable)
Enables clipping if enable is true, or disables clipping if enable is false.
int y() const
Returns the y-coordinate of the rectangle's top edge.
Holds the rules used to draw a pixmap or image split into nine segments, similar to [CSS3 border-imag...
int x() const
Returns the x-coordinate of the rectangle's left edge.
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
The QPoint class defines a point in the plane using integer precision.
void setBrush(const QBrush &brush)
Sets the painter's brush to the given brush.
void setWidth(int w)
Sets the width of the rectangle to the given width.
void setPen(const QColor &color)
Sets the painter's pen to have style Qt::SolidLine, width 0 and the specified color.
The QRect class defines a rectangle in the plane using integer precision.
void setPoint(int index, int x, int y)
Sets the point at the given index to the point specified by ({x}, {y}).
qint64 cacheKey() const
Returns a number that identifies this QPixmap.
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
int 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...
static void qDrawWinShades(QPainter *p, int x, int y, int w, int h, const QColor &c1, const QColor &c2, const QColor &c3, const QColor &c4, const QBrush *fill)
This function draws a rectangle with two pixel line width.
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...
int height() const
Returns the height of the pixmap.
int left() const
Returns the left margin.
void setPoints(int nPoints, const int *points)
Resizes the polygon to nPoints and populates it with the given points.
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
void reserve(int size)
Attempts to allocate memory for at least size elements.
int x() const
Returns the x coordinate of this point.
The QMargins class defines the four margins of a rectangle.
bool hasAlphaChannel() const
Returns true if the pixmap has a format that respects the alpha channel, otherwise returns false...
const QBrush & button() const
Returns the button brush of the current color group.
void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2, const QPalette &pal, bool sunken, int lineWidth, int midLineWidth)
QBitmap createHeuristicMask(bool clipTight=true) const
Creates and returns a heuristic mask for this pixmap.
void drawPolyline(const QPointF *points, int pointCount)
Draws the polyline defined by the first pointCount points in points using the current pen...
static bool isRightToLeft()
Returns true if the application's layout direction is Qt::RightToLeft; otherwise returns false...
int bottom() const
Returns the bottom margin.
int right() const
Returns the right margin.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
const QBrush & text() const
Returns the text foreground brush of the current color group.
QPoint topLeft() const
Returns the position of the rectangle's top-left corner.
The QPalette class contains color groups for each widget state.