cairo patch
April 12, 2006
Index: e-day-view-main-item.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view-main-item.c,v
retrieving revision 1.45
diff -u -p -r1.45 e-day-view-main-item.c
— e-day-view-main-item.c 8 Feb 2006 13:06:02 -0000 1.45
+++ e-day-view-main-item.c 12 Apr 2006 05:09:39 -0000
@@ -167,7 +167,9 @@ e_day_view_main_item_draw (GnomeCanvasIt
gint start_row, end_row, rect_x, rect_y, rect_width, rect_height;
struct icaltimetype day_start_tt;
gint weekday;
+ cairo_t *cr;
+ cr = gdk_cairo_create (drawable);
#if 0
g_print (“In e_day_view_main_item_draw %i,%i %ix%i\n”,
x, y, width, height);
@@ -179,9 +181,9 @@ e_day_view_main_item_draw (GnomeCanvasIt
style = gtk_widget_get_style (GTK_WIDGET (day_view));
/* Paint the background colors. */
- gc = day_view->main_gc;
work_day_start_y = e_day_view_convert_time_to_position (day_view, day_view->work_day_start_hour, day_view->work_day_start_minute) – y;
- work_day_end_y = e_day_view_convert_time_to_position (day_view, day_view->work_day_end_hour, day_view->work_day_end_minute) – y;
+ gc = day_view->main_gc;
+work_day_end_y = e_day_view_convert_time_to_position (day_view, day_view->work_day_end_hour, day_view->work_day_end_minute) – y;
for (day = 0; day days_shown; day++) {
day_start_tt = icaltime_from_timet_with_zone (day_view->day_starts[day], FALSE,
@@ -194,23 +196,37 @@ e_day_view_main_item_draw (GnomeCanvasIt
day_w = day_view->day_widths[day];
if (work_day) {
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING]);
- gdk_draw_rectangle (drawable, gc, TRUE,
- day_x, 0 – y,
- day_w, work_day_start_y – (0 – y));
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_BG_WORKING]);
- gdk_draw_rectangle (drawable, gc, TRUE,
- day_x, work_day_start_y,
- day_w, work_day_end_y – work_day_start_y);
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING]);
- gdk_draw_rectangle (drawable, gc, TRUE,
- day_x, work_day_end_y,
- day_w, height – work_day_end_y);
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING]);
+
+ cairo_rectangle (cr, day_x, 0 – y, day_w,
+ work_day_start_y – (0 – y));
+ cairo_fill (cr);
+ cairo_restore (cr);
+
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &day_view->colors[E_DAY_VIEW_COLOR_BG_WORKING]);
+
+ cairo_rectangle (cr, day_x, work_day_start_y, day_w,
+ work_day_end_y – work_day_start_y);
+ cairo_fill (cr);
+ cairo_restore (cr);
+
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING]);
+
+ cairo_rectangle (cr, day_x, work_day_end_y, day_w,
+ height – work_day_end_y);
+ cairo_fill (cr);
+ cairo_restore (cr);
+
} else {
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING]);
- gdk_draw_rectangle (drawable, gc, TRUE,
- day_x, 0,
- day_w, height);
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING]);
+
+ cairo_rectangle (cr, day_x, 0, day_w, height);
+ cairo_fill (cr);
+ cairo_restore (cr);
}
}
@@ -236,13 +252,23 @@ e_day_view_main_item_draw (GnomeCanvasIt
rect_y = start_row * day_view->row_height – y;
rect_height = (end_row – start_row + 1) * day_view->row_height;
- if (GTK_WIDGET_HAS_FOCUS(day_view))
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_BG_SELECTED]);
- else
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_BG_SELECTED_UNFOCUSSED]);
- gdk_draw_rectangle (drawable, gc, TRUE,
- rect_x, rect_y,
- rect_width, rect_height);
+ if (GTK_WIDGET_HAS_FOCUS(day_view)) {
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr,
+ &day_view->colors[E_DAY_VIEW_COLOR_BG_SELECTED]);
+ cairo_rectangle (cr, rect_x, rect_y, rect_width,
+ rect_height);
+ cairo_fill (cr);
+ cairo_restore (cr);
+ } else {
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr,
+ &day_view->colors[E_DAY_VIEW_COLOR_BG_SELECTED_UNFOCUSSED]);
+ cairo_rectangle (cr, rect_x, rect_y, rect_width,
+ rect_height);
+ cairo_fill (cr);
+ cairo_restore (cr);
+ }
}
}
@@ -250,14 +276,21 @@ e_day_view_main_item_draw (GnomeCanvasIt
grid_x1 = day_view->day_offsets[0] – x;
grid_x2 = day_view->day_offsets[day_view->days_shown] – x;
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_BG_GRID]);
+ cairo_save(cr);
+ gdk_cairo_set_source_color (cr,
+ &day_view->colors[E_DAY_VIEW_COLOR_BG_GRID]);
+
for (row = 0, row_y = 0 – y;
row rows && row_y row_height) {
- if (row_y >= 0 && row_y = 0 && row_y = width || grid_x1 + E_DAY_VIEW_BAR_WIDTH black_gc,
- grid_x1, grid_y1,
- grid_x1, grid_y2);
- gdk_draw_line (drawable, style->black_gc,
- grid_x1 + E_DAY_VIEW_BAR_WIDTH – 1, grid_y1,
- grid_x1 + E_DAY_VIEW_BAR_WIDTH – 1, grid_y2);
- gdk_draw_rectangle (drawable, style->white_gc, TRUE,
- grid_x1 + 1, grid_y1,
+ cairo_save (cr);
+
+ gdk_cairo_set_source_color (cr,
+ &day_view->colors[E_DAY_VIEW_COLOR_BG_GRID]);
+ cairo_move_to (cr, grid_x1, grid_y1);
+ cairo_line_to (cr, grid_x1, grid_y2);
+ cairo_stroke (cr);
+
+ gdk_cairo_set_source_color (cr,
+ &day_view->colors[E_DAY_VIEW_COLOR_BG_GRID]);
+
+ cairo_move_to (cr, grid_x1 + E_DAY_VIEW_BAR_WIDTH – 1, grid_y1);
+ cairo_line_to (cr, grid_x1 + E_DAY_VIEW_BAR_WIDTH – 1, grid_y2);
+ cairo_stroke (cr);
+
+ cairo_set_source_rgb (cr, 1, 1, 1);
+
+ cairo_rectangle (cr, grid_x1 + 1, grid_y1,
E_DAY_VIEW_BAR_WIDTH – 2, grid_y2 – grid_y1);
+
+ cairo_fill (cr);
+
+ cairo_restore (cr);
+
/* Fill in the bars when the user is busy. */
e_day_view_main_item_draw_events_in_vbars (dvmitem, drawable,
@@ -306,15 +354,16 @@ e_day_view_main_item_draw (GnomeCanvasIt
int marcus_bains_y;
GdkColor mb_color;
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE]);
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr,
+ &day_view->colors[E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE]);
if (day_view->marcus_bains_day_view_color && gdk_color_parse (day_view->marcus_bains_day_view_color, &mb_color)) {
GdkColormap *colormap;
colormap = gtk_widget_get_colormap (GTK_WIDGET (day_view));
- if (gdk_colormap_alloc_color (colormap, &mb_color, TRUE, TRUE)) {
- gdk_gc_set_foreground (gc, &mb_color);
- }
+ if (gdk_colormap_alloc_color (colormap, &mb_color, TRUE, TRUE))
+ gdk_cairo_set_source_color (cr, &mb_color);
}
zone = e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view));
@@ -330,12 +379,15 @@ e_day_view_main_item_draw (GnomeCanvasIt
grid_x1 = day_view->day_offsets[day] – x + E_DAY_VIEW_BAR_WIDTH;
grid_x2 = day_view->day_offsets[day + 1] – x – 1;
marcus_bains_y = (time_now.hour * 60 + time_now.minute) * day_view->row_height / day_view->mins_per_row – y;
- gdk_draw_line (drawable, gc, grid_x1, marcus_bains_y, grid_x2, marcus_bains_y);
+ cairo_set_line_width (cr, 1.5);
+ cairo_move_to (cr, grid_x1, marcus_bains_y);
+ cairo_line_to (cr, grid_x2, marcus_bains_y);
+ cairo_stroke (cr);
}
}
+ cairo_restore (cr);
}
-
-
+ cairo_destroy (cr);
}
@@ -348,14 +400,17 @@ e_day_view_main_item_draw_events_in_vbar
{
EDayView *day_view;
EDayViewEvent *event;
- GdkGC *gc;
gint grid_x, event_num, bar_y, bar_h;
ECalComponentTransparency transparency;
+ cairo_t *cr;
day_view = dvmitem->day_view;
- gc = day_view->main_gc;
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]);
+ cr = gdk_cairo_create (drawable);
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr,
+ &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]);
+
grid_x = day_view->day_offsets[day] + 1 – x;
@@ -388,12 +443,15 @@ e_day_view_main_item_draw_events_in_vbar
if (bar_y >= height || bar_y + bar_h day_view;
- gc = day_view->main_gc;
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]);
+ cr = gdk_cairo_create (drawable);
+ cairo_save (cr);
+
+ gdk_cairo_set_source_color (cr,
+ &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]);
for (event_num = 0; event_num long_events->len;
event_num++) {
@@ -456,16 +517,16 @@ e_day_view_main_item_draw_long_events_in
}
if (bar_y1 0 && bar_y2 > bar_y1) {
- gdk_draw_rectangle (drawable, gc, TRUE,
- grid_x, bar_y1,
- E_DAY_VIEW_BAR_WIDTH – 2,
- bar_y2 – bar_y1);
+ cairo_rectangle (cr, grid_x, bar_y1,
+ E_DAY_VIEW_BAR_WIDTH – 2, bar_y2 – bar_y1);
+
+ cairo_fill (cr);
}
}
-
-
g_object_unref (comp);
}
+ cairo_restore (cr);
+ cairo_destroy (cr);
}
@@ -507,17 +568,27 @@ e_day_view_main_item_draw_day_event (EDa
gboolean draw_attach_icon;
GSList *categories_list, *elem;
ECalComponentTransparency transparency;
+ cairo_t *cr;
+ cairo_pattern_t *pat;
+ guint16 red, green, blue;
+ gint i;
+ gdouble radius, x0, y0, x1, y1, rect_height, rect_width;
+ gdouble cc = 65535.0;
day_view = dvmitem->day_view;
+ cr = gdk_cairo_create (drawable);
+ gdk_cairo_set_source_color (cr,
+ &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]);
+
+ gc = day_view->main_gc;
+
/* If the event is currently being dragged, don’t draw it. It will
be drawn in the special drag items. */
if (day_view->drag_event_day == day
&& day_view->drag_event_num == event_num)
return;
- gc = day_view->main_gc;
-
/* Get the position of the event. If it is not shown skip it.*/
if (!e_day_view_get_event_position (day_view, day, event_num,
&item_x, &item_y,
@@ -533,40 +604,124 @@ e_day_view_main_item_draw_day_event (EDa
/* Fill in the event background. Note that for events in the first
column of the day, we might not want to paint over the vertical bar,
since that is used for multiple events. But then you can’t see
- where the event in the first column finishes. */
+ where the event in the first column finishes. The border is drawn
+ along with the event using cairo*/
+
+ cairo_save (cr);
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND]);
+ red = day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND].red;
+ green = day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND].green;
+ blue = day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND].blue;
if (gdk_color_parse (e_cal_model_get_color_for_component (e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)), event->comp_data),
&bg_color)) {
GdkColormap *colormap;
colormap = gtk_widget_get_colormap (GTK_WIDGET (day_view));
- if (gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE))
- gdk_gc_set_foreground (gc, &bg_color);
+ if (gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE)) {
+ red = bg_color.red;
+ green = bg_color.green;
+ blue = bg_color.blue;
+ }
}
+ cairo_save (cr);
+ cairo_set_line_width (cr, 0.8);
+
#if 1
- if (event->start_row_or_col == 0)
- gdk_draw_rectangle (drawable, gc, TRUE,
- item_x + E_DAY_VIEW_BAR_WIDTH, item_y + 1,
- MAX (item_w – E_DAY_VIEW_BAR_WIDTH – 1, 0),
- item_h – 2);
- else
-#endif
- gdk_draw_rectangle (drawable, gc, TRUE,
- item_x + 1, item_y + 1,
- MAX (item_w – 2, 0), item_h – 2);
+ if (event->start_row_or_col == 0) {
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]);
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_rectangle (cr, item_x + E_DAY_VIEW_BAR_WIDTH, item_y + 1,
+ MAX (item_w – E_DAY_VIEW_BAR_WIDTH – 1, 0), item_h – 2);
+ cairo_fill (cr);
+
+ x0 = item_x + E_DAY_VIEW_BAR_WIDTH;
+ y0 = item_y + 1;
+ rect_width = MAX (item_w – E_DAY_VIEW_BAR_WIDTH – 1, 0);
+ rect_height = item_h – 2;
+ } else {
+#endif
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_rectangle (cr, item_x + 1, item_y + 1,
+ MAX (item_w – 2, 0), item_h – 2);
+ cairo_fill (cr);
+
+ x0 = item_x + 1;
+ y0 = item_y + 1;
+ rect_width = MAX (item_w – 2, 0);
+ rect_height = item_h – 2;
+ }
+
+ radius = 8;
+
+ x1=x0+rect_width;
+ y1=y0+rect_height;
+
+ if (!rect_width || !rect_height)
+ return;
+
+ if (rect_width/2colors[E_DAY_VIEW_COLOR_EVENT_BORDER]);
- gdk_draw_line (drawable, gc,
- item_x + E_DAY_VIEW_BAR_WIDTH – 1,
- item_y + 1,
- item_x + E_DAY_VIEW_BAR_WIDTH – 1,
- item_y + item_h – 2);
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr,
+ &day_view->colors[E_DAY_VIEW_COLOR_BG_GRID]);
+ cairo_set_line_width (cr, 0.7);
+ cairo_move_to (cr, item_x + E_DAY_VIEW_BAR_WIDTH – 1, item_y + 1);
+ cairo_line_to (cr, item_x + E_DAY_VIEW_BAR_WIDTH – 1, item_y + item_h – 2);
+ cairo_stroke (cr);
+ cairo_restore (cr);
+
+ gdk_cairo_set_source_color (cr,
+ &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]);
/* Draw the vertical colored bar showing when the appointment
begins & ends. */
@@ -589,36 +744,106 @@ e_day_view_main_item_draw_day_event (EDa
/* Only fill it in if the event isn’t TRANSPARENT. */
e_cal_component_get_transparency (comp, &transparency);
if (transparency != E_CAL_COMPONENT_TRANSP_TRANSPARENT) {
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]);
- gdk_draw_rectangle (drawable, gc, TRUE,
- item_x + 1, bar_y1,
- E_DAY_VIEW_BAR_WIDTH – 2, bar_y2 – bar_y1);
- }
+ cairo_save (cr);
+ pat = cairo_pattern_create_linear (item_x + E_DAY_VIEW_BAR_WIDTH, item_y + 1,
+ item_x + E_DAY_VIEW_BAR_WIDTH, item_y + item_h – 1);
+ cairo_pattern_add_color_stop_rgba (pat, 1, red/cc, green/cc, blue/cc, 0.7);
+ cairo_pattern_add_color_stop_rgba (pat, 0, red/cc, green/cc, blue/cc, 0.2);
+
+ cairo_rectangle (cr, item_x + 1, bar_y1,
+ E_DAY_VIEW_BAR_WIDTH – 2, bar_y2 – bar_y1);
+
+ cairo_set_source (cr, pat);
+ cairo_fill (cr);
+ cairo_pattern_destroy (pat);
+ cairo_restore (cr);
+
+ for (i = 0; i colors[E_DAY_VIEW_COLOR_EVENT_BORDER]);
- gdk_draw_rectangle (drawable, gc, FALSE,
- item_x, item_y, MAX (item_w – 1, 0), item_h – 1);
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]);
+ gdk_cairo_set_source_color (cr,
+ &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]);
#if 0
/* Draw the horizontal bars above and beneath the event if it
is currently being edited. */
if (day_view->editing_event_day == day
&& day_view->editing_event_num == event_num) {
- gdk_draw_rectangle (drawable, gc, TRUE,
- item_x,
- item_y – E_DAY_VIEW_BAR_HEIGHT,
- item_w,
- E_DAY_VIEW_BAR_HEIGHT);
- gdk_draw_rectangle (drawable, gc, TRUE,
- item_x, item_y + item_h,
- item_w, E_DAY_VIEW_BAR_HEIGHT);
+ cairo_save (cr);
+ cairo_rectangle (cr, item_x, item_y – E_DAY_VIEW_BAR_HEIGHT,
+ item_w, E_DAY_VIEW_BAR_HEIGHT);
+ cairo_fill (cr);
+ cairo_restore (cr);
+
+ cairo_save (cr);
+ cairo_rectangle (cr, item_x, item_y + item_h,
+ item_w, E_DAY_VIEW_BAR_HEIGHT);
+ cairo_fill (cr);
+ cairo_restore (cr);
}
#endif
-
+
/* Draw the reminder & recurrence icons, if needed. */
num_icons = 0;
draw_reminder_icon = FALSE;
@@ -684,16 +909,11 @@ e_day_view_main_item_draw_day_event (EDa
max_icon_h = item_y + item_h – icon_y
- E_DAY_VIEW_EVENT_BORDER_HEIGHT;
- gdk_gc_set_clip_mask (gc, NULL);
- gdk_draw_pixbuf (drawable, gc,
- day_view->reminder_icon,
- 0, 0, icon_x, icon_y,
- MIN (E_DAY_VIEW_ICON_WIDTH,
- max_icon_w),
- MIN (E_DAY_VIEW_ICON_HEIGHT,
- max_icon_h),
- GDK_RGB_DITHER_NORMAL,
- 0, 0);
+ cairo_save (cr);
+ gdk_cairo_set_source_pixbuf (cr, day_view->reminder_icon, icon_x, icon_y);
+ cairo_paint (cr);
+ cairo_restore (cr);
+
icon_x += icon_x_inc;
icon_y += icon_y_inc;
}
@@ -703,17 +923,12 @@ e_day_view_main_item_draw_day_event (EDa
- E_DAY_VIEW_EVENT_BORDER_WIDTH;
max_icon_h = item_y + item_h – icon_y
- E_DAY_VIEW_EVENT_BORDER_HEIGHT;
-
- gdk_gc_set_clip_mask (gc, NULL);
- gdk_draw_pixbuf (drawable, gc,
- day_view->recurrence_icon,
- 0, 0, icon_x, icon_y,
- MIN (E_DAY_VIEW_ICON_WIDTH,
- max_icon_w),
- MIN (E_DAY_VIEW_ICON_HEIGHT,
- max_icon_h),
- GDK_RGB_DITHER_NORMAL,
- 0, 0);
+
+ cairo_save (cr);
+ gdk_cairo_set_source_pixbuf (cr, day_view->recurrence_icon, icon_x, icon_y);
+ cairo_paint (cr);
+ cairo_restore (cr);
+
icon_x += icon_x_inc;
icon_y += icon_y_inc;
}
@@ -723,16 +938,10 @@ e_day_view_main_item_draw_day_event (EDa
max_icon_h = item_y + item_h – icon_y
- E_DAY_VIEW_EVENT_BORDER_HEIGHT;
- gdk_gc_set_clip_mask (gc, NULL);
- gdk_draw_pixbuf (drawable, gc,
- day_view->attach_icon,
- 0, 0, icon_x, icon_y,
- MIN (E_DAY_VIEW_ICON_WIDTH,
- max_icon_w),
- MIN (E_DAY_VIEW_ICON_HEIGHT,
- max_icon_h),
- GDK_RGB_DITHER_NORMAL,
- 0, 0);
+ cairo_save (cr);
+ gdk_cairo_set_source_pixbuf (cr, day_view->attach_icon, icon_x, icon_y);
+ cairo_paint (cr);
+ cairo_restore (cr);
icon_x += icon_x_inc;
icon_y += icon_y_inc;
}
@@ -742,16 +951,11 @@ e_day_view_main_item_draw_day_event (EDa
max_icon_h = item_y + item_h – icon_y
- E_DAY_VIEW_EVENT_BORDER_HEIGHT;
- gdk_gc_set_clip_mask (gc, NULL);
- gdk_draw_pixbuf (drawable, gc,
- day_view->timezone_icon,
- 0, 0, icon_x, icon_y,
- MIN (E_DAY_VIEW_ICON_WIDTH,
- max_icon_w),
- MIN (E_DAY_VIEW_ICON_HEIGHT,
- max_icon_h),
- GDK_RGB_DITHER_NORMAL,
- 0, 0);
+ cairo_save (cr);
+ gdk_cairo_set_source_pixbuf (cr, day_view->timezone_icon, icon_x, icon_y);
+ cairo_paint (cr);
+ cairo_restore (cr);
+
icon_x += icon_x_inc;
icon_y += icon_y_inc;
}
@@ -763,16 +967,11 @@ e_day_view_main_item_draw_day_event (EDa
max_icon_h = item_y + item_h – icon_y
- E_DAY_VIEW_EVENT_BORDER_HEIGHT;
- gdk_gc_set_clip_mask (gc, NULL);
- gdk_draw_pixbuf (drawable, gc,
- day_view->meeting_icon,
- 0, 0, icon_x, icon_y,
- MIN (E_DAY_VIEW_ICON_WIDTH,
- max_icon_w),
- MIN (E_DAY_VIEW_ICON_HEIGHT,
- max_icon_h),
- GDK_RGB_DITHER_NORMAL,
- 0, 0);
+ cairo_save (cr);
+ gdk_cairo_set_source_pixbuf (cr, day_view->meeting_icon, icon_x, icon_y);
+ cairo_paint (cr);
+ cairo_restore (cr);
+
icon_x += icon_x_inc;
icon_y += icon_y_inc;
}
@@ -817,6 +1016,7 @@ e_day_view_main_item_draw_day_event (EDa
/* free memory */
e_cal_component_free_categories_list (categories_list);
g_object_unref (comp);
+ cairo_destroy (cr);
}
Index: e-day-view-time-item.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view-time-item.c,v
retrieving revision 1.36
diff -u -p -r1.36 e-day-view-time-item.c
— e-day-view-time-item.c 8 Feb 2006 13:06:02 -0000 1.36
+++ e-day-view-time-item.c 12 Apr 2006 05:09:39 -0000
@@ -198,6 +198,7 @@ e_day_view_time_item_get_column_width (E
layout = gtk_widget_create_pango_layout (GTK_WIDGET (day_view), digit_str);
pango_layout_set_font_description (layout, day_view->large_font_desc);
pango_layout_get_pixel_size (layout, &large_digit_width, NULL);
+
g_object_unref (layout);
max_large_digit_width = MAX (max_large_digit_width,
@@ -228,7 +229,6 @@ e_day_view_time_item_get_column_width (E
dvtmitem->column_width = MAX (column_width_default,
column_width_60_min_rows);
-
return dvtmitem->column_width;
}
@@ -248,7 +248,6 @@ e_day_view_time_item_draw (GnomeCanvasIt
EDayView *day_view;
EDayViewTimeItem *dvtmitem;
GtkStyle *style;
- GdkGC *gc, *fg_gc, *dark_gc;
gchar buffer[64], *suffix;
gint hour, display_hour, minute, row;
gint row_y, start_y, large_hour_y_offset, small_font_y_offset;
@@ -260,6 +259,10 @@ e_day_view_time_item_draw (GnomeCanvasIt
PangoContext *context;
PangoFontDescription *small_font_desc;
PangoFontMetrics *large_font_metrics, *small_font_metrics;
+ cairo_t *cr;
+ GdkColor fg, dark;
+
+ cr = gdk_cairo_create (drawable);
dvtmitem = E_DAY_VIEW_TIME_ITEM (canvas_item);
day_view = dvtmitem->day_view;
@@ -274,9 +277,8 @@ e_day_view_time_item_draw (GnomeCanvasIt
small_font_metrics = pango_context_get_metrics (context, small_font_desc,
pango_context_get_language (context));
- gc = day_view->main_gc;
- fg_gc = style->fg_gc[GTK_STATE_NORMAL];
- dark_gc = style->dark_gc[GTK_STATE_NORMAL];
+ fg = style->fg[GTK_STATE_NORMAL];
+ dark = style->dark[GTK_STATE_NORMAL];
/* The start and end of the long horizontal line between hours. */
long_line_x1 = E_DVTMI_TIME_GRID_X_PAD – x;
@@ -334,22 +336,25 @@ e_day_view_time_item_draw (GnomeCanvasIt
int marcus_bains_y;
GdkColor mb_color;
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE]);
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &day_view->colors[E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE]);
if (day_view->marcus_bains_time_bar_color && gdk_color_parse (day_view->marcus_bains_time_bar_color, &mb_color)) {
GdkColormap *colormap;
colormap = gtk_widget_get_colormap (GTK_WIDGET (day_view));
if (gdk_colormap_alloc_color (colormap, &mb_color, TRUE, TRUE)) {
- gdk_gc_set_foreground (gc, &mb_color);
+ gdk_cairo_set_source_color (cr, &mb_color);
}
}
time_now = icaltime_current_time_with_zone (e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view)));
marcus_bains_y = (time_now.hour * 60 + time_now.minute) * day_view->row_height / day_view->mins_per_row – y;
- gdk_draw_line (drawable, gc,
- long_line_x1, marcus_bains_y,
- long_line_x2, marcus_bains_y);
+ cairo_set_line_width (cr, 1.5);
+ cairo_move_to (cr, long_line_x1, marcus_bains_y);
+ cairo_line_to (cr, long_line_x2, marcus_bains_y);
+ cairo_stroke (cr);
+ cairo_restore (cr);
}
/* Step through each row, drawing the times and the horizontal lines
@@ -376,9 +381,14 @@ e_day_view_time_item_draw (GnomeCanvasIt
/* 60 minute intervals – draw a long horizontal line
between hours and display as one long string,
e.g. “14:00″ or “2 pm”. */
- gdk_draw_line (drawable, dark_gc,
- long_line_x1, row_y,
- long_line_x2, row_y);
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &dark);
+ cairo_save (cr);
+ cairo_set_line_width (cr, 0.7);
+ cairo_move_to (cr, long_line_x1, row_y);
+ cairo_line_to (cr, long_line_x2, row_y);
+ cairo_stroke (cr);
+ cairo_restore (cr);
if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) {
g_snprintf (buffer, sizeof (buffer), “%i:%02i”,
@@ -388,12 +398,16 @@ e_day_view_time_item_draw (GnomeCanvasIt
display_hour, suffix);
}
- layout = gtk_widget_create_pango_layout (GTK_WIDGET (day_view), buffer);
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &fg);
+ layout = pango_cairo_create_layout (cr);
+ pango_layout_set_text (layout, buffer, -1);
pango_layout_get_pixel_size (layout, &minute_width, NULL);
- gdk_draw_layout (drawable, fg_gc,
- minute_x2 – minute_width,
- row_y + small_font_y_offset,
- layout);
+ cairo_translate (cr, minute_x2 – minute_width, row_y + small_font_y_offset);
+ pango_cairo_update_layout (cr, layout);
+ pango_cairo_show_layout (cr, layout);
+ cairo_restore (cr);
+
g_object_unref (layout);
} else {
/* 5/10/15/30 minute intervals. */
@@ -402,27 +416,40 @@ e_day_view_time_item_draw (GnomeCanvasIt
/* On the hour – draw a long horizontal line
before the hour and display the hour in the
large font. */
- gdk_draw_line (drawable, dark_gc,
- long_line_x1, row_y,
- long_line_x2, row_y);
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &dark);
g_snprintf (buffer, sizeof (buffer), “%i”,
display_hour);
- layout = gtk_widget_create_pango_layout (GTK_WIDGET (day_view), buffer);
+ cairo_set_line_width (cr, 0.7);
+ cairo_move_to (cr, long_line_x1, row_y);
+ cairo_line_to (cr, long_line_x2, row_y);
+ cairo_stroke (cr);
+ cairo_restore (cr);
+
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &fg);
+ layout = pango_cairo_create_layout (cr);
+ pango_layout_set_text (layout, buffer, -1);
pango_layout_set_font_description (layout, day_view->large_font_desc);
pango_layout_get_pixel_size (layout, &hour_width, NULL);
- gdk_draw_layout (drawable, fg_gc,
- large_hour_x2 – hour_width,
- row_y + large_hour_y_offset,
- layout);
+ cairo_translate (cr, large_hour_x2 – hour_width, row_y + large_hour_y_offset);
+ pango_cairo_update_layout (cr, layout);
+ pango_cairo_show_layout (cr, layout);
+ cairo_restore (cr);
+
g_object_unref (layout);
} else {
/* Within the hour – draw a short line before
the time. */
- gdk_draw_line (drawable, dark_gc,
- short_line_x1, row_y,
- long_line_x2, row_y);
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &dark);
+ cairo_set_line_width (cr, 0.7);
+ cairo_move_to (cr, short_line_x1, row_y);
+ cairo_line_to (cr, long_line_x2, row_y);
+ cairo_stroke (cr);
+ cairo_restore (cr);
}
/* Normally we display the minute in each
@@ -439,12 +466,17 @@ e_day_view_time_item_draw (GnomeCanvasIt
“%02i”, minute);
}
- layout = gtk_widget_create_pango_layout (GTK_WIDGET (day_view), buffer);
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &fg);
+ layout = pango_cairo_create_layout (cr);
+ pango_layout_set_text (layout, buffer, -1);
+ pango_layout_set_font_description (layout, day_view->small_font_desc);
pango_layout_get_pixel_size (layout, &minute_width, NULL);
- gdk_draw_layout (drawable, fg_gc,
- minute_x2 – minute_width,
- row_y + small_font_y_offset,
- layout);
+ cairo_translate (cr, minute_x2 – minute_width, row_y + small_font_y_offset);
+ pango_cairo_update_layout (cr, layout);
+ pango_cairo_show_layout (cr, layout);
+ cairo_restore (cr);
+
g_object_unref (layout);
}
}
@@ -455,6 +487,7 @@ e_day_view_time_item_draw (GnomeCanvasIt
pango_font_metrics_unref (large_font_metrics);
pango_font_metrics_unref (small_font_metrics);
+ cairo_destroy (cr);
}
Index: e-day-view-top-item.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view-top-item.c,v
retrieving revision 1.45
diff -u -p -r1.45 e-day-view-top-item.c
— e-day-view-top-item.c 8 Feb 2006 13:06:02 -0000 1.45
+++ e-day-view-top-item.c 12 Apr 2006 05:09:40 -0000
@@ -164,6 +164,8 @@ e_day_view_top_item_draw (GnomeCanvasIte
gint canvas_width, canvas_height, left_edge, day, date_width, date_x;
gint item_height, event_num;
PangoLayout *layout;
+ cairo_t *cr;
+ GdkColor fg, bg, light, dark;
#if 0
g_print (“In e_day_view_top_item_draw %i,%i %ix%i\n”,
@@ -173,6 +175,8 @@ e_day_view_top_item_draw (GnomeCanvasIte
day_view = dvtitem->day_view;
g_return_if_fail (day_view != NULL);
+ cr = gdk_cairo_create (drawable);
+
style = gtk_widget_get_style (GTK_WIDGET (day_view));
gc = day_view->main_gc;
fg_gc = style->fg_gc[GTK_STATE_NORMAL];
@@ -184,32 +188,47 @@ e_day_view_top_item_draw (GnomeCanvasIte
left_edge = 0;
item_height = day_view->top_row_height – E_DAY_VIEW_TOP_CANVAS_Y_GAP;
+ fg = style->fg[GTK_STATE_NORMAL];
+ bg = style->bg[GTK_STATE_NORMAL];
+ light = style->light[GTK_STATE_NORMAL];
+ dark = style->dark[GTK_STATE_NORMAL];
+
/* Draw the shadow around the dates. */
- gdk_draw_line (drawable, light_gc,
- left_edge – x, 1 – y,
- canvas_width – 2 – x, 1 – y);
- gdk_draw_line (drawable, light_gc,
- left_edge – x, 2 – y,
- left_edge – x, item_height – 2 – y);
- gdk_draw_line (drawable, dark_gc,
- left_edge – x, item_height – 1 – y,
- canvas_width – 1 – x, item_height – 1 – y);
- gdk_draw_line (drawable, dark_gc,
- canvas_width – 1 – x, 1 – y,
- canvas_width – 1 – x, item_height – 1 – y);
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &light);
+ cairo_move_to (cr, left_edge – x, 1 – y);
+ cairo_line_to (cr, canvas_width – 2 – x, 1 – y);
+ cairo_move_to (cr, left_edge – x, 2 – y);
+ cairo_line_to (cr, left_edge – x, item_height – 2 – y);
+ cairo_stroke (cr);
+ cairo_restore (cr);
+
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &dark);
+ cairo_move_to (cr, left_edge – x, item_height – 1 – y);
+ cairo_line_to (cr, canvas_width – 1 – x, item_height – 1 – y);
+ cairo_move_to (cr, canvas_width – 1 – x, 1 – y);
+ cairo_line_to (cr, canvas_width – 1 – x, item_height – 1 – y);
+ cairo_stroke (cr);
+ cairo_restore (cr);
/* Draw the background for the dates. */
- gdk_draw_rectangle (drawable, bg_gc, TRUE,
- left_edge + 2 – x, 2 – y,
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &bg);
+ cairo_rectangle (cr, left_edge + 2 – x, 2 – y,
canvas_width – left_edge – 3,
item_height – 3);
+ cairo_fill (cr);
+ cairo_restore (cr);
/* Clear the main area background. */
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS]);
- gdk_draw_rectangle (drawable, gc, TRUE,
- left_edge – x, item_height – y,
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS]);
+ cairo_rectangle (cr, left_edge – x, item_height – y,
canvas_width – left_edge,
canvas_height – item_height);
+ cairo_fill (cr);
+ cairo_restore (cr);
/* Draw the selection background. */
if (GTK_WIDGET_HAS_FOCUS (day_view)
@@ -227,10 +246,12 @@ e_day_view_top_item_draw (GnomeCanvasIte
rect_w = day_view->day_offsets[end_col + 1] – rect_x;
rect_h = canvas_height – 1 – rect_y;
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_SELECTED]);
- gdk_draw_rectangle (drawable, gc, TRUE,
- rect_x – x, rect_y – y,
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_SELECTED]);
+ cairo_rectangle (cr, rect_x – x, rect_y – y,
rect_w, rect_h);
+ cairo_fill (cr);
+ cairo_restore (cr);
}
}
@@ -243,6 +264,7 @@ e_day_view_top_item_draw (GnomeCanvasIte
clip_rect.y = 2 – y;
clip_rect.width = day_view->day_widths[day];
clip_rect.height = item_height – 2;
+
gdk_gc_set_clip_rectangle (fg_gc, &clip_rect);
layout = gtk_widget_create_pango_layout (GTK_WIDGET (day_view), buffer);
@@ -259,27 +281,32 @@ e_day_view_top_item_draw (GnomeCanvasIte
/* Draw the lines down the left and right of the date cols. */
if (day != 0) {
- gdk_draw_line (drawable, light_gc,
- day_view->day_offsets[day] – x,
- 4 – y,
- day_view->day_offsets[day] – x,
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &light);
+ cairo_move_to (cr, day_view->day_offsets[day] – x,
+ 4 – y);
+ cairo_line_to (cr, day_view->day_offsets[day] – x,
item_height – 4 – y);
-
- gdk_draw_line (drawable, dark_gc,
- day_view->day_offsets[day] – 1 – x,
- 4 – y,
- day_view->day_offsets[day] – 1 – x,
+ cairo_stroke (cr);
+ gdk_cairo_set_source_color (cr, &dark);
+ cairo_move_to (cr, day_view->day_offsets[day] – 1 – x,
+ 4 – y);
+ cairo_line_to (cr, day_view->day_offsets[day] – 1 – x,
item_height – 4 – y);
+ cairo_stroke (cr);
+ cairo_restore (cr);
}
/* Draw the lines between each column. */
if (day != 0) {
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_GRID]);
- gdk_draw_line (drawable, gc,
- day_view->day_offsets[day] – x,
- item_height – y,
- day_view->day_offsets[day] – x,
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_GRID]);
+ cairo_move_to (cr, day_view->day_offsets[day] – x,
+ item_height – y);
+ cairo_line_to (cr, day_view->day_offsets[day] – x,
canvas_height – y);
+ cairo_stroke (cr);
+ cairo_restore (cr);
}
}
@@ -290,6 +317,7 @@ e_day_view_top_item_draw (GnomeCanvasIte
drawable,
x, y, width, height);
}
+ cairo_destroy (cr);
}
@@ -320,8 +348,15 @@ e_day_view_top_item_draw_long_event (EDa
GSList *categories_list, *elem;
PangoLayout *layout;
GdkColor bg_color;
+ cairo_t *cr;
+ cairo_pattern_t *pat;
+ guint16 red, green, blue;
+ GdkColor fg;
+ gdouble cc = 65535.0;
+ gdouble x0, y0, x1, y1, rect_height, rect_width, radius;
day_view = dvtitem->day_view;
+ cr = gdk_cairo_create (drawable);
/* If the event is currently being dragged, don’t draw it. It will
be drawn in the special drag items. */
@@ -341,17 +376,19 @@ e_day_view_top_item_draw_long_event (EDa
style = gtk_widget_get_style (GTK_WIDGET (day_view));
gc = day_view->main_gc;
fg_gc = style->fg_gc[GTK_STATE_NORMAL];
+ fg = style->fg[GTK_STATE_NORMAL];
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
/* Draw the lines across the top & bottom of the entire event. */
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER]);
- gdk_draw_line (drawable, gc,
- item_x – x, item_y – y,
- item_x + item_w – 1 – x, item_y – y);
- gdk_draw_line (drawable, gc,
- item_x – x, item_y + item_h – 1 – y,
- item_x + item_w – 1 – x, item_y + item_h – 1 – y);
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER]);
+ cairo_move_to (cr, item_x – x, item_y + item_h – 1 – y);
+ cairo_line_to (cr, item_x + item_w – 1 – x, item_y – y);
+ cairo_move_to (cr, item_x – x, item_y + item_h – 1 – y);
+ cairo_line_to (cr, item_x + item_w – 1 – x, item_y + item_h – 1 – y);
+ cairo_stroke (cr);
+ cairo_restore (cr);
/* Fill it in. */
if (gdk_color_parse (e_cal_model_get_color_for_component (e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)),
@@ -360,15 +397,91 @@ e_day_view_top_item_draw_long_event (EDa
GdkColormap *colormap;
colormap = gtk_widget_get_colormap (GTK_WIDGET (day_view));
- if (gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE))
- gdk_gc_set_foreground (gc, &bg_color);
- else
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND]);
- } else
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND]);
- gdk_draw_rectangle (drawable, gc, TRUE,
- item_x – x, item_y + 1 – y,
- item_w, item_h – 2);
+ if (gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE)){
+ red = bg_color.red;
+ green = bg_color.green;
+ blue = bg_color.blue;
+ } else {
+ red = day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND].red;
+ green = day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND].green;
+ blue = day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND].blue;
+ }
+ } else {
+ red = day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND].red;
+ green = day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND].green;
+ blue = day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND].blue;
+ }
+
+
+ cairo_save (cr);
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_rectangle (cr, item_x + 2- x, item_y + 1 – y,
+ item_w – 6, item_h – 2);
+ cairo_fill (cr);
+
+ cairo_set_line_width (cr, 0.8);
+
+ x0 = item_x – x + 1;
+ y0 = item_y + 1 – y;
+ rect_width = item_w – 3;
+ rect_height = item_h – 2;
+
+ radius = 8;
+
+ x1=x0+rect_width;
+ y1=y0+rect_height;
+
+ if (!rect_width || !rect_height)
+ return;
+
+ if (rect_width/2colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER]);
- gdk_draw_line (drawable, gc,
- item_x – x, item_y – y,
- item_x – x, item_y + item_h – 1 – y);
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER]);
+ cairo_move_to (cr, item_x – x, item_y – y);
+ cairo_line_to (cr, item_x – x, item_y + item_h – 1 – y);
+ cairo_stroke (cr);
+ cairo_restore (cr);
}
/* Similar for the event end. */
@@ -407,12 +522,12 @@ e_day_view_top_item_draw_long_event (EDa
E_DAY_VIEW_BAR_WIDTH,
item_h, event_num);
} else {
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER]);
- gdk_draw_line (drawable, gc,
- item_x + item_w – 1 – x,
- item_y – y,
- item_x + item_w – 1 – x,
- item_y + item_h – 1 – y);
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER]);
+ cairo_move_to (cr, item_x + item_w – 1 – x, item_y – y);
+ cairo_line_to (cr, item_x + item_w – 1 – x, item_y + item_h – 1 – y);
+ cairo_stroke (cr);
+ cairo_restore (cr);
}
/* If we are editing the event we don’t show the icons or the start
@@ -521,41 +636,32 @@ e_day_view_top_item_draw_long_event (EDa
+ E_DAY_VIEW_ICON_Y_PAD – y;
if (icon_x recurrence_icon,
- 0, 0, icon_x, icon_y,
- E_DAY_VIEW_ICON_WIDTH,
- E_DAY_VIEW_ICON_HEIGHT,
- GDK_RGB_DITHER_NORMAL,
- 0, 0);
+ cairo_save (cr);
+ gdk_cairo_set_source_pixbuf (cr, day_view->recurrence_icon, icon_x, icon_y);
+ cairo_paint (cr);
+ cairo_restore (cr);
+
icon_x -= icon_x_inc;
}
if (icon_x attach_icon,
- 0, 0, icon_x, icon_y,
- E_DAY_VIEW_ICON_WIDTH,
- E_DAY_VIEW_ICON_HEIGHT,
- GDK_RGB_DITHER_NORMAL,
- 0, 0);
+ cairo_save (cr);
+ gdk_cairo_set_source_pixbuf (cr, day_view->attach_icon, icon_x, icon_y);
+ cairo_paint (cr);
+ cairo_restore (cr);
+
icon_x -= icon_x_inc;
}
if (icon_x reminder_icon,
- 0, 0, icon_x, icon_y,
- E_DAY_VIEW_ICON_WIDTH,
- E_DAY_VIEW_ICON_HEIGHT,
- GDK_RGB_DITHER_NORMAL,
- 0, 0);
+ cairo_save (cr);
+ gdk_cairo_set_source_pixbuf (cr, day_view->reminder_icon, icon_x, icon_y);
+ cairo_paint (cr);
+ cairo_restore (cr);
+
icon_x -= icon_x_inc;
}
- /* draw categories icons */
+ /* draw categories icons */ /* categories alone – yet to be cairo – ified */
e_cal_component_get_categories_list (comp, &categories_list);
for (elem = categories_list; elem; elem = elem->next) {
char *category;
@@ -586,7 +692,7 @@ e_day_view_top_item_draw_long_event (EDa
e_cal_component_free_categories_list (categories_list);
g_object_unref (comp);
-
+ cairo_destroy (cr);
gdk_gc_set_clip_mask (gc, NULL);
}
@@ -608,6 +714,9 @@ e_day_view_top_item_draw_triangle (EDayV
GdkColor bg_color;
GdkPoint points[3];
gint c1, c2;
+ cairo_t *cr;
+
+ cr = gdk_cairo_create (drawable);
day_view = dvtitem->day_view;
@@ -628,7 +737,7 @@ e_day_view_top_item_draw_triangle (EDayV
event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
-
+ cairo_save (cr);
/* Fill it in. */
if (gdk_color_parse (e_cal_model_get_color_for_component (e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)),
event->comp_data),
@@ -636,18 +745,32 @@ e_day_view_top_item_draw_triangle (EDayV
GdkColormap *colormap;
colormap = gtk_widget_get_colormap (GTK_WIDGET (day_view));
- if (gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE))
- gdk_gc_set_foreground (gc, &bg_color);
- else
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND]);
- } else
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND]);
-
- gdk_draw_polygon (drawable, gc, TRUE, points, 3);
-
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER]);
- gdk_draw_line (drawable, gc, x, y, x + w, c1);
- gdk_draw_line (drawable, gc, x, y + h – 1, x + w, c2);
+ if (gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE)) {
+ gdk_cairo_set_source_color (cr, &bg_color);
+ } else {
+ gdk_cairo_set_source_color (cr, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND]);
+ }
+ } else {
+ gdk_cairo_set_source_color (cr, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND]);
+ }
+
+ cairo_move_to (cr, points[0].x, points[0].y);
+ cairo_line_to (cr, points[1].x, points[1].y);
+ cairo_line_to (cr, points[2].x, points[2].y);
+ cairo_line_to (cr, points[0].x, points[0].y);
+ cairo_fill (cr);
+ cairo_restore (cr);
+
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER]);
+ cairo_move_to (cr, x, y);
+ cairo_line_to (cr, x + w, c1);
+ cairo_move_to (cr, x, y + h – 1);
+ cairo_line_to (cr, x + w, c2);
+ cairo_stroke (cr);
+ cairo_restore (cr);
+
+ cairo_destroy (cr);
}
Index: e-day-view.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view.c,v
retrieving revision 1.295
diff -u -p -r1.295 e-day-view.c
— e-day-view.c 6 Apr 2006 09:17:23 -0000 1.295
+++ e-day-view.c 12 Apr 2006 05:09:42 -0000
@@ -78,6 +78,7 @@
#define E_DAY_VIEW_DATE_X_PAD 4
#define E_DAY_VIEW_LARGE_FONT_PTSIZE 18
+#define E_DAY_VIEW_SMALL_FONT_PTSIZE 10
/* The offset from the top/bottom of the canvas before auto-scrolling starts.*/
#define E_DAY_VIEW_AUTO_SCROLL_OFFSET 16
@@ -739,6 +740,7 @@ e_day_view_init (EDayView *day_view)
day_view->auto_scroll_timeout_id = 0;
day_view->large_font_desc = NULL;
+ day_view->small_font_desc = NULL;
/* String to use in 12-hour time format for times in the morning. */
day_view->am_string = _(“am”);
@@ -1033,6 +1035,11 @@ e_day_view_destroy (GtkObject *object)
day_view->large_font_desc = NULL;
}
+ if (day_view->small_font_desc) {
+ pango_font_description_free (day_view->small_font_desc);
+ day_view->small_font_desc = NULL;
+ }
+
if (day_view->normal_cursor) {
gdk_cursor_unref (day_view->normal_cursor);
day_view->normal_cursor = NULL;
@@ -1254,6 +1261,14 @@ e_day_view_style_set (GtkWidget *widget,
day_view->large_font_desc = pango_font_description_copy (font_desc);
pango_font_description_set_size (day_view->large_font_desc,
E_DAY_VIEW_LARGE_FONT_PTSIZE * PANGO_SCALE);
+
+ /* Create the small fonts. */
+ if (day_view->small_font_desc != NULL)
+ pango_font_description_free (day_view->small_font_desc);
+
+ day_view->small_font_desc = pango_font_description_copy (font_desc);
+ pango_font_description_set_size (day_view->small_font_desc,
+ E_DAY_VIEW_SMALL_FONT_PTSIZE * PANGO_SCALE);
/* Recalculate the height of each row based on the font size. */
day_view->row_height =
Index: e-day-view.h
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view.h,v
retrieving revision 1.66
diff -u -p -r1.66 e-day-view.h
— e-day-view.h 30 May 2005 09:14:26 -0000 1.66
+++ e-day-view.h 12 Apr 2006 05:09:42 -0000
@@ -325,6 +325,7 @@ struct _EDayView
/* The large font used to display the hours. I don’t think we need a
fontset since we only display numbers. */
PangoFontDescription *large_font_desc;
+ PangoFontDescription *small_font_desc;
/* The GC used for painting in different colors. */
GdkGC *main_gc;
Index: e-week-view-event-item.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-week-view-event-item.c,v
retrieving revision 1.55
diff -u -p -r1.55 e-week-view-event-item.c
— e-week-view-event-item.c 8 Feb 2006 13:06:02 -0000 1.55
+++ e-week-view-event-item.c 12 Apr 2006 05:09:47 -0000
@@ -229,6 +229,11 @@ e_week_view_event_item_draw (GnomeCanvas
gboolean draw_start_triangle = FALSE, draw_end_triangle = FALSE;
GdkRectangle clip_rect;
GdkColor bg_color;
+ cairo_t *cr;
+ cairo_pattern_t *pat;
+ guint16 red, green, blue;
+ gdouble radius, cx0, cy0, cx1, cy1, rect_height, rect_width;
+ gdouble cc = 65535.0;
#if 0
g_print (“In e_week_view_event_item_draw %i,%i %ix%i\n”,
@@ -239,6 +244,8 @@ e_week_view_event_item_draw (GnomeCanvas
week_view = E_WEEK_VIEW (GTK_WIDGET (canvas_item->canvas)->parent);
g_return_if_fail (E_IS_WEEK_VIEW (week_view));
+ cr = gdk_cairo_create (drawable);
+
if (wveitem->event_num == -1 || wveitem->span_num == -1)
return;
@@ -284,26 +291,149 @@ e_week_view_event_item_draw (GnomeCanvas
time_x = x1 + E_WEEK_VIEW_EVENT_L_PAD + 1;
rect_x = x1 + E_WEEK_VIEW_EVENT_L_PAD;
rect_w = x2 – x1 – E_WEEK_VIEW_EVENT_L_PAD – E_WEEK_VIEW_EVENT_R_PAD + 1;
-
+
+ cairo_save (cr);
if (gdk_color_parse (e_cal_model_get_color_for_component (e_calendar_view_get_model (E_CALENDAR_VIEW (week_view)),
event->comp_data),
&bg_color)) {
GdkColormap *colormap;
colormap = gtk_widget_get_colormap (GTK_WIDGET (week_view));
- if (gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE))
- gdk_gc_set_foreground (gc, &bg_color);
- else
- gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND]);
- } else
- gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND]);
- gdk_draw_rectangle (drawable, gc, TRUE, rect_x, y1 + 1, rect_w, y2 – y1 – 1);
-
- gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER]);
- gdk_draw_line (drawable, gc, rect_x, y1 + 1, rect_x + rect_w, y1 + 1);
- gdk_draw_line (drawable, gc, rect_x, y2, rect_x + rect_w, y2);
- gdk_draw_line (drawable, gc, rect_x, y1 + 1, rect_x, y1 + (y2 – (y1 + 1)));
- gdk_draw_line (drawable, gc, rect_x + rect_w, y1 + 1, rect_x + rect_w, y1 + (y2 – (y1 + 1)));
+ if (gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE)) {
+ red = bg_color.red;
+ green = bg_color.green;
+ blue = bg_color.blue;
+ } else {
+ red = week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].red;
+ green = week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].green;
+ blue = week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].blue;
+ }
+ } else {
+ red = week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].green;
+ green = week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].green;
+ blue = week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].green;
+ }
+
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_rectangle (cr, rect_x, y1 + 1, rect_w, y2 – y1 – 1);
+ cairo_fill (cr);
+
+ cx0 = rect_x;
+ cy0 = y1 + 1;
+ rect_width = rect_w;
+ rect_height = y2 – y1 – 1;
+
+ radius = 3;
+
+ cx1 = cx0 + rect_width;
+ cy1 = cy0 + rect_height;
+
+ if (!rect_width || !rect_height)
+ return;
+ if (rect_width/2time_format) {
@@ -375,35 +505,171 @@ e_week_view_event_item_draw (GnomeCanvas
rect_w -= 2;
}
+ cairo_save (cr);
if (gdk_color_parse (e_cal_model_get_color_for_component (e_calendar_view_get_model (E_CALENDAR_VIEW (week_view)),
event->comp_data),
&bg_color)) {
GdkColormap *colormap;
colormap = gtk_widget_get_colormap (GTK_WIDGET (week_view));
- if (gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE))
- gdk_gc_set_foreground (gc, &bg_color);
- else
- gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND]);
- } else
- gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND]);
- gdk_draw_rectangle (drawable, gc, TRUE, rect_x, y1 + 1, rect_w, y2 – y1 – 1);
-
- gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER]);
- rect_x2 = rect_x + rect_w – 1;
- gdk_draw_line (drawable, gc, rect_x, y1, rect_x2, y1);
- gdk_draw_line (drawable, gc, rect_x, y2, rect_x2, y2);
+ if (gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE)) {
+ red = bg_color.red;
+ green = bg_color.green;
+ blue = bg_color.blue;
+ } else {
+ red = week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].red;
+ green = week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].green;
+ blue = week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].blue;
+ }
+ } else {
+ red = week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].green;
+ green = week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].green;
+ blue = week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].green;
+ }
+
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_rectangle (cr, rect_x, y1 + 1, rect_w, y2 – y1 – 1);
+ cairo_fill (cr);
+
+ cx0 = rect_x;
+ cy0 = y1 + 1;
+ rect_width = rect_w;
+ rect_height = y2 – y1 – 1;
+
+ radius = 3;
+
+ cx1 = cx0 + rect_width;
+ cy1 = cy0 + rect_height;
+
+ if (!rect_width || !rect_height)
+ return;
+ if (rect_width/2colors[E_WEEK_VIEW_COLOR_EVENT_BORDER]);
+ cairo_set_line_width (cr, 0.7);
+ cairo_move_to (cr, rect_x, y1);
+ cairo_line_to (cr, rect_x, y2);
+ cairo_stroke (cr);
+ cairo_restore (cr);
}
if (draw_end_triangle) {
e_week_view_event_item_draw_triangle (wveitem, drawable, x2 – E_WEEK_VIEW_EVENT_R_PAD – 2, y1, 3, y2 – y1 + 1);
} else {
- gdk_draw_line (drawable, gc, rect_x2, y1, rect_x2, y2);
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER]);
+ cairo_set_line_width (cr, 0.7);
+ cairo_move_to (cr, rect_x2, y2);
+ cairo_line_to (cr, rect_x2, y2);
+ cairo_stroke (cr);
+ cairo_restore (cr);
}
if (span->text_item && E_TEXT (span->text_item)->editing)
@@ -480,6 +746,7 @@ e_week_view_event_item_draw (GnomeCanvas
max_icon_x, TRUE);
}
}
+ cairo_destroy (cr);
}
@@ -542,7 +809,7 @@ e_week_view_draw_time (EWeekView *week_v
time_x,
time_y_small_font,
layout);
-
+
pango_layout_set_font_description (layout, style->font_desc);
time_x += week_view->small_digit_width * 2;
@@ -550,6 +817,7 @@ e_week_view_draw_time (EWeekView *week_v
/* Draw the ‘am’/'pm’ suffix, if 12-hour format. */
if (!e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (week_view))) {
pango_layout_set_text (layout, suffix, -1);
+
gdk_draw_layout (drawable, gc,
time_x,
time_y_normal_font,
@@ -574,7 +842,6 @@ e_week_view_draw_time (EWeekView *week_v
}
}
-
g_object_unref (layout);
}
@@ -595,6 +862,7 @@ e_week_view_event_item_draw_icons (EWeek
gboolean draw_reminder_icon = FALSE, draw_recurrence_icon = FALSE;
gboolean draw_timezone_icon = FALSE, draw_attach_icon = FALSE;
GSList *categories_list, *elem;
+ cairo_t *cr;
week_view = E_WEEK_VIEW (GTK_WIDGET (GNOME_CANVAS_ITEM (wveitem)->canvas)->parent);
@@ -604,6 +872,7 @@ e_week_view_event_item_draw_icons (EWeek
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
gc = week_view->main_gc;
+ cr = gdk_cairo_create (drawable);
if (e_cal_component_has_alarms (comp)) {
draw_reminder_icon = TRUE;
@@ -642,54 +911,40 @@ e_week_view_event_item_draw_icons (EWeek
icon_x -= icon_x_inc * num_icons;
if (draw_reminder_icon && icon_x + E_WEEK_VIEW_ICON_WIDTH reminder_icon,
- 0, 0, icon_x, icon_y,
- E_WEEK_VIEW_ICON_WIDTH,
- E_WEEK_VIEW_ICON_HEIGHT,
- GDK_RGB_DITHER_NORMAL,
- 0, 0);
+ cairo_save (cr);
+ gdk_cairo_set_source_pixbuf (cr, week_view->reminder_icon, icon_x, icon_y);
+ cairo_paint (cr);
+ cairo_restore (cr);
+
icon_x += icon_x_inc;
}
if (draw_attach_icon && icon_x + E_WEEK_VIEW_ICON_WIDTH attach_icon,
- 0, 0, icon_x, icon_y,
- E_WEEK_VIEW_ICON_WIDTH,
- E_WEEK_VIEW_ICON_HEIGHT,
- GDK_RGB_DITHER_NORMAL,
- 0, 0);
+ cairo_save (cr);
+ gdk_cairo_set_source_pixbuf (cr, week_view->attach_icon, icon_x, icon_y);
+ cairo_paint (cr);
+ cairo_restore (cr);
+
icon_x += icon_x_inc;
}
if (draw_recurrence_icon && icon_x + E_WEEK_VIEW_ICON_WIDTH recurrence_icon,
- 0, 0, icon_x, icon_y,
- E_WEEK_VIEW_ICON_WIDTH,
- E_WEEK_VIEW_ICON_HEIGHT,
- GDK_RGB_DITHER_NORMAL,
- 0, 0);
+ cairo_save (cr);
+ gdk_cairo_set_source_pixbuf (cr, week_view->recurrence_icon, icon_x, icon_y);
+ cairo_paint (cr);
+ cairo_restore (cr);
icon_x += icon_x_inc;
}
if (draw_timezone_icon && icon_x + E_WEEK_VIEW_ICON_WIDTH timezone_icon,
- 0, 0, icon_x, icon_y,
- E_WEEK_VIEW_ICON_WIDTH,
- E_WEEK_VIEW_ICON_HEIGHT,
- GDK_RGB_DITHER_NORMAL,
- 0, 0);
+ cairo_save (cr);
+ gdk_cairo_set_source_pixbuf (cr, week_view->timezone_icon, icon_x, icon_y);
+ cairo_paint (cr);
+ cairo_restore (cr);
icon_x += icon_x_inc;
}
- /* draw categories icons */
+ /* draw categories icons *//*categories has issue when cairo – ifying FIXME*/
for (elem = categories_list; elem; elem = elem->next) {
char *category;
GdkPixmap *pixmap = NULL;
@@ -738,6 +993,7 @@ e_week_view_event_item_draw_triangle (EW
GdkColor bg_color;
GdkPoint points[3];
gint c1, c2;
+ cairo_t *cr;
week_view = E_WEEK_VIEW (GTK_WIDGET (GNOME_CANVAS_ITEM (wveitem)->canvas)->parent);
@@ -745,6 +1001,7 @@ e_week_view_event_item_draw_triangle (EW
wveitem->event_num);
gc = week_view->main_gc;
+ cr = gdk_cairo_create (drawable);
points[0].x = x;
points[0].y = y;
@@ -759,16 +1016,29 @@ e_week_view_event_item_draw_triangle (EW
GdkColormap *colormap;
colormap = gtk_widget_get_colormap (GTK_WIDGET (week_view));
- if (gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE))
- gdk_gc_set_foreground (gc, &bg_color);
- else
- gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND]);
- } else
- gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND]);
+ if (gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE)) {
+ gdk_cairo_set_source_color (cr, &bg_color);
+ }
+ else {
+ gdk_cairo_set_source_color (cr, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND]);
- gdk_draw_polygon (drawable, gc, TRUE, points, 3);
+ }
+ } else {
+ gdk_cairo_set_source_color (cr, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND]);
+ }
+
+ cairo_save (cr);
+ cairo_set_line_width (cr, 0.7);
+ cairo_move_to (cr, points[0].x, points[0].y);
+ cairo_line_to (cr, points[1].x, points[1].y);
+ cairo_line_to (cr, points[2].x, points[2].y);
+ cairo_line_to (cr, points[0].x, points[0].y);
+ cairo_fill (cr);
+ cairo_restore (cr);
+
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER]);
- gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER]);
/* If the height is odd we can use the same central point for both
lines. If it is even we use different end-points. */
@@ -776,8 +1046,14 @@ e_week_view_event_item_draw_triangle (EW
if (h % 2 == 0)
c1–;
- gdk_draw_line (drawable, gc, x, y, x + w, c1);
- gdk_draw_line (drawable, gc, x, y + h – 1, x + w, c2);
+ cairo_set_line_width (cr, 0.7);
+ cairo_move_to (cr, x, y);
+ cairo_line_to (cr, x + w, c1);
+ cairo_move_to (cr, x, y + h – 1);
+ cairo_line_to (cr, x + w, c2);
+ cairo_restore (cr);
+
+ cairo_destroy (cr);
}
Index: e-week-view-main-item.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-week-view-main-item.c,v
retrieving revision 1.23
diff -u -p -r1.23 e-week-view-main-item.c
— e-week-view-main-item.c 8 Feb 2006 13:06:02 -0000 1.23
+++ e-week-view-main-item.c 12 Apr 2006 05:09:48 -0000
@@ -210,6 +210,7 @@ e_week_view_main_item_draw_day (EWeekVie
PangoFontMetrics *font_metrics;
PangoLayout *layout;
gboolean today = FALSE;
+ cairo_t *cr;
#if 0
g_print (“Drawing Day:%i at %i,%i\n”, day, x, y);
@@ -217,6 +218,7 @@ e_week_view_main_item_draw_day (EWeekVie
week_view = wvmitem->week_view;
style = gtk_widget_get_style (GTK_WIDGET (week_view));
gc = week_view->main_gc;
+ cr = gdk_cairo_create (drawable);
/* Set up Pango prerequisites */
font_desc = style->font_desc;
@@ -238,13 +240,16 @@ e_week_view_main_item_draw_day (EWeekVie
month starts (defaults are white for odd – January, March, … and
light gray for even). In the week view the background is always the
same color, the color used for the odd months in the month view. */
- if (week_view->multi_week_view && (month % 2 == 0))
+ if (week_view->multi_week_view && (month % 2 == 0))
bg_color = &week_view->colors[E_WEEK_VIEW_COLOR_EVEN_MONTHS];
- else
+ else
bg_color = &week_view->colors[E_WEEK_VIEW_COLOR_ODD_MONTHS];
- gdk_gc_set_foreground (gc, bg_color);
- gdk_draw_rectangle (drawable, gc, TRUE, x, y, width, height);
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, bg_color);
+ cairo_rectangle (cr, x, y, width, height);
+ cairo_fill (cr);
+ cairo_restore (cr);
/* Draw the lines on the right and bottom of the cell. The canvas is
sized so that the lines on the right & bottom edges will be off the
@@ -252,37 +257,44 @@ e_week_view_main_item_draw_day (EWeekVie
right_edge = x + width – 1;
bottom_edge = y + height – 1;
- gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_GRID]);
- gdk_draw_line (drawable, gc,
- right_edge, y, right_edge, bottom_edge);
- gdk_draw_line (drawable, gc,
- x, bottom_edge, right_edge, bottom_edge);
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &week_view->colors[E_WEEK_VIEW_COLOR_GRID]);
+ cairo_set_line_width (cr, 0.7);
+ cairo_move_to (cr, right_edge, y);
+ cairo_line_to (cr, right_edge, bottom_edge);
+ cairo_move_to (cr, x, bottom_edge);
+ cairo_line_to (cr, right_edge, bottom_edge);
+ cairo_stroke (cr);
+ cairo_restore (cr);
/* If the day is selected, draw the blue background. */
+ cairo_save (cr);
selected = TRUE;
if (week_view->selection_start_day == -1
|| week_view->selection_start_day > day
|| week_view->selection_end_day colors[E_WEEK_VIEW_COLOR_SELECTED]);
- else
- gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_SELECTED_UNFOCUSSED]);
-
- if (week_view->multi_week_view) {
- gdk_draw_rectangle (drawable, gc, TRUE,
- x + 2, y + 1,
+ if (GTK_WIDGET_HAS_FOCUS (week_view)) {
+ gdk_cairo_set_source_color (cr, &week_view->colors[E_WEEK_VIEW_COLOR_SELECTED]);
+ } else {
+ gdk_cairo_set_source_color (cr, &week_view->colors[E_WEEK_VIEW_COLOR_SELECTED]);
+ }
+
+ if (week_view->multi_week_view) {
+ cairo_rectangle (cr, x + 2, y + 1,
width – 5,
E_WEEK_VIEW_DATE_T_PAD – 1 +
- PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) +
- PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics)));
+ PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) +
+ PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics)));
+ cairo_fill (cr);
} else {
- gdk_draw_rectangle (drawable, gc, TRUE,
- x + 2, y + 1,
- width – 5, line_y – y);
+ cairo_rectangle (cr, x + 2, y + 1,
+ width – 5, line_y – y);
+ cairo_fill (cr);
}
- }
+ }
+ cairo_restore (cr);
/* Display the date in the top of the cell.
In the week view, display the long format “10 January” in all cells,
@@ -335,8 +347,9 @@ e_week_view_main_item_draw_day (EWeekVie
format_string = _(“%d %b”);
}
+ cairo_save (cr);
if (selected) {
- gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_DATES_SELECTED]);
+ gdk_cairo_set_source_color (cr, &week_view->colors[E_WEEK_VIEW_COLOR_DATES_SELECTED]);
} else if (week_view->multi_week_view) {
struct icaltimetype tt;
@@ -346,45 +359,58 @@ e_week_view_main_item_draw_day (EWeekVie
if (g_date_year (date) == tt.year
&& g_date_month (date) == tt.month
&& g_date_day (date) == tt.day) {
- gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_TODAY]);
+ gdk_cairo_set_source_color (cr, &week_view->colors[E_WEEK_VIEW_COLOR_TODAY]);
today = TRUE;
}
- else
- gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_DATES]);
+ else {
+ gdk_cairo_set_source_color (cr, &week_view->colors[E_WEEK_VIEW_COLOR_DATES]);
+
+ }
} else {
- gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_DATES]);
+ gdk_cairo_set_source_color (cr, &week_view->colors[E_WEEK_VIEW_COLOR_DATES]);
}
if (today) {
g_date_strftime (buffer, sizeof (buffer),
format_string ? format_string : “%d“, date);
- layout = gtk_widget_create_pango_layout (GTK_WIDGET (week_view), buffer);
+ pango_cairo_update_context (cr, pango_context);
+ layout = pango_cairo_create_layout (cr);
+ pango_font_description_set_size (font_desc, 10 * PANGO_SCALE);
+ pango_layout_set_font_description (layout, font_desc);
+ pango_layout_set_text (layout, buffer, -1);
pango_layout_set_markup (layout, buffer, strlen(buffer));
} else {
g_date_strftime (buffer, sizeof (buffer),
format_string ? format_string : “%d”, date);
- layout = gtk_widget_create_pango_layout (GTK_WIDGET (week_view), buffer);
+ pango_cairo_update_context (cr, pango_context);
+ layout = pango_cairo_create_layout (cr);
+ pango_font_description_set_size (font_desc, 10 * PANGO_SCALE);
+ pango_layout_set_font_description (layout, font_desc);
+ pango_layout_set_text (layout, buffer, -1);
}
pango_layout_get_pixel_size (layout, &date_width, NULL);
date_x = x + width – date_width – E_WEEK_VIEW_DATE_R_PAD;
date_x = MAX (date_x, x + 1);
- gdk_draw_layout (drawable, gc,
- date_x,
- y + E_WEEK_VIEW_DATE_T_PAD,
- layout);
+ cairo_translate (cr, date_x, y + E_WEEK_VIEW_DATE_T_PAD);
+ pango_cairo_update_layout (cr, layout);
+ pango_cairo_show_layout (cr, layout);
+ cairo_restore (cr);
g_object_unref (layout);
/* Draw the line under the date. */
if (!week_view->multi_week_view) {
- gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_GRID]);
- gdk_draw_line (drawable, gc,
- x + E_WEEK_VIEW_DATE_LINE_L_PAD, line_y,
- right_edge, line_y);
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &week_view->colors[E_WEEK_VIEW_COLOR_GRID]);
+ cairo_set_line_width (cr, 0.7);
+ cairo_move_to (cr, x + E_WEEK_VIEW_DATE_LINE_L_PAD, line_y);
+ cairo_line_to (cr, right_edge, line_y);
+ cairo_stroke (cr);
+ cairo_restore (cr);
}
-
pango_font_metrics_unref (font_metrics);
+ cairo_destroy (cr);
}