qdrawutil.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2016 The Qt Company Ltd.
  4. ** Contact: https://www.qt.io/licensing/
  5. **
  6. ** This file is part of the QtWidgets 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 The Qt Company. For licensing terms
  14. ** and conditions see https://www.qt.io/terms-conditions. For further
  15. ** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
  20. ** Foundation and appearing in the file LICENSE.LGPL3 included in the
  21. ** packaging of this file. Please review the following information to
  22. ** ensure the GNU Lesser General Public License version 3 requirements
  23. ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
  24. **
  25. ** GNU General Public License Usage
  26. ** Alternatively, this file may be used under the terms of the GNU
  27. ** General Public License version 2.0 or (at your option) the GNU General
  28. ** Public license version 3 or any later version approved by the KDE Free
  29. ** Qt Foundation. The licenses are as published by the Free Software
  30. ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
  31. ** included in the packaging of this file. Please review the following
  32. ** information to ensure the GNU General Public License requirements will
  33. ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
  34. ** https://www.gnu.org/licenses/gpl-3.0.html.
  35. **
  36. ** $QT_END_LICENSE$
  37. **
  38. ****************************************************************************/
  39. #ifndef QDRAWUTIL_H
  40. #define QDRAWUTIL_H
  41. #include <QtCore/qnamespace.h>
  42. #include <QtCore/qstring.h> // char*->QString conversion
  43. #include <QtCore/qmargins.h>
  44. #include <QtGui/qpixmap.h>
  45. QT_BEGIN_NAMESPACE
  46. class QPainter;
  47. class QPalette;
  48. class QPoint;
  49. class QColor;
  50. class QBrush;
  51. class QRect;
  52. //
  53. // Standard shade drawing
  54. //
  55. Q_WIDGETS_EXPORT void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2,
  56. const QPalette &pal, bool sunken = true,
  57. int lineWidth = 1, int midLineWidth = 0);
  58. Q_WIDGETS_EXPORT void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint &p2,
  59. const QPalette &pal, bool sunken = true,
  60. int lineWidth = 1, int midLineWidth = 0);
  61. Q_WIDGETS_EXPORT void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
  62. const QPalette &pal, bool sunken = false,
  63. int lineWidth = 1, int midLineWidth = 0,
  64. const QBrush *fill = Q_NULLPTR);
  65. Q_WIDGETS_EXPORT void qDrawShadeRect(QPainter *p, const QRect &r,
  66. const QPalette &pal, bool sunken = false,
  67. int lineWidth = 1, int midLineWidth = 0,
  68. const QBrush *fill = Q_NULLPTR);
  69. Q_WIDGETS_EXPORT void qDrawShadePanel(QPainter *p, int x, int y, int w, int h,
  70. const QPalette &pal, bool sunken = false,
  71. int lineWidth = 1, const QBrush *fill = Q_NULLPTR);
  72. Q_WIDGETS_EXPORT void qDrawShadePanel(QPainter *p, const QRect &r,
  73. const QPalette &pal, bool sunken = false,
  74. int lineWidth = 1, const QBrush *fill = Q_NULLPTR);
  75. Q_WIDGETS_EXPORT void qDrawWinButton(QPainter *p, int x, int y, int w, int h,
  76. const QPalette &pal, bool sunken = false,
  77. const QBrush *fill = Q_NULLPTR);
  78. Q_WIDGETS_EXPORT void qDrawWinButton(QPainter *p, const QRect &r,
  79. const QPalette &pal, bool sunken = false,
  80. const QBrush *fill = Q_NULLPTR);
  81. Q_WIDGETS_EXPORT void qDrawWinPanel(QPainter *p, int x, int y, int w, int h,
  82. const QPalette &pal, bool sunken = false,
  83. const QBrush *fill = Q_NULLPTR);
  84. Q_WIDGETS_EXPORT void qDrawWinPanel(QPainter *p, const QRect &r,
  85. const QPalette &pal, bool sunken = false,
  86. const QBrush *fill = Q_NULLPTR);
  87. Q_WIDGETS_EXPORT void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &,
  88. int lineWidth = 1, const QBrush *fill = Q_NULLPTR);
  89. Q_WIDGETS_EXPORT void qDrawPlainRect(QPainter *p, const QRect &r, const QColor &,
  90. int lineWidth = 1, const QBrush *fill = Q_NULLPTR);
  91. struct QTileRules
  92. {
  93. inline QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule)
  94. : horizontal(horizontalRule), vertical(verticalRule) {}
  95. inline QTileRules(Qt::TileRule rule = Qt::StretchTile)
  96. : horizontal(rule), vertical(rule) {}
  97. Qt::TileRule horizontal;
  98. Qt::TileRule vertical;
  99. };
  100. #ifndef Q_QDOC
  101. // For internal use only.
  102. namespace QDrawBorderPixmap
  103. {
  104. enum DrawingHint
  105. {
  106. OpaqueTopLeft = 0x0001,
  107. OpaqueTop = 0x0002,
  108. OpaqueTopRight = 0x0004,
  109. OpaqueLeft = 0x0008,
  110. OpaqueCenter = 0x0010,
  111. OpaqueRight = 0x0020,
  112. OpaqueBottomLeft = 0x0040,
  113. OpaqueBottom = 0x0080,
  114. OpaqueBottomRight = 0x0100,
  115. OpaqueCorners = OpaqueTopLeft | OpaqueTopRight | OpaqueBottomLeft | OpaqueBottomRight,
  116. OpaqueEdges = OpaqueTop | OpaqueLeft | OpaqueRight | OpaqueBottom,
  117. OpaqueFrame = OpaqueCorners | OpaqueEdges,
  118. OpaqueAll = OpaqueCenter | OpaqueFrame
  119. };
  120. Q_DECLARE_FLAGS(DrawingHints, DrawingHint)
  121. }
  122. #endif
  123. Q_WIDGETS_EXPORT void qDrawBorderPixmap(QPainter *painter,
  124. const QRect &targetRect,
  125. const QMargins &targetMargins,
  126. const QPixmap &pixmap,
  127. const QRect &sourceRect,
  128. const QMargins &sourceMargins,
  129. const QTileRules &rules = QTileRules()
  130. #ifndef Q_QDOC
  131. , QDrawBorderPixmap::DrawingHints hints = QDrawBorderPixmap::DrawingHints()
  132. #endif
  133. );
  134. inline void qDrawBorderPixmap(QPainter *painter,
  135. const QRect &target,
  136. const QMargins &margins,
  137. const QPixmap &pixmap)
  138. {
  139. qDrawBorderPixmap(painter, target, margins, pixmap, pixmap.rect(), margins);
  140. }
  141. QT_END_NAMESPACE
  142. #endif // QDRAWUTIL_H