]> saetta.ns0.it Git - libgtkcalendarex/commitdiff
Draft of the day view.
authorAndrea Zagli <azagli@libero.it>
Mon, 1 Nov 2010 09:26:53 +0000 (10:26 +0100)
committerAndrea Zagli <azagli@libero.it>
Mon, 1 Nov 2010 09:26:53 +0000 (10:26 +0100)
src/gtkcalex.c

index 121993feb91f905819f77975f37d69ac200025d8..67a18a477f068d684db860b641d6fe4c48a5ae9e 100644 (file)
@@ -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);
+               }
+}