Use DPI Aware wxGetSystemMetrics

If no wxWindow is known, use wxTheApp->GetTopWindow().
Also use a wxWindow for all wxSystemSettings::GetMetric calls.
This commit is contained in:
Maarten Bent 2018-07-22 14:16:51 +02:00
parent 04b99d54bd
commit f74d756ca5
37 changed files with 106 additions and 87 deletions

View File

@ -1290,8 +1290,8 @@ void wxAuiTabCtrl::OnMotion(wxMouseEvent& evt)
}
int drag_x_threshold = wxSystemSettings::GetMetric(wxSYS_DRAG_X);
int drag_y_threshold = wxSystemSettings::GetMetric(wxSYS_DRAG_Y);
int drag_x_threshold = wxSystemSettings::GetMetric(wxSYS_DRAG_X, this);
int drag_y_threshold = wxSystemSettings::GetMetric(wxSYS_DRAG_Y, this);
if (abs(pos.x - m_clickPt.x) > drag_x_threshold ||
abs(pos.y - m_clickPt.y) > drag_y_threshold)

View File

@ -4589,8 +4589,8 @@ void wxAuiManager::OnMotion(wxMouseEvent& event)
}
else if (m_action == actionClickCaption)
{
int drag_x_threshold = wxSystemSettings::GetMetric(wxSYS_DRAG_X);
int drag_y_threshold = wxSystemSettings::GetMetric(wxSYS_DRAG_Y);
int drag_x_threshold = wxSystemSettings::GetMetric(wxSYS_DRAG_X, m_frame);
int drag_y_threshold = wxSystemSettings::GetMetric(wxSYS_DRAG_Y, m_frame);
// caption has been clicked. we need to check if the mouse
// is now being dragged. if it is, we need to change the

View File

@ -611,8 +611,8 @@ void wxAuiMDIChildFrame::SetIcons(const wxIconBundle& icons)
wxAuiMDIParentFrame* pParentFrame = GetMDIParentFrame();
wxASSERT_MSG(pParentFrame, wxT("Missing MDI Parent Frame"));
const wxSize sizeIcon(wxSystemSettings::GetMetric(wxSYS_SMALLICON_X),
wxSystemSettings::GetMetric(wxSYS_SMALLICON_Y));
const wxSize sizeIcon(wxSystemSettings::GetMetric(wxSYS_SMALLICON_X, this),
wxSystemSettings::GetMetric(wxSYS_SMALLICON_Y, this));
wxBitmap bmp;
bmp.CopyFromIcon(icons.GetIcon(sizeIcon));

View File

@ -2276,7 +2276,7 @@ void wxComboCtrlBase::ShowPopup()
int maxHeightPopup;
wxSize ctrlSz = GetSize();
screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y );
screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y, this );
scrPos = GetScreenPosition();
spaceAbove = scrPos.y;
@ -2354,7 +2354,7 @@ void wxComboCtrlBase::ShowPopup()
if ( wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft )
leftX -= ctrlSz.x;
int screenWidth = wxSystemSettings::GetMetric( wxSYS_SCREEN_X );
int screenWidth = wxSystemSettings::GetMetric( wxSYS_SCREEN_X, this );
// If there is not enough horizontal space, anchor on the other side.
// If there is no space even then, place the popup at x 0.

View File

@ -1743,7 +1743,7 @@ wxSize wxDataViewSpinRenderer::GetSize() const
// Allow some space for the spin buttons, which is approximately the size
// of a scrollbar (and getting pixel-exact value would be complicated).
// Also add some whitespace between the text and the button:
sz.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
sz.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X, m_editorCtrl);
sz.x += GetTextExtent("M").x;
return sz;
@ -1821,7 +1821,7 @@ wxSize wxDataViewChoiceRenderer::GetSize() const
// Allow some space for the right-side button, which is approximately the
// size of a scrollbar (and getting pixel-exact value would be complicated).
// Also add some whitespace between the text and the button:
sz.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
sz.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X, m_editorCtrl);
sz.x += GetTextExtent("M").x;
return sz;

View File

@ -210,7 +210,7 @@ wxSizer *wxDialogBase::CreateTextSizer(const wxString& message,
const bool is_pda = wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA;
if (is_pda)
{
widthMax = wxSystemSettings::GetMetric( wxSYS_SCREEN_X ) - 25;
widthMax = wxSystemSettings::GetMetric( wxSYS_SCREEN_X, this ) - 25;
}
return wrapper.CreateSizer(message, widthMax);

View File

@ -20,6 +20,7 @@
#ifdef __WINDOWS__
#include "wx/msw/wrapwin.h"
#endif
#include "wx/app.h"
#include "wx/settings.h"
#include "wx/log.h"
#include "wx/intl.h"
@ -266,8 +267,9 @@ wxIcon wxIconBundle::GetIcon(const wxSize& size, int flags) const
sysY = 0;
if ( flags & FALLBACK_SYSTEM )
{
sysX = wxSystemSettings::GetMetric(wxSYS_ICON_X);
sysY = wxSystemSettings::GetMetric(wxSYS_ICON_Y);
wxWindow* win = wxTheApp ? wxTheApp->GetTopWindow() : NULL;
sysX = wxSystemSettings::GetMetric(wxSYS_ICON_X, win);
sysY = wxSystemSettings::GetMetric(wxSYS_ICON_Y, win);
}
// If size == wxDefaultSize, we use system default icon size by convention.

View File

@ -155,9 +155,9 @@ void wxMouseEventsManager::OnMove(wxMouseEvent& event)
// assumption that they don't change -- which is wrong, of
// course, the user can change them but it doesn't happen often
static const int
dragMinX = wxSystemSettings::GetMetric(wxSYS_DRAG_X);
dragMinX = wxSystemSettings::GetMetric(wxSYS_DRAG_X, m_win);
static const int
dragMinY = wxSystemSettings::GetMetric(wxSYS_DRAG_Y);
dragMinY = wxSystemSettings::GetMetric(wxSYS_DRAG_Y, m_win);
const wxPoint& pos = event.GetPosition();
const wxPoint ofs = pos - m_posLast;

View File

@ -58,9 +58,9 @@ public:
{
int w = GetSize().x;
#ifdef __WXMSW__
w -= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X) + 6;
w -= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X, this) + 6;
#else
w -= 2*wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
w -= 2*wxSystemSettings::GetMetric(wxSYS_VSCROLL_X, this);
#endif
if (w < 0) w = 0;
SetColumnWidth(0, w);

View File

@ -830,7 +830,7 @@ wxSize wxVListBoxComboPopup::GetAdjustedSize( int minWidth, int prefHeight, int
CalcWidths();
// Take scrollbar into account in width calculations
int widestWidth = m_widestWidth + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
int widestWidth = m_widestWidth + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X, this);
return wxSize(minWidth > widestWidth ? minWidth : widestWidth,
height+2);
}

View File

@ -1553,11 +1553,12 @@ wxSize wxScrolledT_Helper::FilterBestSize(const wxWindow *win,
wxSize minSize = win->GetMinSize();
wxWindow* window = const_cast<wxWindow*>(win);
if ( ppuX > 0 )
best.x = minSize.x + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
best.x = minSize.x + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X, window);
if ( ppuY > 0 )
best.y = minSize.y + wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y);
best.y = minSize.y + wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y, window);
}
return best;

View File

