------------------------------------------------------------ revno: 2342 committer: poy <p...@123gen.com> branch nick: trunk timestamp: Sun 2010-12-12 00:50:40 +0100 message: DPI awareness modified: changelog.txt dcpp/SettingsManager.cpp dcpp/SettingsManager.h help/settings_colors_and_sounds.html res/DCPlusPlus.manifest.ia64 res/DCPlusPlus.manifest.x64 res/DCPlusPlus.manifest.x86 win32/Appearance2Page.cpp win32/DCPlusPlus.rc win32/GridDialog.cpp win32/MagnetDlg.cpp win32/SConscript 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 2010-12-11 18:16:14 +0000 +++ changelog.txt 2010-12-11 23:50:40 +0000 @@ -54,6 +54,8 @@ * Add user information tooltips (poy) * Avoid parallel hub list downloads (emtee) * Display full country names rather than abbreviations (poy) +* Select a better default font (poy) +* [L#681754] Fonts and dialogs respect DPI settings - mark DC++ as DPI aware (poy) -- 0.770 2010-07-05 -- * [L#550300] Catch more potential file corruptions (thanks bigmuscle) === modified file 'dcpp/SettingsManager.cpp' --- dcpp/SettingsManager.cpp 2010-11-28 15:52:39 +0000 +++ dcpp/SettingsManager.cpp 2010-12-11 23:50:40 +0000 @@ -38,7 +38,7 @@ { // Strings "Nick", "UploadSpeed", "Description", "DownloadDirectory", "EMail", "ExternalIp", - "Font", "ConnectionsOrder", "ConnectionsWidths", "HubFrameOrder", "HubFrameWidths", + "MainFont", "ConnectionsOrder", "ConnectionsWidths", "HubFrameOrder", "HubFrameWidths", "SearchFrameOrder", "SearchFrameWidths", "FavHubsFrameOrder", "FavHubsFrameWidths", "HublistServers", "QueueFrameOrder", "QueueFrameWidths", "PublicHubsFrameOrder", "PublicHubsFrameWidths", "FinishedDLFilesOrder", "FinishedDLFilesWidths", "FinishedDLUsersOrder", "FinishedDLUsersWidths", === modified file 'dcpp/SettingsManager.h' --- dcpp/SettingsManager.h 2010-11-25 18:35:55 +0000 +++ dcpp/SettingsManager.h 2010-12-11 23:50:40 +0000 @@ -56,7 +56,7 @@ enum StrSetting { STR_FIRST, NICK = STR_FIRST, UPLOAD_SPEED, DESCRIPTION, DOWNLOAD_DIRECTORY, EMAIL, EXTERNAL_IP, - TEXT_FONT, CONNECTIONS_ORDER, CONNECTIONS_WIDTHS, HUBFRAME_ORDER, HUBFRAME_WIDTHS, + MAIN_FONT, CONNECTIONS_ORDER, CONNECTIONS_WIDTHS, HUBFRAME_ORDER, HUBFRAME_WIDTHS, SEARCHFRAME_ORDER, SEARCHFRAME_WIDTHS, FAVHUBSFRAME_ORDER, FAVHUBSFRAME_WIDTHS, HUBLIST_SERVERS, QUEUEFRAME_ORDER, QUEUEFRAME_WIDTHS, PUBLICHUBSFRAME_ORDER, PUBLICHUBSFRAME_WIDTHS, FINISHED_DL_FILES_ORDER, FINISHED_DL_FILES_WIDTHS, FINISHED_DL_USERS_ORDER, FINISHED_DL_USERS_WIDTHS, === modified file 'help/settings_colors_and_sounds.html' --- help/settings_colors_and_sounds.html 2008-11-13 16:27:41 +0000 +++ help/settings_colors_and_sounds.html 2010-12-11 23:50:40 +0000 @@ -17,10 +17,10 @@ <dl style="margin-left: 40px;"> <dt>Select window color</dt> <dd cshelp="IDH_SETTINGS_APPEARANCE2_SELWINCOLOR">This setting determines the background color of the windows in -DC++. </dd> +DC++.</dd> <dt>Select text style</dt> - <dd cshelp="IDH_SETTINGS_APPEARANCE2_SELTEXT">This setting determines the color and font used in many DC++ -windows.</dd> + <dd cshelp="IDH_SETTINGS_APPEARANCE2_SELTEXT">This setting determines the color and font used in DC++ +windows. The default depends on the Windows version and the selected theme; it is generally Tahoma (size 8) on XP and Segoe UI (size 9) on Vista and higher.</dd> <dt id="transfercolors">Uploads</dt> <dd cshelp="IDH_SETTINGS_APPEARANCE2_UPLOAD_BAR_COLOR">This will set the coloring for the upload progress bars (default: RGB(205, 60, 55)).</dd> === modified file 'res/DCPlusPlus.manifest.ia64' --- res/DCPlusPlus.manifest.ia64 2009-03-11 09:18:01 +0000 +++ res/DCPlusPlus.manifest.ia64 2010-12-11 23:50:40 +0000 @@ -1,14 +1,20 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" + xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> + <assemblyIdentity version="1.0.0.0" processorArchitecture="ia64" + name="OpenSource.DirectConnect.DC++Client" type="win32" /> + <description>The ultimate Direct Connect client.</description> + <dependency> + <dependentAssembly> + <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" + version="6.0.0.0" processorArchitecture="ia64" publicKeyToken="6595b64144ccf1df" + language="*" /> + </dependentAssembly> + </dependency> + <asmv3:application> + <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"> + <dpiAware>true</dpiAware> + </asmv3:windowsSettings> + </asmv3:application> +</assembly> -<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> - <assemblyIdentity version="1.0.0.0" processorArchitecture="ia64" - name="OpenSource.DirectConnect.DC++Client" type="win32" /> - <description>The ultimate Direct Connect client.</description> - <dependency> - <dependentAssembly> - <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" - version="6.0.0.0" processorArchitecture="ia64" publicKeyToken="6595b64144ccf1df" - language="*" /> - </dependentAssembly> - </dependency> -</assembly> === modified file 'res/DCPlusPlus.manifest.x64' --- res/DCPlusPlus.manifest.x64 2009-03-11 09:18:01 +0000 +++ res/DCPlusPlus.manifest.x64 2010-12-11 23:50:40 +0000 @@ -1,14 +1,20 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" + xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> + <assemblyIdentity version="1.0.0.0" processorArchitecture="amd64" + name="OpenSource.DirectConnect.DC++Client" type="win32" /> + <description>The ultimate Direct Connect client.</description> + <dependency> + <dependentAssembly> + <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" + version="6.0.0.0" processorArchitecture="amd64" publicKeyToken="6595b64144ccf1df" + language="*" /> + </dependentAssembly> + </dependency> + <asmv3:application> + <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"> + <dpiAware>true</dpiAware> + </asmv3:windowsSettings> + </asmv3:application> +</assembly> -<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> - <assemblyIdentity version="1.0.0.0" processorArchitecture="amd64" - name="OpenSource.DirectConnect.DC++Client" type="win32" /> - <description>The ultimate Direct Connect client.</description> - <dependency> - <dependentAssembly> - <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" - version="6.0.0.0" processorArchitecture="amd64" publicKeyToken="6595b64144ccf1df" - language="*" /> - </dependentAssembly> - </dependency> -</assembly> === modified file 'res/DCPlusPlus.manifest.x86' --- res/DCPlusPlus.manifest.x86 2009-03-11 09:18:01 +0000 +++ res/DCPlusPlus.manifest.x86 2010-12-11 23:50:40 +0000 @@ -1,14 +1,19 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> - -<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> - <assemblyIdentity version="1.0.0.0" processorArchitecture="x86" - name="OpenSource.DirectConnect.DC++Client" type="win32" /> - <description>The ultimate Direct Connect client.</description> - <dependency> - <dependentAssembly> - <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" - version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" - language="*" /> - </dependentAssembly> - </dependency> +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" + xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> + <assemblyIdentity version="1.0.0.0" processorArchitecture="x86" + name="OpenSource.DirectConnect.DC++Client" type="win32" /> + <description>The ultimate Direct Connect client.</description> + <dependency> + <dependentAssembly> + <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" + version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" + language="*" /> + </dependentAssembly> + </dependency> + <asmv3:application> + <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"> + <dpiAware>true</dpiAware> + </asmv3:windowsSettings> + </asmv3:application> </assembly> === modified file 'win32/Appearance2Page.cpp' --- win32/Appearance2Page.cpp 2010-09-28 21:29:06 +0000 +++ win32/Appearance2Page.cpp 2010-12-11 23:50:40 +0000 @@ -107,7 +107,7 @@ upBar = SETTING(UPLOAD_BAR_COLOR); downBar = SETTING(DOWNLOAD_BAR_COLOR); - WinUtil::decodeFont(Text::toT(SETTING(TEXT_FONT)), logFont); + WinUtil::decodeFont(Text::toT(SETTING(MAIN_FONT)), logFont); font = dwt::FontPtr(new dwt::Font(::CreateFontIndirect(&logFont), true)); example->setColor(fg, bg); @@ -152,7 +152,7 @@ settings->set(SettingsManager::BACKGROUND_COLOR, (int)bg); settings->set(SettingsManager::UPLOAD_BAR_COLOR, (int)upBar); settings->set(SettingsManager::DOWNLOAD_BAR_COLOR, (int)downBar); - settings->set(SettingsManager::TEXT_FONT, Text::fromT(WinUtil::encodeFont(logFont))); + settings->set(SettingsManager::MAIN_FONT, Text::fromT(WinUtil::encodeFont(logFont))); saveSoundOptions(); for(size_t i = 0; soundOptions[i].setting != 0; ++i) === modified file 'win32/DCPlusPlus.rc' --- win32/DCPlusPlus.rc 2010-09-01 22:17:02 +0000 +++ win32/DCPlusPlus.rc 2010-12-11 23:50:40 +0000 @@ -22,7 +22,6 @@ #endif // APSTUDIO_INVOKED -#ifndef NO_MANIFEST #if defined x86 1 24 "res/DCPlusPlus.manifest.x86" #elif defined x64 @@ -32,7 +31,6 @@ #else #error "manifest: unknown arch" #endif -#endif ///////////////////////////////////////////////////////////////////////////// // === modified file 'win32/GridDialog.cpp' --- win32/GridDialog.cpp 2010-03-07 19:00:57 +0000 +++ win32/GridDialog.cpp 2010-12-11 23:50:40 +0000 @@ -20,10 +20,12 @@ #include "GridDialog.h" +#include "WinUtil.h" + GridDialog::GridDialog(dwt::Widget* parent, const long width_, const DWORD styles_) : dwt::ModalDialog(parent), grid(0), -width(width_), +width(width_ * WinUtil::dpiFactor), styles(styles_) { } === modified file 'win32/MagnetDlg.cpp' --- win32/MagnetDlg.cpp 2010-11-24 22:14:02 +0000 +++ win32/MagnetDlg.cpp 2010-12-11 23:50:40 +0000 @@ -42,7 +42,7 @@ } int MagnetDlg::run() { - create(dwt::Point(458, 171)); + create(dwt::Point(460 * WinUtil::dpiFactor, 180 * WinUtil::dpiFactor)); return show(); } === modified file 'win32/SConscript' --- win32/SConscript 2010-12-05 21:56:45 +0000 +++ win32/SConscript 2010-12-11 23:50:40 +0000 @@ -25,13 +25,7 @@ env.Append(LIBPATH = [openssl_lib]) if env['RC'] == 'rc': # MSVC - env.Append(RCFLAGS = ['/dNO_MANIFEST']) - manifest_arch = env['arch'] - if manifest_arch == 'x64': - manifest_arch = 'amd64' - env.Append(LINKFLAGS = ["/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls'\ - version='6.0.0.0' processorArchitecture='" + manifest_arch + "' publicKeyToken='6595b64144ccf1df'\ - language='*'"]) + env.Append(RCFLAGS = ['/d' + env['arch']]) elif env['RC'].find('windres') != -1: # MinGW env.Append(RCFLAGS = ['-D' + env['arch']]) else: === modified file 'win32/SettingsDialog.cpp' --- win32/SettingsDialog.cpp 2010-12-05 18:24:48 +0000 +++ win32/SettingsDialog.cpp 2010-12-11 23:50:40 +0000 @@ -55,7 +55,7 @@ } int SettingsDialog::run() { - create(Seed(dwt::Point(680, 560), DS_CONTEXTHELP)); + create(Seed(dwt::Point(700 * WinUtil::dpiFactor, 580 * WinUtil::dpiFactor), DS_CONTEXTHELP)); return show(); } @@ -90,7 +90,7 @@ cur->row(0).mode = GridInfo::FILL; cur->row(0).align = GridInfo::STRETCH; - cur->column(0).size = 155; + cur->column(0).size = 170; cur->column(0).mode = GridInfo::STATIC; cur->column(1).mode = GridInfo::FILL; === modified file 'win32/WinUtil.cpp' --- win32/WinUtil.cpp 2010-12-05 18:37:25 +0000 +++ win32/WinUtil.cpp 2010-12-11 23:50:40 +0000 @@ -81,6 +81,7 @@ int WinUtil::dirMaskedIndex; TStringList WinUtil::lastDirs; MainWindow* WinUtil::mainWindow = 0; +float WinUtil::dpiFactor = 0; bool WinUtil::urlDcADCRegistered = false; bool WinUtil::urlMagnetRegistered = false; WinUtil::ImageMap WinUtil::fileIndexes; @@ -118,12 +119,20 @@ bgColor = SETTING(BACKGROUND_COLOR); bgBrush = dwt::BrushPtr(new dwt::Brush(bgColor)); - LOGFONT lf; - ::GetObject(reinterpret_cast<HFONT>(::GetStockObject(DEFAULT_GUI_FONT)), sizeof(lf), &lf); - SettingsManager::getInstance()->setDefault(SettingsManager::TEXT_FONT, Text::fromT(encodeFont(lf))); - decodeFont(Text::toT(SETTING(TEXT_FONT)), lf); - - font = dwt::FontPtr(new dwt::Font(::CreateFontIndirect(&lf), true)); + // 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); + SettingsManager::getInstance()->setDefault(SettingsManager::MAIN_FONT, Text::fromT(encodeFont(metrics.lfMessageFont))); + } + + { + LOGFONT lf; + decodeFont(Text::toT(SETTING(MAIN_FONT)), lf); + font = dwt::FontPtr(new dwt::Font(::CreateFontIndirect(&lf), true)); + } monoFont = dwt::FontPtr(new dwt::Font((BOOLSETTING(USE_OEM_MONOFONT) ? dwt::OemFixedFont : dwt::AnsiFixedFont))); fileImages = dwt::ImageListPtr(new dwt::ImageList(dwt::Point(16, 16))); @@ -308,7 +317,7 @@ tstring WinUtil::encodeFont(LOGFONT const& font) { tstring res(font.lfFaceName); res += _T(','); - res += Text::toT(Util::toString(font.lfHeight)); + res += Text::toT(Util::toString(font.lfHeight / dpiFactor)); res += _T(','); res += Text::toT(Util::toString(font.lfWeight)); res += _T(','); @@ -332,11 +341,14 @@ StringTokenizer<tstring> st(setting, _T(',')); TStringList &sl = st.getTokens(); - ::GetObject(reinterpret_cast<HFONT>(::GetStockObject(DEFAULT_GUI_FONT)), sizeof(dest), &dest); + NONCLIENTMETRICS metrics = { sizeof(NONCLIENTMETRICS) }; + ::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &metrics, 0); + dest = metrics.lfMessageFont; + tstring face; if(sl.size() >= 4) { face = sl[0]; - dest.lfHeight = Util::toInt(Text::fromT(sl[1])); + dest.lfHeight = Util::toInt(Text::fromT(sl[1])) * dpiFactor; dest.lfWeight = Util::toInt(Text::fromT(sl[2])); dest.lfItalic = static_cast<BYTE>(Util::toInt(Text::fromT(sl[3]))); if(sl.size() >= 5) { @@ -646,10 +658,10 @@ } string WinUtil::makeMagnet(const TTHValue& aHash, const string& aFile, int64_t size) { - string ret = "magnet:?xt=urn:tree:tiger:" + aHash.toBase32() + "&dn=" + Util::encodeURI(aFile); + string ret = "magnet:?xt=urn:tree:tiger:" + aHash.toBase32(); if(size > 0) ret += "&xl=" + Util::toString(size); - return ret; + return ret + "&dn=" + Util::encodeURI(aFile); } void WinUtil::searchAny(const tstring& aSearch) { === modified file 'win32/WinUtil.h' --- win32/WinUtil.h 2010-12-08 16:54:29 +0000 +++ win32/WinUtil.h 2010-12-11 23:50:40 +0000 @@ -64,6 +64,7 @@ static TStringList lastDirs; static MainWindow* mainWindow; //static dwt::TabView* mdiParent; + static float dpiFactor; typedef unordered_map<string, int> ImageMap; typedef ImageMap::iterator ImageIter;
_______________________________________________ Mailing list: https://launchpad.net/~linuxdcpp-team Post to : linuxdcpp-team@lists.launchpad.net Unsubscribe : https://launchpad.net/~linuxdcpp-team More help : https://help.launchpad.net/ListHelp