Newbie seeks advice (mixing text, widgets, images on a scrollable canvas)



Hello everybody,

I am trying to learn GTK by perusing the reference manuals and the mailing
list archives -- and so far so good -- but now I have hit upon a stumbling
block that I don't know how to overcome. Frankly, I don't even know how to
approach the problem in a GTK friendly fashion, so I am at a bit of a loss
as to how to proceed here and am hoping some of the weathered veterans are
willing to help me out.

Basically, the application I am trying to write is a browser. That means I
need to render text, images and form elements onto some kind of canvas, and
have the entire canvas be scrollable. What I am ultimately looking for is
the best way to implement this using GTK, but I'll first explain where my
current hackish implementation breaks down.

Right now, I am using a GtkFixed container widget as my canvas. Text is
drawn directly onto the GtkFixed container widget and I add form elements
using gtk_fixed_put().

The first problem is that I get into endless redraw loops:

1. I get a "draw" signal for the GtkFixed widget.
2. I draw some text.
3. I add a form element and show it.
4. This triggers another "draw" signal on the GtkFixed widget.
5. Go to 1.

What would be the best solution to avoid this loop? Should I render the text
onto a pixmap and use that as the background for the GtkFixed widget? Should
I subclass GtkFixed? Should I write my own widget alltogether?

The second problem concerns scrolling. Currently, the GtkFixed widget is
inside a GtkViewport, which is inside a GtkScrolledWindow. What I would
really like to do is to get rid of the GtkViewport and implement scrolling
natively in the GtkFixed container widget, but I do not understand how to do
this. Is it necessary to write my own widget? And if so, do I have to start
from scratch or is GtkFixed a good place to start at?

Any advice/hints/help/pointers/tips would be greatly appreciated.

TIA!




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