1 /*******************************************************************************
\r
2 TPI - flexible but useless plug-in framework.
\r
3 Copyright (C) 2002-2009 Silky
\r
5 This library is free software; you can redistribute it and/or modify it under
\r
6 the terms of the GNU Lesser General Public License as published by the Free
\r
7 Software Foundation; either version 2.1 of the License, or (at your option)
\r
10 This library is distributed in the hope that it will be useful, but WITHOUT
\r
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
\r
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
\r
15 You should have received a copy of the GNU Lesser General Public License along
\r
16 with this library; if not, write to the Free Software Foundation, Inc.,
\r
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
\r
19 $Id: cls_listctrl.cpp,v 1.6 2009/08/23 03:00:34 sirakaba Exp $
\r
20 *******************************************************************************/
\r
22 #include "frontend.h"
\r
24 #include "cls_listctrl.h"
\r
25 #include "dlg_make.h"
\r
26 #include "frm_main.h"
\r
27 #include "functions.h"
\r
29 //******************************************************************************
\r
31 //******************************************************************************
\r
33 IMPLEMENT_DYNAMIC_CLASS(myListCtrl, wxListView)
\r
35 //******************************************************************************
\r
37 //******************************************************************************
\r
39 BEGIN_EVENT_TABLE(myListCtrl, wxListCtrl)
\r
41 EVT_LIST_COL_CLICK(XRCID("ListView"), myListCtrl::OnColClick)
\r
44 //******************************************************************************
\r
46 //******************************************************************************
\r
48 wxString myListCtrl::OnGetItemText(long i, long column) const
\r
50 //
\83\8a\83X
\83g
\83r
\83\85\81[
\82É
\8d\80\96Ú
\82ð
\92Ç
\89Á
\81B
\r
54 return this->showFileInfo[i].fnFileName.GetFullName();
\r
56 return this->showFileInfo[i].llUnpackedSize.ToString();
\r
58 return this->showFileInfo[i].llPackedSize.ToString();
\r
60 return wxString::Format(wxT("%3.1f%%"), this->showFileInfo[i].wCompressRatio / 10.0);
\r
62 return this->showFileInfo[i].szMethod;
\r
65 wxString szTemp = wxT("---w-");
\r
66 szTemp[0] = this->showFileInfo[i].dwAttribute & TPI_ATTRIBUTE_DIRECTORY ? wxT('d') :
\r
67 this->showFileInfo[i].dwAttribute & TPI_ATTRIBUTE_ARCHIVE ? wxT('a') : wxT('-');
\r
68 szTemp[1] = this->showFileInfo[i].dwAttribute & TPI_ATTRIBUTE_SYSTEM ? wxT('s') : wxT('-');
\r
69 szTemp[2] = this->showFileInfo[i].dwAttribute & TPI_ATTRIBUTE_HIDDEN ? wxT('h') : wxT('-');
\r
70 szTemp[3] = this->showFileInfo[i].dwAttribute & TPI_ATTRIBUTE_READONLY ? wxT('r') : wxT('w');
\r
71 szTemp[4] = this->showFileInfo[i].dwAttribute & TPI_ATTRIBUTE_ENCRYPTED ? wxT('g') : wxT('-');
\r
75 return this->showFileInfo[i].tmModified.Format(wxT("%Y/%m/%d %H:%M:%S"));
\r
77 return this->showFileInfo[i].fnFileName.GetPath();
\r
79 return GetFileTypeName(this->showFileInfo[i].fnFileName);
\r
81 return wxString::Format(wxT("%d"), this->showFileInfo[i].llFileID.ToULong());
\r
83 return wxEmptyString;
\r
87 int myListCtrl::OnGetItemImage(long i) const
\r
89 wxIcon icon = GetFileTypeIcon(this->showFileInfo[i].fnFileName);
\r
90 g_hIconLL.Add(icon);
\r
91 // wxGTK
\82Å16x16
\82Ì
\83A
\83C
\83R
\83\93\82ª
\95\
\8e¦
\82Å
\82«
\82é
\82æ
\82¤
\83\8a\83T
\83C
\83Y
\82µ
\82Ä
\82¨
\82
\81B
\r
93 return g_hIconLS.Add(icon);
\r
95 return g_hIconLS.Add(icon.ConvertToImage().Rescale(16, 16));
\r
99 wxListItemAttr * myListCtrl::OnGetItemAttr(long i) const
\r
101 return (wxListItemAttr *) this->showFileInfo[i].pCustomInfo;
\r
104 void myListCtrl::OnColClick(wxListEvent& e)
\r
106 g_nSortingColumn = e.GetColumn();
\r
108 //
\83\
\81[
\83g
\81B
\r
109 this->showFileInfo.Sort(& ListCtrlCompareProc);
\r
110 this->SetItemCount(this->showFileInfo.Count());
\r
111 this->RefreshItems(0, this->showFileInfo.Count() - 1);
\r
114 //******************************************************************************
\r
115 //
\8f\94\8f\88\97\9d\8aÖ
\90\94\r
116 //******************************************************************************
\r
118 int ListCtrlCompareProc(TPI_FILEINFO ** pItem1, TPI_FILEINFO ** pItem2)
\r
120 TPI_FILEINFO * item1 = * pItem1, * item2 = * pItem2;
\r
121 switch (g_nSortingColumn)
\r
124 return ::wxStricmp(item1->fnFileName.GetFullName(), item2->fnFileName.GetFullName());
\r
126 return (item1->llUnpackedSize < item2->llUnpackedSize) ? -1 : ((item1->llUnpackedSize > item2->llUnpackedSize) ? 1 : 0);
\r
128 return (item1->llPackedSize < item2->llPackedSize) ? -1 : ((item1->llPackedSize > item2->llPackedSize) ? 1 : 0);
\r
130 return (item1->wCompressRatio < item2->wCompressRatio) ? -1 : ((item1->wCompressRatio > item2->wCompressRatio) ? 1 : 0);
\r
131 case 6:// Last Modified
\r
132 return (item1->tmModified < item2->tmModified) ? -1 : ((item1->tmModified > item2->tmModified) ? 1 : 0);
\r
134 return ::wxStricmp(item1->fnFileName.GetPath(), item2->fnFileName.GetPath());
\r
136 return ::wxStricmp(GetFileTypeName(item1->fnFileName), GetFileTypeName(item2->fnFileName));
\r
138 return (item1->llFileID < item2->llFileID) ? -1 : ((item1->llFileID > item2->llFileID) ? 1 : 0);
\r