aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc/e-calendar-item.h
blob: a59ca6d407f5ea335ce96ec76b15c874fa50c525 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */

/* 
 * Author : 
 *  Damon Chaplin <damon@helixcode.com>
 *
 * Copyright 2000, Helix Code, Inc.
 *
 * This program is free software; you can redistribute it and/or 
 * modify it under the terms of the GNU General Public License as 
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */
#ifndef _E_CALENDAR_ITEM_H_
#define _E_CALENDAR_ITEM_H_

#include <libgnomeui/gnome-canvas.h>

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/*
 * ECalendarItem - canvas item displaying a calendar.
 */

#define E_CALENDAR_ITEM_YPAD1   1
#define E_CALENDAR_ITEM_YPAD2   1

/* These index our colors array. */
typedef enum
{
    E_CALENDAR_COLOR_SELECTION,
    E_CALENDAR_COLOR_HIGHLIGHT,
    E_CALENDAR_COLOR_TODAY,
    
    E_CALENDAR_COLOR_LAST
} ECalendarColors;


#define E_CALENDAR_ITEM(obj)     (GTK_CHECK_CAST((obj), \
        e_calendar_item_get_type (), ECalendarItem))
#define E_CALENDAR_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k),\
    e_calendar_item_get_type ()))
#define E_IS_CALENDAR_ITEM(o)    (GTK_CHECK_TYPE((o), \
    e_calendar_item_get_type ()))

typedef struct {
    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;

    /* The minimum & maximum number of rows & columns of months. */
    gint min_rows;
    gint min_cols;
    gint max_rows;
    gint max_cols;

    /* The number of rows & columns of months. */
    gint rows;
    gint cols;

    /* Whether we show week nubers. */
    gboolean show_week_numbers;

    /* The first day of the week, 0 (Monday) to 6 (Sunday). */
    gint week_start_day;

    /* Whether the cells expand to fill extra space. */
    gboolean expand;

    /* The minimum size of each month, based on the fonts used. */
    gint min_month_width;
    gint min_month_height;

    /* The actual size of each month, after dividing extra space. */
    gint month_width;
    gint month_height;

    /* The offset to the left edge of the first calendar. */
    gint x_offset;

    /* The padding around each calendar month. */
    gint month_lpad, month_rpad;
    gint month_tpad, month_bpad;

    /* The size of each cell. */
    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;
    gboolean selecting;
    gboolean selection_dragging_end;

    /* The first character of each day of the week, e.g. 'MTWTFSS'. */
    gchar *days;

    /* Widths of the day characters. */
    gint day_widths[7];

    /* Widths of the digits, '0' .. '9'. */
    gint digit_widths[10];
    gint max_digit_width;
    gint week_number_digit_widths[10];
    gint max_week_number_digit_width;

    /* Fonts for drawing text. If font isn't set it uses the font from the
       canvas widget. If week_number_font isn't set it uses font. */
    GdkFont *font, *old_font;
    GdkFont *week_number_font, *old_week_number_font;

    /* Colors for drawing. */
    GdkColor colors[E_CALENDAR_COLOR_LAST];
} ECalendarItem;

typedef struct {
    GnomeCanvasItemClass parent_class;

} ECalendarItemClass;


GtkType  e_calendar_item_get_type   (void);


#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* _E_CALENDAR_ITEM_H_ */