Implemented uiTab minimum size and uiWindow resize restriction.
This commit is contained in:
parent
54332b90fb
commit
3f1b72721e
|
@ -90,34 +90,29 @@ static void tabCommitSetParent(uiWindowsControl *c, HWND parent)
|
||||||
|
|
||||||
static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height)
|
static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height)
|
||||||
{
|
{
|
||||||
/* TODO
|
|
||||||
uiTab *t = uiTab(c);
|
uiTab *t = uiTab(c);
|
||||||
intmax_t maxwid, maxht;
|
|
||||||
intmax_t pagewid, pageht;
|
intmax_t pagewid, pageht;
|
||||||
uiControl *page;
|
struct child *page;
|
||||||
uintmax_t i;
|
LRESULT n;
|
||||||
RECT r;
|
RECT r;
|
||||||
|
|
||||||
maxwid = 0;
|
// only consider the current page
|
||||||
maxht = 0;
|
pagewid = 0;
|
||||||
for (i = 0; i < t->pages->len; i++) {
|
pageht = 0;
|
||||||
page = ptrArrayIndex(t->pages, struct child *, i);
|
n = curpage(t);
|
||||||
|
if (n != (LRESULT) (-1)) {
|
||||||
|
page = ptrArrayIndex(t->pages, struct child *, n);
|
||||||
childMinimumSize(page, d, &pagewid, &pageht);
|
childMinimumSize(page, d, &pagewid, &pageht);
|
||||||
if (maxwid < pagewid)
|
|
||||||
maxwid = pagewid;
|
|
||||||
if (maxht < pageht)
|
|
||||||
maxht = pageht;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r.left = 0;
|
r.left = 0;
|
||||||
r.top = 0;
|
r.top = 0;
|
||||||
r.right = maxwid;
|
r.right = pagewid;
|
||||||
r.bottom = maxht;
|
r.bottom = pageht;
|
||||||
// this also includes the tabs themselves
|
// this also includes the tabs themselves
|
||||||
SendMessageW(t->hwnd, TCM_ADJUSTRECT, (WPARAM) TRUE, (LPARAM) (&r));
|
SendMessageW(t->hwnd, TCM_ADJUSTRECT, (WPARAM) TRUE, (LPARAM) (&r));
|
||||||
*width = r.right - r.left;
|
*width = r.right - r.left;
|
||||||
*height = r.bottom - r.top;
|
*height = r.bottom - r.top;
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tabRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height)
|
static void tabRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height)
|
||||||
|
|
|
@ -28,6 +28,7 @@ extern DWORD getStyle(HWND);
|
||||||
extern void setStyle(HWND, DWORD);
|
extern void setStyle(HWND, DWORD);
|
||||||
extern DWORD getExStyle(HWND);
|
extern DWORD getExStyle(HWND);
|
||||||
extern void setExStyle(HWND, DWORD);
|
extern void setExStyle(HWND, DWORD);
|
||||||
|
extern void clientSizeToWindowSize(HWND, intmax_t *, intmax_t *, BOOL);
|
||||||
|
|
||||||
// text.c
|
// text.c
|
||||||
extern WCHAR *toUTF16(const char *);
|
extern WCHAR *toUTF16(const char *);
|
||||||
|
|
|
@ -98,3 +98,26 @@ void uiWindowsEnsureAssignControlIDZOrder(HWND hwnd, LONG_PTR controlID, HWND in
|
||||||
SetWindowLongPtrW(hwnd, GWLP_ID, controlID);
|
SetWindowLongPtrW(hwnd, GWLP_ID, controlID);
|
||||||
setWindowInsertAfter(hwnd, insertAfter);
|
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)
|
||||||
|
{
|
||||||
|
RECT window;
|
||||||
|
|
||||||
|
window.left = 0;
|
||||||
|
window.top = 0;
|
||||||
|
window.right = *width;
|
||||||
|
window.bottom = *height;
|
||||||
|
if (AdjustWindowRectEx(&window, getStyle(hwnd), hasMenubar, getExStyle(hwnd)) == 0)
|
||||||
|
logLastError("error getting real window coordinates in clientSizeToWindowSize()");
|
||||||
|
if (hasMenubar) {
|
||||||
|
RECT temp;
|
||||||
|
|
||||||
|
temp = window;
|
||||||
|
temp.bottom = 0x7FFF; // infinite height
|
||||||
|
SendMessageW(hwnd, WM_NCCALCSIZE, (WPARAM) FALSE, (LPARAM) (&temp));
|
||||||
|
window.bottom += temp.top;
|
||||||
|
}
|
||||||
|
*width = window.right - window.left;
|
||||||
|
*height = window.bottom - window.top;
|
||||||
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ struct uiWindow {
|
||||||
int (*onClosing)(uiWindow *, void *);
|
int (*onClosing)(uiWindow *, void *);
|
||||||
void *onClosingData;
|
void *onClosingData;
|
||||||
int margined;
|
int margined;
|
||||||
|
BOOL hasMenubar;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void onDestroy(uiWindow *);
|
static void onDestroy(uiWindow *);
|
||||||
|
@ -28,6 +29,9 @@ static LRESULT CALLBACK windowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA
|
||||||
uiWindow *w;
|
uiWindow *w;
|
||||||
CREATESTRUCTW *cs = (CREATESTRUCTW *) lParam;
|
CREATESTRUCTW *cs = (CREATESTRUCTW *) lParam;
|
||||||
WINDOWPOS *wp = (WINDOWPOS *) lParam;
|
WINDOWPOS *wp = (WINDOWPOS *) lParam;
|
||||||
|
MINMAXINFO *mmi = (MINMAXINFO *) lParam;
|
||||||
|
uiWindowsControl *c;
|
||||||
|
intmax_t width, height;
|
||||||
LRESULT lResult;
|
LRESULT lResult;
|
||||||
|
|
||||||
ww = GetWindowLongPtrW(hwnd, GWLP_USERDATA);
|
ww = GetWindowLongPtrW(hwnd, GWLP_USERDATA);
|
||||||
|
@ -55,6 +59,18 @@ static LRESULT CALLBACK windowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA
|
||||||
if (w->child != NULL)
|
if (w->child != NULL)
|
||||||
childQueueRelayout(w->child);
|
childQueueRelayout(w->child);
|
||||||
return 0;
|
return 0;
|
||||||
|
case WM_GETMINMAXINFO:
|
||||||
|
// ensure the user cannot resize the window smaller than its minimum size
|
||||||
|
lResult = DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
||||||
|
if (w->child == NULL)
|
||||||
|
return lResult;
|
||||||
|
c = uiWindowsControl(w);
|
||||||
|
(*(c->MinimumSize))(c, NULL, &width, &height);
|
||||||
|
// width and height are in client coordinates; ptMinTrackSize is in window coordinates
|
||||||
|
clientSizeToWindowSize(w->hwnd, &width, &height, w->hasMenubar);
|
||||||
|
mmi->ptMinTrackSize.x = width;
|
||||||
|
mmi->ptMinTrackSize.y = height;
|
||||||
|
return lResult;
|
||||||
case WM_PRINTCLIENT:
|
case WM_PRINTCLIENT:
|
||||||
// we do no special painting; just erase the background
|
// we do no special painting; just erase the background
|
||||||
// don't worry about the return value; we let DefWindowProcW() handle this message
|
// don't worry about the return value; we let DefWindowProcW() handle this message
|
||||||
|
@ -249,6 +265,7 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
||||||
hasMenubarBOOL = FALSE;
|
hasMenubarBOOL = FALSE;
|
||||||
if (hasMenubar)
|
if (hasMenubar)
|
||||||
hasMenubarBOOL = TRUE;
|
hasMenubarBOOL = TRUE;
|
||||||
|
w->hasMenubar = hasMenubarBOOL;
|
||||||
|
|
||||||
#define style WS_OVERLAPPEDWINDOW
|
#define style WS_OVERLAPPEDWINDOW
|
||||||
#define exstyle 0
|
#define exstyle 0
|
||||||
|
|
Loading…
Reference in New Issue