Moved drawing of owner-drawn parts to after the background and edge.
Also added some indentation to the code.
This commit is contained in:
parent
751f683f07
commit
8fe5e0fcfa
|
@ -119,7 +119,7 @@ STATUSBAR_DrawSizeGrip (HDC hdc, LPRECT lpRect)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
STATUSBAR_DrawPart (HDC hdc, STATUSWINDOWPART *part)
|
STATUSBAR_DrawPart (HDC hdc, const STATUSWINDOWPART *part, const STATUSWINDOWINFO *infoPtr, int itemID)
|
||||||
{
|
{
|
||||||
RECT r = part->bound;
|
RECT r = part->bound;
|
||||||
UINT border = BDR_SUNKENOUTER;
|
UINT border = BDR_SUNKENOUTER;
|
||||||
|
@ -132,20 +132,36 @@ STATUSBAR_DrawPart (HDC hdc, STATUSWINDOWPART *part)
|
||||||
|
|
||||||
DrawEdge(hdc, &r, border, BF_RECT|BF_ADJUST);
|
DrawEdge(hdc, &r, border, BF_RECT|BF_ADJUST);
|
||||||
|
|
||||||
if (part->hIcon) {
|
if (part->style & SBT_OWNERDRAW)
|
||||||
INT cy = r.bottom - r.top;
|
{
|
||||||
|
DRAWITEMSTRUCT dis;
|
||||||
|
|
||||||
r.left += 2;
|
dis.CtlID = GetWindowLongW (infoPtr->Self, GWL_ID);
|
||||||
DrawIconEx (hdc, r.left, r.top, part->hIcon, cy, cy, 0, 0, DI_NORMAL);
|
dis.itemID = itemID;
|
||||||
r.left += cy;
|
dis.hwndItem = infoPtr->Self;
|
||||||
|
dis.hDC = hdc;
|
||||||
|
dis.rcItem = r;
|
||||||
|
dis.itemData = (INT)part->text;
|
||||||
|
SendMessageW (GetParent (infoPtr->Self), WM_DRAWITEM,
|
||||||
|
(WPARAM)dis.CtlID, (LPARAM)&dis);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (part->hIcon)
|
||||||
|
{
|
||||||
|
INT cy = r.bottom - r.top;
|
||||||
|
|
||||||
|
r.left += 2;
|
||||||
|
DrawIconEx (hdc, r.left, r.top, part->hIcon, cy, cy, 0, 0, DI_NORMAL);
|
||||||
|
r.left += cy;
|
||||||
|
}
|
||||||
|
DrawStatusTextW (hdc, &r, part->text, SBT_NOBORDERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawStatusTextW (hdc, &r, part->text, SBT_NOBORDERS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
STATUSBAR_RefreshPart (STATUSWINDOWINFO *infoPtr, STATUSWINDOWPART *part, HDC hdc, int itemID)
|
STATUSBAR_RefreshPart (const STATUSWINDOWINFO *infoPtr, const STATUSWINDOWPART *part, HDC hdc, int itemID)
|
||||||
{
|
{
|
||||||
HBRUSH hbrBk;
|
HBRUSH hbrBk;
|
||||||
HFONT hOldFont;
|
HFONT hOldFont;
|
||||||
|
@ -157,37 +173,26 @@ STATUSBAR_RefreshPart (STATUSWINDOWINFO *infoPtr, STATUSWINDOWPART *part, HDC hd
|
||||||
if (part->bound.right < part->bound.left) return;
|
if (part->bound.right < part->bound.left) return;
|
||||||
|
|
||||||
if (infoPtr->clrBk != CLR_DEFAULT)
|
if (infoPtr->clrBk != CLR_DEFAULT)
|
||||||
hbrBk = CreateSolidBrush (infoPtr->clrBk);
|
hbrBk = CreateSolidBrush (infoPtr->clrBk);
|
||||||
else
|
else
|
||||||
hbrBk = GetSysColorBrush (COLOR_3DFACE);
|
hbrBk = GetSysColorBrush (COLOR_3DFACE);
|
||||||
FillRect(hdc, &part->bound, hbrBk);
|
FillRect(hdc, &part->bound, hbrBk);
|
||||||
|
|
||||||
hOldFont = SelectObject (hdc, infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont);
|
hOldFont = SelectObject (hdc, infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont);
|
||||||
|
|
||||||
if (part->style & SBT_OWNERDRAW) {
|
STATUSBAR_DrawPart (hdc, part, infoPtr, itemID);
|
||||||
DRAWITEMSTRUCT dis;
|
|
||||||
|
|
||||||
dis.CtlID = GetWindowLongW (infoPtr->Self, GWL_ID);
|
|
||||||
dis.itemID = itemID;
|
|
||||||
dis.hwndItem = infoPtr->Self;
|
|
||||||
dis.hDC = hdc;
|
|
||||||
dis.rcItem = part->bound;
|
|
||||||
dis.itemData = (INT)part->text;
|
|
||||||
SendMessageW (GetParent (infoPtr->Self), WM_DRAWITEM,
|
|
||||||
(WPARAM)dis.CtlID, (LPARAM)&dis);
|
|
||||||
} else
|
|
||||||
STATUSBAR_DrawPart (hdc, part);
|
|
||||||
|
|
||||||
SelectObject (hdc, hOldFont);
|
SelectObject (hdc, hOldFont);
|
||||||
|
|
||||||
if (infoPtr->clrBk != CLR_DEFAULT)
|
if (infoPtr->clrBk != CLR_DEFAULT)
|
||||||
DeleteObject (hbrBk);
|
DeleteObject (hbrBk);
|
||||||
|
|
||||||
if (GetWindowLongW (infoPtr->Self, GWL_STYLE) & SBARS_SIZEGRIP) {
|
if (GetWindowLongW (infoPtr->Self, GWL_STYLE) & SBARS_SIZEGRIP)
|
||||||
RECT rect;
|
{
|
||||||
|
RECT rect;
|
||||||
|
|
||||||
GetClientRect (infoPtr->Self, &rect);
|
GetClientRect (infoPtr->Self, &rect);
|
||||||
STATUSBAR_DrawSizeGrip (hdc, &rect);
|
STATUSBAR_DrawSizeGrip (hdc, &rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,40 +214,28 @@ STATUSBAR_Refresh (STATUSWINDOWINFO *infoPtr, HDC hdc)
|
||||||
GetClientRect (infoPtr->Self, &rect);
|
GetClientRect (infoPtr->Self, &rect);
|
||||||
|
|
||||||
if (infoPtr->clrBk != CLR_DEFAULT)
|
if (infoPtr->clrBk != CLR_DEFAULT)
|
||||||
hbrBk = CreateSolidBrush (infoPtr->clrBk);
|
hbrBk = CreateSolidBrush (infoPtr->clrBk);
|
||||||
else
|
else
|
||||||
hbrBk = GetSysColorBrush (COLOR_3DFACE);
|
hbrBk = GetSysColorBrush (COLOR_3DFACE);
|
||||||
FillRect(hdc, &rect, hbrBk);
|
FillRect(hdc, &rect, hbrBk);
|
||||||
|
|
||||||
hOldFont = SelectObject (hdc, infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont);
|
hOldFont = SelectObject (hdc, infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont);
|
||||||
|
|
||||||
if (infoPtr->simple) {
|
if (infoPtr->simple) {
|
||||||
STATUSBAR_RefreshPart (infoPtr, &infoPtr->part0, hdc, 0);
|
STATUSBAR_RefreshPart (infoPtr, &infoPtr->part0, hdc, 0);
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < infoPtr->numParts; i++) {
|
for (i = 0; i < infoPtr->numParts; i++) {
|
||||||
if (infoPtr->parts[i].style & SBT_OWNERDRAW) {
|
STATUSBAR_RefreshPart (infoPtr, &infoPtr->parts[i], hdc, i);
|
||||||
DRAWITEMSTRUCT dis;
|
}
|
||||||
|
|
||||||
dis.CtlID = GetWindowLongW (infoPtr->Self, GWL_ID);
|
|
||||||
dis.itemID = i;
|
|
||||||
dis.hwndItem = infoPtr->Self;
|
|
||||||
dis.hDC = hdc;
|
|
||||||
dis.rcItem = infoPtr->parts[i].bound;
|
|
||||||
dis.itemData = (INT)infoPtr->parts[i].text;
|
|
||||||
SendMessageW (GetParent (infoPtr->Self), WM_DRAWITEM,
|
|
||||||
(WPARAM)dis.CtlID, (LPARAM)&dis);
|
|
||||||
} else
|
|
||||||
STATUSBAR_RefreshPart (infoPtr, &infoPtr->parts[i], hdc, i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectObject (hdc, hOldFont);
|
SelectObject (hdc, hOldFont);
|
||||||
|
|
||||||
if (infoPtr->clrBk != CLR_DEFAULT)
|
if (infoPtr->clrBk != CLR_DEFAULT)
|
||||||
DeleteObject (hbrBk);
|
DeleteObject (hbrBk);
|
||||||
|
|
||||||
if (GetWindowLongW (infoPtr->Self, GWL_STYLE) & SBARS_SIZEGRIP)
|
if (GetWindowLongW (infoPtr->Self, GWL_STYLE) & SBARS_SIZEGRIP)
|
||||||
STATUSBAR_DrawSizeGrip (hdc, &rect);
|
STATUSBAR_DrawSizeGrip (hdc, &rect);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -636,7 +629,7 @@ STATUSBAR_SetTextT (STATUSWINDOWINFO *infoPtr, INT nPart, WORD style,
|
||||||
if (nPart == 0x00ff) {
|
if (nPart == 0x00ff) {
|
||||||
part = &infoPtr->part0;
|
part = &infoPtr->part0;
|
||||||
} else {
|
} else {
|
||||||
if (infoPtr->parts && (nPart < 0 || nPart >= infoPtr->numParts)) {
|
if (infoPtr->parts && nPart >= 0 && nPart < infoPtr->numParts) {
|
||||||
part = &infoPtr->parts[nPart];
|
part = &infoPtr->parts[nPart];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue