diff options
author | George Hazan <george.hazan@gmail.com> | 2014-12-03 09:48:40 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-12-03 09:48:40 +0000 |
commit | 7ce3ed55b501b4d54ff73c9717cf858784769e02 (patch) | |
tree | 85f16c6a1712ac9a7742a5c95b9f97ef4e5c9553 | |
parent | 7e252e5a42579e5082d760eb56a61c2e7a51d854 (diff) |
code cleaning using mir_cs*
git-svn-id: http://svn.miranda-ng.org/main/trunk@11227 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/Clist_modern/src/init.cpp | 1 | ||||
-rw-r--r-- | plugins/Clist_modern/src/m_api/m_xpTheme.h | 5 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_xptheme.cpp | 162 |
3 files changed, 59 insertions, 109 deletions
diff --git a/plugins/Clist_modern/src/init.cpp b/plugins/Clist_modern/src/init.cpp index 8387f6f17d..45f7a81d1c 100644 --- a/plugins/Clist_modern/src/init.cpp +++ b/plugins/Clist_modern/src/init.cpp @@ -84,7 +84,6 @@ extern "C" __declspec(dllexport) int CListInitialise() CHECKRES ( PreLoadContactListModule ( ) );
CHECKRES ( SubclassClistInterface ( ) );
CHECKRES ( CreateHookableEvents ( ) );
- CHECKRES ( XPThemesLoadModule ( ) );
CHECKRES ( SkinEngineLoadModule ( ) );
CHECKRES ( BackgroundsLoadModule ( ) );
CHECKRES ( CluiLoadModule ( ) );
diff --git a/plugins/Clist_modern/src/m_api/m_xpTheme.h b/plugins/Clist_modern/src/m_api/m_xpTheme.h index 63f1b0a5d3..fc4b384b59 100644 --- a/plugins/Clist_modern/src/m_api/m_xpTheme.h +++ b/plugins/Clist_modern/src/m_api/m_xpTheme.h @@ -1,6 +1,6 @@ /* Wrapper for XP theme */
typedef void * XPTHANDLE;
-typedef HANDLE HTHEME;
+typedef HANDLE HTHEME;
XPTHANDLE xpt_AddThemeHandle(HWND hwnd, LPCWSTR className);
void xpt_FreeThemeHandle(XPTHANDLE xptHandle);
@@ -15,7 +15,6 @@ BOOL xpt_IsThemed(XPTHANDLE xptHandle); BOOL xpt_EnableThemeDialogTexture(HWND hwnd, DWORD flags);
// next will be called only from one place
-HRESULT XPThemesLoadModule();
void XPThemesUnloadModule();
void xpt_OnWM_THEMECHANGED();
@@ -25,7 +24,7 @@ void xpt_OnWM_THEMECHANGED(); //#include <tmschema.h>
//TODO: ADD HERE other definitions of part and states from <tmschema.h>
-//WINDOW
+//WINDOW
#define WP_CAPTION 1
#define WP_SMALLCAPTION 2
#define WP_SMALLMINCAPTION 4
diff --git a/plugins/Clist_modern/src/modern_xptheme.cpp b/plugins/Clist_modern/src/modern_xptheme.cpp index 6a671a521f..e81b968e8f 100644 --- a/plugins/Clist_modern/src/modern_xptheme.cpp +++ b/plugins/Clist_modern/src/modern_xptheme.cpp @@ -13,176 +13,128 @@ typedef struct _tagXPTObject } XPTObject;
static OBJLIST<XPTObject> xptObjectList(1);
-static CRITICAL_SECTION xptCS;
-
-#define xptlock() EnterCriticalSection(&xptCS)
-#define xptunlock() LeaveCriticalSection(&xptCS)
+static mir_cs xptCS;
static void _sttXptCloseThemeData(XPTObject * xptObject)
{
CloseThemeData(xptObject->hThemeHandle);
xptObject->hThemeHandle = NULL;
}
+
static void _sttXptReloadThemeData(XPTObject * xptObject)
{
CloseThemeData(xptObject->hThemeHandle);
xptObject->hThemeHandle = OpenThemeData(xptObject->hOwnerWindow, xptObject->lpcwClassObject);
}
-
-HRESULT XPThemesLoadModule()
-{
- InitializeCriticalSection(&xptCS);
- return S_OK;
-}
-
void XPThemesUnloadModule()
{
- xptlock();
- xptunlock();
xptObjectList.destroy();
- DeleteCriticalSection(&xptCS);
}
-
BOOL xpt_IsThemed(XPTHANDLE xptHandle)
{
- BOOL res = FALSE;
if (!xptHandle) return FALSE;
- xptlock();
- {
- if (xpt_IsValidHandle(xptHandle) && ((XPTObject*) xptHandle)->hThemeHandle)
- res = TRUE;
- }
- xptunlock();
- return res;
+
+ mir_cslock lck(xptCS);
+ return xpt_IsValidHandle(xptHandle) && ((XPTObject*)xptHandle)->hThemeHandle;
}
BOOL xpt_IsValidHandle(XPTHANDLE xptHandle)
{
- BOOL res = FALSE;
if (!xptHandle) return FALSE;
- xptlock();
- {
- if (xptObjectList.indexOf((XPTObject*)xptHandle) != -1)
- res = TRUE;
- }
- xptunlock();
- return res;
+
+ mir_cslock lck(xptCS);
+ return xptObjectList.indexOf((XPTObject*)xptHandle) != -1;
}
XPTHANDLE xpt_AddThemeHandle(HWND hwnd, LPCWSTR className)
{
- XPTHANDLE res = NULL;
- xptlock();
- {
- XPTObject* xptObject = new XPTObject;
- xptObject->lpcwClassObject = className;
- xptObject->hOwnerWindow = hwnd;
- _sttXptReloadThemeData(xptObject);
- xptObjectList.insert(xptObject);
- res = (XPTHANDLE)xptObject;
- }
- xptunlock();
- return res;
+ mir_cslock lck(xptCS);
+ XPTObject* xptObject = new XPTObject;
+ xptObject->lpcwClassObject = className;
+ xptObject->hOwnerWindow = hwnd;
+ _sttXptReloadThemeData(xptObject);
+ xptObjectList.insert(xptObject);
+ return (XPTHANDLE)xptObject;
}
void xpt_FreeThemeHandle(XPTHANDLE xptHandle)
{
- xptlock();
- if (xpt_IsValidHandle(xptHandle))
- {
- XPTObject* xptObject = (XPTObject*)xptHandle;
- _sttXptCloseThemeData(xptObject);
- mir_free(xptHandle);
- xptObjectList.remove( xptObjectList.indexOf(xptObject));
- }
- xptunlock();
+ mir_cslock lck(xptCS);
+ if (xpt_IsValidHandle(xptHandle)) {
+ XPTObject* xptObject = (XPTObject*)xptHandle;
+ _sttXptCloseThemeData(xptObject);
+ mir_free(xptHandle);
+ xptObjectList.remove(xptObjectList.indexOf(xptObject));
+ }
}
+
void xpt_FreeThemeForWindow(HWND hwnd)
{
- xptlock();
- {
- for (int i=0; i < xptObjectList.getCount(); )
- {
- XPTObject& xptObject = xptObjectList[i];
- if (xptObject.hOwnerWindow == hwnd)
- {
- _sttXptCloseThemeData(&xptObject);
- xptObjectList.remove(i);
- }
- else i++;
+ mir_cslock lck(xptCS);
+ for (int i = 0; i < xptObjectList.getCount();) {
+ XPTObject& xptObject = xptObjectList[i];
+ if (xptObject.hOwnerWindow == hwnd) {
+ _sttXptCloseThemeData(&xptObject);
+ xptObjectList.remove(i);
}
+ else i++;
}
- xptunlock();
}
void xpt_OnWM_THEMECHANGED()
{
- xptlock();
- {
- for (int i=0; i < xptObjectList.getCount(); i++)
- _sttXptReloadThemeData(&xptObjectList[i]);
- }
- xptunlock();
+ mir_cslock lck(xptCS);
+
+ for (int i = 0; i < xptObjectList.getCount(); i++)
+ _sttXptReloadThemeData(&xptObjectList[i]);
}
HRESULT xpt_DrawThemeBackground(XPTHANDLE xptHandle, HDC hdc, int type, int state, const RECT *sizeRect, const RECT *clipRect)
{
- HRESULT res = S_FALSE;
- xptlock();
+ mir_cslock lck(xptCS);
if (xpt_IsThemed(xptHandle))
- res = DrawThemeBackground(((XPTObject*)xptHandle)->hThemeHandle, hdc, type, state, sizeRect, clipRect);
- xptunlock();
- return res;
+ return DrawThemeBackground(((XPTObject*)xptHandle)->hThemeHandle, hdc, type, state, sizeRect, clipRect);
+
+ return S_FALSE;
}
-BOOL xpt_IsThemeBackgroundPartiallyTransparent(XPTHANDLE xptHandle, int type, int state)
+BOOL xpt_IsThemeBackgroundPartiallyTransparent(XPTHANDLE xptHandle, int type, int state)
{
- BOOL res = FALSE;
- xptlock();
+ mir_cslock lck(xptCS);
if (xpt_IsThemed(xptHandle))
- res = IsThemeBackgroundPartiallyTransparent(((XPTObject*)xptHandle)->hThemeHandle, type, state);
- xptunlock();
- return res;
+ return IsThemeBackgroundPartiallyTransparent(((XPTObject*)xptHandle)->hThemeHandle, type, state);
+
+ return FALSE;
}
HRESULT xpt_DrawTheme(XPTHANDLE xptHandle, HWND hwnd, HDC hdc, int type, int state, const RECT *sizeRect, const RECT *clipRect)
{
- HRESULT res = S_FALSE;
- xptlock();
- if (xpt_IsThemed(xptHandle))
- {
- if (IsThemeBackgroundPartiallyTransparent(((XPTObject*)xptHandle)->hThemeHandle, type, state)) {
- DrawThemeParentBackground(hwnd,hdc,sizeRect);
- res = DrawThemeBackground(((XPTObject*)xptHandle)->hThemeHandle, hdc, type, state, sizeRect, clipRect);
+ mir_cslock lck(xptCS);
+ if (xpt_IsThemed(xptHandle)) {
+ if (IsThemeBackgroundPartiallyTransparent(((XPTObject*)xptHandle)->hThemeHandle, type, state)) {
+ DrawThemeParentBackground(hwnd, hdc, sizeRect);
+ return DrawThemeBackground(((XPTObject*)xptHandle)->hThemeHandle, hdc, type, state, sizeRect, clipRect);
}
}
- xptunlock();
- return res;
+
+ return S_FALSE;
}
HRESULT xpt_DrawThemeText(XPTHANDLE xptHandle, HDC hdc, int type, int state, LPCTSTR lpStr, int len, DWORD flag1, DWORD flag2, const RECT *textRect)
{
- HRESULT res = S_FALSE;
- xptlock();
+ mir_cslock lck(xptCS);
if (xpt_IsThemed(xptHandle))
- DrawThemeText(((XPTObject*)xptHandle)->hThemeHandle, hdc, type, state, (LPCWSTR)lpStr, len, flag1, flag2, textRect);
+ DrawThemeText(((XPTObject*)xptHandle)->hThemeHandle, hdc, type, state, (LPCWSTR)lpStr, len, flag1, flag2, textRect);
else
- ske_DrawText(hdc,lpStr,len, (RECT*)textRect, flag1);
- xptunlock();
+ ske_DrawText(hdc, lpStr, len, (RECT*)textRect, flag1);
+
return S_OK;
}
+
BOOL xpt_EnableThemeDialogTexture(HWND hwnd, DWORD flags)
{
- BOOL res = FALSE;
- xptlock();
- res = EnableThemeDialogTexture(hwnd, flags);
- xptunlock();
- return res;
+ mir_cslock lck(xptCS);
+ return SUCCEEDED(EnableThemeDialogTexture(hwnd, flags));
}
-//usage outside
-// add theme data
-// in WM_DESTROY - release theme data
-// in paint xpt_DrawTheme
-
|