Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Bartosz Pokorski
- //281814
- #include <graph.h>
- #include <GUI.h>
- #include <string>
- #include <iostream>
- #include <sstream>
- #include <fstream>
- using namespace Graph_lib;
- void cb_close (Address addr1, Address pWnd);
- class myWindow;
- struct myButton : Button
- {
- myWindow* pMyWindow;
- myButton(Point xy, int w, int h, const string& label, Callback cb, myWindow* pMyWin) : Button(xy, w,h, label, cb),
- pMyWindow(pMyWin)
- {}
- void attach(Graph_lib::Window& wnd)
- {
- Button::attach(wnd);
- pw -> callback(reinterpret_cast<Fl_Callback*>(do_it),pMyWindow);
- }
- Address getWigdetAddress() const { return pw; }
- };
- //class Spinner
- //{
- //private:
- //
- // myButton btn_down;
- // myButton btn_left;
- // myButton btn_right;
- // myButton btn_up;
- //
- // Graph_lib::Out_box positionBox;
- // Point position;
- // static const int crs_size = 5;
- //
- // Lines crosshair;
- // Graph_lib::Window *pWnd = nullptr;
- //
- //
- // static void cb_down (Address pWidget, Address pSpin)
- // {
- // ((Spinner*)pSpin)->changePositionY(crs_size);
- // }
- //
- //
- //
- // static void cb_right (Address pWidget, Address pSpin)
- // {
- // ((Spinner*)pSpin)->changePositionX(crs_size);
- // }
- //
- // static void cb_up (Address pWidget, Address pSpin)
- // {
- // ((Spinner*)pSpin)->changePositionY(-crs_size);
- // }
- //
- //
- // void changePositionX(int Step)
- // {
- // if ((position.x > 5 && position.x < 595))
- // {
- // position.x += Step;
- // }
- //
- // positionBox.put(position.x);
- // pWnd->detach(crosshair);
- // crosshair.move(position.x, position.y);
- //
- // crosshair.add(Point(position.x - crs_size, position.y), Point(position.x + crs_size, position.y));
- // crosshair.add(Point(position.x, position.y - crs_size), Point(position.x, position.y + crs_size));
- // pWnd->attach(crosshair);
- // pWnd->redraw();
- //
- // }
- //
- // void changePositionY(int Step)
- // {
- // if ((position.y > 5 && position.y < 395))
- // {
- // position.y += Step;
- // }
- //
- // positionBox.put(position.y);
- // pWnd->detach(crosshair);
- // crosshair.move(position.x, position.y);
- //
- // crosshair.add(Point(position.x - crs_size, position.y), Point(position.x + crs_size, position.y));
- // crosshair.add(Point(position.x, position.y - crs_size), Point(position.x, position.y + crs_size));
- //
- //
- // pWnd->attach(crosshair);
- // pWnd->redraw();
- //
- // }
- //
- //
- //public:
- // Spinner(Point loc, Point startPoint, Color spinColor)
- // : btn_down(loc, 20, 20, "\\/", Spinner::cb_down, this),
- // btn_left(Point(loc.x + 25, loc.y), 20, 20, "<", Spinner::cb_left,this),
- // btn_right(Point(loc.x + 125, loc.y), 20, 20, ">", Spinner::cb_right, this),
- // btn_up(Point(loc.x + 150, loc.y), 20, 20, "/\\", Spinner::cb_up, this),
- // positionBox(Point(loc.x + 50, loc.y), 70, 20, ""),
- // position(startPoint),
- // crosshair()
- // {
- // crosshair.add(Point(position.x - crs_size, position.y), Point(position.x + crs_size, position.y));
- // crosshair.add(Point(position.x, position.y - crs_size), Point(position.x, position.y + crs_size));
- // crosshair.set_color(spinColor);
- // }
- //
- //
- //
- // void attachTo(Graph_lib::Window& wnd)
- // {
- // wnd.attach(btn_down);
- // wnd.attach(btn_left);
- // wnd.attach(btn_right);
- // wnd.attach(btn_up);
- // wnd.attach(positionBox);
- // positionBox.put(position.x);
- // positionBox.put(position.y);
- //
- // wnd.attach(crosshair);
- // pWnd = &wnd;
- // }
- //};
- class DrawingArea
- {
- Graph_lib::Point AnotherPoint;
- public:
- DrawingArea(Point loc, Point AnotherPoint): {}
- };
- //static void cb_left (Address pWidget, Address pSpin)
- // {
- // ((Spinner*)pSpin)->changePositionX(-crs_size);
- // }
- class myWindow : public Graph_lib::Window
- {
- Graph_lib::Button btn_close, Graph_lib::Button btn_save;
- bool drawingNow;
- DrawingArea canvas;
- Point start, stop;
- Graph_lib::Rectangle *pRect;
- std::vector<shape *> shapes;
- ofstream myFile;
- Graph_lib::Window *pWnd = nullptr;
- static void cb_close(Address pWidget, Address pMyWin)
- {
- ((Graph_lib::Window *)pMyWin) -> hide();
- }
- static void cb_save(Address pWidget, Address pMyWin)
- {
- ((myWindow*)pMyWin->saving());
- }
- void saving(ofstream SavingFiles)
- {
- myFile.open ("Plik.txt");
- myFile.close();
- return myFile;
- }
- public:
- myWindow(Point loc, int w, int h, std::string title) :
- Graph_lib::Window(loc, w, h, title),
- btn_close(Point(x_max() - 80, y_max() - 20), 80, 20,
- "Close", myWindow::cb_close),
- btn_save(Point(x_max() - 80, y_max() - 50), 80, 20,
- "Save", myWindow::cb_save),
- drawingNow(false),
- canvas(Point(10,10), Point(x_max() - 100, y_max() - 10)),
- start(0, 0), stop(0, 0), pRect(nullptr)
- {
- attach(btn_close);
- attach(btn_save);
- }
- };
- main()
- {
- Graph_lib::Window wnd(Point(100, 100), 600, 400, "Bartosz Pokorski (281814)");
- Button btn(Point(wnd.x_max() - 80, wnd.y_max() - 20), 80, 20, "Close", cb_close);
- wnd.attach(btn);
- Spinner crsRed(Point(wnd.x_max() - 170, 10), Point(200, 200), Color::red);
- crsRed.attachTo(wnd);
- Spinner crsBlue(Point(wnd.x_max() - 170, 40),Point(220, 200), Color::blue);
- crsBlue.attachTo(wnd);
- gui_main();
- return 0;
- }
- //void cb_close (Address addr1, Address addr2)
- //{
- // cout << "addr1: "<< addr1 << endl;
- // cout << "addr2: " <<addr2 << endl;
- // cout << "close pressed\n";
- //// btn_close.move(100, -100);
- // ((Graph_lib::Window *)addr2) -> hide();
- //}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement