From: Andrea Zagli Date: Mon, 1 Nov 2010 09:26:53 +0000 (+0100) Subject: Draft of the day view. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=4e399b9bbc4905b9e45f1301f6c415f962c08faa;p=libgtkcalendarex Draft of the day view. --- diff --git a/src/gtkcalex.c b/src/gtkcalex.c index 121993f..67a18a4 100644 --- a/src/gtkcalex.c +++ b/src/gtkcalex.c @@ -59,6 +59,8 @@ static void gtk_calex_size_request (GtkWidget *widget, static void gtk_calex_size_allocate (GtkWidget *widget, GtkAllocation *allocation); +static void gtk_calex_draw_day (GtkCalEx *gtk_calex); + #define GTK_CALEX_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_CALEX, GtkCalExPrivate)) @@ -119,19 +121,13 @@ gtk_calex_init (GtkCalEx *gtk_calex) priv->goo_canvas_root = goo_canvas_get_root_item (GOO_CANVAS (priv->goo_canvas)); - goo_canvas_rect_new (priv->goo_canvas_root, 100, 100, 400, 400, - "line-width", 10.0, - "radius-x", 20.0, - "radius-y", 10.0, - "stroke-color", "yellow", - "fill-color", "red", - NULL); - priv->view_type = GTK_CALEX_VIEW_TYPE_DAY; priv->date = g_date_new (); g_get_current_time (&tval); g_date_set_time_val (priv->date, &tval); + + gtk_calex_draw_day (gtk_calex); } static void @@ -401,3 +397,43 @@ gtk_calex_size_allocate (GtkWidget *widget, gtk_widget_size_allocate (bin->child, &child_allocation); } } + +static void +gtk_calex_draw_day (GtkCalEx *gtk_calex) +{ + guint hour; + + g_return_if_fail (IS_GTK_CALEX (gtk_calex)); + + GtkCalExPrivate *priv = GTK_CALEX_GET_PRIVATE (gtk_calex); + + for (hour = 0; hour < 24; hour++) + { + goo_canvas_text_new (priv->goo_canvas_root, g_strdup_printf ("%d", hour), + 0, hour * 40, 50, + GTK_ANCHOR_NORTH_WEST, + "font", "Sans 24", + NULL); + goo_canvas_text_new (priv->goo_canvas_root, "00", + 25, hour * 40, 25, + GTK_ANCHOR_NORTH_WEST, + "font", "Sans 12", + NULL); + goo_canvas_polyline_new_line (priv->goo_canvas_root, 0, hour * 40, 50, hour * 40, + "stroke-color", "black", + NULL); + goo_canvas_rect_new (priv->goo_canvas_root, 55, hour * 40, 400, 20, + "line-width", 1.0, + "stroke-color", "black", + "fill-color", "yellow", + NULL); + goo_canvas_polyline_new_line (priv->goo_canvas_root, 25, hour * 40 + 20, 50, hour * 40 + 20, + "stroke-color", "black", + NULL); + goo_canvas_rect_new (priv->goo_canvas_root, 55, hour * 40 + 20, 400, 20, + "line-width", 1.0, + "stroke-color", "black", + "fill-color", "yellow", + NULL); + } +}