Allow to put URLs into "<>" and allow spaces and other chars there (as the RichEdit...
[TortoiseGit.git] / src / Utils / MiscUI / Gradient.h
blob10618a3c4040425674e2d11a8a972199a632a4a6
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2007, 2013 - 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
22 /**
23 * \ingroup Utils
24 * Class for drawing gradients.
25 * There are two methods for each gradient. One using standard API function and the other using GDI.
26 * Since not all systems (e.g. WinCE and the like) don't have GDI you must define USE_GDI_GRADIENT to
27 * use those.
29 class CGradient
31 public:
32 CGradient(void);
33 ~CGradient(void);
35 /**
36 * Fills a rectangle with a two color gradient.
37 * \param pDC the device context to draw on
38 * \param rect the rectangle to fill
39 * \param colorStart the starting color. This is either the color used on the left (if bHorz == TRUE) or top
40 * \param colorEnd the ending color. This is either the color used on the right (if bHorz == TRUE) or bottom
41 * \param bHorz if TRUE then the gradient is drawn from left to right, otherwise from top to bottom
42 * \param nSteps the steps the gradient shall have. The more the smoother the gradient will be but also slower.
44 static void Draw(CDC * pDC, CRect rect, COLORREF colorStart, COLORREF colorEnd, BOOL bHorz = TRUE, UINT nSteps = 64);
45 /**
46 * Fills a rectangle with a three color gradient.
47 * \param pDC the device context to draw on
48 * \param rect the rectangle to fill
49 * \param colorStart the starting color. This is either the color used on the left (if bHorz == TRUE) or top
50 * \param colorMid the middle color.
51 * \param colorFinish the ending color. This is either the color used on the right (if bHorz == TRUE) or bottom
52 * \param bHorz if TRUE then the gradient is drawn from left to right, otherwise from top to bottom
53 * \param nSteps the steps the gradient shall have. The more the smoother the gradient will be but also slower.
55 static void Draw(CDC * pDC, CRect rect, COLORREF colorStart, COLORREF colorMid, COLORREF colorFinish, BOOL bHorz = TRUE, UINT nSteps = 64);
56 #ifdef USE_GDI_GRADIENT
57 /**
58 * Fills a rectangle with a two color gradient.
59 * \param pDC the device context to draw on
60 * \param rect the rectangle to fill
61 * \param colorStart the starting color. This is either the color used on the left (if bHorz == TRUE) or top
62 * \param colorEnd the ending color. This is either the color used on the right (if bHorz == TRUE) or bottom
63 * \param bHorz if TRUE then the gradient is drawn from left to right, otherwise from top to bottom
65 static void DrawGDI(CDC * pDC, CRect rect, COLORREF colorStart, COLORREF colorEnd, BOOL bHorz = TRUE);
66 /**
67 * Fills a rectangle with a three color gradient.
68 * \param pDC the device context to draw on
69 * \param rect the rectangle to fill
70 * \param colorStart the starting color. This is either the color used on the left (if bHorz == TRUE) or top
71 * \param colorMid the middle color.
72 * \param colorEnd the ending color. This is either the color used on the right (if bHorz == TRUE) or bottom
73 * \param bHorz if TRUE then the gradient is drawn from left to right, otherwise from top to bottom
75 static void DrawGDI(CDC * pDC, CRect rect, COLORREF colorStart, COLORREF colorMid, COLORREF colorEnd, BOOL bHorz = TRUE);
76 #endif
77 private:
78 static void SplitRect(const CRect& rSource, CRect& rHalf1, CRect& rHalf2, BOOL bHorz);