summaryrefslogtreecommitdiff
path: root/Editor/GUI/GUIWindow.h
blob: 06d8a17253342caa1149cf2f32d10723d3c392df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#pragma once

#include <windows.h>
#include <vector>
#include "Runtime/Math/Rect.h"
#include "Runtime/Lua/LuaBind/LuaBind.h"
#include "Runtime/Lua/LuaHelper.h"
#include "Runtime/Utilities/Singleton.h"
#include "Runtime/Debug/Log.h"
#include "Runtime/Graphics/OpenGL.h"
#include "Runtime/Utilities/UtilMacros.h"
#include "Editor/Utils/HelperFuncs.h"
#include "Runtime/Math/Math.h"
#include "Runtime/Utilities/Exception.h"
#include "WindowUtil.h"

// GUI窗口,事件相应、绘制、布局的单元
class GUIWindow
	: public WindowBase
	, public LuaBind::NativeClass<GUIWindow>
{
public:
	static LRESULT CALLBACK GUIViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
	static void RepaintAll();

	GUIWindow(LuaBind::VM* vm, std::string name = ""); //throw WindowException

	void DoPaint();
	void SetContainerWindow(ContainerWindow* wnd);
	void Focus();
	void SetPosition(Rect position);
	void SetAsRenderContext();

	void OnFocus();
	void OnLostFocus();
	void OnPaint();

	GET_SET(std::string, Name, m_Name);
	GET(HDC, DC, m_DC);

private:
	void ProcessEventMessages(UINT message, WPARAM wParam, LPARAM lParam);
	bool SetRenderContext();

	//----------------------------------------------------------------- 

	std::string m_Name;

	LuaBind::MemberRef m_Script;

	BOOL m_MouseTracking;
	DWORD m_MouseHoverTime;

	HWND m_Handle;
	HDC  m_DC;

	//-----------------------------------------------------------------

	LUA_BIND_DECL_CLASS(GUIWindow);

	LUA_BIND_DECL_METHOD(_New);
	LUA_BIND_DECL_METHOD(_DoPaint);
	LUA_BIND_DECL_METHOD(_Focus);
	LUA_BIND_DECL_METHOD(_SetContainerWindow);
	LUA_BIND_DECL_METHOD(_SetPosition);

};