Commit 03e48980 authored by Arturo Espinosa's avatar Arturo Espinosa

Typing text into cells feels almost like Excel (modulo the fact that my



Typing text into cells feels almost like Excel (modulo the fact that
my input line is not as cute).  No Cell manager yet, so everthing yuo
type is gratiously dropped.  Very baboon like.

Also, some notes from one hour figuring Excel.
parent 6590a4f1
......@@ -18,6 +18,7 @@
* src/item-bar.c (item_bar_event): Do world->canvas cordinate
conversion to get zoomed resizng working).
(bar_draw_cell): Minor look fix.
* src/sheet.c (sheet_row_set_height): Silly mistake, add the newly
created rowinfo to the row array, not the column array.
......
......@@ -18,6 +18,7 @@
* src/item-bar.c (item_bar_event): Do world->canvas cordinate
conversion to get zoomed resizng working).
(bar_draw_cell): Minor look fix.
* src/sheet.c (sheet_row_set_height): Silly mistake, add the newly
created rowinfo to the row array, not the column array.
......
......@@ -18,6 +18,7 @@
* src/item-bar.c (item_bar_event): Do world->canvas cordinate
conversion to get zoomed resizng working).
(bar_draw_cell): Minor look fix.
* src/sheet.c (sheet_row_set_height): Silly mistake, add the newly
created rowinfo to the row array, not the column array.
......
......@@ -18,6 +18,7 @@
* src/item-bar.c (item_bar_event): Do world->canvas cordinate
conversion to get zoomed resizng working).
(bar_draw_cell): Minor look fix.
* src/sheet.c (sheet_row_set_height): Silly mistake, add the newly
created rowinfo to the row array, not the column array.
......
Control-Enter after finishing entering some data into a cell
sets the whole range of selected cells to that value.
On a selection: Enter, COntrol Enter, Tab, Shift-Tab navigate trought
the selected cells.
Double clicking on a column division automatically adjusts the column
size.
Sheet drawing:
1. Selected background + white margin
2. Grids
3. CEll content
If more than one sheet is selected changes take place on all sheets.
Dates are stored as numbers with the format for the date.
Today's date is inserted with Control-;
Current tiem is inserted as Control-Shift+;
The expression: ="5/12/94"-"3/5/98" yields 68
Date 1 is Jannuary 1, 1900
Texts can be used in a formula:
="Total for "& 1985 displays "Totals for 1985"
Hard carriage returns are entered with alt-enter
Automatic completion of names is done per column (looked backwards)
Alt-down arrow pops up a list of available choices for the autofill
Insert blank cells
Inser columns
Insert rows
Copy cells
copy characters withing a cell
* FORMULAS:
Operators, cell references, values, worsheet functions,
and names.
Arrays: SUM({1,2,3}*4) gets converted to:
SUM({1,2,3}*{4,4,4})
** Operators
*** Arithmetic
+, -, /, *,
% (percent, as in 20%)
^ Exponentiation
*** Comparision
=, <, >, <=, >= <>
*** Text operator
& Concatenates values and returns a string value
*** Reference operator
Range (colon) Produces one reference to all the cells between
and includig the two references.
Union (comma) Produces one reference that includes the two
references
Intersection (space) Produces on reference to cells common
to the two references
** Wierd things
="1"+"2" yields 3, Excel does the converion to itegers
="A"&TRUE, Excel convers TRUE to a string: ATRUE
** Display
Control-` Switches between computed formula display and
actual formua display
** References
$ is the absolute cell reference
R[-2]C Two rows above, same column
R[2]C[2] two column down, two right
R2C2 Absolute reference to B2
R[-1] Entire row above the active cell
R current row
=Sheet4!D12+4
='Miguel is a moron'!A1+2
** Functions
They can take any number of arguments
X(number)
They are documented
The arguments are documented
A wizard can be popped up to help with it
*** Types
Database and list management functions
Date and time functions
DDE and external functions
Engineering functions
Financial functions
Information functons
Logical functions
Lookup and reference functions
Math and trigonometric functions
Statistical functions
Text functions
** Errors
#####
Result too big to fit in scell
#DIV/0
Division by zero
#N/A
#NAME?
#NULL!
#NUM!
#REF!
#VALUE!
\ No newline at end of file
Control-Enter after finishing entering some data into a cell
sets the whole range of selected cells to that value.
On a selection: Enter, COntrol Enter, Tab, Shift-Tab navigate trought
the selected cells.
Double clicking on a column division automatically adjusts the column
size.
Sheet drawing:
1. Selected background + white margin
2. Grids
3. CEll content
If more than one sheet is selected changes take place on all sheets.
Dates are stored as numbers with the format for the date.
Today's date is inserted with Control-;
Current tiem is inserted as Control-Shift+;
The expression: ="5/12/94"-"3/5/98" yields 68
Date 1 is Jannuary 1, 1900
Texts can be used in a formula:
="Total for "& 1985 displays "Totals for 1985"
Hard carriage returns are entered with alt-enter
Automatic completion of names is done per column (looked backwards)
Alt-down arrow pops up a list of available choices for the autofill
Insert blank cells
Inser columns
Insert rows
Copy cells
copy characters withing a cell
* FORMULAS:
Operators, cell references, values, worsheet functions,
and names.
Arrays: SUM({1,2,3}*4) gets converted to:
SUM({1,2,3}*{4,4,4})
** Operators
*** Arithmetic
+, -, /, *,
% (percent, as in 20%)
^ Exponentiation
*** Comparision
=, <, >, <=, >= <>
*** Text operator
& Concatenates values and returns a string value
*** Reference operator
Range (colon) Produces one reference to all the cells between
and includig the two references.
Union (comma) Produces one reference that includes the two
references
Intersection (space) Produces on reference to cells common
to the two references
** Wierd things
="1"+"2" yields 3, Excel does the converion to itegers
="A"&TRUE, Excel convers TRUE to a string: ATRUE
** Display
Control-` Switches between computed formula display and
actual formua display
** References
$ is the absolute cell reference
R[-2]C Two rows above, same column
R[2]C[2] two column down, two right
R2C2 Absolute reference to B2
R[-1] Entire row above the active cell
R current row
=Sheet4!D12+4
='Miguel is a moron'!A1+2
** Functions
They can take any number of arguments
X(number)
They are documented
The arguments are documented
A wizard can be popped up to help with it
*** Types
Database and list management functions
Date and time functions
DDE and external functions
Engineering functions
Financial functions
Information functons
Logical functions
Lookup and reference functions
Math and trigonometric functions
Statistical functions
Text functions
** Errors
#####
Result too big to fit in scell
#DIV/0
Division by zero
#N/A
#NAME?
#NULL!
#NUM!
#REF!
#VALUE!
\ No newline at end of file
......@@ -56,13 +56,33 @@ gnumeric_sheet_create (Sheet *sheet, GtkWidget *entry)
return gsheet;
}
static void
gnumeric_sheet_accept_pending_output (GnumericSheet *sheet)
{
/* Destroy the object */
if (sheet->item_editor){
gtk_object_destroy (GTK_OBJECT (sheet->item_editor));
sheet->item_editor = NULL;
}
}
static void
gnumeric_sheet_load_new_cell (GnumericSheet *gsheet)
{
Sheet *sheet = gsheet->sheet;
Workbook *wb = sheet->parent_workbook;
GtkWidget *entry = wb->ea_input;
gtk_entry_set_text (GTK_ENTRY(entry), "");
}
static void
gnumeric_sheet_move_cursor_horizontal (GnumericSheet *sheet, int count)
{
ItemCursor *item_cursor = sheet->item_cursor;
int new_left;
new_left = item_cursor->start_col + count;
new_left = sheet->cursor_col + count;
if (new_left < 0)
return;
......@@ -74,10 +94,13 @@ gnumeric_sheet_move_cursor_horizontal (GnumericSheet *sheet, int count)
if (new_left < 0)
new_left = 0;
gnumeric_sheet_accept_pending_output (sheet);
sheet->cursor_col = new_left;
item_cursor_set_bounds (item_cursor,
new_left, item_cursor->end_col + count,
item_cursor->start_row, item_cursor->end_row);
gnumeric_sheet_load_new_cell (sheet);
}
static void
......@@ -85,8 +108,8 @@ gnumeric_sheet_move_cursor_vertical (GnumericSheet *sheet, int count)
{
ItemCursor *item_cursor = sheet->item_cursor;
int new_top;
new_top = item_cursor->start_row + count;
new_top = sheet->cursor_row + count;
if (new_top < 0)
return;
......@@ -95,10 +118,13 @@ gnumeric_sheet_move_cursor_vertical (GnumericSheet *sheet, int count)
g_warning ("do scroll\n");
return;
}
gnumeric_sheet_accept_pending_output (sheet);
sheet->cursor_row = new_top;
item_cursor_set_bounds (item_cursor,
item_cursor->start_col, item_cursor->end_col,
new_top, item_cursor->end_row + count);
gnumeric_sheet_load_new_cell (sheet);
}
static void
......@@ -112,8 +138,8 @@ start_editing_at_cursor (GnumericSheet *sheet, GtkWidget *entry)
item_edit_get_type (),
"ItemEdit::Sheet", sheet->sheet,
"ItemEdit::Grid", sheet->item_grid,
"ItemEdit::Col", 2,
"ItemEdit::Row", 2,
"ItemEdit::Col", sheet->cursor_col,
"ItemEdit::Row", sheet->cursor_row,
"ItemEdit::GtkEntry", entry,
NULL);
......
......@@ -20,6 +20,7 @@ typedef struct {
ColType top_col;
RowType top_row;
int cursor_col, cursor_row;
ItemGrid *item_grid;
ItemCursor *item_cursor;
ItemBar *item_bar_col;
......
......@@ -56,13 +56,33 @@ gnumeric_sheet_create (Sheet *sheet, GtkWidget *entry)
return gsheet;
}
static void
gnumeric_sheet_accept_pending_output (GnumericSheet *sheet)
{
/* Destroy the object */
if (sheet->item_editor){
gtk_object_destroy (GTK_OBJECT (sheet->item_editor));
sheet->item_editor = NULL;
}
}
static void
gnumeric_sheet_load_new_cell (GnumericSheet *gsheet)
{
Sheet *sheet = gsheet->sheet;
Workbook *wb = sheet->parent_workbook;
GtkWidget *entry = wb->ea_input;
gtk_entry_set_text (GTK_ENTRY(entry), "");
}
static void
gnumeric_sheet_move_cursor_horizontal (GnumericSheet *sheet, int count)
{
ItemCursor *item_cursor = sheet->item_cursor;
int new_left;
new_left = item_cursor->start_col + count;
new_left = sheet->cursor_col + count;
if (new_left < 0)
return;
......@@ -74,10 +94,13 @@ gnumeric_sheet_move_cursor_horizontal (GnumericSheet *sheet, int count)
if (new_left < 0)
new_left = 0;
gnumeric_sheet_accept_pending_output (sheet);
sheet->cursor_col = new_left;
item_cursor_set_bounds (item_cursor,
new_left, item_cursor->end_col + count,
item_cursor->start_row, item_cursor->end_row);
gnumeric_sheet_load_new_cell (sheet);
}
static void
......@@ -85,8 +108,8 @@ gnumeric_sheet_move_cursor_vertical (GnumericSheet *sheet, int count)
{
ItemCursor *item_cursor = sheet->item_cursor;
int new_top;
new_top = item_cursor->start_row + count;
new_top = sheet->cursor_row + count;
if (new_top < 0)
return;
......@@ -95,10 +118,13 @@ gnumeric_sheet_move_cursor_vertical (GnumericSheet *sheet, int count)
g_warning ("do scroll\n");
return;
}
gnumeric_sheet_accept_pending_output (sheet);
sheet->cursor_row = new_top;
item_cursor_set_bounds (item_cursor,
item_cursor->start_col, item_cursor->end_col,
new_top, item_cursor->end_row + count);
gnumeric_sheet_load_new_cell (sheet);
}
static void
......@@ -112,8 +138,8 @@ start_editing_at_cursor (GnumericSheet *sheet, GtkWidget *entry)
item_edit_get_type (),
"ItemEdit::Sheet", sheet->sheet,
"ItemEdit::Grid", sheet->item_grid,
"ItemEdit::Col", 2,
"ItemEdit::Row", 2,
"ItemEdit::Col", sheet->cursor_col,
"ItemEdit::Row", sheet->cursor_row,
"ItemEdit::GtkEntry", entry,
NULL);
......
......@@ -20,6 +20,7 @@ typedef struct {
ColType top_col;
RowType top_row;
int cursor_col, cursor_row;
ItemGrid *item_grid;
ItemCursor *item_cursor;
ItemBar *item_bar_col;
......
......@@ -235,7 +235,6 @@ is_pointer_on_division (ItemBar *item_bar, int pos, int *the_total, int *the_ele
else
cri = sheet_col_get_info (item_bar->sheet, i);
printf ("%d %d->%d\n", i, cri->pixels, pos);
total += cri->pixels;
if ((total - 4 < pos) && (pos < total + 4)){
if (the_total)
......
......@@ -35,22 +35,49 @@ item_edit_get_pixel_coords (ItemEdit *item_edit, int *x, int *y, int *w, int *h)
}
static void
item_edit_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width, int height)
item_edit_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
int x, int y, int width, int height)
{
GtkWidget *canvas = GTK_WIDGET (item->canvas);
ItemEdit *item_edit = ITEM_EDIT (item);
GdkFont *font;
int xd, yd, wd, hd, dx, dy;
if (!item_edit->sheet)
return;
item_edit_get_pixel_coords (item_edit, &xd, &yd, &wd, &hd);
char *text;
int cursor_pos, text_len, first_part_len, total_len;
font = canvas->style->font;
text = gtk_entry_get_text (GTK_ENTRY (item_edit->editor));
text_len = strlen (text);
cursor_pos = GTK_EDITABLE (item_edit->editor)->current_pos;
total_len = gdk_text_width (font, text, text_len);
/* Adjust the col_span if necesary */
do {
item_edit_get_pixel_coords (item_edit, &xd, &yd, &wd, &hd);
if (total_len >= wd)
item_edit->col_span++;
} while (total_len >= wd);
dx = xd - x;
dy = yd - y;
gdk_draw_rectangle (drawable, canvas->style->white_gc,
TRUE,
/* Do the drawing */
gdk_draw_rectangle (drawable, canvas->style->white_gc, TRUE,
dx + 1, dy + 1, wd - 1, hd - 1);
first_part_len = gdk_text_width (font, text, cursor_pos);
gdk_draw_text (drawable, font, canvas->style->black_gc,
dx + 1, dy + hd - font->descent, text, cursor_pos);
gdk_draw_line (drawable, canvas->style->black_gc,
first_part_len + dx + 1,
dy + hd - font->descent,
first_part_len + dx + 1,
dy + hd - (font->ascent + font->descent));
gdk_draw_text (drawable, font, canvas->style->black_gc,
dx + 1 + first_part_len,
dy + hd - font->descent,
text + cursor_pos, text_len - cursor_pos);
}
static double
......@@ -114,6 +141,18 @@ item_edit_init (ItemEdit *item_edit)
item_edit->sheet = 0;
}
static void
entry_changed (GtkEntry *entry, void *data)
{
ItemEdit *item_edit = ITEM_EDIT (data);
GnomeCanvas *canvas = GNOME_CANVAS_ITEM (item_edit)->canvas;
int x, y, w, h;
item_edit_get_pixel_coords (item_edit, &x, &y, &w, &h);
gnome_canvas_request_redraw (canvas, x, y, x+w, y+h);
}
static void
item_edit_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
{
......@@ -132,6 +171,8 @@ item_edit_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
break;
case ARG_GTK_ENTRY:
item_edit->editor = GTK_VALUE_POINTER (*arg);
gtk_signal_connect (GTK_OBJECT (item_edit->editor), "changed",
GTK_SIGNAL_FUNC(entry_changed), item_edit);
break;
case ARG_COL:
item_edit->col = GTK_VALUE_INT (*arg);
......
......@@ -324,7 +324,6 @@ sheet_row_set_height (Sheet *sheet, int row, int height)
colrow_set_units (sheet, ri);
if (add)
sheet_row_add (sheet, ri);
printf ("ROW=%d %d\n", ri->pos, ri->pixels);
sheet_redraw_all (sheet);
}
......
#include <gnome.h>
#include <gdk/gdkkeysyms.h>
#include "gnumeric.h"
/* The locations within the main table in the workbook */
......@@ -36,6 +37,48 @@ workbook_setup_sheets (Workbook *wb)
0, 0);
}
Sheet *
workbook_focus_current_sheet (Workbook *wb)
{
GtkWidget *current_notebook;
Sheet *sheet;
current_notebook = GTK_NOTEBOOK (wb->notebook)->cur_page->child;
sheet = gtk_object_get_data (GTK_OBJECT (current_notebook), "sheet");
gtk_window_set_focus (GTK_WINDOW (wb->toplevel),
sheet->sheet_view);
return sheet;
}
static void
wb_input_finished (GtkEntry *entry, Workbook *wb)
{
printf ("FOCUS!\n");
workbook_focus_current_sheet (wb);
}
static int
wb_edit_key_pressed (GtkEntry *entry, GdkEvent *event, Workbook *wb)
{
Sheet *sheet;
if (event->type != GDK_KEY_PRESS)
return 0;
switch (event->key.keyval){
case GDK_Left:
case GDK_Right:
case GDK_Up:
case GDK_Down:
sheet = workbook_focus_current_sheet (wb);
gtk_widget_event (sheet->sheet_view, event);
return 1;
default:
return 0;
}
}
static void
workbook_setup_edit_area (Workbook *wb)
{
......@@ -68,6 +111,14 @@ workbook_setup_edit_area (Workbook *wb)