Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: third_party/wtl/include/atltheme.h

Issue 703753005: More Windows build fixes. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: remove generated files Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/wtl/include/atlsplit.h ('k') | third_party/wtl/include/atluser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Windows Template Library - WTL version 8.0
2 // Copyright (C) Microsoft Corporation. All rights reserved.
3 //
4 // This file is a part of the Windows Template Library.
5 // The use and distribution terms for this software are covered by the
6 // Microsoft Permissive License (Ms-PL) which can be found in the file
7 // Ms-PL.txt at the root of this distribution.
8
9 #ifndef __ATLTHEME_H__
10 #define __ATLTHEME_H__
11
12 #pragma once
13
14 #ifndef __cplusplus
15 #error ATL requires C++ compilation (use a .cpp suffix)
16 #endif
17
18 #ifdef _WIN32_WCE
19 #error atltheme.h is not supported on Windows CE
20 #endif
21
22 #ifndef __ATLAPP_H__
23 #error atltheme.h requires atlapp.h to be included first
24 #endif
25
26 #ifndef __ATLWIN_H__
27 #error atltheme.h requires atlwin.h to be included first
28 #endif
29
30 #if (_WIN32_WINNT < 0x0501)
31 #error atltheme.h requires _WIN32_WINNT >= 0x0501
32 #endif // (_WIN32_WINNT < 0x0501)
33
34 #if defined(_WTL_USE_VSSYM32) || (defined(NTDDI_VERSION) && (NTDDI_VERSION >= NT DDI_LONGHORN))
35 #include <vssym32.h>
36 #else
37 #include <tmschema.h>
38 #endif
39
40 #include <uxtheme.h>
41 #pragma comment(lib, "uxtheme.lib")
42
43 // Note: To create an application that also runs on older versions of Windows,
44 // use delay load of uxtheme.dll and ensure that no calls to the Theme API are
45 // made if theming is not supported. It is enough to check if m_hTheme is NULL.
46 // Example:
47 // if(m_hTheme != NULL)
48 // {
49 // DrawThemeBackground(dc, BP_PUSHBUTTON, PBS_NORMAL, &rect, NULL);
50 // DrawThemeText(dc, BP_PUSHBUTTON, PBS_NORMAL, L"Button", -1, DT_S INGLELINE | DT_CENTER | DT_VCENTER, 0, &rect);
51 // }
52 // else
53 // {
54 // dc.DrawFrameControl(&rect, DFC_BUTTON, DFCS_BUTTONPUSH);
55 // dc.DrawText(_T("Button"), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
56 // }
57 //
58 // Delay load is NOT AUTOMATIC for VC++ 7, you have to link to delayimp.lib,
59 // and add uxtheme.dll in the Linker.Input.Delay Loaded DLLs section of the
60 // project properties.
61 #if (_MSC_VER < 1300) && !defined(_WTL_NO_THEME_DELAYLOAD)
62 #pragma comment(lib, "delayimp.lib")
63 #pragma comment(linker, "/delayload:uxtheme.dll")
64 #endif // (_MSC_VER < 1300) && !defined(_WTL_NO_THEME_DELAYLOAD)
65
66 // Hack: Signatures in uxtheme.h changed - the only way to check which variant o f uxtheme.h
67 // is included is to check for presence of new defines MAX_THEMECOLOR and MAX_TH EMESIZE
68 #ifndef _WTL_NEW_UXTHEME
69 #if defined(MAX_THEMECOLOR) && defined(MAX_THEMESIZE)
70 #define _WTL_NEW_UXTHEME
71 #endif // defined(MAX_THEMECOLOR) && defined(MAX_THEMESIZE)
72 #endif // _WTL_NEW_UXTHEME
73
74
75 ///////////////////////////////////////////////////////////////////////////////
76 // Classes in this file:
77 //
78 // CTheme
79 // CThemeImpl<T, TBase>
80 //
81 // CBufferedPaint
82 // CBufferedPaintImpl<T>
83 // CBufferedPaintWindowImpl<T, TBase, TWinTraits>
84 // CBufferedAnimation
85 // CBufferedAnimationImpl<T, TState>
86 // CBufferedAnimationWindowImpl<T, TState, TBase, TWinTraits>
87 //
88 // Global functions:
89 // AtlDrawThemeClientEdge()
90
91
92 namespace WTL
93 {
94
95 ///////////////////////////////////////////////////////////////////////////////
96 // CTheme - wrapper for theme handle
97
98 class CTheme
99 {
100 public:
101 // Data members
102 HTHEME m_hTheme;
103 static int m_nIsThemingSupported;
104
105 // Constructor
106 CTheme(HTHEME hTheme = NULL) : m_hTheme(hTheme)
107 {
108 IsThemingSupported();
109 }
110
111 // Operators and helpers
112 bool IsThemeNull() const
113 {
114 return (m_hTheme == NULL);
115 }
116
117 CTheme& operator =(HTHEME hTheme)
118 {
119 m_hTheme = hTheme;
120 return *this;
121 }
122
123 operator HTHEME() const
124 {
125 return m_hTheme;
126 }
127
128 void Attach(HTHEME hTheme)
129 {
130 m_hTheme = hTheme;
131 }
132
133 HTHEME Detach()
134 {
135 HTHEME hTheme = m_hTheme;
136 m_hTheme = NULL;
137 return hTheme;
138 }
139
140 // Theme support helper
141 static bool IsThemingSupported()
142 {
143 if(m_nIsThemingSupported == -1)
144 {
145 CStaticDataInitCriticalSectionLock lock;
146 if(FAILED(lock.Lock()))
147 {
148 ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to l ock critical section in CTheme::IsThemingSupported.\n"));
149 ATLASSERT(FALSE);
150 return false;
151 }
152
153 if(m_nIsThemingSupported == -1)
154 {
155 HMODULE hThemeDLL = ::LoadLibrary(_T("uxtheme.dl l"));
156 m_nIsThemingSupported = (hThemeDLL != NULL) ? 1 : 0;
157 if(hThemeDLL != NULL)
158 ::FreeLibrary(hThemeDLL);
159 }
160
161 lock.Unlock();
162 }
163
164 ATLASSERT(m_nIsThemingSupported != -1);
165 return (m_nIsThemingSupported == 1);
166 }
167
168 // Operations and theme properties
169 HTHEME OpenThemeData(HWND hWnd, LPCWSTR pszClassList)
170 {
171 if(!IsThemingSupported())
172 return NULL;
173
174 ATLASSERT(m_hTheme == NULL);
175 m_hTheme = ::OpenThemeData(hWnd, pszClassList);
176 return m_hTheme;
177 }
178
179 HRESULT CloseThemeData()
180 {
181 HRESULT hRet = S_FALSE;
182 if(m_hTheme != NULL)
183 {
184 hRet = ::CloseThemeData(m_hTheme);
185 if(SUCCEEDED(hRet))
186 m_hTheme = NULL;
187 }
188 return hRet;
189 }
190
191 HRESULT DrawThemeBackground(HDC hDC, int nPartID, int nStateID, LPCRECT pRect, LPCRECT pClipRect = NULL)
192 {
193 ATLASSERT(m_hTheme != NULL);
194 return ::DrawThemeBackground(m_hTheme, hDC, nPartID, nStateID, p Rect, pClipRect);
195 }
196
197 HRESULT DrawThemeBackgroundEx(HDC hDC, int nPartID, int nStateID, LPCREC T pRect, const DTBGOPTS* pOptions = NULL)
198 {
199 ATLASSERT(m_hTheme != NULL);
200 return ::DrawThemeBackgroundEx(m_hTheme, hDC, nPartID, nStateID, pRect, pOptions);
201 }
202
203 HRESULT DrawThemeText(HDC hDC, int nPartID, int nStateID, LPCWSTR pszTex t, int nCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, LPCRECT pRect)
204 {
205 ATLASSERT(m_hTheme != NULL);
206 return ::DrawThemeText(m_hTheme, hDC, nPartID, nStateID, pszText , nCharCount, dwTextFlags, dwTextFlags2, pRect);
207 }
208
209 HRESULT GetThemeBackgroundContentRect(HDC hDC, int nPartID, int nStateID , LPCRECT pBoundingRect, LPRECT pContentRect) const
210 {
211 ATLASSERT(m_hTheme != NULL);
212 return ::GetThemeBackgroundContentRect(m_hTheme, hDC, nPartID, n StateID, pBoundingRect, pContentRect);
213 }
214
215 HRESULT GetThemeBackgroundExtent(HDC hDC, int nPartID, int nStateID, LPC RECT pContentRect, LPRECT pExtentRect) const
216 {
217 ATLASSERT(m_hTheme != NULL);
218 return ::GetThemeBackgroundExtent(m_hTheme, hDC, nPartID, nState ID, pContentRect, pExtentRect);
219 }
220
221 HRESULT GetThemePartSize(HDC hDC, int nPartID, int nStateID, LPRECT pRec t, enum THEMESIZE eSize, LPSIZE pSize) const
222 {
223 ATLASSERT(m_hTheme != NULL);
224 return ::GetThemePartSize(m_hTheme, hDC, nPartID, nStateID, pRec t, eSize, pSize);
225 }
226
227 HRESULT GetThemeTextExtent(HDC hDC, int nPartID, int nStateID, LPCWSTR p szText, int nCharCount, DWORD dwTextFlags, LPCRECT pBoundingRect, LPRECT pExten tRect) const
228 {
229 ATLASSERT(m_hTheme != NULL);
230 return ::GetThemeTextExtent(m_hTheme, hDC, nPartID, nStateID, ps zText, nCharCount, dwTextFlags, pBoundingRect, pExtentRect);
231 }
232
233 HRESULT GetThemeTextMetrics(HDC hDC, int nPartID, int nStateID, PTEXTMET RICW pTextMetric) const
234 {
235 ATLASSERT(m_hTheme != NULL);
236 #ifdef _WTL_NEW_UXTHEME
237 return ::GetThemeTextMetrics(m_hTheme, hDC, nPartID, nStateID, p TextMetric);
238 #else // !_WTL_NEW_UXTHEME
239 // Note: The cast to PTEXTMETRIC is because uxtheme.h incorrectl y uses it instead of PTEXTMETRICW
240 return ::GetThemeTextMetrics(m_hTheme, hDC, nPartID, nStateID, ( PTEXTMETRIC)pTextMetric);
241 #endif // !_WTL_NEW_UXTHEME
242 }
243
244 HRESULT GetThemeBackgroundRegion(HDC hDC, int nPartID, int nStateID, LPC RECT pRect, HRGN* pRegion) const
245 {
246 ATLASSERT(m_hTheme != NULL);
247 return ::GetThemeBackgroundRegion(m_hTheme, hDC, nPartID, nState ID, pRect, pRegion);
248 }
249
250 HRESULT HitTestThemeBackground(HDC hDC, int nPartID, int nStateID, DWORD dwOptions, LPCRECT pRect, HRGN hrgn, POINT ptTest, WORD* pwHitTestCode) const
251 {
252 ATLASSERT(m_hTheme != NULL);
253 return ::HitTestThemeBackground(m_hTheme, hDC, nPartID, nStateID , dwOptions, pRect, hrgn, ptTest, pwHitTestCode);
254 }
255
256 HRESULT DrawThemeEdge(HDC hDC, int nPartID, int nStateID, LPCRECT pDestR ect, UINT uEdge, UINT uFlags, LPRECT pContentRect = NULL)
257 {
258 ATLASSERT(m_hTheme != NULL);
259 return ::DrawThemeEdge(m_hTheme, hDC, nPartID, nStateID, pDestRe ct, uEdge, uFlags, pContentRect);
260 }
261
262 HRESULT DrawThemeIcon(HDC hDC, int nPartID, int nStateID, LPCRECT pRect, HIMAGELIST himl, int nImageIndex)
263 {
264 ATLASSERT(m_hTheme != NULL);
265 return ::DrawThemeIcon(m_hTheme, hDC, nPartID, nStateID, pRect, himl, nImageIndex);
266 }
267
268 BOOL IsThemePartDefined(int nPartID, int nStateID) const
269 {
270 ATLASSERT(m_hTheme != NULL);
271 return ::IsThemePartDefined(m_hTheme, nPartID, nStateID);
272 }
273
274 BOOL IsThemeBackgroundPartiallyTransparent(int nPartID, int nStateID) co nst
275 {
276 ATLASSERT(m_hTheme != NULL);
277 return ::IsThemeBackgroundPartiallyTransparent(m_hTheme, nPartID , nStateID);
278 }
279
280 HRESULT GetThemeColor(int nPartID, int nStateID, int nPropID, COLORREF* pColor) const
281 {
282 ATLASSERT(m_hTheme != NULL);
283 return ::GetThemeColor(m_hTheme, nPartID, nStateID, nPropID, pCo lor);
284 }
285
286 HRESULT GetThemeMetric(HDC hDC, int nPartID, int nStateID, int nPropID, int* pnVal) const
287 {
288 ATLASSERT(m_hTheme != NULL);
289 return ::GetThemeMetric(m_hTheme, hDC, nPartID, nStateID, nPropI D, pnVal);
290 }
291
292 HRESULT GetThemeString(int nPartID, int nStateID, int nPropID, LPWSTR ps zBuff, int cchMaxBuffChars) const
293 {
294 ATLASSERT(m_hTheme != NULL);
295 return ::GetThemeString(m_hTheme, nPartID, nStateID, nPropID, ps zBuff, cchMaxBuffChars);
296 }
297
298 HRESULT GetThemeBool(int nPartID, int nStateID, int nPropID, BOOL* pfVal ) const
299 {
300 ATLASSERT(m_hTheme != NULL);
301 return ::GetThemeBool(m_hTheme, nPartID, nStateID, nPropID, pfVa l);
302 }
303
304 HRESULT GetThemeInt(int nPartID, int nStateID, int nPropID, int* pnVal) const
305 {
306 ATLASSERT(m_hTheme != NULL);
307 return ::GetThemeInt(m_hTheme, nPartID, nStateID, nPropID, pnVal );
308 }
309
310 HRESULT GetThemeEnumValue(int nPartID, int nStateID, int nPropID, int* p nVal) const
311 {
312 ATLASSERT(m_hTheme != NULL);
313 return ::GetThemeEnumValue(m_hTheme, nPartID, nStateID, nPropID, pnVal);
314 }
315
316 HRESULT GetThemePosition(int nPartID, int nStateID, int nPropID, LPPOINT pPoint) const
317 {
318 ATLASSERT(m_hTheme != NULL);
319 return ::GetThemePosition(m_hTheme, nPartID, nStateID, nPropID, pPoint);
320 }
321
322 // deprecated
323 HRESULT GetThemeFont(int nPartID, HDC hDC, int nStateID, int nPropID, LO GFONTW* pFont) const
324 {
325 ATLASSERT(m_hTheme != NULL);
326 #ifdef _WTL_NEW_UXTHEME
327 return ::GetThemeFont(m_hTheme, hDC, nPartID, nStateID, nPropID, pFont);
328 #else // !_WTL_NEW_UXTHEME
329 // Note: The cast to LOGFONT* is because uxtheme.h incorrectly u ses it instead of LOGFONTW*
330 return ::GetThemeFont(m_hTheme, hDC, nPartID, nStateID, nPropID, (LOGFONT*)pFont);
331 #endif // !_WTL_NEW_UXTHEME
332 }
333
334 HRESULT GetThemeFont(HDC hDC, int nPartID, int nStateID, int nPropID, LO GFONTW* pFont) const
335 {
336 ATLASSERT(m_hTheme != NULL);
337 #ifdef _WTL_NEW_UXTHEME
338 return ::GetThemeFont(m_hTheme, hDC, nPartID, nStateID, nPropID, pFont);
339 #else // !_WTL_NEW_UXTHEME
340 // Note: The cast to LOGFONT* is because uxtheme.h incorrectly u ses it instead of LOGFONTW*
341 return ::GetThemeFont(m_hTheme, hDC, nPartID, nStateID, nPropID, (LOGFONT*)pFont);
342 #endif // !_WTL_NEW_UXTHEME
343 }
344
345 HRESULT GetThemeRect(int nPartID, int nStateID, int nPropID, LPRECT pRec t) const
346 {
347 ATLASSERT(m_hTheme != NULL);
348 return ::GetThemeRect(m_hTheme, nPartID, nStateID, nPropID, pRec t);
349 }
350
351 HRESULT GetThemeMargins(HDC hDC, int nPartID, int nStateID, int nPropID, LPRECT pRect, PMARGINS pMargins) const
352 {
353 ATLASSERT(m_hTheme != NULL);
354 return ::GetThemeMargins(m_hTheme, hDC, nPartID, nStateID, nProp ID, pRect, pMargins);
355 }
356
357 HRESULT GetThemeIntList(int nPartID, int nStateID, int nPropID, INTLIST* pIntList) const
358 {
359 ATLASSERT(m_hTheme != NULL);
360 return ::GetThemeIntList(m_hTheme, nPartID, nStateID, nPropID, p IntList);
361 }
362
363 HRESULT GetThemePropertyOrigin(int nPartID, int nStateID, int nPropID, e num PROPERTYORIGIN* pOrigin) const
364 {
365 ATLASSERT(m_hTheme != NULL);
366 return ::GetThemePropertyOrigin(m_hTheme, nPartID, nStateID, nPr opID, pOrigin);
367 }
368
369 HRESULT GetThemeFilename(int nPartID, int nStateID, int nPropID, LPWSTR pszThemeFileName, int cchMaxBuffChars) const
370 {
371 ATLASSERT(m_hTheme != NULL);
372 return ::GetThemeFilename(m_hTheme, nPartID, nStateID, nPropID, pszThemeFileName, cchMaxBuffChars);
373 }
374
375 COLORREF GetThemeSysColor(int nColorID) const
376 {
377 ATLASSERT(m_hTheme != NULL);
378 return ::GetThemeSysColor(m_hTheme, nColorID);
379 }
380
381 HBRUSH GetThemeSysColorBrush(int nColorID) const
382 {
383 ATLASSERT(m_hTheme != NULL);
384 return ::GetThemeSysColorBrush(m_hTheme, nColorID);
385 }
386
387 int GetThemeSysSize(int nSizeID) const
388 {
389 ATLASSERT(m_hTheme != NULL);
390 return ::GetThemeSysSize(m_hTheme, nSizeID);
391 }
392
393 BOOL GetThemeSysBool(int nBoolID) const
394 {
395 ATLASSERT(m_hTheme != NULL);
396 return ::GetThemeSysBool(m_hTheme, nBoolID);
397 }
398
399 HRESULT GetThemeSysFont(int nFontID, LOGFONTW* plf) const
400 {
401 ATLASSERT(m_hTheme != NULL);
402 #ifdef _WTL_NEW_UXTHEME
403 return ::GetThemeSysFont(m_hTheme, nFontID, plf);
404 #else // !_WTL_NEW_UXTHEME
405 // Note: The cast to LOGFONT* is because uxtheme.h incorrectly u ses it instead of LOGFONTW*
406 return ::GetThemeSysFont(m_hTheme, nFontID, (LOGFONT*)plf);
407 #endif // !_WTL_NEW_UXTHEME
408 }
409
410 HRESULT GetThemeSysString(int nStringID, LPWSTR pszStringBuff, int cchMa xStringChars) const
411 {
412 ATLASSERT(m_hTheme != NULL);
413 return ::GetThemeSysString(m_hTheme, nStringID, pszStringBuff, c chMaxStringChars);
414 }
415
416 HRESULT GetThemeSysInt(int nIntID, int* pnValue) const
417 {
418 ATLASSERT(m_hTheme != NULL);
419 return ::GetThemeSysInt(m_hTheme, nIntID, pnValue);
420 }
421
422 #ifdef _WTL_NEW_UXTHEME
423 HTHEME OpenThemeDataEx(HWND hWnd, LPCWSTR pszClassList, DWORD dwFlags)
424 {
425 if(!IsThemingSupported())
426 return NULL;
427
428 ATLASSERT(m_hTheme == NULL);
429 m_hTheme = ::OpenThemeDataEx(hWnd, pszClassList, dwFlags);
430 return m_hTheme;
431 }
432
433 HRESULT DrawThemeTextEx(HDC hDC, int nPartID, int nStateID, LPCWSTR pszT ext, int cchText, DWORD dwTextFlags, LPRECT lpRect, const DTTOPTS* pOptions)
434 {
435 ATLASSERT(m_hTheme != NULL);
436 return ::DrawThemeTextEx(m_hTheme, hDC, nPartID, nStateID, pszTe xt, cchText, dwTextFlags, lpRect, pOptions);
437 }
438
439 HRESULT GetThemeTransitionDuration(int nPartID, int nFromStateID, int nT oStateID, int nPropID, DWORD& dwDuration)
440 {
441 ATLASSERT(m_hTheme != NULL);
442 return ::GetThemeTransitionDuration(m_hTheme, nPartID, nFromStat eID, nToStateID, nPropID, &dwDuration);
443 }
444 #endif // _WTL_NEW_UXTHEME
445
446 #if (_WIN32_WINNT >= 0x0600)
447 HRESULT GetThemeBitmap(int nPartID, int nStateID, int nPropID, ULONG uFl ags, HBITMAP& hBitmap)
448 {
449 ATLASSERT(m_hTheme != NULL);
450 return ::GetThemeBitmap(m_hTheme, nPartID, nStateID, nPropID, uF lags, &hBitmap);
451 }
452
453 HRESULT GetThemeStream(int nPartID, int nStateID, int nPropID, VOID** pp vStream, DWORD* pcbStream, HINSTANCE hInstance)
454 {
455 ATLASSERT(m_hTheme != NULL);
456 return ::GetThemeStream(m_hTheme, nPartID, nStateID, nPropID, pp vStream, pcbStream, hInstance);
457 }
458 #endif // (_WIN32_WINNT >= 0x0600)
459 };
460
461 __declspec(selectany) int CTheme::m_nIsThemingSupported = -1;
462
463
464 ///////////////////////////////////////////////////////////////////////////////
465 // CThemeImpl - theme support implementation
466
467 // Derive from this class to implement window with theme support.
468 // Example:
469 // class CMyThemeWindow : public CWindowImpl<CMyThemeWindow>, public CTheme Impl<CMyThemeWindow>
470 // {
471 // ...
472 // BEGIN_MSG_MAP(CMyThemeWindow)
473 // CHAIN_MSG_MAP(CThemeImpl<CMyThemeWindow>)
474 // ...
475 // END_MSG_MAP()
476 // ...
477 // };
478 //
479 // If you set theme class list, the class will automaticaly open/close/reopen th eme data.
480
481
482 // Helper for drawing theme client edge
483 inline bool AtlDrawThemeClientEdge(HTHEME hTheme, HWND hWnd, HRGN hRgnUpdate = N ULL, HBRUSH hBrush = NULL, int nPartID = 0, int nStateID = 0)
484 {
485 ATLASSERT(hTheme != NULL);
486 ATLASSERT(::IsWindow(hWnd));
487
488 CWindowDC dc(hWnd);
489 if(dc.IsNull())
490 return false;
491
492 // Get border size
493 int cxBorder = GetSystemMetrics(SM_CXBORDER);
494 int cyBorder = GetSystemMetrics(SM_CYBORDER);
495 if(SUCCEEDED(::GetThemeInt(hTheme, nPartID, nStateID, TMT_SIZINGBORDERWI DTH, &cxBorder)))
496 cyBorder = cxBorder;
497
498 RECT rect;
499 ::GetWindowRect(hWnd, &rect);
500
501 // Remove the client edge from the update region
502 int cxEdge = GetSystemMetrics(SM_CXEDGE);
503 int cyEdge = GetSystemMetrics(SM_CYEDGE);
504 ::InflateRect(&rect, -cxEdge, -cyEdge);
505 CRgn rgn;
506 rgn.CreateRectRgnIndirect(&rect);
507 if(rgn.IsNull())
508 return false;
509
510 if(hRgnUpdate != NULL)
511 rgn.CombineRgn(hRgnUpdate, rgn, RGN_AND);
512
513 ::OffsetRect(&rect, -rect.left, -rect.top);
514
515 ::OffsetRect(&rect, cxEdge, cyEdge);
516 dc.ExcludeClipRect(&rect);
517 ::InflateRect(&rect, cxEdge, cyEdge);
518
519 ::DrawThemeBackground(hTheme, dc, nPartID, nStateID, &rect, NULL);
520
521 // Use background brush too, since theme border might not cover everythi ng
522 if(cxBorder < cxEdge && cyBorder < cyEdge)
523 {
524 if(hBrush == NULL)
525 // need conditional code because types don't match in winuser.h
526 #ifdef _WIN64
527 hBrush = (HBRUSH)::GetClassLongPtr(hWnd, GCLP_HBRBACKGRO UND);
528 #else
529 hBrush = (HBRUSH)UlongToPtr(::GetClassLongPtr(hWnd, GCLP _HBRBACKGROUND));
530 #endif
531
532 ::InflateRect(&rect, cxBorder - cxEdge, cyBorder - cyEdge);
533 dc.FillRect(&rect, hBrush);
534 }
535
536 ::DefWindowProc(hWnd, WM_NCPAINT, (WPARAM)rgn.m_hRgn, 0L);
537
538 return true;
539 }
540
541
542 // Theme extended styles
543 #define THEME_EX_3DCLIENTEDGE 0x00000001
544 #define THEME_EX_THEMECLIENTEDGE 0x00000002
545
546 template <class T, class TBase = CTheme>
547 class CThemeImpl : public TBase
548 {
549 public:
550 // Data members
551 LPWSTR m_lpstrThemeClassList;
552 DWORD m_dwExtendedStyle; // theme specific extended styles
553
554 // Constructor & destructor
555 CThemeImpl() : m_lpstrThemeClassList(NULL), m_dwExtendedStyle(0)
556 { }
557
558 ~CThemeImpl()
559 {
560 delete [] m_lpstrThemeClassList;
561 }
562
563 // Attributes
564 bool SetThemeClassList(LPCWSTR lpstrThemeClassList)
565 {
566 if(m_lpstrThemeClassList != NULL)
567 {
568 delete [] m_lpstrThemeClassList;
569 m_lpstrThemeClassList = NULL;
570 }
571
572 if(lpstrThemeClassList == NULL)
573 return true;
574
575 int cchLen = lstrlenW(lpstrThemeClassList) + 1;
576 ATLTRY(m_lpstrThemeClassList = new WCHAR[cchLen]);
577 if(m_lpstrThemeClassList == NULL)
578 return false;
579
580 SecureHelper::strcpyW_x(m_lpstrThemeClassList, cchLen, lpstrThem eClassList);
581
582 return true;
583 }
584
585 bool GetThemeClassList(LPWSTR lpstrThemeClassList, int cchListBuffer) co nst
586 {
587 int cchLen = lstrlenW(m_lpstrThemeClassList) + 1;
588 if(cchListBuffer < cchLen)
589 return false;
590
591 SecureHelper::strcpyW_x(lpstrThemeClassList, cchListBuffer, m_lp strThemeClassList);
592
593 return true;
594 }
595
596 LPCWSTR GetThemeClassList() const
597 {
598 return m_lpstrThemeClassList;
599 }
600
601 DWORD SetThemeExtendedStyle(DWORD dwExtendedStyle, DWORD dwMask = 0)
602 {
603 DWORD dwPrevStyle = m_dwExtendedStyle;
604 if(dwMask == 0)
605 m_dwExtendedStyle = dwExtendedStyle;
606 else
607 m_dwExtendedStyle = (m_dwExtendedStyle & ~dwMask) | (dwE xtendedStyle & dwMask);
608 return dwPrevStyle;
609 }
610
611 DWORD GetThemeExtendedStyle() const
612 {
613 return m_dwExtendedStyle;
614 }
615
616 // Operations
617 HTHEME OpenThemeData()
618 {
619 T* pT = static_cast<T*>(this);
620 ATLASSERT(::IsWindow(pT->m_hWnd));
621 ATLASSERT(m_lpstrThemeClassList != NULL);
622 if(m_lpstrThemeClassList == NULL)
623 return NULL;
624 CloseThemeData();
625 return TBase::OpenThemeData(pT->m_hWnd, m_lpstrThemeClassList);
626 }
627
628 HTHEME OpenThemeData(LPCWSTR pszClassList)
629 {
630 if(!SetThemeClassList(pszClassList))
631 return NULL;
632 return OpenThemeData();
633 }
634
635 HRESULT SetWindowTheme(LPCWSTR pszSubAppName, LPCWSTR pszSubIDList)
636 {
637 if(!IsThemingSupported())
638 return S_FALSE;
639
640 T* pT = static_cast<T*>(this);
641 ATLASSERT(::IsWindow(pT->m_hWnd));
642 return ::SetWindowTheme(pT->m_hWnd, pszSubAppName, pszSubIDList) ;
643 }
644
645 HTHEME GetWindowTheme() const
646 {
647 if(!IsThemingSupported())
648 return NULL;
649
650 const T* pT = static_cast<const T*>(this);
651 ATLASSERT(::IsWindow(pT->m_hWnd));
652 return ::GetWindowTheme(pT->m_hWnd);
653 }
654
655 HRESULT EnableThemeDialogTexture(DWORD dwFlags)
656 {
657 if(!IsThemingSupported())
658 return S_FALSE;
659
660 T* pT = static_cast<T*>(this);
661 ATLASSERT(::IsWindow(pT->m_hWnd));
662 return ::EnableThemeDialogTexture(pT->m_hWnd, dwFlags);
663 }
664
665 BOOL IsThemeDialogTextureEnabled() const
666 {
667 if(!IsThemingSupported())
668 return FALSE;
669
670 const T* pT = static_cast<const T*>(this);
671 ATLASSERT(::IsWindow(pT->m_hWnd));
672 return ::IsThemeDialogTextureEnabled(pT->m_hWnd);
673 }
674
675 HRESULT DrawThemeParentBackground(HDC hDC, const RECT* pRect = NULL)
676 {
677 if(!IsThemingSupported())
678 return S_FALSE;
679
680 T* pT = static_cast<T*>(this);
681 ATLASSERT(::IsWindow(pT->m_hWnd));
682 #ifdef _WTL_NEW_UXTHEME
683 return ::DrawThemeParentBackground(pT->m_hWnd, hDC, pRect);
684 #else
685 return ::DrawThemeParentBackground(pT->m_hWnd, hDC, (RECT*)pRect );
686 #endif
687 }
688
689 #ifdef _WTL_NEW_UXTHEME
690 HRESULT SetWindowThemeAttribute(WINDOWTHEMEATTRIBUTETYPE type, PVOID pvA ttribute, DWORD cbAttribute)
691 {
692 if(!IsThemingSupported())
693 return S_FALSE;
694
695 T* pT = static_cast<T*>(this);
696 ATLASSERT(::IsWindow(pT->m_hWnd));
697 return ::SetWindowThemeAttribute(pT->m_hWnd, type, pvAttribute, cbAttribute);
698 }
699
700 HRESULT SetWindowThemeNonClientAttributes(DWORD dwAttributes, DWORD dwMa sk)
701 {
702 if(!IsThemingSupported())
703 return S_FALSE;
704
705 T* pT = static_cast<T*>(this);
706 ATLASSERT(::IsWindow(pT->m_hWnd));
707 WTA_OPTIONS opt = { dwAttributes, dwMask };
708 return ::SetWindowThemeAttribute(pT->m_hWnd, WTA_NONCLIENT, (PVO ID)&opt, sizeof(opt));
709 }
710
711 HRESULT DrawThemeParentBackgroundEx(HDC hDC, DWORD dwFlags, const RECT* lpRect = NULL)
712 {
713 if(!IsThemingSupported())
714 return S_FALSE;
715
716 T* pT = static_cast<T*>(this);
717 ATLASSERT(::IsWindow(pT->m_hWnd));
718 return ::DrawThemeParentBackgroundEx(pT->m_hWnd, hDC, dwFlags, l pRect);
719 }
720 #endif // _WTL_NEW_UXTHEME
721
722 // Message map and handlers
723 // Note: If you handle any of these messages in your derived class,
724 // it is better to put CHAIN_MSG_MAP at the start of your message map.
725 BEGIN_MSG_MAP(CThemeImpl)
726 MESSAGE_HANDLER(WM_CREATE, OnCreate)
727 MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
728 MESSAGE_HANDLER(WM_THEMECHANGED, OnThemeChanged)
729 MESSAGE_HANDLER(WM_NCPAINT, OnNcPaint)
730 END_MSG_MAP()
731
732 LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BO OL& bHandled)
733 {
734 if(m_lpstrThemeClassList != NULL)
735 OpenThemeData();
736 bHandled = FALSE;
737 return 1;
738 }
739
740 LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, B OOL& bHandled)
741 {
742 CloseThemeData();
743 bHandled = FALSE;
744 return 1;
745 }
746
747 LRESULT OnThemeChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam */, BOOL& bHandled)
748 {
749 CloseThemeData();
750 if(m_lpstrThemeClassList != NULL)
751 OpenThemeData();
752 bHandled = FALSE;
753 return 1;
754 }
755
756 LRESULT OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandle d)
757 {
758 T* pT = static_cast<T*>(this);
759 ATLASSERT(::IsWindow(pT->m_hWnd));
760 LRESULT lRet = 0;
761 bHandled = FALSE;
762 if(IsThemingSupported() && ((pT->GetExStyle() & WS_EX_CLIENTEDGE ) != 0))
763 {
764 if((m_dwExtendedStyle & THEME_EX_3DCLIENTEDGE) != 0)
765 {
766 lRet = ::DefWindowProc(pT->m_hWnd, uMsg, wParam, lParam);
767 bHandled = TRUE;
768 }
769 else if((m_hTheme != NULL) && ((m_dwExtendedStyle & THEM E_EX_THEMECLIENTEDGE) != 0))
770 {
771 HRGN hRgn = (wParam != 1) ? (HRGN)wParam : NULL;
772 if(pT->DrawThemeClientEdge(hRgn))
773 bHandled = TRUE;
774 }
775 }
776 return lRet;
777 }
778
779 // Drawing helper
780 bool DrawThemeClientEdge(HRGN hRgnUpdate)
781 {
782 T* pT = static_cast<T*>(this);
783 return AtlDrawThemeClientEdge(m_hTheme, pT->m_hWnd, hRgnUpdate, NULL, 0, 0);
784 }
785 };
786
787 ///////////////////////////////////////////////////////////////////////////////
788 // Buffered Paint and Animation
789
790 #ifdef _WTL_NEW_UXTHEME
791
792 ///////////////////////////////////////////////////////////////////////////////
793 // CBufferedPaintBase - Buffered Paint support for othe classes
794
795 class CBufferedPaintBase
796 {
797 public:
798 static int m_nIsBufferedPaintSupported;
799
800 CBufferedPaintBase()
801 {
802 if(IsBufferedPaintSupported())
803 ATLVERIFY(SUCCEEDED(::BufferedPaintInit()));
804 }
805
806 ~CBufferedPaintBase()
807 {
808 if(IsBufferedPaintSupported())
809 ATLVERIFY(SUCCEEDED(::BufferedPaintUnInit()));
810 }
811
812 static bool IsBufferedPaintSupported()
813 {
814 if(m_nIsBufferedPaintSupported == -1)
815 {
816 CStaticDataInitCriticalSectionLock lock;
817 if(FAILED(lock.Lock()))
818 {
819 ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to l ock critical section in CBufferedPaintBase::IsBufferedPaintSupported.\n"));
820 ATLASSERT(FALSE);
821 return false;
822 }
823
824 if(m_nIsBufferedPaintSupported == -1)
825 m_nIsBufferedPaintSupported = RunTimeHelper::IsV ista() ? 1 : 0;
826
827 lock.Unlock();
828 }
829
830 ATLASSERT(m_nIsBufferedPaintSupported != -1);
831 return (m_nIsBufferedPaintSupported == 1);
832 }
833 };
834
835 __declspec(selectany) int CBufferedPaintBase::m_nIsBufferedPaintSupported = -1;
836
837
838 ///////////////////////////////////////////////////////////////////////////////
839 // CBufferedPaint - support for buffered paint functions
840
841 class CBufferedPaint
842 {
843 public:
844 HPAINTBUFFER m_hPaintBuffer;
845
846 CBufferedPaint() : m_hPaintBuffer(NULL)
847 { }
848
849 ~CBufferedPaint()
850 {
851 ATLVERIFY(SUCCEEDED(End()));
852 }
853
854 bool IsNull() const
855 {
856 return (m_hPaintBuffer == NULL);
857 }
858
859 HPAINTBUFFER Begin(HDC hdcTarget, const RECT* prcTarget, BP_BUFFERFORMAT dwFormat, BP_PAINTPARAMS* pPaintParams, HDC* phdcPaint)
860 {
861 ATLASSERT(m_hPaintBuffer == NULL);
862 m_hPaintBuffer = ::BeginBufferedPaint(hdcTarget, prcTarget, dwFo rmat, pPaintParams, phdcPaint);
863 return m_hPaintBuffer;
864 }
865
866 HRESULT End(BOOL bUpdate = TRUE)
867 {
868 HRESULT hRet = S_FALSE;
869 if(m_hPaintBuffer != NULL)
870 {
871 hRet = ::EndBufferedPaint(m_hPaintBuffer, bUpdate);
872 m_hPaintBuffer = NULL;
873 }
874 return hRet;
875 }
876
877 HRESULT GetTargetRect(LPRECT pRect) const
878 {
879 ATLASSERT(m_hPaintBuffer != NULL);
880 return ::GetBufferedPaintTargetRect(m_hPaintBuffer, pRect);
881 }
882
883 HDC GetTargetDC() const
884 {
885 ATLASSERT(m_hPaintBuffer != NULL);
886 return ::GetBufferedPaintTargetDC(m_hPaintBuffer);
887 }
888
889 HDC GetPaintDC() const
890 {
891 ATLASSERT(m_hPaintBuffer != NULL);
892 return ::GetBufferedPaintDC(m_hPaintBuffer);
893 }
894
895 HRESULT GetBits(RGBQUAD** ppbBuffer, int* pcxRow) const
896 {
897 ATLASSERT(m_hPaintBuffer != NULL);
898 return ::GetBufferedPaintBits(m_hPaintBuffer, ppbBuffer, pcxRow) ;
899 }
900
901 HRESULT Clear(const RECT* pRect = NULL)
902 {
903 ATLASSERT(m_hPaintBuffer != NULL);
904 return ::BufferedPaintClear(m_hPaintBuffer, pRect);
905 }
906
907 HRESULT SetAlpha(BYTE alpha, const RECT* pRect = NULL)
908 {
909 ATLASSERT(m_hPaintBuffer != NULL);
910 return ::BufferedPaintSetAlpha(m_hPaintBuffer, pRect, alpha);
911 }
912
913 HRESULT MakeOpaque(const RECT* pRect = NULL)
914 {
915 ATLASSERT(m_hPaintBuffer != NULL);
916 return ::BufferedPaintSetAlpha(m_hPaintBuffer, pRect, 255);
917 }
918 };
919
920
921 ///////////////////////////////////////////////////////////////////////////////
922 // CBufferedPaintImpl - provides buffered paint for any window
923
924 template <class T>
925 class ATL_NO_VTABLE CBufferedPaintImpl : public CBufferedPaintBase
926 {
927 public:
928 CBufferedPaint m_BufferedPaint;
929 BP_BUFFERFORMAT m_dwFormat;
930 BP_PAINTPARAMS m_PaintParams;
931
932 CBufferedPaintImpl() : m_dwFormat(BPBF_TOPDOWNDIB)
933 {
934 memset(&m_PaintParams, 0, sizeof(BP_PAINTPARAMS));
935 m_PaintParams.cbSize = sizeof(BP_PAINTPARAMS);
936 }
937
938 // Message map and handlers
939 BEGIN_MSG_MAP(CBufferedPaintImpl)
940 MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground)
941 MESSAGE_HANDLER(WM_PAINT, OnPaint)
942 MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint)
943 END_MSG_MAP()
944
945 LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPa ram*/, BOOL& /*bHandled*/)
946 {
947 return 1; // no background needed
948 }
949
950 LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& / *bHandled*/)
951 {
952 T* pT = static_cast<T*>(this);
953 if(wParam != NULL)
954 {
955 RECT rect = { 0 };
956 pT->GetClientRect(&rect);
957 pT->DoPaint((HDC)wParam, rect);
958 }
959 else
960 {
961 CPaintDC dc(pT->m_hWnd);
962 pT->DoBufferedPaint(dc.m_hDC, dc.m_ps.rcPaint);
963 }
964
965 return 0;
966 }
967
968 // Overrideables
969 void DoBufferedPaint(CDCHandle dc, RECT& rect)
970 {
971 HDC hDCPaint = NULL;
972 if(IsBufferedPaintSupported())
973 m_BufferedPaint.Begin(dc, &rect, m_dwFormat, &m_PaintPar ams, &hDCPaint);
974
975 T* pT = static_cast<T*>(this);
976 if(hDCPaint != NULL)
977 pT->DoPaint(hDCPaint, rect);
978 else
979 pT->DoPaint(dc.m_hDC, rect);
980
981 if(IsBufferedPaintSupported())
982 m_BufferedPaint.End();
983 }
984
985 void DoPaint(CDCHandle /*dc*/, RECT& /*rect*/)
986 {
987 // must be implemented in a derived class
988 ATLASSERT(FALSE);
989 }
990 };
991
992
993 ///////////////////////////////////////////////////////////////////////////////
994 // CBufferedPaintWindowImpl - implements a window that uses buffered paint
995
996 template <class T, class TBase = ATL::CWindow, class TWinTraits = ATL::CControlW inTraits>
997 class ATL_NO_VTABLE CBufferedPaintWindowImpl :
998 public ATL::CWindowImpl<T, TBase, TWinTraits>,
999 public CBufferedPaintImpl< T >
1000 {
1001 public:
1002 BEGIN_MSG_MAP(CBufferedPaintWindowImpl)
1003 CHAIN_MSG_MAP(CBufferedPaintImpl< T >)
1004 END_MSG_MAP()
1005 };
1006
1007
1008 ///////////////////////////////////////////////////////////////////////////////
1009 // CBufferedAnimation - support for buffered animation
1010
1011 class CBufferedAnimation
1012 {
1013 public:
1014 HANIMATIONBUFFER m_hAnimationBuffer;
1015
1016 CBufferedAnimation() : m_hAnimationBuffer(NULL)
1017 { }
1018
1019 ~CBufferedAnimation()
1020 {
1021 ATLVERIFY(SUCCEEDED(End()));
1022 }
1023
1024 bool IsNull() const
1025 {
1026 return (m_hAnimationBuffer == NULL);
1027 }
1028
1029 HANIMATIONBUFFER Begin(HWND hWnd, HDC hDCTarget, const RECT* pRectTarget , BP_BUFFERFORMAT dwFormat, BP_PAINTPARAMS* pPaintParams, BP_ANIMATIONPARAMS* pA nimationParams, HDC* phdcFrom, HDC* phdcTo)
1030 {
1031 ATLASSERT(m_hAnimationBuffer == NULL);
1032 m_hAnimationBuffer = ::BeginBufferedAnimation(hWnd, hDCTarget, p RectTarget, dwFormat, pPaintParams, pAnimationParams, phdcFrom, phdcTo);
1033 return m_hAnimationBuffer;
1034 }
1035
1036 HRESULT End(BOOL bUpdate = TRUE)
1037 {
1038 HRESULT hRet = S_FALSE;
1039 if(m_hAnimationBuffer != NULL)
1040 {
1041 hRet = ::EndBufferedAnimation(m_hAnimationBuffer, bUpdat e);
1042 m_hAnimationBuffer = NULL;
1043 }
1044 return hRet;
1045 }
1046
1047 static bool IsRendering(HWND hWnd, HDC hDC)
1048 {
1049 return (::BufferedPaintRenderAnimation(hWnd, hDC) != FALSE);
1050 }
1051 };
1052
1053
1054 ///////////////////////////////////////////////////////////////////////////////
1055 // CBufferedAnimationImpl - provides buffered animation support for any window
1056
1057 // Note: You can either use m_State and m_NewState to store the state informatio n
1058 // for the animation change, or map your state to those data members. DoPaint()
1059 // should only rely on the state information that is passed to it.
1060
1061 template <class T, class TState = DWORD_PTR>
1062 class ATL_NO_VTABLE CBufferedAnimationImpl : public CBufferedPaintBase
1063 {
1064 public:
1065 BP_BUFFERFORMAT m_dwFormat;
1066 BP_PAINTPARAMS m_PaintParams;
1067 BP_ANIMATIONPARAMS m_AnimationParams;
1068
1069 TState m_State;
1070 TState m_NewState;
1071
1072 CBufferedAnimationImpl(TState InitialState) : m_dwFormat(BPBF_TOPDOWNDIB )
1073 {
1074 memset(&m_PaintParams, 0, sizeof(BP_PAINTPARAMS));
1075 m_PaintParams.cbSize = sizeof(BP_PAINTPARAMS);
1076
1077 memset(&m_AnimationParams, 0, sizeof(BP_ANIMATIONPARAMS));
1078 m_AnimationParams.cbSize = sizeof(BP_ANIMATIONPARAMS);
1079 m_AnimationParams.style = BPAS_LINEAR;
1080 m_AnimationParams.dwDuration = 500;
1081
1082 T* pT = static_cast<T*>(this);
1083 pT->SetState(InitialState);
1084 pT->SetNewState(InitialState);
1085 }
1086
1087 DWORD GetDuration() const
1088 {
1089 return m_AnimationParams.dwDuration;
1090 }
1091
1092 void SetDuration(DWORD dwDuration)
1093 {
1094 m_AnimationParams.dwDuration = dwDuration;
1095 }
1096
1097 void DoAnimation(TState NewState, const RECT* pRect = NULL)
1098 {
1099 T* pT = static_cast<T*>(this);
1100 pT->SetNewState(NewState);
1101
1102 pT->InvalidateRect(pRect, FALSE);
1103 pT->UpdateWindow();
1104
1105 pT->SetState(NewState);
1106 }
1107
1108 // Message map and handlers
1109 BEGIN_MSG_MAP(CBufferedAnimationImpl)
1110 MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground)
1111 MESSAGE_HANDLER(WM_PAINT, OnPaint)
1112 MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint)
1113 END_MSG_MAP()
1114
1115 LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPa ram*/, BOOL& /*bHandled*/)
1116 {
1117 return 1; // no background needed
1118 }
1119
1120 LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& / *bHandled*/)
1121 {
1122 T* pT = static_cast<T*>(this);
1123 if(wParam != NULL)
1124 {
1125 RECT rect = { 0 };
1126 pT->GetClientRect(&rect);
1127 pT->DoPaint((HDC)wParam, rect, m_NewState);
1128 }
1129 else
1130 {
1131 CPaintDC dc(pT->m_hWnd);
1132 pT->DoAnimationPaint(dc.m_hDC, dc.m_ps.rcPaint);
1133 }
1134
1135 return 0;
1136 }
1137
1138 // Overrideables
1139 void SetState(TState State)
1140 {
1141 m_State = State;
1142 }
1143
1144 void SetNewState(TState State)
1145 {
1146 m_NewState = State;
1147 }
1148
1149 bool AreStatesEqual() const
1150 {
1151 return (m_State == m_NewState);
1152 }
1153
1154 void DoAnimationPaint(CDCHandle dc, RECT& rect)
1155 {
1156 T* pT = static_cast<T*>(this);
1157 if(IsBufferedPaintSupported() && CBufferedAnimation::IsRendering (pT->m_hWnd, dc))
1158 return;
1159
1160 DWORD dwDurationSave = m_AnimationParams.dwDuration;
1161 if(pT->AreStatesEqual())
1162 m_AnimationParams.dwDuration = 0;
1163
1164 HDC hdcFrom = NULL, hdcTo = NULL;
1165 CBufferedAnimation ba;
1166 if(IsBufferedPaintSupported())
1167 ba.Begin(pT->m_hWnd, dc, &rect, m_dwFormat, &m_PaintPara ms, &m_AnimationParams, &hdcFrom, &hdcTo);
1168
1169 if(!ba.IsNull())
1170 {
1171 if(hdcFrom != NULL)
1172 pT->DoPaint(hdcFrom, rect, m_State);
1173
1174 if (hdcTo != NULL)
1175 pT->DoPaint(hdcTo, rect, m_NewState);
1176 }
1177 else
1178 {
1179 pT->DoPaint(dc.m_hDC, rect, m_NewState);
1180 }
1181
1182 m_AnimationParams.dwDuration = dwDurationSave;
1183 }
1184
1185 void DoPaint(CDCHandle /*dc*/, RECT& /*rect*/, TState /*State*/)
1186 {
1187 // must be implemented in a derived class
1188 ATLASSERT(FALSE);
1189 }
1190 };
1191
1192
1193 ///////////////////////////////////////////////////////////////////////////////
1194 // CBufferedAnimationWindowImpl - implements a window that uses buffered animati on
1195
1196 template <class T, class TState = DWORD_PTR, class TBase = ATL::CWindow, class T WinTraits = ATL::CControlWinTraits>
1197 class ATL_NO_VTABLE CBufferedAnimationWindowImpl :
1198 public ATL::CWindowImpl<T, TBase, TWinTraits>,
1199 public CBufferedAnimationImpl< T, TState >
1200 {
1201 public:
1202 CBufferedAnimationWindowImpl(TState InitialState) : CBufferedAnimationIm pl< T, TState >(InitialState)
1203 { }
1204
1205 typedef CBufferedAnimationImpl< T, TState > _baseBufferedAnimation;
1206 BEGIN_MSG_MAP(CBufferedAnimationWindowImpl)
1207 CHAIN_MSG_MAP(_baseBufferedAnimation)
1208 END_MSG_MAP()
1209 };
1210
1211 #endif // _WTL_NEW_UXTHEME
1212
1213 }; // namespace WTL
1214
1215 #endif // __ATLTHEME_H__
OLDNEW
« no previous file with comments | « third_party/wtl/include/atlsplit.h ('k') | third_party/wtl/include/atluser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698