Scrollable large GdkWindows in GTK+ 2.0 - confusion!



Hi all,

Could somebody help me to understand the meaning of this intriguing quote:

"This means that you can implement scrolling by simply creating a huge
GdkWindow and calling gdk_window_scroll() to move it around.
gdk_window_scroll() will perform a fast, flicker-free scroll. Look at
GtkTextView and GtkTreeView for example code."
 -- from Malcolm Tredinnick's porting guide for GNOME 2.0

I am trying to build a scrollable widget with a 'header' window and a
'bin' window, to sit inside a GtkScrolledWindow, following the design of
GtkTreeView.

I took the above quote to mean that I can create a huge bin GdkWindow
inside my small widget->window and then use gdk_window_scroll to change
its position. However, the expose events this generates are in on-screen
rather than 'virtual' coordinates, so I have to convert them to something
useful by maintaining x and y bin offsets. Furthermore, I can't use GDK
drawing primitives in the 'off-screen' coordinates, but must convert
buffer coordinates back into on-screen coordinates first.

It all seems to work fine - but my question is: what's the point of having
a large theoretical GdkWindow at all? It doesn't give me transparent
access to those coordinates, gdk_window_scroll uses relative coordinates
anyway, and in fact my code works exactly the same whether I make the
window huge or just the same size as widget->window.

I feel like I must be missing something, but have only been able to find
brief mention of this feature on the mailing lists and in FAQs. I'd be
grateful for any explanatory comments!

Perhaps I am expecting too much of this low-level API, but the quote I
pasted above seems to suggest there is some useful help GdkWindow can
offer me. Note that I can't use GnomeCanvas in this instance - I need full
control over the display.

Thanks in advance,


James.




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