xref: /trunk/main/avmedia/inc/avmedia/mediawindow.hxx (revision deb7b1c2)
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 #include <avmedia/avmediadllapi.h>
35 
36 // -----------
37 // - Defines -
38 // -----------
39 
40 #define AVMEDIA_FRAMEGRABBER_DEFAULTFRAME -1.0
41 
42 // ------------------------
43 // - Forward Declarations -
44 // ------------------------
45 
46 class Window;
47 class KeyEvent;
48 class MouseEvent;
49 class CommandEvent;
50 class PopupMenu;
51 class Pointer;
52 struct AcceptDropEvent;
53 struct ExecuteDropEvent;
54 
55 namespace rtl { class OUString; }
56 
57 /* Declaration of MediaWindow class */
58 
59 namespace avmedia
60 {
61     typedef ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString > > FilterNameVector;
62 
63     class MediaItem;
64 
65     namespace priv { class MediaWindowImpl; }
66 
67     // ---------------
68     // - MediaWindow -
69     // ---------------
70 
71     class AVMEDIA_DLLPUBLIC MediaWindow
72     {
73     public:
74                             MediaWindow( Window* parent, bool bInternalMediaControl );
75 		virtual				~MediaWindow();
76 
77         void                setURL( const ::rtl::OUString& rURL );
78         const ::rtl::OUString&  getURL() const;
79 
80         bool                isValid() const;
81 //
82         bool                hasPreferredSize() const;
83         Size                getPreferredSize() const;
84 
85         Window*             getWindow() const;
86 
87         void                setPosSize( const Rectangle& rNewRect );
88         Rectangle           getPosSize() const;
89 
90         void                setPointer( const Pointer& rPointer );
91         const Pointer&      getPointer() const;
92 
93         bool                setZoom( ::com::sun::star::media::ZoomLevel eLevel );
94         ::com::sun::star::media::ZoomLevel  getZoom() const;
95 
96         bool                start();
97         void                stop();
98 
99         bool                isPlaying() const;
100 
101         double              getDuration() const;
102 
103         void                setMediaTime( double fTime );
104         double              getMediaTime() const;
105 
106         void                setStopTime( double fTime );
107         double              getStopTime() const;
108 
109         void                setRate( double fRate );
110         double              getRate() const;
111 
112         void                setPlaybackLoop( bool bSet );
113         bool                isPlaybackLoop() const;
114 
115         void                setMute( bool bSet );
116         bool                isMute() const;
117 
118         void                updateMediaItem( MediaItem& rItem ) const;
119         void                executeMediaItem( const MediaItem& rItem );
120 
121         void                show();
122         void                hide();
123 
124         void                enable();
125         void                disable();
126 
127     public:
128 
129         virtual void        MouseMove( const MouseEvent& rMEvt );
130         virtual void        MouseButtonDown( const MouseEvent& rMEvt );
131         virtual void        MouseButtonUp( const MouseEvent& rMEvt );
132 
133         virtual void        KeyInput( const KeyEvent& rKEvt );
134         virtual void        KeyUp( const KeyEvent& rKEvt );
135 
136         virtual void        Command( const CommandEvent& rCEvt );
137 
138         virtual sal_Int8    AcceptDrop( const AcceptDropEvent& rEvt );
139         virtual sal_Int8    ExecuteDrop( const ExecuteDropEvent& rEvt );
140 
141         virtual void        StartDrag( sal_Int8 nAction, const Point& rPosPixel );
142 
143     public:
144 
145         static void         getMediaFilters( FilterNameVector& rFilterNameVector );
146         static bool         executeMediaURLDialog( Window* pParent, ::rtl::OUString& rURL, bool bInsertDialog = true );
147         static void         executeFormatErrorBox( Window* pParent );
148         static bool         isMediaURL( const ::rtl::OUString& rURL, bool bDeep = false, Size* pPreferredSizePixel = NULL );
149 
150         static ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > createPlayer( const ::rtl::OUString& rURL );
151 
152         static ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > grabFrame( const ::rtl::OUString& rURL,
153                                                                                                   bool bAllowToCreateReplacementGraphic = false,
154                                                                                                   double fMediaTime = AVMEDIA_FRAMEGRABBER_DEFAULTFRAME );
155 
156     private:
157 
158                     // default: disabled copy/assignment
159         MediaWindow(const MediaWindow&);
160         MediaWindow& operator =( const MediaWindow& );
161 
162         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >   mxIFace;
163         priv::MediaWindowImpl*                                                  mpImpl;
164     };
165 }
166 
167 #endif // _AVMEDIA_MEDIAWINDOW_HXX
168