diff --git a/include/wx/propgrid/propgrid.h b/include/wx/propgrid/propgrid.h index 455570d13d..7c8b22d1f5 100644 --- a/include/wx/propgrid/propgrid.h +++ b/include/wx/propgrid/propgrid.h @@ -1465,6 +1465,9 @@ protected: // wxWindow pointers to editor control(s). wxWindow *m_wndEditor; wxWindow *m_wndEditor2; + // Actual positions of the editors within the cell. + wxPoint m_wndEditorPosRel; + wxPoint m_wndEditor2PosRel; wxBitmap *m_doubleBuffer; @@ -1644,8 +1647,9 @@ protected: // pointer to property that has mouse hovering wxPGProperty* m_propHover; - // Active label editor + // Active label editor and its actual position within the cell wxTextCtrl* m_labelEditor; + wxPoint m_labelEditorPosRel; // For which property the label editor is active wxPGProperty* m_labelEditorProperty; diff --git a/src/propgrid/editors.cpp b/src/propgrid/editors.cpp index 7288acd256..7124d86973 100644 --- a/src/propgrid/editors.cpp +++ b/src/propgrid/editors.cpp @@ -1835,12 +1835,7 @@ void wxPropertyGrid::CorrectEditorWidgetPosY() if ( m_labelEditor ) { wxRect r = GetEditorWidgetRect(selected, m_selColumn); - wxPoint pos = m_labelEditor->GetPosition(); - - // Calculate y offset - int offset = pos.y % m_lineHeight; - - m_labelEditor->Move(pos.x, r.y + offset); + m_labelEditor->Move(r.GetPosition() + m_labelEditorPosRel); } if ( m_wndEditor || m_wndEditor2 ) @@ -1849,19 +1844,12 @@ void wxPropertyGrid::CorrectEditorWidgetPosY() if ( m_wndEditor ) { - wxPoint pos = m_wndEditor->GetPosition(); - - // Calculate y offset - int offset = pos.y % m_lineHeight; - - m_wndEditor->Move(pos.x, r.y + offset); + m_wndEditor->Move(r.GetPosition() + m_wndEditorPosRel); } if ( m_wndEditor2 ) { - wxPoint pos = m_wndEditor2->GetPosition(); - - m_wndEditor2->Move(pos.x, r.y); + m_wndEditor2->Move(r.GetPosition() + m_wndEditor2PosRel); } } } diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index b1c878c6f1..0b207b79f7 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -1039,6 +1039,8 @@ void wxPropertyGrid::DoBeginLabelEdit( unsigned int colIndex, tc->SetFocus(); m_labelEditor = wxStaticCast(tc, wxTextCtrl); + // Get actual position within required rectangle + m_labelEditorPosRel = m_labelEditor->GetPosition() - r.GetPosition(); m_labelEditorProperty = selected; } @@ -4198,6 +4200,17 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags ) m_wndEditor = wndList.m_primary; m_wndEditor2 = wndList.m_secondary; + // Remember actual positions within required cell. + // These values can be used when there will be required + // to reposition the cell. + if ( m_wndEditor ) + { + m_wndEditorPosRel = m_wndEditor->GetPosition() - goodPos; + } + if ( m_wndEditor2 ) + { + m_wndEditor2PosRel = m_wndEditor2->GetPosition() - goodPos; + } primaryCtrl = GetEditorControl(); //