Started splitting the role of a tab page over to a new internal control.
This commit is contained in:
parent
c1773621ac
commit
1a55d1fcb3
|
@ -26,6 +26,7 @@ osCFILES = \
|
||||||
windows/spinbox.c \
|
windows/spinbox.c \
|
||||||
windows/stddialogs.c \
|
windows/stddialogs.c \
|
||||||
windows/tab.c \
|
windows/tab.c \
|
||||||
|
windows/tabpage.c \
|
||||||
windows/text.c \
|
windows/text.c \
|
||||||
windows/util.c \
|
windows/util.c \
|
||||||
windows/utilwin.c \
|
windows/utilwin.c \
|
||||||
|
|
|
@ -12,11 +12,6 @@ struct tab {
|
||||||
void (*baseCommitDestroy)(uiControl *);
|
void (*baseCommitDestroy)(uiControl *);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tabPage {
|
|
||||||
uiControl *control;
|
|
||||||
int margined;
|
|
||||||
};
|
|
||||||
|
|
||||||
uiDefineControlType(uiTab, uiTypeTab, struct tab)
|
uiDefineControlType(uiTab, uiTypeTab, struct tab)
|
||||||
|
|
||||||
// utility functions
|
// utility functions
|
||||||
|
@ -28,17 +23,17 @@ static LRESULT curpage(struct tab *t)
|
||||||
|
|
||||||
static void showHidePage(struct tab *t, LRESULT which, int hide)
|
static void showHidePage(struct tab *t, LRESULT which, int hide)
|
||||||
{
|
{
|
||||||
struct tabPage *page;
|
uiControl *page;
|
||||||
|
|
||||||
if (which == (LRESULT) (-1))
|
if (which == (LRESULT) (-1))
|
||||||
return;
|
return;
|
||||||
page = ptrArrayIndex(t->pages, struct tabPage *, which);
|
page = ptrArrayIndex(t->pages, uiControl *, which);
|
||||||
if (hide)
|
if (hide)
|
||||||
;//TODO uiControlContainerHide(page->control);
|
uiControlHide(page);
|
||||||
else {
|
else {
|
||||||
//TODO uiControlContainerShow(page->control);
|
uiControlShow(page);
|
||||||
// we only resize the current page, so we have to do this here
|
// we only resize the current page, so we have to do this here
|
||||||
uiControlQueueResize(page->control);
|
uiControlQueueResize(page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +123,7 @@ static void tabAppend(uiTab *tt, const char *name, uiControl *child)
|
||||||
static void tabInsertAt(uiTab *tt, const char *name, uintmax_t n, uiControl *child)
|
static void tabInsertAt(uiTab *tt, const char *name, uintmax_t n, uiControl *child)
|
||||||
{
|
{
|
||||||
struct tab *t = (struct tab *) tt;
|
struct tab *t = (struct tab *) tt;
|
||||||
struct tabPage *page;
|
uiControl *page;
|
||||||
LRESULT hide, show;
|
LRESULT hide, show;
|
||||||
TCITEMW item;
|
TCITEMW item;
|
||||||
WCHAR *wname;
|
WCHAR *wname;
|
||||||
|
@ -136,11 +131,10 @@ static void tabInsertAt(uiTab *tt, const char *name, uintmax_t n, uiControl *chi
|
||||||
// see below
|
// see below
|
||||||
hide = curpage(t);
|
hide = curpage(t);
|
||||||
|
|
||||||
page = uiNew(struct tabPage);
|
page = newTabPage(child);
|
||||||
page->control = child;
|
uiControlSetParent(page, uiControl(t));
|
||||||
uiControlSetParent(page->control, uiControl(t));
|
|
||||||
// and make it invisible at first; we show it later if needed
|
// and make it invisible at first; we show it later if needed
|
||||||
//TODO uiControlContainerHide(page->control);
|
uiControlHide(page);
|
||||||
ptrArrayInsertAt(t->pages, n, page);
|
ptrArrayInsertAt(t->pages, n, page);
|
||||||
|
|
||||||
ZeroMemory(&item, sizeof (TCITEMW));
|
ZeroMemory(&item, sizeof (TCITEMW));
|
||||||
|
@ -162,7 +156,7 @@ static void tabInsertAt(uiTab *tt, const char *name, uintmax_t n, uiControl *chi
|
||||||
static void tabDelete(uiTab *tt, uintmax_t n)
|
static void tabDelete(uiTab *tt, uintmax_t n)
|
||||||
{
|
{
|
||||||
struct tab *t = (struct tab *) tt;
|
struct tab *t = (struct tab *) tt;
|
||||||
struct tabPage *page;
|
uiControl *page;
|
||||||
|
|
||||||
// first delete the tab from the tab control
|
// first delete the tab from the tab control
|
||||||
// if this is the current tab, no tab will be selected, which is good
|
// if this is the current tab, no tab will be selected, which is good
|
||||||
|
@ -170,15 +164,13 @@ static void tabDelete(uiTab *tt, uintmax_t n)
|
||||||
logLastError("error deleting uiTab tab in tabDelete()");
|
logLastError("error deleting uiTab tab in tabDelete()");
|
||||||
|
|
||||||
// now delete the page itself
|
// now delete the page itself
|
||||||
page = ptrArrayIndex(t->pages, struct tabPage *, n);
|
page = ptrArrayIndex(t->pages, uiControl *, n);
|
||||||
ptrArrayDelete(t->pages, n);
|
ptrArrayDelete(t->pages, n);
|
||||||
|
|
||||||
// and keep the page control alive
|
// and free the page
|
||||||
uiControlSetParent(page->control, NULL);
|
// this will keep the control alive
|
||||||
// and show it again, as we don't know where it will go next
|
uiControlSetParent(page, NULL);
|
||||||
//TODO uiControlContainerShow(page->control);
|
uiControlDestroy(page);
|
||||||
|
|
||||||
uiFree(page);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uintmax_t tabNumPages(uiTab *tt)
|
static uintmax_t tabNumPages(uiTab *tt)
|
||||||
|
@ -191,20 +183,21 @@ static uintmax_t tabNumPages(uiTab *tt)
|
||||||
static int tabMargined(uiTab *tt, uintmax_t n)
|
static int tabMargined(uiTab *tt, uintmax_t n)
|
||||||
{
|
{
|
||||||
struct tab *t = (struct tab *) tt;
|
struct tab *t = (struct tab *) tt;
|
||||||
struct tabPage *page;
|
uiControl *page;
|
||||||
|
|
||||||
page = ptrArrayIndex(t->pages, struct tabPage *, n);
|
page = ptrArrayIndex(t->pages, uiControl *, n);
|
||||||
return page->margined;
|
//TODO return page->margined;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tabSetMargined(uiTab *tt, uintmax_t n, int margined)
|
static void tabSetMargined(uiTab *tt, uintmax_t n, int margined)
|
||||||
{
|
{
|
||||||
struct tab *t = (struct tab *) tt;
|
struct tab *t = (struct tab *) tt;
|
||||||
struct tabPage *page;
|
uiControl *page;
|
||||||
|
|
||||||
page = ptrArrayIndex(t->pages, struct tabPage *, n);
|
page = ptrArrayIndex(t->pages, uiControl *, n);
|
||||||
page->margined = margined;
|
//TODO page->margined = margined;
|
||||||
uiControlQueueResize(page->control);
|
//TODO uiControlQueueResize(page->control);
|
||||||
}
|
}
|
||||||
|
|
||||||
uiTab *uiNewTab(void)
|
uiTab *uiNewTab(void)
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
// 30 may 2015
|
||||||
|
#include "uicontrol_windows.h"
|
||||||
|
|
||||||
|
// This is a special internal control type that handles tab pages.
|
||||||
|
// This doesn't use the container class, but rather a subclassed WC_DIALOG, as that supports tab textures properly.
|
||||||
|
// The standard property sheet control oes the same thing.
|
||||||
|
// TODO (long term) figure out how to use uiContainer with this
|
||||||
|
|
||||||
|
struct tabPage {
|
||||||
|
uiControl c;
|
||||||
|
HWND hwnd;
|
||||||
|
uiControl *control;
|
||||||
|
int margined;
|
||||||
|
};
|
||||||
|
|
||||||
|
uiDefineControlType(tabPage, tabPageType, struct tabPage)
|
||||||
|
|
||||||
|
// TODO override methods
|
||||||
|
// TODO when overriding CommitDestroy, DO NOT DESTROY THE CHILD
|
||||||
|
|
||||||
|
static uintptr_t tabPageHandle(uiControl *c)
|
||||||
|
{
|
||||||
|
struct tabPage *t = (struct tabPage *) c;
|
||||||
|
|
||||||
|
return (uintptr_t) (t->hwnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
uiControl *newTabPage(uiControl *child)
|
||||||
|
{
|
||||||
|
struct tabPage *t;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
t = (struct tabPage *) uiWindowsNewSingleHWNDControl(tabPageType());
|
||||||
|
|
||||||
|
t->hwnd = uiWindowsUtilCreateControlHWND(WS_EX_CONTROLPARENT,
|
||||||
|
WC_DIALOGW, L"",
|
||||||
|
0,
|
||||||
|
hInstance, NULL,
|
||||||
|
FALSE);
|
||||||
|
|
||||||
|
hr = EnableThemeDialogTexture(t->hwnd, ETDT_ENABLE | ETDT_USETABTEXTURE | ETDT_ENABLETAB);
|
||||||
|
if (hr != S_OK)
|
||||||
|
logHRESULT("error setting tab page background in newTabPage()", hr);
|
||||||
|
|
||||||
|
// TODO subclass hwnd to handle events
|
||||||
|
|
||||||
|
t->control = child;
|
||||||
|
uiControlSetParent(t->control, uiControl(t));
|
||||||
|
|
||||||
|
uiControl(t)->Handle = tabPageHandle;
|
||||||
|
|
||||||
|
return uiControl(t);
|
||||||
|
}
|
|
@ -131,3 +131,6 @@ extern void endDialogHelper(HWND);
|
||||||
|
|
||||||
// control.c
|
// control.c
|
||||||
extern void setSingleHWNDFuncs(uiControl *);
|
extern void setSingleHWNDFuncs(uiControl *);
|
||||||
|
|
||||||
|
// tabpage.c
|
||||||
|
extern uiControl *newTabPage(uiControl *);
|
||||||
|
|
Loading…
Reference in New Issue