← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2734: fix filter icon background; better quality for icons picked by static controls

 

------------------------------------------------------------
revno: 2734
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Mon 2011-12-19 17:46:55 +0100
message:
  fix filter icon background; better quality for icons picked by static controls
modified:
  dwt/include/dwt/widgets/Label.h
  dwt/src/widgets/Label.cpp
  win32/AboutDlg.cpp
  win32/HashProgressDlg.cpp
  win32/MagnetDlg.cpp
  win32/WinUtil.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/widgets/Label.h'
--- dwt/include/dwt/widgets/Label.h	2011-11-19 00:10:54 +0000
+++ dwt/include/dwt/widgets/Label.h	2011-12-19 16:46:55 +0000
@@ -80,11 +80,13 @@
 
 		FontPtr font;
 
-		/// Fills with default parameters
+		IconPtr icon;
+
+		/// Make the control display text.
 		Seed(const tstring& caption_ = tstring());
 
-		/// Make the control display an icon. The control handles loading the icon and resizing by itself.
-		Seed(unsigned iconId);
+		/// Make the control display an icon.
+		Seed(IconPtr icon);
 	};
 
 	/// Actually creates the Static Control
@@ -92,9 +94,7 @@
 	  * directly. <br>
 	  * Only if you DERIVE from class you should call this function directly.
 	  */
-	void create( const Seed & cs = Seed() );
-
-	virtual void layout();
+	void create(const Seed& seed = Seed());
 
 	virtual Point getPreferredSize();
 
@@ -114,6 +114,8 @@
 	friend class ChainingDispatcher;
 	static const TCHAR windowClass[];
 
+	IconPtr icon; // keep a reference
+
 	// aspects::Clickable
 	static Message getClickMessage();
 	static Message getDblClickMessage();

=== modified file 'dwt/src/widgets/Label.cpp'
--- dwt/src/widgets/Label.cpp	2011-11-15 19:05:59 +0000
+++ dwt/src/widgets/Label.cpp	2011-12-19 16:46:55 +0000
@@ -31,8 +31,6 @@
 
 #include <dwt/widgets/Label.h>
 
