32 #include <gdk/gdkkeysyms.h> 34 #include "gnc-locale-utils.h" 35 #include "gnc-exp-parser.h" 38 #include "pricecell-gnome.h" 41 # include <gdk/gdkwin32.h> 45 gnc_price_cell_direct_update (BasicCell *bcell,
52 GdkEventKey *
event = gui_data;
56 if (event->type != GDK_KEY_PRESS)
59 lc = gnc_localeconv ();
63 switch (event->keyval)
67 (GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK)))
71 case GDK_KEY_KP_Enter:
76 gboolean changed = FALSE;
81 parse_ok = gnc_exp_parser_parse (cell->cell.value,
86 else if (!cell->cell.value || cell->cell.value[0] ==
'\0')
90 *cursor_position = error_loc - cell->cell.value;
109 case GDK_KEY_KP_Decimal:
117 gnc_basic_cell_insert_decimal(bcell,
119 ? lc->mon_decimal_point[0]
120 : lc->decimal_point[0],
131 gnc_price_cell_gnome_new (
void)
137 cell->direct_update = gnc_price_cell_direct_update;
143 gnc_basic_cell_insert_decimal(BasicCell *bcell,
145 int *cursor_position,
146 int *start_selection,
155 newval_gs = g_string_new(
"");
157 start = MIN(*start_selection, *end_selection);
158 end = MAX(*start_selection, *end_selection);
161 buf = g_malloc0(strlen(bcell->value) + 1);
162 g_utf8_strncpy(buf, bcell->value, start);
163 g_string_append(newval_gs, buf);
166 g_string_append_unichar(newval_gs, decimal_point);
168 buf = g_utf8_offset_to_pointer(bcell->value, end);
169 g_string_append(newval_gs, buf);
172 *cursor_position = start + 1;
174 gnc_basic_cell_set_value_internal (bcell, newval_gs->str);
176 g_string_free (newval_gs, TRUE);
utility functions for the GnuCash UI
The PriceCell object implements a cell handler that stores a single double-precision value...
GNCPrintAmountInfo print_info
controls printing of zero values
gboolean need_to_parse
amount printing context
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