@ -146,7 +146,7 @@ wxTipWindow::wxTipWindow(wxWindow *parent,
// NB: the reason we use "/ 2" here is that we don't know where the current
// cursors hot spot is... it would be nice if we could find this out
// though
y += wxSystemSettings::GetMetric(wxSYS_CURSOR_Y) / 2;
y += wxSystemSettings::GetMetric(wxSYS_CURSOR_Y, this) / 2;
#if wxUSE_POPUPWIN
Position(wxPoint(x, y), wxSize(0,0));

View File

@ -714,8 +714,8 @@ wxSize wxWizard::GetPageSize() const
if ( wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA )
{
// Make the default page size small enough to fit on screen
DEFAULT_PAGE_WIDTH = wxSystemSettings::GetMetric(wxSYS_SCREEN_X) / 2;
DEFAULT_PAGE_HEIGHT = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) / 2;
DEFAULT_PAGE_WIDTH = wxSystemSettings::GetMetric(wxSYS_SCREEN_X, m_parent) / 2;
DEFAULT_PAGE_HEIGHT = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y, m_parent) / 2;
}
else // !PDA
{

View File

@ -404,7 +404,7 @@ wxSize wxMSWButton::GetFittingSize(wxWindow *win,
// account for the shield UAC icon if we have it
if ( flags & Size_AuthNeeded )
sizeBtn.x += wxSystemSettings::GetMetric(wxSYS_SMALLICON_X);
sizeBtn.x += wxSystemSettings::GetMetric(wxSYS_SMALLICON_X, win);
return sizeBtn;
}

View File

@ -20,6 +20,11 @@
#endif
#include "wx/artprov.h"
#ifndef WX_PRECOMP
#include "wx/app.h"
#endif
#include "wx/image.h"
#include "wx/dynlib.h"
#include "wx/volume.h"
@ -324,32 +329,33 @@ wxBitmap wxWindowsArtProvider::CreateBitmap(const wxArtID& id,
/*static*/
wxSize wxArtProvider::GetNativeSizeHint(const wxArtClient& client)
{
const wxWindow* win = wxTheApp ? wxTheApp->GetTopWindow() : NULL;
if ( client == wxART_TOOLBAR )
{
return wxWindow::FromDIP(wxSize(24, 24), NULL);
return wxWindow::FromDIP(wxSize(24, 24), win);
}
else if ( client == wxART_MENU )
{
return wxWindow::FromDIP(wxSize(16, 16), NULL);
return wxWindow::FromDIP(wxSize(16, 16), win);
}
else if ( client == wxART_FRAME_ICON )
{
return wxSize(::GetSystemMetrics(SM_CXSMICON),
::GetSystemMetrics(SM_CYSMICON));
return wxSize(wxGetSystemMetrics(SM_CXSMICON, win),
wxGetSystemMetrics(SM_CYSMICON, win));
}
else if ( client == wxART_CMN_DIALOG ||
client == wxART_MESSAGE_BOX )
{
return wxSize(::GetSystemMetrics(SM_CXICON),
::GetSystemMetrics(SM_CYICON));
return wxSize(wxGetSystemMetrics(SM_CXICON, win),
wxGetSystemMetrics(SM_CYICON, win));
}
else if (client == wxART_BUTTON)
{
return wxWindow::FromDIP(wxSize(16, 16), NULL);
return wxWindow::FromDIP(wxSize(16, 16), win);
}
else if (client == wxART_LIST)
{
return wxWindow::FromDIP(wxSize(16, 16), NULL);
return wxWindow::FromDIP(wxSize(16, 16), win);
}
return wxDefaultSize;

View File

@ -523,7 +523,7 @@ bool wxMSWOwnerDrawnButtonBase::MSWDrawButton(WXDRAWITEMSTRUCT *item)
// choose the values consistent with those used for native, non
// owner-drawn, buttons
static const int MARGIN = 3;
int CXMENUCHECK = ::GetSystemMetrics(SM_CXMENUCHECK) + 1;
int CXMENUCHECK = wxGetSystemMetrics(SM_CXMENUCHECK, m_win) + 1;
// the buttons were even bigger under Windows XP
if ( wxGetWinVersion() < wxWinVersion_6 )

View File

@ -115,7 +115,10 @@ wxSize wxCursorRefData::ms_sizeStd;
wxCoord wxCursorRefData::GetStandardWidth()
{
if ( !ms_sizeStd.x )
ms_sizeStd.x = wxSystemSettings::GetMetric(wxSYS_CURSOR_X);
{
wxWindow* win = wxTheApp ? wxTheApp->GetTopWindow() : NULL;
ms_sizeStd.x = wxSystemSettings::GetMetric(wxSYS_CURSOR_X, win);
}
return ms_sizeStd.x;
}
@ -123,7 +126,10 @@ wxCoord wxCursorRefData::GetStandardWidth()
wxCoord wxCursorRefData::GetStandardHeight()
{
if ( !ms_sizeStd.y )
ms_sizeStd.y = wxSystemSettings::GetMetric(wxSYS_CURSOR_Y);
{
wxWindow* win = wxTheApp ? wxTheApp->GetTopWindow() : NULL;
ms_sizeStd.y = wxSystemSettings::GetMetric(wxSYS_CURSOR_Y, win);
}
return ms_sizeStd.y;
}

View File

@ -148,7 +148,7 @@ wxSize wxDateTimePickerCtrl::DoGetBestSize() const
size = dc.GetTextExtent(s);
// account for the drop-down arrow or spin arrows
size.x += wxSystemSettings::GetMetric(wxSYS_HSCROLL_ARROW_X);
size.x += wxSystemSettings::GetMetric(wxSYS_HSCROLL_ARROW_X, m_parent);
}
// We need to account for the checkbox, if we have one, ourselves as

View File

@ -334,8 +334,8 @@ bool wxDragImage::BeginDrag(const wxPoint& hotspot, wxWindow* window, bool fullS
#else
if (!m_hCursorImageList)
{
int cxCursor = ::GetSystemMetrics(SM_CXCURSOR);
int cyCursor = ::GetSystemMetrics(SM_CYCURSOR);
int cxCursor = wxGetSystemMetrics(SM_CXCURSOR, window);
int cyCursor = wxGetSystemMetrics(SM_CYCURSOR, window);
m_hCursorImageList = (WXHIMAGELIST) ImageList_Create(cxCursor, cyCursor, ILC_MASK, 1, 1);
}

View File

@ -473,9 +473,10 @@ bool wxICOFileHandler::LoadIcon(wxIcon *icon,
}
else
#endif
// were we asked for a large icon?
if ( desiredWidth == ::GetSystemMetrics(SM_CXICON) &&
desiredHeight == ::GetSystemMetrics(SM_CYICON) )
// were we asked for a large icon?
const wxWindow* win = wxTheApp ? wxTheApp->GetTopWindow() : NULL;
if ( desiredWidth == wxGetSystemMetrics(SM_CXICON, win) &&
desiredHeight == wxGetSystemMetrics(SM_CYICON, win) )
{
// get the specified large icon from file
if ( !::ExtractIconEx(nameReal.t_str(), iconIndex, &hicon, NULL, 1) )
@ -487,8 +488,8 @@ bool wxICOFileHandler::LoadIcon(wxIcon *icon,
name.c_str());
}
}
else if ( desiredWidth == ::GetSystemMetrics(SM_CXSMICON) &&
desiredHeight == ::GetSystemMetrics(SM_CYSMICON) )
else if ( desiredWidth == wxGetSystemMetrics(SM_CXSMICON, win) &&
desiredHeight == wxGetSystemMetrics(SM_CYSMICON, win) )
{
// get the specified small icon from file
if ( !::ExtractIconEx(nameReal.t_str(), iconIndex, NULL, &hicon, 1) )
@ -668,8 +669,9 @@ wxSize wxGetHiconSize(HICON hicon)
if ( !size.x )
{
// use default icon size on this hardware
size.x = ::GetSystemMetrics(SM_CXICON);
size.y = ::GetSystemMetrics(SM_CYICON);
const wxWindow* win = wxTheApp ? wxTheApp->GetTopWindow() : NULL;
size.x = wxGetSystemMetrics(SM_CXICON, win);
size.y = wxGetSystemMetrics(SM_CYICON, win);
}
return size;

View File

@ -124,7 +124,7 @@ bool wxHeaderCtrl::Create(wxWindow *parent,
// use 0 here but this starts to look ugly)
if ( wxApp::GetComCtl32Version() >= 600 )
{
(void)Header_SetBitmapMargin(GetHwnd(), ::GetSystemMetrics(SM_CXEDGE));
(void)Header_SetBitmapMargin(GetHwnd(), wxGetSystemMetrics(SM_CXEDGE, parent));
}
return true;

View File

@ -625,7 +625,7 @@ wxSize wxListBox::DoGetBestClientSize() const
wListbox += 3*GetCharWidth();
// add room for the scrollbar
wListbox += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
wListbox += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X, m_parent);
// don't make the listbox too tall (limit height to 10 items) but don't
// make it too small neither

View File

@ -1486,9 +1486,9 @@ wxSize wxListCtrl::MSWGetBestViewRect(int x, int y) const
const DWORD mswStyle = ::GetWindowLong(GetHwnd(), GWL_STYLE);
if ( mswStyle & WS_HSCROLL )
size.y += wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y);
size.y += wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y, m_parent);
if ( mswStyle & WS_VSCROLL )
size.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
size.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X, m_parent);
// OTOH we have to subtract the size of our borders because the base class
// public method already adds them, but ListView_ApproximateViewRect()

View File

@ -126,10 +126,10 @@ private:
int m_modeOld;
};
inline bool IsGreaterThanStdSize(const wxBitmap& bmp)
inline bool IsGreaterThanStdSize(const wxBitmap& bmp, const wxWindow* win)
{
return bmp.GetWidth() > ::GetSystemMetrics(SM_CXMENUCHECK) ||
bmp.GetHeight() > ::GetSystemMetrics(SM_CYMENUCHECK);
return bmp.GetWidth() > wxGetSystemMetrics(SM_CXMENUCHECK, win) ||
bmp.GetHeight() > wxGetSystemMetrics(SM_CYMENUCHECK, win);
}
} // anonymous namespace
@ -306,9 +306,9 @@ MenuDrawData* MenuDrawData::ms_instance = NULL;
void MenuDrawData::Init()
{
#if wxUSE_UXTHEME
const wxWindow* window = wxTheApp ? wxTheApp->GetTopWindow() : NULL;
if ( IsUxThemeActive() )
{
wxWindow* window = static_cast<wxApp*>(wxApp::GetInstance())->GetTopWindow();
wxUxThemeHandle hTheme(window, L"MENU");
::GetThemeMargins(hTheme, NULL, MENU_POPUPITEM, 0,
@ -366,12 +366,12 @@ void MenuDrawData::Init()
const NONCLIENTMETRICS& metrics = wxMSWImpl::GetNonClientMetrics();
CheckMargin.cxLeftWidth =
CheckMargin.cxRightWidth = ::GetSystemMetrics(SM_CXEDGE);
CheckMargin.cxRightWidth = wxGetSystemMetrics(SM_CXEDGE, window);
CheckMargin.cyTopHeight =
CheckMargin.cyBottomHeight = ::GetSystemMetrics(SM_CYEDGE);
CheckMargin.cyBottomHeight = wxGetSystemMetrics(SM_CYEDGE, window);
CheckSize.cx = ::GetSystemMetrics(SM_CXMENUCHECK);
CheckSize.cy = ::GetSystemMetrics(SM_CYMENUCHECK);
CheckSize.cx = wxGetSystemMetrics(SM_CXMENUCHECK, window);
CheckSize.cy = wxGetSystemMetrics(SM_CYMENUCHECK, window);
ArrowSize = CheckSize;
@ -1293,8 +1293,9 @@ bool wxMenuItem::MSWMustUseOwnerDrawn()
const wxBitmap& bmpUnchecked = GetBitmap(false),
bmpChecked = GetBitmap(true);
if ( (bmpUnchecked.IsOk() && IsGreaterThanStdSize(bmpUnchecked)) ||
(bmpChecked.IsOk() && IsGreaterThanStdSize(bmpChecked)) ||
const wxWindow* win = m_parentMenu ? m_parentMenu->GetWindow() : NULL;
if ( (bmpUnchecked.IsOk() && IsGreaterThanStdSize(bmpUnchecked, win)) ||
(bmpChecked.IsOk() && IsGreaterThanStdSize(bmpChecked, win)) ||
(bmpChecked.IsOk() && IsCheckable()) )
{
mustUseOwnerDrawn = true;

View File

@ -193,8 +193,8 @@ void wxMessageDialog::ReplaceStaticWithEdit()
// some space above and below it
const int hText = (7*rectDisplay.height)/8 -
(
2*::GetSystemMetrics(SM_CYFIXEDFRAME) +
::GetSystemMetrics(SM_CYCAPTION) +
2*wxGetSystemMetrics(SM_CYFIXEDFRAME, this) +
wxGetSystemMetrics(SM_CYCAPTION, this) +
5*GetCharHeight() // buttons + margins
);
const int dh = (rc.bottom - rc.top) - hText; // vertical space we save
@ -207,8 +207,8 @@ void wxMessageDialog::ReplaceStaticWithEdit()
// NB: you would have thought that 2*SM_CXEDGE would be enough but it
// isn't, somehow, and the text control breaks lines differently from
// the static one so fudge by adding some extra space
const int dw = ::GetSystemMetrics(SM_CXVSCROLL) +
4*::GetSystemMetrics(SM_CXEDGE);
const int dw = wxGetSystemMetrics(SM_CXVSCROLL, this) +
4*wxGetSystemMetrics(SM_CXEDGE, this);
rc.right += dw;

View File

@ -802,10 +802,10 @@ void wxProgressDialog::SetIcons(const wxIconBundle& icons)
wxIcon iconBig;
if (!icons.IsEmpty())
{
const wxSize sizeSmall(::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON));
const wxSize sizeSmall(wxGetSystemMetrics(SM_CXSMICON, this), wxGetSystemMetrics(SM_CYSMICON, this));
iconSmall = icons.GetIcon(sizeSmall, wxIconBundle::FALLBACK_NEAREST_LARGER);
const wxSize sizeBig(::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON));
const wxSize sizeBig(wxGetSystemMetrics(SM_CXICON, this), wxGetSystemMetrics(SM_CYICON, this));
iconBig = icons.GetIcon(sizeBig, wxIconBundle::FALLBACK_NEAREST_LARGER);
}

View File

@ -527,8 +527,8 @@ wxSize wxRendererMSW::GetCheckBoxSize(wxWindow* win)
// that it's valid to avoid surprises when using themes.
wxCHECK_MSG( win, wxSize(0, 0), "Must have a valid window" );
return wxSize(::GetSystemMetrics(SM_CXMENUCHECK),
::GetSystemMetrics(SM_CYMENUCHECK));
return wxSize(wxGetSystemMetrics(SM_CXMENUCHECK, win),
wxGetSystemMetrics(SM_CYMENUCHECK, win));
}
int wxRendererMSW::GetHeaderButtonHeight(wxWindow * win)

View File

@ -208,11 +208,11 @@ wxSize wxScrollBar::DoGetBestSize() const
if ( IsVertical() )
{
w = wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
w = wxSystemSettings::GetMetric(wxSYS_VSCROLL_X, m_parent);
}
else
{
h = wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y);
h = wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y, m_parent);
}
return wxSize(w, h);

