Scrolling DrawingArea [was: Re: Adding a signal to an exixting widget]
- From: Stefano Salvi <stefano salvi mn it>
- To: Murray Cumming <murrayc murrayc com>
- Cc: gtkmm-list <gtkmm-list gnome org>
- Subject: Scrolling DrawingArea [was: Re: Adding a signal to an exixting widget]
- Date: Thu, 18 Aug 2005 16:40:40 +0200
Murray Cumming wrote:
On Tue, 2005-08-16 at 12:33 +0200, Stefano Salvi wrote:
I'm using gtkmm-2.6 from Sarge.
I need a "scrollable DrawingArea" to insert into a ScrolledWindow widget.
To get the adjustmets to scroll it I need to add the
signal_set_scroll_adjustments signal to my widget.
I added the SignalProxy with this declaration:
The SignalProxy is for wrapping C GTK+ signals and should never be used
directly. You would normally just patch gtkmm to patch the new/missing
signal.
However, this "set_scroll_adjustments" thing seems to be some strange
special case:
http://developer.gnome.org/doc/API/2.0/gtk/GtkWidget.html#GtkWidgetClass
The "ScrolledWindow" is a nice container to ad scrollbars to another widget.
It's primary working method is to take a great object and show only a
part of it. This is rather inefficent for large objects that require a
large amount of time or other operations to render.
Another method is used if a widget is "scroll capable". In this case,
this container gives the scrollable widgets a couple of adjustments to
position itself.
To know if a widget is "scrolling capable", the ScrolledWindow widget
(GtkScrolledWindow) checks a field present in EVERY WIDGET CLASS that is
"guint set_scroll_adjustments_signal;". This int keeps the signal ID of
the signal to set the scrollbars, if the widget is scrollable, and 0
otherwise.
GtkScrolledWindow tests this class field (and GtkMM ScrolledWindow class
does the same) to know if a widget is scrollable.
I think this is not a corrct programming choice, as you cannot extend an
existing widget (say a DrawingArea or a VBox) to add scroll capabilities
to it, but it's not Gtkmm-related, but Dtk+-related.
In conclusion, to solve the problem I had to:
- create a new GTK widget, derived from GtkDrawingArea, adding the
"scrolling capabilities" to it (copying extensively from GtlLayout Widget)
- modify my original class to be a wrapper of this new widget
I know this is not a straight way, but it's the only I was able to
figure out (and actually it works).
If you are interested in some (not very clean) piece of code, ask.
Thank you
Stefano Salvi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]