1
0
Fork 0
spectre/source/Platform/Win32/Win32Display.h

73 lines
1.5 KiB
C++

#ifndef PLATFORM_WIN32_DISPLAY_H
#define PLATFORM_WIN32_DISPLAY_H
#include "Win32GLContext.h"
#include <Platform/PlatformDisplay.h>
#include <cstdint>
#include <Windows.h>
namespace sp {
class Win32Display : public PlatformDisplay
{
public :
Win32Display();
virtual ~Win32Display();
virtual bool create(DisplayDescription description);
virtual void destroy();
virtual bool isValid();
virtual void* getHandle() const;
virtual void setSize(unsigned int width, unsigned int height);
virtual Vector2u getSize() const;
virtual void setPosition(unsigned int x, unsigned int y);
virtual void setCaption(const std::string& caption);
virtual void setIcon(unsigned int width, unsigned int height, const uint8_t *pixels);
virtual void showCursor(bool value);
virtual void grabCursor(bool value);
protected :
void registerClass();
DWORD getWin32Flags(unsigned int flags);
void centerWindow(int &x, int &y, int width, int height);
void processMessage(UINT message, WPARAM wParam, LPARAM lParam);
void processResizeMessage(const Vector2u& new_size);
static LRESULT CALLBACK staticWndProc(HWND handle, UINT message, WPARAM wParam, LPARAM lParam);
protected :
HWND m_handle;
HCURSOR m_cursor;
HICON m_icon;
// True if this window is in a resize loop.
bool m_inResizeModalLoop;
// Client area size. cached here to check if a resize has been made.
Vector2u m_size;
Vector2u m_minSize;
};
} // namespace sp
#endif /* PLATFORM_WIN32_DISPLAY_H */