[Scummvm-cvs-logs] SF.net SVN: scummvm: [28427] tools/branches/gsoc2007-toolsgui

lightcast at users.sourceforge.net lightcast at users.sourceforge.net
Fri Aug 3 05:40:48 CEST 2007


Revision: 28427
          http://scummvm.svn.sourceforge.net/scummvm/?rev=28427&view=rev
Author:   lightcast
Date:     2007-08-02 20:40:48 -0700 (Thu, 02 Aug 2007)

Log Message:
-----------
Enable drag and drop on file input and output boxes.

Modified Paths:
--------------
    tools/branches/gsoc2007-toolsgui/tools_gui.cpp
    tools/branches/gsoc2007-toolsgui/tools_gui.h

Modified: tools/branches/gsoc2007-toolsgui/tools_gui.cpp
===================================================================
--- tools/branches/gsoc2007-toolsgui/tools_gui.cpp	2007-08-03 03:39:23 UTC (rev 28426)
+++ tools/branches/gsoc2007-toolsgui/tools_gui.cpp	2007-08-03 03:40:48 UTC (rev 28427)
@@ -78,6 +78,35 @@
 	sizer->Add(_choice, 1, wxEXPAND | wxLEFT | wxRIGHT, 5);
 }
 
+FileDrop::FileDrop(wxTextCtrl *target, bool isFileChooser) : wxFileDropTarget() {
+	_target = target;
+	_isFileChooser = isFileChooser;
+}
+
+bool FileDrop::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &filenames) {
+	if (_isFileChooser) {
+		if (_target->GetValue().Last() != wxChar(" ")) {
+			_target->AppendText(" ");
+		}
+
+		for (size_t i = 0; i < filenames.GetCount(); i++) {
+			_target->AppendText("\"");
+			_target->AppendText(filenames[i]);
+			_target->AppendText("\"");
+			
+			if (i != filenames.GetCount() - 1) {
+				_target->AppendText(" ");
+			}
+		}
+	} else {
+		_target->SetValue("\"");
+		_target->AppendText(filenames[0]);
+		_target->AppendText("\"");
+	}
+
+	return true;
+};
+
 IOChooser::IOChooser(wxWindow *parent, wxString title, wxString defaultPath, bool isFileChooser) : wxPanel(parent) {
 	wxStaticBox *box = new wxStaticBox(this, wxID_ANY, title);
 	wxStaticBoxSizer *sizer = new wxStaticBoxSizer(box, wxHORIZONTAL);
@@ -87,6 +116,9 @@
 	_browse = new wxButton(this, wxID_ANY, wxT("Browse"));
 	_isFileChooser = isFileChooser;
 
+	_dropTarget = new FileDrop(_text, _isFileChooser);
+	this->SetDropTarget(_dropTarget);
+
 	/* The button looks like it is shifted 2 pixels down 
 	 * from the text control (probably because of the wxStaticBox label)
 	 * so we simply pad the top by -2
@@ -180,7 +212,7 @@
 	_compressionTypeBox->GetSizer()->Add(_compressionOptionsChooser, 1, wxEXPAND | wxLEFT | wxRIGHT, 10);
 
 	_inputPanel = new IOChooser(topPanel, wxT("Input"), wxT(""), true);
-	_outputPanel = new IOChooser(topPanel, wxT("Output"), wxT(""), true);
+	_outputPanel = new IOChooser(topPanel, wxT("Output"), wxT(""), false);
 
 	/* Bottom Panel */
 	wxPanel *bottomPanel = new wxPanel(this);
@@ -272,7 +304,7 @@
 	_extractionToolChooserPanel = new DropDownBox((wxWindow *)topPanel, kExtractionToolChoice, wxT("Game Engine"), kNumExtractionTools, kExtractionToolNames);
 	_input1Panel = new IOChooser(topPanel, wxT("Input 1"), wxT(""), true);
 	_input2Panel = new IOChooser(topPanel, wxT("Input 2"), wxT(""), true);
-	_outputPanel = new IOChooser(topPanel, wxT("Output"), wxT(""), true);
+	_outputPanel = new IOChooser(topPanel, wxT("Output"), wxT(""), false);
 
 	/* Bottom Panel */
 	wxPanel *bottomPanel = new wxPanel(this);
@@ -309,7 +341,9 @@
 
 	this->_inputPanel->_browse->Enable(true);
 	this->_inputPanel->_text->Enable(true);
+	this->_inputPanel->_text->Clear();
 	this->_outputPanel->_isFileChooser = false;
+	this->_outputPanel->_text->Clear();
 
 	if (selectedTool == wxT("AGOS")) {
 		this->_inputPanel->_isFileChooser = true;
@@ -510,8 +544,11 @@
 	this->_input1Panel->_browse->Enable(true);
 	this->_input1Panel->_text->Enable(true);
 	this->_input1Panel->_isFileChooser = true;
+	this->_input1Panel->_text->Clear();
 	this->_input2Panel->_isFileChooser = true;
+	this->_input2Panel->_text->Clear();
 	this->_outputPanel->_isFileChooser = false;
+	this->_outputPanel->_text->Clear();
 
 	if (selectedTool == wxT("AGOS")) {
 		this->_input2Panel->_browse->Enable(false);

Modified: tools/branches/gsoc2007-toolsgui/tools_gui.h
===================================================================
--- tools/branches/gsoc2007-toolsgui/tools_gui.h	2007-08-03 03:39:23 UTC (rev 28426)
+++ tools/branches/gsoc2007-toolsgui/tools_gui.h	2007-08-03 03:40:48 UTC (rev 28427)
@@ -21,6 +21,7 @@
  */
 
 #include <wx/wx.h>
+#include <wx/dnd.h>
 #include <wx/notebook.h>
 #include <wx/statbox.h>
 #include <wx/textctrl.h>
@@ -92,6 +93,16 @@
 	wxChoice *_choice;
 };
 
+class FileDrop : public wxFileDropTarget {
+public:
+	FileDrop(wxTextCtrl *target, bool isFileChooser);
+
+	wxTextCtrl *_target;
+	bool _isFileChooser;
+
+	virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames);
+};
+
 class IOChooser : public wxPanel {
 public:
 	IOChooser(wxWindow *parent, wxString title, wxString defaultPath, bool isFileChooser);
@@ -99,6 +110,7 @@
 	wxTextCtrl *_text;
 	wxButton *_browse;
 	bool _isFileChooser;
+	FileDrop *_dropTarget;
 };
 
 /* ----- Compression ----- */


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list