typedef BOOL (WINAPI* LPAMGETERRORTEXT)(HRESULT, wxChar *, DWORD);
-//cludgy workaround for wx events. slots would be nice :)
-class WXDLLIMPEXP_MEDIA wxAMMediaEvtHandler : public wxEvtHandler
-{
-public:
- void OnEraseBackground(wxEraseEvent&);
-};
-
class WXDLLIMPEXP_MEDIA wxAMMediaBackend : public wxMediaBackend
{
public:
return true;
}
-//cludgy workaround for wx events. slots would be nice :)
-class WXDLLIMPEXP_MEDIA wxQTMediaEvtHandler : public wxEvtHandler
-{
-public:
- void OnEraseBackground(wxEraseEvent&);
-};
-
class WXDLLIMPEXP_MEDIA wxQTMediaBackend : public wxMediaBackend
{
public:
DECLARE_DYNAMIC_CLASS(wxQTMediaBackend)
};
+// helper to hijack background erasing for the QT window
+class WXDLLIMPEXP_MEDIA wxQTMediaEvtHandler : public wxEvtHandler
+{
+public:
+ wxQTMediaEvtHandler(wxQTMediaBackend *qtb) { m_qtb = qtb; }
+
+ void OnEraseBackground(wxEraseEvent& event);
+
+private:
+ wxQTMediaBackend *m_qtb;
+
+ DECLARE_NO_COPY_CLASS(wxQTMediaEvtHandler)
+};
+
//===========================================================================
// IMPLEMENTATION
//by default with AM only 0.5
wxAMMediaBackend::SetVolume(1.0);
- // My problem with this was only with a previous patch, probably the
- // third rewrite fixed it as a side-effect. In fact, the erase
- // background style of drawing not only works now, but is much better
- // than paint-based updates (the paint event handler flickers if the
- // wxMediaCtrl shares a sizer with another child window, or is on a
- // notebook)
- // - Greg Hazel
- m_ctrl->Connect(m_ctrl->GetId(), wxEVT_ERASE_BACKGROUND,
- wxEraseEventHandler(wxAMMediaEvtHandler::OnEraseBackground),
- NULL, (wxEvtHandler*) this);
+ // don't erase the background of our control window so that resizing is a
+ // bit smoother
+ m_ctrl->SetBackgroundStyle(wxBG_STYLE_CUSTOM);
// success
return true;
{
}
-//---------------------------------------------------------------------------
-// wxAMMediaEvtHandler::OnEraseBackground
-//
-// Tell WX not to erase the background of our control window
-// so that resizing is a bit smoother
-//---------------------------------------------------------------------------
-void wxAMMediaEvtHandler::OnEraseBackground(wxEraseEvent& WXUNUSED(evt))
-{
-}
-
//---------------------------------------------------------------------------
// End of wxAMMediaBackend
//---------------------------------------------------------------------------
// m_pMC = NULL;
}
+ // destroy wxQTMediaEvtHandler we pushed on it
+ m_ctrl->PopEventHandler(true);
+
m_lib.DestroyPortAssociation(
(CGrafPtr)m_lib.GetNativeWindowPort(m_ctrl->GetHWND()));
//Part of a suggestion from Greg Hazel to repaint
//movie when idle
- m_ctrl->Connect(m_ctrl->GetId(), wxEVT_ERASE_BACKGROUND,
- wxEraseEventHandler(wxQTMediaEvtHandler::OnEraseBackground),
- NULL, (wxEvtHandler*) this);
+ m_ctrl->PushEventHandler(new wxQTMediaEvtHandler(this));
// done
return true;
//---------------------------------------------------------------------------
void wxQTMediaEvtHandler::OnEraseBackground(wxEraseEvent& evt)
{
- wxQTMediaBackend* qtb = (wxQTMediaBackend*)this;
- wxQuickTimeLibrary* m_pLib = &(qtb->m_lib);
+ wxQuickTimeLibrary& m_pLib = m_qtb->m_lib;
- if(qtb->m_pMC)
+ if ( m_qtb->m_pMC )
{
//repaint movie controller
- m_pLib->MCDoAction(qtb->m_pMC, 2 /*mcActionDraw*/,
- m_pLib->GetNativeWindowPort(qtb->m_ctrl->GetHWND())
+ m_pLib.MCDoAction(m_qtb->m_pMC, 2 /*mcActionDraw*/,
+ m_pLib.GetNativeWindowPort(m_qtb->m_ctrl->GetHWND())
);
}
- else if(qtb->m_movie)
+ else if(m_qtb->m_movie)
{
- CGrafPtr port = (CGrafPtr)m_pLib->GetNativeWindowPort
- (qtb->m_ctrl->GetHWND());
+ CGrafPtr port = (CGrafPtr)m_pLib.GetNativeWindowPort
+ (m_qtb->m_ctrl->GetHWND());
- m_pLib->BeginUpdate(port);
- m_pLib->UpdateMovie(qtb->m_movie);
- wxASSERT(m_pLib->GetMoviesError() == noErr);
- m_pLib->EndUpdate(port);
+ m_pLib.BeginUpdate(port);
+ m_pLib.UpdateMovie(m_qtb->m_movie);
+ wxASSERT(m_pLib.GetMoviesError() == noErr);
+ m_pLib.EndUpdate(port);
}
+ // VZ: this doesn't make sense: why should we erase the background after
+ // taking the trouble to do whatever we did above? (FIXME)
evt.Skip(); //repaint with window background (TODO: maybe !m_movie?)
}