]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/mediactrl_am.cpp
Applied patch [ 1701723 ] wxAUI: Added event for doubleclicks on the tabbar bg
[wxWidgets.git] / src / msw / mediactrl_am.cpp
index cee182bf065f6c915ae00389359e476e795b9e95..eb139307d57a983206ab9c8730212a355964c4c4 100644 (file)
@@ -56,7 +56,7 @@
 #pragma warning (disable:4310)
 #endif
 
 #pragma warning (disable:4310)
 #endif
 
-#if wxUSE_MEDIACTRL
+#if wxUSE_MEDIACTRL && wxUSE_ACTIVEX
 
 #include "wx/mediactrl.h"
 
 
 #include "wx/mediactrl.h"
 
     #include "wx/dcclient.h"
     #include "wx/timer.h"
     #include "wx/math.h"        // log10 & pow
     #include "wx/dcclient.h"
     #include "wx/timer.h"
     #include "wx/math.h"        // log10 & pow
+    #include "wx/stopwatch.h"
 #endif
 
 #include "wx/msw/private.h" // user info and wndproc setting/getting
 #include "wx/dynlib.h"
 #endif
 
 #include "wx/msw/private.h" // user info and wndproc setting/getting
 #include "wx/dynlib.h"
-#include "wx/stopwatch.h"
 
 //---------------------------------------------------------------------------
 //  wxActiveXContainer - includes all the COM-specific stuff we need
 
 //---------------------------------------------------------------------------
 //  wxActiveXContainer - includes all the COM-specific stuff we need
@@ -1483,6 +1483,7 @@ public:
     LPAMGETERRORTEXT m_lpAMGetErrorText;
     wxString GetErrorString(HRESULT hrdsv);
 #endif // __WXDEBUG__
     LPAMGETERRORTEXT m_lpAMGetErrorText;
     wxString GetErrorString(HRESULT hrdsv);
 #endif // __WXDEBUG__
+    wxEvtHandler* m_evthandler;
 
     friend class wxAMMediaEvtHandler;
     DECLARE_DYNAMIC_CLASS(wxAMMediaBackend)
 
     friend class wxAMMediaEvtHandler;
     DECLARE_DYNAMIC_CLASS(wxAMMediaBackend)
@@ -1566,12 +1567,14 @@ wxString wxAMMediaBackend::GetErrorString(HRESULT hrdsv)
 wxAMMediaBackend::wxAMMediaBackend()
                  :m_pAX(NULL),
 #ifdef __WXWINCE__
 wxAMMediaBackend::wxAMMediaBackend()
                  :m_pAX(NULL),
 #ifdef __WXWINCE__
-                  m_pWMP(NULL)
+                  m_pWMP(NULL),
 #else
                   m_pAM(NULL),
 #else
                   m_pAM(NULL),
-                  m_pMP(NULL)
+                  m_pMP(NULL),
 #endif
 #endif
+                  m_bestSize(wxDefaultSize)
 {
 {
+   m_evthandler = NULL;
 }
 
 //---------------------------------------------------------------------------
 }
 
 //---------------------------------------------------------------------------
@@ -1590,7 +1593,11 @@ wxAMMediaBackend::~wxAMMediaBackend()
         if (GetMP())
             GetMP()->Release();
 
         if (GetMP())
             GetMP()->Release();
 
-        m_ctrl->PopEventHandler(true);
+        if (m_evthandler)
+        {
+            m_ctrl->RemoveEventHandler(m_evthandler);
+            delete m_evthandler;
+        }
     }
 }
 
     }
 }
 
@@ -1682,7 +1689,8 @@ bool wxAMMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
 #endif
                                   );
     // Connect for events
 #endif
                                   );
     // Connect for events
-    m_ctrl->PushEventHandler(new wxAMMediaEvtHandler(this));
+    m_evthandler = new wxAMMediaEvtHandler(this);
+    m_ctrl->PushEventHandler(m_evthandler);
 
     //
     //  Here we set up wx-specific stuff for the default
 
     //
     //  Here we set up wx-specific stuff for the default
@@ -1791,6 +1799,7 @@ bool wxAMMediaBackend::DoLoad(const wxString& location)
         return false;
     }
 
         return false;
     }
 
+    m_bestSize = wxDefaultSize;
     return true;
 }
 
     return true;
 }
 
@@ -1804,10 +1813,6 @@ bool wxAMMediaBackend::DoLoad(const wxString& location)
 //---------------------------------------------------------------------------
 void wxAMMediaBackend::FinishLoad()
 {
 //---------------------------------------------------------------------------
 void wxAMMediaBackend::FinishLoad()
 {
-    // Get the original video size
-    GetAM()->get_ImageSourceWidth((long*)&m_bestSize.x);
-    GetAM()->get_ImageSourceHeight((long*)&m_bestSize.y);
-
     NotifyMovieLoaded();
 }
 
     NotifyMovieLoaded();
 }
 
@@ -2142,7 +2147,22 @@ void wxAMMediaBackend::DoGetDownloadProgress(wxLongLong* pLoadProgress,
 //---------------------------------------------------------------------------
 wxSize wxAMMediaBackend::GetVideoSize() const
 {
 //---------------------------------------------------------------------------
 wxSize wxAMMediaBackend::GetVideoSize() const
 {
-    return m_bestSize;
+    if (m_bestSize == wxDefaultSize)
+    {
+        wxAMMediaBackend* self = wxConstCast(this, wxAMMediaBackend);
+        long w = 0;
+        long h = 0;
+
+        self->GetAM()->get_ImageSourceWidth(&w);
+        self->GetAM()->get_ImageSourceHeight(&h);
+
+        if (w != 0 && h != 0)
+            self->m_bestSize.Set(w, h);
+        else
+            return wxSize(0,0);
+    }
+
+   return m_bestSize;
 }
 
 //---------------------------------------------------------------------------
 }
 
 //---------------------------------------------------------------------------
@@ -2257,4 +2277,4 @@ void wxAMMediaEvtHandler::OnActiveX(wxActiveXEvent& event)
 #include "wx/html/forcelnk.h"
 FORCE_LINK_ME(wxmediabackend_am)
 
 #include "wx/html/forcelnk.h"
 FORCE_LINK_ME(wxmediabackend_am)
 
-#endif // wxUSE_MEDIACTRL
+#endif // wxUSE_MEDIACTRL && wxUSE_ACTIVEX