00001 /* 00002 * wxChecksums 00003 * Copyright (C) 2003-2004 Julien Couot 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 */ 00019 00020 /** 00021 * \file slstview.cpp 00022 * A sortable ListView control. 00023 */ 00024 00025 //--------------------------------------------------------------------------- 00026 // For compilers that support precompilation, includes "wx.h". 00027 #include <wx/wxprec.h> 00028 00029 #ifdef __BORLANDC__ 00030 #pragma hdrstop 00031 #endif 00032 00033 #ifndef WX_PRECOMP 00034 // Include your minimal set of headers here, or wx.h 00035 #include <wx/wx.h> 00036 #endif 00037 00038 #include <wx/listctrl.h> 00039 00040 #include "slstview.hpp" 00041 00042 #include "compat.hpp" 00043 //--------------------------------------------------------------------------- 00044 00045 /// The C++ standard namespace. 00046 using namespace std; 00047 00048 00049 IMPLEMENT_DYNAMIC_CLASS(wxSortableListView, wxListView) 00050 00051 00052 /// Default Constructor. 00053 wxSortableListView::wxSortableListView() 00054 { 00055 SetSortOrder(none); 00056 SetColumnToSort(0); 00057 } 00058 //--------------------------------------------------------------------------- 00059 00060 00061 // Constructor, creating and showing a list control. 00062 wxSortableListView::wxSortableListView(wxWindow *parent, wxWindowID id, 00063 const wxPoint& pos, const wxSize& size, 00064 long style, const wxValidator& validator, 00065 const wxString &name) 00066 { 00067 Create(parent, id, pos, size, style, validator, name); 00068 SetSortOrder(none); 00069 SetColumnToSort(0); 00070 } 00071 //--------------------------------------------------------------------------- 00072 00073 00074 // Sets the sort order for this ListView control. 00075 void wxSortableListView::SetSortOrder(const SortOrder sortOrder) 00076 { 00077 switch (sortOrder) 00078 { 00079 case ascending : 00080 case descending : 00081 m_sortOrder = sortOrder; 00082 break; 00083 default : 00084 m_sortOrder = none; 00085 } 00086 } 00087 //--------------------------------------------------------------------------- 00088 00089 00090 // Sets the column to sort on this ListView control. 00091 void wxSortableListView::SetColumnToSort(const int sortColumn) 00092 { 00093 if (sortColumn < 0 || sortColumn >= GetColumnCount()) 00094 m_sortColumn = 0; 00095 else 00096 m_sortColumn = sortColumn; 00097 } 00098 //---------------------------------------------------------------------------