]> git.saurik.com Git - wxWidgets.git/commitdiff
Implemented wxMouseCaptureChangedEvent and made wxGenericDragImage check it
authorJulian Smart <julian@anthemion.co.uk>
Fri, 12 Apr 2002 20:26:43 +0000 (20:26 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Fri, 12 Apr 2002 20:26:43 +0000 (20:26 +0000)
the capture before release it.
Documented wxMouseCaptureChangedEvent and GetCapture/FindCapture.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15117 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
docs/latex/wx/category.tex
docs/latex/wx/classes.tex
docs/latex/wx/mcaptevt.tex [new file with mode: 0644]
docs/latex/wx/window.tex
include/wx/event.h
include/wx/msw/window.h
src/common/event.cpp
src/generic/dragimgg.cpp
src/msw/window.cpp

index 4fd63579219c22e063b6ceea67b6105be3861ad5..9aa739d0e0227cd1236c3ae5cc45f03f4ab0283f 100644 (file)
@@ -157,6 +157,7 @@ All (GUI):
   for GTK+, Mac, MGL, X11, Motif ports (Chris Elliott)
 - added (platform-dependent) scan code to wxKeyEvent (Bryce Denney)
 - added wxTextCtrl::EmulateKeyPress()
+- Added wxMouseCaptureChangedEvent
 
 wxMSW:
 
@@ -180,6 +181,8 @@ wxMSW:
 - wxWindowDC and wxClientDC::GetSize() works correctly now
 - Added wxTB_NODIVIDER and wxTB_NOALIGN so native toolbar can be used in FL
 - Multiline labels in buttons are now supoprted (simply use "\n" in the label)
+- Implemented wxMouseCaptureChangedEvent and made wxGenericDragImage check it
+  has the capture before release it.
 
 wxGTK:
 
index 9f4e00b35e521a13837d877988df486264ea921b..4909916033213922a58edee0f68cf7bf5dd88f47 100644 (file)
@@ -222,6 +222,7 @@ An event object contains information about a specific event. Event handlers
 \twocolitem{\helpref{wxListEvent}{wxlistevent}}{A list control event}
 \twocolitem{\helpref{wxMaximizeEvent}{wxmaximizeevent}}{A maximize event}
 \twocolitem{\helpref{wxMenuEvent}{wxmenuevent}}{A menu event}
+\twocolitem{\helpref{wxMouseCaptureChangedEvent}{wxmousecapturechangedevent}}{A mouse capture changed event}
 \twocolitem{\helpref{wxMouseEvent}{wxmouseevent}}{A mouse event}
 \twocolitem{\helpref{wxMoveEvent}{wxmoveevent}}{A move event}
 \twocolitem{\helpref{wxNotebookEvent}{wxnotebookevent}}{A notebook control event}
index 18e77a0da7086c19b12652a5103ae213d6b76406..5120418bcbe507f4f93b502c2cd4e20366254f07 100644 (file)
 \input mimetype.tex
 \input minifram.tex
 \input module.tex
+\input mcaptevt.tex
 \input mouseevt.tex
 \input moveevt.tex
 \input mltchdlg.tex
diff --git a/docs/latex/wx/mcaptevt.tex b/docs/latex/wx/mcaptevt.tex
new file mode 100644 (file)
index 0000000..05810e3
--- /dev/null
@@ -0,0 +1,50 @@
+\section{\class{wxMouseCaptureChangedEvent}}\label{wxmousecapturechangedevent}
+
+An mouse capture changed event is sent to a window that loses its
+mouse capture. This is called even if wxWindow::ReleaseCapture
+was called by the application code. Handling this event allows
+an application to cater for unexpected capture releases which
+might otherwise confuse mouse handling code.
+
+This event is implemented under Windows only.
+
+\wxheading{Derived from}
+
+\helpref{wxEvent}{wxevent}\\
+\helpref{wxObject}{wxobject}
+
+\wxheading{Include files}
+
+<wx/event.h>
+
+\wxheading{Event table macros}
+
+To process this event, use the following event handler macro to direct input to a member
+function that takes a wxMouseCaptureChangedEvent argument.
+
+\twocolwidtha{7cm}
+\begin{twocollist}\itemsep=0pt
+\twocolitem{{\bf EVT\_MOUSE\_CAPTURE\_CHANGED(func)}}{Process a wxEVT\_MOUSE\_CAPTURE\_CHANGED event.}
+\end{twocollist}%
+
+\wxheading{See also}
+
+\helpref{Event handling overview}{eventhandlingoverview}, 
+\helpref{wxWindow::CaptureMouse}{wxwindowcapturemouse}, 
+\helpref{wxWindow::ReleaseMouse}{wxwindowreleasemouse}, 
+\helpref{wxWindow::GetCapture}{wxwindowgetcapture}
+
+\latexignore{\rtfignore{\wxheading{Members}}}
+
+\membersection{wxMouseCaptureChangedEvent::wxMouseCaptureChangedEvent}
+
+\func{}{wxMouseCaptureChangedEvent}{\param{wxWindowID }{windowId = 0}, \param{wxWindow*}{ gainedCapture = NULL}}
+
+Constructor.
+
+\membersection{wxActivateEvent::GetCapturedWindow}\label{wxmousecapturechangedeventgetcapturedwindow}
+
+\constfunc{wxWindow*}{GetCapturedWindow}{\void}
+
+Returns the window that gained the capture, or NULL if it was a non-wxWindows window.
+
index ca648a2f1f60dc2ba1074b26039ab8ccd5c1abe4..c5846f1cd0e3c547353a13f3ed919b7fa525ef6e 100644 (file)
@@ -509,6 +509,19 @@ same as the size the window would have had after calling
 
 Returns the \helpref{caret}{wxcaret} associated with the window.
 
+\membersection{wxWindow::GetCapture}\label{wxwindowgetcapture}
+
+\func{static wxWindow *}{GetCapture}{\void}
+
+Returns the currently captured window.
+
+\wxheading{See also}
+
+\helpref{wxWindow::HasCapture}{wxwindowhascapture}, 
+\helpref{wxWindow::CaptureMouse}{wxwindowcapturemouse}, 
+\helpref{wxWindow::ReleaseMouse}{wxwindowreleasemouse}, 
+\helpref{wxMouseCaptureChangedEvent}{wxmousecapturechangedevent}
+
 \membersection{wxWindow::GetCharHeight}
 
 \constfunc{virtual int}{GetCharHeight}{\void}
@@ -896,6 +909,18 @@ Returns a pointer to the current validator for the window, or NULL if there is n
 Gets the window style that was passed to the constructor or {\bf Create}
 method. {\bf GetWindowStyle()} is another name for the same function.
 
+\membersection{wxWindow::HasCapture}\label{wxwindowhascapture}
+
+\constfunc{virtual bool}{HasCapture}{\void}
+
+Returns TRUE if this window has the current mouse capture.
+
+\wxheading{See also}
+
+\helpref{wxWindow::CaptureMouse}{wxwindowcapturemouse}, 
+\helpref{wxWindow::ReleaseMouse}{wxwindowreleasemouse}, 
+\helpref{wxMouseCaptureChangedEvent}{wxmousecapturechangedevent}
+
 \membersection{wxWindow::Hide}\label{wxwindowhide}
 
 \func{bool}{Hide}{\void}
@@ -1665,7 +1690,10 @@ Releases mouse input captured with \helpref{wxWindow::CaptureMouse}{wxwindowcapt
 
 \wxheading{See also}
 
-\helpref{wxWindow::CaptureMouse}{wxwindowcapturemouse}
+\helpref{wxWindow::CaptureMouse}{wxwindowcapturemouse}, 
+\helpref{wxWindow::HasCapture}{wxwindowhascapture}, 
+\helpref{wxWindow::ReleaseMouse}{wxwindowreleasemouse}, 
+\helpref{wxMouseCaptureChangedEvent}{wxmousecapturechangedevent}
 
 \membersection{wxWindow::RemoveChild}\label{wxwindowremovechild}
 
index 42ad307d7f11d05e2309aef192e1797e0ff5b01f..d4aa880a672b680962c36dafcf0049b739eebb3e 100644 (file)
@@ -1397,6 +1397,27 @@ private:
     DECLARE_DYNAMIC_CLASS(wxSysColourChangedEvent)
 };
 
+/*
+ wxEVT_MOUSE_CAPTURE_CHANGED
+ The window losing the capture receives this message
+ (even if it released the capture itself).
+ */
+
+class WXDLLEXPORT wxMouseCaptureChangedEvent : public wxEvent
+{
+public:
+    wxMouseCaptureChangedEvent(wxWindowID id = 0, wxWindow* gainedCapture = NULL): wxEvent(id)
+        { m_eventType = wxEVT_MOUSE_CAPTURE_CHANGED; m_gainedCapture = gainedCapture; }
+
+    virtual wxEvent *Clone() const { return new wxMouseCaptureChangedEvent(*this); }
+
+    wxWindow* GetCapturedWindow() const { return m_gainedCapture; };
+
+private:
+    wxWindow* m_gainedCapture;
+    DECLARE_DYNAMIC_CLASS(wxMouseCaptureChangedEvent)
+};
+
 /*
  wxEVT_DISPLAY_CHANGED
  */
@@ -1947,6 +1968,7 @@ typedef void (wxEvtHandler::*wxSetCursorEventFunction)(wxSetCursorEvent&);
 typedef void (wxEvtHandler::*wxNotifyEventFunction)(wxNotifyEvent&);
 typedef void (wxEvtHandler::*wxHelpEventFunction)(wxHelpEvent&);
 typedef void (wxEvtHandler::*wxContextMenuEventFunction)(wxContextMenuEvent&);
+typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureChangedEvent&);
 #endif // wxUSE_GUI
 
 // N.B. In GNU-WIN32, you *have* to take the address of a member function