-#include <boost/lexical_cast.hpp>
-
 namespace dwt {
 
 const TCHAR Label::windowClass[] = WC_STATIC;
@@ -43,32 +41,25 @@
 {
 }
 
-Label::Seed::Seed(unsigned iconId) :
-BaseType::Seed(WS_CHILD | SS_NOTIFY | SS_ICON, 0, _T('#') + boost::lexical_cast<tstring>(iconId))
+Label::Seed::Seed(IconPtr icon) :
+BaseType::Seed(WS_CHILD | SS_NOTIFY | SS_ICON),
+icon(icon)
 {
 }
 
-void Label::create( const Seed & cs ) {
-	BaseType::create(cs);
-	setFont(cs.font);
-}
-
-void Label::layout() {
-	/* TODO
-	Rectangle r = r_;
-
-	if(hasStyle(SS_ICON)) {
-		// icon control; we don't want the size to change.
-		r.size = getWindowSize();
-	} */
-
-	BaseType::layout();
+void Label::create(const Seed& seed) {
+	BaseType::create(seed);
+	if(seed.icon) {
+		icon = seed.icon;
+		sendMessage(STM_SETICON, reinterpret_cast<WPARAM>(icon->handle()));
+	} else {
+		setFont(seed.font);
+	}
 }
 
 Point Label::getPreferredSize() {
-	if(hasStyle(SS_ICON)) {
-		// icon control; the control should have already resized itself to its preferred size.
-		return getWindowSize();
+	if(icon) {
+		return icon->getSize();
 	}
 
 	auto ret = getTextSize(getText());

=== modified file 'win32/AboutDlg.cpp'
--- win32/AboutDlg.cpp	2011-10-10 20:18:18 +0000
+++ win32/AboutDlg.cpp	2011-12-19 16:46:55 +0000
@@ -93,7 +93,7 @@
 		cur->column(0).mode = GridInfo::FILL;
 		cur->column(0).align = GridInfo::CENTER;
 
-		cur->addChild(Label::Seed(IDI_DCPP));
+		cur->addChild(Label::Seed(WinUtil::createIcon(IDI_DCPP, 48)));
 
 		ls.caption = Text::toT(dcpp::fullVersionString) + _T("\n(c) Copyright 2001-2011 Jacek Sieka\n");
 		ls.caption += T_("Ex-codeveloper: Per Lind\303\251n\nGraphics: Martin Skogevall et al.\nDC++ is licenced under GPL\n");
@@ -141,6 +141,8 @@
 		).second->setVisible(false);
 
 	setText(T_("About DC++"));
+	setSmallIcon(WinUtil::createIcon(IDI_DCPP, 16));
+	setLargeIcon(WinUtil::createIcon(IDI_DCPP, 32));
 
 	layout();
 	centerWindow();

=== modified file 'win32/HashProgressDlg.cpp'
--- win32/HashProgressDlg.cpp	2011-10-10 20:18:18 +0000
+++ win32/HashProgressDlg.cpp	2011-12-19 16:46:55 +0000
@@ -107,6 +107,8 @@
 	setTimer([this] { return updateStats(); }, 1000);
 
 	setText(T_("Creating file index..."));
+	setSmallIcon(WinUtil::createIcon(IDI_INDEXING, 16));
+	setLargeIcon(WinUtil::createIcon(IDI_INDEXING, 32));
 
 	layout();
 	centerWindow();

=== modified file 'win32/MagnetDlg.cpp'
--- win32/MagnetDlg.cpp	2011-10-10 20:18:18 +0000
+++ win32/MagnetDlg.cpp	2011-12-19 16:46:55 +0000
@@ -66,7 +66,7 @@
 		cur->row(0).align = GridInfo::STRETCH;
 		cur->setSpacing(10);
 
-		cur->addChild(Label::Seed(IDI_MAGNET));
+		cur->addChild(Grid::Seed(1, 1))->addChild(Label::Seed(WinUtil::createIcon(IDI_MAGNET, 32)));
 
 		cur->addChild(Label::Seed(T_("DC++ has detected a MAGNET link with a file hash that can be searched for on the Direct Connect network.  What would you like to do?")));
 	}
@@ -120,6 +120,8 @@
 	}
 
 	setText(T_("MAGNET Link detected"));
+	setSmallIcon(WinUtil::createIcon(IDI_MAGNET, 16));
+	setLargeIcon(WinUtil::createIcon(IDI_MAGNET, 32));
 
 	layout();
 	centerWindow();

=== modified file 'win32/WinUtil.cpp'
--- win32/WinUtil.cpp	2011-12-18 15:37:20 +0000
+++ win32/WinUtil.cpp	2011-12-19 16:46:55 +0000
@@ -1052,8 +1052,8 @@
 	const auto margin = HIWORD(box->sendMessage(EM_GETMARGINS));
 	box->sendMessage(EM_SETMARGINS, EC_RIGHTMARGIN, MAKELONG(0, spacing + size + margin));
 
-	auto label = dwt::WidgetCreator<Label>::create(box, Label::Seed(IDI_SEARCH));
-	label->onRaw([](WPARAM, LPARAM) { return reinterpret_cast<LRESULT>(::GetStockObject(NULL_BRUSH)); }, dwt::Message(WM_CTLCOLOR));
+	auto label = dwt::WidgetCreator<Label>::create(box, Label::Seed(createIcon(IDI_SEARCH, 16)));
+	setColor(label);
 	box->onSized([box, label, size, margin](const dwt::SizedEvent&) {
 		auto sz = box->getClientSize();
 		label->resize(dwt::Rectangle(sz.x - margin - size, std::max(sz.y - size, 0L) / 2, size, size));