Advertisement
bhattigurjot

drawing_in_gtkmm

Jul 14th, 2014
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. bool DrawingArea::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
  2. {
  3. cr->set_source_rgb(1.0, 1.0, 1.0); // white background
  4. cr->paint();
  5.  
  6. cr->set_line_width(2.0);
  7.  
  8. if(entity == 1) // draw point
  9. {
  10. cr->set_source_rgb(0.0, 0.26, 0.26);
  11. cr->save();
  12. cr->arc(205.0, 110.0, 1.0, 0.0, 2 * M_PI); // full circle
  13. cr->restore();
  14. cr->stroke();
  15. }
  16.  
  17. if(entity == 2) // draw line
  18. {
  19. cr->set_source_rgb(0.0, 0.26, 0.26);
  20. cr->save();
  21. cr->move_to(0,0);
  22. cr->line_to(100,100);
  23. cr->restore();
  24. cr->stroke();
  25. }
  26. return true;
  27. }
  28.  
  29. void DrawingArea :: on_point_cb()
  30. {
  31. entity = 1;
  32. queue_draw();
  33. std::cout<<"Point created"<<std::endl;
  34. }
  35.  
  36. void DrawingArea :: on_line_cb()
  37. {
  38. entity = 2;
  39. queue_draw();
  40. std::cout<<"Line created"<<std::endl;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement