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