]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/mousemanager.cpp
fix building with WXWIN_COMPATIBILITY_2_8 == 0
[wxWidgets.git] / src / common / mousemanager.cpp
index c37395503880e7c0f8d86848c7ea31ee6052b9d9..b000c1b468cd89c26191faba220479b7e269907b 100644 (file)
@@ -3,7 +3,6 @@
 // Purpose:     implementation of wxMouseEventsManager class
 // Author:      Vadim Zeitlin
 // Created:     2009-04-21
-// RCS-ID:      $Id$
 // Copyright:   (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
 // Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
@@ -24,6 +23,8 @@
 #endif
 
 #ifndef WX_PRECOMP
+    #include "wx/settings.h"
+    #include "wx/window.h"
 #endif // WX_PRECOMP
 
 #include "wx/mousemanager.h"
@@ -43,18 +44,27 @@ END_EVENT_TABLE()
 // wxMouseEventsManager implementation
 // ============================================================================
 
-wxMouseEventsManager::wxMouseEventsManager(wxWindow *win)
-    : m_win(win)
+void wxMouseEventsManager::Init()
 {
+    m_win = NULL;
     m_state = State_Normal;
     m_item = wxNOT_FOUND;
+}
+
+bool wxMouseEventsManager::Create(wxWindow *win)
+{
+    wxASSERT_MSG( !m_win, "Create() must not be called twice" );
 
+    m_win = win;
     win->PushEventHandler(this);
+
+    return true;
 }
 
 wxMouseEventsManager::~wxMouseEventsManager()
 {
-    m_win->RemoveEventHandler(this);
+    if ( m_win )
+        m_win->RemoveEventHandler(this);
 }
 
 void wxMouseEventsManager::OnCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(event))
@@ -92,6 +102,7 @@ void wxMouseEventsManager::OnLeftDown(wxMouseEvent& event)
     }
 
     m_state = State_Pressed;
+    m_win->SetFocus();
     m_win->CaptureMouse();
     MouseClickBegin(m_item);
 }