Fix repositioning editors for horizontally scrolled grid

Closes #18313.
This commit is contained in:
Artur Wieczorek
2018-12-28 09:18:06 +01:00
parent 9b7c281e6b
commit 95461c566d
4 changed files with 70 additions and 10 deletions

View File

@@ -123,6 +123,7 @@ All (GUI):
- Implement wxAuiNotebook::GetBestSize() (Sebastian Walderich). - Implement wxAuiNotebook::GetBestSize() (Sebastian Walderich).
- Allow changing tooltip text for button allowing to enter a new string - Allow changing tooltip text for button allowing to enter a new string
in wxPGArrayEditorDialog. in wxPGArrayEditorDialog.
- Fix wxPropertyGrid issues with horizontal scrolling.
3.1.2: (released 2018-12-10) 3.1.2: (released 2018-12-10)

View File

@@ -1687,10 +1687,10 @@ protected:
// Which column's editor is selected (usually 1)? // Which column's editor is selected (usually 1)?
unsigned int m_selColumn; unsigned int m_selColumn;
#if WXWIN_COMPATIBILITY_3_0
// x relative to splitter (needed for resize). // x relative to splitter (needed for resize).
int m_ctrlXAdjust; int m_ctrlXAdjust;
#endif // WXWIN_COMPATIBILITY_3_0
// lines between cells // lines between cells
wxColour m_colLine; wxColour m_colLine;
// property labels and values are written in this colour // property labels and values are written in this colour
@@ -1803,7 +1803,11 @@ protected:
wxRect GetEditorWidgetRect( wxPGProperty* p, int column ) const; 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(); void CorrectEditorWidgetSizeX();
#endif // WXWIN_COMPATIBILITY_3_0
void CorrectEditorWidgetSizeX(int xPosChange, int widthChange);
// Called in RecalculateVirtualSize() to reposition control // Called in RecalculateVirtualSize() to reposition control
// on virtual height changes. // on virtual height changes.

View File

@@ -1786,6 +1786,7 @@ wxWindow* wxPropertyGrid::GetEditorControl() const
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
#if WXWIN_COMPATIBILITY_3_0
void wxPropertyGrid::CorrectEditorWidgetSizeX() void wxPropertyGrid::CorrectEditorWidgetSizeX()
{ {
int secWid = 0; int secWid = 0;
@@ -1827,6 +1828,32 @@ void wxPropertyGrid::CorrectEditorWidgetSizeX()
if ( m_wndEditor2 ) if ( m_wndEditor2 )
m_wndEditor2->Refresh(); 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();
}
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------

View File

@@ -2796,17 +2796,23 @@ void wxPropertyGrid::DoSetSplitterPosition( int newxpos,
if ( ( newxpos < wxPG_DRAG_MARGIN ) ) if ( ( newxpos < wxPG_DRAG_MARGIN ) )
return; return;
wxPropertyGridPageState* state = m_pState;
if ( flags & wxPG_SPLITTER_FROM_EVENT ) 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 ( flags & wxPG_SPLITTER_REFRESH )
{ {
if ( GetSelection() ) if ( GetSelection() )
CorrectEditorWidgetSizeX(); {
int xPosChange = m_pState->DoGetSplitterPosition(0) - xPosEditorCol;
int widthColChange = m_pState->GetColumnWidth(1) - widthEditorCol;
CorrectEditorWidgetSizeX(xPosChange, widthColChange);
}
Refresh(); Refresh();
} }
@@ -2820,9 +2826,17 @@ void wxPropertyGrid::ResetColumnSizes( bool enableAutoResizing )
{ {
if ( m_pState ) 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); m_pState->ResetColumnSizes(0);
if ( GetSelection() ) if ( GetSelection() )
CorrectEditorWidgetSizeX(); {
int xPosChange = m_pState->DoGetSplitterPosition(0) - xPosEditorCol;
int widthColChange = m_pState->GetColumnWidth(1) - widthEditorCol;
CorrectEditorWidgetSizeX(xPosChange, widthColChange);
}
Refresh(); Refresh();
if ( enableAutoResizing && HasFlag(wxPG_SPLITTER_AUTO_CENTER) ) 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) && if ( p->HasFlag(wxPG_PROP_MODIFIED) &&
(m_windowStyle & wxPG_BOLD_MODIFIED) ) (m_windowStyle & wxPG_BOLD_MODIFIED) )
SetCurControlBoldFont(); SetCurControlBoldFont();
#if WXWIN_COMPATIBILITY_3_0
// Store x relative to splitter (we'll need it). // Store x relative to splitter (we'll need it).
m_ctrlXAdjust = m_wndEditor->GetPosition().x - splitterX; m_ctrlXAdjust = m_wndEditor->GetPosition().x - splitterX;
#endif // WXWIN_COMPATIBILITY_3_0
// Check if background clear is not necessary // Check if background clear is not necessary
wxPoint pos = m_wndEditor->GetPosition(); wxPoint pos = m_wndEditor->GetPosition();
@@ -4556,6 +4571,13 @@ void wxPropertyGrid::RecalculateVirtualSize( int forceXPos )
m_iFlags |= wxPG_FL_RECALCULATING_VIRTUAL_SIZE; 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 x = m_pState->GetVirtualWidth();
int y = m_pState->m_virtualHeight; int y = m_pState->m_virtualHeight;
@@ -4607,7 +4629,13 @@ void wxPropertyGrid::RecalculateVirtualSize( int forceXPos )
m_pState->CheckColumnWidths(); m_pState->CheckColumnWidths();
if ( GetSelection() ) 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; m_iFlags &= ~wxPG_FL_RECALCULATING_VIRTUAL_SIZE;
} }