custom DrawingArea and glade



I am not certain if this should be a gtkmm or Glade question but I am
hoping that someone here can answer this.  I wanted to make a custom
widget similar to the clock in the example at
http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/sec-drawing-clock-example.html
With this example, leaning how was easy.  I like to use Glade for making
the gui and I was able to figure out two different ways to include the
Clock class into a sample Glade project.

1. add DrawingArea widget in Glade
   in hello::hello
     get_widget("draw1", draw1);
     clock1->signal_expose_event().connect( sigc::mem_fun(*this, &hello::on_clock1_expose_event ));
   in hello::on_clock1_expose_event
     use example code to draw the clock onto draw1

2. no DrawingArea widget in Glade
   use Clock class from example
   in hello::hello
     clock1 = new Clock();
     clock1->set_size_request(80, 80);
     main_vbox->put(*clock1, 183, 363);
     clock1->show();
   in Clock::on_expose_event
     use example code to draw the clock

Both methods work well but I would like to combine the methods.  I
want to have the custom Clock class as in method 2 but I also want
to be able to use Glade to place the DrawingArea on the window.  Would
this require adding the Clock widget to Glade or could I put a
DrawingArea in Glade and somehow tie what I get from get_widget
to my instance of the Clock class?

Damon Register


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