aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/e-day-view-top-item.c
diff options
context:
space:
mode:
authorDamon Chaplin <damon@helixcode.com>2000-11-29 08:19:44 +0800
committerDamon Chaplin <damon@src.gnome.org>2000-11-29 08:19:44 +0800
commite1635ef07ac4dbbb2511a01ed32ef096399d11fb (patch)
treeb2dd3c3596335e2ad97bfd863fb54242beadf467 /calendar/gui/e-day-view-top-item.c
parent2eabc063bc04b4c2cd74b6829f939b036f937792 (diff)
downloadgsoc2013-evolution-e1635ef07ac4dbbb2511a01ed32ef096399d11fb.tar.gz
gsoc2013-evolution-e1635ef07ac4dbbb2511a01ed32ef096399d11fb.tar.zst
gsoc2013-evolution-e1635ef07ac4dbbb2511a01ed32ef096399d11fb.zip
finished 12-hour support and tried to tidy up & comment the drawing code
2000-11-28 Damon Chaplin <damon@helixcode.com> * gui/e-day-view*.[hc]: * gui/e-week-view*.[hc]: finished 12-hour support and tried to tidy up & comment the drawing code in places. Also fixed a couple of bugs I spotted. All the options on the 'Calendar' page should now work. svn path=/trunk/; revision=6706
Diffstat (limited to 'calendar/gui/e-day-view-top-item.c')
-rw-r--r--calendar/gui/e-day-view-top-item.c119
1 files changed, 79 insertions, 40 deletions
diff --git a/calendar/gui/e-day-view-top-item.c b/calendar/gui/e-day-view-top-item.c
index 8a85983592..a9ece2cc50 100644
--- a/calendar/gui/e-day-view-top-item.c
+++ b/calendar/gui/e-day-view-top-item.c
@@ -340,7 +340,9 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
gint text_x, icon_x, icon_y, icon_x_inc;
CalComponent *comp;
gchar buffer[16];
- gint hour, minute, offset, time_width, time_x, min_end_time_x;
+ gint hour, display_hour, minute, offset, time_width, time_x;
+ gint min_end_time_x, suffix_width, max_icon_x;
+ gchar *suffix;
gboolean draw_start_triangle, draw_end_triangle;
GdkRectangle clip_rect;
@@ -435,45 +437,28 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
to take the scroll offset into account. It will always be 0. */
text_x = event->canvas_item->x1;
- /* Draw the icons. */
- icon_x_inc = E_DAY_VIEW_ICON_WIDTH + E_DAY_VIEW_ICON_X_PAD;
- icon_x = text_x - icon_x_inc - x;
- icon_y = item_y + 1 + E_DAY_VIEW_ICON_Y_PAD - y;
-
- if (cal_component_has_recurrences (comp)) {
- gdk_gc_set_clip_origin (gc, icon_x, icon_y);
- gdk_gc_set_clip_mask (gc, day_view->recurrence_mask);
- gdk_draw_pixmap (drawable, gc,
- day_view->recurrence_icon,
- 0, 0, icon_x, icon_y,
- E_DAY_VIEW_ICON_WIDTH,
- E_DAY_VIEW_ICON_HEIGHT);
- icon_x -= icon_x_inc;
- }
-
- if (cal_component_has_alarms (comp)) {
- gdk_gc_set_clip_origin (gc, icon_x, icon_y);
- gdk_gc_set_clip_mask (gc, day_view->reminder_mask);
- gdk_draw_pixmap (drawable, gc,
- day_view->reminder_icon,
- 0, 0, icon_x, icon_y,
- E_DAY_VIEW_ICON_WIDTH,
- E_DAY_VIEW_ICON_HEIGHT);
- icon_x -= icon_x_inc;
- }
- gdk_gc_set_clip_mask (gc, NULL);
-
- /* Draw the start & end times, if necessary.
- Note that GtkLabel adds 1 to the ascent so we must do that to be
- level with it. */
+ /* Draw the start & end times, if necessary. */
min_end_time_x = item_x + E_DAY_VIEW_LONG_EVENT_X_PAD - x;
+ time_width = e_day_view_get_time_string_width (day_view);
+
if (event->start > day_view->day_starts[start_day]) {
offset = day_view->first_hour_shown * 60
+ day_view->first_minute_shown + event->start_minute;
hour = offset / 60;
minute = offset % 60;
- sprintf (buffer, "%02i:%02i", hour, minute);
+ /* Calculate the actual hour number to display. For 12-hour
+ format we convert 0-23 to 12-11am/12-11pm. */
+ e_day_view_convert_time_to_display (day_view, hour,
+ &display_hour,
+ &suffix, &suffix_width);
+ if (day_view->use_24_hour_format) {
+ g_snprintf (buffer, sizeof (buffer), "%2i:%02i",
+ display_hour, minute);
+ } else {
+ g_snprintf (buffer, sizeof (buffer), "%2i:%02i%s",
+ display_hour, minute, suffix);
+ }
clip_rect.x = item_x - x;
clip_rect.y = item_y - y;
@@ -481,36 +466,90 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
clip_rect.height = item_h;
gdk_gc_set_clip_rectangle (fg_gc, &clip_rect);
+ time_x = item_x + E_DAY_VIEW_LONG_EVENT_X_PAD - x;
+ if (hour < 10)
+ time_x += day_view->digit_width;
+
gdk_draw_string (drawable, font, fg_gc,
- item_x + E_DAY_VIEW_LONG_EVENT_X_PAD - x,
- item_y + E_DAY_VIEW_LONG_EVENT_Y_PAD + font->ascent + 1 - y,
+ time_x,
+ item_y + E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT
+ + E_DAY_VIEW_LONG_EVENT_Y_PAD
+ + font->ascent - y,
buffer);
gdk_gc_set_clip_rectangle (fg_gc, NULL);
- min_end_time_x += day_view->small_hour_widths[hour] + 2
- + day_view->max_minute_width + day_view->colon_width;
+ min_end_time_x += time_width
+ + E_DAY_VIEW_LONG_EVENT_TIME_X_PAD;
}
+ max_icon_x = item_x + item_w - E_DAY_VIEW_LONG_EVENT_X_PAD
+ - E_DAY_VIEW_ICON_WIDTH;
+
if (event->end < day_view->day_starts[end_day + 1]) {
offset = day_view->first_hour_shown * 60
+ day_view->first_minute_shown
+ event->end_minute;
hour = offset / 60;
minute = offset % 60;
- time_width = day_view->small_hour_widths[hour]
- + day_view->max_minute_width + day_view->colon_width;
time_x = item_x + item_w - E_DAY_VIEW_LONG_EVENT_X_PAD - time_width - E_DAY_VIEW_LONG_EVENT_TIME_X_PAD - x;
if (time_x >= min_end_time_x) {
- sprintf (buffer, "%02i:%02i", hour, minute);
+ /* Calculate the actual hour number to display. */
+ e_day_view_convert_time_to_display (day_view, hour,
+ &display_hour,
+ &suffix,
+ &suffix_width);
+ if (day_view->use_24_hour_format) {
+ g_snprintf (buffer, sizeof (buffer),
+ "%2i:%02i", display_hour, minute);
+ } else {
+ g_snprintf (buffer, sizeof (buffer),
+ "%2i:%02i%s", display_hour, minute,
+ suffix);
+ }
+
+ if (hour < 10)
+ time_x += day_view->digit_width;
+
gdk_draw_string (drawable, font, fg_gc,
time_x,
item_y + E_DAY_VIEW_LONG_EVENT_Y_PAD
+ font->ascent + 1 - y,
buffer);
+
+ max_icon_x -= time_width + E_DAY_VIEW_LONG_EVENT_TIME_X_PAD;
}
}
+
+ /* Draw the icons. */
+ icon_x_inc = E_DAY_VIEW_ICON_WIDTH + E_DAY_VIEW_ICON_X_PAD;
+ icon_x = text_x - icon_x_inc - x;
+ icon_y = item_y + E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT
+ + E_DAY_VIEW_ICON_Y_PAD - y;
+
+ if (icon_x <= max_icon_x && cal_component_has_recurrences (comp)) {
+ gdk_gc_set_clip_origin (gc, icon_x, icon_y);
+ gdk_gc_set_clip_mask (gc, day_view->recurrence_mask);
+ gdk_draw_pixmap (drawable, gc,
+ day_view->recurrence_icon,
+ 0, 0, icon_x, icon_y,
+ E_DAY_VIEW_ICON_WIDTH,
+ E_DAY_VIEW_ICON_HEIGHT);
+ icon_x -= icon_x_inc;
+ }
+
+ if (icon_x <= max_icon_x && cal_component_has_alarms (comp)) {
+ gdk_gc_set_clip_origin (gc, icon_x, icon_y);
+ gdk_gc_set_clip_mask (gc, day_view->reminder_mask);
+ gdk_draw_pixmap (drawable, gc,
+ day_view->reminder_icon,
+ 0, 0, icon_x, icon_y,
+ E_DAY_VIEW_ICON_WIDTH,
+ E_DAY_VIEW_ICON_HEIGHT);
+ icon_x -= icon_x_inc;
+ }
+ gdk_gc_set_clip_mask (gc, NULL);
}