2015-08-30 17:45:45 -05:00
|
|
|
// 28 august 2015
|
2016-04-22 20:36:19 -05:00
|
|
|
#include "uipriv_windows.hpp"
|
2015-08-30 17:45:45 -05:00
|
|
|
|
|
|
|
// This file contains helpers for managing child controls.
|
|
|
|
|
|
|
|
struct child {
|
|
|
|
uiControl *c;
|
|
|
|
HWND hwnd;
|
|
|
|
|
2015-08-31 09:55:33 -05:00
|
|
|
// This is a helper for uiTab pages.
|
|
|
|
// For visual accuracy of tab page backgrounds, margins are also handled here, applied to the child only (rather than applied to the whole tab page).
|
|
|
|
HWND tabpage;
|
|
|
|
int margined;
|
2015-08-30 17:45:45 -05:00
|
|
|
|
|
|
|
// This flag is for users of these functions.
|
|
|
|
// For uiBox, this is "spaced".
|
|
|
|
int flag;
|
2015-08-31 16:05:50 -05:00
|
|
|
|
|
|
|
// These intmax_t variables are for users of these functions.
|
|
|
|
// For uiBox, these are "width" and "height".
|
|
|
|
intmax_t im[2];
|
2015-08-30 17:45:45 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
struct child *newChild(uiControl *child, uiControl *parent, HWND parentHWND)
|
|
|
|
{
|
|
|
|
struct child *c;
|
2015-09-02 12:19:34 -05:00
|
|
|
uiWindowsControl *wc;
|
2015-08-30 17:45:45 -05:00
|
|
|
|
|
|
|
if (child == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
c = uiNew(struct child);
|
|
|
|
c->c = child;
|
|
|
|
c->hwnd = (HWND) uiControlHandle(c->c);
|
|
|
|
|
|
|
|
uiControlSetParent(c->c, parent);
|
2015-09-02 12:19:34 -05:00
|
|
|
wc = uiWindowsControl(c->c);
|
|
|
|
(*(wc->CommitSetParent))(wc, parentHWND);
|
2015-08-30 17:45:45 -05:00
|
|
|
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2015-08-31 09:55:33 -05:00
|
|
|
struct child *newChildWithTabPage(uiControl *child, uiControl *parent, HWND parentHWND)
|
|
|
|
{
|
|
|
|
struct child *c;
|
|
|
|
HWND tabpage;
|
|
|
|
|
|
|
|
tabpage = newTabPage();
|
|
|
|
c = newChild(child, parent, tabpage);
|
|
|
|
uiWindowsEnsureSetParent(tabpage, parentHWND);
|
2015-09-01 08:39:25 -05:00
|
|
|
c->tabpage = tabpage;
|
2015-08-31 09:55:33 -05:00
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2015-08-30 17:45:45 -05:00
|
|
|
void childRemove(struct child *c)
|
|
|
|
{
|
2015-08-31 16:50:23 -05:00
|
|
|
uiWindowsEnsureSetParent(c->hwnd, utilWindow);
|
2015-08-30 17:45:45 -05:00
|
|
|
uiControlSetParent(c->c, NULL);
|
2015-08-31 09:55:33 -05:00
|
|
|
if (c->tabpage != NULL)
|
|
|
|
uiWindowsEnsureDestroyWindow(c->tabpage);
|
2015-08-30 17:45:45 -05:00
|
|
|
uiFree(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
void childDestroy(struct child *c)
|
|
|
|
{
|
|
|
|
uiControl *child;
|
|
|
|
|
|
|
|
child = c->c;
|
|
|
|
childRemove(c);
|
|
|
|
uiControlDestroy(child);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWND childHWND(struct child *c)
|
|
|
|
{
|
|
|
|
return c->hwnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
void childMinimumSize(struct child *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height)
|
|
|
|
{
|
|
|
|
uiWindowsControl *wc;
|
2015-08-31 16:50:23 -05:00
|
|
|
intmax_t left, top, right, bottom;
|
2015-08-30 17:45:45 -05:00
|
|
|
|
|
|
|
wc = uiWindowsControl(c->c);
|
|
|
|
(*(wc->MinimumSize))(wc, d, width, height);
|
2015-08-31 09:55:33 -05:00
|
|
|
if (c->tabpage != NULL && c->margined) {
|
|
|
|
tabPageMargins(c->tabpage, &left, &top, &right, &bottom);
|
|
|
|
*width += left + right;
|
|
|
|
*height += top + bottom;
|
|
|
|
}
|
2015-08-30 17:45:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void childRelayout(struct child *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height)
|
|
|
|
{
|
|
|
|
uiWindowsControl *wc;
|
2015-08-31 09:55:33 -05:00
|
|
|
intmax_t left, top, right, bottom;
|
|
|
|
|
|
|
|
if (c->tabpage != NULL) {
|
2016-04-23 20:38:51 -05:00
|
|
|
uiWindowsEnsureMoveWindowDuringResize(c->tabpage, x, y, width, height);
|
2015-08-31 09:55:33 -05:00
|
|
|
x = 0; // and make relative to the client rect of the tab page
|
|
|
|
y = 0;
|
|
|
|
if (c->margined) {
|
|
|
|
tabPageMargins(c->tabpage, &left, &top, &right, &bottom);
|
|
|
|
x += left;
|
|
|
|
y += top;
|
|
|
|
width -= left + right;
|
|
|
|
height -= top + bottom;
|
|
|
|
}
|
|
|
|
}
|
2015-08-30 17:45:45 -05:00
|
|
|
wc = uiWindowsControl(c->c);
|
|
|
|
(*(wc->Relayout))(wc, x, y, width, height);
|
|
|
|
}
|
|
|
|
|
2015-09-01 06:21:18 -05:00
|
|
|
void childQueueRelayout(struct child *c)
|
|
|
|
{
|
|
|
|
uiWindowsControlQueueRelayout(uiWindowsControl(c->c));
|
|
|
|
}
|
|
|
|
|
2015-09-01 15:44:09 -05:00
|
|
|
int childVisible(struct child *c)
|
|
|
|
{
|
|
|
|
return controlSelfVisible(c->c);
|
|
|
|
}
|
|
|
|
|
2015-08-30 17:45:45 -05:00
|
|
|
void childUpdateState(struct child *c)
|
|
|
|
{
|
|
|
|
controlUpdateState(c->c);
|
|
|
|
}
|
|
|
|
|
2015-09-02 08:36:53 -05:00
|
|
|
void childAssignControlIDZOrder(struct child *c, LONG_PTR *controlID, HWND *insertAfter)
|
|
|
|
{
|
|
|
|
uiWindowsControl *wc;
|
|
|
|
|
|
|
|
wc = uiWindowsControl(c->c);
|
|
|
|
(*(wc->AssignControlIDZOrder))(wc, controlID, insertAfter);
|
|
|
|
}
|
|
|
|
|
2015-09-02 08:18:49 -05:00
|
|
|
void childSetSoleControlID(struct child *c)
|
|
|
|
{
|
|
|
|
uiWindowsEnsureAssignControlIDZOrder(c->hwnd, 100, NULL);
|
|
|
|
}
|
|
|
|
|
2015-08-31 09:55:33 -05:00
|
|
|
HWND childTabPage(struct child *c)
|
|
|
|
{
|
|
|
|
return c->tabpage;
|
|
|
|
}
|
|
|
|
|
|
|
|
int childMargined(struct child *c)
|
|
|
|
{
|
|
|
|
return c->margined;
|
|
|
|
}
|
|
|
|
|
2015-08-31 16:50:23 -05:00
|
|
|
void childSetMargined(struct child *c, int margined)
|
2015-08-31 09:55:33 -05:00
|
|
|
{
|
|
|
|
c->margined = margined;
|
2015-09-01 06:21:18 -05:00
|
|
|
uiWindowsControlQueueRelayout(uiWindowsControl(c->c));
|
2015-08-31 09:55:33 -05:00
|
|
|
}
|
|
|
|
|
2015-08-30 17:45:45 -05:00
|
|
|
int childFlag(struct child *c)
|
|
|
|
{
|
|
|
|
return c->flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
void childSetFlag(struct child *c, int flag)
|
|
|
|
{
|
|
|
|
c->flag = flag;
|
|
|
|
}
|
2015-08-31 16:05:50 -05:00
|
|
|
|
|
|
|
intmax_t childIntmax(struct child *c, int n)
|
|
|
|
{
|
|
|
|
return c->im[n];
|
|
|
|
}
|
|
|
|
|
|
|
|
void childSetIntmax(struct child *c, int n, intmax_t to)
|
|
|
|
{
|
|
|
|
c->im[n] = to;
|
|
|
|
}
|