Qt 4.8
Classes | Functions
qdrawutil.h File Reference
#include <QtCore/qnamespace.h>
#include <QtCore/qstring.h>
#include <QtCore/qmargins.h>
#include <QtGui/qpixmap.h>

Go to the source code of this file.

Classes

class  QTileRules
 Holds the rules used to draw a pixmap or image split into nine segments, similar to [CSS3 border-images](http://www. More...
 

Functions

Q_GUI_EXPORT void qDrawBorderPixmap (QPainter *painter, const QRect &targetRect, const QMargins &targetMargins, const QPixmap &pixmap, const QRect &sourceRect, const QMargins &sourceMargins, const QTileRules &rules=QTileRules())
 
void qDrawBorderPixmap (QPainter *painter, const QRect &target, const QMargins &margins, const QPixmap &pixmap)
 
Q_GUI_EXPORT void qDrawPlainRect (QPainter *p, int x, int y, int w, int h, const QColor &, int lineWidth=1, const QBrush *fill=0)
 
Q_GUI_EXPORT void qDrawPlainRect (QPainter *p, const QRect &r, const QColor &, int lineWidth=1, const QBrush *fill=0)
 
Q_GUI_EXPORT void qDrawShadeLine (QPainter *p, int x1, int y1, int x2, int y2, const QPalette &pal, bool sunken=true, int lineWidth=1, int midLineWidth=0)
 
Q_GUI_EXPORT void qDrawShadeLine (QPainter *p, const QPoint &p1, const QPoint &p2, const QPalette &pal, bool sunken=true, int lineWidth=1, int midLineWidth=0)
 
Q_GUI_EXPORT void qDrawShadePanel (QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken=false, int lineWidth=1, const QBrush *fill=0)
 
Q_GUI_EXPORT void qDrawShadePanel (QPainter *p, const QRect &r, const QPalette &pal, bool sunken=false, int lineWidth=1, const QBrush *fill=0)
 
Q_GUI_EXPORT void qDrawShadeRect (QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken=false, int lineWidth=1, int midLineWidth=0, const QBrush *fill=0)
 
Q_GUI_EXPORT void qDrawShadeRect (QPainter *p, const QRect &r, const QPalette &pal, bool sunken=false, int lineWidth=1, int midLineWidth=0, const QBrush *fill=0)
 
Q_GUI_EXPORT void qDrawWinButton (QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken=false, const QBrush *fill=0)
 
Q_GUI_EXPORT void qDrawWinButton (QPainter *p, const QRect &r, const QPalette &pal, bool sunken=false, const QBrush *fill=0)
 
Q_GUI_EXPORT void qDrawWinPanel (QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken=false, const QBrush *fill=0)
 
Q_GUI_EXPORT void qDrawWinPanel (QPainter *p, const QRect &r, const QPalette &pal, bool sunken=false, const QBrush *fill=0)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the Windows-style panel at the rectangle specified by rect using the given painter with a line width of 2 pixels. More...
 

Function Documentation

◆ qDrawBorderPixmap() [1/2]

Q_GUI_EXPORT void qDrawBorderPixmap ( QPainter painter,
const QRect targetRect,
const QMargins targetMargins,
const QPixmap pixmap,
const QRect sourceRect,
const QMargins sourceMargins,
const QTileRules rules = QTileRules() 
)

Referenced by qDrawBorderPixmap().

◆ qDrawBorderPixmap() [2/2]

void qDrawBorderPixmap ( QPainter painter,
const QRect target,
const QMargins margins,
const QPixmap pixmap 
)
inline

Definition at line 183 of file qdrawutil.h.

187 {
188  qDrawBorderPixmap(painter, target, margins, pixmap, pixmap.rect(), margins);
189 }
Q_GUI_EXPORT void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMargins, const QPixmap &pixmap, const QRect &sourceRect, const QMargins &sourceMargins, const QTileRules &rules=QTileRules())
QRect rect() const
Returns the pixmap&#39;s enclosing rectangle.
Definition: qpixmap.cpp:676

◆ qDrawPlainRect() [1/2]

Q_GUI_EXPORT void qDrawPlainRect ( QPainter p,
int  x,
int  y,
int  w,
int  h,
const QColor ,
int  lineWidth = 1,
const QBrush fill = 0 
)

Definition at line 511 of file qdrawutil.cpp.

Referenced by QWindowsMobileStyle::drawComplexControl(), QCommonStyle::drawControl(), QWindowsCEStyle::drawControl(), QWindowsMobileStyle::drawControl(), QWindowsCEStyle::drawPrimitive(), QCommonStyle::drawPrimitive(), QWindowsMobileStyle::drawPrimitive(), QMotifStyle::drawPrimitive(), and qDrawPlainRect().

513 {
514  if (w == 0 || h == 0)
515  return;
516  if (!(w > 0 && h > 0 && lineWidth >= 0)) {
517  qWarning("qDrawPlainRect: Invalid parameters");
518  }
519  QPen oldPen = p->pen();
520  QBrush oldBrush = p->brush();
521  p->setPen(c);
522  p->setBrush(Qt::NoBrush);
523  for (int i=0; i<lineWidth; i++)
524  p->drawRect(x+i, y+i, w-i*2 - 1, h-i*2 - 1);
525  if (fill) { // fill with fill color
526  p->setPen(Qt::NoPen);
527  p->setBrush(*fill);
528  p->drawRect(x+lineWidth, y+lineWidth, w-lineWidth*2, h-lineWidth*2);
529  }
530  p->setPen(oldPen);
531  p->setBrush(oldBrush);
532 }
unsigned char c[8]
Definition: qnumeric_p.h:62
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
Q_CORE_EXPORT void qWarning(const char *,...)
const QBrush & brush() const
Returns the painter&#39;s current brush.
Definition: qpainter.cpp:4232
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition: qpainter.h:650

◆ qDrawPlainRect() [2/2]

Q_GUI_EXPORT void qDrawPlainRect ( QPainter p,
const QRect r,
const QColor ,
int  lineWidth = 1,
const QBrush fill = 0 
)

Definition at line 726 of file qdrawutil.cpp.

728 {
729  qDrawPlainRect(p, r.x(), r.y(), r.width(), r.height(), c,
730  lineWidth, fill);
731 }
unsigned char c[8]
Definition: qnumeric_p.h:62
void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &c, int lineWidth, const QBrush *fill)
Definition: qdrawutil.cpp:511
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252

◆ qDrawShadeLine() [1/2]

Q_GUI_EXPORT void qDrawShadeLine ( QPainter p,
int  x1,
int  y1,
int  x2,
int  y2,
const QPalette pal,
bool  sunken = true,
int  lineWidth = 1,
int  midLineWidth = 0 
)

Definition at line 93 of file qdrawutil.cpp.

Referenced by QMotifStyle::drawComplexControl(), QCommonStyle::drawControl(), QCommonStyle::drawPrimitive(), QMotifStyle::drawPrimitive(), and qDrawShadeLine().

