#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
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;
+#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 create();
void init();
- void process_event(const XEvent &);
- virtual void on_resize() { }
-
- 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