include/cinder/app/FileDropEvent.h
Go to the documentation of this file.
00001 /*
00002  Copyright (c) 2012, The Cinder Project, All rights reserved.
00003 
00004  This code is intended for use with the Cinder C++ library: http://libcinder.org
00005 
00006  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
00007  the following conditions are met:
00008 
00009     * Redistributions of source code must retain the above copyright notice, this list of conditions and
00010     the following disclaimer.
00011     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
00012     the following disclaimer in the documentation and/or other materials provided with the distribution.
00013 
00014  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
00015  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00016  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
00017  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
00018  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00019  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00020  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00021  POSSIBILITY OF SUCH DAMAGE.
00022 */
00023 
00024 #pragma once
00025 
00026 #include "cinder/Cinder.h"
00027 #include "cinder/app/Event.h"
00028 #include "cinder/Filesystem.h"
00029 
00030 #include <vector>
00031 #include <string>
00032 
00033 namespace cinder { namespace app {
00034 
00036 class FileDropEvent : public Event {
00037   public:
00038     FileDropEvent( WindowRef win, int aX, int aY, const std::vector<fs::path> &aFiles )
00039         : Event( win ), mX( aX ), mY( aY ), mFiles( aFiles )
00040     {}
00041     
00043     int         getX() const { return mX; }
00045     int         getY() const { return mY; }
00047     Vec2i       getPos() const { return Vec2i( mX, mY ); }
00048 
00050     const std::vector<fs::path>&    getFiles() const { return mFiles; }
00052     size_t                          getNumFiles() const { return mFiles.size(); }
00054     const fs::path&                 getFile( size_t index ) const { return mFiles.at(index); }
00055 
00056   private:
00057     int                         mX, mY;
00058     std::vector<fs::path>       mFiles;
00059 };
00060 
00061 inline std::ostream& operator<<( std::ostream &out, const FileDropEvent &event )
00062 {
00063     out << event.getPos() << ": ";
00064     out << "{" << std::endl;
00065     for( std::vector<fs::path>::const_iterator fIt = event.getFiles().begin(); fIt != event.getFiles().end(); ++fIt )
00066         out << "  " << *fIt << std::endl;
00067     out << "}";
00068     return out;
00069 }
00070 
00071 } } // namespace cinder::app