+//---------------------------------------------------------------------------
+// wxQTMediaBackend::DoSetControllerVisible
+//
+// Utility function that takes care of showing the moviecontroller
+// and showing/hiding the particular controls on it
+//---------------------------------------------------------------------------
+void wxQTMediaBackend::DoSetControllerVisible(wxMediaCtrlPlayerControls flags)
+{
+ ::MCSetVisible(m_mc, TRUE);
+
+ //
+ // Take care of subcontrols
+ //
+ if(::GetMoviesError() == noErr)
+ {
+ long mcFlags = 0;
+ ::MCDoAction(m_mc, 39/*mcActionGetFlags*/, (void*)&mcFlags);
+
+ if(::GetMoviesError() == noErr)
+ {
+ mcFlags |= ( //(1<<0)/*mcFlagSuppressMovieFrame*/ |
+ (1<<3)/*mcFlagsUseWindowPalette*/
+ | ((flags & wxMEDIACTRLPLAYERCONTROLS_STEP)
+ ? 0 : (1<<1)/*mcFlagSuppressStepButtons*/)
+ | ((flags & wxMEDIACTRLPLAYERCONTROLS_VOLUME)
+ ? 0 : (1<<2)/*mcFlagSuppressSpeakerButton*/)
+ // | (1<<4) /*mcFlagDontInvalidate*/ //if we take care of repainting ourselves
+ );
+ ::MCDoAction(m_mc, 38/*mcActionSetFlags*/, (void*)mcFlags);
+ }
+ }
+
+ //
+ //Adjust height and width of best size for movie controller
+ //if the user wants it shown
+ //
+ m_bestSize.x = m_bestSize.x > wxMCWIDTH ? m_bestSize.x : wxMCWIDTH;
+ m_bestSize.y += wxMCHEIGHT;
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::ShowPlayerControls
+//
+// Shows/Hides subcontrols on the media control
+//---------------------------------------------------------------------------
+bool wxQTMediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags)
+{
+ if(!m_mc)
+ return false; //no movie controller...
+
+ bool bSizeChanged = false;
+
+ //if the controller is visible and we want to hide it do so
+ if(m_interfaceflags && !flags)
+ {
+ bSizeChanged = true;
+ DoLoadBestSize();
+ ::MCSetVisible(m_mc, FALSE);
+ }
+ else if(!m_interfaceflags && flags) //show controller if hidden
+ {
+ bSizeChanged = true;
+ DoSetControllerVisible(flags);
+ }
+
+ //readjust parent sizers
+ if(bSizeChanged)
+ {
+ NotifyMovieSizeChanged();
+
+ //remember state in case of loading new media
+ m_interfaceflags = flags;
+ }
+
+ return ::GetMoviesError() == noErr;
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::OnEraseBackground
+//
+// Suggestion from Greg Hazel to repaint the movie when idle
+// (on pause also)
+//---------------------------------------------------------------------------
+#if !wxUSE_CREATEMOVIECONTROL
+void wxQTMediaEvtHandler::OnEraseBackground(wxEraseEvent& evt)
+{
+ // Work around Nasty OSX drawing bug -
+ // http://lists.apple.com/archives/QuickTime-API/2002/Feb/msg00311.html
+ WindowRef wrTLW =
+ (WindowRef) m_qtb->m_ctrl->MacGetTopLevelWindowRef();
+
+ RgnHandle region = MCGetControllerBoundsRgn(m_qtb->m_mc);
+ MCInvalidate(m_qtb->m_mc, wrTLW, region);
+ MCIdle(m_qtb->m_mc);
+}
+#endif
+
+//---------------------------------------------------------------------------
+// wxQTMediaWindowEventHandler
+//
+// Event callback for the top level window of our control that passes
+// messages to our moviecontroller so it can recieve mouse clicks etc.
+//---------------------------------------------------------------------------
+#if !wxUSE_CREATEMOVIECONTROL
+OSStatus wxQTMediaWindowEventHandler(EventHandlerCallRef inHandlerCallRef,
+ EventRef inEvent, void *inUserData)
+{
+ EventRecord theEvent;
+ ConvertEventRefToEventRecord( inEvent, &theEvent );
+ OSStatus err;
+ err = ::MCIsPlayerEvent( (MovieController) inUserData, &theEvent );
+
+ // pass on to other event handlers if not handled- i.e. wx
+ if(err)
+ return noErr;
+ else
+ return eventNotHandledErr;
+}
+#endif