Add remaining files
[juce-lv2.git] / juce / source / src / gui / components / controls / juce_ImageComponent.cpp
blob0e7c453e6d7379022def8c29738e19d10ee06afa
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #include "../../../core/juce_StandardHeader.h"
28 BEGIN_JUCE_NAMESPACE
30 #include "juce_ImageComponent.h"
33 //==============================================================================
34 ImageComponent::ImageComponent (const String& name)
35 : Component (name),
36 placement (RectanglePlacement::centred)
40 ImageComponent::~ImageComponent()
44 void ImageComponent::setImage (const Image& newImage)
46 if (image != newImage)
48 image = newImage;
49 repaint();
53 void ImageComponent::setImage (const Image& newImage, const RectanglePlacement& placementToUse)
55 if (image != newImage || placement != placementToUse)
57 image = newImage;
58 placement = placementToUse;
59 repaint();
63 void ImageComponent::setImagePlacement (const RectanglePlacement& newPlacement)
65 if (placement != newPlacement)
67 placement = newPlacement;
68 repaint();
72 const Image& ImageComponent::getImage() const
74 return image;
77 const RectanglePlacement ImageComponent::getImagePlacement() const
79 return placement;
82 void ImageComponent::paint (Graphics& g)
84 g.setOpacity (1.0f);
85 g.drawImageWithin (image, 0, 0, getWidth(), getHeight(), placement, false);
89 END_JUCE_NAMESPACE