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

Rename currentWorkbook to current_workbook, so that it follows the style


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

	* src/main.c (main): Rename currentWorkbook to current_workbook,
	so that it follows the style of the rest of my code ;-)

	* src/item-cursor.c (item_cursor_init): Add a timeout handler for
	drawing the anted animation.
	(item_cursor_set_bounds): Setup the Canvas Item bounding box when
	the bounds of the cursor change.

	* src/gnumeric-sheet.c (start_cell_selection): Create the
	selection cursor at the same position the regular cursor is.

	(gnumeric_sheet_init): Share colors between items and the canvas.
parent 18db3f14
1998-07-27 <miguel@nuclecu.unam.mx>
* src/main.c (main): Rename currentWorkbook to current_workbook,
so that it follows the style of the rest of my code ;-)
* src/item-cursor.c (item_cursor_init): Add a timeout handler for
drawing the anted animation.
(item_cursor_set_bounds): Setup the Canvas Item bounding box when
the bounds of the cursor change.
* src/gnumeric-sheet.c (start_cell_selection): Create the
selection cursor at the same position the regular cursor is.
(gnumeric_sheet_init): Share colors between items and the canvas.
Sun Jul 26 17:39:53 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* configure.in: added GNOME_XML_CHECK
......
1998-07-27 <miguel@nuclecu.unam.mx>
* src/main.c (main): Rename currentWorkbook to current_workbook,
so that it follows the style of the rest of my code ;-)
* src/item-cursor.c (item_cursor_init): Add a timeout handler for
drawing the anted animation.
(item_cursor_set_bounds): Setup the Canvas Item bounding box when
the bounds of the cursor change.
* src/gnumeric-sheet.c (start_cell_selection): Create the
selection cursor at the same position the regular cursor is.
(gnumeric_sheet_init): Share colors between items and the canvas.
Sun Jul 26 17:39:53 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* configure.in: added GNOME_XML_CHECK
......
1998-07-27 <miguel@nuclecu.unam.mx>
* src/main.c (main): Rename currentWorkbook to current_workbook,
so that it follows the style of the rest of my code ;-)
* src/item-cursor.c (item_cursor_init): Add a timeout handler for
drawing the anted animation.
(item_cursor_set_bounds): Setup the Canvas Item bounding box when
the bounds of the cursor change.
* src/gnumeric-sheet.c (start_cell_selection): Create the
selection cursor at the same position the regular cursor is.
(gnumeric_sheet_init): Share colors between items and the canvas.
Sun Jul 26 17:39:53 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* configure.in: added GNOME_XML_CHECK
......
1998-07-27 <miguel@nuclecu.unam.mx>
* src/main.c (main): Rename currentWorkbook to current_workbook,
so that it follows the style of the rest of my code ;-)
* src/item-cursor.c (item_cursor_init): Add a timeout handler for
drawing the anted animation.
(item_cursor_set_bounds): Setup the Canvas Item bounding box when
the bounds of the cursor change.
* src/gnumeric-sheet.c (start_cell_selection): Create the
selection cursor at the same position the regular cursor is.
(gnumeric_sheet_init): Share colors between items and the canvas.
Sun Jul 26 17:39:53 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* configure.in: added GNOME_XML_CHECK
......
......@@ -10,6 +10,7 @@ INCLUDES = \
-I$(includedir) \
$(GNOME_INCLUDEDIR)
GNOME_XML_LIB = -lxml
GNUMERIC_BASE_SOURCES = \
cell.h \
......
......@@ -17,6 +17,8 @@
static GnomeCanvasClass *sheet_parent_class;
GdkColor gs_white, gs_black, gs_light_gray, gs_dark_gray;
static void
gnumeric_sheet_destroy (GtkObject *object)
{
......@@ -291,7 +293,12 @@ start_cell_selection (GnumericSheet *gsheet)
"Sheet", gsheet->sheet,
"Grid", gsheet->item_grid,
"Style", ITEM_CURSOR_ANTED, NULL));
item_cursor_set_bounds (ITEM_CURSOR (gsheet->selection),
gsheet->item_cursor->start_col,
gsheet->item_cursor->start_row,
gsheet->item_cursor->end_col,
gsheet->item_cursor->end_row);
gsheet->sel_cursor_pos = GTK_EDITABLE (gsheet->entry)->current_pos;
gsheet->sel_text_len = 0;
}
......@@ -470,8 +477,9 @@ gnumeric_sheet_key (GtkWidget *widget, GdkEventKey *event)
void (*movefn_vertical) (GnumericSheet *, int);
int cursor_move = gnumeric_sheet_can_move_cursor (sheet);
printf ("%d\n", cursor_move);
printf ("cursor_moving=%d\n", cursor_move);
if ((event->state & GDK_SHIFT_MASK) != 0){
printf ("SHIFT!\n");
if (cursor_move){
printf ("Selection exand!\n");
movefn_horizontal = selection_expand_horizontal;
......@@ -490,6 +498,18 @@ gnumeric_sheet_key (GtkWidget *widget, GdkEventKey *event)
}
}
/* Ignore a few keys (to avoid the selection cursor to be killed
* in some cases
*/
if (cursor_move){
switch (event->keyval){
case GDK_Shift_L: case GDK_Shift_R:
case GDK_Alt_L: case GDK_Alt_R:
case GDK_Control_L: case GDK_Control_R:
return 1;
}
}
switch (event->keyval){
case GDK_Left:
(*movefn_horizontal)(sheet, -1);
......@@ -660,9 +680,25 @@ static void
gnumeric_sheet_init (GnumericSheet *gsheet)
{
GnomeCanvas *canvas = GNOME_CANVAS (gsheet);
GTK_WIDGET_SET_FLAGS (canvas, GTK_CAN_FOCUS);
GTK_WIDGET_SET_FLAGS (canvas, GTK_CAN_DEFAULT);
}
void
gnumeric_sheet_color_alloc (GnomeCanvas *canvas)
{
static int colors_loaded;
if (colors_loaded)
return;
gdk_color_white (canvas->colormap, &gs_white);
gdk_color_black (canvas->colormap, &gs_black);
gnome_canvas_get_color (canvas, "gray60", &gs_light_gray);
gnome_canvas_get_color (canvas, "gray20", &gs_dark_gray);
colors_loaded = 1;
}
GtkType
......
......@@ -46,6 +46,10 @@ void gnumeric_sheet_load_cell_val (GnumericSheet *gsheet);
void gnumeric_sheet_accept_pending_output (GnumericSheet *sheet);
void gnumeric_sheet_compute_visible_ranges (GnumericSheet *gsheet);
void gnumeric_sheet_set_current_value (GnumericSheet *sheet);
void gnumeric_sheet_color_alloc (GnomeCanvas *canvas);
/* Colors used by any GnumericSheet item */
extern GdkColor gs_white, gs_light_gray, gs_dark_gray, gs_black;
typedef struct {
GnomeCanvasClass parent_class;
......
......@@ -17,6 +17,8 @@
static GnomeCanvasClass *sheet_parent_class;
GdkColor gs_white, gs_black, gs_light_gray, gs_dark_gray;
static void
gnumeric_sheet_destroy (GtkObject *object)
{
......@@ -291,7 +293,12 @@ start_cell_selection (GnumericSheet *gsheet)
"Sheet", gsheet->sheet,
"Grid", gsheet->item_grid,
"Style", ITEM_CURSOR_ANTED, NULL));
item_cursor_set_bounds (ITEM_CURSOR (gsheet->selection),
gsheet->item_cursor->start_col,
gsheet->item_cursor->start_row,
gsheet->item_cursor->end_col,
gsheet->item_cursor->end_row);
gsheet->sel_cursor_pos = GTK_EDITABLE (gsheet->entry)->current_pos;
gsheet->sel_text_len = 0;
}
......@@ -470,8 +477,9 @@ gnumeric_sheet_key (GtkWidget *widget, GdkEventKey *event)
void (*movefn_vertical) (GnumericSheet *, int);
int cursor_move = gnumeric_sheet_can_move_cursor (sheet);
printf ("%d\n", cursor_move);
printf ("cursor_moving=%d\n", cursor_move);
if ((event->state & GDK_SHIFT_MASK) != 0){
printf ("SHIFT!\n");
if (cursor_move){
printf ("Selection exand!\n");
movefn_horizontal = selection_expand_horizontal;
......@@ -490,6 +498,18 @@ gnumeric_sheet_key (GtkWidget *widget, GdkEventKey *event)
}
}
/* Ignore a few keys (to avoid the selection cursor to be killed
* in some cases
*/
if (cursor_move){
switch (event->keyval){
case GDK_Shift_L: case GDK_Shift_R:
case GDK_Alt_L: case GDK_Alt_R:
case GDK_Control_L: case GDK_Control_R:
return 1;
}
}
switch (event->keyval){
case GDK_Left:
(*movefn_horizontal)(sheet, -1);
......@@ -660,9 +680,25 @@ static void
gnumeric_sheet_init (GnumericSheet *gsheet)
{
GnomeCanvas *canvas = GNOME_CANVAS (gsheet);
GTK_WIDGET_SET_FLAGS (canvas, GTK_CAN_FOCUS);
GTK_WIDGET_SET_FLAGS (canvas, GTK_CAN_DEFAULT);
}
void
gnumeric_sheet_color_alloc (GnomeCanvas *canvas)
{
static int colors_loaded;
if (colors_loaded)
return;
gdk_color_white (canvas->colormap, &gs_white);
gdk_color_black (canvas->colormap, &gs_black);
gnome_canvas_get_color (canvas, "gray60", &gs_light_gray);
gnome_canvas_get_color (canvas, "gray20", &gs_dark_gray);
colors_loaded = 1;
}
GtkType
......
......@@ -46,6 +46,10 @@ void gnumeric_sheet_load_cell_val (GnumericSheet *gsheet);
void gnumeric_sheet_accept_pending_output (GnumericSheet *sheet);
void gnumeric_sheet_compute_visible_ranges (GnumericSheet *gsheet);
void gnumeric_sheet_set_current_value (GnumericSheet *sheet);
void gnumeric_sheet_color_alloc (GnomeCanvas *canvas);
/* Colors used by any GnumericSheet item */
extern GdkColor gs_white, gs_light_gray, gs_dark_gray, gs_black;
typedef struct {
GnomeCanvasClass parent_class;
......
......@@ -13,10 +13,12 @@
#include "item-grid.h"
#include "item-cursor.h"
#include "item-debug.h"
#include "gnumeric-sheet.h"
static GdkColor black, white;
static GnomeCanvasItem *item_cursor_parent_class;
static void item_cursor_request_redraw (ItemCursor *item_cursor);
/* The argument we take */
enum {
ARG_0,
......@@ -25,6 +27,31 @@ enum {
ARG_STYLE /* The style type */
};
static void
item_cursor_animation_callback (ItemCursor *item_cursor)
{
item_cursor->state = !item_cursor->state;
item_cursor_request_redraw (item_cursor);
}
static void
item_cursor_stop_animation (ItemCursor *item_cursor)
{
if (item_cursor->tag == -1)
return;
gtk_timeout_remove (item_cursor->tag);
item_cursor->tag = -1;
}
static void
item_cursor_start_animation (ItemCursor *item_cursor)
{
item_cursor->tag = gtk_timeout_add (
300, (GtkFunction)(item_cursor_animation_callback),
item_cursor);
}
static void
item_cursor_destroy (GtkObject *object)
{
......@@ -32,6 +59,7 @@ item_cursor_destroy (GtkObject *object)
item_cursor = ITEM_CURSOR (object);
item_cursor_stop_animation (item_cursor);
if (GTK_OBJECT_CLASS (item_cursor_parent_class)->destroy)
(*GTK_OBJECT_CLASS (item_cursor_parent_class)->destroy)(object);
}
......@@ -48,10 +76,10 @@ item_cursor_realize (GnomeCanvasItem *item)
gc = item_cursor->gc = gdk_gc_new (window);
gdk_color_black (item->canvas->colormap, &black);
gdk_color_white (item->canvas->colormap, &white);
gdk_gc_set_foreground (gc, &black);
gdk_gc_set_background (gc, &white);
gnumeric_sheet_color_alloc (item->canvas);
if (item_cursor->style == ITEM_CURSOR_ANTED)
item_cursor_start_animation (item_cursor);
}
static void
......@@ -93,6 +121,7 @@ item_cursor_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, in
GdkPoint points [40];
int draw_external, draw_internal, draw_handle, draw_center;
int premove;
GdkColor *fore = NULL, *back = NULL;
item_cursor_get_pixel_coords (item_cursor, &xd, &yd,
&cursor_width, &cursor_height);
......@@ -120,6 +149,13 @@ item_cursor_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, in
draw_handle = 0;
draw_center = 1;
draw_external = 0;
if (item_cursor->state){
fore = &gs_light_gray;
back = &gs_dark_gray;
} else {
fore = &gs_dark_gray;
back = &gs_light_gray;
}
};
if (draw_handle)
......@@ -129,6 +165,8 @@ item_cursor_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, in
gdk_gc_set_line_attributes (item_cursor->gc, 1,
GDK_LINE_SOLID, -1, -1);
gdk_gc_set_foreground (item_cursor->gc, &gs_black);
gdk_gc_set_background (item_cursor->gc, &gs_white);
if (draw_external){
points [0].x = dx + cursor_width + 1;
points [0].y = dy + cursor_height + 1 - premove;
......@@ -175,12 +213,13 @@ item_cursor_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, in
}
if (draw_center){
gdk_gc_set_foreground (item_cursor->gc, fore);
gdk_gc_set_background (item_cursor->gc, back);
gdk_gc_set_line_attributes (item_cursor->gc, 1,
GDK_LINE_DOUBLE_DASH, -1, -1);
gdk_draw_rectangle (drawable, item_cursor->gc, FALSE,
dx, dy,
dx + cursor_width, dy + cursor_height);
cursor_width, cursor_height);
}
}
......@@ -191,24 +230,40 @@ item_cursor_request_redraw (ItemCursor *item_cursor)
int x, y, w, h;
item_cursor_get_pixel_coords (item_cursor, &x, &y, &w, &h);
#if 0
printf ("Requesting redraw: %d %d %d %d\n",
x - 2, y - 2, x + w + 5, y + h + 5);
#endif
gnome_canvas_request_redraw (canvas, x - 2, y - 2, x + w + 5, y + h + 5);
}
void
item_cursor_set_bounds (ItemCursor *item_cursor, int start_col, int start_row, int end_col, int end_row)
{
GnomeCanvasItem *item;
int x, y, w, h;
g_return_if_fail (start_col <= end_col);
g_return_if_fail (start_row <= end_row);
g_return_if_fail (item_cursor != NULL);
g_return_if_fail (IS_ITEM_CURSOR (item_cursor));
item = GNOME_CANVAS_ITEM (item_cursor);
item_cursor_request_redraw (item_cursor);
printf ("BOUNDS: %d,%d %d,%d\n", start_col, start_row, end_col, end_row);
item_cursor->start_col = start_col;
item_cursor->end_col = end_col;
item_cursor->start_row = start_row;
item_cursor->end_row = end_row;
item_cursor_request_redraw (item_cursor);
item_cursor_get_pixel_coords (item_cursor, &x, &y, &w, &h);
item->x1 = x - 1;
item->y1 = y - 1;
item->x2 = x + w + 1;
item->y2 = y + h + 1;
gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item);
}
static double
......@@ -249,6 +304,7 @@ item_cursor_init (ItemCursor *item_cursor)
item_cursor->start_row = 0;
item_cursor->end_row = 0;
item_cursor->start_row = ITEM_CURSOR_SELECTION;
item_cursor->tag = -1;
}
static void
......
......@@ -21,7 +21,8 @@ typedef struct {
ItemCursorStyle style;
GdkGC *gc;
GdkColor black;
int state;
int tag;
} ItemCursor;
GtkType item_cursor_get_type (void);
......
......@@ -6,6 +6,7 @@
#include "item-edit.h"
#include "item-debug.h"
#define CURSOR_LEN 4
static GnomeCanvasItem *item_edit_parent_class;
/* The arguments we take */
......@@ -41,6 +42,7 @@ item_edit_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
GtkWidget *canvas = GTK_WIDGET (item->canvas);
ItemEdit *item_edit = ITEM_EDIT (item);
GdkFont *font;
ColRowInfo *ci;
int xd, yd, wd, hd, dx, dy;
char *text;
int cursor_pos, text_len, first_part_len, total_len;
......@@ -52,9 +54,13 @@ item_edit_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
total_len = gdk_text_width (font, text, text_len);
ci = sheet_col_get_info (item_edit->sheet, item_edit->col);
total_len += ci->margin_a + ci->margin_b + CURSOR_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);
......
......@@ -33,17 +33,6 @@ item_grid_destroy (GtkObject *object)
(*GTK_OBJECT_CLASS (item_grid_parent_class)->destroy)(object);
}
static GdkColor
color_alloc (GnomeCanvas *canvas, char *color_name)
{
GdkColor color;
color.pixel = 0;
gnome_canvas_get_color (canvas, color_name, &color);
return color;
}
static void
item_grid_realize (GnomeCanvasItem *item)
{
......@@ -62,10 +51,12 @@ item_grid_realize (GnomeCanvasItem *item)
gdk_gc_set_line_attributes (gc, 1, GDK_LINE_SOLID,
GDK_CAP_PROJECTING, GDK_JOIN_MITER);
gnumeric_sheet_color_alloc (item->canvas);
/* Allocate the default colors */
item_grid->background = color_alloc (item->canvas, "white");
item_grid->grid_color = color_alloc (item->canvas, "gray60");
item_grid->default_color = color_alloc (item->canvas, "black");
item_grid->background = gs_white;
item_grid->grid_color = gs_light_gray;
item_grid->default_color = gs_black;
gdk_gc_set_foreground (gc, &item_grid->grid_color);
gdk_gc_set_background (gc, &item_grid->background);
......
......@@ -10,8 +10,8 @@ main (int argc, char *argv [])
style_init ();
symbol_init ();
currentWorkbook = workbook_new_with_sheets (1);
gtk_widget_show (currentWorkbook->toplevel);
current_workbook = workbook_new_with_sheets (1);
gtk_widget_show (current_workbook->toplevel);
gtk_main ();
......
......@@ -10,8 +10,8 @@ main (int argc, char *argv [])
style_init ();
symbol_init ();
currentWorkbook = workbook_new_with_sheets (1);
gtk_widget_show (currentWorkbook->toplevel);
current_workbook = workbook_new_with_sheets (1);
gtk_widget_show (current_workbook->toplevel);
gtk_main ();
......
......@@ -151,5 +151,5 @@ Sheet *workbook_get_current_sheet (Workbook *wb);
*/
void workbook_realized (Workbook *, GdkWindow *);
extern Workbook *currentWorkbook;
extern Workbook *current_workbook;
#endif
......@@ -11,7 +11,7 @@
#define WB_COLS 1
Workbook *currentWorkbook;
Workbook *current_workbook;
static void
quit_cmd (void)
......@@ -22,7 +22,7 @@ quit_cmd (void)
static void
save_cmd (void)
{
gnumericWriteXmlWorkbook(currentWorkbook, "default.wb");
gnumericWriteXmlWorkbook (current_workbook, "default.wb");
}
static GnomeUIInfo workbook_menu_file [] = {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment