Wed, 20 Jan 2016 16:00:05 +0100
improved grid container (Qt)
78
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | // Dies ist die Haupt-DLL. |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | #include "stdafx.h" |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | #include <stdio.h> |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | #include "toolkit.h" |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | #using "UIcore.dll" |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | void* ObjectToPtr(Object ^obj) { |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | GCHandle handle = GCHandle::Alloc(obj); |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | IntPtr pointer = GCHandle::ToIntPtr(handle); |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | return pointer.ToPointer(); |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | } |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | Object^ PtrToObject(void *ptr) { |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | GCHandle h = GCHandle::FromIntPtr(IntPtr(ptr)); |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | Object^ object = h.Target; |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | h.Free(); |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | return object; |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | } |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | |
81
5eb765a7a793
added menus (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
78
diff
changeset
|
24 | // EventWrapper |
5eb765a7a793
added menus (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
78
diff
changeset
|
25 | |
83
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
26 | ObjEventWrapper::ObjEventWrapper(UIcallback callback, void *eventdata) { |
81
5eb765a7a793
added menus (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
78
diff
changeset
|
27 | this->callback = callback; |
83
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
28 | this->eventdata = eventdata; |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
29 | action = gcnew Action<IntPtr>(this, &ObjEventWrapper::Callback); |
81
5eb765a7a793
added menus (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
78
diff
changeset
|
30 | } |
5eb765a7a793
added menus (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
78
diff
changeset
|
31 | |
83
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
32 | Action<IntPtr>^ ObjEventWrapper::GetAction() { |
81
5eb765a7a793
added menus (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
78
diff
changeset
|
33 | return action; |
5eb765a7a793
added menus (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
78
diff
changeset
|
34 | } |
5eb765a7a793
added menus (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
78
diff
changeset
|
35 | |
83
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
36 | void ObjEventWrapper::Callback(IntPtr uiobj) { |
82
0cdb8089a29f
added event handler for menus (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
81
diff
changeset
|
37 | if (callback) { |
83
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
38 | callback(uiobj.ToPointer(), eventdata); |
82
0cdb8089a29f
added event handler for menus (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
81
diff
changeset
|
39 | } |
81
5eb765a7a793
added menus (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
78
diff
changeset
|
40 | } |
78
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
41 | |
83
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
42 | |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
43 | EventWrapper::EventWrapper(UIcallback callback, void *eventdata) { |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
44 | this->callback = callback; |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
45 | this->eventdata = eventdata; |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
46 | } |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
47 | |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
48 | void EventWrapper::Callback(Object ^sender, RoutedEventArgs ^e) { |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
49 | if (callback) { |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
50 | callback(NULL, eventdata); |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
51 | } |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
52 | } |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
53 | |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
54 | |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
55 | |
78
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
56 | UI_EXPORT void __stdcall UIinit(char *appname) { |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
57 | UI::Application ^app = UI::Application::GetInstance(); |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
58 | app->Name = gcnew String(appname); |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
59 | } |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
60 | |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
61 | UI_EXPORT void __stdcall UImain() { |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
62 | Thread ^thread = UI::Application::GetInstance()->Start(); |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
63 | thread->Join(); |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
64 | } |
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
65 | |
83
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
66 | UI_EXPORT void __stdcall UIshow(gcroot<UI::MainWindow^> *window) { |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
67 | (*window)->ShowWindow(); |
78
135920fe441b
added initial WPF code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
68 | } |