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...

This commit is contained in:
Pietro Gagliardi 2022-07-30 12:13:36 -04:00
parent 1d7c530c32
commit eb1250a32b
5 changed files with 35 additions and 4 deletions

View File

@ -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),

View File

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

View File

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

View File

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

View File

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