diff options
author | Benjamin Otte <otte@redhat.com> | 2010-10-22 19:40:28 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-10-30 01:50:05 +0800 |
commit | 2cb8ee8d454245c10e1430dc97f10715d6db84b6 (patch) | |
tree | 9991abd3b8291673c50e595d0fc06038ea7c051f /calendar/gui | |
parent | d1487cdf64a8e4b5447e57d151d53b1e692097ba (diff) | |
download | gsoc2013-evolution-2cb8ee8d454245c10e1430dc97f10715d6db84b6.tar.gz gsoc2013-evolution-2cb8ee8d454245c10e1430dc97f10715d6db84b6.tar.zst gsoc2013-evolution-2cb8ee8d454245c10e1430dc97f10715d6db84b6.zip |
calendar: Draw EWeekViewTitlesItem with cairo
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/e-week-view-titles-item.c | 75 |
1 files changed, 35 insertions, 40 deletions
diff --git a/calendar/gui/e-week-view-titles-item.c b/calendar/gui/e-week-view-titles-item.c index 91fe23336a..2a5056d7f4 100644 --- a/calendar/gui/e-week-view-titles-item.c +++ b/calendar/gui/e-week-view-titles-item.c @@ -124,39 +124,38 @@ week_view_titles_item_draw (GnomeCanvasItem *canvas_item, EWeekViewTitlesItem *titles_item; EWeekView *week_view; GtkStyle *style; - GdkGC *fg_gc, *light_gc, *dark_gc; gint col_width, col, date_width, date_x; gchar buffer[128]; - GdkRectangle clip_rect; GtkAllocation allocation; gboolean abbreviated; gint weekday; PangoLayout *layout; + cairo_t *cr; titles_item = E_WEEK_VIEW_TITLES_ITEM (canvas_item); week_view = e_week_view_titles_item_get_week_view (titles_item); g_return_if_fail (week_view != NULL); + cr = gdk_cairo_create (drawable); + cairo_set_line_width (cr, 1.0); + gtk_widget_get_allocation ( GTK_WIDGET (canvas_item->canvas), &allocation); style = gtk_widget_get_style (GTK_WIDGET (week_view)); - fg_gc = style->fg_gc[GTK_STATE_NORMAL]; - light_gc = style->light_gc[GTK_STATE_NORMAL]; - dark_gc = style->dark_gc[GTK_STATE_NORMAL]; layout = gtk_widget_create_pango_layout (GTK_WIDGET (week_view), NULL); /* Draw the shadow around the dates. */ - gdk_draw_line (drawable, light_gc, - 1 - x, 1 - y, - allocation.width - 2 - x, 1 - y); - gdk_draw_line (drawable, light_gc, - 1 - x, 2 - y, - 1 - x, allocation.height - 1 - y); + gdk_cairo_set_source_color (cr, &style->light[GTK_STATE_NORMAL]); + cairo_move_to (cr, 1.5 - x, 1.5 - y); + cairo_rel_line_to (cr, allocation.width - 1, 0); + cairo_move_to (cr, 1.5 - x, 2.5 - y); + cairo_rel_line_to (cr, 0, allocation.height - 1); + cairo_stroke (cr); - gdk_draw_rectangle (drawable, dark_gc, FALSE, - 0 - x, 0 - y, - allocation.width - 1, allocation.height); + gdk_cairo_set_source_color (cr, &style->dark[GTK_STATE_NORMAL]); + cairo_rectangle (cr, 0.5 - x, 0.5 - y, allocation.width - 1, allocation.height); + cairo_stroke (cr); /* Determine the format to use. */ col_width = allocation.width / week_view->columns; @@ -180,11 +179,12 @@ week_view_titles_item_draw (GnomeCanvasItem *canvas_item, buffer, sizeof (buffer), "%s", e_get_weekday_name (weekday + 1, abbreviated)); - clip_rect.x = week_view->col_offsets[col] - x; - clip_rect.y = 2 - y; - clip_rect.width = week_view->col_widths[col]; - clip_rect.height = allocation.height - 2; - gdk_gc_set_clip_rectangle (fg_gc, &clip_rect); + cairo_save (cr); + + cairo_rectangle (cr, + week_view->col_offsets[col] - x, 2 - y, + week_view->col_widths[col], allocation.height - 2); + cairo_clip (cr); if (weekday == 5 && week_view->compress_weekend) date_width = week_view->abbr_day_widths[5] @@ -200,35 +200,29 @@ week_view_titles_item_draw (GnomeCanvasItem *canvas_item, date_x = MAX (date_x, week_view->col_offsets[col]); pango_layout_set_text (layout, buffer, -1); - gdk_draw_layout (drawable, fg_gc, - date_x - x, - 3 - y, - layout); + cairo_move_to (cr, date_x - x, 3 - y); + pango_cairo_show_layout (cr, layout); - gdk_gc_set_clip_rectangle (fg_gc, NULL); + cairo_restore (cr); /* Draw the lines down the left and right of the date cols. */ if (col != 0) { - gdk_draw_line (drawable, light_gc, - week_view->col_offsets[col] - x, - 4 - y, - week_view->col_offsets[col] - x, - allocation.height - 4 - y); - - gdk_draw_line (drawable, dark_gc, - week_view->col_offsets[col] - 1 - x, - 4 - y, - week_view->col_offsets[col] - 1 - x, - allocation.height - 4 - y); + gdk_cairo_set_source_color (cr, &style->light[GTK_STATE_NORMAL]); + cairo_move_to (cr, week_view->col_offsets[col] - x + 0.5, 4.5 - y); + cairo_rel_line_to (cr, 0, allocation.height - 8); + cairo_stroke (cr); + + gdk_cairo_set_source_color (cr, &style->dark[GTK_STATE_NORMAL]); + cairo_move_to (cr, week_view->col_offsets[col] - x - 0.5, 4.5 - y); + cairo_rel_line_to (cr, 0, allocation.height - 8); + cairo_stroke (cr); } /* Draw the lines between each column. */ if (col != 0) { - gdk_draw_line (drawable, style->black_gc, - week_view->col_offsets[col] - x, - allocation.height - y, - week_view->col_offsets[col] - x, - allocation.height - y); + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_rectangle (cr, week_view->col_offsets[col] - x, allocation.height - y, 1, 1); + cairo_fill (cr); } if (weekday == 5 && week_view->compress_weekend) @@ -240,6 +234,7 @@ week_view_titles_item_draw (GnomeCanvasItem *canvas_item, } g_object_unref (layout); + cairo_destroy (cr); } static GnomeCanvasItem * |