GnuCash  5.6-150-g038405b370+
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 #ifdef __cplusplus
161 extern "C" {
162 #endif
163 
164 #include <gdk/gdk.h>
165 #include <glib.h>
166 #include <gtk/gtk.h>
167 
168 #include "gnc-ui-util.h"
169 
170 typedef struct basic_cell BasicCell;
171 
172 typedef BasicCell * (*CellCreateFunc) (void);
173 
174 typedef void (*CellSetValueFunc) (BasicCell *cell,
175  const char * new_value);
176 
177 typedef gboolean (*CellEnterFunc) (BasicCell *cell,
178  int *cursor_position,
179  int *start_selection,
180  int *end_selection);
181 
182 typedef void (*CellModifyVerifyFunc) (BasicCell *cell,
183  const char *add_str,
184  int add_str_len,
185  const char *new_value,
186  int new_value_len,
187  int *cursor_position,
188  int *start_selection,
189  int *end_selection);
190 
191 typedef gboolean (*CellDirectUpdateFunc) (BasicCell *cell,
192  int *cursor_position,
193  int *start_selection,
194  int *end_selection,
195  gpointer gui_data);
196 
197 typedef void (*CellLeaveFunc) (BasicCell *cell);
198 
199 typedef void (*CellRealizeFunc) (BasicCell *cell, gpointer gui_handle);
200 
201 typedef void (*CellMoveFunc) (BasicCell *cell);
202 
203 typedef void (*CellDestroyFunc) (BasicCell *cell);
204 
205 typedef enum
206 {
207  CELL_ALIGN_RIGHT,
208  CELL_ALIGN_CENTER,
209  CELL_ALIGN_LEFT
210 } CellAlignment;
211 
213 {
214  char * cell_name;
215  gchar *cell_type_name;
216  char * value;
217  guint value_chars;
219  gboolean changed;
222  /* "virtual", overloaded methods */
223  CellSetValueFunc set_value;
224  CellDestroyFunc destroy;
225 
226  /* cell-editing callbacks */
227  CellEnterFunc enter_cell;
228  CellModifyVerifyFunc modify_verify;
229  CellDirectUpdateFunc direct_update;
230  CellLeaveFunc leave_cell;
231 
232  /* private, GUI-specific callbacks */
233  CellRealizeFunc gui_realize;
234  CellMoveFunc gui_move;
235  CellDestroyFunc gui_destroy;
236 
237  /* GUI information */
238  char *sample_text;
239  CellAlignment alignment;
240  gboolean expandable;
241  gboolean span;
242  gboolean is_popup;
244  gpointer gui_private;
245 };
246 
247 
248 gboolean gnc_cell_name_equal (const char * cell_name_1,
249  const char * cell_name_2);
250 
251 BasicCell * gnc_basic_cell_new (void);
252 void gnc_basic_cell_init (BasicCell *bcell);
253 void gnc_basic_cell_destroy (BasicCell *bcell);
254 
255 void gnc_basic_cell_set_name (BasicCell *cell, const char *name);
256 gboolean gnc_basic_cell_has_name (BasicCell *cell, const char *name);
257 void gnc_basic_cell_set_type_name (BasicCell *cell, const gchar *type_name);
258 gboolean gnc_basic_cell_has_type_name (BasicCell *cell, const gchar *type_name);
259 
260 
261 
262 void gnc_basic_cell_set_sample_text (BasicCell *cell,
263  const char *sample_text);
264 void gnc_basic_cell_set_alignment (BasicCell *cell,
265  CellAlignment alignment);
266 void gnc_basic_cell_set_expandable (BasicCell *cell,
267  gboolean expandable);
268 void gnc_basic_cell_set_span (BasicCell *cell,
269  gboolean span);
270 
271 const char * gnc_basic_cell_get_value (BasicCell *cell);
272 void gnc_basic_cell_set_value (BasicCell *bcell, const char *value);
273 
274 gboolean gnc_basic_cell_get_changed (BasicCell *cell);
275 gboolean gnc_basic_cell_get_conditionally_changed (BasicCell *cell);
276 
277 void gnc_basic_cell_set_changed (BasicCell *cell, gboolean changed);
278 void gnc_basic_cell_set_conditionally_changed (BasicCell *cell,
279  gboolean changed);
280 
281 /* for sub-class use only */
282 void gnc_basic_cell_set_value_internal (BasicCell *bcell,
283  const char *value);
284 
285 char * gnc_basic_cell_validate (BasicCell *bcell,
286  GNCPrintAmountInfo print_info,
287  const char *change,
288  const char *newval,
289  const char *toks,
290  gint *cursor_position);
291 
292 #ifdef __cplusplus
293 }
294 #endif
295 
297 #endif /* BASIC_CELL_H */
utility functions for the GnuCash UI
CellAlignment alignment
sample text for sizing purposes
Definition: basiccell.h:239
gboolean span
can fill with extra space
Definition: basiccell.h:241
guint value_chars
current value
Definition: basiccell.h:217
gboolean conditionally_changed
true if value modified
Definition: basiccell.h:220
CellSetValueFunc set_value
true if value modified conditionally
Definition: basiccell.h:223
gpointer gui_private
is a popup widget
Definition: basiccell.h:244
gboolean is_popup
can span multiple columns
Definition: basiccell.h:242
gboolean changed
number of characters in value
Definition: basiccell.h:219
gboolean expandable
horizontal alignment in column
Definition: basiccell.h:240
The BasicCell class provides an abstract base class defining the handling of the editing of a cell of...
Definition: basiccell.h:212