From 01b4ff7532756f9202336e59d2f1e401e758fcf9 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Fri, 3 Apr 1998 03:59:49 +0000 Subject: Use better format specifier for strftime(). 1998-04-02 Federico Mena Quintero * view-utils.c (view_utils_draw_events): Use better format specifier for strftime(). (view_utils_draw_textured_frame): Ultra-nifty function to draw textured "metal" frames, like Netscape's handles. HEAR YE! HEAR YE! GtkHandleBox could use this last function to draw a prettier drag handle. Any takers? svn path=/trunk/; revision=97 --- calendar/ChangeLog | 7 +++++++ calendar/gui/view-utils.c | 46 +++++++++++++++++++++++++++++++++++++++++++--- calendar/gui/view-utils.h | 2 ++ calendar/view-utils.c | 46 +++++++++++++++++++++++++++++++++++++++++++--- calendar/view-utils.h | 2 ++ 5 files changed, 97 insertions(+), 6 deletions(-) diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 560261725e..154f8a212c 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,10 @@ +1998-04-02 Federico Mena Quintero + + * view-utils.c (view_utils_draw_events): Use better format + specifier for strftime(). + (view_utils_draw_textured_frame): Ultra-nifty function to draw + textured "metal" frames, like Netscape's handles. + 1998-04-02 Miguel de Icaza * gncal-day-view.c (gncal_day_view_update): Day events are now diff --git a/calendar/gui/view-utils.c b/calendar/gui/view-utils.c index 6e8c4044dd..b13fbf7b54 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, "%X - ", &tm_start); + strftime (buf, 512, "%R%p - ", &tm_start); len = strlen (buf); - strftime (buf + len, 512 - len, "%X ", &tm_end); + strftime (buf + len, 512 - len, "%R%p ", &tm_end); } else - strftime (buf, 512, "%X ", &tm_start); + strftime (buf, 512, "%R%p ", &tm_start); gdk_draw_string (window, widget->style->font, @@ -107,3 +107,43 @@ view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRect } gdk_gc_set_clip_rectangle (gc, NULL); } + +void +view_utils_draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectangle *rect, GtkShadowType shadow) +{ + int x, y; + int xthick, ythick; + GdkGC *light_gc, *dark_gc; + + gdk_draw_rectangle (window, + widget->style->bg_gc[GTK_STATE_NORMAL], + TRUE, + rect->x, rect->y, + rect->width, rect->height); + + light_gc = widget->style->light_gc[GTK_STATE_NORMAL]; + dark_gc = widget->style->dark_gc[GTK_STATE_NORMAL]; + + xthick = widget->style->klass->xthickness; + ythick = widget->style->klass->ythickness; + + gdk_gc_set_clip_rectangle (light_gc, rect); + gdk_gc_set_clip_rectangle (dark_gc, rect); + + for (y = rect->y + ythick; y < (rect->y + rect->height - ythick); y += 3) + for (x = rect->x + xthick; x < (rect->x + rect->width - xthick); x += 6) { + gdk_draw_point (window, light_gc, x, y); + gdk_draw_point (window, dark_gc, x + 1, y + 1); + + gdk_draw_point (window, light_gc, x + 3, y + 1); + gdk_draw_point (window, dark_gc, x + 4, y + 2); + } + + gdk_gc_set_clip_rectangle (light_gc, NULL); + gdk_gc_set_clip_rectangle (dark_gc, NULL); + + gtk_draw_shadow (widget->style, window, + GTK_STATE_NORMAL, shadow, + rect->x, rect->y, + rect->width, rect->height); +} diff --git a/calendar/gui/view-utils.h b/calendar/gui/view-utils.h index ea6e885eb0..6e934c0407 100644 --- a/calendar/gui/view-utils.h +++ b/calendar/gui/view-utils.h @@ -22,5 +22,7 @@ enum { void view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRectangle *area, int flags, GList *events, time_t start, time_t end); +void view_utils_draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectangle *rect, GtkShadowType shadow); + #endif diff --git a/calendar/view-utils.c b/calendar/view-utils.c index 6e8c4044dd..b13fbf7b54 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, "%X - ", &tm_start); + strftime (buf, 512, "%R%p - ", &tm_start); len = strlen (buf); - strftime (buf + len, 512 - len, "%X ", &tm_end); + strftime (buf + len, 512 - len, "%R%p ", &tm_end); } else - strftime (buf, 512, "%X ", &tm_start); + strftime (buf, 512, "%R%p ", &tm_start); gdk_draw_string (window, widget->style->font, @@ -107,3 +107,43 @@ view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRect } gdk_gc_set_clip_rectangle (gc, NULL); } + +void +view_utils_draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectangle *rect, GtkShadowType shadow) +{ + int x, y; + int xthick, ythick; + GdkGC *light_gc, *dark_gc; + + gdk_draw_rectangle (window, + widget->style->bg_gc[GTK_STATE_NORMAL], + TRUE, + rect->x, rect->y, + rect->width, rect->height); + + light_gc = widget->style->light_gc[GTK_STATE_NORMAL]; + dark_gc = widget->style->dark_gc[GTK_STATE_NORMAL]; + + xthick = widget->style->klass->xthickness; + ythick = widget->style->klass->ythickness; + + gdk_gc_set_clip_rectangle (light_gc, rect); + gdk_gc_set_clip_rectangle (dark_gc, rect); + + for (y = rect->y + ythick; y < (rect->y + rect->height - ythick); y += 3) + for (x = rect->x + xthick; x < (rect->x + rect->width - xthick); x += 6) { + gdk_draw_point (window, light_gc, x, y); + gdk_draw_point (window, dark_gc, x + 1, y + 1); + + gdk_draw_point (window, light_gc, x + 3, y + 1); + gdk_draw_point (window, dark_gc, x + 4, y + 2); + } + + gdk_gc_set_clip_rectangle (light_gc, NULL); + gdk_gc_set_clip_rectangle (dark_gc, NULL); + + gtk_draw_shadow (widget->style, window, + GTK_STATE_NORMAL, shadow, + rect->x, rect->y, + rect->width, rect->height); +} diff --git a/calendar/view-utils.h b/calendar/view-utils.h index ea6e885eb0..6e934c0407 100644 --- a/calendar/view-utils.h +++ b/calendar/view-utils.h @@ -22,5 +22,7 @@ enum { void view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRectangle *area, int flags, GList *events, time_t start, time_t end); +void view_utils_draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectangle *rect, GtkShadowType shadow); + #endif -- cgit