@@ -2013,6 +2035,7 @@ typedef void (wxEvtHandler::*wxContextMenuEventFunction)(wxContextMenuEvent&);
 #define EVT_WINDOW_CREATE(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_CREATE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxWindowCreateEventFunction) & func, (wxObject *) NULL ),
 #define EVT_WINDOW_DESTROY(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_DESTROY, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxWindowDestroyEventFunction) & func, (wxObject *) NULL ),
 #define EVT_SET_CURSOR(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_SET_CURSOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxSetCursorEventFunction) & func, (wxObject *) NULL ),
+#define EVT_MOUSE_CAPTURE_CHANGED(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MOUSE_CAPTURE_CHANGED, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseCaptureChangedEventFunction) & func, (wxObject *) NULL ),
 
 // Mouse events
 #define EVT_LEFT_DOWN(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_LEFT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL ),
index 21baed1557a7a7a81408a78331cd8f74ffde6128..a65bdbc19188b3235bc26bbc34236f5c9634f190 100644 (file)
@@ -341,7 +341,7 @@ public:
     bool HandleQueryNewPalette();
     bool HandleSysColorChange();
     bool HandleDisplayChange();
-
+    bool HandleCaptureChanged(WXHWND gainedCapture);
 
     bool HandleQueryEndSession(long logOff, bool *mayEnd);
     bool HandleEndSession(bool endSession, long logOff);
