Split the public functions out of winutil.cpp to organize things. Renamed uiWindowsEnsureSetParent() to uiWindowsEnsureSetParentHWND() to denote its intended use.
This commit is contained in:
parent
37e83d133b
commit
227c3b3ec1
|
@ -106,7 +106,7 @@ _UI_EXTERN void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *, LONG_P
|
|||
#define uiWindowsControlDefaultSetParentHWND(type) \
|
||||
static void type ## SetParentHWND(uiWindowsControl *c, HWND parent) \
|
||||
{ \
|
||||
uiWindowsEnsureSetParent(type(c)->hwnd, parent); \
|
||||
uiWindowsEnsureSetParentHWND(type(c)->hwnd, parent); \
|
||||
}
|
||||
// note that there is no uiWindowsControlDefaultMinimumSize(); you MUST define this yourself!
|
||||
#define uiWindowsDefaultChildMinimumSizeChanged(type) \
|
||||
|
@ -171,7 +171,7 @@ _UI_EXTERN HWND uiWindowsEnsureCreateControlHWND(DWORD dwExStyle, LPCWSTR lpClas
|
|||
_UI_EXTERN void uiWindowsEnsureDestroyWindow(HWND hwnd);
|
||||
|
||||
// TODO document
|
||||
_UI_EXTERN void uiWindowsEnsureSetParent(HWND hwnd, HWND parent);
|
||||
_UI_EXTERN void uiWindowsEnsureSetParentHWND(HWND hwnd, HWND parent);
|
||||
|
||||
// TODO document
|
||||
_UI_EXTERN void uiWindowsEnsureAssignControlIDZOrder(HWND hwnd, LONG_PTR *controlID, HWND *insertAfter);
|
||||
|
|
|
@ -44,6 +44,7 @@ CXXFILES += \
|
|||
windows/utf16.cpp \
|
||||
windows/utilwin.cpp \
|
||||
windows/window.cpp \
|
||||
windows/winpublic.cpp \
|
||||
windows/winutil.cpp
|
||||
|
||||
HFILES += \
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
// 6 april 2015
|
||||
#include "uipriv_windows.hpp"
|
||||
|
||||
void uiWindowsEnsureDestroyWindow(HWND hwnd)
|
||||
{
|
||||
if (DestroyWindow(hwnd) == 0)
|
||||
logLastError(L"error destroying window");
|
||||
}
|
||||
|
||||
void uiWindowsEnsureSetParentHWND(HWND hwnd, HWND parent)
|
||||
{
|
||||
if (parent == NULL)
|
||||
parent = utilWindow;
|
||||
if (SetParent(hwnd, parent) == 0)
|
||||
logLastError(L"error setting window parent");
|
||||
}
|
||||
|
||||
void uiWindowsEnsureAssignControlIDZOrder(HWND hwnd, LONG_PTR controlID, HWND insertAfter)
|
||||
{
|
||||
SetWindowLongPtrW(hwnd, GWLP_ID, controlID);
|
||||
setWindowInsertAfter(hwnd, insertAfter);
|
||||
}
|
||||
|
||||
void uiWindowsEnsureMoveWindowDuringResize(HWND hwnd, intmax_t x, intmax_t y, intmax_t width, intmax_t height)
|
||||
{
|
||||
RECT r;
|
||||
|
||||
r.left = x;
|
||||
r.top = y;
|
||||
r.right = x + width;
|
||||
r.bottom = y + height;
|
||||
if (SetWindowPos(hwnd, NULL, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOREDRAW | SWP_NOZORDER) == 0)
|
||||
logLastError(L"error moving window");
|
||||
}
|
|
@ -76,26 +76,6 @@ void setExStyle(HWND hwnd, DWORD exstyle)
|
|||
SetWindowLongPtrW(hwnd, GWL_EXSTYLE, (LONG_PTR) exstyle);
|
||||
}
|
||||
|
||||
void uiWindowsEnsureDestroyWindow(HWND hwnd)
|
||||
{
|
||||
if (DestroyWindow(hwnd) == 0)
|
||||
logLastError(L"error destroying window");
|
||||
}
|
||||
|
||||
// TODO allow passing NULL to indicate no parent
|
||||
// this would allow for custom containers
|
||||
void uiWindowsEnsureSetParent(HWND hwnd, HWND parent)
|
||||
{
|
||||
if (SetParent(hwnd, parent) == 0)
|
||||
logLastError(L"error setting window parent");
|
||||
}
|
||||
|
||||
void uiWindowsEnsureAssignControlIDZOrder(HWND hwnd, LONG_PTR controlID, HWND insertAfter)
|
||||
{
|
||||
SetWindowLongPtrW(hwnd, GWLP_ID, controlID);
|
||||
setWindowInsertAfter(hwnd, insertAfter);
|
||||
}
|
||||
|
||||
// see http://blogs.msdn.com/b/oldnewthing/archive/2003/09/11/54885.aspx and http://blogs.msdn.com/b/oldnewthing/archive/2003/09/13/54917.aspx
|
||||
void clientSizeToWindowSize(HWND hwnd, intmax_t *width, intmax_t *height, BOOL hasMenubar)
|
||||
{
|
||||
|
@ -135,18 +115,6 @@ HWND parentToplevel(HWND child)
|
|||
return GetAncestor(child, GA_ROOT);
|
||||
}
|
||||
|
||||
void uiWindowsEnsureMoveWindowDuringResize(HWND hwnd, intmax_t x, intmax_t y, intmax_t width, intmax_t height)
|
||||
{
|
||||
RECT r;
|
||||
|
||||
r.left = x;
|
||||
r.top = y;
|
||||
r.right = x + width;
|
||||
r.bottom = y + height;
|
||||
if (SetWindowPos(hwnd, NULL, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOREDRAW | SWP_NOZORDER) == 0)
|
||||
logLastError(L"error moving window");
|
||||
}
|
||||
|
||||
void setWindowInsertAfter(HWND hwnd, HWND insertAfter)
|
||||
{
|
||||
if (SetWindowPos(hwnd, insertAfter, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOSIZE) == 0)
|
||||
|
|
Loading…
Reference in New Issue