Implemented uiWindowSetMargined() on Windows.
This commit is contained in:
parent
9c2fe78f78
commit
73f6841272
|
@ -55,7 +55,7 @@ BOOL sharedWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void resize(uiControl *control, HWND parent, RECT r)
|
void resize(uiControl *control, HWND parent, RECT r, RECT margin)
|
||||||
{
|
{
|
||||||
uiSizing d;
|
uiSizing d;
|
||||||
HDC dc;
|
HDC dc;
|
||||||
|
@ -83,6 +83,10 @@ void resize(uiControl *control, HWND parent, RECT r)
|
||||||
logLastError("error restoring previous font into device context in resize()");
|
logLastError("error restoring previous font into device context in resize()");
|
||||||
if (ReleaseDC(parent, dc) == 0)
|
if (ReleaseDC(parent, dc) == 0)
|
||||||
logLastError("error releasing DC in resize()");
|
logLastError("error releasing DC in resize()");
|
||||||
|
r.left += uiDlgUnitToX(margin.left, d.baseX);
|
||||||
|
r.top += uiDlgUnitToY(margin.top, d.baseY);
|
||||||
|
r.right -= uiDlgUnitToX(margin.right, d.baseX);
|
||||||
|
r.bottom -= uiDlgUnitToY(margin.bottom, d.baseY);
|
||||||
(*(control->resize))(control, r.left, r.top, r.right - r.left, r.bottom - r.top, &d);
|
(*(control->resize))(control, r.left, r.top, r.right - r.left, r.bottom - r.top, &d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ struct uiSizing {
|
||||||
int baseY;
|
int baseY;
|
||||||
LONG internalLeading;
|
LONG internalLeading;
|
||||||
};
|
};
|
||||||
extern void resize(uiControl *, HWND, RECT);
|
extern void resize(uiControl *, HWND, RECT, RECT);
|
||||||
|
|
||||||
// comctl32_windows.c
|
// comctl32_windows.c
|
||||||
extern BOOL (*WINAPI fv_SetWindowSubclass)(HWND, SUBCLASSPROC, UINT_PTR, DWORD_PTR);
|
extern BOOL (*WINAPI fv_SetWindowSubclass)(HWND, SUBCLASSPROC, UINT_PTR, DWORD_PTR);
|
||||||
|
|
|
@ -7,17 +7,21 @@ struct uiWindow {
|
||||||
BOOL shownOnce;
|
BOOL shownOnce;
|
||||||
int (*onClosing)(uiWindow *, void *);
|
int (*onClosing)(uiWindow *, void *);
|
||||||
void *onClosingData;
|
void *onClosingData;
|
||||||
|
int margined;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define uiWindowClass L"uiWindowClass"
|
#define uiWindowClass L"uiWindowClass"
|
||||||
|
|
||||||
|
// TODO get source
|
||||||
|
#define windowMargin 7
|
||||||
|
|
||||||
static LRESULT CALLBACK uiWindowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
static LRESULT CALLBACK uiWindowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
uiWindow *w;
|
uiWindow *w;
|
||||||
CREATESTRUCTW *cs = (CREATESTRUCTW *) lParam;
|
CREATESTRUCTW *cs = (CREATESTRUCTW *) lParam;
|
||||||
LRESULT lResult;
|
LRESULT lResult;
|
||||||
WINDOWPOS *wp = (WINDOWPOS *) lParam;
|
WINDOWPOS *wp = (WINDOWPOS *) lParam;
|
||||||
RECT r;
|
RECT r, margin;
|
||||||
|
|
||||||
w = (uiWindow *) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
|
w = (uiWindow *) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
|
||||||
if (w == NULL) {
|
if (w == NULL) {
|
||||||
|
@ -38,7 +42,17 @@ static LRESULT CALLBACK uiWindowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPA
|
||||||
break;
|
break;
|
||||||
if (GetClientRect(w->hwnd, &r) == 0)
|
if (GetClientRect(w->hwnd, &r) == 0)
|
||||||
logLastError("error getting window client rect for resize in uiWindowWndProc()");
|
logLastError("error getting window client rect for resize in uiWindowWndProc()");
|
||||||
resize(w->child, w->hwnd, r);
|
margin.left = 0;
|
||||||
|
margin.top = 0;
|
||||||
|
margin.right = 0;
|
||||||
|
margin.bottom = 0;
|
||||||
|
if (w->margined) {
|
||||||
|
margin.left = windowMargin;
|
||||||
|
margin.top = windowMargin;
|
||||||
|
margin.right = windowMargin;
|
||||||
|
margin.bottom = windowMargin;
|
||||||
|
}
|
||||||
|
resize(w->child, w->hwnd, r, margin);
|
||||||
return 0;
|
return 0;
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
if (!(*(w->onClosing))(w, w->onClosingData))
|
if (!(*(w->onClosing))(w, w->onClosingData))
|
||||||
|
@ -165,3 +179,11 @@ void uiWindowSetChild(uiWindow *w, uiControl *c)
|
||||||
w->child = c;
|
w->child = c;
|
||||||
(*(w->child->setParent))(w->child, (uintptr_t) (w->hwnd));
|
(*(w->child->setParent))(w->child, (uintptr_t) (w->hwnd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO uiWindowMargined
|
||||||
|
|
||||||
|
void uiWindowSetMargined(uiWindow *w, int margined)
|
||||||
|
{
|
||||||
|
w->margined = margined;
|
||||||
|
updateParent((uintptr_t) (w->hwnd));
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue