3
votes

I am making a GUI program using "gtkmm". I would like to draw some graphics to the "Gtk::DrawingArea" widget but I want that widget to be "resizable", so when I draw let's say a line from "(0, 0)" to "(50, 50)" pixel - the drawing area should be resized to a square of size "(50, 50)"; and when I for example draw a line from "(0, 0)" to let's say "(100, 70)" pixel - the drawing area should be resized to a rectangle of size "(100, 70)".

And to do this - I put the "Gtk::DrawingArea" widget into the "Gtk::ScrolledWindow" container.

So when I put a picture with size "(100, 100)" to the drawing area -> I will call the appropriate member function "Gtk::DrawingArea::set___size_request(100, 100)", which will set the size of the drawing area to (100, 100) pixels. So if the "Gtk::ScrolledWindow" is "smaller" than the "Gtk::DrawingArea" inside it, the scrolled window should change to "scrollable" - BUT THE PROBLEM IS, THAT IT DOES NOT WORK!!!!!

So could anybody explain me how can I do this?

Thanks.

2

2 Answers

4
votes

Add a GTK::Viewport in between your ScrolledWindow and DrawingArea.

2
votes

If anyone is still searching an answer to this, there is a way to do this without Gtk::Viewport, by using this function

Gtk::DrawingArea::set_size_request(width,height);