1+ /*
2+ * Vista+ functions copied and pasted from draw.c and system.c
3+ *
4+ * Copyright (C) 2003 Kevin Koltzau
5+ *
6+ * This library is free software; you can redistribute it and/or
7+ * modify it under the terms of the GNU Lesser General Public
8+ * License as published by the Free Software Foundation; either
9+ * version 2.1 of the License, or (at your option) any later version.
10+ *
11+ * This library is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+ * Lesser General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU Lesser General Public
17+ * License along with this library; if not, write to the Free Software
18+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19+ */
20+
21+ #include "uxthemep.h"
22+
23+ #include <stdlib.h>
24+
25+ typedef int (WINAPI * DRAWSHADOWTEXT )(HDC hdc , LPCWSTR pszText , UINT cch , RECT * prc , DWORD dwFlags ,
26+ COLORREF crText , COLORREF crShadow , int ixOffset , int iyOffset );
27+
28+ /***********************************************************************
29+ * DrawThemeTextEx (UXTHEME.@)
30+ */
31+ HRESULT
32+ WINAPI
33+ DrawThemeTextEx (
34+ _In_ HTHEME hTheme ,
35+ _In_ HDC hdc ,
36+ _In_ int iPartId ,
37+ _In_ int iStateId ,
38+ _In_ LPCWSTR pszText ,
39+ _In_ int iCharCount ,
40+ _In_ DWORD dwTextFlags ,
41+ _Inout_ LPRECT pRect ,
42+ _In_ const DTTOPTS * options
43+ )
44+ {
45+ HRESULT hr ;
46+ HFONT hFont = NULL ;
47+ HGDIOBJ oldFont = NULL ;
48+ LOGFONTW logfont ;
49+ COLORREF textColor ;
50+ COLORREF oldTextColor ;
51+ COLORREF shadowColor ;
52+ POINT ptShadowOffset ;
53+ int oldBkMode ;
54+ RECT rt ;
55+ int iShadowType ;
56+ DWORD optFlags ;
57+
58+ if (!hTheme )
59+ return E_HANDLE ;
60+ if (!options )
61+ return E_NOTIMPL ;
62+
63+ optFlags = options -> dwFlags ;
64+
65+ hr = GetThemeFont (hTheme , hdc , iPartId , iStateId , TMT_FONT , & logfont );
66+ if (SUCCEEDED (hr ))
67+ {
68+ hFont = CreateFontIndirectW (& logfont );
69+ if (!hFont )
70+ {
71+ ERR ("Failed to create font\n" );
72+ }
73+ }
74+
75+ CopyRect (& rt , pRect );
76+ if (hFont )
77+ oldFont = SelectObject (hdc , hFont );
78+
79+ oldBkMode = SetBkMode (hdc , TRANSPARENT );
80+
81+ if (optFlags & DTT_TEXTCOLOR )
82+ {
83+ textColor = options -> crText ;
84+ }
85+ else
86+ {
87+ int textColorProp = TMT_TEXTCOLOR ;
88+ if (optFlags & DTT_COLORPROP )
89+ textColorProp = options -> iColorPropId ;
90+
91+ if (FAILED (GetThemeColor (hTheme , iPartId , iStateId , textColorProp , & textColor )))
92+ textColor = GetTextColor (hdc );
93+ }
94+
95+ hr = GetThemeEnumValue (hTheme , iPartId , iStateId , TMT_TEXTSHADOWTYPE , & iShadowType );
96+ if (SUCCEEDED (hr ))
97+ {
98+ hr = GetThemeColor (hTheme , iPartId , iStateId , TMT_TEXTSHADOWCOLOR , & shadowColor );
99+ if (FAILED (hr ))
100+ {
101+ ERR ("GetThemeColor failed\n" );
102+ }
103+
104+ hr = GetThemePosition (hTheme , iPartId , iStateId , TMT_TEXTSHADOWOFFSET , & ptShadowOffset );
105+ if (FAILED (hr ))
106+ {
107+ ERR ("GetThemePosition failed\n" );
108+ }
109+
110+ if (iShadowType == TST_SINGLE )
111+ {
112+ oldTextColor = SetTextColor (hdc , shadowColor );
113+ OffsetRect (& rt , ptShadowOffset .x , ptShadowOffset .y );
114+ DrawTextW (hdc , pszText , iCharCount , & rt , dwTextFlags );
115+ OffsetRect (& rt , - ptShadowOffset .x , - ptShadowOffset .y );
116+ SetTextColor (hdc , oldTextColor );
117+ }
118+ else if (iShadowType == TST_CONTINUOUS )
119+ {
120+ HANDLE hcomctl32 = GetModuleHandleW (L"comctl32.dll" );
121+ DRAWSHADOWTEXT pDrawShadowText ;
122+ if (!hcomctl32 )
123+ {
124+ hcomctl32 = LoadLibraryW (L"comctl32.dll" );
125+ if (!hcomctl32 )
126+ ERR ("Failed to load comctl32\n" );
127+ }
128+
129+ pDrawShadowText = (DRAWSHADOWTEXT )GetProcAddress (hcomctl32 , "DrawShadowText" );
130+ if (pDrawShadowText )
131+ {
132+ pDrawShadowText (hdc , pszText , iCharCount , & rt , dwTextFlags , textColor , shadowColor , ptShadowOffset .x , ptShadowOffset .y );
133+ goto cleanup ;
134+ }
135+ }
136+ }
137+
138+ oldTextColor = SetTextColor (hdc , textColor );
139+ DrawTextW (hdc , pszText , iCharCount , & rt , dwTextFlags );
140+ SetTextColor (hdc , oldTextColor );
141+ cleanup :
142+ SetBkMode (hdc , oldBkMode );
143+
144+ if (hFont ) {
145+ SelectObject (hdc , oldFont );
146+ DeleteObject (hFont );
147+ }
148+ return S_OK ;
149+ }
150+ /***********************************************************************
151+ * GetThemeTransitionDuration (UXTHEME.@)
152+ */
153+ HRESULT WINAPI GetThemeTransitionDuration (HTHEME hTheme , int iPartId , int iStateIdFrom ,
154+ int iStateIdTo , int iPropId , DWORD * pdwDuration )
155+ {
156+ INTLIST intlist ;
157+ HRESULT hr ;
158+
159+ TRACE ("(%p, %d, %d, %d, %d, %p)\n" , hTheme , iPartId , iStateIdFrom , iStateIdTo , iPropId ,
160+ pdwDuration );
161+
162+ if (!pdwDuration || iStateIdFrom < 1 || iStateIdTo < 1 )
163+ return E_INVALIDARG ;
164+
165+ hr = GetThemeIntList (hTheme , iPartId , 0 , iPropId , & intlist );
166+ if (FAILED (hr ))
167+ {
168+ if (hr == E_PROP_ID_UNSUPPORTED )
169+ * pdwDuration = 0 ;
170+
171+ return hr ;
172+ }
173+
174+ if (intlist .iValueCount < 1 || iStateIdFrom > intlist .iValues [0 ]
175+ || iStateIdTo > intlist .iValues [0 ]
176+ || intlist .iValueCount != 1 + intlist .iValues [0 ] * intlist .iValues [0 ])
177+ {
178+ * pdwDuration = 0 ;
179+ return E_INVALIDARG ;
180+ }
181+
182+ * pdwDuration = intlist .iValues [1 + intlist .iValues [0 ] * (iStateIdFrom - 1 ) + (iStateIdTo - 1 )];
183+ return S_OK ;
184+ }
185+
186+ BOOL WINAPI IsCompositionActive (void )
187+ {
188+ // No DWM until we move to Vista+
189+ return FALSE;
190+ }
191+
192+ /***********************************************************************
193+ * SetWindowThemeAttribute (UXTHEME.@)
194+ */
195+ HRESULT
196+ WINAPI
197+ SetWindowThemeAttribute (
198+ _In_ HWND hwnd ,
199+ _In_ enum WINDOWTHEMEATTRIBUTETYPE eAttribute ,
200+ _In_ PVOID pvAttribute ,
201+ _In_ DWORD cbAttribute )
202+ {
203+ FIXME ("(%p,%d,%p,%ld): stub\n" , hwnd , eAttribute , pvAttribute , cbAttribute );
204+ return E_NOTIMPL ;
205+ }
206+
207+ /***********************************************************************
208+ * OpenThemeDataForDpi (UXTHEME.@)
209+ */
210+ HTHEME
211+ WINAPI
212+ OpenThemeDataForDpi (
213+ _In_ HWND hwnd ,
214+ _In_ LPCWSTR pszClassList ,
215+ _In_ UINT dpi )
216+ {
217+ FIXME ("dpi (%x) is currently ignored" , dpi );
218+ return OpenThemeData (hwnd , pszClassList );
219+ }
0 commit comments