aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc/e-calendar-item.h
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/misc/e-calendar-item.h')
-rw-r--r--widgets/misc/e-calendar-item.h179
1 files changed, 153 insertions, 26 deletions
diff --git a/widgets/misc/e-calendar-item.h b/widgets/misc/e-calendar-item.h
index a59ca6d407..3091e47bb4 100644
--- a/widgets/misc/e-calendar-item.h
+++ b/widgets/misc/e-calendar-item.h
@@ -34,18 +34,42 @@ extern "C" {
* ECalendarItem - canvas item displaying a calendar.
*/
-#define E_CALENDAR_ITEM_YPAD1 1
-#define E_CALENDAR_ITEM_YPAD2 1
+#define E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME 1
+#define E_CALENDAR_ITEM_YPAD_BELOW_MONTH_NAME 1
+
+/* Used to mark days as bold in e_calendar_item_mark_day(). */
+#define E_CALENDAR_ITEM_MARK_BOLD 1
+
/* These index our colors array. */
typedef enum
{
- E_CALENDAR_COLOR_SELECTION,
- E_CALENDAR_COLOR_HIGHLIGHT,
- E_CALENDAR_COLOR_TODAY,
+ E_CALENDAR_ITEM_COLOR_TODAY_BOX,
+ E_CALENDAR_ITEM_COLOR_SELECTION_FG,
+ E_CALENDAR_ITEM_COLOR_SELECTION_BG,
+ E_CALENDAR_ITEM_COLOR_PREV_OR_NEXT_MONTH_FG,
- E_CALENDAR_COLOR_LAST
-} ECalendarColors;
+ E_CALENDAR_ITEM_COLOR_LAST
+} ECalendarItemColors;
+
+typedef struct _ECalendarItem ECalendarItem;
+typedef struct _ECalendarItemClass ECalendarItemClass;
+
+typedef void (*ECalendarItemStyleCallback) (ECalendarItem *calitem,
+ gint year,
+ gint month,
+ gint day,
+ gint day_style,
+ gboolean today,
+ gboolean prev_or_next_month,
+ gboolean selected,
+ gboolean has_focus,
+ gboolean drop_target,
+ GdkColor **bg_color,
+ GdkColor **fg_color,
+ GdkColor **box_color,
+ gboolean *bold,
+ gpointer data);
#define E_CALENDAR_ITEM(obj) (GTK_CHECK_CAST((obj), \
@@ -55,23 +79,34 @@ typedef enum
#define E_IS_CALENDAR_ITEM(o) (GTK_CHECK_TYPE((o), \
e_calendar_item_get_type ()))
-typedef struct {
+struct _ECalendarItem
+{
GnomeCanvasItem canvas_item;
/* The year & month of the first calendar being displayed. */
gint year;
gint month; /* 0 to 11 */
- /* Bounds of item. */
- gdouble x1, y1, x2, y2;
+ /* Points to an array of styles, one char for each day. We use 32
+ chars for each month, with n + 2 months, where n is the number of
+ complete months shown (since we show some days before the first
+ month and after the last month grayes out).
+ A value of 0 is the default, and 1 is bold. */
+ guint8 *styles;
+
+ /*
+ * Options.
+ */
- /* The minimum & maximum number of rows & columns of months. */
+ /* The minimum & maximum number of rows & columns of months.
+ If the maximum values are -1 then there is no maximum.
+ The minimum valies default to 1. The maximum values to -1. */
gint min_rows;
gint min_cols;
gint max_rows;
gint max_cols;
- /* The number of rows & columns of months. */
+ /* The actual number of rows & columns of months. */
gint rows;
gint cols;
@@ -84,6 +119,27 @@ typedef struct {
/* Whether the cells expand to fill extra space. */
gboolean expand;
+ /* The maximum number of days that can be selected. Defaults to 1. */
+ gint max_days_selected;
+
+ /* The number of days selected before we switch to selecting whole
+ weeks, or -1 if we never switch. Defaults to -1. */
+ gint days_to_start_week_selection;
+
+ /* Whether the selection is rounded down to the nearest week when we
+ move back/forward one month. Used for the week view. */
+ gboolean round_selection_when_moving;
+
+ /* The space to leave at the bottom for the Today & None buttons. */
+ gdouble buttons_space;
+
+ /*
+ * Internal stuff.
+ */
+
+ /* Bounds of item. */
+ gdouble x1, y1, x2, y2;
+
/* The minimum size of each month, based on the fonts used. */
gint min_month_width;
gint min_month_height;
@@ -103,16 +159,18 @@ typedef struct {
gint cell_width;
gint cell_height;
-
/* The current selection. The month offsets are from 0, which is the
- top-left calendar month view. The day offsets are from 0, which is
- the top-left cell in the month view (which may be empty). */
- gint selection_start_month_offset;
- gint selection_start_day_offset;
- gint selection_end_month_offset;
- gint selection_end_day_offset;
+ top-left calendar month view. Note that -1 is used for the last days
+ from the previous month. The days are real month days. */
gboolean selecting;
gboolean selection_dragging_end;
+ gboolean selection_from_full_week;
+ gint selection_start_month_offset;
+ gint selection_start_day;
+ gint selection_end_month_offset;
+ gint selection_end_day;
+ gint selection_real_start_month_offset;
+ gint selection_real_start_day;
/* The first character of each day of the week, e.g. 'MTWTFSS'. */
gchar *days;
@@ -131,18 +189,87 @@ typedef struct {
GdkFont *font, *old_font;
GdkFont *week_number_font, *old_week_number_font;
- /* Colors for drawing. */
- GdkColor colors[E_CALENDAR_COLOR_LAST];
-} ECalendarItem;
+ ECalendarItemStyleCallback style_callback;
+ gpointer style_callback_data;
+ GtkDestroyNotify style_callback_destroy;
-typedef struct {
- GnomeCanvasItemClass parent_class;
+ /* Colors for drawing. */
+ GdkColor colors[E_CALENDAR_ITEM_COLOR_LAST];
-} ECalendarItemClass;
+ /* Our idle handler for emitting signals. */
+ gint signal_emission_idle_id;
+ /* A flag to indicate that the selection or date range has changed.
+ When set the idle function will emit the signal and reset it to
+ FALSE. This is so we don't emit it several times when args are set
+ etc. */
+ gboolean selection_changed;
+ gboolean date_range_changed;
+};
-GtkType e_calendar_item_get_type (void);
+struct _ECalendarItemClass
+{
+ GnomeCanvasItemClass parent_class;
+ void (* date_range_changed) (ECalendarItem *calitem);
+ void (* selection_changed) (ECalendarItem *calitem);
+};
+
+
+GtkType e_calendar_item_get_type (void);
+
+void e_calendar_item_get_first_month (ECalendarItem *calitem,
+ gint *year,
+ gint *month);
+void e_calendar_item_set_first_month (ECalendarItem *calitem,
+ gint year,
+ gint month);
+
+/* Returns the range of dates actually shown. Months are 0 to 11.
+ This also includes the last days of the previous month and the first days
+ of the following month, which are normally shown in gray. */
+void e_calendar_item_get_date_range (ECalendarItem *calitem,
+ gint *start_year,
+ gint *start_month,
+ gint *start_day,
+ gint *end_year,
+ gint *end_month,
+ gint *end_day);
+
+gboolean e_calendar_item_get_selection (ECalendarItem *calitem,
+ GDate *start_date,
+ GDate *end_date);
+void e_calendar_item_set_selection (ECalendarItem *calitem,
+ GDate *start_date,
+ GDate *end_date);
+
+/* Marks a particular day. Passing E_CALENDAR_ITEM_MARK_BOLD as the day style
+ will result in the day being shown as bold by default. The style callback
+ could support more day_styles, or the style callback could determine the
+ colors itself, without needing to mark days. */
+void e_calendar_item_clear_marks (ECalendarItem *calitem);
+void e_calendar_item_mark_day (ECalendarItem *calitem,
+ gint year,
+ gint month,
+ gint day,
+ guint8 day_style);
+
+/* Mark a range of days. Any days outside the currently shown range are
+ ignored. */
+void e_calendar_item_mark_days (ECalendarItem *calitem,
+ gint start_year,
+ gint start_month,
+ gint start_day,
+ gint end_year,
+ gint end_month,
+ gint end_day,
+ guint8 day_style);
+
+/* Sets the function to call to get the colors to use for a particular day. */
+void e_calendar_item_set_style_callback (ECalendarItem *calitem,
+ ECalendarItemStyleCallback cb,
+ gpointer data,
+ GtkDestroyNotify destroy);
#ifdef __cplusplus
}