From e2fbfd581d4bfc223f50af93fb48667e78f4398d Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Fri, 3 Apr 1998 08:05:35 +0000 Subject: The "better" format string for strftime() wasn't better, after all :-( 1998-04-03 Federico Mena Quintero * view-utils.c (view_utils_draw_events): The "better" format string for strftime() wasn't better, after all :-( ... plus more work on progress svn path=/trunk/; revision=101 --- calendar/gui/gncal-full-day.c | 68 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 3 deletions(-) (limited to 'calendar/gui/gncal-full-day.c') diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c index 4b4820417a..ba646d5a2e 100644 --- a/calendar/gui/gncal-full-day.c +++ b/calendar/gui/gncal-full-day.c @@ -158,6 +158,9 @@ get_tm_bounds (GncalFullDay *fullday, struct tm *lower, struct tm *upper) lmin = 60 * tm_lower.tm_hour + tm_lower.tm_min; umin = 60 * tm_upper.tm_hour + tm_upper.tm_min; + if (umin == 0) /* midnight of next day? */ + umin = 60 * 24; + return (umin - lmin) / fullday->interval; /* number of rows in view */ } @@ -177,7 +180,7 @@ calc_labels_width (GncalFullDay *fullday) time_upper = mktime (&upper); while (tim < time_upper) { - strftime (buf, 256, "%R%p", &cur); + strftime (buf, 256, "%X", &cur); width = gdk_string_width (GTK_WIDGET (fullday)->style->font, buf); @@ -240,9 +243,13 @@ static void paint_back (GncalFullDay *fullday, GdkRectangle *area) { GtkWidget *widget; - GdkRectangle rect; + GdkRectangle rect, dest; int x1, y1, width, height; int labels_width, division_x; + int rows, row_height; + int i, y; + struct tm tm; + char buf[256]; widget = GTK_WIDGET (fullday); @@ -261,10 +268,24 @@ paint_back (GncalFullDay *fullday, GdkRectangle *area) widget->allocation.width, widget->allocation.height); - /* Vertical division */ + /* Clear space for labels */ labels_width = calc_labels_width (fullday); + rect.x = x1; + rect.y = y1; + rect.width = 2 * TEXT_BORDER + labels_width; + rect.height = height; + + if (gdk_rectangle_intersect (&rect, area, &dest)) + gdk_draw_rectangle (widget->window, + widget->style->bg_gc[GTK_STATE_NORMAL], + TRUE, + dest.x, dest.y, + dest.width, dest.height); + + /* Vertical division */ + division_x = x1 + 2 * TEXT_BORDER + labels_width; gtk_draw_vline (widget->style, widget->window, @@ -272,6 +293,47 @@ paint_back (GncalFullDay *fullday, GdkRectangle *area) y1, y1 + height - 1, division_x); + + /* Horizontal divisions */ + + rows = get_tm_bounds (fullday, &tm, NULL); + + row_height = height / rows; /* includes division line */ + + y = row_height; + + for (i = 1; i < rows; i++) { + gdk_draw_line (widget->window, + widget->style->black_gc, + x1, y, + x1 + width - 1, y); + + y += row_height; + } + + /* Labels */ + + y = y1 + ((row_height - 1) - (widget->style->font->ascent + widget->style->font->descent)) / 2; + + for (i = 0; i < rows; i++) { + mktime (&tm); + + if (gdk_rectangle_intersect (&rect, area, &dest)) { + strftime (buf, 256, "%X", &tm); + + gdk_draw_string (widget->window, + widget->style->font, + widget->style->fg_gc[GTK_STATE_NORMAL], + x1 + TEXT_BORDER, + y + widget->style->font->ascent, + buf); + } + + rect.y += row_height; + y += row_height; + + tm.tm_min += fullday->interval; + } } static gint -- cgit