From 0706ecae13065cbb7179b67ae5a33186857a1d18 Mon Sep 17 00:00:00 2001 From: Twan van Laarhoven Date: Thu, 16 Apr 2020 19:29:46 +0200 Subject: [PATCH] Fix wxGTK warnings about GetScrollPos on window without scrollbar --- src/gui/control/card_viewer.cpp | 3 ++- src/gui/control/native_look_editor.cpp | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gui/control/card_viewer.cpp b/src/gui/control/card_viewer.cpp index 18fac477..55621493 100644 --- a/src/gui/control/card_viewer.cpp +++ b/src/gui/control/card_viewer.cpp @@ -146,7 +146,8 @@ Rotation CardViewer::getRotation() const { // Same as DataViewer::getRotation, only taking into account scrolling if (!stylesheet) stylesheet = set->stylesheet; StyleSheetSettings& ss = settings.stylesheetSettingsFor(*stylesheet); - int dx = GetScrollPos(wxHORIZONTAL), dy = GetScrollPos(wxVERTICAL); + int dx = CanScroll(wxHORIZONTAL) ? GetScrollPos(wxHORIZONTAL) : 0; + int dy = CanScroll(wxVERTICAL) ? GetScrollPos(wxVERTICAL) : 0; return Rotation(deg_to_rad(ss.card_angle()), stylesheet->getCardRect().move(-dx,-dy,0,0), ss.card_zoom(), 1.0, ROTATION_ATTACH_TOP_LEFT); } diff --git a/src/gui/control/native_look_editor.cpp b/src/gui/control/native_look_editor.cpp index 16ac61c2..ca2b53a8 100644 --- a/src/gui/control/native_look_editor.cpp +++ b/src/gui/control/native_look_editor.cpp @@ -24,7 +24,8 @@ NativeLookEditor::NativeLookEditor(Window* parent, int id, long style) {} Rotation NativeLookEditor::getRotation() const { - int dx = GetScrollPos(wxHORIZONTAL), dy = GetScrollPos(wxVERTICAL); + int dx = CanScroll(wxHORIZONTAL) ? GetScrollPos(wxHORIZONTAL) : 0; + int dy = CanScroll(wxVERTICAL) ? GetScrollPos(wxVERTICAL) : 0; return Rotation(0, RealRect(RealPoint(-dx,-dy),GetClientSize())); } @@ -90,7 +91,9 @@ void NativeLookEditor::resizeViewers() { } y = y - vspace + margin; SetVirtualSize(w, (int)y); - SetScrollbar(wxVERTICAL, 0, h, (int)y); + if (CanScroll(wxVERTICAL)) { + SetScrollbar(wxVERTICAL, 0, h, (int)y); + } if (y >= h) { // Doesn't fit vertically, add scrollbar and resize /*