From 60becb332e119e1981751188c6aed2d3ad50b1db Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 26 Nov 2015 20:34:21 -0500 Subject: [PATCH] More work. NOW we're getting boring :v --- wpf/box.cpp | 1 + wpf/combobox.cpp | 7 +++---- wpf/group.cpp | 35 +++++++++++++++++++++++++++++++---- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/wpf/box.cpp b/wpf/box.cpp index 49d54686..590495ad 100644 --- a/wpf/box.cpp +++ b/wpf/box.cpp @@ -59,6 +59,7 @@ static void boxContainerUpdateState(uiControl *c) // Grid unfortunately does not have a way to set the spacing between rows and columns. // This means we have to do padding ourselves. +// TODO this doesn't work right for visibility purposes static void resetMargins(uiBox *b) { double paddingUnit; diff --git a/wpf/combobox.cpp b/wpf/combobox.cpp index 62654cf7..892d3e95 100644 --- a/wpf/combobox.cpp +++ b/wpf/combobox.cpp @@ -49,8 +49,7 @@ static uiCombobox *finishNewCombobox(bool editable) c->combobox = new gcroot(); *(c->combobox) = gcnew ComboBox(); - // TODO doesn't affect the presence of a textbox - (*(c->combobox))->IsReadOnly = editable; + (*(c->combobox))->IsEditable = editable; uiComboboxOnSelected(c, defaultOnSelected, NULL); @@ -61,10 +60,10 @@ static uiCombobox *finishNewCombobox(bool editable) uiCombobox *uiNewCombobox(void) { - return finishNewCombobox(true); + return finishNewCombobox(false); } uiCombobox *uiNewEditableCombobox(void) { - return finishNewCombobox(false); + return finishNewCombobox(true); } diff --git a/wpf/group.cpp b/wpf/group.cpp index 8c00c4d1..2d3bb30f 100644 --- a/wpf/group.cpp +++ b/wpf/group.cpp @@ -4,15 +4,28 @@ struct uiGroup { uiWindowsControl c; gcroot *groupbox; + uiControl *child; int margined; }; -uiWindowsDefineControl( +static void onDestroy(uiGroup *); + +uiWindowsDefineControlWithOnDestroy( uiGroup, // type name uiGroupType, // type function - groupbox // handle + groupbox, // handle + onDestroy(hthis); // on destroy ) +static void onDestroy(uiGroup *g) +{ + if (g->child != NULL) { + (*(g->groupbox))->Content = nullptr; + uiControlSetParent(g->child, NULL); + uiControlDestroy(g->child); + } +} + char *uiGroupTitle(uiGroup *g) { String ^text; @@ -30,7 +43,15 @@ void uiGroupSetTitle(uiGroup *g, const char *title) void uiGroupSetChild(uiGroup *g, uiControl *c) { - // TODO + if (g->child != NULL) { + uiControlSetParent(g->child, NULL); + (*(g->groupbox))->Content = nullptr; + } + g->child = c; + if (g->child != NULL) { + (*(g->groupbox))->Content = genericHandle(g->child); + uiControlSetParent(g->child, uiControl(g)); + } } int uiGroupMargined(uiGroup *g) @@ -40,7 +61,13 @@ int uiGroupMargined(uiGroup *g) void uiGroupSetMargined(uiGroup *g, int margined) { - // TODO + g->margined = margined; + // TODO Margin or Padding? + // TODO really this? or should we just use another Border? + if (g->margined) + (*(g->groupbox))->Padding = Thickness(10, 10, 10, 10); + else + (*(g->groupbox))->Padding = Thickness(0, 0, 0, 0); } uiGroup *uiNewGroup(const char *title)