Merge branch 'high-dpi-checkboxes-fix' of https://github.com/MaartenBent/wxWidgets
Correct calculation of the checkboxes size when using themes and other minor renderer fixes.
This commit is contained in:
@@ -1152,9 +1152,7 @@ bool wxDataViewToggleRenderer::WXActivateCell(const wxRect& WXUNUSED(cellRect),
|
||||
|
||||
wxSize wxDataViewToggleRenderer::GetSize() const
|
||||
{
|
||||
// the window parameter is not used by GetCheckBoxSize() so it's
|
||||
// safe to pass NULL
|
||||
return wxRendererNative::Get().GetCheckBoxSize(NULL);
|
||||
return wxRendererNative::Get().GetCheckBoxSize(GetView());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
@@ -712,9 +712,9 @@ wxRendererGeneric::DrawCheckBox(wxWindow *WXUNUSED(win),
|
||||
}
|
||||
}
|
||||
|
||||
wxSize wxRendererGeneric::GetCheckBoxSize(wxWindow *WXUNUSED(win))
|
||||
wxSize wxRendererGeneric::GetCheckBoxSize(wxWindow *win)
|
||||
{
|
||||
return wxSize(16, 16);
|
||||
return win->FromDIP(wxSize(16, 16));
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -327,6 +327,8 @@ public:
|
||||
wxTitleBarButton button,
|
||||
int flags = 0);
|
||||
|
||||
virtual wxSize GetCheckBoxSize(wxWindow *win);
|
||||
|
||||
virtual void DrawGauge(wxWindow* win,
|
||||
wxDC& dc,
|
||||
const wxRect& rect,
|
||||
@@ -902,6 +904,23 @@ wxRendererXP::DrawTitleBarBitmap(wxWindow *win,
|
||||
DoDrawButtonLike(hTheme, part, dc, rect, flags);
|
||||
}
|
||||
|
||||
wxSize wxRendererXP::GetCheckBoxSize(wxWindow* win)
|
||||
{
|
||||
wxUxThemeHandle hTheme(win, L"BUTTON");
|
||||
if (hTheme)
|
||||
{
|
||||
wxUxThemeEngine* const te = wxUxThemeEngine::Get();
|
||||
|
||||
if (te && te->IsThemePartDefined(hTheme, BP_CHECKBOX, 0))
|
||||
{
|
||||
SIZE checkSize;
|
||||
if (te->GetThemePartSize(hTheme, NULL, BP_CHECKBOX, CBS_UNCHECKEDNORMAL, NULL, TS_DRAW, &checkSize) == S_OK)
|
||||
return wxSize(checkSize.cx, checkSize.cy);
|
||||
}
|
||||
}
|
||||
return m_rendererNative.GetCheckBoxSize(win);
|
||||
}
|
||||
|
||||
void
|
||||
wxRendererXP::DrawCollapseButton(wxWindow *win,
|
||||
wxDC& dc,
|
||||
@@ -922,7 +941,7 @@ wxRendererXP::DrawCollapseButton(wxWindow *win,
|
||||
if ( flags & wxCONTROL_EXPANDED )
|
||||
state += 3;
|
||||
|
||||
if ( te->IsThemePartDefined(hTheme, TDLG_EXPANDOBUTTON, state) )
|
||||
if ( te->IsThemePartDefined(hTheme, TDLG_EXPANDOBUTTON, 0) )
|
||||
{
|
||||
if (flags & wxCONTROL_EXPANDED)
|
||||
flags |= wxCONTROL_CHECKED;
|
||||
@@ -953,7 +972,7 @@ wxSize wxRendererXP::GetCollapseButtonSize(wxWindow *win, wxDC& dc)
|
||||
|
||||
// EXPANDOBUTTON scales ugly if not using the correct size, get size from theme
|
||||
|
||||
if ( te->IsThemePartDefined(hTheme, TDLG_EXPANDOBUTTON, TDLGEBS_NORMAL) )
|
||||
if ( te->IsThemePartDefined(hTheme, TDLG_EXPANDOBUTTON, 0) )
|
||||
{
|
||||
SIZE s;
|
||||
te->GetThemePartSize(hTheme,
|
||||
@@ -981,7 +1000,7 @@ wxRendererXP::DrawItemSelectionRect(wxWindow *win,
|
||||
const int itemState = GetListItemState(flags);
|
||||
|
||||
wxUxThemeEngine* const te = wxUxThemeEngine::Get();
|
||||
if ( te->IsThemePartDefined(hTheme, LVP_LISTITEM, itemState) )
|
||||
if ( te->IsThemePartDefined(hTheme, LVP_LISTITEM, 0) )
|
||||
{
|
||||
RECT rc;
|
||||
wxCopyRectToRECT(rect, rc);
|
||||
@@ -1010,7 +1029,7 @@ void wxRendererXP::DrawItemText(wxWindow* win,
|
||||
|
||||
wxUxThemeEngine* te = wxUxThemeEngine::Get();
|
||||
if ( te->DrawThemeTextEx && // Might be not available if we're under XP
|
||||
te->IsThemePartDefined(hTheme, LVP_LISTITEM, itemState) )
|
||||
te->IsThemePartDefined(hTheme, LVP_LISTITEM, 0) )
|
||||
{
|
||||
RECT rc;
|
||||
wxCopyRectToRECT(rect, rc);
|
||||
@@ -1019,10 +1038,20 @@ void wxRendererXP::DrawItemText(wxWindow* win,
|
||||
textOpts.dwSize = sizeof(textOpts);
|
||||
textOpts.dwFlags = DTT_STATEID;
|
||||
textOpts.iStateId = itemState;
|
||||
if (flags & wxCONTROL_DISABLED)
|
||||
|
||||
wxColour textColour = dc.GetTextForeground();
|
||||
if (flags & wxCONTROL_SELECTED)
|
||||
{
|
||||
textColour = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXTEXT);
|
||||
}
|
||||
else if (flags & wxCONTROL_DISABLED)
|
||||
{
|
||||
textColour = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
|
||||
}
|
||||
|
||||
if (textColour.IsOk()) {
|
||||
textOpts.dwFlags |= DTT_TEXTCOLOR;
|
||||
textOpts.crText = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT).GetPixel();
|
||||
textOpts.crText = textColour.GetPixel();
|
||||
}
|
||||
|
||||
DWORD textFlags = DT_NOPREFIX;
|
||||
|
Reference in New Issue
Block a user