Author: gadamopoulos
Date: Mon Sep 19 12:51:42 2011
New Revision: 53748
URL:
http://svn.reactos.org/svn/reactos?rev=53748&view=rev
Log:
[uxtheme]
- Merge from the themes branch
Added:
trunk/reactos/dll/win32/uxtheme/ncscrollbar.c
- copied unchanged from r53732,
branches/GSoC_2011/ThemesSupport/dll/win32/uxtheme/ncscrollbar.c
trunk/reactos/dll/win32/uxtheme/ncthm.h
- copied unchanged from r53732,
branches/GSoC_2011/ThemesSupport/dll/win32/uxtheme/ncthm.h
trunk/reactos/dll/win32/uxtheme/nonclient.c
- copied unchanged from r53732,
branches/GSoC_2011/ThemesSupport/dll/win32/uxtheme/nonclient.c
trunk/reactos/dll/win32/uxtheme/themehooks.c
- copied unchanged from r53732,
branches/GSoC_2011/ThemesSupport/dll/win32/uxtheme/themehooks.c
Modified:
trunk/reactos/dll/win32/uxtheme/CMakeLists.txt
trunk/reactos/dll/win32/uxtheme/draw.c
trunk/reactos/dll/win32/uxtheme/msstyles.c
trunk/reactos/dll/win32/uxtheme/system.c
trunk/reactos/dll/win32/uxtheme/uxtheme.rbuild
trunk/reactos/dll/win32/uxtheme/uxtheme.spec
trunk/reactos/dll/win32/uxtheme/uxthemedll.h
Modified: trunk/reactos/dll/win32/uxtheme/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/uxtheme/CMakeLis…
==============================================================================
--- trunk/reactos/dll/win32/uxtheme/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/uxtheme/CMakeLists.txt [iso-8859-1] Mon Sep 19 12:51:42 2011
@@ -11,9 +11,12 @@
main.c
metric.c
msstyles.c
+ ncscrollbar.c
+ nonclient.c
property.c
stylemap.c
system.c
+ themehooks.c
uxini.c
version.rc
${CMAKE_CURRENT_BINARY_DIR}/uxtheme_stubs.c
Modified: trunk/reactos/dll/win32/uxtheme/draw.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/uxtheme/draw.c?r…
==============================================================================
--- trunk/reactos/dll/win32/uxtheme/draw.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/uxtheme/draw.c [iso-8859-1] Mon Sep 19 12:51:42 2011
@@ -1731,6 +1731,166 @@
return S_OK;
}
+
+static HBITMAP UXTHEME_DrawThemePartToDib(HTHEME hTheme, HDC hdc, int iPartId, int
iStateId, LPCRECT pRect)
+{
+ HDC hdcMem;
+ BITMAPINFO bmi = {0};
+ HBITMAP hbmp, hbmpOld;
+ HBRUSH hbrBack;
+
+ hdcMem = CreateCompatibleDC(0);
+
+ bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
+ bmi.bmiHeader.biWidth = pRect->right;
+ bmi.bmiHeader.biHeight = -pRect->bottom;
+ bmi.bmiHeader.biPlanes = 1;
+ bmi.bmiHeader.biBitCount = 32;
+ hbmp = CreateDIBSection(hdcMem, &bmi, DIB_RGB_COLORS , NULL, 0, 0);
+
+ hbmpOld = (HBITMAP)SelectObject(hdcMem, hbmp);
+
+ /* FIXME: use an internal function that doesn't do transparent blt */
+ hbrBack = CreateSolidBrush(RGB(255,0,255));
+
+ FillRect(hdcMem, pRect, hbrBack);
+
+ DrawThemeBackground(hTheme, hdcMem, iPartId, iStateId, pRect, NULL);
+
+ DeleteObject(hbrBack);
+ SelectObject(hdcMem, hbmpOld);
+ DeleteObject(hdcMem);
+
+ return hbmp;
+}
+
+#define PT_IN_RECT(lprc,x,y) ( x >= lprc->left && x < lprc->right
&& \
+ y >= lprc->top && y < lprc->bottom)
+
+static HRGN UXTHEME_RegionFromDibBits(RGBQUAD* pBuffer, RGBQUAD* pclrTransparent, LPCRECT
pRect)
+{
+ int x, y, xstart;
+ int cMaxRgnRects, cRgnDataSize, cRgnRects;
+#ifdef EXTCREATEREGION_WORKS
+ RECT* prcCurrent;
+ PRGNDATA prgnData;
+#else
+ HRGN hrgnTemp;
+#endif
+ ULONG clrTransparent, *pclrCurrent;
+ HRGN hrgnRet;
+
+ pclrCurrent = (PULONG)pBuffer;
+ clrTransparent = *(PULONG)pclrTransparent;
+
+ /* Create a region and pre-allocate memory enough for 3 spaces in one row*/
+ cRgnRects = 0;
+ cMaxRgnRects = 4* (pRect->bottom-pRect->top);
+ cRgnDataSize = sizeof(RGNDATA) + cMaxRgnRects * sizeof(RECT);
+
+#ifdef EXTCREATEREGION_WORKS
+ /* Allocate the region data */
+ prgnData = (PRGNDATA)HeapAlloc(GetProcessHeap(), 0, cRgnDataSize);
+
+ prcCurrent = (PRECT)prgnData->Buffer;
+#else
+ hrgnRet = CreateRectRgn(0,0,0,0);
+#endif
+
+ /* Calculate the region rects */
+ y=0;
+ /* Scan each line of the bitmap */
+ while(y<pRect->bottom)
+ {
+ x=0;
+ /* Scan each pixel */
+ while (x<pRect->right)
+ {
+ /* Check if the pixel is not transparent and it is in the requested rect */
+ if(*pclrCurrent != clrTransparent && PT_IN_RECT(pRect,x,y))
+ {
+ xstart = x;
+ /* Find the end of the opaque row of pixels */
+ while (x<pRect->right)
+ {
+ if(*pclrCurrent == clrTransparent || !PT_IN_RECT(pRect,x,y))
+ break;
+ x++;
+ pclrCurrent++;
+ }
+
+#ifdef EXTCREATEREGION_WORKS
+ /* Add the scaned line to the region */
+ SetRect(prcCurrent, xstart, y,x,y+1);
+ prcCurrent++;
+ cRgnRects++;
+
+ /* Increase the size of the buffer if it is full */
+ if(cRgnRects == cMaxRgnRects)
+ {
+ cMaxRgnRects *=2;
+ cRgnDataSize = sizeof(RGNDATA) + cMaxRgnRects * sizeof(RECT);
+ prgnData = (PRGNDATA)HeapReAlloc(GetProcessHeap(),
+ 0,
+ prgnData,
+ cRgnDataSize);
+ prcCurrent = (RECT*)prgnData->Buffer + cRgnRects;
+ }
+#else
+ hrgnTemp = CreateRectRgn(xstart, y,x,y+1);
+ CombineRgn(hrgnRet, hrgnRet, hrgnTemp, RGN_OR );
+ DeleteObject(hrgnTemp);
+#endif
+ }
+ else
+ {
+ x++;
+ pclrCurrent++;
+ }
+ }
+ y++;
+ }
+
+#ifdef EXTCREATEREGION_WORKS
+ /* Fill the region data header */
+ prgnData->rdh.dwSize = sizeof(prgnData->rdh);
+ prgnData->rdh.iType = RDH_RECTANGLES;
+ prgnData->rdh.nCount = cRgnRects;
+ prgnData->rdh.nRgnSize = cRgnDataSize;
+ prgnData->rdh.rcBound = *pRect;
+
+ /* Create the region*/
+ hrgnRet = ExtCreateRegion (NULL, cRgnDataSize, prgnData);
+
+ /* Free the region data*/
+ HeapFree(GetProcessHeap(),0,prgnData);
+#endif
+
+ /* return the region*/
+ return hrgnRet;
+}
+
+HRESULT UXTHEME_GetImageBackBackgroundRegion(HTHEME hTheme, HDC hdc, int iPartId, int
iStateId, LPCRECT pRect, HRGN *pRegion)
+{
+ HBITMAP hbmp;
+ DIBSECTION dib;
+ RGBQUAD clrTransparent = {0xFF,0x0, 0xFF,0x0};
+
+ /* Draw the theme part to a dib */
+ hbmp = UXTHEME_DrawThemePartToDib(hTheme, hdc, iPartId, iStateId, pRect);
+
+ /* Retrieve the info of the dib section */
+ GetObject(hbmp, sizeof (DIBSECTION), &dib);
+
+ /* Convert the bits of the dib section to a region */
+ *pRegion = UXTHEME_RegionFromDibBits((RGBQUAD*)dib.dsBm.bmBits, &clrTransparent,
pRect);
+
+ /* Free the temp bitmap */
+ DeleteObject(hbmp);
+
+ return S_OK;
+}
+
/***********************************************************************
* GetThemeBackgroundRegion (UXTHEME.@)
*
@@ -1752,8 +1912,7 @@
GetThemeEnumValue(hTheme, iPartId, iStateId, TMT_BGTYPE, &bgtype);
if(bgtype == BT_IMAGEFILE) {
- FIXME("Images not handled yet\n");
- hr = ERROR_CALL_NOT_IMPLEMENTED;
+ hr = UXTHEME_GetImageBackBackgroundRegion(hTheme, hdc, iPartId, iStateId, pRect,
pRegion);
}
else if(bgtype == BT_BORDERFILL) {
*pRegion = CreateRectRgn(pRect->left, pRect->top, pRect->right,
pRect->bottom);
Modified: trunk/reactos/dll/win32/uxtheme/msstyles.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/uxtheme/msstyles…
==============================================================================
--- trunk/reactos/dll/win32/uxtheme/msstyles.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/uxtheme/msstyles.c [iso-8859-1] Mon Sep 19 12:51:42 2011
@@ -1257,6 +1257,13 @@
*lpValEnd = lpCur;
return E_PROP_ID_UNSUPPORTED;
}
+ if(pointSize > 0)
+ {
+ HDC hdc = GetDC(0);
+ pointSize = -MulDiv(pointSize, GetDeviceCaps(hdc, LOGPIXELSY), 72);
+ ReleaseDC(0, hdc);
+ }
+
pFont->lfHeight = pointSize;
pFont->lfWeight = FW_REGULAR;
pFont->lfCharSet = DEFAULT_CHARSET;
@@ -1278,8 +1285,6 @@
ZeroMemory(pFont, sizeof(LOGFONTW));
hr = MSSTYLES_GetFont (lpCur, lpEnd, &lpCur, pFont);
- if (SUCCEEDED (hr))
- pFont->lfHeight = -MulDiv(pFont->lfHeight, GetDeviceCaps(hdc, LOGPIXELSY),
72);
return hr;
}
Modified: trunk/reactos/dll/win32/uxtheme/system.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/uxtheme/system.c…
==============================================================================
--- trunk/reactos/dll/win32/uxtheme/system.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/uxtheme/system.c [iso-8859-1] Mon Sep 19 12:51:42 2011
@@ -31,9 +31,11 @@
#include "vfwmsgs.h"
#include "uxtheme.h"
#include "tmschema.h"
+#include "uxundoc.h"
#include "uxthemedll.h"
#include "msstyles.h"
+#include "ncthm.h"
#include "wine/debug.h"
@@ -61,9 +63,10 @@
ATOM atDialogThemeEnabled;
static DWORD dwThemeAppProperties = STAP_ALLOW_NONCLIENT | STAP_ALLOW_CONTROLS;
-static ATOM atWindowTheme;
+ATOM atWindowTheme;
static ATOM atSubAppName;
static ATOM atSubIdList;
+ATOM atWndContrext;
static BOOL bThemeActive = FALSE;
static WCHAR szCurrentTheme[MAX_PATH];
@@ -79,7 +82,7 @@
}
/* Broadcast a message to *all* windows, including children */
-static BOOL CALLBACK UXTHEME_broadcast_msg (HWND hWnd, LPARAM msg)
+BOOL CALLBACK UXTHEME_broadcast_msg (HWND hWnd, LPARAM msg)
{
if (hWnd == NULL)
{
@@ -140,7 +143,6 @@
}
}
- RegCloseKey(hKey);
return dwRet;
}
@@ -149,7 +151,7 @@
*
* Set the current active theme from the registry
*/
-static void UXTHEME_LoadTheme(void)
+void UXTHEME_LoadTheme(BOOL bLoad)
{
HKEY hKey;
DWORD buffsize;
@@ -157,29 +159,36 @@
WCHAR tmp[10];
PTHEME_FILE pt;
- /* Get current theme configuration */
- if(!RegOpenKeyW(HKEY_CURRENT_USER, szThemeManager, &hKey)) {
- TRACE("Loading theme config\n");
- buffsize = sizeof(tmp)/sizeof(tmp[0]);
- if(!RegQueryValueExW(hKey, szThemeActive, NULL, NULL, (LPBYTE)tmp,
&buffsize)) {
- bThemeActive = (tmp[0] != '0');
+ if(bLoad == TRUE)
+ {
+ /* Get current theme configuration */
+ if(!RegOpenKeyW(HKEY_CURRENT_USER, szThemeManager, &hKey)) {
+ TRACE("Loading theme config\n");
+ buffsize = sizeof(tmp)/sizeof(tmp[0]);
+ if(!RegQueryValueExW(hKey, szThemeActive, NULL, NULL, (LPBYTE)tmp,
&buffsize)) {
+ bThemeActive = (tmp[0] != '0');
+ }
+ else {
+ bThemeActive = FALSE;
+ TRACE("Failed to get ThemeActive: %d\n", GetLastError());
+ }
+ buffsize = sizeof(szCurrentColor)/sizeof(szCurrentColor[0]);
+ if(RegQueryValueExW(hKey, szColorName, NULL, NULL, (LPBYTE)szCurrentColor,
&buffsize))
+ szCurrentColor[0] = '\0';
+ buffsize = sizeof(szCurrentSize)/sizeof(szCurrentSize[0]);
+ if(RegQueryValueExW(hKey, szSizeName, NULL, NULL, (LPBYTE)szCurrentSize,
&buffsize))
+ szCurrentSize[0] = '\0';
+ if (query_reg_path (hKey, szDllName, szCurrentTheme))
+ szCurrentTheme[0] = '\0';
+ RegCloseKey(hKey);
}
- else {
- bThemeActive = FALSE;
- TRACE("Failed to get ThemeActive: %d\n", GetLastError());
- }
- buffsize = sizeof(szCurrentColor)/sizeof(szCurrentColor[0]);
- if(RegQueryValueExW(hKey, szColorName, NULL, NULL, (LPBYTE)szCurrentColor,
&buffsize))
- szCurrentColor[0] = '\0';
- buffsize = sizeof(szCurrentSize)/sizeof(szCurrentSize[0]);
- if(RegQueryValueExW(hKey, szSizeName, NULL, NULL, (LPBYTE)szCurrentSize,
&buffsize))
- szCurrentSize[0] = '\0';
- if (query_reg_path (hKey, szDllName, szCurrentTheme))
- szCurrentTheme[0] = '\0';
- RegCloseKey(hKey);
+ else
+ TRACE("Failed to open theme registry key\n");
}
else
- TRACE("Failed to open theme registry key\n");
+ {
+ bThemeActive = FALSE;
+ }
if(bThemeActive) {
/* Make sure the theme requested is actually valid */
@@ -543,8 +552,7 @@
atSubAppName = GlobalAddAtomW(szSubAppName);
atSubIdList = GlobalAddAtomW(szSubIdList);
atDialogThemeEnabled = GlobalAddAtomW(szDialogThemeEnabled);
-
- UXTHEME_LoadTheme();
+ atWndContrext = GlobalAddAtomW(L"ux_WndContext");
}
/***********************************************************************
@@ -973,7 +981,7 @@
* Success: S_OK
* Failure: HRESULT error-code
*/
-HRESULT WINAPI EnumThemes(LPCWSTR pszThemePath, EnumThemeProc callback,
+HRESULT WINAPI EnumThemes(LPCWSTR pszThemePath, ENUMTHEMEPROC callback,
LPVOID lpData)
{
WCHAR szDir[MAX_PATH];
@@ -1171,7 +1179,7 @@
* any other purpose
*/
HRESULT WINAPI ParseThemeIniFile(LPCWSTR pszIniFileName, LPWSTR pszUnknown,
- ParseThemeIniFileProc callback, LPVOID lpData)
+ PARSETHEMEINIFILEPROC callback, LPVOID lpData)
{
FIXME("%s %s: stub\n", debugstr_w(pszIniFileName),
debugstr_w(pszUnknown));
return ERROR_CALL_NOT_IMPLEMENTED;
Modified: trunk/reactos/dll/win32/uxtheme/uxtheme.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/uxtheme/uxtheme.…
==============================================================================
--- trunk/reactos/dll/win32/uxtheme/uxtheme.rbuild [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/uxtheme/uxtheme.rbuild [iso-8859-1] Mon Sep 19 12:51:42 2011
@@ -11,9 +11,12 @@
<file>main.c</file>
<file>metric.c</file>
<file>msstyles.c</file>
+ <file>ncscrollbar.c</file>
+ <file>nonclient.c</file>
<file>property.c</file>
<file>stylemap.c</file>
<file>system.c</file>
+ <file>themehooks.c</file>
<file>uxini.c</file>
<file>version.rc</file>
<library>wine</library>
Modified: trunk/reactos/dll/win32/uxtheme/uxtheme.spec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/uxtheme/uxtheme.…
==============================================================================
--- trunk/reactos/dll/win32/uxtheme/uxtheme.spec [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/uxtheme/uxtheme.spec [iso-8859-1] Mon Sep 19 12:51:42 2011
@@ -29,8 +29,8 @@
31 stub -noname InitUserTheme
32 stub -noname InitUserRegistry
33 stub -noname ReestablishServerConnection
-34 stub -noname ThemeHooksInstall
-35 stub -noname ThemeHooksRemove
+34 stdcall -noname ThemeHooksInstall()
+35 stdcall -noname ThemeHooksRemove()
36 stub -noname RefreshThemeForTS
43 stub -noname ClassicGetSystemMetrics
44 stub -noname ClassicSystemParametersInfoA
@@ -95,3 +95,4 @@
@ stdcall OpenThemeData(ptr wstr)
@ stdcall SetThemeAppProperties(long)
@ stdcall SetWindowTheme(ptr wstr wstr)
+@ stdcall ThemeInitApiHook(long ptr)
Modified: trunk/reactos/dll/win32/uxtheme/uxthemedll.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/uxtheme/uxthemed…
==============================================================================
--- trunk/reactos/dll/win32/uxtheme/uxthemedll.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/uxtheme/uxthemedll.h [iso-8859-1] Mon Sep 19 12:51:42 2011
@@ -21,80 +21,9 @@
#ifndef __WINE_UXTHEMEDLL_H
#define __WINE_UXTHEMEDLL_H
-typedef HANDLE HTHEMEFILE;
-
-/**********************************************************************
- * EnumThemeProc
- *
- * Callback function for EnumThemes.
- *
- * RETURNS
- * TRUE to continue enumeration, FALSE to stop
- *
- * PARAMS
- * lpReserved Always 0
- * pszThemeFileName Full path to theme msstyles file
- * pszThemeName Display name for theme
- * pszToolTip Tooltip name for theme
- * lpReserved2 Always 0
- * lpData Value passed through lpData from EnumThemes
- */
-typedef BOOL (CALLBACK *EnumThemeProc)(LPVOID lpReserved, LPCWSTR pszThemeFileName,
- LPCWSTR pszThemeName, LPCWSTR pszToolTip, LPVOID
lpReserved2,
- LPVOID lpData);
-
-/**********************************************************************
- * ParseThemeIniFileProc
- *
- * Callback function for ParseThemeIniFile.
- *
- * RETURNS
- * TRUE to continue enumeration, FALSE to stop
- *
- * PARAMS
- * dwType Entry type
- * pszParam1 Use defined by entry type
- * pszParam2 Use defined by entry type
- * pszParam3 Use defined by entry type
- * dwParam Use defined by entry type
- * lpData Value passed through lpData from ParseThemeIniFile
- *
- * NOTES
- * I don't know what the valid entry types are
- */
-typedef BOOL (CALLBACK*ParseThemeIniFileProc)(DWORD dwType, LPWSTR pszParam1,
- LPWSTR pszParam2, LPWSTR pszParam3,
- DWORD dwParam, LPVOID lpData);
-
-/* Structure filled in by EnumThemeColors() and EnumeThemeSizes() with the
- * various strings for a theme color or size. */
-typedef struct tagTHEMENAMES
-{
- WCHAR szName[MAX_PATH+1];
- WCHAR szDisplayName[MAX_PATH+1];
- WCHAR szTooltip[MAX_PATH+1];
-} THEMENAMES, *PTHEMENAMES;
-
-/* Declarations for undocumented functions for use internally */
-DWORD WINAPI QueryThemeServices(void);
-HRESULT WINAPI OpenThemeFile(LPCWSTR pszThemeFileName, LPCWSTR pszColorName,
- LPCWSTR pszSizeName, HTHEMEFILE *hThemeFile,
- DWORD unknown);
-HRESULT WINAPI CloseThemeFile(HTHEMEFILE hThemeFile);
-HRESULT WINAPI ApplyTheme(HTHEMEFILE hThemeFile, char *unknown, HWND hWnd);
-HRESULT WINAPI GetThemeDefaults(LPCWSTR pszThemeFileName, LPWSTR pszColorName,
- DWORD dwColorNameLen, LPWSTR pszSizeName,
- DWORD dwSizeNameLen);
-HRESULT WINAPI EnumThemes(LPCWSTR pszThemePath, EnumThemeProc callback,
- LPVOID lpData);
-HRESULT WINAPI EnumThemeColors(LPWSTR pszThemeFileName, LPWSTR pszSizeName,
- DWORD dwColorNum, PTHEMENAMES pszColorNames);
-HRESULT WINAPI EnumThemeSizes(LPWSTR pszThemeFileName, LPWSTR pszColorName,
- DWORD dwSizeNum, PTHEMENAMES pszColorNames);
-HRESULT WINAPI ParseThemeIniFile(LPCWSTR pszIniFileName, LPWSTR pszUnknown,
- ParseThemeIniFileProc callback, LPVOID lpData);
-
extern void UXTHEME_InitSystem(HINSTANCE hInst);
+extern void UXTHEME_LoadTheme(BOOL bLoad);
+extern BOOL CALLBACK UXTHEME_broadcast_msg (HWND hWnd, LPARAM msg);
/* No alpha blending */
#define ALPHABLEND_NONE 0