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
44 if (::wxGetKeyState(WXK_SHIFT) && this->mainFrame->aiArchive.fiInfo.eSupportedCommand & TPI_COMMAND_ADD)
\r
47 e = new wxCommandEvent(wxEVT_COMMAND_MENU_SELECTED, XRCID("Arc_Add"));
\r
48 e->SetClientData(& this->as);
\r
50 #if wxCHECK_VERSION(2, 9, 0)
\r
51 this->mainFrame->GetEventHandler()->QueueEvent(e);
\r
53 this->mainFrame->OnArcAdd(* e);
\r
60 if (asFiles.GetCount() == 1 && ::wxFileExists(asFiles[0]))
\r
63 e = new wxCommandEvent(wxEVT_COMMAND_MENU_SELECTED, XRCID("Arc_Open"));
\r
64 e->SetClientData(& this->as);
\r
66 this->mainFrame->fnArchive = wxFileName(asFiles[0]);
\r
67 #if wxCHECK_VERSION(2, 9, 0)
\r
68 this->mainFrame->GetEventHandler()->QueueEvent(e);
\r
70 this->mainFrame->OnArcOpen(* e);
\r
76 // 対応していない場合は書庫の作成を試みる。
\r
77 e = new wxCommandEvent(wxEVT_COMMAND_MENU_SELECTED, XRCID("Arc_Create"));
\r
78 e->SetClientData(& this->as);
\r
79 #if wxCHECK_VERSION(2, 9, 0)
\r
80 this->mainFrame->GetEventHandler()->QueueEvent(e);
\r
82 this->mainFrame->OnArcCreate(* e);
\r
88 //******************************************************************************
\r
90 //******************************************************************************
\r
92 myFileDataObject::~myFileDataObject()
\r
95 for (size_t i = 0; i < this->m_filenames.GetCount(); i++)
\r
97 chmod(this->m_filenames[i].ToUTF8(), 0600);
\r
98 ::wxRemoveFile(this->m_filenames[i]);
\r
102 ::wxRmdir(this->szTempDir);
\r
106 // wxGTKのwxFileDataObjectでは多バイト文字の扱いに問題があるので代替。
\r
107 bool myFileDataObject::GetDataHere(void * buf) const
\r
109 wxString filenames;
\r
110 for (size_t i = 0; i < m_filenames.GetCount(); i++)
\r
112 filenames += wxT("file:") + m_filenames[i] + wxT("\r\n");
\r
114 memcpy(buf, filenames.mbc_str(), strlen(filenames.mbc_str()) + 1);
\r
118 size_t myFileDataObject::GetDataSize() const
\r
121 for (size_t i = 0; i < m_filenames.GetCount(); i++)
\r
123 res += strlen(m_filenames[i].mbc_str()) + 5 + 2; // "file:" (5) + "\r\n" (2)
\r
128 void myFileDataObject::AddFile(const wxString & filename)
\r
130 m_filenames.Add(filename);
\r