← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2408: simplify fav hub group color customization & apply to theme-less visual styles

 

------------------------------------------------------------
revno: 2408
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Tue 2011-02-01 21:32:13 +0100
message:
  simplify fav hub group color customization & apply to theme-less visual styles
modified:
  changelog.txt
  dcpp/SettingsManager.cpp
  dcpp/version.h
  dwt/include/dwt/dwt_vsstyle.h
  dwt/src/Theme.cpp
  dwt/src/widgets/Grid.cpp
  dwt/src/widgets/Table.cpp
  win32/DCPlusPlus.rc
  win32/FavHubsFrame.cpp


--
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 'changelog.txt'
--- changelog.txt	2011-01-30 20:01:21 +0000
+++ changelog.txt	2011-02-01 20:32:13 +0000
@@ -2,7 +2,7 @@
 * Experimental implementation of KEYP ADC extension
 * Prevent a remote crash triggered via malformed user commands (poy)
 * Avoid crashes when closing from the taskbar too often (poy)
-* [L#580051] Restore DC++ colors to fav hubs on >= Vista (poy)
+* [L#580051] Restore DC++ colors to the fav hub window (poy)
 * Favorite user nicks are saved in Users.xml
 
 -- 0.781 2011-01-12 --

=== modified file 'dcpp/SettingsManager.cpp'
--- dcpp/SettingsManager.cpp	2011-01-30 16:17:57 +0000
+++ dcpp/SettingsManager.cpp	2011-02-01 20:32:13 +0000
@@ -435,6 +435,10 @@
 			// These were remade completely...
 			set(USERSFRAME_ORDER, Util::emptyString);
 			set(USERSFRAME_WIDTHS, Util::emptyString);
+
+			// the id has changed
+			if(isSet[TOOLBAR])
+				Util::replace("FavUsers", "Users", strSettings[TOOLBAR - STR_FIRST]);
 		}
 
 		if(SETTING(SET_MINISLOT_SIZE) < 64)

=== modified file 'dcpp/version.h'
--- dcpp/version.h	2011-01-27 23:11:24 +0000
+++ dcpp/version.h	2011-02-01 20:32:13 +0000
@@ -19,8 +19,8 @@
 #define APPNAME "DC++"
 
 // don't forget to update the .rc file as well!
-#define VERSIONSTRING "0.781"
-#define VERSIONFLOAT 0.781
+#define VERSIONSTRING "0.785"
+#define VERSIONFLOAT 0.785
 
 namespace dcpp {
 extern const string fullVersionString;

=== modified file 'dwt/include/dwt/dwt_vsstyle.h'
--- dwt/include/dwt/dwt_vsstyle.h	2011-01-27 23:11:24 +0000
+++ dwt/include/dwt/dwt_vsstyle.h	2011-02-01 20:32:13 +0000
@@ -37,11 +37,7 @@
 
 #define VSCLASS_LISTVIEW L"LISTVIEW"
 #define LVP_GROUPHEADER 6
-#define LVP_GROUPHEADERLINE 7
 #define LVGH_OPEN 1
-#define LVGH_OPENHOT 2
-#define LVGHL_OPEN 1
-#define LVGHL_OPENHOT 2
 
 #define VSCLASS_MENU L"MENU"
 #define MENU_BARBACKGROUND 7

=== modified file 'dwt/src/Theme.cpp'
--- dwt/src/Theme.cpp	2011-01-27 22:57:05 +0000
+++ dwt/src/Theme.cpp	2011-02-01 20:32:13 +0000
@@ -157,7 +157,9 @@
 
 int64_t Theme::getColor(int part, int state, int specifier) {
 	COLORREF color;
-	return (GetThemeColor(theme, part, state, specifier, &color) == S_OK) ? color : -1;
+	if(GetThemeColor(theme, part, state, specifier, &color) == S_OK)
+		return color;
+	return -1;
 }
 
 bool Theme::getPartSize(Canvas& canvas, int part, int state, Point& ret) {

=== modified file 'dwt/src/widgets/Grid.cpp'
--- dwt/src/widgets/Grid.cpp	2011-01-30 20:05:04 +0000
+++ dwt/src/widgets/Grid.cpp	2011-02-01 20:32:13 +0000
@@ -31,6 +31,7 @@
 
 #include <dwt/widgets/Grid.h>
 
+#include <algorithm>
 #include <numeric>
 
 namespace dwt {

=== modified file 'dwt/src/widgets/Table.cpp'
--- dwt/src/widgets/Table.cpp	2011-01-30 16:17:57 +0000
+++ dwt/src/widgets/Table.cpp	2011-02-01 20:32:13 +0000
@@ -352,7 +352,7 @@
 			group.pszHeader = 0;
 		} else {
 			group.mask = LVGF_GROUPID | LVGF_HEADER;
-			group.pszHeader = const_cast<LPWSTR>(i->c_str()); /// @todo this will fail when compiling in A mode
+			group.pszHeader = const_cast<LPWSTR>(i->c_str());
 		}
 		if(ListView_InsertGroup(handle(), -1, &group) == -1) {
 			throw DWTException("Group insertion failed in Table::setGroups");
@@ -374,72 +374,45 @@
 }
 
 void Table::handleGroupDraw(COLORREF bgColor) {
-	if(!util::win32::ensureVersion(util::win32::VISTA))
-		return; // can get messy on XP, leave default colors to these users...
-
 	theme.load(VSCLASS_LISTVIEW, this);
 
 	onRaw([this, bgColor](WPARAM, LPARAM lParam) -> LRESULT {
-		if(!grouped || !lParam || !theme)
+		if(!grouped || !lParam)
 			return CDRF_DODEFAULT;
 		auto& data = *reinterpret_cast<LPNMLVCUSTOMDRAW>(lParam);
-		if(data.dwItemType == LVCDI_GROUP && data.nmcd.dwDrawStage == CDDS_PREPAINT) {
-			// got a group!
-			int id = data.nmcd.dwItemSpec;
-			if(id <= 0) // skip id=-1 (error) and id=0 (first group, that has no header)
-				return CDRF_DODEFAULT;
-
-			FreeCanvas canvas(data.nmcd.hdc);
-			bool oldMode = canvas.setBkMode(true);
-
-			Rectangle rect(data.rcText);
-			Region region(rect);
-
-			// find out whether the mouse is hovering the group header.
-			LVHITTESTINFO hit = { ClientCoordinate(ScreenCoordinate(Point::fromLParam(::GetMessagePos())), this).getPoint(), LVHT_EX_GROUP };
-			const bool hot = GCC_WTF->sendMessage(LVM_HITTEST, static_cast<WPARAM>(-1), reinterpret_cast<LPARAM>(&hit)) == id;
-
-			int part = LVP_GROUPHEADER;
-			int state = hot ? LVGH_OPENHOT : LVGH_OPEN;
-
-			bool invert = false;
-
-			auto color = theme.getColor(part, state, TMT_HEADING1TEXTCOLOR);
-			if(color != -1) {
-				auto r = GetRValue(bgColor), g = GetGValue(bgColor), b = GetBValue(bgColor);
-				if(abs(GetRValue(color) + GetGValue(color) + GetBValue(color) - r - g - b) < 300) {
-					/* the theme color and the bg color are too close to each other; start by
-					filling the canvas with an invert of the bg, then invert the whole canvas after
-					everything has been drawn. */
-					canvas.fill(rect, Brush(RGB(255 - r, 255 - g, 255 - b)));
-					invert = true;
-				}
-			}
-
-			// draw the global background (including borders).
-			theme.drawBackground(canvas, part, state, rect, false);
-
-			// draw the text.
-			const tstring text = getGroup(id);
-			const unsigned textFlags = DT_VCENTER | DT_SINGLELINE;
-			theme.formatTextRect(canvas, part, LVGH_OPEN /* the hot version doesn't expose margins... */, text, textFlags, rect);
-			theme.drawText(canvas, part, state, text, textFlags, rect, color);
-
-			// draw the horizontal line.
-			part = LVP_GROUPHEADERLINE;
-			state = hot ? LVGHL_OPENHOT : LVGHL_OPEN;
-			const unsigned margin = 4;
-			Point lineSize(0, 1); // default: 1px height - ignore the width.
-			theme.getPartSize(canvas, part, state, lineSize);
-			theme.drawBackground(canvas, part, state, Rectangle(rect.right() + margin, rect.top() + (rect.height() - lineSize.y) / 2,
-				data.rcText.right - rect.right() - 2 * margin, lineSize.y), false);
-
-			if(invert) {
-				canvas.invert(region);
-			}
-
-			canvas.setBkMode(oldMode);
-			return CDRF_SKIPDEFAULT;
+		if(data.dwItemType == LVCDI_GROUP) {
+			switch(data.nmcd.dwDrawStage) {
+			case CDDS_PREPAINT:
+				{
+					// got a group! get the current theme text color and compare it to the bg.
+					int64_t color = -1;
+					if(theme)
+						color = theme.getColor(LVP_GROUPHEADER, LVGH_OPEN, TMT_HEADING1TEXTCOLOR);
+					if(color == -1)
+						color = 0; // assume black
+					auto r = GetRValue(bgColor), g = GetGValue(bgColor), b = GetBValue(bgColor);
+					if(abs(GetRValue(color) + GetGValue(color) + GetBValue(color) - r - g - b) < 300) {
+						/* the theme color and the bg color are too close to each other; start by
+						filling the canvas with an invert of the bg, then invert the whole canvas
+						after everything has been drawn (after CDDS_POSTPAINT). */
+						Rectangle rect(data.rcText);
+						if(!theme && util::win32::ensureVersion(util::win32::VISTA))
+							rect.size.y += 6;
+						FreeCanvas(data.nmcd.hdc).fill(rect, Brush(RGB(255 - r, 255 - g, 255 - b)));
+
+						// set a flag so we don't have to re-compare colors on CDDS_POSTPAINT.
+						data.nmcd.lItemlParam = 1;
+					}
+					break;
+				}
+			case CDDS_POSTPAINT:
+				{
+					if(data.nmcd.lItemlParam) {
+						FreeCanvas(data.nmcd.hdc).invert(Region(Rectangle(data.rcText)));
+					}
+					break;
+				}
+			}
 		}
 		return CDRF_DODEFAULT;
 	}, Message(WM_NOTIFY, NM_CUSTOMDRAW));

=== modified file 'win32/DCPlusPlus.rc'
--- win32/DCPlusPlus.rc	2011-01-30 16:17:57 +0000
+++ win32/DCPlusPlus.rc	2011-02-01 20:32:13 +0000
@@ -105,8 +105,8 @@
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION 0,7,8,1
- PRODUCTVERSION 0,7,8,1
+ FILEVERSION 0,7,8,5
+ PRODUCTVERSION 0,7,8,5
  FILEFLAGSMASK 0x3fL
 #ifdef _DEBUG
  FILEFLAGS 0x1L
@@ -123,12 +123,12 @@
         BEGIN
             VALUE "Comments", "http://dcplusplus.sourceforge.net";
             VALUE "FileDescription", "DC++"
-            VALUE "FileVersion", "0, 7, 8, 1"
+            VALUE "FileVersion", "0, 7, 8, 5"
             VALUE "InternalName", "DC++"
             VALUE "LegalCopyright", "Copyright 2001-2011 Jacek Sieka"
             VALUE "OriginalFilename", "DCPlusPlus.exe"
             VALUE "ProductName", "DC++"
-            VALUE "ProductVersion", "0, 7, 8, 1"
+            VALUE "ProductVersion", "0, 7, 8, 5"
         END
     END
     BLOCK "VarFileInfo"

=== modified file 'win32/FavHubsFrame.cpp'
--- win32/FavHubsFrame.cpp	2011-01-27 22:57:05 +0000
+++ win32/FavHubsFrame.cpp	2011-02-01 20:32:13 +0000
@@ -23,8 +23,6 @@
 #include <dcpp/FavoriteManager.h>
 #include <dcpp/version.h>
 
-#include <dwt/util/win32/Version.h>
-
 #include "HubFrame.h"
 #include "FavHubProperties.h"
 #include "FavHubGroupsDlg.h"
@@ -64,7 +62,7 @@
 		cs.style |= LVS_NOSORTHEADER;
 		hubs = grid->addChild(cs);
 		grid->setWidget(hubs, 0, 0, 1, 8);
-		addWidget(hubs, false, true, dwt::util::win32::ensureVersion(dwt::util::win32::VISTA)); // default colors for XP
+		addWidget(hubs);
 
 		WinUtil::makeColumns(hubs, hubsColumns, COLUMN_LAST, SETTING(FAVHUBSFRAME_ORDER), SETTING(FAVHUBSFRAME_WIDTHS));