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
This commit is contained in:

committed by
Arturo Espinosa

parent
d1769d5646
commit
7dae771114
@ -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.
|
||||
|
||||
|
@ -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:
|
||||
|
||||
|
@ -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 *
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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 *
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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" }
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
double width, height;
|
||||
double mwidth, mheight;
|
||||
double h_yofs, m_yofs;
|
||||
double x, y;
|
||||
GtkArg arg;
|
||||
GdkFont *head_font, *title_font;
|
||||
double head_height;
|
||||
double title_height;
|
||||
double width, height;
|
||||
double month_width;
|
||||
double month_height;
|
||||
double month_yofs;
|
||||
double xofs, yofs;
|
||||
double x, y;
|
||||
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 */
|
||||
|
||||
width = yv->canvas.width;
|
||||
height = yv->canvas.height - head_height;
|
||||
|
||||
/* Offsets */
|
||||
|
||||
xofs = (width + SPACING) / 3.0;
|
||||
yofs = (height + SPACING) / 4.0;
|
||||
|
||||
/* Month item vertical offset */
|
||||
|
||||
month_yofs = title_height + TITLE_SPACING;
|
||||
|
||||
/* Month item dimensions */
|
||||
|
||||
month_width = (width - 2 * SPACING) / 3.0;
|
||||
month_height = (yofs - SPACING) - month_yofs;
|
||||
|
||||
/* Adjust the year heading */
|
||||
|
||||
gnome_canvas_item_set (yv->heading,
|
||||
"x", (double) yv->canvas.width / 2.0,
|
||||
"x", width / 2.0,
|
||||
"y", (double) HEAD_SPACING,
|
||||
NULL);
|
||||
|
||||
/* Adjust months */
|
||||
|
||||
h_yofs = 2 * HEAD_SPACING + head_font->ascent + head_font->descent;
|
||||
m_yofs = SPACING + title_font->ascent + title_font->descent;
|
||||
|
||||
width = (yv->canvas.width + SPACING) / 3.0;
|
||||
height = (yv->canvas.height - h_yofs + SPACING) / 4.0;
|
||||
|
||||
mwidth = (yv->canvas.width - 2 * SPACING) / 3.0;
|
||||
mheight = (yv->canvas.height - h_yofs - 3 * SPACING - 4 * m_yofs) / 4.0;
|
||||
/* Adjust titles and months */
|
||||
|
||||
for (i = 0; i < 12; i++) {
|
||||
x = (i % 3) * width;
|
||||
y = (i / 3) * height + h_yofs;
|
||||
|
||||
/* Title */
|
||||
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
|
||||
|
@ -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 */
|
||||
|
@ -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" }
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
double width, height;
|
||||
double mwidth, mheight;
|
||||
double h_yofs, m_yofs;
|
||||
double x, y;
|
||||
GtkArg arg;
|
||||
GdkFont *head_font, *title_font;
|
||||
double head_height;
|
||||
double title_height;
|
||||
double width, height;
|
||||
double month_width;
|
||||
double month_height;
|
||||
double month_yofs;
|
||||
double xofs, yofs;
|
||||
double x, y;
|
||||
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 */
|
||||
|
||||
width = yv->canvas.width;
|
||||
height = yv->canvas.height - head_height;
|
||||
|
||||
/* Offsets */
|
||||
|
||||
xofs = (width + SPACING) / 3.0;
|
||||
yofs = (height + SPACING) / 4.0;
|
||||
|
||||
/* Month item vertical offset */
|
||||
|
||||
month_yofs = title_height + TITLE_SPACING;
|
||||
|
||||
/* Month item dimensions */
|
||||
|
||||
month_width = (width - 2 * SPACING) / 3.0;
|
||||
month_height = (yofs - SPACING) - month_yofs;
|
||||
|
||||
/* Adjust the year heading */
|
||||
|
||||
gnome_canvas_item_set (yv->heading,
|
||||
"x", (double) yv->canvas.width / 2.0,
|
||||
"x", width / 2.0,
|
||||
"y", (double) HEAD_SPACING,
|
||||
NULL);
|
||||
|
||||
/* Adjust months */
|
||||
|
||||
h_yofs = 2 * HEAD_SPACING + head_font->ascent + head_font->descent;
|
||||
m_yofs = SPACING + title_font->ascent + title_font->descent;
|
||||
|
||||
width = (yv->canvas.width + SPACING) / 3.0;
|
||||
height = (yv->canvas.height - h_yofs + SPACING) / 4.0;
|
||||
|
||||
mwidth = (yv->canvas.width - 2 * SPACING) / 3.0;
|
||||
mheight = (yv->canvas.height - h_yofs - 3 * SPACING - 4 * m_yofs) / 4.0;
|
||||
/* Adjust titles and months */
|
||||
|
||||
for (i = 0; i < 12; i++) {
|
||||
x = (i % 3) * width;
|
||||
y = (i / 3) * height + h_yofs;
|
||||
|
||||
/* Title */
|
||||
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
|
||||
|
@ -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 */
|
||||
|
Reference in New Issue
Block a user