1 /********************************************************************\ 2 * gnc-dense-cal.h : a custom densely-dispalyed calendar widget * 3 * Copyright (C) 2002,2006 Joshua Sled <jsled@asynchronous.org> * 4 * * 5 * This program is free software; you can redistribute it and/or * 6 * modify it under the terms of the GNU General Public License as * 7 * published by the Free Software Foundation, under version 2 and/or version 3 of * 8 * the License. * 9 * * 10 * This program is distributed in the hope that it will be useful, * 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 13 * GNU General Public License for more details. * 14 * * 15 * You should have received a copy of the GNU General Public License* 16 * along with this program; if not, contact: * 17 * * 18 * Free Software Foundation Voice: +1-617-542-5942 * 19 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 * 20 * Boston, MA 02110-1301, USA gnu@gnu.org * 21 \********************************************************************/ 22 23 #ifndef _GNC_DENSE_CAL_H 24 #define _GNC_DENSE_CAL_H 25 26 #include <config.h> 27 28 #include <glib.h> 29 #include "gnc-dense-cal-model.h" 30 #include <gtk/gtk.h> 31 32 G_BEGIN_DECLS 33 34 #define GNC_TYPE_DENSE_CAL (gnc_dense_cal_get_type ()) 35 #define GNC_DENSE_CAL(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, gnc_dense_cal_get_type (), GncDenseCal) 36 #define GNC_DENSE_CAL_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, gnc_dense_cal_get_type (), GncDenseCalClass) 37 #define GNC_IS_DENSE_CAL(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, gnc_dense_cal_get_type ()) 38 39 typedef struct _GncDenseCal GncDenseCal; 40 typedef struct _GncDenseCalClass GncDenseCalClass; 41 42 typedef struct _gdc_month_coords 43 { 44 gint x, y; 45 } gdc_month_coords; 46 47 struct _GncDenseCal 48 { 49 GtkBox widget; 50 51 GtkComboBox *view_options; 52 GtkDrawingArea *cal_drawing_area; 53 54 cairo_surface_t *surface; 55 56 gboolean initialized; 57 58 gboolean showPopup; 59 GtkWindow *transPopup; 60 gint screen_width; 61 gint screen_height; 62 gint doc; 63 64 gint min_x_scale; 65 gint min_y_scale; 66 67 gint x_scale; 68 gint y_scale; 69 70 gint numMonths; 71 gint monthsPerCol; 72 gint num_weeks; /* computed */ 73 74 GDateMonth month; 75 gint year; 76 gint firstOfMonthOffset; 77 78 gint leftPadding; 79 gint topPadding; 80 81 gdc_month_coords monthPositions[12]; 82 83 guint label_width; 84 guint label_height; 85 gint dayLabelHeight; 86 87 GncDenseCalModel *model; 88 89 guint lastMarkTag; 90 91 gint week_starts_monday; 92 93 /** 94 * A GList of gdc_mark_data structs, one for each active/valid markTag. 95 **/ 96 GList *markData; 97 int numMarks; 98 /* array of GList*s of per-cell markings. */ 99 GList **marks; 100 101 int disposed; /* private */ 102 }; 103 104 struct _GncDenseCalClass 105 { 106 GtkVBoxClass parent_class; 107 }; 108 109 typedef struct _gdc_mark_data 110 { 111 gchar *name; 112 gchar *info; 113 guint tag; 114 /** 115 * A GList of the dcal->marks indexes containing this mark. 116 **/ 117 GList *ourMarks; 118 } gdc_mark_data; 119 120 GtkWidget* gnc_dense_cal_new (void); 121 GtkWidget* gnc_dense_cal_new_with_model (GncDenseCalModel *model); 122 GType gnc_dense_cal_get_type (void); 123 124 void gnc_dense_cal_set_model(GncDenseCal *cal, GncDenseCalModel *model); 125 126 void gnc_dense_cal_set_month(GncDenseCal *dcal, GDateMonth mon); 127 GDateMonth gnc_dense_cal_get_month( GncDenseCal *dcal ); 128 /** 129 * @param year Julian year: 2000 = 2000AD. 130 **/ 131 void gnc_dense_cal_set_year( GncDenseCal *dcal, guint year ); 132 GDateYear gnc_dense_cal_get_year( GncDenseCal *dcal ); 133 134 void gnc_dense_cal_set_num_months( GncDenseCal *dcal, guint num_months ); 135 guint gnc_dense_cal_get_num_months( GncDenseCal *dcal ); 136 137 void gnc_dense_cal_set_months_per_col( GncDenseCal *dcal, guint monthsPerCol ); 138 139 G_END_DECLS 140 141 #endif /* _GNC_DENSE_CAL_H */ 142