96 {
97  if (!(p && lineWidth >= 0 && midLineWidth >= 0)) {
98  qWarning("qDrawShadeLine: Invalid parameters");
99  return;
100  }
101  int tlw = lineWidth*2 + midLineWidth; // total line width
102  QPen oldPen = p->pen(); // save pen
103  if (sunken)
104  p->setPen(pal.color(QPalette::Dark));
105  else
106  p->setPen(pal.light().color());
107  QPolygon a;
108  int i;
109  if (y1 == y2) { // horizontal line
110  int y = y1 - tlw/2;
111  if (x1 > x2) { // swap x1 and x2
112  int t = x1;
113  x1 = x2;
114  x2 = t;
115  }
116  x2--;
117  for (i=0; i<lineWidth; i++) { // draw top shadow
118  a.setPoints(3, x1+i, y+tlw-1-i,
119  x1+i, y+i,
120  x2-i, y+i);
121  p->drawPolyline(a);
122  }
123  if (midLineWidth > 0) {
124  p->setPen(pal.mid().color());
125  for (i=0; i<midLineWidth; i++) // draw lines in the middle
126  p->drawLine(x1+lineWidth, y+lineWidth+i,
127  x2-lineWidth, y+lineWidth+i);
128  }
129  if (sunken)
130  p->setPen(pal.light().color());
131  else
132  p->setPen(pal.dark().color());
133  for (i=0; i<lineWidth; i++) { // draw bottom shadow
134  a.setPoints(3, x1+i, y+tlw-i-1,
135  x2-i, y+tlw-i-1,
136  x2-i, y+i+1);
137  p->drawPolyline(a);
138  }
139  }
140  else if (x1 == x2) { // vertical line
141  int x = x1 - tlw/2;
142  if (y1 > y2) { // swap y1 and y2
143  int t = y1;
144  y1 = y2;
145  y2 = t;
146  }
147  y2--;
148  for (i=0; i<lineWidth; i++) { // draw left shadow
149  a.setPoints(3, x+i, y2,
150  x+i, y1+i,
151  x+tlw-1, y1+i);
152  p->drawPolyline(a);
153  }
154  if (midLineWidth > 0) {
155  p->setPen(pal.mid().color());
156  for (i=0; i<midLineWidth; i++) // draw lines in the middle
157  p->drawLine(x+lineWidth+i, y1+lineWidth, x+lineWidth+i, y2);
158  }
159  if (sunken)
160  p->setPen(pal.light().color());
161  else
162  p->setPen(pal.dark().color());
163  for (i=0; i<lineWidth; i++) { // draw right shadow
164  a.setPoints(3, x+lineWidth, y2-i,
165  x+tlw-i-1, y2-i,
166  x+tlw-i-1, y1+lineWidth);
167  p->drawPolyline(a);
168  }
169  }
170  p->setPen(oldPen);
171 }
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
long ASN1_INTEGER_get ASN1_INTEGER * a
The QPolygon class provides a vector of points using integer precision.
Definition: qpolygon.h:60
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
const QBrush & light() const
Returns the light brush of the current color group.
Definition: qpalette.h:126
const QBrush & mid() const
Returns the mid brush of the current color group.
Definition: qpalette.h:128
Q_CORE_EXPORT void qWarning(const char *,...)
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
void setPoints(int nPoints, const int *points)
Resizes the polygon to nPoints and populates it with the given points.
Definition: qpolygon.cpp:350
void drawPolyline(const QPointF *points, int pointCount)
Draws the polyline defined by the first pointCount points in points using the current pen...
Definition: qpainter.cpp:5055

◆ qDrawShadeLine() [2/2]

Q_GUI_EXPORT void qDrawShadeLine ( QPainter p,
const QPoint p1,
const QPoint p2,
const QPalette pal,
bool  sunken = true,
int  lineWidth = 1,
int  midLineWidth = 0 
)

Definition at line 568 of file qdrawutil.cpp.

571 {
572  qDrawShadeLine(p, p1.x(), p1.y(), p2.x(), p2.y(), pal, sunken,
573  lineWidth, midLineWidth);
574 }
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2, const QPalette &pal, bool sunken, int lineWidth, int midLineWidth)
Definition: qdrawutil.cpp:93

◆ qDrawShadePanel() [1/2]

Q_GUI_EXPORT void qDrawShadePanel ( QPainter p,
int  x,
int  y,
int  w,
int  h,
const QPalette pal,
bool  sunken = false,
int  lineWidth = 1,
const QBrush fill = 0 
)

Definition at line 303 of file qdrawutil.cpp.

Referenced by QMotifStyle::drawComplexControl(), QCommonStyle::drawControl(), QWindowsCEStyle::drawControl(), QCDEStyle::drawControl(), QWindowsStyle::drawControl(), QMotifStyle::drawControl(), QStyleSheetStyle::drawControl(), QCommonStyle::drawPrimitive(), QWindowsMobileStyle::drawPrimitive(), QCDEStyle::drawPrimitive(), QWindowsStyle::drawPrimitive(), QMotifStyle::drawPrimitive(), QDecorationDefault::paint(), QColorLuminancePicker::paintEvent(), and qDrawShadePanel().

