diff --git a/docs/changes.txt b/docs/changes.txt index 16cb9613f5..09bfd27724 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -123,6 +123,7 @@ All (GUI): - Implement wxAuiNotebook::GetBestSize() (Sebastian Walderich). - Allow changing tooltip text for button allowing to enter a new string in wxPGArrayEditorDialog. +- Fix wxPropertyGrid issues with horizontal scrolling. 3.1.2: (released 2018-12-10) diff --git a/include/wx/propgrid/propgrid.h b/include/wx/propgrid/propgrid.h index 9239043908..f7b444c21d 100644 --- a/include/wx/propgrid/propgrid.h +++ b/include/wx/propgrid/propgrid.h @@ -1687,10 +1687,10 @@ protected: // Which column's editor is selected (usually 1)? unsigned int m_selColumn; - +#if WXWIN_COMPATIBILITY_3_0 // x relative to splitter (needed for resize). int m_ctrlXAdjust; - +#endif // WXWIN_COMPATIBILITY_3_0 // lines between cells wxColour m_colLine; // property labels and values are written in this colour @@ -1803,7 +1803,11 @@ protected: wxRect GetEditorWidgetRect( wxPGProperty* p, int column ) const; +#if WXWIN_COMPATIBILITY_3_0 + wxDEPRECATED_MSG("Don't use this function. It works only if horizontal scrolling is not active") void CorrectEditorWidgetSizeX(); +#endif // WXWIN_COMPATIBILITY_3_0 + void CorrectEditorWidgetSizeX(int xPosChange, int widthChange); // Called in RecalculateVirtualSize() to reposition control // on virtual height changes. diff --git a/src/propgrid/editors.cpp b/src/propgrid/editors.cpp index fce63e54bd..03d3457529 100644 --- a/src/propgrid/editors.cpp +++ b/src/propgrid/editors.cpp @@ -1786,6 +1786,7 @@ wxWindow* wxPropertyGrid::GetEditorControl() const // ----------------------------------------------------------------------- +#if WXWIN_COMPATIBILITY_3_0 void wxPropertyGrid::CorrectEditorWidgetSizeX() { int secWid = 0; @@ -1827,6 +1828,32 @@ void wxPropertyGrid::CorrectEditorWidgetSizeX() if ( m_wndEditor2 ) m_wndEditor2->Refresh(); } +#endif // WXWIN_COMPATIBILITY_3_0 + +void wxPropertyGrid::CorrectEditorWidgetSizeX(int xPosChange, int widthChange) +{ + if ( m_wndEditor2 ) + { + // if width change occurred, move secondary wnd by that amount + wxPoint p = m_wndEditor2->GetPosition(); + p.x += xPosChange + widthChange; + m_wndEditor2->SetPosition(p); + } + + if ( m_wndEditor ) + { + wxRect r = m_wndEditor->GetRect(); + r.x += xPosChange; + + if ( !(m_iFlags & wxPG_FL_FIXED_WIDTH_EDITOR) ) + r.width += widthChange; + + m_wndEditor->SetSize(r); + } + + if ( m_wndEditor2 ) + m_wndEditor2->Refresh(); +} // ----------------------------------------------------------------------- diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index 0897101c90..1675f2697d 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -2796,17 +2796,23 @@ void wxPropertyGrid::DoSetSplitterPosition( int newxpos, if ( ( newxpos < wxPG_DRAG_MARGIN ) ) return; - wxPropertyGridPageState* state = m_pState; - if ( flags & wxPG_SPLITTER_FROM_EVENT ) - state->m_dontCenterSplitter = true; + m_pState->m_dontCenterSplitter = true; - state->DoSetSplitterPosition(newxpos, splitterIndex, flags); + // Save position and size of column 1 used for main editor widgets + int xPosEditorCol = m_pState->DoGetSplitterPosition(0); + int widthEditorCol = m_pState->GetColumnWidth(1); + + m_pState->DoSetSplitterPosition(newxpos, splitterIndex, flags); if ( flags & wxPG_SPLITTER_REFRESH ) { if ( GetSelection() ) - CorrectEditorWidgetSizeX(); + { + int xPosChange = m_pState->DoGetSplitterPosition(0) - xPosEditorCol; + int widthColChange = m_pState->GetColumnWidth(1) - widthEditorCol; + CorrectEditorWidgetSizeX(xPosChange, widthColChange); + } Refresh(); } @@ -2820,9 +2826,17 @@ void wxPropertyGrid::ResetColumnSizes( bool enableAutoResizing ) { if ( m_pState ) { + // Save position and size of column 1 used for main editor widgets + int xPosEditorCol = m_pState->DoGetSplitterPosition(0); + int widthEditorCol = m_pState->GetColumnWidth(1); + m_pState->ResetColumnSizes(0); if ( GetSelection() ) - CorrectEditorWidgetSizeX(); + { + int xPosChange = m_pState->DoGetSplitterPosition(0) - xPosEditorCol; + int widthColChange = m_pState->GetColumnWidth(1) - widthEditorCol; + CorrectEditorWidgetSizeX(xPosChange, widthColChange); + } Refresh(); if ( enableAutoResizing && HasFlag(wxPG_SPLITTER_AUTO_CENTER) ) @@ -4221,9 +4235,10 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags ) if ( p->HasFlag(wxPG_PROP_MODIFIED) && (m_windowStyle & wxPG_BOLD_MODIFIED) ) SetCurControlBoldFont(); - +#if WXWIN_COMPATIBILITY_3_0 // Store x relative to splitter (we'll need it). m_ctrlXAdjust = m_wndEditor->GetPosition().x - splitterX; +#endif // WXWIN_COMPATIBILITY_3_0 // Check if background clear is not necessary wxPoint pos = m_wndEditor->GetPosition(); @@ -4556,6 +4571,13 @@ void wxPropertyGrid::RecalculateVirtualSize( int forceXPos ) m_iFlags |= wxPG_FL_RECALCULATING_VIRTUAL_SIZE; + // Save position and size of column 1 used for main editor widgets + int vx; + GetViewStart(&vx, NULL); + vx *= wxPG_PIXELS_PER_UNIT; + int xPosEditorCol = m_pState->DoGetSplitterPosition(0) - vx; + int widthEditorCol = m_pState->GetColumnWidth(1); + int x = m_pState->GetVirtualWidth(); int y = m_pState->m_virtualHeight; @@ -4607,7 +4629,13 @@ void wxPropertyGrid::RecalculateVirtualSize( int forceXPos ) m_pState->CheckColumnWidths(); if ( GetSelection() ) - CorrectEditorWidgetSizeX(); + { + GetViewStart(&vx, NULL); + vx *= wxPG_PIXELS_PER_UNIT; + int xPosChange = m_pState->DoGetSplitterPosition(0) - vx - xPosEditorCol; + int widthColChange = m_pState->GetColumnWidth(1) - widthEditorCol; + CorrectEditorWidgetSizeX(xPosChange, widthColChange); + } m_iFlags &= ~wxPG_FL_RECALCULATING_VIRTUAL_SIZE; }