Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FileDropEvent.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2012, The Cinder Project, All rights reserved.
3 
4  This code is intended for use with the Cinder C++ library: http://libcinder.org
5 
6  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
7  the following conditions are met:
8 
9  * Redistributions of source code must retain the above copyright notice, this list of conditions and
10  the following disclaimer.
11  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
12  the following disclaimer in the documentation and/or other materials provided with the distribution.
13 
14  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
15  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
16  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
17  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
18  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
20  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
21  POSSIBILITY OF SUCH DAMAGE.
22 */
23 
24 #pragma once
25 
26 #include "cinder/Cinder.h"
27 #include "cinder/app/Event.h"
28 #include "cinder/Filesystem.h"
29 
30 #include <vector>
31 #include <string>
32 
33 namespace cinder { namespace app {
34 
36 class FileDropEvent : public Event {
37  public:
38  FileDropEvent( WindowRef win, int aX, int aY, const std::vector<fs::path> &aFiles )
39  : Event( win ), mX( aX ), mY( aY ), mFiles( aFiles )
40  {}
41 
43  int getX() const { return mX; }
45  int getY() const { return mY; }
47  Vec2i getPos() const { return Vec2i( mX, mY ); }
48 
50  const std::vector<fs::path>& getFiles() const { return mFiles; }
52  size_t getNumFiles() const { return mFiles.size(); }
54  const fs::path& getFile( size_t index ) const { return mFiles.at(index); }
55 
56  private:
57  int mX, mY;
58  std::vector<fs::path> mFiles;
59 };
60 
61 inline std::ostream& operator<<( std::ostream &out, const FileDropEvent &event )
62 {
63  out << event.getPos() << ": ";
64  out << "{" << std::endl;
65  for( std::vector<fs::path>::const_iterator fIt = event.getFiles().begin(); fIt != event.getFiles().end(); ++fIt )
66  out << " " << *fIt << std::endl;
67  out << "}";
68  return out;
69 }
70 
71 } } // namespace cinder::app
size_t getNumFiles() const
Returns the number of files dropped during the event.
Definition: FileDropEvent.h:52
std::ostream & operator<<(std::ostream &lhs, const InterfaceOrientation &rhs)
Stream InterfacefaceOrientation enum to std::ostream.
Definition: AppCocoaTouch.mm:666
const std::vector< fs::path > & getFiles() const
Returns the vector of file paths which were dropped.
Definition: FileDropEvent.h:50
int getX() const
Returns the X coordinate measured in points of the mouse during the event.
Definition: FileDropEvent.h:43
GLuint index
Definition: GLee.h:2259
Vec2i getPos() const
Returns the coordinates measured in points of the mouse during the event.
Definition: FileDropEvent.h:47
GLXFBConfig Window win
Definition: GLee.h:16730
std::shared_ptr< Window > WindowRef
Definition: Event.h:49
Base class for all Events.
Definition: Event.h:53
const fs::path & getFile(size_t index) const
Returns the path for file number index.
Definition: FileDropEvent.h:54
Represents a file-drop event, typically received from Windows Explorer or Mac OS X Finder...
Definition: FileDropEvent.h:36
FileDropEvent(WindowRef win, int aX, int aY, const std::vector< fs::path > &aFiles)
Definition: FileDropEvent.h:38
int getY() const
Returns the Y coordinate measured in points of the mouse during the event.
Definition: FileDropEvent.h:45
Vec2< int > Vec2i
Definition: Vector.h:1313