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.

707 lines
31KB

  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_GRAPHICSCONTEXT_JUCEHEADER__
  19. #define __JUCE_GRAPHICSCONTEXT_JUCEHEADER__
  20. #include "../fonts/juce_Font.h"
  21. #include "../geometry/juce_Rectangle.h"
  22. #include "../geometry/juce_PathStrokeType.h"
  23. #include "../geometry/juce_Line.h"
  24. #include "../colour/juce_Colours.h"
  25. #include "../colour/juce_ColourGradient.h"
  26. #include "../placement/juce_RectanglePlacement.h"
  27. class LowLevelGraphicsContext;
  28. class Image;
  29. class FillType;
  30. class RectangleList;
  31. //==============================================================================
  32. /**
  33. A graphics context, used for drawing a component or image.
  34. When a Component needs painting, a Graphics context is passed to its
  35. Component::paint() method, and this you then call methods within this
  36. object to actually draw the component's content.
  37. A Graphics can also be created from an image, to allow drawing directly onto
  38. that image.
  39. @see Component::paint
  40. */
  41. class JUCE_API Graphics
  42. {
  43. public:
  44. //==============================================================================
  45. /** Creates a Graphics object to draw directly onto the given image.
  46. The graphics object that is created will be set up to draw onto the image,
  47. with the context's clipping area being the entire size of the image, and its
  48. origin being the image's origin. To draw into a subsection of an image, use the
  49. reduceClipRegion() and setOrigin() methods.
  50. Obviously you shouldn't delete the image before this context is deleted.
  51. */
  52. explicit Graphics (const Image& imageToDrawOnto);
  53. /** Destructor. */
  54. ~Graphics();
  55. //==============================================================================
  56. /** Changes the current drawing colour.
  57. This sets the colour that will now be used for drawing operations - it also
  58. sets the opacity to that of the colour passed-in.
  59. If a brush is being used when this method is called, the brush will be deselected,
  60. and any subsequent drawing will be done with a solid colour brush instead.
  61. @see setOpacity
  62. */
  63. void setColour (const Colour& newColour);
  64. /** Changes the opacity to use with the current colour.
  65. If a solid colour is being used for drawing, this changes its opacity
  66. to this new value (i.e. it doesn't multiply the colour's opacity by this amount).
  67. If a gradient is being used, this will have no effect on it.
  68. A value of 0.0 is completely transparent, 1.0 is completely opaque.
  69. */
  70. void setOpacity (float newOpacity);
  71. /** Sets the context to use a gradient for its fill pattern.
  72. */
  73. void setGradientFill (const ColourGradient& gradient);
  74. /** Sets the context to use a tiled image pattern for filling.
  75. Make sure that you don't delete this image while it's still being used by
  76. this context!
  77. */
  78. void setTiledImageFill (const Image& imageToUse,
  79. int anchorX, int anchorY,
  80. float opacity);
  81. /** Changes the current fill settings.
  82. @see setColour, setGradientFill, setTiledImageFill
  83. */
  84. void setFillType (const FillType& newFill);
  85. //==============================================================================
  86. /** Changes the font to use for subsequent text-drawing functions.
  87. Note there's also a setFont (float, int) method to quickly change the size and
  88. style of the current font.
  89. @see drawSingleLineText, drawMultiLineText, drawTextAsPath, drawText, drawFittedText
  90. */
  91. void setFont (const Font& newFont);
  92. /** Changes the size and style of the currently-selected font.
  93. This is a convenient shortcut that changes the context's current font to a
  94. different size or style. The typeface won't be changed.
  95. @see Font
  96. */
  97. void setFont (float newFontHeight, int fontStyleFlags = Font::plain);
  98. /** Returns the currently selected font. */
  99. Font getCurrentFont() const;
  100. /** Draws a one-line text string.
  101. This will use the current colour (or brush) to fill the text. The font is the last
  102. one specified by setFont().
  103. @param text the string to draw
  104. @param startX the position to draw the left-hand edge of the text
  105. @param baselineY the position of the text's baseline
  106. @param justification the horizontal flags indicate which end of the text string is
  107. anchored at the specified point.
  108. @see drawMultiLineText, drawText, drawFittedText, GlyphArrangement::addLineOfText
  109. */
  110. void drawSingleLineText (const String& text,
  111. int startX, int baselineY,
  112. const Justification& justification = Justification::left) const;
  113. /** Draws text across multiple lines.
  114. This will break the text onto a new line where there's a new-line or
  115. carriage-return character, or at a word-boundary when the text becomes wider
  116. than the size specified by the maximumLineWidth parameter.
  117. @see setFont, drawSingleLineText, drawFittedText, GlyphArrangement::addJustifiedText
  118. */
  119. void drawMultiLineText (const String& text,
  120. int startX, int baselineY,
  121. int maximumLineWidth) const;
  122. /** Renders a string of text as a vector path.
  123. This allows a string to be transformed with an arbitrary AffineTransform and
  124. rendered using the current colour/brush. It's much slower than the normal text methods
  125. but more accurate.
  126. @see setFont
  127. */
  128. void drawTextAsPath (const String& text,
  129. const AffineTransform& transform) const;
  130. /** Draws a line of text within a specified rectangle.
  131. The text will be positioned within the rectangle based on the justification
  132. flags passed-in. If the string is too long to fit inside the rectangle, it will
  133. either be truncated or will have ellipsis added to its end (if the useEllipsesIfTooBig
  134. flag is true).
  135. @see drawSingleLineText, drawFittedText, drawMultiLineText, GlyphArrangement::addJustifiedText
  136. */
  137. void drawText (const String& text,
  138. int x, int y, int width, int height,
  139. const Justification& justificationType,
  140. bool useEllipsesIfTooBig) const;
  141. /** Tries to draw a text string inside a given space.
  142. This does its best to make the given text readable within the specified rectangle,
  143. so it useful for labelling things.
  144. If the text is too big, it'll be squashed horizontally or broken over multiple lines
  145. if the maximumLinesToUse value allows this. If the text just won't fit into the space,
  146. it'll cram as much as possible in there, and put some ellipsis at the end to show that
  147. it's been truncated.
  148. A Justification parameter lets you specify how the text is laid out within the rectangle,
  149. both horizontally and vertically.
  150. The minimumHorizontalScale parameter specifies how much the text can be squashed horizontally
  151. to try to squeeze it into the space. If you don't want any horizontal scaling to occur, you
  152. can set this value to 1.0f.
  153. @see GlyphArrangement::addFittedText
  154. */
  155. void drawFittedText (const String& text,
  156. int x, int y, int width, int height,
  157. const Justification& justificationFlags,
  158. int maximumNumberOfLines,
  159. float minimumHorizontalScale = 0.7f) const;
  160. //==============================================================================
  161. /** Fills the context's entire clip region with the current colour or brush.
  162. (See also the fillAll (const Colour&) method which is a quick way of filling
  163. it with a given colour).
  164. */
  165. void fillAll() const;
  166. /** Fills the context's entire clip region with a given colour.
  167. This leaves the context's current colour and brush unchanged, it just
  168. uses the specified colour temporarily.
  169. */
  170. void fillAll (const Colour& colourToUse) const;
  171. //==============================================================================
  172. /** Fills a rectangle with the current colour or brush.
  173. @see drawRect, fillRoundedRectangle
  174. */
  175. void fillRect (int x, int y, int width, int height) const;
  176. /** Fills a rectangle with the current colour or brush. */
  177. void fillRect (const Rectangle<int>& rectangle) const;
  178. /** Fills a rectangle with the current colour or brush.
  179. This uses sub-pixel positioning so is slower than the fillRect method which
  180. takes integer co-ordinates.
  181. */
  182. void fillRect (float x, float y, float width, float height) const;
  183. /** Uses the current colour or brush to fill a rectangle with rounded corners.
  184. @see drawRoundedRectangle, Path::addRoundedRectangle
  185. */
  186. void fillRoundedRectangle (float x, float y, float width, float height,
  187. float cornerSize) const;
  188. /** Uses the current colour or brush to fill a rectangle with rounded corners.
  189. @see drawRoundedRectangle, Path::addRoundedRectangle
  190. */
  191. void fillRoundedRectangle (const Rectangle<float>& rectangle,
  192. float cornerSize) const;
  193. /** Fills a rectangle with a checkerboard pattern, alternating between two colours.
  194. */
  195. void fillCheckerBoard (const Rectangle<int>& area,
  196. int checkWidth, int checkHeight,
  197. const Colour& colour1, const Colour& colour2) const;
  198. /** Draws four lines to form a rectangular outline, using the current colour or brush.
  199. The lines are drawn inside the given rectangle, and greater line thicknesses
  200. extend inwards.
  201. @see fillRect
  202. */
  203. void drawRect (int x, int y, int width, int height,
  204. int lineThickness = 1) const;
  205. /** Draws four lines to form a rectangular outline, using the current colour or brush.
  206. The lines are drawn inside the given rectangle, and greater line thicknesses
  207. extend inwards.
  208. @see fillRect
  209. */
  210. void drawRect (float x, float y, float width, float height,
  211. float lineThickness = 1.0f) const;
  212. /** Draws four lines to form a rectangular outline, using the current colour or brush.
  213. The lines are drawn inside the given rectangle, and greater line thicknesses
  214. extend inwards.
  215. @see fillRect
  216. */
  217. void drawRect (const Rectangle<int>& rectangle,
  218. int lineThickness = 1) const;
  219. /** Uses the current colour or brush to draw the outline of a rectangle with rounded corners.
  220. @see fillRoundedRectangle, Path::addRoundedRectangle
  221. */
  222. void drawRoundedRectangle (float x, float y, float width, float height,
  223. float cornerSize, float lineThickness) const;
  224. /** Uses the current colour or brush to draw the outline of a rectangle with rounded corners.
  225. @see fillRoundedRectangle, Path::addRoundedRectangle
  226. */
  227. void drawRoundedRectangle (const Rectangle<float>& rectangle,
  228. float cornerSize, float lineThickness) const;
  229. /** Draws a 3D raised (or indented) bevel using two colours.
  230. The bevel is drawn inside the given rectangle, and greater bevel thicknesses
  231. extend inwards.
  232. The top-left colour is used for the top- and left-hand edges of the
  233. bevel; the bottom-right colour is used for the bottom- and right-hand
  234. edges.
  235. If useGradient is true, then the bevel fades out to make it look more curved
  236. and less angular. If sharpEdgeOnOutside is true, the outside of the bevel is
  237. sharp, and it fades towards the centre; if sharpEdgeOnOutside is false, then
  238. the centre edges are sharp and it fades towards the outside.
  239. */
  240. void drawBevel (int x, int y, int width, int height,
  241. int bevelThickness,
  242. const Colour& topLeftColour = Colours::white,
  243. const Colour& bottomRightColour = Colours::black,
  244. bool useGradient = true,
  245. bool sharpEdgeOnOutside = true) const;
  246. /** Draws a pixel using the current colour or brush.
  247. */
  248. void setPixel (int x, int y) const;
  249. //==============================================================================
  250. /** Fills an ellipse with the current colour or brush.
  251. The ellipse is drawn to fit inside the given rectangle.
  252. @see drawEllipse, Path::addEllipse
  253. */
  254. void fillEllipse (float x, float y, float width, float height) const;
  255. /** Draws an elliptical stroke using the current colour or brush.
  256. @see fillEllipse, Path::addEllipse
  257. */
  258. void drawEllipse (float x, float y, float width, float height,
  259. float lineThickness) const;
  260. //==============================================================================
  261. /** Draws a line between two points.
  262. The line is 1 pixel wide and drawn with the current colour or brush.
  263. */
  264. void drawLine (float startX, float startY, float endX, float endY) const;
  265. /** Draws a line between two points with a given thickness.
  266. @see Path::addLineSegment
  267. */
  268. void drawLine (float startX, float startY, float endX, float endY,
  269. float lineThickness) const;
  270. /** Draws a line between two points.
  271. The line is 1 pixel wide and drawn with the current colour or brush.
  272. */
  273. void drawLine (const Line<float>& line) const;
  274. /** Draws a line between two points with a given thickness.
  275. @see Path::addLineSegment
  276. */
  277. void drawLine (const Line<float>& line, float lineThickness) const;
  278. /** Draws a dashed line using a custom set of dash-lengths.
  279. @param line the line to draw
  280. @param dashLengths a series of lengths to specify the on/off lengths - e.g.
  281. { 4, 5, 6, 7 } will draw a line of 4 pixels, skip 5 pixels,
  282. draw 6 pixels, skip 7 pixels, and then repeat.
  283. @param numDashLengths the number of elements in the array (this must be an even number).
  284. @param lineThickness the thickness of the line to draw
  285. @param dashIndexToStartFrom the index in the dash-length array to use for the first segment
  286. @see PathStrokeType::createDashedStroke
  287. */
  288. void drawDashedLine (const Line<float>& line,
  289. const float* dashLengths, int numDashLengths,
  290. float lineThickness = 1.0f,
  291. int dashIndexToStartFrom = 0) const;
  292. /** Draws a vertical line of pixels at a given x position.
  293. The x position is an integer, but the top and bottom of the line can be sub-pixel
  294. positions, and these will be anti-aliased if necessary.
  295. The bottom parameter must be greater than or equal to the top parameter.
  296. */
  297. void drawVerticalLine (int x, float top, float bottom) const;
  298. /** Draws a horizontal line of pixels at a given y position.
  299. The y position is an integer, but the left and right ends of the line can be sub-pixel
  300. positions, and these will be anti-aliased if necessary.
  301. The right parameter must be greater than or equal to the left parameter.
  302. */
  303. void drawHorizontalLine (int y, float left, float right) const;
  304. //==============================================================================
  305. /** Fills a path using the currently selected colour or brush.
  306. */
  307. void fillPath (const Path& path,
  308. const AffineTransform& transform = AffineTransform::identity) const;
  309. /** Draws a path's outline using the currently selected colour or brush.
  310. */
  311. void strokePath (const Path& path,
  312. const PathStrokeType& strokeType,
  313. const AffineTransform& transform = AffineTransform::identity) const;
  314. /** Draws a line with an arrowhead at its end.
  315. @param line the line to draw
  316. @param lineThickness the thickness of the line
  317. @param arrowheadWidth the width of the arrow head (perpendicular to the line)
  318. @param arrowheadLength the length of the arrow head (along the length of the line)
  319. */
  320. void drawArrow (const Line<float>& line,
  321. float lineThickness,
  322. float arrowheadWidth,
  323. float arrowheadLength) const;
  324. //==============================================================================
  325. /** Types of rendering quality that can be specified when drawing images.
  326. @see blendImage, Graphics::setImageResamplingQuality
  327. */
  328. enum ResamplingQuality
  329. {
  330. lowResamplingQuality = 0, /**< Just uses a nearest-neighbour algorithm for resampling. */
  331. mediumResamplingQuality = 1, /**< Uses bilinear interpolation for upsampling and area-averaging for downsampling. */
  332. highResamplingQuality = 2 /**< Uses bicubic interpolation for upsampling and area-averaging for downsampling. */
  333. };
  334. /** Changes the quality that will be used when resampling images.
  335. By default a Graphics object will be set to mediumRenderingQuality.
  336. @see Graphics::drawImage, Graphics::drawImageTransformed, Graphics::drawImageWithin
  337. */
  338. void setImageResamplingQuality (const ResamplingQuality newQuality);
  339. /** Draws an image.
  340. This will draw the whole of an image, positioning its top-left corner at the
  341. given co-ordinates, and keeping its size the same. This is the simplest image
  342. drawing method - the others give more control over the scaling and clipping
  343. of the images.
  344. Images are composited using the context's current opacity, so if you
  345. don't want it to be drawn semi-transparently, be sure to call setOpacity (1.0f)
  346. (or setColour() with an opaque colour) before drawing images.
  347. */
  348. void drawImageAt (const Image& imageToDraw, int topLeftX, int topLeftY,
  349. bool fillAlphaChannelWithCurrentBrush = false) const;
  350. /** Draws part of an image, rescaling it to fit in a given target region.
  351. The specified area of the source image is rescaled and drawn to fill the
  352. specifed destination rectangle.
  353. Images are composited using the context's current opacity, so if you
  354. don't want it to be drawn semi-transparently, be sure to call setOpacity (1.0f)
  355. (or setColour() with an opaque colour) before drawing images.
  356. @param imageToDraw the image to overlay
  357. @param destX the left of the destination rectangle
  358. @param destY the top of the destination rectangle
  359. @param destWidth the width of the destination rectangle
  360. @param destHeight the height of the destination rectangle
  361. @param sourceX the left of the rectangle to copy from the source image
  362. @param sourceY the top of the rectangle to copy from the source image
  363. @param sourceWidth the width of the rectangle to copy from the source image
  364. @param sourceHeight the height of the rectangle to copy from the source image
  365. @param fillAlphaChannelWithCurrentBrush if true, then instead of drawing the source image's pixels,
  366. the source image's alpha channel is used as a mask with
  367. which to fill the destination using the current colour
  368. or brush. (If the source is has no alpha channel, then
  369. it will just fill the target with a solid rectangle)
  370. @see setImageResamplingQuality, drawImageAt, drawImageWithin, fillAlphaMap
  371. */
  372. void drawImage (const Image& imageToDraw,
  373. int destX, int destY, int destWidth, int destHeight,
  374. int sourceX, int sourceY, int sourceWidth, int sourceHeight,
  375. bool fillAlphaChannelWithCurrentBrush = false) const;
  376. /** Draws an image, having applied an affine transform to it.
  377. This lets you throw the image around in some wacky ways, rotate it, shear,
  378. scale it, etc.
  379. Images are composited using the context's current opacity, so if you
  380. don't want it to be drawn semi-transparently, be sure to call setOpacity (1.0f)
  381. (or setColour() with an opaque colour) before drawing images.
  382. If fillAlphaChannelWithCurrentBrush is set to true, then the image's RGB channels
  383. are ignored and it is filled with the current brush, masked by its alpha channel.
  384. If you want to render only a subsection of an image, use Image::getClippedImage() to
  385. create the section that you need.
  386. @see setImageResamplingQuality, drawImage
  387. */
  388. void drawImageTransformed (const Image& imageToDraw,
  389. const AffineTransform& transform,
  390. bool fillAlphaChannelWithCurrentBrush = false) const;
  391. /** Draws an image to fit within a designated rectangle.
  392. If the image is too big or too small for the space, it will be rescaled
  393. to fit as nicely as it can do without affecting its aspect ratio. It will
  394. then be placed within the target rectangle according to the justification flags
  395. specified.
  396. @param imageToDraw the source image to draw
  397. @param destX top-left of the target rectangle to fit it into
  398. @param destY top-left of the target rectangle to fit it into
  399. @param destWidth size of the target rectangle to fit the image into
  400. @param destHeight size of the target rectangle to fit the image into
  401. @param placementWithinTarget this specifies how the image should be positioned
  402. within the target rectangle - see the RectanglePlacement
  403. class for more details about this.
  404. @param fillAlphaChannelWithCurrentBrush if true, then instead of drawing the image, just its
  405. alpha channel will be used as a mask with which to
  406. draw with the current brush or colour. This is
  407. similar to fillAlphaMap(), and see also drawImage()
  408. @see setImageResamplingQuality, drawImage, drawImageTransformed, drawImageAt, RectanglePlacement
  409. */
  410. void drawImageWithin (const Image& imageToDraw,
  411. int destX, int destY, int destWidth, int destHeight,
  412. const RectanglePlacement& placementWithinTarget,
  413. bool fillAlphaChannelWithCurrentBrush = false) const;
  414. //==============================================================================
  415. /** Returns the position of the bounding box for the current clipping region.
  416. @see getClipRegion, clipRegionIntersects
  417. */
  418. Rectangle<int> getClipBounds() const;
  419. /** Checks whether a rectangle overlaps the context's clipping region.
  420. If this returns false, no part of the given area can be drawn onto, so this
  421. method can be used to optimise a component's paint() method, by letting it
  422. avoid drawing complex objects that aren't within the region being repainted.
  423. */
  424. bool clipRegionIntersects (const Rectangle<int>& area) const;
  425. /** Intersects the current clipping region with another region.
  426. @returns true if the resulting clipping region is non-zero in size
  427. @see setOrigin, clipRegionIntersects
  428. */
  429. bool reduceClipRegion (int x, int y, int width, int height);
  430. /** Intersects the current clipping region with another region.
  431. @returns true if the resulting clipping region is non-zero in size
  432. @see setOrigin, clipRegionIntersects
  433. */
  434. bool reduceClipRegion (const Rectangle<int>& area);
  435. /** Intersects the current clipping region with a rectangle list region.
  436. @returns true if the resulting clipping region is non-zero in size
  437. @see setOrigin, clipRegionIntersects
  438. */
  439. bool reduceClipRegion (const RectangleList& clipRegion);
  440. /** Intersects the current clipping region with a path.
  441. @returns true if the resulting clipping region is non-zero in size
  442. @see reduceClipRegion
  443. */
  444. bool reduceClipRegion (const Path& path, const AffineTransform& transform = AffineTransform::identity);
  445. /** Intersects the current clipping region with an image's alpha-channel.
  446. The current clipping path is intersected with the area covered by this image's
  447. alpha-channel, after the image has been transformed by the specified matrix.
  448. @param image the image whose alpha-channel should be used. If the image doesn't
  449. have an alpha-channel, it is treated as entirely opaque.
  450. @param transform a matrix to apply to the image
  451. @returns true if the resulting clipping region is non-zero in size
  452. @see reduceClipRegion
  453. */
  454. bool reduceClipRegion (const Image& image, const AffineTransform& transform);
  455. /** Excludes a rectangle to stop it being drawn into. */
  456. void excludeClipRegion (const Rectangle<int>& rectangleToExclude);
  457. /** Returns true if no drawing can be done because the clip region is zero. */
  458. bool isClipEmpty() const;
  459. //==============================================================================
  460. /** Saves the current graphics state on an internal stack.
  461. To restore the state, use restoreState().
  462. @see ScopedSaveState
  463. */
  464. void saveState();
  465. /** Restores a graphics state that was previously saved with saveState().
  466. @see ScopedSaveState
  467. */
  468. void restoreState();
  469. /** Uses RAII to save and restore the state of a graphics context.
  470. On construction, this calls Graphics::saveState(), and on destruction it calls
  471. Graphics::restoreState() on the Graphics object that you supply.
  472. */
  473. class ScopedSaveState
  474. {
  475. public:
  476. ScopedSaveState (Graphics& g);
  477. ~ScopedSaveState();
  478. private:
  479. Graphics& context;
  480. JUCE_DECLARE_NON_COPYABLE (ScopedSaveState);
  481. };
  482. //==============================================================================
  483. /** Begins rendering to an off-screen bitmap which will later be flattened onto the current
  484. context with the given opacity.
  485. The context uses an internal stack of temporary image layers to do this. When you've
  486. finished drawing to the layer, call endTransparencyLayer() to complete the operation and
  487. composite the finished layer. Every call to beginTransparencyLayer() MUST be matched
  488. by a corresponding call to endTransparencyLayer()!
  489. This call also saves the current state, and endTransparencyLayer() restores it.
  490. */
  491. void beginTransparencyLayer (float layerOpacity);
  492. /** Completes a drawing operation to a temporary semi-transparent buffer.
  493. See beginTransparencyLayer() for more details.
  494. */
  495. void endTransparencyLayer();
  496. /** Moves the position of the context's origin.
  497. This changes the position that the context considers to be (0, 0) to
  498. the specified position.
  499. So if you call setOrigin (100, 100), then the position that was previously
  500. referred to as (100, 100) will subsequently be considered to be (0, 0).
  501. @see reduceClipRegion, addTransform
  502. */
  503. void setOrigin (int newOriginX, int newOriginY);
  504. /** Adds a transformation which will be performed on all the graphics operations that
  505. the context subsequently performs.
  506. After calling this, all the coordinates that are passed into the context will be
  507. transformed by this matrix.
  508. @see setOrigin
  509. */
  510. void addTransform (const AffineTransform& transform);
  511. /** Resets the current colour, brush, and font to default settings. */
  512. void resetToDefaultState();
  513. /** Returns true if this context is drawing to a vector-based device, such as a printer. */
  514. bool isVectorDevice() const;
  515. //==============================================================================
  516. /** Create a graphics that uses a given low-level renderer.
  517. For internal use only.
  518. NB. The context will NOT be deleted by this object when it is deleted.
  519. */
  520. Graphics (LowLevelGraphicsContext* internalContext) noexcept;
  521. /** @internal */
  522. LowLevelGraphicsContext* getInternalContext() const noexcept { return context; }
  523. private:
  524. //==============================================================================
  525. LowLevelGraphicsContext* const context;
  526. ScopedPointer <LowLevelGraphicsContext> contextToDelete;
  527. bool saveStatePending;
  528. void saveStateIfPending();
  529. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Graphics);
  530. };
  531. #endif // __JUCE_GRAPHICSCONTEXT_JUCEHEADER__