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
86
87
88
89
90
91
92
93
|
#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"
class GUIWindow;
class GUIWindowProxy : public LuaObjectProxy
{
public:
GUIWindow * owner;
LuaBind::MemberRef script;
GUIWindowProxy() {}
GUIWindowProxy(GUIWindow *owner, LuaBind::MemberRef script);
void DoInputEvent(LuaBind::State& state);
void DoGUI(LuaBind::State& state);
void DoClean(LuaBind::State& state);
//------------------------------------------------------
// callbacks
//------------------------------------------------------
void Start(LuaBind::State& state);
void Destroy(LuaBind::State& state);
void OnGUI(LuaBind::State& state);
void OnFocus(LuaBind::State& state);
};
// 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;
GUIWindowProxy 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);
};
|