Zalgo/include/Window.hpp
Quantum 8596131f44 Added X-SAMPA table.
Also:
1. Cleaned up text handling by storing them in resource.
2. Added useful methods to make code look better.
3. Allowed PreviewWindow to be used for general text displaying.
2013-08-26 16:52:47 -04:00

64 lines
1.7 KiB
C++

#pragma once
#ifndef idC3714409_EABC_45DE_B5338EC60149AE87
#define idC3714409_EABC_45DE_B5338EC60149AE87
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
inline void MakeRect(RECT &rect, int x, int y, int cx, int cy)
{
rect.left = x;
rect.top = y;
rect.right = x + cx;
rect.bottom = y + cy;
}
inline void MakeRectRight(RECT &rect, int x, int y, int cx, int cy)
{
MakeRect(rect, x - cx, y, cx, cy);
}
inline void MakeRectBottom(RECT &rect, int x, int y, int cx, int cy)
{
MakeRect(rect, x, y - cy, cx, cy);
}
inline void MakeRectBottomRight(RECT &rect, int x, int y, int cx, int cy)
{
MakeRect(rect, x - cx, y - cy, cx, cy);
}
class Window {
public:
HWND GetHWND() const { return m_hwnd; }
bool ShowWindow(int nCmdShow) { return ::ShowWindow(m_hwnd, nCmdShow) != 0; }
static HINSTANCE GetInstance() { return (HINSTANCE) GetModuleHandle(NULL); }
operator HWND() const { return m_hwnd; }
protected:
virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
virtual void PaintContent(PAINTSTRUCT *pps) {}
virtual LPCTSTR ClassName() = 0;
virtual HICON GetIcon() { return NULL; }
virtual BOOL WinRegisterClass(WNDCLASS *pwc) {
return RegisterClass(pwc);
}
virtual ~Window();
HWND WinCreateWindow(DWORD dwExStyle, LPCTSTR pszName,
DWORD dwStyle, int x, int y, int cx,
int cy, HWND hwndParent, HMENU hmenu);
private:
virtual void Register();
void OnPaint();
void OnPrintClient(HDC hdc);
static LRESULT CALLBACK s_WndProc(HWND hwnd, UINT uMsg,
WPARAM wParam, LPARAM lParam);
protected:
HWND m_hwnd;
};
#endif // header