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
|
|
|
|
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-22 11:44:18 -05:00
|
|
|
// TODO make this unnecessary
|
2015-08-31 14:16:36 -05:00
|
|
|
static uintmax_t type_uiWindowsControl = 0;
|
|
|
|
|
|
|
|
uintmax_t uiWindowsControlType(void)
|
|
|
|
{
|
|
|
|
if (type_uiWindowsControl == 0)
|
|
|
|
type_uiWindowsControl = uiRegisterType("uiWindowsControl", uiControlType(), sizeof (uiWindowsControl));
|
|
|
|
return type_uiWindowsControl;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void defaultCommitShow(uiControl *c)
|
|
|
|
{
|
|
|
|
ShowWindow((HWND) uiControlHandle(c), SW_SHOW);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void defaultCommitHide(uiControl *c)
|
|
|
|
{
|
|
|
|
ShowWindow((HWND) uiControlHandle(c), SW_HIDE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void osCommitEnable(uiControl *c)
|
|
|
|
{
|
|
|
|
EnableWindow((HWND) uiControlHandle(c), TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void osCommitDisable(uiControl *c)
|
|
|
|
{
|
|
|
|
EnableWindow((HWND) uiControlHandle(c), FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void uiWindowsFinishControl(uiControl *c)
|
|
|
|
{
|
|
|
|
c->CommitShow = defaultCommitShow;
|
|
|
|
c->CommitHide = defaultCommitHide;
|
|
|
|
}
|
2015-09-01 06:33:13 -05:00
|
|
|
|
2015-09-02 11:59:57 -05:00
|
|
|
void uiWindowsRearrangeControlIDsZOrder(uiControl *c)
|
|
|
|
{
|
|
|
|
uiWindowsControl *wc;
|
|
|
|
|
|
|
|
c = uiControlParent(c);
|
|
|
|
if (c == NULL)
|
|
|
|
return;
|
|
|
|
wc = uiWindowsControl(c);
|
|
|
|
(*(wc->ArrangeChildrenControlIDsZOrder))(wc);
|
|
|
|
}
|