GnuCash  5.6-150-g038405b370+
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 gnu@gnu.org *
21  * *
22 \********************************************************************/
23 
24 #include <config.h>
25 
26 #include "doclinkcell.h"
27 #include "basiccell.h"
28 #include "cell-factory.h"
29 #include "combocell.h"
30 #include "completioncell.h"
31 #include "datecell.h"
32 #include "formulacell.h"
33 #include "numcell.h"
34 #include "pricecell.h"
35 #include "recncell.h"
36 #include "checkboxcell.h"
37 #include "register-common.h"
38 #include "quickfillcell.h"
39 
40 
41 static gboolean register_inited = FALSE;
42 static CellFactory *global_factory = NULL;
43 
44 void
45 gnc_register_init (void)
46 {
47  if (register_inited)
48  return;
49 
50  register_inited = TRUE;
51 
52  global_factory = gnc_cell_factory_new ();
53 
54  gnc_register_add_cell_type (BASIC_CELL_TYPE_NAME, gnc_basic_cell_new);
55 
56  gnc_register_add_cell_type (NUM_CELL_TYPE_NAME, gnc_num_cell_new);
57 
58  gnc_register_add_cell_type (PRICE_CELL_TYPE_NAME, gnc_price_cell_new);
59 
60  gnc_register_add_cell_type (RECN_CELL_TYPE_NAME, gnc_recn_cell_new);
61 
62  gnc_register_add_cell_type (DOCLINK_CELL_TYPE_NAME, gnc_doclink_cell_new);
63 
64  gnc_register_add_cell_type (QUICKFILL_CELL_TYPE_NAME,
65  gnc_quickfill_cell_new);
66 
67  gnc_register_add_cell_type (FORMULA_CELL_TYPE_NAME,
68  gnc_formula_cell_new);
69 
70  gnc_register_add_cell_type (CHECKBOX_CELL_TYPE_NAME, gnc_checkbox_cell_new);
71 }
72 
73 void
74 gnc_register_shutdown (void)
75 {
76  if (!register_inited)
77  return;
78 
79  gnc_cell_factory_destroy (global_factory);
80  global_factory = NULL;
81 }
82 
83 void
84 gnc_register_add_cell_type (const char *cell_type_name,
85  CellCreateFunc cell_creator)
86 {
87  gnc_register_init ();
88 
89  gnc_cell_factory_add_cell_type (global_factory,
90  cell_type_name, cell_creator);
91 }
92 
93 BasicCell *
94 gnc_register_make_cell (const char *cell_type_name)
95 {
96  gnc_register_init ();
97 
98  return gnc_cell_factory_make_cell (global_factory, cell_type_name);
99 }
100 
101 gboolean
102 virt_cell_loc_equal (VirtualCellLocation vcl1, VirtualCellLocation vcl2)
103 {
104  return ((vcl1.virt_row == vcl2.virt_row) &&
105  (vcl1.virt_col == vcl2.virt_col));
106 }
107 
108 gboolean
109 virt_loc_equal (VirtualLocation vl1, VirtualLocation vl2)
110 {
111  return (virt_cell_loc_equal (vl1.vcell_loc, vl2.vcell_loc) &&
112  (vl1.phys_row_offset == vl2.phys_row_offset) &&
113  (vl1.phys_col_offset == vl2.phys_col_offset));
114 }
BasicCell * gnc_price_cell_new(void)
installs a callback to handle price recording
Definition: pricecell.c:168
Common declarations for the register core.