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 // ------------------
DBG_NAME(GalleryPreview)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
GalleryPreview(Window * pParent,const ResId & rResId)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
~GalleryPreview()83cdf0e10cSrcweir GalleryPreview::~GalleryPreview()
84cdf0e10cSrcweir {
85cdf0e10cSrcweir
86cdf0e10cSrcweir DBG_DTOR(GalleryPreview,NULL);
87cdf0e10cSrcweir }
88cdf0e10cSrcweir
89cdf0e10cSrcweir
SetGraphic(const INetURLObject & _aURL)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
InitSettings()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
DataChanged(const DataChangedEvent & rDCEvt)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
ImplGetGraphicCenterRect(const Graphic & rGraphic,Rectangle & rResultRect) const132cdf0e10cSrcweir 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
Paint(const Rectangle & rRect)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
MouseButtonDown(const MouseEvent & rMEvt)185cdf0e10cSrcweir void GalleryPreview::MouseButtonDown( const MouseEvent& rMEvt )
186cdf0e10cSrcweir {
187cdf0e10cSrcweir if( mpTheme && ( rMEvt.GetClicks() == 2 ) )
188cdf0e10cSrcweir ( (GalleryBrowser2*) GetParent() )->TogglePreview( this );
189cdf0e10cSrcweir }
190cdf0e10cSrcweir
191cdf0e10cSrcweir // ------------------------------------------------------------------------
192cdf0e10cSrcweir
Command(const CommandEvent & rCEvt)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
KeyInput(const KeyEvent & rKEvt)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
AcceptDrop(const AcceptDropEvent & rEvt)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
ExecuteDrop(const ExecuteDropEvent & rEvt)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
StartDrag(sal_Int8,const Point &)276cdf0e10cSrcweir void GalleryPreview::StartDrag( sal_Int8, const Point& )
277cdf0e10cSrcweir {
278cdf0e10cSrcweir if( mpTheme )
279cdf0e10cSrcweir ( (GalleryBrowser2*) GetParent() )->StartDrag( this );
280cdf0e10cSrcweir }
281cdf0e10cSrcweir
282cdf0e10cSrcweir // ------------------------------------------------------------------------
283cdf0e10cSrcweir
PreviewMedia(const INetURLObject & rURL)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
drawTransparenceBackground(OutputDevice & rOut,const Point & rPos,const Size & rSize)30335726d9dSArmin Le Grand void drawTransparenceBackground(OutputDevice& rOut, const Point& rPos, const Size& rSize)
30435726d9dSArmin Le Grand {
30535726d9dSArmin Le Grand const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
30635726d9dSArmin Le Grand
30733b19716SArmin Le Grand if(rStyleSettings.GetPreviewUsesCheckeredBackground())
3086dd94783SArmin Le Grand {
3096dd94783SArmin Le Grand // draw checkered background
3106dd94783SArmin Le Grand static const sal_uInt32 nLen(8);
3116dd94783SArmin Le Grand static const Color aW(COL_WHITE);
3126dd94783SArmin Le Grand static const Color aG(0xef, 0xef, 0xef);
3136dd94783SArmin Le Grand
3146dd94783SArmin Le Grand rOut.DrawCheckered(rPos, rSize, nLen, aW, aG);
3156dd94783SArmin Le Grand }
31635726d9dSArmin Le Grand else
31735726d9dSArmin Le Grand {
31835726d9dSArmin Le Grand rOut.SetLineColor();
31935726d9dSArmin Le Grand rOut.SetFillColor(rStyleSettings.GetFieldColor());
32035726d9dSArmin Le Grand rOut.DrawRect(Rectangle(rPos, rSize));
32135726d9dSArmin Le Grand }
32235726d9dSArmin Le Grand }
3236dd94783SArmin Le Grand
324cdf0e10cSrcweir // -------------------
325cdf0e10cSrcweir // - GalleryIconView -
326cdf0e10cSrcweir // -------------------
DBG_NAME(GalleryIconView)327cdf0e10cSrcweir DBG_NAME(GalleryIconView)
328cdf0e10cSrcweir
329cdf0e10cSrcweir GalleryIconView::GalleryIconView( GalleryBrowser2* pParent, GalleryTheme* pTheme ) :
330cdf0e10cSrcweir ValueSet( pParent, WB_TABSTOP | WB_3DLOOK | WB_BORDER | WB_ITEMBORDER | WB_DOUBLEBORDER | WB_VSCROLL | WB_FLATVALUESET ),
331cdf0e10cSrcweir DropTargetHelper( this ),
332cdf0e10cSrcweir DragSourceHelper( this ),
333cdf0e10cSrcweir mpTheme ( pTheme )
334cdf0e10cSrcweir {
335cdf0e10cSrcweir DBG_CTOR(GalleryIconView,NULL);
336cdf0e10cSrcweir EnableFullItemMode( sal_False );
337cdf0e10cSrcweir
338cdf0e10cSrcweir SetHelpId( HID_GALLERY_WINDOW );
339cdf0e10cSrcweir InitSettings();
340cdf0e10cSrcweir SetExtraSpacing( 2 );
341cdf0e10cSrcweir SetItemWidth( S_THUMB + 6 );
342cdf0e10cSrcweir SetItemHeight( S_THUMB + 6 );
343cdf0e10cSrcweir }
344cdf0e10cSrcweir
345cdf0e10cSrcweir // ------------------------------------------------------------------------
346cdf0e10cSrcweir
~GalleryIconView()347cdf0e10cSrcweir GalleryIconView::~GalleryIconView()
348cdf0e10cSrcweir {
349cdf0e10cSrcweir
350cdf0e10cSrcweir DBG_DTOR(GalleryIconView,NULL);
351cdf0e10cSrcweir }
352cdf0e10cSrcweir
353cdf0e10cSrcweir // ------------------------------------------------------------------------
354cdf0e10cSrcweir
InitSettings()355cdf0e10cSrcweir void GalleryIconView::InitSettings()
356cdf0e10cSrcweir {
357cdf0e10cSrcweir SetBackground( Wallpaper( GALLERY_BG_COLOR ) );
358cdf0e10cSrcweir SetControlBackground( GALLERY_BG_COLOR );
359cdf0e10cSrcweir SetControlForeground( GALLERY_FG_COLOR );
360cdf0e10cSrcweir SetColor( GALLERY_BG_COLOR );
361cdf0e10cSrcweir }
362cdf0e10cSrcweir
363cdf0e10cSrcweir // -----------------------------------------------------------------------
364cdf0e10cSrcweir
DataChanged(const DataChangedEvent & rDCEvt)365cdf0e10cSrcweir void GalleryIconView::DataChanged( const DataChangedEvent& rDCEvt )
366cdf0e10cSrcweir {
367cdf0e10cSrcweir if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
368cdf0e10cSrcweir InitSettings();
369cdf0e10cSrcweir else
370cdf0e10cSrcweir ValueSet::DataChanged( rDCEvt );
371cdf0e10cSrcweir }
372cdf0e10cSrcweir
373cdf0e10cSrcweir // ------------------------------------------------------------------------
374cdf0e10cSrcweir
UserDraw(const UserDrawEvent & rUDEvt)375cdf0e10cSrcweir void GalleryIconView::UserDraw( const UserDrawEvent& rUDEvt )
376cdf0e10cSrcweir {
377cdf0e10cSrcweir const sal_uInt16 nId = rUDEvt.GetItemId();
378cdf0e10cSrcweir
379cdf0e10cSrcweir if( nId && mpTheme )
380cdf0e10cSrcweir {
381*21b36550SArmin Le Grand const Rectangle& rRect = rUDEvt.GetRect();
382*21b36550SArmin Le Grand const Size aSize(rRect.GetWidth(), rRect.GetHeight());
383*21b36550SArmin Le Grand BitmapEx aBitmapEx;
384*21b36550SArmin Le Grand Size aPreparedSize;
385*21b36550SArmin Le Grand String aItemTextTitle;
386*21b36550SArmin Le Grand String aItemTextPath;
387*21b36550SArmin Le Grand
388*21b36550SArmin Le Grand mpTheme->GetPreviewBitmapExAndStrings(nId - 1, aBitmapEx, aPreparedSize, aItemTextTitle, aItemTextPath);
389*21b36550SArmin Le Grand
390*21b36550SArmin Le Grand bool bNeedToCreate(aBitmapEx.IsEmpty());
391*21b36550SArmin Le Grand
392*21b36550SArmin Le Grand if(!bNeedToCreate && !aItemTextTitle.Len())
393*21b36550SArmin Le Grand {
394*21b36550SArmin Le Grand bNeedToCreate = true;
395*21b36550SArmin Le Grand }
396*21b36550SArmin Le Grand
397*21b36550SArmin Le Grand if(!bNeedToCreate && aPreparedSize != aSize)
398*21b36550SArmin Le Grand {
399*21b36550SArmin Le Grand bNeedToCreate = true;
400*21b36550SArmin Le Grand }
401*21b36550SArmin Le Grand
402*21b36550SArmin Le Grand if(bNeedToCreate)
403*21b36550SArmin Le Grand {
404cdf0e10cSrcweir SgaObject* pObj = mpTheme->AcquireObject(nId - 1);
405cdf0e10cSrcweir
406cdf0e10cSrcweir if(pObj)
407cdf0e10cSrcweir {
408*21b36550SArmin Le Grand aBitmapEx = pObj->createPreviewBitmapEx(aSize);
409*21b36550SArmin Le Grand aItemTextTitle = GalleryBrowser2::GetItemText(*mpTheme, *pObj, GALLERY_ITEM_TITLE);
410cdf0e10cSrcweir
411*21b36550SArmin Le Grand mpTheme->SetPreviewBitmapExAndStrings(nId - 1, aBitmapEx, aSize, aItemTextTitle, aItemTextPath);
412cdf0e10cSrcweir mpTheme->ReleaseObject(pObj);
413cdf0e10cSrcweir }
414cdf0e10cSrcweir }
415*21b36550SArmin Le Grand
416*21b36550SArmin Le Grand if(!aBitmapEx.IsEmpty())
417*21b36550SArmin Le Grand {
418*21b36550SArmin Le Grand const Size aBitmapExSizePixel(aBitmapEx.GetSizePixel());
419*21b36550SArmin Le Grand const Point aPos(
420*21b36550SArmin Le Grand ((aSize.Width() - aBitmapExSizePixel.Width()) >> 1) + rRect.Left(),
421*21b36550SArmin Le Grand ((aSize.Height() - aBitmapExSizePixel.Height()) >> 1) + rRect.Top());
422*21b36550SArmin Le Grand OutputDevice* pDev = rUDEvt.GetDevice();
423*21b36550SArmin Le Grand
424*21b36550SArmin Le Grand if(aBitmapEx.IsTransparent())
425*21b36550SArmin Le Grand {
426*21b36550SArmin Le Grand // draw checkered background
427*21b36550SArmin Le Grand drawTransparenceBackground(*pDev, aPos, aBitmapExSizePixel);
428*21b36550SArmin Le Grand }
429*21b36550SArmin Le Grand
430*21b36550SArmin Le Grand pDev->DrawBitmapEx(aPos, aBitmapEx);
431*21b36550SArmin Le Grand }
432*21b36550SArmin Le Grand
433*21b36550SArmin Le Grand SetItemText(nId, aItemTextTitle);
434*21b36550SArmin Le Grand
435*21b36550SArmin Le Grand //SgaObject* pObj = mpTheme->AcquireObject( nId - 1 );
436*21b36550SArmin Le Grand //
437*21b36550SArmin Le Grand //if( pObj )
438*21b36550SArmin Le Grand //{
439*21b36550SArmin Le Grand // const Rectangle& rRect = rUDEvt.GetRect();
440*21b36550SArmin Le Grand // const Size aSize(rRect.GetWidth(), rRect.GetHeight());
441*21b36550SArmin Le Grand // const BitmapEx aBitmapEx(pObj->createPreviewBitmapEx(aSize));
442*21b36550SArmin Le Grand // const Size aBitmapExSizePixel(aBitmapEx.GetSizePixel());
443*21b36550SArmin Le Grand //
444*21b36550SArmin Le Grand // if(!aBitmapEx.IsEmpty())
445*21b36550SArmin Le Grand // {
446*21b36550SArmin Le Grand // const Point aPos(
447*21b36550SArmin Le Grand // ((aSize.Width() - aBitmapExSizePixel.Width()) >> 1) + rRect.Left(),
448*21b36550SArmin Le Grand // ((aSize.Height() - aBitmapExSizePixel.Height()) >> 1) + rRect.Top());
449*21b36550SArmin Le Grand // OutputDevice* pDev = rUDEvt.GetDevice();
450*21b36550SArmin Le Grand //
451*21b36550SArmin Le Grand // if(aBitmapEx.IsTransparent())
452*21b36550SArmin Le Grand // {
453*21b36550SArmin Le Grand // // draw checkered background
454*21b36550SArmin Le Grand // drawTransparenceBackground(*pDev, aPos, aBitmapExSizePixel);
455*21b36550SArmin Le Grand // }
456*21b36550SArmin Le Grand //
457*21b36550SArmin Le Grand // pDev->DrawBitmapEx(aPos, aBitmapEx);
458*21b36550SArmin Le Grand // }
459*21b36550SArmin Le Grand //
460*21b36550SArmin Le Grand // //const Rectangle& rRect = rUDEvt.GetRect();
461*21b36550SArmin Le Grand // //OutputDevice* pDev = rUDEvt.GetDevice();
462*21b36550SArmin Le Grand // //Graphic aGraphic;
463*21b36550SArmin Le Grand // //bool bTransparent(false);
464*21b36550SArmin Le Grand // //
465*21b36550SArmin Le Grand // //if( pObj->IsThumbBitmap() )
466*21b36550SArmin Le Grand // //{
467*21b36550SArmin Le Grand // // BitmapEx aBitmapEx;
468*21b36550SArmin Le Grand // //
469*21b36550SArmin Le Grand // // if( pObj->GetObjKind() == SGA_OBJ_SOUND )
470*21b36550SArmin Le Grand // // {
471*21b36550SArmin Le Grand // // Bitmap aTemp = pObj->GetThumbBmp().GetBitmap();
472*21b36550SArmin Le Grand // //
473*21b36550SArmin Le Grand // // aTemp.Replace( COL_LIGHTMAGENTA, COL_WHITE );
474*21b36550SArmin Le Grand // // aBitmapEx = BitmapEx(aTemp);
475*21b36550SArmin Le Grand // // }
476*21b36550SArmin Le Grand // // else
477*21b36550SArmin Le Grand // // {
478*21b36550SArmin Le Grand // // aBitmapEx = pObj->GetThumbBmp();
479*21b36550SArmin Le Grand // // bTransparent = aBitmapEx.IsTransparent();
480*21b36550SArmin Le Grand // // }
481*21b36550SArmin Le Grand // //
482*21b36550SArmin Le Grand // // if( ( pDev->GetBitCount() <= 8 ) && ( aBitmapEx.GetBitCount() >= 8 ) )
483*21b36550SArmin Le Grand // // {
484*21b36550SArmin Le Grand // // aBitmapEx.Dither( BMP_DITHER_FLOYD );
485*21b36550SArmin Le Grand // // }
486*21b36550SArmin Le Grand // //
487*21b36550SArmin Le Grand // // aGraphic = aBitmapEx;
488*21b36550SArmin Le Grand // //}
489*21b36550SArmin Le Grand // //else
490*21b36550SArmin Le Grand // //{
491*21b36550SArmin Le Grand // // aGraphic = pObj->GetThumbMtf();
492*21b36550SArmin Le Grand // // bTransparent = true;
493*21b36550SArmin Le Grand // //}
494*21b36550SArmin Le Grand // //
495*21b36550SArmin Le Grand // //Size aSize( aGraphic.GetSizePixel( pDev ) );
496*21b36550SArmin Le Grand // //
497*21b36550SArmin Le Grand // //if ( aSize.Width() && aSize.Height() )
498*21b36550SArmin Le Grand // //{
499*21b36550SArmin Le Grand // // if( ( aSize.Width() > rRect.GetWidth() ) || ( aSize.Height() > rRect.GetHeight() ) )
500*21b36550SArmin Le Grand // // {
501*21b36550SArmin Le Grand // // Point aNewPos;
502*21b36550SArmin Le Grand // // const double fBmpWH = (double) aSize.Width() / aSize.Height();
503*21b36550SArmin Le Grand // // const double fThmpWH = (double) rRect.GetWidth() / rRect.GetHeight();
504*21b36550SArmin Le Grand // //
505*21b36550SArmin Le Grand // // // Bitmap an Thumbgroesse anpassen
506*21b36550SArmin Le Grand // // if ( fBmpWH < fThmpWH )
507*21b36550SArmin Le Grand // // {
508*21b36550SArmin Le Grand // // aSize.Width() = (long) ( rRect.GetHeight() * fBmpWH );
509*21b36550SArmin Le Grand // // aSize.Height()= rRect.GetHeight();
510*21b36550SArmin Le Grand // // }
511*21b36550SArmin Le Grand // // else
512*21b36550SArmin Le Grand // // {
513*21b36550SArmin Le Grand // // aSize.Width() = rRect.GetWidth();
514*21b36550SArmin Le Grand // // aSize.Height()= (long) ( rRect.GetWidth() / fBmpWH );
515*21b36550SArmin Le Grand // // }
516*21b36550SArmin Le Grand // // }
517*21b36550SArmin Le Grand // //
518*21b36550SArmin Le Grand // // const Point aPos( ( ( rRect.GetWidth() - aSize.Width() ) >> 1 ) + rRect.Left(),
519*21b36550SArmin Le Grand // // ( ( rRect.GetHeight() - aSize.Height() ) >> 1 ) + rRect.Top() );
520*21b36550SArmin Le Grand // //
521*21b36550SArmin Le Grand // // if(bTransparent)
522*21b36550SArmin Le Grand // // {
523*21b36550SArmin Le Grand // // // draw checkered background
524*21b36550SArmin Le Grand // // drawTransparenceBackground(*pDev, aPos, aSize);
525*21b36550SArmin Le Grand // // }
526*21b36550SArmin Le Grand // //
527*21b36550SArmin Le Grand // // aGraphic.Draw( pDev, aPos, aSize );
528*21b36550SArmin Le Grand // //}
529*21b36550SArmin Le Grand //
530*21b36550SArmin Le Grand // SetItemText( nId, GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_TITLE) );
531*21b36550SArmin Le Grand // mpTheme->ReleaseObject( pObj );
532*21b36550SArmin Le Grand //}
533*21b36550SArmin Le Grand }
534cdf0e10cSrcweir }
535cdf0e10cSrcweir
536cdf0e10cSrcweir // ------------------------------------------------------------------------
537cdf0e10cSrcweir
MouseButtonDown(const MouseEvent & rMEvt)538cdf0e10cSrcweir void GalleryIconView::MouseButtonDown( const MouseEvent& rMEvt )
539cdf0e10cSrcweir {
540cdf0e10cSrcweir ValueSet::MouseButtonDown( rMEvt );
541cdf0e10cSrcweir
542cdf0e10cSrcweir if( rMEvt.GetClicks() == 2 )
543cdf0e10cSrcweir ( (GalleryBrowser2*) GetParent() )->TogglePreview( this, &rMEvt.GetPosPixel() );
544cdf0e10cSrcweir }
545cdf0e10cSrcweir
546cdf0e10cSrcweir // ------------------------------------------------------------------------
547cdf0e10cSrcweir
Command(const CommandEvent & rCEvt)548cdf0e10cSrcweir void GalleryIconView::Command( const CommandEvent& rCEvt )
549cdf0e10cSrcweir {
550cdf0e10cSrcweir ValueSet::Command( rCEvt );
551cdf0e10cSrcweir
552cdf0e10cSrcweir if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
553cdf0e10cSrcweir {
554cdf0e10cSrcweir ( (GalleryBrowser2*) GetParent() )->ShowContextMenu( this,
555cdf0e10cSrcweir ( rCEvt.IsMouseEvent() ? &rCEvt.GetMousePosPixel() : NULL ) );
556cdf0e10cSrcweir }
557cdf0e10cSrcweir }
558cdf0e10cSrcweir
559cdf0e10cSrcweir // ------------------------------------------------------------------------
560cdf0e10cSrcweir
KeyInput(const KeyEvent & rKEvt)561cdf0e10cSrcweir void GalleryIconView::KeyInput( const KeyEvent& rKEvt )
562cdf0e10cSrcweir {
563cdf0e10cSrcweir if( !mpTheme || !static_cast< GalleryBrowser2* >( GetParent() )->KeyInput( rKEvt, this ) )
564cdf0e10cSrcweir ValueSet::KeyInput( rKEvt );
565cdf0e10cSrcweir }
566cdf0e10cSrcweir
567cdf0e10cSrcweir // ------------------------------------------------------------------------
568cdf0e10cSrcweir
AcceptDrop(const AcceptDropEvent & rEvt)569cdf0e10cSrcweir sal_Int8 GalleryIconView::AcceptDrop( const AcceptDropEvent& rEvt )
570cdf0e10cSrcweir {
571cdf0e10cSrcweir return( static_cast< GalleryBrowser2* >( GetParent() )->AcceptDrop( *this, rEvt ) );
572cdf0e10cSrcweir }
573cdf0e10cSrcweir
574cdf0e10cSrcweir // ------------------------------------------------------------------------
575cdf0e10cSrcweir
ExecuteDrop(const ExecuteDropEvent & rEvt)576cdf0e10cSrcweir sal_Int8 GalleryIconView::ExecuteDrop( const ExecuteDropEvent& rEvt )
577cdf0e10cSrcweir {
578cdf0e10cSrcweir return( static_cast< GalleryBrowser2* >( GetParent() )->ExecuteDrop( *this, rEvt ) );
579cdf0e10cSrcweir }
580cdf0e10cSrcweir
581cdf0e10cSrcweir // ------------------------------------------------------------------------
582cdf0e10cSrcweir
StartDrag(sal_Int8,const Point &)583cdf0e10cSrcweir void GalleryIconView::StartDrag( sal_Int8, const Point& )
584cdf0e10cSrcweir {
585cdf0e10cSrcweir const CommandEvent aEvt( GetPointerPosPixel(), COMMAND_STARTDRAG, sal_True );
586cdf0e10cSrcweir Region aRegion;
587cdf0e10cSrcweir
588cdf0e10cSrcweir // call this to initiate dragging for ValueSet
589cdf0e10cSrcweir ValueSet::StartDrag( aEvt, aRegion );
590cdf0e10cSrcweir static_cast< GalleryBrowser2* >( GetParent() )->StartDrag( this );
591cdf0e10cSrcweir }
592cdf0e10cSrcweir
593cdf0e10cSrcweir // -------------------
594cdf0e10cSrcweir // - GalleryListView -
595cdf0e10cSrcweir // -------------------
DBG_NAME(GalleryListView)596cdf0e10cSrcweir DBG_NAME(GalleryListView)
597cdf0e10cSrcweir
598cdf0e10cSrcweir GalleryListView::GalleryListView( GalleryBrowser2* pParent, GalleryTheme* pTheme ) :
599cdf0e10cSrcweir BrowseBox( pParent, WB_TABSTOP | WB_3DLOOK | WB_BORDER ),
600cdf0e10cSrcweir mpTheme( pTheme ),
601cdf0e10cSrcweir mnCurRow( 0 ),
602cdf0e10cSrcweir mbInit( sal_False )
603cdf0e10cSrcweir {
604cdf0e10cSrcweir DBG_CTOR(GalleryListView,NULL);
605cdf0e10cSrcweir
606cdf0e10cSrcweir SetHelpId( HID_GALLERY_WINDOW );
607cdf0e10cSrcweir
608cdf0e10cSrcweir InitSettings();
609cdf0e10cSrcweir
610cdf0e10cSrcweir SetMode( BROWSER_AUTO_VSCROLL | BROWSER_AUTOSIZE_LASTCOL );
611cdf0e10cSrcweir SetDataRowHeight( 28 );
612cdf0e10cSrcweir InsertDataColumn( GALLERY_BRWBOX_TITLE, String( GAL_RESID( RID_SVXSTR_GALLERY_TITLE ) ), 256 );
613cdf0e10cSrcweir InsertDataColumn( GALLERY_BRWBOX_PATH, String( GAL_RESID( RID_SVXSTR_GALLERY_PATH ) ), 256 );
614cdf0e10cSrcweir }
615cdf0e10cSrcweir
616cdf0e10cSrcweir // ------------------------------------------------------------------------
617cdf0e10cSrcweir
~GalleryListView()618cdf0e10cSrcweir GalleryListView::~GalleryListView()
619cdf0e10cSrcweir {
620cdf0e10cSrcweir
621cdf0e10cSrcweir DBG_DTOR(GalleryListView,NULL);
622cdf0e10cSrcweir }
623cdf0e10cSrcweir
624cdf0e10cSrcweir // ------------------------------------------------------------------------
625cdf0e10cSrcweir
InitSettings()626cdf0e10cSrcweir void GalleryListView::InitSettings()
627cdf0e10cSrcweir {
628cdf0e10cSrcweir SetBackground( Wallpaper( GALLERY_BG_COLOR ) );
629cdf0e10cSrcweir SetControlBackground( GALLERY_BG_COLOR );
630cdf0e10cSrcweir SetControlForeground( GALLERY_FG_COLOR );
631cdf0e10cSrcweir }
632cdf0e10cSrcweir
633cdf0e10cSrcweir // -----------------------------------------------------------------------
634cdf0e10cSrcweir
DataChanged(const DataChangedEvent & rDCEvt)635cdf0e10cSrcweir void GalleryListView::DataChanged( const DataChangedEvent& rDCEvt )
636cdf0e10cSrcweir {
637cdf0e10cSrcweir if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
638cdf0e10cSrcweir InitSettings();
639cdf0e10cSrcweir else
640cdf0e10cSrcweir BrowseBox::DataChanged( rDCEvt );
641cdf0e10cSrcweir }
642cdf0e10cSrcweir
643cdf0e10cSrcweir // ------------------------------------------------------------------------
644cdf0e10cSrcweir
SeekRow(long nRow)645cdf0e10cSrcweir sal_Bool GalleryListView::SeekRow( long nRow )
646cdf0e10cSrcweir {
647cdf0e10cSrcweir mnCurRow = nRow;
648cdf0e10cSrcweir return sal_True;
649cdf0e10cSrcweir }
650cdf0e10cSrcweir
651cdf0e10cSrcweir // -----------------------------------------------------------------------------
652cdf0e10cSrcweir
GetCellText(long _nRow,sal_uInt16 nColumnId) const653cdf0e10cSrcweir String GalleryListView::GetCellText(long _nRow, sal_uInt16 nColumnId) const
654cdf0e10cSrcweir {
655cdf0e10cSrcweir String sRet;
656cdf0e10cSrcweir if( mpTheme && ( _nRow < static_cast< long >( mpTheme->GetObjectCount() ) ) )
657cdf0e10cSrcweir {
658cdf0e10cSrcweir SgaObject* pObj = mpTheme->AcquireObject( _nRow );
659cdf0e10cSrcweir
660cdf0e10cSrcweir if( pObj )
661cdf0e10cSrcweir {
662cdf0e10cSrcweir sRet = GalleryBrowser2::GetItemText( *mpTheme, *pObj,
663cdf0e10cSrcweir ( GALLERY_BRWBOX_TITLE == nColumnId ) ? GALLERY_ITEM_TITLE : GALLERY_ITEM_PATH );
664cdf0e10cSrcweir
665cdf0e10cSrcweir mpTheme->ReleaseObject( pObj );
666cdf0e10cSrcweir }
667cdf0e10cSrcweir }
668cdf0e10cSrcweir
669cdf0e10cSrcweir return sRet;;
670cdf0e10cSrcweir }
671cdf0e10cSrcweir
672cdf0e10cSrcweir // -----------------------------------------------------------------------------
673cdf0e10cSrcweir
GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex)674cdf0e10cSrcweir Rectangle GalleryListView::GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex)
675cdf0e10cSrcweir {
676cdf0e10cSrcweir DBG_ASSERT(_nColumnPos >= 0 && _nColumnPos <= USHRT_MAX, "GalleryListView::GetFieldCharacterBounds: _nColumnId overflow");
677cdf0e10cSrcweir Rectangle aRect;
678cdf0e10cSrcweir if ( SeekRow(_nRow) )
679cdf0e10cSrcweir {
680cdf0e10cSrcweir SvxFont aFont( GetFont() );
681cdf0e10cSrcweir AccessibleStringWrap aStringWrap( *this, aFont, GetCellText(_nRow, sal::static_int_cast<sal_uInt16>( GetColumnId( sal::static_int_cast<sal_uInt16>(_nColumnPos) ) ) ) );
682cdf0e10cSrcweir
683cdf0e10cSrcweir // get the bounds inside the string
684cdf0e10cSrcweir aStringWrap.GetCharacterBounds(nIndex, aRect);
685cdf0e10cSrcweir
686cdf0e10cSrcweir // offset to
687cdf0e10cSrcweir }
688cdf0e10cSrcweir return aRect;
689cdf0e10cSrcweir }
690cdf0e10cSrcweir
691cdf0e10cSrcweir // -----------------------------------------------------------------------------
692cdf0e10cSrcweir
GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point & _rPoint)693cdf0e10cSrcweir sal_Int32 GalleryListView::GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint)
694cdf0e10cSrcweir {
695cdf0e10cSrcweir DBG_ASSERT(_nColumnPos >= 0 && _nColumnPos <= USHRT_MAX, "GalleryListView::GetFieldIndexAtPoint: _nColumnId overflow");
696cdf0e10cSrcweir sal_Int32 nRet = -1;
697cdf0e10cSrcweir if ( SeekRow(_nRow) )
698cdf0e10cSrcweir {
699cdf0e10cSrcweir SvxFont aFont( GetFont() );
700cdf0e10cSrcweir AccessibleStringWrap aStringWrap( *this, aFont, GetCellText(_nRow, sal::static_int_cast<sal_uInt16>(GetColumnId(sal::static_int_cast<sal_uInt16>(_nColumnPos)))) );
701cdf0e10cSrcweir nRet = aStringWrap.GetIndexAtPoint(_rPoint);
702cdf0e10cSrcweir }
703cdf0e10cSrcweir return nRet;
704cdf0e10cSrcweir }
705cdf0e10cSrcweir
706cdf0e10cSrcweir // ------------------------------------------------------------------------
707cdf0e10cSrcweir
PaintField(OutputDevice & rDev,const Rectangle & rRect,sal_uInt16 nColumnId) const708cdf0e10cSrcweir void GalleryListView::PaintField( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId ) const
709cdf0e10cSrcweir {
710cdf0e10cSrcweir rDev.Push( PUSH_CLIPREGION );
711cdf0e10cSrcweir rDev.IntersectClipRegion( rRect );
712cdf0e10cSrcweir
713cdf0e10cSrcweir if( mpTheme && ( mnCurRow < mpTheme->GetObjectCount() ) )
714cdf0e10cSrcweir {
715*21b36550SArmin Le Grand const Size aSize(rRect.GetHeight(), rRect.GetHeight());
716*21b36550SArmin Le Grand BitmapEx aBitmapEx;
717*21b36550SArmin Le Grand Size aPreparedSize;
718*21b36550SArmin Le Grand String aItemTextTitle;
719*21b36550SArmin Le Grand String aItemTextPath;
720*21b36550SArmin Le Grand
721*21b36550SArmin Le Grand mpTheme->GetPreviewBitmapExAndStrings(mnCurRow, aBitmapEx, aPreparedSize, aItemTextTitle, aItemTextPath);
722*21b36550SArmin Le Grand
723*21b36550SArmin Le Grand bool bNeedToCreate(aBitmapEx.IsEmpty());
724*21b36550SArmin Le Grand
725*21b36550SArmin Le Grand if(!bNeedToCreate && GALLERY_BRWBOX_TITLE == nColumnId && !aItemTextTitle.Len())
726*21b36550SArmin Le Grand {
727*21b36550SArmin Le Grand bNeedToCreate = true;
728*21b36550SArmin Le Grand }
729*21b36550SArmin Le Grand
730*21b36550SArmin Le Grand if(!bNeedToCreate && GALLERY_BRWBOX_PATH == nColumnId && !aItemTextPath.Len())
731*21b36550SArmin Le Grand {
732*21b36550SArmin Le Grand bNeedToCreate = true;
733*21b36550SArmin Le Grand }
734*21b36550SArmin Le Grand
735*21b36550SArmin Le Grand if(!bNeedToCreate && aPreparedSize != aSize)
736*21b36550SArmin Le Grand {
737*21b36550SArmin Le Grand bNeedToCreate = true;
738*21b36550SArmin Le Grand }
739*21b36550SArmin Le Grand
740*21b36550SArmin Le Grand if(bNeedToCreate)
741*21b36550SArmin Le Grand {
742cdf0e10cSrcweir SgaObject* pObj = mpTheme->AcquireObject(mnCurRow);
743cdf0e10cSrcweir
744cdf0e10cSrcweir if(pObj)
745cdf0e10cSrcweir {
746*21b36550SArmin Le Grand aBitmapEx = pObj->createPreviewBitmapEx(aSize);
747*21b36550SArmin Le Grand aItemTextTitle = GalleryBrowser2::GetItemText(*mpTheme, *pObj, GALLERY_ITEM_TITLE);
748*21b36550SArmin Le Grand aItemTextPath = GalleryBrowser2::GetItemText(*mpTheme, *pObj, GALLERY_ITEM_PATH);
749*21b36550SArmin Le Grand
750*21b36550SArmin Le Grand mpTheme->SetPreviewBitmapExAndStrings(mnCurRow, aBitmapEx, aSize, aItemTextTitle, aItemTextPath);
751*21b36550SArmin Le Grand mpTheme->ReleaseObject(pObj);
752*21b36550SArmin Le Grand }
753*21b36550SArmin Le Grand }
754*21b36550SArmin Le Grand
755*21b36550SArmin Le Grand const long nTextPosY(rRect.Top() + ((rRect.GetHeight() - rDev.GetTextHeight()) >> 1));
756cdf0e10cSrcweir
757cdf0e10cSrcweir if(GALLERY_BRWBOX_TITLE == nColumnId)
758cdf0e10cSrcweir {
759*21b36550SArmin Le Grand if(!aBitmapEx.IsEmpty())
7606dd94783SArmin Le Grand {
761*21b36550SArmin Le Grand const Size aBitmapExSizePixel(aBitmapEx.GetSizePixel());
762*21b36550SArmin Le Grand const Point aPos(
763*21b36550SArmin Le Grand ((aSize.Width() - aBitmapExSizePixel.Width()) >> 1) + rRect.Left(),
764*21b36550SArmin Le Grand ((aSize.Height() - aBitmapExSizePixel.Height()) >> 1) + rRect.Top());
7656dd94783SArmin Le Grand
766*21b36550SArmin Le Grand if(aBitmapEx.IsTransparent())
7676dd94783SArmin Le Grand {
7686dd94783SArmin Le Grand // draw checkered background
769*21b36550SArmin Le Grand drawTransparenceBackground(rDev, aPos, aBitmapExSizePixel);
7706dd94783SArmin Le Grand }
7716dd94783SArmin Le Grand
772*21b36550SArmin Le Grand rDev.DrawBitmapEx(aPos, aBitmapEx);
773cdf0e10cSrcweir }
774cdf0e10cSrcweir
775*21b36550SArmin Le Grand rDev.DrawText(Point(rRect.Left() + rRect.GetHeight() + 6, nTextPosY), aItemTextTitle);
776cdf0e10cSrcweir }
777cdf0e10cSrcweir else if(GALLERY_BRWBOX_PATH == nColumnId)
778*21b36550SArmin Le Grand {
779*21b36550SArmin Le Grand rDev.DrawText(Point(rRect.Left(), nTextPosY), aItemTextPath);
780cdf0e10cSrcweir }
781*21b36550SArmin Le Grand
782*21b36550SArmin Le Grand
783*21b36550SArmin Le Grand //SgaObject* pObj = mpTheme->AcquireObject( mnCurRow );
784*21b36550SArmin Le Grand //
785*21b36550SArmin Le Grand //if( pObj )
786*21b36550SArmin Le Grand //{
787*21b36550SArmin Le Grand // const long nTextPosY = rRect.Top() + ( ( rRect.GetHeight() - rDev.GetTextHeight() ) >> 1 );
788*21b36550SArmin Le Grand //
789*21b36550SArmin Le Grand // if( GALLERY_BRWBOX_TITLE == nColumnId )
790*21b36550SArmin Le Grand // {
791*21b36550SArmin Le Grand // const Size aSize(rRect.GetHeight(), rRect.GetHeight());
792*21b36550SArmin Le Grand // const BitmapEx aBitmapEx(pObj->createPreviewBitmapEx(aSize));
793*21b36550SArmin Le Grand // const Size aBitmapExSizePixel(aBitmapEx.GetSizePixel());
794*21b36550SArmin Le Grand //
795*21b36550SArmin Le Grand // if(!aBitmapEx.IsEmpty())
796*21b36550SArmin Le Grand // {
797*21b36550SArmin Le Grand // const Point aPos(
798*21b36550SArmin Le Grand // ((aSize.Width() - aBitmapExSizePixel.Width()) >> 1) + rRect.Left(),
799*21b36550SArmin Le Grand // ((aSize.Height() - aBitmapExSizePixel.Height()) >> 1) + rRect.Top());
800*21b36550SArmin Le Grand //
801*21b36550SArmin Le Grand // if(aBitmapEx.IsTransparent())
802*21b36550SArmin Le Grand // {
803*21b36550SArmin Le Grand // // draw checkered background
804*21b36550SArmin Le Grand // drawTransparenceBackground(rDev, aPos, aBitmapExSizePixel);
805*21b36550SArmin Le Grand // }
806*21b36550SArmin Le Grand //
807*21b36550SArmin Le Grand // rDev.DrawBitmapEx(aPos, aBitmapEx);
808*21b36550SArmin Le Grand // }
809*21b36550SArmin Le Grand //
810*21b36550SArmin Le Grand //
811*21b36550SArmin Le Grand // //Rectangle aOutputRect( rRect.TopLeft(), Size( rRect.GetHeight(), rRect.GetHeight() ) );
812*21b36550SArmin Le Grand // //GraphicObject aGrfObj;
813*21b36550SArmin Le Grand // //bool bTransparent(false);
814*21b36550SArmin Le Grand // //
815*21b36550SArmin Le Grand // //if( pObj->GetObjKind() == SGA_OBJ_SOUND )
816*21b36550SArmin Le Grand // //{
817*21b36550SArmin Le Grand // // aGrfObj = Graphic( BitmapEx( GAL_RESID( RID_SVXBMP_GALLERY_MEDIA ) ) );
818*21b36550SArmin Le Grand // //}
819*21b36550SArmin Le Grand // //else if( pObj->IsThumbBitmap() )
820*21b36550SArmin Le Grand // //{
821*21b36550SArmin Le Grand // // const BitmapEx aBitmapEx(pObj->GetThumbBmp());
822*21b36550SArmin Le Grand // //
823*21b36550SArmin Le Grand // // bTransparent = aBitmapEx.IsTransparent();
824*21b36550SArmin Le Grand // // aGrfObj = Graphic(aBitmapEx);
825*21b36550SArmin Le Grand // //}
826*21b36550SArmin Le Grand // //else
827*21b36550SArmin Le Grand // //{
828*21b36550SArmin Le Grand // // aGrfObj = Graphic( pObj->GetThumbMtf() );
829*21b36550SArmin Le Grand // // bTransparent = true;
830*21b36550SArmin Le Grand // //}
831*21b36550SArmin Le Grand // //
832*21b36550SArmin Le Grand // //Size aSize( rDev.LogicToPixel( aGrfObj.GetPrefSize(), aGrfObj.GetPrefMapMode() ) );
833*21b36550SArmin Le Grand // //
834*21b36550SArmin Le Grand // //if( aSize.Width() && aSize.Height() )
835*21b36550SArmin Le Grand // //{
836*21b36550SArmin Le Grand // // if( ( aSize.Width() > aOutputRect.GetWidth() ) || ( aSize.Height() > aOutputRect.GetHeight() ) )
837*21b36550SArmin Le Grand // // {
838*21b36550SArmin Le Grand // // Point aNewPos;
839*21b36550SArmin Le Grand // // const double fBmpWH = (double) aSize.Width() / aSize.Height();
840*21b36550SArmin Le Grand // // const double fThmpWH = (double) aOutputRect.GetWidth() / aOutputRect.GetHeight();
841*21b36550SArmin Le Grand // //
842*21b36550SArmin Le Grand // // // Bitmap an Thumbgroesse anpassen
843*21b36550SArmin Le Grand // // if ( fBmpWH < fThmpWH )
844*21b36550SArmin Le Grand // // {
845*21b36550SArmin Le Grand // // aSize.Width() = (long) ( aOutputRect.GetHeight() * fBmpWH );
846*21b36550SArmin Le Grand // // aSize.Height()= aOutputRect.GetHeight();
847*21b36550SArmin Le Grand // // }
848*21b36550SArmin Le Grand // // else
849*21b36550SArmin Le Grand // // {
850*21b36550SArmin Le Grand // // aSize.Width() = aOutputRect.GetWidth();
851*21b36550SArmin Le Grand // // aSize.Height()= (long) ( aOutputRect.GetWidth() / fBmpWH );
852*21b36550SArmin Le Grand // // }
853*21b36550SArmin Le Grand // // }
854*21b36550SArmin Le Grand // //
855*21b36550SArmin Le Grand // // aSize.Width() = Max( aSize.Width(), 4L );
856*21b36550SArmin Le Grand // // aSize.Height() = Max( aSize.Height(), 4L );
857*21b36550SArmin Le Grand // //
858*21b36550SArmin Le Grand // // const Point aPos( ( ( aOutputRect.GetWidth() - aSize.Width() ) >> 1 ) + aOutputRect.Left(),
859*21b36550SArmin Le Grand // // ( ( aOutputRect.GetHeight() - aSize.Height() ) >> 1 ) + aOutputRect.Top() );
860*21b36550SArmin Le Grand // //
861*21b36550SArmin Le Grand // // if(bTransparent)
862*21b36550SArmin Le Grand // // {
863*21b36550SArmin Le Grand // // // draw checkered background
864*21b36550SArmin Le Grand // // drawTransparenceBackground(rDev, aPos, aSize);
865*21b36550SArmin Le Grand // // }
866*21b36550SArmin Le Grand // //
867*21b36550SArmin Le Grand // // aGrfObj.Draw( &rDev, aPos, aSize );
868*21b36550SArmin Le Grand // //}
869*21b36550SArmin Le Grand //
870*21b36550SArmin Le Grand // // aOutputRect.Right() is here rRect.Left() + rRect.GetHeight()
871*21b36550SArmin Le Grand // rDev.DrawText( Point( rRect.Left() + rRect.GetHeight() + 6, nTextPosY ), GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_TITLE ) );
872*21b36550SArmin Le Grand // }
873*21b36550SArmin Le Grand // else if( GALLERY_BRWBOX_PATH == nColumnId )
874*21b36550SArmin Le Grand // {
875*21b36550SArmin Le Grand // rDev.DrawText( Point( rRect.Left(), nTextPosY ), GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_PATH ) );
876*21b36550SArmin Le Grand // }
877*21b36550SArmin Le Grand //
878*21b36550SArmin Le Grand // mpTheme->ReleaseObject( pObj );
879*21b36550SArmin Le Grand //}
880cdf0e10cSrcweir }
881cdf0e10cSrcweir
882cdf0e10cSrcweir rDev.Pop();
883cdf0e10cSrcweir }
884cdf0e10cSrcweir
885cdf0e10cSrcweir // ------------------------------------------------------------------------
886cdf0e10cSrcweir
Command(const CommandEvent & rCEvt)887cdf0e10cSrcweir void GalleryListView::Command( const CommandEvent& rCEvt )
888cdf0e10cSrcweir {
889cdf0e10cSrcweir BrowseBox::Command( rCEvt );
890cdf0e10cSrcweir
891cdf0e10cSrcweir if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
892cdf0e10cSrcweir {
893cdf0e10cSrcweir const Point* pPos = NULL;
894cdf0e10cSrcweir
895cdf0e10cSrcweir if( rCEvt.IsMouseEvent() && ( GetRowAtYPosPixel( rCEvt.GetMousePosPixel().Y() ) != BROWSER_ENDOFSELECTION ) )
896cdf0e10cSrcweir pPos = &rCEvt.GetMousePosPixel();
897cdf0e10cSrcweir
898cdf0e10cSrcweir ( (GalleryBrowser2*) GetParent() )->ShowContextMenu( this, pPos );
899cdf0e10cSrcweir }
900cdf0e10cSrcweir }
901cdf0e10cSrcweir
902cdf0e10cSrcweir // ------------------------------------------------------------------------
903cdf0e10cSrcweir
KeyInput(const KeyEvent & rKEvt)904cdf0e10cSrcweir void GalleryListView::KeyInput( const KeyEvent& rKEvt )
905cdf0e10cSrcweir {
906cdf0e10cSrcweir if( !mpTheme || !static_cast< GalleryBrowser2* >( GetParent() )->KeyInput( rKEvt, this ) )
907cdf0e10cSrcweir BrowseBox::KeyInput( rKEvt );
908cdf0e10cSrcweir }
909cdf0e10cSrcweir
910cdf0e10cSrcweir // ------------------------------------------------------------------------
911cdf0e10cSrcweir
DoubleClick(const BrowserMouseEvent & rEvt)912cdf0e10cSrcweir void GalleryListView::DoubleClick( const BrowserMouseEvent& rEvt )
913cdf0e10cSrcweir {
914cdf0e10cSrcweir BrowseBox::DoubleClick( rEvt );
915cdf0e10cSrcweir
916cdf0e10cSrcweir if( rEvt.GetRow() != BROWSER_ENDOFSELECTION )
917cdf0e10cSrcweir ( (GalleryBrowser2*) GetParent() )->TogglePreview( this, &rEvt.GetPosPixel() );
918cdf0e10cSrcweir }
919cdf0e10cSrcweir
920cdf0e10cSrcweir // ------------------------------------------------------------------------
921cdf0e10cSrcweir
Select()922cdf0e10cSrcweir void GalleryListView::Select()
923cdf0e10cSrcweir {
924cdf0e10cSrcweir if( maSelectHdl.IsSet() )
925cdf0e10cSrcweir maSelectHdl.Call( this );
926cdf0e10cSrcweir }
927cdf0e10cSrcweir
928cdf0e10cSrcweir // ------------------------------------------------------------------------
929cdf0e10cSrcweir
AcceptDrop(const BrowserAcceptDropEvent &)930cdf0e10cSrcweir sal_Int8 GalleryListView::AcceptDrop( const BrowserAcceptDropEvent& )
931cdf0e10cSrcweir {
932cdf0e10cSrcweir sal_Int8 nRet = DND_ACTION_NONE;
933cdf0e10cSrcweir
934cdf0e10cSrcweir if( mpTheme && !mpTheme->IsReadOnly() && !mpTheme ->IsImported() )
935cdf0e10cSrcweir {
936cdf0e10cSrcweir if( !mpTheme->IsDragging() )
937cdf0e10cSrcweir nRet = DND_ACTION_COPY;
938cdf0e10cSrcweir else
939cdf0e10cSrcweir nRet = DND_ACTION_COPY;
940cdf0e10cSrcweir }
941cdf0e10cSrcweir
942cdf0e10cSrcweir return nRet;
943cdf0e10cSrcweir }
944cdf0e10cSrcweir
945cdf0e10cSrcweir // ------------------------------------------------------------------------
946cdf0e10cSrcweir
ExecuteDrop(const BrowserExecuteDropEvent & rEvt)947cdf0e10cSrcweir sal_Int8 GalleryListView::ExecuteDrop( const BrowserExecuteDropEvent& rEvt )
948cdf0e10cSrcweir {
949cdf0e10cSrcweir ExecuteDropEvent aEvt( rEvt );
950cdf0e10cSrcweir
951cdf0e10cSrcweir aEvt.maPosPixel.Y() += GetTitleHeight();
952cdf0e10cSrcweir
953cdf0e10cSrcweir return( ( (GalleryBrowser2*) GetParent() )->ExecuteDrop( *this, aEvt ) );
954cdf0e10cSrcweir }
955cdf0e10cSrcweir
956cdf0e10cSrcweir // ------------------------------------------------------------------------
957cdf0e10cSrcweir
StartDrag(sal_Int8,const Point & rPosPixel)958cdf0e10cSrcweir void GalleryListView::StartDrag( sal_Int8, const Point& rPosPixel )
959cdf0e10cSrcweir {
960cdf0e10cSrcweir ( (GalleryBrowser2*) GetParent() )->StartDrag( this, &rPosPixel );
961cdf0e10cSrcweir }
962