← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2482: apply the DPI factor to every dialog and grid

 

------------------------------------------------------------
revno: 2482
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Thu 2011-04-07 16:57:29 +0200
message:
  apply the DPI factor to every dialog and grid
modified:
  changelog.txt
  dwt/include/dwt/util/GDI.h
  dwt/src/util/GDI.cpp
  dwt/src/widgets/Grid.cpp
  dwt/src/widgets/ModalDialog.cpp
  win32/GridDialog.cpp
  win32/MagnetDlg.cpp
  win32/SettingsDialog.cpp
  win32/WinUtil.cpp
  win32/WinUtil.h


--
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-04-07 13:40:55 +0000
+++ changelog.txt	2011-04-07 14:57:29 +0000
@@ -15,6 +15,7 @@
 * Reduce flickering when resizing
 * Reorganize connectivity settings (poy)
 * [L#748623] MiniUPnP respects the bind address (poy)
+* Make more parts of the interface DPI-aware (poy)
 
 -- 0.782 2011-03-05 --
 * Prevent a remote crash triggered via malformed user commands (poy)

=== modified file 'dwt/include/dwt/util/GDI.h'
--- dwt/include/dwt/util/GDI.h	2011-01-02 17:12:02 +0000
+++ dwt/include/dwt/util/GDI.h	2011-04-07 14:57:29 +0000
@@ -32,12 +32,15 @@
 #ifndef DWT_UTIL_GDI_H
 #define DWT_UTIL_GDI_H
 
-#include <dwt/CanvasClasses.h>
+#include <dwt/forward.h>
 
 namespace dwt { namespace util {
 
 BitmapPtr merge(const std::vector<IconPtr>& icons);
 
+/// Conversion factor for DPI awareness, see <http://msdn.microsoft.com/en-us/library/dd464660(VS.85).aspx>.
+const float& dpiFactor();
+
 } }
 
 #endif

=== modified file 'dwt/src/util/GDI.cpp'
--- dwt/src/util/GDI.cpp	2011-01-27 22:57:05 +0000
+++ dwt/src/util/GDI.cpp	2011-04-07 14:57:29 +0000
@@ -31,6 +31,9 @@
 
 #include <dwt/util/GDI.h>
 
+#include <dwt/CanvasClasses.h>
+#include <dwt/resources/Bitmap.h>
+#include <dwt/resources/Icon.h>
 #include <dwt/util/check.h>
 
 namespace dwt { namespace util {
@@ -52,4 +55,11 @@
 	return ret;
 }
 
+const float& dpiFactor() {
+	static float factor = 0;
+	if(!factor)
+		factor = static_cast<float>(UpdateCanvas(reinterpret_cast<HWND>(0)).getDeviceCaps(LOGPIXELSX)) / 96.0;
+	return factor;
+}
+
 } }

=== modified file 'dwt/src/widgets/Grid.cpp'
--- dwt/src/widgets/Grid.cpp	2011-03-15 22:39:48 +0000
+++ dwt/src/widgets/Grid.cpp	2011-04-07 14:57:29 +0000
@@ -30,7 +30,9 @@
 */
 
 #include <dwt/widgets/Grid.h>
+
 #include <dwt/util/check.h>
+#include <dwt/util/GDI.h>
 #include <dwt/util/HoldResize.h>
 
 #include <boost/range/distance.hpp>
@@ -124,6 +126,7 @@
 
 		switch(x[i].mode) {
 		case GridInfo::STATIC:
+			ret[i] *= util::dpiFactor();
 			break;
 		case GridInfo::FILL:
 			fills++;

=== modified file 'dwt/src/widgets/ModalDialog.cpp'
--- dwt/src/widgets/ModalDialog.cpp	2011-01-02 17:12:02 +0000
+++ dwt/src/widgets/ModalDialog.cpp	2011-04-07 14:57:29 +0000
@@ -30,7 +30,9 @@
 */
 
 #include <dwt/widgets/ModalDialog.h>
+
 #include <dwt/Application.h>
+#include <dwt/util/GDI.h>
 
 namespace dwt {
 
@@ -40,6 +42,8 @@
 BaseType::Seed(tstring(), styles_ | WS_POPUP | WS_CAPTION | WS_SYSMENU, WS_EX_CONTROLPARENT | WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE)
 {
 	location.size = size;
+	location.size.x *= util::dpiFactor();
+	location.size.y *= util::dpiFactor();
 }
 
 ModalDialog::ModalDialog(Widget* parent) :

=== modified file 'win32/GridDialog.cpp'
--- win32/GridDialog.cpp	2011-03-15 19:52:17 +0000
+++ win32/GridDialog.cpp	2011-04-07 14:57:29 +0000
@@ -20,12 +20,13 @@
 
 #include "GridDialog.h"
 
+#include <dwt/util/GDI.h>
 #include "WinUtil.h"
 
 GridDialog::GridDialog(dwt::Widget* parent, const long width_, const DWORD styles_) :
 dwt::ModalDialog(parent),
 grid(0),
-width(width_ * WinUtil::dpiFactor),
+width(width_),
 styles(styles_)
 {
 }
@@ -43,7 +44,7 @@
 	grid->resize(dwt::Rectangle(spacing, spacing, sz.x - spacing * 2, sz.y));
 
 	// now resize the dialog itself
-	sz.x = width; // don't change the horizontal size
+	sz.x = width * dwt::util::dpiFactor(); // don't change the horizontal size
 	sz.y += spacing * 2 + getYBorders();
 	dwt::ModalDialog::resize(dwt::Rectangle(getWindowRect().pos, sz));
 }

=== modified file 'win32/MagnetDlg.cpp'
--- win32/MagnetDlg.cpp	2011-04-05 19:16:53 +0000
+++ win32/MagnetDlg.cpp	2011-04-07 14:57:29 +0000
@@ -42,7 +42,7 @@
 }
 
 int MagnetDlg::run() {
-	create(dwt::Point(460 * WinUtil::dpiFactor, 180 * WinUtil::dpiFactor));
+	create(dwt::Point(460, 180));
 	return show();
 }
 

