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.9KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-10 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. bool clipToRectangle (const Rectangle<int>& r);
  40. bool clipToRectangleList (const RectangleList& clipRegion);
  41. void excludeClipRectangle (const Rectangle<int>& r);
  42. void clipToPath (const Path& path, const AffineTransform& transform);
  43. void clipToImageAlpha (const Image& sourceImage, const AffineTransform& transform);
  44. void saveState();
  45. void restoreState();
  46. bool clipRegionIntersects (const Rectangle<int>& r);
  47. const Rectangle<int> getClipBounds() const;
  48. bool isClipEmpty() const;
  49. //==============================================================================
  50. void setFill (const FillType& fillType);
  51. void setOpacity (float opacity);
  52. void setInterpolationQuality (Graphics::ResamplingQuality quality);
  53. //==============================================================================
  54. void fillRect (const Rectangle<int>& r, bool replaceExistingContents);
  55. void fillPath (const Path& path, const AffineTransform& transform);
  56. void drawImage (const Image& sourceImage, const AffineTransform& transform, bool fillEntireClipAsTiles);
  57. void drawLine (const Line <float>& line);
  58. void drawVerticalLine (int x, float top, float bottom);
  59. void drawHorizontalLine (int x, float top, float bottom);
  60. //==============================================================================
  61. const Font getFont();
  62. void setFont (const Font& newFont);
  63. void drawGlyph (int glyphNumber, const AffineTransform& transform);
  64. //==============================================================================
  65. juce_UseDebuggingNewOperator
  66. protected:
  67. //==============================================================================
  68. OutputStream& out;
  69. int totalWidth, totalHeight;
  70. bool needToClip;
  71. Colour lastColour;
  72. struct SavedState
  73. {
  74. SavedState();
  75. ~SavedState();
  76. RectangleList clip;
  77. int xOffset, yOffset;
  78. FillType fillType;
  79. Font font;
  80. private:
  81. SavedState& operator= (const SavedState&);
  82. };
  83. OwnedArray <SavedState> stateStack;
  84. void writeClip();
  85. void writeColour (const Colour& colour);
  86. void writePath (const Path& path) const;
  87. void writeXY (float x, float y) const;
  88. void writeTransform (const AffineTransform& trans) const;
  89. void writeImage (const Image& im, int sx, int sy, int maxW, int maxH) const;
  90. LowLevelGraphicsPostScriptRenderer (const LowLevelGraphicsPostScriptRenderer& other);
  91. LowLevelGraphicsPostScriptRenderer& operator= (const LowLevelGraphicsPostScriptRenderer&);
  92. };
  93. #endif // __JUCE_LOWLEVELGRAPHICSPOSTSCRIPTRENDERER_JUCEHEADER__