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.

112 lines
4.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_LOWLEVELGRAPHICSCONTEXT_H_INCLUDED
  18. #define JUCE_LOWLEVELGRAPHICSCONTEXT_H_INCLUDED
  19. #include "../images/juce_Image.h"
  20. #include "../geometry/juce_Path.h"
  21. #include "../geometry/juce_RectangleList.h"
  22. #include "../colour/juce_ColourGradient.h"
  23. #include "../colour/juce_FillType.h"
  24. class AttributedString;
  25. //==============================================================================
  26. /**
  27. Interface class for graphics context objects, used internally by the Graphics class.
  28. Users are not supposed to create instances of this class directly - do your drawing
  29. via the Graphics object instead.
  30. It's a base class for different types of graphics context, that may perform software-based
  31. or OS-accelerated rendering.
  32. E.g. the LowLevelGraphicsSoftwareRenderer renders onto an image in memory, but other
  33. subclasses could render directly to a windows HDC, a Quartz context, or an OpenGL
  34. context.
  35. */
  36. class JUCE_API LowLevelGraphicsContext
  37. {
  38. protected:
  39. //==============================================================================
  40. LowLevelGraphicsContext();
  41. public:
  42. virtual ~LowLevelGraphicsContext();
  43. /** Returns true if this device is vector-based, e.g. a printer. */
  44. virtual bool isVectorDevice() const = 0;
  45. //==============================================================================
  46. /** Moves the origin to a new position.
  47. The coordinates are relative to the current origin, and indicate the new position
  48. of (0, 0).
  49. */
  50. virtual void setOrigin (int x, int y) = 0;
  51. virtual void addTransform (const AffineTransform&) = 0;
  52. virtual float getScaleFactor() = 0;
  53. virtual float getTargetDeviceScaleFactor() { return 1.0f; }
  54. virtual bool clipToRectangle (const Rectangle<int>&) = 0;
  55. virtual bool clipToRectangleList (const RectangleList<int>&) = 0;
  56. virtual void excludeClipRectangle (const Rectangle<int>&) = 0;
  57. virtual void clipToPath (const Path&, const AffineTransform&) = 0;
  58. virtual void clipToImageAlpha (const Image&, const AffineTransform&) = 0;
  59. virtual bool clipRegionIntersects (const Rectangle<int>&) = 0;
  60. virtual Rectangle<int> getClipBounds() const = 0;
  61. virtual bool isClipEmpty() const = 0;
  62. virtual void saveState() = 0;
  63. virtual void restoreState() = 0;
  64. virtual void beginTransparencyLayer (float opacity) = 0;
  65. virtual void endTransparencyLayer() = 0;
  66. //==============================================================================
  67. virtual void setFill (const FillType&) = 0;
  68. virtual void setOpacity (float newOpacity) = 0;
  69. virtual void setInterpolationQuality (Graphics::ResamplingQuality) = 0;
  70. //==============================================================================
  71. virtual void fillRect (const Rectangle<int>&, bool replaceExistingContents) = 0;
  72. virtual void fillPath (const Path&, const AffineTransform&) = 0;
  73. virtual void drawImage (const Image&, const AffineTransform&) = 0;
  74. virtual void drawLine (const Line <float>&) = 0;
  75. virtual void drawVerticalLine (int x, float top, float bottom) = 0;
  76. virtual void drawHorizontalLine (int y, float left, float right) = 0;
  77. virtual void setFont (const Font&) = 0;
  78. virtual const Font& getFont() = 0;
  79. virtual void drawGlyph (int glyphNumber, const AffineTransform&) = 0;
  80. virtual bool drawTextLayout (const AttributedString&, const Rectangle<float>&) { return false; }
  81. };
  82. #endif // JUCE_LOWLEVELGRAPHICSCONTEXT_H_INCLUDED