GnuCash 2.4.99
split-register-layout.c
00001 /********************************************************************\
00002  * split-register-layout.c -- split register layout object          *
00003  * Copyright (C) 1998 Linas Vepstas <linas@linas.org>               *
00004  *                                                                  *
00005  * This program is free software; you can redistribute it and/or    *
00006  * modify it under the terms of the GNU General Public License as   *
00007  * published by the Free Software Foundation; either version 2 of   *
00008  * the License, or (at your option) any later version.              *
00009  *                                                                  *
00010  * This program is distributed in the hope that it will be useful,  *
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00013  * GNU General Public License for more details.                     *
00014  *                                                                  *
00015  * You should have received a copy of the GNU General Public License*
00016  * along with this program; if not, contact:                        *
00017  *                                                                  *
00018  * Free Software Foundation           Voice:  +1-617-542-5942       *
00019  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
00020  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
00021  *                                                                  *
00022 \********************************************************************/
00023 
00024 #include "config.h"
00025 
00026 #include <glib.h>
00027 #include <glib/gi18n.h>
00028 
00029 #include "gnc-engine.h"
00030 #include "split-register-layout.h"
00031 
00032 
00033 /* This static indicates the debugging module that this .o belongs to.  */
00034 static QofLogModule log_module = GNC_MOD_REGISTER;
00035 
00036 
00037 static void
00038 gnc_register_add_cell (TableLayout *layout,
00039                        const char *cell_name,
00040                        const char *cell_type_name,
00041                        const char *sample_text,
00042                        CellAlignment alignment,
00043                        gboolean expandable,
00044                        gboolean span)
00045 {
00046     BasicCell *cell;
00047 
00048     g_return_if_fail (layout != NULL);
00049     g_return_if_fail (cell_type_name != NULL);
00050 
00051     cell = gnc_register_make_cell (cell_type_name);
00052 
00053     gnc_basic_cell_set_name (cell, cell_name);
00054     gnc_basic_cell_set_type_name (cell, cell_type_name);
00055     gnc_basic_cell_set_sample_text (cell, sample_text);
00056     gnc_basic_cell_set_alignment (cell, alignment);
00057     gnc_basic_cell_set_expandable (cell, expandable);
00058     gnc_basic_cell_set_span (cell, span);
00059 
00060     gnc_table_layout_add_cell (layout, cell);
00061 }
00062 
00063 static void
00064 copy_cursor_row (TableLayout *layout, CellBlock *to, CellBlock *from, int row)
00065 {
00066     int col;
00067 
00068     for (col = 0; col < from->num_cols; col++)
00069     {
00070         BasicCell *cell;
00071 
00072         cell = gnc_cellblock_get_cell (from, row, col);
00073         if (!cell || !cell->cell_name)
00074             continue;
00075 
00076         gnc_table_layout_set_cell (layout, to, cell->cell_name, row, col);
00077     }
00078 }
00079 
00080 static void
00081 gnc_split_register_set_cells (SplitRegister *reg, TableLayout *layout)
00082 {
00083     CellBlock *curs;
00084     CellBlock *curs_last;
00085 
00086     switch (reg->type)
00087     {
00088     case BANK_REGISTER:
00089     case CASH_REGISTER:
00090     case ASSET_REGISTER:
00091     case CREDIT_REGISTER:
00092     case LIABILITY_REGISTER:
00093     case INCOME_REGISTER:
00094     case EXPENSE_REGISTER:
00095     case EQUITY_REGISTER:
00096     case TRADING_REGISTER:
00097     {
00098         curs = gnc_table_layout_get_cursor (layout,
00099                                             CURSOR_SINGLE_LEDGER);
00100 
00101         gnc_table_layout_set_cell (layout, curs, DATE_CELL,  0, 0);
00102         gnc_table_layout_set_cell (layout, curs, NUM_CELL,   0, 1);
00103         gnc_table_layout_set_cell (layout, curs, DESC_CELL,  0, 2);
00104         gnc_table_layout_set_cell (layout, curs, MXFRM_CELL, 0, 3);
00105         gnc_table_layout_set_cell (layout, curs, RECN_CELL,  0, 4);
00106         if (reg->is_template)
00107         {
00108             gnc_table_layout_set_cell (layout, curs, FDEBT_CELL, 0, 5);
00109             gnc_table_layout_set_cell (layout, curs, FCRED_CELL, 0, 6);
00110         }
00111         else
00112         {
00113             gnc_table_layout_set_cell (layout, curs, DEBT_CELL,  0, 5);
00114             gnc_table_layout_set_cell (layout, curs, CRED_CELL,  0, 6);
00115         }
00116         gnc_table_layout_set_cell (layout, curs, BALN_CELL,  0, 7);
00117         gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 8);
00118 
00119         curs_last = curs;
00120         curs = gnc_table_layout_get_cursor (layout,
00121                                             CURSOR_DOUBLE_LEDGER);
00122 
00123         copy_cursor_row (layout, curs, curs_last, 0);
00124 
00125         gnc_table_layout_set_cell (layout, curs, ACTN_CELL,  1, 1);
00126         gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
00127         gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
00128 
00129         curs = gnc_table_layout_get_cursor (layout,
00130                                             CURSOR_SINGLE_JOURNAL);
00131 
00132         gnc_table_layout_set_cell (layout, curs, DATE_CELL,  0, 0);
00133         gnc_table_layout_set_cell (layout, curs, NUM_CELL,   0, 1);
00134         gnc_table_layout_set_cell (layout, curs, DESC_CELL,  0, 2);
00135         gnc_table_layout_set_cell (layout, curs, TDEBT_CELL, 0, 5);
00136         gnc_table_layout_set_cell (layout, curs, TCRED_CELL, 0, 6);
00137         gnc_table_layout_set_cell (layout, curs, TBALN_CELL, 0, 7);
00138         gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 8);
00139 
00140         curs_last = curs;
00141         curs = gnc_table_layout_get_cursor (layout,
00142                                             CURSOR_DOUBLE_JOURNAL);
00143 
00144         copy_cursor_row (layout, curs, curs_last, 0);
00145 
00146         gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
00147         gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
00148 
00149         curs = gnc_table_layout_get_cursor (layout,
00150                                             CURSOR_SPLIT);
00151 
00152         gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 0, 1);
00153         gnc_table_layout_set_cell (layout, curs, MEMO_CELL, 0, 2);
00154         gnc_table_layout_set_cell (layout, curs, XFRM_CELL, 0, 3);
00155         gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
00156         if (reg->is_template)
00157         {
00158             gnc_table_layout_set_cell (layout, curs, FDEBT_CELL, 0, 5);
00159             gnc_table_layout_set_cell (layout, curs, FCRED_CELL, 0, 6);
00160         }
00161         else
00162         {
00163             gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 5);
00164             gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 6);
00165         }
00166         gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 8);
00167 
00168         break;
00169     }
00170     /* --------------------------------------------------------- */
00171 
00172     case PAYABLE_REGISTER:
00173     case RECEIVABLE_REGISTER:
00174     {
00175         curs = gnc_table_layout_get_cursor (layout,
00176                                             CURSOR_SINGLE_LEDGER);
00177 
00178         gnc_table_layout_set_cell (layout, curs, DATE_CELL,  0, 0);
00179         gnc_table_layout_set_cell (layout, curs, TYPE_CELL,  0, 1);
00180         gnc_table_layout_set_cell (layout, curs, DDUE_CELL,  0, 2);
00181         gnc_table_layout_set_cell (layout, curs, NUM_CELL,   0, 3);
00182         gnc_table_layout_set_cell (layout, curs, DESC_CELL,  0, 4);
00183         gnc_table_layout_set_cell (layout, curs, MXFRM_CELL, 0, 5);
00184         gnc_table_layout_set_cell (layout, curs, DEBT_CELL,  0, 6);
00185         gnc_table_layout_set_cell (layout, curs, CRED_CELL,  0, 7);
00186         gnc_table_layout_set_cell (layout, curs, BALN_CELL,  0, 8);
00187 
00188         curs_last = curs;
00189         curs = gnc_table_layout_get_cursor (layout,
00190                                             CURSOR_DOUBLE_LEDGER);
00191 
00192         copy_cursor_row (layout, curs, curs_last, 0);
00193 
00194         gnc_table_layout_set_cell (layout, curs, ACTN_CELL,  1, 3);
00195         gnc_table_layout_set_cell (layout, curs, MEMO_CELL, 1, 4);
00196 
00197         curs = gnc_table_layout_get_cursor (layout,
00198                                             CURSOR_SINGLE_JOURNAL);
00199 
00200         gnc_table_layout_set_cell (layout, curs, DATE_CELL,  0, 0);
00201         gnc_table_layout_set_cell (layout, curs, TYPE_CELL,  0, 1);
00202         gnc_table_layout_set_cell (layout, curs, DDUE_CELL,  0, 2);
00203         gnc_table_layout_set_cell (layout, curs, NUM_CELL,   0, 3);
00204         gnc_table_layout_set_cell (layout, curs, DESC_CELL,  0, 4);
00205 
00206         gnc_table_layout_set_cell (layout, curs, TDEBT_CELL, 0, 6);
00207         gnc_table_layout_set_cell (layout, curs, TCRED_CELL, 0, 7);
00208         gnc_table_layout_set_cell (layout, curs, TBALN_CELL, 0, 8);
00209 
00210         curs_last = curs;
00211         curs = gnc_table_layout_get_cursor (layout,
00212                                             CURSOR_DOUBLE_JOURNAL);
00213 
00214         copy_cursor_row (layout, curs, curs_last, 0);
00215 
00216         gnc_table_layout_set_cell (layout, curs, MEMO_CELL, 1, 4);
00217 
00218         curs = gnc_table_layout_get_cursor (layout,
00219                                             CURSOR_SPLIT);
00220 
00221         gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 0, 3);
00222         gnc_table_layout_set_cell (layout, curs, MEMO_CELL, 0, 4);
00223         gnc_table_layout_set_cell (layout, curs, XFRM_CELL, 0, 5);
00224         gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 6);
00225         gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 7);
00226 
00227         break;
00228     }
00229 
00230     /* --------------------------------------------------------- */
00231     case INCOME_LEDGER:
00232     case GENERAL_LEDGER:
00233     case SEARCH_LEDGER:
00234     {
00235         curs = gnc_table_layout_get_cursor (layout,
00236                                             CURSOR_SINGLE_LEDGER);
00237 
00238         gnc_table_layout_set_cell (layout, curs, DATE_CELL,  0, 0);
00239         gnc_table_layout_set_cell (layout, curs, NUM_CELL,   0, 1);
00240         gnc_table_layout_set_cell (layout, curs, DESC_CELL,  0, 2);
00241         gnc_table_layout_set_cell (layout, curs, MXFRM_CELL, 0, 3);
00242         gnc_table_layout_set_cell (layout, curs, RECN_CELL,  0, 4);
00243         if (reg->is_template)
00244         {
00245             gnc_table_layout_set_cell (layout, curs, FDEBT_CELL,  0, 5);
00246             gnc_table_layout_set_cell (layout, curs, FCRED_CELL,  0, 6);
00247             gnc_table_layout_set_cell (layout, curs, RATE_CELL,   0, 7);
00248         }
00249         else
00250         {
00251             gnc_table_layout_set_cell (layout, curs, DEBT_CELL,  0, 5);
00252             gnc_table_layout_set_cell (layout, curs, CRED_CELL,  0, 6);
00253             gnc_table_layout_set_cell (layout, curs, RBALN_CELL, 0, 7);
00254             gnc_table_layout_set_cell (layout, curs, RATE_CELL,  0, 8);
00255         }
00256 
00257         curs_last = curs;
00258         curs = gnc_table_layout_get_cursor (layout,
00259                                             CURSOR_DOUBLE_LEDGER);
00260 
00261         copy_cursor_row (layout, curs, curs_last, 0);
00262 
00263         gnc_table_layout_set_cell (layout, curs, ACTN_CELL,  1, 1);
00264         gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
00265         gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
00266 
00267         curs = gnc_table_layout_get_cursor (layout,
00268                                             CURSOR_SINGLE_JOURNAL);
00269 
00270         gnc_table_layout_set_cell (layout, curs, DATE_CELL,  0, 0);
00271         gnc_table_layout_set_cell (layout, curs, NUM_CELL,   0, 1);
00272         gnc_table_layout_set_cell (layout, curs, DESC_CELL,  0, 2);
00273         gnc_table_layout_set_cell (layout, curs, TDEBT_CELL, 0, 5);
00274         gnc_table_layout_set_cell (layout, curs, TCRED_CELL, 0, 6);
00275         if (reg->is_template)
00276             gnc_table_layout_set_cell (layout, curs, RATE_CELL,  0, 7);
00277         else
00278         {
00279             gnc_table_layout_set_cell (layout, curs, RBALN_CELL, 0, 7);
00280             gnc_table_layout_set_cell (layout, curs, RATE_CELL,  0, 8);
00281         }
00282 
00283         curs_last = curs;
00284         curs = gnc_table_layout_get_cursor (layout,
00285                                             CURSOR_DOUBLE_JOURNAL);
00286 
00287         copy_cursor_row (layout, curs, curs_last, 0);
00288 
00289         gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
00290         gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
00291 
00292         curs = gnc_table_layout_get_cursor (layout,
00293                                             CURSOR_SPLIT);
00294 
00295         gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 0, 1);
00296         gnc_table_layout_set_cell (layout, curs, MEMO_CELL, 0, 2);
00297         gnc_table_layout_set_cell (layout, curs, XFRM_CELL, 0, 3);
00298         gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
00299         if (reg->is_template)
00300         {
00301             gnc_table_layout_set_cell (layout, curs, FDEBT_CELL,  0, 5);
00302             gnc_table_layout_set_cell (layout, curs, FCRED_CELL,  0, 6);
00303             gnc_table_layout_set_cell (layout, curs, RATE_CELL,   0, 7);
00304         }
00305         else
00306         {
00307             gnc_table_layout_set_cell (layout, curs, DEBT_CELL,  0, 5);
00308             gnc_table_layout_set_cell (layout, curs, CRED_CELL,  0, 6);
00309             gnc_table_layout_set_cell (layout, curs, RATE_CELL,  0, 8);
00310         }
00311 
00312         break;
00313     }
00314 
00315     /* --------------------------------------------------------- */
00316     case STOCK_REGISTER:
00317     case CURRENCY_REGISTER:
00318     {
00319         curs = gnc_table_layout_get_cursor (layout,
00320                                             CURSOR_SINGLE_LEDGER);
00321 
00322         gnc_table_layout_set_cell (layout, curs, DATE_CELL,  0,  0);
00323         gnc_table_layout_set_cell (layout, curs, NUM_CELL,   0,  1);
00324         gnc_table_layout_set_cell (layout, curs, DESC_CELL,  0,  2);
00325         gnc_table_layout_set_cell (layout, curs, MXFRM_CELL, 0,  3);
00326         gnc_table_layout_set_cell (layout, curs, RECN_CELL,  0,  4);
00327         gnc_table_layout_set_cell (layout, curs, SHRS_CELL,  0,  5);
00328         gnc_table_layout_set_cell (layout, curs, PRIC_CELL,  0,  6);
00329         gnc_table_layout_set_cell (layout, curs, DEBT_CELL,  0,  7);
00330         gnc_table_layout_set_cell (layout, curs, CRED_CELL,  0,  8);
00331         gnc_table_layout_set_cell (layout, curs, BALN_CELL,  0,  9);
00332 
00333         curs_last = curs;
00334         curs = gnc_table_layout_get_cursor (layout,
00335                                             CURSOR_DOUBLE_LEDGER);
00336 
00337         copy_cursor_row (layout, curs, curs_last, 0);
00338 
00339         gnc_table_layout_set_cell (layout, curs, ACTN_CELL,  1, 1);
00340         gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
00341         gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
00342 
00343         curs = gnc_table_layout_get_cursor (layout,
00344                                             CURSOR_SINGLE_JOURNAL);
00345 
00346         gnc_table_layout_set_cell (layout, curs, DATE_CELL,  0,  0);
00347         gnc_table_layout_set_cell (layout, curs, NUM_CELL,   0,  1);
00348         gnc_table_layout_set_cell (layout, curs, DESC_CELL,  0,  2);
00349         gnc_table_layout_set_cell (layout, curs, TSHRS_CELL, 0,  5);
00350         gnc_table_layout_set_cell (layout, curs, TDEBT_CELL, 0,  7);
00351         gnc_table_layout_set_cell (layout, curs, TCRED_CELL, 0,  8);
00352         gnc_table_layout_set_cell (layout, curs, TBALN_CELL, 0,  9);
00353 
00354         curs_last = curs;
00355         curs = gnc_table_layout_get_cursor (layout,
00356                                             CURSOR_DOUBLE_JOURNAL);
00357 
00358         copy_cursor_row (layout, curs, curs_last, 0);
00359 
00360         gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
00361         gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
00362 
00363         curs = gnc_table_layout_get_cursor (layout,
00364                                             CURSOR_SPLIT);
00365 
00366         gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 0, 1);
00367         gnc_table_layout_set_cell (layout, curs, MEMO_CELL, 0, 2);
00368         gnc_table_layout_set_cell (layout, curs, XFRM_CELL, 0, 3);
00369         gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
00370         gnc_table_layout_set_cell (layout, curs, SHRS_CELL, 0, 5);
00371         gnc_table_layout_set_cell (layout, curs, PRIC_CELL, 0, 6);
00372         gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 7);
00373         gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 8);
00374 
00375         break;
00376     }
00377 
00378     /* --------------------------------------------------------- */
00379     case PORTFOLIO_LEDGER:
00380     {
00381         curs = gnc_table_layout_get_cursor (layout,
00382                                             CURSOR_SINGLE_LEDGER);
00383 
00384         gnc_table_layout_set_cell (layout, curs, DATE_CELL,  0, 0);
00385         gnc_table_layout_set_cell (layout, curs, NUM_CELL,   0, 1);
00386         gnc_table_layout_set_cell (layout, curs, DESC_CELL,  0, 2);
00387         gnc_table_layout_set_cell (layout, curs, MXFRM_CELL, 0, 3);
00388         gnc_table_layout_set_cell (layout, curs, RECN_CELL,  0, 4);
00389         gnc_table_layout_set_cell (layout, curs, SHRS_CELL,  0, 5);
00390         gnc_table_layout_set_cell (layout, curs, PRIC_CELL,  0, 6);
00391         gnc_table_layout_set_cell (layout, curs, DEBT_CELL,  0, 7);
00392         gnc_table_layout_set_cell (layout, curs, CRED_CELL,  0, 8);
00393 
00394         curs_last = curs;
00395         curs = gnc_table_layout_get_cursor (layout,
00396                                             CURSOR_DOUBLE_LEDGER);
00397 
00398         copy_cursor_row (layout, curs, curs_last, 0);
00399 
00400         gnc_table_layout_set_cell (layout, curs, ACTN_CELL,  1, 1);
00401         gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
00402         gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
00403 
00404         curs = gnc_table_layout_get_cursor (layout,
00405                                             CURSOR_SINGLE_JOURNAL);
00406 
00407         gnc_table_layout_set_cell (layout, curs, DATE_CELL,  0, 0);
00408         gnc_table_layout_set_cell (layout, curs, NUM_CELL,   0, 1);
00409         gnc_table_layout_set_cell (layout, curs, DESC_CELL,  0, 2);
00410         gnc_table_layout_set_cell (layout, curs, TSHRS_CELL, 0, 5);
00411         gnc_table_layout_set_cell (layout, curs, TDEBT_CELL, 0, 7);
00412         gnc_table_layout_set_cell (layout, curs, TCRED_CELL, 0, 8);
00413 
00414         curs_last = curs;
00415         curs = gnc_table_layout_get_cursor (layout,
00416                                             CURSOR_DOUBLE_JOURNAL);
00417 
00418         copy_cursor_row (layout, curs, curs_last, 0);
00419 
00420         gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
00421         gnc_table_layout_set_cell (layout, curs, VNOTES_CELL, 1, 3);
00422 
00423         curs = gnc_table_layout_get_cursor (layout,
00424                                             CURSOR_SPLIT);
00425 
00426         gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 0, 1);
00427         gnc_table_layout_set_cell (layout, curs, MEMO_CELL, 0, 2);
00428         gnc_table_layout_set_cell (layout, curs, XFRM_CELL, 0, 3);
00429         gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
00430         gnc_table_layout_set_cell (layout, curs, SHRS_CELL, 0, 5);
00431         gnc_table_layout_set_cell (layout, curs, PRIC_CELL, 0, 6);
00432         gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 7);
00433         gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 8);
00434 
00435         break;
00436     }
00437 
00438     /* --------------------------------------------------------- */
00439     default:
00440         PERR ("unknown register type %d \n", reg->type);
00441         break;
00442     }
00443 }
00444 
00445 static void
00446 gnc_split_register_layout_add_cursors (SplitRegister *reg,
00447                                        TableLayout *layout)
00448 {
00449     CellBlock *cursor;
00450     int num_cols;
00451 
00452     switch (reg->type)
00453     {
00454     case BANK_REGISTER:
00455     case CASH_REGISTER:
00456     case ASSET_REGISTER:
00457     case CREDIT_REGISTER:
00458     case LIABILITY_REGISTER:
00459     case INCOME_REGISTER:
00460     case EXPENSE_REGISTER:
00461     case EQUITY_REGISTER:
00462     case TRADING_REGISTER:
00463         num_cols = 9;
00464         break;
00465 
00466     case PAYABLE_REGISTER:
00467     case RECEIVABLE_REGISTER:
00468         num_cols = 9;
00469         break;
00470 
00471     case INCOME_LEDGER:
00472     case GENERAL_LEDGER:
00473     case SEARCH_LEDGER:
00474         if (reg->is_template)
00475             num_cols = 8;
00476         else
00477             num_cols = 9;
00478         break;
00479 
00480     case STOCK_REGISTER:
00481     case CURRENCY_REGISTER:
00482         num_cols = 10;
00483         break;
00484 
00485     case PORTFOLIO_LEDGER:
00486         num_cols = 9;
00487         break;
00488 
00489     default:
00490         PERR("Bad register type");
00491         g_assert (FALSE);
00492         return;
00493     }
00494 
00495     cursor = gnc_cellblock_new (1, num_cols, CURSOR_HEADER);
00496     gnc_table_layout_add_cursor (layout, cursor);
00497 
00498     /* cursors used in ledger mode */
00499     cursor = gnc_cellblock_new (1, num_cols, CURSOR_SINGLE_LEDGER);
00500     gnc_table_layout_add_cursor (layout, cursor);
00501 
00502     gnc_table_layout_set_primary_cursor (layout, cursor);
00503 
00504     cursor = gnc_cellblock_new (2, num_cols, CURSOR_DOUBLE_LEDGER);
00505     gnc_table_layout_add_cursor (layout, cursor);
00506 
00507     /* cursors used for journal mode */
00508     cursor = gnc_cellblock_new (1, num_cols, CURSOR_SINGLE_JOURNAL);
00509     gnc_table_layout_add_cursor (layout, cursor);
00510 
00511     cursor = gnc_cellblock_new (2, num_cols, CURSOR_DOUBLE_JOURNAL);
00512     gnc_table_layout_add_cursor (layout, cursor);
00513 
00514     cursor = gnc_cellblock_new (1, num_cols, CURSOR_SPLIT);
00515     gnc_table_layout_add_cursor (layout, cursor);
00516 }
00517 
00518 static void
00519 gnc_split_register_layout_add_cells (SplitRegister *reg,
00520                                      TableLayout *layout)
00521 {
00522     gnc_register_add_cell (layout,
00523                            DATE_CELL,
00524                            DATE_CELL_TYPE_NAME,
00525                            N_("sample:12/12/2000") + 7,
00526                            CELL_ALIGN_RIGHT,
00527                            FALSE,
00528                            FALSE);
00529 
00530     gnc_register_add_cell (layout,
00531                            DDUE_CELL,
00532                            DATE_CELL_TYPE_NAME,
00533                            N_("sample:12/12/2000") + 7,
00534                            CELL_ALIGN_RIGHT,
00535                            FALSE,
00536                            FALSE);
00537 
00538     gnc_register_add_cell (layout,
00539                            NUM_CELL,
00540                            NUM_CELL_TYPE_NAME,
00541                            /* Translators: The 'sample:' items are
00542                               strings which are not displayed, but only
00543                               used to estimate widths. Please only
00544                               translate the portion after the ':' and
00545                               leave the rest ("sample:") as is. */
00546                            N_("sample:99999") + 7,
00547                            CELL_ALIGN_LEFT,
00548                            FALSE,
00549                            FALSE);
00550 
00551     gnc_register_add_cell (layout,
00552                            DESC_CELL,
00553                            QUICKFILL_CELL_TYPE_NAME,
00554                            N_("sample:Description of a transaction") + 7,
00555                            CELL_ALIGN_LEFT,
00556                            TRUE,
00557                            FALSE);
00558 
00559     gnc_register_add_cell (layout,
00560                            RATE_CELL,
00561                            PRICE_CELL_TYPE_NAME,
00562                            NULL,
00563                            CELL_ALIGN_RIGHT,
00564                            FALSE,
00565                            FALSE);
00566 
00567     gnc_register_add_cell (layout,
00568                            RECN_CELL,
00569                            RECN_CELL_TYPE_NAME,
00570                            N_("Reconciled:R") + 11,
00571                            CELL_ALIGN_CENTER,
00572                            FALSE,
00573                            FALSE);
00574 
00575     gnc_register_add_cell (layout,
00576                            BALN_CELL,
00577                            PRICE_CELL_TYPE_NAME,
00578                            N_("sample:999,999.000") + 7,
00579                            CELL_ALIGN_RIGHT,
00580                            FALSE,
00581                            FALSE);
00582 
00583     gnc_register_add_cell (layout,
00584                            XFRM_CELL,
00585                            COMBO_CELL_TYPE_NAME,
00586                            N_("Transfer"),
00587                            CELL_ALIGN_RIGHT,
00588                            FALSE,
00589                            FALSE);
00590 
00591     gnc_register_add_cell (layout,
00592                            MXFRM_CELL,
00593                            COMBO_CELL_TYPE_NAME,
00594                            N_("sample:Expenses:Automobile:Gasoline") + 7,
00595                            CELL_ALIGN_RIGHT,
00596                            FALSE,
00597                            FALSE);
00598 
00599     gnc_register_add_cell (layout,
00600                            ACTN_CELL,
00601                            COMBO_CELL_TYPE_NAME,
00602                            N_("sample:Expenses:Automobile:Gasoline") + 7,
00603                            CELL_ALIGN_RIGHT,
00604                            FALSE,
00605                            FALSE);
00606 
00607     gnc_register_add_cell (layout,
00608                            MEMO_CELL,
00609                            QUICKFILL_CELL_TYPE_NAME,
00610                            N_("sample:Memo field sample text string") + 7,
00611                            CELL_ALIGN_LEFT,
00612                            FALSE,
00613                            TRUE);
00614 
00615     gnc_register_add_cell (layout,
00616                            DEBT_CELL,
00617                            PRICE_CELL_TYPE_NAME,
00618                            N_("sample:999,999.000") + 7,
00619                            CELL_ALIGN_RIGHT,
00620                            FALSE,
00621                            FALSE);
00622 
00623     gnc_register_add_cell (layout,
00624                            CRED_CELL,
00625                            PRICE_CELL_TYPE_NAME,
00626                            N_("sample:999,999.000") + 7,
00627                            CELL_ALIGN_RIGHT,
00628                            FALSE,
00629                            FALSE);
00630 
00631     gnc_register_add_cell (layout,
00632                            SHRS_CELL,
00633                            PRICE_CELL_TYPE_NAME,
00634                            N_("sample:999,999.000") + 7,
00635                            CELL_ALIGN_RIGHT,
00636                            FALSE,
00637                            FALSE);
00638 
00639     /* Price cell must come after shares cell, as its callback performs
00640      * a computation on the value set by the shares cell callback. */
00641     gnc_register_add_cell (layout,
00642                            PRIC_CELL,
00643                            PRICE_CELL_TYPE_NAME,
00644                            N_("sample:999,999.000") + 7,
00645                            CELL_ALIGN_RIGHT,
00646                            FALSE,
00647                            FALSE);
00648 
00649     gnc_register_add_cell (layout,
00650                            TDEBT_CELL,
00651                            PRICE_CELL_TYPE_NAME,
00652                            N_("sample:999,999.000") + 7,
00653                            CELL_ALIGN_RIGHT,
00654                            FALSE,
00655                            FALSE);
00656 
00657     gnc_register_add_cell (layout,
00658                            TCRED_CELL,
00659                            PRICE_CELL_TYPE_NAME,
00660                            N_("sample:999,999.000") + 7,
00661                            CELL_ALIGN_RIGHT,
00662                            FALSE,
00663                            FALSE);
00664 
00665     gnc_register_add_cell (layout,
00666                            TSHRS_CELL,
00667                            PRICE_CELL_TYPE_NAME,
00668                            N_("sample:999,999.000") + 7,
00669                            CELL_ALIGN_RIGHT,
00670                            FALSE,
00671                            FALSE);
00672 
00673     gnc_register_add_cell (layout,
00674                            TBALN_CELL,
00675                            PRICE_CELL_TYPE_NAME,
00676                            N_("sample:999,999.000") + 7,
00677                            CELL_ALIGN_RIGHT,
00678                            FALSE,
00679                            FALSE);
00680 
00681     gnc_register_add_cell (layout,
00682                            TYPE_CELL,
00683                            RECN_CELL_TYPE_NAME,
00684                            N_("Type:T") + 5,
00685                            CELL_ALIGN_LEFT,
00686                            FALSE,
00687                            FALSE);
00688 
00689     gnc_register_add_cell (layout,
00690                            NOTES_CELL,
00691                            QUICKFILL_CELL_TYPE_NAME,
00692                            N_("sample:Notes field sample text string") + 7,
00693                            CELL_ALIGN_LEFT,
00694                            FALSE,
00695                            TRUE);
00696 
00697     gnc_register_add_cell (layout,
00698                            VNOTES_CELL,
00699                            BASIC_CELL_TYPE_NAME,
00700                            N_("sample:No Particular Reason") + 7,
00701                            CELL_ALIGN_RIGHT,
00702                            FALSE,
00703                            TRUE);
00704 
00705     gnc_register_add_cell (layout,
00706                            FCRED_CELL,
00707                            FORMULA_CELL_TYPE_NAME,
00708                            N_("sample:(x + 0.33 * y + (x+y) )") + 7,
00709                            CELL_ALIGN_LEFT,
00710                            FALSE,
00711                            FALSE);
00712 
00713     gnc_register_add_cell (layout,
00714                            FDEBT_CELL,
00715                            FORMULA_CELL_TYPE_NAME,
00716                            N_("sample:(x + 0.33 * y + (x+y) )") + 7,
00717                            CELL_ALIGN_LEFT,
00718                            FALSE,
00719                            FALSE);
00720 
00721     gnc_register_add_cell (layout,
00722                            RBALN_CELL,
00723                            PRICE_CELL_TYPE_NAME,
00724                            N_("sample:999,999.000") + 7,
00725                            CELL_ALIGN_RIGHT,
00726                            FALSE,
00727                            FALSE);
00728 
00729 }
00730 
00731 TableLayout *
00732 gnc_split_register_layout_new (SplitRegister *reg)
00733 {
00734     TableLayout *layout;
00735 
00736     layout = gnc_table_layout_new ();
00737 
00738     gnc_split_register_layout_add_cells (reg, layout);
00739     gnc_split_register_layout_add_cursors (reg, layout);
00740     gnc_split_register_set_cells (reg, layout);
00741 
00742     return layout;
00743 }
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines