|
GnuCash 2.4.99
|
00001 /********************************************************************\ 00002 * table-model.h -- 2D grid table object model * 00003 * Copyright (c) 2001 Free Software Foundation * 00004 * Author: Dave Peticolas <dave@krondo.com> * 00005 * * 00006 * This program is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU General Public License as * 00008 * published by the Free Software Foundation; either version 2 of * 00009 * the License, or (at your option) any later version. * 00010 * * 00011 * This program is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00014 * GNU General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU General Public License* 00017 * along with this program; if not, contact: * 00018 * * 00019 * Free Software Foundation Voice: +1-617-542-5942 * 00020 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 * 00021 * Boston, MA 02110-1301, USA gnu@gnu.org * 00022 * * 00023 \********************************************************************/ 00024 00025 #ifndef TABLE_MODEL_H 00026 #define TABLE_MODEL_H 00027 00028 #include <glib.h> 00029 00030 #include "basiccell.h" 00031 #include "register-common.h" 00032 00033 typedef enum 00034 { 00035 XACC_CELL_ALLOW_NONE = 0, 00036 XACC_CELL_ALLOW_INPUT = 1 << 0, 00037 XACC_CELL_ALLOW_SHADOW = 1 << 1, 00038 XACC_CELL_ALLOW_ALL = XACC_CELL_ALLOW_INPUT | XACC_CELL_ALLOW_SHADOW, 00039 XACC_CELL_ALLOW_EXACT_ONLY = 1 << 2, 00040 XACC_CELL_ALLOW_ENTER = 1 << 3, 00041 XACC_CELL_ALLOW_READ_ONLY = XACC_CELL_ALLOW_SHADOW | XACC_CELL_ALLOW_ENTER 00042 } CellIOFlags; 00043 00044 typedef enum 00045 { 00046 CELL_BORDER_LINE_NONE, 00047 CELL_BORDER_LINE_LIGHT, 00048 CELL_BORDER_LINE_NORMAL, 00049 CELL_BORDER_LINE_HEAVY, 00050 CELL_BORDER_LINE_HIGHLIGHT 00051 } PhysicalCellBorderLineStyle; 00052 00053 typedef struct 00054 { 00055 PhysicalCellBorderLineStyle top; 00056 PhysicalCellBorderLineStyle bottom; 00057 PhysicalCellBorderLineStyle left; 00058 PhysicalCellBorderLineStyle right; 00059 } PhysicalCellBorders; 00060 00061 typedef const char * (*TableGetEntryHandler) (VirtualLocation virt_loc, 00062 gboolean translate, 00063 gboolean *conditionally_changed, 00064 gpointer user_data); 00065 00066 typedef const char * (*TableGetLabelHandler) (VirtualLocation virt_loc, 00067 gpointer user_data); 00068 00069 typedef char * (*TableGetHelpHandler) (VirtualLocation virt_loc, 00070 gpointer user_data); 00071 00072 typedef CellIOFlags (*TableGetCellIOFlagsHandler) (VirtualLocation virt_loc, 00073 gpointer user_data); 00074 00075 typedef guint32 (*TableGetFGColorHandler) (VirtualLocation virt_loc, 00076 gpointer user_data); 00077 00078 typedef guint32 (*TableGetBGColorHandler) (VirtualLocation virt_loc, 00079 gboolean *hatching, 00080 gpointer user_data); 00081 00082 typedef void (*TableGetCellBorderHandler) (VirtualLocation virt_loc, 00083 PhysicalCellBorders *borders, 00084 gpointer user_data); 00085 00086 typedef gboolean (*TableConfirmHandler) (VirtualLocation virt_loc, 00087 gpointer user_data); 00088 00089 typedef void (*TableSaveCellHandler) (BasicCell * cell, 00090 gpointer save_data, 00091 gpointer user_data); 00092 00093 typedef void (*TableSaveHandler) (gpointer save_data, 00094 gpointer user_data); 00095 00096 typedef gpointer (*VirtCellDataAllocator) (void); 00097 typedef void (*VirtCellDataDeallocator) (gpointer cell_data); 00098 typedef void (*VirtCellDataCopy) (gpointer to, gconstpointer from); 00099 00100 typedef struct 00101 { 00102 GHashTable *entry_handlers; 00103 GHashTable *label_handlers; 00104 GHashTable *help_handlers; 00105 GHashTable *io_flags_handlers; 00106 GHashTable *fg_color_handlers; 00107 GHashTable *bg_color_handlers; 00108 GHashTable *cell_border_handlers; 00109 GHashTable *confirm_handlers; 00110 00111 GHashTable *save_handlers; 00112 TableSaveHandler pre_save_handler; 00113 TableSaveHandler post_save_handler; 00114 00115 gpointer handler_user_data; 00116 00117 /* If true, denotes that this table is read-only 00118 * and edits should not be allowed. */ 00119 gboolean read_only; 00120 00121 /* If positive, denotes a row that marks a boundary that should 00122 * be visually distinguished. */ 00123 int dividing_row; 00124 /* If positive, denotes a row that marks a boundary that should 00125 * be visually distinguished, but different from the other. */ 00126 int dividing_row_upper; 00127 00128 VirtCellDataAllocator cell_data_allocator; 00129 VirtCellDataDeallocator cell_data_deallocator; 00130 VirtCellDataCopy cell_data_copy; 00131 } TableModel; 00132 00133 00134 TableModel * gnc_table_model_new (void); 00135 void gnc_table_model_destroy (TableModel *model); 00136 00137 void gnc_table_model_set_read_only (TableModel *model, 00138 gboolean read_only); 00139 gboolean gnc_table_model_read_only (TableModel *model); 00140 00141 void gnc_table_model_set_entry_handler 00142 (TableModel *model, 00143 TableGetEntryHandler entry_handler, 00144 const char * cell_name); 00145 void gnc_table_model_set_default_entry_handler 00146 (TableModel *model, 00147 TableGetEntryHandler entry_handler); 00148 TableGetEntryHandler gnc_table_model_get_entry_handler 00149 (TableModel *model, 00150 const char * cell_name); 00151 00152 void gnc_table_model_set_label_handler 00153 (TableModel *model, 00154 TableGetLabelHandler label_handler, 00155 const char * cell_name); 00156 void gnc_table_model_set_default_label_handler 00157 (TableModel *model, 00158 TableGetLabelHandler label_handler); 00159 TableGetLabelHandler gnc_table_model_get_label_handler 00160 (TableModel *model, 00161 const char * cell_name); 00162 00163 void gnc_table_model_set_help_handler 00164 (TableModel *model, 00165 TableGetHelpHandler help_handler, 00166 const char * cell_name); 00167 void gnc_table_model_set_default_help_handler 00168 (TableModel *model, 00169 TableGetHelpHandler help_handler); 00170 TableGetHelpHandler gnc_table_model_get_help_handler 00171 (TableModel *model, 00172 const char * cell_name); 00173 00174 void gnc_table_model_set_io_flags_handler 00175 (TableModel *model, 00176 TableGetCellIOFlagsHandler io_flags_handler, 00177 const char * cell_name); 00178 void gnc_table_model_set_default_io_flags_handler 00179 (TableModel *model, 00180 TableGetCellIOFlagsHandler io_flags_handler); 00181 TableGetCellIOFlagsHandler gnc_table_model_get_io_flags_handler 00182 (TableModel *model, 00183 const char * cell_name); 00184 00185 void gnc_table_model_set_fg_color_handler 00186 (TableModel *model, 00187 TableGetFGColorHandler io_flags_handler, 00188 const char * cell_name); 00189 void gnc_table_model_set_default_fg_color_handler 00190 (TableModel *model, 00191 TableGetFGColorHandler io_flags_handler); 00192 TableGetFGColorHandler gnc_table_model_get_fg_color_handler 00193 (TableModel *model, 00194 const char * cell_name); 00195 00196 void gnc_table_model_set_bg_color_handler 00197 (TableModel *model, 00198 TableGetBGColorHandler io_flags_handler, 00199 const char * cell_name); 00200 void gnc_table_model_set_default_bg_color_handler 00201 (TableModel *model, 00202 TableGetBGColorHandler io_flags_handler); 00203 TableGetBGColorHandler gnc_table_model_get_bg_color_handler 00204 (TableModel *model, 00205 const char * cell_name); 00206 00207 void gnc_table_model_set_cell_border_handler 00208 (TableModel *model, 00209 TableGetCellBorderHandler io_flags_handler, 00210 const char * cell_name); 00211 void gnc_table_model_set_default_cell_border_handler 00212 (TableModel *model, 00213 TableGetCellBorderHandler io_flags_handler); 00214 TableGetCellBorderHandler gnc_table_model_get_cell_border_handler 00215 (TableModel *model, 00216 const char * cell_name); 00217 00218 void gnc_table_model_set_confirm_handler 00219 (TableModel *model, 00220 TableConfirmHandler io_flags_handler, 00221 const char * cell_name); 00222 void gnc_table_model_set_default_confirm_handler 00223 (TableModel *model, 00224 TableConfirmHandler io_flags_handler); 00225 TableConfirmHandler gnc_table_model_get_confirm_handler 00226 (TableModel *model, 00227 const char * cell_name); 00228 00229 void gnc_table_model_set_save_handler 00230 (TableModel *model, 00231 TableSaveCellHandler save_handler, 00232 const char * cell_name); 00233 void gnc_table_model_set_pre_save_handler 00234 (TableModel *model, 00235 TableSaveHandler save_handler); 00236 void gnc_table_model_set_post_save_handler 00237 (TableModel *model, 00238 TableSaveHandler save_handler); 00239 TableSaveCellHandler gnc_table_model_get_save_handler 00240 (TableModel *model, 00241 const char * cell_name); 00242 TableSaveHandler gnc_table_model_get_pre_save_handler 00243 (TableModel *model); 00244 TableSaveHandler gnc_table_model_get_post_save_handler 00245 (TableModel *model); 00246 00247 #endif
1.7.4