Sync translations with Transifex
[TortoiseGit.git] / src / Utils / MiscUI / SVG.h
blob64cb3b80d9dd125873bb49dbdac00b61dc5d501d
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2010, 2014 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #pragma once
20 #include <GdiPlus.h>
21 #include <vector>
23 /**
24 * Class to create an svg file.
25 * Provides method to add svg primitives like lines, rectangles, text.
27 * \remark this class is specifically tailored to the TSVN revision graph.
28 * That's why the color params are Gdiplus::Color and not simple COLORREFs,
29 * and also the styles and attributes of the used primitives are set
30 * the way it's required for the revision graph.
32 class SVG
34 public:
35 SVG();
36 virtual ~SVG();
38 bool Save(const CString& path);
39 enum align {left, middle, right};
41 void StartGroup() { objects.push_back("<g>"); }
42 void EndGroup() { objects.push_back("</g>"); }
43 void SetViewSize(int w, int h) { viewportWidth = w; viewportHeight = h; }
44 void RoundedRectangle(int x, int y, int width, int height, Gdiplus::Color stroke, int penWidth, Gdiplus::Color fill, int radius = 0, int mode = 0x3);
45 void Polygon(const Gdiplus::PointF * points, int numPoints, Gdiplus::Color stroke, int penWidth, Gdiplus::Color fill);
46 void DrawPath(const Gdiplus::PointF * points, int numPoints, Gdiplus::Color stroke, int penWidth, Gdiplus::Color fill);
47 void Polyline(const Gdiplus::PointF * points, int numPoints, Gdiplus::Color stroke, int penWidth);
48 void GradientRectangle(int x, int y, int width, int height, Gdiplus::Color topColor, Gdiplus::Color bottomColor, Gdiplus::Color stroke);
49 void PolyBezier(const POINT * points, int numPoints, Gdiplus::Color stroke);
50 void Ellipse(int x, int y, int width, int height, Gdiplus::Color stroke, int penWidth, Gdiplus::Color fill);
51 void Text(int x, int y, LPCSTR font, int fontsize, bool italic, bool bold, Gdiplus::Color color, LPCSTR text, int al=SVG::left);
52 private:
53 DWORD GetColor(Gdiplus::Color c) const;
55 std::vector<CStringA> objects;
56 int viewportWidth;
57 int viewportHeight;