Qt 4.8
Public Functions | Static Public Functions | Private Functions | Properties | List of all members
QGtkPainter Class Reference

#include <qgtkpainter_p.h>

Public Functions

GtkStyle * getStyle (GtkWidget *gtkWidget)
 
GtkStateType gtkState (const QStyleOption *option)
 
void paintArrow (GtkWidget *gtkWidget, const gchar *part, const QRect &arrowrect, GtkArrowType arrow_type, GtkStateType state, GtkShadowType shadow, gboolean fill, GtkStyle *style, const QString &pmKey=QString())
 
void paintBox (GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &pmKey=QString())
 
void paintBoxGap (GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkPositionType gap_side, gint x, gint width, GtkStyle *style)
 
void paintCheckbox (GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail)
 
void paintExpander (GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkExpanderStyle expander_state, GtkStyle *style, const QString &pmKey=QString())
 
void paintExtention (GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkPositionType gap_pos, GtkStyle *style)
 
void paintFlatBox (GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &=QString())
 
void paintFocus (GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkStyle *style, const QString &pmKey=QString())
 
void paintHandle (GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkOrientation orientation, GtkStyle *style)
 
void paintHline (GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkStyle *style, int x1, int x2, int y, const QString &pmKey=QString())
 
void paintOption (GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail)
 
void paintResizeGrip (GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GdkWindowEdge edge, GtkStyle *style, const QString &pmKey=QString())
 
void paintShadow (GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &pmKey=QString())
 
void paintSlider (GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, GtkOrientation orientation, const QString &pmKey=QString())
 
void paintVline (GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkStyle *style, int y1, int y2, int x, const QString &pmKey=QString())
 
 QGtkPainter (QPainter *painter)
 
void setAlphaSupport (bool value)
 
void setClipRect (const QRect &rect)
 
void setFlipHorizontal (bool value)
 
void setFlipVertical (bool value)
 
void setUsePixmapCache (bool value)
 

Static Public Functions

static QPixmap getIcon (const char *iconName, GtkIconSize size=GTK_ICON_SIZE_BUTTON)
 

Private Functions

QPixmap renderTheme (uchar *bdata, uchar *wdata, const QRect &)
 

Properties

bool m_alpha
 
QRect m_cliprect
 
bool m_hflipped
 
QPainterm_painter
 
bool m_usePixmapCache
 
bool m_vflipped
 
GtkWidget * m_window
 

Detailed Description

Definition at line 67 of file qgtkpainter_p.h.

Constructors and Destructors

◆ QGtkPainter()

QGtkPainter::QGtkPainter ( QPainter painter)

Definition at line 145 of file qgtkpainter.cpp.

146  : m_window(QGtkStylePrivate::gtkWidget("GtkWindow"))
147  , m_painter(_painter)
148  , m_alpha(true)
149  , m_hflipped(false)
150  , m_vflipped(false)
151  , m_usePixmapCache(true)
152 {}
QPainter * m_painter
static GtkWidget * gtkWidget(const QHashableLatin1Literal &path)
bool m_usePixmapCache
GtkWidget * m_window

Functions

◆ getIcon()

QPixmap QGtkPainter::getIcon ( const char *  iconName,
GtkIconSize  size = GTK_ICON_SIZE_BUTTON 
)
static

Definition at line 191 of file qgtkpainter.cpp.

Referenced by setUsePixmapCache(), QGtkStyle::standardIconImplementation(), and QGtkStyle::standardPixmap().

