美文网首页
21.5 开放多线段

21.5 开放多线段

作者: Jianbaozi | 来源:发表于2019-04-11 16:07 被阅读0次
    Annotation 2019-04-15 223227.png
    #include <iostream>
    #include <sstream>
    #include "Graph.h"
    #include "GUI.h"
    #include "Simple_Window.h"
    #include "GUI.h"
    #include "Window.h"
    struct Lines_window :Window {
        Lines_window(Point xy, int w, int h, const string& title);
        Open_polyline lines;
    private:
        Button next_button;
        Button quit_button;
        In_box next_x;
        In_box next_y;
        Out_box xy_out;
        void next();
        void quit();
    };
    Lines_window::Lines_window(Point xy, int w, int h, const string& title) :
      Window{ xy,w,h,title },
    next_button{ Point{x_max() - 150,0 },70,20,"Next Point",
      [](Address,Address pw) {reference_to<Lines_window>(pw).next(); } },
    quit_button{ Point{x_max() - 70,0},70,20,"Quit",
      [](Address,Address pw) {reference_to<Lines_window>(pw).quit(); } },
    next_x{ Point{x_max() - 310,0},50,20,"next x:" },
    next_y{ Point{x_max() - 210,0},50,20,"next y:" },
    xy_out{ Point{100,0},100,20,"current(x,y):" }{
        attach(next_button);
        attach(quit_button);
        attach(next_x);
        attach(next_y);
        attach(xy_out);
        attach(lines);
    }
    void Lines_window::next() {
        int x = next_x.get_int();
        int y = next_y.get_int();
        lines.add(Point{ x,y });
        lines.set_style(Line_style{ Line_style::solid,2 });//不改一下线粗根本看不出来效果
        lines.set_color(Color::dark_green);
        stringstream ss;
        ss << '(' << x << ',' << y << ')';
        xy_out.put(ss.str());
        redraw();
    }
    void Lines_window::quit() {
        hide();
    }
    int main() {
            Lines_window win(Point(100, 100), 600, 400, "lines");
            return gui_main();
    }
    
    

    相关文章

      网友评论

          本文标题:21.5 开放多线段

          本文链接:https://www.haomeiwen.com/subject/maztwqtx.html