GTK+ Reference Manual
<<< Previous Page | Home | Up | Next Page >>>

# GtkCalendar

## Name

GtkCalendar -- display a calendar and/or allow the user to select a date.

## Synopsis

    #include <gtk/gtk.h>

    struct      GtkCalendar;
    enum        GtkCalendarDisplayOptions;
    GtkWidget*  gtk_calendar_new                (void);
    gint        gtk_calendar_select_month       (GtkCalendar *calendar,
                                                 guint month,
                                                 guint year);
    void        gtk_calendar_select_day         (GtkCalendar *calendar,
                                                 guint day);
    gint        gtk_calendar_mark_day           (GtkCalendar *calendar,
                                                 guint day);
    gint        gtk_calendar_unmark_day         (GtkCalendar *calendar,
                                                 guint day);
    void        gtk_calendar_clear_marks        (GtkCalendar *calendar);
    void        gtk_calendar_display_options    (GtkCalendar *calendar,
                                                 GtkCalendarDisplayOptions flags);
    void        gtk_calendar_get_date           (GtkCalendar *calendar,
                                                 guint *year,
                                                 guint *month,
                                                 guint *day);
    void        gtk_calendar_freeze             (GtkCalendar *calendar);
    void        gtk_calendar_thaw               (GtkCalendar *calendar);

## Object Hierarchy

      GtkObject
       +----GtkWidget
             +----GtkCalendar

## Signal Prototypes

    "month-changed"
                void        user_function      (GtkCalendar *calendar,
                                                gpointer user_data);
    "day-selected"
                void        user_function      (GtkCalendar *calendar,
                                                gpointer user_data);
    "day-selected-double-click"
                void        user_function      (GtkCalendar *calendar,
                                                gpointer user_data);
    "prev-month"
                void        user_function      (GtkCalendar *calendar,
                                                gpointer user_data);
    "next-month"
                void        user_function      (GtkCalendar *calendar,
                                                gpointer user_data);
    "prev-year" void        user_function      (GtkCalendar *calendar,
                                                gpointer user_data);
    "next-year" void        user_function      (GtkCalendar *calendar,
                                                gpointer user_data);

## Description

GtkCalendar is a widget that displays a calendar, one month at a time. It can be created with gtk_calendar_new().

The month and year currently displayed can be altered with gtk_calendar_select_month(). The exact day can be selected from the displayed month using gtk_calendar_select_day().

FIXME: (check)To place a visual marker on a particular day, use gtk_calendar_mark_day() and to remove the marker, gtk_calendar_unmark_day(). Alternative, all marks can be cleared with gtk_calendar_clear_marks().

The way in which the calendar itself is displayed can be altered using gtk_calendar_display_options().

The selected date can be retrieved from a GtkCalendar using gtk_calendar_get_date().

If performing many 'mark' operations, the calendar can be frozen to prevent flicker, using gtk_calendar_freeze(), and 'thawed' again using gtk_calendar_thaw().

## Details

### struct GtkCalendar

    struct GtkCalendar;

`num_marked_dates` is an integer containing the number of days that have a mark over them.

`marked_date` is an array containing the day numbers that currently have a mark over them.

`month`, `year`, and `selected_day` contain the currently visible month, year, and selected day respectively.

All of these fields should be considered read only, and everything in this struct should only be modified using the functions provided below.

### enum GtkCalendarDisplayOptions

    typedef enum
    {
      GTK_CALENDAR_SHOW_HEADING		= 1 << 0,
      GTK_CALENDAR_SHOW_DAY_NAMES		= 1 << 1,
      GTK_CALENDAR_NO_MONTH_CHANGE		= 1 << 2,
      GTK_CALENDAR_SHOW_WEEK_NUMBERS	= 1 << 3,
      GTK_CALENDAR_WEEK_START_MONDAY	= 1 << 4
    } GtkCalendarDisplayOptions;

GTK_CALENDAR_SHOW_HEADING | Specifies that the month and year should be displayed.
GTK_CALENDAR_SHOW_DAY_NAMES | Specifies that three letter day descriptions should be present.
GTK_CALENDAR_NO_MONTH_CHANGE | Prevents the user from switching months with the calendar.
GTK_CALENDAR_SHOW_WEEK_NUMBERS | Displays each week numbers of the current year, down the left side of the calendar.
GTK_CALENDAR_WEEK_START_MONDAY | Starts the calendar week on Monday, instead of the default Sunday.

### gtk_calendar_new ()

    GtkWidget*  gtk_calendar_new                (void);

Creates a new calendar. FIXME:default date.

Returns : | a GtkCalendar.

### gtk_calendar_select_month ()

    gint        gtk_calendar_select_month       (GtkCalendar *calendar,
                                                 guint month,
                                                 guint year);

Shifts the calendar to a different month.

`calendar` : | a GtkCalendar.
`month` : | a month number.
`year` : | the year the month is in.
Returns : | FIXME.

### gtk_calendar_select_day ()

    void        gtk_calendar_select_day         (GtkCalendar *calendar,
                                                 guint day);

Selects a day from the current month.

`calendar` : | a GtkCalendar.
`day` : | the day number to select.

### gtk_calendar_mark_day ()

    gint        gtk_calendar_mark_day           (GtkCalendar *calendar,
                                                 guint day);

`calendar` : |
`day` : |
Returns : |

### gtk_calendar_unmark_day ()

    gint        gtk_calendar_unmark_day         (GtkCalendar *calendar,
                                                 guint day);

`calendar` : |
`day` : |
Returns : |

### gtk_calendar_clear_marks ()

    void        gtk_calendar_clear_marks        (GtkCalendar *calendar);

`calendar` : |

### gtk_calendar_display_options ()

    void        gtk_calendar_display_options    (GtkCalendar *calendar,
                                                 GtkCalendarDisplayOptions flags);

`calendar` : |
`flags` : |

### gtk_calendar_get_date ()

    void        gtk_calendar_get_date           (GtkCalendar *calendar,
                                                 guint *year,
                                                 guint *month,
                                                 guint *day);

`calendar` : |
`year` : |
`month` : |
`day` : |

### gtk_calendar_freeze ()

    void        gtk_calendar_freeze             (GtkCalendar *calendar);

Locks the display of the calendar until it is thawed with gtk_calendar_thaw().

`calendar` : | a GtkCalendar.

### gtk_calendar_thaw ()

    void        gtk_calendar_thaw               (GtkCalendar *calendar);

Defrosts a calendar; all the changes made since the last gtk_calendar_freeze() are displayed.

`calendar` : | a GtkCalendar.

## Signals

### The "month-changed" signal

    void        user_function                  (GtkCalendar *calendar,
                                                gpointer user_data);

Emitted when the user clicks a button to change the selected month on a calendar.

`calendar` : | the object which received the signal.
`user_data` : | user data set when the signal handler was connected.

### The "day-selected" signal

    void        user_function                  (GtkCalendar *calendar,
                                                gpointer user_data);

Emitted when the user selects a day.

`calendar` : | the object which received the signal.
`user_data` : | user data set when the signal handler was connected.

### The "day-selected-double-click" signal

    void        user_function                  (GtkCalendar *calendar,
                                                gpointer user_data);

`calendar` : | the object which received the signal.
`user_data` : | user data set when the signal handler was connected.

### The "prev-month" signal

    void        user_function                  (GtkCalendar *calendar,
                                                gpointer user_data);

`calendar` : | the object which received the signal.
`user_data` : | user data set when the signal handler was connected.

### The "next-month" signal

    void        user_function                  (GtkCalendar *calendar,
                                                gpointer user_data);

`calendar` : | the object which received the signal.
`user_data` : | user data set when the signal handler was connected.

### The "prev-year" signal

    void        user_function                  (GtkCalendar *calendar,
                                                gpointer user_data);

`calendar` : | the object which received the signal.
`user_data` : | user data set when the signal handler was connected.

### The "next-year" signal

    void        user_function                  (GtkCalendar *calendar,
                                                gpointer user_data);

`calendar` : | the object which received the signal.
`user_data` : | user data set when the signal handler was connected.

<<< Previous Page | Home | Up | Next Page >>>
GtkButton | GtkCheckButton