|
@@ -10,53 +10,56 @@
|
10
|
10
|
|
11
|
11
|
class TestApp1 : public DKApplication
|
12
|
12
|
{
|
13
|
|
- DKObject<DKThread> thread;
|
|
13
|
+ DKObject<DKWindow> window;
|
14
|
14
|
public:
|
15
|
15
|
void OnInitialize(void) override
|
16
|
16
|
{
|
17
|
17
|
DKLog("%s", __PRETTY_FUNCTION__);
|
|
18
|
+ window = DKWindow::Create("DefaultWindow");
|
|
19
|
+ window->Activate();
|
18
|
20
|
|
19
|
|
- DKLog("---- SystemPath ----");
|
20
|
|
- DKLog("SystemRoot: %ls", (const wchar_t*)DefaultPath(SystemPath::SystemRoot));
|
21
|
|
- DKLog("AppRoot: %ls", (const wchar_t*)DefaultPath(SystemPath::AppRoot));
|
22
|
|
- DKLog("AppResource: %ls", (const wchar_t*)DefaultPath(SystemPath::AppResource));
|
23
|
|
- DKLog("AppExecutable: %ls", (const wchar_t*)DefaultPath(SystemPath::AppExecutable));
|
24
|
|
- DKLog("AppData: %ls", (const wchar_t*)DefaultPath(SystemPath::AppData));
|
25
|
|
- DKLog("UserHome: %ls", (const wchar_t*)DefaultPath(SystemPath::UserHome));
|
26
|
|
- DKLog("UserDocuments: %ls", (const wchar_t*)DefaultPath(SystemPath::UserDocuments));
|
27
|
|
- DKLog("UserPreferences: %ls", (const wchar_t*)DefaultPath(SystemPath::UserPreferences));
|
28
|
|
- DKLog("UserCache: %ls", (const wchar_t*)DefaultPath(SystemPath::UserCache));
|
29
|
|
- DKLog("UserTemp: %ls", (const wchar_t*)DefaultPath(SystemPath::UserTemp));
|
30
|
|
- DKLog("---- ProcessInfo ----");
|
31
|
|
- DKLog("HostName: %ls", (const wchar_t*)ProcessInfoString(ProcessInfo::HostName));
|
32
|
|
- DKLog("OsName: %ls", (const wchar_t*)ProcessInfoString(ProcessInfo::OsName));
|
33
|
|
- DKLog("UserName: %ls", (const wchar_t*)ProcessInfoString(ProcessInfo::UserName));
|
34
|
|
- DKLog("ModulePath: %ls", (const wchar_t*)ProcessInfoString(ProcessInfo::ModulePath));
|
35
|
|
-
|
36
|
|
- thread = DKThread::Create(DKFunction([this]()
|
37
|
|
- {
|
38
|
|
- DKLog("Running new thread!");
|
39
|
|
- this->EventLoop()->Post(DKFunction([&]()
|
|
21
|
+ window->AddEventHandler(this,
|
|
22
|
+ DKFunction([this](const DKWindow::WindowEvent& e)
|
40
|
23
|
{
|
41
|
|
- DKLog("test1");
|
42
|
|
- })->Invocation(), 2);
|
43
|
|
- this->EventLoop()->Post(DKFunction([&]()
|
|
24
|
+ DKLog("WindowEvent: %d, origin:(%.1f, %.1f), size:(%.1f x %.1f), content:(%.1f, %.1f), scale:%f",
|
|
25
|
+ e.type,
|
|
26
|
+ e.windowRect.origin.x, e.windowRect.origin.y,
|
|
27
|
+ e.windowRect.size.width, e.windowRect.size.height,
|
|
28
|
+ e.contentRect.size.width, e.contentRect.size.height,
|
|
29
|
+ e.contentScaleFactor);
|
|
30
|
+ if (e.type == DKWindow::WindowEvent::WindowClosed)
|
|
31
|
+ DKApplication::Instance()->Terminate(0);
|
|
32
|
+ }),
|
|
33
|
+ DKFunction([this](const DKWindow::KeyboardEvent& e)
|
44
|
34
|
{
|
45
|
|
- DKLog("test2");
|
46
|
|
- })->Invocation(), 4);
|
47
|
|
- this->EventLoop()->Post(DKFunction([&]()
|
|
35
|
+ if (e.type == DKWindow::KeyboardEvent::KeyUp)
|
|
36
|
+ {
|
|
37
|
+ if (e.key == DKVK_ENTER)
|
|
38
|
+ {
|
|
39
|
+ window->SetTextInputEnabled(0, !window->IsTextInputEnabled(0));
|
|
40
|
+ DKLog("TextInput: %d", window->IsTextInputEnabled(0));
|
|
41
|
+ }
|
|
42
|
+ else if (e.key == DKVK_ESCAPE)
|
|
43
|
+ {
|
|
44
|
+ window->HoldMouse(0, !window->IsMouseHeld(0));
|
|
45
|
+ DKLog("HoldMouse: %d", window->IsMouseHeld(0));
|
|
46
|
+ }
|
|
47
|
+ }
|
|
48
|
+ DKLog("KeyboardEvent: %d, %ls, %ls",
|
|
49
|
+ e.type,
|
|
50
|
+ (const wchar_t*)DKWindow::GetVKName(e.key),
|
|
51
|
+ (const wchar_t*)e.text);
|
|
52
|
+ }),
|
|
53
|
+ DKFunction([this](const DKWindow::MouseEvent& e)
|
48
|
54
|
{
|
49
|
|
- DKLog("Terminate!!");
|
50
|
|
- DKApplication::Instance()->Terminate(0);
|
51
|
|
- })->Invocation(), 10);
|
52
|
|
-
|
53
|
|
- })->Invocation());
|
|
55
|
+ DKLog("MouseEvent: %d, btn:%d, location:%.1f, %.1f, delta:%.1f, %.1f",
|
|
56
|
+ e.type, e.buttonId, e.location.x, e.location.y, e.delta.x, e.delta.y);
|
|
57
|
+ })
|
|
58
|
+ );
|
54
|
59
|
}
|
55
|
60
|
void OnTerminate(void) override
|
56
|
61
|
{
|
57
|
62
|
DKLog("%s", __PRETTY_FUNCTION__);
|
58
|
|
- DKLog("Waiting for worker thread!");
|
59
|
|
- thread->WaitTerminate();
|
60
|
63
|
}
|
61
|
64
|
};
|
62
|
65
|
|