View File

@ -260,7 +260,7 @@ static const int gs_metricsMap[] =
};
// Get a system metric, e.g. scrollbar size
int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow* WXUNUSED(win))
int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow* win)
{
wxCHECK_MSG( index > 0 && (size_t)index < WXSIZEOF(gs_metricsMap), 0,
wxT("invalid metric") );
@ -297,7 +297,7 @@ int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow* WXUNUSED(w
return -1;
}
int rc = ::GetSystemMetrics(indexMSW);
int rc = wxGetSystemMetrics(indexMSW, win);
if ( index == wxSYS_NETWORK_PRESENT )
{
// only the last bit is significant according to the MSDN

View File

@ -150,8 +150,8 @@ wxSize wxSpinButton::DoGetBestSize() const
{
const bool vert = HasFlag(wxSP_VERTICAL);
wxSize bestSize(::GetSystemMetrics(vert ? SM_CXVSCROLL : SM_CXHSCROLL),
::GetSystemMetrics(vert ? SM_CYVSCROLL : SM_CYHSCROLL));
wxSize bestSize(wxGetSystemMetrics(vert ? SM_CXVSCROLL : SM_CXHSCROLL, m_parent),
wxGetSystemMetrics(vert ? SM_CYVSCROLL : SM_CYHSCROLL, m_parent));
if ( vert )
bestSize.y *= 2;

View File

@ -2442,14 +2442,14 @@ wxSize wxTextCtrl::DoGetSizeFromTextSize(int xlen, int ylen) const
{
// add space for vertical scrollbar
if ( !(m_windowStyle & wxTE_NO_VSCROLL) )
wText += ::GetSystemMetrics(SM_CXVSCROLL);
wText += wxGetSystemMetrics(SM_CXVSCROLL, m_parent);
if ( ylen <= 0 )
{
hText *= wxMax(wxMin(GetNumberOfLines(), 10), 2);
// add space for horizontal scrollbar
if ( m_windowStyle & wxHSCROLL )
hText += ::GetSystemMetrics(SM_CYHSCROLL);
hText += wxGetSystemMetrics(SM_CYHSCROLL, m_parent);
}
}
// for single line control cy (height + external leading) is ok

View File

@ -581,11 +581,11 @@ wxSize wxToolBar::DoGetBestSize() const
wxSize sizeBest;
if ( IsVertical() )
{
sizeBest.x = sizeTool.x + 2 * ::GetSystemMetrics(SM_CXBORDER);
sizeBest.x = sizeTool.x + 2 * wxGetSystemMetrics(SM_CXBORDER, this);
}
else
{
sizeBest.y = sizeTool.y + 2 * ::GetSystemMetrics(SM_CYBORDER);
sizeBest.y = sizeTool.y + 2 * wxGetSystemMetrics(SM_CYBORDER, this);
}
wxToolBarToolsList::compatibility_iterator node;
@ -634,11 +634,11 @@ wxSize wxToolBar::DoGetBestSize() const
{
if ( IsVertical() )
{
sizeBest.x += 2 * ::GetSystemMetrics(SM_CXBORDER);
sizeBest.x += 2 * wxGetSystemMetrics(SM_CXBORDER, this);
}
else
{
sizeBest.y += 2 * ::GetSystemMetrics(SM_CYBORDER);
sizeBest.y += 2 * wxGetSystemMetrics(SM_CYBORDER, this);
}
}
@ -1247,7 +1247,7 @@ bool wxToolBar::Realize()
{
// We want just the usable height, so remove the space taken by the
// border/divider.
height -= 2 * ::GetSystemMetrics(SM_CYBORDER);
height -= 2 * wxGetSystemMetrics(SM_CYBORDER, this);
}
// adjust the controls size to fit nicely in the toolbar and compute its

View File

@ -984,7 +984,7 @@ bool wxTopLevelWindowMSW::DoSelectAndSetIcon(const wxIconBundle& icons,
int smY,
int i)
{
const wxSize size(::GetSystemMetrics(smX), ::GetSystemMetrics(smY));
const wxSize size(wxGetSystemMetrics(smX, this), wxGetSystemMetrics(smY, this));
wxIcon icon = icons.GetIcon(size, wxIconBundle::FALLBACK_NEAREST_LARGER);

View File

@ -3018,8 +3018,8 @@ wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
int cx = abs(m_ptClick.x - x);
int cy = abs(m_ptClick.y - y);
if ( cx > ::GetSystemMetrics(SM_CXDRAG) ||
cy > ::GetSystemMetrics(SM_CYDRAG) )
if ( cx > wxGetSystemMetrics(SM_CXDRAG, this) ||
cy > wxGetSystemMetrics(SM_CYDRAG, this) )
{
NM_TREEVIEW tv;
wxZeroMemory(tv);

View File

@ -647,7 +647,7 @@ void wxPropertyGridManager::SetId( wxWindowID winid )
wxSize wxPropertyGridManager::DoGetBestSize() const
{
// Width: margin=15 + columns=2*40 + scroll bar
return wxSize(15+2*40+wxSystemSettings::GetMetric(wxSYS_VSCROLL_X), 150);
return wxSize(15+2*40+wxSystemSettings::GetMetric(wxSYS_VSCROLL_X, m_pPropGrid), 150);
}
// -----------------------------------------------------------------------

View File

@ -1711,8 +1711,8 @@ wxPoint wxPropertyGrid::GetGoodEditorDialogPosition( wxPGProperty* p,
ImprovedClientToScreen( &x, &y );
int sw = wxSystemSettings::GetMetric( ::wxSYS_SCREEN_X );
int sh = wxSystemSettings::GetMetric( ::wxSYS_SCREEN_Y );
int sw = wxSystemSettings::GetMetric( ::wxSYS_SCREEN_X, this );
int sh = wxSystemSettings::GetMetric( ::wxSYS_SCREEN_Y, this );
int new_x;
int new_y;

View File

@ -2718,7 +2718,8 @@ PRectangle wxSTCListBox::GetDesiredRect() const
// Add space for a scrollbar if needed.
if ( count > desiredVisibleRows )
maxw += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
maxw += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X,
const_cast<wxWindow*>(wxDynamicCast(this, wxWindow)));
// Add borders.
maxw += 2 * m_borderSize;