]> git.tdb.fi Git - libs/gui.git/blobdiff - source/window.h
Win32 compatibility (for most things)
[libs/gui.git] / source / window.h
index 6f1f0d1e26bf5cd4db7d8c32cefe86b9bb26acc1..e85f86ac7128e522e7869d9a9faec8f5e811b7f7 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
@@ -32,33 +35,46 @@ public:
        sigc::signal<void, int, int> signal_pointer_motion;
        sigc::signal<void, unsigned, unsigned, unsigned> signal_key_press;
        sigc::signal<void, unsigned, unsigned> signal_key_release;
+       sigc::signal<void, unsigned, unsigned> signal_resize;
+       sigc::signal<void> signal_close;
 
 protected:
-       typedef ::Window Handle;
-
-       Display *display;
-       DisplayOptions options;
-       Handle  window;
+       Display &display;
+       WindowOptions options;
+       WindowHandle window;
+#ifndef WIN32
+       Atom wm_delete_window;
+#endif
 
-       Window();
 public:
-       Window(unsigned, unsigned);
-       Window(const DisplayOptions &);
-       virtual ~Window();
+       Window(Display &, unsigned w, unsigned h, bool fs=false);
+       Window(Display &, const WindowOptions &);
+       ~Window();
 
+       void set_title(const std::string &);
+       void reconfigure(const WindowOptions &);
+
+       Display &get_display() const { return display; }
+       const WindowOptions &get_options() const { return options; }
        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();
+
+#ifndef WIN32
+       void event(const XEvent &ev);
+#endif
 protected:
-       void prepare();
        void init();
-       void process_event(const XEvent &);
-
-       static int x_error_handler(Display *, XErrorEvent *);
+#ifdef WIN32
+       int wndproc(UINT, WPARAM, LPARAM);
+       static LRESULT CALLBACK wndproc_(HWND, UINT, WPARAM, LPARAM);
+#endif
 };
 
+} // namespace Graphics
 } // namespace Msp
 
 #endif