Added uiLabel to WPF.
This commit is contained in:
parent
10ec52d8db
commit
77c3e83821
|
@ -0,0 +1,46 @@
|
||||||
|
// 26 november 2015
|
||||||
|
#include "uipriv_wpf.hpp"
|
||||||
|
|
||||||
|
// TODO alignment
|
||||||
|
// TODO lots of padding
|
||||||
|
|
||||||
|
struct uiLabel {
|
||||||
|
uiWindowsControl c;
|
||||||
|
gcroot<Label ^> *label;
|
||||||
|
};
|
||||||
|
|
||||||
|
uiWindowsDefineControl(
|
||||||
|
uiLabel, // type name
|
||||||
|
uiLabelType, // type function
|
||||||
|
label // handle
|
||||||
|
)
|
||||||
|
|
||||||
|
char *uiLabelText(uiLabel *l)
|
||||||
|
{
|
||||||
|
String ^text;
|
||||||
|
|
||||||
|
// TOOD bad cast?
|
||||||
|
text = (String ^) ((*(l->label))->Content);
|
||||||
|
return uiWindowsCLRStringToText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void uiLabelSetText(uiLabel *l, const char *text)
|
||||||
|
{
|
||||||
|
(*(l->label))->Content = fromUTF8(text);
|
||||||
|
// TODO does this adjust the layout?
|
||||||
|
}
|
||||||
|
|
||||||
|
uiLabel *uiNewLabel(const char *text)
|
||||||
|
{
|
||||||
|
uiLabel *l;
|
||||||
|
|
||||||
|
l = (uiLabel *) uiNewControl(uiLabelType());
|
||||||
|
|
||||||
|
l->label = new gcroot<Label ^>();
|
||||||
|
*(l->label) = gcnew Label();
|
||||||
|
(*(l->label))->Content = fromUTF8(text);
|
||||||
|
|
||||||
|
uiWindowsFinishNewControl(l, uiLabel, label);
|
||||||
|
|
||||||
|
return l;
|
||||||
|
}
|
|
@ -84,6 +84,7 @@
|
||||||
<ClCompile Include="init.c">
|
<ClCompile Include="init.c">
|
||||||
<CompileAsManaged>false</CompileAsManaged>
|
<CompileAsManaged>false</CompileAsManaged>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="label.cpp" />
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
<ClCompile Include="tab.cpp" />
|
<ClCompile Include="tab.cpp" />
|
||||||
<ClCompile Include="text.cpp" />
|
<ClCompile Include="text.cpp" />
|
||||||
|
|
|
@ -17,6 +17,7 @@ var uiBoxSetPadded = libui.NewProc("uiBoxSetPadded")
|
||||||
var uiNewTab = libui.NewProc("uiNewTab")
|
var uiNewTab = libui.NewProc("uiNewTab")
|
||||||
var uiTabAppend = libui.NewProc("uiTabAppend")
|
var uiTabAppend = libui.NewProc("uiTabAppend")
|
||||||
var uiTabSetMargined = libui.NewProc("uiTabSetMargined")
|
var uiTabSetMargined = libui.NewProc("uiTabSetMargined")
|
||||||
|
var uiNewLabel = libui.NewProc("uiNewLabel")
|
||||||
var uiControlShow = libui.NewProc("uiControlShow")
|
var uiControlShow = libui.NewProc("uiControlShow")
|
||||||
var uiMain = libui.NewProc("uiMain")
|
var uiMain = libui.NewProc("uiMain")
|
||||||
var uiQuit = libui.NewProc("uiQuit")
|
var uiQuit = libui.NewProc("uiQuit")
|
||||||
|
@ -45,7 +46,7 @@ func main() {
|
||||||
btn, _, _ = uiNewButton.Call(
|
btn, _, _ = uiNewButton.Call(
|
||||||
uintptr(unsafe.Pointer(&s[0])))
|
uintptr(unsafe.Pointer(&s[0])))
|
||||||
uiBoxAppend.Call(box, btn, 1)
|
uiBoxAppend.Call(box, btn, 1)
|
||||||
btn, _, _ = uiNewButton.Call(
|
btn, _, _ = uiNewLabel.Call(
|
||||||
uintptr(unsafe.Pointer(&s[0])))
|
uintptr(unsafe.Pointer(&s[0])))
|
||||||
uiBoxAppend.Call(box, btn, 0)
|
uiBoxAppend.Call(box, btn, 0)
|
||||||
btn, _, _ = uiNewButton.Call(
|
btn, _, _ = uiNewButton.Call(
|
||||||
|
|
Loading…
Reference in New Issue