From 923c4c091ed4476524ad68421fbd3dca13ffe488 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 27 Nov 2015 10:49:50 -0500 Subject: [PATCH] Decided not to bother with winforms either. --- winforms/alloc.c | 93 ----------------- winforms/area.cpp | 39 ------- winforms/box.cpp | 195 ----------------------------------- winforms/button.cpp | 58 ----------- winforms/checkbox.cpp | 71 ------------- winforms/combobox.cpp | 69 ------------- winforms/control.cpp | 46 --------- winforms/datetimepicker.cpp | 49 --------- winforms/debug.c | 111 -------------------- winforms/draw.cpp | 151 --------------------------- winforms/entry.cpp | 62 ----------- winforms/group.cpp | 86 --------------- winforms/init.c | 102 ------------------ winforms/label.cpp | 47 --------- winforms/libui.msbuild | 145 -------------------------- winforms/main.cpp | 26 ----- winforms/menu.cpp | 69 ------------- winforms/progressbar.cpp | 31 ------ winforms/radiobuttons.cpp | 31 ------ winforms/separator.cpp | 26 ----- winforms/slider.cpp | 52 ---------- winforms/spinbox.cpp | 42 -------- winforms/stddialogs.cpp | 24 ----- winforms/tab.cpp | 126 ---------------------- winforms/text.cpp | 37 ------- winforms/ui_winforms.hpp | 72 ------------- winforms/uipriv_winforms.hpp | 28 ----- winforms/unmanaged.h | 23 ----- winforms/util.c | 17 --- winforms/winapi.h | 13 --- winforms/window.cpp | 165 ----------------------------- 31 files changed, 2106 deletions(-) delete mode 100644 winforms/alloc.c delete mode 100644 winforms/area.cpp delete mode 100644 winforms/box.cpp delete mode 100644 winforms/button.cpp delete mode 100644 winforms/checkbox.cpp delete mode 100644 winforms/combobox.cpp delete mode 100644 winforms/control.cpp delete mode 100644 winforms/datetimepicker.cpp delete mode 100644 winforms/debug.c delete mode 100644 winforms/draw.cpp delete mode 100644 winforms/entry.cpp delete mode 100644 winforms/group.cpp delete mode 100644 winforms/init.c delete mode 100644 winforms/label.cpp delete mode 100755 winforms/libui.msbuild delete mode 100644 winforms/main.cpp delete mode 100644 winforms/menu.cpp delete mode 100644 winforms/progressbar.cpp delete mode 100644 winforms/radiobuttons.cpp delete mode 100644 winforms/separator.cpp delete mode 100644 winforms/slider.cpp delete mode 100644 winforms/spinbox.cpp delete mode 100644 winforms/stddialogs.cpp delete mode 100644 winforms/tab.cpp delete mode 100644 winforms/text.cpp delete mode 100644 winforms/ui_winforms.hpp delete mode 100644 winforms/uipriv_winforms.hpp delete mode 100644 winforms/unmanaged.h delete mode 100644 winforms/util.c delete mode 100644 winforms/winapi.h delete mode 100644 winforms/window.cpp diff --git a/winforms/alloc.c b/winforms/alloc.c deleted file mode 100644 index f76e7dcc..00000000 --- a/winforms/alloc.c +++ /dev/null @@ -1,93 +0,0 @@ -// 4 december 2014 -#ifdef __cplusplus -#error msbuild is being dumb and making this a C++ file -#endif -#include "unmanaged.h" -#include - -// wrappers for allocator of choice -// panics on memory exhausted, undefined on heap corruption or other unreliably-detected malady (see http://stackoverflow.com/questions/28761680/is-there-a-windows-api-memory-allocator-deallocator-i-can-use-that-will-just-giv) -// new memory is set to zero -// passing NULL to tableRealloc() acts like tableAlloc() -// passing NULL to tableFree() is a no-op - -static HANDLE heap; - -int initAlloc(void) -{ - heap = HeapCreate(0, 0, 0); - return heap != NULL; -} - -#define UINT8(p) ((uint8_t *) (p)) -#define PVOID(p) ((void *) (p)) -#define EXTRA (sizeof (const char **)) -#define DATA(p) PVOID(UINT8(p) + EXTRA) -#define BASE(p) PVOID(UINT8(p) - EXTRA) -#define CCHAR(p) ((const char **) (p)) -#define TYPE(p) CCHAR(UINT8(p)) - -void uninitAlloc(void) -{ - BOOL hasEntry; - PROCESS_HEAP_ENTRY phe; - DWORD le; - - hasEntry = FALSE; - ZeroMemory(&phe, sizeof (PROCESS_HEAP_ENTRY)); - while (HeapWalk(heap, &phe) != 0) { - // skip non-allocations - if ((phe.wFlags & PROCESS_HEAP_ENTRY_BUSY) == 0) - continue; - if (!hasEntry) { - fprintf(stderr, "[libui] leaked allocations:\n"); - hasEntry = TRUE; - } - fprintf(stderr, "[libui] %p %s\n", phe.lpData, *TYPE(phe.lpData)); - } - le = GetLastError(); - SetLastError(le); // just in case - if (le != ERROR_NO_MORE_ITEMS) - logLastError("error walking heap in uninitAlloc()"); - if (hasEntry) - complain("either you left something around or there's a bug in libui"); - if (HeapDestroy(heap) == 0) - logLastError("error destroying heap in uninitAlloc()"); -} - -void *uiAlloc(size_t size, const char *type) -{ - void *out; - - out = HeapAlloc(heap, HEAP_ZERO_MEMORY, EXTRA + size); - if (out == NULL) { - fprintf(stderr, "memory exhausted in uiAlloc()\n"); - abort(); - } - *TYPE(out) = type; - return DATA(out); -} - -void *uiRealloc(void *p, size_t size, const char *type) -{ - void *out; - - if (p == NULL) - return uiAlloc(size, type); - p = BASE(p); - out = HeapReAlloc(heap, HEAP_ZERO_MEMORY, p, EXTRA + size); - if (out == NULL) { - fprintf(stderr, "memory exhausted in uiRealloc()\n"); - abort(); - } - return DATA(out); -} - -void uiFree(void *p) -{ - if (p == NULL) - complain("attempt to uiFree(NULL); there's a bug somewhere"); - p = BASE(p); - if (HeapFree(heap, 0, p) == 0) - logLastError("error freeing memory in uiFree()"); -} diff --git a/winforms/area.cpp b/winforms/area.cpp deleted file mode 100644 index 247cb34c..00000000 --- a/winforms/area.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// 26 november 2015 -#include "uipriv_winforms.hpp" - -struct uiArea { - uiWindowsControl c; - DUMMY dummy; - uiAreaHandler *ah; -}; - -uiWindowsDefineControl( - uiArea, // type name - uiAreaType, // type function - dummy // handle -) - -void uiAreaUpdateScroll(uiArea *a) -{ - // TODO -} - -void uiAreaQueueRedrawAll(uiArea *a) -{ - // TODO -} - -uiArea *uiNewArea(uiAreaHandler *ah) -{ - uiArea *a; - - a = (uiArea *) uiNewControl(uiAreaType()); - - a->ah = ah; - - a->dummy = mkdummy(L"uiArea"); - - uiWindowsFinishNewControl(a, uiArea, dummy); - - return a; -} diff --git a/winforms/box.cpp b/winforms/box.cpp deleted file mode 100644 index b81f0b30..00000000 --- a/winforms/box.cpp +++ /dev/null @@ -1,195 +0,0 @@ -// 26 november 2015 -#include "uipriv_winforms.hpp" - -using namespace System::Collections::Generic; - -// TODO -// - save Alignment of children? -// - SnapsToDevicePixels? http://stackoverflow.com/questions/10718985/grid-border-gap-between-cells - -ref class boxChild { -public: - uiControl *c; - Border ^border; - int stretchy; -}; - -struct uiBox { - uiWindowsControl c; - // we could've used StackPanel but that doesn't care about available size - gcroot *grid; - gcroot ^> *children; - int vertical; - int padded; -}; - -static void onDestroy(uiBox *b); - -uiWindowsDefineControlWithOnDestroy( - uiBox, // type name - uiBoxType, // type function - grid, // handle - onDestroy(hthis); // on destroy -) - -static void onDestroy(uiBox *b) -{ - List ^children; - - children = *(b->children); - while (children->Count != 0) { - children[0]->border->Child = nullptr; - uiControlSetParent(children[0]->c, NULL); - uiControlDestroy(children[0]->c); - children->RemoveAt(0); - } - delete b->children; -} - -static void boxContainerUpdateState(uiControl *c) -{ - uiBox *b = uiBox(c); - List ^children; - int i; - - children = *(b->children); - for (i = 0; i < children->Count; i++) - controlUpdateState(children[i]->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; - Thickness first; - Thickness after; - List ^children; - int i; - - children = *(b->children); - if (children->Count == 0) - return; - - paddingUnit = 0; - if (b->padded) - paddingUnit = 5; - first = Thickness(0, 0, 0, 0); - after = Thickness(paddingUnit, 0, 0, 0); - if (b->vertical) - after = Thickness(0, paddingUnit, 0, 0); - - // TODO padding? - children[0]->border->Margin = first; - for (i = 1; i < children->Count; i++) - children[i]->border->Margin = after; -} - -void uiBoxAppend(uiBox *b, uiControl *c, int stretchy) -{ - Grid ^g; - boxChild ^bc; - int pos; - - bc = gcnew boxChild(); - bc->c = c; - bc->border = gcnew Border(); - bc->stretchy = stretchy; - - bc->border->Child = genericHandle(bc->c); - - g = *(b->grid); - - // get position before adding the child so that we get the right count value - pos = g->ColumnDefinitions->Count; - if (b->vertical) - pos = g->RowDefinitions->Count; - - g->Children->Add(bc->border); - - if (b->vertical) { - g->SetRow(bc->border, pos); - g->SetColumn(bc->border, 0); - // apparently we have to do this ourselves... - g->RowDefinitions->Add(gcnew RowDefinition()); - if (bc->stretchy) - g->RowDefinitions[pos]->Height = GridLength(1, GridUnitType::Star); - else - g->RowDefinitions[pos]->Height = GridLength(1, GridUnitType::Auto); - } else { - g->SetRow(bc->border, 0); - g->SetColumn(bc->border, pos); - g->ColumnDefinitions->Add(gcnew ColumnDefinition()); - if (bc->stretchy) - g->ColumnDefinitions[pos]->Width = GridLength(1, GridUnitType::Star); - else - g->ColumnDefinitions[pos]->Width = GridLength(1, GridUnitType::Auto); - } - - uiControlSetParent(bc->c, uiControl(b)); - (*(b->children))->Add(bc); - resetMargins(b); -} - -void uiBoxDelete(uiBox *b, uintmax_t index) -{ - boxChild ^bc; - List ^children; - - children = *(b->children); - bc = children[index]; - children->RemoveAt(index); - uiControlSetParent(bc->c, NULL); - bc->border->Child = nullptr; - (*(b->grid))->Children->RemoveAt(index); - resetMargins(b); -} - -int uiBoxPadded(uiBox *b) -{ - return b->padded; -} - -void uiBoxSetPadded(uiBox *b, int padded) -{ - b->padded = padded; - resetMargins(b); -} - -static uiBox *finishNewBox(int vertical) -{ - uiBox *b; - - b = (uiBox *) uiNewControl(uiBoxType()); - - b->grid = new gcroot(); - *(b->grid) = gcnew Grid(); - - b->vertical = vertical; - if (b->vertical) { - (*(b->grid))->ColumnDefinitions->Add(gcnew ColumnDefinition()); - (*(b->grid))->ColumnDefinitions[0]->Width = GridLength(1, GridUnitType::Star); - } else { - (*(b->grid))->RowDefinitions->Add(gcnew RowDefinition()); - (*(b->grid))->RowDefinitions[0]->Height = GridLength(1, GridUnitType::Star); - } - - b->children = new gcroot ^>(); - *(b->children) = gcnew List(); - - uiWindowsFinishNewControl(b, uiBox, grid); - uiControl(b)->ContainerUpdateState = boxContainerUpdateState; - - return b; -} - -uiBox *uiNewHorizontalBox(void) -{ - return finishNewBox(0); -} - -uiBox *uiNewVerticalBox(void) -{ - return finishNewBox(1); -} diff --git a/winforms/button.cpp b/winforms/button.cpp deleted file mode 100644 index 16fccdf9..00000000 --- a/winforms/button.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// 25 november 2015 -#include "uipriv_winforms.hpp" - -struct uiButton { - uiWindowsControl c; - gcroot