Qt 4.8
qdrawutil.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qdrawutil.h"
43 #include "qbitmap.h"
44 #include "qpixmapcache.h"
45 #include "qapplication.h"
46 #include "qpainter.h"
47 #include "qpalette.h"
48 #include <private/qpaintengineex_p.h>
49 #include <qvarlengtharray.h>
50 #include <qmath.h>
51 #include <private/qstylehelper_p.h>
52 
54 
93 void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2,
94  const QPalette &pal, bool sunken,
95  int lineWidth, int midLineWidth)
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 }
172 
204 void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
205  const QPalette &pal, bool sunken,
206  int lineWidth, int midLineWidth,
207  const QBrush *fill)
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 }
274 
275 
303 void qDrawShadePanel(QPainter *p, int x, int y, int w, int h,
304  const QPalette &pal, bool sunken,
305  int lineWidth, const QBrush *fill)
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 }
364 
365 
384 static void qDrawWinShades(QPainter *p,
385  int x, int y, int w, int h,
386  const QColor &c1, const QColor &c2,
387  const QColor &c3, const QColor &c4,
388  const QBrush *fill)
389 {
390  if (w < 2 || h < 2) // can't do anything with that
391  return;
392  QPen oldPen = p->pen();
393  QPoint a[3] = { QPoint(x, y+h-2), QPoint(x, y), QPoint(x+w-2, y) };
394  p->setPen(c1);
395  p->drawPolyline(a, 3);
396  QPoint b[3] = { QPoint(x, y+h-1), QPoint(x+w-1, y+h-1), QPoint(x+w-1, y) };
397  p->setPen(c2);
398  p->drawPolyline(b, 3);
399  if (w > 4 && h > 4) {
400  QPoint c[3] = { QPoint(x+1, y+h-3), QPoint(x+1, y+1), QPoint(x+w-3, y+1) };
401  p->setPen(c3);
402  p->drawPolyline(c, 3);
403  QPoint d[3] = { QPoint(x+1, y+h-2), QPoint(x+w-2, y+h-2), QPoint(x+w-2, y+1) };
404  p->setPen(c4);
405  p->drawPolyline(d, 3);
406  if (fill)
407  p->fillRect(QRect(x+2, y+2, w-4, h-4), *fill);
408  }
409  p->setPen(oldPen);
410 }
411 
412 
435 void qDrawWinButton(QPainter *p, int x, int y, int w, int h,
436  const QPalette &pal, bool sunken,
437  const QBrush *fill)
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 }
448 
475 void qDrawWinPanel(QPainter *p, int x, int y, int w, int h,
476  const QPalette &pal, bool sunken,
477  const QBrush *fill)
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 }
488 
511 void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &c,
512  int lineWidth, const QBrush *fill)
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 }
533 
534 /*****************************************************************************
535  Overloaded functions.
536  *****************************************************************************/
537 
568 void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint &p2,
569  const QPalette &pal, bool sunken,
570  int lineWidth, int midLineWidth)
571 {
572  qDrawShadeLine(p, p1.x(), p1.y(), p2.x(), p2.y(), pal, sunken,
573  lineWidth, midLineWidth);
574 }
575 
605 void qDrawShadeRect(QPainter *p, const QRect &r,
606  const QPalette &pal, bool sunken,
607  int lineWidth, int midLineWidth,
608  const QBrush *fill)
609 {
610  qDrawShadeRect(p, r.x(), r.y(), r.width(), r.height(), pal, sunken,
611  lineWidth, midLineWidth, fill);
612 }
613 
640 void qDrawShadePanel(QPainter *p, const QRect &r,
641  const QPalette &pal, bool sunken,
642  int lineWidth, const QBrush *fill)
643 {
644  qDrawShadePanel(p, r.x(), r.y(), r.width(), r.height(), pal, sunken,
645  lineWidth, fill);
646 }
647 
669 void qDrawWinButton(QPainter *p, const QRect &r,
670  const QPalette &pal, bool sunken, const QBrush *fill)
671 {
672  qDrawWinButton(p, r.x(), r.y(), r.width(), r.height(), pal, sunken, fill);
673 }
674 
699 void qDrawWinPanel(QPainter *p, const QRect &r,
700  const QPalette &pal, bool sunken, const QBrush *fill)
701 {
702  qDrawWinPanel(p, r.x(), r.y(), r.width(), r.height(), pal, sunken, fill);
703 }
704 
726 void qDrawPlainRect(QPainter *p, const QRect &r, const QColor &c,
727  int lineWidth, const QBrush *fill)
728 {
729  qDrawPlainRect(p, r.x(), r.y(), r.width(), r.height(), c,
730  lineWidth, fill);
731 }
732 
733 #ifdef QT3_SUPPORT
734 static void qDrawWinArrow(QPainter *p, Qt::ArrowType type, bool down,
735  int x, int y, int w, int h,
736  const QPalette &pal, bool enabled)
737 {
738  QPolygon a; // arrow polygon
739  switch (type) {
740  case Qt::UpArrow:
741  a.setPoints(7, -3,1, 3,1, -2,0, 2,0, -1,-1, 1,-1, 0,-2);
742  break;
743  case Qt::DownArrow:
744  a.setPoints(7, -3,-1, 3,-1, -2,0, 2,0, -1,1, 1,1, 0,2);
745  break;
746  case Qt::LeftArrow:
747  a.setPoints(7, 1,-3, 1,3, 0,-2, 0,2, -1,-1, -1,1, -2,0);
748  break;
749  case Qt::RightArrow:
750  a.setPoints(7, -1,-3, -1,3, 0,-2, 0,2, 1,-1, 1,1, 2,0);
751  break;
752  default:
753  break;
754  }
755  if (a.isEmpty())
756  return;
757 
758  if (down) {
759  x++;
760  y++;
761  }
762 
763  QPen savePen = p->pen(); // save current pen
764  if (down)
765  p->setBrushOrigin(p->brushOrigin() + QPoint(1,1));
766  p->fillRect(x, y, w, h, pal.brush(QPalette::Button));
767  if (down)
768  p->setBrushOrigin(p->brushOrigin() - QPoint(1,1));
769  if (enabled) {
770  a.translate(x+w/2, y+h/2);
771  p->setPen(pal.foreground().color());
772  p->drawLine(a.at(0), a.at(1));
773  p->drawLine(a.at(2), a.at(2));
774  p->drawPoint(a[6]);
775  } else {
776  a.translate(x+w/2+1, y+h/2+1);
777  p->setPen(pal.light().color());
778  p->drawLine(a.at(0), a.at(1));
779  p->drawLine(a.at(2), a.at(2));
780  p->drawPoint(a[6]);
781  a.translate(-1, -1);
782  p->setPen(pal.mid().color());
783  p->drawLine(a.at(0), a.at(1));
784  p->drawLine(a.at(2), a.at(2));
785  p->drawPoint(a[6]);
786  }
787  p->setPen(savePen); // restore pen
788 }
789 #endif // QT3_SUPPORT
790 
791 #if defined(Q_CC_MSVC)
792 #pragma warning(disable: 4244)
793 #endif
794 
795 #ifdef QT3_SUPPORT
796 #ifndef QT_NO_STYLE_MOTIF
797 // motif arrows look the same whether they are used or not
798 // is this correct?
799 static void qDrawMotifArrow(QPainter *p, Qt::ArrowType type, bool down,
800  int x, int y, int w, int h,
801  const QPalette &pal, bool)
802 {
803  QPolygon bFill; // fill polygon
804  QPolygon bTop; // top shadow.
805  QPolygon bBot; // bottom shadow.
806  QPolygon bLeft; // left shadow.
807  QTransform matrix; // xform matrix
808  bool vertical = type == Qt::UpArrow || type == Qt::DownArrow;
809  bool horizontal = !vertical;
810  int dim = w < h ? w : h;
811  int colspec = 0x0000; // color specification array
812 
813  if (dim < 2) // too small arrow
814  return;
815 
816  if (dim > 3) {
817  if (dim > 6)
818  bFill.resize(dim & 1 ? 3 : 4);
819  bTop.resize((dim/2)*2);
820  bBot.resize(dim & 1 ? dim + 1 : dim);
821  bLeft.resize(dim > 4 ? 4 : 2);
822  bLeft.putPoints(0, 2, 0,0, 0,dim-1);
823  if (dim > 4)
824  bLeft.putPoints(2, 2, 1,2, 1,dim-3);
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);
827 
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);
831  }
832  if (dim & 1) // odd number size: extra line
833  bBot.putPoints(dim-1, 2, dim-3,dim/2, dim-1,dim/2);
834  if (dim > 6) { // dim>6: must fill interior
835  bFill.putPoints(0, 2, 1,dim-3, 1,2);
836  if (dim & 1) // if size is an odd number
837  bFill.setPoint(2, dim - 3, dim / 2);
838  else
839  bFill.putPoints(2, 2, dim-4,dim/2-1, dim-4,dim/2);
840  }
841  }
842  else {
843  if (dim == 3) { // 3x3 arrow pattern
844  bLeft.setPoints(4, 0,0, 0,2, 1,1, 1,1);
845  bTop .setPoints(2, 1,0, 1,0);
846  bBot .setPoints(2, 1,2, 2,1);
847  }
848  else { // 2x2 arrow pattern
849  bLeft.setPoints(2, 0,0, 0,1);
850  bTop .setPoints(2, 1,0, 1,0);
851  bBot .setPoints(2, 1,1, 1,1);
852  }
853  }
854 
855  if (type == Qt::UpArrow || type == Qt::LeftArrow) {
856  matrix.translate(x, y);
857  if (vertical) {
858  matrix.translate(0, h - 1);
859  matrix.rotate(-90);
860  } else {
861  matrix.translate(w - 1, h - 1);
862  matrix.rotate(180);
863  }
864  if (down)
865  colspec = horizontal ? 0x2334 : 0x2343;
866  else
867  colspec = horizontal ? 0x1443 : 0x1434;
868  }
869  else if (type == Qt::DownArrow || type == Qt::RightArrow) {
870  matrix.translate(x, y);
871  if (vertical) {
872  matrix.translate(w-1, 0);
873  matrix.rotate(90);
874  }
875  if (down)
876  colspec = horizontal ? 0x2443 : 0x2434;
877  else
878  colspec = horizontal ? 0x1334 : 0x1343;
879  }
880 
881  const QColor *cols[5];
882  cols[0] = 0;
883  cols[1] = &pal.button().color();
884  cols[2] = &pal.mid().color();
885  cols[3] = &pal.light().color();
886  cols[4] = &pal.dark().color();
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]
891 
892  QPen savePen = p->pen(); // save current pen
893  QBrush saveBrush = p->brush(); // save current brush
894  QTransform wxm = p->transform();
895  QPen pen(Qt::NoPen);
896  const QBrush &brush = pal.brush(QPalette::Button);
897 
898  p->setPen(pen);
899  p->setBrush(brush);
900  p->setTransform(matrix, true); // set transformation matrix
901  p->drawPolygon(bFill); // fill arrow
902  p->setBrush(Qt::NoBrush); // don't fill
903 
904  p->setPen(CLEFT);
905  p->drawLines(bLeft);
906  p->setPen(CTOP);
907  p->drawLines(bTop);
908  p->setPen(CBOT);
909  p->drawLines(bBot);
910 
911  p->setTransform(wxm);
912  p->setBrush(saveBrush); // restore brush
913  p->setPen(savePen); // restore pen
914 
915 #undef CMID
916 #undef CLEFT
917 #undef CTOP
918 #undef CBOT
919 }
920 #endif // QT_NO_STYLE_MOTIF
921 
922 QRect qItemRect(QPainter *p, Qt::GUIStyle gs,
923  int x, int y, int w, int h,
924  int flags,
925  bool enabled,
926  const QPixmap *pixmap,
927  const QString& text, int len)
928 {
929  QRect result;
930 
931  if (pixmap) {
932  if ((flags & Qt::AlignVCenter) == Qt::AlignVCenter)
933  y += h/2 - pixmap->height()/2;
934  else if ((flags & Qt::AlignBottom) == Qt::AlignBottom)
935  y += h - pixmap->height();
936  if ((flags & Qt::AlignRight) == Qt::AlignRight)
937  x += w - pixmap->width();
938  else if ((flags & Qt::AlignHCenter) == Qt::AlignHCenter)
939  x += w/2 - pixmap->width()/2;
940  else if ((flags & Qt::AlignLeft) != Qt::AlignLeft && QApplication::isRightToLeft())
941  x += w - pixmap->width();
942  result = QRect(x, y, pixmap->width(), pixmap->height());
943  } else if (!text.isNull() && p) {
944  result = p->boundingRect(QRect(x, y, w, h), flags, text.left(len));
945  if (gs == Qt::WindowsStyle && !enabled) {
946  result.setWidth(result.width()+1);
947  result.setHeight(result.height()+1);
948  }
949  } else {
950  result = QRect(x, y, w, h);
951  }
952 
953  return result;
954 }
955 
956 void qDrawArrow(QPainter *p, Qt::ArrowType type, Qt::GUIStyle style, bool down,
957  int x, int y, int w, int h,
958  const QPalette &pal, bool enabled)
959 {
960  switch (style) {
961  case Qt::WindowsStyle:
962  qDrawWinArrow(p, type, down, x, y, w, h, pal, enabled);
963  break;
964 #ifndef QT_NO_STYLE_MOTIF
965  case Qt::MotifStyle:
966  qDrawMotifArrow(p, type, down, x, y, w, h, pal, enabled);
967  break;
968 #endif
969  default:
970  qWarning("qDrawArrow: Requested unsupported GUI style");
971  }
972 }
973 
974 void qDrawItem(QPainter *p, Qt::GUIStyle gs,
975  int x, int y, int w, int h,
976  int flags,
977  const QPalette &pal, bool enabled,
978  const QPixmap *pixmap,
979  const QString& text, int len , const QColor* penColor)
980 {
981  p->setPen(penColor?*penColor:pal.foreground().color());
982  if (pixmap) {
983  QPixmap pm(*pixmap);
984  bool clip = (flags & Qt::TextDontClip) == 0;
985  if (clip) {
986  if (pm.width() < w && pm.height() < h)
987  clip = false;
988  else
989  p->setClipRect(x, y, w, h);
990  }
991  if ((flags & Qt::AlignVCenter) == Qt::AlignVCenter)
992  y += h/2 - pm.height()/2;
993  else if ((flags & Qt::AlignBottom) == Qt::AlignBottom)
994  y += h - pm.height();
995  if ((flags & Qt::AlignRight) == Qt::AlignRight)
996  x += w - pm.width();
997  else if ((flags & Qt::AlignHCenter) == Qt::AlignHCenter)
998  x += w/2 - pm.width()/2;
999  else if (((flags & Qt::AlignLeft) != Qt::AlignLeft) && QApplication::isRightToLeft()) // Qt::AlignAuto && rightToLeft
1000  x += w - pm.width();
1001 
1002  if (!enabled) {
1003  if (pm.hasAlphaChannel()) { // pixmap with a mask
1004  pm = pm.mask();
1005  } else if (pm.depth() == 1) { // monochrome pixmap, no mask
1006  ;
1007 #ifndef QT_NO_IMAGE_HEURISTIC_MASK
1008  } else { // color pixmap, no mask
1009  QString k = QLatin1Literal("$qt-drawitem")
1010  % HexString<qint64>(pm.cacheKey());
1011 
1012  if (!QPixmapCache::find(k, pm)) {
1013  pm = pm.createHeuristicMask();
1014  pm.setMask((QBitmap&)pm);
1015  QPixmapCache::insert(k, pm);
1016  }
1017 #endif
1018  }
1019  if (gs == Qt::WindowsStyle) {
1020  p->setPen(pal.light().color());
1021  p->drawPixmap(x+1, y+1, pm);
1022  p->setPen(pal.text().color());
1023  }
1024  }
1025  p->drawPixmap(x, y, pm);
1026  if (clip)
1027  p->setClipping(false);
1028  } else if (!text.isNull()) {
1029  if (gs == Qt::WindowsStyle && !enabled) {
1030  p->setPen(pal.light().color());
1031  p->drawText(x+1, y+1, w, h, flags, text.left(len));
1032  p->setPen(pal.text().color());
1033  }
1034  p->drawText(x, y, w, h, flags, text.left(len));
1035  }
1036 }
1037 
1038 #endif
1039 
1087 
1106 void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMargins,
1107  const QPixmap &pixmap, const QRect &sourceRect,const QMargins &sourceMargins,
1108  const QTileRules &rules, QDrawBorderPixmap::DrawingHints hints)
1109 {
1110  if (!painter->isActive()) {
1111  qWarning("qDrawBorderPixmap: Painter not active");
1112  return;
1113  }
1114 
1115  QRectFArray sourceData[2];
1116  QRectFArray targetData[2];
1117 
1118  // source center
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;
1125  // target center
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;
1132 
1133  QVarLengthArray<qreal, 16> xTarget; // x-coordinates of target rectangles
1134  QVarLengthArray<qreal, 16> yTarget; // y-coordinates of target rectangles
1135 
1136  int columns = 3;
1137  int rows = 3;
1138  if (rules.horizontal != Qt::StretchTile && sourceCenterWidth != 0)
1139  columns = qMax(3, 2 + qCeil(targetCenterWidth / qreal(sourceCenterWidth)));
1140  if (rules.vertical != Qt::StretchTile && sourceCenterHeight != 0)
1141  rows = qMax(3, 2 + qCeil(targetCenterHeight / qreal(sourceCenterHeight)));
1142 
1143  xTarget.resize(columns + 1);
1144  yTarget.resize(rows + 1);
1145 
1146  bool oldAA = painter->testRenderHint(QPainter::Antialiasing);
1147  if (painter->paintEngine()->type() != QPaintEngine::OpenGL
1148  && painter->paintEngine()->type() != QPaintEngine::OpenGL2
1149  && oldAA && painter->combinedTransform().type() != QTransform::TxNone) {
1150  painter->setRenderHint(QPainter::Antialiasing, false);
1151  }
1152 
1153  xTarget[0] = targetRect.left();
1154  xTarget[1] = targetCenterLeft;
1155  xTarget[columns - 1] = targetCenterRight;
1156  xTarget[columns] = targetRect.left() + targetRect.width();
1157 
1158  yTarget[0] = targetRect.top();
1159  yTarget[1] = targetCenterTop;
1160  yTarget[rows - 1] = targetCenterBottom;
1161  yTarget[rows] = targetRect.top() + targetRect.height();
1162 
1163  qreal dx = targetCenterWidth;
1164  qreal dy = targetCenterHeight;
1165 
1166  switch (rules.horizontal) {
1167  case Qt::StretchTile:
1168  dx = targetCenterWidth;
1169  break;
1170  case Qt::RepeatTile:
1171  dx = sourceCenterWidth;
1172  break;
1173  case Qt::RoundTile:
1174  dx = targetCenterWidth / qreal(columns - 2);
1175  break;
1176  }
1177 
1178  for (int i = 2; i < columns - 1; ++i)
1179  xTarget[i] = xTarget[i - 1] + dx;
1180 
1181  switch (rules.vertical) {
1182  case Qt::StretchTile:
1183  dy = targetCenterHeight;
1184  break;
1185  case Qt::RepeatTile:
1186  dy = sourceCenterHeight;
1187  break;
1188  case Qt::RoundTile:
1189  dy = targetCenterHeight / qreal(rows - 2);
1190  break;
1191  }
1192 
1193  for (int i = 2; i < rows - 1; ++i)
1194  yTarget[i] = yTarget[i - 1] + dy;
1195 
1196  // corners
1197  if (targetMargins.top() > 0 && targetMargins.left() > 0 && sourceMargins.top() > 0 && sourceMargins.left() > 0) { // top left
1198  int index = bool(hints & QDrawBorderPixmap::OpaqueTopLeft);
1199  sourceData[index].append(QRectF(sourceRect.topLeft(), QSizeF(sourceMargins.left(), sourceMargins.top())));
1200  targetData[index].append(QRectF(QPointF(xTarget[0], yTarget[0]), QPointF(xTarget[1], yTarget[1])));
1201  }
1202  if (targetMargins.top() > 0 && targetMargins.right() > 0 && sourceMargins.top() > 0 && sourceMargins.right() > 0) { // top right
1203  int index = bool(hints & QDrawBorderPixmap::OpaqueTopRight);
1204  sourceData[index].append(QRectF(QPointF(sourceCenterRight, sourceRect.top()), QSizeF(sourceMargins.right(), sourceMargins.top())));
1205  targetData[index].append(QRectF(QPointF(xTarget[columns-1], yTarget[0]), QPointF(xTarget[columns], yTarget[1])));
1206  }
1207  if (targetMargins.bottom() > 0 && targetMargins.left() > 0 && sourceMargins.bottom() > 0 && sourceMargins.left() > 0) { // bottom left
1208  int index = bool(hints & QDrawBorderPixmap::OpaqueBottomLeft);
1209  sourceData[index].append(QRectF(QPointF(sourceRect.left(), sourceCenterBottom), QSizeF(sourceMargins.left(), sourceMargins.bottom())));
1210  targetData[index].append(QRectF(QPointF(xTarget[0], yTarget[rows - 1]), QPointF(xTarget[1], yTarget[rows])));
1211  }
1212  if (targetMargins.bottom() > 0 && targetMargins.right() > 0 && sourceMargins.bottom() > 0 && sourceMargins.right() > 0) { // bottom right
1213  int index = bool(hints & QDrawBorderPixmap::OpaqueBottomRight);
1214  sourceData[index].append(QRectF(QPointF(sourceCenterRight, sourceCenterBottom), QSizeF(sourceMargins.right(), sourceMargins.bottom())));
1215  targetData[index].append(QRectF(QPointF(xTarget[columns - 1], yTarget[rows - 1]), QPointF(xTarget[columns], yTarget[rows])));
1216  }
1217 
1218  // horizontal edges
1219  if (targetCenterWidth > 0 && sourceCenterWidth > 0) {
1220  if (targetMargins.top() > 0 && sourceMargins.top() > 0) { // top
1221  int index = bool(hints & QDrawBorderPixmap::OpaqueTop);
1222  for (int i = 1; i < columns - 1; ++i) {
1223  if (rules.horizontal == Qt::RepeatTile && i == columns - 2) {
1224  sourceData[index].append(QRectF(QPointF(sourceCenterLeft, sourceRect.top()), QSizeF(xTarget[i + 1] - xTarget[i], sourceMargins.top())));
1225  } else {
1226  sourceData[index].append(QRectF(QPointF(sourceCenterLeft, sourceRect.top()), QSizeF(sourceCenterWidth, sourceMargins.top())));
1227  }
1228  targetData[index].append(QRectF(QPointF(xTarget[i], yTarget[0]), QPointF(xTarget[i + 1], yTarget[1])));
1229  }
1230  }
1231  if (targetMargins.bottom() > 0 && sourceMargins.bottom() > 0) { // bottom
1232  int index = bool(hints & QDrawBorderPixmap::OpaqueBottom);
1233  for (int i = 1; i < columns - 1; ++i) {
1234  if (rules.horizontal == Qt::RepeatTile && i == columns - 2) {
1235  sourceData[index].append(QRectF(QPointF(sourceCenterLeft, sourceCenterBottom), QSizeF(xTarget[i + 1] - xTarget[i], sourceMargins.bottom())));
1236  } else {
1237  sourceData[index].append(QRectF(QPointF(sourceCenterLeft, sourceCenterBottom), QSizeF(sourceCenterWidth, sourceMargins.bottom())));
1238  }
1239  targetData[index].append(QRectF(QPointF(xTarget[i], yTarget[rows - 1]), QPointF(xTarget[i + 1], yTarget[rows])));
1240  }
1241  }
1242  }
1243 
1244  // vertical edges
1245  if (targetCenterHeight > 0 && sourceCenterHeight > 0) {
1246  if (targetMargins.left() > 0 && sourceMargins.left() > 0) { // left
1247  int index = bool(hints & QDrawBorderPixmap::OpaqueLeft);
1248  for (int i = 1; i < rows - 1; ++i) {
1249  if (rules.vertical == Qt::RepeatTile && i == rows - 2) {
1250  sourceData[index].append(QRectF(QPointF(sourceRect.left(), sourceCenterTop), QSizeF(sourceMargins.left(), yTarget[i + 1] - yTarget[i])));
1251  } else {
1252  sourceData[index].append(QRectF(QPointF(sourceRect.left(), sourceCenterTop), QSizeF(sourceMargins.left(), sourceCenterHeight)));
1253  }
1254  targetData[index].append(QRectF(QPointF(xTarget[0], yTarget[i]), QPointF(xTarget[1], yTarget[i + 1])));
1255  }
1256  }
1257  if (targetMargins.right() > 0 && sourceMargins.right() > 0) { // right
1258  int index = bool(hints & QDrawBorderPixmap::OpaqueRight);
1259  for (int i = 1; i < rows - 1; ++i) {
1260  if (rules.vertical == Qt::RepeatTile && i == rows - 2) {
1261  sourceData[index].append(QRectF(QPointF(sourceCenterRight, sourceCenterTop), QSizeF(sourceMargins.right(), yTarget[i + 1] - yTarget[i])));
1262  } else {
1263  sourceData[index].append(QRectF(QPointF(sourceCenterRight, sourceCenterTop), QSizeF(sourceMargins.right(), sourceCenterHeight)));
1264  }
1265  targetData[index].append(QRectF(QPointF(xTarget[columns - 1], yTarget[i]), QPointF(xTarget[columns], yTarget[i + 1])));
1266  }
1267  }
1268  }
1269 
1270  // center
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) {
1274  qreal sourceHeight = (rules.vertical == Qt::RepeatTile && j == rows - 2) ? yTarget[j + 1] - yTarget[j] : sourceCenterHeight;
1275  for (int i = 1; i < columns - 1; ++i) {
1276  qreal sourceWidth = (rules.horizontal == Qt::RepeatTile && i == columns - 2) ? xTarget[i + 1] - xTarget[i] : sourceCenterWidth;
1277  sourceData[index].append(QRectF(QPointF(sourceCenterLeft, sourceCenterTop), QSizeF(sourceWidth, sourceHeight)));
1278  targetData[index].append(QRectF(QPointF(xTarget[i], yTarget[j]), QPointF(xTarget[i + 1], yTarget[j + 1])));
1279  }
1280  }
1281  }
1282 
1283  for (int i = 0; i < 2; ++i) {
1284  if (sourceData[i].size())
1285  painter->drawPixmapFragments(targetData[i].data(), sourceData[i].data(), sourceData[i].size(), pixmap, i == 1 ? QPainter::OpaqueHint : QPainter::PixmapFragmentHint(0));
1286  }
1287 
1288  if (oldAA)
1289  painter->setRenderHint(QPainter::Antialiasing, true);
1290 }
1291 
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...
Definition: qpainter.cpp:7093
void setTransform(const QTransform &transform, bool combine=false)
Sets the world transformation matrix.
Definition: qpainter.cpp:9547
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
void resize(int size)
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
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...
Definition: qpainter.cpp:9697
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
int type
Definition: qmetatype.cpp:239
double qreal
Definition: qglobal.h:1193
unsigned char c[8]
Definition: qnumeric_p.h:62
const QTransform & transform() const
Returns the world transformation matrix.
Definition: qpainter.cpp:9558
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &c, int lineWidth, const QBrush *fill)
Definition: qdrawutil.cpp:511
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
int qCeil(qreal v)
Definition: qmath.h:63
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
void setMask(const QBitmap &)
Sets a mask bitmap.
Definition: qpixmap.cpp:822
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...
Definition: qpainter.cpp:2801
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
const QBrush & foreground() const
Use windowText() instead.
Definition: qpalette.h:123
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 ...
Definition: qpolygon.cpp:406
The QPolygon class provides a vector of points using integer precision.
Definition: qpolygon.h:60
QTransform & translate(qreal dx, qreal dy)
Moves the coordinate system dx along the x axis and dy along the y axis, and returns a reference to t...
Definition: qtransform.cpp:417
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
bool testRenderHint(RenderHint hint) const
Returns true if hint is set; otherwise returns false.
Definition: qpainter.h:457
int depth() const
Returns the depth of the pixmap.
Definition: qpixmap.cpp:695
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
TransformationType type() const
Returns the transformation type of this matrix.
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
void setBrushOrigin(int x, int y)
Sets the brush&#39;s origin to point (x, y).
Definition: qpainter.h:825
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
void append(const T &t)
Qt::TileRule vertical
Definition: qdrawutil.h:143
void drawPoint(const QPointF &pt)
Draws a single point at the given position using the current pen&#39;s color.
Definition: qpainter.h:676
#define CTOP
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
static QPixmap * find(const QString &key)
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
The QLineF class provides a two-dimensional vector using floating point precision.
Definition: qline.h:212
int top() const
Returns the top margin.
Definition: qmargins.h:99
The QBitmap class provides monochrome (1-bit depth) pixmaps.
Definition: qbitmap.h:55
void translate(int dx, int dy)
Translates all points in the polygon by ({dx}, {dy}).
Definition: qpolygon.cpp:238
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position...
Definition: qpainter.cpp:6231
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
Definition: qpainter.cpp:7620
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QPoint brushOrigin() const
Returns the currently set brush origin.
Definition: qpainter.cpp:2168
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
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
Definition: qvector.h:347
QVarLengthArray< QRectF, 16 > QRectFArray
Definition: qdrawutil.cpp:1086
void qDrawWinPanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, const QBrush *fill)
Definition: qdrawutil.cpp:475
bool isActive() const
Returns true if begin() has been called and end() has not yet been called; otherwise returns false...
Definition: qpainter.cpp:1545
QTransform & rotate(qreal a, Qt::Axis axis=Qt::ZAxis)
Rotates the coordinate system counterclockwise by the given angle about the specified axis and return...
Definition: qtransform.cpp:615
virtual Type type() const =0
Reimplement this function to return the paint engine Type.
#define CBOT
const QBrush & midlight() const
Returns the midlight brush of the current color group.
Definition: qpalette.h:136
const QBrush & mid() const
Returns the mid brush of the current color group.
Definition: qpalette.h:128
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)
Definition: qdrawutil.cpp:435
QPaintEngine * paintEngine() const
Returns the paint engine that the painter is currently operating on if the painter is active; otherwi...
Definition: qpainter.cpp:1991
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...
Definition: qpainter.cpp:5205
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
QTransform combinedTransform() const
Returns the transformation matrix combining the current window/viewport and world transformation...
Definition: qpainter.cpp:9669
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...
Definition: qdrawutil.cpp:1106
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
Definition: qpalette.cpp:874
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
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
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
const QBrush & shadow() const
Returns the shadow brush of the current color group.
Definition: qpalette.h:139
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
Qt::TileRule horizontal
Definition: qdrawutil.h:142
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
QBitmap mask() const
Extracts a bitmap mask from the pixmap&#39;s alpha channel.
Definition: qpixmap.cpp:2077
void setClipping(bool enable)
Enables clipping if enable is true, or disables clipping if enable is false.
Definition: qpainter.cpp:2517
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
Holds the rules used to draw a pixmap or image split into nine segments, similar to [CSS3 border-imag...
Definition: qdrawutil.h:136
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
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.
Definition: qpoint.h:53
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
void setWidth(int w)
Sets the width of the rectangle to the given width.
Definition: qrect.h:442
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
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void setPoint(int index, int x, int y)
Sets the point at the given index to the point specified by ({x}, {y}).
Definition: qpolygon.h:120
#define CLEFT
qint64 cacheKey() const
Returns a number that identifies this QPixmap.
Definition: qpixmap.cpp:1136
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition: qpainter.h:650
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
quint16 index
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
PixmapFragmentHint
Definition: qpainter.h:120
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
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...
Definition: qpainter.cpp:5619
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645
int left() const
Returns the left margin.
Definition: qmargins.h:96
void setPoints(int nPoints, const int *points)
Resizes the polygon to nPoints and populates it with the given points.
Definition: qpolygon.cpp:350
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139
void reserve(int size)
Attempts to allocate memory for at least size elements.
Definition: qvector.h:339
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
The QMargins class defines the four margins of a rectangle.
Definition: qmargins.h:53
bool hasAlphaChannel() const
Returns true if the pixmap has a format that respects the alpha channel, otherwise returns false...
Definition: qpixmap.cpp:1965
const QBrush & button() const
Returns the button brush of the current color group.
Definition: qpalette.h:125
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
QBitmap createHeuristicMask(bool clipTight=true) const
Creates and returns a heuristic mask for this pixmap.
Definition: qpixmap.cpp:864
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
static bool isRightToLeft()
Returns true if the application&#39;s layout direction is Qt::RightToLeft; otherwise returns false...
Definition: qapplication.h:233
int bottom() const
Returns the bottom margin.
Definition: qmargins.h:105
int right() const
Returns the right margin.
Definition: qmargins.h:102
#define enabled
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
#define text
Definition: qobjectdefs.h:80
const QBrush & text() const
Returns the text foreground brush of the current color group.
Definition: qpalette.h:129
ArrowType
Definition: qnamespace.h:1126
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61