192 {
193  GtkStyle *style = QGtkStylePrivate::gtkStyle();
194  GtkIconSet* iconSet = QGtkStylePrivate::gtk_icon_factory_lookup_default (iconName);
195  GdkPixbuf* icon = QGtkStylePrivate::gtk_icon_set_render_icon(iconSet,
196  style,
197  GTK_TEXT_DIR_LTR,
198  GTK_STATE_NORMAL,
199  size,
200  NULL,
201  "button");
203  int width = QGtkStylePrivate::gdk_pixbuf_get_width(icon);
204  int height = QGtkStylePrivate::gdk_pixbuf_get_height(icon);
205  QImage converted(width, height, QImage::Format_ARGB32);
206  uchar* tdata = (uchar*)converted.bits();
207 
208  for ( int index = 0 ; index < height * width*4 ; index +=4 ) {
209  //int index = y * rowstride + x;
210  tdata[index + QT_RED] = data[index + GTK_RED];
211  tdata[index + QT_GREEN] = data[index + GTK_GREEN];
212  tdata[index + QT_BLUE] = data[index + GTK_BLUE];
213  tdata[index + QT_ALPHA] = data[index + GTK_ALPHA];
214  }
215 
217 
218  // should we free iconset?
219  return QPixmap::fromImage(converted);
220 
221 }
#define GTK_GREEN
Definition: qgtkpainter.cpp:72
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition: qpixmap.cpp:2197
#define GTK_RED
Definition: qgtkpainter.cpp:71
#define QT_RED
Definition: qgtkpainter.cpp:61
static Ptr_gdk_pixbuf_get_width gdk_pixbuf_get_width
Definition: qgtkstyle_p.h:461
static Ptr_gdk_pixbuf_get_height gdk_pixbuf_get_height
Definition: qgtkstyle_p.h:462
unsigned char uchar
Definition: qglobal.h:994
static Ptr_gtk_icon_set_render_icon gtk_icon_set_render_icon
Definition: qgtkstyle_p.h:406
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
static const char * data(const QByteArray &arr)
static Ptr_gdk_pixbuf_get_pixels gdk_pixbuf_get_pixels
Definition: qgtkstyle_p.h:460
#define QT_GREEN
Definition: qgtkpainter.cpp:62
#define QT_BLUE
Definition: qgtkpainter.cpp:63
static Ptr_gtk_icon_factory_lookup_default gtk_icon_factory_lookup_default
Definition: qgtkstyle_p.h:403
#define GTK_ALPHA
Definition: qgtkpainter.cpp:74
static GtkStyle * gtkStyle(const QHashableLatin1Literal &path=QHashableLatin1Literal("GtkWindow"))
static Ptr_gdk_pixbuf_unref gdk_pixbuf_unref
Definition: qgtkstyle_p.h:467
quint16 index
#define QT_ALPHA
Definition: qgtkpainter.cpp:64
#define GTK_BLUE
Definition: qgtkpainter.cpp:73

◆ getStyle()

GtkStyle * QGtkPainter::getStyle ( GtkWidget *  gtkWidget)

Definition at line 182 of file qgtkpainter.cpp.

Referenced by QGtkStyle::drawComplexControl(), QGtkStyle::drawControl(), and QGtkStyle::drawPrimitive().

184 {
185  Q_ASSERT(gtkWidget);
186  GtkStyle* style = gtkWidget->style;
187  Q_ASSERT(style);
188  return style;
189 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ gtkState()

GtkStateType QGtkPainter::gtkState ( const QStyleOption option)

Definition at line 169 of file qgtkpainter.cpp.

Referenced by QGtkStyle::drawComplexControl(), QGtkStyle::drawControl(), and QGtkStyle::drawPrimitive().

171 {
172  GtkStateType state = GTK_STATE_NORMAL;
173  if (!(option->state & QStyle::State_Enabled))
174  state = GTK_STATE_INSENSITIVE;
175  else if (option->state & QStyle::State_MouseOver)
176  state = GTK_STATE_PRELIGHT;
177 
178  return state;
179 }
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88

◆ paintArrow()

void QGtkPainter::paintArrow ( GtkWidget *  gtkWidget,
const gchar *  part,
const QRect arrowrect,
GtkArrowType  arrow_type,
GtkStateType  state,
GtkShadowType  shadow,
gboolean  fill,
GtkStyle *  style,
const QString pmKey = QString() 
)

Definition at line 488 of file qgtkpainter.cpp.

Referenced by QGtkStyle::drawComplexControl(), QGtkStyle::drawControl(), QGtkStyle::drawPrimitive(), and setUsePixmapCache().

492 {
493  QRect rect = m_cliprect.isValid() ? m_cliprect : arrowrect;
494  if (!rect.isValid())
495  return;
496 
497  QPixmap cache;
498  QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size())
499  % HexString<uchar>(arrow_type)
500  % pmKey;
501 
502  GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
503  int xOffset = m_cliprect.isValid() ? arrowrect.x() - m_cliprect.x() : 0;
504  int yOffset = m_cliprect.isValid() ? arrowrect.y() - m_cliprect.y() : 0;
505  if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
506  DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_arrow (style, pixmap, state, shadow,
507  &gtkCliprect,
508  gtkWidget,
509  part,
510  arrow_type, fill,
511  xOffset, yOffset,
512  arrowrect.width(),
513  arrowrect.height()))
515  QPixmapCache::insert(pixmapName, cache);
516  }
517 
518  m_painter->drawPixmap(rect.topLeft(), cache);
519 }
static int pmKey(const QSize &size, QIcon::Mode mode, QIcon::State state)
QPainter * m_painter
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
#define DRAW_TO_CACHE(draw_func)
static Ptr_gtk_paint_arrow gtk_paint_arrow
Definition: qgtkstyle_p.h:420
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QPixmap * find(const QString &key)
static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget=0)
#define QLS(x)
Definition: qgtkstyle_p.h:77
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
QRect m_cliprect
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
bool m_usePixmapCache
if(void) toggleToolbarShown
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
The QPixmapCache class provides an application-wide cache for pixmaps.
Definition: qpixmapcache.h:57

