diff --git a/Builds/Linux/Makefile b/Builds/Linux/Makefile index 31585aeaee..68580ab60e 100644 --- a/Builds/Linux/Makefile +++ b/Builds/Linux/Makefile @@ -140,6 +140,7 @@ OBJECTS := \ $(OBJDIR)/juce_CodeEditorComponent_6fe4a170.o \ $(OBJDIR)/juce_CPlusPlusCodeTokeniser_6b8548a9.o \ $(OBJDIR)/juce_ComboBox_bcb5e365.o \ + $(OBJDIR)/juce_ImageComponent_1f90572a.o \ $(OBJDIR)/juce_Label_7af0aab6.o \ $(OBJDIR)/juce_ListBox_d4a8704f.o \ $(OBJDIR)/juce_ProgressBar_38bc3ba8.o \ @@ -888,6 +889,11 @@ $(OBJDIR)/juce_ComboBox_bcb5e365.o: ../../src/gui/components/controls/juce_Combo @echo "Compiling juce_ComboBox.cpp" @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" +$(OBJDIR)/juce_ImageComponent_1f90572a.o: ../../src/gui/components/controls/juce_ImageComponent.cpp + -@mkdir -p $(OBJDIR) + @echo "Compiling juce_ImageComponent.cpp" + @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" + $(OBJDIR)/juce_Label_7af0aab6.o: ../../src/gui/components/controls/juce_Label.cpp -@mkdir -p $(OBJDIR) @echo "Compiling juce_Label.cpp" diff --git a/Builds/MacOSX/Juce.xcodeproj/project.pbxproj b/Builds/MacOSX/Juce.xcodeproj/project.pbxproj index 580787090d..2fa1fb1641 100644 --- a/Builds/MacOSX/Juce.xcodeproj/project.pbxproj +++ b/Builds/MacOSX/Juce.xcodeproj/project.pbxproj @@ -109,6 +109,7 @@ DA5DA96B9D1A26342D9278B6 = { isa = PBXBuildFile; fileRef = 04F48B09426293224576DA9A; }; CA49EF43B1478B146ADBBF62 = { isa = PBXBuildFile; fileRef = 346CC505FAFEE9451040108D; }; FE6F6A4946B7E4F6C9F44C4A = { isa = PBXBuildFile; fileRef = ADC16C18C8237A7F8E35E37A; }; + 28254F1E6E686CF6F29AE56A = { isa = PBXBuildFile; fileRef = 0D3FA24FF38399E0EDA80860; }; 9EA7FEF4CAD2BF46DD3596DA = { isa = PBXBuildFile; fileRef = 7330A9643F50DE8BEACDBB61; }; D1400B3D9D07FA9E8BAA21CB = { isa = PBXBuildFile; fileRef = 1BC6C010045A06BDB4C684F6; }; 716823F3B5437A20FCADA50E = { isa = PBXBuildFile; fileRef = 71B6CE03D6DB07BB293C8206; }; @@ -616,6 +617,8 @@ 3384A91143018ED9346E4118 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_CPlusPlusCodeTokeniser.h; path = ../../src/gui/components/code_editor/juce_CPlusPlusCodeTokeniser.h; sourceTree = SOURCE_ROOT; }; ADC16C18C8237A7F8E35E37A = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ComboBox.cpp; path = ../../src/gui/components/controls/juce_ComboBox.cpp; sourceTree = SOURCE_ROOT; }; D8EB3EA456D9FCC211CD1ED5 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ComboBox.h; path = ../../src/gui/components/controls/juce_ComboBox.h; sourceTree = SOURCE_ROOT; }; + 0D3FA24FF38399E0EDA80860 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ImageComponent.cpp; path = ../../src/gui/components/controls/juce_ImageComponent.cpp; sourceTree = SOURCE_ROOT; }; + CA3454A9B6F80A2F4735C37E = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ImageComponent.h; path = ../../src/gui/components/controls/juce_ImageComponent.h; sourceTree = SOURCE_ROOT; }; 7330A9643F50DE8BEACDBB61 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_Label.cpp; path = ../../src/gui/components/controls/juce_Label.cpp; sourceTree = SOURCE_ROOT; }; C0CC0FA84A4F7AA76C1611CB = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_Label.h; path = ../../src/gui/components/controls/juce_Label.h; sourceTree = SOURCE_ROOT; }; 1BC6C010045A06BDB4C684F6 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ListBox.cpp; path = ../../src/gui/components/controls/juce_ListBox.cpp; sourceTree = SOURCE_ROOT; }; @@ -1377,6 +1380,8 @@ BCB2FFE7C2A4084A267F57F2 = { isa = PBXGroup; children = ( ADC16C18C8237A7F8E35E37A, D8EB3EA456D9FCC211CD1ED5, + 0D3FA24FF38399E0EDA80860, + CA3454A9B6F80A2F4735C37E, 7330A9643F50DE8BEACDBB61, C0CC0FA84A4F7AA76C1611CB, 1BC6C010045A06BDB4C684F6, @@ -2133,6 +2138,7 @@ DA5DA96B9D1A26342D9278B6, CA49EF43B1478B146ADBBF62, FE6F6A4946B7E4F6C9F44C4A, + 28254F1E6E686CF6F29AE56A, 9EA7FEF4CAD2BF46DD3596DA, D1400B3D9D07FA9E8BAA21CB, 716823F3B5437A20FCADA50E, diff --git a/Builds/VisualStudio2005/Juce.vcproj b/Builds/VisualStudio2005/Juce.vcproj index d121f0c26d..05c19b3de5 100644 --- a/Builds/VisualStudio2005/Juce.vcproj +++ b/Builds/VisualStudio2005/Juce.vcproj @@ -472,6 +472,8 @@ + + diff --git a/Builds/VisualStudio2008/Juce.vcproj b/Builds/VisualStudio2008/Juce.vcproj index 47e691bedf..b95c38446d 100644 --- a/Builds/VisualStudio2008/Juce.vcproj +++ b/Builds/VisualStudio2008/Juce.vcproj @@ -472,6 +472,8 @@ + + diff --git a/Builds/VisualStudio2008_DLL/Juce.vcproj b/Builds/VisualStudio2008_DLL/Juce.vcproj index 548f7375a4..3ed2ab7a2a 100644 --- a/Builds/VisualStudio2008_DLL/Juce.vcproj +++ b/Builds/VisualStudio2008_DLL/Juce.vcproj @@ -474,6 +474,8 @@ + + diff --git a/Builds/VisualStudio2010/Juce.vcxproj b/Builds/VisualStudio2010/Juce.vcxproj index 0e2bc2c2df..a02c9d3645 100644 --- a/Builds/VisualStudio2010/Juce.vcxproj +++ b/Builds/VisualStudio2010/Juce.vcxproj @@ -223,6 +223,7 @@ + @@ -591,6 +592,7 @@ + diff --git a/Builds/VisualStudio2010/Juce.vcxproj.filters b/Builds/VisualStudio2010/Juce.vcxproj.filters index e09cdb63dd..f66bd21c58 100644 --- a/Builds/VisualStudio2010/Juce.vcxproj.filters +++ b/Builds/VisualStudio2010/Juce.vcxproj.filters @@ -529,6 +529,9 @@ Juce\Source\gui\components\controls + + Juce\Source\gui\components\controls + Juce\Source\gui\components\controls @@ -1707,6 +1710,9 @@ Juce\Source\gui\components\controls + + Juce\Source\gui\components\controls + Juce\Source\gui\components\controls diff --git a/Builds/iOS/Juce.xcodeproj/project.pbxproj b/Builds/iOS/Juce.xcodeproj/project.pbxproj index c8dad8c8bf..04f6298a47 100644 --- a/Builds/iOS/Juce.xcodeproj/project.pbxproj +++ b/Builds/iOS/Juce.xcodeproj/project.pbxproj @@ -109,6 +109,7 @@ DA5DA96B9D1A26342D9278B6 = { isa = PBXBuildFile; fileRef = 04F48B09426293224576DA9A; }; CA49EF43B1478B146ADBBF62 = { isa = PBXBuildFile; fileRef = 346CC505FAFEE9451040108D; }; FE6F6A4946B7E4F6C9F44C4A = { isa = PBXBuildFile; fileRef = ADC16C18C8237A7F8E35E37A; }; + 28254F1E6E686CF6F29AE56A = { isa = PBXBuildFile; fileRef = 0D3FA24FF38399E0EDA80860; }; 9EA7FEF4CAD2BF46DD3596DA = { isa = PBXBuildFile; fileRef = 7330A9643F50DE8BEACDBB61; }; D1400B3D9D07FA9E8BAA21CB = { isa = PBXBuildFile; fileRef = 1BC6C010045A06BDB4C684F6; }; 716823F3B5437A20FCADA50E = { isa = PBXBuildFile; fileRef = 71B6CE03D6DB07BB293C8206; }; @@ -616,6 +617,8 @@ 3384A91143018ED9346E4118 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_CPlusPlusCodeTokeniser.h; path = ../../src/gui/components/code_editor/juce_CPlusPlusCodeTokeniser.h; sourceTree = SOURCE_ROOT; }; ADC16C18C8237A7F8E35E37A = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ComboBox.cpp; path = ../../src/gui/components/controls/juce_ComboBox.cpp; sourceTree = SOURCE_ROOT; }; D8EB3EA456D9FCC211CD1ED5 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ComboBox.h; path = ../../src/gui/components/controls/juce_ComboBox.h; sourceTree = SOURCE_ROOT; }; + 0D3FA24FF38399E0EDA80860 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ImageComponent.cpp; path = ../../src/gui/components/controls/juce_ImageComponent.cpp; sourceTree = SOURCE_ROOT; }; + CA3454A9B6F80A2F4735C37E = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ImageComponent.h; path = ../../src/gui/components/controls/juce_ImageComponent.h; sourceTree = SOURCE_ROOT; }; 7330A9643F50DE8BEACDBB61 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_Label.cpp; path = ../../src/gui/components/controls/juce_Label.cpp; sourceTree = SOURCE_ROOT; }; C0CC0FA84A4F7AA76C1611CB = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_Label.h; path = ../../src/gui/components/controls/juce_Label.h; sourceTree = SOURCE_ROOT; }; 1BC6C010045A06BDB4C684F6 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ListBox.cpp; path = ../../src/gui/components/controls/juce_ListBox.cpp; sourceTree = SOURCE_ROOT; }; @@ -1377,6 +1380,8 @@ BCB2FFE7C2A4084A267F57F2 = { isa = PBXGroup; children = ( ADC16C18C8237A7F8E35E37A, D8EB3EA456D9FCC211CD1ED5, + 0D3FA24FF38399E0EDA80860, + CA3454A9B6F80A2F4735C37E, 7330A9643F50DE8BEACDBB61, C0CC0FA84A4F7AA76C1611CB, 1BC6C010045A06BDB4C684F6, @@ -2137,6 +2142,7 @@ DA5DA96B9D1A26342D9278B6, CA49EF43B1478B146ADBBF62, FE6F6A4946B7E4F6C9F44C4A, + 28254F1E6E686CF6F29AE56A, 9EA7FEF4CAD2BF46DD3596DA, D1400B3D9D07FA9E8BAA21CB, 716823F3B5437A20FCADA50E, diff --git a/Juce.jucer b/Juce.jucer index 1072c3c8d7..8640fc226f 100644 --- a/Juce.jucer +++ b/Juce.jucer @@ -582,6 +582,10 @@ file="src/gui/components/controls/juce_ComboBox.cpp"/> + + diff --git a/amalgamation/juce_amalgamated_template.cpp b/amalgamation/juce_amalgamated_template.cpp index 9ff9cafca7..a54d47fdad 100644 --- a/amalgamation/juce_amalgamated_template.cpp +++ b/amalgamation/juce_amalgamated_template.cpp @@ -245,6 +245,7 @@ #include "../src/gui/components/code_editor/juce_CodeEditorComponent.cpp" #include "../src/gui/components/code_editor/juce_CPlusPlusCodeTokeniser.cpp" #include "../src/gui/components/controls/juce_ComboBox.cpp" + #include "../src/gui/components/controls/juce_ImageComponent.cpp" #include "../src/gui/components/controls/juce_Label.cpp" #include "../src/gui/components/controls/juce_ListBox.cpp" #include "../src/gui/components/controls/juce_ProgressBar.cpp" diff --git a/extras/Introjucer/Source/Utility/jucer_PresetIDs.h b/extras/Introjucer/Source/Utility/jucer_PresetIDs.h index 95d8827ebd..9f0e54d267 100644 --- a/extras/Introjucer/Source/Utility/jucer_PresetIDs.h +++ b/extras/Introjucer/Source/Utility/jucer_PresetIDs.h @@ -44,6 +44,7 @@ namespace Ids DECLARE_ID (readOnly); DECLARE_ID (editMode); DECLARE_ID (justification); + DECLARE_ID (placement); DECLARE_ID (items); DECLARE_ID (editable); DECLARE_ID (textJustification); @@ -110,6 +111,7 @@ namespace Ids DECLARE_ID (rootItemVisible); DECLARE_ID (openByDefault); DECLARE_ID (locked); + DECLARE_ID (image); DECLARE_ID (tooltip); DECLARE_ID (memberName); DECLARE_ID (focusOrder); diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 82db0fed15..826450e9b3 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -47856,6 +47856,67 @@ END_JUCE_NAMESPACE /*** End of inlined file: juce_ComboBox.cpp ***/ +/*** Start of inlined file: juce_ImageComponent.cpp ***/ +BEGIN_JUCE_NAMESPACE + +ImageComponent::ImageComponent (const String& componentName) + : Component (componentName), + placement (RectanglePlacement::centred) +{ +} + +ImageComponent::~ImageComponent() +{ +} + +void ImageComponent::setImage (const Image& newImage) +{ + if (image != newImage) + { + image = newImage; + repaint(); + } +} + +void ImageComponent::setImage (const Image& newImage, const RectanglePlacement& placementToUse) +{ + if (image != newImage || placement != placementToUse) + { + image = newImage; + placement = placementToUse; + repaint(); + } +} + +void ImageComponent::setImagePlacement (const RectanglePlacement& newPlacement) +{ + if (placement != newPlacement) + { + placement = newPlacement; + repaint(); + } +} + +const Image ImageComponent::getImage() const +{ + return image; +} + +const RectanglePlacement ImageComponent::getImagePlacement() const +{ + return placement; +} + +void ImageComponent::paint (Graphics& g) +{ + g.setOpacity (1.0f); + g.drawImageWithin (image, 0, 0, getWidth(), getHeight(), placement, false); +} + +END_JUCE_NAMESPACE +/*** End of inlined file: juce_ImageComponent.cpp ***/ + + /*** Start of inlined file: juce_Label.cpp ***/ BEGIN_JUCE_NAMESPACE @@ -86423,6 +86484,16 @@ RectanglePlacement& RectanglePlacement::operator= (const RectanglePlacement& oth return *this; } +bool RectanglePlacement::operator== (const RectanglePlacement& other) const throw() +{ + return flags == other.flags; +} + +bool RectanglePlacement::operator!= (const RectanglePlacement& other) const throw() +{ + return flags != other.flags; +} + void RectanglePlacement::applyTo (double& x, double& y, double& w, double& h, const double dx, const double dy, const double dw, const double dh) const throw() { @@ -130356,7 +130427,7 @@ typedef struct { * ov_open() to avoid problems with incompatible crt.o version linking * issues. */ -static int _ov_header_fseek_wrap(FILE *f,ogg_int64_t off,int whence){ +/*static int _ov_header_fseek_wrap(FILE *f,ogg_int64_t off,int whence){ if(f==NULL)return(-1); #ifdef __MINGW32__ @@ -130366,7 +130437,7 @@ static int _ov_header_fseek_wrap(FILE *f,ogg_int64_t off,int whence){ #else return fseek(f,off,whence); #endif -} +}*/ /* These structs below (OV_CALLBACKS_DEFAULT etc) are defined here as * static data. That means that every file which includes this header diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 57e4c285a7..58a93eb769 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -73,7 +73,7 @@ namespace JuceDummyNamespace {} */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 53 -#define JUCE_BUILDNUMBER 64 +#define JUCE_BUILDNUMBER 65 /** Current Juce version number. @@ -28462,6 +28462,9 @@ public: /** Copies another RectanglePlacement object. */ RectanglePlacement& operator= (const RectanglePlacement& other) throw(); + bool operator== (const RectanglePlacement& other) const throw(); + bool operator!= (const RectanglePlacement& other) const throw(); + /** Flag values that can be combined and used in the constructor. */ enum { @@ -52020,6 +52023,62 @@ private: #endif #ifndef __JUCE_COMBOBOX_JUCEHEADER__ +#endif +#ifndef __JUCE_IMAGECOMPONENT_JUCEHEADER__ + +/*** Start of inlined file: juce_ImageComponent.h ***/ +#ifndef __JUCE_IMAGECOMPONENT_JUCEHEADER__ +#define __JUCE_IMAGECOMPONENT_JUCEHEADER__ + +/** + A component that simply displays an image. + + Use setImage to give it an image, and it'll display it - simple as that! +*/ +class JUCE_API ImageComponent : public Component, + public SettableTooltipClient +{ +public: + + /** Creates an ImageComponent. */ + ImageComponent (const String& componentName = String::empty); + + /** Destructor. */ + ~ImageComponent(); + + /** Sets the image that should be displayed. */ + void setImage (const Image& newImage); + + /** Sets the image that should be displayed, and its placement within the component. */ + void setImage (const Image& newImage, + const RectanglePlacement& placementToUse); + + /** Returns the current image. */ + const Image getImage() const; + + /** Sets the method of positioning that will be used to fit the image within the component's bounds. + By default the positioning is centred, and will fit the image inside the component's bounds + whilst keeping its aspect ratio correct, but you can change it to whatever layout you need. + */ + void setImagePlacement (const RectanglePlacement& newPlacement); + + /** Returns the current image placement. */ + const RectanglePlacement getImagePlacement() const; + + /** @internal */ + void paint (Graphics& g); + +private: + Image image; + RectanglePlacement placement; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ImageComponent); +}; + +#endif // __JUCE_IMAGECOMPONENT_JUCEHEADER__ +/*** End of inlined file: juce_ImageComponent.h ***/ + + #endif #ifndef __JUCE_LABEL_JUCEHEADER__ diff --git a/src/audio/audio_file_formats/oggvorbis/vorbisfile.h b/src/audio/audio_file_formats/oggvorbis/vorbisfile.h index a50d370a56..ee6e3f73d5 100644 --- a/src/audio/audio_file_formats/oggvorbis/vorbisfile.h +++ b/src/audio/audio_file_formats/oggvorbis/vorbisfile.h @@ -50,7 +50,7 @@ typedef struct { * ov_open() to avoid problems with incompatible crt.o version linking * issues. */ -static int _ov_header_fseek_wrap(FILE *f,ogg_int64_t off,int whence){ +/*static int _ov_header_fseek_wrap(FILE *f,ogg_int64_t off,int whence){ if(f==NULL)return(-1); #ifdef __MINGW32__ @@ -60,7 +60,7 @@ static int _ov_header_fseek_wrap(FILE *f,ogg_int64_t off,int whence){ #else return fseek(f,off,whence); #endif -} +}*/ /* These structs below (OV_CALLBACKS_DEFAULT etc) are defined here as * static data. That means that every file which includes this header diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index 8974a5f735..53dc4433ed 100644 --- a/src/core/juce_StandardHeader.h +++ b/src/core/juce_StandardHeader.h @@ -33,7 +33,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 53 -#define JUCE_BUILDNUMBER 64 +#define JUCE_BUILDNUMBER 65 /** Current Juce version number. diff --git a/src/gui/components/controls/juce_ImageComponent.cpp b/src/gui/components/controls/juce_ImageComponent.cpp new file mode 100644 index 0000000000..220f2b54f7 --- /dev/null +++ b/src/gui/components/controls/juce_ImageComponent.cpp @@ -0,0 +1,89 @@ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-11 by Raw Material Software Ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the GNU General + Public License (Version 2), as published by the Free Software Foundation. + A copy of the license is included in the JUCE distribution, or can be found + online at www.gnu.org/licenses. + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.rawmaterialsoftware.com/juce for more information. + + ============================================================================== +*/ + +#include "../../../core/juce_StandardHeader.h" + +BEGIN_JUCE_NAMESPACE + +#include "juce_ImageComponent.h" + + +//============================================================================== +ImageComponent::ImageComponent (const String& componentName) + : Component (componentName), + placement (RectanglePlacement::centred) +{ +} + +ImageComponent::~ImageComponent() +{ +} + +void ImageComponent::setImage (const Image& newImage) +{ + if (image != newImage) + { + image = newImage; + repaint(); + } +} + +void ImageComponent::setImage (const Image& newImage, const RectanglePlacement& placementToUse) +{ + if (image != newImage || placement != placementToUse) + { + image = newImage; + placement = placementToUse; + repaint(); + } +} + +void ImageComponent::setImagePlacement (const RectanglePlacement& newPlacement) +{ + if (placement != newPlacement) + { + placement = newPlacement; + repaint(); + } +} + +const Image ImageComponent::getImage() const +{ + return image; +} + +const RectanglePlacement ImageComponent::getImagePlacement() const +{ + return placement; +} + +void ImageComponent::paint (Graphics& g) +{ + g.setOpacity (1.0f); + g.drawImageWithin (image, 0, 0, getWidth(), getHeight(), placement, false); +} + + +END_JUCE_NAMESPACE diff --git a/src/gui/components/controls/juce_ImageComponent.h b/src/gui/components/controls/juce_ImageComponent.h new file mode 100644 index 0000000000..7f5ed96876 --- /dev/null +++ b/src/gui/components/controls/juce_ImageComponent.h @@ -0,0 +1,83 @@ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-11 by Raw Material Software Ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the GNU General + Public License (Version 2), as published by the Free Software Foundation. + A copy of the license is included in the JUCE distribution, or can be found + online at www.gnu.org/licenses. + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.rawmaterialsoftware.com/juce for more information. + + ============================================================================== +*/ + +#ifndef __JUCE_IMAGECOMPONENT_JUCEHEADER__ +#define __JUCE_IMAGECOMPONENT_JUCEHEADER__ + +#include "../juce_Component.h" +#include "../mouse/juce_TooltipClient.h" + + +//============================================================================== +/** + A component that simply displays an image. + + Use setImage to give it an image, and it'll display it - simple as that! +*/ +class JUCE_API ImageComponent : public Component, + public SettableTooltipClient +{ +public: + //============================================================================== + /** Creates an ImageComponent. */ + ImageComponent (const String& componentName = String::empty); + + /** Destructor. */ + ~ImageComponent(); + + //============================================================================== + /** Sets the image that should be displayed. */ + void setImage (const Image& newImage); + + /** Sets the image that should be displayed, and its placement within the component. */ + void setImage (const Image& newImage, + const RectanglePlacement& placementToUse); + + /** Returns the current image. */ + const Image getImage() const; + + /** Sets the method of positioning that will be used to fit the image within the component's bounds. + By default the positioning is centred, and will fit the image inside the component's bounds + whilst keeping its aspect ratio correct, but you can change it to whatever layout you need. + */ + void setImagePlacement (const RectanglePlacement& newPlacement); + + /** Returns the current image placement. */ + const RectanglePlacement getImagePlacement() const; + + + //============================================================================== + /** @internal */ + void paint (Graphics& g); + +private: + Image image; + RectanglePlacement placement; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ImageComponent); +}; + + +#endif // __JUCE_IMAGECOMPONENT_JUCEHEADER__ diff --git a/src/gui/graphics/contexts/juce_RectanglePlacement.cpp b/src/gui/graphics/contexts/juce_RectanglePlacement.cpp index e9714b8372..59370fdd66 100644 --- a/src/gui/graphics/contexts/juce_RectanglePlacement.cpp +++ b/src/gui/graphics/contexts/juce_RectanglePlacement.cpp @@ -42,6 +42,16 @@ RectanglePlacement& RectanglePlacement::operator= (const RectanglePlacement& oth return *this; } +bool RectanglePlacement::operator== (const RectanglePlacement& other) const throw() +{ + return flags == other.flags; +} + +bool RectanglePlacement::operator!= (const RectanglePlacement& other) const throw() +{ + return flags != other.flags; +} + void RectanglePlacement::applyTo (double& x, double& y, double& w, double& h, const double dx, const double dy, const double dw, const double dh) const throw() { diff --git a/src/gui/graphics/contexts/juce_RectanglePlacement.h b/src/gui/graphics/contexts/juce_RectanglePlacement.h index fcb9fb6482..fbc3fc269c 100644 --- a/src/gui/graphics/contexts/juce_RectanglePlacement.h +++ b/src/gui/graphics/contexts/juce_RectanglePlacement.h @@ -51,6 +51,9 @@ public: /** Copies another RectanglePlacement object. */ RectanglePlacement& operator= (const RectanglePlacement& other) throw(); + bool operator== (const RectanglePlacement& other) const throw(); + bool operator!= (const RectanglePlacement& other) const throw(); + //============================================================================== /** Flag values that can be combined and used in the constructor. */ enum diff --git a/src/juce_app_includes.h b/src/juce_app_includes.h index 45d3b4f434..8c2466995c 100644 --- a/src/juce_app_includes.h +++ b/src/juce_app_includes.h @@ -311,6 +311,9 @@ #ifndef __JUCE_COMBOBOX_JUCEHEADER__ #include "gui/components/controls/juce_ComboBox.h" #endif +#ifndef __JUCE_IMAGECOMPONENT_JUCEHEADER__ + #include "gui/components/controls/juce_ImageComponent.h" +#endif #ifndef __JUCE_LABEL_JUCEHEADER__ #include "gui/components/controls/juce_Label.h" #endif