aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@nuclecu.unam.mx>1998-10-01 09:32:47 +0800
committerArturo Espinosa <unammx@src.gnome.org>1998-10-01 09:32:47 +0800
commit7dae771114a7121f78f368f07f5e3adc69651c17 (patch)
treed894c1f4f505e2638ff0b7998a085f4567c755b4
parentd1769d5646e9fef3c6de607f9f884b02dd954844 (diff)
downloadgsoc2013-evolution-7dae771114a7121f78f368f07f5e3adc69651c17.tar.gz
gsoc2013-evolution-7dae771114a7121f78f368f07f5e3adc69651c17.tar.zst
gsoc2013-evolution-7dae771114a7121f78f368f07f5e3adc69651c17.zip
Colorify the month item and prepare it for prelighting here.
1998-09-30 Federico Mena Quintero <federico@nuclecu.unam.mx> * goto.c (create_days): Colorify the month item and prepare it for prelighting here. * main.c (color_props): Changed the default colors to something not dull. * year-view.c (compute_min_size): New function to compute the minimum size of the year view properly. (year_view_size_request): Added two new fields to the year view structure that contain the minimum size. Return this in the size_request method. (year_view_new): Call compute_min_size to save the minimum size for later use. (idle_handler): Make it resize the items correctly. * gnome-month-item.c (gnome_month_item_set_arg): Reshape when necessary. This is needed becaues we now actually calculate a minimum size for the month item based on the font sizes and paddings. (check_heading_sizes): New function to calculate a minimum size based on the headings' dimensions. (check_day_sizes): New function to calculate a minimum size based on the day number labels' dimensions. (check_sizes): New function that computes a minimum size for the month item. (reshape): Now calls check_sizes() to ensure a minimum size for the month item. svn path=/trunk/; revision=419
-rw-r--r--calendar/ChangeLog27
-rw-r--r--calendar/TODO3
-rw-r--r--calendar/gnome-cal.c3
-rw-r--r--calendar/gnome-month-item.c206
-rw-r--r--calendar/goto.c3
-rw-r--r--calendar/gui/gnome-cal.c3
-rw-r--r--calendar/gui/gnome-month-item.c206
-rw-r--r--calendar/gui/goto.c3
-rw-r--r--calendar/gui/main.c10
-rw-r--r--calendar/gui/year-view.c147
-rw-r--r--calendar/gui/year-view.h3
-rw-r--r--calendar/main.c10
-rw-r--r--calendar/year-view.c147
-rw-r--r--calendar/year-view.h3
14 files changed, 565 insertions, 209 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 38e85e9a8d..23fcfcc68c 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,5 +1,32 @@
1998-09-30 Federico Mena Quintero <federico@nuclecu.unam.mx>
+ * goto.c (create_days): Colorify the month item and prepare it for
+ prelighting here.
+
+ * main.c (color_props): Changed the default colors to something
+ not dull.
+
+ * year-view.c (compute_min_size): New function to compute the
+ minimum size of the year view properly.
+ (year_view_size_request): Added two new fields to the year view
+ structure that contain the minimum size. Return this in the
+ size_request method.
+ (year_view_new): Call compute_min_size to save the minimum size
+ for later use.
+ (idle_handler): Make it resize the items correctly.
+
+ * gnome-month-item.c (gnome_month_item_set_arg): Reshape when
+ necessary. This is needed becaues we now actually calculate a
+ minimum size for the month item based on the font sizes and paddings.
+ (check_heading_sizes): New function to calculate a minimum size
+ based on the headings' dimensions.
+ (check_day_sizes): New function to calculate a minimum size based
+ on the day number labels' dimensions.
+ (check_sizes): New function that computes a minimum size for the
+ month item.
+ (reshape): Now calls check_sizes() to ensure a minimum size for
+ the month item.
+
* year-view.c (mark_current_day): New function to mark the current
day in the year view.
diff --git a/calendar/TODO b/calendar/TODO
index c2dfab8367..7c33183b5e 100644
--- a/calendar/TODO
+++ b/calendar/TODO
@@ -5,7 +5,8 @@ BUGS:
Year view:
-- See why it is so fucking slow.
+- See why it is so fucking slow when opening its notebook page for the
+ first time.
Month view:
diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c
index 2a2635f178..fbbd5c2c19 100644
--- a/calendar/gnome-cal.c
+++ b/calendar/gnome-cal.c
@@ -60,9 +60,8 @@ setup_widgets (GnomeCalendar *gcal)
gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->year_view, gtk_label_new (_("Year View")));
gtk_widget_show_all (gcal->notebook);
-
+
gnome_app_set_contents (GNOME_APP (gcal), gcal->notebook);
-
}
static GtkWidget *
diff --git a/calendar/gnome-month-item.c b/calendar/gnome-month-item.c
index b0dded9a66..fa1ea79e48 100644
--- a/calendar/gnome-month-item.c
+++ b/calendar/gnome-month-item.c
@@ -152,6 +152,146 @@ gnome_month_item_class_init (GnomeMonthItemClass *class)
object_class->get_arg = gnome_month_item_get_arg;
}
+/* Calculates the minimum heading height based on the heading font size and padding. It also
+ * calculates the minimum width of the month item based on the width of the headings.
+ */
+static void
+check_heading_sizes (GnomeMonthItem *mitem)
+{
+ double m_height;
+ double m_width;
+ int width;
+ int max_width;
+ int i;
+
+ /* Calculate minimum height */
+
+ m_height = mitem->head_font->ascent + mitem->head_font->descent + 2 * mitem->head_padding;
+
+ if (mitem->head_height < m_height)
+ mitem->head_height = m_height;
+
+ /* Go through each heading and remember the widest one */
+
+ max_width = 0;
+
+ for (i = 0; i < 7; i++) {
+ width = gdk_string_width (mitem->head_font, mitem->day_names[i]);
+ if (max_width < width)
+ max_width = width;
+ }
+
+ m_width = 7 * (max_width + 2 * mitem->head_padding);
+
+ if (mitem->width < m_width)
+ mitem->width = m_width;
+}
+
+/* Calculates the minimum width and height of the month item based on the day font size and padding.
+ * Assumes that the minimum heading height has already been computed.
+ */
+static void
+check_day_sizes (GnomeMonthItem *mitem)
+{
+ double m_height;
+ double m_width;
+ int width;
+ int max_width;
+ char buf[100];
+ int i;
+
+ /* Calculate minimum height */
+
+ m_height = mitem->head_height + 6 * (mitem->day_font->ascent + mitem->day_font->descent + 2 * mitem->day_padding);
+
+ if (mitem->height < m_height)
+ mitem->height = m_height;
+
+ /* Calculate minimum width */
+
+ max_width = 0;
+
+ for (i = 1; i < 32; i++) {
+ sprintf (buf, "%d", i);
+ width = gdk_string_width (mitem->day_font, buf);
+ if (max_width < width)
+ max_width = width;
+ }
+
+ m_width = 7 * (max_width + 2 * mitem->day_padding);
+
+ if (mitem->width < m_width)
+ mitem->width = m_width;
+}
+
+/* Calculates the minimum size of the month item based on the font sizes and paddings. If the
+ * current size of the month item is smaller than the required minimum size, this function will
+ * change the size to the appropriate values.
+ */
+static void
+check_sizes (GnomeMonthItem *mitem)
+{
+ check_heading_sizes (mitem);
+ check_day_sizes (mitem);
+}
+
+/* Recalculates the position of the toplevel calendar group based on the logical position and anchor */
+static void
+reanchor (GnomeMonthItem *mitem)
+{
+ double x, y;
+
+ x = mitem->x;
+ y = mitem->y;
+
+ switch (mitem->anchor) {
+ case GTK_ANCHOR_NW:
+ case GTK_ANCHOR_W:
+ case GTK_ANCHOR_SW:
+ break;
+
+ case GTK_ANCHOR_N:
+ case GTK_ANCHOR_CENTER:
+ case GTK_ANCHOR_S:
+ x -= mitem->width / 2;
+ break;
+
+ case GTK_ANCHOR_NE:
+ case GTK_ANCHOR_E:
+ case GTK_ANCHOR_SE:
+ x -= mitem->width;
+ break;
+ }
+
+ switch (mitem->anchor) {
+ case GTK_ANCHOR_NW:
+ case GTK_ANCHOR_N:
+ case GTK_ANCHOR_NE:
+ break;
+
+ case GTK_ANCHOR_W:
+ case GTK_ANCHOR_CENTER:
+ case GTK_ANCHOR_E:
+ y -= mitem->height / 2;
+ break;
+
+ case GTK_ANCHOR_SW:
+ case GTK_ANCHOR_S:
+ case GTK_ANCHOR_SE:
+ y -= mitem->height;
+ break;
+ }
+
+ /* Explicitly use the canvas group class prefix since the month item class has x and y
+ * arguments as well.
+ */
+
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem),
+ "GnomeCanvasGroup::x", x,
+ "GnomeCanvasGroup::y", y,
+ NULL);
+}
+
/* Takes an anchor specification and the corners of a rectangle, and returns an anchored point with
* respect to that rectangle.
*/
@@ -294,6 +434,8 @@ reshape_days (GnomeMonthItem *mitem)
static void
reshape (GnomeMonthItem *mitem)
{
+ check_sizes (mitem);
+ reanchor (mitem);
reshape_headings (mitem);
reshape_days (mitem);
}
@@ -700,63 +842,6 @@ gnome_month_item_destroy (GtkObject *object)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
-/* Recalculates the position of the toplevel calendar group based on the logical position and anchor */
-static void
-reanchor (GnomeMonthItem *mitem)
-{
- double x, y;
-
- x = mitem->x;
- y = mitem->y;
-
- switch (mitem->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_SW:
- break;
-
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_S:
- x -= mitem->width / 2;
- break;
-
- case GTK_ANCHOR_NE:
- case GTK_ANCHOR_E:
- case GTK_ANCHOR_SE:
- x -= mitem->width;
- break;
- }
-
- switch (mitem->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_NE:
- break;
-
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_E:
- y -= mitem->height / 2;
- break;
-
- case GTK_ANCHOR_SW:
- case GTK_ANCHOR_S:
- case GTK_ANCHOR_SE:
- y -= mitem->height;
- break;
- }
-
- /* Explicitly use the canvas group class prefix since the month item class has x and y
- * arguments as well.
- */
-
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem),
- "GnomeCanvasGroup::x", x,
- "GnomeCanvasGroup::y", y,
- NULL);
-}
-
/* Sets the color of the specified pixel value to that of the specified argument, which must be in
* GdkColor format if format is TRUE, otherwise it must be in string format.
*/
@@ -813,13 +898,11 @@ gnome_month_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
case ARG_WIDTH:
mitem->width = fabs (GTK_VALUE_DOUBLE (*arg));
- reanchor (mitem);
reshape (mitem);
break;
case ARG_HEIGHT:
mitem->height = fabs (GTK_VALUE_DOUBLE (*arg));
- reanchor (mitem);
reshape (mitem);
break;
@@ -856,6 +939,7 @@ gnome_month_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
mitem->day_names[i] = g_strdup (day_names[i]);
set_day_names (mitem);
+ reshape (mitem);
break;
case ARG_HEADING_HEIGHT:
@@ -889,6 +973,7 @@ gnome_month_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
}
set_head_font (mitem);
+ reshape (mitem);
break;
case ARG_HEAD_FONT_GDK:
@@ -897,6 +982,7 @@ gnome_month_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
mitem->head_font = GTK_VALUE_BOXED (*arg);
gdk_font_ref (mitem->head_font);
set_head_font (mitem);
+ reshape (mitem);
break;
case ARG_DAY_FONT:
@@ -909,6 +995,7 @@ gnome_month_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
}
set_day_font (mitem);
+ reshape (mitem);
break;
case ARG_DAY_FONT_GDK:
@@ -917,6 +1004,7 @@ gnome_month_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
mitem->day_font = GTK_VALUE_BOXED (*arg);
gdk_font_ref (mitem->day_font);
set_day_font (mitem);
+ reshape (mitem);
break;
case ARG_HEAD_COLOR:
diff --git a/calendar/goto.c b/calendar/goto.c
index aca5edc3f8..bbc489ddee 100644
--- a/calendar/goto.c
+++ b/calendar/goto.c
@@ -26,7 +26,6 @@ update (void)
{
unmark_month_item (GNOME_MONTH_ITEM (month_item));
mark_month_item (GNOME_MONTH_ITEM (month_item), gnome_calendar->cal);
- month_item_prepare_prelight (GNOME_MONTH_ITEM (month_item), default_color_func, NULL);
}
/* Callback used when the year adjustment is changed */
@@ -186,6 +185,8 @@ create_days (int day, int month, int year)
"year", year,
"start_on_monday", week_starts_on_monday,
NULL);
+ colorify_month_item (GNOME_MONTH_ITEM (month_item), default_color_func, NULL);
+ month_item_prepare_prelight (GNOME_MONTH_ITEM (month_item), default_color_func, NULL);
update ();
/* Connect to size_allocate so that we can change the size of the month item and the
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 2a2635f178..fbbd5c2c19 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -60,9 +60,8 @@ setup_widgets (GnomeCalendar *gcal)
gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->year_view, gtk_label_new (_("Year View")));
gtk_widget_show_all (gcal->notebook);
-
+
gnome_app_set_contents (GNOME_APP (gcal), gcal->notebook);
-
}
static GtkWidget *
diff --git a/calendar/gui/gnome-month-item.c b/calendar/gui/gnome-month-item.c
index b0dded9a66..fa1ea79e48 100644
--- a/calendar/gui/gnome-month-item.c
+++ b/calendar/gui/gnome-month-item.c
@@ -152,6 +152,146 @@ gnome_month_item_class_init (GnomeMonthItemClass *class)
object_class->get_arg = gnome_month_item_get_arg;
}
+/* Calculates the minimum heading height based on the heading font size and padding. It also
+ * calculates the minimum width of the month item based on the width of the headings.
+ */
+static void
+check_heading_sizes (GnomeMonthItem *mitem)
+{
+ double m_height;
+ double m_width;
+ int width;
+ int max_width;
+ int i;
+
+ /* Calculate minimum height */
+
+ m_height = mitem->head_font->ascent + mitem->head_font->descent + 2 * mitem->head_padding;
+
+ if (mitem->head_height < m_height)
+ mitem->head_height = m_height;
+
+ /* Go through each heading and remember the widest one */
+
+ max_width = 0;
+
+ for (i = 0; i < 7; i++) {
+ width = gdk_string_width (mitem->head_font, mitem->day_names[i]);
+ if (max_width < width)
+ max_width = width;
+ }
+
+ m_width = 7 * (max_width + 2 * mitem->head_padding);
+
+ if (mitem->width < m_width)
+ mitem->width = m_width;
+}
+
+/* Calculates the minimum width and height of the month item based on the day font size and padding.
+ * Assumes that the minimum heading height has already been computed.
+ */
+static void
+check_day_sizes (GnomeMonthItem *mitem)
+{
+ double m_height;
+ double m_width;
+ int width;
+ int max_width;
+ char buf[100];
+ int i;
+
+ /* Calculate minimum height */
+
+ m_height = mitem->head_height + 6 * (mitem->day_font->ascent + mitem->day_font->descent + 2 * mitem->day_padding);
+
+ if (mitem->height < m_height)
+ mitem->height = m_height;
+
+ /* Calculate minimum width */
+
+ max_width = 0;
+
+ for (i = 1; i < 32; i++) {
+ sprintf (buf, "%d", i);
+ width = gdk_string_width (mitem->day_font, buf);
+ if (max_width < width)
+ max_width = width;
+ }
+
+ m_width = 7 * (max_width + 2 * mitem->day_padding);
+
+ if (mitem->width < m_width)
+ mitem->width = m_width;
+}
+
+/* Calculates the minimum size of the month item based on the font sizes and paddings. If the
+ * current size of the month item is smaller than the required minimum size, this function will
+ * change the size to the appropriate values.
+ */
+static void
+check_sizes (GnomeMonthItem *mitem)
+{
+ check_heading_sizes (mitem);
+ check_day_sizes (mitem);
+}
+
+/* Recalculates the position of the toplevel calendar group based on the logical position and anchor */
+static void
+reanchor (GnomeMonthItem *mitem)
+{
+ double x, y;
+
+ x = mitem->x;
+ y = mitem->y;
+
+ switch (mitem->anchor) {
+ case GTK_ANCHOR_NW:
+ case GTK_ANCHOR_W:
+ case GTK_ANCHOR_SW:
+ break;
+
+ case GTK_ANCHOR_N:
+ case GTK_ANCHOR_CENTER:
+ case GTK_ANCHOR_S:
+ x -= mitem->width / 2;
+ break;
+
+ case GTK_ANCHOR_NE:
+ case GTK_ANCHOR_E:
+ case GTK_ANCHOR_SE:
+ x -= mitem->width;
+ break;
+ }
+
+ switch (mitem->anchor) {
+ case GTK_ANCHOR_NW:
+ case GTK_ANCHOR_N:
+ case GTK_ANCHOR_NE:
+ break;
+
+ case GTK_ANCHOR_W:
+ case GTK_ANCHOR_CENTER:
+ case GTK_ANCHOR_E:
+ y -= mitem->height / 2;
+ break;
+
+ case GTK_ANCHOR_SW:
+ case GTK_ANCHOR_S:
+ case GTK_ANCHOR_SE:
+ y -= mitem->height;
+ break;
+ }
+
+ /* Explicitly use the canvas group class prefix since the month item class has x and y
+ * arguments as well.
+ */
+
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem),
+ "GnomeCanvasGroup::x", x,
+ "GnomeCanvasGroup::y", y,
+ NULL);
+}
+
/* Takes an anchor specification and the corners of a rectangle, and returns an anchored point with
* respect to that rectangle.
*/
@@ -294,6 +434,8 @@ reshape_days (GnomeMonthItem *mitem)
static void
reshape (GnomeMonthItem *mitem)
{
+ check_sizes (mitem);
+ reanchor (mitem);
reshape_headings (mitem);
reshape_days (mitem);
}
@@ -700,63 +842,6 @@ gnome_month_item_destroy (GtkObject *object)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
-/* Recalculates the position of the toplevel calendar group based on the logical position and anchor */
-static void
-reanchor (GnomeMonthItem *mitem)
-{
- double x, y;
-
- x = mitem->x;
- y = mitem->y;
-
- switch (mitem->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_SW:
- break;
-
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_S:
- x -= mitem->width / 2;
- break;
-
- case GTK_ANCHOR_NE:
- case GTK_ANCHOR_E:
- case GTK_ANCHOR_SE:
- x -= mitem->width;
- break;
- }
-
- switch (mitem->anchor) {
- case GTK_ANCHOR_NW:
- case GTK_ANCHOR_N:
- case GTK_ANCHOR_NE:
- break;
-
- case GTK_ANCHOR_W:
- case GTK_ANCHOR_CENTER:
- case GTK_ANCHOR_E:
- y -= mitem->height / 2;
- break;
-
- case GTK_ANCHOR_SW:
- case GTK_ANCHOR_S:
- case GTK_ANCHOR_SE:
- y -= mitem->height;
- break;
- }
-
- /* Explicitly use the canvas group class prefix since the month item class has x and y
- * arguments as well.
- */
-
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem),
- "GnomeCanvasGroup::x", x,
- "GnomeCanvasGroup::y", y,
- NULL);
-}
-
/* Sets the color of the specified pixel value to that of the specified argument, which must be in
* GdkColor format if format is TRUE, otherwise it must be in string format.
*/
@@ -813,13 +898,11 @@ gnome_month_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
case ARG_WIDTH:
mitem->width = fabs (GTK_VALUE_DOUBLE (*arg));
- reanchor (mitem);
reshape (mitem);
break;
case ARG_HEIGHT:
mitem->height = fabs (GTK_VALUE_DOUBLE (*arg));
- reanchor (mitem);
reshape (mitem);
break;
@@ -856,6 +939,7 @@ gnome_month_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
mitem->day_names[i] = g_strdup (day_names[i]);
set_day_names (mitem);
+ reshape (mitem);
break;
case ARG_HEADING_HEIGHT:
@@ -889,6 +973,7 @@ gnome_month_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
}
set_head_font (mitem);
+ reshape (mitem);
break;
case ARG_HEAD_FONT_GDK:
@@ -897,6 +982,7 @@ gnome_month_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
mitem->head_font = GTK_VALUE_BOXED (*arg);
gdk_font_ref (mitem->head_font);
set_head_font (mitem);
+ reshape (mitem);
break;
case ARG_DAY_FONT:
@@ -909,6 +995,7 @@ gnome_month_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
}
set_day_font (mitem);
+ reshape (mitem);
break;
case ARG_DAY_FONT_GDK:
@@ -917,6 +1004,7 @@ gnome_month_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
mitem->day_font = GTK_VALUE_BOXED (*arg);
gdk_font_ref (mitem->day_font);
set_day_font (mitem);
+ reshape (mitem);
break;
case ARG_HEAD_COLOR:
diff --git a/calendar/gui/goto.c b/calendar/gui/goto.c
index aca5edc3f8..bbc489ddee 100644
--- a/calendar/gui/goto.c
+++ b/calendar/gui/goto.c
@@ -26,7 +26,6 @@ update (void)
{
unmark_month_item (GNOME_MONTH_ITEM (month_item));
mark_month_item (GNOME_MONTH_ITEM (month_item), gnome_calendar->cal);
- month_item_prepare_prelight (GNOME_MONTH_ITEM (month_item), default_color_func, NULL);
}
/* Callback used when the year adjustment is changed */
@@ -186,6 +185,8 @@ create_days (int day, int month, int year)
"year", year,
"start_on_monday", week_starts_on_monday,
NULL);
+ colorify_month_item (GNOME_MONTH_ITEM (month_item), default_color_func, NULL);
+ month_item_prepare_prelight (GNOME_MONTH_ITEM (month_item), default_color_func, NULL);
update ();
/* Connect to size_allocate so that we can change the size of the month item and the
diff --git a/calendar/gui/main.c b/calendar/gui/main.c
index 802cd56972..e889d223d6 100644
--- a/calendar/gui/main.c
+++ b/calendar/gui/main.c
@@ -46,12 +46,12 @@ int week_starts_on_monday;
* values specified here are the defaults for the program.
*/
struct color_prop color_props[] = {
- { 0x0000, 0x0000, 0x0000, "Outline:", "/calendar/Colors/outline" },
+ { 0x3e72, 0x35ec, 0x8ba2, "Outline:", "/calendar/Colors/outline" },
{ 0xffff, 0xffff, 0xffff, "Headings:", "/calendar/Colors/headings" },
- { 0xd6d6, 0xd6d6, 0xd6d6, "Empty days:", "/calendar/Colors/empty_bg" },
- { 0xd2d2, 0xb4b4, 0x8c8c, "Appointment days:", "/calendar/Colors/mark_bg" },
- { 0xea60, 0xea60, 0xea60, "Highlighted day:", "/calendar/Colors/prelight_bg" },
- { 0x0000, 0x0000, 0x0000, "Day numbers:", "/calendar/Colors/day_fg" },
+ { 0xf26c, 0xecec, 0xbbe7, "Empty days:", "/calendar/Colors/empty_bg" },
+ { 0xfc1e, 0xf87f, 0x5f80, "Appointment days:", "/calendar/Colors/mark_bg" },
+ { 0xd364, 0xc6b7, 0x7969, "Highlighted day:", "/calendar/Colors/prelight_bg" },
+ { 0x01f0, 0x01f0, 0x01f0, "Day numbers:", "/calendar/Colors/day_fg" },
{ 0x0000, 0x0000, 0xffff, "Current day's number:", "/calendar/Colors/current_fg" }
};
diff --git a/calendar/gui/year-view.c b/calendar/gui/year-view.c
index 96b43c264b..93cd591292 100644
--- a/calendar/gui/year-view.c
+++ b/calendar/gui/year-view.c
@@ -18,7 +18,7 @@
#define HEAD_SPACING 4 /* Spacing between year heading and months */
-#define TITLE_SPACING 2 /* Spacing between title and calendar */
+#define TITLE_SPACING 1 /* Spacing between title and calendar */
#define SPACING 4 /* Spacing between months */
@@ -81,62 +81,71 @@ static gint
idle_handler (gpointer data)
{
YearView *yv;
+ GtkArg arg;
+ double head_height;
+ double title_height;
double width, height;
- double mwidth, mheight;
- double h_yofs, m_yofs;
+ double month_width;
+ double month_height;
+ double month_yofs;
+ double xofs, yofs;
double x, y;
- GtkArg arg;
- GdkFont *head_font, *title_font;
int i;
yv = data;
- /* Get the fonts to get their size later */
+ /* Get the heights of the heading and the titles */
- arg.name = "font_gdk";
+ arg.name = "text_height";
gtk_object_getv (GTK_OBJECT (yv->heading), 1, &arg);
- head_font = GTK_VALUE_BOXED (arg);
+ head_height = GTK_VALUE_DOUBLE (arg) + 2 * HEAD_SPACING;
- arg.name = "font_gdk";
+ arg.name = "text_height";
gtk_object_getv (GTK_OBJECT (yv->titles[0]), 1, &arg);
- title_font = GTK_VALUE_BOXED (arg);
+ title_height = GTK_VALUE_DOUBLE (arg);
- /* Adjust heading */
+ /* Space for the titles and months */
- gnome_canvas_item_set (yv->heading,
- "x", (double) yv->canvas.width / 2.0,
- "y", (double) HEAD_SPACING,
- NULL);
+ width = yv->canvas.width;
+ height = yv->canvas.height - head_height;
- /* Adjust months */
+ /* Offsets */
- h_yofs = 2 * HEAD_SPACING + head_font->ascent + head_font->descent;
- m_yofs = SPACING + title_font->ascent + title_font->descent;
+ xofs = (width + SPACING) / 3.0;
+ yofs = (height + SPACING) / 4.0;
- width = (yv->canvas.width + SPACING) / 3.0;
- height = (yv->canvas.height - h_yofs + SPACING) / 4.0;
+ /* Month item vertical offset */
- mwidth = (yv->canvas.width - 2 * SPACING) / 3.0;
- mheight = (yv->canvas.height - h_yofs - 3 * SPACING - 4 * m_yofs) / 4.0;
+ month_yofs = title_height + TITLE_SPACING;
- for (i = 0; i < 12; i++) {
- x = (i % 3) * width;
- y = (i / 3) * height + h_yofs;
+ /* Month item dimensions */
- /* Title */
+ month_width = (width - 2 * SPACING) / 3.0;
+ month_height = (yofs - SPACING) - month_yofs;
+
+ /* Adjust the year heading */
+
+ gnome_canvas_item_set (yv->heading,
+ "x", width / 2.0,
+ "y", (double) HEAD_SPACING,
+ NULL);
+
+ /* Adjust titles and months */
+
+ for (i = 0; i < 12; i++) {
+ x = (i % 3) * xofs;
+ y = head_height + (i / 3) * yofs;
gnome_canvas_item_set (yv->titles[i],
- "x", x + width / 2.0,
+ "x", x + month_width / 2.0,
"y", y,
NULL);
- /* Month item */
-
gnome_canvas_item_set (yv->mitems[i],
"x", x,
- "y", y + m_yofs,
- "width", mwidth,
- "height", mheight,
+ "y", y + month_yofs,
+ "width", month_width,
+ "height", month_height,
NULL);
}
@@ -433,6 +442,72 @@ setup_month_item (YearView *yv, int n)
month_item_prepare_prelight (GNOME_MONTH_ITEM (mitem), default_color_func, NULL);
}
+/* Computes the minimum size for the year view and stores it in its internal fields */
+static void
+compute_min_size (YearView *yv)
+{
+ GtkArg args[2];
+ double m_width;
+ double m_height;
+ double max_width;
+ double w;
+ int i;
+
+ /* Compute the minimum size of the year heading */
+
+ args[0].name = "text_width";
+ args[1].name = "text_height";
+ gtk_object_getv (GTK_OBJECT (yv->heading), 1, args);
+
+ m_width = GTK_VALUE_DOUBLE (args[0]);
+ m_height = 2 * HEAD_SPACING + GTK_VALUE_DOUBLE (args[1]);
+
+ /* Add height of month titles and their spacings */
+
+ args[0].name = "text_height";
+ gtk_object_getv (GTK_OBJECT (yv->titles[0]), 1, &args[0]);
+
+ m_height += 4 * (GTK_VALUE_DOUBLE (args[0]) + TITLE_SPACING);
+
+ /* Add width of month titles */
+
+ max_width = 0.0;
+
+ for (i = 0; i < 12; i++) {
+ args[0].name = "text_width";
+ gtk_object_getv (GTK_OBJECT (yv->titles[i]), 1, &args[0]);
+
+ w = GTK_VALUE_DOUBLE (args[0]);
+ if (max_width < w)
+ max_width = w;
+ }
+
+ max_width = 3 * max_width + 2 * SPACING;
+
+ if (m_width < max_width)
+ m_width = max_width;
+
+ /* Add width of month items */
+
+ args[0].name = "width";
+ args[1].name = "height";
+ gtk_object_getv (GTK_OBJECT (yv->mitems[0]), 2, args);
+
+ max_width = 3 * GTK_VALUE_DOUBLE (args[0]) + 2 * SPACING;
+
+ if (m_width < max_width)
+ m_width = max_width;
+
+ /* Add height of month items */
+
+ m_height += 4 * GTK_VALUE_DOUBLE (args[1]) + 3 * SPACING;
+
+ /* Finally, set the minimum width and height in the year view */
+
+ yv->min_width = (int) (m_width + 0.5);
+ yv->min_height = (int) (m_height + 0.5);
+}
+
static void
year_view_init (YearView *yv)
{
@@ -516,6 +591,7 @@ year_view_new (GnomeCalendar *calendar, time_t year)
year_view_colors_changed (yv);
year_view_set (yv, year);
+ compute_min_size (yv);
return GTK_WIDGET (yv);
}
@@ -530,11 +606,8 @@ year_view_size_request (GtkWidget *widget, GtkRequisition *requisition)
yv = YEAR_VIEW (widget);
- if (GTK_WIDGET_CLASS (parent_class)->size_request)
- (* GTK_WIDGET_CLASS (parent_class)->size_request) (widget, requisition);
-
- requisition->width = 200;
- requisition->height = 150;
+ requisition->width = yv->min_width;
+ requisition->height = yv->min_height;
}
static void
diff --git a/calendar/gui/year-view.h b/calendar/gui/year-view.h
index a59be73f46..77e63366d5 100644
--- a/calendar/gui/year-view.h
+++ b/calendar/gui/year-view.h
@@ -40,6 +40,9 @@ struct _YearView {
int old_marked_day; /* The day that is marked as the current day */
+ int min_width; /* Minimum dimensions of year view, used for size_request*/
+ int min_height;
+
guint idle_id; /* ID of idle handler for resize */
int need_resize : 1; /* Specifies whether we need to resize the canvas items or not */
diff --git a/calendar/main.c b/calendar/main.c
index 802cd56972..e889d223d6 100644
--- a/calendar/main.c
+++ b/calendar/main.c
@@ -46,12 +46,12 @@ int week_starts_on_monday;
* values specified here are the defaults for the program.
*/
struct color_prop color_props[] = {
- { 0x0000, 0x0000, 0x0000, "Outline:", "/calendar/Colors/outline" },
+ { 0x3e72, 0x35ec, 0x8ba2, "Outline:", "/calendar/Colors/outline" },
{ 0xffff, 0xffff, 0xffff, "Headings:", "/calendar/Colors/headings" },
- { 0xd6d6, 0xd6d6, 0xd6d6, "Empty days:", "/calendar/Colors/empty_bg" },
- { 0xd2d2, 0xb4b4, 0x8c8c, "Appointment days:", "/calendar/Colors/mark_bg" },
- { 0xea60, 0xea60, 0xea60, "Highlighted day:", "/calendar/Colors/prelight_bg" },
- { 0x0000, 0x0000, 0x0000, "Day numbers:", "/calendar/Colors/day_fg" },
+ { 0xf26c, 0xecec, 0xbbe7, "Empty days:", "/calendar/Colors/empty_bg" },
+ { 0xfc1e, 0xf87f, 0x5f80, "Appointment days:", "/calendar/Colors/mark_bg" },
+ { 0xd364, 0xc6b7, 0x7969, "Highlighted day:", "/calendar/Colors/prelight_bg" },
+ { 0x01f0, 0x01f0, 0x01f0, "Day numbers:", "/calendar/Colors/day_fg" },
{ 0x0000, 0x0000, 0xffff, "Current day's number:", "/calendar/Colors/current_fg" }
};
diff --git a/calendar/year-view.c b/calendar/year-view.c
index 96b43c264b..93cd591292 100644
--- a/calendar/year-view.c
+++ b/calendar/year-view.c
@@ -18,7 +18,7 @@
#define HEAD_SPACING 4 /* Spacing between year heading and months */
-#define TITLE_SPACING 2 /* Spacing between title and calendar */
+#define TITLE_SPACING 1 /* Spacing between title and calendar */
#define SPACING 4 /* Spacing between months */
@@ -81,62 +81,71 @@ static gint
idle_handler (gpointer data)
{
YearView *yv;
+ GtkArg arg;
+ double head_height;
+ double title_height;
double width, height;
- double mwidth, mheight;
- double h_yofs, m_yofs;
+ double month_width;
+ double month_height;
+ double month_yofs;
+ double xofs, yofs;
double x, y;
- GtkArg arg;
- GdkFont *head_font, *title_font;
int i;
yv = data;
- /* Get the fonts to get their size later */
+ /* Get the heights of the heading and the titles */
- arg.name = "font_gdk";
+ arg.name = "text_height";
gtk_object_getv (GTK_OBJECT (yv->heading), 1, &arg);
- head_font = GTK_VALUE_BOXED (arg);
+ head_height = GTK_VALUE_DOUBLE (arg) + 2 * HEAD_SPACING;
- arg.name = "font_gdk";
+ arg.name = "text_height";
gtk_object_getv (GTK_OBJECT (yv->titles[0]), 1, &arg);
- title_font = GTK_VALUE_BOXED (arg);
+ title_height = GTK_VALUE_DOUBLE (arg);
- /* Adjust heading */
+ /* Space for the titles and months */
- gnome_canvas_item_set (yv->heading,
- "x", (double) yv->canvas.width / 2.0,
- "y", (double) HEAD_SPACING,
- NULL);
+ width = yv->canvas.width;
+ height = yv->canvas.height - head_height;
- /* Adjust months */
+ /* Offsets */
- h_yofs = 2 * HEAD_SPACING + head_font->ascent + head_font->descent;
- m_yofs = SPACING + title_font->ascent + title_font->descent;
+ xofs = (width + SPACING) / 3.0;
+ yofs = (height + SPACING) / 4.0;
- width = (yv->canvas.width + SPACING) / 3.0;
- height = (yv->canvas.height - h_yofs + SPACING) / 4.0;
+ /* Month item vertical offset */
- mwidth = (yv->canvas.width - 2 * SPACING) / 3.0;
- mheight = (yv->canvas.height - h_yofs - 3 * SPACING - 4 * m_yofs) / 4.0;
+ month_yofs = title_height + TITLE_SPACING;
- for (i = 0; i < 12; i++) {
- x = (i % 3) * width;
- y = (i / 3) * height + h_yofs;
+ /* Month item dimensions */
- /* Title */
+ month_width = (width - 2 * SPACING) / 3.0;
+ month_height = (yofs - SPACING) - month_yofs;
+
+ /* Adjust the year heading */
+
+ gnome_canvas_item_set (yv->heading,
+ "x", width / 2.0,
+ "y", (double) HEAD_SPACING,
+ NULL);
+
+ /* Adjust titles and months */
+
+ for (i = 0; i < 12; i++) {
+ x = (i % 3) * xofs;
+ y = head_height + (i / 3) * yofs;
gnome_canvas_item_set (yv->titles[i],
- "x", x + width / 2.0,
+ "x", x + month_width / 2.0,
"y", y,
NULL);
- /* Month item */
-
gnome_canvas_item_set (yv->mitems[i],
"x", x,
- "y", y + m_yofs,
- "width", mwidth,
- "height", mheight,
+ "y", y + month_yofs,
+ "width", month_width,
+ "height", month_height,
NULL);
}
@@ -433,6 +442,72 @@ setup_month_item (YearView *yv, int n)
month_item_prepare_prelight (GNOME_MONTH_ITEM (mitem), default_color_func, NULL);
}
+/* Computes the minimum size for the year view and stores it in its internal fields */
+static void
+compute_min_size (YearView *yv)
+{
+ GtkArg args[2];
+ double m_width;
+ double m_height;
+ double max_width;
+ double w;
+ int i;
+
+ /* Compute the minimum size of the year heading */
+
+ args[0].name = "text_width";
+ args[1].name = "text_height";
+ gtk_object_getv (GTK_OBJECT (yv->heading), 1, args);
+
+ m_width = GTK_VALUE_DOUBLE (args[0]);
+ m_height = 2 * HEAD_SPACING + GTK_VALUE_DOUBLE (args[1]);
+
+ /* Add height of month titles and their spacings */
+
+ args[0].name = "text_height";
+ gtk_object_getv (GTK_OBJECT (yv->titles[0]), 1, &args[0]);
+
+ m_height += 4 * (GTK_VALUE_DOUBLE (args[0]) + TITLE_SPACING);
+
+ /* Add width of month titles */
+
+ max_width = 0.0;
+
+ for (i = 0; i < 12; i++) {
+ args[0].name = "text_width";
+ gtk_object_getv (GTK_OBJECT (yv->titles[i]), 1, &args[0]);
+
+ w = GTK_VALUE_DOUBLE (args[0]);
+ if (max_width < w)
+ max_width = w;
+ }
+
+ max_width = 3 * max_width + 2 * SPACING;
+
+ if (m_width < max_width)
+ m_width = max_width;
+
+ /* Add width of month items */
+
+ args[0].name = "width";
+ args[1].name = "height";
+ gtk_object_getv (GTK_OBJECT (yv->mitems[0]), 2, args);
+
+ max_width = 3 * GTK_VALUE_DOUBLE (args[0]) + 2 * SPACING;
+
+ if (m_width < max_width)
+ m_width = max_width;
+
+ /* Add height of month items */
+
+ m_height += 4 * GTK_VALUE_DOUBLE (args[1]) + 3 * SPACING;
+
+ /* Finally, set the minimum width and height in the year view */
+
+ yv->min_width = (int) (m_width + 0.5);
+ yv->min_height = (int) (m_height + 0.5);
+}
+
static void
year_view_init (YearView *yv)
{
@@ -516,6 +591,7 @@ year_view_new (GnomeCalendar *calendar, time_t year)
year_view_colors_changed (yv);
year_view_set (yv, year);
+ compute_min_size (yv);
return GTK_WIDGET (yv);
}
@@ -530,11 +606,8 @@ year_view_size_request (GtkWidget *widget, GtkRequisition *requisition)
yv = YEAR_VIEW (widget);
- if (GTK_WIDGET_CLASS (parent_class)->size_request)
- (* GTK_WIDGET_CLASS (parent_class)->size_request) (widget, requisition);
-
- requisition->width = 200;
- requisition->height = 150;
+ requisition->width = yv->min_width;
+ requisition->height = yv->min_height;
}
static void
diff --git a/calendar/year-view.h b/calendar/year-view.h
index a59be73f46..77e63366d5 100644
--- a/calendar/year-view.h
+++ b/calendar/year-view.h
@@ -40,6 +40,9 @@ struct _YearView {
int old_marked_day; /* The day that is marked as the current day */
+ int min_width; /* Minimum dimensions of year view, used for size_request*/
+ int min_height;
+
guint idle_id; /* ID of idle handler for resize */
int need_resize : 1; /* Specifies whether we need to resize the canvas items or not */