Commit 169d1191 authored by Miguel de Icaza's avatar Miguel de Icaza Committed by Arturo Espinosa

New:



New:

	- Bold button works properly (ie, it detects what sort of
	  stuff you have and presses/unpresses accordingly).

	- GNumeric now has operation modes: sheet and object.
	  Using delete/backspace/edit-cut will let you kill
	  objects.

	- Lots of the bug fixes reported by Adrian/Federico.

Here is the detailed changelog:

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

	* src/xml-io.c: Destroy the extra style.

	* src/main.c (main): No need to init colors as they are auto-inited.

	* src/style.c (font_compute_hints): At font creation time store a
	couple of the font attributes for quick retrieval.

	* src/sheet-view.c (sheet_view_construct): Do not allow this
	button to have the focus either.

	* src/item-bar.c (item_bar_draw): If the whole sheet is selected,
	draw all of the columns in pressed presenstation

	* src/sheet.c (sheet_is_all_selected): Return wheter all the sheet
	is selected.

	* src/utils.c (cell_name): Fixed cell name computation.
	(parse_cell_name): Fixed parsing of the cell name.
parent c24d3268
1998-09-23 Richard Hestilow <hestgray@ionet.net>
* src/style.c: fixed hyphen vs hypen typo.
1998-09-23 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/main.c (main): No need to init colors as they are auto-inited.
* src/style.c (font_compute_hints): At font creation time store a
couple of the font attributes for quick retrieval.
......@@ -59,6 +57,10 @@
* src/pixmaps/bold.xpm: Oops. Use the bold icon I created
yesterday.
1998-09-23 Richard Hestilow <hestgray@ionet.net>
* src/style.c: fixed hyphen vs hypen typo.
Wed, 23 Sep 1998 12:52:20 +0200 Paolo Molaro <lupus@debian.org>
* src/format.c: added #include <locale.h>
......
1998-09-23 Richard Hestilow <hestgray@ionet.net>
* src/style.c: fixed hyphen vs hypen typo.
1998-09-23 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/main.c (main): No need to init colors as they are auto-inited.
* src/style.c (font_compute_hints): At font creation time store a
couple of the font attributes for quick retrieval.
......@@ -59,6 +57,10 @@
* src/pixmaps/bold.xpm: Oops. Use the bold icon I created
yesterday.
1998-09-23 Richard Hestilow <hestgray@ionet.net>
* src/style.c: fixed hyphen vs hypen typo.
Wed, 23 Sep 1998 12:52:20 +0200 Paolo Molaro <lupus@debian.org>
* src/format.c: added #include <locale.h>
......
1998-09-23 Richard Hestilow <hestgray@ionet.net>
* src/style.c: fixed hyphen vs hypen typo.
1998-09-23 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/main.c (main): No need to init colors as they are auto-inited.
* src/style.c (font_compute_hints): At font creation time store a
couple of the font attributes for quick retrieval.
......@@ -59,6 +57,10 @@
* src/pixmaps/bold.xpm: Oops. Use the bold icon I created
yesterday.
1998-09-23 Richard Hestilow <hestgray@ionet.net>
* src/style.c: fixed hyphen vs hypen typo.
Wed, 23 Sep 1998 12:52:20 +0200 Paolo Molaro <lupus@debian.org>
* src/format.c: added #include <locale.h>
......
1998-09-23 Richard Hestilow <hestgray@ionet.net>
* src/style.c: fixed hyphen vs hypen typo.
1998-09-23 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/main.c (main): No need to init colors as they are auto-inited.
* src/style.c (font_compute_hints): At font creation time store a
couple of the font attributes for quick retrieval.
......@@ -59,6 +57,10 @@
* src/pixmaps/bold.xpm: Oops. Use the bold icon I created
yesterday.
1998-09-23 Richard Hestilow <hestgray@ionet.net>
* src/style.c: fixed hyphen vs hypen typo.
Wed, 23 Sep 1998 12:52:20 +0200 Paolo Molaro <lupus@debian.org>
* src/format.c: added #include <locale.h>
......
......@@ -6,6 +6,10 @@ GNOME Spread Sheet task list
* EDITION
** Object Clipboard
If sheet->mode is OBJECT_SELECTED cut/copy/paste should operate on
the object.
** Paste special
needs some little changes:
......
......@@ -133,6 +133,7 @@ cell_set_style (Cell *cell, Style *reference_style)
g_return_if_fail (reference_style != NULL);
cell_queue_redraw (cell);
style_destroy (cell->style);
cell->style = style_duplicate (reference_style);
cell_calc_dimensions (cell);
cell_queue_redraw (cell);
......@@ -240,6 +241,10 @@ cell_set_text (Cell *cell, char *text)
if (cell->entered_text)
string_unref (cell->entered_text);
if (cell->value){
value_release (cell->value);
cell->value = NULL;
}
cell->entered_text = string_get (text);
if (cell->parsed_node){
......
......@@ -64,4 +64,6 @@ color_init (void)
color_alloc_name ("gray60", &gs_light_gray);
color_alloc_name ("gray20", &gs_dark_gray);
color_inited = 1;
}
......@@ -763,6 +763,9 @@ apply_coloring_format (Style *style, Sheet *sheet, CellList *cells)
back_green = 0xffff;
back_blue = 0xffff;
} else {
back_red = 0;
back_green = 0;
back_blue = 0;
}
/* Apply the color to the cells */
......
......@@ -763,6 +763,9 @@ apply_coloring_format (Style *style, Sheet *sheet, CellList *cells)
back_green = 0xffff;
back_blue = 0xffff;
} else {
back_red = 0;
back_green = 0;
back_blue = 0;
}
/* Apply the color to the cells */
......
......@@ -12,6 +12,7 @@
#include <string.h>
#include "gnumeric.h"
#include "gnumeric-sheet.h"
#include "sheet-object.h"
#include "color.h"
#include "cursors.h"
......@@ -515,12 +516,11 @@ selection_expand_vertical (GnumericSheet *gsheet, int dir)
}
/*
* key press event handler for the gnumeric sheet
* key press event handler for the gnumeric sheet for the sheet mode
*/
static gint
gnumeric_sheet_key (GtkWidget *widget, GdkEventKey *event)
gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
{
GnumericSheet *gsheet = GNUMERIC_SHEET (widget);
Sheet *sheet = gsheet->sheet_view->sheet;
Workbook *wb = sheet->workbook;
void (*movefn_horizontal) (GnumericSheet *, int);
......@@ -705,6 +705,46 @@ gnumeric_sheet_key (GtkWidget *widget, GdkEventKey *event)
return 1;
}
static gint
gnumeric_sheet_key_mode_object (GnumericSheet *gsheet, GdkEventKey *event)
{
Sheet *sheet = gsheet->sheet_view->sheet;
switch (event->keyval){
case GDK_Escape:
sheet_set_mode_type (sheet, SHEET_MODE_SHEET);
break;
case GDK_BackSpace:
case GDK_Delete:
sheet_object_destroy (sheet->current_object);
sheet_set_mode_type (sheet, SHEET_MODE_SHEET);
break;
default:
return FALSE;
}
return TRUE;
}
static gint
gnumeric_sheet_key (GtkWidget *widget, GdkEventKey *event)
{
GnumericSheet *gsheet = GNUMERIC_SHEET (widget);
Sheet *sheet = gsheet->sheet_view->sheet;
switch (sheet->mode){
case SHEET_MODE_SHEET:
return gnumeric_sheet_key_mode_sheet (gsheet, event);
case SHEET_MODE_OBJECT_SELECTED:
return gnumeric_sheet_key_mode_object (gsheet, event);
default:
return TRUE;
}
}
GtkWidget *
gnumeric_sheet_new (SheetView *sheet_view, ItemBar *colbar, ItemBar *rowbar)
{
......
......@@ -12,6 +12,7 @@
#include <string.h>
#include "gnumeric.h"
#include "gnumeric-sheet.h"
#include "sheet-object.h"
#include "color.h"
#include "cursors.h"
......@@ -515,12 +516,11 @@ selection_expand_vertical (GnumericSheet *gsheet, int dir)
}
/*
* key press event handler for the gnumeric sheet
* key press event handler for the gnumeric sheet for the sheet mode
*/
static gint
gnumeric_sheet_key (GtkWidget *widget, GdkEventKey *event)
gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
{
GnumericSheet *gsheet = GNUMERIC_SHEET (widget);
Sheet *sheet = gsheet->sheet_view->sheet;
Workbook *wb = sheet->workbook;
void (*movefn_horizontal) (GnumericSheet *, int);
......@@ -705,6 +705,46 @@ gnumeric_sheet_key (GtkWidget *widget, GdkEventKey *event)
return 1;
}
static gint
gnumeric_sheet_key_mode_object (GnumericSheet *gsheet, GdkEventKey *event)
{
Sheet *sheet = gsheet->sheet_view->sheet;
switch (event->keyval){
case GDK_Escape:
sheet_set_mode_type (sheet, SHEET_MODE_SHEET);
break;
case GDK_BackSpace:
case GDK_Delete:
sheet_object_destroy (sheet->current_object);
sheet_set_mode_type (sheet, SHEET_MODE_SHEET);
break;
default:
return FALSE;
}
return TRUE;
}
static gint
gnumeric_sheet_key (GtkWidget *widget, GdkEventKey *event)
{
GnumericSheet *gsheet = GNUMERIC_SHEET (widget);
Sheet *sheet = gsheet->sheet_view->sheet;
switch (sheet->mode){
case SHEET_MODE_SHEET:
return gnumeric_sheet_key_mode_sheet (gsheet, event);
case SHEET_MODE_OBJECT_SELECTED:
return gnumeric_sheet_key_mode_object (gsheet, event);
default:
return TRUE;
}
}
GtkWidget *
gnumeric_sheet_new (SheetView *sheet_view, ItemBar *colbar, ItemBar *rowbar)
{
......
......@@ -34,7 +34,7 @@ typedef struct {
GnomeCanvasItemClass parent_class;
/* Signals emited */
void (* selection_changed) (ItemBar *, int column);
void (* selection_changed) (ItemBar *, int column, int reset);
void (* size_changed) (ItemBar *, int column, int new_width);
} ItemBarClass;
......
......@@ -173,6 +173,9 @@ item_cursor_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, in
int draw_external, draw_internal, draw_handle, draw_center, draw_thick;
int premove;
GdkColor *fore = NULL, *back = NULL;
if (!item_cursor->visible)
return;
item_cursor_get_pixel_coords (item_cursor, &xd, &yd,
&cursor_width, &cursor_height);
......@@ -598,6 +601,18 @@ item_cursor_set_bounds_visibly (ItemCursor *item_cursor,
gnome_canvas_update_now (GNOME_CANVAS (gsheet));
}
void
item_cursor_set_visibility (ItemCursor *item_cursor, int visible)
{
g_return_if_fail (IS_ITEM_CURSOR (item_cursor));
if (item_cursor->visible == visible)
return;
item_cursor->visible = visible;
item_cursor_request_redraw (item_cursor);
}
static gint
item_cursor_drag_event (GnomeCanvasItem *item, GdkEvent *event)
{
......@@ -757,6 +772,7 @@ item_cursor_init (ItemCursor *item_cursor)
item_cursor->end_row = 0;
item_cursor->start_row = ITEM_CURSOR_SELECTION;
item_cursor->tag = -1;
item_cursor->visible = 1;
}
static void
......
......@@ -39,6 +39,8 @@ typedef struct {
/* Cached values of the last bounding box information used */
int cached_x, cached_y, cached_w, cached_h;
int visible;
GdkPixmap *stipple;
} ItemCursor;
......
......@@ -622,6 +622,7 @@ item_grid_event (GnomeCanvasItem *item, GdkEvent *event)
break;
case GDK_BUTTON_PRESS:
sheet_set_mode_type (sheet, SHEET_MODE_SHEET);
switch (event->button.button){
case 1:
convert (canvas, event->button.x, event->button.y, &x, &y);
......
......@@ -4,7 +4,6 @@
#include "xml-io.h"
#include "plugin.h"
#include "format.h"
#include "color.h"
#include "cursors.h"
#include "dump.h"
......@@ -56,7 +55,6 @@ main (int argc, char *argv [])
gnome_init ("Gnumeric", &parser, argc, argv, 0, NULL);
color_init ();
string_init ();
style_init ();
format_color_init ();
......
......@@ -4,7 +4,6 @@
#include "xml-io.h"
#include "plugin.h"
#include "format.h"
#include "color.h"
#include "cursors.h"
#include "dump.h"
......@@ -56,7 +55,6 @@ main (int argc, char *argv [])
gnome_init ("Gnumeric", &parser, argc, argv, 0, NULL);
color_init ();
string_init ();
style_init ();
format_color_init ();
......
......@@ -567,3 +567,18 @@ sheet_view_get_type (void)
return sheet_view_type;
}
void
sheet_view_hide_cursor (SheetView *sheet_view)
{
GnumericSheet *gsheet = GNUMERIC_SHEET (sheet_view->sheet_view);
item_cursor_set_visibility (gsheet->item_cursor, FALSE);
}
void
sheet_view_show_cursor (SheetView *sheet_view)
{
GnumericSheet *gsheet = GNUMERIC_SHEET (sheet_view->sheet_view);
item_cursor_set_visibility (gsheet->item_cursor, TRUE);
}
......@@ -53,6 +53,9 @@ void sheet_view_redraw_cell_region (SheetView *sheet_view,
void sheet_view_redraw_rows (SheetView *sheet_view);
void sheet_view_redraw_columns (SheetView *sheet_view);
void sheet_view_hide_cursor (SheetView *sheet_view);
void sheet_view_show_cursor (SheetView *sheet_view);
typedef struct {
GtkTableClass parent_class;
} SheetViewClass;
......
......@@ -12,6 +12,7 @@
static void sheet_finish_object_creation (Sheet *sheet, SheetObject *object);
static void sheet_object_start_editing (SheetObject *object);
static void sheet_object_stop_editing (SheetObject *object);
static int object_event (GnomeCanvasItem *item,
GdkEvent *event,
SheetObject *object);
......@@ -125,45 +126,6 @@ sheet_object_create_line (Sheet *sheet, int is_arrow, double x1, double y1, doub
return so;
}
void
sheet_object_destroy (SheetObject *object)
{
SheetFilledObject *sfo = (SheetFilledObject *) object;
Sheet *sheet;
GList *l;
g_return_if_fail (object != NULL);
g_return_if_fail (IS_SHEET_OBJECT (object));
sheet = object->sheet;
switch (object->type){
case SHEET_OBJECT_RECTANGLE:
case SHEET_OBJECT_ELLIPSE:
if (sfo->fill_color)
string_unref (sfo->fill_color);
/* fall down */
case SHEET_OBJECT_ARROW:
case SHEET_OBJECT_LINE:
string_unref (object->color);
gnome_canvas_points_free (object->points);
break;
}
for (l = object->realized_list; l; l = l->next){
GnomeCanvasItem *item = l->data;
gtk_object_destroy (GTK_OBJECT (item));
}
g_list_free (l);
sheet->objects = g_list_remove (sheet->objects, object);
g_free (object);
}
static GnomeCanvasItem *
sheet_view_object_realize (SheetView *sheet_view, SheetObject *object)
{
......@@ -345,6 +307,7 @@ create_object (Sheet *sheet, gdouble to_x, gdouble to_y)
break;
case SHEET_MODE_SHEET:
case SHEET_MODE_OBJECT_SELECTED:
g_warning ("This sould not happen\n");
}
......@@ -406,6 +369,8 @@ sheet_button_press (GnumericSheet *gsheet, GdkEventButton *event, Sheet *sheet)
sheet->coords = g_list_append (sheet->coords, oc);
gsheet->sheet_view->temp_item = NULL;
gtk_signal_connect (GTK_OBJECT (gsheet), "button_release_event",
GTK_SIGNAL_FUNC (sheet_button_release), sheet);
gtk_signal_connect (GTK_OBJECT (gsheet), "motion_notify_event",
......@@ -419,8 +384,8 @@ sheet_finish_object_creation (Sheet *sheet, SheetObject *o)
{
GList *l;
/* Reset the mode */
sheet->mode = SHEET_MODE_SHEET;
/* Set the mode */
sheet_set_mode_type (sheet, SHEET_MODE_OBJECT_SELECTED);
sheet_release_coords (sheet);
......@@ -442,7 +407,24 @@ sheet_finish_object_creation (Sheet *sheet, SheetObject *o)
}
}
/*
* sheet_set_mode_type:
* @sheet: The sheet
* @mode: The new mode of operation
*
* These are the following major mode types:
* Object creation (SHEET_MODE_CREATE_*)
* These are used during object creation in the sheeet
*
* Sheet mode (SHEET_MODE_SHEET)
* Regular spreadsheet operations are in place, sheet
* cursor is displayed.
*
* Object editing (SHEET_MODE_OBJECT_SELECTED)
* No spreadsheet cursor is active, and edition is directed
* towards the currently selected object
*/
void
sheet_set_mode_type (Sheet *sheet, SheetModeType mode)
{
......@@ -451,14 +433,37 @@ sheet_set_mode_type (Sheet *sheet, SheetModeType mode)
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
if (sheet->mode == mode)
return;
sheet->mode = mode;
for (l = sheet->sheet_views; l; l = l->next){
SheetView *sheet_view = l->data;
GnumericSheet *gsheet = GNUMERIC_SHEET (sheet_view->sheet_view);
sheet_view->temp_item = NULL;
gtk_signal_connect (GTK_OBJECT (gsheet), "button_press_event",
GTK_SIGNAL_FUNC (sheet_button_press), sheet);
switch (sheet->mode){
case SHEET_MODE_CREATE_OVAL:
case SHEET_MODE_CREATE_BOX:
case SHEET_MODE_CREATE_LINE:
case SHEET_MODE_CREATE_ARROW:
for (l = sheet->sheet_views; l; l = l->next){
SheetView *sheet_view = l->data;
GnumericSheet *gsheet = GNUMERIC_SHEET (sheet_view->sheet_view);
sheet_view->temp_item = NULL;
gtk_signal_connect (GTK_OBJECT (gsheet), "button_press_event",
GTK_SIGNAL_FUNC (sheet_button_press), sheet);
}
break;
case SHEET_MODE_SHEET:
sheet_show_cursor (sheet);
if (sheet->current_object){
sheet_object_stop_editing (sheet->current_object);
sheet->current_object = NULL;
}
break;
case SHEET_MODE_OBJECT_SELECTED:
sheet_hide_cursor (sheet);
break;
}
}
......@@ -483,8 +488,51 @@ sheet_object_stop_editing (SheetObject *object)
{
Sheet *sheet = object->sheet;
sheet_object_destroy_control_points (sheet);
sheet->current_object = NULL;
if (object == sheet->current_object)
sheet_object_destroy_control_points (sheet);
}
void
sheet_object_destroy (SheetObject *object)
{
SheetFilledObject *sfo = (SheetFilledObject *) object;
Sheet *sheet;
GList *l;
g_return_if_fail (object != NULL);
g_return_if_fail (IS_SHEET_OBJECT (object));
sheet = object->sheet;
sheet_object_stop_editing (object);
if (object == sheet->current_object)
sheet->current_object = NULL;
switch (object->type){
case SHEET_OBJECT_RECTANGLE:
case SHEET_OBJECT_ELLIPSE:
if (sfo->fill_color)
string_unref (sfo->fill_color);
/* fall down */
case SHEET_OBJECT_ARROW:
case SHEET_OBJECT_LINE:
string_unref (object->color);
gnome_canvas_points_free (object->points);
break;
}
for (l = object->realized_list; l; l = l->next){
GnomeCanvasItem *item = l->data;
gtk_object_destroy (GTK_OBJECT (item));
}
g_list_free (l);
sheet->objects = g_list_remove (sheet->objects, object);
g_free (object);
}
#define POINT(x) (1 << x)
......@@ -669,8 +717,10 @@ object_event (GnomeCanvasItem *item, GdkEvent *event, SheetObject *object)
break;
case GDK_BUTTON_PRESS:
if (object->sheet->current_object)
if (object->sheet->current_object){
sheet_object_stop_editing (object->sheet->current_object);
object->sheet->current_object = NULL;
}
object->dragging = 1;
gnome_canvas_item_grab (item,
......@@ -795,6 +845,8 @@ sheet_object_make_current (Sheet *sheet, SheetObject *object)
if (sheet->current_object == object)
return;
sheet_set_mode_type (sheet, SHEET_MODE_OBJECT_SELECTED);
if (sheet->current_object)
sheet_object_stop_editing (sheet->current_object);
......
......@@ -567,3 +567,18 @@ sheet_view_get_type (void)
return sheet_view_type;
}
void
sheet_view_hide_cursor (SheetView *sheet_view)
{
GnumericSheet *gsheet = GNUMERIC_SHEET (sheet_view->sheet_view);
item_cursor_set_visibility (gsheet->item_cursor, FALSE);
}
void
sheet_view_show_cursor (SheetView *sheet_view)
{
GnumericSheet *gsheet = GNUMERIC_SHEET (sheet_view->sheet_view);
item_cursor_set_visibility (gsheet->item_cursor, TRUE);
}