Re: Manipulating viewport in scrolled window



Hi Simon, 

gtk_adjustment_set_value() just emits the "value_changed" signal, so objects
listening for stuff on this adjustment will only look to see if the value field
has altered.

You've altered a bunch of stuff, so you need the full "changed" signal. I'd do:

	adj->lower = small;
	adj->upper = big - window_size; // is this is right?
	adj->page_size = window_size;
	adj->value = small + (big - small) / 2 - window_size / 2;
	gtk_adjustment_changed( adj );

You obviously need to do this after you connected everything up.

John

Simon Gornall wrote:
> 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);




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