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);
|
|
|
|
}
|
|
|
|
|
2016-06-13 20:23:05 -05:00
|
|
|
void uiWindowsControlMinimumSize(uiWindowsControl *c, int *width, int *height)
|
2016-04-26 18:57:13 -05:00
|
|
|
{
|
2016-04-29 16:08:31 -05:00
|
|
|
(*(c->MinimumSize))(c, width, height);
|
2016-04-26 18:57:13 -05:00
|
|
|
}
|
|
|
|
|
2016-04-29 16:08:31 -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);
|
|
|
|
}
|
|
|
|
|
2016-06-14 14:55:24 -05:00
|
|
|
// TODO get rid of this
|
2016-04-28 15:59:26 -05:00
|
|
|
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-29 16:08:31 -05:00
|
|
|
(*(c->AssignControlIDZOrder))(c, controlID, insertAfter);
|
2016-04-26 18:57:13 -05:00
|
|
|
}
|
|
|
|
|
2016-06-14 14:55:24 -05:00
|
|
|
void uiWindowsControlChildVisibilityChanged(uiWindowsControl *c)
|
|
|
|
{
|
|
|
|
(*(c->ChildVisibilityChanged))(c);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
2016-04-29 16:08:31 -05:00
|
|
|
uiWindowsControl *uiWindowsAllocControl(size_t n, uint32_t typesig, const char *typenamestr)
|
2016-04-24 16:38:48 -05:00
|
|
|
{
|
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
|
|
|
|
2016-04-29 16:08:31 -05:00
|
|
|
BOOL uiWindowsShouldStopSyncEnableState(uiWindowsControl *c, BOOL enabled)
|
2016-04-26 18:57:13 -05:00
|
|
|
{
|
2016-04-29 16:08:31 -05:00
|
|
|
int ce;
|
2016-04-26 18:57:13 -05:00
|
|
|
|
2016-04-29 16:08:31 -05:00
|
|
|
ce = uiControlEnabled(uiControl(c));
|
|
|
|
// only stop if we're going from disabled back to enabled; don't stop under any other condition
|
|
|
|
// (if we stop when going from enabled to disabled then enabled children of a disabled control won't get disabled at the OS level)
|
|
|
|
if (!ce && enabled)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
2016-04-26 18:57:13 -05:00
|
|
|
}
|
2016-04-27 16:51:33 -05:00
|
|
|
|
|
|
|
void uiWindowsControlAssignSoleControlIDZOrder(uiWindowsControl *c)
|
|
|
|
{
|
|
|
|
LONG_PTR controlID;
|
|
|
|
HWND insertAfter;
|
|
|
|
|
|
|
|
controlID = 100;
|
|
|
|
insertAfter = NULL;
|
2016-04-29 16:08:31 -05:00
|
|
|
uiWindowsControlAssignControlIDZOrder(c, &controlID, &insertAfter);
|
2016-04-27 16:51:33 -05:00
|
|
|
}
|
2016-04-28 16:11:32 -05:00
|
|
|
|
|
|
|
BOOL uiWindowsControlTooSmall(uiWindowsControl *c)
|
|
|
|
{
|
|
|
|
RECT r;
|
2016-06-13 20:23:05 -05:00
|
|
|
int width, height;
|
2016-04-28 16:11:32 -05:00
|
|
|
|
|
|
|
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));
|
|
|
|
}
|
2016-06-14 14:55:24 -05:00
|
|
|
|
|
|
|
// TODO rename this nad the OS X this and hugging ones to NotifyChild
|
|
|
|
void uiWindowsControlNotifyVisibilityChanged(uiWindowsControl *c)
|
|
|
|
{
|
|
|
|
// TODO we really need to figure this out; the duplication is a mess
|
|
|
|
uiWindowsControlContinueMinimumSizeChanged(c);
|
|
|
|
}
|