More work on winrebarexplorertheme.cpp, including the boilerplate for custom draw. More TODOs in general.
This commit is contained in:
parent
d082b4efa4
commit
6a22c61cd4
|
@ -36,6 +36,10 @@ HWND rebar;
|
||||||
HWND leftbar;
|
HWND leftbar;
|
||||||
HWND rightbar;
|
HWND rightbar;
|
||||||
HWND rebarCombo;
|
HWND rebarCombo;
|
||||||
|
HWND toolbarCombo;
|
||||||
|
HWND toolbarTransparentCheckbox;
|
||||||
|
|
||||||
|
#define toolbarStyles (WS_CHILD | CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_NORESIZE | TBSTYLE_FLAT | TBSTYLE_LIST)
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
const WCHAR *text;
|
const WCHAR *text;
|
||||||
|
@ -48,13 +52,28 @@ static struct {
|
||||||
{ L"New folder", FALSE },
|
{ L"New folder", FALSE },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const WCHAR *buttons[] = {
|
LRESULT customDrawVista(NMCUSTOMDRAW *nm)
|
||||||
L"SetWindowTheme()",
|
{
|
||||||
L"Custom Draw Vista",
|
return CDRF_DODEFAULT;
|
||||||
L"Custom Draw 7",
|
}
|
||||||
NULL,
|
|
||||||
|
LRESULT customDraw7(NMCUSTOMDRAW *nm)
|
||||||
|
{
|
||||||
|
return CDRF_DODEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
const WCHAR *text;
|
||||||
|
LRESULT (*handle)(NMCUSTOMDRAW *nm);
|
||||||
|
} drawmodes[] = {
|
||||||
|
{ L"SetWindowTheme()", NULL },
|
||||||
|
{ L"Custom Draw Vista", customDrawVista },
|
||||||
|
{ L"Custom Draw 7", customDraw7 },
|
||||||
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int drawmode = 0;
|
||||||
|
|
||||||
static const WCHAR *rebarThemes[] = {
|
static const WCHAR *rebarThemes[] = {
|
||||||
L"NULL",
|
L"NULL",
|
||||||
L"",
|
L"",
|
||||||
|
@ -83,6 +102,47 @@ static const WCHAR *rebarThemes[] = {
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static WCHAR *toolbarThemes[] = {
|
||||||
|
L"NULL",
|
||||||
|
L"",
|
||||||
|
L"Alternate",
|
||||||
|
L"BB",
|
||||||
|
L"BBComposited",
|
||||||
|
L"Communications",
|
||||||
|
L"ExplorerMenu",
|
||||||
|
L"Go",
|
||||||
|
L"GoComposited",
|
||||||
|
L"InactiveBB",
|
||||||
|
L"InactiveBBComposited",
|
||||||
|
L"InactiveGo",
|
||||||
|
L"InactiveGoComposited",
|
||||||
|
L"InfoPaneToolbar",
|
||||||
|
L"LVPopup",
|
||||||
|
L"LVPopupBottom",
|
||||||
|
L"MaxBB",
|
||||||
|
L"MaxBBComposited",
|
||||||
|
L"MaxGo",
|
||||||
|
L"MaxGoComposited",
|
||||||
|
L"MaxInactiveBB",
|
||||||
|
L"MaxInactiveBBComposited",
|
||||||
|
L"MaxInactiveGo",
|
||||||
|
L"MaxInactiveGoComposited",
|
||||||
|
L"Media",
|
||||||
|
L"Placesbar",
|
||||||
|
L"SearchButton",
|
||||||
|
L"SearchButtonComposited",
|
||||||
|
L"StartMenu",
|
||||||
|
L"TaskBar",
|
||||||
|
L"TaskBarComposited",
|
||||||
|
L"TaskBarVert",
|
||||||
|
L"TaskBarVertComposited",
|
||||||
|
L"Toolbar",
|
||||||
|
L"ToolbarStyle",
|
||||||
|
L"TrayNotify",
|
||||||
|
L"TrayNotifyComposited",
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
// TODO toolbarThemes
|
// TODO toolbarThemes
|
||||||
|
|
||||||
void onWM_CREATE(HWND hwnd)
|
void onWM_CREATE(HWND hwnd)
|
||||||
|
@ -107,7 +167,7 @@ void onWM_CREATE(HWND hwnd)
|
||||||
|
|
||||||
leftbar = CreateWindowExW(0,
|
leftbar = CreateWindowExW(0,
|
||||||
TOOLBARCLASSNAMEW, NULL,
|
TOOLBARCLASSNAMEW, NULL,
|
||||||
WS_CHILD | CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_NORESIZE | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TRANSPARENT,
|
toolbarStyles | TBSTYLE_TRANSPARENT,
|
||||||
0, 0, 0, 0,
|
0, 0, 0, 0,
|
||||||
hwnd, (HMENU) 101, hInstance, NULL);
|
hwnd, (HMENU) 101, hInstance, NULL);
|
||||||
SendMessageW(leftbar, TB_BUTTONSTRUCTSIZE, sizeof (TBBUTTON), 0);
|
SendMessageW(leftbar, TB_BUTTONSTRUCTSIZE, sizeof (TBBUTTON), 0);
|
||||||
|
@ -157,9 +217,9 @@ void onWM_CREATE(HWND hwnd)
|
||||||
buttony = 40;
|
buttony = 40;
|
||||||
#define buttonwid 200
|
#define buttonwid 200
|
||||||
#define buttonht 25
|
#define buttonht 25
|
||||||
for (i = 0; buttons[i] != NULL; i++) {
|
for (i = 0; drawmodes[i].text != NULL; i++) {
|
||||||
button = CreateWindowExW(0,
|
button = CreateWindowExW(0,
|
||||||
L"BUTTON", buttons[i],
|
L"BUTTON", drawmodes[i].text,
|
||||||
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
||||||
buttonx, buttony,
|
buttonx, buttony,
|
||||||
buttonwid, buttonht,
|
buttonwid, buttonht,
|
||||||
|
@ -183,6 +243,28 @@ void onWM_CREATE(HWND hwnd)
|
||||||
for (i = 0; rebarThemes[i] != NULL; i++)
|
for (i = 0; rebarThemes[i] != NULL; i++)
|
||||||
// TODO check error
|
// TODO check error
|
||||||
SendMessageW(rebarCombo, CB_ADDSTRING, 0, (LPARAM) (rebarThemes[i]));
|
SendMessageW(rebarCombo, CB_ADDSTRING, 0, (LPARAM) (rebarThemes[i]));
|
||||||
|
comboy += buttonht + 5;
|
||||||
|
toolbarCombo = CreateWindowExW(WS_EX_CLIENTEDGE,
|
||||||
|
L"COMBOBOX", L"",
|
||||||
|
WS_CHILD | WS_VISIBLE | CBS_DROPDOWN,
|
||||||
|
combox, comboy,
|
||||||
|
buttonwid, buttonht,
|
||||||
|
hwnd, (HMENU) 301, hInstance, NULL);
|
||||||
|
if (toolbarCombo == NULL)
|
||||||
|
diele("CreateWindowExW(L\"COMBOBOX\")");
|
||||||
|
for (i = 0; toolbarThemes[i] != NULL; i++)
|
||||||
|
// TODO check error
|
||||||
|
SendMessageW(toolbarCombo, CB_ADDSTRING, 0, (LPARAM) (toolbarThemes[i]));
|
||||||
|
comboy += buttonht + 5;
|
||||||
|
toolbarTransparentCheckbox = CreateWindowExW(0,
|
||||||
|
L"BUTTON", L"Transparent toolbar",
|
||||||
|
WS_CHILD | WS_VISIBLE | BS_CHECKBOX,
|
||||||
|
combox, comboy,
|
||||||
|
buttonwid, buttonht,
|
||||||
|
hwnd, (HMENU) 302, hInstance, NULL);
|
||||||
|
if (toolbarTransparentCheckbox == NULL)
|
||||||
|
diele("CreateWindowExW(L\"BUTTON\")");
|
||||||
|
SendMessage(toolbarTransparentCheckbox, BM_SETCHECK, BST_CHECKED, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO it seems like I shouldn't have to do this?
|
// TODO it seems like I shouldn't have to do this?
|
||||||
|
@ -208,6 +290,8 @@ void handleEvents(HWND hwnd, WPARAM wParam)
|
||||||
const WCHAR *selRebar = NULL, *selToolbar = NULL;
|
const WCHAR *selRebar = NULL, *selToolbar = NULL;
|
||||||
WCHAR *bufRebar = NULL, *bufToolbar = NULL;
|
WCHAR *bufRebar = NULL, *bufToolbar = NULL;
|
||||||
BOOL changeRebar = FALSE, changeToolbar = FALSE;
|
BOOL changeRebar = FALSE, changeToolbar = FALSE;
|
||||||
|
BOOL invalidate = FALSE;
|
||||||
|
WPARAM check;
|
||||||
|
|
||||||
switch (wParam) {
|
switch (wParam) {
|
||||||
case MAKEWPARAM(300, CBN_SELCHANGE):
|
case MAKEWPARAM(300, CBN_SELCHANGE):
|
||||||
|
@ -215,15 +299,44 @@ void handleEvents(HWND hwnd, WPARAM wParam)
|
||||||
selRebar = rebarThemes[n];
|
selRebar = rebarThemes[n];
|
||||||
changeRebar = TRUE;
|
changeRebar = TRUE;
|
||||||
break;
|
break;
|
||||||
|
case MAKEWPARAM(301, CBN_SELCHANGE):
|
||||||
|
n = SendMessageW(toolbarCombo, CB_GETCURSEL, 0, 0);
|
||||||
|
selToolbar = toolbarThemes[n];
|
||||||
|
changeToolbar = TRUE;
|
||||||
|
break;
|
||||||
case MAKEWPARAM(200, BN_CLICKED):
|
case MAKEWPARAM(200, BN_CLICKED):
|
||||||
|
drawmode = 0;
|
||||||
n = SendMessageW(rebarCombo, WM_GETTEXTLENGTH, 0, 0);
|
n = SendMessageW(rebarCombo, WM_GETTEXTLENGTH, 0, 0);
|
||||||
bufRebar = new WCHAR[n + 1];
|
bufRebar = new WCHAR[n + 1];
|
||||||
GetWindowTextW(rebarCombo, bufRebar, n + 1);
|
GetWindowTextW(rebarCombo, bufRebar, n + 1);
|
||||||
|
n = SendMessageW(toolbarCombo, WM_GETTEXTLENGTH, 0, 0);
|
||||||
|
bufToolbar = new WCHAR[n + 1];
|
||||||
|
GetWindowTextW(toolbarCombo, bufToolbar, n + 1);
|
||||||
selRebar = bufRebar;
|
selRebar = bufRebar;
|
||||||
selToolbar = bufRebar;
|
selToolbar = bufToolbar;
|
||||||
changeRebar = TRUE;
|
changeRebar = TRUE;
|
||||||
changeToolbar = TRUE;
|
changeToolbar = TRUE;
|
||||||
break;
|
break;
|
||||||
|
case MAKEWPARAM(201, BN_CLICKED):
|
||||||
|
drawmode = 1;
|
||||||
|
invalidate = TRUE;
|
||||||
|
break;
|
||||||
|
case MAKEWPARAM(202, BN_CLICKED):
|
||||||
|
drawmode = 2;
|
||||||
|
invalidate = TRUE;
|
||||||
|
break;
|
||||||
|
case MAKEWPARAM(302, BN_CLICKED):
|
||||||
|
ShowWindow(leftbar, SW_HIDE);
|
||||||
|
check = BST_CHECKED;
|
||||||
|
if (SendMessage(toolbarTransparentCheckbox, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
||||||
|
check = BST_UNCHECKED;
|
||||||
|
SendMessage(toolbarTransparentCheckbox, BM_SETCHECK, check, 0);
|
||||||
|
if (check == BST_CHECKED)
|
||||||
|
SendMessageW(leftbar, TB_SETSTYLE, 0, toolbarStyles | TBSTYLE_TRANSPARENT);
|
||||||
|
else
|
||||||
|
SendMessageW(leftbar, TB_SETSTYLE, 0, toolbarStyles);
|
||||||
|
ShowWindow(leftbar, SW_SHOW);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (changeRebar) {
|
if (changeRebar) {
|
||||||
if (selRebar != NULL && wcscmp(selRebar, L"NULL") == 0)
|
if (selRebar != NULL && wcscmp(selRebar, L"NULL") == 0)
|
||||||
|
@ -232,7 +345,7 @@ void handleEvents(HWND hwnd, WPARAM wParam)
|
||||||
SendMessageW(rebar, RB_SETWINDOWTHEME, 0, (LPARAM) selRebar);
|
SendMessageW(rebar, RB_SETWINDOWTHEME, 0, (LPARAM) selRebar);
|
||||||
else
|
else
|
||||||
SetWindowTheme(rebar, selRebar, selRebar);
|
SetWindowTheme(rebar, selRebar, selRebar);
|
||||||
InvalidateRect(hwnd, NULL, TRUE);
|
invalidate = TRUE;
|
||||||
}
|
}
|
||||||
if (changeToolbar) {
|
if (changeToolbar) {
|
||||||
if (selToolbar != NULL && wcscmp(selToolbar, L"NULL") == 0)
|
if (selToolbar != NULL && wcscmp(selToolbar, L"NULL") == 0)
|
||||||
|
@ -241,8 +354,10 @@ void handleEvents(HWND hwnd, WPARAM wParam)
|
||||||
SendMessageW(leftbar, TB_SETWINDOWTHEME, 0, (LPARAM) selToolbar);
|
SendMessageW(leftbar, TB_SETWINDOWTHEME, 0, (LPARAM) selToolbar);
|
||||||
else
|
else
|
||||||
SetWindowTheme(leftbar, selToolbar, selToolbar);
|
SetWindowTheme(leftbar, selToolbar, selToolbar);
|
||||||
InvalidateRect(hwnd, NULL, TRUE);
|
invalidate = TRUE;
|
||||||
}
|
}
|
||||||
|
if (invalidate)
|
||||||
|
InvalidateRect(hwnd, NULL, TRUE);
|
||||||
if (bufRebar != NULL)
|
if (bufRebar != NULL)
|
||||||
delete[] bufRebar;
|
delete[] bufRebar;
|
||||||
if (bufToolbar != NULL)
|
if (bufToolbar != NULL)
|
||||||
|
@ -251,6 +366,8 @@ void handleEvents(HWND hwnd, WPARAM wParam)
|
||||||
|
|
||||||
LRESULT CALLBACK wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
NMHDR *nm = (NMHDR *) lParam;
|
||||||
|
|
||||||
switch (uMsg) {
|
switch (uMsg) {
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
onWM_CREATE(hwnd);
|
onWM_CREATE(hwnd);
|
||||||
|
@ -264,6 +381,16 @@ LRESULT CALLBACK wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
handleEvents(hwnd, wParam);
|
handleEvents(hwnd, wParam);
|
||||||
break;
|
break;
|
||||||
|
case WM_NOTIFY:
|
||||||
|
switch (nm->code) {
|
||||||
|
case NM_CUSTOMDRAW:
|
||||||
|
if (nm->hwndFrom != rebar)
|
||||||
|
break;
|
||||||
|
if (drawmode == 0)
|
||||||
|
break;
|
||||||
|
return (*(drawmodes[drawmode].handle))((NMCUSTOMDRAW *) nm);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// 20 may 2015
|
// 20 may 2015
|
||||||
#include "uipriv_windows.hpp"
|
#include "uipriv_windows.hpp"
|
||||||
|
|
||||||
|
// TODO no scrollbars? also not sure if true for combobox as well
|
||||||
|
|
||||||
// we as Common Controls 6 users don't need to worry about the height of comboboxes; see http://blogs.msdn.com/b/oldnewthing/archive/2006/03/10/548537.aspx
|
// we as Common Controls 6 users don't need to worry about the height of comboboxes; see http://blogs.msdn.com/b/oldnewthing/archive/2006/03/10/548537.aspx
|
||||||
|
|
||||||
struct uiEditableCombobox {
|
struct uiEditableCombobox {
|
||||||
|
|
Loading…
Reference in New Issue