From eb1250a32bb5b05aa4905af234f8ccca8ada5315 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sat, 30 Jul 2022 12:13:36 -0400 Subject: [PATCH] Fixed the build and implemented some of the missing functions I just added. Not too happy with how these tests are structured so far; I might hack on that before continuing... --- common/controls.c | 5 +++++ common/uipriv.h | 1 + test/controls_windows.c | 4 ++-- test/window_windows.c | 2 +- windows/controls.cpp | 27 ++++++++++++++++++++++++++- 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/common/controls.c b/common/controls.c index 13bfdecf..82641303 100644 --- a/common/controls.c +++ b/common/controls.c @@ -264,6 +264,11 @@ uiControlOSVtable *uiprivControlOSVtable(uiControl *c) return c->type->osVtable; } +uiControl *uiprivControlParent(uiControl *c) +{ + return c->parent; +} + static uiControl testHookControlWithInvalidControlMarker = { // use something other than 0 here to make it look like accidental real data .controlID = UINT32_C(0x5A5A5A5A), diff --git a/common/uipriv.h b/common/uipriv.h index 4f815848..540c6f60 100644 --- a/common/uipriv.h +++ b/common/uipriv.h @@ -76,6 +76,7 @@ extern void uiprivReportError(const char *prefix, const char *msg, const char *s extern bool uiprivOSVtableValid(const char *name, const uiControlOSVtable *osVtable, const char *func); extern uiControlOSVtable *uiprivCloneOSVtable(const uiControlOSVtable *osVtable); extern uiControlOSVtable *uiprivControlOSVtable(uiControl *c); +extern uiControl *uiprivControlParent(uiControl *c); // utf8.c extern char *uiprivSanitizeUTF8(const char *str); diff --git a/test/controls_windows.c b/test/controls_windows.c index b4b5e214..4a0390a1 100644 --- a/test/controls_windows.c +++ b/test/controls_windows.c @@ -97,7 +97,7 @@ Test(GettingWindowsParentHandleOfNullControlIsProgrammerError) { void *ctx; - ctx = beginCheckProgrammerError("uiWindowsControlHandle(): invalid null pointer for uiControl"); + ctx = beginCheckProgrammerError("uiWindowsControlParentHandle(): invalid null pointer for uiControl"); uiWindowsControlParentHandle(NULL); endCheckProgrammerError(ctx); } @@ -111,7 +111,7 @@ Test(SettingWindowsControlPosOfNullControlIsProgrammerError) endCheckProgrammerError(ctx); } -Test(SettingWindowsControlPosOfNullControlIsProgrammerError) +Test(SettingWindowsControlPosToNullRectIsProgrammerError) { #if 0 // TODO diff --git a/test/window_windows.c b/test/window_windows.c index 8e9aae2f..25d80ffd 100644 --- a/test/window_windows.c +++ b/test/window_windows.c @@ -87,7 +87,7 @@ Test(WindowsCannotSetWindowControlPos) w = uiNewWindow(); - ctx = beginCheckProgrammerError("cannot set a uiWindow as the child of another uiControl"); + ctx = beginCheckProgrammerError("cannot call uiWindowsControlSetControlPos() on a uiWindow"); r.left = 0; r.top = 0; r.right = 640; diff --git a/windows/controls.cpp b/windows/controls.cpp index ec99b2a5..4db51bfc 100644 --- a/windows/controls.cpp +++ b/windows/controls.cpp @@ -14,6 +14,7 @@ bool uiprivOSVtableValid(const char *name, const uiControlOSVtable *osVtable, co } checkMethod(Handle) checkMethod(ParentHandleForChild) + checkMethod(SetControlPos) return true; } @@ -53,9 +54,33 @@ HWND uiWindowsControlParentHandle(uiControl *c) uiprivProgrammerErrorNullPointer("uiControl", uiprivFunc); return NULL; } - parent = uiControlParent(c); + parent = uiprivControlParent(c); if (parent == NULL) return NULL; parentVtable = uiprivControlOSVtable(parent); return callVtable(parentVtable->ParentHandleForChild, parent, uiControlImplData(parent), c); } + +HRESULT uiWindowsControlSetControlPos(uiControl *c, const RECT *r) +{ + uiControlOSVtable *osVtable; + + if (!uiprivCheckInitializedAndThread()) + return E_FAIL; + if (c == NULL) { + uiprivProgrammerErrorNullPointer("uiControl", uiprivFunc); + return E_FAIL; + } + if (r == NULL) { + uiprivProgrammerErrorNullPointer("RECT", uiprivFunc); + return E_FAIL; + } + osVtable = uiprivControlOSVtable(c); + return callVtable(osVtable->SetControlPos, c, uiControlImplData(c), r); +} + +HRESULT uiWindowsSetControlHandlePos(HWND hwnd, const RECT *r) +{ + // TODO + return S_OK; +}