aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@nuclecu.unam.mx>1998-04-03 16:05:35 +0800
committerArturo Espinosa <unammx@src.gnome.org>1998-04-03 16:05:35 +0800
commite2fbfd581d4bfc223f50af93fb48667e78f4398d (patch)
tree3c3fb2bf21aac5610b122405d8f355aaa034a884 /calendar
parent45a75ede7ff27645c23cd0b009bf023bea2b6d2f (diff)
downloadgsoc2013-evolution-e2fbfd581d4bfc223f50af93fb48667e78f4398d.tar
gsoc2013-evolution-e2fbfd581d4bfc223f50af93fb48667e78f4398d.tar.gz
gsoc2013-evolution-e2fbfd581d4bfc223f50af93fb48667e78f4398d.tar.bz2
gsoc2013-evolution-e2fbfd581d4bfc223f50af93fb48667e78f4398d.tar.lz
gsoc2013-evolution-e2fbfd581d4bfc223f50af93fb48667e78f4398d.tar.xz
gsoc2013-evolution-e2fbfd581d4bfc223f50af93fb48667e78f4398d.tar.zst
gsoc2013-evolution-e2fbfd581d4bfc223f50af93fb48667e78f4398d.zip
The "better" format string for strftime() wasn't better, after all :-(
1998-04-03 Federico Mena Quintero <federico@nuclecu.unam.mx> * 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
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog5
-rw-r--r--calendar/gncal-full-day.c68
-rw-r--r--calendar/gnome-cal.c16
-rw-r--r--calendar/gui/gncal-full-day.c68
-rw-r--r--calendar/gui/gnome-cal.c16
-rw-r--r--calendar/gui/view-utils.c6
-rw-r--r--calendar/view-utils.c6
7 files changed, 171 insertions, 14 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index b8a405c64f..476871c505 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,8 @@
+1998-04-03 Federico Mena Quintero <federico@nuclecu.unam.mx>
+
+ * view-utils.c (view_utils_draw_events): The "better" format
+ string for strftime() wasn't better, after all :-(
+
1998-04-02 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gncal-full-day.c: New full-day widget. It is still a work in
diff --git a/calendar/gncal-full-day.c b/calendar/gncal-full-day.c
index 4b4820417a..ba646d5a2e 100644
--- a/calendar/gncal-full-day.c
+++ b/calendar/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
diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c
index ede2e0825d..7fa7a5e40d 100644
--- a/calendar/gnome-cal.c
+++ b/calendar/gnome-cal.c
@@ -52,7 +52,21 @@ setup_widgets (GnomeCalendar *gcal)
task_view = tasks_create (gcal);
{
- day_view = gncal_full_day_new (gcal, time (NULL), time (NULL) + 86400);
+ struct tm tm;
+ time_t a, b;
+
+ tm = *localtime (&now);
+ tm.tm_hour = 0;
+ tm.tm_min = 0;
+ tm.tm_sec = 0;
+
+ a = mktime (&tm);
+
+ tm.tm_mday++;
+
+ b = mktime (&tm);
+
+ day_view = gncal_full_day_new (gcal, a, b);
}
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), day_view, gtk_label_new (_("Day View")));
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
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index ede2e0825d..7fa7a5e40d 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -52,7 +52,21 @@ setup_widgets (GnomeCalendar *gcal)
task_view = tasks_create (gcal);
{
- day_view = gncal_full_day_new (gcal, time (NULL), time (NULL) + 86400);
+ struct tm tm;
+ time_t a, b;
+
+ tm = *localtime (&now);
+ tm.tm_hour = 0;
+ tm.tm_min = 0;
+ tm.tm_sec = 0;
+
+ a = mktime (&tm);
+
+ tm.tm_mday++;
+
+ b = mktime (&tm);
+
+ day_view = gncal_full_day_new (gcal, a, b);
}
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), day_view, gtk_label_new (_("Day View")));
diff --git a/calendar/gui/view-utils.c b/calendar/gui/view-utils.c
index 0c661d9dd6..f5a3b41928 100644
--- a/calendar/gui/view-utils.c
+++ b/calendar/gui/view-utils.c
@@ -79,11 +79,11 @@ view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRect
str = ico->summary;
if (flags & VIEW_UTILS_DRAW_END) {
- strftime (buf, 512, "%R%p-", &tm_start);
+ strftime (buf, 512, "%X-", &tm_start);
len = strlen (buf);
- strftime (buf + len, 512 - len, "%R%p ", &tm_end);
+ strftime (buf + len, 512 - len, "%X ", &tm_end);
} else
- strftime (buf, 512, "%R%p ", &tm_start);
+ strftime (buf, 512, "%X ", &tm_start);
gdk_draw_string (window,
widget->style->font,
diff --git a/calendar/view-utils.c b/calendar/view-utils.c
index 0c661d9dd6..f5a3b41928 100644
--- a/calendar/view-utils.c
+++ b/calendar/view-utils.c
@@ -79,11 +79,11 @@ view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRect
str = ico->summary;
if (flags & VIEW_UTILS_DRAW_END) {
- strftime (buf, 512, "%R%p-", &tm_start);
+ strftime (buf, 512, "%X-", &tm_start);
len = strlen (buf);
- strftime (buf + len, 512 - len, "%R%p ", &tm_end);
+ strftime (buf + len, 512 - len, "%X ", &tm_end);
} else
- strftime (buf, 512, "%R%p ", &tm_start);
+ strftime (buf, 512, "%X ", &tm_start);
gdk_draw_string (window,
widget->style->font,