306 {
307  if (w == 0 || h == 0)
308  return;
309  if (!(w > 0 && h > 0 && lineWidth >= 0)) {
310  qWarning("qDrawShadePanel: Invalid parameters");
311  }
312  QColor shade = pal.dark().color();
313  QColor light = pal.light().color();
314  if (fill) {
315  if (fill->color() == shade)
316  shade = pal.shadow().color();
317  if (fill->color() == light)
318  light = pal.midlight().color();
319  }
320  QPen oldPen = p->pen(); // save pen
321  QVector<QLineF> lines;
322  lines.reserve(2*lineWidth);
323 
324  if (sunken)
325  p->setPen(shade);
326  else
327  p->setPen(light);
328  int x1, y1, x2, y2;
329  int i;
330  x1 = x;
331  y1 = y2 = y;
332  x2 = x+w-2;
333  for (i=0; i<lineWidth; i++) { // top shadow
334  lines << QLineF(x1, y1++, x2--, y2++);
335  }
336  x2 = x1;
337  y1 = y+h-2;
338  for (i=0; i<lineWidth; i++) { // left shado
339  lines << QLineF(x1++, y1, x2++, y2--);
340  }
341  p->drawLines(lines);
342  lines.clear();
343  if (sunken)
344  p->setPen(light);
345  else
346  p->setPen(shade);
347  x1 = x;
348  y1 = y2 = y+h-1;
349  x2 = x+w-1;
350  for (i=0; i<lineWidth; i++) { // bottom shadow
351  lines << QLineF(x1++, y1--, x2, y2--);
352  }
353  x1 = x2;
354  y1 = y;
355  y2 = y+h-lineWidth-1;
356  for (i=0; i<lineWidth; i++) { // right shadow
357  lines << QLineF(x1--, y1++, x2--, y2);
358  }
359  p->drawLines(lines);
360  if (fill) // fill with fill color
361  p->fillRect(x+lineWidth, y+lineWidth, w-lineWidth*2, h-lineWidth*2, *fill);
362  p->setPen(oldPen); // restore pen
363 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
The QLineF class provides a two-dimensional vector using floating point precision.
Definition: qline.h:212
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
const QBrush & light() const
Returns the light brush of the current color group.
Definition: qpalette.h:126
void drawLines(const QLineF *lines, int lineCount)
Draws the first lineCount lines in the array lines using the current pen.
Definition: qpainter.cpp:4873
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
Definition: qvector.h:347
const QBrush & midlight() const
Returns the midlight brush of the current color group.
Definition: qpalette.h:136
Q_CORE_EXPORT void qWarning(const char *,...)
const QBrush & shadow() const
Returns the shadow brush of the current color group.
Definition: qpalette.h:139
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
void reserve(int size)
Attempts to allocate memory for at least size elements.
Definition: qvector.h:339
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420

◆ qDrawShadePanel() [2/2]

Q_GUI_EXPORT void qDrawShadePanel ( QPainter p,
const QRect r,
const QPalette pal,
bool  sunken = false,
int  lineWidth = 1,
const QBrush fill = 0 
)

Definition at line 640 of file qdrawutil.cpp.

643 {
644  qDrawShadePanel(p, r.x(), r.y(), r.width(), r.height(), pal, sunken,
645  lineWidth, fill);
646 }
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
void qDrawShadePanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, const QBrush *fill)
Definition: qdrawutil.cpp:303
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252

◆ qDrawShadeRect() [1/2]

Q_GUI_EXPORT void qDrawShadeRect ( QPainter p,
int  x,
int  y,
int  w,
int  h,
const QPalette pal,
bool  sunken = false,
int  lineWidth = 1,
int  midLineWidth = 0,
const QBrush fill = 0 
)

Definition at line 204 of file qdrawutil.cpp.

Referenced by QCommonStyle::drawControl(), QWindowsStyle::drawControl(), QWindowsCEStyle::drawPrimitive(), QCommonStyle::drawPrimitive(), QWindowsStyle::drawPrimitive(), and qDrawShadeRect().

