From 03d2a3a685258d823bf4287614c0b3b1273eeb1f Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 7 Aug 2022 17:26:17 +0200 Subject: [PATCH] Windows are properly stacked and destructed in the right order. --- src/gui/fluxviewercontrol.cc | 6 +++--- src/gui/fluxviewerwindow.cc | 4 ++-- src/gui/fluxviewerwindow.h | 2 +- src/gui/hexviewerwindow.cc | 4 ++-- src/gui/hexviewerwindow.h | 2 +- src/gui/mainwindow.cc | 2 +- src/gui/visualisationcontrol.cc | 9 ++++----- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/gui/fluxviewercontrol.cc b/src/gui/fluxviewercontrol.cc index 866b7e0f..75efa72f 100644 --- a/src/gui/fluxviewercontrol.cc +++ b/src/gui/fluxviewercontrol.cc @@ -441,7 +441,7 @@ void FluxViewerControl::DisplayDecodedData(std::shared_ptr sector) hexdump(s, sector->data); - (new HexViewerWindow(s.str()))->Show(true); + (new HexViewerWindow(this, s.str()))->Show(true); } void FluxViewerControl::DisplayRawData(std::shared_ptr sector) @@ -459,7 +459,7 @@ void FluxViewerControl::DisplayRawData(std::shared_ptr sector) hexdump(s, record->rawData); } - (new HexViewerWindow(s.str()))->Show(true); + (new HexViewerWindow(this, s.str()))->Show(true); } void FluxViewerControl::DisplayRawData(const Location& location, std::shared_ptr record) @@ -472,5 +472,5 @@ void FluxViewerControl::DisplayRawData(const Location& location, std::shared_ptr hexdump(s, record->rawData); - (new HexViewerWindow(s.str()))->Show(true); + (new HexViewerWindow(this, s.str()))->Show(true); } diff --git a/src/gui/fluxviewerwindow.cc b/src/gui/fluxviewerwindow.cc index ce53518b..b7ccad84 100644 --- a/src/gui/fluxviewerwindow.cc +++ b/src/gui/fluxviewerwindow.cc @@ -4,8 +4,8 @@ #include "fluxviewerwindow.h" #include "fluxviewercontrol.h" -FluxViewerWindow::FluxViewerWindow(std::shared_ptr flux): - FluxViewerWindowGen(nullptr), +FluxViewerWindow::FluxViewerWindow(wxWindow* parent, std::shared_ptr flux): + FluxViewerWindowGen(parent), _flux(flux) { fluxviewer->SetScrollbar(scrollbar); diff --git a/src/gui/fluxviewerwindow.h b/src/gui/fluxviewerwindow.h index 2bfd75e1..0ef7d6a6 100644 --- a/src/gui/fluxviewerwindow.h +++ b/src/gui/fluxviewerwindow.h @@ -8,7 +8,7 @@ class TrackFlux; class FluxViewerWindow : public FluxViewerWindowGen { public: - FluxViewerWindow(std::shared_ptr flux); + FluxViewerWindow(wxWindow* parent, std::shared_ptr flux); private: void OnExit(wxCommandEvent& event); diff --git a/src/gui/hexviewerwindow.cc b/src/gui/hexviewerwindow.cc index 111e8946..b79ebfe1 100644 --- a/src/gui/hexviewerwindow.cc +++ b/src/gui/hexviewerwindow.cc @@ -4,8 +4,8 @@ #include "hexviewerwindow.h" #include "fmt/format.h" -HexViewerWindow::HexViewerWindow(const std::string& text): - HexViewerWindowGen(nullptr) +HexViewerWindow::HexViewerWindow(wxWindow* parent, const std::string& text): + HexViewerWindowGen(parent) { auto size = hexEntry->GetTextExtent("M"); SetSize(size.Scale(85, 25)); diff --git a/src/gui/hexviewerwindow.h b/src/gui/hexviewerwindow.h index 91ceb4e1..43369d55 100644 --- a/src/gui/hexviewerwindow.h +++ b/src/gui/hexviewerwindow.h @@ -6,7 +6,7 @@ class HexViewerWindow : public HexViewerWindowGen { public: - HexViewerWindow(const std::string& text); + HexViewerWindow(wxWindow* parent, const std::string& text); private: void OnExit(wxCommandEvent& event); diff --git a/src/gui/mainwindow.cc b/src/gui/mainwindow.cc index 7a561ba8..6459428c 100644 --- a/src/gui/mainwindow.cc +++ b/src/gui/mainwindow.cc @@ -384,6 +384,6 @@ void MainWindow::UpdateDevices() void MainWindow::OnTrackSelection(TrackSelectionEvent& event) { - (new FluxViewerWindow(event.trackFlux))->Show(true); + (new FluxViewerWindow(this, event.trackFlux))->Show(true); } diff --git a/src/gui/visualisationcontrol.cc b/src/gui/visualisationcontrol.cc index e8d2e6a5..d748fb96 100644 --- a/src/gui/visualisationcontrol.cc +++ b/src/gui/visualisationcontrol.cc @@ -183,8 +183,6 @@ void VisualisationControl::OnPaint(wxPaintEvent&) void VisualisationControl::OnMotion(wxMouseEvent& event) { - wxClientDC dc(this); - auto loc = event.GetLogicalPosition(dc); auto size = GetSize(); int w = size.GetWidth(); int w2 = w / 2; @@ -195,9 +193,9 @@ void VisualisationControl::OnMotion(wxMouseEvent& event) int scaletop = h / 2 - scalesize / 2; int scalebottom = scaletop + scalesize - 1; - int headno = loc.x > w2; + int headno = event.GetX() > w2; - int trackno = (loc.y - scaletop) / SECTORSIZE; + int trackno = (event.GetY() - scaletop) / SECTORSIZE; if ((trackno < 0) || (trackno >= TRACKS)) trackno = -1; if ((_selectedHead != headno) || (_selectedTrack != trackno)) @@ -210,7 +208,6 @@ void VisualisationControl::OnMotion(wxMouseEvent& event) void VisualisationControl::OnLeftDown(wxMouseEvent& event) { - event.Skip(); OnMotion(event); if ((_selectedHead != -1) && (_selectedTrack != -1)) @@ -225,6 +222,8 @@ void VisualisationControl::OnLeftDown(wxMouseEvent& event) ProcessWindowEvent(event); } } + else + event.Skip(); } void VisualisationControl::OnLeaveWindow(wxMouseEvent&)