Add minimal DPI change handler to wxGrid
This handler redoes wxGrid layout and refreshes it to at least avoid ugly display artifacts when moving wxGrid window between displays with different DPI.
This commit is contained in:
parent
393f5c8e2b
commit
5e761ad99f
@ -2415,6 +2415,13 @@ protected:
|
||||
friend class wxGridHeaderCtrl;
|
||||
|
||||
private:
|
||||
// This is called from both Create() and OnDPIChanged() to (re)initialize
|
||||
// the values in pixels, which depend on the current DPI.
|
||||
void InitPixelFields();
|
||||
|
||||
// Event handler for DPI change event recomputes pixel values and relays
|
||||
// out the grid.
|
||||
void OnDPIChanged(wxDPIChangedEvent& event);
|
||||
|
||||
// implement wxScrolledCanvas method to return m_gridWin size
|
||||
virtual wxSize GetSizeAvailableForScrollTarget(const wxSize& size) wxOVERRIDE;
|
||||
|
@ -2317,6 +2317,7 @@ void wxGridWindow::OnFocus(wxFocusEvent& event)
|
||||
|
||||
wxBEGIN_EVENT_TABLE( wxGrid, wxScrolledCanvas )
|
||||
EVT_SIZE( wxGrid::OnSize )
|
||||
EVT_DPI_CHANGED( wxGrid::OnDPIChanged )
|
||||
EVT_KEY_DOWN( wxGrid::OnKeyDown )
|
||||
EVT_KEY_UP( wxGrid::OnKeyUp )
|
||||
EVT_CHAR ( wxGrid::OnChar )
|
||||
@ -2457,8 +2458,11 @@ void wxGrid::Create()
|
||||
m_labelBackgroundColour = m_rowLabelWin->GetBackgroundColour();
|
||||
m_labelTextColour = m_rowLabelWin->GetForegroundColour();
|
||||
|
||||
// now that we have the grid window, use its font to compute the default
|
||||
// row height
|
||||
InitPixelFields();
|
||||
}
|
||||
|
||||
void wxGrid::InitPixelFields()
|
||||
{
|
||||
m_defaultRowHeight = m_gridWin->GetCharHeight();
|
||||
#if defined(__WXMOTIF__) || defined(__WXGTK__) || defined(__WXQT__) // see also text ctrl sizing in ShowCellEditControl()
|
||||
m_defaultRowHeight += 8;
|
||||
@ -5346,6 +5350,19 @@ void wxGrid::OnSize(wxSizeEvent& WXUNUSED(event))
|
||||
}
|
||||
}
|
||||
|
||||
void wxGrid::OnDPIChanged(wxDPIChangedEvent& event)
|
||||
{
|
||||
InitPixelFields();
|
||||
|
||||
InvalidateBestSize();
|
||||
|
||||
CalcWindowSizes();
|
||||
|
||||
Refresh();
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void wxGrid::OnKeyDown( wxKeyEvent& event )
|
||||
{
|
||||
if ( m_inOnKeyDown )
|
||||
|
Loading…
Reference in New Issue
Block a user