libui/redo/windows/tabpage.c

54 lines
1.3 KiB
C

// 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);
}