]> git.tdb.fi Git - libs/gui.git/blobdiff - source/window.h
Redesign and refactor
[libs/gui.git] / source / window.h
index a8ad867cca9acac780cf3f34535d69c21df286b1..1047038366917854f776f22fae72de60e87ad480 100644 (file)
@@ -9,19 +9,22 @@ Distributed under the LGPL
 #define MSP_GBASE_WINDOW_H_
 
 #include <string>
-#include <X11/Xlib.h>
 #include <sigc++/signal.h>
+#include "types.h"
 
 namespace Msp {
+namespace Graphics {
 
-struct DisplayOptions
+class Display;
+
+struct WindowOptions
 {
-       std::string display;
        unsigned width;
        unsigned height;
        bool fullscreen;
+       bool resizable;
 
-       DisplayOptions();
+       WindowOptions();
 };
 
 class Window
@@ -36,36 +39,31 @@ public:
        sigc::signal<void> signal_close;
 
 protected:
-       typedef ::Window Handle;
-
-       Display *display;
-       DisplayOptions options;
-       Handle  window;
-       Atom    wm_delete_window;
+       Display &display;
+       WindowOptions options;
+       WindowHandle window;
+       Atom wm_delete_window;
 
-       Window();
 public:
-       Window(unsigned w, unsigned h);
-       Window(const DisplayOptions &dopt);
-       virtual ~Window();
+       Window(Display &, unsigned w, unsigned h, bool fs=false);
+       Window(Display &, const WindowOptions &);
+       ~Window();
 
        void set_title(const std::string &);
 
        unsigned get_width() const  { return options.width; }
        unsigned get_height() const { return options.height; }
+       WindowHandle get_handle() const { return window; }
+
        void show();
        void hide();
-       void tick();
+
+       void event(const XEvent &ev);
 protected:
-       void prepare();
-       void set_window(Handle wnd);
        void init();
-       void process_event(const XEvent &event);
-       virtual void on_event(const XEvent &event) { (void)event; }
-
-       static int x_error_handler(Display *, XErrorEvent *);
 };
 
+} // namespace Graphics
 } // namespace Msp
 
 #endif