mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-11 11:20:12 +00:00
gtk/gtkcalendar.c: More changes: - The day with focus is now seperated
Sun Oct 4 22:47:22 CDT 1998 Shawn T. Amundson <amundson@gtk.org> * gtk/gtkcalendar.h: gtk/gtkcalendar.c: More changes: - The day with focus is now seperated from the day selected - The day with focus has the xor's line around it - The selected day is now standard selected style - The week names and week numbers are now also drawn with selected style - Space now selects the day which has focus
This commit is contained in:
parent
edebc6cf21
commit
6b15c2ca82
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
Sun Oct 4 22:47:22 CDT 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
|
* gtk/gtkcalendar.h:
|
||||||
|
gtk/gtkcalendar.c: More changes:
|
||||||
|
- The day with focus is now seperated from the day selected
|
||||||
|
- The day with focus has the xor's line around it
|
||||||
|
- The selected day is now standard selected style
|
||||||
|
- The week names and week numbers are now also drawn
|
||||||
|
with selected style
|
||||||
|
- Space now selects the day which has focus
|
||||||
|
|
||||||
Sun Oct 4 17:55:52 CDT 1998 Shawn T. Amundson <amundson@gtk.org>
|
Sun Oct 4 17:55:52 CDT 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
* gtk/gtkcalendar.h:
|
* gtk/gtkcalendar.h:
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
Sun Oct 4 22:47:22 CDT 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
|
* gtk/gtkcalendar.h:
|
||||||
|
gtk/gtkcalendar.c: More changes:
|
||||||
|
- The day with focus is now seperated from the day selected
|
||||||
|
- The day with focus has the xor's line around it
|
||||||
|
- The selected day is now standard selected style
|
||||||
|
- The week names and week numbers are now also drawn
|
||||||
|
with selected style
|
||||||
|
- Space now selects the day which has focus
|
||||||
|
|
||||||
Sun Oct 4 17:55:52 CDT 1998 Shawn T. Amundson <amundson@gtk.org>
|
Sun Oct 4 17:55:52 CDT 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
* gtk/gtkcalendar.h:
|
* gtk/gtkcalendar.h:
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
Sun Oct 4 22:47:22 CDT 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
|
* gtk/gtkcalendar.h:
|
||||||
|
gtk/gtkcalendar.c: More changes:
|
||||||
|
- The day with focus is now seperated from the day selected
|
||||||
|
- The day with focus has the xor's line around it
|
||||||
|
- The selected day is now standard selected style
|
||||||
|
- The week names and week numbers are now also drawn
|
||||||
|
with selected style
|
||||||
|
- Space now selects the day which has focus
|
||||||
|
|
||||||
Sun Oct 4 17:55:52 CDT 1998 Shawn T. Amundson <amundson@gtk.org>
|
Sun Oct 4 17:55:52 CDT 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
* gtk/gtkcalendar.h:
|
* gtk/gtkcalendar.h:
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
Sun Oct 4 22:47:22 CDT 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
|
* gtk/gtkcalendar.h:
|
||||||
|
gtk/gtkcalendar.c: More changes:
|
||||||
|
- The day with focus is now seperated from the day selected
|
||||||
|
- The day with focus has the xor's line around it
|
||||||
|
- The selected day is now standard selected style
|
||||||
|
- The week names and week numbers are now also drawn
|
||||||
|
with selected style
|
||||||
|
- Space now selects the day which has focus
|
||||||
|
|
||||||
Sun Oct 4 17:55:52 CDT 1998 Shawn T. Amundson <amundson@gtk.org>
|
Sun Oct 4 17:55:52 CDT 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
* gtk/gtkcalendar.h:
|
* gtk/gtkcalendar.h:
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
Sun Oct 4 22:47:22 CDT 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
|
* gtk/gtkcalendar.h:
|
||||||
|
gtk/gtkcalendar.c: More changes:
|
||||||
|
- The day with focus is now seperated from the day selected
|
||||||
|
- The day with focus has the xor's line around it
|
||||||
|
- The selected day is now standard selected style
|
||||||
|
- The week names and week numbers are now also drawn
|
||||||
|
with selected style
|
||||||
|
- Space now selects the day which has focus
|
||||||
|
|
||||||
Sun Oct 4 17:55:52 CDT 1998 Shawn T. Amundson <amundson@gtk.org>
|
Sun Oct 4 17:55:52 CDT 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
* gtk/gtkcalendar.h:
|
* gtk/gtkcalendar.h:
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
Sun Oct 4 22:47:22 CDT 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
|
* gtk/gtkcalendar.h:
|
||||||
|
gtk/gtkcalendar.c: More changes:
|
||||||
|
- The day with focus is now seperated from the day selected
|
||||||
|
- The day with focus has the xor's line around it
|
||||||
|
- The selected day is now standard selected style
|
||||||
|
- The week names and week numbers are now also drawn
|
||||||
|
with selected style
|
||||||
|
- Space now selects the day which has focus
|
||||||
|
|
||||||
Sun Oct 4 17:55:52 CDT 1998 Shawn T. Amundson <amundson@gtk.org>
|
Sun Oct 4 17:55:52 CDT 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
* gtk/gtkcalendar.h:
|
* gtk/gtkcalendar.h:
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
Sun Oct 4 22:47:22 CDT 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
|
* gtk/gtkcalendar.h:
|
||||||
|
gtk/gtkcalendar.c: More changes:
|
||||||
|
- The day with focus is now seperated from the day selected
|
||||||
|
- The day with focus has the xor's line around it
|
||||||
|
- The selected day is now standard selected style
|
||||||
|
- The week names and week numbers are now also drawn
|
||||||
|
with selected style
|
||||||
|
- Space now selects the day which has focus
|
||||||
|
|
||||||
Sun Oct 4 17:55:52 CDT 1998 Shawn T. Amundson <amundson@gtk.org>
|
Sun Oct 4 17:55:52 CDT 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
* gtk/gtkcalendar.h:
|
* gtk/gtkcalendar.h:
|
||||||
|
@ -164,7 +164,7 @@ dates_difference(N_int year1, N_int mm1, N_int dd1,
|
|||||||
/* Color usage */
|
/* Color usage */
|
||||||
#define HEADER_FG_COLOR(widget) (& (widget)->style->fg[GTK_WIDGET_STATE (widget)])
|
#define HEADER_FG_COLOR(widget) (& (widget)->style->fg[GTK_WIDGET_STATE (widget)])
|
||||||
#define HEADER_BG_COLOR(widget) (& (widget)->style->bg[GTK_WIDGET_STATE (widget)])
|
#define HEADER_BG_COLOR(widget) (& (widget)->style->bg[GTK_WIDGET_STATE (widget)])
|
||||||
#define DAY_NAME_COLOR(widget) (& (widget)->style->dark[GTK_WIDGET_STATE (widget)])
|
#define DAY_NAME_COLOR(widget) (& (widget)->style->bg[GTK_STATE_SELECTED])
|
||||||
#define NORMAL_DAY_COLOR(widget) (& (widget)->style->fg[GTK_WIDGET_STATE (widget)])
|
#define NORMAL_DAY_COLOR(widget) (& (widget)->style->fg[GTK_WIDGET_STATE (widget)])
|
||||||
#define SELECTION_FOCUS_COLOR(widget) (& (widget)->style->fg[GTK_WIDGET_STATE (widget)])
|
#define SELECTION_FOCUS_COLOR(widget) (& (widget)->style->fg[GTK_WIDGET_STATE (widget)])
|
||||||
#define SELECTION_NO_FOCUS_COLOR(widget) (& (widget)->style->mid[GTK_WIDGET_STATE (widget)])
|
#define SELECTION_NO_FOCUS_COLOR(widget) (& (widget)->style->mid[GTK_WIDGET_STATE (widget)])
|
||||||
@ -451,6 +451,10 @@ gtk_calendar_init (GtkCalendar *calendar)
|
|||||||
calendar->highlight_row = -1;
|
calendar->highlight_row = -1;
|
||||||
calendar->highlight_col = -1;
|
calendar->highlight_col = -1;
|
||||||
|
|
||||||
|
calendar->focus_row = -1;
|
||||||
|
calendar->focus_col = -1;
|
||||||
|
calendar->xor_gc = NULL;
|
||||||
|
|
||||||
private_data->max_year_width = 0;
|
private_data->max_year_width = 0;
|
||||||
private_data->max_month_width = 0;
|
private_data->max_month_width = 0;
|
||||||
private_data->max_day_char_width = 0;
|
private_data->max_day_char_width = 0;
|
||||||
@ -769,6 +773,7 @@ gtk_calendar_main_button (GtkWidget *widget,
|
|||||||
gint x, y;
|
gint x, y;
|
||||||
gint row, col;
|
gint row, col;
|
||||||
gint day_month;
|
gint day_month;
|
||||||
|
gint old_focus_row, old_focus_col;
|
||||||
|
|
||||||
calendar = GTK_CALENDAR (widget);
|
calendar = GTK_CALENDAR (widget);
|
||||||
|
|
||||||
@ -789,6 +794,11 @@ gtk_calendar_main_button (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
if (!GTK_WIDGET_HAS_FOCUS (widget))
|
if (!GTK_WIDGET_HAS_FOCUS (widget))
|
||||||
gtk_widget_grab_focus (widget);
|
gtk_widget_grab_focus (widget);
|
||||||
|
old_focus_row = calendar->focus_row;
|
||||||
|
old_focus_col = calendar->focus_col;
|
||||||
|
calendar->focus_row = row;
|
||||||
|
calendar->focus_col = col;
|
||||||
|
gtk_calendar_paint_day (widget, old_focus_row, old_focus_col);
|
||||||
gtk_calendar_select_day (calendar, calendar->day[row][col]);
|
gtk_calendar_select_day (calendar, calendar->day[row][col]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1002,7 +1012,8 @@ gtk_calendar_realize (GtkWidget *widget)
|
|||||||
GtkCalendarPrivateData *private_data;
|
GtkCalendarPrivateData *private_data;
|
||||||
GdkWindowAttr attributes;
|
GdkWindowAttr attributes;
|
||||||
gint attributes_mask;
|
gint attributes_mask;
|
||||||
|
GdkGCValues values;
|
||||||
|
|
||||||
g_return_if_fail (widget != NULL);
|
g_return_if_fail (widget != NULL);
|
||||||
g_return_if_fail (GTK_IS_CALENDAR (widget));
|
g_return_if_fail (GTK_IS_CALENDAR (widget));
|
||||||
|
|
||||||
@ -1062,6 +1073,13 @@ gtk_calendar_realize (GtkWidget *widget)
|
|||||||
|
|
||||||
/* Set widgets gc */
|
/* Set widgets gc */
|
||||||
calendar->gc = gdk_gc_new (widget->window);
|
calendar->gc = gdk_gc_new (widget->window);
|
||||||
|
|
||||||
|
values.foreground = widget->style->white;
|
||||||
|
values.function = GDK_XOR;
|
||||||
|
calendar->xor_gc = gdk_gc_new_with_values (widget->window,
|
||||||
|
&values,
|
||||||
|
GDK_GC_FOREGROUND |
|
||||||
|
GDK_GC_FUNCTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1613,14 +1631,12 @@ gtk_calendar_paint_day_names (GtkWidget *widget)
|
|||||||
* Draw rectangles as inverted background for the labels.
|
* Draw rectangles as inverted background for the labels.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
gdk_gc_set_foreground (gc, DAY_NAME_COLOR (GTK_WIDGET (calendar)));
|
gdk_gc_set_foreground (gc, &widget->style->bg[GTK_STATE_SELECTED]);
|
||||||
gdk_gc_set_background (gc, DAY_NAME_COLOR (GTK_WIDGET (calendar)));
|
|
||||||
gdk_draw_rectangle (private_data->day_name_win, gc, TRUE,
|
gdk_draw_rectangle (private_data->day_name_win, gc, TRUE,
|
||||||
CALENDAR_MARGIN, CALENDAR_MARGIN,
|
CALENDAR_MARGIN, CALENDAR_MARGIN,
|
||||||
cal_width-CALENDAR_MARGIN * 2,
|
cal_width-CALENDAR_MARGIN * 2,
|
||||||
private_data->day_name_h - CALENDAR_MARGIN);
|
private_data->day_name_h - CALENDAR_MARGIN);
|
||||||
|
|
||||||
|
|
||||||
if (calendar->display_flags & GTK_CALENDAR_SHOW_WEEK_NUMBERS)
|
if (calendar->display_flags & GTK_CALENDAR_SHOW_WEEK_NUMBERS)
|
||||||
gdk_draw_rectangle (private_data->day_name_win, gc, TRUE,
|
gdk_draw_rectangle (private_data->day_name_win, gc, TRUE,
|
||||||
CALENDAR_MARGIN,
|
CALENDAR_MARGIN,
|
||||||
@ -1631,8 +1647,7 @@ gtk_calendar_paint_day_names (GtkWidget *widget)
|
|||||||
/*
|
/*
|
||||||
* Write the labels
|
* Write the labels
|
||||||
*/
|
*/
|
||||||
|
gdk_gc_set_foreground (gc, &widget->style->fg[GTK_STATE_SELECTED]);
|
||||||
gdk_gc_set_foreground (gc, BACKGROUND_COLOR ( GTK_WIDGET (calendar)));
|
|
||||||
for (i = 0; i < 7; i++)
|
for (i = 0; i < 7; i++)
|
||||||
{
|
{
|
||||||
day=i;
|
day=i;
|
||||||
@ -1690,8 +1705,7 @@ gtk_calendar_paint_week_numbers (GtkWidget *widget)
|
|||||||
* Draw a rectangle as inverted background for the labels.
|
* Draw a rectangle as inverted background for the labels.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
gdk_gc_set_foreground (gc, DAY_NAME_COLOR (GTK_WIDGET (calendar)));
|
gdk_gc_set_foreground (gc, &widget->style->bg[GTK_STATE_SELECTED]);
|
||||||
gdk_gc_set_background (gc, DAY_NAME_COLOR (GTK_WIDGET (calendar)));
|
|
||||||
if (private_data->day_name_win)
|
if (private_data->day_name_win)
|
||||||
gdk_draw_rectangle (private_data->week_win, gc, TRUE,
|
gdk_draw_rectangle (private_data->week_win, gc, TRUE,
|
||||||
CALENDAR_MARGIN,
|
CALENDAR_MARGIN,
|
||||||
@ -1709,7 +1723,7 @@ gtk_calendar_paint_week_numbers (GtkWidget *widget)
|
|||||||
* Write the labels
|
* Write the labels
|
||||||
*/
|
*/
|
||||||
|
|
||||||
gdk_gc_set_foreground (gc, BACKGROUND_COLOR (GTK_WIDGET (calendar)));
|
gdk_gc_set_foreground (gc, &widget->style->fg[GTK_STATE_SELECTED]);
|
||||||
day_height = row_height (calendar);
|
day_height = row_height (calendar);
|
||||||
for (row = 0; row < 6; row++)
|
for (row = 0; row < 6; row++)
|
||||||
{
|
{
|
||||||
@ -1830,29 +1844,33 @@ gtk_calendar_paint_day (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if (calendar->highlight_row == row && calendar->highlight_col == col)
|
if (calendar->highlight_row == row && calendar->highlight_col == col)
|
||||||
{
|
{
|
||||||
gdk_gc_set_foreground (gc, HIGHLIGHT_BACK_COLOR (GTK_WIDGET (calendar)));
|
gdk_gc_set_foreground (gc, HIGHLIGHT_BACK_COLOR (GTK_WIDGET (calendar)));
|
||||||
gdk_draw_rectangle (private_data->main_win, gc, TRUE, x_left, y_top,
|
gdk_draw_rectangle (private_data->main_win, gc, TRUE, x_left, y_top,
|
||||||
private_data->day_width, day_height);
|
private_data->day_width, day_height);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
if (calendar->selected_day == day)
|
if (calendar->selected_day == day)
|
||||||
{
|
{
|
||||||
if (GTK_WIDGET_HAS_FOCUS (widget))
|
gdk_gc_set_foreground (gc, & (GTK_WIDGET (calendar)->style->bg[GTK_STATE_SELECTED]));
|
||||||
gdk_gc_set_foreground (gc, SELECTION_FOCUS_COLOR (GTK_WIDGET (calendar)));
|
gdk_draw_rectangle (private_data->main_win, gc, TRUE, x_left, y_top,
|
||||||
else
|
private_data->day_width, day_height);
|
||||||
gdk_gc_set_foreground (gc, SELECTION_NO_FOCUS_COLOR (GTK_WIDGET (calendar)));
|
|
||||||
gdk_draw_rectangle (private_data->main_win, gc, FALSE, x_left, y_top,
|
|
||||||
private_data->day_width-1, day_height-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (calendar->marked_date[day-1])
|
if (calendar->marked_date[day-1])
|
||||||
gdk_gc_set_foreground (gc, MARKED_COLOR (GTK_WIDGET (calendar)));
|
gdk_gc_set_foreground (gc, MARKED_COLOR (GTK_WIDGET (calendar)));
|
||||||
else
|
else
|
||||||
gdk_gc_set_foreground (gc, NORMAL_DAY_COLOR (GTK_WIDGET (calendar)));
|
gdk_gc_set_foreground (gc, NORMAL_DAY_COLOR (GTK_WIDGET (calendar)));
|
||||||
}
|
|
||||||
|
|
||||||
|
if (calendar->selected_day == day)
|
||||||
|
gdk_gc_set_foreground (gc, & (GTK_WIDGET (calendar)->style->fg[GTK_STATE_SELECTED]));
|
||||||
|
else
|
||||||
|
gdk_gc_set_foreground (gc, & (GTK_WIDGET (calendar)->style->fg[GTK_WIDGET_STATE (calendar)]));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sprintf (buffer, "%d", day);
|
sprintf (buffer, "%d", day);
|
||||||
x_loc -= gdk_string_measure (DAY_FONT (widget), buffer);
|
x_loc -= gdk_string_measure (DAY_FONT (widget), buffer);
|
||||||
sprintf (buffer, "%d", day);
|
sprintf (buffer, "%d", day);
|
||||||
@ -1863,6 +1881,15 @@ gtk_calendar_paint_day (GtkWidget *widget,
|
|||||||
gdk_draw_string (private_data->main_win,
|
gdk_draw_string (private_data->main_win,
|
||||||
DAY_FONT (widget), gc,
|
DAY_FONT (widget), gc,
|
||||||
x_loc-1, y_baseline, buffer);
|
x_loc-1, y_baseline, buffer);
|
||||||
|
|
||||||
|
if (GTK_WIDGET_HAS_FOCUS (calendar)
|
||||||
|
&& calendar->focus_row == row && calendar->focus_col == col)
|
||||||
|
{
|
||||||
|
gdk_draw_rectangle (private_data->main_win, calendar->xor_gc,
|
||||||
|
FALSE, x_left, y_top,
|
||||||
|
private_data->day_width-1, day_height-1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2572,7 +2599,7 @@ gtk_calendar_focus_in (GtkWidget *widget,
|
|||||||
|
|
||||||
GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
|
GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
|
||||||
gtk_widget_draw_focus (widget);
|
gtk_widget_draw_focus (widget);
|
||||||
gtk_calendar_paint_day_num (widget, calendar->selected_day);
|
gtk_calendar_paint_day (widget, calendar->focus_row, calendar->focus_col);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -2591,7 +2618,7 @@ gtk_calendar_focus_out (GtkWidget *widget,
|
|||||||
|
|
||||||
GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
|
GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
|
||||||
gtk_widget_draw_focus (widget);
|
gtk_widget_draw_focus (widget);
|
||||||
gtk_calendar_paint_day_num (widget, calendar->selected_day);
|
gtk_calendar_paint_day (widget, calendar->focus_row, calendar->focus_col);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -2602,7 +2629,10 @@ gtk_calendar_key_press (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
GtkCalendar *calendar;
|
GtkCalendar *calendar;
|
||||||
gint return_val;
|
gint return_val;
|
||||||
|
gint old_focus_row;
|
||||||
|
gint old_focus_col;
|
||||||
|
gint row, col, day;
|
||||||
|
|
||||||
g_return_val_if_fail (widget != NULL, FALSE);
|
g_return_val_if_fail (widget != NULL, FALSE);
|
||||||
g_return_val_if_fail (GTK_IS_CALENDAR (widget), FALSE);
|
g_return_val_if_fail (GTK_IS_CALENDAR (widget), FALSE);
|
||||||
g_return_val_if_fail (event != NULL, FALSE);
|
g_return_val_if_fail (event != NULL, FALSE);
|
||||||
@ -2610,105 +2640,121 @@ gtk_calendar_key_press (GtkWidget *widget,
|
|||||||
calendar = GTK_CALENDAR (widget);
|
calendar = GTK_CALENDAR (widget);
|
||||||
return_val = FALSE;
|
return_val = FALSE;
|
||||||
|
|
||||||
|
old_focus_row = calendar->focus_row;
|
||||||
|
old_focus_col = calendar->focus_col;
|
||||||
|
|
||||||
switch (event->keyval)
|
switch (event->keyval)
|
||||||
{
|
{
|
||||||
case GDK_Left:
|
case GDK_Left:
|
||||||
return_val = TRUE;
|
return_val = TRUE;
|
||||||
if (event->state & GDK_CONTROL_MASK)
|
if (event->state & GDK_CONTROL_MASK)
|
||||||
gtk_calendar_set_month_prev (calendar);
|
{
|
||||||
|
gtk_calendar_set_month_prev (calendar);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (calendar->selected_day == 1)
|
if (calendar->focus_col > 0)
|
||||||
{
|
{
|
||||||
if (calendar->display_flags & GTK_CALENDAR_NO_MONTH_CHANGE)
|
calendar->focus_col--;
|
||||||
{
|
|
||||||
gtk_calendar_select_day (calendar, month_length[leap (calendar->year)][calendar->month + 1]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
calendar->selected_day = -1;
|
|
||||||
gtk_calendar_set_month_prev (calendar);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else if (calendar->focus_row > 0)
|
||||||
gtk_calendar_select_day (calendar, calendar->selected_day - 1);
|
{
|
||||||
|
calendar->focus_col = 6;
|
||||||
|
calendar->focus_row--;
|
||||||
|
}
|
||||||
|
gtk_calendar_paint_day (widget, old_focus_row, old_focus_col);
|
||||||
|
gtk_calendar_paint_day (widget, calendar->focus_row,
|
||||||
|
calendar->focus_col);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GDK_Right:
|
case GDK_Right:
|
||||||
return_val = TRUE;
|
return_val = TRUE;
|
||||||
if (event->state & GDK_CONTROL_MASK)
|
if (event->state & GDK_CONTROL_MASK)
|
||||||
|
{
|
||||||
gtk_calendar_set_month_next (calendar);
|
gtk_calendar_set_month_next (calendar);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (calendar->selected_day == month_length[leap (calendar->year)][calendar->month + 1])
|
if (calendar->focus_col < 6)
|
||||||
{
|
{
|
||||||
if (calendar->display_flags & GTK_CALENDAR_NO_MONTH_CHANGE)
|
calendar->focus_col++;
|
||||||
{
|
|
||||||
gtk_calendar_select_day (calendar, 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
calendar->selected_day = 1;
|
|
||||||
gtk_calendar_set_month_next (calendar);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else if (calendar->focus_row < 5)
|
||||||
gtk_calendar_select_day (calendar, calendar->selected_day + 1);
|
{
|
||||||
|
calendar->focus_col = 0;
|
||||||
|
calendar->focus_row++;
|
||||||
|
}
|
||||||
|
gtk_calendar_paint_day (widget, old_focus_row, old_focus_col);
|
||||||
|
gtk_calendar_paint_day (widget, calendar->focus_row,
|
||||||
|
calendar->focus_col);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GDK_Up:
|
case GDK_Up:
|
||||||
return_val = TRUE;
|
return_val = TRUE;
|
||||||
if (event->state & GDK_CONTROL_MASK)
|
if (event->state & GDK_CONTROL_MASK)
|
||||||
gtk_calendar_set_year_prev (calendar);
|
{
|
||||||
|
gtk_calendar_set_year_prev (calendar);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gint overlap;
|
if (calendar->focus_row > 0)
|
||||||
overlap = calendar->selected_day - 7;
|
|
||||||
if (overlap < 1)
|
|
||||||
{
|
{
|
||||||
if (calendar->display_flags & GTK_CALENDAR_NO_MONTH_CHANGE)
|
calendar->focus_row--;
|
||||||
{
|
|
||||||
gint month_len;
|
|
||||||
month_len = month_length[leap (calendar->year)][calendar->month + 1];
|
|
||||||
gtk_calendar_select_day (calendar, month_len - (month_len - (month_len / 7) * 7 - overlap)%7);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
calendar->selected_day = overlap - 1;
|
|
||||||
gtk_calendar_set_month_prev (calendar);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
gtk_calendar_paint_day (widget, old_focus_row, old_focus_col);
|
||||||
gtk_calendar_select_day (calendar, calendar->selected_day - 7);
|
gtk_calendar_paint_day (widget, calendar->focus_row,
|
||||||
|
calendar->focus_col);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GDK_Down:
|
case GDK_Down:
|
||||||
return_val = TRUE;
|
return_val = TRUE;
|
||||||
if (event->state & GDK_CONTROL_MASK)
|
if (event->state & GDK_CONTROL_MASK)
|
||||||
gtk_calendar_set_year_next (calendar);
|
{
|
||||||
|
gtk_calendar_set_year_next (calendar);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gint month_len;
|
if (calendar->focus_row < 5)
|
||||||
gint overlap;
|
|
||||||
month_len = month_length[leap (calendar->year)][calendar->month + 1];
|
|
||||||
overlap = (calendar->selected_day + 7 - month_len);
|
|
||||||
if (overlap > 0)
|
|
||||||
{
|
{
|
||||||
if (calendar->display_flags & GTK_CALENDAR_NO_MONTH_CHANGE)
|
calendar->focus_row++;
|
||||||
{
|
|
||||||
gtk_calendar_select_day (calendar, (month_len - 1 - (month_len / 7) * 7
|
|
||||||
+ overlap) % 7 + 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
calendar->selected_day = overlap;
|
|
||||||
gtk_calendar_set_month_next (calendar);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
gtk_calendar_paint_day (widget, old_focus_row, old_focus_col);
|
||||||
gtk_calendar_select_day (calendar, calendar->selected_day + 7);
|
gtk_calendar_paint_day (widget, calendar->focus_row,
|
||||||
|
calendar->focus_col);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case GDK_space:
|
||||||
|
row = calendar->focus_row;
|
||||||
|
col = calendar->focus_col;
|
||||||
|
day = calendar->day[row][col];
|
||||||
|
|
||||||
|
if (row > -1 && col > -1)
|
||||||
|
{
|
||||||
|
gtk_calendar_freeze (calendar);
|
||||||
|
|
||||||
|
if (calendar->day_month[row][col] == MONTH_PREV)
|
||||||
|
{
|
||||||
|
gtk_calendar_set_month_prev (calendar);
|
||||||
|
}
|
||||||
|
else if (calendar->day_month[row][col] == MONTH_NEXT)
|
||||||
|
{
|
||||||
|
gtk_calendar_set_month_next (calendar);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_calendar_select_day (calendar, day);
|
||||||
|
|
||||||
|
for (row = 0; row < 6; row ++)
|
||||||
|
for (col = 0; col < 7; col++)
|
||||||
|
{
|
||||||
|
if (calendar->day_month[row][col] == MONTH_CURRENT
|
||||||
|
&& calendar->day[row][col] == day)
|
||||||
|
{
|
||||||
|
calendar->focus_row = row;
|
||||||
|
calendar->focus_col = col;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gtk_calendar_thaw (calendar);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return return_val;
|
return return_val;
|
||||||
|
@ -71,9 +71,13 @@ struct _GtkCalendar
|
|||||||
GdkColor marked_date_color[31];
|
GdkColor marked_date_color[31];
|
||||||
|
|
||||||
GdkGC *gc;
|
GdkGC *gc;
|
||||||
|
GdkGC *xor_gc;
|
||||||
guint highlight_row;
|
|
||||||
guint highlight_col;
|
gint focus_row;
|
||||||
|
gint focus_col;
|
||||||
|
|
||||||
|
gint highlight_row;
|
||||||
|
gint highlight_col;
|
||||||
|
|
||||||
gpointer private_data;
|
gpointer private_data;
|
||||||
char grow_space [32];
|
char grow_space [32];
|
||||||
|
Loading…
Reference in New Issue
Block a user