Bug 478147 - Focus rect missing from checkboxes on Vista. r=vlad

This commit is contained in:
Jim Mathies 2009-02-18 17:56:51 -06:00
Родитель 156dcb76c0
Коммит 420a773ff6
1 изменённых файлов: 38 добавлений и 8 удалений

Просмотреть файл

@ -1140,15 +1140,45 @@ RENDER_AGAIN:
contentState = GetContentState(aFrame, aWidgetType); contentState = GetContentState(aFrame, aWidgetType);
if (contentState & NS_EVENT_STATE_FOCUS) { if (contentState & NS_EVENT_STATE_FOCUS) {
// setup DC to make DrawFocusRect draw correctly
POINT vpOrg; POINT vpOrg;
HPEN hPen = nsnull;
PRUint8 id = SaveDC(hdc);
::SelectClipRgn(hdc, NULL);
::GetViewportOrgEx(hdc, &vpOrg); ::GetViewportOrgEx(hdc, &vpOrg);
::SetBrushOrgEx(hdc, vpOrg.x + widgetRect.left, vpOrg.y + widgetRect.top, NULL); ::SetBrushOrgEx(hdc, vpOrg.x + widgetRect.left, vpOrg.y + widgetRect.top, NULL);
PRInt32 oldColor;
oldColor = ::SetTextColor(hdc, 0); // On vista, choose our own colors and draw an XP style half focus rect
// draw focus rectangle // for focused checkboxes and a full rect when active.
if (nsUXThemeData::sIsVistaOrLater && aWidgetType == NS_THEME_CHECKBOX) {
LOGBRUSH lb;
lb.lbStyle = BS_SOLID;
lb.lbColor = RGB(255,255,255);
lb.lbHatch = 0;
hPen = ::ExtCreatePen(PS_COSMETIC|PS_ALTERNATE, 1, &lb, 0, NULL);
::SelectObject(hdc, hPen);
// If pressed, draw the upper left corner of the dotted rect.
if (contentState & NS_EVENT_STATE_ACTIVE) {
::MoveToEx(hdc, widgetRect.left, widgetRect.bottom-1, NULL);
::LineTo(hdc, widgetRect.left, widgetRect.top);
::LineTo(hdc, widgetRect.right-1, widgetRect.top);
}
// Draw the lower right corner of the dotted rect.
::MoveToEx(hdc, widgetRect.right-1, widgetRect.top, NULL);
::LineTo(hdc, widgetRect.right-1, widgetRect.bottom-1);
::LineTo(hdc, widgetRect.left, widgetRect.bottom-1);
} else {
::SetTextColor(hdc, 0);
::DrawFocusRect(hdc, &widgetRect); ::DrawFocusRect(hdc, &widgetRect);
::SetTextColor(hdc, oldColor); }
::RestoreDC(hdc, id);
if (hPen) {
::DeleteObject(hPen);
}
} }
} }
else if (aWidgetType == NS_THEME_TOOLBAR && state == 0) { else if (aWidgetType == NS_THEME_TOOLBAR && state == 0) {