sorting test added
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4790 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -46,6 +46,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU(LIST_DESELECT_ALL, MyFrame::OnDeselectAll)
|
||||
EVT_MENU(LIST_SELECT_ALL, MyFrame::OnSelectAll)
|
||||
EVT_MENU(LIST_DELETE_ALL, MyFrame::OnDeleteAll)
|
||||
EVT_MENU(LIST_SORT, MyFrame::OnSort)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl)
|
||||
@@ -65,6 +66,12 @@ END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_APP(MyApp)
|
||||
|
||||
int wxCALLBACK MyCompareFunction(long item1, long item2, long sortData)
|
||||
{
|
||||
// inverse the order
|
||||
return item1 < item2;
|
||||
}
|
||||
|
||||
// `Main program' equivalent, creating windows and returning main app frame
|
||||
bool MyApp::OnInit(void)
|
||||
{
|
||||
@@ -134,6 +141,8 @@ bool MyApp::OnInit(void)
|
||||
file_menu->Append(LIST_DESELECT_ALL, "&Deselect All");
|
||||
file_menu->Append(LIST_SELECT_ALL, "S&elect All");
|
||||
file_menu->AppendSeparator();
|
||||
file_menu->Append(LIST_SORT, "&Sort\tCtrl-S");
|
||||
file_menu->AppendSeparator();
|
||||
file_menu->Append(LIST_DELETE_ALL, "Delete &all items");
|
||||
file_menu->AppendSeparator();
|
||||
file_menu->Append(BUSY_ON, "&Busy cursor on");
|
||||
@@ -265,11 +274,12 @@ void MyFrame::OnReportView(wxCommandEvent& WXUNUSED(event))
|
||||
m_listCtrl->InsertColumn(1, "Column 2"); // , wxLIST_FORMAT_LEFT, 140);
|
||||
m_listCtrl->InsertColumn(2, "One More Column (2)"); // , wxLIST_FORMAT_LEFT, 140);
|
||||
|
||||
for ( int i = 0; i < 3000; i++ )
|
||||
for ( int i = 0; i < 300; i++ )
|
||||
{
|
||||
wxChar buf[50];
|
||||
wxSprintf(buf, _T("This is item %d"), i);
|
||||
long tmp = m_listCtrl->InsertItem(i, buf, 0);
|
||||
m_listCtrl->SetItemData(tmp, i);
|
||||
|
||||
wxSprintf(buf, _T("Col 1, item %d"), i);
|
||||
tmp = m_listCtrl->SetItem(i, 1, buf);
|
||||
@@ -341,6 +351,11 @@ void MyFrame::OnSmallIconTextView(wxCommandEvent& WXUNUSED(event))
|
||||
}
|
||||
}
|
||||
|
||||
void MyFrame::OnSort(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
m_listCtrl->SortItems(MyCompareFunction, 0);
|
||||
}
|
||||
|
||||
void MyFrame::OnDeleteAll(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
(void)wxGetElapsedTime(TRUE);
|
||||
|
@@ -11,8 +11,9 @@
|
||||
|
||||
// Define a new application type
|
||||
class MyApp: public wxApp
|
||||
{ public:
|
||||
bool OnInit();
|
||||
{
|
||||
public:
|
||||
virtual bool OnInit();
|
||||
|
||||
wxImageList *m_imageListNormal;
|
||||
wxImageList *m_imageListSmall;
|
||||
@@ -67,6 +68,7 @@ public:
|
||||
void OnDeselectAll(wxCommandEvent& event);
|
||||
void OnSelectAll(wxCommandEvent& event);
|
||||
void OnDeleteAll(wxCommandEvent& event);
|
||||
void OnSort(wxCommandEvent& event);
|
||||
|
||||
void BusyOn(wxCommandEvent& event);
|
||||
void BusyOff(wxCommandEvent& event);
|
||||
@@ -76,20 +78,23 @@ public:
|
||||
|
||||
|
||||
// ID for the menu quit command
|
||||
#define LIST_QUIT 1
|
||||
#define LIST_LIST_VIEW 2
|
||||
#define LIST_ICON_VIEW 3
|
||||
#define LIST_ICON_TEXT_VIEW 4
|
||||
#define LIST_SMALL_ICON_VIEW 5
|
||||
#define LIST_SMALL_ICON_TEXT_VIEW 6
|
||||
#define LIST_REPORT_VIEW 7
|
||||
#define LIST_DESELECT_ALL 8
|
||||
#define LIST_SELECT_ALL 9
|
||||
#define LIST_ABOUT 102
|
||||
#define BUSY_ON 10
|
||||
#define BUSY_OFF 11
|
||||
#define LIST_DELETE_ALL 12
|
||||
|
||||
#define LIST_CTRL 1000
|
||||
enum
|
||||
{
|
||||
LIST_QUIT = 1,
|
||||
LIST_LIST_VIEW = 2,
|
||||
LIST_ICON_VIEW = 3,
|
||||
LIST_ICON_TEXT_VIEW = 4,
|
||||
LIST_SMALL_ICON_VIEW = 5,
|
||||
LIST_SMALL_ICON_TEXT_VIEW = 6,
|
||||
LIST_REPORT_VIEW = 7,
|
||||
LIST_DESELECT_ALL = 8,
|
||||
LIST_SELECT_ALL = 9,
|
||||
LIST_ABOUT = 102,
|
||||
BUSY_ON = 10,
|
||||
BUSY_OFF = 11,
|
||||
LIST_DELETE_ALL = 12,
|
||||
LIST_SORT,
|
||||
|
||||
LIST_CTRL = 1000
|
||||
};
|
||||
|
||||
|
@@ -1,118 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="test" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 5.00
|
||||
# ** NICHT BEARBEITEN **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=test - Win32 Release
|
||||
!MESSAGE Dies ist kein g<>ltiges Makefile. Zum Erstellen dieses Projekts mit\
|
||||
NMAKE
|
||||
!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und f<>hren Sie den\
|
||||
Befehl
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "test.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE Sie k<>nnen beim Ausf<73>hren von NMAKE eine Konfiguration angeben
|
||||
!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "test.mak" CFG="test - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE F<>r die Konfiguration stehen zur Auswahl:
|
||||
!MESSAGE
|
||||
!MESSAGE "test - Win32 Release" (basierend auf "Win32 (x86) Application")
|
||||
!MESSAGE "test - Win32 Debug" (basierend auf "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "test - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir ".\Release"
|
||||
# PROP BASE Intermediate_Dir ".\Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\Release"
|
||||
# PROP Intermediate_Dir ".\Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\include" /I "funcs" /I "santis2" /I "funcdefs" /I "tnt" /D "__WIN32__" /D "__WXMSW__" /D "__WIN95__" /D "STRICT" /D "__WINDOWS__" /YX /FD /D /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x407 /d "NDEBUG"
|
||||
# ADD RSC /l 0x407 /i "..\..\include" /d "__WXMSW__"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib oldnames.lib comctl32.lib ctl3d32.lib odbc32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib ..\..\release\wxwin.lib ctl3d32.lib /nologo /subsystem:windows /machine:I386
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "test - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir ".\Debug"
|
||||
# PROP BASE Intermediate_Dir ".\Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\Debug"
|
||||
# PROP Intermediate_Dir ".\Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /W3 /GX /Z7 /Od /I "..\..\include" /I "funcs" /I "santis2" /I "funcdefs" /I "tnt" /D "__WIN32__" /D "__WXMSW__" /D "__WIN95__" /D DEBUG=2 /D "STRICT" /D "__WINDOWS__" /YX /FD /D /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x407 /d "_DEBUG"
|
||||
# ADD RSC /l 0x407 /i "..\..\include" /d "__WXMSW__"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib oldnames.lib comctl32.lib ctl3d32.lib odbc32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib ..\..\debug\wxwin.lib ctl3d32.lib /nologo /subsystem:windows /debug /machine:I386
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "test - Win32 Release"
|
||||
# Name "test - Win32 Debug"
|
||||
# Begin Group "Quellcodedateien"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\listtest.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header-Dateien"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\listtest.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Ressourcendateien"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\listtest.rc
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
@@ -1,29 +0,0 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 5.00
|
||||
# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GEL<45>SCHT WERDEN!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "test"=.\santis.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
Reference in New Issue
Block a user