xref: /AOO41X/main/svx/source/gallery2/galctrl.cxx (revision 6dd9478380e712ce9b6e65d8594f0d3b444cce2d)
1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <vcl/svapp.hxx>
28cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
29cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
30cdf0e10cSrcweir #include <avmedia/mediaplayer.hxx>
31cdf0e10cSrcweir #include "helpid.hrc"
32cdf0e10cSrcweir #include "galbrws2.hxx"
33cdf0e10cSrcweir #include "svx/galtheme.hxx"
34cdf0e10cSrcweir #include "svx/galmisc.hxx"
35cdf0e10cSrcweir #include "svx/galctrl.hxx"
36cdf0e10cSrcweir #include "editeng/AccessibleStringWrap.hxx"
37cdf0e10cSrcweir #include <editeng/svxfont.hxx>
38cdf0e10cSrcweir #include "galobj.hxx"
39cdf0e10cSrcweir #include <avmedia/mediawindow.hxx>
40cdf0e10cSrcweir #include "gallery.hrc"
41cdf0e10cSrcweir #include <svtools/filter.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir // -----------
44cdf0e10cSrcweir // - Defines -
45cdf0e10cSrcweir // -----------
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #define GALLERY_BRWBOX_TITLE    1
48cdf0e10cSrcweir #define GALLERY_BRWBOX_PATH     2
49cdf0e10cSrcweir 
50cdf0e10cSrcweir // ------------------
51cdf0e10cSrcweir // - GalleryPreview -
52cdf0e10cSrcweir // ------------------
53cdf0e10cSrcweir DBG_NAME(GalleryPreview)
54cdf0e10cSrcweir 
55cdf0e10cSrcweir GalleryPreview::GalleryPreview( GalleryBrowser2* pParent, GalleryTheme* pTheme ) :
56cdf0e10cSrcweir 	Window( pParent, WB_TABSTOP | WB_BORDER ),
57cdf0e10cSrcweir 	DropTargetHelper( this ),
58cdf0e10cSrcweir     DragSourceHelper( this ),
59cdf0e10cSrcweir     mpTheme( pTheme )
60cdf0e10cSrcweir {
61cdf0e10cSrcweir     DBG_CTOR(GalleryPreview,NULL);
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 	SetHelpId( HID_GALLERY_WINDOW );
64cdf0e10cSrcweir     InitSettings();
65cdf0e10cSrcweir }
66cdf0e10cSrcweir 
67cdf0e10cSrcweir // ------------------------------------------------------------------------
68cdf0e10cSrcweir 
69cdf0e10cSrcweir GalleryPreview::GalleryPreview( Window* pParent, const ResId & rResId  ) :
70cdf0e10cSrcweir 	Window( pParent, rResId ),
71cdf0e10cSrcweir 	DropTargetHelper( this ),
72cdf0e10cSrcweir     DragSourceHelper( this ),
73cdf0e10cSrcweir     mpTheme( NULL )
74cdf0e10cSrcweir {
75cdf0e10cSrcweir     DBG_CTOR(GalleryPreview,NULL);
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 	SetHelpId( HID_GALLERY_PREVIEW );
78cdf0e10cSrcweir     InitSettings();
79cdf0e10cSrcweir }
80cdf0e10cSrcweir 
81cdf0e10cSrcweir // ------------------------------------------------------------------------
82cdf0e10cSrcweir 
83cdf0e10cSrcweir GalleryPreview::~GalleryPreview()
84cdf0e10cSrcweir {
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     DBG_DTOR(GalleryPreview,NULL);
87cdf0e10cSrcweir }
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 
90cdf0e10cSrcweir bool GalleryPreview::SetGraphic( const INetURLObject& _aURL )
91cdf0e10cSrcweir {
92cdf0e10cSrcweir 	bool bRet = true;
93cdf0e10cSrcweir 	Graphic	aGraphic;
94cdf0e10cSrcweir     if( ::avmedia::MediaWindow::isMediaURL( _aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) ) )
95cdf0e10cSrcweir 	{
96cdf0e10cSrcweir 		aGraphic = BitmapEx( GAL_RESID( RID_SVXBMP_GALLERY_MEDIA ) );
97cdf0e10cSrcweir 	}
98cdf0e10cSrcweir 	else
99cdf0e10cSrcweir 	{
100cdf0e10cSrcweir 		GraphicFilter*  pFilter = GraphicFilter::GetGraphicFilter();
101cdf0e10cSrcweir 		GalleryProgress aProgress( pFilter );
102cdf0e10cSrcweir         if( pFilter->ImportGraphic( aGraphic, _aURL, GRFILTER_FORMAT_DONTKNOW ) )
103cdf0e10cSrcweir 			bRet = false;
104cdf0e10cSrcweir 	}
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 	SetGraphic( aGraphic );
107cdf0e10cSrcweir 	Invalidate();
108cdf0e10cSrcweir 	return bRet;
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir // ------------------------------------------------------------------------
112cdf0e10cSrcweir 
113cdf0e10cSrcweir void GalleryPreview::InitSettings()
114cdf0e10cSrcweir {
115cdf0e10cSrcweir 	SetBackground( Wallpaper( GALLERY_BG_COLOR ) );
116cdf0e10cSrcweir 	SetControlBackground( GALLERY_BG_COLOR );
117cdf0e10cSrcweir 	SetControlForeground( GALLERY_FG_COLOR );
118cdf0e10cSrcweir }
119cdf0e10cSrcweir 
120cdf0e10cSrcweir // -----------------------------------------------------------------------
121cdf0e10cSrcweir 
122cdf0e10cSrcweir void GalleryPreview::DataChanged( const DataChangedEvent& rDCEvt )
123cdf0e10cSrcweir {
124cdf0e10cSrcweir 	if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
125cdf0e10cSrcweir 		InitSettings();
126cdf0e10cSrcweir 	else
127cdf0e10cSrcweir 		Window::DataChanged( rDCEvt );
128cdf0e10cSrcweir }
129cdf0e10cSrcweir 
130cdf0e10cSrcweir // ------------------------------------------------------------------------
131cdf0e10cSrcweir 
132cdf0e10cSrcweir sal_Bool GalleryPreview::ImplGetGraphicCenterRect( const Graphic& rGraphic, Rectangle& rResultRect ) const
133cdf0e10cSrcweir {
134cdf0e10cSrcweir 	const Size	aWinSize( GetOutputSizePixel() );
135cdf0e10cSrcweir 	Size		aNewSize( LogicToPixel( rGraphic.GetPrefSize(), rGraphic.GetPrefMapMode() ) );
136cdf0e10cSrcweir 	sal_Bool		bRet = sal_False;
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 	if( aNewSize.Width() && aNewSize.Height() )
139cdf0e10cSrcweir 	{
140cdf0e10cSrcweir 		// scale to fit window
141cdf0e10cSrcweir 		const double fGrfWH = (double) aNewSize.Width() / aNewSize.Height();
142cdf0e10cSrcweir 		const double fWinWH = (double) aWinSize.Width() / aWinSize.Height();
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 		if ( fGrfWH < fWinWH )
145cdf0e10cSrcweir 		{
146cdf0e10cSrcweir 			aNewSize.Width() = (long) ( aWinSize.Height() * fGrfWH );
147cdf0e10cSrcweir 			aNewSize.Height()= aWinSize.Height();
148cdf0e10cSrcweir 		}
149cdf0e10cSrcweir 		else
150cdf0e10cSrcweir 		{
151cdf0e10cSrcweir 			aNewSize.Width() = aWinSize.Width();
152cdf0e10cSrcweir 			aNewSize.Height()= (long) ( aWinSize.Width() / fGrfWH);
153cdf0e10cSrcweir 		}
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 		const Point aNewPos( ( aWinSize.Width()  - aNewSize.Width() ) >> 1,
156cdf0e10cSrcweir 							 ( aWinSize.Height() - aNewSize.Height() ) >> 1 );
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 		rResultRect = Rectangle( aNewPos, aNewSize );
159cdf0e10cSrcweir 		bRet = sal_True;
160cdf0e10cSrcweir 	}
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 	return bRet;
163cdf0e10cSrcweir }
164cdf0e10cSrcweir 
165cdf0e10cSrcweir // ------------------------------------------------------------------------
166cdf0e10cSrcweir 
167cdf0e10cSrcweir void GalleryPreview::Paint( const Rectangle& rRect )
168cdf0e10cSrcweir {
169cdf0e10cSrcweir 	Window::Paint( rRect );
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 	if( ImplGetGraphicCenterRect( aGraphicObj.GetGraphic(), aPreviewRect ) )
172cdf0e10cSrcweir 	{
173cdf0e10cSrcweir 		const Point aPos( aPreviewRect.TopLeft() );
174cdf0e10cSrcweir 		const Size	aSize( aPreviewRect.GetSize() );
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 		if( aGraphicObj.IsAnimated() )
177cdf0e10cSrcweir 			aGraphicObj.StartAnimation( this, aPos, aSize );
178cdf0e10cSrcweir 		else
179cdf0e10cSrcweir 			aGraphicObj.Draw( this, aPos, aSize );
180cdf0e10cSrcweir 	}
181cdf0e10cSrcweir }
182cdf0e10cSrcweir 
183cdf0e10cSrcweir // ------------------------------------------------------------------------
184cdf0e10cSrcweir 
185cdf0e10cSrcweir void GalleryPreview::MouseButtonDown( const MouseEvent& rMEvt )
186cdf0e10cSrcweir {
187cdf0e10cSrcweir     if( mpTheme && ( rMEvt.GetClicks() == 2 ) )
188cdf0e10cSrcweir         ( (GalleryBrowser2*) GetParent() )->TogglePreview( this );
189cdf0e10cSrcweir }
190cdf0e10cSrcweir 
191cdf0e10cSrcweir // ------------------------------------------------------------------------
192cdf0e10cSrcweir 
193cdf0e10cSrcweir void GalleryPreview::Command(const CommandEvent& rCEvt )
194cdf0e10cSrcweir {
195cdf0e10cSrcweir 	Window::Command( rCEvt );
196cdf0e10cSrcweir 
197cdf0e10cSrcweir     if( mpTheme && ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ) )
198cdf0e10cSrcweir         ( (GalleryBrowser2*) GetParent() )->ShowContextMenu( this,
199cdf0e10cSrcweir 			( rCEvt.IsMouseEvent() ? &rCEvt.GetMousePosPixel() : NULL ) );
200cdf0e10cSrcweir }
201cdf0e10cSrcweir 
202cdf0e10cSrcweir // ------------------------------------------------------------------------
203cdf0e10cSrcweir 
204cdf0e10cSrcweir void GalleryPreview::KeyInput( const KeyEvent& rKEvt )
205cdf0e10cSrcweir {
206cdf0e10cSrcweir     if( mpTheme )
207cdf0e10cSrcweir     {
208cdf0e10cSrcweir         GalleryBrowser2* pBrowser = static_cast< GalleryBrowser2* >( GetParent() );
209cdf0e10cSrcweir 
210cdf0e10cSrcweir         switch( rKEvt.GetKeyCode().GetCode() )
211cdf0e10cSrcweir         {
212cdf0e10cSrcweir             case( KEY_BACKSPACE ):
213cdf0e10cSrcweir                 pBrowser->TogglePreview( this );
214cdf0e10cSrcweir             break;
215cdf0e10cSrcweir 
216cdf0e10cSrcweir             case( KEY_HOME ):
217cdf0e10cSrcweir                 pBrowser->Travel( GALLERYBROWSERTRAVEL_FIRST );
218cdf0e10cSrcweir             break;
219cdf0e10cSrcweir 
220cdf0e10cSrcweir             case( KEY_END ):
221cdf0e10cSrcweir                 pBrowser->Travel( GALLERYBROWSERTRAVEL_LAST );
222cdf0e10cSrcweir             break;
223cdf0e10cSrcweir 
224cdf0e10cSrcweir             case( KEY_LEFT ):
225cdf0e10cSrcweir             case( KEY_UP ):
226cdf0e10cSrcweir                 pBrowser->Travel( GALLERYBROWSERTRAVEL_PREVIOUS );
227cdf0e10cSrcweir             break;
228cdf0e10cSrcweir 
229cdf0e10cSrcweir             case( KEY_RIGHT ):
230cdf0e10cSrcweir             case( KEY_DOWN ):
231cdf0e10cSrcweir                 pBrowser->Travel( GALLERYBROWSERTRAVEL_NEXT );
232cdf0e10cSrcweir             break;
233cdf0e10cSrcweir 
234cdf0e10cSrcweir             default:
235cdf0e10cSrcweir             {
236cdf0e10cSrcweir                 if( !pBrowser->KeyInput( rKEvt, this ) )
237cdf0e10cSrcweir                     Window::KeyInput( rKEvt );
238cdf0e10cSrcweir             }
239cdf0e10cSrcweir             break;
240cdf0e10cSrcweir         }
241cdf0e10cSrcweir     }
242cdf0e10cSrcweir     else
243cdf0e10cSrcweir         Window::KeyInput( rKEvt );
244cdf0e10cSrcweir }
245cdf0e10cSrcweir 
246cdf0e10cSrcweir // ------------------------------------------------------------------------
247cdf0e10cSrcweir 
248cdf0e10cSrcweir sal_Int8 GalleryPreview::AcceptDrop( const AcceptDropEvent& rEvt )
249cdf0e10cSrcweir {
250cdf0e10cSrcweir     sal_Int8 nRet;
251cdf0e10cSrcweir 
252cdf0e10cSrcweir     if( mpTheme )
253cdf0e10cSrcweir         nRet = ( (GalleryBrowser2*) GetParent() )->AcceptDrop( *this, rEvt );
254cdf0e10cSrcweir     else
255cdf0e10cSrcweir         nRet = DND_ACTION_NONE;
256cdf0e10cSrcweir 
257cdf0e10cSrcweir     return nRet;
258cdf0e10cSrcweir }
259cdf0e10cSrcweir 
260cdf0e10cSrcweir // ------------------------------------------------------------------------
261cdf0e10cSrcweir 
262cdf0e10cSrcweir sal_Int8 GalleryPreview::ExecuteDrop( const ExecuteDropEvent& rEvt )
263cdf0e10cSrcweir {
264cdf0e10cSrcweir     sal_Int8 nRet;
265cdf0e10cSrcweir 
266cdf0e10cSrcweir     if( mpTheme )
267cdf0e10cSrcweir         nRet = ( (GalleryBrowser2*) GetParent() )->ExecuteDrop( *this, rEvt );
268cdf0e10cSrcweir     else
269cdf0e10cSrcweir         nRet = DND_ACTION_NONE;
270cdf0e10cSrcweir 
271cdf0e10cSrcweir     return nRet;
272cdf0e10cSrcweir }
273cdf0e10cSrcweir 
274cdf0e10cSrcweir // ------------------------------------------------------------------------
275cdf0e10cSrcweir 
276cdf0e10cSrcweir void GalleryPreview::StartDrag( sal_Int8, const Point& )
277cdf0e10cSrcweir {
278cdf0e10cSrcweir     if( mpTheme )
279cdf0e10cSrcweir         ( (GalleryBrowser2*) GetParent() )->StartDrag( this );
280cdf0e10cSrcweir }
281cdf0e10cSrcweir 
282cdf0e10cSrcweir // ------------------------------------------------------------------------
283cdf0e10cSrcweir 
284cdf0e10cSrcweir void GalleryPreview::PreviewMedia( const INetURLObject& rURL )
285cdf0e10cSrcweir {
286cdf0e10cSrcweir 	if( rURL.GetProtocol() != INET_PROT_NOT_VALID )
287cdf0e10cSrcweir 	{
288cdf0e10cSrcweir 		::avmedia::MediaFloater* pFloater = AVMEDIA_MEDIAWINDOW();
289cdf0e10cSrcweir 
290cdf0e10cSrcweir 		if( !pFloater )
291cdf0e10cSrcweir 		{
292cdf0e10cSrcweir 			SfxViewFrame::Current()->GetBindings().GetDispatcher()->Execute( SID_AVMEDIA_PLAYER, SFX_CALLMODE_SYNCHRON );
293cdf0e10cSrcweir 			pFloater = AVMEDIA_MEDIAWINDOW();
294cdf0e10cSrcweir 		}
295cdf0e10cSrcweir 
296cdf0e10cSrcweir 		if( pFloater )
297cdf0e10cSrcweir 			pFloater->setURL( rURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ), true );
298cdf0e10cSrcweir 	}
299cdf0e10cSrcweir }
300cdf0e10cSrcweir 
301cdf0e10cSrcweir // ------------------------------------------------------------------------
302cdf0e10cSrcweir 
303*6dd94783SArmin Le Grand void drawCheckered(OutputDevice& rOut, const Point& rPos, const Size& rSize)
304*6dd94783SArmin Le Grand {
305*6dd94783SArmin Le Grand     // draw checkered background
306*6dd94783SArmin Le Grand     static const sal_uInt32 nLen(8);
307*6dd94783SArmin Le Grand     static const Color aW(COL_WHITE);
308*6dd94783SArmin Le Grand     static const Color aG(0xef, 0xef, 0xef);
309*6dd94783SArmin Le Grand 
310*6dd94783SArmin Le Grand     rOut.DrawCheckered(rPos, rSize, nLen, aW, aG);
311*6dd94783SArmin Le Grand }
312*6dd94783SArmin Le Grand 
313cdf0e10cSrcweir // -------------------
314cdf0e10cSrcweir // - GalleryIconView -
315cdf0e10cSrcweir // -------------------
316cdf0e10cSrcweir DBG_NAME(GalleryIconView)
317cdf0e10cSrcweir 
318cdf0e10cSrcweir GalleryIconView::GalleryIconView( GalleryBrowser2* pParent, GalleryTheme* pTheme ) :
319cdf0e10cSrcweir 		ValueSet( pParent, WB_TABSTOP | WB_3DLOOK | WB_BORDER | WB_ITEMBORDER | WB_DOUBLEBORDER | WB_VSCROLL | WB_FLATVALUESET ),
320cdf0e10cSrcweir 		DropTargetHelper( this ),
321cdf0e10cSrcweir         DragSourceHelper( this ),
322cdf0e10cSrcweir 		mpTheme	( pTheme )
323cdf0e10cSrcweir {
324cdf0e10cSrcweir     DBG_CTOR(GalleryIconView,NULL);
325cdf0e10cSrcweir 	EnableFullItemMode( sal_False );
326cdf0e10cSrcweir 
327cdf0e10cSrcweir 	SetHelpId( HID_GALLERY_WINDOW );
328cdf0e10cSrcweir     InitSettings();
329cdf0e10cSrcweir 	SetExtraSpacing( 2 );
330cdf0e10cSrcweir 	SetItemWidth( S_THUMB + 6 );
331cdf0e10cSrcweir 	SetItemHeight( S_THUMB + 6 );
332cdf0e10cSrcweir }
333cdf0e10cSrcweir 
334cdf0e10cSrcweir // ------------------------------------------------------------------------
335cdf0e10cSrcweir 
336cdf0e10cSrcweir GalleryIconView::~GalleryIconView()
337cdf0e10cSrcweir {
338cdf0e10cSrcweir 
339cdf0e10cSrcweir     DBG_DTOR(GalleryIconView,NULL);
340cdf0e10cSrcweir }
341cdf0e10cSrcweir 
342cdf0e10cSrcweir // ------------------------------------------------------------------------
343cdf0e10cSrcweir 
344cdf0e10cSrcweir void GalleryIconView::InitSettings()
345cdf0e10cSrcweir {
346cdf0e10cSrcweir 	SetBackground( Wallpaper( GALLERY_BG_COLOR ) );
347cdf0e10cSrcweir 	SetControlBackground( GALLERY_BG_COLOR );
348cdf0e10cSrcweir 	SetControlForeground( GALLERY_FG_COLOR );
349cdf0e10cSrcweir 	SetColor( GALLERY_BG_COLOR );
350cdf0e10cSrcweir }
351cdf0e10cSrcweir 
352cdf0e10cSrcweir // -----------------------------------------------------------------------
353cdf0e10cSrcweir 
354cdf0e10cSrcweir void GalleryIconView::DataChanged( const DataChangedEvent& rDCEvt )
355cdf0e10cSrcweir {
356cdf0e10cSrcweir 	if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
357cdf0e10cSrcweir 		InitSettings();
358cdf0e10cSrcweir 	else
359cdf0e10cSrcweir 		ValueSet::DataChanged( rDCEvt );
360cdf0e10cSrcweir }
361cdf0e10cSrcweir 
362cdf0e10cSrcweir // ------------------------------------------------------------------------
363cdf0e10cSrcweir 
364cdf0e10cSrcweir void GalleryIconView::UserDraw( const UserDrawEvent& rUDEvt )
365cdf0e10cSrcweir {
366cdf0e10cSrcweir 	const sal_uInt16 nId = rUDEvt.GetItemId();
367cdf0e10cSrcweir 
368cdf0e10cSrcweir 	if( nId && mpTheme )
369cdf0e10cSrcweir 	{
370cdf0e10cSrcweir 		SgaObject* pObj = mpTheme->AcquireObject( nId - 1 );
371cdf0e10cSrcweir 
372cdf0e10cSrcweir 		if( pObj )
373cdf0e10cSrcweir 		{
374cdf0e10cSrcweir 			const Rectangle&	rRect = rUDEvt.GetRect();
375cdf0e10cSrcweir 			OutputDevice*		pDev = rUDEvt.GetDevice();
376cdf0e10cSrcweir 			Graphic 			aGraphic;
377*6dd94783SArmin Le Grand             bool bTransparent(false);
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 			if( pObj->IsThumbBitmap() )
380cdf0e10cSrcweir 			{
381*6dd94783SArmin Le Grand 				BitmapEx aBitmapEx;
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 				if( pObj->GetObjKind() == SGA_OBJ_SOUND )
384*6dd94783SArmin Le Grand                 {
385*6dd94783SArmin Le Grand                     Bitmap aTemp = pObj->GetThumbBmp().GetBitmap();
386cdf0e10cSrcweir 
387*6dd94783SArmin Le Grand                     aTemp.Replace( COL_LIGHTMAGENTA, COL_WHITE );
388*6dd94783SArmin Le Grand                     aBitmapEx = BitmapEx(aTemp);
389cdf0e10cSrcweir                 }
390cdf0e10cSrcweir                 else
391*6dd94783SArmin Le Grand                 {
392*6dd94783SArmin Le Grand                     aBitmapEx = pObj->GetThumbBmp();
393*6dd94783SArmin Le Grand                     bTransparent = aBitmapEx.IsTransparent();
394*6dd94783SArmin Le Grand                 }
395*6dd94783SArmin Le Grand 
396*6dd94783SArmin Le Grand 				if( ( pDev->GetBitCount() <= 8 ) && ( aBitmapEx.GetBitCount() >= 8 ) )
397*6dd94783SArmin Le Grand                 {
398*6dd94783SArmin Le Grand 					aBitmapEx.Dither( BMP_DITHER_FLOYD );
399*6dd94783SArmin Le Grand                 }
400*6dd94783SArmin Le Grand 
401*6dd94783SArmin Le Grand 				aGraphic = aBitmapEx;
402*6dd94783SArmin Le Grand 			}
403*6dd94783SArmin Le Grand 			else
404*6dd94783SArmin Le Grand             {
405cdf0e10cSrcweir 				aGraphic = pObj->GetThumbMtf();
406*6dd94783SArmin Le Grand                 bTransparent = true;
407*6dd94783SArmin Le Grand             }
408cdf0e10cSrcweir 
409cdf0e10cSrcweir 			Size aSize( aGraphic.GetSizePixel( pDev ) );
410cdf0e10cSrcweir 
411cdf0e10cSrcweir 			if ( aSize.Width() && aSize.Height() )
412cdf0e10cSrcweir 			{
413cdf0e10cSrcweir 				if( ( aSize.Width() > rRect.GetWidth() ) || ( aSize.Height() > rRect.GetHeight() ) )
414cdf0e10cSrcweir 				{
415cdf0e10cSrcweir 					Point			aNewPos;
416cdf0e10cSrcweir 					const double	fBmpWH	= (double) aSize.Width() / aSize.Height();
417cdf0e10cSrcweir 					const double	fThmpWH = (double) rRect.GetWidth() / rRect.GetHeight();
418cdf0e10cSrcweir 
419cdf0e10cSrcweir 					// Bitmap an Thumbgroesse anpassen
420cdf0e10cSrcweir 					if ( fBmpWH < fThmpWH )
421cdf0e10cSrcweir 					{
422cdf0e10cSrcweir 						aSize.Width() = (long) ( rRect.GetHeight() * fBmpWH );
423cdf0e10cSrcweir 						aSize.Height()= rRect.GetHeight();
424cdf0e10cSrcweir 					}
425cdf0e10cSrcweir 					else
426cdf0e10cSrcweir 					{
427cdf0e10cSrcweir 						aSize.Width() = rRect.GetWidth();
428cdf0e10cSrcweir 						aSize.Height()= (long) ( rRect.GetWidth() / fBmpWH );
429cdf0e10cSrcweir 					}
430cdf0e10cSrcweir 				}
431cdf0e10cSrcweir 
432cdf0e10cSrcweir 				const Point aPos( ( ( rRect.GetWidth() - aSize.Width() ) >> 1 ) + rRect.Left(),
433cdf0e10cSrcweir 								  ( ( rRect.GetHeight() - aSize.Height() ) >> 1 ) + rRect.Top() );
434cdf0e10cSrcweir 
435*6dd94783SArmin Le Grand                 if(bTransparent)
436*6dd94783SArmin Le Grand                 {
437*6dd94783SArmin Le Grand                     // draw checkered background
438*6dd94783SArmin Le Grand                     drawCheckered(*pDev, aPos, aSize);
439*6dd94783SArmin Le Grand                 }
440*6dd94783SArmin Le Grand 
441cdf0e10cSrcweir 				aGraphic.Draw( pDev, aPos, aSize );
442cdf0e10cSrcweir 			}
443cdf0e10cSrcweir 
444cdf0e10cSrcweir 			SetItemText( nId, GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_TITLE) );
445cdf0e10cSrcweir 			mpTheme->ReleaseObject( pObj );
446cdf0e10cSrcweir 		}
447cdf0e10cSrcweir 	}
448cdf0e10cSrcweir }
449cdf0e10cSrcweir 
450cdf0e10cSrcweir // ------------------------------------------------------------------------
451cdf0e10cSrcweir 
452cdf0e10cSrcweir void GalleryIconView::MouseButtonDown( const MouseEvent& rMEvt )
453cdf0e10cSrcweir {
454cdf0e10cSrcweir     ValueSet::MouseButtonDown( rMEvt );
455cdf0e10cSrcweir 
456cdf0e10cSrcweir     if( rMEvt.GetClicks() == 2 )
457cdf0e10cSrcweir         ( (GalleryBrowser2*) GetParent() )->TogglePreview( this, &rMEvt.GetPosPixel() );
458cdf0e10cSrcweir }
459cdf0e10cSrcweir 
460cdf0e10cSrcweir // ------------------------------------------------------------------------
461cdf0e10cSrcweir 
462cdf0e10cSrcweir void GalleryIconView::Command( const CommandEvent& rCEvt )
463cdf0e10cSrcweir {
464cdf0e10cSrcweir 	ValueSet::Command( rCEvt );
465cdf0e10cSrcweir 
466cdf0e10cSrcweir     if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
467cdf0e10cSrcweir 	{
468cdf0e10cSrcweir         ( (GalleryBrowser2*) GetParent() )->ShowContextMenu( this,
469cdf0e10cSrcweir 			( rCEvt.IsMouseEvent() ? &rCEvt.GetMousePosPixel() : NULL ) );
470cdf0e10cSrcweir 	}
471cdf0e10cSrcweir }
472cdf0e10cSrcweir 
473cdf0e10cSrcweir // ------------------------------------------------------------------------
474cdf0e10cSrcweir 
475cdf0e10cSrcweir void GalleryIconView::KeyInput( const KeyEvent& rKEvt )
476cdf0e10cSrcweir {
477cdf0e10cSrcweir     if( !mpTheme || !static_cast< GalleryBrowser2* >( GetParent() )->KeyInput( rKEvt, this ) )
478cdf0e10cSrcweir         ValueSet::KeyInput( rKEvt );
479cdf0e10cSrcweir }
480cdf0e10cSrcweir 
481cdf0e10cSrcweir // ------------------------------------------------------------------------
482cdf0e10cSrcweir 
483cdf0e10cSrcweir sal_Int8 GalleryIconView::AcceptDrop( const AcceptDropEvent& rEvt )
484cdf0e10cSrcweir {
485cdf0e10cSrcweir 	return( static_cast< GalleryBrowser2* >( GetParent() )->AcceptDrop( *this, rEvt ) );
486cdf0e10cSrcweir }
487cdf0e10cSrcweir 
488cdf0e10cSrcweir // ------------------------------------------------------------------------
489cdf0e10cSrcweir 
490cdf0e10cSrcweir sal_Int8 GalleryIconView::ExecuteDrop( const ExecuteDropEvent& rEvt )
491cdf0e10cSrcweir {
492cdf0e10cSrcweir 	return(	static_cast< GalleryBrowser2* >( GetParent() )->ExecuteDrop( *this, rEvt ) );
493cdf0e10cSrcweir }
494cdf0e10cSrcweir 
495cdf0e10cSrcweir // ------------------------------------------------------------------------
496cdf0e10cSrcweir 
497cdf0e10cSrcweir void GalleryIconView::StartDrag( sal_Int8, const Point& )
498cdf0e10cSrcweir {
499cdf0e10cSrcweir 	const CommandEvent	aEvt( GetPointerPosPixel(), COMMAND_STARTDRAG, sal_True );
500cdf0e10cSrcweir 	Region				aRegion;
501cdf0e10cSrcweir 
502cdf0e10cSrcweir 	// call this to initiate dragging for ValueSet
503cdf0e10cSrcweir     ValueSet::StartDrag( aEvt, aRegion );
504cdf0e10cSrcweir     static_cast< GalleryBrowser2* >( GetParent() )->StartDrag( this );
505cdf0e10cSrcweir }
506cdf0e10cSrcweir 
507cdf0e10cSrcweir // -------------------
508cdf0e10cSrcweir // - GalleryListView -
509cdf0e10cSrcweir // -------------------
510cdf0e10cSrcweir DBG_NAME(GalleryListView)
511cdf0e10cSrcweir 
512cdf0e10cSrcweir GalleryListView::GalleryListView( GalleryBrowser2* pParent, GalleryTheme* pTheme ) :
513cdf0e10cSrcweir     BrowseBox( pParent, WB_TABSTOP | WB_3DLOOK | WB_BORDER ),
514cdf0e10cSrcweir     mpTheme( pTheme ),
515cdf0e10cSrcweir     mnCurRow( 0 ),
516cdf0e10cSrcweir     mbInit( sal_False )
517cdf0e10cSrcweir {
518cdf0e10cSrcweir     DBG_CTOR(GalleryListView,NULL);
519cdf0e10cSrcweir 
520cdf0e10cSrcweir 	SetHelpId( HID_GALLERY_WINDOW );
521cdf0e10cSrcweir 
522cdf0e10cSrcweir     InitSettings();
523cdf0e10cSrcweir 
524cdf0e10cSrcweir     SetMode( BROWSER_AUTO_VSCROLL | BROWSER_AUTOSIZE_LASTCOL );
525cdf0e10cSrcweir     SetDataRowHeight( 28 );
526cdf0e10cSrcweir 	InsertDataColumn( GALLERY_BRWBOX_TITLE, String( GAL_RESID( RID_SVXSTR_GALLERY_TITLE ) ), 256  );
527cdf0e10cSrcweir 	InsertDataColumn( GALLERY_BRWBOX_PATH, String( GAL_RESID( RID_SVXSTR_GALLERY_PATH ) ), 256 );
528cdf0e10cSrcweir }
529cdf0e10cSrcweir 
530cdf0e10cSrcweir // ------------------------------------------------------------------------
531cdf0e10cSrcweir 
532cdf0e10cSrcweir GalleryListView::~GalleryListView()
533cdf0e10cSrcweir {
534cdf0e10cSrcweir 
535cdf0e10cSrcweir     DBG_DTOR(GalleryListView,NULL);
536cdf0e10cSrcweir }
537cdf0e10cSrcweir 
538cdf0e10cSrcweir // ------------------------------------------------------------------------
539cdf0e10cSrcweir 
540cdf0e10cSrcweir void GalleryListView::InitSettings()
541cdf0e10cSrcweir {
542cdf0e10cSrcweir 	SetBackground( Wallpaper( GALLERY_BG_COLOR ) );
543cdf0e10cSrcweir 	SetControlBackground( GALLERY_BG_COLOR );
544cdf0e10cSrcweir 	SetControlForeground( GALLERY_FG_COLOR );
545cdf0e10cSrcweir }
546cdf0e10cSrcweir 
547cdf0e10cSrcweir // -----------------------------------------------------------------------
548cdf0e10cSrcweir 
549cdf0e10cSrcweir void GalleryListView::DataChanged( const DataChangedEvent& rDCEvt )
550cdf0e10cSrcweir {
551cdf0e10cSrcweir 	if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
552cdf0e10cSrcweir 		InitSettings();
553cdf0e10cSrcweir 	else
554cdf0e10cSrcweir 		BrowseBox::DataChanged( rDCEvt );
555cdf0e10cSrcweir }
556cdf0e10cSrcweir 
557cdf0e10cSrcweir // ------------------------------------------------------------------------
558cdf0e10cSrcweir 
559cdf0e10cSrcweir sal_Bool GalleryListView::SeekRow( long nRow )
560cdf0e10cSrcweir {
561cdf0e10cSrcweir     mnCurRow = nRow;
562cdf0e10cSrcweir     return sal_True;
563cdf0e10cSrcweir }
564cdf0e10cSrcweir 
565cdf0e10cSrcweir // -----------------------------------------------------------------------------
566cdf0e10cSrcweir 
567cdf0e10cSrcweir String GalleryListView::GetCellText(long _nRow, sal_uInt16 nColumnId) const
568cdf0e10cSrcweir {
569cdf0e10cSrcweir 	String sRet;
570cdf0e10cSrcweir 	if( mpTheme && ( _nRow < static_cast< long >( mpTheme->GetObjectCount() ) ) )
571cdf0e10cSrcweir 	{
572cdf0e10cSrcweir     	SgaObject* pObj = mpTheme->AcquireObject( _nRow );
573cdf0e10cSrcweir 
574cdf0e10cSrcweir 		if( pObj )
575cdf0e10cSrcweir 		{
576cdf0e10cSrcweir 			sRet = GalleryBrowser2::GetItemText( *mpTheme, *pObj,
577cdf0e10cSrcweir 				( GALLERY_BRWBOX_TITLE == nColumnId ) ? GALLERY_ITEM_TITLE : GALLERY_ITEM_PATH );
578cdf0e10cSrcweir 
579cdf0e10cSrcweir 		    mpTheme->ReleaseObject( pObj );
580cdf0e10cSrcweir 		}
581cdf0e10cSrcweir 	}
582cdf0e10cSrcweir 
583cdf0e10cSrcweir 	return sRet;;
584cdf0e10cSrcweir }
585cdf0e10cSrcweir 
586cdf0e10cSrcweir // -----------------------------------------------------------------------------
587cdf0e10cSrcweir 
588cdf0e10cSrcweir Rectangle GalleryListView::GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex)
589cdf0e10cSrcweir {
590cdf0e10cSrcweir     DBG_ASSERT(_nColumnPos >= 0 && _nColumnPos <= USHRT_MAX, "GalleryListView::GetFieldCharacterBounds: _nColumnId overflow");
591cdf0e10cSrcweir 	Rectangle aRect;
592cdf0e10cSrcweir 	if ( SeekRow(_nRow) )
593cdf0e10cSrcweir 	{
594cdf0e10cSrcweir         SvxFont aFont( GetFont() );
595cdf0e10cSrcweir         AccessibleStringWrap aStringWrap( *this, aFont, GetCellText(_nRow, sal::static_int_cast<sal_uInt16>( GetColumnId( sal::static_int_cast<sal_uInt16>(_nColumnPos) ) ) ) );
596cdf0e10cSrcweir 
597cdf0e10cSrcweir         // get the bounds inside the string
598cdf0e10cSrcweir         aStringWrap.GetCharacterBounds(nIndex, aRect);
599cdf0e10cSrcweir 
600cdf0e10cSrcweir         // offset to
601cdf0e10cSrcweir 	}
602cdf0e10cSrcweir 	return aRect;
603cdf0e10cSrcweir }
604cdf0e10cSrcweir 
605cdf0e10cSrcweir // -----------------------------------------------------------------------------
606cdf0e10cSrcweir 
607cdf0e10cSrcweir sal_Int32 GalleryListView::GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint)
608cdf0e10cSrcweir {
609cdf0e10cSrcweir     DBG_ASSERT(_nColumnPos >= 0 && _nColumnPos <= USHRT_MAX, "GalleryListView::GetFieldIndexAtPoint: _nColumnId overflow");
610cdf0e10cSrcweir 	sal_Int32 nRet = -1;
611cdf0e10cSrcweir 	if ( SeekRow(_nRow) )
612cdf0e10cSrcweir 	{
613cdf0e10cSrcweir         SvxFont aFont( GetFont() );
614cdf0e10cSrcweir         AccessibleStringWrap aStringWrap( *this, aFont, GetCellText(_nRow, sal::static_int_cast<sal_uInt16>(GetColumnId(sal::static_int_cast<sal_uInt16>(_nColumnPos)))) );
615cdf0e10cSrcweir         nRet = aStringWrap.GetIndexAtPoint(_rPoint);
616cdf0e10cSrcweir 	}
617cdf0e10cSrcweir 	return nRet;
618cdf0e10cSrcweir }
619cdf0e10cSrcweir 
620cdf0e10cSrcweir // ------------------------------------------------------------------------
621cdf0e10cSrcweir 
622cdf0e10cSrcweir void GalleryListView::PaintField( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId ) const
623cdf0e10cSrcweir {
624cdf0e10cSrcweir     rDev.Push( PUSH_CLIPREGION );
625cdf0e10cSrcweir     rDev.IntersectClipRegion( rRect );
626cdf0e10cSrcweir 
627cdf0e10cSrcweir 	if( mpTheme && ( mnCurRow < mpTheme->GetObjectCount() ) )
628cdf0e10cSrcweir 	{
629cdf0e10cSrcweir     	SgaObject* pObj = mpTheme->AcquireObject( mnCurRow );
630cdf0e10cSrcweir 
631cdf0e10cSrcweir 		if( pObj )
632cdf0e10cSrcweir 		{
633cdf0e10cSrcweir             const long nTextPosY = rRect.Top() + ( ( rRect.GetHeight() - rDev.GetTextHeight() ) >> 1 );
634cdf0e10cSrcweir 
635cdf0e10cSrcweir             if( GALLERY_BRWBOX_TITLE == nColumnId )
636cdf0e10cSrcweir             {
637cdf0e10cSrcweir                 Rectangle       aOutputRect( rRect.TopLeft(), Size( rRect.GetHeight(), rRect.GetHeight() ) );
638cdf0e10cSrcweir     			GraphicObject   aGrfObj;
639*6dd94783SArmin Le Grand                 bool bTransparent(false);
640cdf0e10cSrcweir 
641cdf0e10cSrcweir                 if( pObj->GetObjKind() == SGA_OBJ_SOUND )
642*6dd94783SArmin Le Grand                 {
643cdf0e10cSrcweir                     aGrfObj = Graphic( BitmapEx( GAL_RESID( RID_SVXBMP_GALLERY_MEDIA ) ) );
644*6dd94783SArmin Le Grand                 }
645cdf0e10cSrcweir                 else if( pObj->IsThumbBitmap() )
646*6dd94783SArmin Le Grand                 {
647*6dd94783SArmin Le Grand                     const BitmapEx aBitmapEx(pObj->GetThumbBmp());
648*6dd94783SArmin Le Grand 
649*6dd94783SArmin Le Grand                     bTransparent = aBitmapEx.IsTransparent();
650*6dd94783SArmin Le Grand 				    aGrfObj = Graphic(aBitmapEx);
651*6dd94783SArmin Le Grand                 }
652cdf0e10cSrcweir 			    else
653*6dd94783SArmin Le Grand                 {
654cdf0e10cSrcweir 				    aGrfObj = Graphic( pObj->GetThumbMtf() );
655*6dd94783SArmin Le Grand                     bTransparent = true;
656*6dd94783SArmin Le Grand                 }
657cdf0e10cSrcweir 
658cdf0e10cSrcweir 			    Size aSize( rDev.LogicToPixel( aGrfObj.GetPrefSize(), aGrfObj.GetPrefMapMode() ) );
659cdf0e10cSrcweir 
660cdf0e10cSrcweir 			    if( aSize.Width() && aSize.Height() )
661cdf0e10cSrcweir 			    {
662cdf0e10cSrcweir 				    if( ( aSize.Width() > aOutputRect.GetWidth() ) || ( aSize.Height() > aOutputRect.GetHeight() ) )
663cdf0e10cSrcweir 				    {
664cdf0e10cSrcweir 					    Point			aNewPos;
665cdf0e10cSrcweir 					    const double	fBmpWH	= (double) aSize.Width() / aSize.Height();
666cdf0e10cSrcweir 					    const double	fThmpWH = (double) aOutputRect.GetWidth() / aOutputRect.GetHeight();
667cdf0e10cSrcweir 
668cdf0e10cSrcweir 					    // Bitmap an Thumbgroesse anpassen
669cdf0e10cSrcweir 					    if ( fBmpWH < fThmpWH )
670cdf0e10cSrcweir 					    {
671cdf0e10cSrcweir 						    aSize.Width() = (long) ( aOutputRect.GetHeight() * fBmpWH );
672cdf0e10cSrcweir 						    aSize.Height()= aOutputRect.GetHeight();
673cdf0e10cSrcweir 					    }
674cdf0e10cSrcweir 					    else
675cdf0e10cSrcweir 					    {
676cdf0e10cSrcweir 						    aSize.Width() = aOutputRect.GetWidth();
677cdf0e10cSrcweir 						    aSize.Height()= (long) ( aOutputRect.GetWidth() / fBmpWH );
678cdf0e10cSrcweir 					    }
679cdf0e10cSrcweir 				    }
680cdf0e10cSrcweir 
681cdf0e10cSrcweir                     aSize.Width() = Max( aSize.Width(), 4L );
682cdf0e10cSrcweir                     aSize.Height() = Max( aSize.Height(), 4L );
683cdf0e10cSrcweir 
684cdf0e10cSrcweir 				    const Point aPos( ( ( aOutputRect.GetWidth() - aSize.Width() ) >> 1 ) + aOutputRect.Left(),
685cdf0e10cSrcweir 								      ( ( aOutputRect.GetHeight() - aSize.Height() ) >> 1 ) + aOutputRect.Top() );
686cdf0e10cSrcweir 
687*6dd94783SArmin Le Grand                     if(bTransparent)
688*6dd94783SArmin Le Grand                     {
689*6dd94783SArmin Le Grand                         // draw checkered background
690*6dd94783SArmin Le Grand                         drawCheckered(rDev, aPos, aSize);
691*6dd94783SArmin Le Grand                     }
692*6dd94783SArmin Le Grand 
693cdf0e10cSrcweir                     aGrfObj.Draw( &rDev, aPos, aSize );
694cdf0e10cSrcweir 			    }
695cdf0e10cSrcweir 
696cdf0e10cSrcweir 			    rDev.DrawText( Point( aOutputRect.Right() + 6, nTextPosY ), GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_TITLE ) );
697cdf0e10cSrcweir             }
698cdf0e10cSrcweir             else if( GALLERY_BRWBOX_PATH == nColumnId )
699cdf0e10cSrcweir                 rDev.DrawText( Point( rRect.Left(), nTextPosY ), GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_PATH ) );
700cdf0e10cSrcweir 
701cdf0e10cSrcweir 		    mpTheme->ReleaseObject( pObj );
702cdf0e10cSrcweir 		}
703cdf0e10cSrcweir 	}
704cdf0e10cSrcweir 
705cdf0e10cSrcweir     rDev.Pop();
706cdf0e10cSrcweir }
707cdf0e10cSrcweir 
708cdf0e10cSrcweir // ------------------------------------------------------------------------
709cdf0e10cSrcweir 
710cdf0e10cSrcweir void GalleryListView::Command( const CommandEvent& rCEvt )
711cdf0e10cSrcweir {
712cdf0e10cSrcweir 	BrowseBox::Command( rCEvt );
713cdf0e10cSrcweir 
714cdf0e10cSrcweir     if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
715cdf0e10cSrcweir 	{
716cdf0e10cSrcweir 		const Point* pPos = NULL;
717cdf0e10cSrcweir 
718cdf0e10cSrcweir 		if( rCEvt.IsMouseEvent() && ( GetRowAtYPosPixel( rCEvt.GetMousePosPixel().Y() ) != BROWSER_ENDOFSELECTION ) )
719cdf0e10cSrcweir 			pPos = &rCEvt.GetMousePosPixel();
720cdf0e10cSrcweir 
721cdf0e10cSrcweir 		( (GalleryBrowser2*) GetParent() )->ShowContextMenu( this, pPos );
722cdf0e10cSrcweir 	}
723cdf0e10cSrcweir }
724cdf0e10cSrcweir 
725cdf0e10cSrcweir // ------------------------------------------------------------------------
726cdf0e10cSrcweir 
727cdf0e10cSrcweir void GalleryListView::KeyInput( const KeyEvent& rKEvt )
728cdf0e10cSrcweir {
729cdf0e10cSrcweir     if( !mpTheme || !static_cast< GalleryBrowser2* >( GetParent() )->KeyInput( rKEvt, this ) )
730cdf0e10cSrcweir         BrowseBox::KeyInput( rKEvt );
731cdf0e10cSrcweir }
732cdf0e10cSrcweir 
733cdf0e10cSrcweir // ------------------------------------------------------------------------
734cdf0e10cSrcweir 
735cdf0e10cSrcweir void GalleryListView::DoubleClick( const BrowserMouseEvent& rEvt )
736cdf0e10cSrcweir {
737cdf0e10cSrcweir     BrowseBox::DoubleClick( rEvt );
738cdf0e10cSrcweir 
739cdf0e10cSrcweir     if( rEvt.GetRow() != BROWSER_ENDOFSELECTION )
740cdf0e10cSrcweir         ( (GalleryBrowser2*) GetParent() )->TogglePreview( this, &rEvt.GetPosPixel() );
741cdf0e10cSrcweir }
742cdf0e10cSrcweir 
743cdf0e10cSrcweir // ------------------------------------------------------------------------
744cdf0e10cSrcweir 
745cdf0e10cSrcweir void GalleryListView::Select()
746cdf0e10cSrcweir {
747cdf0e10cSrcweir     if( maSelectHdl.IsSet() )
748cdf0e10cSrcweir         maSelectHdl.Call( this );
749cdf0e10cSrcweir }
750cdf0e10cSrcweir 
751cdf0e10cSrcweir // ------------------------------------------------------------------------
752cdf0e10cSrcweir 
753cdf0e10cSrcweir sal_Int8 GalleryListView::AcceptDrop( const BrowserAcceptDropEvent& )
754cdf0e10cSrcweir {
755cdf0e10cSrcweir     sal_Int8 nRet = DND_ACTION_NONE;
756cdf0e10cSrcweir 
757cdf0e10cSrcweir    	if( mpTheme && !mpTheme->IsReadOnly() && !mpTheme ->IsImported() )
758cdf0e10cSrcweir 	{
759cdf0e10cSrcweir 		if( !mpTheme->IsDragging() )
760cdf0e10cSrcweir 			nRet = DND_ACTION_COPY;
761cdf0e10cSrcweir 		else
762cdf0e10cSrcweir 			nRet = DND_ACTION_COPY;
763cdf0e10cSrcweir 	}
764cdf0e10cSrcweir 
765cdf0e10cSrcweir 	return nRet;
766cdf0e10cSrcweir }
767cdf0e10cSrcweir 
768cdf0e10cSrcweir // ------------------------------------------------------------------------
769cdf0e10cSrcweir 
770cdf0e10cSrcweir sal_Int8 GalleryListView::ExecuteDrop( const BrowserExecuteDropEvent& rEvt )
771cdf0e10cSrcweir {
772cdf0e10cSrcweir     ExecuteDropEvent aEvt( rEvt );
773cdf0e10cSrcweir 
774cdf0e10cSrcweir     aEvt.maPosPixel.Y() += GetTitleHeight();
775cdf0e10cSrcweir 
776cdf0e10cSrcweir     return(	( (GalleryBrowser2*) GetParent() )->ExecuteDrop( *this, aEvt ) );
777cdf0e10cSrcweir }
778cdf0e10cSrcweir 
779cdf0e10cSrcweir // ------------------------------------------------------------------------
780cdf0e10cSrcweir 
781cdf0e10cSrcweir void GalleryListView::StartDrag( sal_Int8, const Point& rPosPixel )
782cdf0e10cSrcweir {
783cdf0e10cSrcweir     ( (GalleryBrowser2*) GetParent() )->StartDrag( this, &rPosPixel );
784cdf0e10cSrcweir }
785