1 /********************************************************************\ 2 * gnc-ledger-display.h -- utilities for dealing with multiple * 3 * register/ledger windows in GnuCash * 4 * * 5 * Copyright (C) 1997 Robin D. Clark * 6 * Copyright (C) 1997, 1998 Linas Vepstas * 7 * Copyright (C) 2001 Linux Developers Group * 8 * Copyright (C) 2012 Robert Fewell * 9 * * 10 * This program is free software; you can redistribute it and/or * 11 * modify it under the terms of the GNU General Public License as * 12 * published by the Free Software Foundation; either version 2 of * 13 * the License, or (at your option) any later version. * 14 * * 15 * This program is distributed in the hope that it will be useful, * 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 18 * GNU General Public License for more details. * 19 * * 20 * You should have received a copy of the GNU General Public License* 21 * along with this program; if not, write to the Free Software * 22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 23 * * 24 \********************************************************************/ 25 26 #ifndef GNC_LEDGER_DISPLAY2_H 27 #define GNC_LEDGER_DISPLAY2_H 28 29 #include <glib.h> 30 31 #include "Account.h" 32 #include "Query.h" 33 34 #include "split-register.h" 35 36 #include "SchedXaction.h" 37 #include "Transaction.h" 38 #include "gnc-tree-model-split-reg.h" 39 #include "gnc-tree-view-split-reg.h" 40 41 /** @ingroup Register 42 * @addtogroup Register2 43 * @brief Register2 is a reimplementation of the original Register with new 44 * classes based on GtkListView. 45 * @{ 46 */ 47 /** @file gnc-ledger-display2.h 48 * @brief Public declarations for GncLedgerDisplay2 class. 49 */ 50 51 /**@brief Defines a single register/ledger 52 * instance. It has a SplitRegister specially configured for 53 * displaying the results of a Query. It also stores the Query. */ 54 typedef struct gnc_ledger_display2 GNCLedgerDisplay2; 55 56 typedef void (*GNCLedgerDisplay2Destroy) (GNCLedgerDisplay2 *ld); 57 typedef GtkWidget *(*GNCLedgerDisplay2GetParent) (GNCLedgerDisplay2 *ld); 58 typedef void (*GNCLedgerDisplay2SetHelp) (GNCLedgerDisplay2 *ld, 59 const char *help_str); 60 61 62 typedef enum 63 { 64 LD2_SINGLE, 65 LD2_SUBACCOUNT, 66 LD2_GL, 67 } GNCLedgerDisplay2Type; 68 69 70 /** returns the 'lead' account of a ledger display, or NULL if none. */ 71 Account * gnc_ledger_display2_leader (GNCLedgerDisplay2 *ld); 72 73 GNCLedgerDisplay2Type gnc_ledger_display2_type (GNCLedgerDisplay2 *ld); 74 75 /** get and set the user data associated with the ledger */ 76 void gnc_ledger_display2_set_user_data (GNCLedgerDisplay2 *ld, 77 gpointer user_data); 78 gpointer gnc_ledger_display2_get_user_data (GNCLedgerDisplay2 *ld); 79 80 /** set the handlers used by the ledger display */ 81 void gnc_ledger_display2_set_handlers (GNCLedgerDisplay2 *ld, 82 GNCLedgerDisplay2Destroy destroy, 83 GNCLedgerDisplay2GetParent get_parent); 84 85 /** Set and Get the tree view used by the ledger display */ 86 void gnc_ledger_display2_set_split_view_register (GNCLedgerDisplay2 *ld, GncTreeViewSplitReg *view); 87 GncTreeViewSplitReg * gnc_ledger_display2_get_split_view_register (GNCLedgerDisplay2 *ld); 88 89 void gnc_ledger_display2_set_split_view_refresh (GNCLedgerDisplay2 *ld, gboolean ok); 90 91 /** Returns the parent of a given ledger display */ 92 GtkWidget *gnc_ledger_display2_get_parent( GNCLedgerDisplay2 *ld ); 93 94 /** return the split register associated with a ledger display */ 95 GncTreeModelSplitReg * gnc_ledger_display2_get_split_model_register (GNCLedgerDisplay2 *ld); 96 97 /** opens up a register window to display a single account */ 98 GNCLedgerDisplay2 * gnc_ledger_display2_simple (Account *account); 99 100 /** opens up a register window to display the parent account and all of 101 * its children. */ 102 GNCLedgerDisplay2 * gnc_ledger_display2_subaccounts (Account *account, gboolean mismatched_commodities); 103 104 /** opens up a general ledger window */ 105 GNCLedgerDisplay2 * gnc_ledger_display2_gl (void); 106 107 /** 108 * Displays a template ledger. 109 * This lists template Splits from the given ScheduledTransaction. 110 * 111 * Really, requires a GList of scheduled transactions and kvp-frame 112 * data. 113 **/ 114 GNCLedgerDisplay2 * gnc_ledger_display2_template_gl (char *id); 115 116 /** display a general ledger for an arbitrary query */ 117 GNCLedgerDisplay2 * gnc_ledger_display2_query (Query *query, 118 SplitRegisterType2 type, 119 SplitRegisterStyle2 style); 120 121 /** Set the query used for a register. */ 122 void gnc_ledger_display2_set_query (GNCLedgerDisplay2 *ledger_display, 123 Query *q); 124 125 /** return the query associated with a ledger */ 126 Query * gnc_ledger_display2_get_query (GNCLedgerDisplay2 *ld); 127 128 /** If the given ledger display still exists, return it. Otherwise, 129 * return NULL */ 130 GNCLedgerDisplay2 * gnc_ledger_display2_find_by_query (Query *q); 131 132 /** redisplay/redraw only the indicated window. Both routines do same 133 * thing, they differ only by the argument they take. */ 134 void gnc_ledger_display2_refresh (GNCLedgerDisplay2 * ledger_display); 135 void gnc_ledger_display2_refresh_by_split_register (GncTreeModelSplitReg *model); 136 137 /** This is used to load the register for the schedule */ 138 void gnc_ledger_display2_refresh_sched (GNCLedgerDisplay2 *ld, GList *splits); 139 140 /** Refilter the register */ 141 void gnc_ledger_display2_refilter (GNCLedgerDisplay2 *ld); 142 143 /** close the window */ 144 void gnc_ledger_display2_close (GNCLedgerDisplay2 * ledger_display); 145 146 /** Returns a boolean of whether this display should be single or double lined 147 * mode by default */ 148 gboolean gnc_ledger_display2_default_double_line (GNCLedgerDisplay2 *gld); 149 150 #endif 151