Laid the foundation for proper tab navigation in uiTabs.

This commit is contained in:
Pietro Gagliardi 2015-05-06 18:05:07 -04:00
parent ab3fea8cd7
commit c5e5fbd909
5 changed files with 43 additions and 1 deletions

View File

@ -56,6 +56,7 @@ extern void uiWindowsControlSetText(uiControl *, const char *);
struct uiControlSysFuncParams {
int Func;
BOOL HasTabStops;
};
enum {
@ -63,6 +64,11 @@ enum {
// These are needed because while disabling a parent window does cause children to stop receiving events, they are not shown as disabled, which is not what we want.
uiWindowsSysFuncContainerEnable,
uiWindowsSysFuncContainerDisable,
// This is interpreted by controls that are tab stops; the control should set HasTabStops to TRUE if so, and *LEAVE IT ALONE* if not.
// You only need this if implementing your own uiControl.
// Controls created with uiWindowsMakeControl() check for the presence of WS_TABSTOP.
// The name is "has tab stops" because it is used by uiTabs to say "does the current tab page have tab stops?".
uiWindowsSysFuncHasTabStops,
};
#endif

View File

@ -118,6 +118,10 @@ static void singleSysFunc(uiControl *c, uiControlSysFuncParams *p)
s->containerDisabled = 1;
EnableWindow(s->hwnd, FALSE);
return;
case uiWindowsSysFuncHasTabStops:
if ((getStyle(s->hwnd) & WS_TABSTOP) != 0)
p->HasTabStops = TRUE;
return;
}
complain("unknown p->Func %d in singleSysFunc()", p->Func);
}

View File

@ -131,6 +131,14 @@ static void tabSysFunc(uiControl *c, uiControlSysFuncParams *p)
struct tabPage *page;
uintmax_t i;
// we handle tab stops specially
if (p->Func == uiWindowsSysFuncHasTabStops) {
// if there are no tabs, it is not a tab stop
if (t->pages->len != 0)
p->HasTabStops = TRUE;
return;
}
// otherwise distribute it throughout all pages
(*(t->baseSysFunc))(uiControl(t), p);
for (i = 0; i < t->pages->len; i++) {
page = ptrArrayIndex(t->pages, struct tabPage *, i);
@ -324,7 +332,7 @@ uiTab *uiNewTab(void)
p.dwExStyle = 0; // don't set WS_EX_CONTROLPARENT yet; we do that dynamically in the message loop (see main_windows.c)
p.lpClassName = WC_TABCONTROLW;
p.lpWindowName = L"";
p.dwStyle = TCS_TOOLTIPS | WS_TABSTOP;
p.dwStyle = TCS_TOOLTIPS | WS_TABSTOP; // start with this; we will alternate between this and WS_EX_CONTROLPARENT as needed (see main.c and msgHasTabStops above)
p.hInstance = hInstance;
p.useStandardControlFont = TRUE;
p.onWM_COMMAND = onWM_COMMAND;

View File

@ -52,6 +52,10 @@ extern HBRUSH hollowBrush;
// util.c
extern int windowClassOf(HWND, ...);
extern void mapWindowRect(HWND, HWND, RECT *);
extern DWORD getStyle(HWND);
extern void setStyle(HWND, DWORD);
extern DWORD getExStyle(HWND);
extern void setExStyle(HWND, DWORD);
// text.c
extern WCHAR *toUTF16(const char *);

View File

@ -95,3 +95,23 @@ void mapWindowRect(HWND from, HWND to, RECT *r)
logLastError("error calling MapWindowRect() in mapWindowRect()");
}
}
DWORD getStyle(HWND hwnd)
{
return (DWORD) GetWindowLongPtrW(hwnd, GWL_STYLE);
}
void setStyle(HWND hwnd, DWORD style)
{
SetWindowLongPtrW(hwnd, GWL_STYLE, (LONG_PTR) style);
}
DWORD getExStyle(HWND hwnd)
{
return (DWORD) GetWindowLongPtrW(hwnd, GWL_EXSTYLE);
}
void setExStyle(HWND hwnd, DWORD exstyle)
{
SetWindowLongPtrW(hwnd, GWL_EXSTYLE, (LONG_PTR) exstyle);
}