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.

128 lines
4.7KB

  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_LOWLEVELGRAPHICSPOSTSCRIPTRENDERER_JUCEHEADER__
  19. #define __JUCE_LOWLEVELGRAPHICSPOSTSCRIPTRENDERER_JUCEHEADER__
  20. #include "juce_LowLevelGraphicsContext.h"
  21. //==============================================================================
  22. /**
  23. An implementation of LowLevelGraphicsContext that turns the drawing operations
  24. into a PostScript document.
  25. */
  26. class JUCE_API LowLevelGraphicsPostScriptRenderer : public LowLevelGraphicsContext
  27. {
  28. public:
  29. //==============================================================================
  30. LowLevelGraphicsPostScriptRenderer (OutputStream& resultingPostScript,
  31. const String& documentTitle,
  32. int totalWidth,
  33. int totalHeight);
  34. ~LowLevelGraphicsPostScriptRenderer();
  35. //==============================================================================
  36. bool isVectorDevice() const;
  37. void setOrigin (int x, int y);
  38. void addTransform (const AffineTransform& transform);
  39. float getScaleFactor();
  40. bool clipToRectangle (const Rectangle<int>& r);
  41. bool clipToRectangleList (const RectangleList& clipRegion);
  42. void excludeClipRectangle (const Rectangle<int>& r);
  43. void clipToPath (const Path& path, const AffineTransform& transform);
  44. void clipToImageAlpha (const Image& sourceImage, const AffineTransform& transform);
  45. void saveState();
  46. void restoreState();
  47. void beginTransparencyLayer (float opacity);
  48. void endTransparencyLayer();
  49. bool clipRegionIntersects (const Rectangle<int>& r);
  50. Rectangle<int> getClipBounds() const;
  51. bool isClipEmpty() const;
  52. //==============================================================================
  53. void setFill (const FillType& fillType);
  54. void setOpacity (float opacity);
  55. void setInterpolationQuality (Graphics::ResamplingQuality quality);
  56. //==============================================================================
  57. void fillRect (const Rectangle<int>& r, bool replaceExistingContents);
  58. void fillPath (const Path& path, const AffineTransform& transform);
  59. void drawImage (const Image& sourceImage, const AffineTransform& transform);
  60. void drawLine (const Line <float>& line);
  61. void drawVerticalLine (int x, float top, float bottom);
  62. void drawHorizontalLine (int x, float top, float bottom);
  63. //==============================================================================
  64. const Font& getFont();
  65. void setFont (const Font& newFont);
  66. void drawGlyph (int glyphNumber, const AffineTransform& transform);
  67. protected:
  68. //==============================================================================
  69. OutputStream& out;
  70. int totalWidth, totalHeight;
  71. bool needToClip;
  72. Colour lastColour;
  73. struct SavedState
  74. {
  75. SavedState();
  76. ~SavedState();
  77. RectangleList clip;
  78. int xOffset, yOffset;
  79. FillType fillType;
  80. Font font;
  81. private:
  82. SavedState& operator= (const SavedState&);
  83. };
  84. OwnedArray <SavedState> stateStack;
  85. void writeClip();
  86. void writeColour (const Colour& colour);
  87. void writePath (const Path& path) const;
  88. void writeXY (float x, float y) const;
  89. void writeTransform (const AffineTransform& trans) const;
  90. void writeImage (const Image& im, int sx, int sy, int maxW, int maxH) const;
  91. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LowLevelGraphicsPostScriptRenderer);
  92. };
  93. #endif // __JUCE_LOWLEVELGRAPHICSPOSTSCRIPTRENDERER_JUCEHEADER__