static void cpaf_fixed_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkFixed *fixed; GtkFixedChild *child; GtkAllocation child_allocation; GtkRequisition child_requisition; GList *children; guint16 border_width; fixed = GTK_FIXED (widget); widget->allocation = *allocation; if (!GTK_WIDGET_NO_WINDOW (widget)) { if (GTK_WIDGET_REALIZED (widget)) gdk_window_move_resize (widget->window, allocation->x, allocation->y, allocation->width, allocation->height); } border_width = GTK_CONTAINER (fixed)->border_width; children = fixed->children; while (children) { child = children->data; children = children->next; if (GTK_WIDGET_VISIBLE (child->widget)) { gtk_widget_get_child_requisition (child->widget, &child_requisition); child_allocation.x = child->x + border_width; child_allocation.y = child->y + border_width; child_allocation.height = child->widget->allocation.height; child_allocation.width = child->widget->allocation.width; /* Ensure that the allocation is not smaller than the requisition (CHECKME:) */ if (child_allocation.height < child_requisition.height) child_allocation.height = child_requisition.height; if (child_allocation.width < child_requisition.width) child_allocation.width = child_requisition.width; if (GTK_WIDGET_NO_WINDOW (widget)) { child_allocation.x += widget->allocation.x; child_allocation.y += widget->allocation.y; } gtk_widget_size_allocate (child->widget, &child_allocation); } } }
static gint relay_popup_button_pressed (GtkWidget *widget, GdkEventButton *event, gpointer data) { GtkWidget *new_widget = NULL; if (event->button != 3) return FALSE; g_signal_stop_emission_by_name (widget, "button_press_event"); if (GTK_IS_CONTAINER(widget)) { do { GList *children; GList *child; children = gtk_container_get_children (GTK_CONTAINER (widget)); for (child = children, new_widget = NULL; child; child = child->next) { GtkWidget *cur; cur = (GtkWidget *)child->data; if(! GTK_WIDGET_NO_WINDOW(cur) ) continue; if(cur->allocation.x <= event->x && cur->allocation.y <= event->y && (cur->allocation.x + cur->allocation.width) > event->x && (cur->allocation.y + cur->allocation.height) > event->y && g_object_get_data (G_OBJECT(cur), "gnome_popup_menu_nowindow")) { new_widget = cur; break; } } if(new_widget) widget = new_widget; else break; } while(widget && GTK_IS_CONTAINER (widget) && GTK_WIDGET_NO_WINDOW(widget)); if(!widget || !g_object_get_data (G_OBJECT(widget), "gnome_popup_menu")) { return TRUE; } } else new_widget = widget; return real_popup_button_pressed (new_widget, event, data); }
static gint columns_expose(GtkWidget *widget, GdkEventExpose *event) { Columns *cols; ColumnsChild *child; GList *children; GdkEventExpose child_event; g_return_val_if_fail(widget != NULL, FALSE); g_return_val_if_fail(IS_COLUMNS(widget), FALSE); g_return_val_if_fail(event != NULL, FALSE); if (GTK_WIDGET_DRAWABLE(widget)) { cols = COLUMNS(widget); child_event = *event; for (children = cols->children; children && (child = children->data); children = children->next) { if (child->widget && GTK_WIDGET_DRAWABLE(child->widget) && GTK_WIDGET_NO_WINDOW(child->widget) && gtk_widget_intersect(child->widget, &event->area, &child_event.area)) gtk_widget_event(child->widget, (GdkEvent *)&child_event); } } return FALSE; }
static void gtk_pizza_adjust_allocations (GtkPizza *pizza, gint dx, gint dy) { GList *tmp_list; GtkPizzaAdjData data; data.dx = dx; data.dy = dy; tmp_list = pizza->children; while (tmp_list) { GtkPizzaChild *child = tmp_list->data; tmp_list = tmp_list->next; child->widget->allocation.x += dx; child->widget->allocation.y += dy; if (GTK_WIDGET_NO_WINDOW (child->widget) && GTK_IS_CONTAINER (child->widget)) { gtk_container_forall (GTK_CONTAINER (child->widget), gtk_pizza_adjust_allocations_recurse, &data); } } }
/* * 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); }
static gint awt_gtk_panel_expose (GtkWidget *widget, GdkEventExpose *event) { AWTGtkPanel *panel; GtkWidget *child; GdkEventExpose child_event; GList *children; g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (event != NULL, FALSE); if (GTK_WIDGET_DRAWABLE (widget)) { panel = AWT_GTK_PANEL (widget); child_event = *event; children = panel->children; while (children) { child = children->data; children = children->next; if (GTK_WIDGET_NO_WINDOW (child) && gtk_widget_intersect (child, &event->area, &child_event.area)) gtk_widget_event (child, (GdkEvent*) &child_event); } } return FALSE; }
/* From gtkcontainer.c */ void _container_propagate_expose (GtkContainer *container, GtkWidget *child, GdkEventExpose *event) { GdkEvent *child_event; g_return_if_fail (GTK_IS_CONTAINER (container)); g_return_if_fail (GTK_IS_WIDGET (child)); g_return_if_fail (event != NULL); g_assert (child->parent == GTK_WIDGET (container)); if (GTK_WIDGET_DRAWABLE (child) && GTK_WIDGET_NO_WINDOW (child) && (child->window == event->window)&& AWN_IS_CAIRO_MENU_ITEM(child)) { child_event = gdk_event_new (GDK_EXPOSE); child_event->expose = *event; g_object_ref (child_event->expose.window); child_event->expose.region = gtk_widget_region_intersect (child, event->region); if (!gdk_region_empty (child_event->expose.region)) { gdk_region_get_clipbox (child_event->expose.region, &child_event->expose.area); gtk_widget_send_expose (child, child_event); } gdk_event_free (child_event); } }
static gint panels_expose(GtkWidget *widget, GdkEventExpose *event) { Panels *panels; GtkWidget *child; GList *children; GdkEventExpose child_event; g_return_val_if_fail(widget != NULL, FALSE); g_return_val_if_fail(IS_PANELS(widget), FALSE); g_return_val_if_fail(event != NULL, FALSE); if (GTK_WIDGET_DRAWABLE(widget)) { panels = PANELS(widget); child_event = *event; for (children = panels->children; children && (child = children->data); children = children->next) { if (child && GTK_WIDGET_DRAWABLE(child) && GTK_WIDGET_NO_WINDOW(child) && gtk_widget_intersect(child, &event->area, &child_event.area)) gtk_widget_event(child, (GdkEvent *)&child_event); } } return FALSE; }
static void hippo_canvas_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { HippoCanvas *canvas = HIPPO_CANVAS(widget); /* assign widget->allocation and resize widget->window */ GTK_WIDGET_CLASS(hippo_canvas_parent_class)->size_allocate(widget, allocation); if (canvas->root != NULL) { int x, y; if (GTK_WIDGET_NO_WINDOW(widget)) { x = allocation->x; y = allocation->y; } else { x = 0; y = 0; } hippo_canvas_item_allocate(canvas->root, x, y, allocation->width, allocation->height); } }
static void gimp_container_grid_view_menu_position (GtkMenu *menu, gint *x, gint *y, gpointer data) { GimpContainerGridView *grid_view = GIMP_CONTAINER_GRID_VIEW (data); GtkWidget *widget; if (grid_view->selected_item) widget = GTK_WIDGET (grid_view->selected_item); else widget = GTK_WIDGET (grid_view->wrap_box); gdk_window_get_origin (widget->window, x, y); if (GTK_WIDGET_NO_WINDOW (widget)) { *x += widget->allocation.x; *y += widget->allocation.y; } if (grid_view->selected_item) { *x += widget->allocation.width / 2; *y += widget->allocation.height / 2; } else { *x += widget->style->xthickness; *y += widget->style->ythickness; } gimp_menu_position (menu, x, y); }
static void na_tray_manager_make_socket_transparent (GtkWidget *widget, gpointer user_data) { if (GTK_WIDGET_NO_WINDOW (widget)) return; gdk_window_set_back_pixmap (widget->window, NULL, TRUE); }
void aurora_get_parent_bg (const GtkWidget *widget, AuroraRGB *color) { GtkStateType state_type; const GtkWidget *parent; GdkColor *gcolor; gboolean stop; GtkShadowType shadow = GTK_SHADOW_NONE; if (widget == NULL) return; parent = widget->parent; stop = FALSE; while (parent && !stop) { stop = FALSE; stop |= !GTK_WIDGET_NO_WINDOW (parent); stop |= GTK_IS_NOTEBOOK (parent) && gtk_notebook_get_show_tabs (GTK_NOTEBOOK (parent)) && gtk_notebook_get_show_border (GTK_NOTEBOOK (parent)); if (GTK_IS_FRAME(parent)) { shadow = gtk_frame_get_shadow_type(GTK_FRAME(parent)); stop |= (shadow != GTK_SHADOW_NONE); } else if (GTK_IS_TOOLBAR (parent)) { gtk_widget_style_get (GTK_WIDGET (parent), "shadow-type", &shadow, NULL); stop |= (shadow != GTK_SHADOW_NONE); } if (!stop) parent = parent->parent; } if (parent == NULL) return; state_type = GTK_WIDGET_STATE (parent); gcolor = &parent->style->bg[state_type]; aurora_gdk_color_to_rgb (gcolor, &color->r, &color->g, &color->b); if (GTK_IS_FRAME (parent) && shadow != GTK_SHADOW_NONE) { if (shadow == (GTK_SHADOW_IN || GTK_SHADOW_ETCHED_IN)) aurora_shade (color, color, 0.97); else aurora_shade (color, color, 1.04); } }
static void egg_tray_manager_make_socket_transparent (GtkWidget *widget, gpointer user_data) { ENTER; if (GTK_WIDGET_NO_WINDOW (widget)) RET(); gdk_window_set_back_pixmap (widget->window, NULL, TRUE); RET(); }
static void menu_position_under_widget (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data) { GtkWidget *widget; GtkWidget *container; GtkRequisition req; GtkRequisition menu_req; GdkRectangle monitor; int monitor_num; GdkScreen *screen; widget = GTK_WIDGET (user_data); g_assert (GTK_IS_WIDGET (widget)); container = gtk_widget_get_ancestor (widget, GTK_TYPE_CONTAINER); g_assert (container != NULL); gtk_widget_size_request (widget, &req); gtk_widget_size_request (GTK_WIDGET (menu), &menu_req); screen = gtk_widget_get_screen (GTK_WIDGET (menu)); monitor_num = gdk_screen_get_monitor_at_window (screen, widget->window); if (monitor_num < 0) { monitor_num = 0; } gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); gdk_window_get_origin (widget->window, x, y); if (GTK_WIDGET_NO_WINDOW (widget)) { *x += widget->allocation.x; *y += widget->allocation.y; } if (gtk_widget_get_direction (container) == GTK_TEXT_DIR_LTR) { *x += widget->allocation.width - req.width; } else { *x += req.width - menu_req.width; } if ((*y + widget->allocation.height + menu_req.height) <= monitor.y + monitor.height) { *y += widget->allocation.height; } else if ((*y - menu_req.height) >= monitor.y) { *y -= menu_req.height; } else if (monitor.y + monitor.height - (*y + widget->allocation.height) > *y) { *y += widget->allocation.height; } else { *y -= menu_req.height; } *push_in = FALSE; }
void uim_cand_win_horizontal_gtk_layout_sub_window(UIMCandWinHorizontalGtk *horizontal_cwin) { UIMCandWinGtk *cwin; #if GTK_CHECK_VERSION(2, 90, 0) gint x, y, w, h, x2, y2, w2, h2, x3, y3; #else gint x, y, w, h, d, x2, y2, w2, h2, d2, x3, y3; #endif struct index_button *idxbutton; g_return_if_fail(UIM_IS_CAND_WIN_HORIZONTAL_GTK(horizontal_cwin)); cwin = UIM_CAND_WIN_GTK(horizontal_cwin); if (!cwin->sub_window.window) return; #if GTK_CHECK_VERSION(2, 90, 0) gdk_window_get_geometry(gtk_widget_get_window(GTK_WIDGET(cwin)), &x, &y, &w, &h); #else gdk_window_get_geometry(gtk_widget_get_window(GTK_WIDGET(cwin)), &x, &y, &w, &h, &d); #endif gdk_window_get_origin(gtk_widget_get_window(GTK_WIDGET(cwin)), &x, &y); #if GTK_CHECK_VERSION(2, 90, 0) gdk_window_get_geometry(gtk_widget_get_window(cwin->sub_window.window), &x2, &y2, &w2, &h2); #else gdk_window_get_geometry(gtk_widget_get_window(cwin->sub_window.window), &x2, &y2, &w2, &h2, &d2); #endif if (horizontal_cwin->selected) { GtkWidget *button; idxbutton = horizontal_cwin->selected; button = GTK_WIDGET(idxbutton->button); gdk_window_get_origin(gtk_widget_get_window(button), &x3, &y3); #if GTK_CHECK_VERSION(2, 18, 0) if (!gtk_widget_get_has_window(button)) { GtkAllocation allocation; gtk_widget_get_allocation(button, &allocation); x3 += allocation.x; } #else if (GTK_WIDGET_NO_WINDOW(button)) x3 += button->allocation.x; #endif } y = y + h; gtk_window_move(GTK_WINDOW(cwin->sub_window.window), x3, y); }
static void make_transparent (GtkWidget *widget, gpointer user_data) { #if GTK_CHECK_VERSION(2,19,3) if (GTK_WIDGET_NO_WINDOW (widget) || gtk_widget_get_app_paintable (widget)) #else if (GTK_WIDGET_NO_WINDOW (widget) || GTK_WIDGET_APP_PAINTABLE (widget)) #endif return; gtk_widget_set_app_paintable (widget, TRUE); gtk_widget_set_double_buffered (widget, FALSE); #if !GTK_CHECK_VERSION(2,91,0) gdk_window_set_back_pixmap (gtk_widget_get_window(widget), NULL, TRUE); g_signal_connect (widget, "expose_event", G_CALLBACK (transparent_expose_event), NULL); g_signal_connect_after (widget, "style_set", G_CALLBACK (make_transparent_again), NULL); #endif }
static void calc_menu_position(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, GtkWidget *button) { gint sc_height, sc_width, menu_width, menu_height, button_height; GtkRequisition requisition; g_return_if_fail(x && y); g_return_if_fail(GTK_IS_BUTTON(button)); gdk_window_get_origin(gtk_widget_get_window(button), x, y); #if GTK_CHECK_VERSION(2, 90, 0) button_height = gdk_window_get_height(gtk_widget_get_window(button)); #else gdk_drawable_get_size(gtk_widget_get_window(button), NULL, &button_height); #endif #if GTK_CHECK_VERSION(2, 18, 0) if (!gtk_widget_get_has_window(button)) { GtkAllocation allocation; gtk_widget_get_allocation(button, &allocation); *x += allocation.x; } #else if (GTK_WIDGET_NO_WINDOW(button)) *x += button->allocation.x; #endif sc_height = gdk_screen_get_height(gdk_screen_get_default()); sc_width = gdk_screen_get_width(gdk_screen_get_default()); #if GTK_CHECK_VERSION(3, 0, 0) gtk_widget_get_preferred_size(GTK_WIDGET(menu), &requisition, NULL); #else gtk_widget_size_request(GTK_WIDGET(menu), &requisition); #endif menu_width = requisition.width; menu_height = requisition.height; if (*y + button_height + menu_height < sc_height) *y = *y + button_height; else { if (*y + button_height < sc_height / 2) *y = *y + button_height; else *y = *y - menu_height; } if (*x + menu_width > sc_width) *x = sc_width - menu_width; }
void GtkPluginWidget::invalidateRect(const IntRect& _rect) { /* no need to */ if (GTK_WIDGET_NO_WINDOW(platformWidget())) return; GdkWindow* window = platformWidget()->window; if (!window) return; GdkRectangle rect = _rect; gdk_window_invalidate_rect(window, &rect, FALSE); }
static void tray_widget_make_transparent(GtkWidget *widget, gpointer user_data) { if (user_data){} if (GTK_WIDGET_NO_WINDOW(widget) || GTK_WIDGET_APP_PAINTABLE(widget)) return; gtk_widget_set_app_paintable(widget, TRUE); gtk_widget_set_double_buffered(widget, FALSE); gdk_window_set_back_pixmap(widget->window, NULL, TRUE); g_signal_connect(widget, "expose_event", G_CALLBACK(tray_widget_transparent_expose_event), NULL); g_signal_connect_after(widget, "style_set", G_CALLBACK(tray_widget_make_transparent_again), NULL); }
static void gtk_form_attach_child_window(GtkForm *form, GtkFormChild *child) { if (child->window != NULL) return; /* been there, done that */ if (GTK_WIDGET_NO_WINDOW(child->widget)) { GtkWidget *widget; GdkWindowAttr attributes; gint attributes_mask; widget = GTK_WIDGET(form); attributes.window_type = GDK_WINDOW_CHILD; attributes.x = child->x; attributes.y = child->y; attributes.width = child->widget->requisition.width; attributes.height = child->widget->requisition.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual(widget); attributes.colormap = gtk_widget_get_colormap(widget); attributes.event_mask = GDK_EXPOSURE_MASK; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; child->window = gdk_window_new(form->bin_window, &attributes, attributes_mask); gdk_window_set_user_data(child->window, widget); gtk_style_set_background(widget->style, child->window, GTK_STATE_NORMAL); gtk_widget_set_parent_window(child->widget, child->window); gtk_form_set_static_gravity(child->window, TRUE); /* * Install signal handlers to map/unmap child->window * alongside with the actual widget. */ gtk_signal_connect(GTK_OBJECT(child->widget), "map", GTK_SIGNAL_FUNC(>k_form_child_map), child); gtk_signal_connect(GTK_OBJECT(child->widget), "unmap", GTK_SIGNAL_FUNC(>k_form_child_unmap), child); } else if (!GTK_WIDGET_REALIZED(child->widget)) { gtk_widget_set_parent_window(child->widget, form->bin_window); } }
static void clearlooks_style_draw_layout (GtkStyle * style, GdkWindow * window, GtkStateType state_type, gboolean use_text, GdkRectangle * area, GtkWidget * widget, const gchar * detail, gint x, gint y, PangoLayout * layout) { (void) detail; GdkGC *gc; g_return_if_fail (GTK_IS_STYLE (style)); g_return_if_fail (window != NULL); gc = use_text ? style->text_gc[state_type] : style->fg_gc[state_type]; if (area) gdk_gc_set_clip_rectangle (gc, area); if (state_type == GTK_STATE_INSENSITIVE) { ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); ClearlooksColors *colors = &clearlooks_style->colors; WidgetParameters params; GdkColor etched; CairoColor temp; clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); if (GTK_WIDGET_NO_WINDOW (widget)) ge_shade_color (¶ms.parentbg, 1.2, &temp); else ge_shade_color (&colors->bg[widget->state], 1.2, &temp); etched.red = (int) (temp.r * 65535); etched.green = (int) (temp.g * 65535); etched.blue = (int) (temp.b * 65535); gdk_draw_layout_with_colors (window, gc, x + 1, y + 1, layout, &etched, NULL); gdk_draw_layout (window, gc, x, y, layout); } else gdk_draw_layout (window, gc, x, y, layout); if (area) gdk_gc_set_clip_rectangle (gc, NULL); }
void GtkPluginWidget::paint(GraphicsContext* context, const IntRect& rect) { if (!context->gdkExposeEvent()) return; /* only paint widgets with NO_WINDOW this way */ if (!GTK_WIDGET_NO_WINDOW(platformWidget())) return; GtkWidget* widget = platformWidget(); ASSERT(GTK_WIDGET_NO_WINDOW(widget)); GdkEvent* event = gdk_event_new(GDK_EXPOSE); event->expose = *context->gdkExposeEvent(); event->expose.area = static_cast<GdkRectangle>(rect); IntPoint loc = parent()->contentsToWindow(rect.location()); event->expose.area.x = loc.x(); event->expose.area.y = loc.y(); event->expose.region = gdk_region_rectangle(&event->expose.area); /* * 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)) gtk_widget_send_expose(widget, event); gdk_event_free(event); }
static void gtk_pizza_adjust_allocations_recurse (GtkWidget *widget, gpointer cb_data) { GtkPizzaAdjData *data = cb_data; widget->allocation.x += data->dx; widget->allocation.y += data->dy; if (GTK_WIDGET_NO_WINDOW (widget) && GTK_IS_CONTAINER (widget)) { gtk_container_forall (GTK_CONTAINER (widget), gtk_pizza_adjust_allocations_recurse, cb_data); } }
static gint gtk_form_expose(GtkWidget *widget, GdkEventExpose *event) { GList *tmp_list; GtkForm *form; g_return_val_if_fail(GTK_IS_FORM(widget), FALSE); form = GTK_FORM(widget); if (event->window == form->bin_window) return FALSE; for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next) { #ifdef HAVE_GTK2 GtkFormChild *formchild = tmp_list->data; GtkWidget *child = formchild->widget; /* * The following chunk of code is taken from gtkcontainer.c. The * gtk1.x code synthesized expose events directly on the child widgets, * which can't be done in gtk2 */ if (GTK_WIDGET_DRAWABLE(child) && GTK_WIDGET_NO_WINDOW(child) && child->window == event->window) { GdkEventExpose child_event; child_event = *event; child_event.region = gtk_widget_region_intersect(child, event->region); if (!gdk_region_empty(child_event.region)) { gdk_region_get_clipbox(child_event.region, &child_event.area); gtk_widget_send_expose(child, (GdkEvent *)&child_event); } } #else /* !HAVE_GTK2 */ GtkFormChild *child = tmp_list->data; if (event->window == child->window) return gtk_widget_event(child->widget, (GdkEvent *) event); #endif /* !HAVE_GTK2 */ } return FALSE; }
static void cl_get_window_style_state (GtkWidget *widget, GtkStyle **style, GtkStateType *state_type) { GtkStyle *windowstyle = NULL; GtkWidget *tmpwidget = widget; GtkStateType windowstate; if (widget && GTK_IS_ENTRY (widget)) tmpwidget = tmpwidget->parent; while (tmpwidget && GTK_WIDGET_NO_WINDOW (tmpwidget) && !GTK_IS_NOTEBOOK(tmpwidget)) { tmpwidget = tmpwidget->parent; } *style = tmpwidget->style; *state_type = GTK_WIDGET_STATE(tmpwidget); }
static void menu_position_under (GtkMenu *menu, int *x, int *y, gboolean *push_in, gpointer user_data) { GtkWidget *widget; g_return_if_fail (GTK_IS_BUTTON (user_data)); g_return_if_fail (GTK_WIDGET_NO_WINDOW (user_data)); widget = GTK_WIDGET (user_data); gdk_window_get_origin (widget->window, x, y); *x += widget->allocation.x; *y += widget->allocation.y + widget->allocation.height; *push_in = FALSE; }
static void menu_position_under(GtkMenu *menu, int *x, int *y, gboolean *push_in, gpointer user_data) { GtkWidget *widget; GtkAllocation allocation; g_return_if_fail(GTK_IS_BUTTON(user_data)); #if defined(HAVE_GTK_220) || defined(USE_GTK_3) g_return_if_fail(gtk_widget_get_window(user_data)); #else g_return_if_fail(GTK_WIDGET_NO_WINDOW(user_data)); #endif widget = GTK_WIDGET(user_data); gdk_window_get_origin(gtk_widget_get_window(widget), x, y); gtk_widget_get_allocation(widget, &allocation); *x += allocation.x; *y += allocation.y + allocation.height; *push_in = FALSE; }
gboolean set_gtk_widget_bg_image (GtkWidget *widget, const gchar *filename, guint bgcolor) { GdkPixbuf *pbuf, *bg; GdkPixmap *pixmap; gint width, height; if (GTK_WIDGET_NO_WINDOW(widget) || !GTK_WIDGET_REALIZED(widget) || !filename) goto fail; pbuf = gdk_pixbuf_new_from_file(filename, NULL); if (!pbuf) goto fail; width = gdk_pixbuf_get_width(pbuf); height = gdk_pixbuf_get_height(pbuf); bg = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, gdk_pixbuf_get_bits_per_sample(pbuf), width, height); gdk_pixbuf_fill(bg, bgcolor); gdk_pixbuf_composite(pbuf, bg, 0, 0, width, height, 0, 0, 1, 1, GDK_INTERP_BILINEAR,0xFF); pixmap = gdk_pixmap_new(widget->window, width, height, -1); gdk_draw_pixbuf(pixmap, NULL, bg, 0, 0, 0, 0, -1, -1, GDK_RGB_DITHER_NORMAL, 0, 0); g_object_unref(pbuf); g_object_unref(bg); gtk_widget_set_app_paintable(widget,TRUE); gdk_window_set_back_pixmap(widget->window, pixmap, FALSE); g_object_unref(pixmap); //gtk_widget_queue_draw(widget); return TRUE; fail: return FALSE; }
static gint gtk_pizza_expose (GtkWidget *widget, GdkEventExpose *event) { GtkPizza *pizza; GtkPizzaChild *child; GdkEventExpose child_event; GList *children; g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_PIZZA (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); pizza = GTK_PIZZA (widget); if (event->window != pizza->bin_window) return FALSE; /* We handle all expose events in window.cpp now. */ if (pizza->external_expose) return FALSE; children = pizza->children; while (children) { child = children->data; children = children->next; child_event = *event; if (GTK_WIDGET_NO_WINDOW (child->widget) && GTK_WIDGET_DRAWABLE (child->widget) && gtk_widget_intersect (child->widget, &event->area, &child_event.area)) { gtk_widget_event (child->widget, (GdkEvent*) &child_event); } } return TRUE; }
static gboolean gtk_check_item_expose (GtkWidget *widget, GdkEventExpose *event) { GtkCheckItem *check_item; GtkToggleButton *toggle_button; GtkBin *bin; GdkEventExpose child_event; g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_CHECK_ITEM (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); check_item = GTK_CHECK_ITEM (widget); toggle_button = GTK_TOGGLE_BUTTON (widget); bin = GTK_BIN (widget); if (GTK_WIDGET_DRAWABLE (widget)) { if (toggle_button->draw_indicator) { gtk_check_item_paint (widget, &event->area); child_event = *event; if (bin->child && GTK_WIDGET_NO_WINDOW (bin->child) && gtk_widget_intersect (bin->child, &event->area, &child_event.area)) gtk_widget_event (bin->child, (GdkEvent*) &child_event); } else { if (GTK_WIDGET_CLASS (parent_class)->expose_event) (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event); } } return FALSE; }