aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorSrinivasa Ragavan <sragavan@src.gnome.org>2006-04-24 18:39:20 +0800
committerSrinivasa Ragavan <sragavan@src.gnome.org>2006-04-24 18:39:20 +0800
commit63351c17f7ebba7dfafd17be824212c0c6d2e583 (patch)
tree5d3eedd949568a287940ca474719ae49e8efecbd /calendar
parentd91fa3b9901e778cf7814dd3f4f69f0e80d8eef9 (diff)
downloadgsoc2013-evolution-63351c17f7ebba7dfafd17be824212c0c6d2e583.tar
gsoc2013-evolution-63351c17f7ebba7dfafd17be824212c0c6d2e583.tar.gz
gsoc2013-evolution-63351c17f7ebba7dfafd17be824212c0c6d2e583.tar.bz2
gsoc2013-evolution-63351c17f7ebba7dfafd17be824212c0c6d2e583.tar.lz
gsoc2013-evolution-63351c17f7ebba7dfafd17be824212c0c6d2e583.tar.xz
gsoc2013-evolution-63351c17f7ebba7dfafd17be824212c0c6d2e583.tar.zst
gsoc2013-evolution-63351c17f7ebba7dfafd17be824212c0c6d2e583.zip
Added Cairo support for Evolution.
svn path=/trunk/; revision=31880
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog30
-rw-r--r--calendar/gui/apps_evolution_calendar.schemas.in.in12
-rw-r--r--calendar/gui/e-calendar-view.c50
-rw-r--r--calendar/gui/e-day-view-main-item.c474
-rw-r--r--calendar/gui/e-day-view-time-item.c102
-rw-r--r--calendar/gui/e-day-view-top-item.c320
-rw-r--r--calendar/gui/e-day-view.c21
-rw-r--r--calendar/gui/e-day-view.h1
-rw-r--r--calendar/gui/e-week-view-event-item.c261
-rw-r--r--calendar/gui/e-week-view-main-item.c104
10 files changed, 967 insertions, 408 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 722978bdfa..53cf440365 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,33 @@
+2006-04-24 Srinivasa Ragavan <sragavan@novell.com>
+
+ Cairo support for Calendar (Rajeev Ramanathan)
+
+ * gui/apps_evolution_calendar.schemas.in.in: Added key for
+ transparency control.
+ * gui/e-calendar-view.c: (draw_curved_rectangle): A common code for
+ drawing curved rectangles
+ * gui/e-day-view-main-item.c: (e_day_view_main_item_draw),
+ (e_day_view_main_item_draw_events_in_vbars),
+ (e_day_view_main_item_draw_long_events_in_vbars),
+ (e_day_view_main_item_draw_day_event): Used cairo to draw day view events.
+ * gui/e-day-view-time-item.c:
+ (e_day_view_time_item_get_column_width),
+ (e_day_view_time_item_draw): Used cairo to draw day view time items.
+ * gui/e-day-view-top-item.c: (e_day_view_top_item_draw),
+ (e_day_view_top_item_draw_long_event),
+ (e_day_view_top_item_draw_triangle): Used cairo to draw day view long events.
+ * gui/e-day-view.c: (e_day_view_init), (e_day_view_destroy),
+ (e_day_view_style_set),
+ (e_day_view_reshape_main_canvas_resize_bars),
+ (e_day_view_get_num_events_selected): Used cairo to draw day controls.
+ * gui/e-day-view.h: Added a new font size variable
+ * gui/e-week-view-event-item.c: (e_week_view_event_item_draw),
+ (e_week_view_draw_time), (e_week_view_event_item_draw_icons),
+ (e_week_view_event_item_draw_triangle): Used cairo to draw week view
+ controls.
+ * gui/e-week-view-main-item.c: (e_week_view_main_item_draw_day): Used
+ cairo to draw week view events.
+
2006-04-24 Chenthill Palanisamy <pchenthill@novell.com>
Fixes #332409
diff --git a/calendar/gui/apps_evolution_calendar.schemas.in.in b/calendar/gui/apps_evolution_calendar.schemas.in.in
index 4b2c39b29a..768c7c42a8 100644
--- a/calendar/gui/apps_evolution_calendar.schemas.in.in
+++ b/calendar/gui/apps_evolution_calendar.schemas.in.in
@@ -317,6 +317,18 @@
</locale>
</schema>
+ <schema>
+ <key>/schemas/apps/evolution/calendar/display/events_transparency</key>
+ <applyto>/apps/evolution/calendar/display/events_transparency</applyto>
+ <owner>evolution-calendar</owner>
+ <type>float</type>
+ <default>1.0</default>
+ <locale name="C">
+ <short>Event Transparency</short>
+ <long>Transparency of the events in calendar views (A value between 0 and 10, opaque by default).</long>
+ </locale>
+ </schema>
+
<!-- Tasks -->
<schema>
diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c
index 3b9c0758de..f405cd80b4 100644
--- a/calendar/gui/e-calendar-view.c
+++ b/calendar/gui/e-calendar-view.c
@@ -2261,4 +2261,52 @@ e_calendar_view_get_tooltips (ECalendarViewEventData *data)
return FALSE;
}
-
+void
+draw_curved_rectangle (cairo_t *cr, double x0, double y0,
+ double rect_width, double rect_height,
+ double radius)
+{
+ double x1, y1;
+
+ x1 = x0 + rect_width;
+ y1 = y0 + rect_height;
+
+ if (!rect_width || !rect_height)
+ return;
+ if (rect_width / 2 < radius) {
+ if (rect_height / 2 < radius) {
+ cairo_move_to (cr, x0, (y0 + y1)/2);
+ cairo_curve_to (cr, x0 ,y0, x0, y0, (x0 + x1)/2, y0);
+ cairo_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1)/2);
+ cairo_curve_to (cr, x1, y1, x1, y1, (x1 + x0)/2, y1);
+ cairo_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1)/2);
+ } else {
+ cairo_move_to (cr, x0, y0 + radius);
+ cairo_curve_to (cr, x0 ,y0, x0, y0, (x0 + x1)/2, y0);
+ cairo_curve_to (cr, x1, y0, x1, y0, x1, y0 + radius);
+ cairo_line_to (cr, x1 , y1 - radius);
+ cairo_curve_to (cr, x1, y1, x1, y1, (x1 + x0)/2, y1);
+ cairo_curve_to (cr, x0, y1, x0, y1, x0, y1- radius);
+ }
+ } else {
+ if (rect_height / 2 < radius) {
+ cairo_move_to (cr, x0, (y0 + y1)/2);
+ cairo_curve_to (cr, x0 , y0, x0 , y0, x0 + radius, y0);
+ cairo_line_to (cr, x1 - radius, y0);
+ cairo_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1)/2);
+ cairo_curve_to (cr, x1, y1, x1, y1, x1 - radius, y1);
+ cairo_line_to (cr, x0 + radius, y1);
+ cairo_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1)/2);
+ } else {
+ cairo_move_to (cr, x0, y0 + radius);
+ cairo_curve_to (cr, x0 , y0, x0 , y0, x0 + radius, y0);
+ cairo_line_to (cr, x1 - radius, y0);
+ cairo_curve_to (cr, x1, y0, x1, y0, x1, y0 + radius);
+ cairo_line_to (cr, x1 , y1 - radius);
+ cairo_curve_to (cr, x1, y1, x1, y1, x1 - radius, y1);
+ cairo_line_to (cr, x0 + radius, y1);
+ cairo_curve_to (cr, x0, y1, x0, y1, x0, y1- radius);
+ }
+ }
+ cairo_close_path (cr);
+}
diff --git a/calendar/gui/e-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c
index 0522db2ce7..caa7a882cc 100644
--- a/calendar/gui/e-day-view-main-item.c
+++ b/calendar/gui/e-day-view-main-item.c
@@ -35,9 +35,11 @@
#include "e-day-view-layout.h"
#include "e-day-view-main-item.h"
#include "ea-calendar.h"
+#include "e-calendar-view.h"
#include <libecal/e-cal-time-util.h>
+#include <e-calendar-view.h>
-static void e_day_view_main_item_set_arg (GtkObject *o, GtkArg *arg,
+static void e_day_view_main_item_set_arg (GtkObject *o, GtkArg *arg ,
guint arg_id);
static void e_day_view_main_item_update (GnomeCanvasItem *item,
double *affine,
@@ -167,7 +169,9 @@ e_day_view_main_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable,
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,8 +183,8 @@ e_day_view_main_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable,
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;
+ 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 < day_view->days_shown; day++) {
@@ -194,23 +198,37 @@ e_day_view_main_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable,
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 +254,23 @@ e_day_view_main_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable,
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 +278,21 @@ e_day_view_main_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable,
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 < day_view->rows && row_y < height;
row++, row_y += day_view->row_height) {
- if (row_y >= 0 && row_y < height)
- gdk_draw_line (drawable, gc,
- grid_x1, row_y, grid_x2, row_y);
+ if (row_y >= 0 && row_y < height) {
+ cairo_set_line_width (cr, 0.7);
+ cairo_move_to (cr, grid_x1, row_y);
+ cairo_line_to (cr, grid_x2, row_y);
+ cairo_stroke (cr);
+ }
}
+ cairo_restore (cr);
/* Draw the vertical bars down the left of each column. */
grid_y1 = 0;
@@ -269,15 +304,30 @@ e_day_view_main_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable,
if (grid_x1 >= width || grid_x1 + E_DAY_VIEW_BAR_WIDTH <= 0)
continue;
- gdk_draw_line (drawable, style->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 +356,16 @@ e_day_view_main_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable,
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 +381,15 @@ e_day_view_main_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable,
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 +402,19 @@ e_day_view_main_item_draw_events_in_vbars (EDayViewMainItem *dvmitem,
{
EDayView *day_view;
EDayViewEvent *event;
- GdkGC *gc;
gint grid_x, event_num, bar_y, bar_h;
ECalComponentTransparency transparency;
-
+ cairo_t *cr;
+ GdkColor bg_color;
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]);
+
+ gdk_cairo_set_source_color (cr,
+ &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND]);
grid_x = day_view->day_offsets[day] + 1 - x;
@@ -366,6 +425,17 @@ e_day_view_main_item_draw_events_in_vbars (EDayViewMainItem *dvmitem,
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
+ 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_cairo_set_source_color (cr,
+ &bg_color);
+ }
+ }
+
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
@@ -388,12 +458,15 @@ e_day_view_main_item_draw_events_in_vbars (EDayViewMainItem *dvmitem,
if (bar_y >= height || bar_y + bar_h <= 0)
continue;
- gdk_draw_rectangle (drawable, gc, TRUE,
- grid_x, bar_y,
- E_DAY_VIEW_BAR_WIDTH - 2, bar_h);
+ cairo_rectangle (cr, grid_x, bar_y,
+ E_DAY_VIEW_BAR_WIDTH - 2, bar_h);
+
+ cairo_fill (cr);
g_object_unref (comp);
}
+ cairo_restore (cr);
+ cairo_destroy (cr);
}
@@ -406,13 +479,17 @@ e_day_view_main_item_draw_long_events_in_vbars (EDayViewMainItem *dvmitem,
EDayView *day_view;
EDayViewEvent *event;
gint event_num, start_day, end_day, day, bar_y1, bar_y2, grid_x;
- GdkGC *gc;
ECalComponentTransparency transparency;
+ cairo_t *cr;
+ GdkColor *bg_color;
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_BACKGROUND]);
for (event_num = 0; event_num < day_view->long_events->len;
event_num++) {
@@ -420,6 +497,16 @@ e_day_view_main_item_draw_long_events_in_vbars (EDayViewMainItem *dvmitem,
event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
+ 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_cairo_set_source_color (cr,
+ &bg_color);
+ }
+ }
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
@@ -456,16 +543,16 @@ e_day_view_main_item_draw_long_events_in_vbars (EDayViewMainItem *dvmitem,
}
if (bar_y1 < height && bar_y2 > 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);
}
@@ -488,7 +575,6 @@ e_day_view_main_item_draw_day_events (EDayViewMainItem *dvmitem,
}
}
-
static void
e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
GdkDrawable *drawable,
@@ -507,17 +593,31 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
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, rect_height, rect_width;
+ gfloat alpha;
+ 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;
+
+ alpha = gconf_client_get_float (gconf_client_get_default (),
+ "/apps/evolution/calendar/display/events_transparency",
+ NULL);
+
/* 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 +633,108 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
/* 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*/
- 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;
+ }
}
-#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);
+ /* Draw the background of the event with white to play with transparency */
+ cairo_save (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.;
+
+ radius = 16;
+
+ draw_curved_rectangle (cr, x0, y0, rect_width, rect_height, radius);
+
+ cairo_set_source_rgba (cr, 1, 1, 1, alpha);
+ cairo_fill (cr);
+
+ cairo_restore (cr);
+
+ /* second inner border */
+ cairo_save (cr);
+
+ x0 = item_x + E_DAY_VIEW_BAR_WIDTH + 1.;
+ y0 = item_y + 2.;
+ rect_width = item_w - E_DAY_VIEW_BAR_WIDTH - 3.;
+ rect_height = item_h - 4.;
+
+ radius = 12;
+
+ draw_curved_rectangle (cr, x0, y0, rect_width, rect_height, radius);
+ cairo_set_source_rgba (cr, red/cc, green/cc, blue/cc, 0);
+ cairo_set_line_width (cr, 0.6);
+ cairo_stroke (cr);
+ cairo_restore (cr);
+
+ /* Here we draw the border in event color */
+ cairo_save (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.;
+
+ radius = 16;
+
+ draw_curved_rectangle (cr, x0, y0, rect_width,rect_height, radius);
+ cairo_set_line_width (cr, 1.0);
+ cairo_set_source_rgb (cr, red/cc, green/cc, blue/cc);
+ cairo_stroke (cr);
+ cairo_restore (cr);
+
+ /* Fill in the Event */
+
+ cairo_save (cr);
- gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]);
+ x0 = item_x + E_DAY_VIEW_BAR_WIDTH + 1.5;
+ y0 = item_y + 2.5;
+ rect_width = item_w - E_DAY_VIEW_BAR_WIDTH - 4.;
+ rect_height = item_h - 5.;
+ radius = 14;
+
+ draw_curved_rectangle (cr, x0, y0, rect_width, rect_height, radius);
+
+ pat = cairo_pattern_create_linear (item_x + E_DAY_VIEW_BAR_WIDTH + 2.5, item_y + 3.5,
+ item_x + E_DAY_VIEW_BAR_WIDTH + 2.5, item_y + item_h - 4);
+ cairo_pattern_add_color_stop_rgba (pat, 1, red/cc, green/cc, blue/cc, 0.8);
+ cairo_pattern_add_color_stop_rgba (pat, 0, red/cc, green/cc, blue/cc, 0.4);
+ cairo_set_source (cr, pat);
+ cairo_fill (cr);
+ cairo_pattern_destroy (pat);
+ cairo_restore (cr);
+
/* Draw the right edge of the vertical bar. */
- gdk_gc_set_foreground (gc, &day_view->colors[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 +757,53 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
/* 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.5, 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);
+
+ /* This is for achieving the white stripes in vbar across event color */
+ for (i = 0; i <= (bar_y2 - bar_y1) ; i+=4) {
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_set_line_width (cr, 0.3);
+ cairo_move_to (cr, item_x + 1, bar_y1 + i);
+ cairo_line_to (cr, item_x + E_DAY_VIEW_BAR_WIDTH - 1, bar_y1 + i);
+ cairo_stroke (cr);
+ }
}
- /* Draw the box around the entire event. Do this after drawing
- the colored bar so we don't have to worry about being 1
- pixel out. */
- gdk_gc_set_foreground (gc, &day_view->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 +869,11 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
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 +883,12 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
- 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 +898,10 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
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 +911,11 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
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 +927,11 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
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 +976,7 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
/* free memory */
e_cal_component_free_categories_list (categories_list);
g_object_unref (comp);
+ cairo_destroy (cr);
}
diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c
index 4c2ed4d63c..015356af6f 100644
--- a/calendar/gui/e-day-view-time-item.c
+++ b/calendar/gui/e-day-view-time-item.c
@@ -178,6 +178,7 @@ e_day_view_time_item_get_column_width (EDayViewTimeItem *dvtmitem)
gint digit, large_digit_width, max_large_digit_width = 0;
gint max_suffix_width, max_minute_or_suffix_width;
gint column_width_default, column_width_60_min_rows;
+ cairo_t *cr;
day_view = dvtmitem->day_view;
g_return_val_if_fail (day_view != NULL, 0);
@@ -198,6 +199,7 @@ e_day_view_time_item_get_column_width (EDayViewTimeItem *dvtmitem)
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 +230,6 @@ e_day_view_time_item_get_column_width (EDayViewTimeItem *dvtmitem)
dvtmitem->column_width = MAX (column_width_default,
column_width_60_min_rows);
-
return dvtmitem->column_width;
}
@@ -248,7 +249,6 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item,
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 +260,10 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item,
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 +278,8 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item,
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 +337,25 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item,
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 +382,14 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item,
/* 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 +399,16 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item,
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 +417,40 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item,
/* 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 +467,17 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item,
"%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 +488,7 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item,
pango_font_metrics_unref (large_font_metrics);
pango_font_metrics_unref (small_font_metrics);
+ cairo_destroy (cr);
}
diff --git a/calendar/gui/e-day-view-top-item.c b/calendar/gui/e-day-view-top-item.c
index bfdc31bbd9..f953c605f9 100644
--- a/calendar/gui/e-day-view-top-item.c
+++ b/calendar/gui/e-day-view-top-item.c
@@ -34,6 +34,7 @@
#include "e-util/e-categories-config.h"
#include <libecal/e-cal-time-util.h>
#include <libedataserver/e-data-server-util.h>
+#include "e-calendar-view.h"
#include "e-day-view-top-item.h"
static void e_day_view_top_item_set_arg (GtkObject *o,
@@ -164,6 +165,8 @@ e_day_view_top_item_draw (GnomeCanvasItem *canvas_item,
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 +176,8 @@ e_day_view_top_item_draw (GnomeCanvasItem *canvas_item,
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 +189,47 @@ e_day_view_top_item_draw (GnomeCanvasItem *canvas_item,
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 +247,12 @@ e_day_view_top_item_draw (GnomeCanvasItem *canvas_item,
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 +265,7 @@ e_day_view_top_item_draw (GnomeCanvasItem *canvas_item,
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 +282,32 @@ e_day_view_top_item_draw (GnomeCanvasItem *canvas_item,
/* 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,9 +318,9 @@ e_day_view_top_item_draw (GnomeCanvasItem *canvas_item,
drawable,
x, y, width, height);
}
+ cairo_destroy (cr);
}
-
/* This draws one event in the top canvas. */
static void
e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
@@ -320,8 +348,20 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
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;
+ gfloat alpha;
+ gdouble x0, y0, rect_height, rect_width, radius;
day_view = dvtitem->day_view;
+ cr = gdk_cairo_create (drawable);
+
+ alpha = gconf_client_get_float (gconf_client_get_default (),
+ "/apps/evolution/calendar/display/events_transparency",
+ NULL);
/* If the event is currently being dragged, don't draw it. It will
be drawn in the special drag items. */
@@ -341,34 +381,102 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
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)),
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);
- 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;
+ }
+
+ /* Fill the background with white to play with transparency */
+ cairo_save (cr);
+ x0 = item_x - x + 2;
+ y0 = item_y + 1 - y;
+ rect_width = item_w - 5;
+ rect_height = item_h - 2;
+
+ radius = 12;
+
+ draw_curved_rectangle (cr, x0, y0, rect_width, rect_height, radius);
+
+ cairo_set_source_rgba (cr, 1, 1, 1, alpha);
+ cairo_fill_preserve (cr);
+
+ cairo_restore (cr);
+
+ /* Draw the border around the event */
+
+ cairo_save (cr);
+ x0 = item_x - x + 2;
+ y0 = item_y + 1 - y;
+ rect_width = item_w - 5;
+ rect_height = item_h - 2;
+
+ radius = 12;
+
+ draw_curved_rectangle (cr, x0, y0, rect_width, rect_height, radius);
+
+ cairo_set_source_rgba (cr, 1, 1, 1, alpha);
+ cairo_fill_preserve (cr);
+
+ cairo_set_source_rgb (cr, red/cc, green/cc, blue/cc);
+ cairo_set_line_width (cr, 1.0);
+ cairo_stroke (cr);
+ cairo_restore (cr);
+
+ /* Fill in with gradient */
+
+ cairo_save (cr);
+
+ x0 = item_x - x + 3.75;
+ y0 = item_y + 2.75 - y;
+ rect_width = item_w - 8.5;
+ rect_height = item_h - 5.5;
+
+ radius = 6;
+
+ draw_curved_rectangle (cr, x0, y0, rect_width, rect_height, radius);
+
+ pat = cairo_pattern_create_linear (item_x - x, item_y + 1 - y,
+ item_x - x , item_y - y + item_h - 1);
+ cairo_pattern_add_color_stop_rgba (pat, 1, red/cc, green/cc, blue/cc, 0.8);
+ cairo_pattern_add_color_stop_rgba (pat, 0, red/cc, green/cc, blue/cc, 0.4);
+ cairo_set_source (cr, pat);
+ cairo_fill_preserve (cr);
+ cairo_pattern_destroy (pat);
+
+ cairo_set_source_rgba (cr, red/cc, green/cc, blue/cc, 0);
+ cairo_set_line_width (cr, 0.5);
+ cairo_stroke (cr);
+ cairo_restore (cr);
/* When resizing we don't draw the triangles.*/
draw_start_triangle = TRUE;
@@ -392,10 +500,12 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
-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 - 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 +517,12 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
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 +631,32 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
+ E_DAY_VIEW_ICON_Y_PAD - y;
if (icon_x <= max_icon_x && (e_cal_component_has_recurrences (comp) || e_cal_component_is_instance (comp))) {
- gdk_gc_set_clip_mask (gc, NULL);
- gdk_draw_pixbuf (drawable, gc,
- day_view->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 <= max_icon_x && e_cal_component_has_attachments (comp)) {
- gdk_gc_set_clip_mask (gc, NULL);
- gdk_draw_pixbuf (drawable, gc,
- day_view->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 <= max_icon_x && e_cal_component_has_alarms (comp)) {
- gdk_gc_set_clip_mask (gc, NULL);
- gdk_draw_pixbuf (drawable, gc,
- day_view->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 +687,7 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
e_cal_component_free_categories_list (categories_list);
g_object_unref (comp);
-
+ cairo_destroy (cr);
gdk_gc_set_clip_mask (gc, NULL);
}
@@ -608,6 +709,9 @@ e_day_view_top_item_draw_triangle (EDayViewTopItem *dvtitem,
GdkColor bg_color;
GdkPoint points[3];
gint c1, c2;
+ cairo_t *cr;
+
+ cr = gdk_cairo_create (drawable);
day_view = dvtitem->day_view;
@@ -628,7 +732,7 @@ e_day_view_top_item_draw_triangle (EDayViewTopItem *dvtitem,
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 +740,32 @@ e_day_view_top_item_draw_triangle (EDayViewTopItem *dvtitem,
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);
}
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index f58502946d..75744d2347 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -1,5 +1,4 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
/*
* Authors :
* Damon Chaplin <damon@ximian.com>
@@ -78,6 +77,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 +739,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");
@@ -893,7 +894,7 @@ e_day_view_init (EDayView *day_view)
day_view->drag_rect_item =
gnome_canvas_item_new (canvas_group,
- gnome_canvas_rect_get_type (),
+ gnome_canvas_rect_get_type (),
"width_pixels", 1,
NULL);
gnome_canvas_item_hide (day_view->drag_rect_item);
@@ -1033,6 +1034,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 +1260,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 =
@@ -4671,6 +4685,7 @@ e_day_view_reshape_main_canvas_resize_bars (EDayView *day_view)
"x2", x + w - 1,
"y2", y + h + E_DAY_VIEW_BAR_HEIGHT - 1,
NULL);
+
gnome_canvas_item_show (day_view->main_canvas_bottom_resize_bar_item);
}
@@ -7788,5 +7803,3 @@ e_day_view_get_num_events_selected (EDayView *day_view)
return (day_view->editing_event_day != -1) ? 1 : 0;
}
-
-
diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h
index d137332a88..351bcd1039 100644
--- a/calendar/gui/e-day-view.h
+++ b/calendar/gui/e-day-view.h
@@ -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;
diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c
index d671b2e876..0aa69c3530 100644
--- a/calendar/gui/e-week-view-event-item.c
+++ b/calendar/gui/e-week-view-event-item.c
@@ -36,6 +36,8 @@
#include "e-week-view-event-item.h"
#include <gtk/gtksignal.h>
+#include "e-calendar-view.h"
+
#include <text/e-text.h>
static void e_week_view_event_item_set_arg (GtkObject *o,
@@ -202,7 +204,6 @@ e_week_view_event_item_update (GnomeCanvasItem *item,
}
}
-
/*
* DRAWING ROUTINES - functions to paint the canvas item.
*/
@@ -229,6 +230,11 @@ e_week_view_event_item_draw (GnomeCanvasItem *canvas_item,
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, 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 +245,8 @@ e_week_view_event_item_draw (GnomeCanvasItem *canvas_item,
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 +292,66 @@ e_week_view_event_item_draw (GnomeCanvasItem *canvas_item,
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;
-
+
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;
+ }
+
+ /* Here we draw the border around the event*/
+ cairo_save (cr);
+
+ cx0 = rect_x;
+ cy0 = y1 + 1;
+ rect_width = rect_w;
+ rect_height = y2 - y1 - 1;
+
+ radius = 12;
+
+ draw_curved_rectangle (cr, cx0, cy0, rect_width, rect_height, radius);
+
+ cairo_set_line_width (cr, 1.0);
+ cairo_set_source_rgb (cr, red/cc, green/cc, blue/cc);
+ cairo_stroke (cr);
+ cairo_restore (cr);
+
+ /* Fill it in the Event */
+
+ cairo_save (cr);
+
+ cx0 = rect_x + 2;
+ cy0 = y1 + 2.75;
+ rect_width = rect_w - 3.5;
+ rect_height = y2 - y1 - 4.5;
+
+ radius = 6;
+
+ draw_curved_rectangle (cr, cx0, cy0, rect_width, rect_height, radius);
+
+ pat = cairo_pattern_create_linear (rect_x + 2, y1 + 1,
+ rect_x + 2, y2 - 7.25);
+ cairo_pattern_add_color_stop_rgba (pat, 1, red/cc, green/cc, blue/cc, 0.8);
+ cairo_pattern_add_color_stop_rgba (pat, 0, red/cc, green/cc, blue/cc, 0.4);
+ cairo_set_source (cr, pat);
+ cairo_fill (cr);
+ cairo_pattern_destroy (pat);
+ cairo_restore (cr);
/* Draw the start and end times, as required. */
switch (week_view->time_format) {
@@ -375,35 +423,94 @@ e_week_view_event_item_draw (GnomeCanvasItem *canvas_item,
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]);
+ 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;
+ }
+
+ /* Here we draw the border around the event */
+
+ cx0 = rect_x;
+ cy0 = y1 + 1;
+ rect_width = rect_w;
+ rect_height = y2 - y1 - 1;
+
+ radius = 12;
+
+ draw_curved_rectangle (cr, cx0, cy0, rect_width, rect_height, radius);
+
+ cairo_set_line_width (cr, 1.0);
+ cairo_set_source_rgb (cr, red/cc, green/cc, blue/cc);
+ cairo_stroke (cr);
+ cairo_restore (cr);
+
+ /* Here we fill it in the event*/
+
+ cairo_save (cr);
+ cx0 = rect_x + 2;
+ cy0 = y1 + 2.75;
+ rect_width = rect_w - 3.5;
+ rect_height = y2 - y1 - 4.5;
+
+ radius = 6;
+
+ draw_curved_rectangle (cr, cx0, cy0, rect_width, rect_height, radius);
+
+ pat = cairo_pattern_create_linear (rect_x + 1, y1 + 1,
+ rect_x + 1, y2);
+ cairo_pattern_add_color_stop_rgba (pat, 1, red/cc, green/cc, blue/cc, 0.8);
+ cairo_pattern_add_color_stop_rgba (pat, 0, red/cc, green/cc, blue/cc, 0.4);
+ cairo_set_source (cr, pat);
+ cairo_fill_preserve (cr);
+ cairo_pattern_destroy (pat);
+ cairo_restore (cr);
+
+ gdk_cairo_set_source_color (cr, &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);
+ cairo_move_to (cr, rect_x, y1);
+ cairo_line_to (cr, rect_x2, y1);
+ cairo_move_to (cr, rect_x, y2);
+ cairo_line_to (cr, rect_x2, y2);
if (draw_start_triangle) {
e_week_view_event_item_draw_triangle (wveitem, drawable, x1 + E_WEEK_VIEW_EVENT_L_PAD + 2, y1, -3, y2 - y1 + 1);
} else {
- gdk_draw_line (drawable, gc, rect_x, y1, rect_x, 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_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 +587,7 @@ e_week_view_event_item_draw (GnomeCanvasItem *canvas_item,
max_icon_x, TRUE);
}
}
+ cairo_destroy (cr);
}
@@ -542,7 +650,7 @@ e_week_view_draw_time (EWeekView *week_view,
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 +658,7 @@ e_week_view_draw_time (EWeekView *week_view,
/* 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 +683,6 @@ e_week_view_draw_time (EWeekView *week_view,
}
}
-
g_object_unref (layout);
}
@@ -595,6 +703,7 @@ e_week_view_event_item_draw_icons (EWeekViewEventItem *wveitem,
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 +713,7 @@ e_week_view_event_item_draw_icons (EWeekViewEventItem *wveitem,
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,50 +752,36 @@ e_week_view_event_item_draw_icons (EWeekViewEventItem *wveitem,
icon_x -= icon_x_inc * num_icons;
if (draw_reminder_icon && icon_x + E_WEEK_VIEW_ICON_WIDTH <= x2) {
- gdk_gc_set_clip_mask (gc, NULL);
- gdk_draw_pixbuf (drawable, gc,
- week_view->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 <= x2) {
- gdk_gc_set_clip_mask (gc, NULL);
- gdk_draw_pixbuf (drawable, gc,
- week_view->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 <= x2) {
- gdk_gc_set_clip_mask (gc, NULL);
- gdk_draw_pixbuf (drawable, gc,
- week_view->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 <= x2) {
- gdk_gc_set_clip_mask (gc, NULL);
- gdk_draw_pixbuf (drawable, gc,
- week_view->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;
}
@@ -738,6 +834,7 @@ e_week_view_event_item_draw_triangle (EWeekViewEventItem *wveitem,
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 +842,7 @@ e_week_view_event_item_draw_triangle (EWeekViewEventItem *wveitem,
wveitem->event_num);
gc = week_view->main_gc;
+ cr = gdk_cairo_create (drawable);
points[0].x = x;
points[0].y = y;
@@ -759,16 +857,29 @@ e_week_view_event_item_draw_triangle (EWeekViewEventItem *wveitem,
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]);
+
+ }
+ } else {
+ gdk_cairo_set_source_color (cr, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND]);
+ }
- gdk_draw_polygon (drawable, gc, TRUE, points, 3);
+ 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 +887,14 @@ e_week_view_event_item_draw_triangle (EWeekViewEventItem *wveitem,
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);
}
diff --git a/calendar/gui/e-week-view-main-item.c b/calendar/gui/e-week-view-main-item.c
index ca6812b463..32ac8546aa 100644
--- a/calendar/gui/e-week-view-main-item.c
+++ b/calendar/gui/e-week-view-main-item.c
@@ -210,6 +210,7 @@ e_week_view_main_item_draw_day (EWeekViewMainItem *wvmitem,
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 (EWeekViewMainItem *wvmitem,
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 (EWeekViewMainItem *wvmitem,
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 (EWeekViewMainItem *wvmitem,
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 < day)
selected = FALSE;
if (selected) {
- if (GTK_WIDGET_HAS_FOCUS (week_view))
- gdk_gc_set_foreground (gc, &week_view->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 (EWeekViewMainItem *wvmitem,
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 (EWeekViewMainItem *wvmitem,
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 : "<b>%d</b>", 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);
}