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