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
|
wxSize wxDataViewToggleRenderer::GetSize() const
|
||||||
{
|
{
|
||||||
// the window parameter is not used by GetCheckBoxSize() so it's
|
return wxRendererNative::Get().GetCheckBoxSize(GetView());
|
||||||
// safe to pass NULL
|
|
||||||
return wxRendererNative::Get().GetCheckBoxSize(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
@@ -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
|
void
|
||||||
|
@@ -327,6 +327,8 @@ public:
|
|||||||
wxTitleBarButton button,
|
wxTitleBarButton button,
|
||||||
int flags = 0);
|
int flags = 0);
|
||||||
|
|
||||||
|
virtual wxSize GetCheckBoxSize(wxWindow *win);
|
||||||
|
|
||||||
virtual void DrawGauge(wxWindow* win,
|
virtual void DrawGauge(wxWindow* win,
|
||||||
wxDC& dc,
|
wxDC& dc,
|
||||||
const wxRect& rect,
|
const wxRect& rect,
|
||||||
@@ -902,6 +904,23 @@ wxRendererXP::DrawTitleBarBitmap(wxWindow *win,
|
|||||||
DoDrawButtonLike(hTheme, part, dc, rect, flags);
|
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
|
void
|
||||||
wxRendererXP::DrawCollapseButton(wxWindow *win,
|
wxRendererXP::DrawCollapseButton(wxWindow *win,
|
||||||
wxDC& dc,
|
wxDC& dc,
|
||||||
@@ -922,7 +941,7 @@ wxRendererXP::DrawCollapseButton(wxWindow *win,
|
|||||||
if ( flags & wxCONTROL_EXPANDED )
|
if ( flags & wxCONTROL_EXPANDED )
|
||||||
state += 3;
|
state += 3;
|
||||||
|
|
||||||
if ( te->IsThemePartDefined(hTheme, TDLG_EXPANDOBUTTON, state) )
|
if ( te->IsThemePartDefined(hTheme, TDLG_EXPANDOBUTTON, 0) )
|
||||||
{
|
{
|
||||||
if (flags & wxCONTROL_EXPANDED)
|
if (flags & wxCONTROL_EXPANDED)
|
||||||
flags |= wxCONTROL_CHECKED;
|
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
|
// 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;
|
SIZE s;
|
||||||
te->GetThemePartSize(hTheme,
|
te->GetThemePartSize(hTheme,
|
||||||
@@ -981,7 +1000,7 @@ wxRendererXP::DrawItemSelectionRect(wxWindow *win,
|
|||||||
const int itemState = GetListItemState(flags);
|
const int itemState = GetListItemState(flags);
|
||||||
|
|
||||||
wxUxThemeEngine* const te = wxUxThemeEngine::Get();
|
wxUxThemeEngine* const te = wxUxThemeEngine::Get();
|
||||||
if ( te->IsThemePartDefined(hTheme, LVP_LISTITEM, itemState) )
|
if ( te->IsThemePartDefined(hTheme, LVP_LISTITEM, 0) )
|
||||||
{
|
{
|
||||||
RECT rc;
|
RECT rc;
|
||||||
wxCopyRectToRECT(rect, rc);
|
wxCopyRectToRECT(rect, rc);
|
||||||
@@ -1010,7 +1029,7 @@ void wxRendererXP::DrawItemText(wxWindow* win,
|
|||||||
|
|
||||||
wxUxThemeEngine* te = wxUxThemeEngine::Get();
|
wxUxThemeEngine* te = wxUxThemeEngine::Get();
|
||||||
if ( te->DrawThemeTextEx && // Might be not available if we're under XP
|
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;
|
RECT rc;
|
||||||
wxCopyRectToRECT(rect, rc);
|
wxCopyRectToRECT(rect, rc);
|
||||||
@@ -1019,10 +1038,20 @@ void wxRendererXP::DrawItemText(wxWindow* win,
|
|||||||
textOpts.dwSize = sizeof(textOpts);
|
textOpts.dwSize = sizeof(textOpts);
|
||||||
textOpts.dwFlags = DTT_STATEID;
|
textOpts.dwFlags = DTT_STATEID;
|
||||||
textOpts.iStateId = itemState;
|
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.dwFlags |= DTT_TEXTCOLOR;
|
||||||
textOpts.crText = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT).GetPixel();
|
textOpts.crText = textColour.GetPixel();
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD textFlags = DT_NOPREFIX;
|
DWORD textFlags = DT_NOPREFIX;
|
||||||
|
Reference in New Issue
Block a user