static gboolean gtk_rotated_bin_draw (GtkWidget *widget, cairo_t *cr) { GtkRotatedBin *bin = GTK_ROTATED_BIN (widget); GdkWindow *window; gdouble s, c; gdouble w, h; window = gtk_widget_get_window (widget); if (gtk_cairo_should_draw_window (cr, window)) { cairo_surface_t *surface; GtkAllocation child_area; if (bin->child && gtk_widget_get_visible (bin->child)) { surface = gdk_offscreen_window_get_surface (bin->offscreen_window); gtk_widget_get_allocation (bin->child, &child_area); /* transform */ s = sin (bin->angle); c = cos (bin->angle); w = c * child_area.width + s * child_area.height; h = s * child_area.width + c * child_area.height; cairo_translate (cr, (w - child_area.width) / 2, (h - child_area.height) / 2); cairo_translate (cr, child_area.width / 2, child_area.height / 2); cairo_rotate (cr, bin->angle); cairo_translate (cr, -child_area.width / 2, -child_area.height / 2); /* clip */ cairo_rectangle (cr, 0, 0, gdk_window_get_width (bin->offscreen_window), gdk_window_get_height (bin->offscreen_window)); cairo_clip (cr); /* paint */ cairo_set_source_surface (cr, surface, 0, 0); cairo_paint (cr); } } if (gtk_cairo_should_draw_window (cr, bin->offscreen_window)) { gtk_render_background (gtk_widget_get_style_context (widget), cr, 0, 0, gdk_window_get_width (bin->offscreen_window), gdk_window_get_height (bin->offscreen_window)); if (bin->child) gtk_container_propagate_draw (GTK_CONTAINER (widget), bin->child, cr); } return FALSE; }
static void gdl_dock_tablabel_paint (GtkWidget *widget, cairo_t *cr) { GtkBin *bin; GtkAllocation widget_allocation; GdlDockTablabel *tablabel; gint border_width; cairo_rectangle_int_t rect; bin = GTK_BIN (widget); tablabel = GDL_DOCK_TABLABEL (widget); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); gtk_widget_get_allocation (widget, &widget_allocation); rect.x = widget_allocation.x + border_width; rect.y = widget_allocation.y + border_width; rect.width = tablabel->drag_handle_size * HANDLE_RATIO; rect.height = widget_allocation.height - 2*border_width; if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget))) { GtkStyleContext* context = gtk_widget_get_style_context (widget); gtk_style_context_set_state (context, tablabel->active ? 0 : GTK_STATE_FLAG_ACTIVE); gtk_render_handle (gtk_widget_get_style_context (widget), cr, rect.x, rect.y, rect.width, rect.height); }; }
static gboolean locate_pointer_draw (GtkWidget *widget, cairo_t *cr, gpointer user_data) { CsdLocatePointerData *data = (CsdLocatePointerData *) user_data; if (gtk_cairo_should_draw_window (cr, data->window)) locate_pointer_paint (data, cr, gtk_widget_is_composited (data->widget)); return TRUE; }
static gboolean gtk_revealer_real_draw (GtkWidget *widget, cairo_t *cr) { GtkRevealer *revealer = GTK_REVEALER (widget); GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer); if (gtk_cairo_should_draw_window (cr, priv->bin_window)) GTK_WIDGET_CLASS (gtk_revealer_parent_class)->draw (widget, cr); return TRUE; }
static gboolean gd_stack_draw (GtkWidget *widget, cairo_t *cr) { GdStack *stack = GD_STACK (widget); GdStackPrivate *priv = stack->priv; cairo_t *pattern_cr; if (priv->visible_child) { if (priv->transition_pos < 1.0) { if (priv->last_visible_surface == NULL && priv->last_visible_child != NULL) { gtk_widget_get_allocation (priv->last_visible_child->widget, &priv->last_visible_surface_allocation); priv->last_visible_surface = gdk_window_create_similar_surface (gtk_widget_get_window (widget), CAIRO_CONTENT_COLOR_ALPHA, priv->last_visible_surface_allocation.width, priv->last_visible_surface_allocation.height); pattern_cr = cairo_create (priv->last_visible_surface); /* We don't use propagate_draw here, because we don't want to apply the bin_window offset */ gtk_widget_draw (priv->last_visible_child->widget, pattern_cr); cairo_destroy (pattern_cr); } switch (priv->transition_type) { case GD_STACK_TRANSITION_TYPE_CROSSFADE: gd_stack_draw_crossfade (widget, cr); break; case GD_STACK_TRANSITION_TYPE_SLIDE_LEFT: case GD_STACK_TRANSITION_TYPE_SLIDE_RIGHT: gd_stack_draw_slide (widget, cr); break; default: g_assert_not_reached (); } } else if (gtk_cairo_should_draw_window (cr, priv->bin_window)) gtk_container_propagate_draw (GTK_CONTAINER (stack), priv->visible_child->widget, cr); } return TRUE; }
static gboolean preview_draw (GtkWidget *widget, cairo_t *cr, SoliPrintPreview *preview) { GdkWindow *bin_window; gint tile_width; gint page_num; gint n_pages; gint col; bin_window = gtk_layout_get_bin_window (preview->layout); if (!gtk_cairo_should_draw_window (cr, bin_window)) { return GDK_EVENT_STOP; } cairo_save (cr); gtk_cairo_transform_to_window (cr, widget, bin_window); get_tile_size (preview, &tile_width, NULL); n_pages = get_n_pages (preview); col = 0; page_num = get_first_page_displayed (preview); while (col < preview->n_columns && page_num < n_pages) { if (!gtk_print_operation_preview_is_selected (preview->gtk_preview, page_num)) { page_num++; continue; } draw_page (cr, col * tile_width, 0, page_num, preview); col++; page_num++; } cairo_restore (cr); return GDK_EVENT_STOP; }
static gboolean handle_real_draw (GtkWidget* base, cairo_t* cr) { Handle * self; gboolean result = FALSE; cairo_t* _tmp0_; GdkWindow* _tmp1_ = NULL; gboolean _tmp2_ = FALSE; self = (Handle*) base; g_return_val_if_fail (cr != NULL, FALSE); _tmp0_ = cr; _tmp1_ = gtk_widget_get_window ((GtkWidget*) self); _tmp2_ = gtk_cairo_should_draw_window (_tmp0_, _tmp1_); if (_tmp2_) { GtkStyleContext* _tmp3_ = NULL; GtkStyleContext* _tmp4_; GtkStyleContext* context; GtkAllocation allocation = {0}; GtkAllocation _tmp5_ = {0}; GtkStyleContext* _tmp6_; cairo_t* _tmp7_; GtkAllocation _tmp8_; gint _tmp9_; GtkAllocation _tmp10_; gint _tmp11_; GtkAllocation _tmp12_; gint _tmp13_; GtkAllocation _tmp14_; gint _tmp15_; _tmp3_ = gtk_widget_get_style_context ((GtkWidget*) self); _tmp4_ = _g_object_ref0 (_tmp3_); context = _tmp4_; gtk_widget_get_allocation ((GtkWidget*) self, &_tmp5_); allocation = _tmp5_; _tmp6_ = context; _tmp7_ = cr; _tmp8_ = allocation; _tmp9_ = _tmp8_.x; _tmp10_ = allocation; _tmp11_ = _tmp10_.y; _tmp12_ = allocation; _tmp13_ = _tmp12_.height; _tmp14_ = allocation; _tmp15_ = _tmp14_.width; gtk_render_handle (_tmp6_, _tmp7_, (gdouble) _tmp9_, (gdouble) (_tmp11_ + ((_tmp13_ - 40) / 2)), (gdouble) _tmp15_, 40.0); _g_object_unref0 (context); } result = FALSE; return result; }
static gboolean _gcr_display_view_draw (GtkWidget *widget, cairo_t *cr) { GdkWindow *window; gboolean handled; /* Have GtkTextView draw the text first. */ if (GTK_WIDGET_CLASS (_gcr_display_view_parent_class)->draw) handled = GTK_WIDGET_CLASS (_gcr_display_view_parent_class)->draw (widget, cr); window = gtk_text_view_get_window (GTK_TEXT_VIEW (widget), GTK_TEXT_WINDOW_TEXT); if (gtk_cairo_should_draw_window (cr, window)) paint_widget_icons (GCR_DISPLAY_VIEW (widget), cr); return handled; }
/* Returns %TRUE if @clip is set. @clip contains the area that should be drawn. */ static gboolean get_clip_rectangle (GtkSourceGutter *gutter, GtkSourceView *view, cairo_t *cr, GdkRectangle *clip) { GdkWindow *window = get_window (gutter); if (window == NULL || !gtk_cairo_should_draw_window (cr, window)) { return FALSE; } gtk_cairo_transform_to_window (cr, GTK_WIDGET (view), window); return gdk_cairo_get_clip_rectangle (cr, clip); }
static gboolean cb_treeview_draw (GtkWidget *widget, cairo_t *cr, StfDialogData *pagedata) { int ruler_x = pagedata->fixed.ruler_x; int height; GtkAllocation a; GdkWindow *bin_window; GdkRGBA ruler_color; GtkStyleContext *context; if (ruler_x < 0) return FALSE; bin_window = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget)); if (!gtk_cairo_should_draw_window (cr, bin_window)) return FALSE; gtk_widget_get_allocation (widget, &a); height = a.height; context = gtk_widget_get_style_context (GTK_WIDGET (pagedata->dialog)); gtk_style_context_save (context); gtk_style_context_add_region (context, "fixed-format-ruler", 0); gnm_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &ruler_color); gtk_style_context_restore (context); cairo_save (cr); cairo_rectangle (cr, ruler_x, 0, ruler_x + 1, height); cairo_clip (cr); gdk_cairo_set_source_rgba (cr, &ruler_color); cairo_move_to (cr, ruler_x, 0); cairo_line_to (cr, ruler_x, height); cairo_stroke (cr); cairo_restore (cr); return FALSE; }
static gboolean lyric_show_viewport_draw(GtkWidget *widget,cairo_t *cr) { LyricShowViewport *lsv; lsv = LYRIC_SHOW_VIEWPORT(widget); GtkStyleContext *context; GdkWindow *bin = gtk_viewport_get_bin_window(GTK_VIEWPORT(widget)); context = gtk_widget_get_style_context(widget); GTK_WIDGET_CLASS(lyric_show_viewport_parent_class)->draw(widget,cr); if(lsv->priv->is_pressed && gtk_cairo_should_draw_window(cr,bin)) { gint y0,y1; y0=y1 = gtk_widget_get_allocated_height(widget)/2.0;///lsv->priv->pos+lsv->priv->pressed_pos; gtk_render_line(context,cr,0,y0, gtk_widget_get_allocated_width(widget),y1); } return FALSE; }
static gboolean gd_notification_draw (GtkWidget *widget, cairo_t *cr) { GdNotification *notification = GD_NOTIFICATION (widget); GdNotificationPrivate *priv = notification->priv; GtkStyleContext *context; GdkRectangle rect; int inner_radius; if (gtk_cairo_should_draw_window (cr, priv->bin_window)) { gtk_widget_get_allocation (widget, &rect); context = gtk_widget_get_style_context(widget); inner_radius = 5; draw_shadow_box (cr, rect, SHADOW_OFFSET_X + inner_radius, SHADOW_OFFSET_X + inner_radius, SHADOW_OFFSET_Y + inner_radius, 0.8); gtk_style_context_save (context); gtk_render_background (context, cr, SHADOW_OFFSET_X, 0, gtk_widget_get_allocated_width (widget) - 2 *SHADOW_OFFSET_X, gtk_widget_get_allocated_height (widget) - SHADOW_OFFSET_Y); gtk_render_frame (context,cr, SHADOW_OFFSET_X, 0, gtk_widget_get_allocated_width (widget) - 2 *SHADOW_OFFSET_X, gtk_widget_get_allocated_height (widget) - SHADOW_OFFSET_Y); gtk_style_context_restore (context); if (GTK_WIDGET_CLASS (gd_notification_parent_class)->draw) GTK_WIDGET_CLASS (gd_notification_parent_class)->draw(widget, cr); } return FALSE; }
static gboolean layout_draw_handler (GtkWidget *widget, cairo_t *cr) { GtkLayout *layout = GTK_LAYOUT (widget); GdkWindow *bin_window = gtk_layout_get_bin_window (layout); GdkRectangle clip; gint i, j, x, y; gint imin, imax, jmin, jmax; if (!gtk_cairo_should_draw_window (cr, bin_window)) return FALSE; gdk_window_get_position (bin_window, &x, &y); cairo_translate (cr, x, y); gdk_cairo_get_clip_rectangle (cr, &clip); imin = (clip.x) / 10; imax = (clip.x + clip.width + 9) / 10; jmin = (clip.y) / 10; jmax = (clip.y + clip.height + 9) / 10; for (i = imin; i < imax; i++) for (j = jmin; j < jmax; j++) if ((i + j) % 2) cairo_rectangle (cr, 10 * i, 10 * j, 1 + i % 10, 1 + j % 10); cairo_fill (cr); return FALSE; }
static gboolean gtk_form_draw(GtkWidget *widget, cairo_t *cr) { GList *tmp_list = NULL; GtkForm *form = NULL; g_return_val_if_fail(GTK_IS_FORM(widget), FALSE); gtk_form_render_background(widget, cr); form = GTK_FORM(widget); for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next) { GtkFormChild * const formchild = tmp_list->data; if (!gtk_widget_get_has_window(formchild->widget) && gtk_cairo_should_draw_window(cr, formchild->window)) { /* To get gtk_widget_draw() to work, it is required to call * gtk_widget_size_allocate() in advance with a well-posed * allocation for a given child widget in order to set a * certain private GtkWidget variable, called * widget->priv->alloc_need, to the proper value; otherwise, * gtk_widget_draw() fails and the relevant scrollbar won't * appear on the screen. * * Calling gtk_form_position_child() like this is one of ways * to make sure of that. */ gtk_form_position_child(form, formchild, TRUE); gtk_form_render_background(formchild->widget, cr); } } return GTK_WIDGET_CLASS(gtk_form_parent_class)->draw(widget, cr); }
static gboolean on_view_draw (GtkSourceView *view, cairo_t *cr, GtkSourceGutter *gutter) { GdkWindow *window; GtkTextView *text_view; GArray *sizes; GdkRectangle clip; gint x, y; gint y1, y2; GArray *numbers; GArray *pixels; GArray *heights; GtkTextIter cur; gint cur_line; gint count; gint i; GList *item; GtkTextIter start; GtkTextIter end; GtkTextBuffer *buffer; GdkRectangle background_area; GdkRectangle cell_area; GtkTextIter selection_start; GtkTextIter selection_end; gboolean has_selection; gint idx; GtkStyleContext *style_context; GdkRGBA fg_color; window = gtk_source_gutter_get_window (gutter); if (window == NULL || !gtk_cairo_should_draw_window (cr, window)) { return FALSE; } gtk_cairo_transform_to_window (cr, GTK_WIDGET (view), window); text_view = GTK_TEXT_VIEW (view); if (!gdk_cairo_get_clip_rectangle (cr, &clip)) { return FALSE; } gutter->priv->is_drawing = TRUE; buffer = gtk_text_view_get_buffer (text_view); gdk_window_get_pointer (window, &x, &y, NULL); y1 = clip.y; y2 = y1 + clip.height; /* get the extents of the line printing */ gtk_text_view_window_to_buffer_coords (text_view, gutter->priv->window_type, 0, y1, NULL, &y1); gtk_text_view_window_to_buffer_coords (text_view, gutter->priv->window_type, 0, y2, NULL, &y2); numbers = g_array_new (FALSE, FALSE, sizeof (gint)); pixels = g_array_new (FALSE, FALSE, sizeof (gint)); heights = g_array_new (FALSE, FALSE, sizeof (gint)); sizes = g_array_new (FALSE, FALSE, sizeof (gint)); calculate_gutter_size (gutter, sizes); i = 0; x = 0; background_area.x = 0; background_area.height = get_lines (text_view, y1, y2, pixels, heights, numbers, &count, &start, &end); cell_area.x = gutter->priv->xpad; cell_area.height = background_area.height; gtk_text_view_buffer_to_window_coords (text_view, gutter->priv->window_type, 0, g_array_index (pixels, gint, 0), NULL, &background_area.y); cell_area.y = background_area.y; item = gutter->priv->renderers; idx = 0; style_context = gtk_widget_get_style_context (GTK_WIDGET (view)); gtk_style_context_get_color (style_context, gtk_widget_get_state (GTK_WIDGET (view)), &fg_color); gdk_cairo_set_source_rgba (cr, &fg_color); while (item) { Renderer *renderer = item->data; gint xpad; gint width; width = g_array_index (sizes, gint, idx++); if (gtk_source_gutter_renderer_get_visible (renderer->renderer)) { gtk_source_gutter_renderer_get_padding (renderer->renderer, &xpad, NULL); background_area.width = width; cell_area.width = width - 2 * xpad; cell_area.x = background_area.x + xpad; cairo_save (cr); gdk_cairo_rectangle (cr, &background_area); cairo_clip (cr); gtk_source_gutter_renderer_begin (renderer->renderer, cr, &background_area, &cell_area, &start, &end); cairo_restore (cr); background_area.x += background_area.width; } item = g_list_next (item); } gtk_text_buffer_get_iter_at_mark (buffer, &cur, gtk_text_buffer_get_insert (buffer)); cur_line = gtk_text_iter_get_line (&cur); gtk_text_buffer_get_selection_bounds (buffer, &selection_start, &selection_end); has_selection = !gtk_text_iter_equal (&selection_start, &selection_end); if (has_selection) { if (!gtk_text_iter_starts_line (&selection_start)) { gtk_text_iter_set_line_offset (&selection_start, 0); } if (!gtk_text_iter_ends_line (&selection_end)) { gtk_text_iter_forward_to_line_end (&selection_end); } } for (i = 0; i < count; ++i) { gint pos; gint line_to_paint; end = start; if (!gtk_text_iter_ends_line (&end)) { gtk_text_iter_forward_to_line_end (&end); } gtk_text_view_buffer_to_window_coords (text_view, gutter->priv->window_type, 0, g_array_index (pixels, gint, i), NULL, &pos); line_to_paint = g_array_index (numbers, gint, i); background_area.y = pos; background_area.height = g_array_index (heights, gint, i); background_area.x = 0; idx = 0; for (item = gutter->priv->renderers; item; item = g_list_next (item)) { Renderer *renderer; gint width; GtkSourceGutterRendererState state; gint xpad; gint ypad; renderer = item->data; width = g_array_index (sizes, gint, idx++); if (!gtk_source_gutter_renderer_get_visible (renderer->renderer)) { continue; } gtk_source_gutter_renderer_get_padding (renderer->renderer, &xpad, &ypad); background_area.width = width; cell_area.y = background_area.y + ypad; cell_area.height = background_area.height - 2 * ypad; cell_area.x = background_area.x + xpad; cell_area.width = background_area.width - 2 * xpad; state = GTK_SOURCE_GUTTER_RENDERER_STATE_NORMAL; if (line_to_paint == cur_line) { state |= GTK_SOURCE_GUTTER_RENDERER_STATE_CURSOR; } if (has_selection && gtk_text_iter_in_range (&start, &selection_start, &selection_end)) { state |= GTK_SOURCE_GUTTER_RENDERER_STATE_SELECTED; } if (renderer->prelit >= 0 && cell_area.y <= renderer->prelit && cell_area.y + cell_area.height >= renderer->prelit) { state |= GTK_SOURCE_GUTTER_RENDERER_STATE_PRELIT; } gtk_source_gutter_renderer_query_data (renderer->renderer, &start, &end, state); cairo_save (cr); gdk_cairo_rectangle (cr, &background_area); cairo_clip (cr); /* Call render with correct area */ gtk_source_gutter_renderer_draw (renderer->renderer, cr, &background_area, &cell_area, &start, &end, state); cairo_restore (cr); background_area.x += background_area.width; } gtk_text_iter_forward_line (&start); } for (item = gutter->priv->renderers; item; item = g_list_next (item)) { Renderer *renderer = item->data; if (gtk_source_gutter_renderer_get_visible (renderer->renderer)) { gtk_source_gutter_renderer_end (renderer->renderer); } } g_array_free (numbers, TRUE); g_array_free (pixels, TRUE); g_array_free (heights, TRUE); g_array_free (sizes, TRUE); gutter->priv->is_drawing = FALSE; return FALSE; }
static gboolean gtk_offscreen_box_draw (GtkWidget *widget, cairo_t *cr) { GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (widget); GdkWindow *window; window = gtk_widget_get_window (widget); if (gtk_cairo_should_draw_window (cr, window)) { cairo_surface_t *surface; GtkAllocation child_area; if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1)) { surface = gdk_offscreen_window_get_surface (offscreen_box->offscreen_window1); cairo_set_source_surface (cr, surface, 0, 0); cairo_paint (cr); gtk_widget_get_allocation (offscreen_box->child1, &child_area); cairo_translate (cr, 0, child_area.height); } if (offscreen_box->child2 && gtk_widget_get_visible (offscreen_box->child2)) { surface = gdk_offscreen_window_get_surface (offscreen_box->offscreen_window2); gtk_widget_get_allocation (offscreen_box->child2, &child_area); /* transform */ cairo_translate (cr, child_area.width / 2, child_area.height / 2); cairo_rotate (cr, offscreen_box->angle); cairo_translate (cr, -child_area.width / 2, -child_area.height / 2); /* paint */ cairo_set_source_surface (cr, surface, 0, 0); cairo_paint (cr); } } else if (gtk_cairo_should_draw_window (cr, offscreen_box->offscreen_window1)) { gtk_render_background (gtk_widget_get_style_context (widget), cr, 0, 0, gdk_window_get_width (offscreen_box->offscreen_window1), gdk_window_get_height (offscreen_box->offscreen_window1)); if (offscreen_box->child1) gtk_container_propagate_draw (GTK_CONTAINER (widget), offscreen_box->child1, cr); } else if (gtk_cairo_should_draw_window (cr, offscreen_box->offscreen_window2)) { gtk_render_background (gtk_widget_get_style_context (widget), cr, 0, 0, gdk_window_get_width (offscreen_box->offscreen_window2), gdk_window_get_height (offscreen_box->offscreen_window2)); if (offscreen_box->child2) gtk_container_propagate_draw (GTK_CONTAINER (widget), offscreen_box->child2, cr); } return FALSE; }
static gboolean widget_overlay_draw (GtkWidget *widget, cairo_t *cr) { WidgetOverlay *ovl = WIDGET_OVERLAY (widget); GdkWindow *window; GtkAllocation area; gtk_widget_get_allocation (widget, &area); window = gtk_widget_get_window (widget); if (gtk_cairo_should_draw_window (cr, window)) { GList *list; for (list = ovl->priv->children; list; list = list->next) { ChildData *cd = (ChildData*) list->data; if (gtk_widget_get_visible (cd->child)) { cairo_surface_t *surface; GtkAllocation child_area; double x, y; gtk_widget_get_allocation (cd->child, &child_area); child_area.width *= cd->scale; child_area.height *= cd->scale; switch (cd->halign) { case WIDGET_OVERLAY_ALIGN_FILL: case WIDGET_OVERLAY_ALIGN_START: x = 0; break; case WIDGET_OVERLAY_ALIGN_END: x = area.width - child_area.width; break; case WIDGET_OVERLAY_ALIGN_CENTER: x = (area.width - child_area.width) / 2.; break; } switch (cd->valign) { case WIDGET_OVERLAY_ALIGN_FILL: case WIDGET_OVERLAY_ALIGN_START: y = 0; break; case WIDGET_OVERLAY_ALIGN_END: y = area.height - child_area.height; break; case WIDGET_OVERLAY_ALIGN_CENTER: y = (area.height - child_area.height) / 2.; break; } surface = gdk_offscreen_window_get_surface (cd->offscreen_window); if (cd->scale == 1.) { cairo_set_source_surface (cr, surface, x, y); cairo_paint_with_alpha (cr, cd->alpha); } else { cairo_save (cr); cairo_scale (cr, cd->scale, cd->scale); cairo_set_source_surface (cr, surface, x/cd->scale, y/cd->scale); cairo_paint_with_alpha (cr, cd->alpha); cairo_restore (cr); } cd->x = x; cd->y = y; } if (list->next && ((ChildData*) list->next->data == ovl->priv->scale_child) && (ovl->priv->scale_child->alpha > 0.)) { cairo_set_source_rgba (cr, 0., 0., 0., .3); cairo_rectangle (cr, 0, 0, area.width, area.height); cairo_fill (cr); } } } else { GList *list; for (list = ovl->priv->children; list; list = list->next) { ChildData *cd = (ChildData*) list->data; if (gtk_cairo_should_draw_window (cr, cd->offscreen_window)) gtk_container_propagate_draw (GTK_CONTAINER (widget), cd->child, cr); } } return TRUE; }
static gboolean expose_event(GtkWidget* widget, GdkEventExpose* gdk_event, wxMiniFrame* win) #endif { #ifdef __WXGTK3__ if (!gtk_cairo_should_draw_window(cr, gtk_widget_get_window(widget))) return false; GtkStyleContext* sc = gtk_widget_get_style_context(widget); gtk_style_context_save(sc); gtk_style_context_add_class(sc, GTK_STYLE_CLASS_BUTTON); gtk_render_frame(sc, cr, 0, 0, win->m_width, win->m_height); gtk_style_context_restore(sc); wxGTKCairoDC dc(cr); #else if (gdk_event->count > 0 || gdk_event->window != gtk_widget_get_window(widget)) { return false; } gtk_paint_shadow (gtk_widget_get_style(widget), gtk_widget_get_window(widget), GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, NULL, NULL, // FIXME: No clipping? 0, 0, win->m_width, win->m_height); wxClientDC dc(win); wxDCImpl *impl = dc.GetImpl(); wxClientDCImpl *gtk_impl = wxDynamicCast( impl, wxClientDCImpl ); gtk_impl->m_gdkwindow = gtk_widget_get_window(widget); // Hack alert #endif int style = win->GetWindowStyle(); if (style & wxRESIZE_BORDER) { dc.SetBrush( *wxGREY_BRUSH ); dc.SetPen( *wxTRANSPARENT_PEN ); dc.DrawRectangle( win->m_width - 14, win->m_height-14, 14, 14 ); } if (win->m_miniTitle && !win->GetTitle().empty()) { dc.SetFont( *wxSMALL_FONT ); wxBrush brush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); dc.SetBrush( brush ); dc.SetPen( *wxTRANSPARENT_PEN ); dc.DrawRectangle( win->m_miniEdge-1, win->m_miniEdge-1, win->m_width - (2*(win->m_miniEdge-1)), 15 ); const wxColour textColor = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); dc.SetTextForeground(textColor); dc.DrawText( win->GetTitle(), 6, 4 ); if (style & wxCLOSE_BOX) { dc.SetTextBackground(textColor); dc.DrawBitmap( win->m_closeButton, win->m_width-18, 3, true ); } } return false; }
inf_text_gtk_viewport_scrollbar_expose_event_cb(GtkWidget* scrollbar, GdkEventExpose* event, gpointer user_data) #endif { InfTextGtkViewport* viewport; InfTextGtkViewportPrivate* priv; InfTextGtkViewportUser* viewport_user; GdkRectangle* rectangle; GdkColor* color; double h,s,v; double r,g,b; GSList* item; double line_width; #if GTK_CHECK_VERSION(2, 91, 0) GdkRectangle clip_area; #else cairo_t* cr; #endif viewport = INF_TEXT_GTK_VIEWPORT(user_data); priv = INF_TEXT_GTK_VIEWPORT_PRIVATE(viewport); /* Can this happen? */ #if GTK_CHECK_VERSION(2, 91, 0) if(!gtk_cairo_should_draw_window(cr, gtk_widget_get_window(scrollbar))) #elif GTK_CHECK_VERSION(2,14,0) if(event->window != gtk_widget_get_window(scrollbar)) #else if(event->window != GTK_WIDGET(scrollbar)->window) #endif return FALSE; if(priv->show_user_markers) { color = >k_widget_get_style(scrollbar)->bg[GTK_STATE_NORMAL]; h = color->red / 65535.0; s = color->green / 65535.0; v = color->blue / 65535.0; rgb_to_hsv(&h, &s, &v); s = MIN(MAX(s, 0.5), 0.8); v = MAX(v, 0.5); #if GTK_CHECK_VERSION(2, 91, 0) gtk_cairo_transform_to_window( cr, GTK_WIDGET(scrollbar), gtk_widget_get_window(scrollbar) ); gdk_cairo_get_clip_rectangle(cr, &clip_area); #else cr = gdk_cairo_create(event->window); #endif line_width = cairo_get_line_width(cr); for(item = priv->users; item != NULL; item = item->next) { viewport_user = (InfTextGtkViewportUser*)item->data; rectangle = &viewport_user->rectangle; #if GTK_CHECK_VERSION(2, 91, 0) if(gdk_rectangle_intersect(&clip_area, rectangle, NULL)) #elif GTK_CHECK_VERSION(2,90,5) if(cairo_region_contains_rectangle(event->region, rectangle) != CAIRO_REGION_OVERLAP_OUT) #else if(gdk_region_rect_in(event->region, rectangle) != GDK_OVERLAP_RECTANGLE_OUT) #endif { h = inf_text_user_get_hue(viewport_user->user); cairo_rectangle( cr, rectangle->x + line_width/2, rectangle->y + line_width/2, rectangle->width - line_width, rectangle->height - line_width ); r = h; g = s; b = v/2.0; hsv_to_rgb(&r, &g, &b); cairo_set_source_rgba(cr, r, g, b, 0.6); cairo_stroke_preserve(cr); r = h; g = s; b = v; hsv_to_rgb(&r, &g, &b); cairo_set_source_rgba(cr, r, g, b, 0.6); cairo_fill(cr); } } #if ! GTK_CHECK_VERSION(2, 91, 0) cairo_destroy(cr); #endif } return FALSE; }