juce_Drawable.h

Go to the documentation of this file.
00001 /*
00002   ==============================================================================
00003 
00004    This file is part of the JUCE library - "Jules' Utility Class Extensions"
00005    Copyright 2004-7 by Raw Material Software ltd.
00006 
00007   ------------------------------------------------------------------------------
00008 
00009    JUCE can be redistributed and/or modified under the terms of the
00010    GNU General Public License, as published by the Free Software Foundation;
00011    either version 2 of the License, or (at your option) any later version.
00012 
00013    JUCE is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with JUCE; if not, visit www.gnu.org/licenses or write to the
00020    Free Software Foundation, Inc., 59 Temple Place, Suite 330,
00021    Boston, MA 02111-1307 USA
00022 
00023   ------------------------------------------------------------------------------
00024 
00025    If you'd like to release a closed-source product which uses JUCE, commercial
00026    licenses are also available: visit www.rawmaterialsoftware.com/juce for
00027    more information.
00028 
00029   ==============================================================================
00030 */
00031 
00032 #ifndef __JUCE_DRAWABLE_JUCEHEADER__
00033 #define __JUCE_DRAWABLE_JUCEHEADER__
00034 
00035 #include "../contexts/juce_Graphics.h"
00036 #include "../../../../juce_core/text/juce_XmlElement.h"
00037 
00038 
00039 //==============================================================================
00045 class JUCE_API  Drawable
00046 {
00047 protected:
00048     //==============================================================================
00053     Drawable();
00054 
00055 public:
00057     virtual ~Drawable();
00058 
00059     //==============================================================================
00064     virtual Drawable* createCopy() const = 0;
00065 
00066     //==============================================================================
00073     virtual void draw (Graphics& g,
00074                        const AffineTransform& transform = AffineTransform::identity) const = 0;
00075 
00085     void drawAt (Graphics& g,
00086                  const float x,
00087                  const float y) const;
00088 
00103     void drawWithin (Graphics& g,
00104                      const int destX,
00105                      const int destY,
00106                      const int destWidth,
00107                      const int destHeight,
00108                      const RectanglePlacement& placement) const;
00109 
00110 
00111     //==============================================================================
00116     virtual void getBounds (float& x, float& y, float& width, float& height) const = 0;
00117 
00122     virtual bool hitTest (float x, float y) const = 0;
00123 
00124     //==============================================================================
00128     const String& getName() const throw()               { return name; }
00129 
00131     void setName (const String& newName) throw()        { name = newName; }
00132 
00133     //==============================================================================
00139     static Drawable* createFromImageData (const void* data, const int numBytes);
00140 
00146     static Drawable* createFromImageDataStream (InputStream& dataSource);
00147 
00153     static Drawable* createFromImageFile (const File& file);
00154 
00164     static Drawable* createFromSVG (const XmlElement& svgDocument);
00165 
00166 
00167     //==============================================================================
00168     juce_UseDebuggingNewOperator
00169 
00170 private:
00171     Drawable (const Drawable&);
00172     const Drawable& operator= (const Drawable&);
00173 
00174     String name;
00175 };
00176 
00177 
00178 #endif   // __JUCE_DRAWABLE_JUCEHEADER__