Commit 3b45426a authored by Arturo Espinosa's avatar Arturo Espinosa

More changes GUI changes


More changes GUI changes
parent 86c717b2
1998-08-04 Miguel de Icaza <miguel@nuclecu.unam.mx>
1998-08-05 <miguel@nuclecu.unam.mx>
* src/gnumeric-sheet.c (cancel_pending_input): Cancel changes
made.
(start_editing_at_cursor): Make a copy of the original text, and
clear the actual text to fix the redraw problems.
* src/item-edit.c (item_edit_set_editor): Make the cursor be in
sync with the GtkEntry by hooking to the "event" signal and
catching key press and key release events.
* src/func.c: More functions added.
......
1998-08-04 Miguel de Icaza <miguel@nuclecu.unam.mx>
1998-08-05 <miguel@nuclecu.unam.mx>
* src/gnumeric-sheet.c (cancel_pending_input): Cancel changes
made.
(start_editing_at_cursor): Make a copy of the original text, and
clear the actual text to fix the redraw problems.
* src/item-edit.c (item_edit_set_editor): Make the cursor be in
sync with the GtkEntry by hooking to the "event" signal and
catching key press and key release events.
* src/func.c: More functions added.
......
1998-08-04 Miguel de Icaza <miguel@nuclecu.unam.mx>
1998-08-05 <miguel@nuclecu.unam.mx>
* src/gnumeric-sheet.c (cancel_pending_input): Cancel changes
made.
(start_editing_at_cursor): Make a copy of the original text, and
clear the actual text to fix the redraw problems.
* src/item-edit.c (item_edit_set_editor): Make the cursor be in
sync with the GtkEntry by hooking to the "event" signal and
catching key press and key release events.
* src/func.c: More functions added.
......
1998-08-04 Miguel de Icaza <miguel@nuclecu.unam.mx>
1998-08-05 <miguel@nuclecu.unam.mx>
* src/gnumeric-sheet.c (cancel_pending_input): Cancel changes
made.
(start_editing_at_cursor): Make a copy of the original text, and
clear the actual text to fix the redraw problems.
* src/item-edit.c (item_edit_set_editor): Make the cursor be in
sync with the GtkEntry by hooking to the "event" signal and
catching key press and key release events.
* src/func.c: More functions added.
......
......@@ -5,6 +5,8 @@ GNOME Spread Sheet task list
* Implement recalculation
* Implement functions
* Implement Ranges.
* Redo the Selection code
* Routine for returning the bounding box of a cell.
* Edit
......
......@@ -155,7 +155,7 @@ value_get_as_double (Value *v)
if (v->type == VALUE_INTEGER)
return (float_t) v->v.v_int;
return v->v.v_float;
return (float_t) v->v.v_float;
}
static Value *
......@@ -334,7 +334,7 @@ eval_expr (void *asheet, ExprTree *tree, int eval_col, int eval_row, char **erro
break;
case OP_DIV:
if (mpf_cmp_si (b->v.v_int, 0)){
if (mpf_cmp_si (b->v.v_float, 0.0)){
value_release (a);
value_release (b);
value_release (res);
......
......@@ -167,10 +167,10 @@ static Value *
gnumeric_sin (int argc, Value *argv [], char **error_string)
{
Value *v = g_new (Value, 1);
v->type = VALUE_FLOAT;
v->v.v_float = sin (value_get_as_double (argv [0]));
return v;
}
......
......@@ -83,6 +83,21 @@ gnumeric_sheet_set_current_value (GnumericSheet *sheet)
#endif
}
static void
destroy_item_editor (GnumericSheet *gsheet)
{
g_return_if_fail (gsheet->item_editor);
gtk_object_destroy (GTK_OBJECT (gsheet->item_editor));
gsheet->item_editor = NULL;
if (gsheet->editing_saved_text){
string_unref (gsheet->editing_saved_text);
gsheet->editing_saved_text = NULL;
gsheet->editing_cell = NULL;
}
}
void
gnumeric_sheet_accept_pending_output (GnumericSheet *sheet)
{
......@@ -93,9 +108,7 @@ gnumeric_sheet_accept_pending_output (GnumericSheet *sheet)
return;
gnumeric_sheet_set_current_value (sheet);
gtk_object_destroy (GTK_OBJECT (sheet->item_editor));
sheet->item_editor = NULL;
destroy_item_editor (sheet);
}
void
......@@ -149,6 +162,7 @@ start_editing_at_cursor (GnumericSheet *sheet, GtkWidget *entry)
{
GnomeCanvasItem *item;
GnomeCanvas *canvas = GNOME_CANVAS (sheet);
Cell *cell;
gtk_entry_set_text (GTK_ENTRY(entry), "");
item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(canvas->root),
......@@ -160,6 +174,14 @@ start_editing_at_cursor (GnumericSheet *sheet, GtkWidget *entry)
"ItemEdit::GtkEntry", entry,
NULL);
cell = sheet_cell_get (sheet->sheet, sheet->cursor_col, sheet->cursor_row);
if (cell){
sheet->editing_saved_text = cell->entered_text;
sheet->editing_cell = cell;
string_ref (sheet->editing_saved_text);
cell_set_text (sheet->sheet, cell, "");
}
sheet->item_editor = ITEM_EDIT (item);
}
......@@ -312,6 +334,15 @@ stop_cell_selection (GnumericSheet *gsheet)
gsheet->selection = NULL;
}
static void
cancel_pending_input (GnumericSheet *gsheet)
{
stop_cell_selection (gsheet);
if (gsheet->item_editor)
destroy_item_editor (gsheet);
}
static void
selection_remove_selection_string (GnumericSheet *gsheet)
{
......@@ -526,6 +557,10 @@ gnumeric_sheet_key (GtkWidget *widget, GdkEventKey *event)
g_warning ("FIXME: Should move to next cell in selection\n");
move_cursor (sheet, sheet->cursor_col, sheet->cursor_row, 0);
break;
case GDK_Escape:
cancel_pending_input (sheet);
break;
case GDK_F2:
gtk_window_set_focus (GTK_WINDOW (wb->toplevel), wb->ea_input);
......
......@@ -24,7 +24,13 @@ typedef struct {
ItemGrid *item_grid;
ItemCursor *item_cursor;
ItemBar *item_bar_col;
/* When editing: The editor, the cell being edited
* (may be NULL) and the original text on the cell.
*/
ItemEdit *item_editor;
String *editing_saved_text;
Cell *editing_cell;
/* This flag keeps track of a cell selector
* (ie, when the user uses the cursor keys
......
......@@ -83,6 +83,21 @@ gnumeric_sheet_set_current_value (GnumericSheet *sheet)
#endif
}
static void
destroy_item_editor (GnumericSheet *gsheet)
{
g_return_if_fail (gsheet->item_editor);
gtk_object_destroy (GTK_OBJECT (gsheet->item_editor));
gsheet->item_editor = NULL;
if (gsheet->editing_saved_text){
string_unref (gsheet->editing_saved_text);
gsheet->editing_saved_text = NULL;
gsheet->editing_cell = NULL;
}
}
void
gnumeric_sheet_accept_pending_output (GnumericSheet *sheet)
{
......@@ -93,9 +108,7 @@ gnumeric_sheet_accept_pending_output (GnumericSheet *sheet)
return;
gnumeric_sheet_set_current_value (sheet);
gtk_object_destroy (GTK_OBJECT (sheet->item_editor));
sheet->item_editor = NULL;
destroy_item_editor (sheet);
}
void
......@@ -149,6 +162,7 @@ start_editing_at_cursor (GnumericSheet *sheet, GtkWidget *entry)
{
GnomeCanvasItem *item;
GnomeCanvas *canvas = GNOME_CANVAS (sheet);
Cell *cell;
gtk_entry_set_text (GTK_ENTRY(entry), "");
item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(canvas->root),
......@@ -160,6 +174,14 @@ start_editing_at_cursor (GnumericSheet *sheet, GtkWidget *entry)
"ItemEdit::GtkEntry", entry,
NULL);
cell = sheet_cell_get (sheet->sheet, sheet->cursor_col, sheet->cursor_row);
if (cell){
sheet->editing_saved_text = cell->entered_text;
sheet->editing_cell = cell;
string_ref (sheet->editing_saved_text);
cell_set_text (sheet->sheet, cell, "");
}
sheet->item_editor = ITEM_EDIT (item);
}
......@@ -312,6 +334,15 @@ stop_cell_selection (GnumericSheet *gsheet)
gsheet->selection = NULL;
}
static void
cancel_pending_input (GnumericSheet *gsheet)
{
stop_cell_selection (gsheet);
if (gsheet->item_editor)
destroy_item_editor (gsheet);
}
static void
selection_remove_selection_string (GnumericSheet *gsheet)
{
......@@ -526,6 +557,10 @@ gnumeric_sheet_key (GtkWidget *widget, GdkEventKey *event)
g_warning ("FIXME: Should move to next cell in selection\n");
move_cursor (sheet, sheet->cursor_col, sheet->cursor_row, 0);
break;
case GDK_Escape:
cancel_pending_input (sheet);
break;
case GDK_F2:
gtk_window_set_focus (GTK_WINDOW (wb->toplevel), wb->ea_input);
......
......@@ -24,7 +24,13 @@ typedef struct {
ItemGrid *item_grid;
ItemCursor *item_cursor;
ItemBar *item_bar_col;
/* When editing: The editor, the cell being edited
* (may be NULL) and the original text on the cell.
*/
ItemEdit *item_editor;
String *editing_saved_text;
Cell *editing_cell;
/* This flag keeps track of a cell selector
* (ie, when the user uses the cursor keys
......
......@@ -148,9 +148,8 @@ item_edit_init (ItemEdit *item_edit)
}
static void
entry_changed (GtkEntry *entry, void *data)
queue_sync (ItemEdit *item_edit)
{
ItemEdit *item_edit = ITEM_EDIT (data);
GnomeCanvas *canvas = GNOME_CANVAS_ITEM (item_edit)->canvas;
int x, y, w, h;
......@@ -159,6 +158,12 @@ entry_changed (GtkEntry *entry, void *data)
gnome_canvas_request_redraw (canvas, x, y, x+w, y+h);
}
static void
entry_changed (GtkEntry *entry, void *data)
{
queue_sync (ITEM_EDIT (data));
}
static void
item_edit_destroy (GtkObject *o)
{
......@@ -175,6 +180,32 @@ item_edit_destroy (GtkObject *o)
(*GTK_OBJECT_CLASS (item_edit_parent_class)->destroy)(o);
}
static int
entry_event (GtkEntry *entry, GdkEvent *event, ItemEdit *item_edit)
{
switch (event->type){
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
case GDK_BUTTON_PRESS:
queue_sync (item_edit);
default:
}
return FALSE;
}
static void
item_edit_set_editor (ItemEdit *item_edit, void *data)
{
item_edit->editor = GTK_ENTRY (data);
item_edit->signal = gtk_signal_connect (
GTK_OBJECT (item_edit->editor), "changed",
GTK_SIGNAL_FUNC(entry_changed), item_edit);
gtk_signal_connect_after (
GTK_OBJECT (item_edit->editor), "event",
GTK_SIGNAL_FUNC(entry_event), item_edit);
}
static void
item_edit_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
{
......@@ -186,16 +217,13 @@ item_edit_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
switch (arg_id){
case ARG_SHEET:
item_edit->sheet = GTK_VALUE_POINTER (*arg);
item_edit->sheet = (Sheet *) GTK_VALUE_POINTER (*arg);
break;
case ARG_ITEM_GRID:
item_edit->item_grid = GTK_VALUE_POINTER (*arg);
break;
case ARG_GTK_ENTRY:
item_edit->editor = GTK_VALUE_POINTER (*arg);
item_edit->signal = gtk_signal_connect (
GTK_OBJECT (item_edit->editor), "changed",
GTK_SIGNAL_FUNC(entry_changed), item_edit);
item_edit_set_editor (item_edit, GTK_VALUE_POINTER (*arg));
break;
case ARG_COL:
item_edit->col = GTK_VALUE_INT (*arg);
......
......@@ -182,6 +182,7 @@ item_grid_draw_cell (GdkDrawable *drawable, ItemGrid *item_grid,
style = cell->style;
font = style->font->font;
#if 0
/* Code to test the different alignements, hardcoded for now */
switch (col){
case 0:
......@@ -200,6 +201,8 @@ item_grid_draw_cell (GdkDrawable *drawable, ItemGrid *item_grid,
style->halign = HALIGN_FILL;
break;
}
#endif
switch (style->halign){
case HALIGN_GENERAL:
if (col < SHEET_MAX_COLS-1)
......
......@@ -29,7 +29,7 @@ sheet_init_default_styles (Sheet *sheet)
/* The default column style */
sheet->default_col_style.pos = -1;
sheet->default_col_style.style = style_new ();
sheet->default_col_style.units = 40;
sheet->default_col_style.units = 80;
sheet->default_col_style.pixels = 0;
sheet->default_col_style.margin_a = 1;
sheet->default_col_style.margin_b = 1;
......@@ -220,7 +220,8 @@ sheet_new (Workbook *wb, char *name)
sheet_init_default_styles (sheet);
/* Dummy initialization */
sheet_init_dummy_stuff (sheet);
if (0)
sheet_init_dummy_stuff (sheet);
/* Column canvas */
sheet->col_canvas = new_canvas_bar (sheet, GTK_ORIENTATION_HORIZONTAL, &sheet->col_item);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment