1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "mediacontrol.hxx"
21 #include "mediacontrol.hrc"
22 #include "mediamisc.hxx"
23 #include <avmedia/mediawindow.hxx>
24 #include <avmedia/mediaplayer.hxx>
25 #include "helpids.hrc"
26 #include <tools/time.hxx>
27 #include <svtools/miscopt.hxx>
28 #include <vcl/svapp.hxx>
29 #include <vcl/lstbox.hxx>
30 #include <unotools/syslocale.hxx>
31 #include <sfx2/viewfrm.hxx>
35 #define AVMEDIA_TIMEOUT 100
36 #define AVMEDIA_TIME_RANGE 2048
37 #define AVMEDIA_DB_RANGE -40
38 #define AVMEDIA_LINEINCREMENT 1.0
39 #define AVMEDIA_PAGEINCREMENT 10.0
41 #define AVMEDIA_TOOLBOXITEM_PLAY 0x0001
42 #define AVMEDIA_TOOLBOXITEM_PLAYFFW 0x0002
43 #define AVMEDIA_TOOLBOXITEM_PAUSE 0x0004
44 #define AVMEDIA_TOOLBOXITEM_STOP 0x0008
45 #define AVMEDIA_TOOLBOXITEM_MUTE 0x0010
46 #define AVMEDIA_TOOLBOXITEM_LOOP 0x0011
47 #define AVMEDIA_TOOLBOXITEM_ZOOM 0x0012
48 #define AVMEDIA_TOOLBOXITEM_OPEN 0x0014
49 #define AVMEDIA_TOOLBOXITEM_INSERT 0x0018
51 #define AVMEDIA_ZOOMLEVEL_50 0
52 #define AVMEDIA_ZOOMLEVEL_100 1
53 #define AVMEDIA_ZOOMLEVEL_200 2
54 #define AVMEDIA_ZOOMLEVEL_FIT 3
55 #define AVMEDIA_ZOOMLEVEL_SCALED 4
56 #define AVMEDIA_ZOOMLEVEL_INVALID 65535
65 MediaControl::MediaControl( Window
* pParent
, MediaControlStyle eControlStyle
) :
67 maImageList( SvtMiscOptions().AreCurrentSymbolsLarge() ? AVMEDIA_RESID( AVMEDIA_IMGLST_L
) : AVMEDIA_RESID( AVMEDIA_IMGLST
) ),
68 maItem( 0, AVMEDIA_SETMASK_ALL
),
69 maPlayToolBox( this, WB_3DLOOK
),
70 maTimeSlider( this, WB_HORZ
| WB_DRAG
| WB_3DLOOK
| WB_SLIDERSET
),
71 maMuteToolBox( this, WB_3DLOOK
),
72 maVolumeSlider( this, WB_HORZ
| WB_DRAG
| WB_SLIDERSET
),
73 maZoomToolBox( this, WB_3DLOOK
),
74 mpZoomListBox( new ListBox( &maZoomToolBox
, WB_BORDER
| WB_DROPDOWN
| WB_AUTOHSCROLL
| WB_3DLOOK
) ),
75 maTimeEdit( this, WB_CENTER
| WB_READONLY
| WB_BORDER
| WB_3DLOOK
| WB_READONLY
),
76 meControlStyle( eControlStyle
),
79 const OUString
aTimeText( " 00:00:00/00:00:00 " );
82 SetPaintTransparent( sal_True
);
83 SetParentClipMode( PARENTCLIPMODE_NOCLIP
);
85 if( MEDIACONTROLSTYLE_SINGLELINE
!= meControlStyle
)
87 maPlayToolBox
.InsertItem( AVMEDIA_TOOLBOXITEM_OPEN
, implGetImage( AVMEDIA_IMG_OPEN
), OUString( AVMEDIA_RESID( AVMEDIA_STR_OPEN
) ) );
88 maPlayToolBox
.SetHelpId( AVMEDIA_TOOLBOXITEM_OPEN
, HID_AVMEDIA_TOOLBOXITEM_OPEN
);
90 maPlayToolBox
.InsertItem( AVMEDIA_TOOLBOXITEM_INSERT
, implGetImage( AVMEDIA_IMG_INSERT
), OUString( AVMEDIA_RESID( AVMEDIA_STR_INSERT
) ) );
91 maPlayToolBox
.SetHelpId( AVMEDIA_TOOLBOXITEM_INSERT
, HID_AVMEDIA_TOOLBOXITEM_INSERT
);
93 maPlayToolBox
.InsertSeparator();
97 mpZoomListBox
->SetBackground();
99 maZoomToolBox
.SetBackground();
100 maZoomToolBox
.SetPaintTransparent( sal_True
);
101 maPlayToolBox
.SetBackground();
102 maPlayToolBox
.SetPaintTransparent( sal_True
);
103 maMuteToolBox
.SetBackground();
104 maMuteToolBox
.SetPaintTransparent( sal_True
);
108 maPlayToolBox
.InsertItem( AVMEDIA_TOOLBOXITEM_PLAY
, implGetImage( AVMEDIA_IMG_PLAY
), OUString( AVMEDIA_RESID( AVMEDIA_STR_PLAY
) ), TIB_CHECKABLE
);
109 maPlayToolBox
.SetHelpId( AVMEDIA_TOOLBOXITEM_PLAY
, HID_AVMEDIA_TOOLBOXITEM_PLAY
);
111 maPlayToolBox
.InsertItem( AVMEDIA_TOOLBOXITEM_PAUSE
, implGetImage( AVMEDIA_IMG_PAUSE
), OUString( AVMEDIA_RESID( AVMEDIA_STR_PAUSE
) ), TIB_CHECKABLE
);
112 maPlayToolBox
.SetHelpId( AVMEDIA_TOOLBOXITEM_PAUSE
, HID_AVMEDIA_TOOLBOXITEM_PAUSE
);
114 maPlayToolBox
.InsertItem( AVMEDIA_TOOLBOXITEM_STOP
, implGetImage( AVMEDIA_IMG_STOP
), OUString( AVMEDIA_RESID( AVMEDIA_STR_STOP
) ), TIB_CHECKABLE
);
115 maPlayToolBox
.SetHelpId( AVMEDIA_TOOLBOXITEM_STOP
, HID_AVMEDIA_TOOLBOXITEM_STOP
);
117 maPlayToolBox
.InsertSeparator();
119 maPlayToolBox
.InsertItem( AVMEDIA_TOOLBOXITEM_LOOP
, implGetImage( AVMEDIA_IMG_ENDLESS
), OUString( AVMEDIA_RESID( AVMEDIA_STR_ENDLESS
) ) );
120 maPlayToolBox
.SetHelpId( AVMEDIA_TOOLBOXITEM_LOOP
, HID_AVMEDIA_TOOLBOXITEM_LOOP
);
122 if( MEDIACONTROLSTYLE_SINGLELINE
== meControlStyle
)
123 maPlayToolBox
.InsertSeparator();
125 maPlayToolBox
.SetSelectHdl( LINK( this, MediaControl
, implSelectHdl
) );
126 maPlayToolBox
.SetSizePixel( maPlayToolBox
.CalcWindowSizePixel() );
127 maPlayToolBox
.Show();
128 maMinSize
= maPlayToolBox
.GetSizePixel();
130 maTimeSlider
.SetSlideHdl( LINK( this, MediaControl
, implTimeHdl
) );
131 maTimeSlider
.SetEndSlideHdl( LINK( this, MediaControl
, implTimeEndHdl
) );
132 maTimeSlider
.SetRange( Range( 0, AVMEDIA_TIME_RANGE
) );
133 maTimeSlider
.SetHelpId( HID_AVMEDIA_TIMESLIDER
);
134 maTimeSlider
.SetUpdateMode( true );
135 maTimeSlider
.SetSizePixel( Size( 128, maPlayToolBox
.GetSizePixel().Height() ) );
137 maMinSize
.Width() += maTimeSlider
.GetSizePixel().Width();
139 maTimeEdit
.SetText( aTimeText
);
140 maTimeEdit
.SetUpdateMode( true );
141 maTimeEdit
.SetSizePixel( Size( maTimeEdit
.GetTextWidth( aTimeText
) + 8, maPlayToolBox
.GetSizePixel().Height() ) );
142 maTimeEdit
.SetControlBackground( Application::GetSettings().GetStyleSettings().GetWindowColor() );
143 maTimeEdit
.SetHelpId( HID_AVMEDIA_TIMEEDIT
);
144 maTimeEdit
.Disable();
146 maMinSize
.Width() += maTimeEdit
.GetSizePixel().Width();
148 if( MEDIACONTROLSTYLE_SINGLELINE
== meControlStyle
)
149 maMuteToolBox
.InsertSeparator();
151 maMuteToolBox
.InsertItem( AVMEDIA_TOOLBOXITEM_MUTE
, implGetImage( AVMEDIA_IMG_MUTE
), OUString( AVMEDIA_RESID( AVMEDIA_STR_MUTE
) ) );
152 maMuteToolBox
.SetHelpId( AVMEDIA_TOOLBOXITEM_MUTE
, HID_AVMEDIA_TOOLBOXITEM_MUTE
);
154 maMuteToolBox
.SetSelectHdl( LINK( this, MediaControl
, implSelectHdl
) );
155 maMuteToolBox
.SetSizePixel( maMuteToolBox
.CalcWindowSizePixel() );
156 maMuteToolBox
.Show();
157 maMinSize
.Width() += maMuteToolBox
.GetSizePixel().Width();
159 maVolumeSlider
.SetSlideHdl( LINK( this, MediaControl
, implVolumeHdl
) );
160 maVolumeSlider
.SetEndSlideHdl( LINK( this, MediaControl
, implVolumeEndHdl
) );
161 maVolumeSlider
.SetRange( Range( AVMEDIA_DB_RANGE
, 0 ) );
162 maVolumeSlider
.SetUpdateMode( true );
163 maVolumeSlider
.SetHelpId( HID_AVMEDIA_VOLUMESLIDER
);
164 maVolumeSlider
.SetSizePixel( Size( 48, maPlayToolBox
.GetSizePixel().Height() ) );
165 maVolumeSlider
.Show();
166 maMinSize
.Width() += maVolumeSlider
.GetSizePixel().Width();
168 mpZoomListBox
->SetSizePixel( Size( maTimeEdit
.GetSizePixel().Width(), 260 ) );
169 mpZoomListBox
->InsertEntry( OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_50
) ), AVMEDIA_ZOOMLEVEL_50
);
170 mpZoomListBox
->InsertEntry( OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_100
) ), AVMEDIA_ZOOMLEVEL_100
);
171 mpZoomListBox
->InsertEntry( OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_200
) ), AVMEDIA_ZOOMLEVEL_200
);
172 mpZoomListBox
->InsertEntry( OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_FIT
) ), AVMEDIA_ZOOMLEVEL_FIT
);
173 mpZoomListBox
->SetSelectHdl( LINK( this, MediaControl
, implZoomSelectHdl
) );
174 mpZoomListBox
->SetHelpId( HID_AVMEDIA_ZOOMLISTBOX
);
176 maZoomToolBox
.InsertItem( AVMEDIA_TOOLBOXITEM_ZOOM
, OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM
) ) );
177 maZoomToolBox
.SetHelpId( AVMEDIA_TOOLBOXITEM_ZOOM
, HID_AVMEDIA_ZOOMLISTBOX
);
179 maZoomToolBox
.SetItemWindow( AVMEDIA_TOOLBOXITEM_ZOOM
, mpZoomListBox
);
180 maZoomToolBox
.SetSelectHdl( LINK( this, MediaControl
, implSelectHdl
) );
181 maZoomToolBox
.SetSizePixel( maZoomToolBox
.CalcWindowSizePixel() );
182 maZoomToolBox
.Show();
183 maMinSize
.Width() += maZoomToolBox
.GetSizePixel().Width();
185 if( MEDIACONTROLSTYLE_MULTILINE
== meControlStyle
)
187 maMinSize
.Width() = 256;
188 maMinSize
.Height() = ( maMinSize
.Height() << 1 ) + AVMEDIA_CONTROLOFFSET
;
191 maTimer
.SetTimeout( AVMEDIA_TIMEOUT
);
192 maTimer
.SetTimeoutHdl( LINK( this, MediaControl
, implTimeoutHdl
) );
196 // ------------------------------------------------------------------------------
198 MediaControl::~MediaControl()
200 maZoomToolBox
.SetItemWindow( AVMEDIA_TOOLBOXITEM_ZOOM
, NULL
);
201 delete mpZoomListBox
;
204 // ------------------------------------------------------------------------------
206 const Size
& MediaControl::getMinSizePixel() const
211 // ------------------------------------------------------------------------------
213 void MediaControl::Resize()
216 const sal_Int32 nPlayToolBoxWidth
= maPlayToolBox
.GetSizePixel().Width();
217 const sal_Int32 nMuteToolBoxWidth
= maMuteToolBox
.GetSizePixel().Width();
218 const sal_Int32 nVolumeSliderWidth
= maVolumeSlider
.GetSizePixel().Width();
219 const sal_Int32 nZoomToolBoxWidth
= maZoomToolBox
.GetSizePixel().Width();
220 const sal_Int32 nTimeEditWidth
= maTimeEdit
.GetSizePixel().Width();
221 const sal_Int32 nTimeSliderHeight
= maTimeSlider
.GetSizePixel().Height();
223 if( MEDIACONTROLSTYLE_SINGLELINE
== meControlStyle
)
225 const sal_Int32 nTimeSliderWidth
= GetSizePixel().Width() - ( AVMEDIA_CONTROLOFFSET
* 3 ) -
226 nPlayToolBoxWidth
- nMuteToolBoxWidth
- nVolumeSliderWidth
- nTimeEditWidth
- nZoomToolBoxWidth
;
228 maPlayToolBox
.SetPosSizePixel( aPos
, maPlayToolBox
.GetSizePixel() );
230 aPos
.X() += nPlayToolBoxWidth
;
231 maTimeSlider
.SetPosSizePixel( aPos
, Size( nTimeSliderWidth
, nTimeSliderHeight
) );
233 aPos
.X() += nTimeSliderWidth
+ AVMEDIA_CONTROLOFFSET
;
234 maTimeEdit
.SetPosSizePixel( aPos
, maTimeEdit
.GetSizePixel() );
236 aPos
.X() += nTimeEditWidth
+ AVMEDIA_CONTROLOFFSET
;
237 maMuteToolBox
.SetPosSizePixel( aPos
, maMuteToolBox
.GetSizePixel() );
239 aPos
.X() += nMuteToolBoxWidth
;
240 maVolumeSlider
.SetPosSizePixel( aPos
, maVolumeSlider
.GetSizePixel() );
242 aPos
.X() += nVolumeSliderWidth
+ AVMEDIA_CONTROLOFFSET
;
243 maZoomToolBox
.SetPosSizePixel( aPos
, maZoomToolBox
.GetSizePixel() );
247 const sal_Int32 nTimeSliderWidth
= GetSizePixel().Width() - AVMEDIA_CONTROLOFFSET
- nTimeEditWidth
;
249 maTimeSlider
.SetPosSizePixel( aPos
, Size( nTimeSliderWidth
, nTimeSliderHeight
) );
251 aPos
.X() += nTimeSliderWidth
+ AVMEDIA_CONTROLOFFSET
;
252 maTimeEdit
.SetPosSizePixel( aPos
, maTimeEdit
.GetSizePixel() );
255 aPos
.Y() += nTimeSliderHeight
+ AVMEDIA_CONTROLOFFSET
;
256 maPlayToolBox
.SetPosSizePixel( aPos
, maPlayToolBox
.GetSizePixel() );
258 aPos
.X() = GetSizePixel().Width() - nVolumeSliderWidth
- nMuteToolBoxWidth
- nZoomToolBoxWidth
- AVMEDIA_CONTROLOFFSET
;
259 maMuteToolBox
.SetPosSizePixel( aPos
, maMuteToolBox
.GetSizePixel() );
261 aPos
.X() += nMuteToolBoxWidth
;
262 maVolumeSlider
.SetPosSizePixel( aPos
, maVolumeSlider
.GetSizePixel() );
264 aPos
.X() = GetSizePixel().Width() - nZoomToolBoxWidth
;
265 maZoomToolBox
.SetPosSizePixel( aPos
, maZoomToolBox
.GetSizePixel() );
269 // ------------------------------------------------------------------------------
271 void MediaControl::setState( const MediaItem
& rItem
)
275 maItem
.merge( rItem
);
277 implUpdateToolboxes();
278 implUpdateTimeSlider();
279 implUpdateVolumeSlider();
280 implUpdateTimeField( maItem
.getTime() );
284 // ------------------------------------------------------------------------------
286 void MediaControl::implUpdateToolboxes()
288 const bool bValidURL
= ( !maItem
.getURL().isEmpty());
290 maPlayToolBox
.EnableItem( AVMEDIA_TOOLBOXITEM_INSERT
, bValidURL
);
291 maPlayToolBox
.EnableItem( AVMEDIA_TOOLBOXITEM_PLAY
, bValidURL
);
292 maPlayToolBox
.EnableItem( AVMEDIA_TOOLBOXITEM_PLAYFFW
, bValidURL
);
293 maPlayToolBox
.EnableItem( AVMEDIA_TOOLBOXITEM_PAUSE
, bValidURL
);
294 maPlayToolBox
.EnableItem( AVMEDIA_TOOLBOXITEM_STOP
, bValidURL
);
295 maPlayToolBox
.EnableItem( AVMEDIA_TOOLBOXITEM_LOOP
, bValidURL
);
296 maMuteToolBox
.EnableItem( AVMEDIA_TOOLBOXITEM_MUTE
, bValidURL
);
298 if( !bValidURL
|| !IsEnabled() )
300 mpZoomListBox
->Disable();
302 if( MEDIACONTROLSTYLE_SINGLELINE
== meControlStyle
)
303 maPlayToolBox
.Disable();
305 maMuteToolBox
.Disable();
309 maPlayToolBox
.Enable();
310 maMuteToolBox
.Enable();
312 if( MEDIASTATE_PLAY
== maItem
.getState() || MEDIASTATE_PLAYFFW
== maItem
.getState() )
314 maPlayToolBox
.CheckItem( AVMEDIA_TOOLBOXITEM_PLAY
, true );
315 maPlayToolBox
.CheckItem( AVMEDIA_TOOLBOXITEM_PLAYFFW
, MEDIASTATE_PLAYFFW
== maItem
.getState() );
316 maPlayToolBox
.CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE
, false );
317 maPlayToolBox
.CheckItem( AVMEDIA_TOOLBOXITEM_STOP
, false );
319 else if( maItem
.getTime() > 0.0 && ( maItem
.getTime() < maItem
.getDuration() ) )
321 maPlayToolBox
.CheckItem( AVMEDIA_TOOLBOXITEM_PLAY
, false );
322 maPlayToolBox
.CheckItem( AVMEDIA_TOOLBOXITEM_PLAYFFW
, false );
323 maPlayToolBox
.CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE
, true );
324 maPlayToolBox
.CheckItem( AVMEDIA_TOOLBOXITEM_STOP
, false );
328 maPlayToolBox
.CheckItem( AVMEDIA_TOOLBOXITEM_PLAY
, false );
329 maPlayToolBox
.CheckItem( AVMEDIA_TOOLBOXITEM_PLAYFFW
, false );
330 maPlayToolBox
.CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE
, false );
331 maPlayToolBox
.CheckItem( AVMEDIA_TOOLBOXITEM_STOP
, true );
334 maPlayToolBox
.CheckItem( AVMEDIA_TOOLBOXITEM_LOOP
, maItem
.isLoop() );
335 maMuteToolBox
.CheckItem( AVMEDIA_TOOLBOXITEM_MUTE
, maItem
.isMute() );
337 if( !mpZoomListBox
->IsTravelSelect() && !mpZoomListBox
->IsInDropDown() )
339 sal_uInt16 nSelectEntryPos
;
341 switch( maItem
.getZoom() )
343 case( ::com::sun::star::media::ZoomLevel_ZOOM_1_TO_2
): nSelectEntryPos
= AVMEDIA_ZOOMLEVEL_50
; break;
344 case( ::com::sun::star::media::ZoomLevel_ORIGINAL
): nSelectEntryPos
= AVMEDIA_ZOOMLEVEL_100
; break;
345 case( ::com::sun::star::media::ZoomLevel_ZOOM_2_TO_1
): nSelectEntryPos
= AVMEDIA_ZOOMLEVEL_200
; break;
346 case( ::com::sun::star::media::ZoomLevel_FIT_TO_WINDOW_FIXED_ASPECT
): nSelectEntryPos
= AVMEDIA_ZOOMLEVEL_FIT
; break;
347 case( ::com::sun::star::media::ZoomLevel_FIT_TO_WINDOW
): nSelectEntryPos
= AVMEDIA_ZOOMLEVEL_SCALED
; break;
349 default: nSelectEntryPos
= AVMEDIA_ZOOMLEVEL_INVALID
; break;
352 if( nSelectEntryPos
!= AVMEDIA_ZOOMLEVEL_INVALID
)
354 mpZoomListBox
->Enable();
355 mpZoomListBox
->SelectEntryPos( nSelectEntryPos
);
358 mpZoomListBox
->Disable();
363 // ------------------------------------------------------------------------------
365 void MediaControl::implUpdateTimeSlider()
367 if( maItem
.getURL().isEmpty() || !IsEnabled() )
368 maTimeSlider
.Disable();
371 maTimeSlider
.Enable();
373 const double fDuration
= maItem
.getDuration();
375 if( fDuration
> 0.0 )
377 const double fTime
= ::std::min( maItem
.getTime(), fDuration
);
379 if( !maTimeSlider
.GetLineSize() )
380 maTimeSlider
.SetLineSize( static_cast< sal_uInt32
>( AVMEDIA_TIME_RANGE
* AVMEDIA_LINEINCREMENT
/ fDuration
) );
382 if( !maTimeSlider
.GetPageSize() )
383 maTimeSlider
.SetPageSize( static_cast< sal_uInt32
>( AVMEDIA_TIME_RANGE
* AVMEDIA_PAGEINCREMENT
/ fDuration
) );
385 maTimeSlider
.SetThumbPos( static_cast< sal_Int32
>( fTime
/ fDuration
* AVMEDIA_TIME_RANGE
) );
390 // ------------------------------------------------------------------------------
392 void MediaControl::implUpdateVolumeSlider()
394 if( maItem
.getURL().isEmpty() || !IsEnabled() )
395 maVolumeSlider
.Disable();
398 maVolumeSlider
.Enable();
400 const sal_Int32 nVolumeDB
= maItem
.getVolumeDB();
402 maVolumeSlider
.SetThumbPos( ::std::min( ::std::max( nVolumeDB
, static_cast< sal_Int32
>( AVMEDIA_DB_RANGE
) ),
403 static_cast< sal_Int32
>( 0 ) ) );
407 // ------------------------------------------------------------------------------
409 void MediaControl::implUpdateTimeField( double fCurTime
)
411 if( !maItem
.getURL().isEmpty() )
413 OUString aTimeString
;
415 SvtSysLocale aSysLocale
;
416 const LocaleDataWrapper
& rLocaleData
= aSysLocale
.GetLocaleData();
418 aTimeString
+= rLocaleData
.getDuration( Time( 0, 0, static_cast< sal_uInt32
>( floor( fCurTime
) ) ) ) +
420 rLocaleData
.getDuration( Time( 0, 0, static_cast< sal_uInt32
>( floor( maItem
.getDuration() ) )) );
422 if( maTimeEdit
.GetText() != aTimeString
)
423 maTimeEdit
.SetText( aTimeString
);
427 // ------------------------------------------------------------------------------
429 Image
MediaControl::implGetImage( sal_Int32 nImageId
) const
431 return maImageList
.GetImage( static_cast< sal_uInt16
>( nImageId
) );
434 // ------------------------------------------------------------------------------
436 IMPL_LINK( MediaControl
, implTimeHdl
, Slider
*, p
)
440 implUpdateTimeField( p
->GetThumbPos() * maItem
.getDuration() / AVMEDIA_TIME_RANGE
);
445 // ------------------------------------------------------------------------------
447 IMPL_LINK( MediaControl
, implTimeEndHdl
, Slider
*, p
)
451 aExecItem
.setTime( p
->GetThumbPos() * maItem
.getDuration() / AVMEDIA_TIME_RANGE
);
452 execute( aExecItem
);
460 // ------------------------------------------------------------------------------
462 IMPL_LINK( MediaControl
, implVolumeHdl
, Slider
*, p
)
466 aExecItem
.setVolumeDB( static_cast< sal_Int16
>( p
->GetThumbPos() ) );
467 execute( aExecItem
);
473 // ------------------------------------------------------------------------------
475 IMPL_LINK_NOARG(MediaControl
, implVolumeEndHdl
)
480 // ------------------------------------------------------------------------------
482 IMPL_LINK( MediaControl
, implSelectHdl
, ToolBox
*, p
)
488 switch( p
->GetCurItemId() )
490 case( AVMEDIA_TOOLBOXITEM_OPEN
):
494 if (::avmedia::MediaWindow::executeMediaURLDialog(
495 GetParent(), aURL
, 0))
497 if( !::avmedia::MediaWindow::isMediaURL( aURL
, true ) )
498 ::avmedia::MediaWindow::executeFormatErrorBox( this );
501 aExecItem
.setURL( aURL
, 0 );
502 aExecItem
.setState( MEDIASTATE_PLAY
);
508 case( AVMEDIA_TOOLBOXITEM_INSERT
):
510 MediaFloater
* pFloater
= AVMEDIA_MEDIAWINDOW();
513 pFloater
->dispatchCurrentURL();
517 case( AVMEDIA_TOOLBOXITEM_PLAY
):
518 case( AVMEDIA_TOOLBOXITEM_PLAYFFW
):
520 aExecItem
.setState( ( AVMEDIA_TOOLBOXITEM_PLAYFFW
== p
->GetCurItemId() ) ? MEDIASTATE_PLAYFFW
: MEDIASTATE_PLAY
);
522 if( maItem
.getTime() == maItem
.getDuration() )
523 aExecItem
.setTime( 0.0 );
525 aExecItem
.setTime( maItem
.getTime() );
529 case( AVMEDIA_TOOLBOXITEM_PAUSE
):
531 aExecItem
.setState( MEDIASTATE_PAUSE
);
535 case( AVMEDIA_TOOLBOXITEM_STOP
):
537 aExecItem
.setState( MEDIASTATE_STOP
);
538 aExecItem
.setTime( 0.0 );
542 case( AVMEDIA_TOOLBOXITEM_MUTE
):
544 aExecItem
.setMute( !maMuteToolBox
.IsItemChecked( AVMEDIA_TOOLBOXITEM_MUTE
) );
548 case( AVMEDIA_TOOLBOXITEM_LOOP
):
550 aExecItem
.setLoop( !maPlayToolBox
.IsItemChecked( AVMEDIA_TOOLBOXITEM_LOOP
) );
558 if( aExecItem
.getMaskSet() != AVMEDIA_SETMASK_NONE
)
559 execute( aExecItem
);
565 p
->Invalidate( INVALIDATE_UPDATE
);
571 // ------------------------------------------------------------------------------
573 IMPL_LINK( MediaControl
, implZoomSelectHdl
, ListBox
*, p
)
578 ::com::sun::star::media::ZoomLevel eLevel
;
580 switch( p
->GetSelectEntryPos() )
582 case( AVMEDIA_ZOOMLEVEL_50
): eLevel
= ::com::sun::star::media::ZoomLevel_ZOOM_1_TO_2
; break;
583 case( AVMEDIA_ZOOMLEVEL_100
): eLevel
= ::com::sun::star::media::ZoomLevel_ORIGINAL
; break;
584 case( AVMEDIA_ZOOMLEVEL_200
): eLevel
= ::com::sun::star::media::ZoomLevel_ZOOM_2_TO_1
; break;
585 case( AVMEDIA_ZOOMLEVEL_FIT
): eLevel
= ::com::sun::star::media::ZoomLevel_FIT_TO_WINDOW_FIXED_ASPECT
; break;
586 case( AVMEDIA_ZOOMLEVEL_SCALED
): eLevel
= ::com::sun::star::media::ZoomLevel_FIT_TO_WINDOW
; break;
588 default: eLevel
= ::com::sun::star::media::ZoomLevel_NOT_AVAILABLE
; break;
591 aExecItem
.setZoom( eLevel
);
592 execute( aExecItem
);
599 // ------------------------------------------------------------------------------
601 IMPL_LINK_NOARG(MediaControl
, implTimeoutHdl
)
611 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */