void panel_frame_draw (GtkWidget *widget, #if GTK_CHECK_VERSION (3, 0, 0) cairo_t *cr, #endif PanelFrameEdge edges) { PanelFrame *frame = (PanelFrame *) widget; #if GTK_CHECK_VERSION (3, 0, 0) GtkStyleContext *context; GtkStateFlags state; GdkRGBA *bg; GdkRGBA dark, light; GtkBorder padding; #else GdkWindow *window; GtkStyle *style; GtkStateType state; GtkAllocation allocation; GdkGC *dark, *light, *black; int xthickness, ythickness; #endif int x, y, width, height; if (edges == PANEL_EDGE_NONE) return; #if GTK_CHECK_VERSION (3, 0, 0) context = gtk_widget_get_style_context (widget); state = gtk_widget_get_state_flags (widget); width = gtk_widget_get_allocated_width (widget); height = gtk_widget_get_allocated_height (widget); gtk_style_context_get (context, state, "background-color", &bg, NULL); gtk_style_shade (bg, &dark, 0.7); gtk_style_shade (bg, &light, 1.3); gtk_style_context_get_padding (context, state, &padding); #else window = gtk_widget_get_window (widget); style = gtk_widget_get_style (widget); state = gtk_widget_get_state (widget); gtk_widget_get_allocation (widget, &allocation); x = allocation.x; y = allocation.y; width = allocation.width; height = allocation.height; dark = style->dark_gc [state]; light = style->light_gc [state]; black = style->black_gc; xthickness = style->xthickness; ythickness = style->ythickness; #endif /* Copied from gtk_default_draw_shadow() */ x = y = 0; #if GTK_CHECK_VERSION (3, 0, 0) cairo_set_line_width (cr, 1); if (frame->edges & PANEL_EDGE_BOTTOM && padding.bottom > 0) { if (padding.bottom > 1) { gdk_cairo_set_source_rgba (cr, &dark); cairo_move_to (cr, x + .5, y + height - 2 + .5); cairo_line_to (cr, x + width - 1 - .5, y + height - 2 + .5); cairo_stroke (cr); cairo_set_source_rgb (cr, 0., 0., 0.); cairo_move_to (cr, x + .5, y + height - 1 - .5); cairo_line_to (cr, x + width - 1 - .5, y + height - 1 - .5); cairo_stroke (cr); } else { gdk_cairo_set_source_rgba (cr, &dark); cairo_move_to (cr, x + .5, y + height - 1 - .5); cairo_line_to (cr, x + width - 1 - .5, y + height - 1 - .5); cairo_stroke (cr); } } if (frame->edges & PANEL_EDGE_RIGHT && padding.right > 0) { if (padding.right > 1) { gdk_cairo_set_source_rgba (cr, &dark); cairo_move_to (cr, x + width - 2 - .5, y + .5); cairo_line_to (cr, x + width - 2 - .5, y + height - 1 - .5); cairo_stroke (cr); cairo_set_source_rgb (cr, 0., 0., 0.); cairo_move_to (cr, x + width - 1 - .5, y + .5); cairo_line_to (cr, x + width - 1 - .5, y + height - 1 - .5); cairo_stroke (cr); } else { gdk_cairo_set_source_rgba (cr, &dark); cairo_move_to (cr, x + width - 1 - .5, y + .5); cairo_line_to (cr, x + width - 1 - .5, y + height - 1 - .5); cairo_stroke (cr); } } if (frame->edges & PANEL_EDGE_TOP && padding.top > 0) { gdk_cairo_set_source_rgba (cr, &light); cairo_move_to (cr, x + .5, y + .5); cairo_line_to (cr, x + width - 1 - .5, y + .5); cairo_stroke (cr); if (padding.top > 1) { gdk_cairo_set_source_rgba (cr, bg); cairo_move_to (cr, x + .5, y + 1 + .5); cairo_line_to (cr, x + width - 1 - .5, y + 1 + .5); cairo_stroke (cr); } } if (frame->edges & PANEL_EDGE_LEFT && padding.left > 0) { gdk_cairo_set_source_rgba (cr, &light); cairo_move_to (cr, x + .5, y + .5); cairo_line_to (cr, x + .5, y + height - 1 - .5); cairo_stroke (cr); if (padding.left > 1) { gdk_cairo_set_source_rgba (cr, bg); cairo_move_to (cr, x + 1 + .5, y + .5); cairo_line_to (cr, x + 1 + .5, y + height - 1 - .5); cairo_stroke (cr); } } #else if (frame->edges & PANEL_EDGE_BOTTOM && ythickness > 0) { if (ythickness > 1) { gdk_draw_line (window, dark, x, y + height - 2, x + width - 1, y + height - 2); gdk_draw_line (window, black, x, y + height - 1, x + width - 1, y + height - 1); } else gdk_draw_line (window, dark, x, y + height - 1, x + width - 1, y + height - 1); } if (frame->edges & PANEL_EDGE_RIGHT && xthickness > 0) { if (xthickness > 1) { gdk_draw_line (window, dark, x + width - 2, y, x + width - 2, y + height - 1); gdk_draw_line (window, black, x + width - 1, y, x + width - 1, y + height - 1); } else gdk_draw_line (window, dark, x + width - 1, y, x + width - 1, y + height - 1); } if (frame->edges & PANEL_EDGE_TOP && ythickness > 0) { gdk_draw_line (window, light, x, y, x + width - 1, y); if (ythickness > 1) gdk_draw_line (window, style->bg_gc [state], x, y + 1, x + width - 1, y + 1); } if (frame->edges & PANEL_EDGE_LEFT && xthickness > 0) { gdk_draw_line (window, light, x, y, x, y + height - 1); if (xthickness > 1) gdk_draw_line (window, style->bg_gc [state], x + 1, y, x + 1, y + height - 1); } #endif }
void panel_frame_draw (GtkWidget *widget, cairo_t *cr, PanelFrameEdge edges) { PanelFrame *frame = (PanelFrame *) widget; GtkStyleContext *context; GtkStateFlags state; GdkRGBA *bg; GdkRGBA dark, light; GtkBorder padding; int x, y, width, height; if (edges == PANEL_EDGE_NONE) return; context = gtk_widget_get_style_context (widget); state = gtk_widget_get_state_flags (widget); width = gtk_widget_get_allocated_width (widget); height = gtk_widget_get_allocated_height (widget); gtk_style_context_get (context, state, "background-color", &bg, NULL); gtk_style_shade (bg, &dark, 0.7); gtk_style_shade (bg, &light, 1.3); gtk_style_context_get_padding (context, state, &padding); /* Copied from gtk_default_draw_shadow() */ x = y = 0; cairo_set_line_width (cr, 1); if (frame->edges & PANEL_EDGE_BOTTOM && padding.bottom > 0) { if (padding.bottom > 1) { gdk_cairo_set_source_rgba (cr, &dark); cairo_move_to (cr, x + .5, y + height - 2 + .5); cairo_line_to (cr, x + width - 1 - .5, y + height - 2 + .5); cairo_stroke (cr); cairo_set_source_rgb (cr, 0., 0., 0.); cairo_move_to (cr, x + .5, y + height - 1 - .5); cairo_line_to (cr, x + width - 1 - .5, y + height - 1 - .5); cairo_stroke (cr); } else { gdk_cairo_set_source_rgba (cr, &dark); cairo_move_to (cr, x + .5, y + height - 1 - .5); cairo_line_to (cr, x + width - 1 - .5, y + height - 1 - .5); cairo_stroke (cr); } } if (frame->edges & PANEL_EDGE_RIGHT && padding.right > 0) { if (padding.right > 1) { gdk_cairo_set_source_rgba (cr, &dark); cairo_move_to (cr, x + width - 2 - .5, y + .5); cairo_line_to (cr, x + width - 2 - .5, y + height - 1 - .5); cairo_stroke (cr); cairo_set_source_rgb (cr, 0., 0., 0.); cairo_move_to (cr, x + width - 1 - .5, y + .5); cairo_line_to (cr, x + width - 1 - .5, y + height - 1 - .5); cairo_stroke (cr); } else { gdk_cairo_set_source_rgba (cr, &dark); cairo_move_to (cr, x + width - 1 - .5, y + .5); cairo_line_to (cr, x + width - 1 - .5, y + height - 1 - .5); cairo_stroke (cr); } } if (frame->edges & PANEL_EDGE_TOP && padding.top > 0) { gdk_cairo_set_source_rgba (cr, &light); cairo_move_to (cr, x + .5, y + .5); cairo_line_to (cr, x + width - 1 - .5, y + .5); cairo_stroke (cr); if (padding.top > 1) { gdk_cairo_set_source_rgba (cr, bg); cairo_move_to (cr, x + .5, y + 1 + .5); cairo_line_to (cr, x + width - 1 - .5, y + 1 + .5); cairo_stroke (cr); } } if (frame->edges & PANEL_EDGE_LEFT && padding.left > 0) { gdk_cairo_set_source_rgba (cr, &light); cairo_move_to (cr, x + .5, y + .5); cairo_line_to (cr, x + .5, y + height - 1 - .5); cairo_stroke (cr); if (padding.left > 1) { gdk_cairo_set_source_rgba (cr, bg); cairo_move_to (cr, x + 1 + .5, y + .5); cairo_line_to (cr, x + 1 + .5, y + height - 1 - .5); cairo_stroke (cr); } } }