Fix repositioning of active property editor in wxPG
When there is open an editor for some property and in the same time wxPropertyGrid layout is changed (due to the adding or removing a property, sorting), it is necessary to recalculate the actual position of the active editor to display it in the cell dedicated for the edited property. Under some platforms the position of the edit control is shifted within the cell and we have to take this shift into account in repositioning process. Because actual value of the shift depends on the platform and on the particular control, it is convenient to determine actual shift when the editor is created and use this value whenever repositioning is done. Close #17912.
This commit is contained in:
parent
dd9c08447e
commit
6395e7805a
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user