index df2d8c44770c9246037ed7b86fc0bf7c93aea5b3..425df9d857ac5fb0e7d0121d6e9fcf26af593d76 100644 (file)
@@ -88,6 +88,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxEvent, wxObject)
     IMPLEMENT_DYNAMIC_CLASS(wxWindowDestroyEvent, wxEvent)
     IMPLEMENT_DYNAMIC_CLASS(wxHelpEvent, wxCommandEvent)
     IMPLEMENT_DYNAMIC_CLASS(wxContextMenuEvent, wxCommandEvent)
+    IMPLEMENT_DYNAMIC_CLASS(wxMouseCaptureChangedEvent, wxEvent)
 #endif // wxUSE_GUI
 
 const wxEventTable *wxEvtHandler::GetEventTable() const
index 8c1b4ab485d33dc22f1470ae00c76fd7c17b8a10..d625524ed37e72bf31b04cad9b2fd4c88c8958ee 100644 (file)
@@ -295,7 +295,13 @@ bool wxGenericDragImage::EndDrag()
 {
     if (m_window)
     {
-        m_window->ReleaseMouse();
+#ifdef __WXMSW__
+        // Under Windows we can be pretty sure this test will give
+        // the correct results
+        if (wxWindow::GetCapture() == m_window)
+#endif
+            m_window->ReleaseMouse();
+
         if (m_cursor.Ok() && m_oldCursor.Ok())
         {
             m_window->SetCursor(m_oldCursor);
index 5869ed162c16ca58fbc308cbd8c0dd5c90cbf2f8..8bb6886ec302be22f5c2413eba8f559a89faa45f 100644 (file)
@@ -2647,6 +2647,10 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
             processed = HandlePaletteChanged((WXHWND) (HWND) wParam);
             break;
 
+        case WM_CAPTURECHANGED:
+            processed = HandleCaptureChanged((WXHWND) (HWND) lParam);
+            break;
+
         case WM_QUERYNEWPALETTE:
             processed = HandleQueryNewPalette();
             break;
@@ -3511,6 +3515,14 @@ bool wxWindowMSW::HandlePaletteChanged(WXHWND hWndPalChange)
     return GetEventHandler()->ProcessEvent(event);
 }
 
+bool wxWindowMSW::HandleCaptureChanged(WXHWND hWndGainedCapture)
+{
+    wxMouseCaptureChangedEvent event(GetId(), wxFindWinFromHandle(hWndGainedCapture));
+    event.SetEventObject(this);
+
+    return GetEventHandler()->ProcessEvent(event);
+}
+
 bool wxWindowMSW::HandleQueryNewPalette()
 {