◆ paintBox()

void QGtkPainter::paintBox ( GtkWidget *  gtkWidget,
const gchar *  part,
const QRect rect,
GtkStateType  state,
GtkShadowType  shadow,
GtkStyle *  style,
const QString pmKey = QString() 
)

Definition at line 291 of file qgtkpainter.cpp.

Referenced by QGtkStyle::drawComplexControl(), QGtkStyle::drawControl(), QGtkStyle::drawPrimitive(), and setUsePixmapCache().

295 {
296  if (!paintRect.isValid())
297  return;
298 
299  QPixmap cache;
300  QRect rect = paintRect;
301 
302  // To avoid exhausting cache on large tabframes we cheat a bit by
303  // tiling the center part.
304 
305  const int maxHeight = 256;
306  const int maxArea = 256*512;
307  const int border = 32;
308  if (rect.height() > maxHeight && (rect.width()*rect.height() > maxArea))
309  rect.setHeight(2 * border + 1);
310 
311  QString pixmapName = uniqueName(QLS(part), state, shadow,
312  rect.size(), gtkWidget) % pmKey;
313 
314  if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
316  pixmap,
317  state,
318  shadow,
319  NULL,
320  gtkWidget,
321  part,
322  0, 0,
323  rect.width(),
324  rect.height()));
325  if (m_usePixmapCache)
326  QPixmapCache::insert(pixmapName, cache);
327  }
328  if (rect.size() != paintRect.size()) {
329  // We assume we can stretch the middle tab part
330  // Note: the side effect of this is that pinstripe patterns will get fuzzy
331  const QSize size = cache.size();
332  // top part
333  m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top(),
334  paintRect.width(), border), cache,
335  QRect(0, 0, size.width(), border));
336 
337  // tiled center part
338  QPixmap tilePart(cache.width(), 1);
339  QPainter scanLinePainter(&tilePart);
340  scanLinePainter.drawPixmap(QRect(0, 0, tilePart.width(), tilePart.height()), cache, QRect(0, border, size.width(), 1));
341  scanLinePainter.end();
342  m_painter->drawTiledPixmap(QRect(paintRect.left(), paintRect.top() + border,
343  paintRect.width(), paintRect.height() - 2*border), tilePart);
344 
345  // bottom part
346  m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top() + paintRect.height() - border,
347  paintRect.width(), border), cache,
348  QRect(0, size.height() - border, size.width(), border));
349  } else
350  m_painter->drawPixmap(paintRect.topLeft(), cache);
351 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
QSize size() const
Returns the size of the pixmap.
Definition: qpixmap.cpp:661
QPainter * m_painter
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
#define DRAW_TO_CACHE(draw_func)
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QString class provides a Unicode character string.
Definition: qstring.h:83
static Ptr_gtk_paint_box gtk_paint_box
Definition: qgtkstyle_p.h:411
static QPixmap * find(const QString &key)
static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget=0)
int width() const
Returns the width.
Definition: qsize.h:126
#define QLS(x)
Definition: qgtkstyle_p.h:77
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
void drawTiledPixmap(const QRectF &rect, const QPixmap &pm, const QPointF &offset=QPointF())
Draws a tiled pixmap, inside the given rectangle with its origin at the given position.
Definition: qpainter.cpp:7146
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
int height() const
Returns the height.
Definition: qsize.h:129
bool m_usePixmapCache
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
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
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ paintBoxGap()

void QGtkPainter::paintBoxGap ( GtkWidget *  gtkWidget,
const gchar *  part,
const QRect rect,
GtkStateType  state,
GtkShadowType  shadow,
GtkPositionType  gap_side,
gint  x,
gint  width,
GtkStyle *  style 
)

Definition at line 224 of file qgtkpainter.cpp.

Referenced by QGtkStyle::drawPrimitive(), and setUsePixmapCache().

