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
20 *******************************************************************************/
\r
24 #include "frm_main.h"
\r
25 #include "cls_filedroptarget.h"
\r
27 //******************************************************************************
\r
29 //******************************************************************************
\r
31 myFileDropTarget::myFileDropTarget(MainFrame * mainFrame)
\r
33 this->mainFrame = mainFrame;
\r
36 //******************************************************************************
\r
38 //******************************************************************************
\r
40 bool myFileDropTarget::OnDropFiles(wxCoord, wxCoord, const wxArrayString & asFiles)
\r
42 #if wxCHECK_VERSION(2, 9, 0)
\r
49 if (asFiles.GetCount() == 1 && ::wxFileExists(asFiles[0]))
\r
52 wxULongLong_t llFileCount = 0;
\r
53 if (this->mainFrame->LoadTPI(asFiles[0], & llFileCount))
\r
56 #if wxCHECK_VERSION(2, 9, 0)
\r
57 e = new wxThreadEvent(wxEVT_COMMAND_MENU_SELECTED, XRCID("Arc_Open"));
\r
59 e = new wxCommandEvent(wxEVT_COMMAND_MENU_SELECTED, XRCID("Arc_Open"));
\r
62 e->SetExtraLong((long) llFileCount);
\r
63 this->mainFrame->fnArchive = wxFileName(asFiles[0]);
\r
64 #if wxCHECK_VERSION(2, 9, 0)
\r
65 ::wxQueueEvent(this->mainFrame, e);
\r
67 this->mainFrame->OnArcOpen(* e);
\r
74 // 対応していない場合は書庫の作成を試みる。
\r
76 #if wxCHECK_VERSION(2, 9, 0)
\r
77 e = new wxThreadEvent(wxEVT_COMMAND_MENU_SELECTED, XRCID("Arc_Create"));
\r
79 e = new wxCommandEvent(wxEVT_COMMAND_MENU_SELECTED, XRCID("Arc_Create"));
\r
81 e->SetClientData(& this->as);
\r
82 #if wxCHECK_VERSION(2, 9, 0)
\r
83 ::wxQueueEvent(this->mainFrame, e);
\r
85 this->mainFrame->OnArcCreate(* e);
\r
91 //******************************************************************************
\r
93 //******************************************************************************
\r
95 myFileDataObject::~myFileDataObject()
\r
98 for (size_t i = 0; i < this->m_filenames.GetCount(); i++)
\r
100 chmod(this->m_filenames[i].ToUTF8(), 0600);
\r
101 ::wxRemoveFile(this->m_filenames[i]);
\r
105 ::wxRmdir(this->szTempDir);
\r
109 // wxGTKのwxFileDataObjectでは多バイト文字の扱いに問題があるので代替。
\r
110 bool myFileDataObject::GetDataHere(void * buf) const
\r
112 wxString filenames;
\r
113 for (size_t i = 0; i < m_filenames.GetCount(); i++)
\r
115 filenames += wxT("file:") + m_filenames[i] + wxT("\r\n");
\r
117 memcpy(buf, filenames.mbc_str(), strlen(filenames.mbc_str()) + 1);
\r
121 size_t myFileDataObject::GetDataSize() const
\r
124 for (size_t i = 0; i < m_filenames.GetCount(); i++)
\r
126 res += strlen(m_filenames[i].mbc_str()) + 5 + 2; // "file:" (5) + "\r\n" (2)
\r
131 void myFileDataObject::AddFile(const wxString & filename)
\r
133 m_filenames.Add(filename);
\r