OSDN Git Service

Show Ignore Sub Menu
[tortoisegit/TortoiseGitJp.git] / Utils / MiscUI / Gradient.h
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2007 - TortoiseSVN\r
4 \r
5 // This program is free software; you can redistribute it and/or\r
6 // modify it under the terms of the GNU General Public License\r
7 // as published by the Free Software Foundation; either version 2\r
8 // of the License, or (at your option) any later version.\r
9 \r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 \r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, write to the Free Software Foundation,\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 //\r
19 #pragma once\r
20 \r
21 \r
22 /**\r
23  * \ingroup Utils\r
24  * Class for drawing gradients.\r
25  * There are two methods for each gradient. One using standard API function and the other using GDI.\r
26  * Since not all systems (e.g. WinCE and the like) don't have GDI you must define USE_GDI_GRADIENT to\r
27  * use those.\r
28  */\r
29 class CGradient\r
30 {\r
31 public:\r
32         CGradient(void);\r
33         ~CGradient(void);\r
34 \r
35         /**\r
36          * Fills a rectangle with a two color gradient.\r
37          * \param pDC the device context to draw on\r
38          * \param rect the rectangle to fill\r
39          * \param colorStart the starting color. This is either the color used on the left (if bHorz == TRUE) or top\r
40          * \param colorEnd the ending color. This is either the color used on the right (if bHorz == TRUE) or bottom\r
41          * \param bHorz if TRUE then the gradient is drawn from left to right, otherwise from top to bottom\r
42          * \param nSteps the steps the gradient shall have. The more the smoother the gradient will be but also slower.\r
43          */\r
44         static void Draw(CDC * pDC, CRect rect, COLORREF colorStart, COLORREF colorEnd, BOOL bHorz = TRUE, UINT nSteps = 64);\r
45         /**\r
46          * Fills a rectangle with a three color gradient.\r
47          * \param pDC the device context to draw on\r
48          * \param rect the rectangle to fill\r
49          * \param colorStart the starting color. This is either the color used on the left (if bHorz == TRUE) or top\r
50          * \param colorMid the middle color.\r
51          * \param colorEnd the ending color. This is either the color used on the right (if bHorz == TRUE) or bottom\r
52          * \param bHorz if TRUE then the gradient is drawn from left to right, otherwise from top to bottom\r
53          * \param nSteps the steps the gradient shall have. The more the smoother the gradient will be but also slower.\r
54          */\r
55         static void Draw(CDC * pDC, CRect rect, COLORREF colorStart, COLORREF colorMid, COLORREF colorFinish, BOOL bHorz = TRUE, UINT nSteps = 64);\r
56 #ifdef USE_GDI_GRADIENT\r
57         /**\r
58          * Fills a rectangle with a two color gradient.\r
59          * \param pDC the device context to draw on\r
60          * \param rect the rectangle to fill\r
61          * \param colorStart the starting color. This is either the color used on the left (if bHorz == TRUE) or top\r
62          * \param colorEnd the ending color. This is either the color used on the right (if bHorz == TRUE) or bottom\r
63          * \param bHorz if TRUE then the gradient is drawn from left to right, otherwise from top to bottom\r
64          */\r
65         static void DrawGDI(CDC * pDC, CRect rect, COLORREF colorStart, COLORREF colorEnd, BOOL bHorz = TRUE);\r
66         /**\r
67          * Fills a rectangle with a three color gradient.\r
68          * \param pDC the device context to draw on\r
69          * \param rect the rectangle to fill\r
70          * \param colorStart the starting color. This is either the color used on the left (if bHorz == TRUE) or top\r
71          * \param colorMid the middle color.\r
72          * \param colorEnd the ending color. This is either the color used on the right (if bHorz == TRUE) or bottom\r
73          * \param bHorz if TRUE then the gradient is drawn from left to right, otherwise from top to bottom\r
74          */\r
75         static void DrawGDI(CDC * pDC, CRect rect, COLORREF colorStart, COLORREF colorMid, COLORREF colorEnd, BOOL bHorz = TRUE);\r
76 #endif\r
77 private:\r
78         static void SplitRect(const CRect& rSource, CRect& rHalf1, CRect& rHalf2, BOOL bHorz);\r
79 };\r