1
|
/*
|
2
|
* gncEntryLedgerLayout.c -- Layout for GncEntry ledger
|
3
|
* Copyright (C) 2001, 2002, 2003 Derek Atkins
|
4
|
* Author: Derek Atkins <warlord@MIT.EDU>
|
5
|
*
|
6
|
* This program is free software; you can redistribute it and/or
|
7
|
* modify it under the terms of the GNU General Public License as
|
8
|
* published by the Free Software Foundation; either version 2 of
|
9
|
* the License, or (at your option) any later version.
|
10
|
*
|
11
|
* This program is distributed in the hope that it will be useful,
|
12
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
* GNU General Public License for more details.
|
15
|
*
|
16
|
* You should have received a copy of the GNU General Public License
|
17
|
* along with this program; if not, contact:
|
18
|
*
|
19
|
* Free Software Foundation Voice: +1-617-542-5942
|
20
|
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
21
|
* Boston, MA 02110-1301, USA gnu@gnu.org
|
22
|
*/
|
23
|
|
24
|
#include "config.h"
|
25
|
|
26
|
#include <glib.h>
|
27
|
#include <glib/gi18n.h>
|
28
|
|
29
|
#include "gncEntryLedgerP.h"
|
30
|
#include "gncEntryLedgerLayout.h"
|
31
|
|
32
|
static void
|
33
|
gnc_register_add_cell (TableLayout *layout,
|
34
|
const char *cell_name,
|
35
|
const char *cell_type_name,
|
36
|
const char *sample_text,
|
37
|
CellAlignment alignment,
|
38
|
gboolean expandable,
|
39
|
gboolean span)
|
40
|
{
|
41
|
BasicCell *cell;
|
42
|
|
43
|
g_return_if_fail (layout != NULL);
|
44
|
g_return_if_fail (cell_type_name != NULL);
|
45
|
|
46
|
cell = gnc_register_make_cell (cell_type_name);
|
47
|
|
48
|
gnc_basic_cell_set_name (cell, cell_name);
|
49
|
gnc_basic_cell_set_type_name (cell, cell_type_name);
|
50
|
gnc_basic_cell_set_sample_text (cell, sample_text);
|
51
|
gnc_basic_cell_set_alignment (cell, alignment);
|
52
|
gnc_basic_cell_set_expandable (cell, expandable);
|
53
|
gnc_basic_cell_set_span (cell, span);
|
54
|
|
55
|
gnc_table_layout_add_cell (layout, cell);
|
56
|
}
|
57
|
|
58
|
static void gnc_entry_ledger_layout_add_cells (GncEntryLedger *ledger,
|
59
|
TableLayout *layout)
|
60
|
{
|
61
|
struct cell_list
|
62
|
{
|
63
|
const char *cell_name;
|
64
|
const char *cell_type_name;
|
65
|
const char *sample_text;
|
66
|
CellAlignment alignment;
|
67
|
gboolean expandable;
|
68
|
gboolean span;
|
69
|
} cells[] =
|
70
|
{
|
71
|
/* Translators: The 'sample:' items are strings which are not
|
72
|
displayed, but only used to estimate widths. Please only
|
73
|
translate the portion after the ':' and leave the rest
|
74
|
("sample:") as is. */
|
75
|
{
|
76
|
ENTRY_INV_CELL, CHECKBOX_CELL_TYPE_NAME, N_("sample:X") + 7,
|
77
|
CELL_ALIGN_LEFT, FALSE, FALSE
|
78
|
},
|
79
|
{
|
80
|
ENTRY_DATE_CELL, DATE_CELL_TYPE_NAME, N_("sample:12/12/2000") + 7,
|
81
|
CELL_ALIGN_RIGHT, FALSE, FALSE
|
82
|
},
|
83
|
{
|
84
|
ENTRY_DESC_CELL, QUICKFILL_CELL_TYPE_NAME,
|
85
|
N_("sample:Description of an Entry") + 7, CELL_ALIGN_LEFT, TRUE, FALSE
|
86
|
},
|
87
|
{
|
88
|
ENTRY_ACTN_CELL, COMBO_CELL_TYPE_NAME,
|
89
|
N_("sample:Action") + 7, CELL_ALIGN_RIGHT,
|
90
|
FALSE, FALSE
|
91
|
},
|
92
|
{
|
93
|
ENTRY_QTY_CELL, PRICE_CELL_TYPE_NAME, N_("sample:9,999.00") + 7,
|
94
|
CELL_ALIGN_RIGHT, FALSE, FALSE
|
95
|
},
|
96
|
{
|
97
|
ENTRY_PRIC_CELL, PRICE_CELL_TYPE_NAME, N_("sample:999,999.00") + 7,
|
98
|
CELL_ALIGN_RIGHT, FALSE, FALSE
|
99
|
},
|
100
|
{
|
101
|
ENTRY_DISC_CELL, PRICE_CELL_TYPE_NAME, N_("sample:9,999.00") + 7,
|
102
|
CELL_ALIGN_RIGHT, FALSE, FALSE
|
103
|
},
|
104
|
/* xgettext:no-c-format */
|
105
|
{
|
106
|
ENTRY_DISTYPE_CELL, RECN_CELL_TYPE_NAME, N_("sample(DT):+%") + 11,
|
107
|
CELL_ALIGN_LEFT, FALSE, FALSE
|
108
|
},
|
109
|
/* xgettext:no-c-format */
|
110
|
{
|
111
|
ENTRY_DISHOW_CELL, RECN_CELL_TYPE_NAME, N_("sample(DH):+%") + 11,
|
112
|
CELL_ALIGN_LEFT, FALSE, FALSE
|
113
|
},
|
114
|
{
|
115
|
ENTRY_IACCT_CELL, COMBO_CELL_TYPE_NAME,
|
116
|
N_("sample:Expenses:Automobile:Gasoline") + 7,
|
117
|
CELL_ALIGN_RIGHT, FALSE, FALSE
|
118
|
},
|
119
|
{
|
120
|
ENTRY_BACCT_CELL, COMBO_CELL_TYPE_NAME,
|
121
|
N_("sample:Expenses:Automobile:Gasoline") + 7,
|
122
|
CELL_ALIGN_RIGHT, FALSE, FALSE
|
123
|
},
|
124
|
{
|
125
|
ENTRY_TAXABLE_CELL, CHECKBOX_CELL_TYPE_NAME, N_("sample:T?") + 7,
|
126
|
CELL_ALIGN_LEFT, FALSE, FALSE
|
127
|
},
|
128
|
{
|
129
|
ENTRY_TAXINCLUDED_CELL, CHECKBOX_CELL_TYPE_NAME, N_("sample:TI") + 7,
|
130
|
CELL_ALIGN_LEFT, FALSE, FALSE
|
131
|
},
|
132
|
{
|
133
|
ENTRY_TAXTABLE_CELL, COMBO_CELL_TYPE_NAME, N_("sample:Tax Table 1") + 7,
|
134
|
CELL_ALIGN_RIGHT, FALSE, FALSE
|
135
|
},
|
136
|
{
|
137
|
ENTRY_VALUE_CELL, PRICE_CELL_TYPE_NAME, N_("sample:999,999.00") + 7,
|
138
|
CELL_ALIGN_RIGHT, FALSE, FALSE
|
139
|
},
|
140
|
{
|
141
|
ENTRY_TAXVAL_CELL, PRICE_CELL_TYPE_NAME, N_("sample:999.00") + 7,
|
142
|
CELL_ALIGN_RIGHT, FALSE, FALSE
|
143
|
},
|
144
|
{
|
145
|
ENTRY_BILLABLE_CELL, CHECKBOX_CELL_TYPE_NAME, N_("sample:BI") + 7,
|
146
|
CELL_ALIGN_LEFT, FALSE, FALSE
|
147
|
},
|
148
|
{
|
149
|
ENTRY_PAYMENT_CELL, COMBO_CELL_TYPE_NAME, N_("sample:Payment") + 7,
|
150
|
CELL_ALIGN_LEFT, FALSE, FALSE
|
151
|
}
|
152
|
};
|
153
|
unsigned int i;
|
154
|
|
155
|
for (i = 0; i < (sizeof(cells) / sizeof(*cells)); i++)
|
156
|
gnc_register_add_cell (layout, cells[i].cell_name, cells[i].cell_type_name,
|
157
|
cells[i].sample_text, cells[i].alignment,
|
158
|
cells[i].expandable, cells[i].span);
|
159
|
}
|
160
|
|
161
|
static void gnc_entry_ledger_layout_add_cursors (GncEntryLedger *ledger,
|
162
|
TableLayout *layout)
|
163
|
{
|
164
|
CellBlock *cursor;
|
165
|
int num_cols;
|
166
|
|
167
|
switch (ledger->type)
|
168
|
{
|
169
|
case GNCENTRY_ORDER_ENTRY:
|
170
|
case GNCENTRY_ORDER_VIEWER:
|
171
|
case GNCENTRY_INVOICE_ENTRY:
|
172
|
case GNCENTRY_INVOICE_VIEWER:
|
173
|
num_cols = 15;
|
174
|
break;
|
175
|
case GNCENTRY_BILL_ENTRY:
|
176
|
case GNCENTRY_BILL_VIEWER:
|
177
|
num_cols = 12;
|
178
|
break;
|
179
|
case GNCENTRY_EXPVOUCHER_ENTRY:
|
180
|
case GNCENTRY_EXPVOUCHER_VIEWER:
|
181
|
num_cols = 10;
|
182
|
break;
|
183
|
default:
|
184
|
g_assert (FALSE);
|
185
|
return;
|
186
|
}
|
187
|
|
188
|
cursor = gnc_cellblock_new (1, num_cols, CURSOR_HEADER);
|
189
|
gnc_table_layout_add_cursor (layout, cursor);
|
190
|
|
191
|
cursor = gnc_cellblock_new (1, num_cols, "cursor");
|
192
|
gnc_table_layout_add_cursor (layout, cursor);
|
193
|
gnc_table_layout_set_primary_cursor (layout, cursor);
|
194
|
}
|
195
|
|
196
|
static void gnc_entry_ledger_set_cells (GncEntryLedger *ledger,
|
197
|
TableLayout *layout)
|
198
|
{
|
199
|
CellBlock *curs;
|
200
|
|
201
|
switch (ledger->type)
|
202
|
{
|
203
|
case GNCENTRY_ORDER_ENTRY:
|
204
|
case GNCENTRY_ORDER_VIEWER:
|
205
|
case GNCENTRY_INVOICE_ENTRY:
|
206
|
case GNCENTRY_INVOICE_VIEWER:
|
207
|
|
208
|
curs = gnc_table_layout_get_cursor (layout, "cursor");
|
209
|
gnc_table_layout_set_cell (layout, curs, ENTRY_DATE_CELL, 0, 0);
|
210
|
gnc_table_layout_set_cell (layout, curs, ENTRY_INV_CELL, 0, 1);
|
211
|
gnc_table_layout_set_cell (layout, curs, ENTRY_DESC_CELL, 0, 2);
|
212
|
gnc_table_layout_set_cell (layout, curs, ENTRY_ACTN_CELL, 0, 3);
|
213
|
gnc_table_layout_set_cell (layout, curs, ENTRY_IACCT_CELL, 0, 4);
|
214
|
gnc_table_layout_set_cell (layout, curs, ENTRY_QTY_CELL, 0, 5);
|
215
|
gnc_table_layout_set_cell (layout, curs, ENTRY_PRIC_CELL, 0, 6);
|
216
|
gnc_table_layout_set_cell (layout, curs, ENTRY_DISTYPE_CELL, 0, 7);
|
217
|
gnc_table_layout_set_cell (layout, curs, ENTRY_DISHOW_CELL, 0, 8);
|
218
|
gnc_table_layout_set_cell (layout, curs, ENTRY_DISC_CELL, 0, 9);
|
219
|
gnc_table_layout_set_cell (layout, curs, ENTRY_TAXABLE_CELL, 0, 10);
|
220
|
gnc_table_layout_set_cell (layout, curs, ENTRY_TAXINCLUDED_CELL, 0, 11);
|
221
|
gnc_table_layout_set_cell (layout, curs, ENTRY_TAXTABLE_CELL, 0, 12);
|
222
|
gnc_table_layout_set_cell (layout, curs, ENTRY_VALUE_CELL, 0, 13);
|
223
|
gnc_table_layout_set_cell (layout, curs, ENTRY_TAXVAL_CELL, 0, 14);
|
224
|
|
225
|
break;
|
226
|
|
227
|
case GNCENTRY_BILL_ENTRY:
|
228
|
case GNCENTRY_BILL_VIEWER:
|
229
|
|
230
|
curs = gnc_table_layout_get_cursor (layout, "cursor");
|
231
|
gnc_table_layout_set_cell (layout, curs, ENTRY_DATE_CELL, 0, 0);
|
232
|
gnc_table_layout_set_cell (layout, curs, ENTRY_INV_CELL, 0, 1);
|
233
|
gnc_table_layout_set_cell (layout, curs, ENTRY_DESC_CELL, 0, 2);
|
234
|
gnc_table_layout_set_cell (layout, curs, ENTRY_ACTN_CELL, 0, 3);
|
235
|
gnc_table_layout_set_cell (layout, curs, ENTRY_BACCT_CELL, 0, 4);
|
236
|
gnc_table_layout_set_cell (layout, curs, ENTRY_QTY_CELL, 0, 5);
|
237
|
gnc_table_layout_set_cell (layout, curs, ENTRY_PRIC_CELL, 0, 6);
|
238
|
gnc_table_layout_set_cell (layout, curs, ENTRY_TAXABLE_CELL, 0, 7);
|
239
|
gnc_table_layout_set_cell (layout, curs, ENTRY_TAXINCLUDED_CELL, 0, 8);
|
240
|
gnc_table_layout_set_cell (layout, curs, ENTRY_TAXTABLE_CELL, 0, 9);
|
241
|
gnc_table_layout_set_cell (layout, curs, ENTRY_VALUE_CELL, 0, 10);
|
242
|
gnc_table_layout_set_cell (layout, curs, ENTRY_BILLABLE_CELL, 0, 11);
|
243
|
|
244
|
break;
|
245
|
|
246
|
case GNCENTRY_EXPVOUCHER_ENTRY:
|
247
|
case GNCENTRY_EXPVOUCHER_VIEWER:
|
248
|
|
249
|
curs = gnc_table_layout_get_cursor (layout, "cursor");
|
250
|
gnc_table_layout_set_cell (layout, curs, ENTRY_DATE_CELL, 0, 0);
|
251
|
gnc_table_layout_set_cell (layout, curs, ENTRY_INV_CELL, 0, 1);
|
252
|
gnc_table_layout_set_cell (layout, curs, ENTRY_DESC_CELL, 0, 2);
|
253
|
gnc_table_layout_set_cell (layout, curs, ENTRY_ACTN_CELL, 0, 3);
|
254
|
gnc_table_layout_set_cell (layout, curs, ENTRY_BACCT_CELL, 0, 4);
|
255
|
gnc_table_layout_set_cell (layout, curs, ENTRY_QTY_CELL, 0, 5);
|
256
|
gnc_table_layout_set_cell (layout, curs, ENTRY_PRIC_CELL, 0, 6);
|
257
|
gnc_table_layout_set_cell (layout, curs, ENTRY_VALUE_CELL, 0, 7);
|
258
|
gnc_table_layout_set_cell (layout, curs, ENTRY_BILLABLE_CELL, 0, 8);
|
259
|
gnc_table_layout_set_cell (layout, curs, ENTRY_PAYMENT_CELL, 0, 9);
|
260
|
|
261
|
break;
|
262
|
|
263
|
default:
|
264
|
g_assert (FALSE);
|
265
|
return;
|
266
|
}
|
267
|
}
|
268
|
|
269
|
TableLayout * gnc_entry_ledger_layout_new (GncEntryLedger *ledger)
|
270
|
{
|
271
|
TableLayout *layout;
|
272
|
|
273
|
layout = gnc_table_layout_new ();
|
274
|
gnc_entry_ledger_layout_add_cells (ledger, layout);
|
275
|
gnc_entry_ledger_layout_add_cursors (ledger, layout);
|
276
|
gnc_entry_ledger_set_cells (ledger, layout);
|
277
|
|
278
|
return layout;
|
279
|
}
|
280
|
|
281
|
|