|
GnuCash 2.4.99
|
00001 /********************************************************************\ 00002 * register-common.c -- Common functions for the register * 00003 * Copyright (c) 2001 Dave Peticolas * 00004 * * 00005 * This program is free software; you can redistribute it and/or * 00006 * modify it under the terms of the GNU General Public License as * 00007 * published by the Free Software Foundation; either version 2 of * 00008 * the License, or (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License* 00016 * along with this program; if not, contact: * 00017 * * 00018 * Free Software Foundation Voice: +1-617-542-5942 * 00019 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 * 00020 * Boston, MA 02110-1301, USA gnu@gnu.org * 00021 * * 00022 \********************************************************************/ 00023 00024 #include "config.h" 00025 00026 #include "basiccell.h" 00027 #include "cell-factory.h" 00028 #include "combocell.h" 00029 #include "datecell.h" 00030 #include "formulacell.h" 00031 #include "numcell.h" 00032 #include "pricecell.h" 00033 #include "recncell.h" 00034 #include "checkboxcell.h" 00035 #include "register-common.h" 00036 #include "quickfillcell.h" 00037 00038 00039 static gboolean register_inited = FALSE; 00040 static CellFactory *global_factory = NULL; 00041 00042 void 00043 gnc_register_init (void) 00044 { 00045 if (register_inited) 00046 return; 00047 00048 register_inited = TRUE; 00049 00050 global_factory = gnc_cell_factory_new (); 00051 00052 gnc_register_add_cell_type (BASIC_CELL_TYPE_NAME, gnc_basic_cell_new); 00053 00054 gnc_register_add_cell_type (NUM_CELL_TYPE_NAME, gnc_num_cell_new); 00055 00056 gnc_register_add_cell_type (PRICE_CELL_TYPE_NAME, gnc_price_cell_new); 00057 00058 gnc_register_add_cell_type (RECN_CELL_TYPE_NAME, gnc_recn_cell_new); 00059 00060 gnc_register_add_cell_type (QUICKFILL_CELL_TYPE_NAME, 00061 gnc_quickfill_cell_new); 00062 00063 gnc_register_add_cell_type (FORMULA_CELL_TYPE_NAME, 00064 gnc_formula_cell_new); 00065 00066 gnc_register_add_cell_type (CHECKBOX_CELL_TYPE_NAME, gnc_checkbox_cell_new); 00067 } 00068 00069 void 00070 gnc_register_shutdown (void) 00071 { 00072 if (!register_inited) 00073 return; 00074 00075 gnc_cell_factory_destroy (global_factory); 00076 global_factory = NULL; 00077 } 00078 00079 void 00080 gnc_register_add_cell_type (const char *cell_type_name, 00081 CellCreateFunc cell_creator) 00082 { 00083 gnc_register_init (); 00084 00085 gnc_cell_factory_add_cell_type (global_factory, 00086 cell_type_name, cell_creator); 00087 } 00088 00089 BasicCell * 00090 gnc_register_make_cell (const char *cell_type_name) 00091 { 00092 gnc_register_init (); 00093 00094 return gnc_cell_factory_make_cell (global_factory, cell_type_name); 00095 } 00096 00097 gboolean 00098 virt_cell_loc_equal (VirtualCellLocation vcl1, VirtualCellLocation vcl2) 00099 { 00100 return ((vcl1.virt_row == vcl2.virt_row) && 00101 (vcl1.virt_col == vcl2.virt_col)); 00102 } 00103 00104 gboolean 00105 virt_loc_equal (VirtualLocation vl1, VirtualLocation vl2) 00106 { 00107 return (virt_cell_loc_equal (vl1.vcell_loc, vl2.vcell_loc) && 00108 (vl1.phys_row_offset == vl2.phys_row_offset) && 00109 (vl1.phys_col_offset == vl2.phys_col_offset)); 00110 }
1.7.4