Commit b1e92caa authored by Arturo Espinosa's avatar Arturo Espinosa

Implemented the new strategy for computing the region that should be



Implemented the new strategy for computing the region that should
be redrawn for a given cell.
parent a27bee33
1998-08-31 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/item-bar.c (item_bar_event): grab the focus when selecting
as well.
* src/sheet-view.c (sheet_view_redraw_cell_region): Implemented
correctly: we now use cell_get_span on every cell in the range to
actually compute which areas need to be updated.
* src/cell.c (cell_get_span): New routine. Computes the number of
columns spanned by a cell.
=======
Sun Aug 30 17:19:02 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* src/xml-io.c: added saving of the current workbook as one
file, added code to load the workbook. Some part are really
untested/incomplete especially the style support.
* src/main.c (main): added loading of "default.wb" on startup
i.e. the default workbook.
......
1998-08-31 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/item-bar.c (item_bar_event): grab the focus when selecting
as well.
* src/sheet-view.c (sheet_view_redraw_cell_region): Implemented
correctly: we now use cell_get_span on every cell in the range to
actually compute which areas need to be updated.
* src/cell.c (cell_get_span): New routine. Computes the number of
columns spanned by a cell.
=======
Sun Aug 30 17:19:02 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* src/xml-io.c: added saving of the current workbook as one
file, added code to load the workbook. Some part are really
untested/incomplete especially the style support.
* src/main.c (main): added loading of "default.wb" on startup
i.e. the default workbook.
......
1998-08-31 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/item-bar.c (item_bar_event): grab the focus when selecting
as well.
* src/sheet-view.c (sheet_view_redraw_cell_region): Implemented
correctly: we now use cell_get_span on every cell in the range to
actually compute which areas need to be updated.
* src/cell.c (cell_get_span): New routine. Computes the number of
columns spanned by a cell.
=======
Sun Aug 30 17:19:02 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* src/xml-io.c: added saving of the current workbook as one
file, added code to load the workbook. Some part are really
untested/incomplete especially the style support.
* src/main.c (main): added loading of "default.wb" on startup
i.e. the default workbook.
......
1998-08-31 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/item-bar.c (item_bar_event): grab the focus when selecting
as well.
* src/sheet-view.c (sheet_view_redraw_cell_region): Implemented
correctly: we now use cell_get_span on every cell in the range to
actually compute which areas need to be updated.
* src/cell.c (cell_get_span): New routine. Computes the number of
columns spanned by a cell.
=======
Sun Aug 30 17:19:02 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* src/xml-io.c: added saving of the current workbook as one
file, added code to load the workbook. Some part are really
untested/incomplete especially the style support.
* src/main.c (main): added loading of "default.wb" on startup
i.e. the default workbook.
......
......@@ -2,17 +2,74 @@
GNOME Spread Sheet task list
* Split the sheet from the view
* EDITION
** Paste special
needs some little changes:
- When formulas are pasted with an operation,
the new ExprTree should be created with the operation.
** Style
Alignment:
Horizontal:
General/Left/Right/Center/Justify/
Center with respect to selection.
Vertical
Up/Center/Fown/Justify
Automatic return check box
This automatically "wraps" text when it overflows the cell
Right now the code has a Sheet (which is the repository for
information) and this Sheet has a GnumericSheet inside (which is the
display canvas).
Orientation
horizontal
vertical: 3 types of string display.
We need to make the Sheet control multiple "views". Say, SheetView
objects, which will in turn include GnumericSheet objects.
Fonts:
Borders:
Cursor position should be moved from GnumericSheet to Sheet as
well
Color/patterns
Protection:
Bloqued/Hidden
* File Load/Save
Support for popular formats.
I have the specs for the XS3 format. SC should be
trivial to support as well (from the guile sources)
* Scrolling
** Scrollbar scrolling
* CORBA exporting
* Perl bindings.
* Display Engine
** item-edit
This should be improved to use a cell rendering routine.
which should be shared between item-grid and item-edit, to
get life feedback on the result.
* Workbooks:
** Notebook:
Clicking on it chooses it
Double clicking changes the name
Right clicking gets:
insert
* Cell selection
It does not shrink.
* Format engine
......@@ -117,78 +174,3 @@ PM/pm/p/p "AM", "am", "M" or "a" for the hours between midnight
the 24-hour format.
* EDITION
** Paste special
needs some little changes:
- When formulas are pasted with an operation,
the new ExprTree should be created with the operation.
** Style
Alignment:
Horizontal:
General/Left/Right/Center/Justify/
Center with respect to selection.
Vertical
Up/Center/Fown/Justify
Automatic return check box
This automatically "wraps" text when it overflows the cell
Orientation
horizontal
vertical: 3 types of string display.
Fonts:
Borders:
Color/patterns
Protection:
Bloqued/Hidden
* File Load/Save
Support for popular formats.
I have the specs for the XS3 format. SC should be
trivial to support as well (from the guile sources)
* Scrolling
** Nice page scrolling with tooltips
** Scrollbar scrolling
* CORBA exporting
* Perl bindings.
* Display Engine
** item-edit
This should be improved to use a cell rendering routine.
which should be shared between item-grid and item-edit, to
get life feedback on the result.
* Selection
Make the selection work by drawing with the invert or the xor
operations instead of drawing and redrawing on top with the text.
* Workbooks:
** Notebook:
Clicking on it chooses it
Double clicking changes the name
Right clicking gets:
insert
* Cell selection
It does not shrink.
\ No newline at end of file
\title {The Gnumeric Spreadsheet Internal Design}
\author { Miguel de Icaza \\ \bf {(miguel@gnu.org)} }
\section { Design goals }
The Gnumeric Spreadsheet is a spreadsheet that is intended to grow in
the future to provide all of the features available in
commercial-grade spreadsheets.
I am not only intending to provide Gnumeric with a very good
computation engine, but I am also interested in making the GUI
experience for the user as pleasant as possible, and that includes
taking a lot of ideas from existing spreadsheets.
\section {Basic organization}
The Gnumeric spreadsheet is basically organized as Workbooks (see
src/sheet.h for the definition of the workbook object). There might
be various workbooks loaded at the same time. Every one of these
workbooks might have a variable number of Sheets (see src/sheet.h for
the definition of the Sheet object), and finally each sheet contains
cells (The definition of a Gnumeric Cell is in src/cell.h).
\begin{itemize}
\item Workbooks only take care of keeping various sheets together and giving
a name to them.
\item Sheets are the repository of information: cells are kept here,
information on the columns and rows is kept here, and the styles
attached to the regions is also kept here.
Sheets might have multiple views, this is required to support split
views and in the future to support the GNOME document model. The
actual front-end to the Sheet object is the SheetView object:
SheetView object each one has a number of components:
\begin {itemize}
\item Their scrollbars.
\item Their cell display engine (more in a second).
\item Their bar display (column and row display).
\end{itemize}
The cell display engine is basically a modified GnomeCanvas that can
deal with keystrokes and can do some extra spreadsheet oriented
tasks. This cell display engine is of type GnumericSheet.
\item GnumericSheet objects usually contain a number of Gnome Canvas items
specially designed to be used for a spreadsheet: the Grid Item and the
Cursor Item:
\begin{itemize}
\item The Grid item takes care of rendering the actual contents of the Sheet
object and displaying the Cells in the way the user requested, this is
the actual "core" display engine.
\item The Cursor item is the item that actually draws the spreadsheet
cursor. This item, as every other Gnome Canvas item can take events
and this one is specially interesting, as it provides the basic
facilities for dragging a region of cells.
\end{itemize}
During the course of a user session, Gnumeric will create Items of
type Editor, a special item designed to display the contents of a cell
as it is being typed and it is syncronized with a GtkEntry (to provide
an Excel-like way of typing text into the cells).
\end{itemize}
\section{Sheet organization}
Sheets contain information for columns and rows in linked lists to
facilitate their traversal (in the future, when bottlenecks are
identified, we will provide an alternate quick access method based on
hash tables).
The column and row information is stored in GList's that contain
ColRowInfo structures. These structures include a number of
interesting bits:
- Their assigned position (or -1 if they are the "default"
style), field name "pos".
- The actual width used in pixels (for the current
magnification setting) as well as their logical size, plus
the margins required in pixels for displaying various cell
adornements.
When a cell is allocated, both ColRowInfos (for column and row) are
allocated and properly linked, the cell is made to point to these new
structures.
The column ColRowInfos have a field called "data", this is a linked
list of Cells for every row where a cell exists.
Cells are stored in a hash table inside the Sheet data structure for
quick retrieval and they are also linked properly in their respective
columns.
\section{Resource management}
Data structures in Gnumeric are lightweight, they are designed to
consume little memory by reusing as much information as possible.
This is achieved by making common information be hashed and
reference-counted. This is done with strings, parser/interprester
symbols and styles.
\end{document}
\title {The Gnumeric Spreadsheet Internal Design}
\author { Miguel de Icaza \\ \bf {(miguel@gnu.org)} }
\section { Design goals }
The Gnumeric Spreadsheet is a spreadsheet that is intended to grow in
the future to provide all of the features available in
commercial-grade spreadsheets.
I am not only intending to provide Gnumeric with a very good
computation engine, but I am also interested in making the GUI
experience for the user as pleasant as possible, and that includes
taking a lot of ideas from existing spreadsheets.
\section {Basic organization}
The Gnumeric spreadsheet is basically organized as Workbooks (see
src/sheet.h for the definition of the workbook object). There might
be various workbooks loaded at the same time. Every one of these
workbooks might have a variable number of Sheets (see src/sheet.h for
the definition of the Sheet object), and finally each sheet contains
cells (The definition of a Gnumeric Cell is in src/cell.h).
\begin{itemize}
\item Workbooks only take care of keeping various sheets together and giving
a name to them.
\item Sheets are the repository of information: cells are kept here,
information on the columns and rows is kept here, and the styles
attached to the regions is also kept here.
Sheets might have multiple views, this is required to support split
views and in the future to support the GNOME document model. The
actual front-end to the Sheet object is the SheetView object:
SheetView object each one has a number of components:
\begin {itemize}
\item Their scrollbars.
\item Their cell display engine (more in a second).
\item Their bar display (column and row display).
\end{itemize}
The cell display engine is basically a modified GnomeCanvas that can
deal with keystrokes and can do some extra spreadsheet oriented
tasks. This cell display engine is of type GnumericSheet.
\item GnumericSheet objects usually contain a number of Gnome Canvas items
specially designed to be used for a spreadsheet: the Grid Item and the
Cursor Item:
\begin{itemize}
\item The Grid item takes care of rendering the actual contents of the Sheet
object and displaying the Cells in the way the user requested, this is
the actual "core" display engine.
\item The Cursor item is the item that actually draws the spreadsheet
cursor. This item, as every other Gnome Canvas item can take events
and this one is specially interesting, as it provides the basic
facilities for dragging a region of cells.
\end{itemize}
During the course of a user session, Gnumeric will create Items of
type Editor, a special item designed to display the contents of a cell
as it is being typed and it is syncronized with a GtkEntry (to provide
an Excel-like way of typing text into the cells).
\end{itemize}
\section{Sheet organization}
Sheets contain information for columns and rows in linked lists to
facilitate their traversal (in the future, when bottlenecks are
identified, we will provide an alternate quick access method based on
hash tables).
The column and row information is stored in GList's that contain
ColRowInfo structures. These structures include a number of
interesting bits:
- Their assigned position (or -1 if they are the "default"
style), field name "pos".
- The actual width used in pixels (for the current
magnification setting) as well as their logical size, plus
the margins required in pixels for displaying various cell
adornements.
When a cell is allocated, both ColRowInfos (for column and row) are
allocated and properly linked, the cell is made to point to these new
structures.
The column ColRowInfos have a field called "data", this is a linked
list of Cells for every row where a cell exists.
Cells are stored in a hash table inside the Sheet data structure for
quick retrieval and they are also linked properly in their respective
columns.
\section{Resource management}
Data structures in Gnumeric are lightweight, they are designed to
consume little memory by reusing as much information as possible.
This is achieved by making common information be hashed and
reference-counted. This is done with strings, parser/interprester
symbols and styles.
\end{document}
/*
* cell.c: Cell management of the Gnumeric spreadsheet.
*
* Author:
* Miguel de Icaza (miguel@kernel.org)
*
*/
#include <config.h>
#include <gnome.h>
#include "gnumeric.h"
......@@ -348,3 +355,185 @@ cell_make_value (Cell *cell)
string_unref (cell->entered_text);
cell->entered_text = string_ref (cell->text);
}
int
cell_get_horizontal_align (Cell *cell)
{
g_return_val_if_fail (cell != NULL, HALIGN_LEFT);
if (cell->style->halign == HALIGN_GENERAL)
if (cell->value){
if (cell->value->type== VALUE_FLOAT ||
cell->value->type == VALUE_INTEGER)
return HALIGN_RIGHT;
else
return HALIGN_LEFT;
} else
return HALIGN_RIGHT;
else
return cell->style->halign;
}
static inline int
cell_is_number (Cell *cell)
{
if (cell->value)
if (cell->value->type == VALUE_FLOAT || cell->value->type == VALUE_INTEGER)
return TRUE;
return FALSE;
}
static inline int
cell_contents_fit_inside_column (Cell *cell)
{
if (cell->width < COL_INTERNAL_WIDTH (cell->col))
return TRUE;
else
return FALSE;
}
/*
* cell_get_span:
* @cell: The cell we will examine
* @col1: return value: the first column used by this cell
* @col2: return value: the last column used by this cell
*
* This routine returns the column interval used by a Cell.
*/
void
cell_get_span (Cell *cell, int *col1, int *col2)
{
Sheet *sheet;
int align, left;
int row, pos, margin;
g_return_if_fail (cell != NULL);
/*
* If the cell is a number, or the text fits inside the
* column, then we report only one column is used
*/
if (cell_is_number (cell) ||
cell->style->halign == HALIGN_JUSTIFY ||
cell_contents_fit_inside_column (cell)){
*col1 = *col2 = cell->col->pos;
return;
}
sheet = cell->sheet;
align = cell_get_horizontal_align (cell);
row = cell->row->pos;
switch (cell->style->halign){
case HALIGN_LEFT:
*col1 = *col2 = cell->col->pos;
pos = cell->col->pos + 1;
left = cell->width - COL_INTERNAL_WIDTH (cell->col);
margin = cell->col->margin_b;
for (; left > 0 && pos < SHEET_MAX_COLS-1; pos++){
ColRowInfo *ci;
Cell *sibling;
sibling = sheet_cell_get (sheet, pos, row);
if (sibling)
return;
ci = sheet_col_get_info (sheet, pos);
/* The space consumed is:
* - The margin_b from the last column
* - The width of the cell
*/
left -= COL_INTERNAL_WIDTH (ci) +
margin + ci->margin_a;
margin = ci->margin_b;
(*col2)++;
}
return;
case HALIGN_RIGHT:
*col1 = *col2 = cell->col->pos;
pos = cell->col->pos - 1;
left = cell->width - COL_INTERNAL_WIDTH (cell->col);
margin = cell->col->margin_a;
for (; left > 0 && pos >= 0; pos--){
ColRowInfo *ci;
Cell *sibling;
sibling = sheet_cell_get (sheet, pos, row);
if (sibling)
return;
ci = sheet_col_get_info (sheet, pos);
/* The space consumed is:
* - The margin_a from the last column
* - The widht of this cell
*/
left -= COL_INTERNAL_WIDTH (ci) +
margin + ci->margin_b;
margin = ci->margin_a;
(*col1)--;
}
return;
case HALIGN_CENTER: {
int left_left, left_right;
int margin_a, margin_b;
*col1 = *col2 = cell->col->pos;
left = cell->width - COL_INTERNAL_WIDTH (cell->col);
left_left = left / 2 + (left % 2);
left_right = left / 2;
margin_a = cell->col->margin_a;
margin_b = cell->col->margin_b;
for (; left_left > 0 || left_right > 0;){
ColRowInfo *ci;
Cell *left_sibling, *right_sibling;
if (*col1 - 1 > 0){
left_sibling = sheet_cell_get (sheet, *col1 - 1, row);
if (left_sibling)
left_left = 0;
else {
ci = sheet_col_get_info (sheet, *col1 - 1);
left_left -= COL_INTERNAL_WIDTH (ci) +
margin_a + ci->margin_b;
margin_a = ci->margin_a;
(*col1)--;
}
} else
left_left = 0;
if (*col2 + 1 < SHEET_MAX_COLS-1){
right_sibling = sheet_cell_get (sheet, *col2 + 1, row);
if (right_sibling)
left_right = 0;
else {
ci = sheet_col_get_info (sheet, *col2 + 1);
left_right -= COL_INTERNAL_WIDTH (ci) +
margin_b + ci->margin_a;
margin_b = ci->margin_b;
(*col2)++;
}
} else
left_right = 0;
} /* for */
} /* case HALIGN_CENTER */
} /* switch */
}
......@@ -18,6 +18,9 @@ typedef struct {