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