I want to draw some frames, one by one in a Gtk::DrawingArea
. At the beginning of application, I need to get the size of DrawingArea
, to allocate a RGB buffer, hewever, DrawingArea::get_width()
and DrawingArea::get_height()
return 1.
My code is based on https://developer.gnome.org/gtkmm-tutorial/stable/sec-drawing-clock-example.html.en with an extra line to get the size of DrawingArea
:
#include "clock.h"
#include <gtkmm/application.h>
#include <gtkmm/window.h>
int main(int argc, char** argv)
{
auto app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
Gtk::Window win;
win.set_title("Cairomm Clock");
Clock c;
win.add(c);
c.show();
int w = c.get_width();
// w is 1;
return app->run(win);
}
How can I get the size of DrawingArea before actually drawing into it?
I was able to trace size changes based on Scheff's comments:
Where to call
check_size
function is dependent on the design of the application. In my case I call it right beforec.queue_draw()
.