summaryrefslogtreecommitdiff
path: root/wx+/mouse_move_dlg.cpp
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:15:16 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:15:16 +0200
commitbd6336c629841c6db3a6ca53a936d629d34db53b (patch)
tree3721ef997864108df175ce677a8a7d4342a6f1d2 /wx+/mouse_move_dlg.cpp
parent4.0 (diff)
downloadFreeFileSync-bd6336c629841c6db3a6ca53a936d629d34db53b.tar.gz
FreeFileSync-bd6336c629841c6db3a6ca53a936d629d34db53b.tar.bz2
FreeFileSync-bd6336c629841c6db3a6ca53a936d629d34db53b.zip
4.1
Diffstat (limited to 'wx+/mouse_move_dlg.cpp')
-rw-r--r--wx+/mouse_move_dlg.cpp72
1 files changed, 72 insertions, 0 deletions
diff --git a/wx+/mouse_move_dlg.cpp b/wx+/mouse_move_dlg.cpp
new file mode 100644
index 00000000..3f7ca755
--- /dev/null
+++ b/wx+/mouse_move_dlg.cpp
@@ -0,0 +1,72 @@
+// **************************************************************************
+// * This file is part of the FreeFileSync project. It is distributed under *
+// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
+// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
+// **************************************************************************
+
+#include "mouse_move_dlg.h"
+#include <vector>
+#include <zen/win.h> //includes "windows.h"
+#include <wx/stattext.h>
+#include <wx/statbmp.h>
+#include <wx/statline.h>
+#include <wx/animate.h>
+#include <wx/panel.h>
+#include <wx/gauge.h>
+#include <wx/statusbr.h>
+
+using namespace zen;
+
+
+namespace
+{
+template <class Fun> inline
+void forEachChild(wxWindow& parent, Fun f)
+{
+ wxWindowList& wl = parent.GetChildren();
+ for (auto iter = wl.begin(); iter != wl.end(); ++iter) //yet another wxWidgets bug keeps us from using std::for_each
+ {
+ wxWindow& wnd = **iter;
+ f(wnd);
+ forEachChild(wnd, f);
+ }
+}
+}
+
+MouseMoveWindow::MouseMoveWindow(wxWindow& parent, bool includeParent) : wxWindow(&parent, wxID_ANY)
+{
+ wxObjectEventFunction memFunMouseDown = wxMouseEventHandler(MouseMoveWindow::LeftButtonDown);
+ auto connect = [&](wxWindow& wnd)
+ {
+ if (dynamic_cast<wxStaticText*> (&wnd) || //redirect clicks on these "dead" controls to move dialog instead
+ dynamic_cast<wxStaticBitmap*> (&wnd) ||
+ dynamic_cast<wxAnimationCtrl*>(&wnd) ||
+ dynamic_cast<wxGauge*> (&wnd) ||
+ dynamic_cast<wxStaticLine*> (&wnd) ||
+ dynamic_cast<wxStatusBar*> (&wnd) ||
+ dynamic_cast<wxPanel*> (&wnd))
+ wnd.Connect(wxEVT_LEFT_DOWN, memFunMouseDown, NULL, this); //wxWidgets macros are obviously not C++11 ready
+ };
+
+ if (includeParent)
+ connect(parent);
+ forEachChild(parent, connect);
+
+ Hide(); //this is just a dummy window so that its parent can have ownership
+ Disable();
+}
+
+
+void MouseMoveWindow::LeftButtonDown(wxMouseEvent& event)
+{
+ if (GetParent() && allowMove(event))
+ {
+ ::ReleaseCapture();
+ //::SendMessage(GetHwndOf(dialogToMove_), WM_NCLBUTTONDOWN, HTCAPTION, 0);
+ ::SendMessage(static_cast<HWND>(GetParent()->GetHWND()), WM_NCLBUTTONDOWN, HTCAPTION, 0);
+
+ return;
+ //event.Skip(); -> swallow event, to avoid other windows losing focus
+ }
+ event.Skip();
+}
bgstack15