Sun, 15 Jan 2017 15:08:07 +0100
fixes VS settings
83
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | #include "stdafx.h" |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | #include <stdio.h> |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | #include "controls.h" |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | #using "UIcore.dll" |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | |
101
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
10 | /* ------------------------------ Buttons ------------------------------ */ |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
11 | |
83
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | UI_EXPORT void* __stdcall UIbutton(gcroot<UI::Container^> *container, char *label, UIcallback f, void *eventdata) { |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | gcroot<Button^> *button = new gcroot<Button^>(); |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | EventWrapper ^evt = gcnew EventWrapper(f, eventdata); |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | RoutedEventHandler ^handler = gcnew RoutedEventHandler(evt, &EventWrapper::Callback); |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | *button = UI::Controls::Button(*container, gcnew String(label), handler); |
a38aec91bd66
added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | return button; |
88
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
20 | } |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
21 | |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
22 | |
101
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
23 | /* ------------------------------ Labels ------------------------------ */ |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
24 | |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
25 | UI_EXPORT void* __stdcall UIlabel(gcroot<UI::Container^> *container, char *label, int alignment) { |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
26 | gcroot<Label^> *control = new gcroot<Label^>(); |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
27 | *control = UI::Controls::Label(*container, gcnew String(label), alignment); |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
28 | return control; |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
29 | } |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
30 | |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
31 | UI_EXPORT void* __stdcall UIspace(gcroot<UI::Container^> *container) { |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
32 | gcroot<Label^> *control = new gcroot<Label^>(); |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
33 | *control = UI::Controls::Space(*container); |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
34 | return control; |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
35 | } |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
36 | |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
37 | UI_EXPORT void* __stdcall UIseparator(gcroot<UI::Container^> *container) { |
104
3efe0210e27e
added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
38 | gcroot<Separator^> *control = new gcroot<Separator^>(); |
3efe0210e27e
added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
39 | *control = UI::Controls::Separator(*container); |
3efe0210e27e
added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
40 | return control; |
101
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
41 | } |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
42 | |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
43 | |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
44 | |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
45 | /* ------------------------------ Textarea ------------------------------ */ |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
46 | |
88
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
47 | UI_EXPORT void* __stdcall UItextarea(gcroot<UI::Container^> *container, char *text) { |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
48 | String ^str = nullptr; |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
49 | if (text) { |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
50 | str = gcnew String(text); |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
51 | } |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
52 | |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
53 | gcroot<UI::TextArea^> *textarea = new gcroot<UI::TextArea^>(); |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
54 | *textarea = UI::TextArea::CreateTextArea(*container, str); |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
55 | |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
56 | return textarea; |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
57 | } |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
58 | |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
59 | UI_EXPORT void __stdcall UItextarea_set(gcroot<UI::TextArea^> *textarea, char *str) { |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
60 | (*textarea)->SetText(gcnew String(str)); |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
61 | } |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
62 | |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
63 | UI_EXPORT char* __stdcall UItextarea_get(gcroot<UI::TextArea^> *textarea) { |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
64 | String ^str = (*textarea)->GetText(); |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
65 | return (char*)(void*)Marshal::StringToHGlobalAnsi(str); |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
66 | } |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
67 | |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
68 | UI_EXPORT char* __stdcall UItextarea_getsubstr(gcroot<UI::TextArea^> *textarea, int begin, int end) { |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
69 | String ^str = (*textarea)->GetSubString(begin, end); |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
70 | return (char*)(void*)Marshal::StringToHGlobalAnsi(str); |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
71 | } |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
72 | |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
73 | UI_EXPORT void __stdcall UItextarea_insert(gcroot<UI::TextArea^> *textarea, int position, char *str) { |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
74 | // TODO |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
75 | } |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
76 | |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
77 | UI_EXPORT int __stdcall UItextarea_position(gcroot<UI::TextArea^> *textarea) { |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
78 | return (*textarea)->Position(); |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
79 | } |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
80 | |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
81 | UI_EXPORT void __stdcall UItextarea_selection(gcroot<UI::TextArea^> *textarea, int *begin, int *end) { |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
82 | // TODO |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
83 | } |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
84 | |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
85 | UI_EXPORT int __stdcall UItextarea_length(gcroot<UI::TextArea^> *textarea) { |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
86 | return (*textarea)->Length(); |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
87 | } |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
88 | |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
89 | UI_EXPORT void __stdcall UItextarea_remove(gcroot<UI::TextArea^> *textarea, int begin, int end) { |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
90 | // TODO |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
91 | } |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
92 | |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
93 | UI_EXPORT void __stdcall UIfreestr(char *str) { |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
94 | Marshal::FreeHGlobal((IntPtr)(void*)str); |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
95 | } |
101
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
96 | |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
97 | |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
98 | /* ------------------------------ Textfield ------------------------------ */ |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
99 | |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
100 | UI_EXPORT void* __stdcall UItextfield(gcroot<UI::Container^> *container, char *text) { |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
101 | String ^str = nullptr; |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
102 | if (text) { |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
103 | str = gcnew String(text); |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
104 | } |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
105 | |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
106 | gcroot<UI::TextArea^> *textfield = new gcroot<UI::TextArea^>(); |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
107 | *textfield = UI::TextArea::CreateTextField(*container, str); |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
108 | |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
109 | return textfield; |
1c943d43fa81
implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
110 | } |