Manipulating viewport in scrolled window



Hi Guys,

I'm having a bit of trouble getting my scrolled window to "home in"
on the centre of the background drawing area when it first starts
up.

I'm using the fragment of code below (I've tried several variations,
but this is the best result I've found) but it seems to move the
scrollbars but not the viewport (?) 

The symptoms are that the scrollbars move, but the backgrouns is
black (which is what it would be if the scrollbars were at (0,0).
If I slightly move a scrollbar with the mouse, it all appears
properly.

Presumably I have to tell the window to redraw after I set the
value (but I would have thought gtk_adjustment_set_value would
send the correct signal anyway)

Anyway, here's the snippet of code:

/**********************************************************************\
|* centre the drawing area
\***********************************************************************/
GtkAdjustment *adj;
adj = gtk_scrolled_window_get_hadjustment((GtkScrolledWindow *)mapWin);
adj->lower = 0.0;
adj->upper = _map.w;
adj->page_size = 800;
gtk_adjustment_set_value(adj,(adj->upper + adj->lower
-adj->page_size)/2);
adj = gtk_scrolled_window_get_vadjustment((GtkScrolledWindow *)mapWin);
adj->lower = 0.0;
adj->upper = _map.h;
adj->page_size = 600;
gtk_adjustment_set_value(adj,(adj->upper + adj->lower
-adj->page_size)/2);


One other thing is that I noticed a post from (presumably) one
of the maintainers saying the best drawing speed would be
obtained by simply having a large drawing area behind a scrolled
window in GTK1.4. I'm currently using 1.2.9 - is that fast-draw
code already in the development/CVS version of gtk anywhere ?

Cheers,
	Simon.




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