229 {
230  if (!paintRect.isValid())
231  return;
232 
233  QPixmap cache;
234  QRect rect = paintRect;
235 
236  // To avoid exhausting cache on large tabframes we cheat a bit by
237  // tiling the center part.
238 
239  const int maxHeight = 256;
240  const int border = 16;
241  if (rect.height() > maxHeight && (gap_side == GTK_POS_TOP || gap_side == GTK_POS_BOTTOM))
242  rect.setHeight(2 * border + 1);
243 
244  QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget)
245  % HexString<uchar>(gap_side)
246  % HexString<gint>(width)
247  % HexString<gint>(x);
248 
249  if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
251  pixmap,
252  state,
253  shadow,
254  NULL,
255  gtkWidget,
256  (gchar*)part,
257  0, 0,
258  rect.width(),
259  rect.height(),
260  gap_side,
261  x,
262  width));
263  if (m_usePixmapCache)
264  QPixmapCache::insert(pixmapName, cache);
265  }
266  if (rect.size() != paintRect.size()) {
267  // We assume we can stretch the middle tab part
268  // Note: the side effect of this is that pinstripe patterns will get fuzzy
269  const QSize size = cache.size();
270  // top part
271  m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top(),
272  paintRect.width(), border), cache,
273  QRect(0, 0, size.width(), border));
274 
275  // tiled center part
276  QPixmap tilePart(cache.width(), 1);
277  QPainter scanLinePainter(&tilePart);
278  scanLinePainter.drawPixmap(QRect(0, 0, tilePart.width(), tilePart.height()), cache, QRect(0, border, size.width(), 1));
279  scanLinePainter.end();
280  m_painter->drawTiledPixmap(QRect(paintRect.left(), paintRect.top() + border,
281  paintRect.width(), paintRect.height() - 2*border), tilePart);
282 
283  // bottom part
284  m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top() + paintRect.height() - border,
285  paintRect.width(), border), cache,
286  QRect(0, size.height() - border, size.width(), border));
287  } else
288  m_painter->drawPixmap(paintRect.topLeft(), cache);
289 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
QSize size() const
Returns the size of the pixmap.
Definition: qpixmap.cpp:661
QPainter * m_painter
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
#define DRAW_TO_CACHE(draw_func)
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QPixmap * find(const QString &key)
static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget=0)
int width() const
Returns the width.
Definition: qsize.h:126
#define QLS(x)
Definition: qgtkstyle_p.h:77
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
static Ptr_gtk_paint_box_gap gtk_paint_box_gap
Definition: qgtkstyle_p.h:412
void drawTiledPixmap(const QRectF &rect, const QPixmap &pm, const QPointF &offset=QPointF())
Draws a tiled pixmap, inside the given rectangle with its origin at the given position.
Definition: qpainter.cpp:7146
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
int height() const
Returns the height.
Definition: qsize.h:129
bool m_usePixmapCache
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
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
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ paintCheckbox()

void QGtkPainter::paintCheckbox ( GtkWidget *  gtkWidget,
const QRect rect,
GtkStateType  state,
GtkShadowType  shadow,
GtkStyle *  style,
const QString detail 
)

Definition at line 682 of file qgtkpainter.cpp.

Referenced by QGtkStyle::drawControl(), QGtkStyle::drawPrimitive(), and setUsePixmapCache().

686 {
687  QRect rect = m_cliprect.isValid() ? m_cliprect : checkrect;
688  if (!rect.isValid())
689  return;
690 
691  QPixmap cache;
692  QString pixmapName = uniqueName(detail, state, shadow, rect.size());
693  GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
694  int xOffset = m_cliprect.isValid() ? checkrect.x() - m_cliprect.x() : 0;
695  int yOffset = m_cliprect.isValid() ? checkrect.y() - m_cliprect.y() : 0;
696  if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
698  pixmap,
699  state,
700  shadow,
701  &gtkCliprect,
702  gtkWidget,
703  detail.toLatin1(),
704  xOffset, yOffset,
705  checkrect.width(),
706  checkrect.height()));
707  if (m_usePixmapCache)
708  QPixmapCache::insert(pixmapName, cache);
709  }
710 
711  m_painter->drawPixmap(rect.topLeft(), cache);
712 }
static Ptr_gtk_paint_check gtk_paint_check
Definition: qgtkstyle_p.h:410
QPainter * m_painter
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
#define DRAW_TO_CACHE(draw_func)
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QPixmap * find(const QString &key)
static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget=0)
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
QRect m_cliprect
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.
bool m_usePixmapCache
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
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
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ paintExpander()

void QGtkPainter::paintExpander ( GtkWidget *  gtkWidget,
const gchar *  part,
const QRect rect,
GtkStateType  state,
GtkExpanderStyle  expander_state,
GtkStyle *  style,
const QString pmKey = QString() 
)

Definition at line 413 of file qgtkpainter.cpp.

Referenced by QGtkStyle::drawPrimitive(), and setUsePixmapCache().

417 {
418  if (!rect.isValid())
419  return;
420 
421  QPixmap cache;
422  QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
423  % HexString<uchar>(expander_state)
424  % pmKey;
425 
426  if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
428  state, NULL,
429  gtkWidget, part,
430  rect.width()/2,
431  rect.height()/2,
432  expander_state));
433  if (m_usePixmapCache)
434  QPixmapCache::insert(pixmapName, cache);
435  }
436 
437  m_painter->drawPixmap(rect.topLeft(), cache);
438 }
static int pmKey(const QSize &size, QIcon::Mode mode, QIcon::State state)
QPainter * m_painter
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
#define DRAW_TO_CACHE(draw_func)
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QPixmap * find(const QString &key)
static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget=0)
static Ptr_gtk_paint_expander gtk_paint_expander
Definition: qgtkstyle_p.h:422
#define QLS(x)
Definition: qgtkstyle_p.h:77
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
bool m_usePixmapCache
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
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
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ paintExtention()

void QGtkPainter::paintExtention ( GtkWidget *  gtkWidget,
const gchar *  part,
const QRect rect,
GtkStateType  state,
GtkShadowType  shadow,
GtkPositionType  gap_pos,
GtkStyle *  style 
)

Definition at line 625 of file qgtkpainter.cpp.

Referenced by QGtkStyle::drawControl(), and setUsePixmapCache().

629 {
630  if (!rect.isValid())
631  return;
632 
633  QPixmap cache;
634  QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget)
635  % HexString<uchar>(gap_pos);
636 
637  if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
638  DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_extension (style, pixmap, state, shadow,
639  NULL, gtkWidget,
640  (gchar*)part, 0, 0,
641  rect.width(),
642  rect.height(),
643  gap_pos));
644  if (m_usePixmapCache)
645  QPixmapCache::insert(pixmapName, cache);
646  }
647 
648  m_painter->drawPixmap(rect.topLeft(), cache);
649 }
QPainter * m_painter
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
#define DRAW_TO_CACHE(draw_func)
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QPixmap * find(const QString &key)
static Ptr_gtk_paint_extension gtk_paint_extension
Definition: qgtkstyle_p.h:415
static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget=0)
#define QLS(x)
Definition: qgtkstyle_p.h:77
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
bool m_usePixmapCache
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
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
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ paintFlatBox()

void QGtkPainter::paintFlatBox ( GtkWidget *  gtkWidget,
const gchar *  part,
const QRect rect,
GtkStateType  state,
GtkShadowType  shadow,
GtkStyle *  style,
const QString pmKey = QString() 
)

Definition at line 600 of file qgtkpainter.cpp.

Referenced by QGtkStyle::drawComplexControl(), QGtkStyle::drawControl(), QGtkStyle::drawPrimitive(), and setUsePixmapCache().

604 {
605  if (!rect.isValid())
606  return;
607  QPixmap cache;
608  QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) % pmKey;
609  if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
611  pixmap,
612  state,
613  shadow,
614  NULL,
615  gtkWidget,
616  part, 0, 0,
617  rect.width(),
618  rect.height()));
619  if (m_usePixmapCache)
620  QPixmapCache::insert(pixmapName, cache);
621  }
622  m_painter->drawPixmap(rect.topLeft(), cache);
623 }
QPainter * m_painter
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
#define DRAW_TO_CACHE(draw_func)
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QPixmap * find(const QString &key)
static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget=0)
#define QLS(x)
Definition: qgtkstyle_p.h:77
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
static Ptr_gtk_paint_flat_box gtk_paint_flat_box
Definition: qgtkstyle_p.h:413
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
bool m_usePixmapCache
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
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
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ paintFocus()

void QGtkPainter::paintFocus ( GtkWidget *  gtkWidget,
const gchar *  part,
const QRect rect,
GtkStateType  state,
GtkStyle *  style,
const QString pmKey = QString() 
)

Definition at line 440 of file qgtkpainter.cpp.

Referenced by QGtkStyle::drawComplexControl(), QGtkStyle::drawControl(), QGtkStyle::drawPrimitive(), and setUsePixmapCache().

443 {
444  if (!rect.isValid())
445  return;
446 
447  QPixmap cache;
448  QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget) % pmKey;
449  if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
450  DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_focus (style, pixmap, state, NULL,
451  gtkWidget,
452  part,
453  0, 0,
454  rect.width(),
455  rect.height()));
456  if (m_usePixmapCache)
457  QPixmapCache::insert(pixmapName, cache);
458  }
459 
460  m_painter->drawPixmap(rect.topLeft(), cache);
461 }
QPainter * m_painter
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
#define DRAW_TO_CACHE(draw_func)
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QPixmap * find(const QString &key)
static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget=0)
#define QLS(x)
Definition: qgtkstyle_p.h:77
static Ptr_gtk_paint_focus gtk_paint_focus
Definition: qgtkstyle_p.h:419
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
bool m_usePixmapCache
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
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
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ paintHandle()

void QGtkPainter::paintHandle ( GtkWidget *  gtkWidget,
const gchar *  part,
const QRect rect,
GtkStateType  state,
GtkShadowType  shadow,
GtkOrientation  orientation,
GtkStyle *  style 
)

