More uiWindow work.
This commit is contained in:
parent
4f99fdd90f
commit
ae8bb69385
|
@ -84,83 +84,6 @@ static int defaultOnClosing(uiWindow *w, void *data)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static char *windowTitle(uiWindow *ww)
|
||||
{
|
||||
struct window *w = (struct window *) ww;
|
||||
WCHAR *wtext;
|
||||
char *text;
|
||||
|
||||
wtext = windowText(w->hwnd);
|
||||
text = toUTF8(wtext);
|
||||
uiFree(wtext);
|
||||
return text;
|
||||
}
|
||||
|
||||
static void windowSetTitle(uiWindow *ww, const char *text)
|
||||
{
|
||||
struct window *w = (struct window *) ww;
|
||||
WCHAR *wtext;
|
||||
|
||||
wtext = toUTF16(text);
|
||||
if (SetWindowTextW(w->hwnd, wtext) == 0)
|
||||
logLastError("error setting window title in uiWindowSetTitle()");
|
||||
uiFree(wtext);
|
||||
}
|
||||
|
||||
static void windowShow(uiWindow *ww)
|
||||
{
|
||||
struct window *w = (struct window *) ww;
|
||||
|
||||
if (w->shownOnce) {
|
||||
ShowWindow(w->hwnd, SW_SHOW);
|
||||
return;
|
||||
}
|
||||
w->shownOnce = TRUE;
|
||||
ShowWindow(w->hwnd, nCmdShow);
|
||||
if (UpdateWindow(w->hwnd) == 0)
|
||||
logLastError("error calling UpdateWindow() after showing uiWindow for the first time");
|
||||
}
|
||||
|
||||
static void windowOnClosing(uiWindow *ww, int (*f)(uiWindow *, void *), void *data)
|
||||
{
|
||||
struct window *w = (struct window *) ww;
|
||||
|
||||
w->onClosing = f;
|
||||
w->onClosingData = data;
|
||||
}
|
||||
|
||||
static void windowSetChild(uiWindow *ww, uiControl *c)
|
||||
{
|
||||
struct window *w = (struct window *) ww;
|
||||
|
||||
uiOSContainerSetMainControl(w->content, c);
|
||||
// don't call uiOSContainerUpdate(); instead, synthesize a resize
|
||||
// otherwise, we'll have a 0x0 content area at first
|
||||
SendMessageW(w->hwnd, msgUpdateChild, 0, 0);
|
||||
}
|
||||
|
||||
static int windowMargined(uiWindow *ww)
|
||||
{
|
||||
struct window *w = (struct window *) ww;
|
||||
|
||||
return w->margined;
|
||||
}
|
||||
|
||||
// from https://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
|
||||
#define windowMargin 7
|
||||
|
||||
static void windowSetMargined(uiWindow *ww, int margined)
|
||||
{
|
||||
struct window *w = (struct window *) ww;
|
||||
|
||||
w->margined = margined;
|
||||
if (w->margined)
|
||||
uiOSContainerSetMargins(w->content, windowMargin, windowMargin, windowMargin, windowMargin);
|
||||
else
|
||||
uiOSContainerSetMargins(w->content, 0, 0, 0, 0);
|
||||
uiOSContainerUpdate(w->content);
|
||||
}
|
||||
|
||||
uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
||||
{
|
||||
struct window *w;
|
||||
|
|
|
@ -6,6 +6,9 @@ struct window {
|
|||
HWND hwnd;
|
||||
uiContainer *bin;
|
||||
int hidden;
|
||||
BOOL shownOnce;
|
||||
int (*onClosing)(uiWindow *, void *);
|
||||
void *onClosingData;
|
||||
int margined;
|
||||
};
|
||||
|
||||
|
@ -60,8 +63,15 @@ static void windowShow(uiControl *w)
|
|||
{
|
||||
struct window *w = (struct window *) c;
|
||||
|
||||
// TODO first show logic
|
||||
ShowWindow(w->hwnd, SW_SHOW);
|
||||
if (w->shownOnce) {
|
||||
ShowWindow(w->hwnd, SW_SHOW);
|
||||
w->hidden = 0;
|
||||
return;
|
||||
}
|
||||
w->shownOnce = TRUE;
|
||||
ShowWindow(w->hwnd, nCmdShow);
|
||||
if (UpdateWindow(w->hwnd) == 0)
|
||||
logLastError("error calling UpdateWindow() after showing uiWindow for the first time in windowShow()");
|
||||
w->hidden = 0;
|
||||
}
|
||||
|
||||
|
@ -86,3 +96,62 @@ static void windowDisable(uiControl *c)
|
|||
|
||||
EnableWindow(w->hwnd, FALSE);
|
||||
}
|
||||
|
||||
static char *windowTitle(uiWindow *ww)
|
||||
{
|
||||
struct window *w = (struct window *) ww;
|
||||
WCHAR *wtext;
|
||||
char *text;
|
||||
|
||||
wtext = windowText(w->hwnd);
|
||||
text = toUTF8(wtext);
|
||||
uiFree(wtext);
|
||||
return text;
|
||||
}
|
||||
|
||||
static void windowSetTitle(uiWindow *ww, const char *title)
|
||||
{
|
||||
struct window *w = (struct window *) ww;
|
||||
WCHAR *wtext;
|
||||
|
||||
wtext = toUTF16(text);
|
||||
if (SetWindowTextW(w->hwnd, wtext) == 0)
|
||||
logLastError("error setting window title in uiWindowSetTitle()");
|
||||
uiFree(wtext);
|
||||
}
|
||||
|
||||
static void windowOnClosing(uiWindow *ww, int (*f)(uiWindow *, void *), void *data)
|
||||
{
|
||||
struct window *w = (struct window *) ww;
|
||||
|
||||
w->onClosing = f;
|
||||
w->onClosingData = data;
|
||||
}
|
||||
|
||||
static void windowSetChild(uiWindow *ww, uiControl *child)
|
||||
{
|
||||
struct window *w = (struct window *) ww;
|
||||
|
||||
binSetMainControl(w->bin, child);
|
||||
}
|
||||
|
||||
static int windowMargined(uiWindow *ww)
|
||||
{
|
||||
struct window *w = (struct window *) ww;
|
||||
|
||||
return w->margined;
|
||||
}
|
||||
|
||||
// from https://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
|
||||
#define windowMargin 7
|
||||
|
||||
static void windowSetMargined(uiWindow *ww, int margined)
|
||||
{
|
||||
struct window *w = (struct window *) ww;
|
||||
|
||||
w->margined = margined;
|
||||
if (w->margined)
|
||||
binSetMargins(w->bin, windowMargin, windowMargin, windowMargin, windowMargin);
|
||||
else
|
||||
binSetMargins(w->bin, 0, 0, 0, 0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue