GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
register-common.c
1 /********************************************************************\
2  * register-common.c -- Common functions for the register *
3  * Copyright (c) 2001 Dave Peticolas *
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; either version 2 of *
8  * the License, or (at your option) any later version. *
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 [email protected] *
21  * *
22 \********************************************************************/
23 
24 #include "config.h"
25 
26 #include "basiccell.h"
27 #include "cell-factory.h"
28 #include "combocell.h"
29 #include "datecell.h"
30 #include "formulacell.h"
31 #include "numcell.h"
32 #include "pricecell.h"
33 #include "recncell.h"
34 #include "checkboxcell.h"
35 #include "register-common.h"
36 #include "quickfillcell.h"
37 
38 
39 static gboolean register_inited = FALSE;
40 static CellFactory *global_factory = NULL;
41 
42 void
43 gnc_register_init (void)
44 {
45  if (register_inited)
46  return;
47 
48  register_inited = TRUE;
49 
50  global_factory = gnc_cell_factory_new ();
51 
52  gnc_register_add_cell_type (BASIC_CELL_TYPE_NAME, gnc_basic_cell_new);
53 
54  gnc_register_add_cell_type (NUM_CELL_TYPE_NAME, gnc_num_cell_new);
55 
56  gnc_register_add_cell_type (PRICE_CELL_TYPE_NAME, gnc_price_cell_new);
57 
58  gnc_register_add_cell_type (RECN_CELL_TYPE_NAME, gnc_recn_cell_new);
59 
60  gnc_register_add_cell_type (QUICKFILL_CELL_TYPE_NAME,
61  gnc_quickfill_cell_new);
62 
63  gnc_register_add_cell_type (FORMULA_CELL_TYPE_NAME,
64  gnc_formula_cell_new);
65 
66  gnc_register_add_cell_type (CHECKBOX_CELL_TYPE_NAME, gnc_checkbox_cell_new);
67 }
68 
69 void
70 gnc_register_shutdown (void)
71 {
72  if (!register_inited)
73  return;
74 
75  gnc_cell_factory_destroy (global_factory);
76  global_factory = NULL;
77 }
78 
79 void
80 gnc_register_add_cell_type (const char *cell_type_name,
81  CellCreateFunc cell_creator)
82 {
83  gnc_register_init ();
84 
85  gnc_cell_factory_add_cell_type (global_factory,
86  cell_type_name, cell_creator);
87 }
88 
89 BasicCell *
90 gnc_register_make_cell (const char *cell_type_name)
91 {
92  gnc_register_init ();
93 
94  return gnc_cell_factory_make_cell (global_factory, cell_type_name);
95 }
96 
97 gboolean
98 virt_cell_loc_equal (VirtualCellLocation vcl1, VirtualCellLocation vcl2)
99 {
100  return ((vcl1.virt_row == vcl2.virt_row) &&
101  (vcl1.virt_col == vcl2.virt_col));
102 }
103 
104 gboolean
105 virt_loc_equal (VirtualLocation vl1, VirtualLocation vl2)
106 {
107  return (virt_cell_loc_equal (vl1.vcell_loc, vl2.vcell_loc) &&
108  (vl1.phys_row_offset == vl2.phys_row_offset) &&
109  (vl1.phys_col_offset == vl2.phys_col_offset));
110 }
The ComboCell object implements a cell handler with a "combination-box" pull-down menu in it...
Common declarations for the register core.