QGtkStyle: use gtk_widget_get/set_allocation()

Do not access GtkWidget::allocation directly, it doesn't exist in GTK3.

Change-Id: I8ce69fab19ce8f3afe35d0d30d4e28b0348fdaf1
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
This commit is contained in:
J-P Nurmi 2012-10-08 15:59:09 +02:00 committed by The Qt Project
parent 3c05a0f3e7
commit e91b27b610
3 changed files with 39 additions and 17 deletions

View File

@ -1921,10 +1921,9 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
: QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkHBox.GtkVSeparator");
if (GtkWidget *gtkVSeparator = d->gtkWidget(vSeparatorPath)) {
QRect vLineRect(gtkVSeparator->allocation.x,
gtkVSeparator->allocation.y,
gtkVSeparator->allocation.width,
gtkVSeparator->allocation.height);
GtkAllocation allocation;
d->gtk_widget_get_allocation(gtkVSeparator, &allocation);
QRect vLineRect(allocation.x, allocation.y, allocation.width, allocation.height);
gtkCachedPainter.paintVline( gtkVSeparator, "vseparator",
vLineRect, state, gtkVSeparator->style,
@ -1976,8 +1975,9 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
d->gtk_widget_style_get(gtkCombo, "arrow-size", &minSize, NULL);
}
if (gtkArrow) {
arrowWidgetRect = QRect(gtkArrow->allocation.x, gtkArrow->allocation.y,
gtkArrow->allocation.width, gtkArrow->allocation.height);
GtkAllocation allocation;
d->gtk_widget_get_allocation(gtkArrow, &allocation);
arrowWidgetRect = QRect(allocation.x, allocation.y, allocation.width, allocation.height);
style = gtkArrow->style;
}
@ -2199,10 +2199,15 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
}
if (scrollBar->subControls & SC_ScrollBarAddLine) {
gtkVScrollBar->allocation.y = scrollBarAddLine.top();
gtkVScrollBar->allocation.height = scrollBarAddLine.height() - rect.height() + 6;
gtkHScrollBar->allocation.x = scrollBarAddLine.right();
gtkHScrollBar->allocation.width = scrollBarAddLine.width() - rect.width();
GtkAllocation vAllocation;
vAllocation.y = scrollBarAddLine.top();
vAllocation.height = scrollBarAddLine.height() - rect.height() + 6;
d->gtk_widget_set_allocation(gtkVScrollBar, &vAllocation);
GtkAllocation hAllocation;
hAllocation.x = scrollBarAddLine.right();
hAllocation.width = scrollBarAddLine.width() - rect.width();
d->gtk_widget_set_allocation(gtkHScrollBar, &hAllocation);
GtkShadowType shadow = GTK_SHADOW_OUT;
GtkStateType state = GTK_STATE_NORMAL;
@ -2226,10 +2231,15 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
}
if (scrollBar->subControls & SC_ScrollBarSubLine) {
gtkVScrollBar->allocation.y = 0;
gtkVScrollBar->allocation.height = scrollBarSubLine.height();
gtkHScrollBar->allocation.x = 0;
gtkHScrollBar->allocation.width = scrollBarSubLine.width();
GtkAllocation vAllocation;
vAllocation.y = 0;
vAllocation.height = scrollBarSubLine.height();
d->gtk_widget_set_allocation(gtkVScrollBar, &vAllocation);
GtkAllocation hAllocation;
hAllocation.x = 0;
hAllocation.width = scrollBarSubLine.width();
d->gtk_widget_set_allocation(gtkHScrollBar, &hAllocation);
GtkShadowType shadow = GTK_SHADOW_OUT;
GtkStateType state = GTK_STATE_NORMAL;
@ -3761,9 +3771,11 @@ QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComple
if (!arrowWidget)
return QWindowsStyle::subControlRect(control, option, subControl, widget);
QRect buttonRect(option->rect.left() + arrowWidget->allocation.x,
option->rect.top() + arrowWidget->allocation.y,
arrowWidget->allocation.width, arrowWidget->allocation.height);
GtkAllocation allocation;
d->gtk_widget_get_allocation(arrowWidget, &allocation);
QRect buttonRect(option->rect.left() + allocation.x,
option->rect.top() + allocation.y,
allocation.width, allocation.height);
switch (subControl) {

View File

@ -175,6 +175,9 @@ Ptr_gtk_widget_get_type QGtkStylePrivate::gtk_widget_get_type = 0;
Ptr_gtk_rc_get_style_by_paths QGtkStylePrivate::gtk_rc_get_style_by_paths = 0;
Ptr_gtk_check_version QGtkStylePrivate::gtk_check_version = 0;
Ptr_gtk_border_free QGtkStylePrivate::gtk_border_free = 0;
Ptr_gtk_widget_get_allocation QGtkStylePrivate::gtk_widget_get_allocation = 0;
Ptr_gtk_widget_set_allocation QGtkStylePrivate::gtk_widget_set_allocation = 0;
Ptr_pango_font_description_get_size QGtkStylePrivate::pango_font_description_get_size = 0;
Ptr_pango_font_description_get_weight QGtkStylePrivate::pango_font_description_get_weight = 0;
Ptr_pango_font_description_get_family QGtkStylePrivate::pango_font_description_get_family = 0;
@ -439,6 +442,9 @@ void QGtkStylePrivate::resolveGtk() const
gtk_rc_get_style_by_paths =(Ptr_gtk_rc_get_style_by_paths)libgtk.resolve("gtk_rc_get_style_by_paths");
gtk_check_version =(Ptr_gtk_check_version)libgtk.resolve("gtk_check_version");
gtk_border_free =(Ptr_gtk_border_free)libgtk.resolve("gtk_border_free");
gtk_widget_get_allocation = (Ptr_gtk_widget_get_allocation)libgtk.resolve("gtk_widget_get_allocation");
gtk_widget_set_allocation = (Ptr_gtk_widget_set_allocation)libgtk.resolve("gtk_widget_set_allocation");
pango_font_description_get_size = (Ptr_pango_font_description_get_size)libgtk.resolve("pango_font_description_get_size");
pango_font_description_get_weight = (Ptr_pango_font_description_get_weight)libgtk.resolve("pango_font_description_get_weight");
pango_font_description_get_family = (Ptr_pango_font_description_get_family)libgtk.resolve("pango_font_description_get_family");

View File

@ -238,6 +238,8 @@ typedef void (*Ptr_gtk_file_chooser_set_current_name) (GtkFileChooser *, const g
typedef gboolean (*Ptr_gtk_file_chooser_set_filename) (GtkFileChooser *chooser, const gchar *name);
typedef gint (*Ptr_gtk_dialog_run) (GtkDialog*);
typedef void (*Ptr_gtk_border_free)(GtkBorder *);
typedef void (*Ptr_gtk_widget_get_allocation) (GtkWidget*, GtkAllocation*);
typedef void (*Ptr_gtk_widget_set_allocation) (GtkWidget*, const GtkAllocation*);
typedef guchar* (*Ptr_gdk_pixbuf_get_pixels) (const GdkPixbuf *pixbuf);
typedef int (*Ptr_gdk_pixbuf_get_width) (const GdkPixbuf *pixbuf);
@ -439,6 +441,8 @@ public:
static Ptr_gtk_rc_get_style_by_paths gtk_rc_get_style_by_paths;
static Ptr_gtk_check_version gtk_check_version;
static Ptr_gtk_border_free gtk_border_free;
static Ptr_gtk_widget_get_allocation gtk_widget_get_allocation;
static Ptr_gtk_widget_set_allocation gtk_widget_set_allocation;
static Ptr_pango_font_description_get_size pango_font_description_get_size;
static Ptr_pango_font_description_get_weight pango_font_description_get_weight;