OSDN Git Service

Show Ignore Sub Menu
[tortoisegit/TortoiseGitJp.git] / src / Utils / TreePropSheet / PropPageFrame.h
1 /********************************************************************\r
2 *\r
3 * Copyright (c) 2002 Sven Wiegand <mail@sven-wiegand.de>\r
4 *\r
5 * You can use this and modify this in any way you want,\r
6 * BUT LEAVE THIS HEADER INTACT.\r
7 *\r
8 * Redistribution is appreciated.\r
9 *\r
10 * $Workfile:$\r
11 * $Revision:$\r
12 * $Modtime:$\r
13 * $Author:$\r
14 *\r
15 * Revision History:\r
16 *       $History:$\r
17 *\r
18 *********************************************************************/\r
19 \r
20 \r
21 #if !defined(AFX_PROPPAGEFRAME_H__B968548B_F0B4_4C35_85DD_C44242A9D368__INCLUDED_)\r
22 #define AFX_PROPPAGEFRAME_H__B968548B_F0B4_4C35_85DD_C44242A9D368__INCLUDED_\r
23 \r
24 #if _MSC_VER > 1000\r
25 #pragma once\r
26 #endif // _MSC_VER > 1000\r
27 \r
28 \r
29 namespace TreePropSheet\r
30 {\r
31 \r
32 \r
33 /**\r
34 An object of an CPropertyPageFrame-derived class is used by \r
35 CTreePropSheet to display a frame for the property pages.\r
36 \r
37 Derived classes have to implement at least the Create() and the \r
38 GetWnd() method, which\r
39 returns a pointer to the CWnd-obect of the window, that has been\r
40 created by the call to the Create() method. An implementation can\r
41 provide the CWnd-object by using it as a property or by deriving\r
42 from CWnd or a more specialiced class. This way has been choosen \r
43 instead of deriving CPropPageFrame from CWnd, to allow derived class\r
44 to derive from more specialized classes than CWnd \r
45 (i.e. CStatic, etc.). From the WM_PAINT-handler of your derived class\r
46 you have to call the Draw()-method.\r
47 \r
48 Most implementations will also implement the DrawCaption() and \r
49 DrawMsg() methods, to provide custom drawing functionality.\r
50 \r
51 @author Sven Wiegand\r
52 */\r
53 class /*AFX_EXT_CLASS*/ CPropPageFrame\r
54 {\r
55 // Construction/Destruction\r
56 public:\r
57         CPropPageFrame();\r
58         virtual ~CPropPageFrame();\r
59 \r
60 // Operations\r
61 public:\r
62         /**\r
63         Has to create a window with the specified properties.\r
64 \r
65         @param dwWindowStyle\r
66                 Standard window styles, to apply to the window to create.\r
67         @param rect\r
68                 Position and size of the window to create.\r
69         @param pwndParent\r
70                 Parent window. (Never be NULL).\r
71         @param nID\r
72                 Window id.\r
73 \r
74         @return\r
75                 TRUE on success, FALSE otherwise.\r
76         */\r
77         virtual BOOL Create(DWORD dwWindowStyle, const RECT &rect, CWnd *pwndParent, UINT nID) = 0;\r
78 \r
79         /**\r
80         Returns a pointer to the window object, that represents the frame.\r
81         */\r
82         virtual CWnd* GetWnd() = 0;\r
83 \r
84         /**\r
85         Enables or disables page caption.\r
86 \r
87         This default implementation calls the SafeUpdateWindow() method\r
88         with the caption rectangle, to force it to be redrawn.\r
89         */\r
90         virtual void ShowCaption(BOOL bEnable);\r
91 \r
92         /**\r
93         Returns TRUE if captions are enabled, FALSE otherwise.\r
94         */\r
95         BOOL GetShowCaption() const;\r
96 \r
97         /**\r
98         Sets the height of the caption in pixels. This value is ignored \r
99         until the caption is enabled by ShowCaption(TRUE).\r
100 \r
101         This default implementation calls the SafeUpdateWindow() method\r
102         with the caption rectangle, to force it to be redrawn.\r
103         */\r
104         virtual void SetCaptionHeight(int nCaptionHeight);\r
105 \r
106         /**\r
107         Returns the caption height, that has been most recently set by a\r
108         call to the SetCaptionHeight() method.\r
109         */\r
110         int GetCaptionHeight() const;\r
111 \r
112         /**\r
113         Sets caption text an icon.\r
114 \r
115         This default implementation calls the SafeUpdateWindow() method\r
116         with the caption rectangle, to force it to be redrawn.\r
117 \r
118         @param lpszCaption\r
119                 Text to display for the caption.\r
120         @param hIcon\r
121                 Icon to display for the caption.\r
122         */\r
123         virtual void SetCaption(LPCTSTR lpszCaption, HICON hIcon = NULL);\r
124 \r
125         /**\r
126         Returns the caption, that has been set most recently using the\r
127         SetCaption() method.\r
128 \r
129         @param pIcon\r
130                 Pointer to a HICON variable, that should receive the handle of\r
131                 the currently set icon or NULL, if there is no icon or a NULL\r
132                 pointer, if the caller is not interested in the icon.\r
133 \r
134         @return\r
135                 The text that has been set most recently using the SetCaption()\r
136                 method.\r
137         */\r
138         CString GetCaption(HICON *pIcon = NULL) const;\r
139 \r
140         /**\r
141         Sets the text to display.\r
142 \r
143         This default implementation calls the SafeUpdateWindow() method\r
144         with the message rectangle, to force it to be redrawn.\r
145         */\r
146         virtual void SetMsgText(LPCTSTR lpszMsg);\r
147 \r
148         /**\r
149         Returns the text currently displayed.\r
150         */\r
151         CString GetMsgText() const;\r
152 \r
153         /**\r
154         Specifies the format to draw the text with, set by SetMsgText().\r
155 \r
156         This default implementation calls the SafeUpdateWindow() method\r
157         with the message rectangle, to force it to be redrawn.\r
158 \r
159         @param dwFormat\r
160                 Combination of the DT_* flags, specified by the Win32 function\r
161                 DrawText().\r
162         */\r
163         virtual void SetMsgFormat(DWORD dwFormat);\r
164 \r
165         /**\r
166         Returns the format to draw the text with, set by SetMsgText().\r
167 \r
168         @see SetMsgFormat()\r
169         */\r
170         DWORD GetMsgFormat() const;\r
171 \r
172 // Overridable implementation helpers\r
173 protected:\r
174         /**\r
175         Draws the whole frame including caption (if enabled) and message.\r
176 \r
177         This method calculates the rectangles for the message area and\r
178         the caption area using the CalcMsgArea() and the CalcCaptionArea()\r
179         methods, draws then the caption calling the DrawCaption() method\r
180         (only if caption is enabled) and afterwards the message calling\r
181         the DrawMsg() method.\r
182 \r
183         You should call this method from the WM_PAINT-handler of your\r
184         derived class.\r
185 \r
186         @param pDc\r
187                 Device context to draw in.\r
188         */\r
189         virtual void Draw(CDC *pDc);\r
190 \r
191         /**\r
192         Calculates the area, the message, set by SetMsgText() should be\r
193         displayed in. The returned rectangle (client coordinates) will be\r
194         passed to DrawMsg().\r
195 \r
196         This default implementation calls the CalcCaptionArea() method,\r
197         substracts the returned rectangle from the client area and returns\r
198         the result.\r
199         */\r
200         virtual CRect CalcMsgArea();\r
201 \r
202         /**\r
203         Draws the message with the specified format.\r
204 \r
205         This default implementation draws the given msg using the specified\r
206         properties.\r
207 \r
208         @param pDc\r
209                 Device context to draw in.\r
210         @param rect\r
211                 Rectangle to draw the message in.\r
212         @param lpszMsg\r
213                 Message to draw.\r
214         @param dwFormat.\r
215                 Combination of the DT_* flags, specified by the Win32 function\r
216                 DrawText() to draw the message with.\r
217         */\r
218         virtual void DrawMsg(CDC *pDc, CRect rect, LPCTSTR lpszMsg, DWORD dwFormat);\r
219 \r
220         /**\r
221         Calculates the caption area. The caption area is the rectangular\r
222         range, the current page's caption should be drawn in.\r
223 \r
224         The caption can be enabled or disabled using the ShowCaption()\r
225         method. This method should return an empty rect, if the caption\r
226         is disabled. If the caption is enabled the height of the rect \r
227         should be as large, as specified by the latest call to the \r
228         SetCaptionHeight() method.\r
229 \r
230         The rectangle, returned by this method will be passed to the\r
231         DrawCaption() method to draw the caption.\r
232 \r
233         If the caption is enabled currently, this default implementation\r
234         returns a rectangle, that has the width of the client area and\r
235         the height, specified by the latest call to SetCaptionHeight(),\r
236         starting and y-position 0. If the caption is disabled at the \r
237         moment, this method returns an empty rectangle with the width of \r
238         the client area.\r
239         */\r
240         virtual CRect CalcCaptionArea();\r
241 \r
242         /**\r
243         Draws the caption.\r
244 \r
245         This default implementation draws nothing.\r
246 \r
247         @param pDc\r
248                 Device context to draw in.\r
249         @param rect\r
250                 Rectangle to draw the caption in.\r
251         @param lpszCaption\r
252                 Text to display in the caption.\r
253         @param hIcon\r
254                 Icon to display in the caption.\r
255         */\r
256         virtual void DrawCaption(CDC *pDc, CRect rect, LPCTSTR lpszCaption, HICON hIcon);\r
257 \r
258 // Implementation helpers\r
259 protected:\r
260         /**\r
261         If the m_hWnd property of the CWnd-object returend by GetWnd() \r
262         specifies a valid window, this method will invalidate the specified\r
263         rectangle, to schedule it for repaint, otherwise the method will\r
264         return without doing anything.\r
265 \r
266         @param lpRect\r
267                 Pointer to the rectangular area, that should be marked for \r
268                 repainting or NULL, if the whole client area should be marked\r
269                 for repainting.\r
270         */\r
271         void SafeUpdateWindow(LPCRECT lpRect = NULL);\r
272 \r
273 // Properties\r
274 private:\r
275         /** TRUE if the caption should be drawn, FALSE otherwise. */\r
276         BOOL m_bShowCaption;\r
277                 \r
278         /** Height of the caption in pixels, if it is enabled. */\r
279         int m_nCaptionHeight;\r
280 \r
281         /** Text to display in the caption. */\r
282         CString m_strCaption;\r
283 \r
284         /** \r
285         Icon to display in the caption or NULL if no icon should be \r
286         displayed.\r
287         */\r
288         HICON m_hCaptionIcon;\r
289 \r
290         /** Message text to display. */\r
291         CString m_strMsg;\r
292 \r
293         /** Style to use when drawing the message text m_strMsg. */\r
294         DWORD m_dwMsgFormat;\r
295 };\r
296 \r
297 \r
298 } //namespace TreePropSheet\r
299 \r
300 \r
301 /////////////////////////////////////////////////////////////////////////////\r
302 \r
303 //{{AFX_INSERT_LOCATION}}\r
304 // Microsoft Visual C++ fügt unmittelbar vor der vorhergehenden Zeile zusätzliche Deklarationen ein.\r
305 \r
306 #endif // AFX_PROPPAGEFRAME_H__B968548B_F0B4_4C35_85DD_C44242A9D368__INCLUDED_\r