=== modified file 'win32/SettingsDialog.cpp'
--- win32/SettingsDialog.cpp	2011-04-07 13:40:55 +0000
+++ win32/SettingsDialog.cpp	2011-04-07 14:57:29 +0000
@@ -62,7 +62,7 @@
 }
 
 int SettingsDialog::run() {
-	create(Seed(dwt::Point(700 * WinUtil::dpiFactor, 580 * WinUtil::dpiFactor), DS_CONTEXTHELP));
+	create(Seed(dwt::Point(700, 580), DS_CONTEXTHELP));
 	return show();
 }
 

=== modified file 'win32/WinUtil.cpp'
--- win32/WinUtil.cpp	2011-04-07 13:40:55 +0000
+++ win32/WinUtil.cpp	2011-04-07 14:57:29 +0000
@@ -83,7 +83,6 @@
 dwt::ImageListPtr WinUtil::userImages;
 TStringList WinUtil::lastDirs;
 MainWindow* WinUtil::mainWindow = 0;
-float WinUtil::dpiFactor = 0;
 bool WinUtil::urlDcADCRegistered = false;
 bool WinUtil::urlMagnetRegistered = false;
 WinUtil::ImageMap WinUtil::fileIndexes;
@@ -121,9 +120,6 @@
 	bgColor = SETTING(BACKGROUND_COLOR);
 	bgBrush = dwt::BrushPtr(new dwt::Brush(bgColor));
 
-	// Conversion for DPI awareness, see <http://msdn.microsoft.com/en-us/library/dd464660(VS.85).aspx>.
-	dpiFactor = static_cast<float>(dwt::UpdateCanvas(reinterpret_cast<HWND>(0)).getDeviceCaps(LOGPIXELSX)) / 96.0;
-
 	if(SettingsManager::getInstance()->isDefault(SettingsManager::MAIN_FONT)) {
 		NONCLIENTMETRICS metrics = { sizeof(NONCLIENTMETRICS) };
 		::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &metrics, 0);
@@ -344,7 +340,7 @@
 tstring WinUtil::encodeFont(LOGFONT const& font) {
 	tstring res(font.lfFaceName);
 	res += _T(',');
-	res += Text::toT(Util::toString(static_cast<int>(font.lfHeight / dpiFactor)));
+	res += Text::toT(Util::toString(static_cast<int>(font.lfHeight / dwt::util::dpiFactor())));
 	res += _T(',');
 	res += Text::toT(Util::toString(font.lfWeight));
 	res += _T(',');
@@ -376,7 +372,7 @@
 	tstring face;
 	if(sl.size() >= 4) {
 		face = sl[0];
-		dest.lfHeight = Util::toInt(Text::fromT(sl[1])) * dpiFactor;
+		dest.lfHeight = Util::toInt(Text::fromT(sl[1])) * dwt::util::dpiFactor();
 		dest.lfWeight = Util::toInt(Text::fromT(sl[2]));
 		dest.lfItalic = static_cast<BYTE>(Util::toInt(Text::fromT(sl[3])));
 		if(sl.size() >= 5) {

=== modified file 'win32/WinUtil.h'
--- win32/WinUtil.h	2011-03-29 20:40:28 +0000
+++ win32/WinUtil.h	2011-04-07 14:57:29 +0000
@@ -84,7 +84,6 @@
 	static dwt::ImageListPtr userImages;
 	static TStringList lastDirs;
 	static MainWindow* mainWindow;
-	static float dpiFactor;
 
 	typedef unordered_map<string, size_t> ImageMap;
 	typedef ImageMap::iterator ImageIter;