The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
3.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCE_IMAGECOMPONENT_JUCEHEADER__
  19. #define __JUCE_IMAGECOMPONENT_JUCEHEADER__
  20. #include "../components/juce_Component.h"
  21. #include "../mouse/juce_TooltipClient.h"
  22. //==============================================================================
  23. /**
  24. A component that simply displays an image.
  25. Use setImage to give it an image, and it'll display it - simple as that!
  26. */
  27. class JUCE_API ImageComponent : public Component,
  28. public SettableTooltipClient
  29. {
  30. public:
  31. //==============================================================================
  32. /** Creates an ImageComponent. */
  33. ImageComponent (const String& componentName = String::empty);
  34. /** Destructor. */
  35. ~ImageComponent();
  36. //==============================================================================
  37. /** Sets the image that should be displayed. */
  38. void setImage (const Image& newImage);
  39. /** Sets the image that should be displayed, and its placement within the component. */
  40. void setImage (const Image& newImage,
  41. const RectanglePlacement& placementToUse);
  42. /** Returns the current image. */
  43. const Image& getImage() const;
  44. /** Sets the method of positioning that will be used to fit the image within the component's bounds.
  45. By default the positioning is centred, and will fit the image inside the component's bounds
  46. whilst keeping its aspect ratio correct, but you can change it to whatever layout you need.
  47. */
  48. void setImagePlacement (const RectanglePlacement& newPlacement);
  49. /** Returns the current image placement. */
  50. const RectanglePlacement getImagePlacement() const;
  51. //==============================================================================
  52. /** @internal */
  53. void paint (Graphics& g);
  54. private:
  55. Image image;
  56. RectanglePlacement placement;
  57. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ImageComponent);
  58. };
  59. #endif // __JUCE_IMAGECOMPONENT_JUCEHEADER__