Commit 918eefa6 authored by Jody Goldberg's avatar Jody Goldberg

- Fix a draw problem with the item-bar.

- Add hooks for correct scroll wheel support.  Will not be possible
  until there is a workbook-view.
parent e4c9204e
2000-02-01 Jody Goldberg <jgoldberg@home.com>
* src/item-bar.c (item_bar_draw) : Fix minor fence-post drawing
glitch.
(bar_draw_cell) : Apply a clipping region to ensure that title strings
do not overlap when sizes are small.
* src/workbook.h : Remove bogus ';' from comments.
Bug 5717.
2000-01-31 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/dialogs/dialog-solver.c, src/dialogs/solver.glade,
......
......@@ -20,6 +20,7 @@ Jody:
* Row/Col header redraw improvements.
* Zoom enhancement/fixing.
* More work on undo.
* Parse interbook references.
Jon:
* Cursor fixes and speedups.
......
2000-02-01 Jody Goldberg <jgoldberg@home.com>
* src/item-bar.c (item_bar_draw) : Fix minor fence-post drawing
glitch.
(bar_draw_cell) : Apply a clipping region to ensure that title strings
do not overlap when sizes are small.
* src/workbook.h : Remove bogus ';' from comments.
Bug 5717.
2000-01-31 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/dialogs/dialog-solver.c, src/dialogs/solver.glade,
......
......@@ -15,6 +15,7 @@
#include "dialogs.h"
#include "workbook.h"
#include "func.h"
#include "ranges.h"
#define OK 0
......
......@@ -168,9 +168,7 @@ get_row_name (int n)
static void
bar_draw_cell (ItemBar const * const item_bar,
GdkDrawable *drawable, ItemBarSelectionType const type,
char const * const str,
int const x, int const y,
int const width, int const height)
char const * const str, GdkRectangle * rect)
{
GtkWidget *canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (item_bar)->canvas);
GdkFont *font;
......@@ -201,12 +199,13 @@ bar_draw_cell (ItemBar const * const item_bar,
len = gdk_string_width (font, str);
texth = font->ascent + font->descent;
gdk_draw_rectangle (drawable, gc, TRUE, x + 1, y + 1, width-2, height-2);
gdk_gc_set_clip_rectangle (gc, rect);
gdk_draw_rectangle (drawable, gc, TRUE, rect->x + 1, rect->y + 1, rect->width-2, rect->height-2);
gtk_draw_shadow (canvas->style, drawable, GTK_STATE_NORMAL, shadow,
x, y, width, height);
rect->x, rect->y, rect->width, rect->height);
gdk_draw_string (drawable, font, item_bar->gc,
x + (width - len) / 2,
y + (height - texth) / 2 + font->ascent,
rect->x + (rect->width - len) / 2,
rect->y + (rect->height - texth) / 2 + font->ascent,
str);
}
......@@ -216,13 +215,34 @@ item_bar_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int w
ItemBar const * const item_bar = ITEM_BAR (item);
Sheet const * const sheet = item_bar->sheet_view->sheet;
GnumericSheet const * const gsheet = GNUMERIC_SHEET (item_bar->sheet_view->sheet_view);
GtkWidget *canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (item)->canvas);
int pixels;
GdkRectangle rect;
if (item_bar->orientation == GTK_ORIENTATION_VERTICAL) {
int const real_width = GTK_WIDGET (item->canvas)->allocation.width;
/* Include a 1 pixel buffer.
* To avoid overlaping the cells the shared pixel belongs to the cell above.
* This has the nice property that the bottom dark line of the
* shadow aligns with the grid lines.
* Unfortunately it also implies a 1 pixel empty space at the
* top of the bar. Which we are forced to fill in with
* something. For now I draw a black line there to be
* compatible with the default colour used on the bottom of the
* cell shadows.
*/
int total = 1 + gsheet->row_offset.first - y;
int element = gsheet->row.first;
int total = gsheet->row_offset.first - y;
rect.x = -x;
rect.width = canvas->allocation.width;
/* FIXME : How to avoid hard coding this color ?
* We need the color that will be drawn as the bottom bevel
* for the button shadow
*/
gdk_draw_line (drawable, canvas->style->black_gc,
rect.x, total-1,
rect.x + rect.width, total-1);
do {
if (element >= SHEET_MAX_ROWS)
return;
......@@ -237,19 +257,30 @@ item_bar_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int w
total += pixels;
if (total >= 0) {
char const * const str = get_row_name (element);
rect.y = total - pixels;
rect.height = pixels;
bar_draw_cell (item_bar, drawable,
sheet_row_selection_type (sheet, element),
str,
-x, 1 + total - pixels,
real_width, pixels);
str, &rect);
}
}
++element;
} while (total < height);
} else {
int const real_height = GTK_WIDGET (item->canvas)->allocation.height;
/* See comment above for explaination of the extra 1 pixel */
int total = 1 + gsheet->col_offset.first - x;
int element = gsheet->col.first;
int total = gsheet->col_offset.first - x;
rect.y = -y;
rect.height = canvas->allocation.height;
/* FIXME : How to avoid hard coding this color ?
* We need the color that will be drawn as the right bevel
* for the button shadow
*/
gdk_draw_line (drawable, canvas->style->black_gc,
total-1, rect.y,
total-1, rect.y + rect.height);
do {
if (element >= SHEET_MAX_COLS)
......@@ -263,12 +294,13 @@ item_bar_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int w
if (pixels > 0) {
total += pixels;
if (total >= 0)
if (total >= 0) {
rect.x = total - pixels;
rect.width = pixels;
bar_draw_cell (item_bar, drawable,
sheet_col_selection_type (sheet, element),
col_name (element),
1 + total - pixels, -y,
pixels, real_height);
col_name (element), &rect);
}
}
++element;
......
......@@ -1094,7 +1094,7 @@ item_grid_event (GnomeCanvasItem *item, GdkEvent *event)
row = MIN (gsheet->row.last_full , SHEET_MAX_ROWS-1);
gnumeric_sheet_set_top_row (gsheet, row);
}
return TRUE;
return FALSE;
default:
return FALSE;
......@@ -1179,7 +1179,7 @@ item_grid_event (GnomeCanvasItem *item, GdkEvent *event)
event->motion.y = 0;
sheet_selection_extend_to (sheet, col, row);
return 1;
return TRUE;
case GDK_BUTTON_PRESS:
sheet_set_mode_type (sheet, SHEET_MODE_SHEET);
......@@ -1203,14 +1203,17 @@ item_grid_event (GnomeCanvasItem *item, GdkEvent *event)
item_grid_popup_menu (sheet,
event, col, row,
FALSE, FALSE);
return 1;
return TRUE;
default :
return FALSE;
}
default:
return 0;
return FALSE;
}
return 0;
return FALSE;
}
/*
......
......@@ -58,13 +58,13 @@ struct _Workbook {
GtkObject gtk_object;
#endif
/* { Start view specific elements */;
/* { Start view specific elements */
GtkWidget *toplevel;
GtkWidget *notebook;
/* Edit area */
GtkWidget *ea_input;
/* } End view specific elements */;
/* } End view specific elements */
char *filename;
gboolean needs_name;
......
......@@ -91,11 +91,13 @@ workbook_view_set_size (Workbook const * const wb,
int const screen_width = gdk_screen_width ();
int const screen_height = gdk_screen_height ();
#if 0
printf ("%dx%d mm, %dx%d pixels\n",
gdk_screen_width_mm (),
gdk_screen_height_mm (),
gdk_screen_width (),
gdk_screen_height ());
#endif
gtk_window_set_default_size (GTK_WINDOW (wb->toplevel),
MIN (screen_width - 64, width_in_points),
MIN (screen_height - 64, height_in_points));
......
......@@ -2128,6 +2128,23 @@ workbook_create_toolbars (Workbook *wb)
gtk_widget_show (wb->priv->format_toolbar);
}
static gboolean
cb_scroll_wheel_support (GtkWidget *w, GdkEventButton *event, Workbook *wb)
{
/* This is a stub routine to handle scroll wheel events
* Unfortunately the toplevel window is currently owned by the workbook
* rather than a workbook-view so we can not really scroll things
* unless we scrolled al lthe views at once which is ugly.
*/
#if 0
if (event->button == 4)
puts("up");
else if (event->button == 5)
puts("down");
#endif
return FALSE;
}
/**
* workbook_new:
*
......@@ -2244,6 +2261,10 @@ workbook_new (void)
/* clipboard setup */
x_clipboard_bind_workbook (wb);
gtk_signal_connect (GTK_OBJECT (wb->toplevel), "button-release-event",
GTK_SIGNAL_FUNC (cb_scroll_wheel_support),
wb);
gtk_widget_show_all (wb->priv->table);
return wb;
......
......@@ -58,13 +58,13 @@ struct _Workbook {
GtkObject gtk_object;
#endif
/* { Start view specific elements */;
/* { Start view specific elements */
GtkWidget *toplevel;
GtkWidget *notebook;
/* Edit area */
GtkWidget *ea_input;
/* } End view specific elements */;
/* } End view specific elements */
char *filename;
gboolean needs_name;
......
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