Improve wxGridCellNumberEditor placement in the grid
Use the best height and don't let the editor be smaller then min size. Also align center vertically.
This commit is contained in:
committed by
Vadim Zeitlin
parent
1be43ed67b
commit
8dadc2e68c
@@ -116,6 +116,8 @@ public:
|
|||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
wxEvtHandler* evtHandler) wxOVERRIDE;
|
wxEvtHandler* evtHandler) wxOVERRIDE;
|
||||||
|
|
||||||
|
virtual void SetSize(const wxRect& rect) wxOVERRIDE;
|
||||||
|
|
||||||
virtual bool IsAcceptedKey(wxKeyEvent& event) wxOVERRIDE;
|
virtual bool IsAcceptedKey(wxKeyEvent& event) wxOVERRIDE;
|
||||||
virtual void BeginEdit(int row, int col, wxGrid* grid) wxOVERRIDE;
|
virtual void BeginEdit(int row, int col, wxGrid* grid) wxOVERRIDE;
|
||||||
virtual bool EndEdit(int row, int col, const wxGrid* grid,
|
virtual bool EndEdit(int row, int col, const wxGrid* grid,
|
||||||
|
@@ -703,6 +703,48 @@ void wxGridCellNumberEditor::Create(wxWindow* parent,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxGridCellNumberEditor::SetSize(const wxRect& rectCell)
|
||||||
|
{
|
||||||
|
#if wxUSE_SPINCTRL
|
||||||
|
if ( HasRange() )
|
||||||
|
{
|
||||||
|
wxASSERT_MSG(m_control, "The wxSpinCtrl must be created first!");
|
||||||
|
|
||||||
|
wxSize size = Spin()->GetBestSize();
|
||||||
|
|
||||||
|
// Extend the control to fill the entire cell horizontally.
|
||||||
|
if ( size.x < rectCell.GetWidth() )
|
||||||
|
size.x = rectCell.GetWidth();
|
||||||
|
|
||||||
|
// Ensure it uses a reasonable height even if wxSpinCtrl::GetBestSize()
|
||||||
|
// didn't return anything useful.
|
||||||
|
if ( size.y <= 0 )
|
||||||
|
size.y = rectCell.GetHeight();
|
||||||
|
|
||||||
|
wxRect rectSpin(rectCell.GetPosition(), size);
|
||||||
|
|
||||||
|
// If possible, i.e. if we're not editing the topmost or leftmost cell,
|
||||||
|
// center the control rectangle in the cell.
|
||||||
|
if ( rectCell.GetTop() > 0 )
|
||||||
|
{
|
||||||
|
rectSpin.SetTop(rectCell.GetTop() -
|
||||||
|
(rectSpin.GetHeight() - rectCell.GetHeight()) / 2);
|
||||||
|
}
|
||||||
|
if ( rectCell.GetLeft() > 0 )
|
||||||
|
{
|
||||||
|
rectSpin.SetLeft(rectCell.GetLeft() -
|
||||||
|
(rectSpin.GetWidth() - rectCell.GetWidth()) / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxGridCellEditor::SetSize(rectSpin);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif // wxUSE_SPINCTRL
|
||||||
|
{
|
||||||
|
wxGridCellTextEditor::SetSize(rectCell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void wxGridCellNumberEditor::BeginEdit(int row, int col, wxGrid* grid)
|
void wxGridCellNumberEditor::BeginEdit(int row, int col, wxGrid* grid)
|
||||||
{
|
{
|
||||||
// first get the value
|
// first get the value
|
||||||
|
Reference in New Issue
Block a user