GnuCash  4.13-74-g66d9f1383e+
basiccell.h
Go to the documentation of this file.
1 /********************************************************************\
2  * basiccell.h -- base class for editable cell in a table *
3  * *
4  * This program is free software; you can redistribute it and/or *
5  * modify it under the terms of the GNU General Public License as *
6  * published by the Free Software Foundation; either version 2 of *
7  * the License, or (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License*
15  * along with this program; if not, contact: *
16  * *
17  * Free Software Foundation Voice: +1-617-542-5942 *
18  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
19  * Boston, MA 02110-1301, USA gnu@gnu.org *
20  * *
21 \********************************************************************/
22 
152 /* HISTORY:
153  * Copyright (c) 1998 Linas Vepstas
154  * Copyright (c) 2000 Dave Peticolas <dave@krondo.com>
155  */
156 
157 #ifndef BASIC_CELL_H
158 #define BASIC_CELL_H
159 
160 #include <gdk/gdk.h>
161 #include <glib.h>
162 #include <gtk/gtk.h>
163 
164 #include "gnc-ui-util.h"
165 
166 typedef struct basic_cell BasicCell;
167 
168 typedef BasicCell * (*CellCreateFunc) (void);
169 
170 typedef void (*CellSetValueFunc) (BasicCell *cell,
171  const char * new_value);
172 
173 typedef gboolean (*CellEnterFunc) (BasicCell *cell,
174  int *cursor_position,
175  int *start_selection,
176  int *end_selection);
177 
178 typedef void (*CellModifyVerifyFunc) (BasicCell *cell,
179  const char *add_str,
180  int add_str_len,
181  const char *new_value,
182  int new_value_len,
183  int *cursor_position,
184  int *start_selection,
185  int *end_selection);
186 
187 typedef gboolean (*CellDirectUpdateFunc) (BasicCell *cell,
188  int *cursor_position,
189  int *start_selection,
190  int *end_selection,
191  gpointer gui_data);
192 
193 typedef void (*CellLeaveFunc) (BasicCell *cell);
194 
195 typedef void (*CellRealizeFunc) (BasicCell *cell, gpointer gui_handle);
196 
197 typedef void (*CellMoveFunc) (BasicCell *cell);
198 
199 typedef void (*CellDestroyFunc) (BasicCell *cell);
200 
201 typedef enum
202 {
203  CELL_ALIGN_RIGHT,
204  CELL_ALIGN_CENTER,
205  CELL_ALIGN_LEFT
206 } CellAlignment;
207 
209 {
210  char * cell_name;
211  gchar *cell_type_name;
212  char * value;
213  guint value_chars;
215  gboolean changed;
218  /* "virtual", overloaded methods */
219  CellSetValueFunc set_value;
220  CellDestroyFunc destroy;
221 
222  /* cell-editing callbacks */
223  CellEnterFunc enter_cell;
224  CellModifyVerifyFunc modify_verify;
225  CellDirectUpdateFunc direct_update;
226  CellLeaveFunc leave_cell;
227 
228  /* private, GUI-specific callbacks */
229  CellRealizeFunc gui_realize;
230  CellMoveFunc gui_move;
231  CellDestroyFunc gui_destroy;
232 
233  /* GUI information */
234  char *sample_text;
235  CellAlignment alignment;
236  gboolean expandable;
237  gboolean span;
238  gboolean is_popup;
240  gpointer gui_private;
241 };
242 
243 
244 gboolean gnc_cell_name_equal (const char * cell_name_1,
245  const char * cell_name_2);
246 
247 BasicCell * gnc_basic_cell_new (void);
248 void gnc_basic_cell_init (BasicCell *bcell);
249 void gnc_basic_cell_destroy (BasicCell *bcell);
250 
251 void gnc_basic_cell_set_name (BasicCell *cell, const char *name);
252 gboolean gnc_basic_cell_has_name (BasicCell *cell, const char *name);
253 void gnc_basic_cell_set_type_name (BasicCell *cell, const gchar *type_name);
254 gboolean gnc_basic_cell_has_type_name (BasicCell *cell, const gchar *type_name);
255 
256 
257 
258 void gnc_basic_cell_set_sample_text (BasicCell *cell,
259  const char *sample_text);
260 void gnc_basic_cell_set_alignment (BasicCell *cell,
261  CellAlignment alignment);
262 void gnc_basic_cell_set_expandable (BasicCell *cell,
263  gboolean expandable);
264 void gnc_basic_cell_set_span (BasicCell *cell,
265  gboolean span);
266 
267 const char * gnc_basic_cell_get_value (BasicCell *cell);
268 void gnc_basic_cell_set_value (BasicCell *bcell, const char *value);
269 
270 gboolean gnc_basic_cell_get_changed (BasicCell *cell);
271 gboolean gnc_basic_cell_get_conditionally_changed (BasicCell *cell);
272 
273 void gnc_basic_cell_set_changed (BasicCell *cell, gboolean changed);
274 void gnc_basic_cell_set_conditionally_changed (BasicCell *cell,
275  gboolean changed);
276 
277 /* for sub-class use only */
278 void gnc_basic_cell_set_value_internal (BasicCell *bcell,
279  const char *value);
280 
281 char * gnc_basic_cell_validate (BasicCell *bcell,
282  GNCPrintAmountInfo print_info,
283  const char *change,
284  const char *newval,
285  const char *toks,
286  gint *cursor_position);
287 
289 #endif /* BASIC_CELL_H */
utility functions for the GnuCash UI
CellAlignment alignment
sample text for sizing purposes
Definition: basiccell.h:235
gboolean span
can fill with extra space
Definition: basiccell.h:237
guint value_chars
current value
Definition: basiccell.h:213
gboolean conditionally_changed
true if value modified
Definition: basiccell.h:216
CellSetValueFunc set_value
true if value modified conditionally
Definition: basiccell.h:219
gpointer gui_private
is a popup widget
Definition: basiccell.h:240
gboolean is_popup
can span multiple columns
Definition: basiccell.h:238
gboolean changed
number of characters in value
Definition: basiccell.h:215
gboolean expandable
horizontal alignment in column
Definition: basiccell.h:236
The BasicCell class provides an abstract base class defining the handling of the editing of a cell of...
Definition: basiccell.h:208