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