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: functions.cpp,v 1.17 2009/09/02 11:18:49 sirakaba Exp $
\r
20 *******************************************************************************/
\r
22 //******************************************************************************
\r
23 //
\83t
\83@
\83C
\83\8b\93Ç
\82Ý
\8d\9e\82Ý
\r
24 //******************************************************************************
\r
26 #include "frontend.h"
\r
27 #include "frm_main.h"
\r
28 #include "dlg_make.h"
\r
29 #include "functions.h"
\r
31 //******************************************************************************
\r
32 //
\83R
\83\93\83g
\83\8d\81[
\83\8b\8f\88\97\9d\8cn
\8aÖ
\90\94\r
33 //******************************************************************************
\r
35 bool TreeView_CheckNewerItem(wxTreeCtrl * tree_ctrl, wxTreeItemId idParent, const wxString & szDirPath, bool bReallyMake)
\r
37 //
\8dÅ
\8f\89\82Ì
\8eq
\83A
\83C
\83e
\83\80\82ð
\8eæ
\93¾
\81B
\r
38 wxTreeItemIdValue idv;
\r
39 wxTreeItemId idChild = tree_ctrl->GetFirstChild(idParent, idv);
\r
40 wxChar cSep = wxFileName::GetPathSeparator();
\r
41 while (idChild.IsOk())
\r
43 //
\83A
\83C
\83e
\83\80\82Æ
\96¼
\91O
\82ª
\93¯
\82¶
\82È
\82çOK
\81B
\r
44 if (tree_ctrl->GetItemText(idChild) == szDirPath.BeforeFirst(cSep))
\r
46 //
\82±
\82ê
\88È
\89º
\82Ì
\8aK
\91w
\82ª
\96³
\82¢
\8fê
\8d\87\81B
\r
47 if (szDirPath.Find(cSep) == wxNOT_FOUND)
\r
52 //
\82Ü
\82¾
\8aK
\91w
\82ª
\97L
\82é
\8fê
\8d\87\81A
\8dÄ
\8bA
\81B
\r
53 return TreeView_CheckNewerItem(tree_ctrl, idChild, szDirPath.AfterFirst(cSep), bReallyMake);
\r
56 idChild = tree_ctrl->GetNextSibling(idChild);
\r
59 //
\91Î
\8fÛ
\82ª
\96³
\82¢
\8fê
\8d\87\82É
\82Í
\8dì
\90¬
\81B
\r
60 if (! szDirPath.IsEmpty())
\r
64 //
\8am
\94F
\82·
\82é
\82¾
\82¯
\82È
\82ç
\82±
\82±
\82Å
\8fI
\97¹
\81B
\r
68 // 2
\8aK
\91w
\88È
\8fã
\90[
\82¢
\8fê
\8d\87\82É
\82à
\91Î
\89\9e\81B
\r
69 wxString szTemp = szDirPath;
\r
70 wxTreeItemId idTemp = idParent;
\r
73 //
\93W
\8aJ
\82µ
\82Ä
\82©
\82ç
\8dì
\90¬
\81B
\r
74 idTemp = tree_ctrl->AppendItem(idTemp, szTemp.BeforeFirst(cSep), 0, 1);
\r
75 szTemp = szTemp.AfterFirst(cSep);
\r
77 while (szTemp.Find(cSep) != wxNOT_FOUND);
\r
79 //
\8dÅ
\8cã
\82É
\8bó
\82Å
\82È
\82¢
\8fê
\8d\87\82É
\82Í
\82à
\82¤1
\8aK
\91w
\8dì
\90¬
\81B
\r
80 if (! szTemp.IsEmpty())
\r
82 tree_ctrl->AppendItem(idTemp, szTemp, 0, 1);
\r
89 wxString TreeView_GetItemPath(wxTreeCtrl * tree_ctrl, wxTreeItemId idItem)
\r
91 wxString szItemName, szNodePath = wxEmptyString;
\r
92 wxChar cSep = wxFileName::GetPathSeparator();
\r
94 //
\83A
\83C
\83e
\83\80\82Ì
\96¼
\91O
\82ð
\8eæ
\93¾
\81B
\r
95 while ((szItemName = tree_ctrl->GetItemText(idItem)))
\r
97 if (szItemName == wxT("-----"))
\r
102 //
\83p
\83X
\82É
\92Ç
\89Á
\81B
\r
103 szNodePath = szItemName + cSep + szNodePath;
\r
105 //
\90e
\83A
\83C
\83e
\83\80\82É
\91k
\82é
\81B
\r
106 idItem = tree_ctrl->GetItemParent(idItem);
\r
107 if (idItem == tree_ctrl->GetRootItem())
\r
109 //
\82±
\82±
\82É
\82
\82é
\82Ì
\82Í
\8f\91\8cÉ
\93à
\91S
\95\
\8e¦
\8e\9e\81B
\r
110 szNodePath = wxT("*");
\r
115 return (szNodePath.Find(cSep) == wxNOT_FOUND) ? szNodePath : szNodePath.BeforeLast(cSep);
\r
118 //******************************************************************************
\r
119 //
\8f\94\8f\88\97\9d\8aÖ
\90\94\r
120 //******************************************************************************
\r
122 //
\83f
\83B
\83\8c\83N
\83g
\83\8a\82ð
\90V
\8bK
\82É
\8dì
\90¬
\81B
\r
123 wxFileName MakeDirPath(wxFileName fnPath, wxString szBase, bool bAct)
\r
125 //
\82Æ
\82è
\82 \82¦
\82¸
\8dì
\82Á
\82Ä
\82Ý
\82é
\81B
\r
126 wxFileName fnDir = fnPath;
\r
127 fnDir.AppendDir(szBase);
\r
128 if (! fnDir.DirExists() && ! ::wxFileExists(fnDir.GetPath()))
\r
130 if (! bAct || fnDir.Mkdir())
\r
136 //
\83_
\83\81\82È
\82ç"_%d"
\82ð
\95t
\89Á
\82µ
\82Ä
\8e\8e\8ds
\81B
\r
137 for (int i = 0; i < 255; i++)
\r
140 fnDir.AppendDir(szBase + wxString::Format(wxT("_%d"), i));
\r
141 if (! fnDir.DirExists() && ! ::wxFileExists(fnDir.GetPath()))
\r
143 if (! bAct || fnDir.Mkdir())
\r
150 //
\83G
\83\89\81[
\8fI
\97¹
\81B
\r
155 wxArrayString MakeTargetFileList(MainFrame * frm, bool fOnlyOneFile)
\r
158 const int nState = frm->list_ctrl->GetSelectedItemCount() == 0 ? wxLIST_STATE_DONTCARE : wxLIST_STATE_SELECTED;
\r
159 long nId = frm->list_ctrl->GetNextItem(-1, wxLIST_NEXT_ALL, nState);
\r
162 as.Add(frm->list_ctrl->showFileInfo[nId].szStoredName);
\r
167 nId = frm->list_ctrl->GetNextItem(nId, wxLIST_NEXT_ALL, nState);
\r
173 bool WillMakeDirByArcName(MainFrame * frm, MakeDialog * mk)
\r
175 if (mk->chDirMake->GetSelection() != 2)
\r
177 return mk->chDirMake->GetSelection() == 1;
\r
180 //
\83\8b\81[
\83g
\82É
\83f
\83B
\83\8c\83N
\83g
\83\8a\82Æ
\83t
\83@
\83C
\83\8b\8d\87\82í
\82¹
\82Ä2
\8cÂ
\88È
\8fã
\82 \82é
\82Æ
\82«
\81A
\83f
\83B
\83\8c\83N
\83g
\83\8a\82ð
\8dì
\90¬
\81B
\r
181 wxTreeItemId tiArcRoot = frm->tree_ctrl->GetLastChild(frm->tree_ctrl->GetRootItem());
\r
182 switch (frm->tree_ctrl->GetChildrenCount(tiArcRoot, false))
\r
186 //
\83f
\83B
\83\8c\83N
\83g
\83\8a\82ª
\82È
\82¢
\82Ì
\82Å
\81A
\83\8b\81[
\83g
\82É
\83t
\83@
\83C
\83\8b\82ª2
\8cÂ
\88È
\8fã
\82 \82é
\82©
\82Ç
\82¤
\82©
\82ð
\94»
\92è
\81B
\r
187 bool fFlag = false;
\r
188 for (size_t i = 0; i < frm->fileinfo.GetCount(); i++)
\r
190 if (frm->fileinfo[i].fnFileName.GetPath().IsEmpty())
\r
192 //
\83t
\83@
\83C
\83\8b\82Í
\83\8b\81[
\83g
\82É
\82 \82é
\81B
\r
204 //
\83f
\83B
\83\8c\83N
\83g
\83\8a\82ª1
\8cÂ
\82È
\82Ì
\82Å
\81A
\83\8b\81[
\83g
\82É
\83t
\83@
\83C
\83\8b\82ª
\82È
\82¢
\82©
\82Ç
\82¤
\82©
\82ð
\94»
\92è
\81B
\r
205 for (size_t i = 0; i < frm->fileinfo.GetCount(); i++)
\r
207 //
\83f
\83B
\83\8c\83N
\83g
\83\8a\83\81\83\93\83o
\82ª
\8ai
\94[
\82³
\82ê
\82Ä
\82¢
\82é
\8fê
\8d\87\82É
\82Í
\81A
\82»
\82Ì
\96¼
\91O
\82ª
\83c
\83\8a\81[
\83r
\83\85\81[
\82Ì
\83A
\83C
\83e
\83\80\96¼
\82É
\88ê
\92v
\82µ
\82½
\8fê
\8d\87\82Í
\83J
\83E
\83\93\83g
\82µ
\82È
\82¢
\81B
\r
208 if (frm->fileinfo[i].fnFileName.GetPath().IsEmpty() && frm->fileinfo[i].fnFileName.GetFullName() != frm->tree_ctrl->GetItemText(frm->tree_ctrl->GetLastChild(tiArcRoot)))
\r
215 //
\83f
\83B
\83\8c\83N
\83g
\83\8a\82¾
\82¯
\82Å2
\8cÂ
\88È
\8fã
\82 \82é
\82Ì
\82Å
\81A
\8e©
\93®
\93I
\82É
\93W
\8aJ
\90æ
\83f
\83B
\83\8c\83N
\83g
\83\8a\82ð
\8dì
\90¬
\81B
\r
222 wxString GetFileTypeName(wxFileName fn)
\r
224 wxString szExt = fn.GetExt().MakeUpper();
\r
225 wxString sz = szExt + (szExt.IsEmpty() ? wxT("file") : wxT(" file"));
\r
226 wxFileType * ftFile = wxTheMimeTypesManager->GetFileTypeFromExtension(szExt);
\r
229 ftFile->GetDescription(& sz);
\r
234 wxIcon GetFileTypeIcon(wxFileName fn)
\r
237 wxIconLocation ilFile;
\r
238 wxFileType * ftFile = wxTheMimeTypesManager->GetFileTypeFromExtension(fn.GetExt());
\r
239 if (ftFile && ftFile->GetIcon(& ilFile))
\r
241 if (! ::wxFileExists(ilFile.GetFileName()))
\r
243 icon.CopyFromBitmap(wxBitmap((ilFile.GetFileName() == wxT("%1") || ilFile.GetFileName() == wxT("\"%1\"")) ? FE_DIR_S_ICO wxT("exe.png") : FE_DIR_S_ICO wxT("file.png"), wxBITMAP_TYPE_ANY));
\r
247 icon = wxIcon(ilFile);
\r
252 icon.CopyFromBitmap(wxBitmap(FE_DIR_S_ICO wxT("file.png"), wxBITMAP_TYPE_ANY));
\r