Use correct expander size in wxDataViewCtrl under MSW
Add wxRendererNative::GetExpanderSize(), implement it using the appropriate theme element and use it instead of hardcoding the expander size to 3 character widths. Closes https://github.com/wxWidgets/wxWidgets/pull/1431 Closes #18449.
This commit is contained in:
@@ -253,6 +253,9 @@ public:
|
|||||||
// Returns the default size of a check box.
|
// Returns the default size of a check box.
|
||||||
virtual wxSize GetCheckBoxSize(wxWindow *win) = 0;
|
virtual wxSize GetCheckBoxSize(wxWindow *win) = 0;
|
||||||
|
|
||||||
|
// Returns the default size of a expander.
|
||||||
|
virtual wxSize GetExpanderSize(wxWindow *win) = 0;
|
||||||
|
|
||||||
// draw blank button
|
// draw blank button
|
||||||
//
|
//
|
||||||
// flags may use wxCONTROL_PRESSED, wxCONTROL_CURRENT and wxCONTROL_ISDEFAULT
|
// flags may use wxCONTROL_PRESSED, wxCONTROL_CURRENT and wxCONTROL_ISDEFAULT
|
||||||
@@ -479,6 +482,9 @@ public:
|
|||||||
virtual wxSize GetCheckBoxSize(wxWindow *win) wxOVERRIDE
|
virtual wxSize GetCheckBoxSize(wxWindow *win) wxOVERRIDE
|
||||||
{ return m_rendererNative.GetCheckBoxSize(win); }
|
{ return m_rendererNative.GetCheckBoxSize(win); }
|
||||||
|
|
||||||
|
virtual wxSize GetExpanderSize(wxWindow *win) wxOVERRIDE
|
||||||
|
{ return m_rendererNative.GetExpanderSize(win); }
|
||||||
|
|
||||||
virtual void DrawPushButton(wxWindow *win,
|
virtual void DrawPushButton(wxWindow *win,
|
||||||
wxDC& dc,
|
wxDC& dc,
|
||||||
const wxRect& rect,
|
const wxRect& rect,
|
||||||
|
@@ -236,6 +236,8 @@ public:
|
|||||||
|
|
||||||
virtual wxSize GetCheckBoxSize(wxWindow *win);
|
virtual wxSize GetCheckBoxSize(wxWindow *win);
|
||||||
|
|
||||||
|
virtual wxSize GetExpanderSize(wxWindow* win);
|
||||||
|
|
||||||
virtual void DrawPushButton(wxWindow *win, wxDC& dc,
|
virtual void DrawPushButton(wxWindow *win, wxDC& dc,
|
||||||
const wxRect& rect, int flags = 0 );
|
const wxRect& rect, int flags = 0 );
|
||||||
|
|
||||||
@@ -558,6 +560,16 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual wxSize GetCheckBoxSize(wxWindow* win) = 0;
|
virtual wxSize GetCheckBoxSize(wxWindow* win) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the size of the expander used in tree-like controls.
|
||||||
|
|
||||||
|
@param win A valid, i.e. non-null, window pointer which is used to get
|
||||||
|
the theme defining the expander size under some platforms.
|
||||||
|
|
||||||
|
@since 3.1.3
|
||||||
|
*/
|
||||||
|
virtual wxSize GetExpanderSize(wxWindow* win) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the height of a header button, either a fixed platform height if
|
Returns the height of a header button, either a fixed platform height if
|
||||||
available, or a generic height based on the @a win window's font.
|
available, or a generic height based on the @a win window's font.
|
||||||
|
@@ -2573,17 +2573,17 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
|||||||
// Calculate the indent first
|
// Calculate the indent first
|
||||||
indent = GetOwner()->GetIndent() * node->GetIndentLevel();
|
indent = GetOwner()->GetIndent() * node->GetIndentLevel();
|
||||||
|
|
||||||
// We don't have any method to return the size of the expander
|
// Get expander size
|
||||||
// button currently (TODO: add one to wxRendererNative), so
|
wxSize expSize = wxRendererNative::Get().GetExpanderSize(this);
|
||||||
// just guesstimate it.
|
|
||||||
const int expWidth = 3*dc.GetCharWidth();
|
|
||||||
|
|
||||||
// draw expander if needed
|
// draw expander if needed
|
||||||
if ( node->HasChildren() )
|
if ( node->HasChildren() )
|
||||||
{
|
{
|
||||||
wxRect rect = cell_rect;
|
wxRect rect = cell_rect;
|
||||||
rect.x += indent;
|
rect.x += indent;
|
||||||
rect.width = expWidth;
|
rect.y += (cell_rect.GetHeight() - expSize.GetHeight()) / 2; // center vertically
|
||||||
|
rect.width = expSize.GetWidth();
|
||||||
|
rect.height = expSize.GetHeight();
|
||||||
|
|
||||||
int flag = 0;
|
int flag = 0;
|
||||||
if ( m_underMouse == node )
|
if ( m_underMouse == node )
|
||||||
@@ -2598,7 +2598,7 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
|||||||
wxRendererNative::Get().DrawTreeItemButton( this, dc, rect, flag);
|
wxRendererNative::Get().DrawTreeItemButton( this, dc, rect, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
indent += expWidth;
|
indent += expSize.GetWidth();
|
||||||
|
|
||||||
// force the expander column to left-center align
|
// force the expander column to left-center align
|
||||||
cell->SetAlignment( wxALIGN_CENTER_VERTICAL );
|
cell->SetAlignment( wxALIGN_CENTER_VERTICAL );
|
||||||
|
@@ -108,6 +108,8 @@ public:
|
|||||||
|
|
||||||
virtual wxSize GetCheckBoxSize(wxWindow *win) wxOVERRIDE;
|
virtual wxSize GetCheckBoxSize(wxWindow *win) wxOVERRIDE;
|
||||||
|
|
||||||
|
virtual wxSize GetExpanderSize(wxWindow *win) wxOVERRIDE;
|
||||||
|
|
||||||
virtual void DrawPushButton(wxWindow *win,
|
virtual void DrawPushButton(wxWindow *win,
|
||||||
wxDC& dc,
|
wxDC& dc,
|
||||||
const wxRect& rect,
|
const wxRect& rect,
|
||||||
@@ -719,6 +721,13 @@ wxSize wxRendererGeneric::GetCheckBoxSize(wxWindow *win)
|
|||||||
return win->FromDIP(wxSize(16, 16));
|
return win->FromDIP(wxSize(16, 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxSize wxRendererGeneric::GetExpanderSize(wxWindow *win)
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( win, wxSize(0, 0), "Must have a valid window" );
|
||||||
|
|
||||||
|
return win->FromDIP(wxSize(16, 16));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
wxRendererGeneric::DrawPushButton(wxWindow *win,
|
wxRendererGeneric::DrawPushButton(wxWindow *win,
|
||||||
wxDC& dc,
|
wxDC& dc,
|
||||||
|
@@ -273,6 +273,8 @@ public:
|
|||||||
|
|
||||||
virtual wxSize GetCheckBoxSize(wxWindow *win) wxOVERRIDE;
|
virtual wxSize GetCheckBoxSize(wxWindow *win) wxOVERRIDE;
|
||||||
|
|
||||||
|
virtual wxSize GetExpanderSize(wxWindow *win) wxOVERRIDE;
|
||||||
|
|
||||||
virtual void DrawGauge(wxWindow* win,
|
virtual void DrawGauge(wxWindow* win,
|
||||||
wxDC& dc,
|
wxDC& dc,
|
||||||
const wxRect& rect,
|
const wxRect& rect,
|
||||||
@@ -850,6 +852,26 @@ wxSize wxRendererXP::GetCheckBoxSize(wxWindow* win)
|
|||||||
return m_rendererNative.GetCheckBoxSize(win);
|
return m_rendererNative.GetCheckBoxSize(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxSize wxRendererXP::GetExpanderSize(wxWindow* win)
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( win, wxSize(0, 0), "Must have a valid window" );
|
||||||
|
|
||||||
|
wxUxThemeHandle hTheme(win, L"TREEVIEW");
|
||||||
|
if ( hTheme )
|
||||||
|
{
|
||||||
|
if ( ::IsThemePartDefined(hTheme, TVP_GLYPH, 0) )
|
||||||
|
{
|
||||||
|
SIZE expSize;
|
||||||
|
if (::GetThemePartSize(hTheme, NULL, TVP_GLYPH, GLPS_CLOSED, NULL,
|
||||||
|
TS_DRAW, &expSize) == S_OK)
|
||||||
|
return wxSize(expSize.cx, expSize.cy);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_rendererNative.GetExpanderSize(win);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
wxRendererXP::DrawCollapseButton(wxWindow *win,
|
wxRendererXP::DrawCollapseButton(wxWindow *win,
|
||||||
wxDC& dc,
|
wxDC& dc,
|
||||||
|
Reference in New Issue
Block a user