Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool DrawingArea::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
- {
- cr->set_source_rgb(1.0, 1.0, 1.0); // white background
- cr->paint();
- cr->set_line_width(2.0);
- if(entity == 1) // draw point
- {
- cr->set_source_rgb(0.0, 0.26, 0.26);
- cr->save();
- cr->arc(205.0, 110.0, 1.0, 0.0, 2 * M_PI); // full circle
- cr->restore();
- cr->stroke();
- }
- if(entity == 2) // draw line
- {
- cr->set_source_rgb(0.0, 0.26, 0.26);
- cr->save();
- cr->move_to(0,0);
- cr->line_to(100,100);
- cr->restore();
- cr->stroke();
- }
- return true;
- }
- void DrawingArea :: on_point_cb()
- {
- entity = 1;
- queue_draw();
- std::cout<<"Point created"<<std::endl;
- }
- void DrawingArea :: on_line_cb()
- {
- entity = 2;
- queue_draw();
- std::cout<<"Line created"<<std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement