Skip to content

Commit 8a59f2a

Browse files
SplitwirezDarkFire01
authored andcommitted
[UXTHEME] Implement various Vista+ functions, mostly from WINE
1 parent c7a7376 commit 8a59f2a

File tree

6 files changed

+419
-41
lines changed

6 files changed

+419
-41
lines changed

dll/win32/uxtheme/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11

22
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
33
add_definitions(-D__WINESRC__ -D__ROS_LONG64__)
4-
spec2def(uxtheme.dll uxtheme.spec ADD_IMPORTLIB)
4+
5+
if(DLL_EXPORT_VERSION GREATER_EQUAL 0x600)
6+
spec2def(uxtheme.dll uxtheme_vista.spec ADD_IMPORTLIB)
7+
else()
8+
spec2def(uxtheme.dll uxtheme.spec ADD_IMPORTLIB)
9+
endif()
510

611
list(APPEND SOURCE
712
buffer.c

dll/win32/uxtheme/buffer.c

Lines changed: 147 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,28 @@
1919
*/
2020

2121
#include "uxthemep.h"
22+
#include <wine/heap.h>
23+
24+
struct paintbuffer
25+
{
26+
HDC targetdc;
27+
HDC memorydc;
28+
HBITMAP bitmap;
29+
RECT rect;
30+
void *bits;
31+
};
32+
33+
static void free_paintbuffer(struct paintbuffer *buffer)
34+
{
35+
DeleteObject(buffer->bitmap);
36+
DeleteDC(buffer->memorydc);
37+
heap_free(buffer);
38+
}
39+
40+
static struct paintbuffer *get_buffer_obj(HPAINTBUFFER handle)
41+
{
42+
return handle;
43+
}
2244

2345
/***********************************************************************
2446
* BufferedPaintInit (UXTHEME.@)
@@ -41,35 +63,104 @@ HRESULT WINAPI BufferedPaintUnInit(VOID)
4163
/***********************************************************************
4264
* BeginBufferedPaint (UXTHEME.@)
4365
*/
44-
HPAINTBUFFER WINAPI BeginBufferedPaint(HDC hdcTarget,
45-
const RECT * prcTarget,
46-
BP_BUFFERFORMAT dwFormat,
47-
BP_PAINTPARAMS *pPaintParams,
48-
HDC *phdc)
66+
HPAINTBUFFER WINAPI BeginBufferedPaint(HDC targetdc, const RECT *rect,
67+
BP_BUFFERFORMAT format, BP_PAINTPARAMS *params, HDC *retdc)
4968
{
50-
static int i;
69+
#if (defined(_MSC_VER))
70+
char bmibuf[FIELD_OFFSET(BITMAPINFO, bmiColors) + 256 * sizeof(RGBQUAD)];
71+
#else
72+
char bmibuf[FIELD_OFFSET(BITMAPINFO, bmiColors[256])];
73+
#endif
74+
BITMAPINFO *bmi = (BITMAPINFO *)bmibuf;
75+
struct paintbuffer *buffer;
5176

52-
TRACE("Stub (%p %p %d %p %p)\n", hdcTarget, prcTarget, dwFormat,
53-
pPaintParams, phdc);
77+
TRACE("(%p %s %d %p %p)\n", targetdc, wine_dbgstr_rect(rect), format,
78+
params, retdc);
5479

55-
if (!i++)
56-
FIXME("Stub (%p %p %d %p %p)\n", hdcTarget, prcTarget, dwFormat,
57-
pPaintParams, phdc);
58-
return NULL;
80+
if (retdc)
81+
*retdc = NULL;
82+
83+
if (!targetdc || IsRectEmpty(rect))
84+
return NULL;
85+
86+
if (params)
87+
FIXME("painting parameters are ignored\n");
88+
89+
buffer = heap_alloc(sizeof(*buffer));
90+
buffer->targetdc = targetdc;
91+
buffer->rect = *rect;
92+
buffer->memorydc = CreateCompatibleDC(targetdc);
93+
94+
switch (format)
95+
{
96+
case BPBF_COMPATIBLEBITMAP:
97+
buffer->bitmap = CreateCompatibleBitmap(targetdc, rect->right - rect->left, rect->bottom - rect->top);
98+
buffer->bits = NULL;
99+
break;
100+
case BPBF_DIB:
101+
case BPBF_TOPDOWNDIB:
102+
case BPBF_TOPDOWNMONODIB:
103+
/* create DIB section */
104+
memset(bmi, 0, sizeof(bmibuf));
105+
bmi->bmiHeader.biSize = sizeof(bmi->bmiHeader);
106+
bmi->bmiHeader.biHeight = format == BPBF_DIB ? rect->bottom - rect->top :
107+
-(rect->bottom - rect->top);
108+
bmi->bmiHeader.biWidth = rect->right - rect->left;
109+
bmi->bmiHeader.biBitCount = format == BPBF_TOPDOWNMONODIB ? 1 : 32;
110+
bmi->bmiHeader.biPlanes = 1;
111+
bmi->bmiHeader.biCompression = BI_RGB;
112+
buffer->bitmap = CreateDIBSection(buffer->memorydc, bmi, DIB_RGB_COLORS, &buffer->bits, NULL, 0);
113+
break;
114+
default:
115+
WARN("Unknown buffer format %d\n", format);
116+
buffer->bitmap = NULL;
117+
free_paintbuffer(buffer);
118+
return NULL;
119+
}
120+
121+
if (!buffer->bitmap)
122+
{
123+
WARN("Failed to create buffer bitmap\n");
124+
free_paintbuffer(buffer);
125+
return NULL;
126+
}
127+
128+
SetWindowOrgEx(buffer->memorydc, rect->left, rect->top, NULL);
129+
IntersectClipRect(buffer->memorydc, rect->left, rect->top, rect->right, rect->bottom);
130+
DeleteObject(SelectObject(buffer->memorydc, buffer->bitmap));
131+
132+
*retdc = buffer->memorydc;
133+
134+
return (HPAINTBUFFER)buffer;
59135
}
60136

61137

62138
/***********************************************************************
63139
* EndBufferedPaint (UXTHEME.@)
64140
*/
65-
HRESULT WINAPI EndBufferedPaint(HPAINTBUFFER hPaintBuffer, BOOL fUpdateTarget)
141+
HRESULT WINAPI EndBufferedPaint(HPAINTBUFFER bufferhandle, BOOL update)
66142
{
67-
FIXME("Stub (%p %d)\n", hPaintBuffer, fUpdateTarget);
143+
struct paintbuffer *buffer = get_buffer_obj(bufferhandle);
144+
145+
TRACE("(%p %d)\n", bufferhandle, update);
146+
147+
if (!buffer)
148+
return E_INVALIDARG;
149+
150+
if (update)
151+
{
152+
if (!BitBlt(buffer->targetdc, buffer->rect.left, buffer->rect.top,
153+
buffer->rect.right - buffer->rect.left, buffer->rect.bottom - buffer->rect.top,
154+
buffer->memorydc, buffer->rect.left, buffer->rect.top, SRCCOPY))
155+
{
156+
WARN("BitBlt() failed\n");
157+
}
158+
}
159+
160+
free_paintbuffer(buffer);
68161
return S_OK;
69162
}
70163

71-
#ifndef __REACTOS__
72-
73164
/***********************************************************************
74165
* BufferedPaintClear (UXTHEME.@)
75166
*/
@@ -91,38 +182,65 @@ HRESULT WINAPI BufferedPaintSetAlpha(HPAINTBUFFER hBufferedPaint, const RECT *pr
91182
/***********************************************************************
92183
* GetBufferedPaintBits (UXTHEME.@)
93184
*/
94-
HRESULT WINAPI GetBufferedPaintBits(HPAINTBUFFER hBufferedPaint, RGBQUAD **ppbBuffer,
95-
int *pcxRow)
185+
HRESULT WINAPI GetBufferedPaintBits(HPAINTBUFFER bufferhandle, RGBQUAD **bits, int *width)
96186
{
97-
FIXME("Stub (%p %p %p)\n", hBufferedPaint, ppbBuffer, pcxRow);
98-
return E_NOTIMPL;
187+
struct paintbuffer *buffer = get_buffer_obj(bufferhandle);
188+
189+
TRACE("(%p %p %p)\n", buffer, bits, width);
190+
191+
if (!bits || !width)
192+
return E_POINTER;
193+
194+
if (!buffer || !buffer->bits)
195+
return E_FAIL;
196+
197+
*bits = buffer->bits;
198+
*width = buffer->rect.right - buffer->rect.left;
199+
200+
return S_OK;
99201
}
100202

101203
/***********************************************************************
102204
* GetBufferedPaintDC (UXTHEME.@)
103205
*/
104-
HDC WINAPI GetBufferedPaintDC(HPAINTBUFFER hBufferedPaint)
206+
HDC WINAPI GetBufferedPaintDC(HPAINTBUFFER bufferhandle)
105207
{
106-
FIXME("Stub (%p)\n", hBufferedPaint);
107-
return NULL;
208+
struct paintbuffer *buffer = get_buffer_obj(bufferhandle);
209+
210+
TRACE("(%p)\n", buffer);
211+
212+
return buffer ? buffer->memorydc : NULL;
108213
}
109214

110215
/***********************************************************************
111216
* GetBufferedPaintTargetDC (UXTHEME.@)
112217
*/
113-
HDC WINAPI GetBufferedPaintTargetDC(HPAINTBUFFER hBufferedPaint)
218+
HDC WINAPI GetBufferedPaintTargetDC(HPAINTBUFFER bufferhandle)
114219
{
115-
FIXME("Stub (%p)\n", hBufferedPaint);
116-
return NULL;
220+
struct paintbuffer *buffer = get_buffer_obj(bufferhandle);
221+
222+
TRACE("(%p)\n", buffer);
223+
224+
return buffer ? buffer->targetdc : NULL;
117225
}
118226

119227
/***********************************************************************
120228
* GetBufferedPaintTargetRect (UXTHEME.@)
121229
*/
122-
HRESULT WINAPI GetBufferedPaintTargetRect(HPAINTBUFFER hBufferedPaint, RECT *prc)
230+
HRESULT WINAPI GetBufferedPaintTargetRect(HPAINTBUFFER bufferhandle, RECT *rect)
123231
{
124-
FIXME("Stub (%p %p)\n", hBufferedPaint, prc);
125-
return E_NOTIMPL;
232+
struct paintbuffer *buffer = get_buffer_obj(bufferhandle);
233+
234+
TRACE("(%p %p)\n", buffer, rect);
235+
236+
if (!rect)
237+
return E_POINTER;
238+
239+
if (!buffer)
240+
return E_FAIL;
241+
242+
*rect = buffer->rect;
243+
return S_OK;
126244
}
127245

128246
/***********************************************************************
@@ -168,5 +286,3 @@ HRESULT WINAPI EndBufferedAnimation(HANIMATIONBUFFER hbpAnimation, BOOL fUpdateT
168286

169287
return E_NOTIMPL;
170288
}
171-
172-
#endif /* __REACTOS__ */

dll/win32/uxtheme/metric.c

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,16 +220,38 @@ HRESULT WINAPI GetThemeSysString(HTHEME hTheme, int iStringID,
220220
return E_PROP_ID_UNSUPPORTED;
221221
}
222222

223-
#ifndef __REACTOS__
224223
/***********************************************************************
225224
* GetThemeTransitionDuration (UXTHEME.@)
226225
*/
227226
HRESULT WINAPI GetThemeTransitionDuration(HTHEME hTheme, int iPartId, int iStateIdFrom,
228227
int iStateIdTo, int iPropId, DWORD *pdwDuration)
229228
{
230-
FIXME("(%p, %u, %u, %u, %u, %p) stub\n", hTheme, iPartId, iStateIdFrom, iStateIdTo,
231-
iPropId, pdwDuration);
229+
INTLIST intlist;
230+
HRESULT hr;
231+
232+
TRACE("(%p, %d, %d, %d, %d, %p)\n", hTheme, iPartId, iStateIdFrom, iStateIdTo, iPropId,
233+
pdwDuration);
234+
235+
if (!pdwDuration || iStateIdFrom < 1 || iStateIdTo < 1)
236+
return E_INVALIDARG;
237+
238+
hr = GetThemeIntList(hTheme, iPartId, 0, iPropId, &intlist);
239+
if (FAILED(hr))
240+
{
241+
if (hr == E_PROP_ID_UNSUPPORTED)
242+
*pdwDuration = 0;
243+
244+
return hr;
245+
}
246+
247+
if (intlist.iValueCount < 1 || iStateIdFrom > intlist.iValues[0]
248+
|| iStateIdTo > intlist.iValues[0]
249+
|| intlist.iValueCount != 1 + intlist.iValues[0] * intlist.iValues[0])
250+
{
251+
*pdwDuration = 0;
252+
return E_INVALIDARG;
253+
}
232254

233-
return E_NOTIMPL;
255+
*pdwDuration = intlist.iValues[1 + intlist.iValues[0] * (iStateIdFrom - 1) + (iStateIdTo - 1)];
256+
return S_OK;
234257
}
235-
#endif

dll/win32/uxtheme/system.c

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,37 @@ BOOL WINAPI IsThemeActive(void)
648648
return bActive;
649649
}
650650

651+
typedef HRESULT (WINAPI* DWMISCOMPOSITIONENABLED)(BOOL *enabled);
652+
653+
/************************************************************
654+
* IsCompositionActive (UXTHEME.@)
655+
*/
656+
BOOL WINAPI IsCompositionActive(void)
657+
{
658+
BOOL bIsCompositionActive;
659+
DWMISCOMPOSITIONENABLED pDwmIsCompositionEnabled;
660+
HMODULE hdwmapi = GetModuleHandleW(L"dwmapi.dll");
661+
662+
if (!hdwmapi)
663+
{
664+
hdwmapi = LoadLibraryW(L"dwmapi.dll");
665+
if (!hdwmapi)
666+
{
667+
ERR("Failed to load dwmapi\n");
668+
return FALSE;
669+
}
670+
671+
pDwmIsCompositionEnabled = (DWMISCOMPOSITIONENABLED)GetProcAddress(hdwmapi, "DwmIsCompositionEnabled");
672+
}
673+
if (!pDwmIsCompositionEnabled)
674+
return FALSE;
675+
676+
if (pDwmIsCompositionEnabled(&bIsCompositionActive) == S_OK)
677+
return bIsCompositionActive;
678+
679+
return FALSE;
680+
}
681+
651682
/***********************************************************************
652683
* EnableTheming (UXTHEME.@)
653684
*
@@ -847,9 +878,23 @@ HTHEME WINAPI OpenThemeDataFromFile(HTHEMEFILE hThemeFile, HWND hwnd, LPCWSTR ps
847878
/***********************************************************************
848879
* OpenThemeData (UXTHEME.@)
849880
*/
850-
HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR classlist)
881+
HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR pszClassList)
882+
{
883+
return OpenThemeDataInternal(g_ActiveThemeFile, hwnd, pszClassList, 0);
884+
}
885+
886+
/***********************************************************************
887+
* OpenThemeDataForDpi (UXTHEME.@)
888+
*/
889+
HTHEME
890+
WINAPI
891+
OpenThemeDataForDpi(
892+
_In_ HWND hwnd,
893+
_In_ LPCWSTR pszClassList,
894+
_In_ UINT dpi)
851895
{
852-
return OpenThemeDataInternal(g_ActiveThemeFile, hwnd, classlist, 0);
896+
FIXME("dpi (%x) is currently ignored", dpi);
897+
return OpenThemeDataInternal(g_ActiveThemeFile, hwnd, pszClassList, 0);
853898
}
854899

855900
/***********************************************************************
@@ -903,6 +948,23 @@ HRESULT WINAPI SetWindowTheme(HWND hwnd, LPCWSTR pszSubAppName,
903948
return hr;
904949
}
905950

951+
#if (DLL_EXPORT_VERSION >= _WIN32_WINNT_VISTA)
952+
/***********************************************************************
953+
* SetWindowThemeAttribute (UXTHEME.@)
954+
*/
955+
HRESULT
956+
WINAPI
957+
SetWindowThemeAttribute(
958+
_In_ HWND hwnd,
959+
_In_ enum WINDOWTHEMEATTRIBUTETYPE eAttribute,
960+
_In_ PVOID pvAttribute,
961+
_In_ DWORD cbAttribute)
962+
{
963+
FIXME("(%p,%d,%p,%ld): stub\n", hwnd, eAttribute, pvAttribute, cbAttribute);
964+
return E_NOTIMPL;
965+
}
966+
#endif /* (DLL_EXPORT_VERSION >= _WIN32_WINNT_VISTA) */
967+
906968
/***********************************************************************
907969
* GetCurrentThemeName (UXTHEME.@)
908970
*/

0 commit comments

Comments
 (0)