libui/redo/objimpl/windows/control.c

134 lines
2.8 KiB
C
Raw Normal View History

// 27 may 2015
#include "uipriv_windows.h"
2015-05-27 15:47:44 -05:00
// TODO Edit ,s/Util/HWND/g
#define HWND(c) ((HWND) uiControlHandle((c)))
void uiWindowsUtilDestroy(HWND hwnd)
{
if (DestroyWindow(hwnd) == 0)
logLastError("error destroying window in uiWindowsUtilDestroyWindow()");
}
2015-05-29 10:56:47 -05:00
static void singleHWNDCommitDestroy(uiControl *c)
{
uiWindowsUtilDestroy(HWND(c));
}
void uiWindowsUtilSetParent(HWND hwnd, uiControl *parent)
{
HWND newParent;
newParent = utilWindow;
if (parent != NULL)
newParent = HWND(parent);
if (SetParent(hwnd, newParent) == 0)
logLastError("error changing window parent in uiWindowsUtilSetParent()");
}
2015-05-29 10:56:47 -05:00
static void singleHWNDCommitSetParent(uiControl *c, uiControl *parent)
{
uiWindowsUtilSetParent(HWND(c), parent);
}
2015-05-29 10:56:47 -05:00
void uiWindowsUtilResize(HWND hwnd, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d)
{
moveWindow(hwnd, x, y, width, height, d);
}
static void singleHWNDResize(HWND hwnd, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d)
{
uiWindowsUtilResize(HWND(c), x, y, width, height, d);
}
// TODO queue resize
uiSizing *uiWindowsUtilSizing(HWND hwnd)
{
xxxxxTODOxxxxxx
}
static uiSizing *singleHWNDSizing(uiControl *c)
{
return uiWindowsUtilSizing(HWND(c));
}
void uiWIndowsUtilShow(HWND hwnd)
{
ShowWindow(hwnd, SW_SHOW);
}
2015-05-29 10:56:47 -05:00
static void singleHWNDCommitShow(uiControl *c)
{
uiWindowsUtilShow(HWND(c));
}
void uiWindowsUtilHide(HWND hwnd)
{
ShowWindow(hwnd, SW_HIDE);
}
2015-05-29 10:56:47 -05:00
static void singleHWNDCommitHide(uiControl *c)
{
uiWindowsUtilHide(HWND(c));
}
void uiWIndowsUtilEnable(HWND hwnd)
{
EnableWindow(hwnd, TRUE);
}
2015-05-29 10:56:47 -05:00
static void singleHWNDCommitEnable(uiControl *c)
{
uiWindowsUtilEnable(HWND(c));
}
void uiWindowsUtilDisable(HWND hwnd)
{
EnableWindow(hwnd, FALSE);
}
2015-05-29 10:56:47 -05:00
static void singleHWNDCommitDisable(uiControl *c)
{
uiWindowsUtilDisable(HWND(c));
}
2015-05-27 15:47:44 -05:00
void uiWindowsUtilSysFunc(HWND hwnd, uiControlSysFuncParams *p)
{
switch (p->Func) {
case uiControlSysFuncNop:
return;
case uiWindowsSysFuncHasTabStops:
if ((getStyle(hwnd) & WS_TABSTOP) != 0)
p->HasTabStops = TRUE;
return;
case uiWindowsSysFuncSetZOrder:
setWindowInsertAfter(hwnd, p->InsertAfter);
p->InsertAfter = hwnd;
return;
}
complain("unknown uiControlSysFunc() function %d in uiWindowsUtilSysFunc()", p->Func);
}
2015-05-29 10:56:47 -05:00
static void singleHWNDSysFunc(uiControl *c, uiControlSysFuncParams *p)
2015-05-27 15:47:44 -05:00
{
uiWindowsUtilSysFunc(HWND(c), p);
}
void uiWindowsUtilStartZOrder(HWND hwnd, uiControlSysFuncParams *p)
{
HWND insertAfter;
// see http://stackoverflow.com/questions/30491418/
insertAfter = GetWindow(hwnd, GW_HWNDPREV);
if (insertAfter == NULL)
logLastError("error getting insert after window in uiWindowsUtilStartZOrder()");
p->InsertAfter = insertAfter;
}
2015-05-29 10:56:47 -05:00
static void singleHWNDStartZOrder(uiControl *c, uiControlSysFuncParams *p)
2015-05-27 15:47:44 -05:00
{
uiWindowsUtilStartZOrder(HWND(c), p);
}