GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
split-register-layout.c
1 /********************************************************************\
2  * split-register-layout.c -- split register layout object *
3  * Copyright (C) 1998 Linas Vepstas <[email protected]> *
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 <glib.h>
27 #include <glib/gi18n.h>
28 
29 #include "gnc-engine.h"
30 #include "split-register-layout.h"
31 
32 
33 /* This static indicates the debugging module that this .o belongs to. */
34 static QofLogModule log_module = GNC_MOD_REGISTER;
35 
36 
37 static void
38 gnc_register_add_cell (TableLayout *layout,
39  const char *cell_name,
40  const char *cell_type_name,
41  const char *sample_text,
42  CellAlignment alignment,
43  gboolean expandable,
44  gboolean span)
45 {
46  BasicCell *cell;
47 
48  g_return_if_fail (layout != NULL);
49  g_return_if_fail (cell_type_name != NULL);
50 
51  cell = gnc_register_make_cell (cell_type_name);
52 
53  gnc_basic_cell_set_name (cell, cell_name);
54  gnc_basic_cell_set_type_name (cell, cell_type_name);
55  gnc_basic_cell_set_sample_text (cell, sample_text);
56  gnc_basic_cell_set_alignment (cell, alignment);
57  gnc_basic_cell_set_expandable (cell, expandable);
58  gnc_basic_cell_set_span (cell, span);
59 
60  gnc_table_layout_add_cell (layout, cell);
61 }
62 
63 static void
64 copy_cursor_row (TableLayout *layout, CellBlock *to, CellBlock *from, int row)
65 {
66  int col;
67 
68  for (col = 0; col < from->num_cols; col++)
69  {
70  BasicCell *cell;
71 
72  cell = gnc_cellblock_get_cell (from, row, col);
73  if (!cell || !cell->cell_name)
74  continue;
75 
76  gnc_table_layout_set_cell (layout, to, cell->cell_name, row, col);
77  }
78 }
79 
80 static void
81 gnc_split_register_set_cells (SplitRegister *reg, TableLayout *layout)
82 {
83  CellBlock *curs;
84  CellBlock *curs_last;
85 
86  switch (reg->type)
87  {
88  case BANK_REGISTER:
89  case CASH_REGISTER:
90  case ASSET_REGISTER:
91  case CREDIT_REGISTER:
92  case LIABILITY_REGISTER:
93  case INCOME_REGISTER:
94  case EXPENSE_REGISTER:
95  case EQUITY_REGISTER:
96  case TRADING_REGISTER:
97  {
98  curs = gnc_table_layout_get_cursor (layout,
99  CURSOR_SINGLE_LEDGER);
100 
101  gnc_table_layout_set_cell (layout, curs, DATE_CELL, 0, 0);
102  gnc_table_layout_set_cell (layout, curs, NUM_CELL, 0, 1);
103  gnc_table_layout_set_cell (layout, curs, DESC_CELL, 0, 2);
104  gnc_table_layout_set_cell (layout, curs, MXFRM_CELL, 0, 3);
105  gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
106  if (reg->is_template)
107  {
108  gnc_table_layout_set_cell (layout, curs, FDEBT_CELL, 0, 5);
109  gnc_table_layout_set_cell (layout, curs, FCRED_CELL, 0, 6);
110  }
111  else
112  {
113  gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 5);
114  gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 6);
115  }
116  gnc_table_layout_set_cell (layout, curs, BALN_CELL, 0, 7);
117  gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 8);
118 
119  curs_last = curs;
120  curs = gnc_table_layout_get_cursor (layout,
121  CURSOR_DOUBLE_LEDGER);
122 
123  copy_cursor_row (layout, curs, curs_last, 0);
124 
125  gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 1, 1);
126  gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
127  gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
128 
129  curs = gnc_table_layout_get_cursor (layout,
130  CURSOR_DOUBLE_LEDGER_NUM_ACTN);
131 
132  copy_cursor_row (layout, curs, curs_last, 0);
133 
134  gnc_table_layout_set_cell (layout, curs, TNUM_CELL, 1, 1);
135  gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
136  gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
137 
138  curs = gnc_table_layout_get_cursor (layout,
139  CURSOR_SINGLE_JOURNAL);
140 
141  gnc_table_layout_set_cell (layout, curs, DATE_CELL, 0, 0);
142  gnc_table_layout_set_cell (layout, curs, NUM_CELL, 0, 1);
143  gnc_table_layout_set_cell (layout, curs, DESC_CELL, 0, 2);
144  gnc_table_layout_set_cell (layout, curs, TDEBT_CELL, 0, 5);
145  gnc_table_layout_set_cell (layout, curs, TCRED_CELL, 0, 6);
146  gnc_table_layout_set_cell (layout, curs, TBALN_CELL, 0, 7);
147  gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 8);
148 
149  curs_last = curs;
150  curs = gnc_table_layout_get_cursor (layout,
151  CURSOR_DOUBLE_JOURNAL);
152 
153  copy_cursor_row (layout, curs, curs_last, 0);
154 
155  gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
156  gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
157 
158  curs = gnc_table_layout_get_cursor (layout,
159  CURSOR_DOUBLE_JOURNAL_NUM_ACTN);
160 
161  copy_cursor_row (layout, curs, curs_last, 0);
162 
163  gnc_table_layout_set_cell (layout, curs, TNUM_CELL, 1, 1);
164  gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
165  gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
166 
167  curs = gnc_table_layout_get_cursor (layout,
168  CURSOR_SPLIT);
169 
170  gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 0, 1);
171  gnc_table_layout_set_cell (layout, curs, MEMO_CELL, 0, 2);
172  gnc_table_layout_set_cell (layout, curs, XFRM_CELL, 0, 3);
173  gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
174  if (reg->is_template)
175  {
176  gnc_table_layout_set_cell (layout, curs, FDEBT_CELL, 0, 5);
177  gnc_table_layout_set_cell (layout, curs, FCRED_CELL, 0, 6);
178  }
179  else
180  {
181  gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 5);
182  gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 6);
183  }
184  gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 8);
185 
186  break;
187  }
188  /* --------------------------------------------------------- */
189 
190  case PAYABLE_REGISTER:
191  case RECEIVABLE_REGISTER:
192  {
193  curs = gnc_table_layout_get_cursor (layout,
194  CURSOR_SINGLE_LEDGER);
195 
196  gnc_table_layout_set_cell (layout, curs, DATE_CELL, 0, 0);
197  gnc_table_layout_set_cell (layout, curs, TYPE_CELL, 0, 1);
198  gnc_table_layout_set_cell (layout, curs, DDUE_CELL, 0, 2);
199  gnc_table_layout_set_cell (layout, curs, NUM_CELL, 0, 3);
200  gnc_table_layout_set_cell (layout, curs, DESC_CELL, 0, 4);
201  gnc_table_layout_set_cell (layout, curs, MXFRM_CELL, 0, 5);
202  gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 6);
203  gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 7);
204  gnc_table_layout_set_cell (layout, curs, BALN_CELL, 0, 8);
205 
206  curs_last = curs;
207  curs = gnc_table_layout_get_cursor (layout,
208  CURSOR_DOUBLE_LEDGER);
209 
210  copy_cursor_row (layout, curs, curs_last, 0);
211 
212  gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 1, 3);
213  gnc_table_layout_set_cell (layout, curs, MEMO_CELL, 1, 4);
214 
215  curs = gnc_table_layout_get_cursor (layout,
216  CURSOR_DOUBLE_LEDGER_NUM_ACTN);
217 
218  copy_cursor_row (layout, curs, curs_last, 0);
219 
220  gnc_table_layout_set_cell (layout, curs, TNUM_CELL, 1, 3);
221  gnc_table_layout_set_cell (layout, curs, MEMO_CELL, 1, 4);
222 
223  curs = gnc_table_layout_get_cursor (layout,
224  CURSOR_SINGLE_JOURNAL);
225 
226  gnc_table_layout_set_cell (layout, curs, DATE_CELL, 0, 0);
227  gnc_table_layout_set_cell (layout, curs, TYPE_CELL, 0, 1);
228  gnc_table_layout_set_cell (layout, curs, DDUE_CELL, 0, 2);
229  gnc_table_layout_set_cell (layout, curs, NUM_CELL, 0, 3);
230  gnc_table_layout_set_cell (layout, curs, DESC_CELL, 0, 4);
231 
232  gnc_table_layout_set_cell (layout, curs, TDEBT_CELL, 0, 6);
233  gnc_table_layout_set_cell (layout, curs, TCRED_CELL, 0, 7);
234  gnc_table_layout_set_cell (layout, curs, TBALN_CELL, 0, 8);
235 
236  curs_last = curs;
237  curs = gnc_table_layout_get_cursor (layout,
238  CURSOR_DOUBLE_JOURNAL);
239 
240  copy_cursor_row (layout, curs, curs_last, 0);
241 
242  gnc_table_layout_set_cell (layout, curs, MEMO_CELL, 1, 4);
243 
244  curs = gnc_table_layout_get_cursor (layout,
245  CURSOR_DOUBLE_JOURNAL_NUM_ACTN);
246 
247  copy_cursor_row (layout, curs, curs_last, 0);
248 
249  gnc_table_layout_set_cell (layout, curs, TNUM_CELL, 1, 3);
250  gnc_table_layout_set_cell (layout, curs, MEMO_CELL, 1, 4);
251 
252  curs = gnc_table_layout_get_cursor (layout,
253  CURSOR_SPLIT);
254 
255  gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 0, 3);
256  gnc_table_layout_set_cell (layout, curs, MEMO_CELL, 0, 4);
257  gnc_table_layout_set_cell (layout, curs, XFRM_CELL, 0, 5);
258  gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 6);
259  gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 7);
260 
261  break;
262  }
263 
264  /* --------------------------------------------------------- */
265  case INCOME_LEDGER:
266  case GENERAL_LEDGER:
267  case SEARCH_LEDGER:
268  {
269  curs = gnc_table_layout_get_cursor (layout,
270  CURSOR_SINGLE_LEDGER);
271 
272  gnc_table_layout_set_cell (layout, curs, DATE_CELL, 0, 0);
273  gnc_table_layout_set_cell (layout, curs, TNUM_CELL, 0, 1);
274  gnc_table_layout_set_cell (layout, curs, DESC_CELL, 0, 2);
275  gnc_table_layout_set_cell (layout, curs, MXFRM_CELL, 0, 3);
276  gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
277  if (reg->is_template)
278  {
279  gnc_table_layout_set_cell (layout, curs, FDEBT_CELL, 0, 5);
280  gnc_table_layout_set_cell (layout, curs, FCRED_CELL, 0, 6);
281  gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 7);
282  }
283  else
284  {
285  gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 5);
286  gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 6);
287  gnc_table_layout_set_cell (layout, curs, RBALN_CELL, 0, 7);
288  gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 8);
289  }
290 
291  curs_last = curs;
292  curs = gnc_table_layout_get_cursor (layout,
293  CURSOR_DOUBLE_LEDGER);
294 
295  copy_cursor_row (layout, curs, curs_last, 0);
296 
297  gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 1, 1);
298  gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
299  gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
300 
301  curs = gnc_table_layout_get_cursor (layout,
302  CURSOR_DOUBLE_LEDGER_NUM_ACTN);
303 
304  copy_cursor_row (layout, curs, curs_last, 0);
305 
306  gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 1, 1);
307  gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
308  gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
309 
310  curs = gnc_table_layout_get_cursor (layout,
311  CURSOR_SINGLE_JOURNAL);
312 
313  gnc_table_layout_set_cell (layout, curs, DATE_CELL, 0, 0);
314  gnc_table_layout_set_cell (layout, curs, TNUM_CELL, 0, 1);
315  gnc_table_layout_set_cell (layout, curs, DESC_CELL, 0, 2);
316  gnc_table_layout_set_cell (layout, curs, TDEBT_CELL, 0, 5);
317  gnc_table_layout_set_cell (layout, curs, TCRED_CELL, 0, 6);
318  if (reg->is_template)
319  gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 7);
320  else
321  {
322  gnc_table_layout_set_cell (layout, curs, RBALN_CELL, 0, 7);
323  gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 8);
324  }
325 
326  curs_last = curs;
327  curs = gnc_table_layout_get_cursor (layout,
328  CURSOR_DOUBLE_JOURNAL);
329 
330  copy_cursor_row (layout, curs, curs_last, 0);
331 
332  gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
333  gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
334 
335  curs = gnc_table_layout_get_cursor (layout,
336  CURSOR_DOUBLE_JOURNAL_NUM_ACTN);
337 
338  copy_cursor_row (layout, curs, curs_last, 0);
339 
340  gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
341  gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
342 
343  curs = gnc_table_layout_get_cursor (layout,
344  CURSOR_SPLIT);
345 
346  gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 0, 1);
347  gnc_table_layout_set_cell (layout, curs, MEMO_CELL, 0, 2);
348  gnc_table_layout_set_cell (layout, curs, XFRM_CELL, 0, 3);
349  gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
350  if (reg->is_template)
351  {
352  gnc_table_layout_set_cell (layout, curs, FDEBT_CELL, 0, 5);
353  gnc_table_layout_set_cell (layout, curs, FCRED_CELL, 0, 6);
354  gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 7);
355  }
356  else
357  {
358  gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 5);
359  gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 6);
360  gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 8);
361  }
362 
363  break;
364  }
365 
366  /* --------------------------------------------------------- */
367  case STOCK_REGISTER:
368  case CURRENCY_REGISTER:
369  {
370  curs = gnc_table_layout_get_cursor (layout,
371  CURSOR_SINGLE_LEDGER);
372 
373  gnc_table_layout_set_cell (layout, curs, DATE_CELL, 0, 0);
374  gnc_table_layout_set_cell (layout, curs, NUM_CELL, 0, 1);
375  gnc_table_layout_set_cell (layout, curs, DESC_CELL, 0, 2);
376  gnc_table_layout_set_cell (layout, curs, MXFRM_CELL, 0, 3);
377  gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
378  gnc_table_layout_set_cell (layout, curs, SHRS_CELL, 0, 5);
379  gnc_table_layout_set_cell (layout, curs, PRIC_CELL, 0, 6);
380  gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 7);
381  gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 8);
382  gnc_table_layout_set_cell (layout, curs, BALN_CELL, 0, 9);
383 
384  curs_last = curs;
385  curs = gnc_table_layout_get_cursor (layout,
386  CURSOR_DOUBLE_LEDGER);
387 
388  copy_cursor_row (layout, curs, curs_last, 0);
389 
390  gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 1, 1);
391  gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
392  gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
393 
394  curs = gnc_table_layout_get_cursor (layout,
395  CURSOR_DOUBLE_LEDGER_NUM_ACTN);
396 
397  copy_cursor_row (layout, curs, curs_last, 0);
398 
399  gnc_table_layout_set_cell (layout, curs, TNUM_CELL, 1, 1);
400  gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
401  gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
402 
403  curs = gnc_table_layout_get_cursor (layout,
404  CURSOR_SINGLE_JOURNAL);
405 
406  gnc_table_layout_set_cell (layout, curs, DATE_CELL, 0, 0);
407  gnc_table_layout_set_cell (layout, curs, NUM_CELL, 0, 1);
408  gnc_table_layout_set_cell (layout, curs, DESC_CELL, 0, 2);
409  gnc_table_layout_set_cell (layout, curs, TSHRS_CELL, 0, 5);
410  gnc_table_layout_set_cell (layout, curs, TDEBT_CELL, 0, 7);
411  gnc_table_layout_set_cell (layout, curs, TCRED_CELL, 0, 8);
412  gnc_table_layout_set_cell (layout, curs, TBALN_CELL, 0, 9);
413 
414  curs_last = curs;
415  curs = gnc_table_layout_get_cursor (layout,
416  CURSOR_DOUBLE_JOURNAL);
417 
418  copy_cursor_row (layout, curs, curs_last, 0);
419 
420  gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
421  gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
422 
423  curs = gnc_table_layout_get_cursor (layout,
424  CURSOR_DOUBLE_JOURNAL_NUM_ACTN);
425 
426  copy_cursor_row (layout, curs, curs_last, 0);
427 
428  gnc_table_layout_set_cell (layout, curs, TNUM_CELL, 1, 1);
429  gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
430  gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
431 
432  curs = gnc_table_layout_get_cursor (layout,
433  CURSOR_SPLIT);
434 
435  gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 0, 1);
436  gnc_table_layout_set_cell (layout, curs, MEMO_CELL, 0, 2);
437  gnc_table_layout_set_cell (layout, curs, XFRM_CELL, 0, 3);
438  gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
439  gnc_table_layout_set_cell (layout, curs, SHRS_CELL, 0, 5);
440  gnc_table_layout_set_cell (layout, curs, PRIC_CELL, 0, 6);
441  gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 7);
442  gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 8);
443 
444  break;
445  }
446 
447  /* --------------------------------------------------------- */
448  case PORTFOLIO_LEDGER:
449  {
450  curs = gnc_table_layout_get_cursor (layout,
451  CURSOR_SINGLE_LEDGER);
452 
453  gnc_table_layout_set_cell (layout, curs, DATE_CELL, 0, 0);
454  gnc_table_layout_set_cell (layout, curs, NUM_CELL, 0, 1);
455  gnc_table_layout_set_cell (layout, curs, DESC_CELL, 0, 2);
456  gnc_table_layout_set_cell (layout, curs, MXFRM_CELL, 0, 3);
457  gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
458  gnc_table_layout_set_cell (layout, curs, SHRS_CELL, 0, 5);
459  gnc_table_layout_set_cell (layout, curs, PRIC_CELL, 0, 6);
460  gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 7);
461  gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 8);
462 
463  curs_last = curs;
464  curs = gnc_table_layout_get_cursor (layout,
465  CURSOR_DOUBLE_LEDGER);
466 
467  copy_cursor_row (layout, curs, curs_last, 0);
468 
469  gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 1, 1);
470  gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
471  gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
472 
473  curs = gnc_table_layout_get_cursor (layout,
474  CURSOR_DOUBLE_LEDGER_NUM_ACTN);
475 
476  copy_cursor_row (layout, curs, curs_last, 0);
477 
478  gnc_table_layout_set_cell (layout, curs, TNUM_CELL, 1, 1);
479  gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
480  gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
481 
482  curs = gnc_table_layout_get_cursor (layout,
483  CURSOR_SINGLE_JOURNAL);
484 
485  gnc_table_layout_set_cell (layout, curs, DATE_CELL, 0, 0);
486  gnc_table_layout_set_cell (layout, curs, NUM_CELL, 0, 1);
487  gnc_table_layout_set_cell (layout, curs, DESC_CELL, 0, 2);
488  gnc_table_layout_set_cell (layout, curs, TSHRS_CELL, 0, 5);
489  gnc_table_layout_set_cell (layout, curs, TDEBT_CELL, 0, 7);
490  gnc_table_layout_set_cell (layout, curs, TCRED_CELL, 0, 8);
491 
492  curs_last = curs;
493  curs = gnc_table_layout_get_cursor (layout,
494  CURSOR_DOUBLE_JOURNAL);
495 
496  copy_cursor_row (layout, curs, curs_last, 0);
497 
498  gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
499  gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
500 
501  curs = gnc_table_layout_get_cursor (layout,
502  CURSOR_DOUBLE_JOURNAL_NUM_ACTN);
503 
504  copy_cursor_row (layout, curs, curs_last, 0);
505 
506  gnc_table_layout_set_cell (layout, curs, TNUM_CELL, 1, 1);
507  gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
508  gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
509 
510  curs = gnc_table_layout_get_cursor (layout,
511  CURSOR_SPLIT);
512 
513  gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 0, 1);
514  gnc_table_layout_set_cell (layout, curs, MEMO_CELL, 0, 2);
515  gnc_table_layout_set_cell (layout, curs, XFRM_CELL, 0, 3);
516  gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
517  gnc_table_layout_set_cell (layout, curs, SHRS_CELL, 0, 5);
518  gnc_table_layout_set_cell (layout, curs, PRIC_CELL, 0, 6);
519  gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 7);
520  gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 8);
521 
522  break;
523  }
524 
525  /* --------------------------------------------------------- */
526  default:
527  PERR ("unknown register type %d \n", reg->type);
528  break;
529  }
530 }
531 
532 static void
533 gnc_split_register_layout_add_cursors (SplitRegister *reg,
534  TableLayout *layout)
535 {
536  CellBlock *cursor;
537  int num_cols;
538 
539  switch (reg->type)
540  {
541  case BANK_REGISTER:
542  case CASH_REGISTER:
543  case ASSET_REGISTER:
544  case CREDIT_REGISTER:
545  case LIABILITY_REGISTER:
546  case INCOME_REGISTER:
547  case EXPENSE_REGISTER:
548  case EQUITY_REGISTER:
549  case TRADING_REGISTER:
550  num_cols = 9;
551  break;
552 
553  case PAYABLE_REGISTER:
554  case RECEIVABLE_REGISTER:
555  num_cols = 9;
556  break;
557 
558  case INCOME_LEDGER:
559  case GENERAL_LEDGER:
560  case SEARCH_LEDGER:
561  if (reg->is_template)
562  num_cols = 8;
563  else
564  num_cols = 9;
565  break;
566 
567  case STOCK_REGISTER:
568  case CURRENCY_REGISTER:
569  num_cols = 10;
570  break;
571 
572  case PORTFOLIO_LEDGER:
573  num_cols = 9;
574  break;
575 
576  default:
577  PERR("Bad register type");
578  g_assert (FALSE);
579  return;
580  }
581 
582  cursor = gnc_cellblock_new (1, num_cols, CURSOR_HEADER);
583  gnc_table_layout_add_cursor (layout, cursor);
584 
585  /* cursors used in ledger mode */
586  cursor = gnc_cellblock_new (1, num_cols, CURSOR_SINGLE_LEDGER);
587  gnc_table_layout_add_cursor (layout, cursor);
588 
589  gnc_table_layout_set_primary_cursor (layout, cursor);
590 
591  cursor = gnc_cellblock_new (2, num_cols, CURSOR_DOUBLE_LEDGER);
592  gnc_table_layout_add_cursor (layout, cursor);
593 
594  cursor = gnc_cellblock_new (2, num_cols, CURSOR_DOUBLE_LEDGER_NUM_ACTN);
595  gnc_table_layout_add_cursor (layout, cursor);
596 
597  /* cursors used for journal mode */
598  cursor = gnc_cellblock_new (1, num_cols, CURSOR_SINGLE_JOURNAL);
599  gnc_table_layout_add_cursor (layout, cursor);
600 
601  cursor = gnc_cellblock_new (2, num_cols, CURSOR_DOUBLE_JOURNAL);
602  gnc_table_layout_add_cursor (layout, cursor);
603 
604  cursor = gnc_cellblock_new (2, num_cols, CURSOR_DOUBLE_JOURNAL_NUM_ACTN);
605  gnc_table_layout_add_cursor (layout, cursor);
606 
607  cursor = gnc_cellblock_new (1, num_cols, CURSOR_SPLIT);
608  gnc_table_layout_add_cursor (layout, cursor);
609 }
610 
611 static void
612 gnc_split_register_layout_add_cells (SplitRegister *reg,
613  TableLayout *layout)
614 {
615  gnc_register_add_cell (layout,
616  DATE_CELL,
617  DATE_CELL_TYPE_NAME,
618  N_("sample:12/12/2000") + 7,
619  CELL_ALIGN_RIGHT,
620  FALSE,
621  FALSE);
622 
623  gnc_register_add_cell (layout,
624  DDUE_CELL,
625  DATE_CELL_TYPE_NAME,
626  N_("sample:12/12/2000") + 7,
627  CELL_ALIGN_RIGHT,
628  FALSE,
629  FALSE);
630 
631  gnc_register_add_cell (layout,
632  NUM_CELL,
633  NUM_CELL_TYPE_NAME,
634  /* Translators: The 'sample:' items are
635  strings which are not displayed, but only
636  used to estimate widths. Please only
637  translate the portion after the ':' and
638  leave the rest ("sample:") as is. */
639  N_("sample:99999") + 7,
640  CELL_ALIGN_LEFT,
641  FALSE,
642  FALSE);
643 
644  gnc_register_add_cell (layout,
645  TNUM_CELL,
646  BASIC_CELL_TYPE_NAME,
647  N_("sample:99999") + 7,
648  CELL_ALIGN_LEFT,
649  FALSE,
650  FALSE);
651 
652  gnc_register_add_cell (layout,
653  DESC_CELL,
654  QUICKFILL_CELL_TYPE_NAME,
655  N_("sample:Description of a transaction") + 7,
656  CELL_ALIGN_LEFT,
657  TRUE,
658  FALSE);
659 
660  gnc_register_add_cell (layout,
661  RATE_CELL,
662  PRICE_CELL_TYPE_NAME,
663  NULL,
664  CELL_ALIGN_RIGHT,
665  FALSE,
666  FALSE);
667 
668  gnc_register_add_cell (layout,
669  RECN_CELL,
670  RECN_CELL_TYPE_NAME,
671  N_("Reconciled:R") + 11,
672  CELL_ALIGN_CENTER,
673  FALSE,
674  FALSE);
675 
676  gnc_register_add_cell (layout,
677  BALN_CELL,
678  PRICE_CELL_TYPE_NAME,
679  N_("sample:999,999.000") + 7,
680  CELL_ALIGN_RIGHT,
681  FALSE,
682  FALSE);
683 
684  gnc_register_add_cell (layout,
685  XFRM_CELL,
686  COMBO_CELL_TYPE_NAME,
687  N_("Transfer"),
688  CELL_ALIGN_RIGHT,
689  FALSE,
690  FALSE);
691 
692  gnc_register_add_cell (layout,
693  MXFRM_CELL,
694  COMBO_CELL_TYPE_NAME,
695  N_("sample:Expenses:Automobile:Gasoline") + 7,
696  CELL_ALIGN_RIGHT,
697  FALSE,
698  FALSE);
699 
700  gnc_register_add_cell (layout,
701  ACTN_CELL,
702  COMBO_CELL_TYPE_NAME,
703  N_("sample:Expenses:Automobile:Gasoline") + 7,
704  CELL_ALIGN_RIGHT,
705  FALSE,
706  FALSE);
707 
708  gnc_register_add_cell (layout,
709  MEMO_CELL,
710  QUICKFILL_CELL_TYPE_NAME,
711  N_("sample:Memo field sample text string") + 7,
712  CELL_ALIGN_LEFT,
713  FALSE,
714  TRUE);
715 
716  gnc_register_add_cell (layout,
717  DEBT_CELL,
718  PRICE_CELL_TYPE_NAME,
719  N_("sample:999,999.000") + 7,
720  CELL_ALIGN_RIGHT,
721  FALSE,
722  FALSE);
723 
724  gnc_register_add_cell (layout,
725  CRED_CELL,
726  PRICE_CELL_TYPE_NAME,
727  N_("sample:999,999.000") + 7,
728  CELL_ALIGN_RIGHT,
729  FALSE,
730  FALSE);
731 
732  gnc_register_add_cell (layout,
733  SHRS_CELL,
734  PRICE_CELL_TYPE_NAME,
735  N_("sample:999,999.000") + 7,
736  CELL_ALIGN_RIGHT,
737  FALSE,
738  FALSE);
739 
740  /* Price cell must come after shares cell, as its callback performs
741  * a computation on the value set by the shares cell callback. */
742  gnc_register_add_cell (layout,
743  PRIC_CELL,
744  PRICE_CELL_TYPE_NAME,
745  N_("sample:999,999.000") + 7,
746  CELL_ALIGN_RIGHT,
747  FALSE,
748  FALSE);
749 
750  gnc_register_add_cell (layout,
751  TDEBT_CELL,
752  PRICE_CELL_TYPE_NAME,
753  N_("sample:999,999.000") + 7,
754  CELL_ALIGN_RIGHT,
755  FALSE,
756  FALSE);
757 
758  gnc_register_add_cell (layout,
759  TCRED_CELL,
760  PRICE_CELL_TYPE_NAME,
761  N_("sample:999,999.000") + 7,
762  CELL_ALIGN_RIGHT,
763  FALSE,
764  FALSE);
765 
766  gnc_register_add_cell (layout,
767  TSHRS_CELL,
768  PRICE_CELL_TYPE_NAME,
769  N_("sample:999,999.000") + 7,
770  CELL_ALIGN_RIGHT,
771  FALSE,
772  FALSE);
773 
774  gnc_register_add_cell (layout,
775  TBALN_CELL,
776  PRICE_CELL_TYPE_NAME,
777  N_("sample:999,999.000") + 7,
778  CELL_ALIGN_RIGHT,
779  FALSE,
780  FALSE);
781 
782  gnc_register_add_cell (layout,
783  TYPE_CELL,
784  RECN_CELL_TYPE_NAME,
785  N_("Type:T") + 5,
786  CELL_ALIGN_LEFT,
787  FALSE,
788  FALSE);
789 
790  gnc_register_add_cell (layout,
791  NOTES_CELL,
792  QUICKFILL_CELL_TYPE_NAME,
793  N_("sample:Notes field sample text string") + 7,
794  CELL_ALIGN_LEFT,
795  FALSE,
796  TRUE);
797 
798  gnc_register_add_cell (layout,
799  VNOTES_CELL,
800  BASIC_CELL_TYPE_NAME,
801  N_("sample:No Particular Reason") + 7,
802  CELL_ALIGN_RIGHT,
803  FALSE,
804  TRUE);
805 
806  gnc_register_add_cell (layout,
807  FCRED_CELL,
808  FORMULA_CELL_TYPE_NAME,
809  N_("sample:(x + 0.33 * y + (x+y) )") + 7,
810  CELL_ALIGN_LEFT,
811  FALSE,
812  FALSE);
813 
814  gnc_register_add_cell (layout,
815  FDEBT_CELL,
816  FORMULA_CELL_TYPE_NAME,
817  N_("sample:(x + 0.33 * y + (x+y) )") + 7,
818  CELL_ALIGN_LEFT,
819  FALSE,
820  FALSE);
821 
822  gnc_register_add_cell (layout,
823  RBALN_CELL,
824  PRICE_CELL_TYPE_NAME,
825  N_("sample:999,999.000") + 7,
826  CELL_ALIGN_RIGHT,
827  FALSE,
828  FALSE);
829 
830 }
831 
832 TableLayout *
834 {
835  TableLayout *layout;
836 
837  layout = gnc_table_layout_new ();
838 
839  gnc_split_register_layout_add_cells (reg, layout);
840  gnc_split_register_layout_add_cursors (reg, layout);
841  gnc_split_register_set_cells (reg, layout);
842 
843  return layout;
844 }
The type, style and table for the register.
Create the actual register visual layout.
#define PERR(format, args...)
Definition: qoflog.h:237
All type declarations for the whole Gnucash engine.
TableLayout * gnc_split_register_layout_new(SplitRegister *reg)
const gchar * QofLogModule
Definition: qofid.h:89