← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2982: fix GCC build

 

------------------------------------------------------------
revno: 2982
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sat 2012-07-07 15:21:05 +0200
message:
  fix GCC build
modified:
  dwt/include/dwt/WindowsHeaders.h
  dwt/src/widgets/Link.cpp
  win32/PluginPage.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 'dwt/include/dwt/WindowsHeaders.h'
--- dwt/include/dwt/WindowsHeaders.h	2012-01-13 20:55:20 +0000
+++ dwt/include/dwt/WindowsHeaders.h	2012-07-07 13:21:05 +0000
@@ -78,4 +78,11 @@
 #include <list>
 #include <boost/noncopyable.hpp>
 
+// Other quirks
+
+// LM_GETIDEALSIZE is a >=Vista message; we check the OS version before using it.
+#if WINVER < 0x600
+#define LM_GETIDEALSIZE LM_GETIDEALHEIGHT
+#endif
+
 #endif // !WindowsHeaders_h

=== modified file 'dwt/src/widgets/Link.cpp'
--- dwt/src/widgets/Link.cpp	2012-07-03 19:15:39 +0000
+++ dwt/src/widgets/Link.cpp	2012-07-07 13:21:05 +0000
@@ -31,6 +31,8 @@
 
 #include <dwt/widgets/Link.h>
 
+#include <dwt/util/win32/Version.h>
+
 namespace dwt {
 
 const TCHAR Link::windowClass[] = WC_LINK;
@@ -59,14 +61,29 @@
 }
 
 void Link::setLink(const tstring& link, size_t index) {
-	LITEM item = { LIF_ITEMINDEX | LIF_URL, index };
-	link.copy(item.szUrl, std::min(link.size(), L_MAX_URL_LENGTH - 1));
+	LITEM item = { LIF_ITEMINDEX | LIF_URL, static_cast<int>(index) };
+	link.copy(item.szUrl, std::min(link.size(), static_cast<size_t>(L_MAX_URL_LENGTH - 1)));
 }
 
 Point Link::getPreferredSize() {
-	SIZE size = { 0 };
-	sendMessage(LM_GETIDEALSIZE, getParent()->getClientSize().x, reinterpret_cast<LPARAM>(&size));
-	return Point(size.cx, size.cy);
+	if(util::win32::ensureVersion(util::win32::VISTA)) {
+		SIZE size = { 0 };
+		sendMessage(LM_GETIDEALSIZE, getParent()->getClientSize().x, reinterpret_cast<LPARAM>(&size));
+		return Point(size.cx, size.cy);
+	}
+
+	// no LM_GETIDEALSIZE on XP; do it by hand...
+	auto text = getText();
+	size_t start, end, closing, closingEnd;
+	while((start = text.find(_T("<a"))) != tstring::npos &&
+		(end = text.find(_T(">"), start)) != tstring::npos &&
+		(closing = text.find(_T("</a"), end)) != tstring::npos &&
+		(closingEnd = text.find(_T(">"), closing)) != tstring::npos)
+	{
+		text.erase(closing, closingEnd - closing);
+		text.erase(start, end - start);
+	}
+	return getTextSize(text);
 }
 
 }

=== modified file 'win32/PluginPage.cpp'
--- win32/PluginPage.cpp	2012-07-03 19:15:39 +0000
+++ win32/PluginPage.cpp	2012-07-07 13:21:05 +0000
@@ -209,8 +209,7 @@
 		infoGrid->addRow();
 		infoGrid->addChild(Label::Seed(name));
 		if(link && !value.empty()) {
-			auto valueT = Text::toT(value);
-			infoGrid->addChild(Link::Seed(valueT, true));
+			infoGrid->addChild(Link::Seed(Text::toT(value), true));
 		} else {
 			infoGrid->addChild(Label::Seed(value.empty() ?
 				T_("<Information unavailable>") : Text::toT(value)));