Definition at line 522 of file qgtkpainter.cpp.

Referenced by QGtkStyle::drawControl(), QGtkStyle::drawPrimitive(), and setUsePixmapCache().

525 {
526  if (!rect.isValid())
527  return;
528 
529  QPixmap cache;
530  QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size())
531  % HexString<uchar>(orientation);
532 
533  if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
535  pixmap,
536  state,
537  shadow,
538  NULL,
539  gtkWidget,
540  part, 0, 0,
541  rect.width(),
542  rect.height(),
543  orientation));
544  if (m_usePixmapCache)
545  QPixmapCache::insert(pixmapName, cache);
546  }
547  m_painter->drawPixmap(rect.topLeft(), cache);
548 }
QPainter * m_painter
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
#define DRAW_TO_CACHE(draw_func)
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QString class provides a Unicode character string.
Definition: qstring.h:83
static Ptr_gtk_paint_handle gtk_paint_handle
Definition: qgtkstyle_p.h:421
static QPixmap * find(const QString &key)
static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget=0)
#define QLS(x)
Definition: qgtkstyle_p.h:77
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
bool m_usePixmapCache
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
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
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ paintHline()

void QGtkPainter::paintHline ( GtkWidget *  gtkWidget,
const gchar *  part,
const QRect rect,
GtkStateType  state,
GtkStyle *  style,
int  x1,
int  x2,
int  y,
const QString pmKey = QString() 
)

Definition at line 353 of file qgtkpainter.cpp.

Referenced by QGtkStyle::drawControl(), QGtkStyle::drawPrimitive(), and setUsePixmapCache().

357 {
358  if (!rect.isValid())
359  return;
360 
361  QPixmap cache;
362  QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
363  % HexString<int>(x1)
364  % HexString<int>(x2)
365  % HexString<int>(y)
366  % pmKey;
367  if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
369  pixmap,
370  state,
371  NULL,
372  gtkWidget,
373  part,
374  x1, x2, y));
375  if (m_usePixmapCache)
376  QPixmapCache::insert(pixmapName, cache);
377  }
378 
379  m_painter->drawPixmap(rect.topLeft(), cache);
380 }
static int pmKey(const QSize &size, QIcon::Mode mode, QIcon::State state)
QPainter * m_painter
#define DRAW_TO_CACHE(draw_func)
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QPixmap * find(const QString &key)
static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget=0)
#define QLS(x)
Definition: qgtkstyle_p.h:77
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
static Ptr_gtk_paint_hline gtk_paint_hline
Definition: qgtkstyle_p.h:426
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
bool m_usePixmapCache
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
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
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ paintOption()

void QGtkPainter::paintOption ( GtkWidget *  gtkWidget,
const QRect rect,
GtkStateType  state,
GtkShadowType  shadow,
GtkStyle *  style,
const QString detail 
)

Definition at line 651 of file qgtkpainter.cpp.

Referenced by QGtkStyle::drawControl(), QGtkStyle::drawPrimitive(), and setUsePixmapCache().

655 {
656  QRect rect = m_cliprect.isValid() ? m_cliprect : radiorect;
657  if (!rect.isValid())
658  return;
659 
660  QPixmap cache;
661  QString pixmapName = uniqueName(detail, state, shadow, rect.size());
662  GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
663  int xOffset = m_cliprect.isValid() ? radiorect.x() - m_cliprect.x() : 0;
664  int yOffset = m_cliprect.isValid() ? radiorect.y() - m_cliprect.y() : 0;
665  if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
667  state, shadow,
668  &gtkCliprect,
669  gtkWidget,
670  detail.toLatin1(),
671  xOffset, yOffset,
672  radiorect.width(),
673  radiorect.height()));
674 
675  if (m_usePixmapCache)
676  QPixmapCache::insert(pixmapName, cache);
677  }
678 
679  m_painter->drawPixmap(rect.topLeft(), cache);
680 }
QPainter * m_painter
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
#define DRAW_TO_CACHE(draw_func)
static Ptr_gtk_paint_option gtk_paint_option
Definition: qgtkstyle_p.h:414
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QPixmap * find(const QString &key)
static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget=0)
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
QRect m_cliprect
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.
bool m_usePixmapCache
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
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
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ paintResizeGrip()

void QGtkPainter::paintResizeGrip ( GtkWidget *  gtkWidget,
const gchar *  part,
const QRect rect,
GtkStateType  state,
GtkShadowType  shadow,
GdkWindowEdge  edge,
GtkStyle *  style,
const QString pmKey = QString() 
)

Definition at line 464 of file qgtkpainter.cpp.

Referenced by QGtkStyle::drawControl(), and setUsePixmapCache().

