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 this->showFileInfo[i].llFileID.ToString();
\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 this->showFileInfo[i].uDanger ? (wxListItemAttr *) & this->atDangerItem : NULL;
\r
104 void myListCtrl::OnColClick(wxListEvent& e)
\r
106 g_nSortColumn = e.GetColumn();
\r
107 g_fSortAscend = ! (g_nSortColumn == e.GetColumn() && g_fSortAscend);
\r
109 //
\83\
\81[
\83g
\81B
\r
110 this->showFileInfo.Sort(& ListCtrlCompareProc);
\r
111 this->SetItemCount(this->showFileInfo.Count());
\r
112 this->RefreshItems(0, this->showFileInfo.Count() - 1);
\r
115 //******************************************************************************
\r
116 //
\8f\94\8f\88\97\9d\8aÖ
\90\94\r
117 //******************************************************************************
\r
119 #define NumCmp(member) (item1->member < item2->member) ? -1 : ((item1->member > item2->member) ? 1 : 0)
\r
121 int ListCtrlCompareProc(TPI_FILEINFO ** pItem1, TPI_FILEINFO ** pItem2)
\r
123 TPI_FILEINFO * item1 = * pItem1, * item2 = * pItem2;
\r
124 return (g_fSortAscend ? 1 : -1) * (
\r
125 g_nSortColumn == 0 ? ::wxStricmp(item1->fnFileName.GetFullName(), item2->fnFileName.GetFullName()) : // Filename
\r
126 g_nSortColumn == 1 ? NumCmp(llUnpackedSize) : // Unpacked
\r
127 g_nSortColumn == 2 ? NumCmp(llPackedSize) : // Packed
\r
128 g_nSortColumn == 3 ? NumCmp(wCompressRatio) : // Ratio
\r
129 g_nSortColumn == 6 ? NumCmp(tmModified) : // Last modified
\r
130 g_nSortColumn == 7 ? ::wxStricmp(item1->fnFileName.GetPath(), item2->fnFileName.GetPath()) : // Path
\r
131 g_nSortColumn == 8 ? ::wxStricmp(GetFileTypeName(item1->fnFileName), GetFileTypeName(item2->fnFileName)) : // Type
\r
132 g_nSortColumn == 9 ? NumCmp(llFileID) : // No
\r