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

Color style is now a single color

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

	* src/style.h: Color style is now a single color

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

	* src/sheet-object.c: New file.  The support for adding graphical
	objects to the spreadhseet is here.  The main entry point is
	sheet_set_mode_type which hooks to the signal handlers for object
	creation.

	Various routines for per-view creation, destruction are provided.
parent aece16b8
1998-09-07 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/style.h: Color style is now a single color
1998-09-06 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet-object.c: New file. The support for adding graphical
objects to the spreadhseet is here. The main entry point is
sheet_set_mode_type which hooks to the signal handlers for object
creation.
Various routines for per-view creation, destruction are provided.
1998-09-05 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/parser.y: Add unary '+'
......
1998-09-07 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/style.h: Color style is now a single color
1998-09-06 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet-object.c: New file. The support for adding graphical
objects to the spreadhseet is here. The main entry point is
sheet_set_mode_type which hooks to the signal handlers for object
creation.
Various routines for per-view creation, destruction are provided.
1998-09-05 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/parser.y: Add unary '+'
......
1998-09-07 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/style.h: Color style is now a single color
1998-09-06 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet-object.c: New file. The support for adding graphical
objects to the spreadhseet is here. The main entry point is
sheet_set_mode_type which hooks to the signal handlers for object
creation.
Various routines for per-view creation, destruction are provided.
1998-09-05 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/parser.y: Add unary '+'
......
1998-09-07 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/style.h: Color style is now a single color
1998-09-06 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet-object.c: New file. The support for adding graphical
objects to the spreadhseet is here. The main entry point is
sheet_set_mode_type which hooks to the signal handlers for object
creation.
Various routines for per-view creation, destruction are provided.
1998-09-05 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/parser.y: Add unary '+'
......
......@@ -17,6 +17,17 @@ AM_PROG_LIBTOOL
GNOME_X_CHECKS
GNOME_XML_CHECK
dnl
dnl Check for ORBit
dnl
AC_CHECK_PROG(orbit_val, orbit-config, true, false)
AM_CONDITIONAL(WITH_ORBIT, $orbit_val)
if $orbit_val; then
AC_DEFINE(HAVE_ORBIT)
fi
AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)
......
......@@ -12,96 +12,112 @@ INCLUDES = \
GNOME_XML_LIB = -lxml
GNUMERIC_BASE_SOURCES = \
cell.h \
cell.c \
cellspan.c \
clipboard.c \
clipboard.h \
dialog-cell-format.c \
dialog-goto-cell.c \
dialog-insert-cells.c \
dialog-delete-cells.c \
dialog-paste-special.c \
dialog-zoom.c \
dialogs.h \
eval.c \
expr.c \
expr.h \
file.c \
func.c \
func.h \
fn-sheet.c \
fn-math.c \
fn-misc.c \
format.c \
format.h \
gnumeric-sheet.c \
gnumeric-sheet.h \
gnumeric-util.c \
gnumeric-util.h \
gnumeric.h \
item-bar.c \
item-bar.h \
item-cursor.c \
item-cursor.h \
item-debug.c \
item-debug.h \
item-edit.c \
item-edit.h \
item-grid.c \
item-grid.h \
parser.y \
sheet.c \
sheet.h \
sheet-view.c \
sheet-view.h \
str.c \
str.h \
style.c \
style.h \
symbol.h \
symbol.c \
utils.c \
utils.h \
workbook.c \
GNUMERIC_BASE_SOURCES = \
cell.h \
cell.c \
cellspan.c \
clipboard.c \
clipboard.h \
dialog-cell-format.c \
dialog-goto-cell.c \
dialog-insert-cells.c \
dialog-delete-cells.c \
dialog-paste-special.c \
dialog-zoom.c \
dialogs.h \
eval.c \
expr.c \
expr.h \
file.c \
func.c \
func.h \
fn-sheet.c \
fn-math.c \
fn-misc.c \
format.c \
format.h \
gnumeric-sheet.c \
gnumeric-sheet.h \
gnumeric-util.c \
gnumeric-util.h \
gnumeric.h \
item-bar.c \
item-bar.h \
item-cursor.c \
item-cursor.h \
item-debug.c \
item-debug.h \
item-edit.c \
item-edit.h \
item-grid.c \
item-grid.h \
parser.y \
sheet.c \
sheet.h \
sheet-object.c \
sheet-object.h \
sheet-view.c \
sheet-view.h \
str.c \
str.h \
style.c \
style.h \
symbol.h \
symbol.c \
utils.c \
utils.h \
workbook.c \
xml-io.c
gnumeric_SOURCES = \
main.c \
#if WITH_ORBIT
#GNUMERIC_CORBA_GENERATED = \
# Gnumeric-common.c \
# Gnumeric-skels.c \
# Gnumeric-stubs.c \
# Gnumeric.h
#
#GNUMERIC_CORBA_SOURCES = \
# Gnumeric-impl.c \
# $(GNUMERIC_CORBA_GENERATED)
#
#$(GNUMERIC_CORBA_GENERATED: Gnumeric.idl
# orbit-idl Gnumeric.idl
#
# $(GNUMERIC_CORBA_SOURCES) \
#endif
gnumeric_SOURCES = \
main.c \
$(GNUMERIC_BASE_SOURCES)
gnumeric_LDADD = \
$(GNOME_LIBDIR) \
$(GNOMEUI_LIBS) \
$(GNOME_XML_LIB) \
gnumeric_LDADD = \
$(GNOME_LIBDIR) \
$(GNOMEUI_LIBS) \
$(GNOME_XML_LIB) \
$(INTLLIBS)
test_format_SOURCES = format.c test-format.c
test_format_LDADD = \
$(GNOME_LIBDIR) \
$(GNOMEUI_LIBS) \
test_format_LDADD = \
$(GNOME_LIBDIR) \
$(GNOMEUI_LIBS) \
$(INTLLIBS)
test_parser_SOURCES = \
test-parser.c \
test_parser_SOURCES = \
test-parser.c \
$(GNUMERIC_BASE_SOURCES)
test_parser_LDADD = \
$(GNOME_LIBDIR) \
$(GNOME_XML_LIB) \
test_parser_LDADD = \
$(GNOME_LIBDIR) \
$(GNOME_XML_LIB) \
$(GNOMEUI_LIBS) $(INTLLIBS) -lgmp
#test_token_SOURCES = \
# test-token.c \
# token.c \
# token.h##
#
#test_token_LDADD = \
# $(GNOME_LIBDIR) \
# $(GNOMEUI_LIBS) -lgmp
wc:
wc -l $(gnumeric_SOURCES)
\ No newline at end of file
wc -l $(gnumeric_SOURCES)
dist-hook:
mkdir $(distdir)/pixmaps
cp $(srcdir)/pixmaps/*.xpm $(distdir)/pixmaps
EXTRA_DIST = Gnumeric.idl
......@@ -771,8 +771,8 @@ cell_draw (Cell *cell, void *sv, GdkGC *gc, GdkDrawable *drawable, int x1, int y
halign = cell_get_horizontal_align (cell);
text = CELL_TEXT_GET (cell);
if ((cell->style->valid_flags & STYLE_COLOR) && cell->style->color){
gdk_gc_set_background (gc, &cell->style->color->background);
if ((cell->style->valid_flags & STYLE_BACK_COLOR) && cell->style->back_color){
gdk_gc_set_background (gc, &cell->style->back_color->color);
}
/* if a number overflows, do special drawing */
......
......@@ -987,9 +987,9 @@ gnumeric_sheet_class_init (GnumericSheetClass *class)
/* Method override */
object_class->destroy = gnumeric_sheet_destroy;
widget_class->realize = gnumeric_sheet_realize;
widget_class->size_allocate = gnumeric_size_allocate;
widget_class->key_press_event = gnumeric_sheet_key;
widget_class->realize = gnumeric_sheet_realize;
widget_class->size_allocate = gnumeric_size_allocate;
widget_class->key_press_event = gnumeric_sheet_key;
}
static void
......
......@@ -20,32 +20,34 @@ typedef struct {
extern gnumeric_sheet_pattern_t gnumeric_sheet_patterns [GNUMERIC_SHEET_PATTERNS];
typedef struct {
GnomeCanvas canvas;
GnomeCanvas canvas;
GtkWidget *entry;
SheetView *sheet_view;
GtkWidget *entry;
SheetView *sheet_view;
ColType top_col, last_visible_col, last_full_col;
RowType top_row, last_visible_row, last_full_row;
ColType top_col, last_visible_col, last_full_col;
RowType top_row, last_visible_row, last_full_row;
ItemGrid *item_grid;
ItemCursor *item_cursor;
ItemBar *item_bar_col;
ItemGrid *item_grid;
ItemCursor *item_cursor;
ItemBar *item_bar_col;
ItemEdit *item_editor;
ItemEdit *item_editor;
SheetModeType mode;
/* This flag keeps track of a cell selector
* (ie, when the user uses the cursor keys
* to select a cell for an expression).
*/
int selecting_cell;
int sel_cursor_pos;
int sel_text_len;
ItemCursor *selection;
ItemBar *colbar;
ItemBar *rowbar;
GdkPixmap *patterns [GNUMERIC_SHEET_PATTERNS];
int selecting_cell;
int sel_cursor_pos;
int sel_text_len;
ItemCursor *selection;
ItemBar *colbar;
ItemBar *rowbar;
GdkPixmap *patterns [GNUMERIC_SHEET_PATTERNS];
} GnumericSheet;
GtkType gnumeric_sheet_get_type (void);
......
......@@ -987,9 +987,9 @@ gnumeric_sheet_class_init (GnumericSheetClass *class)
/* Method override */
object_class->destroy = gnumeric_sheet_destroy;
widget_class->realize = gnumeric_sheet_realize;
widget_class->size_allocate = gnumeric_size_allocate;
widget_class->key_press_event = gnumeric_sheet_key;
widget_class->realize = gnumeric_sheet_realize;
widget_class->size_allocate = gnumeric_size_allocate;
widget_class->key_press_event = gnumeric_sheet_key;
}
static void
......
......@@ -20,32 +20,34 @@ typedef struct {
extern gnumeric_sheet_pattern_t gnumeric_sheet_patterns [GNUMERIC_SHEET_PATTERNS];
typedef struct {
GnomeCanvas canvas;
GnomeCanvas canvas;
GtkWidget *entry;
SheetView *sheet_view;
GtkWidget *entry;
SheetView *sheet_view;
ColType top_col, last_visible_col, last_full_col;
RowType top_row, last_visible_row, last_full_row;
ColType top_col, last_visible_col, last_full_col;
RowType top_row, last_visible_row, last_full_row;
ItemGrid *item_grid;
ItemCursor *item_cursor;
ItemBar *item_bar_col;
ItemGrid *item_grid;
ItemCursor *item_cursor;
ItemBar *item_bar_col;
ItemEdit *item_editor;
ItemEdit *item_editor;
SheetModeType mode;
/* This flag keeps track of a cell selector
* (ie, when the user uses the cursor keys
* to select a cell for an expression).
*/
int selecting_cell;
int sel_cursor_pos;
int sel_text_len;
ItemCursor *selection;
ItemBar *colbar;
ItemBar *rowbar;
GdkPixmap *patterns [GNUMERIC_SHEET_PATTERNS];
int selecting_cell;
int sel_cursor_pos;
int sel_text_len;
ItemCursor *selection;
ItemBar *colbar;
ItemBar *rowbar;
GdkPixmap *patterns [GNUMERIC_SHEET_PATTERNS];
} GnumericSheet;
GtkType gnumeric_sheet_get_type (void);
......
......@@ -378,6 +378,7 @@ vertical_scroll_event (GtkScrollbar *scroll, GdkEvent *event, SheetView *sheet_v
static void
sheet_view_construct (SheetView *sheet_view)
{
GnomeCanvasGroup *root_group;
GtkTable *table = GTK_TABLE (sheet_view);
GtkWidget *select_all;
Sheet *sheet = sheet_view->sheet;
......@@ -421,6 +422,16 @@ sheet_view_construct (SheetView *sheet_view)
GTK_OBJECT (sheet_view), "size_allocate",
GTK_SIGNAL_FUNC (sheet_view_size_allocate), sheet_view);
/* Create the object group inside the GnumericSheet */
root_group = GNOME_CANVAS_GROUP (
GNOME_CANVAS (sheet_view->sheet_view)->root);
sheet_view->object_group = gnome_canvas_item_new (
root_group,
gnome_canvas_group_get_type (),
"x", 0.0,
"y", 0.0,
NULL);
/* Attach the GnumericSheet */
gtk_table_attach (table, sheet_view->sheet_view,
1, 2, 1, 2,
......
......@@ -11,17 +11,25 @@
typedef struct {
GtkTable table;
Sheet *sheet;
GtkWidget *sheet_view;
GnomeCanvas *col_canvas, *row_canvas;
GnomeCanvasItem *col_item, *row_item;
Sheet *sheet;
GtkWidget *sheet_view;
GnomeCanvas *col_canvas, *row_canvas;
GnomeCanvasItem *col_item, *row_item;
/* Object group */
GnomeCanvasGroup *object_group;
/* Temporary object used during the creation of objects
* in the canvas
*/
void *temp_item;
/* Scrolling information */
GtkWidget *vs, *hs; /* The scrollbars */
GtkObject *va, *ha; /* The adjustments */
/* Tip for scrolling */
GtkWidget *tip;
GtkWidget *tip;
} SheetView;
GtkType sheet_view_get_type (void);
......
#include <config.h>
#include <gnome.h>
#include <gdk/gdkkeysyms.h>
#include "gnumeric.h"
#include "gnumeric-util.h"
#include "gnumeric-sheet.h"
#include "dialogs.h"
#include "sheet-object.h"
#define GNUMERIC_SHEET_VIEW(p) GNUMERIC_SHEET (SHEET_VIEW(p)->sheet_view);
static void sheet_finish_object_creation (Sheet *sheet);
typedef struct {
gdouble x, y;
} ObjectCoords;
static void
sheet_release_coords (Sheet *sheet)
{
GList *l;
for (l = sheet->coords; l; l = l->next)
g_free (l->data);
g_list_free (sheet->coords);
sheet->coords = NULL;
}
static inline SheetObject *
sheet_object_new (Sheet *sheet)
{
SheetObject *so;
so = g_new0 (SheetObject, 1);
so->signature = SHEET_OBJECT_SIGNATURE;
so->sheet = sheet;
return so;
}
static inline SheetObject *
sheet_filled_object_new (Sheet *sheet)
{
SheetFilledObject *sfo;
sfo = g_new0 (SheetFilledObject, 1);
sfo->sheet_object.signature = SHEET_OBJECT_SIGNATURE;
sfo->sheet_object.sheet = sheet;
return (SheetObject *) sfo;
}
SheetObject *
sheet_object_create_filled (Sheet *sheet, int type,
double x1, double y1,
double x2, double y2,
char *fill_color, char *outline_color, int w)
{
SheetFilledObject *sfo;
SheetObject *so;
g_return_val_if_fail (sheet != NULL, NULL);
g_return_val_if_fail (IS_SHEET (sheet), NULL);
so = sheet_filled_object_new (sheet);
sfo = (SheetFilledObject *) so;
so->type = type;
so->points = gnome_canvas_points_new (2);
so->points->coords [0] = x1;
so->points->coords [1] = y1;
so->points->coords [2] = x2;
so->points->coords [3] = y2;
so->width = w;
sfo->pattern = 0;
if (outline_color)
so->color = string_get (outline_color);
if (fill_color)
sfo->fill_color = string_get (fill_color);
return (SheetObject *) sfo;
}
SheetObject *
sheet_object_create_line (Sheet *sheet, double x1, double y1, double x2, double y2, char *color, int w)
{
SheetObject *so;
g_return_val_if_fail (sheet != NULL, NULL);
g_return_val_if_fail (IS_SHEET (sheet), NULL);
so = sheet_object_new (sheet);
so->type = SHEET_OBJECT_LINE;
so->points = gnome_canvas_points_new (2);
so->points->coords [0] = (gdouble) x1;
so->points->coords [1] = (gdouble) y1;
so->points->coords [2] = (gdouble) x2;
so->points->coords [3] = (gdouble) y2;
so->color = string_get (color);
so->width = w;
return so;
}
void
sheet_object_destroy (SheetObject *object)
{
SheetFilledObject *sfo = (SheetFilledObject *) object;
GList *l;
g_return_if_fail (object != NULL);
g_return_if_fail (IS_SHEET_OBJECT (object));
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);
g_free (object);
}
GnomeCanvasItem *
sheet_view_object_realize (SheetView *sheet_view, SheetObject *object)
{
SheetFilledObject *filled_object = (SheetFilledObject *) object;
GnomeCanvasItem *item;
g_return_val_if_fail (sheet_view != NULL, NULL);
g_return_val_if_fail (IS_SHEET_VIEW (sheet_view), NULL);
g_return_val_if_fail (object != NULL, NULL);
g_return_val_if_fail (IS_SHEET_OBJECT (object), NULL);
item = NULL;
switch (object->type){
case SHEET_OBJECT_LINE:
item = gnome_canvas_item_new (
sheet_view->object_group,
gnome_canvas_line_get_type (),
"points", object->points,
"fill_color", object->color->str,
"width_pixels", object->width,
NULL);
break;
case SHEET_OBJECT_ARROW:
item = gnome_canvas_item_new (
sheet_view->object_group,
gnome_canvas_line_get_type (),
"points", object->points,
"fill_color", object->color->str,
"width_pixels", object->width,
"arrow_shape_a", 1.0,
"arrow_shape_b", 1.0,
"arrow_shape_c", 1.0,
NULL);
break;
case SHEET_OBJECT_RECTANGLE:
item = gnome_canvas_item_new (
sheet_view->object_group,
gnome_canvas_rect_get_type (),
"x1", object->points->coords [0],
"y1", object->points->coords [1],
"x2", object->points->coords [2],
"y2", object->points->coords [3],
"fill_color", filled_object->fill_color ?
filled_object->fill_color->str : NULL,
"outline_color", object->color->str,
"width_pixels", object->width,
NULL);
break;
case SHEET_OBJECT_ELLIPSE:
item = gnome_canvas_item_new (
sheet_view->object_group,
gnome_canvas_ellipse_get_type (),
"x1", object->points->coords [0],
"y1", object->points->coords [1],
"x2", object->points->coords [2],
"y2", object->points->coords [3],
"fill_color", filled_object->fill_color ?
filled_object->fill_color->str : NULL,
"outline_color", object->color->str,
"width_pixels", object->width,
NULL);
break;
}
if (item == NULL)
g_warning ("We created an unsupported type\n");
object->realized_list = g_list_prepend (object->realized_list, item);
return item;
}
void
sheet_view_object_unrealize (SheetView *sheet_view, SheetObject *object)
{
GList *l;
g_return_if_fail (sheet_view != NULL);
g_return_if_fail (IS_SHEET_VIEW (sheet_view));
g_return_if_fail (object != NULL);
g_return_if_fail (IS_SHEET_OBJECT (object));
for (l = object->realized_list; l; l = l->next){
GnomeCanvasItem *item = GNOME_CANVAS_ITEM (l->data);
GnumericSheet *gsheet = GNUMERIC_SHEET (item->canvas);
if (gsheet->sheet_view != sheet_view)
continue;
gtk_object_destroy (GTK_OBJECT (item));
object->realized_list = g_list_remove (object->realized_list, l->data);
break;
}
}
static void
sheet_object_realize (Sheet *sheet, SheetObject *object)
{
GList *l;
for (l = sheet->sheet_views; l; l = l->next){
SheetView *sheet_view = l->data;
GnomeCanvasItem *item;
item = sheet_view_object_realize (sheet_view, object);
sheet_view->temp_item = object;
}
}
static void
create_object (Sheet *sheet, gdouble to_x, gdouble to_y)
{
SheetObject *o = NULL;
ObjectCoords *oc;
oc = sheet->coords->data;
switch (sheet->mode){
case SHEET_MODE_CREATE_LINE:
o = sheet_object_create_line (
sheet,
oc->x, oc->y,
to_x, to_y,
"black", 1);
break;
case SHEET_MODE_CREATE_BOX:
o = sheet_object_create_filled (
sheet, SHEET_OBJECT_RECTANGLE,