1 /**
2  * File name: RkPainter.h
3  * Project: Redkite (A small GUI toolkit)
4  *
5  * Copyright (C) 2019 Iurie Nistor <http://geontime.com>
6  *
7  * This file is part of Redkite.
8  *
9  * Redkite is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  */
23 
24 #ifndef RK_PAINTER_H
25 #define RK_PAINTER_H
26 
27 #include "Rk.h"
28 #include "RkImage.h"
29 #include "RkPoint.h"
30 #include "RkPen.h"
31 #include "RkRect.h"
32 #include "RkFont.h"
33 
34 class RkCanvas;
35 
36 class RK_EXPORT RkPainter {
37  public:
38         RkPainter(RkCanvas *canvas);
39         ~RkPainter();
40         void drawText(int x, int y, const std::string &text);
41         void drawText(const RkPoint &p,  const std::string &text);
42         void drawText(const RkRect &rect,
43                       const std::string &text,
44                       Rk::Alignment alignment = Rk::Alignment::AlignCenter);
45         void drawImage(const RkImage &image, int x, int y);
46         void drawCircle(int x, int y, int radius);
47         void drawCircle(const RkPoint &p, int radius);
48         void drawLine(int x1, int y1, int x2, int y2);
49         void drawLine(const RkPoint &p1, const RkPoint &p2);
50         void drawRect(const RkRect &rect);
51         void drawPolyline(const std::vector<RkPoint> &points);
52         void fillRect(const RkRect &rect, const RkColor &color);
53         void applyAlpha(int alpha);
54         const RkPen& pen() const;
55         void setPen(const RkPen &pen);
56         const RkFont& font() const;
57         void setFont(const RkFont &font);
58         void translate(const RkPoint &offset);
59         void rotate(rk_real angle);
60         int getTextWidth(const std::string &text) const;
61 
62  private:
63         RK_DISABLE_COPY(RkPainter);
64         RK_DISABLE_MOVE(RkPainter);
65         RK_DECLARE_IMPL(RkPainter);
66 };
67 
68 #endif // RK_PAINTER_H
69