Commit 5769426d authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Bug 3289

1999-12-19  Jody Goldberg <jgoldberg@home.com>

	* src/selection.c (sheet_selection_cut) : Fix Typo.

	* src/item-bar.c (item_bar_start_resize) : Don't bother setting the
	  location of the line here.  Instead we set the correctly zoomed
	  bounds of the static-dimension.
	(item_bar_end_resize) : Clear the saved points.
	(item_bar_init) : Init the guide and points to NULL;
	(item_bar_event) : No need to call canvas to world.  We zoom manually.
	(item_bar_get_line_points) : Delete.
parent bc703438
...@@ -351,75 +351,38 @@ set_cursor (ItemBar *item_bar, int pos) ...@@ -351,75 +351,38 @@ set_cursor (ItemBar *item_bar, int pos)
gdk_window_set_cursor (canvas->window, item_bar->normal_cursor); gdk_window_set_cursor (canvas->window, item_bar->normal_cursor);
} }
/* static void
* Returns the GnomeCanvasPoints for a line at position in the item_bar_start_resize (ItemBar *bar)
* correct orientation.
*/
static GnomeCanvasPoints *
item_bar_get_line_points (GnomeCanvas *gcanvas, ItemBar *item_bar, int position)
{ {
GnomeCanvasPoints *points; Sheet const * const sheet = bar->sheet_view->sheet;
GtkWidget *canvas = GTK_WIDGET (item_bar->sheet_view->sheet_view); double const zoom = sheet->last_zoom_factor_used;
double x1, y1, x2, y2; GnumericSheet const * const gsheet = GNUMERIC_SHEET (bar->sheet_view->sheet_view);
GnomeCanvas const * const canvas = GNOME_CANVAS (gsheet);
if (item_bar->orientation == GTK_ORIENTATION_VERTICAL){ GnomeCanvasGroup * const group = GNOME_CANVAS_GROUP (canvas->root);
gnome_canvas_window_to_world GnomeCanvasPoints * const points =
(gcanvas, canvas->allocation.width, position, bar->resize_points = gnome_canvas_points_new (2);
&x2, &y2); GnomeCanvasItem * const item =
x1 = 0.0; gnome_canvas_item_new ( group,
y1 = y2; gnome_canvas_line_get_type (),
"fill_color", "black",
"width_pixels", 1,
NULL);
bar->resize_guide = GTK_OBJECT (item);
/* NOTE : Do not set the position of the line here.
* Do that later based on the motion coordinates
*/
if (bar->orientation == GTK_ORIENTATION_VERTICAL) {
points->coords [0] =
sheet_col_get_distance (sheet, 0, gsheet->left_col) / zoom;
points->coords [2] =
sheet_col_get_distance (sheet, 0, gsheet->last_visible_col+1) / zoom;
} else { } else {
gnome_canvas_window_to_world points->coords [1] =
(gcanvas, position, canvas->allocation.height, sheet_row_get_distance (sheet, 0, gsheet->top_row) / zoom;
&x2, &y2); points->coords [3] =
x1 = x2; sheet_row_get_distance (sheet, 0, gsheet->last_visible_row+1) / zoom;
y1 = 0.0;
} }
points = gnome_canvas_points_new (2);
points->coords [0] = x1;
points->coords [1] = y1;
points->coords [2] = x2;
points->coords [3] = y2;
return points;
}
static void
item_bar_start_resize (ItemBar *item_bar, int pos)
{
GnomeCanvasPoints *points;
GnomeCanvasGroup *group;
GnomeCanvasItem *item;
GnumericSheet *gsheet;
Sheet *sheet;
int division_pos;
GnomeCanvas *canvas;
sheet = item_bar->sheet_view->sheet;
gsheet = GNUMERIC_SHEET (item_bar->sheet_view->sheet_view);
canvas = GNOME_CANVAS (gsheet);
group = GNOME_CANVAS_GROUP (canvas->root);
if (item_bar->orientation == GTK_ORIENTATION_VERTICAL)
division_pos = sheet_row_get_distance (
sheet, gsheet->top_row, pos+1);
else
division_pos = sheet_col_get_distance (
sheet, gsheet->top_col, pos+1);
points = item_bar_get_line_points (canvas, item_bar, division_pos);
item = gnome_canvas_item_new (
group,
gnome_canvas_line_get_type (),
"points", points,
"fill_color", "black",
"width_pixels", 1,
NULL);
gnome_canvas_points_free (points);
item_bar->resize_guide = GTK_OBJECT (item);
} }
static int static int
...@@ -478,6 +441,10 @@ item_bar_end_resize (ItemBar *item_bar, int new_size) ...@@ -478,6 +441,10 @@ item_bar_end_resize (ItemBar *item_bar, int new_size)
item_bar_signals [SIZE_CHANGED], item_bar_signals [SIZE_CHANGED],
item_bar->resize_pos, item_bar->resize_pos,
new_size); new_size);
if (item_bar->resize_points) {
gnome_canvas_points_free (item_bar->resize_points);
item_bar->resize_points = NULL;
}
if (item_bar->resize_guide) { if (item_bar->resize_guide) {
gtk_object_destroy (item_bar->resize_guide); gtk_object_destroy (item_bar->resize_guide);
item_bar->resize_guide = NULL; item_bar->resize_guide = NULL;
...@@ -490,43 +457,45 @@ item_bar_end_resize (ItemBar *item_bar, int new_size) ...@@ -490,43 +457,45 @@ item_bar_end_resize (ItemBar *item_bar, int new_size)
item_bar->resize_pos = -1; item_bar->resize_pos = -1;
} }
#define convert(c,sx,sy,x,y) gnome_canvas_w2c (c,sx,sy,x,y)
static gint static gint
item_bar_event (GnomeCanvasItem *item, GdkEvent *e) item_bar_event (GnomeCanvasItem *item, GdkEvent *e)
{ {
ColRowInfo *cri; ColRowInfo *cri;
GnomeCanvas *canvas = item->canvas; GnomeCanvas * const canvas = item->canvas;
ItemBar *item_bar = ITEM_BAR (item); ItemBar * const item_bar = ITEM_BAR (item);
int pos, start, element, x, y; Sheet * const sheet = item_bar->sheet_view->sheet;
double const zoom = sheet->last_zoom_factor_used;
const gboolean resizing = ITEM_BAR_RESIZING (item_bar); const gboolean resizing = ITEM_BAR_RESIZING (item_bar);
const gboolean is_vertical = (item_bar->orientation == GTK_ORIENTATION_VERTICAL); const gboolean is_vertical = (item_bar->orientation == GTK_ORIENTATION_VERTICAL);
int pos, start, element;
/* NOTE :
* No need to map coordinates since we do the zooming of the item bars manually
* there is no transform needed.
*/
switch (e->type){ switch (e->type){
case GDK_ENTER_NOTIFY: case GDK_ENTER_NOTIFY:
convert (canvas, e->crossing.x, e->crossing.y, &x, &y);
if (is_vertical) if (is_vertical)
pos = y; pos = e->crossing.y;
else else
pos = x; pos = e->crossing.x;
set_cursor (item_bar, pos); set_cursor (item_bar, pos);
break; break;
case GDK_MOTION_NOTIFY: case GDK_MOTION_NOTIFY:
convert (canvas, e->motion.x, e->motion.y, &x, &y);
if (is_vertical) if (is_vertical)
pos = y; pos = e->motion.y;
else else
pos = x; pos = e->motion.x;
/* Do column resizing or incremental marking */ /* Do column resizing or incremental marking */
if (resizing){ if (resizing){
GnomeCanvasPoints *points;
GnomeCanvasItem *resize_guide; GnomeCanvasItem *resize_guide;
GnomeCanvasPoints *points;
int npos; int npos;
if (item_bar->resize_guide == NULL){ if (item_bar->resize_guide == NULL) {
item_bar_start_resize (item_bar, item_bar->resize_pos); item_bar_start_resize (item_bar);
gnome_canvas_item_grab (item, gnome_canvas_item_grab (item,
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK, GDK_BUTTON_RELEASE_MASK,
...@@ -542,11 +511,14 @@ item_bar_event (GnomeCanvasItem *item, GdkEvent *e) ...@@ -542,11 +511,14 @@ item_bar_event (GnomeCanvasItem *item, GdkEvent *e)
colrow_tip_setlabel (item_bar, is_vertical, item_bar->resize_width); colrow_tip_setlabel (item_bar, is_vertical, item_bar->resize_width);
resize_guide = GNOME_CANVAS_ITEM (item_bar->resize_guide); resize_guide = GNOME_CANVAS_ITEM (item_bar->resize_guide);
points = item_bar->resize_points;
points = item_bar_get_line_points (canvas, item_bar, pos); if (is_vertical)
points->coords [1] = points->coords [3] = pos / zoom;
else
points->coords [0] = points->coords [2] = pos / zoom;
gnome_canvas_item_set (resize_guide, "points", points, NULL); gnome_canvas_item_set (resize_guide, "points", points, NULL);
gnome_canvas_points_free (points);
/* Redraw the ItemBar to show nice incremental progress */ /* Redraw the ItemBar to show nice incremental progress */
gnome_canvas_request_redraw ( gnome_canvas_request_redraw (
...@@ -570,11 +542,10 @@ item_bar_event (GnomeCanvasItem *item, GdkEvent *e) ...@@ -570,11 +542,10 @@ item_bar_event (GnomeCanvasItem *item, GdkEvent *e)
break; break;
case GDK_BUTTON_PRESS: case GDK_BUTTON_PRESS:
convert (canvas, e->button.x, e->button.y, &x, &y);
if (is_vertical) if (is_vertical)
pos = y; pos = e->button.y;
else else
pos = x; pos = e->button.x;
cri = is_pointer_on_division (item_bar, pos, &start, &element); cri = is_pointer_on_division (item_bar, pos, &start, &element);
...@@ -587,8 +558,6 @@ item_bar_event (GnomeCanvasItem *item, GdkEvent *e) ...@@ -587,8 +558,6 @@ item_bar_event (GnomeCanvasItem *item, GdkEvent *e)
} }
if (e->button.button == 3) { if (e->button.button == 3) {
Sheet *sheet = item_bar->sheet_view->sheet;
/* If the selection does not contain the current row/col /* If the selection does not contain the current row/col
* then clear the selection and add it. * then clear the selection and add it.
*/ */
...@@ -694,6 +663,8 @@ item_bar_init (ItemBar *item_bar) ...@@ -694,6 +663,8 @@ item_bar_init (ItemBar *item_bar)
item_bar->tip = NULL; item_bar->tip = NULL;
item_bar->normal_font = NULL; item_bar->normal_font = NULL;
item_bar->bold_font = NULL; item_bar->bold_font = NULL;
item_bar->resize_guide = NULL;
item_bar->resize_points = NULL;
} }
static void static void
......
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