Started drawing the button properly. Focus rects are now in the way...

This commit is contained in:
Pietro Gagliardi 2018-10-15 09:30:22 -04:00
parent 38723aeff9
commit fcec8693ca
1 changed files with 19 additions and 53 deletions

View File

@ -120,64 +120,32 @@ void drawExplorerChevron(HTHEME theme, HDC dc, HWND rebar, WPARAM band, RECT *rc
} }
// TODO check errors // TODO check errors
LRESULT customDrawExplorerRebar(NMCUSTOMDRAW *nm) LRESULT drawExplorerButton(NMCUSTOMDRAW *nm)
{ {
HTHEME theme; HWND button;
RECT r;
if (nm->dwDrawStage != CDDS_PREPAINT)
return CDRF_DODEFAULT;
theme = OpenThemeData(nm->hdr.hwndFrom, L"CommandModule");
GetClientRect(nm->hdr.hwndFrom, &r);
drawExplorerBackground(theme, nm->hdc, &r, &(nm->rc));
// TODO dwItemSpec is often invalid?!
drawExplorerChevron(theme, nm->hdc, nm->hdr.hwndFrom, 0, &(nm->rc));
CloseThemeData(theme);
return CDRF_SKIPDEFAULT;
}
// TODO check errors
LRESULT customDrawExplorerToolbar(NMTBCUSTOMDRAW *nm)
{
HWND toolbar, rebar;
WPARAM itemIndex;
TBBUTTON tbb;
HTHEME theme;
RECT r; RECT r;
int part, state; int part, state;
toolbar = nm->nmcd.hdr.hwndFrom; button = nm->hdr.hwndFrom;
switch (nm->nmcd.dwDrawStage) { switch (nm->dwDrawStage) {
case CDDS_PREPAINT: case CDDS_PREPAINT:
theme = OpenThemeData(toolbar, L"CommandModule"); GetClientRect(button, &r);
rebar = GetParent(toolbar);
GetWindowRect(rebar, &r);
MapWindowRect(NULL, toolbar, &r);
drawExplorerBackground(theme, nm->nmcd.hdc, &r, &(nm->nmcd.rc));
CloseThemeData(theme);
return CDRF_NOTIFYITEMDRAW;
case CDDS_ITEMPREPAINT:
itemIndex = (WPARAM) SendMessageW(toolbar, TB_COMMANDTOINDEX, nm->nmcd.dwItemSpec, 0);
ZeroMemory(&tbb, sizeof (TBBUTTON));
SendMessageW(toolbar, TB_GETBUTTON, itemIndex, (LPARAM) (&tbb));
theme = OpenThemeData(toolbar, L"CommandModule");
part = 3; part = 3;
if ((tbb.fsStyle & BTNS_DROPDOWN) != 0) //TODO if ((tbb.fsStyle & BTNS_DROPDOWN) != 0)
part = 4; //TODO part = 4;
state = 1; state = 1;
// TODO this doesn't work; both keyboard and mouse are listed as HOT // TODO this doesn't work; both keyboard and mouse are listed as HOT
if ((nm->nmcd.uItemState & CDIS_FOCUS) != 0) if ((nm->uItemState & CDIS_FOCUS) != 0)
state = 4; state = 4;
if ((nm->nmcd.uItemState & CDIS_HOT) != 0) if ((nm->uItemState & CDIS_HOT) != 0)
state = 2; state = 2;
if ((nm->nmcd.uItemState & CDIS_SELECTED) != 0) if ((nm->uItemState & CDIS_SELECTED) != 0)
state = 3; state = 3;
SendMessageW(toolbar, TB_GETITEMRECT, itemIndex, (LPARAM) (&r)); DrawThemeParentBackground(button, nm->hdc, &(nm->rc));
DrawThemeBackground(theme, nm->nmcd.hdc, DrawThemeBackground(theme, nm->hdc,
3, state, part, state,
&r, &(nm->nmcd.rc)); &r, &(nm->rc));
CloseThemeData(theme); return CDRF_NEWFONT;
return TBCDRF_NOBACKGROUND;
} }
return CDRF_DODEFAULT; return CDRF_DODEFAULT;
} }
@ -399,6 +367,7 @@ 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; NMHDR *nm = (NMHDR *) lParam;
int i;
switch (uMsg) { switch (uMsg) {
case WM_CREATE: case WM_CREATE:
@ -424,12 +393,9 @@ LRESULT CALLBACK wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_NOTIFY: case WM_NOTIFY:
switch (nm->code) { switch (nm->code) {
case NM_CUSTOMDRAW: case NM_CUSTOMDRAW:
#if 0 for (i = 0; i < 5; i++)
if (nm->hwndFrom == rebar) if (nm->hwndFrom == leftButtons[i])
return (*(drawmodes[drawmode].handleRebar))((NMCUSTOMDRAW *) nm); return drawExplorerButton((NMCUSTOMDRAW *) nm);
else if (nm->hwndFrom == leftbar || nm->hwndFrom == rightbar)
return (*(drawmodes[drawmode].handleToolbar))((NMTBCUSTOMDRAW *) nm);
#endif
break; break;
} }
break; break;