mirror of https://github.com/BOINC/boinc.git
MGR: On MS Windows, make DPI setting detection more efficient and DPI adjustments more general.
This commit is contained in:
parent
a79b5c7df7
commit
dd9826c817
|
@ -24,8 +24,8 @@
|
|||
#include "BOINCTaskCtrl.h"
|
||||
#include "MainDocument.h"
|
||||
|
||||
#define TASKPANEWIDTH ADJUSTFORDPI(200)
|
||||
#define TASKBUTTONWIDTH ADJUSTFORDPI(TASKPANEWIDTH - 55)
|
||||
#define TASKPANEWIDTH ADJUSTFORXDPI(200)
|
||||
#define TASKBUTTONWIDTH ADJUSTFORXDPI(TASKPANEWIDTH - 55)
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(CBOINCTaskCtrl, wxScrolledWindow)
|
||||
|
||||
|
|
|
@ -30,8 +30,10 @@
|
|||
#include "SkinManager.h"
|
||||
|
||||
|
||||
#define DLGDIAGNOSTICS_INITIAL_SIZE ADJUSTFORDPI(480)
|
||||
#define DLGDIAGNOSTICS_MIN_SIZE ADJUSTFORDPI(400)
|
||||
#define DLGDIAGNOSTICS_INITIAL_WIDTH ADJUSTFORXDPI(480)
|
||||
#define DLGDIAGNOSTICS_INITIAL_HEIGHT ADJUSTFORYDPI(480)
|
||||
#define DLGDIAGNOSTICS_MIN_WIDTH ADJUSTFORXDPI(400)
|
||||
#define DLGDIAGNOSTICS_MIN_HEIGHT ADJUSTFORYDPI(400)
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(CDlgDiagnosticLogFlags, wxDialog)
|
||||
|
||||
|
@ -45,7 +47,7 @@ END_EVENT_TABLE()
|
|||
/* Constructor */
|
||||
CDlgDiagnosticLogFlags::CDlgDiagnosticLogFlags(wxWindow* parent) :
|
||||
wxDialog( parent, ID_ANYDIALOG, wxEmptyString, wxDefaultPosition,
|
||||
wxSize( DLGDIAGNOSTICS_INITIAL_SIZE,DLGDIAGNOSTICS_INITIAL_SIZE ),
|
||||
wxSize( DLGDIAGNOSTICS_INITIAL_WIDTH,DLGDIAGNOSTICS_INITIAL_HEIGHT ),
|
||||
wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER
|
||||
) {
|
||||
|
||||
|
@ -71,7 +73,7 @@ CDlgDiagnosticLogFlags::CDlgDiagnosticLogFlags(wxWindow* parent) :
|
|||
m_cc_config.defaults();
|
||||
pDoc->rpc.get_cc_config(m_cc_config, log_flags);
|
||||
|
||||
SetSizeHints(DLGDIAGNOSTICS_MIN_SIZE, DLGDIAGNOSTICS_MIN_SIZE);
|
||||
SetSizeHints(DLGDIAGNOSTICS_MIN_WIDTH, DLGDIAGNOSTICS_MIN_HEIGHT);
|
||||
SetExtraStyle( GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY );
|
||||
|
||||
wxBoxSizer* bSizer1 = new wxBoxSizer( wxVERTICAL );
|
||||
|
@ -198,15 +200,15 @@ bool CDlgDiagnosticLogFlags::RestoreState() {
|
|||
|
||||
pConfig->SetPath("/DlgDiagnosticLogFlags/");
|
||||
|
||||
pConfig->Read(wxT("Width"), &iWidth, DLGDIAGNOSTICS_INITIAL_SIZE);
|
||||
pConfig->Read(wxT("Height"), &iHeight, DLGDIAGNOSTICS_INITIAL_SIZE);
|
||||
pConfig->Read(wxT("Width"), &iWidth, DLGDIAGNOSTICS_INITIAL_WIDTH);
|
||||
pConfig->Read(wxT("Height"), &iHeight, DLGDIAGNOSTICS_INITIAL_HEIGHT);
|
||||
|
||||
// Guard against a rare situation where registry values are zero
|
||||
if ((iWidth < 50) && (iWidth != wxDefaultCoord)) iWidth = DLGDIAGNOSTICS_INITIAL_SIZE;
|
||||
if ((iHeight < 50) && (iHeight != wxDefaultCoord)) iHeight = DLGDIAGNOSTICS_INITIAL_SIZE;
|
||||
if ((iWidth < 50) && (iWidth != wxDefaultCoord)) iWidth = DLGDIAGNOSTICS_INITIAL_WIDTH;
|
||||
if ((iHeight < 50) && (iHeight != wxDefaultCoord)) iHeight = DLGDIAGNOSTICS_INITIAL_HEIGHT;
|
||||
|
||||
// Set size to saved values or defaults if no saved values
|
||||
SetSize(std::max(iWidth, DLGDIAGNOSTICS_MIN_SIZE), std::max(iHeight, DLGDIAGNOSTICS_MIN_SIZE));
|
||||
SetSize(std::max(iWidth, DLGDIAGNOSTICS_MIN_WIDTH), std::max(iHeight, DLGDIAGNOSTICS_MIN_HEIGHT));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -49,10 +49,10 @@
|
|||
////@begin XPM images
|
||||
////@end XPM images
|
||||
|
||||
#define DLGEVENTLOG_INITIAL_WIDTH ADJUSTFORDPI(640)
|
||||
#define DLGEVENTLOG_INITIAL_HEIGHT ADJUSTFORDPI(480)
|
||||
#define DLGEVENTLOG_MIN_WIDTH ADJUSTFORDPI(600)
|
||||
#define DLGEVENTLOG_MIN_HEIGHT ADJUSTFORDPI(250)
|
||||
#define DLGEVENTLOG_INITIAL_WIDTH ADJUSTFORXDPI(640)
|
||||
#define DLGEVENTLOG_INITIAL_HEIGHT ADJUSTFORYDPI(480)
|
||||
#define DLGEVENTLOG_MIN_WIDTH ADJUSTFORXDPI(600)
|
||||
#define DLGEVENTLOG_MIN_HEIGHT ADJUSTFORYDPI(250)
|
||||
|
||||
#define COLUMN_PROJECT 0
|
||||
#define COLUMN_TIME 1
|
||||
|
|
|
@ -2637,8 +2637,13 @@ void color_cycle(int i, int n, wxColour& color) {
|
|||
}
|
||||
|
||||
#ifdef __WXMSW__
|
||||
float GetDPIScaling() {
|
||||
float fScale = 1.0;
|
||||
static float XDPIScaleFactor = 0.0;
|
||||
static float YDPIScaleFactor = 0.0;
|
||||
|
||||
void GetDPIScaling() {
|
||||
XDPIScaleFactor = 1.0;
|
||||
YDPIScaleFactor = 1.0;
|
||||
// SetProcessDPIAware() requires Windows Vista or later
|
||||
HMODULE hUser32 = LoadLibrary(_T("user32.dll"));
|
||||
typedef BOOL (*SetProcessDPIAwareFunc)();
|
||||
SetProcessDPIAwareFunc setDPIAware = (SetProcessDPIAwareFunc)GetProcAddress(hUser32, "SetProcessDPIAware");
|
||||
|
@ -2646,10 +2651,24 @@ float GetDPIScaling() {
|
|||
setDPIAware();
|
||||
HWND hWnd = GetForegroundWindow();
|
||||
HDC hdc = GetDC(hWnd);
|
||||
fScale = GetDeviceCaps(hdc, LOGPIXELSX) / 96.0f;
|
||||
XDPIScaleFactor = GetDeviceCaps(hdc, LOGPIXELSX) / 96.0f;
|
||||
YDPIScaleFactor = GetDeviceCaps(hdc, LOGPIXELSY) / 96.0f;
|
||||
ReleaseDC(hWnd, hdc);
|
||||
}
|
||||
FreeLibrary(hUser32);
|
||||
return fScale;
|
||||
}
|
||||
|
||||
float GetXDPIScaling() {
|
||||
if (XDPIScaleFactor == 0.0) {
|
||||
GetDPIScaling();
|
||||
}
|
||||
return XDPIScaleFactor;
|
||||
}
|
||||
|
||||
float GetYDPIScaling() {
|
||||
if (YDPIScaleFactor == 0.0) {
|
||||
GetDPIScaling();
|
||||
}
|
||||
return YDPIScaleFactor;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -418,10 +418,13 @@ extern void https_to_http(wxString& strMessage);
|
|||
extern void color_cycle(int i, int n, wxColour& color);
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#define ADJUSTFORDPI(x) (int)(x * GetDPIScaling())
|
||||
extern float GetDPIScaling();
|
||||
#define ADJUSTFORXDPI(x) (int)(x * GetXDPIScaling())
|
||||
#define ADJUSTFORYDPI(y) (int)(y * GetYDPIScaling())
|
||||
extern float GetXDPIScaling();
|
||||
extern float GetYDPIScaling();
|
||||
#else
|
||||
#define ADJUSTFORDPI(x) x
|
||||
#define ADJUSTFORXDPI(x) x
|
||||
#define ADJUSTFORYDPI(y) y
|
||||
#endif
|
||||
|
||||
#ifdef SANDBOX
|
||||
|
|
Loading…
Reference in New Issue