Re: Scroll to widget?
- From: API <apinheiro igalia com>
- To: lfrench1 gmu edu
- Cc: gtk-list gnome org
- Subject: Re: Scroll to widget?
- Date: Fri, 21 Aug 2009 10:28:07 +0200 (CEST)
From: Lindley M French <lfrench1 gmu edu>
> I've got a GtkScrolledWindow which contains an hbox that in turn contains a number of other widgets, and each of those widgets has an ability to become "active" in some sense.
>
> What I'd like to do is arrange things so that when a particular widget becomes active, the ScrolledWindow is adjusted to ensure that the active widget is entirely visible (assuming it's small enough of course).
>
> This means that I need to get the position of the widget in ScrolledWindow->bin_window coordinates, as I understand it. But I can't figure out which combination of functions I need to do this.
>
> Any help?
GtkWidgets has already support for center on focused objects (I hope
that your "active" means that).
The implementation of this feature are related with this functions and
signals:
http://library.gnome.org/devel/gtk/stable/GtkWidget.html#gtk-widget-child-focus
http://library.gnome.org/devel/gtk/stable/GtkContainer.html#gtk-container-get-focus-child
http://library.gnome.org/devel/gtk/stable/GtkContainer.html#GtkContainer-set-focus-child
Anyway, as you are using a common GtkScrolledWindow, probably you only
require to use the function:
http://library.gnome.org/devel/gtk/stable/GtkContainer.html#gtk-container-set-focus-vadjustment
LibgnomeUI has a example. It has a GtkScrolledWindow, and inside a
hbox with several buttons. Each time you click on the button, the
scrolled window centers on it.
The example is libgnomeui-2.24.1/test-gnome/testgnome.c
(I got the code using "apt-get source libgnomeui", so probably you can too)
I hope this helps.
BR
===
API (apinheiro igalia com)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]