Advertisement
tattersail

Lines_window.cpp

Apr 13th, 2019
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. #include "Lines_window.h"
  2. namespace Graph_lib {
  3. Lines_window::Lines_window(Point xy, int w, int h, const string & title) :
  4. Window{ xy,w,h,title },
  5. next_button{ Point{x_max() - 150,0},70,20,"Next point",
  6. cb_next },
  7. quit_button{ Point{x_max() - 70,0},70,20,"Quit", cb_quit},
  8. next_x{ Point{x_max() - 310,0},50,20,"next x:" },
  9. next_y{ Point{x_max() - 210,0},50,20,"next y:" },
  10. xy_out{ Point{100,0},100,20,"current(x,y):" },
  11. color_menu{ Point{x_max() - 70,40},70,20,Menu::vertical,"color" },
  12. menu_button{ Point{x_max() - 80,30},80,20,"color menu", cb_menu }
  13. {
  14. attach(next_button);
  15. attach(quit_button);
  16. attach(next_x);
  17. attach(next_y);
  18. attach(xy_out);
  19. xy_out.put("no point");
  20. color_menu.attach(new Button{ Point{0,0},0,0,"red",cb_red });
  21. color_menu.attach(new Button{ Point{0,0},0,0,"blue",cb_blue });
  22. color_menu.attach(new Button{ Point{0,0},0,0,"black",cb_black });
  23. attach(color_menu);
  24. color_menu.hide();
  25. attach(menu_button);
  26. attach(lines);
  27. }
  28.  
  29. void Lines_window::next()
  30. {
  31. int x = next_x.get_int();
  32. int y = next_y.get_int();
  33. lines.add(Graph_lib::Point{ x,y });
  34.  
  35. //update current position readout:
  36. ostringstream ss;
  37. ss << '(' << x << ',' << y << ')';
  38. xy_out.put(ss.str());
  39.  
  40. redraw();
  41. }
  42. void Lines_window::cb_next(Address, Address pw) { reference_to<Lines_window>(pw).next(); };
  43. void Lines_window::cb_quit(Address, Address pw) { reference_to<Lines_window>(pw).quit(); };
  44. void Lines_window::cb_menu(Address, Address pw) { reference_to<Lines_window>(pw).menu_pressed(); };
  45. void Lines_window::cb_red(Address, Address pw) { reference_to<Lines_window>(pw).red_pressed(); };
  46. void Lines_window::cb_blue(Address, Address pw) { reference_to<Lines_window>(pw).blue_pressed(); };
  47. void Lines_window::cb_black(Address, Address pw) { reference_to<Lines_window>(pw).black_pressed(); };
  48.  
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement