Painter.h
1 /* Copyright (C) 2006-2015 Laurentiu-Gheorghe Crisan
2  Copyright (C) 2006-2015 Marc Boris Duerner
3  Copyright (C) 2010-2017 Aloysius Indrayanto
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  As a special exception, you may use this file as part of a free
11  software library without restriction. Specifically, if other files
12  instantiate templates or use macros or inline functions from this
13  file, or you compile this file and link it with other files to
14  produce an executable, this file does not by itself cause the
15  resulting executable to be covered by the GNU General Public
16  License. This exception does not however invalidate any other
17  reasons why the executable file might be covered by the GNU Library
18  General Public License.
19 
20  This library is distributed in the hope that it will be useful,
21  but WITHOUT ANY WARRANTY; without even the implied warranty of
22  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23  Lesser General Public License for more details.
24 
25  You should have received a copy of the GNU Lesser General Public
26  License along with this library; if not, write to the Free Software
27  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
28  MA 02110-1301 USA
29 */
30 
31 #ifndef PT_GFX_PAINTER_H
32 #define PT_GFX_PAINTER_H
33 
34 #include <Pt/Gfx/Api.h>
35 #include <Pt/Gfx/Size.h>
36 #include <Pt/Gfx/Point.h>
37 #include <Pt/Gfx/Rect.h>
38 #include <Pt/Gfx/Font.h>
39 #include <Pt/Gfx/FontMetrics.h>
40 #include <Pt/Gfx/Pen.h>
41 #include <Pt/Gfx/Brush.h>
42 #include <Pt/Gfx/Transform.h>
43 #include <Pt/String.h>
44 #include <Pt/Types.h>
45 #include <cstddef>
46 
47 namespace Pt {
48 
49 namespace Gfx {
50 
53 class PT_GFX_API Painter
54 {
55  public:
57  virtual ~Painter()
58  {}
59 
62  virtual const ImageFormat& format() const = 0;
63 
66  virtual void setCompositionMode(const CompositionMode& mode) = 0;
67 
70  virtual const CompositionMode& compositionMode() const = 0;
71 
74  virtual void setClip(const RectF& clip) = 0;
75 
78  virtual void setPen(const Pen& pen) = 0;
79 
82  virtual const Pen& pen() const = 0;
83 
86  virtual void setBrush(const Brush& brush) = 0;
87 
90  virtual const Brush& brush() const = 0;
91 
94  virtual void setFont(const Font& font) = 0;
95 
98  virtual const Font& font() const = 0;
99 
102  virtual FontMetrics fontMetrics(const Pt::String& text) const = 0;
103 
106  virtual void drawLine(const PointF& from, const PointF& to) = 0;
107 
110  virtual void drawPolyline(const PointF* points, const size_t pointCount) = 0;
111 
114  virtual void fillPolygon(const PointF* points, const size_t pointCount) = 0;
115 
118  virtual void drawText(const PointF& to, const Pt::String& text) = 0;
119 
122  virtual void drawRect(const RectF& rect) = 0;
123 
126  virtual void fillRect(const RectF& rect) = 0;
127 
130  void drawCircle(const PointF& topLeft, std::size_t diameter)
131  {
132  drawEllipse(topLeft, SizeF(diameter, diameter));
133  }
134 
137  inline void fillCircle(const PointF& topLeft, std::size_t diameter)
138  {
139  fillEllipse(topLeft, SizeF(diameter, diameter));
140  }
141 
144  virtual void drawEllipse(const PointF& topLeft, const SizeF& size) = 0;
145 
148  virtual void fillEllipse(const PointF& topLeft, const SizeF& size) = 0;
149 
152  virtual void drawImage(const PointF& to, const Image& im) = 0;
153 
156  virtual void drawImage(const PointF& to, const Image& im, const RectF& rect) = 0;
157 };
158 
159 } // namespace
160 
161 } // namespace
162 
163 #endif
virtual ~Painter()
Destructor.
Definition: Painter.h:57
void drawCircle(const PointF &topLeft, std::size_t diameter)
Draws the outline of a circle.
Definition: Painter.h:130
Attributs for the drawing of outlines.
Definition: Pen.h:52
Unicode capable basic_string.
Definition: String.h:42
Image format.
Definition: ImageFormat.h:49
void fillCircle(const PointF &topLeft, std::size_t diameter)
Fills a circular area.
Definition: Painter.h:137
2D painter interface.
Definition: Painter.h:53
Generic image.
Definition: Image.h:43