Respect minimum grid column width when using native header too
Override wxHeaderColumn::GetMinWidth() to return the actual minimum width instead of just returning 0. Add a unit test verifying that this works as intended.
This commit is contained in:
committed by
Vadim Zeitlin
parent
2290d97453
commit
e5d59c6b7f
@@ -95,7 +95,7 @@ public:
|
|||||||
virtual wxString GetTitle() const wxOVERRIDE { return m_grid->GetColLabelValue(m_col); }
|
virtual wxString GetTitle() const wxOVERRIDE { return m_grid->GetColLabelValue(m_col); }
|
||||||
virtual wxBitmap GetBitmap() const wxOVERRIDE { return wxNullBitmap; }
|
virtual wxBitmap GetBitmap() const wxOVERRIDE { return wxNullBitmap; }
|
||||||
virtual int GetWidth() const wxOVERRIDE { return m_grid->GetColSize(m_col); }
|
virtual int GetWidth() const wxOVERRIDE { return m_grid->GetColSize(m_col); }
|
||||||
virtual int GetMinWidth() const wxOVERRIDE { return 0; }
|
virtual int GetMinWidth() const wxOVERRIDE { return m_grid->GetColMinimalAcceptableWidth(); }
|
||||||
virtual wxAlignment GetAlignment() const wxOVERRIDE
|
virtual wxAlignment GetAlignment() const wxOVERRIDE
|
||||||
{
|
{
|
||||||
int horz,
|
int horz,
|
||||||
|
@@ -67,11 +67,13 @@ private:
|
|||||||
WXUISIM_TEST( Editable );
|
WXUISIM_TEST( Editable );
|
||||||
WXUISIM_TEST( ReadOnly );
|
WXUISIM_TEST( ReadOnly );
|
||||||
WXUISIM_TEST( ResizeScrolledHeader );
|
WXUISIM_TEST( ResizeScrolledHeader );
|
||||||
|
WXUISIM_TEST( ColumnMinWidth );
|
||||||
CPPUNIT_TEST( PseudoTest_NativeHeader );
|
CPPUNIT_TEST( PseudoTest_NativeHeader );
|
||||||
NONGTK_TEST( LabelClick );
|
NONGTK_TEST( LabelClick );
|
||||||
NONGTK_TEST( SortClick );
|
NONGTK_TEST( SortClick );
|
||||||
CPPUNIT_TEST( ColumnOrder );
|
CPPUNIT_TEST( ColumnOrder );
|
||||||
WXUISIM_TEST( ResizeScrolledHeader );
|
WXUISIM_TEST( ResizeScrolledHeader );
|
||||||
|
WXUISIM_TEST( ColumnMinWidth );
|
||||||
CPPUNIT_TEST( PseudoTest_NativeLabels );
|
CPPUNIT_TEST( PseudoTest_NativeLabels );
|
||||||
NONGTK_TEST( LabelClick );
|
NONGTK_TEST( LabelClick );
|
||||||
NONGTK_TEST( SortClick );
|
NONGTK_TEST( SortClick );
|
||||||
@@ -100,6 +102,7 @@ private:
|
|||||||
void ReadOnly();
|
void ReadOnly();
|
||||||
void WindowAsEditorControl();
|
void WindowAsEditorControl();
|
||||||
void ResizeScrolledHeader();
|
void ResizeScrolledHeader();
|
||||||
|
void ColumnMinWidth();
|
||||||
void PseudoTest_NativeHeader() { ms_nativeheader = true; }
|
void PseudoTest_NativeHeader() { ms_nativeheader = true; }
|
||||||
void PseudoTest_NativeLabels() { ms_nativeheader = false;
|
void PseudoTest_NativeLabels() { ms_nativeheader = false;
|
||||||
ms_nativelabels = true; }
|
ms_nativelabels = true; }
|
||||||
@@ -848,4 +851,42 @@ void GridTestCase::ResizeScrolledHeader()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GridTestCase::ColumnMinWidth()
|
||||||
|
{
|
||||||
|
// TODO this test currently works only under Windows unfortunately
|
||||||
|
#if wxUSE_UIACTIONSIMULATOR && defined(__WXMSW__)
|
||||||
|
int const startminwidth = m_grid->GetColMinimalAcceptableWidth();
|
||||||
|
m_grid->SetColMinimalAcceptableWidth(startminwidth*2);
|
||||||
|
int const newminwidth = m_grid->GetColMinimalAcceptableWidth();
|
||||||
|
int const startwidth = m_grid->GetColSize(0);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(m_grid->GetColMinimalAcceptableWidth() < startwidth);
|
||||||
|
|
||||||
|
wxRect rect = m_grid->CellToRect(0, 1);
|
||||||
|
wxPoint point = m_grid->CalcScrolledPosition(rect.GetPosition());
|
||||||
|
point = m_grid->ClientToScreen(point
|
||||||
|
+ wxPoint(m_grid->GetRowLabelSize(),
|
||||||
|
m_grid->GetColLabelSize())
|
||||||
|
- wxPoint(0, 5));
|
||||||
|
|
||||||
|
wxUIActionSimulator sim;
|
||||||
|
|
||||||
|
// Drag to reach the minimal width.
|
||||||
|
wxYield();
|
||||||
|
sim.MouseMove(point);
|
||||||
|
wxYield();
|
||||||
|
sim.MouseDown();
|
||||||
|
wxYield();
|
||||||
|
sim.MouseMove(point - wxPoint(startwidth - startminwidth, 0));
|
||||||
|
wxYield();
|
||||||
|
sim.MouseUp();
|
||||||
|
wxYield();
|
||||||
|
|
||||||
|
if ( ms_nativeheader )
|
||||||
|
CPPUNIT_ASSERT_EQUAL(startwidth, m_grid->GetColSize(0));
|
||||||
|
else
|
||||||
|
CPPUNIT_ASSERT_EQUAL(newminwidth, m_grid->GetColSize(0));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#endif //wxUSE_GRID
|
#endif //wxUSE_GRID
|
||||||
|
Reference in New Issue
Block a user