DragonOsman

Window.h

Mar 17th, 2017
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. #ifndef WINDOW_GUARD
  2. #define WINDOW_GUARD 1
  3.  
  4. #include "fltk.h"
  5.  
  6. #include "std_lib_facilities.h"
  7.  
  8. #include "Point.h"
  9. //#include "GUI.h"
  10.  
  11. namespace Graph_lib {
  12.  
  13.     class Shape;    // "forward declare" Shape
  14.     class Widget;
  15.  
  16.     class Window : public Fl_Window {
  17.     public:
  18.         Window(int w, int h, const string& title);          // let the system pick the location
  19.         Window(Point xy, int w, int h, const string& title);    // top left corner in xy
  20.         virtual ~Window() { }
  21.  
  22.         int x_max() const { return w; }
  23.         int y_max() const { return h; }
  24.  
  25.         void resize(int ww, int hh) { w = ww, h = hh; size(ww, hh); }
  26.  
  27.         void set_label(const string& s) { label(s.c_str()); }
  28.  
  29.         void attach(Shape& s);
  30.         void attach(Widget& w);
  31.  
  32.         void detach(Shape& s);  // remove s from shapes
  33.         void detach(Widget& w); // remove w from window (deactivate callbacks)
  34.  
  35.         void put_on_top(Shape& p);  // put p on top of other shapes
  36.  
  37.     protected:
  38.         void draw();
  39.  
  40.     private:
  41.         vector<Shape*> shapes;  // shapes attached to window
  42.         int w, h;                   // window size
  43.  
  44.         void init();
  45.     };
  46.  
  47.     int gui_main(); // invoke GUI library's main event loop
  48.  
  49.     inline int x_max() { return Fl::w(); }  // width of screen in pixels
  50.     inline int y_max() { return Fl::h(); }  // height of screen in pixels
  51.  
  52. }
  53. #endif
Advertisement
Add Comment
Please, Sign In to add comment