Re: Scrolling Drawing Area

Subhankar Chakraborty wrote:
> I have a drawing area within a ScrolledWindow. I want to scroll the 
> drawing area appropriately whenever my mouse pointer moves out of the 
> boundary of the enclosing window. That is, I want to scroll the drawing 
> area such that the user may get to see a coordinate of the darea (if it 
> is not already visible within the window) when the mouse moves out of 
> the main window in the appropriate direction.
> I just don't know how to go about it. I mean, how do I know whether a 
> point of the drawing area is visible to the user, within the window ?? 
> And, how do I scroll the darea to have the point in the middle of the 
> window ???

Hi, I do this in my app:

- listen to "changed" on the horizontal and vertical GtkAdjustments
   for the scrolled window to get the current position and size of
   the part of the drawing area which is visible

- during a drag with a mouse button pressed, check the mouse position
   against the viewport and set flags for "mouse is to right of
   viewport", or whatever

- have a background thing running (on a gtk_timeout) which looks at the
   flags and scrolls the drawingarea (by setting values for the
   adjustments) if necessary

works OK for me,


Fabric of Vision 
Dress and Drapery in Painting 

19 June - 8 September 2002 

For information and tickets:

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]