/* * Strategy to painting a Widget: * 1.) do not paint if there is no GtkWidget set * 2.) We assume that GTK_NO_WINDOW is set and that geometryChanged positioned * the widget correctly. ATM we do not honor the GraphicsContext translation. */ void Widget::paint(GraphicsContext* context, const IntRect&) { if (!gtkWidget()) return; GtkWidget* widget = gtkWidget(); ASSERT(GTK_WIDGET_NO_WINDOW(widget)); GdkEvent* event = gdk_event_new(GDK_EXPOSE); event->expose = *context->gdkExposeEvent(); event->expose.region = gtk_widget_region_intersect(widget, event->expose.region); /* * This will be unref'ed by gdk_event_free. */ g_object_ref(event->expose.window); /* * If we are going to paint do the translation and GtkAllocation manipulation. */ if (!gdk_region_empty(event->expose.region)) { gdk_region_get_clipbox(event->expose.region, &event->expose.area); gtk_widget_send_expose(widget, event); } gdk_event_free(event); }
// Get size of the arrow controls in a GtkSpinButton int QGtkStylePrivate::getSpinboxArrowSize() const { const int MIN_ARROW_WIDTH = 6; GtkWidget *spinButton = gtkWidget("GtkSpinButton"); GtkStyle *style = QGtkStylePrivate::gtk_widget_get_style(spinButton); gint size = pango_font_description_get_size (style->font_desc); gint arrow_size; arrow_size = qMax(PANGO_PIXELS (size), MIN_ARROW_WIDTH) + style->xthickness; arrow_size += arrow_size%2 + 1; return arrow_size; }
void QGtkStylePrivate::applyCustomPaletteHash() { QPalette menuPal = gtkWidgetPalette("GtkMenu"); GdkColor gdkBg = QGtkStylePrivate::gtk_widget_get_style(gtkWidget("GtkMenu"))->bg[GTK_STATE_NORMAL]; QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8); menuPal.setBrush(QPalette::Base, bgColor); menuPal.setBrush(QPalette::Window, bgColor); qApp->setPalette(menuPal, "QMenu"); QPalette toolbarPal = gtkWidgetPalette("GtkToolbar"); qApp->setPalette(toolbarPal, "QToolBar"); QPalette menuBarPal = gtkWidgetPalette("GtkMenuBar"); qApp->setPalette(menuBarPal, "QMenuBar"); }
void Widget::hide() { if (!gtkWidget()) return; gtk_widget_hide(gtkWidget()); }
void Widget::show() { if (!gtkWidget()) return; gtk_widget_show(gtkWidget()); }
void Widget::setFocus() { gtk_widget_grab_focus(gtkWidget() ? gtkWidget() : GTK_WIDGET(containingWindow())); }
/*! \internal * Returns the gtk Widget that should be used to determine text foreground and background colors. */ GtkWidget* QGtkStylePrivate::getTextColorWidget() const { return gtkWidget("GtkEntry"); }