1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _AVMEDIA_MEDIAWINDOW_HXX 25 #define _AVMEDIA_MEDIAWINDOW_HXX 26 27 #include <memory> 28 #include <vector> 29 #include <tools/gen.hxx> 30 #include <com/sun/star/media/ZoomLevel.hpp> 31 #include <com/sun/star/media/XPlayer.hpp> 32 #include <com/sun/star/graphic/XGraphic.hpp> 33 #include <com/sun/star/uno/XInterface.hpp> 34 35 // ----------- 36 // - Defines - 37 // ----------- 38 39 #define AVMEDIA_FRAMEGRABBER_DEFAULTFRAME -1.0 40 41 // ------------------------ 42 // - Forward Declarations - 43 // ------------------------ 44 45 class Window; 46 class KeyEvent; 47 class MouseEvent; 48 class CommandEvent; 49 class PopupMenu; 50 class Pointer; 51 struct AcceptDropEvent; 52 struct ExecuteDropEvent; 53 54 namespace rtl { class OUString; } 55 56 /* Declaration of MediaWindow class */ 57 58 namespace avmedia 59 { 60 typedef ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString > > FilterNameVector; 61 62 class MediaItem; 63 64 namespace priv { class MediaWindowImpl; } 65 66 // --------------- 67 // - MediaWindow - 68 // --------------- 69 70 class MediaWindow 71 { 72 public: 73 MediaWindow( Window* parent, bool bInternalMediaControl ); 74 virtual ~MediaWindow(); 75 76 void setURL( const ::rtl::OUString& rURL ); 77 const ::rtl::OUString& getURL() const; 78 79 bool isValid() const; 80 // 81 bool hasPreferredSize() const; 82 Size getPreferredSize() const; 83 84 Window* getWindow() const; 85 86 void setPosSize( const Rectangle& rNewRect ); 87 Rectangle getPosSize() const; 88 89 void setPointer( const Pointer& rPointer ); 90 const Pointer& getPointer() const; 91 92 bool setZoom( ::com::sun::star::media::ZoomLevel eLevel ); 93 ::com::sun::star::media::ZoomLevel getZoom() const; 94 95 bool start(); 96 void stop(); 97 98 bool isPlaying() const; 99 100 double getDuration() const; 101 102 void setMediaTime( double fTime ); 103 double getMediaTime() const; 104 105 void setStopTime( double fTime ); 106 double getStopTime() const; 107 108 void setRate( double fRate ); 109 double getRate() const; 110 111 void setPlaybackLoop( bool bSet ); 112 bool isPlaybackLoop() const; 113 114 void setMute( bool bSet ); 115 bool isMute() const; 116 117 void updateMediaItem( MediaItem& rItem ) const; 118 void executeMediaItem( const MediaItem& rItem ); 119 120 void show(); 121 void hide(); 122 123 void enable(); 124 void disable(); 125 126 public: 127 128 virtual void MouseMove( const MouseEvent& rMEvt ); 129 virtual void MouseButtonDown( const MouseEvent& rMEvt ); 130 virtual void MouseButtonUp( const MouseEvent& rMEvt ); 131 132 virtual void KeyInput( const KeyEvent& rKEvt ); 133 virtual void KeyUp( const KeyEvent& rKEvt ); 134 135 virtual void Command( const CommandEvent& rCEvt ); 136 137 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ); 138 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ); 139 140 virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ); 141 142 public: 143 144 static void getMediaFilters( FilterNameVector& rFilterNameVector ); 145 static bool executeMediaURLDialog( Window* pParent, ::rtl::OUString& rURL, bool bInsertDialog = true ); 146 static void executeFormatErrorBox( Window* pParent ); 147 static bool isMediaURL( const ::rtl::OUString& rURL, bool bDeep = false, Size* pPreferredSizePixel = NULL ); 148 149 static ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > createPlayer( const ::rtl::OUString& rURL ); 150 151 static ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > grabFrame( const ::rtl::OUString& rURL, 152 bool bAllowToCreateReplacementGraphic = false, 153 double fMediaTime = AVMEDIA_FRAMEGRABBER_DEFAULTFRAME ); 154 155 private: 156 157 // default: disabled copy/assignment 158 MediaWindow(const MediaWindow&); 159 MediaWindow& operator =( const MediaWindow& ); 160 161 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxIFace; 162 priv::MediaWindowImpl* mpImpl; 163 }; 164 } 165 166 #endif // _AVMEDIA_MEDIAWINDOW_HXX 167