extract (and expand and clean up and document) the header window implementation used inside the generic wxDataViewCtrl in a separate wxHeaderCtrl class which could be reused in (generic) wxListCtrl and, most importantly, wxGrid later
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57093 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -124,9 +124,10 @@ TEST_GUI_OBJECTS = \
|
||||
test_gui_point.o \
|
||||
test_gui_config.o \
|
||||
test_gui_comboboxtest.o \
|
||||
test_gui_headerctrltest.o \
|
||||
test_gui_listctrltest.o \
|
||||
test_gui_textctrltest.o \
|
||||
test_gui_textentrytest.o \
|
||||
test_gui_listctrltest.o \
|
||||
test_gui_rawbmp.o \
|
||||
test_gui_htmlwindow.o \
|
||||
test_gui_guifuncs.o \
|
||||
@@ -538,15 +539,18 @@ test_gui_config.o: $(srcdir)/config/config.cpp $(TEST_GUI_ODEP)
|
||||
test_gui_comboboxtest.o: $(srcdir)/controls/comboboxtest.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/comboboxtest.cpp
|
||||
|
||||
test_gui_headerctrltest.o: $(srcdir)/controls/headerctrltest.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/headerctrltest.cpp
|
||||
|
||||
test_gui_listctrltest.o: $(srcdir)/controls/listctrltest.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/listctrltest.cpp
|
||||
|
||||
test_gui_textctrltest.o: $(srcdir)/controls/textctrltest.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/textctrltest.cpp
|
||||
|
||||
test_gui_textentrytest.o: $(srcdir)/controls/textentrytest.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/textentrytest.cpp
|
||||
|
||||
test_gui_listctrltest.o: $(srcdir)/controls/listctrltest.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/listctrltest.cpp
|
||||
|
||||
test_gui_rawbmp.o: $(srcdir)/image/rawbmp.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/image/rawbmp.cpp
|
||||
|
||||
|
104
tests/controls/headerctrltest.cpp
Normal file
104
tests/controls/headerctrltest.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/headerctrltest.cpp
|
||||
// Purpose: wxHeaderCtrl unit test
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2008-11-26
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/headerctrl.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class HeaderCtrlTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
HeaderCtrlTestCase() { }
|
||||
|
||||
virtual void setUp();
|
||||
virtual void tearDown();
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( HeaderCtrlTestCase );
|
||||
CPPUNIT_TEST( AddDelete );
|
||||
CPPUNIT_TEST( BestSize );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void AddDelete();
|
||||
void BestSize();
|
||||
|
||||
wxHeaderCtrl *m_header;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(HeaderCtrlTestCase)
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( HeaderCtrlTestCase );
|
||||
|
||||
// also include in it's own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( HeaderCtrlTestCase, "HeaderCtrlTestCase" );
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test initialization
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void HeaderCtrlTestCase::setUp()
|
||||
{
|
||||
m_header = new wxHeaderCtrl(wxTheApp->GetTopWindow());
|
||||
}
|
||||
|
||||
void HeaderCtrlTestCase::tearDown()
|
||||
{
|
||||
delete m_header;
|
||||
m_header = NULL;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// the tests themselves
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void HeaderCtrlTestCase::AddDelete()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL( 0, m_header->GetColumnCount() );
|
||||
|
||||
m_header->AppendColumn(wxHeaderCtrlColumn("Column 1"));
|
||||
CPPUNIT_ASSERT_EQUAL( 1, m_header->GetColumnCount() );
|
||||
|
||||
m_header->AppendColumn(wxHeaderCtrlColumn("Column 2"));
|
||||
CPPUNIT_ASSERT_EQUAL( 2, m_header->GetColumnCount() );
|
||||
|
||||
m_header->InsertColumn(wxHeaderCtrlColumn("Column 0"), 0);
|
||||
CPPUNIT_ASSERT_EQUAL( 3, m_header->GetColumnCount() );
|
||||
|
||||
m_header->DeleteColumn(2);
|
||||
CPPUNIT_ASSERT_EQUAL( 2, m_header->GetColumnCount() );
|
||||
}
|
||||
|
||||
void HeaderCtrlTestCase::BestSize()
|
||||
{
|
||||
const wxSize sizeEmpty = m_header->GetBestSize();
|
||||
CPPUNIT_ASSERT( sizeEmpty.x > 0 );
|
||||
CPPUNIT_ASSERT( sizeEmpty.y > 0 );
|
||||
|
||||
m_header->AppendColumn(wxHeaderCtrlColumn("Foo"));
|
||||
m_header->AppendColumn(wxHeaderCtrlColumn("Bar"));
|
||||
const wxSize size = m_header->GetBestSize();
|
||||
CPPUNIT_ASSERT_EQUAL( sizeEmpty.y, size.y );
|
||||
}
|
||||
|
@@ -111,9 +111,10 @@ TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_point.obj \
|
||||
$(OBJS)\test_gui_config.obj \
|
||||
$(OBJS)\test_gui_comboboxtest.obj \
|
||||
$(OBJS)\test_gui_headerctrltest.obj \
|
||||
$(OBJS)\test_gui_listctrltest.obj \
|
||||
$(OBJS)\test_gui_textctrltest.obj \
|
||||
$(OBJS)\test_gui_textentrytest.obj \
|
||||
$(OBJS)\test_gui_listctrltest.obj \
|
||||
$(OBJS)\test_gui_rawbmp.obj \
|
||||
$(OBJS)\test_gui_htmlwindow.obj \
|
||||
$(OBJS)\test_gui_guifuncs.obj \
|
||||
@@ -578,15 +579,18 @@ $(OBJS)\test_gui_config.obj: .\config\config.cpp
|
||||
$(OBJS)\test_gui_comboboxtest.obj: .\controls\comboboxtest.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\comboboxtest.cpp
|
||||
|
||||
$(OBJS)\test_gui_headerctrltest.obj: .\controls\headerctrltest.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\headerctrltest.cpp
|
||||
|
||||
$(OBJS)\test_gui_listctrltest.obj: .\controls\listctrltest.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\listctrltest.cpp
|
||||
|
||||
$(OBJS)\test_gui_textctrltest.obj: .\controls\textctrltest.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\textctrltest.cpp
|
||||
|
||||
$(OBJS)\test_gui_textentrytest.obj: .\controls\textentrytest.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\textentrytest.cpp
|
||||
|
||||
$(OBJS)\test_gui_listctrltest.obj: .\controls\listctrltest.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\listctrltest.cpp
|
||||
|
||||
$(OBJS)\test_gui_rawbmp.obj: .\image\rawbmp.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\image\rawbmp.cpp
|
||||
|
||||
|
@@ -104,9 +104,10 @@ TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_point.o \
|
||||
$(OBJS)\test_gui_config.o \
|
||||
$(OBJS)\test_gui_comboboxtest.o \
|
||||
$(OBJS)\test_gui_headerctrltest.o \
|
||||
$(OBJS)\test_gui_listctrltest.o \
|
||||
$(OBJS)\test_gui_textctrltest.o \
|
||||
$(OBJS)\test_gui_textentrytest.o \
|
||||
$(OBJS)\test_gui_listctrltest.o \
|
||||
$(OBJS)\test_gui_rawbmp.o \
|
||||
$(OBJS)\test_gui_htmlwindow.o \
|
||||
$(OBJS)\test_gui_guifuncs.o \
|
||||
@@ -556,15 +557,18 @@ $(OBJS)\test_gui_config.o: ./config/config.cpp
|
||||
$(OBJS)\test_gui_comboboxtest.o: ./controls/comboboxtest.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_gui_headerctrltest.o: ./controls/headerctrltest.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_gui_listctrltest.o: ./controls/listctrltest.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_gui_textctrltest.o: ./controls/textctrltest.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_gui_textentrytest.o: ./controls/textentrytest.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_gui_listctrltest.o: ./controls/listctrltest.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_gui_rawbmp.o: ./image/rawbmp.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
|
@@ -107,9 +107,10 @@ TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_point.obj \
|
||||
$(OBJS)\test_gui_config.obj \
|
||||
$(OBJS)\test_gui_comboboxtest.obj \
|
||||
$(OBJS)\test_gui_headerctrltest.obj \
|
||||
$(OBJS)\test_gui_listctrltest.obj \
|
||||
$(OBJS)\test_gui_textctrltest.obj \
|
||||
$(OBJS)\test_gui_textentrytest.obj \
|
||||
$(OBJS)\test_gui_listctrltest.obj \
|
||||
$(OBJS)\test_gui_rawbmp.obj \
|
||||
$(OBJS)\test_gui_htmlwindow.obj \
|
||||
$(OBJS)\test_gui_guifuncs.obj \
|
||||
@@ -663,15 +664,18 @@ $(OBJS)\test_gui_config.obj: .\config\config.cpp
|
||||
$(OBJS)\test_gui_comboboxtest.obj: .\controls\comboboxtest.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\comboboxtest.cpp
|
||||
|
||||
$(OBJS)\test_gui_headerctrltest.obj: .\controls\headerctrltest.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\headerctrltest.cpp
|
||||
|
||||
$(OBJS)\test_gui_listctrltest.obj: .\controls\listctrltest.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\listctrltest.cpp
|
||||
|
||||
$(OBJS)\test_gui_textctrltest.obj: .\controls\textctrltest.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\textctrltest.cpp
|
||||
|
||||
$(OBJS)\test_gui_textentrytest.obj: .\controls\textentrytest.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\textentrytest.cpp
|
||||
|
||||
$(OBJS)\test_gui_listctrltest.obj: .\controls\listctrltest.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\listctrltest.cpp
|
||||
|
||||
$(OBJS)\test_gui_rawbmp.obj: .\image\rawbmp.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\image\rawbmp.cpp
|
||||
|
||||
|
@@ -321,9 +321,10 @@ TEST_GUI_OBJECTS = &
|
||||
$(OBJS)\test_gui_point.obj &
|
||||
$(OBJS)\test_gui_config.obj &
|
||||
$(OBJS)\test_gui_comboboxtest.obj &
|
||||
$(OBJS)\test_gui_headerctrltest.obj &
|
||||
$(OBJS)\test_gui_listctrltest.obj &
|
||||
$(OBJS)\test_gui_textctrltest.obj &
|
||||
$(OBJS)\test_gui_textentrytest.obj &
|
||||
$(OBJS)\test_gui_listctrltest.obj &
|
||||
$(OBJS)\test_gui_rawbmp.obj &
|
||||
$(OBJS)\test_gui_htmlwindow.obj &
|
||||
$(OBJS)\test_gui_guifuncs.obj &
|
||||
@@ -610,15 +611,18 @@ $(OBJS)\test_gui_config.obj : .AUTODEPEND .\config\config.cpp
|
||||
$(OBJS)\test_gui_comboboxtest.obj : .AUTODEPEND .\controls\comboboxtest.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\test_gui_headerctrltest.obj : .AUTODEPEND .\controls\headerctrltest.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\test_gui_listctrltest.obj : .AUTODEPEND .\controls\listctrltest.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\test_gui_textctrltest.obj : .AUTODEPEND .\controls\textctrltest.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\test_gui_textentrytest.obj : .AUTODEPEND .\controls\textentrytest.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\test_gui_listctrltest.obj : .AUTODEPEND .\controls\listctrltest.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\test_gui_rawbmp.obj : .AUTODEPEND .\image\rawbmp.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
|
||||
|
||||
|
@@ -108,9 +108,10 @@
|
||||
geometry/point.cpp
|
||||
config/config.cpp
|
||||
controls/comboboxtest.cpp
|
||||
controls/headerctrltest.cpp
|
||||
controls/listctrltest.cpp
|
||||
controls/textctrltest.cpp
|
||||
controls/textentrytest.cpp
|
||||
controls/listctrltest.cpp
|
||||
image/rawbmp.cpp
|
||||
html/htmlwindow.cpp
|
||||
misc/guifuncs.cpp
|
||||
|
@@ -257,6 +257,10 @@ SOURCE=.\misc\guifuncs.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\controls\headerctrltest.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\html\htmlwindow.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@@ -612,6 +612,9 @@
|
||||
<File
|
||||
RelativePath=".\misc\guifuncs.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\controls\headerctrltest.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\html\htmlwindow.cpp">
|
||||
</File>
|
||||
|
@@ -895,6 +895,10 @@
|
||||
RelativePath=".\misc\guifuncs.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\controls\headerctrltest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\html\htmlwindow.cpp"
|
||||
>
|
||||
|
@@ -867,6 +867,10 @@
|
||||
RelativePath=".\misc\guifuncs.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\controls\headerctrltest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\html\htmlwindow.cpp"
|
||||
>
|
||||
|
Reference in New Issue
Block a user