Gtkmm - “Gtk::DrawingArea” in “Gtk::ScrolledWindow”?

雨燕双飞 提交于 2019-12-10 10:16:23

问题


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.


回答1:


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




回答2:


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);   


来源:https://stackoverflow.com/questions/1588866/gtkmm-gtkdrawingarea-in-gtkscrolledwindow

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!