468 {
469  if (!rect.isValid())
470  return;
471 
472  QPixmap cache;
473  QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) % pmKey;
474  if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
476  NULL, gtkWidget,
477  part, edge, 0, 0,
478  rect.width(),
479  rect.height()));
480  if (m_usePixmapCache)
481  QPixmapCache::insert(pixmapName, cache);
482  }
483 
484  m_painter->drawPixmap(rect.topLeft(), cache);
485 }
QPainter * m_painter
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
#define DRAW_TO_CACHE(draw_func)
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QPixmap * find(const QString &key)
static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget=0)
#define QLS(x)
Definition: qgtkstyle_p.h:77
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
static Ptr_gtk_paint_resize_grip gtk_paint_resize_grip
Definition: qgtkstyle_p.h:418
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
bool m_usePixmapCache
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
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
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ paintShadow()

void QGtkPainter::paintShadow ( GtkWidget *  gtkWidget,
const gchar *  part,
const QRect rect,
GtkStateType  state,
GtkShadowType  shadow,
GtkStyle *  style,
const QString pmKey = QString() 
)

Definition at line 580 of file qgtkpainter.cpp.

Referenced by QGtkStyle::drawComplexControl(), QGtkStyle::drawPrimitive(), and setUsePixmapCache().

585 {
586  if (!rect.isValid())
587  return;
588 
589  QPixmap cache;
590  QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) % pmKey;
591  if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
592  DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_shadow(style, pixmap, state, shadow, NULL,
593  gtkWidget, part, 0, 0, rect.width(), rect.height()));
594  if (m_usePixmapCache)
595  QPixmapCache::insert(pixmapName, cache);
596  }
597  m_painter->drawPixmap(rect.topLeft(), cache);
598 }
QPainter * m_painter
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
#define DRAW_TO_CACHE(draw_func)
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QPixmap * find(const QString &key)
static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget=0)
#define QLS(x)
Definition: qgtkstyle_p.h:77
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
static Ptr_gtk_paint_shadow gtk_paint_shadow
Definition: qgtkstyle_p.h:417
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
bool m_usePixmapCache
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
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
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ paintSlider()

void QGtkPainter::paintSlider ( GtkWidget *  gtkWidget,
const gchar *  part,
const QRect rect,
GtkStateType  state,
GtkShadowType  shadow,
GtkStyle *  style,
GtkOrientation  orientation,
const QString pmKey = QString() 
)

Definition at line 551 of file qgtkpainter.cpp.

Referenced by QGtkStyle::drawComplexControl(), and setUsePixmapCache().

555 {
556  if (!rect.isValid())
557  return;
558 
559  QPixmap cache;
560  QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) % pmKey;
561  if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
563  pixmap,
564  state,
565  shadow,
566  NULL,
567  gtkWidget,
568  part,
569  0, 0,
570  rect.width(),
571  rect.height(),
572  orientation));
573  if (m_usePixmapCache)
574  QPixmapCache::insert(pixmapName, cache);
575  }
576  m_painter->drawPixmap(rect.topLeft(), cache);
577 }
QPainter * m_painter
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
#define DRAW_TO_CACHE(draw_func)
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QPixmap * find(const QString &key)
static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget=0)
#define QLS(x)
Definition: qgtkstyle_p.h:77
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
bool m_usePixmapCache
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
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
static Ptr_gtk_paint_slider gtk_paint_slider
Definition: qgtkstyle_p.h:416
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ paintVline()

void QGtkPainter::paintVline ( GtkWidget *  gtkWidget,
const gchar *  part,
const QRect rect,
GtkStateType  state,
GtkStyle *  style,
int  y1,
int  y2,
int  x,
const QString pmKey = QString() 
)

Definition at line 382 of file qgtkpainter.cpp.

Referenced by QGtkStyle::drawComplexControl(), QGtkStyle::drawPrimitive(), and setUsePixmapCache().

386 {
387  if (!rect.isValid())
388  return;
389 
390  QPixmap cache;
391  QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
392  % HexString<int>(y1)
393  % HexString<int>(y2)
394  % HexString<int>(x)
395  % pmKey;
396 
397  if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
399  pixmap,
400  state,
401  NULL,
402  gtkWidget,
403  part,
404  y1, y2,
405  x));
406  if (m_usePixmapCache)
407  QPixmapCache::insert(pixmapName, cache);
408  }
409  m_painter->drawPixmap(rect.topLeft(), cache);
410 }
static int pmKey(const QSize &size, QIcon::Mode mode, QIcon::State state)
QPainter * m_painter
static Ptr_gtk_paint_vline gtk_paint_vline
Definition: qgtkstyle_p.h:425
#define DRAW_TO_CACHE(draw_func)
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QPixmap * find(const QString &key)
static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget=0)
#define QLS(x)
Definition: qgtkstyle_p.h:77
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
bool m_usePixmapCache
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
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
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ renderTheme()

