Added uiLabel to WPF.

This commit is contained in:
Pietro Gagliardi 2015-11-26 13:55:39 -05:00
parent 10ec52d8db
commit 77c3e83821
3 changed files with 49 additions and 1 deletions

46
wpf/label.cpp Normal file
View File

@ -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;
}

View File

@ -84,6 +84,7 @@
<ClCompile Include="init.c">
<CompileAsManaged>false</CompileAsManaged>
</ClCompile>
<ClCompile Include="label.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="tab.cpp" />
<ClCompile Include="text.cpp" />

View File

@ -17,6 +17,7 @@ var uiBoxSetPadded = libui.NewProc("uiBoxSetPadded")
var uiNewTab = libui.NewProc("uiNewTab")
var uiTabAppend = libui.NewProc("uiTabAppend")
var uiTabSetMargined = libui.NewProc("uiTabSetMargined")
var uiNewLabel = libui.NewProc("uiNewLabel")
var uiControlShow = libui.NewProc("uiControlShow")
var uiMain = libui.NewProc("uiMain")
var uiQuit = libui.NewProc("uiQuit")
@ -45,7 +46,7 @@ func main() {
btn, _, _ = uiNewButton.Call(
uintptr(unsafe.Pointer(&s[0])))
uiBoxAppend.Call(box, btn, 1)
btn, _, _ = uiNewButton.Call(
btn, _, _ = uiNewLabel.Call(
uintptr(unsafe.Pointer(&s[0])))
uiBoxAppend.Call(box, btn, 0)
btn, _, _ = uiNewButton.Call(