Hi,
i've updated my patch. The autoscrolling now works like Jeffrey has
suggested it. You must leave the canvas with the mouse, to scroll. The
scroll-amount depends on the distance between the mouse-pointer and the
border of the canvas. Because i think that not only the modify-tool
should enable autoscrolling,
i've added a function gboolean ddisplay_autoscroll(ddisp* ddsp, int x,
int y) in which you pass in the coordinates of the mouse-pointer. If the
mouse-pointer is outside the canvas, the canvas is scrolled and the
function returns TRUE. Otherwise it returns FALSE.
I've only added a call to the function in the file modify_tool.c .
The patch is attached to this mail, it's adiff from the lastest CVS.
Matthias
--
Adresse : Matthias K�ster, Alexanderstr.388, 26127 Oldenburg
Tel. : 0441/6835359
eMail : [EMAIL PROTECTED]
--- dia/app/display.h Thu Jan 14 15:34:27 1999
+++ display.h Fri Jan 29 19:55:27 1999
@@ -52,6 +52,8 @@
Grid grid; /* the grid in this display */
+ gboolean autoscroll;
+
RendererGdk *renderer;
GSList *update_areas; /* Update areas list */
@@ -101,9 +103,12 @@
extern void ddisplay_set_all_cursor(GdkCursor *cursor);
extern void ddisplay_scroll(DDisplay *ddisp, Point *delta);
+extern gboolean ddisplay_autoscroll(DDisplay *ddisp, int x, int y);
extern void ddisplay_scroll_up(DDisplay *ddisp);
extern void ddisplay_scroll_down(DDisplay *ddisp);
extern void ddisplay_scroll_left(DDisplay *ddisp);
extern void ddisplay_scroll_right(DDisplay *ddisp);
#endif /* DDISPLAY_H */
+
+
--- dia/app/display.c Mon Jan 25 14:24:12 1999
+++ display.c Fri Jan 29 19:55:29 1999
@@ -67,7 +67,9 @@
ddisp->grid.dialog = NULL;
ddisp->grid.entry_x = NULL;
ddisp->grid.entry_y = NULL;
-
+
+ ddisp->autoscroll = TRUE;
+
ddisp->renderer = NULL;
ddisp->update_areas = NULL;
@@ -427,6 +429,54 @@
ddisplay_update_scrollbars(ddisp);
ddisplay_add_update_all(ddisp);
ddisplay_flush(ddisp);
+}
+
+gboolean
+ddisplay_autoscroll(DDisplay *ddisp, int x, int y)
+{
+ guint16 width, height;
+ Point scroll;
+
+ if (! ddisp->autoscroll)
+ return FALSE;
+
+ scroll.x = scroll.y = 0;
+
+ width = GTK_WIDGET(ddisp->canvas)->allocation.width;
+ height = GTK_WIDGET(ddisp->canvas)->allocation.height;
+
+ if (x < 0)
+ {
+ scroll.x = x;
+ }
+ else if ( x > width)
+ {
+ scroll.x = x - width;
+ }
+
+ if (y < 0)
+ {
+ scroll.y = y;
+ }
+ else if (y > height)
+ {
+ scroll.y = y - height;
+ }
+
+ if ((scroll.x != 0) || (scroll.y != 0))
+ {
+ scroll.x = ddisplay_untransform_length(ddisp, scroll.x);
+ scroll.y = ddisplay_untransform_length(ddisp, scroll.y);
+
+ ddisplay_scroll(ddisp, &scroll);
+ ddisplay_flush(ddisp);
+
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
}
void ddisplay_scroll(DDisplay *ddisp, Point *delta)
--- dia/app/modify_tool.c Wed Jan 27 21:45:01 1999
+++ modify_tool.c Fri Jan 29 19:55:29 1999
@@ -266,10 +266,13 @@
{
Point to;
Point now, delta;
+ gboolean auto_scroll;
ConnectionPoint *connectionpoint;
if (tool->state==STATE_NONE)
return; /* Fast path... */
+
+ auto_scroll = ddisplay_autoscroll(ddisp, event->x, event->y);
ddisplay_untransform_coords(ddisp, event->x, event->y, &to.x, &to.y);
@@ -322,13 +325,16 @@
diagram_flush(ddisp->diagram);
break;
case STATE_BOX_SELECT:
-
- gdk_draw_rectangle (ddisp->renderer->pixmap, tool->gc, FALSE,
- tool->x1, tool->y1,
- tool->x2 - tool->x1, tool->y2 - tool->y1);
- ddisplay_add_display_area(ddisp,
- tool->x1-1, tool->y1-1,
- tool->x2+1, tool->y2+1);
+
+ if (! auto_scroll)
+ {
+ gdk_draw_rectangle (ddisp->renderer->pixmap, tool->gc, FALSE,
+ tool->x1, tool->y1,
+ tool->x2 - tool->x1, tool->y2 - tool->y1);
+ ddisplay_add_display_area(ddisp,
+ tool->x1-1, tool->y1-1,
+ tool->x2+1, tool->y2+1);
+ }
tool->end_box = to;