QPixmap QGtkPainter::renderTheme ( uchar bdata,
uchar wdata,
const QRect rect 
)
private

Definition at line 79 of file qgtkpainter.cpp.

Referenced by setUsePixmapCache().

80 {
81  const int bytecount = rect.width() * rect.height() * 4;
82  for (int index = 0; index < bytecount ; index += 4) {
83  uchar val = bdata[index + GTK_BLUE];
84  if (m_alpha) {
85  int alphaval = qMax(bdata[index + GTK_BLUE] - wdata[index + GTK_BLUE],
86  bdata[index + GTK_GREEN] - wdata[index + GTK_GREEN]);
87  alphaval = qMax(alphaval, bdata[index + GTK_RED] - wdata[index + GTK_RED]) + 255;
88  bdata[index + QT_ALPHA] = alphaval;
89  }
90  bdata[index + QT_RED] = bdata[index + GTK_RED];
91  bdata[index + QT_GREEN] = bdata[index + GTK_GREEN];
92  bdata[index + QT_BLUE] = val;
93  }
94  QImage converted((const uchar*)bdata, rect.width(), rect.height(), m_alpha ?
96 
97  if (m_hflipped || m_vflipped) {
98  return QPixmap::fromImage(converted.mirrored(m_hflipped, m_vflipped));
99  } else {
100  // on raster graphicssystem we need to do a copy here, because
101  // we intend to deallocate the qimage bits shortly after...
102  return QPixmap::fromImage(converted.copy());
103  }
104 }
#define GTK_GREEN
Definition: qgtkpainter.cpp:72
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition: qpixmap.cpp:2197
#define GTK_RED
Definition: qgtkpainter.cpp:71
#define QT_RED
Definition: qgtkpainter.cpp:61
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
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
unsigned char uchar
Definition: qglobal.h:994
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
#define QT_GREEN
Definition: qgtkpainter.cpp:62
#define QT_BLUE
Definition: qgtkpainter.cpp:63
quint16 index
#define QT_ALPHA
Definition: qgtkpainter.cpp:64
#define GTK_BLUE
Definition: qgtkpainter.cpp:73

◆ setAlphaSupport()

void QGtkPainter::setAlphaSupport ( bool  value)
inline

Definition at line 75 of file qgtkpainter_p.h.

Referenced by QGtkStyle::drawPrimitive().

75 { m_alpha = value; }

◆ setClipRect()

void QGtkPainter::setClipRect ( const QRect rect)
inline

Definition at line 76 of file qgtkpainter_p.h.

Referenced by QGtkStyle::drawComplexControl(), QGtkStyle::drawControl(), and QGtkStyle::drawPrimitive().

76 { m_cliprect = rect; }
QRect m_cliprect

◆ setFlipHorizontal()

void QGtkPainter::setFlipHorizontal ( bool  value)
inline

Definition at line 77 of file qgtkpainter_p.h.

Referenced by QGtkStyle::drawControl().

77 { m_hflipped = value; }

◆ setFlipVertical()

void QGtkPainter::setFlipVertical ( bool  value)
inline

Definition at line 78 of file qgtkpainter_p.h.

78 { m_vflipped = value; }

◆ setUsePixmapCache()

void QGtkPainter::setUsePixmapCache ( bool  value)
inline

Definition at line 79 of file qgtkpainter_p.h.

Referenced by QGtkStyle::drawComplexControl(), and QGtkStyle::drawPrimitive().

79 { m_usePixmapCache = value; }
bool m_usePixmapCache

Properties

◆ m_alpha

bool QGtkPainter::m_alpha
private

Definition at line 117 of file qgtkpainter_p.h.

Referenced by renderTheme(), and setAlphaSupport().

◆ m_cliprect

QRect QGtkPainter::m_cliprect
private

Definition at line 121 of file qgtkpainter_p.h.

Referenced by paintArrow(), paintCheckbox(), paintOption(), and setClipRect().

◆ m_hflipped

bool QGtkPainter::m_hflipped
private

Definition at line 118 of file qgtkpainter_p.h.

Referenced by renderTheme(), and setFlipHorizontal().

◆ m_painter

QPainter* QGtkPainter::m_painter
private

◆ m_usePixmapCache

bool QGtkPainter::m_usePixmapCache
private

◆ m_vflipped

bool QGtkPainter::m_vflipped
private

Definition at line 119 of file qgtkpainter_p.h.

Referenced by renderTheme(), and setFlipVertical().

◆ m_window

GtkWidget* QGtkPainter::m_window
private

Definition at line 115 of file qgtkpainter_p.h.


The documentation for this class was generated from the following files: