Skip to content

Commit 5a131ad

Browse files
[UXTHEME] Add uxtheme_ros
Add DLL for use in winesyncs, for functions such as DrawThemeTextEx
1 parent 529246b commit 5a131ad

5 files changed

Lines changed: 239 additions & 5 deletions

File tree

dll/win32/uxtheme/CMakeLists.txt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
add_definitions(-D__WINESRC__ -D__ROS_LONG64__)
33

4+
spec2def(uxtheme_ros.dll uxtheme_vista.spec ADD_IMPORTLIB)
45
if(DLL_EXPORT_VERSION GREATER_EQUAL 0x600)
56
spec2def(uxtheme.dll uxtheme_vista.spec ADD_IMPORTLIB)
67
else()
@@ -22,8 +23,7 @@ list(APPEND SOURCE
2223
system.c
2324
themehooks.c
2425
uxini.c
25-
uxthemep.h
26-
${CMAKE_CURRENT_BINARY_DIR}/uxtheme_stubs.c)
26+
uxthemep.h)
2727

2828
if(DLL_EXPORT_VERSION GREATER_EQUAL 0x600)
2929
add_definitions(-DENABLE_PNG_SUPPORT)
@@ -37,6 +37,7 @@ add_rc_deps(uxtheme.rc ${uxtheme_rc_deps})
3737

3838
add_library(uxtheme MODULE
3939
${SOURCE}
40+
${CMAKE_CURRENT_BINARY_DIR}/uxtheme_stubs.c
4041
uxtheme.rc
4142
${CMAKE_CURRENT_BINARY_DIR}/uxtheme.def)
4243

@@ -50,3 +51,18 @@ else()
5051
endif()
5152
add_pch(uxtheme uxthemep.h SOURCE)
5253
add_cd_file(TARGET uxtheme DESTINATION reactos/system32 FOR all)
54+
55+
56+
add_library(uxtheme_ros MODULE
57+
buffer.c
58+
vista.c
59+
${CMAKE_CURRENT_BINARY_DIR}/uxtheme_ros_stubs.c
60+
uxtheme.rc
61+
${CMAKE_CURRENT_BINARY_DIR}/uxtheme_ros.def)
62+
63+
set_module_type(uxtheme_ros win32dll)
64+
target_link_libraries(uxtheme_ros wine)
65+
add_delay_importlibs(uxtheme_ros msimg32)
66+
add_importlibs(uxtheme_ros uxtheme user32 advapi32 gdiplus gdi32 shlwapi msvcrt kernel32 ntdll)
67+
add_pch(uxtheme_ros uxthemep.h SOURCE)
68+
add_cd_file(TARGET uxtheme_ros DESTINATION reactos/system32 FOR all)

dll/win32/uxtheme/system.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,6 @@ HRESULT WINAPI SetWindowTheme(HWND hwnd, LPCWSTR pszSubAppName,
957957
return hr;
958958
}
959959

960-
#if (DLL_EXPORT_VERSION >= _WIN32_WINNT_VISTA)
961960
/***********************************************************************
962961
* SetWindowThemeAttribute (UXTHEME.@)
963962
*/
@@ -972,7 +971,6 @@ SetWindowThemeAttribute(
972971
FIXME("(%p,%d,%p,%ld): stub\n", hwnd, eAttribute, pvAttribute, cbAttribute);
973972
return E_NOTIMPL;
974973
}
975-
#endif /* (DLL_EXPORT_VERSION >= _WIN32_WINNT_VISTA) */
976974

977975
/***********************************************************************
978976
* GetCurrentThemeName (UXTHEME.@)

dll/win32/uxtheme/vista.c

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
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+
}

sdk/include/psdk/uxtheme.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ BOOL WINAPI IsThemeDialogTextureEnabled(HWND);
200200
BOOL WINAPI IsThemePartDefined(HTHEME,int,int);
201201
HTHEME WINAPI OpenThemeData(HWND,LPCWSTR);
202202
HTHEME WINAPI OpenThemeDataEx(HWND,LPCWSTR,DWORD);
203+
HTHEME WINAPI OpenThemeDataForDpi(HWND,LPCWSTR,UINT);
203204
void WINAPI SetThemeAppProperties(DWORD);
204205
HRESULT WINAPI SetWindowTheme(HWND,LPCWSTR,LPCWSTR);
205206

win32ss/user/ntuser/window.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2804,7 +2804,7 @@ NtUserCreateWindowEx(
28042804

28052805
if(!pwnd)
28062806
{
2807-
ERR("co_UserCreateWindowEx failed!\n");
2807+
TRACE("co_UserCreateWindowEx failed!\n");
28082808
}
28092809
hwnd = pwnd ? UserHMGetHandle(pwnd) : NULL;
28102810

0 commit comments

Comments
 (0)