On the GTKmm first documentation example and on the more complex clock example, they are inhering the public Gtk::DrawingArea
to build they application.
#ifndef GTKMM_EXAMPLE_MYAREA_H
#define GTKMM_EXAMPLE_MYAREA_H
#include <gtkmm/drawingarea.h>
class MyArea : public Gtk::DrawingArea
{
public:
MyArea();
virtual ~MyArea();
protected:
//Override default signal handler:
bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr) override;
};
#endif // GTKMM_EXAMPLE_MYAREA_H
Is possible to use the DrawingArea
by composition, instead of inheriting it and overriding the on_draw
virtual method?
I would like to do so, to not mix my methods/attributes with the DrawingArea
methods inherited from the base class Gtk::DrawingArea
. Therefore, when I am accessing something, I know explicitly I am using something on my creation, because there are only my stuff on my class definition. While by inheriting stuff from Gtk::DrawingArea
, I cannot be sure whether it is my stuff or Gtk::DrawingArea
stuff, unless I know everything which is defined on Gtk::DrawingArea
.