← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2548: update a dwt icon constructor to accept custom sizes

 

------------------------------------------------------------
revno: 2548
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Fri 2011-06-03 20:22:44 +0200
message:
  update a dwt icon constructor to accept custom sizes
modified:
  dwt/include/dwt/resources/Icon.h
  dwt/src/Icon.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/resources/Icon.h'
--- dwt/include/dwt/resources/Icon.h	2011-02-25 17:46:24 +0000
+++ dwt/include/dwt/resources/Icon.h	2011-06-03 18:22:44 +0000
@@ -55,28 +55,19 @@
 class Icon : public Handle<IconPolicy>
 {
 public:
-	/// RAII Constructor taking a HICON
-	/** Note! <br>
-	  * Class takes "control" of HICON meaning it will automatically free the
-	  * contained HICON upon destruction
-	  */
 	explicit Icon(HICON icon, bool own = true);
 
-	/// RAII Constructor loading a icon from a resource ID
-	/** Note! <br>
-	  * Class takes "control" of HICON meaning it will automatically free the
-	  * contained HICON upon destruction
-	  * @params size desired size, useful to pick up the correct image when the icon contains
-	  * multiple images. if 0, the system will figure out the size of the 1st image by itself.
-	  */
+	/** Construct an icon from a resource id.
+	 * @param size desired size, useful to pick up the correct image when the icon contains
+	 * multiple images. if 0, the system will figure out the size of the 1st image by itself.
+	 */
 	explicit Icon(const unsigned resourceId, const Point& size = Point(0, 0));
 
-	/// RAII Constructor loading a icon from a file on disc
-	/** Note! <br>
-	  * Class takes "control" of HICON meaning it will automatically free the
-	  * contained HICON upon destruction
-	  */
-	explicit Icon(const tstring& filePath);
+	/** Construct an icon from a file.
+	 * @param size desired size, useful to pick up the correct image when the icon contains
+	 * multiple images. if 0, the system will figure out the size of the 1st image by itself.
+	 */
+	explicit Icon(const tstring& filePath, const Point& size = Point(0, 0));
 
 	/**
 	* get the size of the icon, in pixels. note: icons can contain multiple images with different

=== modified file 'dwt/src/Icon.cpp'
--- dwt/src/Icon.cpp	2011-02-25 17:52:51 +0000
+++ dwt/src/Icon.cpp	2011-06-03 18:22:44 +0000
@@ -45,20 +45,21 @@
 {
 }
 
-Icon::Icon(const unsigned resourceId, const Point& size) :
 /*
 * we use ::LoadImage instead of ::LoadIcon in order to be able to pick up the correct image,
 * depending on the "size" argument. also, our call to ::LoadImage should use LR_SHARED to match
 * ::LoadIcon more closely, but we don't pass that flag since all our icons are managed and
 * destroyed by DWT.
 */
+
+Icon::Icon(const unsigned resourceId, const Point& size) :
 ResourceType((HICON)::LoadImage(::GetModuleHandle(NULL), MAKEINTRESOURCE(resourceId), IMAGE_ICON, size.x, size.y, LR_DEFAULTCOLOR)),
 resId(resourceId)
 {
 }
 
-Icon::Icon(const tstring& filePath) :
-ResourceType((HICON)::LoadImage(::GetModuleHandle(NULL), filePath.c_str(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE)),
+Icon::Icon(const tstring& filePath, const Point& size) :
+ResourceType((HICON)::LoadImage(0, filePath.c_str(), IMAGE_ICON, size.x, size.y, LR_DEFAULTCOLOR | LR_LOADFROMFILE)),
 resId(0)
 {
 }