32#include <gdk/gdkkeysyms.h>
34#include "gnc-locale-utils.h"
35#include "gnc-exp-parser.h"
38#include "pricecell-gnome.h"
44# include <gdk/gdkwin32.h>
48gnc_price_cell_direct_update (BasicCell *bcell,
55 GdkEventKey *
event = gui_data;
59 if (event->type != GDK_KEY_PRESS)
62 lc = gnc_localeconv ();
66 switch (event->keyval)
71 GnucashSheet *sheet = (GnucashSheet *) bcell->gui_private;
72 const char *value = gnc_table_get_model_entry (sheet->table, bcell->cell_name);
74 gnc_basic_cell_set_value_internal (bcell, value);
75 bcell->changed = FALSE;
85 (GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK)))
89 case GDK_KEY_KP_Enter:
94 gboolean changed = FALSE;
99 parse_ok = gnc_exp_parser_parse (cell->cell.value,
100 &amount, &error_loc);
104 else if (!cell->cell.value || cell->cell.value[0] ==
'\0')
106 gnc_numeric_zero ());
108 *cursor_position = error_loc - cell->cell.value;
127 case GDK_KEY_KP_Decimal:
135 gnc_basic_cell_insert_decimal(bcell,
137 ? lc->mon_decimal_point[0]
138 : lc->decimal_point[0],
149gnc_price_cell_gnome_new (
void)
155 cell->direct_update = gnc_price_cell_direct_update;
161gnc_basic_cell_insert_decimal(BasicCell *bcell,
163 int *cursor_position,
164 int *start_selection,
173 newval_gs = g_string_new(
"");
175 start = MIN(*start_selection, *end_selection);
176 end = MAX(*start_selection, *end_selection);
179 buf = g_malloc0(strlen(bcell->value) + 1);
180 g_utf8_strncpy(buf, bcell->value, start);
181 g_string_append(newval_gs, buf);
184 g_string_append_unichar(newval_gs, decimal_point);
186 buf = g_utf8_offset_to_pointer(bcell->value, end);
187 g_string_append(newval_gs, buf);
190 *cursor_position = start + 1;
192 gnc_basic_cell_set_value_internal (bcell, newval_gs->str);
194 g_string_free (newval_gs, TRUE);
utility functions for the GnuCash UI
Private declarations for GnucashSheet class.
Public declarations of GnucashRegister class.
gboolean gnc_price_cell_set_value(PriceCell *cell, gnc_numeric amount)
updates amount, returns TRUE if string representation actually changed
BasicCell * gnc_price_cell_new(void)
installs a callback to handle price recording
The PriceCell object implements a cell handler that stores a single double-precision value,...
gboolean need_to_parse
amount printing context
GNCPrintAmountInfo print_info
controls printing of zero values
Declarations for the Table object.