2015-08-31 14:16:36 -05:00
|
|
|
// 16 august 2015
|
2016-04-23 20:38:51 -05:00
|
|
|
#include "uipriv_windows.hpp"
|
2015-08-31 14:16:36 -05:00
|
|
|
|
2016-04-26 18:57:13 -05:00
|
|
|
void uiWindowsControlSyncEnableState(uiWindowsControl *c, int enabled)
|
|
|
|
{
|
|
|
|
(*(c->SyncEnableState))(c, enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
void uiWindowsControlSetParentHWND(uiWindowsControl *c, HWND parent)
|
|
|
|
{
|
|
|
|
(*(c->SetParentHWND))(c, parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void uiWindowsControlMinimumSize(uiWindowsControl *c, intmax_t *width, intmax_t *height)
|
|
|
|
{
|
|
|
|
(*(c->MinimumSize))(c, widdth, height);
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:59:26 -05:00
|
|
|
void uiWindowsControlMinimumSizeChanged(uiWIndowsControl *c)
|
2016-04-26 18:57:13 -05:00
|
|
|
{
|
2016-04-28 15:59:26 -05:00
|
|
|
(*(c->MinimumSizeChanged))(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
void uiWindowsControlLayoutRect(uiWindowsControl *c, RECT *r)
|
|
|
|
{
|
|
|
|
(*(c->LayoutRect))(c, r);
|
2016-04-26 18:57:13 -05:00
|
|
|
}
|
|
|
|
|
2016-04-27 16:51:33 -05:00
|
|
|
void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *c, LONG_PTR *controlID, HWND *insertAfter)
|
2016-04-26 18:57:13 -05:00
|
|
|
{
|
2016-04-27 16:51:33 -05:00
|
|
|
(*(c->AssignControlIDZorder))(c, controlID, insertAfter);
|
2016-04-26 18:57:13 -05:00
|
|
|
}
|
|
|
|
|
2015-09-01 06:33:13 -05:00
|
|
|
HWND uiWindowsEnsureCreateControlHWND(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, HINSTANCE hInstance, LPVOID lpParam, BOOL useStandardControlFont)
|
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
|
2015-09-02 17:26:48 -05:00
|
|
|
// don't let using the arrow keys in a uiRadioButtons leave the radio buttons
|
|
|
|
if ((dwStyle & WS_TABSTOP) != 0)
|
|
|
|
dwStyle |= WS_GROUP;
|
2015-09-01 06:33:13 -05:00
|
|
|
hwnd = CreateWindowExW(dwExStyle,
|
|
|
|
lpClassName, lpWindowName,
|
|
|
|
dwStyle | WS_CHILD | WS_VISIBLE,
|
|
|
|
0, 0,
|
|
|
|
// use a nonzero initial size just in case some control breaks with a zero initial size
|
|
|
|
100, 100,
|
|
|
|
utilWindow, NULL, hInstance, lpParam);
|
2016-04-22 11:44:18 -05:00
|
|
|
if (hwnd == NULL) {
|
2016-04-23 20:38:51 -05:00
|
|
|
logLastError(L"error creating window");
|
2016-04-22 11:44:18 -05:00
|
|
|
// TODO return a decoy window
|
|
|
|
}
|
2015-09-01 06:33:13 -05:00
|
|
|
if (useStandardControlFont)
|
|
|
|
SendMessageW(hwnd, WM_SETFONT, (WPARAM) hMessageFont, (LPARAM) TRUE);
|
|
|
|
return hwnd;
|
|
|
|
}
|
|
|
|
|
2016-04-24 16:38:48 -05:00
|
|
|
// choose a value distinct from uiWindowSignature
|
|
|
|
#define uiWindowsControlSignature 0x4D53576E
|
|
|
|
|
|
|
|
uiWindowsControl *uiWindowsNewControl(size_t n, uint32_t typesig, const char *typenamestr)
|
|
|
|
{
|
2016-04-24 18:22:21 -05:00
|
|
|
return uiWindowsControl(uiAllocControl(n, uiWindowsControlSignature, typesig, typenamestr));
|
2016-04-24 16:38:48 -05:00
|
|
|
}
|
2016-04-26 18:57:13 -05:00
|
|
|
|
|
|
|
void uiWindowsControlNotifyMinimumSizeChanged(uiWindowsControl *c)
|
|
|
|
{
|
|
|
|
uiControl *parent;
|
|
|
|
|
|
|
|
parent = uiControlParent(uiControl(c));
|
|
|
|
if (parent != NULL)
|
|
|
|
uiWindowsControlChildMinimumSizeChanged(uiWindowsControl(parent));
|
|
|
|
}
|
2016-04-27 16:51:33 -05:00
|
|
|
|
|
|
|
void uiWindowsControlAssignSoleControlIDZOrder(uiWindowsControl *c)
|
|
|
|
{
|
|
|
|
LONG_PTR controlID;
|
|
|
|
HWND insertAfter;
|
|
|
|
|
|
|
|
controlID = 100;
|
|
|
|
insertAfter = NULL;
|
|
|
|
uiWindowsControlAssignControlIDZorder(c, &controlID, &insertAfter);
|
|
|
|
}
|
2016-04-28 16:11:32 -05:00
|
|
|
|
|
|
|
BOOL uiWindowsControlTooSmall(uiWindowsControl *c)
|
|
|
|
{
|
|
|
|
RECT r;
|
|
|
|
intmax_t width, height;
|
|
|
|
|
|
|
|
uiWindowsControlLayoutRect(c, &r);
|
|
|
|
uiWindowsControlMinimumSize(c, &width, &height);
|
|
|
|
if ((r.right - r.left) < width)
|
|
|
|
return TRUE;
|
|
|
|
if ((r.bottom - r.top) < height)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void uiWindowsControlContinueMinimumSizeChanged(uiWindowsControl *c)
|
|
|
|
{
|
|
|
|
uiControl *parent;
|
|
|
|
|
|
|
|
parent = uiControlParent(uiControl(c));
|
|
|
|
if (parent != NULL)
|
|
|
|
uiWindowsControlMinimumSizeChanged(uiWindowsControl(parent));
|
|
|
|
}
|