GnuCash 2.4.99
table-allgui.h
Go to the documentation of this file.
00001 /********************************************************************\
00002  * table-allgui.h -- 2D grid table object, embeds cells for i/o     *
00003  *                                                                  *
00004  * This program is free software; you can redistribute it and/or    *
00005  * modify it under the terms of the GNU General Public License as   *
00006  * published by the Free Software Foundation; either version 2 of   *
00007  * the License, or (at your option) any later version.              *
00008  *                                                                  *
00009  * This program is distributed in the hope that it will be useful,  *
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00012  * GNU General Public License for more details.                     *
00013  *                                                                  *
00014  * You should have received a copy of the GNU General Public License*
00015  * along with this program; if not, contact:                        *
00016  *                                                                  *
00017  * Free Software Foundation           Voice:  +1-617-542-5942       *
00018  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
00019  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
00020  *                                                                  *
00021 \********************************************************************/
00096 #ifndef TABLE_ALLGUI_H
00097 #define TABLE_ALLGUI_H
00098 
00099 #include <glib.h>
00100 
00101 #include "basiccell.h"
00102 #include "cellblock.h"
00103 #include "gtable.h"
00104 #include "register-common.h"
00105 #include "table-control.h"
00106 #include "table-layout.h"
00107 #include "table-model.h"
00108 
00109 /* The VirtualCell structure holds information about each virtual cell. */
00110 typedef struct
00111 {
00112     CellBlock *cellblock;  /* Array of physical cells */
00113     gpointer   vcell_data; /* Used by higher-level code */
00114 
00115     /* flags */
00116     unsigned int visible : 1;             /* visible in the GUI */
00117     unsigned int start_primary_color : 1; /* color usage flag */
00118 } VirtualCell;
00119 
00120 typedef struct table Table;
00121 
00122 typedef void (*TableCursorRefreshCB) (Table *table,
00123                                       VirtualCellLocation vcell_loc,
00124                                       gboolean do_scroll);
00125 
00126 typedef void (*TableRedrawHelpCB) (Table *table);
00127 typedef void (*TableDestroyCB) (Table *table);
00128 
00129 typedef struct
00130 {
00131     TableCursorRefreshCB cursor_refresh;
00132 
00133     TableRedrawHelpCB redraw_help;
00134     TableDestroyCB destroy;
00135 } TableGUIHandlers;
00136 
00137 struct table
00138 {
00139     TableLayout  *layout;
00140     TableModel   *model;
00141     TableControl *control;
00142 
00143     int num_virt_rows;
00144     int num_virt_cols;
00145 
00146     CellBlock *current_cursor;
00147 
00148     VirtualLocation current_cursor_loc;
00149 
00150     /* private data */
00151 
00152     /* The virtual cell table */
00153     GTable *virt_cells;
00154 
00155     TableGUIHandlers gui_handlers;
00156     gpointer ui_data;
00157 };
00158 
00159 
00160 /* Set the default gui handlers used by new tables. */
00161 void gnc_table_set_default_gui_handlers (TableGUIHandlers *gui_handlers);
00162 
00163 /* Functions to create and destroy Tables.  */
00164 Table *     gnc_table_new (TableLayout *layout,
00165                            TableModel *model,
00166                            TableControl *control);
00167 void        gnc_virtual_location_init (VirtualLocation *vloc);
00168 
00169 void        gnc_table_save_state (Table *table);
00170 void        gnc_table_destroy (Table *table);
00171 
00172 
00173 /* Functions to work with current cursor */
00174 int         gnc_table_current_cursor_changed (Table *table,
00175         gboolean include_conditional);
00176 
00177 void        gnc_table_clear_current_cursor_changes (Table *table);
00178 
00179 void        gnc_table_save_current_cursor (Table *table, CursorBuffer *buffer);
00180 void        gnc_table_restore_current_cursor (Table *table,
00181         CursorBuffer *buffer);
00182 
00183 const char * gnc_table_get_current_cell_name (Table *table);
00184 
00185 gboolean    gnc_table_get_current_cell_location (Table *table,
00186         const char *cell_name,
00187         VirtualLocation *virt_loc);
00188 
00189 
00190 /* This function checks the given location and returns true
00191  * if it is out of bounds of the table. */
00192 gboolean gnc_table_virtual_cell_out_of_bounds (Table *table,
00193         VirtualCellLocation vcell_loc);
00194 
00195 gboolean gnc_table_virtual_location_in_header (Table *table,
00196         VirtualLocation virt_loc);
00197 
00198 
00199 /* This function returns the virtual cell associated with a particular
00200  *   virtual location. If the location is out of bounds, NULL is *
00201  *   returned. */
00202 VirtualCell *  gnc_table_get_virtual_cell (Table *table,
00203         VirtualCellLocation vcell_loc);
00204 
00205 const char *   gnc_table_get_entry (Table *table, VirtualLocation virt_loc);
00206 
00207 const char *   gnc_table_get_label (Table *table, VirtualLocation virt_loc);
00208 
00209 CellIOFlags    gnc_table_get_io_flags (Table *table, VirtualLocation virt_loc);
00210 
00211 guint32        gnc_table_get_fg_color (Table *table, VirtualLocation virt_loc);
00212 
00213 guint32        gnc_table_get_bg_color (Table *table, VirtualLocation virt_loc,
00214                                        gboolean *hatching);
00215 guint32        gnc_table_get_gtkrc_bg_color (Table *table, VirtualLocation virt_loc,
00216         gboolean *hatching);
00217 
00218 void           gnc_table_get_borders (Table *table, VirtualLocation virt_loc,
00219                                       PhysicalCellBorders *borders);
00220 
00221 CellAlignment  gnc_table_get_align (Table *table, VirtualLocation virt_loc);
00222 
00223 gboolean       gnc_table_is_popup (Table *table, VirtualLocation virt_loc);
00224 
00225 char *         gnc_table_get_help (Table *table);
00226 
00227 BasicCell *    gnc_table_get_cell (Table *table, VirtualLocation virt_loc);
00228 
00229 const char *   gnc_table_get_cell_name (Table *table,
00230                                         VirtualLocation virt_loc);
00231 const gchar *  gnc_table_get_cell_type_name (Table *table,
00232         VirtualLocation virt_loc);
00233 gboolean       gnc_table_get_cell_location (Table *table,
00234         const char * cell_name,
00235         VirtualCellLocation vcell_loc,
00236         VirtualLocation *virt_loc);
00237 
00238 void           gnc_table_save_cells (Table *table, gpointer save_data);
00239 
00240 
00241 /* Return the virtual cell of the header */
00242 VirtualCell *  gnc_table_get_header_cell (Table *table);
00243 
00244 /* The gnc_table_set_size() method will resize the table to the
00245  *   indicated dimensions.  */
00246 void        gnc_table_set_size (Table * table, int virt_rows, int virt_cols);
00247 
00248 /* Indicate what handler should be used for a given virtual block */
00249 void        gnc_table_set_vcell (Table *table, CellBlock *cursor,
00250                                  gconstpointer vcell_data,
00251                                  gboolean visible,
00252                                  gboolean start_primary_color,
00253                                  VirtualCellLocation vcell_loc);
00254 
00255 /* Set the virtual cell data for a particular location. */
00256 void        gnc_table_set_virt_cell_data (Table *table,
00257         VirtualCellLocation vcell_loc,
00258         gconstpointer vcell_data);
00259 
00260 /* Set the visibility flag for a particular location. */
00261 void        gnc_table_set_virt_cell_visible (Table *table,
00262         VirtualCellLocation vcell_loc,
00263         gboolean visible);
00264 
00265 /* Set the cellblock handler for a virtual cell. */
00266 void        gnc_table_set_virt_cell_cursor (Table *table,
00267         VirtualCellLocation vcell_loc,
00268         CellBlock *cursor);
00269 
00270 /* The gnc_table_move_cursor() method will move the cursor (but not
00271  *   the cursor GUI) to the indicated location. This function is
00272  *   useful when loading the table from the cursor: data can be loaded
00273  *   into the cursor, then committed to the table, all without the
00274  *   annoying screen flashing associated with GUI redraw. */
00275 void        gnc_table_move_cursor (Table *table, VirtualLocation virt_loc);
00276 
00277 /* The gnc_table_move_cursor_gui() method will move the cursor and its
00278  *   GUI to the indicated location. Through a series of callbacks, all
00279  *   GUI elements get repositioned. */
00280 void        gnc_table_move_cursor_gui (Table *table, VirtualLocation virt_loc);
00281 
00282 /* The gnc_table_verify_cursor_position() method checks the location
00283  *   of the cursor with respect to a virtual location position, and if
00284  *   the resulting virtual location has changed, repositions the
00285  *   cursor and gui to the new position. Returns true if the cell
00286  *   cursor was repositioned. */
00287 gboolean    gnc_table_verify_cursor_position (Table *table,
00288         VirtualLocation virt_loc);
00289 
00290 /* The gnc_table_get_vcell_data() method returns the virtual cell data
00291  *   associated with a cursor located at the given virtual coords, or
00292  *   NULL if the coords are out of bounds. */
00293 gpointer    gnc_table_get_vcell_data (Table *table,
00294                                       VirtualCellLocation vcell_loc);
00295 
00296 /* Find a close valid cell. If exact_cell is true, cells that must
00297  *   be explicitly selected by the user (as opposed to just tabbing
00298  *   into), are considered valid cells. */
00299 gboolean    gnc_table_find_close_valid_cell (Table *table,
00300         VirtualLocation *virt_loc,
00301         gboolean exact_cell);
00302 
00305 /* Initialize the GUI from a table */
00306 void        gnc_table_init_gui (GtkWidget *widget, gpointer data);
00307 
00308 void        gnc_table_realize_gui (Table *table);
00309 
00310 /* Refresh the current cursor gui */
00311 void        gnc_table_refresh_current_cursor_gui (Table * table,
00312         gboolean do_scroll);
00313 
00314 /* Refresh the whole GUI from the table. */
00315 void        gnc_table_refresh_gui (Table *table, gboolean do_scroll);
00316 
00317 /* Try to show the whole range in the register. */
00318 void        gnc_table_show_range (Table *table,
00319                                   VirtualCellLocation start_loc,
00320                                   VirtualCellLocation end_loc);
00321 
00322 /* Refresh the cursor in the given location. If do_scroll is TRUE,
00323  * scroll the register so the location is in view. */
00324 void        gnc_table_refresh_cursor_gui (Table * table,
00325         VirtualCellLocation vcell_loc,
00326         gboolean do_scroll);
00327 
00328 /* ==================================================== */
00329 
00330 void         gnc_table_wrap_verify_cursor_position (Table *table,
00331         VirtualLocation virt_loc);
00332 
00333 gboolean     gnc_table_virtual_loc_valid(Table *table,
00334         VirtualLocation virt_loc,
00335         gboolean exact_pointer);
00336 
00337 gboolean     gnc_table_move_tab (Table *table,
00338                                  VirtualLocation *virt_loc,
00339                                  gboolean move_right);
00340 
00354 gboolean     gnc_table_move_vertical_position (Table *table,
00355         VirtualLocation *virt_loc,
00356         int phys_row_offset);
00357 
00358 gboolean     gnc_table_enter_update(Table *table,
00359                                     VirtualLocation virt_loc,
00360                                     int *cursor_position,
00361                                     int *start_selection,
00362                                     int *end_selection);
00363 
00364 void         gnc_table_leave_update(Table *table, VirtualLocation virt_loc);
00365 
00366 gboolean     gnc_table_confirm_change(Table *table, VirtualLocation virt_loc);
00367 
00368 const char * gnc_table_modify_update(Table *table,
00369                                      VirtualLocation virt_loc,
00370                                      const char *change,
00371                                      int change_len,
00372                                      const char *newval,
00373                                      int newval_len,
00374                                      int *cursor_position,
00375                                      int *start_selection,
00376                                      int *end_selection,
00377                                      gboolean *cancelled);
00378 
00379 gboolean     gnc_table_direct_update(Table *table,
00380                                      VirtualLocation virt_loc,
00381                                      char **newval_ptr,
00382                                      int *cursor_position,
00383                                      int *start_selection,
00384                                      int *end_selection,
00385                                      gpointer gui_data);
00386 
00387 gboolean     gnc_table_traverse_update(Table *table,
00388                                        VirtualLocation virt_loc,
00389                                        gncTableTraversalDir dir,
00390                                        VirtualLocation *dest_loc);
00391 
00392 #endif /* TABLE_ALLGUI_H */
00393 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines