diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2013-09-21 17:37:33 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2013-09-21 17:37:33 +0000 |
commit | fdbc3639a50f40879f390f17ce7aafd5a579a7ab (patch) | |
tree | f2dc612f9d188cfb955b4393e207e5363bcd4e4e /src/core/stdchat/src/richutil.cpp | |
parent | 96325150479b8c93a5e48ac2591f3c7da5f0f9d4 (diff) |
Core cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@6165 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/core/stdchat/src/richutil.cpp')
-rw-r--r-- | src/core/stdchat/src/richutil.cpp | 71 |
1 files changed, 19 insertions, 52 deletions
diff --git a/src/core/stdchat/src/richutil.cpp b/src/core/stdchat/src/richutil.cpp index 46c9e5c28e..8bcc79b509 100644 --- a/src/core/stdchat/src/richutil.cpp +++ b/src/core/stdchat/src/richutil.cpp @@ -19,12 +19,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#include <windows.h>
-#include <stdio.h>
-#include <richedit.h>
-#include <m_core.h>
-#include "richutil.h"
+#include "chat.h"
/*
To initialize this library, call:
@@ -121,50 +117,20 @@ void rlist_free(RList *list) { }
}
-// UxTheme Stuff
-static HMODULE mTheme = 0;
-static HANDLE (WINAPI *MyOpenThemeData)(HWND,LPCWSTR) = 0;
-static HRESULT (WINAPI *MyCloseThemeData)(HANDLE) = 0;
-static BOOL (WINAPI *MyIsThemeActive)() = 0;
-static HRESULT (WINAPI *MyDrawThemeBackground)(HANDLE,HDC,int,int,const RECT*,const RECT *) = 0;
-static HRESULT (WINAPI *MyGetThemeBackgroundContentRect)(HANDLE,HDC,int,int,const RECT *,RECT *) = 0;
-static HRESULT (WINAPI *MyDrawThemeParentBackground)(HWND,HDC,RECT*) = 0;
-static BOOL (WINAPI *MyIsThemeBackgroundPartiallyTransparent)(HANDLE,int,int) = 0;
-
static RList *slist = NULL;
static CRITICAL_SECTION csRich;
static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
static VOID RichUtil_ClearUglyBorder(TRichUtil *ru);
-void RichUtil_Load() {
- mTheme = RIsWinVerXPPlus()?LoadLibraryA("uxtheme.dll"):0;
+void RichUtil_Load()
+{
InitializeCriticalSection(&csRich);
- if (!mTheme) return;
- MyOpenThemeData = (HANDLE (WINAPI *)(HWND, LPCWSTR))GetProcAddress(mTheme, "OpenThemeData");
- MyCloseThemeData = (HRESULT (WINAPI *)(HANDLE))GetProcAddress(mTheme, "CloseThemeData");
- MyIsThemeActive = (BOOL (WINAPI *)())GetProcAddress(mTheme, "IsThemeActive");
- MyDrawThemeBackground = (HRESULT (WINAPI *)(HANDLE, HDC, int, int, const RECT*, const RECT *))GetProcAddress(mTheme, "DrawThemeBackground");
- MyGetThemeBackgroundContentRect = (HRESULT (WINAPI *)(HANDLE, HDC, int, int, const RECT *, RECT *))GetProcAddress(mTheme, "GetThemeBackgroundContentRect");
- MyDrawThemeParentBackground = (HRESULT (WINAPI *)(HWND, HDC, RECT*))GetProcAddress(mTheme, "DrawThemeParentBackground");
- MyIsThemeBackgroundPartiallyTransparent = (BOOL (WINAPI *)(HANDLE, int, int))GetProcAddress(mTheme, "IsThemeBackgroundPartiallyTransparent");
- if (!MyOpenThemeData||
- !MyCloseThemeData||
- !MyIsThemeActive||
- !MyDrawThemeBackground||
- !MyGetThemeBackgroundContentRect||
- !MyDrawThemeParentBackground||
- !MyIsThemeBackgroundPartiallyTransparent) {
- FreeLibrary(mTheme);
- mTheme=NULL;
- }
}
-void RichUtil_Unload() {
+void RichUtil_Unload()
+{
DeleteCriticalSection(&csRich);
- if (mTheme) {
- FreeLibrary(mTheme);
- }
}
int RichUtil_SubClass(HWND hwndEdit) {
@@ -201,8 +167,8 @@ static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM case WM_NCPAINT:
{
LRESULT ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
- if (ru->hasUglyBorder&&MyIsThemeActive()) {
- HANDLE hTheme = MyOpenThemeData(ru->hwnd, L"EDIT");
+ if (ru->hasUglyBorder && IsThemeActive()) {
+ HANDLE hTheme = OpenThemeData(ru->hwnd, L"EDIT");
if (hTheme) {
RECT rcBorder;
@@ -219,15 +185,15 @@ static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM rcClient.right -= ru->rect.right;
rcClient.bottom -= ru->rect.bottom;
ExcludeClipRect(hdc, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
- if(MyIsThemeBackgroundPartiallyTransparent(hTheme, EP_EDITTEXT, ETS_NORMAL))
- MyDrawThemeParentBackground(hwnd, hdc, &rcBorder);
+ if(IsThemeBackgroundPartiallyTransparent(hTheme, EP_EDITTEXT, ETS_NORMAL))
+ DrawThemeParentBackground(hwnd, hdc, &rcBorder);
if (!IsWindowEnabled(hwnd))
nState = ETS_DISABLED;
else if(SendMessage(hwnd, EM_GETOPTIONS, 0, 0) & ECO_READONLY)
nState = ETS_READONLY;
else nState = ETS_NORMAL;
- MyDrawThemeBackground(hTheme, hdc, EP_EDITTEXT, nState, &rcBorder, NULL);
- MyCloseThemeData(hTheme);
+ DrawThemeBackground(hTheme, hdc, EP_EDITTEXT, nState, &rcBorder, NULL);
+ CloseThemeData(hTheme);
ReleaseDC(hwnd, hdc);
return 0;
}
@@ -239,26 +205,26 @@ static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM LRESULT ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
NCCALCSIZE_PARAMS *ncsParam = (NCCALCSIZE_PARAMS*)lParam;
- if (ru->hasUglyBorder&&MyIsThemeActive()) {
- HANDLE hTheme = MyOpenThemeData(hwnd, L"EDIT");
+ if (ru->hasUglyBorder && IsThemeActive()) {
+ HANDLE hTheme = OpenThemeData(hwnd, L"EDIT");
if (hTheme) {
RECT rcClient;
HDC hdc = GetDC(GetParent(hwnd));
ZeroMemory(&rcClient, sizeof(RECT));
- if(MyGetThemeBackgroundContentRect(hTheme, hdc, EP_EDITTEXT, ETS_NORMAL, &ncsParam->rgrc[0], &rcClient) == S_OK) {
+ if(GetThemeBackgroundContentRect(hTheme, hdc, EP_EDITTEXT, ETS_NORMAL, &ncsParam->rgrc[0], &rcClient) == S_OK) {
ru->rect.left = rcClient.left-ncsParam->rgrc[0].left;
ru->rect.top = rcClient.top-ncsParam->rgrc[0].top;
ru->rect.right = ncsParam->rgrc[0].right-rcClient.right;
ru->rect.bottom = ncsParam->rgrc[0].bottom-rcClient.bottom;
CopyRect(&ncsParam->rgrc[0], &rcClient);
- MyCloseThemeData(hTheme);
+ CloseThemeData(hTheme);
ReleaseDC(GetParent(hwnd), hdc);
return WVR_REDRAW;
}
ReleaseDC(GetParent(hwnd), hdc);
- MyCloseThemeData(hTheme);
+ CloseThemeData(hTheme);
}
}
return ret;
@@ -281,8 +247,9 @@ static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM return mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
}
-static VOID RichUtil_ClearUglyBorder(TRichUtil *ru) {
- if (mTheme&&MyIsThemeActive()&&GetWindowLongPtr(ru->hwnd, GWL_EXSTYLE)&WS_EX_CLIENTEDGE) {
+static VOID RichUtil_ClearUglyBorder(TRichUtil *ru)
+{
+ if (IsThemeActive() && GetWindowLongPtr(ru->hwnd, GWL_EXSTYLE)&WS_EX_CLIENTEDGE) {
ru->hasUglyBorder = 1;
SetWindowLongPtr(ru->hwnd, GWL_EXSTYLE, GetWindowLongPtr(ru->hwnd, GWL_EXSTYLE)^WS_EX_CLIENTEDGE);
}
|