3

(C language, GTK library)

On my form, I have a GtkDrawingArea widget on which I draw GdkPixbufs (loaded from files) with Cairo. What I'd like to accomplish is to be able to scroll the drawing area with scrollbars while window size remains fixed (the image drawn is larger than the window). How can I do that? Putting GtkDrawingArea in ScrolledWindow container didn't work (or maybe I have done something wrong - I'm new to GTK).

The simpler solution the better. Cheers!

Clueless
  • 605
  • 3
  • 10
  • 19

1 Answers1

4

Some widgets don't have scrolling capability. GtkDrawingArea is one of them. You can adapt these widgets by putting them first inside a GtkViewport then into a GtkScrolledWindow In versions before GTK 3.8 gtk_scrolled_window_add_with_viewport is a convenience method to do this.

In later versions it is done automatically by gtk_container_add.

ptomato
  • 56,175
  • 13
  • 112
  • 165
  • Thanks for the answer. Another problem is that the size of my GtkDrawingArea (or rather GdkPixbuf drawn on it?) changes during the work of my application, "area for scrollbars" should change its size appropriately as well. How should this be handled? Vertical/horizontal adjustments (of vieport or scrolled window)? – Clueless Jan 06 '12 at 21:49
  • Change the size request of the scrolled window. But please make sure to open a new question if you have another question - that way, other people with the same problem will be able to find it and be helped too. – ptomato Jan 07 '12 at 09:04