2013-11-06 22:52:00 +01:00
|
|
|
#ifndef GLARE_WINDOW_H
|
|
|
|
#define GLARE_WINDOW_H
|
|
|
|
|
|
|
|
#include <Windows.h>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
|
|
class WindowShell
|
|
|
|
{
|
|
|
|
public:
|
2013-12-04 15:59:44 +01:00
|
|
|
struct WINDOW_INIT_DESC
|
2013-11-06 22:52:00 +01:00
|
|
|
{
|
|
|
|
HINSTANCE hInstance;
|
|
|
|
std::wstring windowName;
|
2013-12-04 15:59:44 +01:00
|
|
|
POINT windowSize;
|
|
|
|
POINT windowPosition;
|
2013-11-06 22:52:00 +01:00
|
|
|
WNDPROC windowProcCallback;
|
2013-12-04 15:59:44 +01:00
|
|
|
UINT windowClassStyle;
|
|
|
|
UINT windowStyle;
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-12-04 15:59:44 +01:00
|
|
|
WINDOW_INIT_DESC()
|
2013-11-06 22:52:00 +01:00
|
|
|
{
|
|
|
|
hInstance = NULL;
|
2013-12-04 15:59:44 +01:00
|
|
|
windowName = L"MADAFACKA";
|
2013-11-06 22:52:00 +01:00
|
|
|
windowSize.x = 800;
|
|
|
|
windowSize.y = 600;
|
|
|
|
windowPosition.x = 0;
|
|
|
|
windowPosition.y = 0;
|
|
|
|
windowProcCallback = NULL;
|
2013-12-04 15:59:44 +01:00
|
|
|
windowClassStyle = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
|
|
|
windowStyle = WS_OVERLAPPEDWINDOW;
|
2013-11-06 22:52:00 +01:00
|
|
|
}
|
|
|
|
};
|
2013-12-04 15:59:44 +01:00
|
|
|
struct CHILD_WINDOW_INIT_DESC
|
2013-11-06 22:52:00 +01:00
|
|
|
{
|
|
|
|
std::wstring name;
|
|
|
|
DWORD style;
|
2013-12-04 15:59:44 +01:00
|
|
|
POINT topLeftPos;
|
|
|
|
POINT windowSize;
|
2013-11-06 22:52:00 +01:00
|
|
|
WNDPROC windowProcCallback;
|
|
|
|
|
2013-12-04 15:59:44 +01:00
|
|
|
CHILD_WINDOW_INIT_DESC()
|
2013-11-06 22:52:00 +01:00
|
|
|
{
|
|
|
|
name = L"Child Window";
|
|
|
|
style = WS_CHILD;
|
2013-12-04 15:59:44 +01:00
|
|
|
memset(&topLeftPos, 0, sizeof(POINT));
|
2013-11-06 22:52:00 +01:00
|
|
|
windowSize.x = 300;
|
|
|
|
windowSize.y = 200;
|
|
|
|
windowProcCallback = NULL;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
WindowShell ();
|
|
|
|
WindowShell (const WindowShell&);
|
|
|
|
void operator= (const WindowShell&);
|
|
|
|
virtual~WindowShell ();
|
|
|
|
|
|
|
|
public:
|
|
|
|
const HINSTANCE getHINSTANCE () const;
|
|
|
|
/* Returns NULL if no hwnd exists */
|
|
|
|
const HWND getHWND () const;
|
|
|
|
/* Returns NULL if not found */
|
|
|
|
const HWND getChildHWND (int id) const;
|
|
|
|
/* Returns -1 if not found */
|
|
|
|
const int getChildID (HWND hwnd) const;
|
|
|
|
|
|
|
|
/* Creates an empty window */
|
2013-12-04 15:59:44 +01:00
|
|
|
bool createWin (WINDOW_INIT_DESC&);
|
2013-11-06 22:52:00 +01:00
|
|
|
/*Creates a child window and returns the id of child window or -1 if failed*/
|
2013-12-04 15:59:44 +01:00
|
|
|
int createChildWin (CHILD_WINDOW_INIT_DESC&);
|
2013-11-06 22:52:00 +01:00
|
|
|
/* Removes a child window */
|
|
|
|
bool removeChild (int id);
|
|
|
|
/* Removes a child window */
|
|
|
|
bool removeChild (HWND hwnd);
|
|
|
|
|
|
|
|
|
|
|
|
/* Returns a pointer to this class, dont forget to destroy on exit */
|
|
|
|
static WindowShell* self();
|
|
|
|
/* Deletes the instance */
|
|
|
|
static void destroy();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|