linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #04704
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2655: simplify import of theme calls
------------------------------------------------------------
revno: 2655
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Wed 2011-10-26 20:23:40 +0200
message:
simplify import of theme calls
modified:
dwt/include/dwt/Theme.h
dwt/src/Theme.cpp
win32/SConscript
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dwt/include/dwt/Theme.h'
--- dwt/include/dwt/Theme.h 2011-06-01 19:02:45 +0000
+++ dwt/include/dwt/Theme.h 2011-10-26 18:23:40 +0000
@@ -58,11 +58,8 @@
*/
void drawBackground(Canvas& canvas, int part, int state, const Rectangle& rect,
bool drawParent = true, boost::optional<Rectangle> clip = boost::optional<Rectangle>());
- /**
- * @param textFlags see the DrawText doc for possible values.
- * @param color text color, or NaC for the default theme color.
- */
- void drawText(Canvas& canvas, int part, int state, const tstring& text, unsigned textFlags, const Rectangle& rect, COLORREF color = NaC);
+ /// @param textFlags see the DrawText doc for possible values.
+ void drawText(Canvas& canvas, int part, int state, const tstring& text, unsigned textFlags, const Rectangle& rect);
void formatRect(Canvas& canvas, int part, int state, Rectangle& rect);
/// @param textFlags see the DrawText doc for possible values.
void formatTextRect(Canvas& canvas, int part, int state, const tstring& text, unsigned textFlags, Rectangle& rect);
=== modified file 'dwt/src/Theme.cpp'
--- dwt/src/Theme.cpp 2011-06-01 19:02:45 +0000
+++ dwt/src/Theme.cpp 2011-10-26 18:23:40 +0000
@@ -32,49 +32,11 @@
#include <dwt/Theme.h>
#include <dwt/Dispatchers.h>
-#include <dwt/LibraryLoader.h>
#include <dwt/util/check.h>
-#include <dwt/util/win32/Version.h>
#include <dwt/dwt_vssym32.h>
namespace dwt {
-typedef HRESULT (WINAPI *t_CloseThemeData)(HTHEME);
-static t_CloseThemeData CloseThemeData = 0;
-
-typedef HRESULT (WINAPI *t_DrawThemeBackground)(HTHEME, HDC, int, int, const RECT*, const RECT*);
-static t_DrawThemeBackground DrawThemeBackground = 0;
-
-typedef HRESULT (WINAPI *t_DrawThemeParentBackground)(HWND, HDC, const RECT*);
-static t_DrawThemeParentBackground DrawThemeParentBackground = 0;
-
-typedef HRESULT (WINAPI *t_DrawThemeText)(HTHEME, HDC, int, int, LPCWSTR, int, DWORD, DWORD, LPCRECT);
-static t_DrawThemeText DrawThemeText = 0;
-
-typedef HRESULT (WINAPI *t_DrawThemeTextEx)(HTHEME, HDC, int, int, LPCWSTR, int, DWORD, LPRECT, const DTTOPTS*);
-static t_DrawThemeTextEx DrawThemeTextEx = 0;
-
-typedef HRESULT (WINAPI *t_GetThemeColor)(HTHEME, int, int, int, COLORREF*);
-static t_GetThemeColor GetThemeColor = 0;
-
-typedef HRESULT (WINAPI *t_GetThemeMargins)(HTHEME, HDC, int, int, int, LPRECT, MARGINS*);
-static t_GetThemeMargins GetThemeMargins = 0;
-
-typedef HRESULT (WINAPI *t_GetThemePartSize)(HTHEME, HDC, int, int, LPCRECT, THEMESIZE, SIZE*);
-static t_GetThemePartSize GetThemePartSize = 0;
-
-typedef HRESULT (WINAPI *t_GetThemeTextExtent)(HTHEME, HDC, int, int, LPCWSTR, int, DWORD, LPCRECT, LPRECT);
-static t_GetThemeTextExtent GetThemeTextExtent = 0;
-
-typedef BOOL (WINAPI *t_IsAppThemed)();
-static t_IsAppThemed IsAppThemed = 0;
-
-typedef BOOL (WINAPI *t_IsThemeBackgroundPartiallyTransparent)(HTHEME, int, int);
-static t_IsThemeBackgroundPartiallyTransparent IsThemeBackgroundPartiallyTransparent = 0;
-
-typedef HWND (WINAPI *t_OpenThemeData)(HTHEME, LPCWSTR);
-static t_OpenThemeData OpenThemeData = 0;
-
Theme::Theme() : theme(0)
{
}
@@ -84,34 +46,16 @@
}
void Theme::load(const tstring& classes, Widget* w_, bool handleThemeChanges) {
- static LibraryLoader lib(_T("uxtheme"), true);
- if(lib.loaded()) {
-
-#define get(name) if(!name) { if(!(name = reinterpret_cast<t_##name>(lib.getProcAddress(_T(#name))))) { return; } }
- get(CloseThemeData);
- get(DrawThemeBackground);
- get(DrawThemeParentBackground);
- if(util::win32::ensureVersion(util::win32::VISTA)) { get(DrawThemeTextEx); } else { get(DrawThemeText); }
- get(GetThemeColor);
- get(GetThemeMargins);
- get(GetThemePartSize);
- get(GetThemeTextExtent);
- get(IsAppThemed);
- get(IsThemeBackgroundPartiallyTransparent);
- get(OpenThemeData);
-#undef get
-
- w = w_;
- dwtassert(w, _T("Theme: no widget set"));
-
- open(classes);
-
- if(handleThemeChanges) {
- w->addCallback(Message(WM_THEMECHANGED), Dispatchers::VoidVoid<0, false>([this, classes] {
- close();
- open(classes);
- }));
- }
+ w = w_;
+ dwtassert(w, _T("Theme: no widget set"));
+
+ open(classes);
+
+ if(handleThemeChanges) {
+ w->addCallback(Message(WM_THEMECHANGED), Dispatchers::VoidVoid<0, false>([this, classes] {
+ close();
+ open(classes);
+ }));
}
}
@@ -124,21 +68,9 @@
DrawThemeBackground(theme, canvas.handle(), part, state, &rc, clip ? &rcClip.get() : 0);
}
-void Theme::drawText(Canvas& canvas, int part, int state, const tstring& text, unsigned textFlags, const Rectangle& rect, COLORREF color) {
+void Theme::drawText(Canvas& canvas, int part, int state, const tstring& text, unsigned textFlags, const Rectangle& rect) {
::RECT rc = rect;
-
- if(DrawThemeTextEx) {
- DTTOPTS opts = { sizeof(DTTOPTS) };
- if(color != NaC) {
- opts.dwFlags |= DTT_TEXTCOLOR;
- opts.crText = color;
- }
-
- DrawThemeTextEx(theme, canvas.handle(), part, state, text.c_str(), text.size(), textFlags, &rc, &opts);
-
- } else {
- DrawThemeText(theme, canvas.handle(), part, state, text.c_str(), text.size(), textFlags, 0, &rc);
- }
+ DrawThemeText(theme, canvas.handle(), part, state, text.c_str(), text.size(), textFlags, 0, &rc);
}
void Theme::formatRect(Canvas& canvas, int part, int state, Rectangle& rect) {
=== modified file 'win32/SConscript'
--- win32/SConscript 2011-10-23 13:22:23 +0000
+++ win32/SConscript 2011-10-26 18:23:40 +0000
@@ -15,7 +15,8 @@
if 'HAVE_HTMLHELP_H' in env['CPPDEFINES']:
env.Append(LIBS='htmlhelp')
-env.Append(LIBS = ['comctl32', 'ws2_32', 'ole32', 'gdi32', 'comdlg32', 'iphlpapi', 'winmm', 'shlwapi', 'oleaut32', 'uuid'])
+env.Append(LIBS = ['comctl32', 'ws2_32', 'ole32', 'gdi32', 'comdlg32', 'iphlpapi', 'winmm',
+ 'shlwapi', 'oleaut32', 'uuid', 'uxtheme'])
# add libs for the crash logger.
if 'g++' in env['LINK']: # MinGW