Commit 890ae3fd authored by Miguel de Icaza's avatar Miguel de Icaza Committed by Arturo Espinosa

New routine to paint a little red triangle if the cell hsa notes.


1998-09-29  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* src/cell.c (cell_draw_comment): New routine to paint a little
	red triangle if the cell hsa notes.

	* src/cell.c (cell_destroy): Destroy the comment.
	(str_trim_spaces): New routine.  Trims the spaces on a string.
	(cell_draw): Trim the leading and trailing spaces on every string
	of a multi-line text.

	* src/color.c (color_init): Allocate a red for tagging the
	spreadhseet notes.

	* src/dialog-cell-format.c (format_list_fill): Apply the
	traslation when adding the format.

	* doc/tranlating.sgml: New document that describes how to
	internationalize and localize Gnumeric properly.

	* src/workbook.c (recalc_cmd): Provide a way to force a recomputation.
	(insert_current_time_cmd): New function.  insert the current time.
	(insert_current_date_cmd): New function.  insert the current date.
	(insert_at_cursor): New utility function.

	* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet): Handle control-home
parent fe055883
1998-09-29 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c (cell_draw_comment): New routine to paint a little
red triangle if the cell hsa notes.
* src/cell.c (cell_destroy): Destroy the comment.
(str_trim_spaces): New routine. Trims the spaces on a string.
(cell_draw): Trim the leading and trailing spaces on every string
of a multi-line text.
* src/color.c (color_init): Allocate a red for tagging the
spreadhseet notes.
* src/dialog-cell-format.c (format_list_fill): Apply the
traslation when adding the format.
* doc/tranlating.sgml: New document that describes how to
internationalize and localize Gnumeric properly.
* src/workbook.c (recalc_cmd): Provide a way to force a recomputation.
(insert_current_time_cmd): New function. insert the current time.
(insert_current_date_cmd): New function. insert the current date.
(insert_at_cursor): New utility function.
* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet): Handle control-home
1998-09-29 Raja R Harinath <harinath@cs.umn.edu>
* src/parser.y (dump_tree): Update to change in `expr.h'.
......
1998-09-29 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c (cell_draw_comment): New routine to paint a little
red triangle if the cell hsa notes.
* src/cell.c (cell_destroy): Destroy the comment.
(str_trim_spaces): New routine. Trims the spaces on a string.
(cell_draw): Trim the leading and trailing spaces on every string
of a multi-line text.
* src/color.c (color_init): Allocate a red for tagging the
spreadhseet notes.
* src/dialog-cell-format.c (format_list_fill): Apply the
traslation when adding the format.
* doc/tranlating.sgml: New document that describes how to
internationalize and localize Gnumeric properly.
* src/workbook.c (recalc_cmd): Provide a way to force a recomputation.
(insert_current_time_cmd): New function. insert the current time.
(insert_current_date_cmd): New function. insert the current date.
(insert_at_cursor): New utility function.
* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet): Handle control-home
1998-09-29 Raja R Harinath <harinath@cs.umn.edu>
* src/parser.y (dump_tree): Update to change in `expr.h'.
......
1998-09-29 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c (cell_draw_comment): New routine to paint a little
red triangle if the cell hsa notes.
* src/cell.c (cell_destroy): Destroy the comment.
(str_trim_spaces): New routine. Trims the spaces on a string.
(cell_draw): Trim the leading and trailing spaces on every string
of a multi-line text.
* src/color.c (color_init): Allocate a red for tagging the
spreadhseet notes.
* src/dialog-cell-format.c (format_list_fill): Apply the
traslation when adding the format.
* doc/tranlating.sgml: New document that describes how to
internationalize and localize Gnumeric properly.
* src/workbook.c (recalc_cmd): Provide a way to force a recomputation.
(insert_current_time_cmd): New function. insert the current time.
(insert_current_date_cmd): New function. insert the current date.
(insert_at_cursor): New utility function.
* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet): Handle control-home
1998-09-29 Raja R Harinath <harinath@cs.umn.edu>
* src/parser.y (dump_tree): Update to change in `expr.h'.
......
1998-09-29 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c (cell_draw_comment): New routine to paint a little
red triangle if the cell hsa notes.
* src/cell.c (cell_destroy): Destroy the comment.
(str_trim_spaces): New routine. Trims the spaces on a string.
(cell_draw): Trim the leading and trailing spaces on every string
of a multi-line text.
* src/color.c (color_init): Allocate a red for tagging the
spreadhseet notes.
* src/dialog-cell-format.c (format_list_fill): Apply the
traslation when adding the format.
* doc/tranlating.sgml: New document that describes how to
internationalize and localize Gnumeric properly.
* src/workbook.c (recalc_cmd): Provide a way to force a recomputation.
(insert_current_time_cmd): New function. insert the current time.
(insert_current_date_cmd): New function. insert the current date.
(insert_at_cursor): New utility function.
* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet): Handle control-home
1998-09-29 Raja R Harinath <harinath@cs.umn.edu>
* src/parser.y (dump_tree): Update to change in `expr.h'.
......
......@@ -3,6 +3,9 @@ Miguel de Icaza <miguel@kernel.org>
This is the Gnumeric, the GNOME spreadsheet program.
Gnumeric is licensed under the terms of the GNU GPL included in the
file COPYING.
The goal of this spreadsheet is to become as powerful as other
spreadsheets on the market and do this cleanly and smartly. We have
to do this while being as compatible as possible with Excel.
......@@ -17,7 +20,22 @@ probably will want to read the doc/Design file. I have scribbled my
ideas on how Gnumeric should be developed in the future in the file
doc/Future-Roadmap.
Mailing lists:
Notes regarding plugins
-----------------------
The current plugin setup in Gnumeric is just a way to dynamically
load code at runtime into the address space of Gnumeric: they use and
invoke pieces of Gnumeric code directly. This means that any plugin
written under this scheme has to fall under the license of the GNU
GPL.
In the future, an alternative method based on CORBA will be
provided and then it will be possible to create Gnumeric plugins with
other license, until then, the only setup available requires plugins
to fall under the GNU GPL license.
Mailing lists
-------------
There is a mailing list used to discuss Gnumeric, to subscribe
send a mail to:
......@@ -27,6 +45,9 @@ send a mail to:
And in the body of the message write "subscribe"
Random notes:
-------------
This is a partial list of Features implemented in Gnumeric, we need
documentation for these:
......@@ -104,4 +125,9 @@ documentation for these:
- Selection-keys + control extend the selection to boundary of
worksheet.
- SHift-Backspace: Collapses selection to active cell.
\ No newline at end of file
- SHift-Backspace: Collapses selection to active cell.
- Home: move to the beginning of the row.
- Contorl-Home: move to the cell A1
AC_INIT(src/gnumeric.h)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(gnumeric,0.2)
AM_INIT_AUTOMAKE(gnumeric,0.3)
AM_MAINTAINER_MODE
AM_ACLOCAL_INCLUDE(macros)
......
<sect1>
<title>Translating the number formats</title>
<para>There are a couple of things that should be kept in mind
when translating Gnumeric. Gnumeric, unlike regular applications
includes strings used to render numbers in various ways: as dates,
as times, as currency, number, as accouting-formatted numbers.
You should usually leave alone during the general language
translation the number formatting and the date formatting
codes.</para>
<para>For example, in Mexico, we speak spanish (language code
"es"), so a spanish translation should be done for all of the
messages in the program in the file es.po.</para>
<para>Dates in México are represented as day/month/year. The
Gnumeric default is to follow the rules for the US, which are
month/day/year. Now, instead of adding those translations to the
es.po file, those strings should be added to a per-country file,
in this example the "es@mx.po" file. Currency in México uses the
same symbols, so those format codes are left untouched. Decimal
point separator and thousand separators in Mexico are, again, the
same as in the US, so they are left untouched.</para>
<para>So, basically: when doing currency/date/number format
translation, make sure no other country that speaks your language
has a different set of rules (when in doubt, just dont touch the
formatting codes and add your localized version to the NN@MM.po
file).</para>
</sect1>
<sect1>
<title>Dealing with currency formats</title>
<para>Gnumeric uses the locale information to distinguish whith
character is used as a thousand separator and which one is used as
a decimal separator. On the number formatting strings, use your
country decimal separator as the decimal separator. For example,
given the format in Gnumeric "#.00", French translators for France
should change that to "#,00". Thus, the default format "#,##0"
(which means show at least one number, but separate the thousands
with commas) should be translated in this case to "#.##0".</para>
</sect1>
<sect1>
<title>Translating the number formats</title>
<para>There are a couple of things that should be kept in mind
when translating Gnumeric. Gnumeric, unlike regular applications
includes strings used to render numbers in various ways: as dates,
as times, as currency, number, as accouting-formatted numbers.
You should usually leave alone during the general language
translation the number formatting and the date formatting
codes.</para>
<para>For example, in Mexico, we speak spanish (language code
"es"), so a spanish translation should be done for all of the
messages in the program in the file es.po.</para>
<para>Dates in México are represented as day/month/year. The
Gnumeric default is to follow the rules for the US, which are
month/day/year. Now, instead of adding those translations to the
es.po file, those strings should be added to a per-country file,
in this example the "es@mx.po" file. Currency in México uses the
same symbols, so those format codes are left untouched. Decimal
point separator and thousand separators in Mexico are, again, the
same as in the US, so they are left untouched.</para>
<para>So, basically: when doing currency/date/number format
translation, make sure no other country that speaks your language
has a different set of rules (when in doubt, just dont touch the
formatting codes and add your localized version to the NN@MM.po
file).</para>
</sect1>
<sect1>
<title>Dealing with currency formats</title>
<para>Gnumeric uses the locale information to distinguish whith
character is used as a thousand separator and which one is used as
a decimal separator. On the number formatting strings, use your
country decimal separator as the decimal separator. For example,
given the format in Gnumeric "#.00", French translators for France
should change that to "#,00". Thus, the default format "#,##0"
(which means show at least one number, but separate the thousands
with commas) should be translated in this case to "#.##0".</para>
</sect1>
......@@ -6,7 +6,8 @@ PYTHON =
endif
if WITH_PERL
PERL = perl
PERL =
# Commented out for 0.3 release perl
else
PERL =
endif
......
......@@ -46,7 +46,7 @@ COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS)
SOURCES = cat-id-tbl.c
POFILES = @POFILES@
GMOFILES = @GMOFILES@
DISTFILES = ChangeLog Makefile.in.in POTFILES.in $(PACKAGE).pot \
DISTFILES = README ChangeLog Makefile.in.in POTFILES.in $(PACKAGE).pot \
stamp-cat-id $(POFILES) $(GMOFILES) $(SOURCES)
POTFILES = \
......
If you are working on translating Gnumeric, please read the file
doc/translating.sgml for details on some issues regarding Gnumeric.
\ No newline at end of file
......@@ -2,8 +2,7 @@
* cell.c: Cell management of the Gnumeric spreadsheet.
*
* Author:
* Miguel de Icaza (miguel@kernel.org)
*
* Miguel de Icaza 1998 (miguel@kernel.org)
*/
#include <config.h>
#include <gnome.h>
......@@ -11,6 +10,7 @@
#include "gnumeric-sheet.h"
#include "eval.h"
#include "format.h"
#include "color.h"
static int redraws_frozen = 0;
static GHashTable *cell_hash_queue;
......@@ -406,6 +406,9 @@ cell_destroy (Cell *cell)
if (cell->render_color)
style_color_unref (cell->render_color);
if (cell->comment)
string_unref (cell->comment);
string_unref (cell->entered_text);
string_unref (cell->text);
......@@ -487,6 +490,12 @@ cell_set_format_simple (Cell *cell, char *format)
cell->style->format = style_format_new (format);
}
/*
* cell_set_format:
*
* Changes the format for CELL to be FORMAT. FORMAT should be
* a number display format as specified on the manual
*/
void
cell_set_format (Cell *cell, char *format)
{
......@@ -508,6 +517,36 @@ cell_set_format (Cell *cell, char *format)
cell_queue_redraw (cell);
}
void
cell_set_comment (Cell *cell, char *str)
{
int had_comments = FALSE;
g_return_if_fail (cell != NULL);
g_return_if_fail (str != NULL);
if (cell->comment){
string_unref (cell->comment);
had_comments = TRUE;
}
cell->comment = string_get (str);
if (had_comments)
cell_queue_redraw (cell);
}
/*
* cell_formula_relocate:
* @cell: The cell that is changing position
* @target_col: The new column
* @target_row: The new row.
*
* This routine is used to move a cell to a different location:
* The parsed tree is decoded as if it were evaluated at the new position
* and then it is reparsed (important only for keeping the ->entered_text
* information syncronized).
*/
void
cell_formula_relocate (Cell *cell, int target_col, int target_row)
{
......@@ -515,6 +554,7 @@ cell_formula_relocate (Cell *cell, int target_col, int target_row)
g_return_if_fail (cell != NULL);
g_return_if_fail (cell->entered_text);
g_return_if_fail (cell->parsed_node);
string_unref (cell->entered_text);
......@@ -930,6 +970,58 @@ cell_split_text (GdkFont *font, char *text, int width)
return list;
}
/*
* str_trim_spaces:
* s: the string to modify
*
* This routine trims the leading and trailing spaces of the
* string. The string is possibly modified and the returned
* value lies inside the original string.
*
* No duplication takes place
*/
static char *
str_trim_spaces (char *s)
{
char *p;
while (*s && *s == ' ')
s++;
p = s + strlen (s);
while (p >= s){
if (*p == ' ')
*p = 0;
p--;
}
return s;
}
#define TRIANGLE_WIDTH 6
static void
cell_draw_comment (Cell *cell, GdkGC *gc, GdkDrawable *drawable, int x1, int y1)
{
GdkPoint points [3];
int width;
gdk_gc_set_foreground (gc, &gs_red);
gdk_gc_set_background (gc, &gs_red);
width = cell->col->pixels;
y1++;
points [0].x = x1 + width;
points [0].y = y1;
points [1].x = x1 + width;
points [1].y = y1 + TRIANGLE_WIDTH;
points [2].x = x1 + width - TRIANGLE_WIDTH;
points [2].y = y1;
gdk_draw_polygon (drawable, gc, TRUE, points, 3);
gdk_gc_set_background (gc, &gs_white);
gdk_gc_set_foreground (gc, &gs_black);
}
/*
* Returns the number of columns used for the draw
*/
......@@ -982,8 +1074,8 @@ cell_draw (Cell *cell, void *sv, GdkGC *gc, GdkDrawable *drawable, int x1, int y
rect.x = x1;
rect.y = y1;
rect.height = cell->height;
rect.width = cell->width;
rect.height = cell->row->pixels;
rect.width = cell->col->pixels;
gdk_gc_set_clip_rectangle (gc, &rect);
switch (style->valign){
......@@ -1022,6 +1114,8 @@ cell_draw (Cell *cell, void *sv, GdkGC *gc, GdkDrawable *drawable, int x1, int y
for (l = lines; l; l = l->next){
char *str = l->data;
str = str_trim_spaces (str);
switch (halign){
case HALIGN_LEFT:
case HALIGN_JUSTIFY:
......@@ -1066,7 +1160,7 @@ cell_draw (Cell *cell, void *sv, GdkGC *gc, GdkDrawable *drawable, int x1, int y
/* This rectangle has the whole area used by this cell */
rect.x = x1 + 1 + diff;
rect.y = y1 + 1;
rect.width = sheet_col_get_distance (cell->sheet, start_col, end_col+1) - 2;
rect.width = sheet_col_get_distance (cell->sheet, start_col, end_col+1) - 1;
rect.height = cell->row->pixels - 2;
/* Set the clip rectangle */
......@@ -1107,6 +1201,10 @@ cell_draw (Cell *cell, void *sv, GdkGC *gc, GdkDrawable *drawable, int x1, int y
} while (halign == HALIGN_FILL && total < rect.width);
}
/* Draw the comment indicator */
if (cell->comment)
cell_draw_comment (cell, gc, drawable, x1, y1);
return end_col - start_col + 1;
}
......@@ -21,7 +21,8 @@ typedef struct {
#define COL_INTERNAL_WIDTH(col) ((col)->pixels - ((col)->margin_b + (col)->margin_a))
#define ROW_INTERNAL_HEIGHT(row) ((row)->pixels - ((row)->margin_b + (row)->margin_a))
#define CELL_ERROR 1
#define CELL_ERROR 1
#define CELL_HAS_COMMENT 2
typedef struct {
void *sheet;
......@@ -43,6 +44,7 @@ typedef struct {
int width; /* Width of text */
int height; /* Height of text */
String *comment;
int flags;
char generation;
} Cell;
......
......@@ -64,6 +64,7 @@ color_init (void)
color_alloc_name ("gray60", &gs_light_gray);
color_alloc_name ("gray20", &gs_dark_gray);
color_alloc_name ("red", &gs_red);
color_inited = 1;
}
......@@ -9,6 +9,6 @@ void color_alloc_name (char *name, GdkColor *color);
void color_alloc_gdk (GdkColor *color);
/* Colors used by any GnumericSheet item */
extern GdkColor gs_white, gs_light_gray, gs_dark_gray, gs_black;
extern GdkColor gs_white, gs_light_gray, gs_dark_gray, gs_black, gs_red;
#endif
......@@ -91,7 +91,9 @@ format_list_fill (int n)
gtk_clist_clear (cl);
for (i = 0; texts [i]; i++){
char *t [1] = { texts [i] };
char *t [1];
t [0] = _(texts [i]);
gtk_clist_append (cl, t);
}
......
......@@ -91,7 +91,9 @@ format_list_fill (int n)
gtk_clist_clear (cl);
for (i = 0; texts [i]; i++){
char *t [1] = { texts [i] };
char *t [1];
t [0] = _(texts [i]);
gtk_clist_append (cl, t);
}
......
/*
* formats.c: The default formats supported in Gnumeric
*
* For information on how to translate these format strings properly,
* refer to the doc/translating.sgml file in the Gnumeric distribution.
*
* Author:
* Miguel de Icaza (miguel@kernel.org)
*/
......
......@@ -21,7 +21,7 @@
/* Public colors: shared by all of our items in Gnumeric */
GdkColor gs_white, gs_black, gs_light_gray, gs_dark_gray;
GdkColor gs_white, gs_black, gs_light_gray, gs_dark_gray, gs_red;
static GnomeCanvasClass *sheet_parent_class;
......@@ -623,7 +623,11 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
break;
case GDK_Home:
(*movefn_horizontal)(gsheet, -CURSOR_COL(gsheet));
if ((event->state & GDK_CONTROL_MASK) != 0){
sheet_cursor_move (sheet, 0, 0);
break;
} else
(*movefn_horizontal)(gsheet, -CURSOR_COL(gsheet));
break;
case GDK_KP_Delete:
......
......@@ -21,7 +21,7 @@
/* Public colors: shared by all of our items in Gnumeric */
GdkColor gs_white, gs_black, gs_light_gray, gs_dark_gray;
GdkColor gs_white, gs_black, gs_light_gray, gs_dark_gray, gs_red;
static GnomeCanvasClass *sheet_parent_class;
......@@ -623,7 +623,11 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
break;
case GDK_Home:
(*movefn_horizontal)(gsheet, -CURSOR_COL(gsheet));
if ((event->state & GDK_CONTROL_MASK) != 0){
sheet_cursor_move (sheet, 0, 0);
break;
} else
(*movefn_horizontal)(gsheet, -CURSOR_COL(gsheet));
break;
case GDK_KP_Delete:
......
......@@ -620,7 +620,7 @@ item_grid_event (GnomeCanvasItem *item, GdkEvent *event)
row = SHEET_MAX_ROWS-1;
sheet_selection_extend_to (sheet, col, row);
return 1;
}
}
break;
case GDK_BUTTON_PRESS:
......
......@@ -1699,6 +1699,30 @@ sheet_cell_get (Sheet *sheet, int col, int row)
return cell;
}
/*
* sheet_cell_fetch
* @sheet: The sheet where we want to locate the cell
* @col: the cell column
* @row: the cell row
*
* Return value: a (Cell *) containing the Cell at col, row.
* If no cell existed at that location before, it is created.
*/
Cell *
sheet_cell_fetch (Sheet *sheet, int col, int row)
{
Cell *cell;
g_return_val_if_fail (sheet != NULL, NULL);
g_return_val_if_fail (IS_SHEET (sheet), NULL);
cell = sheet_cell_get (sheet, col, row);
if (!cell)
cell = sheet_cell_new (sheet, col, row);
return cell;
}
/*
* For each existing cell in the range specified, invoke the
* callback routine. If the only_existing flag is passed, then
......
......@@ -199,6 +199,7 @@ int sheet_cell_foreach_range (Sheet *sheet, int only_existing,
sheet_cell_foreach_callback callback,
void *closure);
Cell *sheet_cell_get (Sheet *sheet, int col, int row);
Cell *sheet_cell_fetch (Sheet *sheet, int col, int row);
void sheet_cell_formula_link (Cell *cell);
void sheet_cell_formula_unlink (Cell *cell);
......
......@@ -64,6 +64,7 @@ color_init (void)
color_alloc_name ("gray60", &gs_light_gray);
color_alloc_name ("gray20", &gs_dark_gray);
color_alloc_name ("red", &gs_red);
color_inited = 1;
}
......@@ -9,6 +9,6 @@ void color_alloc_name (char *name, GdkColor *color);
void color_alloc_gdk (GdkColor *color);
/* Colors used by any GnumericSheet item */
extern GdkColor gs_white, gs_light_gray, gs_dark_gray, gs_black;
extern GdkColor gs_white, gs_light_gray, gs_dark_gray, gs_black, gs_red;
#endif
......@@ -8,6 +8,7 @@
#include <config.h>
#include <gnome.h>