GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pricecell.h
1 /********************************************************************\
2  * pricecell.h -- price input/display cell *
3  * *
4  * This program is free software; you can redistribute it and/or *
5  * modify it under the terms of the GNU General Public License as *
6  * published by the Free Software Foundation; either version 2 of *
7  * the License, or (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License*
15  * along with this program; if not, contact: *
16  * *
17  * Free Software Foundation Voice: +1-617-542-5942 *
18  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
19  * Boston, MA 02110-1301, USA [email protected] *
20  * *
21 \********************************************************************/
22 
23 /*
24  * FILE:
25  * pricecell.h
26  *
27  * FUNCTION:
28  * The PriceCell object implements a cell handler that stores
29  * a single double-precision value, and has the smarts to
30  * display it as a price/amount as well as accepting monetary
31  * or general numeric input.
32  *
33  * By default, the PriceCell is an input/output cell.
34  *
35  * On output, it will display negative values in red text.
36  * hack alert -- the actual color (red) should be user configurable.
37  *
38  * HISTORY:
39  * Copyright (c) 1998, 1999, 2000 Linas Vepstas
40  * Copyright (c) 2000 Dave Peticolas <[email protected]>
41  * Copyright (c) 2001 Free Software Foundation
42  */
43 
44 #ifndef PRICE_CELL_H
45 #define PRICE_CELL_H
46 
47 #include "basiccell.h"
48 #include "qof.h"
49 #include "gnc-ui-util.h"
50 
51 typedef struct
52 {
53  BasicCell cell;
54 
55  gnc_numeric amount; /* the amount associated with this cell */
56 
57  int fraction; /* fraction used for rounding, if 0 no rounding */
58 
59  gboolean blank_zero; /* controls printing of zero values */
60 
61  GNCPrintAmountInfo print_info; /* amount printing context */
62 
63  gboolean need_to_parse; /* internal */
64 } PriceCell;
65 
66 /* installs a callback to handle price recording */
67 BasicCell * gnc_price_cell_new (void);
68 
69 /* return the value of a price cell */
70 gnc_numeric gnc_price_cell_get_value (PriceCell *cell);
71 
72 /* updates amount, returns TRUE if string representation
73  * actually changed */
74 gboolean gnc_price_cell_set_value (PriceCell *cell, gnc_numeric amount);
75 
76 /* Sets the fraction used for rounding. If 0, no rounding is performed. */
77 void gnc_price_cell_set_fraction (PriceCell *cell, int fraction);
78 
79 /* Sets the cell as blank, regardless of the blank_zero value */
80 void gnc_price_cell_blank (PriceCell *cell);
81 
82 /* determines whether 0 values are left blank or printed.
83  * defaults to true. */
84 void gnc_price_cell_set_blank_zero (PriceCell *cell,
85  gboolean blank_zero);
86 
87 /* set the printing context of the price cell */
88 void gnc_price_cell_set_print_info (PriceCell *cell,
89  GNCPrintAmountInfo print_info);
90 
91 /* updates two cells; the deb cell if amt is negative, the credit cell
92  * if amount is positive, and makes the other cell blank. */
93 void gnc_price_cell_set_debt_credit_value (PriceCell *debit,
94  PriceCell *credit,
95  gnc_numeric amount);
96 
97 #endif
utility functions for the GnuCash UI