Scrolling DrawingArea [was: Re: Adding a signal to an exixting widget]

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

However, this "set_scroll_adjustments" thing seems to be some strange
special case:
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]