ImagePainter2.h
1 /* Copyright (C) 2017-2017 Aloysius Indrayanto
2  Copyright (C) 2006-2017 Marc Boris Duerner
3  Copyright (C) 2006-2015 Laurentiu-Gheorghe Crisan
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, MA
28  02110-1301 USA
29 */
30 
31 #ifndef PT_GFX_IMAGEPAINTER_2_H
32 #define PT_GFX_IMAGEPAINTER_2_H
33 
34 #include <Pt/Gfx/Painter.h>
35 #include <Pt/Gfx/Transform.h>
36 #include <Pt/Gfx/Path.h>
37 #include <Pt/System/Path.h>
38 
39 namespace Pt {
40 
41 namespace Gfx {
42 
43 class Rasterizer2;
44 
45 class PT_GFX_API ImagePainter2 : public Painter
46 {
47  public:
48  ImagePainter2(Image& image);
49 
50  virtual ~ImagePainter2();
51 
52  void setImage(Image& image);
53 
54  virtual const ImageFormat& format() const;
55 
56  virtual bool isAntiAliasing() const;
57 
58  virtual void setAntiAliasing(bool on);
59 
60  virtual const CompositionMode& compositionMode() const;
61 
62  virtual void setCompositionMode(const CompositionMode& mode);
63 
64  virtual void setClip(const RectF& clip);
65 
66  virtual const Pen& pen() const;
67 
68  virtual void setPen(const Pen& pen);
69 
70  virtual const Brush& brush() const;
71 
72  virtual void setBrush(const Brush& brush);
73 
74  virtual const Font& font() const;
75 
76  virtual void setFont(const Font& font);
77 
78  virtual void drawImage(const PointF& to, const Image& image);
79 
80  virtual void drawImage(const PointF& to, const Image& image, const RectF& imageRect);
81 
82  virtual void drawText(const PointF& to, const Pt::String& text);
83 
84  void drawText(const PointF& to, const Pt::String& text, const Transform& t);
85 
86  virtual FontMetrics fontMetrics(const Pt::String& text) const;
87 
88  static FontMetrics fontMetrics(const Font& font, const Pt::String& text);
89 
90  virtual void drawLine(const PointF& from, const PointF& to);
91 
92  virtual void drawRect(const RectF& rect);
93 
94  virtual void drawRoundedRect(const RectF& rect, float radius);
95 
96  // NOTE: The points must move in counter-clockwise (CCW) direction or something wrong may be drawn!
97  virtual void drawPolyline(const PointF* points, const size_t pointCount);
98 
99  // NOTE: The begin and end angle must move in counter-clockwise (CCW) direction or something wrong may be drawn!
100  virtual void drawArc(const PointF& topLeft, const SizeF& size,
101  float degBegin, float degEnd);
102 
103  // NOTE: The begin and end angle must move in counter-clockwise (CCW) direction or something wrong may be drawn!
104  virtual void drawChord(const PointF& topLeft, const SizeF& size,
105  float degBegin, float degEnd);
106 
107  // NOTE: The begin and end angle must move in counter-clockwise (CCW) direction or something wrong may be drawn!
108  virtual void drawPie(const PointF& topLeft, const SizeF& size,
109  float degBegin, float degEnd);
110 
111  virtual void drawEllipse(const PointF& topLeft, const SizeF& size);
112 
113  // maybe better have ImagePainter::setSmoothness
114  virtual void drawPath(const Path& path, float smoothness = 1.0f);
115 
116  virtual void fillRect(const RectF& rect);
117 
118  virtual void fillRoundedRect(const RectF& rect, float radius);
119 
120  virtual void fillPolygon(const PointF* points, const size_t pointCount);
121 
122  virtual void fillEllipse(const PointF& topLeft, const SizeF& size);
123 
124  virtual void fillPie(const PointF& topLeft, const SizeF& size,
125  float degBegin, float degEnd);
126 
127  virtual void fillChord(const PointF& topLeft, const SizeF& size,
128  float degBegin, float degEnd);
129 
130  // maybe better have a separate ImagePainter::setSmoothness
131  virtual void fillPath(const Path& path, float smoothness = 1.0f);
132 
133  public:
134  static void setFontDir(const System::Path& path);
135 
136  static void setDefaultFont(const std::string& name);
137 
138  static std::string defaultFont();
139 
140  static std::vector<std::string> fontNames();
141 
142  private:
143  // USUSED
144  //void clipPolygonXXX(std::vector<PointF>& result,
145  // const std::vector<PointF>& subject,
146  // const std::vector<PointF>& clipRegion);
147 
148  private:
149  Rasterizer2* _rasterizer;
150 };
151 
152 } // namespace
153 
154 } // namespace
155 
156 #endif
Unicode capable basic_string.
Definition: String.h:42