44 #include <QtCore/qglobal.h> 45 #if !defined(QT_NO_STYLE_GTK) 50 #include <private/qstylehelper_p.h> 51 #include <QtGui/QWidget> 52 #include <QtGui/QStyleOption> 53 #include <QtGui/QPixmapCache> 57 #undef GTK_OBJECT_FLAGS 58 #define GTK_OBJECT_FLAGS(obj)(((GtkObject*)(obj))->flags) 60 #if Q_BYTE_ORDER == Q_BIG_ENDIAN 81 const int bytecount = rect.
width() * rect.
height() * 4;
107 #define DRAW_TO_CACHE(draw_func) \ 108 if (rect.width() > QWIDGETSIZE_MAX || rect.height() > QWIDGETSIZE_MAX) \ 110 QRect pixmapRect(0, 0, rect.width(), rect.height()); \ 112 GdkPixmap *pixmap = QGtkStylePrivate::gdk_pixmap_new((GdkDrawable*)(m_window->window), \ 113 rect.width(), rect.height(), -1); \ 116 style = QGtkStylePrivate::gtk_style_attach (style, m_window->window); \ 117 QGtkStylePrivate::gdk_draw_rectangle(pixmap, m_alpha ? style->black_gc : *style->bg_gc, true, \ 118 0, 0, rect.width(), rect.height()); \ 120 GdkPixbuf *imgb = QGtkStylePrivate::gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, rect.width(), rect.height());\ 123 imgb = QGtkStylePrivate::gdk_pixbuf_get_from_drawable(imgb, pixmap, NULL, 0, 0, 0, 0, \ 124 rect.width(), rect.height()); \ 125 uchar* bdata = (uchar*)QGtkStylePrivate::gdk_pixbuf_get_pixels(imgb); \ 127 QGtkStylePrivate::gdk_draw_rectangle(pixmap, style->white_gc, true, 0, 0, rect.width(), rect.height()); \ 129 GdkPixbuf *imgw = QGtkStylePrivate::gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, rect. \ 130 width(), rect.height()); \ 133 imgw = QGtkStylePrivate::gdk_pixbuf_get_from_drawable(imgw, pixmap, NULL, 0, 0, 0, 0, \ 134 rect.width(), rect.height()); \ 135 uchar* wdata = (uchar*)QGtkStylePrivate::gdk_pixbuf_get_pixels(imgw); \ 136 cache = renderTheme(bdata, wdata, rect); \ 137 QGtkStylePrivate::gdk_pixbuf_unref(imgw); \ 139 cache = renderTheme(bdata, 0, rect); \ 141 QGtkStylePrivate::gdk_drawable_unref(pixmap); \ 142 QGtkStylePrivate::gdk_pixbuf_unref(imgb); \ 172 GtkStateType state = GTK_STATE_NORMAL;
174 state = GTK_STATE_INSENSITIVE;
176 state = GTK_STATE_PRELIGHT;
186 GtkStyle* style = gtkWidget->style;
225 const QRect &paintRect, GtkStateType state,
226 GtkShadowType shadow, GtkPositionType gap_side,
234 QRect rect = paintRect;
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))
266 if (rect.
size() != paintRect.
size()) {
272 paintRect.
width(), border), cache,
277 QPainter scanLinePainter(&tilePart);
278 scanLinePainter.drawPixmap(
QRect(0, 0, tilePart.width(), tilePart.height()), cache,
QRect(0, border, size.
width(), 1));
279 scanLinePainter.end();
281 paintRect.
width(), paintRect.
height() - 2*border), tilePart);
285 paintRect.
width(), border), cache,
292 const QRect &paintRect, GtkStateType state,
293 GtkShadowType shadow, GtkStyle *style,
300 QRect rect = paintRect;
305 const int maxHeight = 256;
306 const int maxArea = 256*512;
307 const int border = 32;
312 rect.
size(), gtkWidget) % pmKey;
328 if (rect.
size() != paintRect.
size()) {
334 paintRect.
width(), border), cache,
339 QPainter scanLinePainter(&tilePart);
340 scanLinePainter.drawPixmap(
QRect(0, 0, tilePart.width(), tilePart.height()), cache,
QRect(0, border, size.
width(), 1));
341 scanLinePainter.end();
343 paintRect.
width(), paintRect.
height() - 2*border), tilePart);
347 paintRect.
width(), border), cache,
354 const QRect &rect, GtkStateType state,
355 GtkStyle *style,
int x1,
int x2,
int y,
383 const QRect &rect, GtkStateType state,
384 GtkStyle *style,
int y1,
int y2,
int x,
414 const gchar* part,
const QRect &rect,
415 GtkStateType state, GtkExpanderStyle expander_state,
441 const QRect &rect, GtkStateType state,
465 const QRect &rect, GtkStateType state,
466 GtkShadowType shadow, GdkWindowEdge edge,
489 const QRect &arrowrect, GtkArrowType arrow_type,
490 GtkStateType state, GtkShadowType shadow,
502 GdkRectangle gtkCliprect = {0, 0, rect.
width(), rect.
height()};
523 GtkStateType state, GtkShadowType shadow,
524 GtkOrientation orientation, GtkStyle *style)
552 GtkStateType state, GtkShadowType shadow,
553 GtkStyle *style, GtkOrientation orientation,
581 const QRect &rect, GtkStateType state,
582 GtkShadowType shadow, GtkStyle *style,
593 gtkWidget, part, 0, 0, rect.
width(), rect.
height()));
601 const QRect &rect, GtkStateType state,
602 GtkShadowType shadow, GtkStyle *style,
626 const gchar *part,
const QRect &rect,
627 GtkStateType state, GtkShadowType shadow,
628 GtkPositionType gap_pos, GtkStyle *style)
652 GtkStateType state, GtkShadowType shadow,
653 GtkStyle *style,
const QString &detail)
662 GdkRectangle gtkCliprect = {0, 0, rect.
width(), rect.
height()};
683 GtkStateType state, GtkShadowType shadow,
684 GtkStyle *style,
const QString &detail)
693 GdkRectangle gtkCliprect = {0, 0, rect.
width(), rect.
height()};
The QPainter class performs low-level painting on widgets and other paint devices.
static int pmKey(const QSize &size, QIcon::Mode mode, QIcon::State state)
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.
void setHeight(int h)
Sets the height of the rectangle to the given height.
#define QT_END_NAMESPACE
This macro expands to.
void paintOption(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail)
int width() const
Returns the width of the pixmap.
QPointer< QWidget > widget
QSize size() const
Returns the size of the pixmap.
void paintExpander(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkExpanderStyle expander_state, GtkStyle *style, const QString &pmKey=QString())
void paintFocus(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkStyle *style, const QString &pmKey=QString())
static Ptr_gtk_paint_check gtk_paint_check
QStyle::State state
the style flags that are used when drawing the control
void paintShadow(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, 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 paintFlatBox(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &=QString())
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())
static QPixmap getIcon(const char *iconName, GtkIconSize size=GTK_ICON_SIZE_BUTTON)
void paintResizeGrip(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GdkWindowEdge edge, GtkStyle *style, const QString &pmKey=QString())
static Ptr_gdk_pixbuf_get_width gdk_pixbuf_get_width
int left() const
Returns the x-coordinate of the rectangle's left edge.
static Ptr_gtk_paint_vline gtk_paint_vline
int width() const
Returns the width of the rectangle.
#define DRAW_TO_CACHE(draw_func)
static Ptr_gtk_paint_arrow gtk_paint_arrow
static Ptr_gtk_paint_option gtk_paint_option
int height() const
Returns the height of the rectangle.
The QString class provides a Unicode character string.
GtkStateType gtkState(const QStyleOption *option)
static Ptr_gtk_paint_box gtk_paint_box
static Ptr_gtk_paint_handle gtk_paint_handle
void paintSlider(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, GtkOrientation orientation, 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 paintExtention(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkPositionType gap_pos, GtkStyle *style)
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
static QPixmap * find(const QString &key)
static Ptr_gtk_paint_extension gtk_paint_extension
static Ptr_gdk_pixbuf_get_height gdk_pixbuf_get_height
static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget=0)
int width() const
Returns the width.
static Ptr_gtk_paint_expander gtk_paint_expander
#define QT_BEGIN_NAMESPACE
This macro expands to.
static Ptr_gtk_icon_set_render_icon gtk_icon_set_render_icon
The QStyleOption class stores the parameters used by QStyle functions.
static Ptr_gtk_paint_focus gtk_paint_focus
void paintCheckbox(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail)
QSize size() const
Returns the size of the rectangle.
The QImage class provides a hardware-independent image representation that allows direct access to th...
static const char * data(const QByteArray &arr)
static Ptr_gdk_pixbuf_get_pixels gdk_pixbuf_get_pixels
static Ptr_gtk_paint_shadow gtk_paint_shadow
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
GtkStyle * getStyle(GtkWidget *gtkWidget)
QPixmap renderTheme(uchar *bdata, uchar *wdata, const QRect &)
static Ptr_gtk_paint_flat_box gtk_paint_flat_box
static Ptr_gtk_paint_box_gap gtk_paint_box_gap
static Ptr_gtk_paint_hline gtk_paint_hline
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.
static Ptr_gtk_icon_factory_lookup_default gtk_icon_factory_lookup_default
static Ptr_gtk_paint_resize_grip gtk_paint_resize_grip
uchar * bits()
Returns a pointer to the first pixel data.
int top() const
Returns the y-coordinate of the rectangle's top edge.
void paintHline(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkStyle *style, int x1, int x2, int y, const QString &pmKey=QString())
int y() const
Returns the y-coordinate of the rectangle's top edge.
int x() const
Returns the x-coordinate of the rectangle's left edge.
static GtkStyle * gtkStyle(const QHashableLatin1Literal &path=QHashableLatin1Literal("GtkWindow"))
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.
The QRect class defines a rectangle in the plane using integer precision.
QGtkPainter(QPainter *painter)
static Ptr_gdk_pixbuf_unref gdk_pixbuf_unref
The QPixmap class is an off-screen image representation that can be used as a paint device...
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...
The QSize class defines the size of a two-dimensional object using integer point precision.
static Ptr_gtk_paint_slider gtk_paint_slider
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
void paintVline(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkStyle *style, int y1, int y2, int x, const QString &pmKey=QString())
QPoint topLeft() const
Returns the position of the rectangle's top-left corner.
void paintBoxGap(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkPositionType gap_side, gint x, gint width, GtkStyle *style)