208 {
209  if (w == 0 || h == 0)
210  return;
211  if (! (w > 0 && h > 0 && lineWidth >= 0 && midLineWidth >= 0)) {
212  qWarning("qDrawShadeRect: Invalid parameters");
213  return;
214  }
215  QPen oldPen = p->pen();
216  if (sunken)
217  p->setPen(pal.dark().color());
218  else
219  p->setPen(pal.light().color());
220  int x1=x, y1=y, x2=x+w-1, y2=y+h-1;
221 
222  if (lineWidth == 1 && midLineWidth == 0) {// standard shade rectangle
223  p->drawRect(x1, y1, w-2, h-2);
224  if (sunken)
225  p->setPen(pal.light().color());
226  else
227  p->setPen(pal.dark().color());
228  QLineF lines[4] = { QLineF(x1+1, y1+1, x2-2, y1+1),
229  QLineF(x1+1, y1+2, x1+1, y2-2),
230  QLineF(x1, y2, x2, y2),
231  QLineF(x2,y1, x2,y2-1) };
232  p->drawLines(lines, 4); // draw bottom/right lines
233  } else { // more complicated
234  int m = lineWidth+midLineWidth;
235  int i, j=0, k=m;
236  for (i=0; i<lineWidth; i++) { // draw top shadow
237  QLineF lines[4] = { QLineF(x1+i, y2-i, x1+i, y1+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) };
241  p->drawLines(lines, 4);
242  k++;
243  }
244  p->setPen(pal.mid().color());
245  j = lineWidth*2;
246  for (i=0; i<midLineWidth; i++) { // draw lines in the middle
247  p->drawRect(x1+lineWidth+i, y1+lineWidth+i, w-j-1, h-j-1);
248  j += 2;
249  }
250  if (sunken)
251  p->setPen(pal.light().color());
252  else
253  p->setPen(pal.dark().color());
254  k = m;
255  for (i=0; i<lineWidth; i++) { // draw bottom shadow
256  QLineF lines[4] = { QLineF(x1+1+i, y2-i, x2-i, y2-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) };
260  p->drawLines(lines, 4);
261  k++;
262  }
263  }
264  if (fill) {
265  QBrush oldBrush = p->brush();
266  int tlw = lineWidth + midLineWidth;
267  p->setPen(Qt::NoPen);
268  p->setBrush(*fill);
269  p->drawRect(x+tlw, y+tlw, w-2*tlw, h-2*tlw);
270  p->setBrush(oldBrush);
271  }
272  p->setPen(oldPen); // restore pen
273 }
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
The QLineF class provides a two-dimensional vector using floating point precision.
Definition: qline.h:212
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
const QBrush & light() const
Returns the light brush of the current color group.
Definition: qpalette.h:126
void drawLines(const QLineF *lines, int lineCount)
Draws the first lineCount lines in the array lines using the current pen.
Definition: qpainter.cpp:4873
const QBrush & mid() const
Returns the mid brush of the current color group.
Definition: qpalette.h:128
Q_CORE_EXPORT void qWarning(const char *,...)
const QBrush & brush() const
Returns the painter&#39;s current brush.
Definition: qpainter.cpp:4232
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition: qpainter.h:650

◆ qDrawShadeRect() [2/2]

Q_GUI_EXPORT void qDrawShadeRect ( QPainter p,
const QRect r,
const QPalette pal,
bool  sunken = false,
int  lineWidth = 1,
int  midLineWidth = 0,
const QBrush fill = 0 
)

Definition at line 605 of file qdrawutil.cpp.

609 {
610  qDrawShadeRect(p, r.x(), r.y(), r.width(), r.height(), pal, sunken,
611  lineWidth, midLineWidth, fill);
612 }
void qDrawShadeRect(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, int midLineWidth, const QBrush *fill)
Definition: qdrawutil.cpp:204
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252

◆ qDrawWinButton() [1/2]

Q_GUI_EXPORT void qDrawWinButton ( QPainter p,
int  x,
int  y,
int  w,
int  h,
const QPalette pal,
bool  sunken = false,
const QBrush fill = 0 
)

Definition at line 435 of file qdrawutil.cpp.

Referenced by QWindowsStyle::drawComplexControl(), QWindowsStyle::drawControl(), QWindowsMobileStyle::drawPrimitive(), QWindowsStyle::drawPrimitive(), and qDrawWinButton().

438 {
439  if (sunken)
440  qDrawWinShades(p, x, y, w, h,
441  pal.shadow().color(), pal.light().color(), pal.dark().color(),
442  pal.button().color(), fill);
443  else
444  qDrawWinShades(p, x, y, w, h,
445  pal.light().color(), pal.shadow().color(), pal.button().color(),
446  pal.dark().color(), fill);
447 }
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
const QBrush & light() const
Returns the light brush of the current color group.
Definition: qpalette.h:126
const QBrush & shadow() const
Returns the shadow brush of the current color group.
Definition: qpalette.h:139
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.
Definition: qdrawutil.cpp:384
const QBrush & button() const
Returns the button brush of the current color group.
Definition: qpalette.h:125

◆ qDrawWinButton() [2/2]

Q_GUI_EXPORT void qDrawWinButton ( QPainter p,
const QRect r,
const QPalette pal,
bool  sunken = false,
const QBrush fill = 0 
)

Definition at line 669 of file qdrawutil.cpp.

671 {
672  qDrawWinButton(p, r.x(), r.y(), r.width(), r.height(), pal, sunken, fill);
673 }
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
void qDrawWinButton(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, const QBrush *fill)
Definition: qdrawutil.cpp:435
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252

◆ qDrawWinPanel() [1/2]

Q_GUI_EXPORT void qDrawWinPanel ( QPainter p,
int  x,
int  y,
int  w,
int  h,
const QPalette pal,
bool  sunken = false,
const QBrush fill = 0 
)

Definition at line 475 of file qdrawutil.cpp.

Referenced by QCommonStyle::drawComplexControl(), QWindowsStyle::drawComplexControl(), QCommonStyle::drawControl(), QCommonStyle::drawPrimitive(), QWindowsStyle::drawPrimitive(), QDecorationDefault::paint(), QDecorationWindows::paintButton(), QDecorationDefault::paintButton(), and qDrawWinPanel().

478 {
479  if (sunken)
480  qDrawWinShades(p, x, y, w, h,
481  pal.dark().color(), pal.light().color(), pal.shadow().color(),
482  pal.midlight().color(), fill);
483  else
484  qDrawWinShades(p, x, y, w, h,
485  pal.light().color(), pal.shadow().color(), pal.midlight().color(),
486  pal.dark().color(), fill);
487 }
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
const QBrush & light() const
Returns the light brush of the current color group.
Definition: qpalette.h:126
const QBrush & midlight() const
Returns the midlight brush of the current color group.
Definition: qpalette.h:136
const QBrush & shadow() const
Returns the shadow brush of the current color group.
Definition: qpalette.h:139
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.
Definition: qdrawutil.cpp:384

◆ qDrawWinPanel() [2/2]

Q_GUI_EXPORT void qDrawWinPanel ( QPainter p,
const QRect r,
const QPalette pal,
bool  sunken,
const QBrush fill 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the Windows-style panel at the rectangle specified by rect using the given painter with a line width of 2 pixels.

The button's interior is filled with the fill brush unless fill is 0.

The given palette specifies the shading colors. The panel appears sunken if sunken is true, otherwise raised.

Warning
This function does not look at QWidget::style() or QApplication::style(). Use the drawing functions in QStyle to make widgets that follow the current GUI style.

Alternatively you can use a QFrame widget and apply the QFrame::setFrameStyle() function to display a shaded panel:

See also
qDrawShadePanel(), qDrawWinButton(), QStyle

Definition at line 699 of file qdrawutil.cpp.

701 {
702  qDrawWinPanel(p, r.x(), r.y(), r.width(), r.height(), pal, sunken, fill);
703 }
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
void qDrawWinPanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, const QBrush *fill)
Definition: qdrawutil.cpp:475
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252