1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_svtools.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <svtools/ivctrl.hxx> 32*cdf0e10cSrcweir #include "imivctl.hxx" 33*cdf0e10cSrcweir #include <vcl/bitmapex.hxx> 34*cdf0e10cSrcweir #include <vcl/controllayout.hxx> 35*cdf0e10cSrcweir #include <vcl/mnemonic.hxx> 36*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir /***************************************************************************** 39*cdf0e10cSrcweir | 40*cdf0e10cSrcweir | class : SvxIconChoiceCtrlEntry 41*cdf0e10cSrcweir | 42*cdf0e10cSrcweir \*****************************************************************************/ 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir SvxIconChoiceCtrlEntry::SvxIconChoiceCtrlEntry( const String& rText, const Image& rImage, sal_uInt16 _nFlags ) 45*cdf0e10cSrcweir { 46*cdf0e10cSrcweir aText = rText; 47*cdf0e10cSrcweir aImage = rImage; 48*cdf0e10cSrcweir aImageHC = rImage; 49*cdf0e10cSrcweir pUserData = NULL; 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir nFlags = _nFlags; 52*cdf0e10cSrcweir eTextMode = IcnShowTextShort; 53*cdf0e10cSrcweir pblink = 0; 54*cdf0e10cSrcweir pflink = 0; 55*cdf0e10cSrcweir } 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir SvxIconChoiceCtrlEntry::SvxIconChoiceCtrlEntry( const String& rText, const Image& rImage, const Image& rImageHC, sal_uInt16 _nFlags ) 58*cdf0e10cSrcweir { 59*cdf0e10cSrcweir aText = rText; 60*cdf0e10cSrcweir aImage = rImage; 61*cdf0e10cSrcweir aImageHC = rImageHC; 62*cdf0e10cSrcweir pUserData = NULL; 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir nFlags = _nFlags; 65*cdf0e10cSrcweir eTextMode = IcnShowTextShort; 66*cdf0e10cSrcweir pblink = 0; 67*cdf0e10cSrcweir pflink = 0; 68*cdf0e10cSrcweir } 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir SvxIconChoiceCtrlEntry::SvxIconChoiceCtrlEntry( sal_uInt16 _nFlags ) 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir pUserData = NULL; 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir nFlags = _nFlags; 75*cdf0e10cSrcweir eTextMode = IcnShowTextShort; 76*cdf0e10cSrcweir pblink = 0; 77*cdf0e10cSrcweir pflink = 0; 78*cdf0e10cSrcweir } 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir void SvxIconChoiceCtrlEntry::SetMoved( sal_Bool bMoved ) 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir if( bMoved ) 83*cdf0e10cSrcweir nFlags |= ICNVIEW_FLAG_POS_MOVED; 84*cdf0e10cSrcweir else 85*cdf0e10cSrcweir nFlags &= ~ICNVIEW_FLAG_POS_MOVED; 86*cdf0e10cSrcweir } 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir void SvxIconChoiceCtrlEntry::LockPos( sal_Bool bLock ) 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir if( bLock ) 91*cdf0e10cSrcweir nFlags |= ICNVIEW_FLAG_POS_LOCKED; 92*cdf0e10cSrcweir else 93*cdf0e10cSrcweir nFlags &= ~ICNVIEW_FLAG_POS_LOCKED; 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir /*sal_Unicode SvxIconChoiceCtrlEntry::GetMnemonicChar() const 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir sal_Unicode cChar = 0; 99*cdf0e10cSrcweir xub_StrLen nPos = aText.Search( '~' ); 100*cdf0e10cSrcweir if ( nPos != STRING_NOTFOUND && nPos < ( aText.Len() ) - 1 ) 101*cdf0e10cSrcweir cChar = aText.GetChar( nPos + 1 ); 102*cdf0e10cSrcweir return cChar; 103*cdf0e10cSrcweir }*/ 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir String SvxIconChoiceCtrlEntry::GetDisplayText() const 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir return MnemonicGenerator::EraseAllMnemonicChars( aText ); 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir // ---------------------------------------------------------------------------- 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir SvxIconChoiceCtrlColumnInfo::SvxIconChoiceCtrlColumnInfo( const SvxIconChoiceCtrlColumnInfo& rInfo ) 113*cdf0e10cSrcweir : aColText( rInfo.aColText ), aColImage( rInfo.aColImage ) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir nWidth = rInfo.nWidth; 116*cdf0e10cSrcweir eAlignment = rInfo.eAlignment; 117*cdf0e10cSrcweir nSubItem = rInfo.nSubItem; 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir /***************************************************************************** 121*cdf0e10cSrcweir | 122*cdf0e10cSrcweir | class : SvtIconChoiceCtrl 123*cdf0e10cSrcweir | 124*cdf0e10cSrcweir \*****************************************************************************/ 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir SvtIconChoiceCtrl::SvtIconChoiceCtrl( Window* pParent, WinBits nWinStyle ) : 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir // WB_CLIPCHILDREN an, da ScrollBars auf dem Fenster liegen! 129*cdf0e10cSrcweir Control( pParent, nWinStyle | WB_CLIPCHILDREN ), 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir _pCurKeyEvent ( NULL ), 132*cdf0e10cSrcweir _pImp ( new SvxIconChoiceCtrl_Impl( this, nWinStyle ) ), 133*cdf0e10cSrcweir _bAutoFontColor ( sal_False ) 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir { 136*cdf0e10cSrcweir SetLineColor(); 137*cdf0e10cSrcweir _pImp->SetGrid( Size( 100, 70 ) ); 138*cdf0e10cSrcweir _pImp->InitSettings(); 139*cdf0e10cSrcweir _pImp->SetPositionMode( IcnViewPositionModeAutoArrange ); 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir SvtIconChoiceCtrl::SvtIconChoiceCtrl( Window* pParent, const ResId& rResId ) : 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir Control( pParent, rResId ), 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir _pCurKeyEvent ( NULL ), 147*cdf0e10cSrcweir _pImp ( new SvxIconChoiceCtrl_Impl( this, WB_BORDER ) ), 148*cdf0e10cSrcweir _bAutoFontColor ( sal_False ) 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir SetLineColor(); 152*cdf0e10cSrcweir _pImp->SetGrid( Size( 100, 70 ) ); 153*cdf0e10cSrcweir _pImp->InitSettings(); 154*cdf0e10cSrcweir _pImp->SetPositionMode( IcnViewPositionModeAutoArrange ); 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir SvtIconChoiceCtrl::~SvtIconChoiceCtrl() 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir _pImp->CallEventListeners( VCLEVENT_OBJECT_DYING ); 160*cdf0e10cSrcweir delete _pImp; 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* SvtIconChoiceCtrl::InsertEntry( sal_uLong nPos, const Point* pPos, sal_uInt16 nFlags ) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = new SvxIconChoiceCtrlEntry( nFlags ); 166*cdf0e10cSrcweir _pImp->InsertEntry( pEntry, nPos, pPos ); 167*cdf0e10cSrcweir return pEntry; 168*cdf0e10cSrcweir } 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* SvtIconChoiceCtrl::InsertEntry( const String& rText, const Image& rImage, sal_uLong nPos, const Point* pPos, sal_uInt16 nFlags ) 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = new SvxIconChoiceCtrlEntry( rText, rImage, nFlags); 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir _pImp->InsertEntry( pEntry, nPos, pPos ); 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir return pEntry; 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* SvtIconChoiceCtrl::InsertEntry( const String& rText, const Image& rImage, const Image& rImageHC, sal_uLong nPos, const Point* pPos, sal_uInt16 nFlags ) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = new SvxIconChoiceCtrlEntry( rText, rImage, rImageHC, nFlags); 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir _pImp->InsertEntry( pEntry, nPos, pPos ); 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir return pEntry; 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir sal_Bool SvtIconChoiceCtrl::EditedEntry( SvxIconChoiceCtrlEntry*, const XubString&, sal_Bool ) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir return sal_True; 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir sal_Bool SvtIconChoiceCtrl::EditingEntry( SvxIconChoiceCtrlEntry* ) 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir return sal_True; 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir void SvtIconChoiceCtrl::DrawEntryImage( SvxIconChoiceCtrlEntry* pEntry, const Point& rPos, OutputDevice& rDev ) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir rDev.DrawImage( rPos, GetSettings().GetStyleSettings().GetHighContrastMode() ? pEntry->GetImageHC() : pEntry->GetImage() ); 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir String SvtIconChoiceCtrl::GetEntryText( SvxIconChoiceCtrlEntry* pEntry, sal_Bool ) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir return pEntry->GetText(); 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir sal_Bool SvtIconChoiceCtrl::HasBackground() const 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir return sal_False; 207*cdf0e10cSrcweir } 208*cdf0e10cSrcweir sal_Bool SvtIconChoiceCtrl::HasFont() const 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir return sal_False; 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir sal_Bool SvtIconChoiceCtrl::HasFontTextColor() const 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir return sal_True; 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir sal_Bool SvtIconChoiceCtrl::HasFontFillColor() const 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir return sal_True; 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir void SvtIconChoiceCtrl::Paint( const Rectangle& rRect ) 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir _pImp->Paint( rRect ); 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir void SvtIconChoiceCtrl::MouseButtonDown( const MouseEvent& rMEvt ) 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir if( !_pImp->MouseButtonDown( rMEvt ) ) 229*cdf0e10cSrcweir Control::MouseButtonDown( rMEvt ); 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir void SvtIconChoiceCtrl::MouseButtonUp( const MouseEvent& rMEvt ) 233*cdf0e10cSrcweir { 234*cdf0e10cSrcweir if( !_pImp->MouseButtonUp( rMEvt ) ) 235*cdf0e10cSrcweir Control::MouseButtonUp( rMEvt ); 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir void SvtIconChoiceCtrl::MouseMove( const MouseEvent& rMEvt ) 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir if( !_pImp->MouseMove( rMEvt ) ) 241*cdf0e10cSrcweir Control::MouseMove( rMEvt ); 242*cdf0e10cSrcweir } 243*cdf0e10cSrcweir void SvtIconChoiceCtrl::ArrangeIcons() 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir if ( GetStyle() & WB_ALIGN_TOP ) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir Size aFullSize; 248*cdf0e10cSrcweir Rectangle aEntryRect; 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir for ( sal_uLong i = 0; i < GetEntryCount(); i++ ) 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = GetEntry ( i ); 253*cdf0e10cSrcweir aEntryRect = _pImp->GetEntryBoundRect ( pEntry ); 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir aFullSize.setWidth ( aFullSize.getWidth()+aEntryRect.GetWidth() ); 256*cdf0e10cSrcweir } 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir _pImp->Arrange ( sal_False, aFullSize.getWidth() ); 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir else if ( GetStyle() & WB_ALIGN_LEFT ) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir Size aFullSize; 263*cdf0e10cSrcweir Rectangle aEntryRect; 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir for ( sal_uLong i = 0; i < GetEntryCount(); i++ ) 266*cdf0e10cSrcweir { 267*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = GetEntry ( i ); 268*cdf0e10cSrcweir aEntryRect = _pImp->GetEntryBoundRect ( pEntry ); 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir aFullSize.setHeight ( aFullSize.getHeight()+aEntryRect.GetHeight() ); 271*cdf0e10cSrcweir } 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir _pImp->Arrange ( sal_False, 0, aFullSize.getHeight() ); 274*cdf0e10cSrcweir } 275*cdf0e10cSrcweir else 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir _pImp->Arrange(); 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir _pImp->Arrange( sal_False, 0, 1000 ); 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir void SvtIconChoiceCtrl::Resize() 282*cdf0e10cSrcweir { 283*cdf0e10cSrcweir _pImp->Resize(); 284*cdf0e10cSrcweir Control::Resize(); 285*cdf0e10cSrcweir } 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir Point SvtIconChoiceCtrl::GetLogicPos( const Point& rPosPixel ) const 288*cdf0e10cSrcweir { 289*cdf0e10cSrcweir Point aPos( rPosPixel ); 290*cdf0e10cSrcweir aPos -= GetMapMode().GetOrigin(); 291*cdf0e10cSrcweir return aPos; 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir Point SvtIconChoiceCtrl::GetPixelPos( const Point& rPosLogic ) const 295*cdf0e10cSrcweir { 296*cdf0e10cSrcweir Point aPos( rPosLogic ); 297*cdf0e10cSrcweir aPos += GetMapMode().GetOrigin(); 298*cdf0e10cSrcweir return aPos; 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir void SvtIconChoiceCtrl::DocumentRectChanged() 302*cdf0e10cSrcweir { 303*cdf0e10cSrcweir _aDocRectChangedHdl.Call( this ); 304*cdf0e10cSrcweir } 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir void SvtIconChoiceCtrl::VisibleRectChanged() 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir _aVisRectChangedHdl.Call( this ); 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir void SvtIconChoiceCtrl::GetFocus() 312*cdf0e10cSrcweir { 313*cdf0e10cSrcweir _pImp->GetFocus(); 314*cdf0e10cSrcweir Control::GetFocus(); 315*cdf0e10cSrcweir sal_uLong nPos; 316*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pSelectedEntry = GetSelectedEntry ( nPos ); 317*cdf0e10cSrcweir if ( pSelectedEntry ) 318*cdf0e10cSrcweir _pImp->CallEventListeners( VCLEVENT_LISTBOX_SELECT, pSelectedEntry ); 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir void SvtIconChoiceCtrl::LoseFocus() 322*cdf0e10cSrcweir { 323*cdf0e10cSrcweir _pImp->LoseFocus(); 324*cdf0e10cSrcweir Control::LoseFocus(); 325*cdf0e10cSrcweir } 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir void SvtIconChoiceCtrl::SetUpdateMode( sal_Bool bUpdate ) 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir Control::SetUpdateMode( bUpdate ); 330*cdf0e10cSrcweir _pImp->SetUpdateMode( bUpdate ); 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir void SvtIconChoiceCtrl::SetFont( const Font& rFont ) 333*cdf0e10cSrcweir { 334*cdf0e10cSrcweir if( rFont != GetFont() ) 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir Control::SetFont( rFont ); 337*cdf0e10cSrcweir _pImp->FontModified(); 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir void SvtIconChoiceCtrl::SetPointFont( const Font& rFont ) 342*cdf0e10cSrcweir { 343*cdf0e10cSrcweir if( rFont != GetPointFont() ) 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir Control::SetPointFont( rFont ); 346*cdf0e10cSrcweir _pImp->FontModified(); 347*cdf0e10cSrcweir } 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* SvtIconChoiceCtrl::GetEntry( const Point& rPixPos, sal_Bool bHit ) const 350*cdf0e10cSrcweir { 351*cdf0e10cSrcweir Point aPos( rPixPos ); 352*cdf0e10cSrcweir aPos -= GetMapMode().GetOrigin(); 353*cdf0e10cSrcweir return ((SvtIconChoiceCtrl*)this)->_pImp->GetEntry( aPos, bHit ); 354*cdf0e10cSrcweir } 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir void SvtIconChoiceCtrl::SetStyle( WinBits nWinStyle ) 357*cdf0e10cSrcweir { 358*cdf0e10cSrcweir _pImp->SetStyle( nWinStyle ); 359*cdf0e10cSrcweir } 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir WinBits SvtIconChoiceCtrl::GetStyle() const 362*cdf0e10cSrcweir { 363*cdf0e10cSrcweir return _pImp->GetStyle(); 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir void SvtIconChoiceCtrl::Command( const CommandEvent& rCEvt ) 366*cdf0e10cSrcweir { 367*cdf0e10cSrcweir _pImp->Command( rCEvt ); 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir void SvtIconChoiceCtrl::SetEntryTextMode( SvxIconChoiceCtrlTextMode eMode, SvxIconChoiceCtrlEntry* pEntry ) 371*cdf0e10cSrcweir { 372*cdf0e10cSrcweir _pImp->SetEntryTextMode( eMode, pEntry ); 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir SvxIconChoiceCtrlTextMode SvtIconChoiceCtrl::GetEntryTextMode( const SvxIconChoiceCtrlEntry* pEntry ) const 376*cdf0e10cSrcweir { 377*cdf0e10cSrcweir return _pImp->GetEntryTextModeSmart( pEntry ); 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* SvtIconChoiceCtrl::GetNextEntry( const Point& rPixPos, SvxIconChoiceCtrlEntry* pCurEntry, sal_Bool ) const 381*cdf0e10cSrcweir { 382*cdf0e10cSrcweir Point aPos( rPixPos ); 383*cdf0e10cSrcweir aPos -= GetMapMode().GetOrigin(); 384*cdf0e10cSrcweir return ((SvtIconChoiceCtrl*)this)->_pImp->GetNextEntry( aPos, pCurEntry ); 385*cdf0e10cSrcweir } 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* SvtIconChoiceCtrl::GetPrevEntry( const Point& rPixPos, SvxIconChoiceCtrlEntry* pCurEntry, sal_Bool ) const 388*cdf0e10cSrcweir { 389*cdf0e10cSrcweir Point aPos( rPixPos ); 390*cdf0e10cSrcweir aPos -= GetMapMode().GetOrigin(); 391*cdf0e10cSrcweir return ((SvtIconChoiceCtrl*)this)->_pImp->GetPrevEntry( aPos, pCurEntry ); 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir sal_uLong SvtIconChoiceCtrl::GetEntryCount() const 394*cdf0e10cSrcweir { 395*cdf0e10cSrcweir return _pImp->GetEntryCount(); 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* SvtIconChoiceCtrl::GetEntry( sal_uLong nPos ) const 399*cdf0e10cSrcweir { 400*cdf0e10cSrcweir return _pImp->GetEntry( nPos ); 401*cdf0e10cSrcweir } 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir void SvtIconChoiceCtrl::CreateAutoMnemonics( MnemonicGenerator& _rUsedMnemonics ) 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir _pImp->CreateAutoMnemonics( &_rUsedMnemonics ); 406*cdf0e10cSrcweir } 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir void SvtIconChoiceCtrl::CreateAutoMnemonics( void ) 409*cdf0e10cSrcweir { 410*cdf0e10cSrcweir _pImp->CreateAutoMnemonics(); 411*cdf0e10cSrcweir } 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir void SvtIconChoiceCtrl::RemoveEntry( SvxIconChoiceCtrlEntry* pEntry ) 414*cdf0e10cSrcweir { 415*cdf0e10cSrcweir _pImp->RemoveEntry( pEntry ); 416*cdf0e10cSrcweir } 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* SvtIconChoiceCtrl::GetSelectedEntry( sal_uLong& rPos ) const 419*cdf0e10cSrcweir { 420*cdf0e10cSrcweir return _pImp->GetFirstSelectedEntry( rPos ); 421*cdf0e10cSrcweir } 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir void SvtIconChoiceCtrl::ClickIcon() 424*cdf0e10cSrcweir { 425*cdf0e10cSrcweir sal_uLong nPos; 426*cdf0e10cSrcweir GetSelectedEntry ( nPos ); 427*cdf0e10cSrcweir _aClickIconHdl.Call( this ); 428*cdf0e10cSrcweir } 429*cdf0e10cSrcweir sal_Bool SvtIconChoiceCtrl::IsEntryEditing() const 430*cdf0e10cSrcweir { 431*cdf0e10cSrcweir return _pImp->IsEntryEditing(); 432*cdf0e10cSrcweir } 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir sal_Bool SvtIconChoiceCtrl::SetChoiceWithCursor ( sal_Bool bDo ) 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir return _pImp->SetChoiceWithCursor (bDo); 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir void SvtIconChoiceCtrl::KeyInput( const KeyEvent& rKEvt ) 440*cdf0e10cSrcweir { 441*cdf0e10cSrcweir sal_Bool bKeyUsed = DoKeyInput( rKEvt ); 442*cdf0e10cSrcweir if ( !bKeyUsed ) 443*cdf0e10cSrcweir { 444*cdf0e10cSrcweir _pCurKeyEvent = (KeyEvent*)&rKEvt; 445*cdf0e10cSrcweir Control::KeyInput( rKEvt ); 446*cdf0e10cSrcweir _pCurKeyEvent = NULL; 447*cdf0e10cSrcweir } 448*cdf0e10cSrcweir } 449*cdf0e10cSrcweir sal_Bool SvtIconChoiceCtrl::DoKeyInput( const KeyEvent& rKEvt ) 450*cdf0e10cSrcweir { 451*cdf0e10cSrcweir // unter OS/2 bekommen wir auch beim Editieren Key-Up/Down 452*cdf0e10cSrcweir if( IsEntryEditing() ) 453*cdf0e10cSrcweir return sal_True; 454*cdf0e10cSrcweir _pCurKeyEvent = (KeyEvent*)&rKEvt; 455*cdf0e10cSrcweir sal_Bool bHandled = _pImp->KeyInput( rKEvt ); 456*cdf0e10cSrcweir _pCurKeyEvent = NULL; 457*cdf0e10cSrcweir return bHandled; 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir sal_uLong SvtIconChoiceCtrl::GetEntryListPos( SvxIconChoiceCtrlEntry* pEntry ) const 460*cdf0e10cSrcweir { 461*cdf0e10cSrcweir return _pImp->GetEntryListPos( pEntry ); 462*cdf0e10cSrcweir } 463*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* SvtIconChoiceCtrl::GetCursor( ) const 464*cdf0e10cSrcweir { 465*cdf0e10cSrcweir return _pImp->GetCurEntry( ); 466*cdf0e10cSrcweir } 467*cdf0e10cSrcweir void SvtIconChoiceCtrl::SetCursor( SvxIconChoiceCtrlEntry* pEntry ) 468*cdf0e10cSrcweir { 469*cdf0e10cSrcweir _pImp->SetCursor( pEntry ); 470*cdf0e10cSrcweir } 471*cdf0e10cSrcweir void SvtIconChoiceCtrl::InvalidateEntry( SvxIconChoiceCtrlEntry* pEntry ) 472*cdf0e10cSrcweir { 473*cdf0e10cSrcweir _pImp->InvalidateEntry( pEntry ); 474*cdf0e10cSrcweir } 475*cdf0e10cSrcweir void SvtIconChoiceCtrl::Clear() 476*cdf0e10cSrcweir { 477*cdf0e10cSrcweir _pImp->Clear(); 478*cdf0e10cSrcweir } 479*cdf0e10cSrcweir void SvtIconChoiceCtrl::StateChanged( StateChangedType nType ) 480*cdf0e10cSrcweir { 481*cdf0e10cSrcweir Control::StateChanged( nType ); 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir void SvtIconChoiceCtrl::DataChanged( const DataChangedEvent& rDCEvt ) 486*cdf0e10cSrcweir { 487*cdf0e10cSrcweir if ( ((rDCEvt.GetType() == DATACHANGED_SETTINGS) || 488*cdf0e10cSrcweir (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) || 489*cdf0e10cSrcweir (rDCEvt.GetType() == DATACHANGED_FONTS) ) && 490*cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 491*cdf0e10cSrcweir { 492*cdf0e10cSrcweir _pImp->InitSettings(); 493*cdf0e10cSrcweir Invalidate(INVALIDATE_NOCHILDREN); 494*cdf0e10cSrcweir } 495*cdf0e10cSrcweir else 496*cdf0e10cSrcweir Control::DataChanged( rDCEvt ); 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir void SvtIconChoiceCtrl::SetBackground( const Wallpaper& rPaper ) 500*cdf0e10cSrcweir { 501*cdf0e10cSrcweir if( rPaper != GetBackground() ) 502*cdf0e10cSrcweir { 503*cdf0e10cSrcweir const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 504*cdf0e10cSrcweir Wallpaper aEmpty; 505*cdf0e10cSrcweir if( rPaper == aEmpty ) 506*cdf0e10cSrcweir Control::SetBackground( rStyleSettings.GetFieldColor() ); 507*cdf0e10cSrcweir else 508*cdf0e10cSrcweir { 509*cdf0e10cSrcweir Wallpaper aBackground( rPaper ); 510*cdf0e10cSrcweir // HACK, da Hintergrund sonst transparent sein koennte 511*cdf0e10cSrcweir if( !aBackground.IsBitmap() ) 512*cdf0e10cSrcweir aBackground.SetStyle( WALLPAPER_TILE ); 513*cdf0e10cSrcweir 514*cdf0e10cSrcweir WallpaperStyle eStyle = aBackground.GetStyle(); 515*cdf0e10cSrcweir Color aBack( aBackground.GetColor()); 516*cdf0e10cSrcweir Color aTrans( COL_TRANSPARENT ); 517*cdf0e10cSrcweir if( aBack == aTrans && ( 518*cdf0e10cSrcweir (!aBackground.IsBitmap() || 519*cdf0e10cSrcweir aBackground.GetBitmap().IsTransparent() || 520*cdf0e10cSrcweir (eStyle != WALLPAPER_TILE && eStyle != WALLPAPER_SCALE)))) 521*cdf0e10cSrcweir { 522*cdf0e10cSrcweir aBackground.SetColor( rStyleSettings.GetFieldColor() ); 523*cdf0e10cSrcweir } 524*cdf0e10cSrcweir if( aBackground.IsScrollable() ) 525*cdf0e10cSrcweir { 526*cdf0e10cSrcweir Rectangle aRect; 527*cdf0e10cSrcweir aRect.SetSize( Size(32765, 32765) ); 528*cdf0e10cSrcweir aBackground.SetRect( aRect ); 529*cdf0e10cSrcweir } 530*cdf0e10cSrcweir else 531*cdf0e10cSrcweir { 532*cdf0e10cSrcweir Rectangle aRect( _pImp->GetOutputRect() ); 533*cdf0e10cSrcweir aBackground.SetRect( aRect ); 534*cdf0e10cSrcweir } 535*cdf0e10cSrcweir Control::SetBackground( aBackground ); 536*cdf0e10cSrcweir } 537*cdf0e10cSrcweir 538*cdf0e10cSrcweir // bei hart attributierter Textfarbe keine 'Automatik', die eine 539*cdf0e10cSrcweir // lesbare Textfarbe einstellt. 540*cdf0e10cSrcweir Font aFont( GetFont() ); 541*cdf0e10cSrcweir aFont.SetColor( rStyleSettings.GetFieldTextColor() ); 542*cdf0e10cSrcweir SetFont( aFont ); 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir Invalidate(INVALIDATE_NOCHILDREN); 545*cdf0e10cSrcweir } 546*cdf0e10cSrcweir } 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir void SvtIconChoiceCtrl::Flush() 549*cdf0e10cSrcweir { 550*cdf0e10cSrcweir _pImp->Flush(); 551*cdf0e10cSrcweir } 552*cdf0e10cSrcweir 553*cdf0e10cSrcweir void SvtIconChoiceCtrl::RequestHelp( const HelpEvent& rHEvt ) 554*cdf0e10cSrcweir { 555*cdf0e10cSrcweir if ( !_pImp->RequestHelp( rHEvt ) ) 556*cdf0e10cSrcweir Control::RequestHelp( rHEvt ); 557*cdf0e10cSrcweir } 558*cdf0e10cSrcweir 559*cdf0e10cSrcweir void SvtIconChoiceCtrl::SetSelectionMode( SelectionMode eMode ) 560*cdf0e10cSrcweir { 561*cdf0e10cSrcweir _pImp->SetSelectionMode( eMode ); 562*cdf0e10cSrcweir } 563*cdf0e10cSrcweir 564*cdf0e10cSrcweir sal_Bool SvtIconChoiceCtrl::HandleShortCutKey( const KeyEvent& r ) 565*cdf0e10cSrcweir { 566*cdf0e10cSrcweir return _pImp->HandleShortCutKey( r ); 567*cdf0e10cSrcweir } 568*cdf0e10cSrcweir 569*cdf0e10cSrcweir Rectangle SvtIconChoiceCtrl::GetBoundingBox( SvxIconChoiceCtrlEntry* pEntry ) const 570*cdf0e10cSrcweir { 571*cdf0e10cSrcweir return _pImp->GetEntryBoundRect( pEntry ); 572*cdf0e10cSrcweir } 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir void SvtIconChoiceCtrl::FillLayoutData() const 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir CreateLayoutData(); 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir SvtIconChoiceCtrl* pNonConstMe = const_cast< SvtIconChoiceCtrl* >( this ); 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir // loop through all entries 581*cdf0e10cSrcweir sal_uInt16 nCount = (sal_uInt16)GetEntryCount(); 582*cdf0e10cSrcweir sal_uInt16 nPos = 0; 583*cdf0e10cSrcweir while ( nPos < nCount ) 584*cdf0e10cSrcweir { 585*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = GetEntry( nPos ); 586*cdf0e10cSrcweir 587*cdf0e10cSrcweir Point aPos = _pImp->GetEntryBoundRect( pEntry ).TopLeft(); 588*cdf0e10cSrcweir String sEntryText = pEntry->GetDisplayText( ); 589*cdf0e10cSrcweir Rectangle aTextRect = _pImp->CalcTextRect( pEntry, &aPos, sal_False, &sEntryText ); 590*cdf0e10cSrcweir 591*cdf0e10cSrcweir sal_Bool bLargeIconMode = WB_ICON == ( _pImp->GetStyle() & ( VIEWMODE_MASK ) ); 592*cdf0e10cSrcweir sal_uInt16 nTextPaintFlags = bLargeIconMode ? PAINTFLAG_HOR_CENTERED : PAINTFLAG_VER_CENTERED; 593*cdf0e10cSrcweir 594*cdf0e10cSrcweir _pImp->PaintItem( aTextRect, IcnViewFieldTypeText, pEntry, nTextPaintFlags, pNonConstMe, &sEntryText, GetLayoutData() ); 595*cdf0e10cSrcweir 596*cdf0e10cSrcweir ++nPos; 597*cdf0e10cSrcweir } 598*cdf0e10cSrcweir } 599*cdf0e10cSrcweir 600*cdf0e10cSrcweir Rectangle SvtIconChoiceCtrl::GetEntryCharacterBounds( const sal_Int32 _nEntryPos, const sal_Int32 _nCharacterIndex ) const 601*cdf0e10cSrcweir { 602*cdf0e10cSrcweir Rectangle aRect; 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir Pair aEntryCharacterRange = GetLineStartEnd( _nEntryPos ); 605*cdf0e10cSrcweir if ( aEntryCharacterRange.A() + _nCharacterIndex < aEntryCharacterRange.B() ) 606*cdf0e10cSrcweir { 607*cdf0e10cSrcweir aRect = GetCharacterBounds( aEntryCharacterRange.A() + _nCharacterIndex ); 608*cdf0e10cSrcweir } 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir return aRect; 611*cdf0e10cSrcweir } 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir void SvtIconChoiceCtrl::SetNoSelection() 614*cdf0e10cSrcweir { 615*cdf0e10cSrcweir _pImp->SetNoSelection(); 616*cdf0e10cSrcweir } 617*cdf0e10cSrcweir 618*cdf0e10cSrcweir void SvtIconChoiceCtrl::CallImplEventListeners(sal_uLong nEvent, void* pData) 619*cdf0e10cSrcweir { 620*cdf0e10cSrcweir CallEventListeners(nEvent, pData); 621*cdf0e10cSrcweir } 622*cdf0e10cSrcweir ::com::sun::star::uno::Reference< XAccessible > SvtIconChoiceCtrl::CreateAccessible() 623*cdf0e10cSrcweir { 624*cdf0e10cSrcweir Window* pParent = GetAccessibleParentWindow(); 625*cdf0e10cSrcweir DBG_ASSERT( pParent, "SvTreeListBox::CreateAccessible - accessible parent not found" ); 626*cdf0e10cSrcweir 627*cdf0e10cSrcweir ::com::sun::star::uno::Reference< XAccessible > xAccessible; 628*cdf0e10cSrcweir if ( pParent ) 629*cdf0e10cSrcweir { 630*cdf0e10cSrcweir ::com::sun::star::uno::Reference< XAccessible > xAccParent = pParent->GetAccessible(); 631*cdf0e10cSrcweir if ( xAccParent.is() ) 632*cdf0e10cSrcweir { 633*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xTemp(GetComponentInterface()); 634*cdf0e10cSrcweir xAccessible = _pImp->GetAccessibleFactory().createAccessibleIconChoiceCtrl( *this, xAccParent ); 635*cdf0e10cSrcweir } 636*cdf0e10cSrcweir } 637*cdf0e10cSrcweir return xAccessible; 638*cdf0e10cSrcweir } 639*cdf0e10cSrcweir 640