Improve wxDataView on DPI change
Fix the row heights after a DPI change and adjust the column widths. Use DPIChangedEvent instead of MSWUpdateFontOnDPIChange because the child controls (m_clientArea, m_headerArea) need to update their font sizes first.
This commit is contained in:
@@ -895,9 +895,9 @@ public:
|
|||||||
void SetDropEffect( wxDragResult effect ) { m_dropEffect = effect; }
|
void SetDropEffect( wxDragResult effect ) { m_dropEffect = effect; }
|
||||||
wxDragResult GetDropEffect() const { return m_dropEffect; }
|
wxDragResult GetDropEffect() const { return m_dropEffect; }
|
||||||
// for plaforms (currently only OSX) that support Drag/Drop insertion of items,
|
// for plaforms (currently only OSX) that support Drag/Drop insertion of items,
|
||||||
// this is the proposed child index for the insertion
|
// this is the proposed child index for the insertion
|
||||||
void SetProposedDropIndex(int index) { m_proposedDropIndex = index; }
|
void SetProposedDropIndex(int index) { m_proposedDropIndex = index; }
|
||||||
int GetProposedDropIndex() const { return m_proposedDropIndex;}
|
int GetProposedDropIndex() const { return m_proposedDropIndex;}
|
||||||
#endif // wxUSE_DRAG_AND_DROP
|
#endif // wxUSE_DRAG_AND_DROP
|
||||||
|
|
||||||
virtual wxEvent *Clone() const wxOVERRIDE { return new wxDataViewEvent(*this); }
|
virtual wxEvent *Clone() const wxOVERRIDE { return new wxDataViewEvent(*this); }
|
||||||
|
@@ -316,6 +316,8 @@ protected:
|
|||||||
|
|
||||||
virtual void DoEnableSystemTheme(bool enable, wxWindow* window) wxOVERRIDE;
|
virtual void DoEnableSystemTheme(bool enable, wxWindow* window) wxOVERRIDE;
|
||||||
|
|
||||||
|
void OnDPIChanged(wxDPIChangedEvent& event);
|
||||||
|
|
||||||
public: // utility functions not part of the API
|
public: // utility functions not part of the API
|
||||||
|
|
||||||
// returns the "best" width for the idx-th column
|
// returns the "best" width for the idx-th column
|
||||||
|
@@ -193,7 +193,7 @@ int wxDataViewColumn::GetWidth() const
|
|||||||
switch ( m_width )
|
switch ( m_width )
|
||||||
{
|
{
|
||||||
case wxCOL_WIDTH_DEFAULT:
|
case wxCOL_WIDTH_DEFAULT:
|
||||||
return wxDVC_DEFAULT_WIDTH;
|
return wxWindow::FromDIP(wxDVC_DEFAULT_WIDTH, m_owner);
|
||||||
|
|
||||||
case wxCOL_WIDTH_AUTOSIZE:
|
case wxCOL_WIDTH_AUTOSIZE:
|
||||||
wxCHECK_MSG( m_owner, wxDVC_DEFAULT_WIDTH, "no owner control" );
|
wxCHECK_MSG( m_owner, wxDVC_DEFAULT_WIDTH, "no owner control" );
|
||||||
@@ -709,8 +709,7 @@ public:
|
|||||||
bool Cleared();
|
bool Cleared();
|
||||||
void Resort()
|
void Resort()
|
||||||
{
|
{
|
||||||
if ( m_rowHeightCache )
|
ClearRowHeightCache();
|
||||||
m_rowHeightCache->Clear();
|
|
||||||
|
|
||||||
if (!IsVirtualList())
|
if (!IsVirtualList())
|
||||||
{
|
{
|
||||||
@@ -718,6 +717,11 @@ public:
|
|||||||
}
|
}
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
}
|
}
|
||||||
|
void ClearRowHeightCache()
|
||||||
|
{
|
||||||
|
if ( m_rowHeightCache )
|
||||||
|
m_rowHeightCache->Clear();
|
||||||
|
}
|
||||||
|
|
||||||
SortOrder GetSortOrder() const
|
SortOrder GetSortOrder() const
|
||||||
{
|
{
|
||||||
@@ -1188,7 +1192,8 @@ wxSize wxDataViewTextRenderer::GetSize() const
|
|||||||
return GetTextExtent(m_text);
|
return GetTextExtent(m_text);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return wxSize(wxDVC_DEFAULT_RENDERER_SIZE,wxDVC_DEFAULT_RENDERER_SIZE);
|
return GetView()->FromDIP(wxSize(wxDVC_DEFAULT_RENDERER_SIZE,
|
||||||
|
wxDVC_DEFAULT_RENDERER_SIZE));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
@@ -1251,7 +1256,8 @@ wxSize wxDataViewBitmapRenderer::GetSize() const
|
|||||||
else if (m_icon.IsOk())
|
else if (m_icon.IsOk())
|
||||||
return wxSize( m_icon.GetWidth(), m_icon.GetHeight() );
|
return wxSize( m_icon.GetWidth(), m_icon.GetHeight() );
|
||||||
|
|
||||||
return wxSize(wxDVC_DEFAULT_RENDERER_SIZE,wxDVC_DEFAULT_RENDERER_SIZE);
|
return GetView()->FromDIP(wxSize(wxDVC_DEFAULT_RENDERER_SIZE,
|
||||||
|
wxDVC_DEFAULT_RENDERER_SIZE));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
@@ -2770,11 +2776,8 @@ bool wxDataViewMainWindow::ItemAdded(const wxDataViewItem & parent, const wxData
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( m_rowHeightCache )
|
// specific position (row) is unclear, so clear whole height cache
|
||||||
{
|
ClearRowHeightCache();
|
||||||
// specific position (row) is unclear, so clear whole height cache
|
|
||||||
m_rowHeightCache->Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
wxDataViewTreeNode *parentNode = FindNode(parent);
|
wxDataViewTreeNode *parentNode = FindNode(parent);
|
||||||
|
|
||||||
@@ -3039,8 +3042,7 @@ bool wxDataViewMainWindow::Cleared()
|
|||||||
m_selection.Clear();
|
m_selection.Clear();
|
||||||
m_currentRow = (unsigned)-1;
|
m_currentRow = (unsigned)-1;
|
||||||
|
|
||||||
if ( m_rowHeightCache )
|
ClearRowHeightCache();
|
||||||
m_rowHeightCache->Clear();
|
|
||||||
|
|
||||||
if (GetModel())
|
if (GetModel())
|
||||||
{
|
{
|
||||||
@@ -5107,6 +5109,7 @@ void wxDataViewMainWindow::UpdateColumnSizes()
|
|||||||
wxIMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl, wxDataViewCtrlBase);
|
wxIMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl, wxDataViewCtrlBase);
|
||||||
wxBEGIN_EVENT_TABLE(wxDataViewCtrl, wxDataViewCtrlBase)
|
wxBEGIN_EVENT_TABLE(wxDataViewCtrl, wxDataViewCtrlBase)
|
||||||
EVT_SIZE(wxDataViewCtrl::OnSize)
|
EVT_SIZE(wxDataViewCtrl::OnSize)
|
||||||
|
EVT_DPI_CHANGED(wxDataViewCtrl::OnDPIChanged)
|
||||||
wxEND_EVENT_TABLE()
|
wxEND_EVENT_TABLE()
|
||||||
|
|
||||||
wxDataViewCtrl::~wxDataViewCtrl()
|
wxDataViewCtrl::~wxDataViewCtrl()
|
||||||
@@ -5251,6 +5254,28 @@ void wxDataViewCtrl::OnSize( wxSizeEvent &WXUNUSED(event) )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxDataViewCtrl::OnDPIChanged(wxDPIChangedEvent& event)
|
||||||
|
{
|
||||||
|
if ( m_clientArea )
|
||||||
|
{
|
||||||
|
m_clientArea->ClearRowHeightCache();
|
||||||
|
m_clientArea->SetRowHeight(m_clientArea->GetDefaultRowHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( unsigned i = 0; i < m_cols.size(); ++i )
|
||||||
|
{
|
||||||
|
int minWidth = m_cols[i]->GetMinWidth();
|
||||||
|
if ( minWidth > 0 )
|
||||||
|
minWidth = minWidth * event.GetNewDPI().x / event.GetOldDPI().x;
|
||||||
|
m_cols[i]->SetMinWidth(minWidth);
|
||||||
|
|
||||||
|
int width = m_cols[i]->WXGetManuallySetWidth();
|
||||||
|
if ( width > 0 )
|
||||||
|
width = width * event.GetNewDPI().x / event.GetOldDPI().x;
|
||||||
|
m_cols[i]->SetWidth(width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void wxDataViewCtrl::SetFocus()
|
void wxDataViewCtrl::SetFocus()
|
||||||
{
|
{
|
||||||
if (m_clientArea)
|
if (m_clientArea)
|
||||||
|
Reference in New Issue
Block a user