#ifndef MY_DRAWING_AREA #define MY_DRAWING_AREA #include #include #include "MyWindow.h" class MyDrawingArea: public Gtk::DrawingArea { public: MyDrawingArea(BaseObjectType* cobject, const Glib::RefPtr& builder); virtual ~MyDrawingArea(); void drawRectangle( MyWindow::Colour, int x, int y, int width, int height ); // Colour of rectangle, coordinates of upper-left corner, width and height of rectangle void drawText( int x, int y, std::string msg ); // Message to write, and position of upper-left corner. private: virtual bool on_draw(const Cairo::RefPtr& cr); struct RGB { int r,g,b; RGB(int r = 0, int g = 0, int b = 0 ); }; struct Rectangle { MyWindow::Colour c; // colour of filled rectangle int x, y; // position of upper-left corner int width, height; // width and height Rectangle( MyWindow::Colour c, int x, int y, int width, int height ); }; struct Message { int x, y; std::string msg; Message( int x, int y, std::string msg ); }; static std::vector colours; // set of RGB values static void createColours(); // initializes RGB values for the enumerated colours unsigned int index( MyWindow::Colour ); // returns the index value associated with the Colour void draw_rectangle( const Cairo::RefPtr& cr, MyWindow::Colour c, int x, int y, int width, int height ); void draw_text( const Cairo::RefPtr& cr, int x, int y, const std::string & s ); Glib::RefPtr builder_; std::vector rectangles; // rectangles to draw std::vector messages; // messages to draw }; #endif