summaryrefslogtreecommitdiff
path: root/Editor/GUI/ContainerWindow.h
blob: 08f08fe6a367ae750ab9eae7bd85ac6e97536cf2 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#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"

// 一个containner window中有多个viewport
class ContainerWindow
	: public LuaBind::NativeClass<ContainerWindow>
{
public:
	static LRESULT CALLBACK ContainerWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

	enum ShowMode {
		kShowNormalWindow = 0,	// normal window with max/min/close buttons
		kShowPopupMenu = 1,		// popup menu - no title bar
		kShowUtility = 2,			// tool window - floats in the app, and hides when the app deactivates
		kShowNoShadow = 3,		// no shadow/decorations
		kShowMainWindow = 4,		// main Unity window. On Mac does not have close button; on Windows has menu bar etc.
		kShowAuxWindow = 5,		// Popup windows like the color picker, gradient editor, etc. Drawn with black background on Mac
	};

	ContainerWindow(LuaBind::VM* vm);
	~ContainerWindow();

	void Init(Rect size, int showMode, const Vector2& minSize, const Vector2& maxSize, std::string name = "");
	void SetTitle(const char* title);
	void SetIcon(LPCSTR iconName);
	void SetAsRenderContext();
	void DoPaint();
	void Close();

	Vector2f GetSize();

	GET_SET(std::string, Name, m_Name);

	GET(HWND, WindowHandle, m_Window);
	GET(HDC, DC, m_DC);

	void OnRectChanged();
	void OnActivateApplication(bool active);

private:
	bool SetRenderContext();

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

	std::string m_Name;

	POINT m_Size;
	ShowMode m_ShowMode; // 窗口类型
	bool  m_IsClosing;
	bool  m_InMenuLoop;
	bool  m_CloseFromScriptDontShutdown;
	Rect  m_InternalRect;
	POINT m_MinSize;
	POINT m_MaxSize;

#ifdef GAMELAB_WIN
	HWND m_Window;
	HDC  m_DC;
#endif

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

	LUA_BIND_DECL_CLASS(ContainerWindow);

	LUA_BIND_DECL_METHOD(_New);
	LUA_BIND_DECL_METHOD(_SetTitle);
	LUA_BIND_DECL_METHOD(_SetIcon);
	LUA_BIND_DECL_METHOD(_DoPaint);
	LUA_BIND_DECL_METHOD(_GetSize);

};