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 <limits.h> 32*cdf0e10cSrcweir #ifndef _METRIC_HXX 33*cdf0e10cSrcweir #include <vcl/metric.hxx> 34*cdf0e10cSrcweir #endif 35*cdf0e10cSrcweir #include <vcl/svapp.hxx> 36*cdf0e10cSrcweir #ifdef DBG_UTIL 37*cdf0e10cSrcweir #include <vcl/sound.hxx> 38*cdf0e10cSrcweir #endif 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #include <svtools/svlbox.hxx> 41*cdf0e10cSrcweir #include <svtools/svicnvw.hxx> 42*cdf0e10cSrcweir #include <svimpicn.hxx> 43*cdf0e10cSrcweir #ifndef _SVLBITM_HXX 44*cdf0e10cSrcweir #include <svtools/svlbitm.hxx> 45*cdf0e10cSrcweir #endif 46*cdf0e10cSrcweir #include <svl/svarray.hxx> 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir #define VIEWMODE_ICON 0x0001 // Text unter Bitmap 51*cdf0e10cSrcweir #define VIEWMODE_NAME 0x0002 // Text rechts neben Bitmap 52*cdf0e10cSrcweir #define VIEWMODE_TEXT 0x0004 // Text ohne Bitmap 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir #define DD_SCROLL_PIXEL 10 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir // alle Angaben in Pixel 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir #define ICONVIEW_OFFS_BMP_STRING 3 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir // fuer das Bounding-Rectangle 61*cdf0e10cSrcweir #define LROFFS_BOUND 2 62*cdf0e10cSrcweir #define TBOFFS_BOUND 2 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir // fuer das Focus-Rectangle um Icons 65*cdf0e10cSrcweir #define LROFFS_ICON 2 66*cdf0e10cSrcweir #define TBOFFS_ICON 2 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir #define NAMEVIEW_OFFS_BMP_STRING 3 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir // Abstaende von Fensterraendern 71*cdf0e10cSrcweir #define LROFFS_WINBORDER 4 72*cdf0e10cSrcweir #define TBOFFS_WINBORDER 4 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir // Breitenoffset Highlight-Rect bei Text 75*cdf0e10cSrcweir #define LROFFS_TEXT 2 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir #define ICNVIEWDATA(xPtr) (SvIcnVwDataEntry*)(pView->GetViewDataEntry(xPtr)) 79*cdf0e10cSrcweir #define ICNVIEWDATA2(xPtr) (SvIcnVwDataEntry*)(pView->pView->GetViewDataEntry(xPtr)) 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir //-------------------------------------------------------------------------- 82*cdf0e10cSrcweir //-------------------------------------------------------------------------- 83*cdf0e10cSrcweir //-------------------------------------------------------------------------- 84*cdf0e10cSrcweir // ------------------------------------------------------------------------- 85*cdf0e10cSrcweir // Hilfsfunktionen von Thomas Hosemann zur mehrzeiligen Ausgabe von 86*cdf0e10cSrcweir // Strings. Die Funktionen werden spaeter in StarView integriert. 87*cdf0e10cSrcweir // ------------------------------------------------------------------------- 88*cdf0e10cSrcweir //-------------------------------------------------------------------------- 89*cdf0e10cSrcweir //-------------------------------------------------------------------------- 90*cdf0e10cSrcweir //-------------------------------------------------------------------------- 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir // keine doppelten Defines 93*cdf0e10cSrcweir #ifdef TEXT_DRAW_CLIP 94*cdf0e10cSrcweir #undef TEXT_DRAW_CLIP 95*cdf0e10cSrcweir #endif 96*cdf0e10cSrcweir #ifdef TEXT_DRAW_MULTILINE 97*cdf0e10cSrcweir #undef TEXT_DRAW_MULTILINE 98*cdf0e10cSrcweir #endif 99*cdf0e10cSrcweir #ifdef TEXT_DRAW_WORDBREAK 100*cdf0e10cSrcweir #undef TEXT_DRAW_WORDBREAK 101*cdf0e10cSrcweir #endif 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir // #define TEXT_DRAW_DISABLE ((sal_uInt16)0x0001) 104*cdf0e10cSrcweir // #define TEXT_DRAW_3DLOOK ((sal_uInt16)0x0002) 105*cdf0e10cSrcweir // #define TEXT_DRAW_MNEMONIC ((sal_uInt16)0x0004) 106*cdf0e10cSrcweir #define TEXT_DRAW_LEFT ((sal_uInt16)0x0010) 107*cdf0e10cSrcweir #define TEXT_DRAW_CENTER ((sal_uInt16)0x0020) 108*cdf0e10cSrcweir #define TEXT_DRAW_RIGHT ((sal_uInt16)0x0040) 109*cdf0e10cSrcweir #define TEXT_DRAW_TOP ((sal_uInt16)0x0080) 110*cdf0e10cSrcweir #define TEXT_DRAW_VCENTER ((sal_uInt16)0x0100) 111*cdf0e10cSrcweir #define TEXT_DRAW_BOTTOM ((sal_uInt16)0x0200) 112*cdf0e10cSrcweir #define TEXT_DRAW_ENDELLIPSIS ((sal_uInt16)0x0400) 113*cdf0e10cSrcweir #define TEXT_DRAW_PATHELLIPSIS ((sal_uInt16)0x0800) 114*cdf0e10cSrcweir #define TEXT_DRAW_CLIP ((sal_uInt16)0x1000) 115*cdf0e10cSrcweir #define TEXT_DRAW_MULTILINE ((sal_uInt16)0x2000) 116*cdf0e10cSrcweir #define TEXT_DRAW_WORDBREAK ((sal_uInt16)0x4000) 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir XubString GetEllipsisString( OutputDevice* pDev, 119*cdf0e10cSrcweir const XubString& rStr, long nMaxWidth, 120*cdf0e10cSrcweir sal_uInt16 nStyle = TEXT_DRAW_ENDELLIPSIS ) 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir XubString aStr = rStr; 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir if ( nStyle & TEXT_DRAW_ENDELLIPSIS ) 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir sal_uInt16 nIndex = pDev->GetTextBreak( rStr, nMaxWidth ); 127*cdf0e10cSrcweir if ( nIndex != STRING_LEN ) 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir aStr.Erase( nIndex ); 130*cdf0e10cSrcweir if ( nIndex > 1 ) 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir aStr.AppendAscii("..."); 133*cdf0e10cSrcweir while ( aStr.Len() && 134*cdf0e10cSrcweir (pDev->GetTextWidth( aStr ) > nMaxWidth) ) 135*cdf0e10cSrcweir { 136*cdf0e10cSrcweir if ( (nIndex > 1) || (nIndex == aStr.Len()) ) 137*cdf0e10cSrcweir nIndex--; 138*cdf0e10cSrcweir aStr.Erase( nIndex, 1 ); 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir if ( !aStr.Len() && (nStyle & TEXT_DRAW_CLIP) ) 143*cdf0e10cSrcweir aStr += rStr.GetChar( 0 ); 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir return aStr; 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir class TextLineInfo 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir private: 153*cdf0e10cSrcweir long mnWidth; 154*cdf0e10cSrcweir sal_uInt16 mnIndex; 155*cdf0e10cSrcweir sal_uInt16 mnLen; 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir public: 158*cdf0e10cSrcweir TextLineInfo( long nWidth, sal_uInt16 nIndex, sal_uInt16 nLen ) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir mnWidth = nWidth; 161*cdf0e10cSrcweir mnIndex = nIndex; 162*cdf0e10cSrcweir mnLen = nLen; 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir long GetWidth() const { return mnWidth; } 166*cdf0e10cSrcweir sal_uInt16 GetIndex() const { return mnIndex; } 167*cdf0e10cSrcweir sal_uInt16 GetLen() const { return mnLen; } 168*cdf0e10cSrcweir }; 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir #define MULTITEXTLINEINFO_RESIZE 16 171*cdf0e10cSrcweir typedef TextLineInfo* PTextLineInfo; 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir class MultiTextLineInfo 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir private: 176*cdf0e10cSrcweir PTextLineInfo* mpLines; 177*cdf0e10cSrcweir sal_uInt16 mnLines; 178*cdf0e10cSrcweir sal_uInt16 mnSize; 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir public: 181*cdf0e10cSrcweir MultiTextLineInfo(); 182*cdf0e10cSrcweir ~MultiTextLineInfo(); 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir void AddLine( TextLineInfo* pLine ); 185*cdf0e10cSrcweir void Clear(); 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir TextLineInfo* GetLine( sal_uInt16 nLine ) const 188*cdf0e10cSrcweir { return mpLines[nLine]; } 189*cdf0e10cSrcweir sal_uInt16 Count() const { return mnLines; } 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir private: 192*cdf0e10cSrcweir MultiTextLineInfo( const MultiTextLineInfo& ); 193*cdf0e10cSrcweir MultiTextLineInfo& operator=( const MultiTextLineInfo& ); 194*cdf0e10cSrcweir }; 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir MultiTextLineInfo::MultiTextLineInfo() 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir mpLines = new PTextLineInfo[MULTITEXTLINEINFO_RESIZE]; 199*cdf0e10cSrcweir mnLines = 0; 200*cdf0e10cSrcweir mnSize = MULTITEXTLINEINFO_RESIZE; 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir MultiTextLineInfo::~MultiTextLineInfo() 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < mnLines; i++ ) 206*cdf0e10cSrcweir delete mpLines[i]; 207*cdf0e10cSrcweir delete [] mpLines; 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir void MultiTextLineInfo::AddLine( TextLineInfo* pLine ) 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir if ( mnSize == mnLines ) 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir mnSize += MULTITEXTLINEINFO_RESIZE; 215*cdf0e10cSrcweir PTextLineInfo* pNewLines = new PTextLineInfo[mnSize]; 216*cdf0e10cSrcweir memcpy( pNewLines, mpLines, mnLines*sizeof(PTextLineInfo) ); 217*cdf0e10cSrcweir mpLines = pNewLines; 218*cdf0e10cSrcweir } 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir mpLines[mnLines] = pLine; 221*cdf0e10cSrcweir mnLines++; 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir void MultiTextLineInfo::Clear() 225*cdf0e10cSrcweir { 226*cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < mnLines; i++ ) 227*cdf0e10cSrcweir delete mpLines[i]; 228*cdf0e10cSrcweir mnLines = 0; 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir // ----------------------------------------------------------------------- 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir long GetTextLines( OutputDevice* pDev, MultiTextLineInfo& rLineInfo, 234*cdf0e10cSrcweir long nWidth, const XubString& rStr, 235*cdf0e10cSrcweir sal_uInt16 nStyle = TEXT_DRAW_WORDBREAK ) 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir rLineInfo.Clear(); 238*cdf0e10cSrcweir if ( !rStr.Len() ) 239*cdf0e10cSrcweir return 0; 240*cdf0e10cSrcweir if ( nWidth <= 0 ) 241*cdf0e10cSrcweir nWidth = 1; 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir sal_uInt16 nStartPos = 0; // Start-Position der Zeile 244*cdf0e10cSrcweir sal_uInt16 nLastLineLen = 0; // Zeilenlaenge bis zum vorherigen Wort 245*cdf0e10cSrcweir sal_uInt16 nLastWordPos = 0; // Position des letzten Wortanfangs 246*cdf0e10cSrcweir sal_uInt16 i = 0; 247*cdf0e10cSrcweir sal_uInt16 nPos; // StartPositon der Zeile (nur Temp) 248*cdf0e10cSrcweir sal_uInt16 nLen; // Laenge der Zeile (nur Temp) 249*cdf0e10cSrcweir sal_uInt16 nStrLen = rStr.Len(); 250*cdf0e10cSrcweir long nMaxLineWidth = 0; // Maximale Zeilenlaenge 251*cdf0e10cSrcweir long nLineWidth; // Aktuelle Zeilenlaenge 252*cdf0e10cSrcweir long nLastLineWidth = 0; // Zeilenlaenge der letzten Zeile 253*cdf0e10cSrcweir xub_Unicode c; 254*cdf0e10cSrcweir xub_Unicode c2; 255*cdf0e10cSrcweir const xub_Unicode* pStr = rStr.GetBuffer(); 256*cdf0e10cSrcweir sal_Bool bHardBreak = sal_False; 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir do 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir c = pStr[i]; 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir // Auf Zeilenende ermitteln 263*cdf0e10cSrcweir if ( (c == _CR) || (c == _LF) ) 264*cdf0e10cSrcweir bHardBreak = sal_True; 265*cdf0e10cSrcweir else 266*cdf0e10cSrcweir bHardBreak = sal_False; 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir // Testen, ob ein Wortende erreicht ist 269*cdf0e10cSrcweir if ( bHardBreak || (i == nStrLen) || 270*cdf0e10cSrcweir (((c == ' ') || (c == '-')) && (nStyle & TEXT_DRAW_WORDBREAK)) ) 271*cdf0e10cSrcweir { 272*cdf0e10cSrcweir nLen = i-nStartPos; 273*cdf0e10cSrcweir if ( c == '-' ) 274*cdf0e10cSrcweir nLen++; 275*cdf0e10cSrcweir nLineWidth = pDev->GetTextWidth( rStr, nStartPos, nLen ); 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir // Findet ein Zeilenumbruch statt 278*cdf0e10cSrcweir if ( bHardBreak || (i == nStrLen) || 279*cdf0e10cSrcweir ((nLineWidth >= nWidth) && (nStyle & TEXT_DRAW_WORDBREAK)) ) 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir nPos = nStartPos; 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir if ( (nLineWidth >= nWidth) && (nStyle & TEXT_DRAW_WORDBREAK) ) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir nLineWidth = nLastLineWidth; 286*cdf0e10cSrcweir nLen = nLastLineLen; 287*cdf0e10cSrcweir nStartPos = nLastWordPos; 288*cdf0e10cSrcweir nLastLineLen = i-nStartPos; 289*cdf0e10cSrcweir nLastWordPos = nStartPos+nLastLineLen+1; 290*cdf0e10cSrcweir if ( c == '-' ) 291*cdf0e10cSrcweir nLastLineLen++; 292*cdf0e10cSrcweir else if ( bHardBreak && (i > nStartPos) ) 293*cdf0e10cSrcweir i--; 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir else 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir nStartPos = i; 298*cdf0e10cSrcweir // Zeilenende-Zeichen und '-' beruecksichtigen 299*cdf0e10cSrcweir if ( bHardBreak ) 300*cdf0e10cSrcweir { 301*cdf0e10cSrcweir nStartPos++; 302*cdf0e10cSrcweir c2 = pStr[i+1]; 303*cdf0e10cSrcweir if ( (c != c2) && ((c2 == _CR) || (c2 == _LF)) ) 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir nStartPos++; 306*cdf0e10cSrcweir i++; 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir else if ( c != '-' ) 310*cdf0e10cSrcweir nStartPos++; 311*cdf0e10cSrcweir nLastWordPos = nStartPos; 312*cdf0e10cSrcweir nLastLineLen = 0; 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir if ( nLineWidth > nMaxLineWidth ) 316*cdf0e10cSrcweir nMaxLineWidth = nLineWidth; 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir if ( nLen || bHardBreak ) 319*cdf0e10cSrcweir rLineInfo.AddLine( new TextLineInfo( nLineWidth, nPos, nLen ) ); 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir // Testen, ob aktuelles Wort noch auf die Zeile passt, 322*cdf0e10cSrcweir // denn ansonsten mueessen wir es auftrennen 323*cdf0e10cSrcweir if ( nLastLineLen ) 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir nLineWidth = pDev->GetTextWidth( rStr, nStartPos, nLastLineLen ); 326*cdf0e10cSrcweir if ( nLineWidth > nWidth ) 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir // Wenn ein Wortumbruch in einem Wort stattfindet, 329*cdf0e10cSrcweir // ist die maximale Zeilenlaenge die Laenge 330*cdf0e10cSrcweir // des laengsten Wortes 331*cdf0e10cSrcweir if ( nLineWidth > nMaxLineWidth ) 332*cdf0e10cSrcweir nMaxLineWidth = nLineWidth; 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir // Solange Wort auftrennen, bis es auf eine Zeile passt 335*cdf0e10cSrcweir do 336*cdf0e10cSrcweir { 337*cdf0e10cSrcweir nPos = pDev->GetTextBreak( rStr, nWidth, nStartPos, nLastLineLen ); 338*cdf0e10cSrcweir nLen = nPos-nStartPos; 339*cdf0e10cSrcweir if ( !nLen ) 340*cdf0e10cSrcweir { 341*cdf0e10cSrcweir nPos++; 342*cdf0e10cSrcweir nLen++; 343*cdf0e10cSrcweir } 344*cdf0e10cSrcweir nLineWidth = pDev->GetTextWidth( rStr, nStartPos, nLen ); 345*cdf0e10cSrcweir rLineInfo.AddLine( new TextLineInfo( nLineWidth, nStartPos, nLen ) ); 346*cdf0e10cSrcweir nStartPos = nPos; 347*cdf0e10cSrcweir nLastLineLen = nLastLineLen - nLen; 348*cdf0e10cSrcweir nLineWidth = pDev->GetTextWidth( rStr, nStartPos, nLastLineLen ); 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir while ( nLineWidth > nWidth ); 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir nLastLineWidth = nLineWidth; 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir // Bei Stringende muessen wir die letzte Zeile auch noch 355*cdf0e10cSrcweir // dranhaengen 356*cdf0e10cSrcweir if ( (i == nStrLen) && nLastLineLen ) 357*cdf0e10cSrcweir rLineInfo.AddLine( new TextLineInfo( nLastLineWidth, nStartPos, nLastLineLen ) ); 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir else 360*cdf0e10cSrcweir nLastLineWidth = 0; 361*cdf0e10cSrcweir } 362*cdf0e10cSrcweir else 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir nLastLineWidth = nLineWidth; 365*cdf0e10cSrcweir nLastLineLen = nLen; 366*cdf0e10cSrcweir nLastWordPos = nStartPos+nLastLineLen; 367*cdf0e10cSrcweir if ( c != '-' ) 368*cdf0e10cSrcweir nLastWordPos++; 369*cdf0e10cSrcweir } 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir i++; 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir while ( i <= nStrLen ); 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir return nMaxLineWidth; 377*cdf0e10cSrcweir } 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir // ----------------------------------------------------------------------- 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir sal_uInt16 GetTextLines( OutputDevice* pDev, const Rectangle& rRect, 382*cdf0e10cSrcweir const XubString& rStr, 383*cdf0e10cSrcweir sal_uInt16 nStyle = TEXT_DRAW_WORDBREAK, 384*cdf0e10cSrcweir long* pMaxWidth = NULL ) 385*cdf0e10cSrcweir { 386*cdf0e10cSrcweir MultiTextLineInfo aMultiLineInfo; 387*cdf0e10cSrcweir long nMaxWidth = GetTextLines( pDev, aMultiLineInfo, 388*cdf0e10cSrcweir rRect.GetWidth(), rStr, nStyle ); 389*cdf0e10cSrcweir if ( pMaxWidth ) 390*cdf0e10cSrcweir *pMaxWidth = nMaxWidth; 391*cdf0e10cSrcweir return aMultiLineInfo.Count(); 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir // ----------------------------------------------------------------------- 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir Rectangle GetTextRect( OutputDevice* pDev, const Rectangle& rRect, 397*cdf0e10cSrcweir const XubString& rStr, 398*cdf0e10cSrcweir sal_uInt16 nStyle = TEXT_DRAW_WORDBREAK ) 399*cdf0e10cSrcweir { 400*cdf0e10cSrcweir Rectangle aRect = rRect; 401*cdf0e10cSrcweir sal_uInt16 nLines; 402*cdf0e10cSrcweir long nWidth = rRect.GetWidth(); 403*cdf0e10cSrcweir long nMaxWidth; 404*cdf0e10cSrcweir long nTextHeight; 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir if ( nStyle & TEXT_DRAW_MULTILINE ) 407*cdf0e10cSrcweir { 408*cdf0e10cSrcweir MultiTextLineInfo aMultiLineInfo; 409*cdf0e10cSrcweir TextLineInfo* pLineInfo; 410*cdf0e10cSrcweir sal_uInt16 nFormatLines; 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir nMaxWidth = 0; 413*cdf0e10cSrcweir GetTextLines( pDev, aMultiLineInfo, nWidth, rStr, nStyle ); 414*cdf0e10cSrcweir nFormatLines = aMultiLineInfo.Count(); 415*cdf0e10cSrcweir nTextHeight = pDev->GetTextHeight(); 416*cdf0e10cSrcweir nLines = (sal_uInt16)(aRect.GetHeight()/nTextHeight); 417*cdf0e10cSrcweir if ( nFormatLines <= nLines ) 418*cdf0e10cSrcweir nLines = nFormatLines; 419*cdf0e10cSrcweir else 420*cdf0e10cSrcweir { 421*cdf0e10cSrcweir if ( !(nStyle & TEXT_DRAW_ENDELLIPSIS) ) 422*cdf0e10cSrcweir nLines = nFormatLines; 423*cdf0e10cSrcweir else 424*cdf0e10cSrcweir nMaxWidth = nWidth; 425*cdf0e10cSrcweir } 426*cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nLines; i++ ) 427*cdf0e10cSrcweir { 428*cdf0e10cSrcweir pLineInfo = aMultiLineInfo.GetLine( i ); 429*cdf0e10cSrcweir if ( pLineInfo->GetWidth() > nMaxWidth ) 430*cdf0e10cSrcweir nMaxWidth = pLineInfo->GetWidth(); 431*cdf0e10cSrcweir } 432*cdf0e10cSrcweir } 433*cdf0e10cSrcweir else 434*cdf0e10cSrcweir { 435*cdf0e10cSrcweir nLines = 1; 436*cdf0e10cSrcweir nMaxWidth = pDev->GetTextWidth( rStr ); 437*cdf0e10cSrcweir nTextHeight = pDev->GetTextHeight(); 438*cdf0e10cSrcweir if ( (nMaxWidth > nWidth) && (nStyle & TEXT_DRAW_ENDELLIPSIS) ) 439*cdf0e10cSrcweir nMaxWidth = nWidth; 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir if ( nStyle & TEXT_DRAW_RIGHT ) 443*cdf0e10cSrcweir aRect.Left() = aRect.Right()-nMaxWidth+1; 444*cdf0e10cSrcweir else if ( nStyle & TEXT_DRAW_CENTER ) 445*cdf0e10cSrcweir { 446*cdf0e10cSrcweir aRect.Left() += (nWidth-nMaxWidth)/2; 447*cdf0e10cSrcweir aRect.Right() = aRect.Left()+nMaxWidth-1; 448*cdf0e10cSrcweir } 449*cdf0e10cSrcweir else 450*cdf0e10cSrcweir aRect.Right() = aRect.Left()+nMaxWidth-1; 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir if ( nStyle & TEXT_DRAW_BOTTOM ) 453*cdf0e10cSrcweir aRect.Top() = aRect.Bottom()-(nTextHeight*nLines)+1; 454*cdf0e10cSrcweir else if ( nStyle & TEXT_DRAW_VCENTER ) 455*cdf0e10cSrcweir { 456*cdf0e10cSrcweir aRect.Top() += (aRect.GetHeight()-(nTextHeight*nLines))/2; 457*cdf0e10cSrcweir aRect.Bottom() = aRect.Top()+(nTextHeight*nLines)-1; 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir else 460*cdf0e10cSrcweir aRect.Bottom() = aRect.Top()+(nTextHeight*nLines)-1; 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir return aRect; 463*cdf0e10cSrcweir } 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir // ----------------------------------------------------------------------- 466*cdf0e10cSrcweir 467*cdf0e10cSrcweir void DrawText( OutputDevice* pDev, const Rectangle& rRect, 468*cdf0e10cSrcweir const XubString& rStr, sal_uInt16 nStyle = 0 ) 469*cdf0e10cSrcweir { 470*cdf0e10cSrcweir if ( !rStr.Len() || rRect.IsEmpty() ) 471*cdf0e10cSrcweir return; 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir Point aPos = rRect.TopLeft(); 474*cdf0e10cSrcweir long nWidth = rRect.GetWidth(); 475*cdf0e10cSrcweir long nHeight = rRect.GetHeight(); 476*cdf0e10cSrcweir FontAlign eAlign = pDev->GetFont().GetAlign(); 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir if ( ((nWidth <= 0) || (nHeight <= 0)) && (nStyle & TEXT_DRAW_CLIP) ) 479*cdf0e10cSrcweir return; 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir // Mehrzeiligen Text behandeln wir anders 482*cdf0e10cSrcweir if ( nStyle & TEXT_DRAW_MULTILINE ) 483*cdf0e10cSrcweir { 484*cdf0e10cSrcweir String aLastLine; 485*cdf0e10cSrcweir Region aOldRegion; 486*cdf0e10cSrcweir MultiTextLineInfo aMultiLineInfo; 487*cdf0e10cSrcweir TextLineInfo* pLineInfo; 488*cdf0e10cSrcweir long nTextHeight = pDev->GetTextHeight(); 489*cdf0e10cSrcweir long nMaxTextWidth; 490*cdf0e10cSrcweir sal_uInt16 i; 491*cdf0e10cSrcweir sal_uInt16 nLines = (sal_uInt16)(nHeight/nTextHeight); 492*cdf0e10cSrcweir sal_uInt16 nFormatLines; 493*cdf0e10cSrcweir sal_Bool bIsClipRegion = sal_False; 494*cdf0e10cSrcweir nMaxTextWidth = GetTextLines( pDev, aMultiLineInfo, nWidth, rStr, nStyle ); 495*cdf0e10cSrcweir 496*cdf0e10cSrcweir nFormatLines = aMultiLineInfo.Count(); 497*cdf0e10cSrcweir if ( nFormatLines > nLines ) 498*cdf0e10cSrcweir { 499*cdf0e10cSrcweir if ( nStyle & TEXT_DRAW_ENDELLIPSIS ) 500*cdf0e10cSrcweir { 501*cdf0e10cSrcweir // Letzte Zeile zusammenbauen und kuerzen 502*cdf0e10cSrcweir nFormatLines = nLines-1; 503*cdf0e10cSrcweir pLineInfo = aMultiLineInfo.GetLine( nFormatLines ); 504*cdf0e10cSrcweir aLastLine = rStr.Copy( pLineInfo->GetIndex() ); 505*cdf0e10cSrcweir aLastLine.ConvertLineEnd( LINEEND_LF ); 506*cdf0e10cSrcweir aLastLine.SearchAndReplace( _LF, ' ' ); 507*cdf0e10cSrcweir aLastLine = GetEllipsisString( pDev, aLastLine, nWidth, nStyle ); 508*cdf0e10cSrcweir nStyle &= ~(TEXT_DRAW_VCENTER | TEXT_DRAW_BOTTOM); 509*cdf0e10cSrcweir nStyle |= TEXT_DRAW_TOP; 510*cdf0e10cSrcweir } 511*cdf0e10cSrcweir } 512*cdf0e10cSrcweir else 513*cdf0e10cSrcweir { 514*cdf0e10cSrcweir if ( nMaxTextWidth <= nWidth ) 515*cdf0e10cSrcweir nStyle &= ~TEXT_DRAW_CLIP; 516*cdf0e10cSrcweir } 517*cdf0e10cSrcweir 518*cdf0e10cSrcweir // Clipping setzen 519*cdf0e10cSrcweir if ( nStyle & TEXT_DRAW_CLIP ) 520*cdf0e10cSrcweir { 521*cdf0e10cSrcweir bIsClipRegion = pDev->IsClipRegion(); 522*cdf0e10cSrcweir if ( bIsClipRegion ) 523*cdf0e10cSrcweir { 524*cdf0e10cSrcweir aOldRegion = pDev->GetClipRegion(); 525*cdf0e10cSrcweir pDev->IntersectClipRegion( rRect ); 526*cdf0e10cSrcweir } 527*cdf0e10cSrcweir else 528*cdf0e10cSrcweir { 529*cdf0e10cSrcweir Region aRegion( rRect ); 530*cdf0e10cSrcweir pDev->SetClipRegion( aRegion ); 531*cdf0e10cSrcweir } 532*cdf0e10cSrcweir } 533*cdf0e10cSrcweir 534*cdf0e10cSrcweir // Vertikales Alignment 535*cdf0e10cSrcweir if ( nStyle & TEXT_DRAW_BOTTOM ) 536*cdf0e10cSrcweir aPos.Y() += nHeight-(nFormatLines*nTextHeight); 537*cdf0e10cSrcweir else if ( nStyle & TEXT_DRAW_VCENTER ) 538*cdf0e10cSrcweir aPos.Y() += (nHeight-(nFormatLines*nTextHeight))/2; 539*cdf0e10cSrcweir 540*cdf0e10cSrcweir // Font Alignment 541*cdf0e10cSrcweir if ( eAlign == ALIGN_BOTTOM ) 542*cdf0e10cSrcweir aPos.Y() += nTextHeight; 543*cdf0e10cSrcweir else if ( eAlign == ALIGN_BASELINE ) 544*cdf0e10cSrcweir aPos.Y() += pDev->GetFontMetric().GetAscent(); 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir // Alle Zeilen ausgeben, bis auf die letzte 547*cdf0e10cSrcweir for ( i = 0; i < nFormatLines; i++ ) 548*cdf0e10cSrcweir { 549*cdf0e10cSrcweir pLineInfo = aMultiLineInfo.GetLine( i ); 550*cdf0e10cSrcweir if ( nStyle & TEXT_DRAW_RIGHT ) 551*cdf0e10cSrcweir aPos.X() += nWidth-pLineInfo->GetWidth(); 552*cdf0e10cSrcweir else if ( nStyle & TEXT_DRAW_CENTER ) 553*cdf0e10cSrcweir aPos.X() += (nWidth-pLineInfo->GetWidth())/2; 554*cdf0e10cSrcweir pDev->DrawText( aPos, rStr, pLineInfo->GetIndex(), pLineInfo->GetLen() ); 555*cdf0e10cSrcweir aPos.Y() += nTextHeight; 556*cdf0e10cSrcweir aPos.X() = rRect.Left(); 557*cdf0e10cSrcweir } 558*cdf0e10cSrcweir 559*cdf0e10cSrcweir // Gibt es noch eine letzte Zeile, dann diese linksbuendig ausgeben, 560*cdf0e10cSrcweir // da die Zeile gekuerzt wurde 561*cdf0e10cSrcweir if ( aLastLine.Len() ) 562*cdf0e10cSrcweir pDev->DrawText( aPos, aLastLine ); 563*cdf0e10cSrcweir 564*cdf0e10cSrcweir // Clipping zuruecksetzen 565*cdf0e10cSrcweir if ( nStyle & TEXT_DRAW_CLIP ) 566*cdf0e10cSrcweir { 567*cdf0e10cSrcweir if ( bIsClipRegion ) 568*cdf0e10cSrcweir pDev->SetClipRegion( aOldRegion ); 569*cdf0e10cSrcweir else 570*cdf0e10cSrcweir pDev->SetClipRegion(); 571*cdf0e10cSrcweir } 572*cdf0e10cSrcweir } 573*cdf0e10cSrcweir else 574*cdf0e10cSrcweir { 575*cdf0e10cSrcweir XubString aStr = rStr; 576*cdf0e10cSrcweir Size aTextSize(pDev->GetTextWidth( aStr ), pDev->GetTextHeight()); 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir // Evt. Text kuerzen 579*cdf0e10cSrcweir if ( aTextSize.Width() > nWidth ) 580*cdf0e10cSrcweir { 581*cdf0e10cSrcweir if ( nStyle & TEXT_DRAW_ENDELLIPSIS ) 582*cdf0e10cSrcweir { 583*cdf0e10cSrcweir aStr = GetEllipsisString( pDev, rStr, nWidth, nStyle ); 584*cdf0e10cSrcweir nStyle &= ~(TEXT_DRAW_CENTER | TEXT_DRAW_RIGHT); 585*cdf0e10cSrcweir nStyle |= TEXT_DRAW_LEFT; 586*cdf0e10cSrcweir aTextSize.Width() = pDev->GetTextWidth(aStr); 587*cdf0e10cSrcweir } 588*cdf0e10cSrcweir } 589*cdf0e10cSrcweir else 590*cdf0e10cSrcweir { 591*cdf0e10cSrcweir if ( aTextSize.Height() <= nHeight ) 592*cdf0e10cSrcweir nStyle &= ~TEXT_DRAW_CLIP; 593*cdf0e10cSrcweir } 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir // Vertikales Alignment 596*cdf0e10cSrcweir if ( nStyle & TEXT_DRAW_RIGHT ) 597*cdf0e10cSrcweir aPos.X() += nWidth-aTextSize.Width(); 598*cdf0e10cSrcweir else if ( nStyle & TEXT_DRAW_CENTER ) 599*cdf0e10cSrcweir aPos.X() += (nWidth-aTextSize.Width())/2; 600*cdf0e10cSrcweir 601*cdf0e10cSrcweir // Font Alignment 602*cdf0e10cSrcweir if ( eAlign == ALIGN_BOTTOM ) 603*cdf0e10cSrcweir aPos.Y() += aTextSize.Height(); 604*cdf0e10cSrcweir else if ( eAlign == ALIGN_BASELINE ) 605*cdf0e10cSrcweir aPos.Y() += pDev->GetFontMetric().GetAscent(); 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir if ( nStyle & TEXT_DRAW_BOTTOM ) 608*cdf0e10cSrcweir aPos.Y() += nHeight-aTextSize.Height(); 609*cdf0e10cSrcweir else if ( nStyle & TEXT_DRAW_VCENTER ) 610*cdf0e10cSrcweir aPos.Y() += (nHeight-aTextSize.Height())/2; 611*cdf0e10cSrcweir 612*cdf0e10cSrcweir if ( nStyle & TEXT_DRAW_CLIP ) 613*cdf0e10cSrcweir { 614*cdf0e10cSrcweir sal_Bool bIsClipRegion = pDev->IsClipRegion(); 615*cdf0e10cSrcweir if ( bIsClipRegion ) 616*cdf0e10cSrcweir { 617*cdf0e10cSrcweir Region aOldRegion = pDev->GetClipRegion(); 618*cdf0e10cSrcweir pDev->IntersectClipRegion( rRect ); 619*cdf0e10cSrcweir pDev->DrawText( aPos, aStr ); 620*cdf0e10cSrcweir pDev->SetClipRegion( aOldRegion ); 621*cdf0e10cSrcweir } 622*cdf0e10cSrcweir else 623*cdf0e10cSrcweir { 624*cdf0e10cSrcweir Region aRegion( rRect ); 625*cdf0e10cSrcweir pDev->SetClipRegion( aRegion ); 626*cdf0e10cSrcweir pDev->DrawText( aPos, aStr ); 627*cdf0e10cSrcweir pDev->SetClipRegion(); 628*cdf0e10cSrcweir } 629*cdf0e10cSrcweir } 630*cdf0e10cSrcweir else 631*cdf0e10cSrcweir pDev->DrawText( aPos, aStr ); 632*cdf0e10cSrcweir } 633*cdf0e10cSrcweir } 634*cdf0e10cSrcweir 635*cdf0e10cSrcweir // ----------------------------------------------------------------------- 636*cdf0e10cSrcweir 637*cdf0e10cSrcweir 638*cdf0e10cSrcweir //-------------------------------------------------------------------------- 639*cdf0e10cSrcweir //-------------------------------------------------------------------------- 640*cdf0e10cSrcweir //-------------------------------------------------------------------------- 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir 643*cdf0e10cSrcweir #define DRAWTEXT_FLAGS (TEXT_DRAW_CENTER|TEXT_DRAW_TOP|TEXT_DRAW_ENDELLIPSIS|\ 644*cdf0e10cSrcweir TEXT_DRAW_CLIP|TEXT_DRAW_MULTILINE|TEXT_DRAW_WORDBREAK) 645*cdf0e10cSrcweir 646*cdf0e10cSrcweir 647*cdf0e10cSrcweir class ImpIcnCursor 648*cdf0e10cSrcweir { 649*cdf0e10cSrcweir SvImpIconView* pView; 650*cdf0e10cSrcweir SvPtrarr* pColumns; 651*cdf0e10cSrcweir SvPtrarr* pRows; 652*cdf0e10cSrcweir sal_Bool* pGridMap; 653*cdf0e10cSrcweir long nGridDX, nGridDY; 654*cdf0e10cSrcweir long nGridCols, nGridRows; 655*cdf0e10cSrcweir long nCols; 656*cdf0e10cSrcweir long nRows; 657*cdf0e10cSrcweir short nDeltaWidth; 658*cdf0e10cSrcweir short nDeltaHeight; 659*cdf0e10cSrcweir SvLBoxEntry* pCurEntry; 660*cdf0e10cSrcweir void SetDeltas(); 661*cdf0e10cSrcweir void ImplCreate(); 662*cdf0e10cSrcweir void Create() { if( !pColumns ) ImplCreate(); } 663*cdf0e10cSrcweir 664*cdf0e10cSrcweir sal_uInt16 GetSortListPos( SvPtrarr* pList, long nValue, int bVertical); 665*cdf0e10cSrcweir SvLBoxEntry* SearchCol(sal_uInt16 nCol,sal_uInt16 nTop,sal_uInt16 nBottom,sal_uInt16 nPref, 666*cdf0e10cSrcweir sal_Bool bDown, sal_Bool bSimple ); 667*cdf0e10cSrcweir SvLBoxEntry* SearchRow(sal_uInt16 nRow,sal_uInt16 nRight,sal_uInt16 nLeft,sal_uInt16 nPref, 668*cdf0e10cSrcweir sal_Bool bRight, sal_Bool bSimple ); 669*cdf0e10cSrcweir 670*cdf0e10cSrcweir void ExpandGrid(); 671*cdf0e10cSrcweir void CreateGridMap(); 672*cdf0e10cSrcweir // Rueckgabe sal_False: Eintrag liegt nicht in der GridMap. rGridx,y werden 673*cdf0e10cSrcweir // dann an nGridCols, nGridRows geclippt 674*cdf0e10cSrcweir sal_Bool GetGrid( const Point& rDocPos, sal_uInt16& rGridX, sal_uInt16& rGridY ) const; 675*cdf0e10cSrcweir void SetGridUsed( sal_uInt16 nDX, sal_uInt16 nDY, sal_Bool bUsed ) 676*cdf0e10cSrcweir { 677*cdf0e10cSrcweir pGridMap[ (nDY * nGridCols) + nDX ] = bUsed; 678*cdf0e10cSrcweir } 679*cdf0e10cSrcweir sal_Bool IsGridUsed( sal_uInt16 nDX, sal_uInt16 nDY ) 680*cdf0e10cSrcweir { 681*cdf0e10cSrcweir return pGridMap[ (nDY * nGridCols) + nDX ]; 682*cdf0e10cSrcweir } 683*cdf0e10cSrcweir public: 684*cdf0e10cSrcweir ImpIcnCursor( SvImpIconView* pOwner ); 685*cdf0e10cSrcweir ~ImpIcnCursor(); 686*cdf0e10cSrcweir void Clear( sal_Bool bGridToo = sal_True ); 687*cdf0e10cSrcweir 688*cdf0e10cSrcweir // fuer Cursortravelling usw. 689*cdf0e10cSrcweir SvLBoxEntry* GoLeftRight( SvLBoxEntry*, sal_Bool bRight ); 690*cdf0e10cSrcweir SvLBoxEntry* GoUpDown( SvLBoxEntry*, sal_Bool bDown ); 691*cdf0e10cSrcweir 692*cdf0e10cSrcweir // Rueckgaebe: sal_False == Das leere Rect steht hinter dem letzten 693*cdf0e10cSrcweir // Eintrag; d.h. beim naechsten Einfuegen ergibt sich das naechste 694*cdf0e10cSrcweir // leere Rechteck durch Addition. Hinweis: Das Rechteck kann dann 695*cdf0e10cSrcweir // ausserhalb des View-Space liegen 696*cdf0e10cSrcweir sal_Bool FindEmptyGridRect( Rectangle& rRect ); 697*cdf0e10cSrcweir 698*cdf0e10cSrcweir // Erzeugt fuer jede Zeile (Hoehe=nGridDY) eine nach BoundRect.Left() 699*cdf0e10cSrcweir // sortierte Liste der Eintraege, die in ihr stehen. Eine Liste kann 700*cdf0e10cSrcweir // leer sein. Die Listen gehen in das Eigentum des Rufenden ueber und 701*cdf0e10cSrcweir // muessen mit DestroyGridAdjustData geloescht werden 702*cdf0e10cSrcweir void CreateGridAjustData( SvPtrarr& pLists, SvLBoxEntry* pRow=0); 703*cdf0e10cSrcweir static void DestroyGridAdjustData( SvPtrarr& rLists ); 704*cdf0e10cSrcweir void SetGridUsed( const Rectangle&, sal_Bool bUsed = sal_True ); 705*cdf0e10cSrcweir }; 706*cdf0e10cSrcweir 707*cdf0e10cSrcweir 708*cdf0e10cSrcweir 709*cdf0e10cSrcweir 710*cdf0e10cSrcweir SvImpIconView::SvImpIconView( SvIconView* pCurView, SvLBoxTreeList* pTree, 711*cdf0e10cSrcweir WinBits i_nWinStyle ) : 712*cdf0e10cSrcweir aVerSBar( pCurView, WB_DRAG | WB_VSCROLL ), 713*cdf0e10cSrcweir aHorSBar( pCurView, WB_DRAG | WB_HSCROLL ) 714*cdf0e10cSrcweir { 715*cdf0e10cSrcweir pView = pCurView; 716*cdf0e10cSrcweir pModel = pTree; 717*cdf0e10cSrcweir pCurParent = 0; 718*cdf0e10cSrcweir pZOrderList = new SvPtrarr; 719*cdf0e10cSrcweir SetStyle( i_nWinStyle ); 720*cdf0e10cSrcweir nHorDist = 0; 721*cdf0e10cSrcweir nVerDist = 0; 722*cdf0e10cSrcweir nFlags = 0; 723*cdf0e10cSrcweir nCurUserEvent = 0; 724*cdf0e10cSrcweir nMaxVirtWidth = 200; 725*cdf0e10cSrcweir pDDRefEntry = 0; 726*cdf0e10cSrcweir pDDDev = 0; 727*cdf0e10cSrcweir pDDBufDev = 0; 728*cdf0e10cSrcweir pDDTempDev = 0; 729*cdf0e10cSrcweir eTextMode = ShowTextShort; 730*cdf0e10cSrcweir pImpCursor = new ImpIcnCursor( this ); 731*cdf0e10cSrcweir 732*cdf0e10cSrcweir aVerSBar.SetScrollHdl( LINK( this, SvImpIconView, ScrollUpDownHdl ) ); 733*cdf0e10cSrcweir aHorSBar.SetScrollHdl( LINK( this, SvImpIconView, ScrollLeftRightHdl ) ); 734*cdf0e10cSrcweir nHorSBarHeight = aHorSBar.GetSizePixel().Height(); 735*cdf0e10cSrcweir nVerSBarWidth = aVerSBar.GetSizePixel().Width(); 736*cdf0e10cSrcweir 737*cdf0e10cSrcweir aMouseMoveTimer.SetTimeout( 20 ); 738*cdf0e10cSrcweir aMouseMoveTimer.SetTimeoutHdl(LINK(this,SvImpIconView,MouseMoveTimeoutHdl)); 739*cdf0e10cSrcweir 740*cdf0e10cSrcweir aEditTimer.SetTimeout( 800 ); 741*cdf0e10cSrcweir aEditTimer.SetTimeoutHdl(LINK(this,SvImpIconView,EditTimeoutHdl)); 742*cdf0e10cSrcweir 743*cdf0e10cSrcweir Clear( sal_True ); 744*cdf0e10cSrcweir } 745*cdf0e10cSrcweir 746*cdf0e10cSrcweir SvImpIconView::~SvImpIconView() 747*cdf0e10cSrcweir { 748*cdf0e10cSrcweir StopEditTimer(); 749*cdf0e10cSrcweir CancelUserEvent(); 750*cdf0e10cSrcweir delete pZOrderList; 751*cdf0e10cSrcweir delete pImpCursor; 752*cdf0e10cSrcweir delete pDDDev; 753*cdf0e10cSrcweir delete pDDBufDev; 754*cdf0e10cSrcweir delete pDDTempDev; 755*cdf0e10cSrcweir ClearSelectedRectList(); 756*cdf0e10cSrcweir } 757*cdf0e10cSrcweir 758*cdf0e10cSrcweir void SvImpIconView::Clear( sal_Bool bInCtor ) 759*cdf0e10cSrcweir { 760*cdf0e10cSrcweir StopEditTimer(); 761*cdf0e10cSrcweir CancelUserEvent(); 762*cdf0e10cSrcweir nMaxBmpWidth = 0; 763*cdf0e10cSrcweir nMaxBmpHeight = 0; 764*cdf0e10cSrcweir nMaxTextWidth = 0; 765*cdf0e10cSrcweir bMustRecalcBoundingRects = sal_False; 766*cdf0e10cSrcweir nMaxBoundHeight = 0; 767*cdf0e10cSrcweir 768*cdf0e10cSrcweir //XXX 769*cdf0e10cSrcweir nFlags |= F_GRID_INSERT; 770*cdf0e10cSrcweir nFlags &= ~F_PAINTED; 771*cdf0e10cSrcweir SetNextEntryPos( Point( LROFFS_WINBORDER, TBOFFS_WINBORDER ) ); 772*cdf0e10cSrcweir pCursor = 0; 773*cdf0e10cSrcweir if( !bInCtor ) 774*cdf0e10cSrcweir { 775*cdf0e10cSrcweir pImpCursor->Clear(); 776*cdf0e10cSrcweir aVirtOutputSize.Width() = 0; 777*cdf0e10cSrcweir aVirtOutputSize.Height() = 0; 778*cdf0e10cSrcweir pZOrderList->Remove(0,pZOrderList->Count()); 779*cdf0e10cSrcweir MapMode aMapMode( pView->GetMapMode()); 780*cdf0e10cSrcweir aMapMode.SetOrigin( Point() ); 781*cdf0e10cSrcweir pView->SetMapMode( aMapMode ); 782*cdf0e10cSrcweir if( pView->IsUpdateMode() ) 783*cdf0e10cSrcweir pView->Invalidate(); 784*cdf0e10cSrcweir } 785*cdf0e10cSrcweir AdjustScrollBars(); 786*cdf0e10cSrcweir } 787*cdf0e10cSrcweir 788*cdf0e10cSrcweir void SvImpIconView::SetStyle( const WinBits i_nWinStyle ) 789*cdf0e10cSrcweir { 790*cdf0e10cSrcweir nViewMode = VIEWMODE_TEXT; 791*cdf0e10cSrcweir if( i_nWinStyle & WB_NAME ) 792*cdf0e10cSrcweir nViewMode = VIEWMODE_NAME; 793*cdf0e10cSrcweir if( i_nWinStyle & WB_ICON ) 794*cdf0e10cSrcweir nViewMode = VIEWMODE_ICON; 795*cdf0e10cSrcweir } 796*cdf0e10cSrcweir 797*cdf0e10cSrcweir 798*cdf0e10cSrcweir IMPL_LINK( SvImpIconView, ScrollUpDownHdl, ScrollBar *, pScrollBar ) 799*cdf0e10cSrcweir { 800*cdf0e10cSrcweir pView->EndEditing( sal_True ); 801*cdf0e10cSrcweir // Pfeil hoch: delta=-1; Pfeil runter: delta=+1 802*cdf0e10cSrcweir Scroll( 0, pScrollBar->GetDelta(), sal_True ); 803*cdf0e10cSrcweir return 0; 804*cdf0e10cSrcweir } 805*cdf0e10cSrcweir 806*cdf0e10cSrcweir IMPL_LINK( SvImpIconView, ScrollLeftRightHdl, ScrollBar *, pScrollBar ) 807*cdf0e10cSrcweir { 808*cdf0e10cSrcweir pView->EndEditing( sal_True ); 809*cdf0e10cSrcweir // Pfeil links: delta=-1; Pfeil rechts: delta=+1 810*cdf0e10cSrcweir Scroll( pScrollBar->GetDelta(), 0, sal_True ); 811*cdf0e10cSrcweir return 0; 812*cdf0e10cSrcweir } 813*cdf0e10cSrcweir 814*cdf0e10cSrcweir void SvImpIconView::ChangedFont() 815*cdf0e10cSrcweir { 816*cdf0e10cSrcweir StopEditTimer(); 817*cdf0e10cSrcweir ImpArrange(); 818*cdf0e10cSrcweir } 819*cdf0e10cSrcweir 820*cdf0e10cSrcweir 821*cdf0e10cSrcweir void SvImpIconView::CheckAllSizes() 822*cdf0e10cSrcweir { 823*cdf0e10cSrcweir nMaxTextWidth = 0; 824*cdf0e10cSrcweir nMaxBmpWidth = 0; 825*cdf0e10cSrcweir nMaxBmpHeight = 0; 826*cdf0e10cSrcweir SvLBoxEntry* pEntry = pModel->First(); 827*cdf0e10cSrcweir while( pEntry ) 828*cdf0e10cSrcweir { 829*cdf0e10cSrcweir CheckSizes( pEntry ); 830*cdf0e10cSrcweir pEntry = pModel->Next( pEntry ); 831*cdf0e10cSrcweir } 832*cdf0e10cSrcweir } 833*cdf0e10cSrcweir 834*cdf0e10cSrcweir void SvImpIconView::CheckSizes( SvLBoxEntry* pEntry, 835*cdf0e10cSrcweir const SvIcnVwDataEntry* pViewData ) 836*cdf0e10cSrcweir { 837*cdf0e10cSrcweir Size aSize; 838*cdf0e10cSrcweir 839*cdf0e10cSrcweir if( !pViewData ) 840*cdf0e10cSrcweir pViewData = ICNVIEWDATA(pEntry); 841*cdf0e10cSrcweir 842*cdf0e10cSrcweir SvLBoxString* pStringItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING)); 843*cdf0e10cSrcweir if( pStringItem ) 844*cdf0e10cSrcweir { 845*cdf0e10cSrcweir aSize = GetItemSize( pView, pEntry, pStringItem, pViewData ); 846*cdf0e10cSrcweir if( aSize.Width() > nMaxTextWidth ) 847*cdf0e10cSrcweir { 848*cdf0e10cSrcweir nMaxTextWidth = aSize.Width(); 849*cdf0e10cSrcweir if( !(nFlags & F_GRIDMODE ) ) 850*cdf0e10cSrcweir bMustRecalcBoundingRects = sal_True; 851*cdf0e10cSrcweir } 852*cdf0e10cSrcweir } 853*cdf0e10cSrcweir SvLBoxContextBmp* pBmpItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP)); 854*cdf0e10cSrcweir if( pBmpItem ) 855*cdf0e10cSrcweir { 856*cdf0e10cSrcweir aSize = GetItemSize( pView, pEntry, pBmpItem, pViewData ); 857*cdf0e10cSrcweir if( aSize.Width() > nMaxBmpWidth ) 858*cdf0e10cSrcweir { 859*cdf0e10cSrcweir nMaxBmpWidth = aSize.Width(); 860*cdf0e10cSrcweir nMaxBmpWidth += (2*LROFFS_ICON); 861*cdf0e10cSrcweir if( !(nFlags & F_GRIDMODE ) ) 862*cdf0e10cSrcweir bMustRecalcBoundingRects = sal_True; 863*cdf0e10cSrcweir } 864*cdf0e10cSrcweir if( aSize.Height() > nMaxBmpHeight ) 865*cdf0e10cSrcweir { 866*cdf0e10cSrcweir nMaxBmpHeight = aSize.Height(); 867*cdf0e10cSrcweir nMaxBmpHeight += (2*TBOFFS_ICON);; 868*cdf0e10cSrcweir if( !(nFlags & F_GRIDMODE ) ) 869*cdf0e10cSrcweir bMustRecalcBoundingRects = sal_True; 870*cdf0e10cSrcweir } 871*cdf0e10cSrcweir } 872*cdf0e10cSrcweir } 873*cdf0e10cSrcweir 874*cdf0e10cSrcweir void SvImpIconView::EntryInserted( SvLBoxEntry* pEntry ) 875*cdf0e10cSrcweir { 876*cdf0e10cSrcweir if( pModel->GetParent(pEntry) == pCurParent ) 877*cdf0e10cSrcweir { 878*cdf0e10cSrcweir StopEditTimer(); 879*cdf0e10cSrcweir DBG_ASSERT(pZOrderList->GetPos(pEntry)==0xffff,"EntryInserted:ZOrder?"); 880*cdf0e10cSrcweir pZOrderList->Insert( pEntry, pZOrderList->Count() ); 881*cdf0e10cSrcweir if( nFlags & F_GRIDMODE ) 882*cdf0e10cSrcweir pImpCursor->Clear( sal_False ); 883*cdf0e10cSrcweir else 884*cdf0e10cSrcweir pImpCursor->Clear( sal_True ); 885*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry); 886*cdf0e10cSrcweir CheckSizes( pEntry, pViewData ); 887*cdf0e10cSrcweir if( pView->IsUpdateMode() ) 888*cdf0e10cSrcweir { 889*cdf0e10cSrcweir FindBoundingRect( pEntry, pViewData ); 890*cdf0e10cSrcweir PaintEntry( pEntry, pViewData ); 891*cdf0e10cSrcweir } 892*cdf0e10cSrcweir else 893*cdf0e10cSrcweir InvalidateBoundingRect( pViewData->aRect ); 894*cdf0e10cSrcweir } 895*cdf0e10cSrcweir } 896*cdf0e10cSrcweir 897*cdf0e10cSrcweir void SvImpIconView::RemovingEntry( SvLBoxEntry* pEntry ) 898*cdf0e10cSrcweir { 899*cdf0e10cSrcweir if( pModel->GetParent(pEntry) == pCurParent) 900*cdf0e10cSrcweir { 901*cdf0e10cSrcweir StopEditTimer(); 902*cdf0e10cSrcweir DBG_ASSERT(pZOrderList->GetPos(pEntry)!=0xffff,"RemovingEntry:ZOrder?"); 903*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry); 904*cdf0e10cSrcweir if( IsBoundingRectValid( pViewData->aRect ) ) 905*cdf0e10cSrcweir { 906*cdf0e10cSrcweir // bei gueltigem Bounding-Rect muss in EntryRemoved eine 907*cdf0e10cSrcweir // Sonderbehandlung erfolgen 908*cdf0e10cSrcweir nFlags |= F_ENTRY_REMOVED; 909*cdf0e10cSrcweir pView->Invalidate( pViewData->aRect ); 910*cdf0e10cSrcweir } 911*cdf0e10cSrcweir if( pEntry == pCursor ) 912*cdf0e10cSrcweir { 913*cdf0e10cSrcweir SvLBoxEntry* pNewCursor = GetNewCursor(); 914*cdf0e10cSrcweir ShowCursor( sal_False ); 915*cdf0e10cSrcweir pCursor = 0; // damit er nicht deselektiert wird 916*cdf0e10cSrcweir SetCursor( pNewCursor ); 917*cdf0e10cSrcweir } 918*cdf0e10cSrcweir sal_uInt16 nPos = pZOrderList->GetPos( (void*)pEntry ); 919*cdf0e10cSrcweir pZOrderList->Remove( nPos, 1 ); 920*cdf0e10cSrcweir pImpCursor->Clear(); 921*cdf0e10cSrcweir } 922*cdf0e10cSrcweir } 923*cdf0e10cSrcweir 924*cdf0e10cSrcweir void SvImpIconView::EntryRemoved() 925*cdf0e10cSrcweir { 926*cdf0e10cSrcweir if( (nFlags & (F_ENTRY_REMOVED | F_PAINTED)) == (F_ENTRY_REMOVED | F_PAINTED)) 927*cdf0e10cSrcweir { 928*cdf0e10cSrcweir // Ein Eintrag mit gueltigem BoundRect wurde geloescht und wir 929*cdf0e10cSrcweir // haben schon mal gepaintet. In diesem Fall muessen wir die 930*cdf0e10cSrcweir // Position des naechsten Eintrags, der eingefuegt wird oder noch 931*cdf0e10cSrcweir // kein gueltiges BoundRect hat, "suchen" d.h. ein "Loch" in 932*cdf0e10cSrcweir // der View auffuellen. 933*cdf0e10cSrcweir nFlags &= ~( F_ENTRY_REMOVED | F_GRID_INSERT ); 934*cdf0e10cSrcweir } 935*cdf0e10cSrcweir } 936*cdf0e10cSrcweir 937*cdf0e10cSrcweir 938*cdf0e10cSrcweir void SvImpIconView::MovingEntry( SvLBoxEntry* pEntry ) 939*cdf0e10cSrcweir { 940*cdf0e10cSrcweir DBG_ASSERT(pEntry,"MovingEntry: 0!"); 941*cdf0e10cSrcweir pNextCursor = 0; 942*cdf0e10cSrcweir StopEditTimer(); 943*cdf0e10cSrcweir if( pModel->GetParent(pEntry) == pCurParent ) 944*cdf0e10cSrcweir { 945*cdf0e10cSrcweir DBG_ASSERT(pZOrderList->GetPos(pEntry)!=0xffff,"MovingEntry:ZOrder?"); 946*cdf0e10cSrcweir nFlags |= F_MOVING_SIBLING; 947*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry); 948*cdf0e10cSrcweir if( IsBoundingRectValid( pViewData->aRect ) ) 949*cdf0e10cSrcweir pView->Invalidate( pViewData->aRect ); 950*cdf0e10cSrcweir // falls Eintrag seinen Parent wechselt vorsichtshalber 951*cdf0e10cSrcweir // die neue Cursorposition berechnen 952*cdf0e10cSrcweir if( pEntry == pCursor ) 953*cdf0e10cSrcweir pNextCursor = GetNewCursor(); 954*cdf0e10cSrcweir pImpCursor->Clear(); 955*cdf0e10cSrcweir } 956*cdf0e10cSrcweir } 957*cdf0e10cSrcweir 958*cdf0e10cSrcweir 959*cdf0e10cSrcweir void SvImpIconView::EntryMoved( SvLBoxEntry* pEntry ) 960*cdf0e10cSrcweir { 961*cdf0e10cSrcweir ShowCursor( sal_False ); 962*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry); 963*cdf0e10cSrcweir if( pModel->GetParent(pEntry)==pCurParent ) 964*cdf0e10cSrcweir { 965*cdf0e10cSrcweir if( nFlags & F_MOVING_SIBLING ) 966*cdf0e10cSrcweir { 967*cdf0e10cSrcweir // die Neu-Positionierung eines Eintrags bei D&D innerhalb 968*cdf0e10cSrcweir // einer IconView findet bereits in NotifyMoving statt 969*cdf0e10cSrcweir // (MovingEntry/EntryMoved wird dann nicht mehr gerufen) 970*cdf0e10cSrcweir ToTop( pEntry ); 971*cdf0e10cSrcweir } 972*cdf0e10cSrcweir else 973*cdf0e10cSrcweir { 974*cdf0e10cSrcweir pImpCursor->Clear(); 975*cdf0e10cSrcweir pZOrderList->Insert( pEntry, pZOrderList->Count() ); 976*cdf0e10cSrcweir DBG_ASSERT(pZOrderList->Count()==pModel->GetChildCount(pCurParent),"EntryMoved:Bad zorder count"); 977*cdf0e10cSrcweir FindBoundingRect( pEntry, pViewData ); 978*cdf0e10cSrcweir } 979*cdf0e10cSrcweir PaintEntry( pEntry, pViewData ); 980*cdf0e10cSrcweir } 981*cdf0e10cSrcweir else 982*cdf0e10cSrcweir { 983*cdf0e10cSrcweir if( pEntry == pCursor ) 984*cdf0e10cSrcweir { 985*cdf0e10cSrcweir DBG_ASSERT(pNextCursor,"EntryMoved: Next cursor bad"); 986*cdf0e10cSrcweir SetCursor( pNextCursor ); 987*cdf0e10cSrcweir } 988*cdf0e10cSrcweir pImpCursor->Clear(); 989*cdf0e10cSrcweir sal_uInt16 nPos = pZOrderList->GetPos( (void*)pEntry ); 990*cdf0e10cSrcweir pZOrderList->Remove( nPos, 1 ); 991*cdf0e10cSrcweir pView->Select( pEntry, sal_False ); 992*cdf0e10cSrcweir // wenn er nochmal in dieser View auftaucht, muss sein 993*cdf0e10cSrcweir // Bounding-Rect neu berechnet werden 994*cdf0e10cSrcweir InvalidateBoundingRect( pViewData->aRect ); 995*cdf0e10cSrcweir } 996*cdf0e10cSrcweir nFlags &= (~F_MOVING_SIBLING); 997*cdf0e10cSrcweir } 998*cdf0e10cSrcweir 999*cdf0e10cSrcweir void SvImpIconView::TreeInserted( SvLBoxEntry* pEntry ) 1000*cdf0e10cSrcweir { 1001*cdf0e10cSrcweir EntryMoved( pEntry ); // vorlaeufig 1002*cdf0e10cSrcweir } 1003*cdf0e10cSrcweir 1004*cdf0e10cSrcweir void SvImpIconView::EntryExpanded( SvLBoxEntry* ) 1005*cdf0e10cSrcweir { 1006*cdf0e10cSrcweir } 1007*cdf0e10cSrcweir 1008*cdf0e10cSrcweir void SvImpIconView::EntryCollapsed( SvLBoxEntry*) 1009*cdf0e10cSrcweir { 1010*cdf0e10cSrcweir } 1011*cdf0e10cSrcweir 1012*cdf0e10cSrcweir void SvImpIconView::CollapsingEntry( SvLBoxEntry* ) 1013*cdf0e10cSrcweir { 1014*cdf0e10cSrcweir } 1015*cdf0e10cSrcweir 1016*cdf0e10cSrcweir void SvImpIconView::EntrySelected( SvLBoxEntry* pEntry, sal_Bool bSelect ) 1017*cdf0e10cSrcweir { 1018*cdf0e10cSrcweir if( pModel->GetParent(pEntry) != pCurParent ) 1019*cdf0e10cSrcweir return; 1020*cdf0e10cSrcweir 1021*cdf0e10cSrcweir // bei SingleSelection dafuer sorgen, dass der Cursor immer 1022*cdf0e10cSrcweir // auf dem (einzigen) selektierten Eintrag steht 1023*cdf0e10cSrcweir if( bSelect && pCursor && 1024*cdf0e10cSrcweir pView->GetSelectionMode() == SINGLE_SELECTION && 1025*cdf0e10cSrcweir pEntry != pCursor ) 1026*cdf0e10cSrcweir { 1027*cdf0e10cSrcweir SetCursor( pEntry ); 1028*cdf0e10cSrcweir DBG_ASSERT(pView->GetSelectionCount()==1,"selection count?"); 1029*cdf0e10cSrcweir } 1030*cdf0e10cSrcweir // bei Gummibandselektion ist uns das zu teuer 1031*cdf0e10cSrcweir if( !(nFlags & F_RUBBERING )) 1032*cdf0e10cSrcweir ToTop( pEntry ); 1033*cdf0e10cSrcweir if( pView->IsUpdateMode() ) 1034*cdf0e10cSrcweir { 1035*cdf0e10cSrcweir if( pEntry == pCursor ) 1036*cdf0e10cSrcweir ShowCursor( sal_False ); 1037*cdf0e10cSrcweir if( nFlags & F_RUBBERING ) 1038*cdf0e10cSrcweir PaintEntry( pEntry ); 1039*cdf0e10cSrcweir else 1040*cdf0e10cSrcweir pView->Invalidate( GetBoundingRect( pEntry ) ); 1041*cdf0e10cSrcweir if( pEntry == pCursor ) 1042*cdf0e10cSrcweir ShowCursor( sal_True ); 1043*cdf0e10cSrcweir } 1044*cdf0e10cSrcweir } 1045*cdf0e10cSrcweir 1046*cdf0e10cSrcweir void SvImpIconView::SetNextEntryPos(const Point& rPos) 1047*cdf0e10cSrcweir { 1048*cdf0e10cSrcweir aPrevBoundRect.SetPos( rPos ); 1049*cdf0e10cSrcweir aPrevBoundRect.Right() = LONG_MAX; // dont know 1050*cdf0e10cSrcweir } 1051*cdf0e10cSrcweir 1052*cdf0e10cSrcweir Point SvImpIconView::FindNextEntryPos( const Size& rBoundSize ) 1053*cdf0e10cSrcweir { 1054*cdf0e10cSrcweir if( nFlags & F_GRIDMODE ) 1055*cdf0e10cSrcweir { 1056*cdf0e10cSrcweir if( nFlags & F_GRID_INSERT ) 1057*cdf0e10cSrcweir { 1058*cdf0e10cSrcweir if( aPrevBoundRect.Right() != LONG_MAX ) 1059*cdf0e10cSrcweir { 1060*cdf0e10cSrcweir // passt der naechste Entry noch in die Zeile ? 1061*cdf0e10cSrcweir long nNextWidth = aPrevBoundRect.Right() + nGridDX + LROFFS_WINBORDER; 1062*cdf0e10cSrcweir if( nNextWidth > aVirtOutputSize.Width() ) 1063*cdf0e10cSrcweir { 1064*cdf0e10cSrcweir // darf aVirtOutputSize verbreitert werden ? 1065*cdf0e10cSrcweir if( nNextWidth < nMaxVirtWidth ) 1066*cdf0e10cSrcweir { 1067*cdf0e10cSrcweir // verbreitern & in Zeile aufnehmen 1068*cdf0e10cSrcweir aPrevBoundRect.Left() += nGridDX; 1069*cdf0e10cSrcweir } 1070*cdf0e10cSrcweir else 1071*cdf0e10cSrcweir { 1072*cdf0e10cSrcweir // erhoehen & neue Zeile beginnen 1073*cdf0e10cSrcweir aPrevBoundRect.Top() += nGridDY; 1074*cdf0e10cSrcweir aPrevBoundRect.Left() = LROFFS_WINBORDER; 1075*cdf0e10cSrcweir } 1076*cdf0e10cSrcweir } 1077*cdf0e10cSrcweir else 1078*cdf0e10cSrcweir { 1079*cdf0e10cSrcweir // in die Zeile aufnehmen 1080*cdf0e10cSrcweir aPrevBoundRect.Left() += nGridDX; 1081*cdf0e10cSrcweir } 1082*cdf0e10cSrcweir } 1083*cdf0e10cSrcweir aPrevBoundRect.SetSize( Size( nGridDX, nGridDY ) ); 1084*cdf0e10cSrcweir } 1085*cdf0e10cSrcweir else 1086*cdf0e10cSrcweir { 1087*cdf0e10cSrcweir if( !pImpCursor->FindEmptyGridRect( aPrevBoundRect ) ) 1088*cdf0e10cSrcweir { 1089*cdf0e10cSrcweir // mitten in den Entries gibts keine Loecher mehr, 1090*cdf0e10cSrcweir // wir koennen also wieder ins "Fast Insert" springen 1091*cdf0e10cSrcweir nFlags |= F_GRID_INSERT; 1092*cdf0e10cSrcweir } 1093*cdf0e10cSrcweir } 1094*cdf0e10cSrcweir } 1095*cdf0e10cSrcweir else 1096*cdf0e10cSrcweir { 1097*cdf0e10cSrcweir if( aPrevBoundRect.Right() != LONG_MAX ) 1098*cdf0e10cSrcweir { 1099*cdf0e10cSrcweir // passt der naechste Entry noch in die Zeile ? 1100*cdf0e10cSrcweir long nNextWidth=aPrevBoundRect.Right()+rBoundSize.Width()+LROFFS_BOUND+nHorDist; 1101*cdf0e10cSrcweir if( nNextWidth > aVirtOutputSize.Width() ) 1102*cdf0e10cSrcweir { 1103*cdf0e10cSrcweir // darf aVirtOutputSize verbreitert werden ? 1104*cdf0e10cSrcweir if( nNextWidth < nMaxVirtWidth ) 1105*cdf0e10cSrcweir { 1106*cdf0e10cSrcweir // verbreitern & in Zeile aufnehmen 1107*cdf0e10cSrcweir aPrevBoundRect.SetPos( aPrevBoundRect.TopRight() ); 1108*cdf0e10cSrcweir aPrevBoundRect.Left() += nHorDist; 1109*cdf0e10cSrcweir } 1110*cdf0e10cSrcweir else 1111*cdf0e10cSrcweir { 1112*cdf0e10cSrcweir // erhoehen & neue Zeile beginnen 1113*cdf0e10cSrcweir aPrevBoundRect.Top() += nMaxBoundHeight + nVerDist + TBOFFS_BOUND; 1114*cdf0e10cSrcweir aPrevBoundRect.Left() = LROFFS_WINBORDER; 1115*cdf0e10cSrcweir } 1116*cdf0e10cSrcweir } 1117*cdf0e10cSrcweir else 1118*cdf0e10cSrcweir { 1119*cdf0e10cSrcweir // in die Zeile aufnehmen 1120*cdf0e10cSrcweir aPrevBoundRect.SetPos( aPrevBoundRect.TopRight() ); 1121*cdf0e10cSrcweir aPrevBoundRect.Left() += nHorDist; 1122*cdf0e10cSrcweir } 1123*cdf0e10cSrcweir } 1124*cdf0e10cSrcweir aPrevBoundRect.SetSize( rBoundSize ); 1125*cdf0e10cSrcweir } 1126*cdf0e10cSrcweir return aPrevBoundRect.TopLeft(); 1127*cdf0e10cSrcweir } 1128*cdf0e10cSrcweir 1129*cdf0e10cSrcweir void SvImpIconView::ResetVirtSize() 1130*cdf0e10cSrcweir { 1131*cdf0e10cSrcweir StopEditTimer(); 1132*cdf0e10cSrcweir aVirtOutputSize.Width() = 0; 1133*cdf0e10cSrcweir aVirtOutputSize.Height() = 0; 1134*cdf0e10cSrcweir sal_Bool bLockedEntryFound = sal_False; 1135*cdf0e10cSrcweir nFlags &= (~F_GRID_INSERT); 1136*cdf0e10cSrcweir SvLBoxEntry* pCur = pModel->FirstChild( pCurParent ); 1137*cdf0e10cSrcweir while( pCur ) 1138*cdf0e10cSrcweir { 1139*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pCur); 1140*cdf0e10cSrcweir if( pViewData->IsEntryPosLocked() ) 1141*cdf0e10cSrcweir { 1142*cdf0e10cSrcweir // VirtSize u.a. anpassen 1143*cdf0e10cSrcweir if( !IsBoundingRectValid( pViewData->aRect ) ) 1144*cdf0e10cSrcweir FindBoundingRect( pCur, pViewData ); 1145*cdf0e10cSrcweir else 1146*cdf0e10cSrcweir AdjustVirtSize( pViewData->aRect ); 1147*cdf0e10cSrcweir bLockedEntryFound = sal_True; 1148*cdf0e10cSrcweir } 1149*cdf0e10cSrcweir else 1150*cdf0e10cSrcweir InvalidateBoundingRect( pViewData->aRect ); 1151*cdf0e10cSrcweir 1152*cdf0e10cSrcweir pCur = pModel->NextSibling( pCur ); 1153*cdf0e10cSrcweir } 1154*cdf0e10cSrcweir if( !bLockedEntryFound ) 1155*cdf0e10cSrcweir { 1156*cdf0e10cSrcweir //XXX 1157*cdf0e10cSrcweir nFlags |= F_GRID_INSERT; 1158*cdf0e10cSrcweir } 1159*cdf0e10cSrcweir 1160*cdf0e10cSrcweir SetNextEntryPos( Point( LROFFS_WINBORDER, TBOFFS_WINBORDER ) ); 1161*cdf0e10cSrcweir pImpCursor->Clear(); 1162*cdf0e10cSrcweir } 1163*cdf0e10cSrcweir 1164*cdf0e10cSrcweir 1165*cdf0e10cSrcweir void SvImpIconView::AdjustVirtSize( const Rectangle& rRect ) 1166*cdf0e10cSrcweir { 1167*cdf0e10cSrcweir long nHeightOffs = 0; 1168*cdf0e10cSrcweir long nWidthOffs = 0; 1169*cdf0e10cSrcweir 1170*cdf0e10cSrcweir if( aVirtOutputSize.Width() < (rRect.Right()+LROFFS_WINBORDER) ) 1171*cdf0e10cSrcweir nWidthOffs = (rRect.Right()+LROFFS_WINBORDER) - aVirtOutputSize.Width(); 1172*cdf0e10cSrcweir 1173*cdf0e10cSrcweir if( aVirtOutputSize.Height() < (rRect.Bottom()+TBOFFS_WINBORDER) ) 1174*cdf0e10cSrcweir nHeightOffs = (rRect.Bottom()+TBOFFS_WINBORDER) - aVirtOutputSize.Height(); 1175*cdf0e10cSrcweir 1176*cdf0e10cSrcweir if( nWidthOffs || nHeightOffs ) 1177*cdf0e10cSrcweir { 1178*cdf0e10cSrcweir Range aRange; 1179*cdf0e10cSrcweir aVirtOutputSize.Width() += nWidthOffs; 1180*cdf0e10cSrcweir aRange.Max() = aVirtOutputSize.Width(); 1181*cdf0e10cSrcweir aHorSBar.SetRange( aRange ); 1182*cdf0e10cSrcweir 1183*cdf0e10cSrcweir aVirtOutputSize.Height() += nHeightOffs; 1184*cdf0e10cSrcweir aRange.Max() = aVirtOutputSize.Height(); 1185*cdf0e10cSrcweir aVerSBar.SetRange( aRange ); 1186*cdf0e10cSrcweir 1187*cdf0e10cSrcweir pImpCursor->Clear(); 1188*cdf0e10cSrcweir AdjustScrollBars(); 1189*cdf0e10cSrcweir } 1190*cdf0e10cSrcweir } 1191*cdf0e10cSrcweir 1192*cdf0e10cSrcweir void SvImpIconView::Arrange() 1193*cdf0e10cSrcweir { 1194*cdf0e10cSrcweir nMaxVirtWidth = aOutputSize.Width(); 1195*cdf0e10cSrcweir ImpArrange(); 1196*cdf0e10cSrcweir } 1197*cdf0e10cSrcweir 1198*cdf0e10cSrcweir void SvImpIconView::ImpArrange() 1199*cdf0e10cSrcweir { 1200*cdf0e10cSrcweir StopEditTimer(); 1201*cdf0e10cSrcweir ShowCursor( sal_False ); 1202*cdf0e10cSrcweir ResetVirtSize(); 1203*cdf0e10cSrcweir bMustRecalcBoundingRects = sal_False; 1204*cdf0e10cSrcweir MapMode aMapMode( pView->GetMapMode()); 1205*cdf0e10cSrcweir aMapMode.SetOrigin( Point() ); 1206*cdf0e10cSrcweir pView->SetMapMode( aMapMode ); 1207*cdf0e10cSrcweir CheckAllSizes(); 1208*cdf0e10cSrcweir RecalcAllBoundingRectsSmart(); 1209*cdf0e10cSrcweir pView->Invalidate(); 1210*cdf0e10cSrcweir ShowCursor( sal_True ); 1211*cdf0e10cSrcweir } 1212*cdf0e10cSrcweir 1213*cdf0e10cSrcweir void SvImpIconView::Paint( const Rectangle& rRect ) 1214*cdf0e10cSrcweir { 1215*cdf0e10cSrcweir if( !pView->IsUpdateMode() ) 1216*cdf0e10cSrcweir return; 1217*cdf0e10cSrcweir 1218*cdf0e10cSrcweir #if defined(DBG_UTIL) && defined(OV_DRAWGRID) 1219*cdf0e10cSrcweir if( nFlags & F_GRIDMODE ) 1220*cdf0e10cSrcweir { 1221*cdf0e10cSrcweir Color aOldColor = pView->GetLineColor(); 1222*cdf0e10cSrcweir Color aNewColor( COL_BLACK ); 1223*cdf0e10cSrcweir pView->SetLineColor( aNewColor ); 1224*cdf0e10cSrcweir Point aOffs( pView->GetMapMode().GetOrigin()); 1225*cdf0e10cSrcweir Size aXSize( pView->GetOutputSizePixel() ); 1226*cdf0e10cSrcweir for( long nDX = nGridDX; nDX <= aXSize.Width(); nDX += nGridDX ) 1227*cdf0e10cSrcweir { 1228*cdf0e10cSrcweir Point aStart( nDX+LROFFS_BOUND, 0 ); 1229*cdf0e10cSrcweir Point aEnd( nDX+LROFFS_BOUND, aXSize.Height()); 1230*cdf0e10cSrcweir aStart -= aOffs; 1231*cdf0e10cSrcweir aEnd -= aOffs; 1232*cdf0e10cSrcweir pView->DrawLine( aStart, aEnd ); 1233*cdf0e10cSrcweir } 1234*cdf0e10cSrcweir for( long nDY = nGridDY; nDY <= aXSize.Height(); nDY += nGridDY ) 1235*cdf0e10cSrcweir { 1236*cdf0e10cSrcweir Point aStart( 0, nDY+TBOFFS_BOUND ); 1237*cdf0e10cSrcweir Point aEnd( aXSize.Width(), nDY+TBOFFS_BOUND ); 1238*cdf0e10cSrcweir aStart -= aOffs; 1239*cdf0e10cSrcweir aEnd -= aOffs; 1240*cdf0e10cSrcweir pView->DrawLine( aStart, aEnd ); 1241*cdf0e10cSrcweir } 1242*cdf0e10cSrcweir pView->SetLineColor( aOldColor ); 1243*cdf0e10cSrcweir } 1244*cdf0e10cSrcweir #endif 1245*cdf0e10cSrcweir nFlags |= F_PAINTED; 1246*cdf0e10cSrcweir 1247*cdf0e10cSrcweir if( !(pModel->HasChilds( pCurParent ) )) 1248*cdf0e10cSrcweir return; 1249*cdf0e10cSrcweir if( !pCursor ) 1250*cdf0e10cSrcweir pCursor = pModel->FirstChild( pCurParent ); 1251*cdf0e10cSrcweir 1252*cdf0e10cSrcweir sal_uInt16 nCount = pZOrderList->Count(); 1253*cdf0e10cSrcweir if( !nCount ) 1254*cdf0e10cSrcweir return; 1255*cdf0e10cSrcweir 1256*cdf0e10cSrcweir SvPtrarr* pNewZOrderList = new SvPtrarr; 1257*cdf0e10cSrcweir SvPtrarr* pPaintedEntries = new SvPtrarr; 1258*cdf0e10cSrcweir 1259*cdf0e10cSrcweir sal_uInt16 nPos = 0; 1260*cdf0e10cSrcweir while( nCount ) 1261*cdf0e10cSrcweir { 1262*cdf0e10cSrcweir SvLBoxEntry* pEntry = (SvLBoxEntry*)(pZOrderList->GetObject(nPos )); 1263*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry); 1264*cdf0e10cSrcweir const Rectangle& rBoundRect = GetBoundingRect( pEntry, pViewData ); 1265*cdf0e10cSrcweir if( rRect.IsOver( rBoundRect ) ) 1266*cdf0e10cSrcweir { 1267*cdf0e10cSrcweir PaintEntry( pEntry, rBoundRect.TopLeft(), pViewData ); 1268*cdf0e10cSrcweir // Eintraege, die neu gezeichnet werden, auf Top setzen 1269*cdf0e10cSrcweir pPaintedEntries->Insert( pEntry, pPaintedEntries->Count() ); 1270*cdf0e10cSrcweir } 1271*cdf0e10cSrcweir else 1272*cdf0e10cSrcweir pNewZOrderList->Insert( pEntry, pNewZOrderList->Count() ); 1273*cdf0e10cSrcweir 1274*cdf0e10cSrcweir nCount--; 1275*cdf0e10cSrcweir nPos++; 1276*cdf0e10cSrcweir } 1277*cdf0e10cSrcweir delete pZOrderList; 1278*cdf0e10cSrcweir pZOrderList = pNewZOrderList; 1279*cdf0e10cSrcweir nCount = pPaintedEntries->Count(); 1280*cdf0e10cSrcweir if( nCount ) 1281*cdf0e10cSrcweir { 1282*cdf0e10cSrcweir for( sal_uInt16 nCur = 0; nCur < nCount; nCur++ ) 1283*cdf0e10cSrcweir pZOrderList->Insert( pPaintedEntries->GetObject( nCur ),pZOrderList->Count()); 1284*cdf0e10cSrcweir } 1285*cdf0e10cSrcweir delete pPaintedEntries; 1286*cdf0e10cSrcweir 1287*cdf0e10cSrcweir Rectangle aRect; 1288*cdf0e10cSrcweir if( GetResizeRect( aRect )) 1289*cdf0e10cSrcweir PaintResizeRect( aRect ); 1290*cdf0e10cSrcweir } 1291*cdf0e10cSrcweir 1292*cdf0e10cSrcweir sal_Bool SvImpIconView::GetResizeRect( Rectangle& rRect ) 1293*cdf0e10cSrcweir { 1294*cdf0e10cSrcweir if( aHorSBar.IsVisible() && aVerSBar.IsVisible() ) 1295*cdf0e10cSrcweir { 1296*cdf0e10cSrcweir const MapMode& rMapMode = pView->GetMapMode(); 1297*cdf0e10cSrcweir Point aOrigin( rMapMode.GetOrigin()); 1298*cdf0e10cSrcweir aOrigin *= -1; 1299*cdf0e10cSrcweir aOrigin.X() += aOutputSize.Width(); 1300*cdf0e10cSrcweir aOrigin.Y() += aOutputSize.Height(); 1301*cdf0e10cSrcweir rRect.SetPos( aOrigin ); 1302*cdf0e10cSrcweir rRect.SetSize( Size( nVerSBarWidth, nHorSBarHeight)); 1303*cdf0e10cSrcweir return sal_True; 1304*cdf0e10cSrcweir } 1305*cdf0e10cSrcweir return sal_False; 1306*cdf0e10cSrcweir } 1307*cdf0e10cSrcweir 1308*cdf0e10cSrcweir void SvImpIconView::PaintResizeRect( const Rectangle& rRect ) 1309*cdf0e10cSrcweir { 1310*cdf0e10cSrcweir const StyleSettings& rStyleSettings = pView->GetSettings().GetStyleSettings(); 1311*cdf0e10cSrcweir Color aNewColor = rStyleSettings.GetFaceColor(); 1312*cdf0e10cSrcweir Color aOldColor = pView->GetFillColor(); 1313*cdf0e10cSrcweir pView->SetFillColor( aNewColor ); 1314*cdf0e10cSrcweir pView->DrawRect( rRect ); 1315*cdf0e10cSrcweir pView->SetFillColor( aOldColor ); 1316*cdf0e10cSrcweir } 1317*cdf0e10cSrcweir 1318*cdf0e10cSrcweir void SvImpIconView::RepaintSelectionItems() 1319*cdf0e10cSrcweir { 1320*cdf0e10cSrcweir DBG_ERROR("RepaintSelectionItems"); 1321*cdf0e10cSrcweir pView->Invalidate(); // vorlaeufig 1322*cdf0e10cSrcweir } 1323*cdf0e10cSrcweir 1324*cdf0e10cSrcweir SvLBoxItem* SvImpIconView::GetItem( SvLBoxEntry* pEntry, 1325*cdf0e10cSrcweir const Point& rAbsPos ) 1326*cdf0e10cSrcweir { 1327*cdf0e10cSrcweir Rectangle aRect; 1328*cdf0e10cSrcweir SvLBoxString* pStringItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING)); 1329*cdf0e10cSrcweir if( pStringItem ) 1330*cdf0e10cSrcweir { 1331*cdf0e10cSrcweir aRect = CalcTextRect( pEntry, pStringItem ); 1332*cdf0e10cSrcweir if( aRect.IsInside( rAbsPos ) ) 1333*cdf0e10cSrcweir return pStringItem; 1334*cdf0e10cSrcweir } 1335*cdf0e10cSrcweir SvLBoxContextBmp* pBmpItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP)); 1336*cdf0e10cSrcweir if( pBmpItem ) 1337*cdf0e10cSrcweir { 1338*cdf0e10cSrcweir aRect = CalcBmpRect( pEntry ); 1339*cdf0e10cSrcweir if( aRect.IsInside( rAbsPos ) ) 1340*cdf0e10cSrcweir return pBmpItem; 1341*cdf0e10cSrcweir } 1342*cdf0e10cSrcweir return 0; 1343*cdf0e10cSrcweir } 1344*cdf0e10cSrcweir 1345*cdf0e10cSrcweir void SvImpIconView::CalcDocPos( Point& aMaeuschenPos ) 1346*cdf0e10cSrcweir { 1347*cdf0e10cSrcweir aMaeuschenPos -= pView->GetMapMode().GetOrigin(); 1348*cdf0e10cSrcweir } 1349*cdf0e10cSrcweir 1350*cdf0e10cSrcweir void SvImpIconView::MouseButtonDown( const MouseEvent& rMEvt) 1351*cdf0e10cSrcweir { 1352*cdf0e10cSrcweir StopEditTimer(); 1353*cdf0e10cSrcweir pView->GrabFocus(); 1354*cdf0e10cSrcweir Point aDocPos( rMEvt.GetPosPixel() ); 1355*cdf0e10cSrcweir if(aDocPos.X()>=aOutputSize.Width() || aDocPos.Y()>=aOutputSize.Height()) 1356*cdf0e10cSrcweir return; 1357*cdf0e10cSrcweir CalcDocPos( aDocPos ); 1358*cdf0e10cSrcweir SvLBoxEntry* pEntry = GetEntry( aDocPos ); 1359*cdf0e10cSrcweir if( !pEntry ) 1360*cdf0e10cSrcweir { 1361*cdf0e10cSrcweir if( pView->GetSelectionMode() != SINGLE_SELECTION ) 1362*cdf0e10cSrcweir { 1363*cdf0e10cSrcweir if( !rMEvt.IsMod1() ) // Ctrl 1364*cdf0e10cSrcweir { 1365*cdf0e10cSrcweir pView->SelectAll( sal_False ); 1366*cdf0e10cSrcweir ClearSelectedRectList(); 1367*cdf0e10cSrcweir } 1368*cdf0e10cSrcweir else 1369*cdf0e10cSrcweir nFlags |= F_ADD_MODE; 1370*cdf0e10cSrcweir nFlags |= F_RUBBERING; 1371*cdf0e10cSrcweir aCurSelectionRect.SetPos( aDocPos ); 1372*cdf0e10cSrcweir pView->CaptureMouse(); 1373*cdf0e10cSrcweir } 1374*cdf0e10cSrcweir return; 1375*cdf0e10cSrcweir } 1376*cdf0e10cSrcweir 1377*cdf0e10cSrcweir sal_Bool bSelected = pView->IsSelected( pEntry ); 1378*cdf0e10cSrcweir sal_Bool bEditingEnabled = pView->IsInplaceEditingEnabled(); 1379*cdf0e10cSrcweir 1380*cdf0e10cSrcweir if( rMEvt.GetClicks() == 2 ) 1381*cdf0e10cSrcweir { 1382*cdf0e10cSrcweir DeselectAllBut( pEntry ); 1383*cdf0e10cSrcweir pView->pHdlEntry = pEntry; 1384*cdf0e10cSrcweir pView->DoubleClickHdl(); 1385*cdf0e10cSrcweir } 1386*cdf0e10cSrcweir else 1387*cdf0e10cSrcweir { 1388*cdf0e10cSrcweir // Inplace-Editing ? 1389*cdf0e10cSrcweir if( rMEvt.IsMod2() ) // Alt? 1390*cdf0e10cSrcweir { 1391*cdf0e10cSrcweir if( bEditingEnabled ) 1392*cdf0e10cSrcweir { 1393*cdf0e10cSrcweir SvLBoxItem* pItem = GetItem(pEntry,aDocPos); 1394*cdf0e10cSrcweir if( pItem ) 1395*cdf0e10cSrcweir pView->EditingRequest( pEntry, pItem, aDocPos); 1396*cdf0e10cSrcweir } 1397*cdf0e10cSrcweir } 1398*cdf0e10cSrcweir else if( pView->GetSelectionMode() == SINGLE_SELECTION ) 1399*cdf0e10cSrcweir { 1400*cdf0e10cSrcweir DeselectAllBut( pEntry ); 1401*cdf0e10cSrcweir SetCursor( pEntry ); 1402*cdf0e10cSrcweir pView->Select( pEntry, sal_True ); 1403*cdf0e10cSrcweir if( bEditingEnabled && bSelected && !rMEvt.GetModifier() && 1404*cdf0e10cSrcweir rMEvt.IsLeft() && IsTextHit( pEntry, aDocPos ) ) 1405*cdf0e10cSrcweir { 1406*cdf0e10cSrcweir nFlags |= F_START_EDITTIMER_IN_MOUSEUP; 1407*cdf0e10cSrcweir } 1408*cdf0e10cSrcweir } 1409*cdf0e10cSrcweir else 1410*cdf0e10cSrcweir { 1411*cdf0e10cSrcweir if( !rMEvt.GetModifier() ) 1412*cdf0e10cSrcweir { 1413*cdf0e10cSrcweir if( !bSelected ) 1414*cdf0e10cSrcweir { 1415*cdf0e10cSrcweir DeselectAllBut( pEntry ); 1416*cdf0e10cSrcweir SetCursor( pEntry ); 1417*cdf0e10cSrcweir pView->Select( pEntry, sal_True ); 1418*cdf0e10cSrcweir } 1419*cdf0e10cSrcweir else 1420*cdf0e10cSrcweir { 1421*cdf0e10cSrcweir // erst im Up deselektieren, falls Move per D&D! 1422*cdf0e10cSrcweir nFlags |= F_DOWN_DESELECT; 1423*cdf0e10cSrcweir if( bEditingEnabled && IsTextHit( pEntry, aDocPos ) && 1424*cdf0e10cSrcweir rMEvt.IsLeft()) 1425*cdf0e10cSrcweir { 1426*cdf0e10cSrcweir nFlags |= F_START_EDITTIMER_IN_MOUSEUP; 1427*cdf0e10cSrcweir } 1428*cdf0e10cSrcweir } 1429*cdf0e10cSrcweir } 1430*cdf0e10cSrcweir else if( rMEvt.IsMod1() ) 1431*cdf0e10cSrcweir nFlags |= F_DOWN_CTRL; 1432*cdf0e10cSrcweir } 1433*cdf0e10cSrcweir } 1434*cdf0e10cSrcweir } 1435*cdf0e10cSrcweir 1436*cdf0e10cSrcweir void SvImpIconView::MouseButtonUp( const MouseEvent& rMEvt ) 1437*cdf0e10cSrcweir { 1438*cdf0e10cSrcweir aMouseMoveTimer.Stop(); 1439*cdf0e10cSrcweir pView->ReleaseMouse(); 1440*cdf0e10cSrcweir // HACK, da Einar noch nicht PrepareCommandEvent aufruft 1441*cdf0e10cSrcweir if( rMEvt.IsRight() && (nFlags & (F_DOWN_CTRL | F_DOWN_DESELECT) )) 1442*cdf0e10cSrcweir nFlags &= ~(F_DOWN_CTRL | F_DOWN_DESELECT); 1443*cdf0e10cSrcweir 1444*cdf0e10cSrcweir if( nFlags & F_RUBBERING ) 1445*cdf0e10cSrcweir { 1446*cdf0e10cSrcweir aMouseMoveTimer.Stop(); 1447*cdf0e10cSrcweir AddSelectedRect( aCurSelectionRect ); 1448*cdf0e10cSrcweir HideSelectionRect(); 1449*cdf0e10cSrcweir nFlags &= ~(F_RUBBERING | F_ADD_MODE); 1450*cdf0e10cSrcweir } 1451*cdf0e10cSrcweir 1452*cdf0e10cSrcweir SvLBoxEntry* pEntry = pView->GetEntry( rMEvt.GetPosPixel(), sal_True ); 1453*cdf0e10cSrcweir if( pEntry ) 1454*cdf0e10cSrcweir { 1455*cdf0e10cSrcweir if( nFlags & F_DOWN_CTRL ) 1456*cdf0e10cSrcweir { 1457*cdf0e10cSrcweir // Ctrl & MultiSelection 1458*cdf0e10cSrcweir ToggleSelection( pEntry ); 1459*cdf0e10cSrcweir SetCursor( pEntry ); 1460*cdf0e10cSrcweir } 1461*cdf0e10cSrcweir else if( nFlags & F_DOWN_DESELECT ) 1462*cdf0e10cSrcweir { 1463*cdf0e10cSrcweir DeselectAllBut( pEntry ); 1464*cdf0e10cSrcweir SetCursor( pEntry ); 1465*cdf0e10cSrcweir pView->Select( pEntry, sal_True ); 1466*cdf0e10cSrcweir } 1467*cdf0e10cSrcweir } 1468*cdf0e10cSrcweir 1469*cdf0e10cSrcweir nFlags &= ~(F_DOWN_CTRL | F_DOWN_DESELECT); 1470*cdf0e10cSrcweir if( nFlags & F_START_EDITTIMER_IN_MOUSEUP ) 1471*cdf0e10cSrcweir { 1472*cdf0e10cSrcweir StartEditTimer(); 1473*cdf0e10cSrcweir nFlags &= ~F_START_EDITTIMER_IN_MOUSEUP; 1474*cdf0e10cSrcweir } 1475*cdf0e10cSrcweir } 1476*cdf0e10cSrcweir 1477*cdf0e10cSrcweir void SvImpIconView::MouseMove( const MouseEvent& rMEvt ) 1478*cdf0e10cSrcweir { 1479*cdf0e10cSrcweir if( nFlags & F_RUBBERING ) 1480*cdf0e10cSrcweir { 1481*cdf0e10cSrcweir const Point& rPosPixel = rMEvt.GetPosPixel(); 1482*cdf0e10cSrcweir if( !aMouseMoveTimer.IsActive() ) 1483*cdf0e10cSrcweir { 1484*cdf0e10cSrcweir aMouseMoveEvent = rMEvt; 1485*cdf0e10cSrcweir aMouseMoveTimer.Start(); 1486*cdf0e10cSrcweir // ausserhalb des Fensters liegende Move-Events muessen 1487*cdf0e10cSrcweir // vom Timer kommen, damit die Scrollgeschwindigkeit 1488*cdf0e10cSrcweir // unabhaengig von Mausbewegungen ist. 1489*cdf0e10cSrcweir if( rPosPixel.X() < 0 || rPosPixel.Y() < 0 ) 1490*cdf0e10cSrcweir return; 1491*cdf0e10cSrcweir const Size& rSize = pView->GetOutputSizePixel(); 1492*cdf0e10cSrcweir if( rPosPixel.X() > rSize.Width() || rPosPixel.Y() > rSize.Height()) 1493*cdf0e10cSrcweir return; 1494*cdf0e10cSrcweir } 1495*cdf0e10cSrcweir 1496*cdf0e10cSrcweir if( &rMEvt != &aMouseMoveEvent ) 1497*cdf0e10cSrcweir aMouseMoveEvent = rMEvt; 1498*cdf0e10cSrcweir 1499*cdf0e10cSrcweir long nScrollDX, nScrollDY; 1500*cdf0e10cSrcweir 1501*cdf0e10cSrcweir CalcScrollOffsets(rMEvt.GetPosPixel(),nScrollDX,nScrollDY,sal_False ); 1502*cdf0e10cSrcweir sal_Bool bSelRectHidden = sal_False; 1503*cdf0e10cSrcweir if( nScrollDX || nScrollDY ) 1504*cdf0e10cSrcweir { 1505*cdf0e10cSrcweir HideSelectionRect(); 1506*cdf0e10cSrcweir bSelRectHidden = sal_True; 1507*cdf0e10cSrcweir pView->Scroll( nScrollDX, nScrollDY ); 1508*cdf0e10cSrcweir } 1509*cdf0e10cSrcweir Point aDocPos( rMEvt.GetPosPixel() ); 1510*cdf0e10cSrcweir aDocPos = pView->PixelToLogic( aDocPos ); 1511*cdf0e10cSrcweir Rectangle aRect( aCurSelectionRect.TopLeft(), aDocPos ); 1512*cdf0e10cSrcweir if( aRect != aCurSelectionRect ) 1513*cdf0e10cSrcweir { 1514*cdf0e10cSrcweir HideSelectionRect(); 1515*cdf0e10cSrcweir bSelRectHidden = sal_True; 1516*cdf0e10cSrcweir sal_Bool bAdd = (nFlags & F_ADD_MODE) ? sal_True : sal_False; 1517*cdf0e10cSrcweir SelectRect( aRect, bAdd, &aSelectedRectList ); 1518*cdf0e10cSrcweir } 1519*cdf0e10cSrcweir if( bSelRectHidden ) 1520*cdf0e10cSrcweir DrawSelectionRect( aRect ); 1521*cdf0e10cSrcweir } 1522*cdf0e10cSrcweir } 1523*cdf0e10cSrcweir 1524*cdf0e10cSrcweir sal_Bool SvImpIconView::KeyInput( const KeyEvent& rKEvt ) 1525*cdf0e10cSrcweir { 1526*cdf0e10cSrcweir StopEditTimer(); 1527*cdf0e10cSrcweir sal_Bool bKeyUsed = sal_True; 1528*cdf0e10cSrcweir sal_Bool bMod1 = rKEvt.GetKeyCode().IsMod1(); 1529*cdf0e10cSrcweir sal_Bool bInAddMode = (sal_Bool)((nFlags & F_ADD_MODE) != 0); 1530*cdf0e10cSrcweir int bDeselAll = (pView->GetSelectionMode() != SINGLE_SELECTION) && 1531*cdf0e10cSrcweir !bInAddMode; 1532*cdf0e10cSrcweir SvLBoxEntry* pNewCursor; 1533*cdf0e10cSrcweir sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode(); 1534*cdf0e10cSrcweir switch( nCode ) 1535*cdf0e10cSrcweir { 1536*cdf0e10cSrcweir case KEY_UP: 1537*cdf0e10cSrcweir if( pCursor ) 1538*cdf0e10cSrcweir { 1539*cdf0e10cSrcweir MakeVisible( pCursor ); 1540*cdf0e10cSrcweir pNewCursor = pImpCursor->GoUpDown(pCursor,sal_False); 1541*cdf0e10cSrcweir if( pNewCursor ) 1542*cdf0e10cSrcweir { 1543*cdf0e10cSrcweir if( bDeselAll ) 1544*cdf0e10cSrcweir pView->SelectAll( sal_False ); 1545*cdf0e10cSrcweir ShowCursor( sal_False ); 1546*cdf0e10cSrcweir MakeVisible( pNewCursor ); 1547*cdf0e10cSrcweir SetCursor( pNewCursor ); 1548*cdf0e10cSrcweir if( !bInAddMode ) 1549*cdf0e10cSrcweir pView->Select( pCursor, sal_True ); 1550*cdf0e10cSrcweir } 1551*cdf0e10cSrcweir else 1552*cdf0e10cSrcweir { 1553*cdf0e10cSrcweir Rectangle aRect( GetBoundingRect( pCursor ) ); 1554*cdf0e10cSrcweir if( aRect.Top()) 1555*cdf0e10cSrcweir { 1556*cdf0e10cSrcweir aRect.Bottom() -= aRect.Top(); 1557*cdf0e10cSrcweir aRect.Top() = 0; 1558*cdf0e10cSrcweir MakeVisible( aRect ); 1559*cdf0e10cSrcweir } 1560*cdf0e10cSrcweir } 1561*cdf0e10cSrcweir } 1562*cdf0e10cSrcweir break; 1563*cdf0e10cSrcweir 1564*cdf0e10cSrcweir case KEY_DOWN: 1565*cdf0e10cSrcweir if( pCursor ) 1566*cdf0e10cSrcweir { 1567*cdf0e10cSrcweir pNewCursor=pImpCursor->GoUpDown( pCursor,sal_True ); 1568*cdf0e10cSrcweir if( pNewCursor ) 1569*cdf0e10cSrcweir { 1570*cdf0e10cSrcweir MakeVisible( pCursor ); 1571*cdf0e10cSrcweir if( bDeselAll ) 1572*cdf0e10cSrcweir pView->SelectAll( sal_False ); 1573*cdf0e10cSrcweir ShowCursor( sal_False ); 1574*cdf0e10cSrcweir MakeVisible( pNewCursor ); 1575*cdf0e10cSrcweir SetCursor( pNewCursor ); 1576*cdf0e10cSrcweir if( !bInAddMode ) 1577*cdf0e10cSrcweir pView->Select( pCursor, sal_True ); 1578*cdf0e10cSrcweir } 1579*cdf0e10cSrcweir } 1580*cdf0e10cSrcweir break; 1581*cdf0e10cSrcweir 1582*cdf0e10cSrcweir case KEY_RIGHT: 1583*cdf0e10cSrcweir if( pCursor ) 1584*cdf0e10cSrcweir { 1585*cdf0e10cSrcweir pNewCursor=pImpCursor->GoLeftRight(pCursor,sal_True ); 1586*cdf0e10cSrcweir if( pNewCursor ) 1587*cdf0e10cSrcweir { 1588*cdf0e10cSrcweir MakeVisible( pCursor ); 1589*cdf0e10cSrcweir if( bDeselAll ) 1590*cdf0e10cSrcweir pView->SelectAll( sal_False ); 1591*cdf0e10cSrcweir ShowCursor( sal_False ); 1592*cdf0e10cSrcweir MakeVisible( pNewCursor ); 1593*cdf0e10cSrcweir SetCursor( pNewCursor ); 1594*cdf0e10cSrcweir if( !bInAddMode ) 1595*cdf0e10cSrcweir pView->Select( pCursor, sal_True ); 1596*cdf0e10cSrcweir } 1597*cdf0e10cSrcweir } 1598*cdf0e10cSrcweir break; 1599*cdf0e10cSrcweir 1600*cdf0e10cSrcweir case KEY_LEFT: 1601*cdf0e10cSrcweir if( pCursor ) 1602*cdf0e10cSrcweir { 1603*cdf0e10cSrcweir MakeVisible( pCursor ); 1604*cdf0e10cSrcweir pNewCursor = pImpCursor->GoLeftRight(pCursor,sal_False ); 1605*cdf0e10cSrcweir if( pNewCursor ) 1606*cdf0e10cSrcweir { 1607*cdf0e10cSrcweir if( bDeselAll ) 1608*cdf0e10cSrcweir pView->SelectAll( sal_False ); 1609*cdf0e10cSrcweir ShowCursor( sal_False ); 1610*cdf0e10cSrcweir MakeVisible( pNewCursor ); 1611*cdf0e10cSrcweir SetCursor( pNewCursor ); 1612*cdf0e10cSrcweir if( !bInAddMode ) 1613*cdf0e10cSrcweir pView->Select( pCursor, sal_True ); 1614*cdf0e10cSrcweir } 1615*cdf0e10cSrcweir else 1616*cdf0e10cSrcweir { 1617*cdf0e10cSrcweir Rectangle aRect( GetBoundingRect(pCursor)); 1618*cdf0e10cSrcweir if( aRect.Left() ) 1619*cdf0e10cSrcweir { 1620*cdf0e10cSrcweir aRect.Right() -= aRect.Left(); 1621*cdf0e10cSrcweir aRect.Left() = 0; 1622*cdf0e10cSrcweir MakeVisible( aRect ); 1623*cdf0e10cSrcweir } 1624*cdf0e10cSrcweir } 1625*cdf0e10cSrcweir } 1626*cdf0e10cSrcweir break; 1627*cdf0e10cSrcweir 1628*cdf0e10cSrcweir case KEY_ESCAPE: 1629*cdf0e10cSrcweir if( nFlags & F_RUBBERING ) 1630*cdf0e10cSrcweir { 1631*cdf0e10cSrcweir HideSelectionRect(); 1632*cdf0e10cSrcweir pView->SelectAll( sal_False ); 1633*cdf0e10cSrcweir nFlags &= ~F_RUBBERING; 1634*cdf0e10cSrcweir } 1635*cdf0e10cSrcweir break; 1636*cdf0e10cSrcweir 1637*cdf0e10cSrcweir case KEY_F8: 1638*cdf0e10cSrcweir if( rKEvt.GetKeyCode().IsShift() ) 1639*cdf0e10cSrcweir { 1640*cdf0e10cSrcweir if( nFlags & F_ADD_MODE ) 1641*cdf0e10cSrcweir nFlags &= (~F_ADD_MODE); 1642*cdf0e10cSrcweir else 1643*cdf0e10cSrcweir nFlags |= F_ADD_MODE; 1644*cdf0e10cSrcweir } 1645*cdf0e10cSrcweir break; 1646*cdf0e10cSrcweir 1647*cdf0e10cSrcweir #ifdef OS2 1648*cdf0e10cSrcweir case KEY_F9: 1649*cdf0e10cSrcweir if( rKEvt.GetKeyCode().IsShift() ) 1650*cdf0e10cSrcweir { 1651*cdf0e10cSrcweir if( pCursor && pView->IsInplaceEditingEnabled() ) 1652*cdf0e10cSrcweir pView->EditEntry( pCursor ); 1653*cdf0e10cSrcweir } 1654*cdf0e10cSrcweir break; 1655*cdf0e10cSrcweir #endif 1656*cdf0e10cSrcweir 1657*cdf0e10cSrcweir case KEY_SPACE: 1658*cdf0e10cSrcweir if( pCursor ) 1659*cdf0e10cSrcweir { 1660*cdf0e10cSrcweir ToggleSelection( pCursor ); 1661*cdf0e10cSrcweir } 1662*cdf0e10cSrcweir break; 1663*cdf0e10cSrcweir 1664*cdf0e10cSrcweir 1665*cdf0e10cSrcweir case KEY_PAGEDOWN: 1666*cdf0e10cSrcweir break; 1667*cdf0e10cSrcweir case KEY_PAGEUP: 1668*cdf0e10cSrcweir break; 1669*cdf0e10cSrcweir 1670*cdf0e10cSrcweir case KEY_ADD: 1671*cdf0e10cSrcweir case KEY_DIVIDE : 1672*cdf0e10cSrcweir if( bMod1 ) 1673*cdf0e10cSrcweir pView->SelectAll( sal_True ); 1674*cdf0e10cSrcweir break; 1675*cdf0e10cSrcweir 1676*cdf0e10cSrcweir case KEY_SUBTRACT: 1677*cdf0e10cSrcweir case KEY_COMMA : 1678*cdf0e10cSrcweir if( bMod1 ) 1679*cdf0e10cSrcweir pView->SelectAll( sal_False ); 1680*cdf0e10cSrcweir break; 1681*cdf0e10cSrcweir 1682*cdf0e10cSrcweir case KEY_RETURN: 1683*cdf0e10cSrcweir if( bMod1 ) 1684*cdf0e10cSrcweir { 1685*cdf0e10cSrcweir if( pCursor && pView->IsInplaceEditingEnabled() ) 1686*cdf0e10cSrcweir pView->EditEntry( pCursor ); 1687*cdf0e10cSrcweir } 1688*cdf0e10cSrcweir break; 1689*cdf0e10cSrcweir 1690*cdf0e10cSrcweir default: 1691*cdf0e10cSrcweir bKeyUsed = sal_False; 1692*cdf0e10cSrcweir 1693*cdf0e10cSrcweir } 1694*cdf0e10cSrcweir return bKeyUsed; 1695*cdf0e10cSrcweir } 1696*cdf0e10cSrcweir 1697*cdf0e10cSrcweir 1698*cdf0e10cSrcweir void SvImpIconView::PositionScrollBars( long nRealWidth, long nRealHeight ) 1699*cdf0e10cSrcweir { 1700*cdf0e10cSrcweir // hor scrollbar 1701*cdf0e10cSrcweir Point aPos( 0, nRealHeight ); 1702*cdf0e10cSrcweir aPos.Y() -= nHorSBarHeight; 1703*cdf0e10cSrcweir 1704*cdf0e10cSrcweir #ifdef OS2 1705*cdf0e10cSrcweir aPos.Y()++; 1706*cdf0e10cSrcweir #endif 1707*cdf0e10cSrcweir if( aHorSBar.GetPosPixel() != aPos ) 1708*cdf0e10cSrcweir aHorSBar.SetPosPixel( aPos ); 1709*cdf0e10cSrcweir 1710*cdf0e10cSrcweir // ver scrollbar 1711*cdf0e10cSrcweir aPos.X() = nRealWidth; aPos.Y() = 0; 1712*cdf0e10cSrcweir aPos.X() -= nVerSBarWidth; 1713*cdf0e10cSrcweir 1714*cdf0e10cSrcweir #if defined(WNT) 1715*cdf0e10cSrcweir aPos.X()++; 1716*cdf0e10cSrcweir aPos.Y()--; 1717*cdf0e10cSrcweir #endif 1718*cdf0e10cSrcweir 1719*cdf0e10cSrcweir #ifdef OS2 1720*cdf0e10cSrcweir aPos.Y()--; 1721*cdf0e10cSrcweir aPos.X()++; 1722*cdf0e10cSrcweir #endif 1723*cdf0e10cSrcweir 1724*cdf0e10cSrcweir if( aVerSBar.GetPosPixel() != aPos ) 1725*cdf0e10cSrcweir aVerSBar.SetPosPixel( aPos ); 1726*cdf0e10cSrcweir } 1727*cdf0e10cSrcweir 1728*cdf0e10cSrcweir 1729*cdf0e10cSrcweir 1730*cdf0e10cSrcweir void SvImpIconView::AdjustScrollBars() 1731*cdf0e10cSrcweir { 1732*cdf0e10cSrcweir long nVirtHeight = aVirtOutputSize.Height(); 1733*cdf0e10cSrcweir long nVirtWidth = aVirtOutputSize.Width(); 1734*cdf0e10cSrcweir 1735*cdf0e10cSrcweir Size aOSize( pView->Control::GetOutputSizePixel() ); 1736*cdf0e10cSrcweir long nRealHeight = aOSize.Height(); 1737*cdf0e10cSrcweir long nRealWidth = aOSize.Width(); 1738*cdf0e10cSrcweir 1739*cdf0e10cSrcweir PositionScrollBars( nRealWidth, nRealHeight ); 1740*cdf0e10cSrcweir 1741*cdf0e10cSrcweir const MapMode& rMapMode = pView->GetMapMode(); 1742*cdf0e10cSrcweir Point aOrigin( rMapMode.GetOrigin() ); 1743*cdf0e10cSrcweir 1744*cdf0e10cSrcweir long nVisibleWidth; 1745*cdf0e10cSrcweir if( nRealWidth > nVirtWidth ) 1746*cdf0e10cSrcweir nVisibleWidth = nVirtWidth + aOrigin.X(); 1747*cdf0e10cSrcweir else 1748*cdf0e10cSrcweir nVisibleWidth = nRealWidth; 1749*cdf0e10cSrcweir 1750*cdf0e10cSrcweir long nVisibleHeight; 1751*cdf0e10cSrcweir if( nRealHeight > nVirtHeight ) 1752*cdf0e10cSrcweir nVisibleHeight = nVirtHeight + aOrigin.Y(); 1753*cdf0e10cSrcweir else 1754*cdf0e10cSrcweir nVisibleHeight = nRealHeight; 1755*cdf0e10cSrcweir 1756*cdf0e10cSrcweir bool bVerSBar = (pView->GetStyle() & WB_VSCROLL) ? true : false; 1757*cdf0e10cSrcweir bool bHorSBar = (pView->GetStyle() & WB_HSCROLL) ? true : false; 1758*cdf0e10cSrcweir 1759*cdf0e10cSrcweir sal_uInt16 nResult = 0; 1760*cdf0e10cSrcweir if( nVirtHeight ) 1761*cdf0e10cSrcweir { 1762*cdf0e10cSrcweir // activate ver scrollbar ? 1763*cdf0e10cSrcweir if( bVerSBar || ( nVirtHeight > nVisibleHeight) ) 1764*cdf0e10cSrcweir { 1765*cdf0e10cSrcweir nResult = 0x0001; 1766*cdf0e10cSrcweir nRealWidth -= nVerSBarWidth; 1767*cdf0e10cSrcweir 1768*cdf0e10cSrcweir if( nRealWidth > nVirtWidth ) 1769*cdf0e10cSrcweir nVisibleWidth = nVirtWidth + aOrigin.X(); 1770*cdf0e10cSrcweir else 1771*cdf0e10cSrcweir nVisibleWidth = nRealWidth; 1772*cdf0e10cSrcweir 1773*cdf0e10cSrcweir nFlags |= F_HOR_SBARSIZE_WITH_VBAR; 1774*cdf0e10cSrcweir } 1775*cdf0e10cSrcweir // activate hor scrollbar ? 1776*cdf0e10cSrcweir if( bHorSBar || (nVirtWidth > nVisibleWidth) ) 1777*cdf0e10cSrcweir { 1778*cdf0e10cSrcweir nResult |= 0x0002; 1779*cdf0e10cSrcweir nRealHeight -= nHorSBarHeight; 1780*cdf0e10cSrcweir 1781*cdf0e10cSrcweir if( nRealHeight > nVirtHeight ) 1782*cdf0e10cSrcweir nVisibleHeight = nVirtHeight + aOrigin.Y(); 1783*cdf0e10cSrcweir else 1784*cdf0e10cSrcweir nVisibleHeight = nRealHeight; 1785*cdf0e10cSrcweir 1786*cdf0e10cSrcweir // brauchen wir jetzt doch eine senkrechte Scrollbar ? 1787*cdf0e10cSrcweir if( !(nResult & 0x0001) && // nur wenn nicht schon da 1788*cdf0e10cSrcweir ( (nVirtHeight > nVisibleHeight) || bVerSBar) ) 1789*cdf0e10cSrcweir { 1790*cdf0e10cSrcweir nResult = 3; // both are active 1791*cdf0e10cSrcweir nRealWidth -= nVerSBarWidth; 1792*cdf0e10cSrcweir 1793*cdf0e10cSrcweir if( nRealWidth > nVirtWidth ) 1794*cdf0e10cSrcweir nVisibleWidth = nVirtWidth + aOrigin.X(); 1795*cdf0e10cSrcweir else 1796*cdf0e10cSrcweir nVisibleWidth = nRealWidth; 1797*cdf0e10cSrcweir 1798*cdf0e10cSrcweir nFlags |= F_VER_SBARSIZE_WITH_HBAR; 1799*cdf0e10cSrcweir } 1800*cdf0e10cSrcweir } 1801*cdf0e10cSrcweir } 1802*cdf0e10cSrcweir 1803*cdf0e10cSrcweir // size ver scrollbar 1804*cdf0e10cSrcweir long nThumb = aVerSBar.GetThumbPos(); 1805*cdf0e10cSrcweir Size aSize( nVerSBarWidth, nRealHeight ); 1806*cdf0e10cSrcweir #if defined(WNT) 1807*cdf0e10cSrcweir aSize.Height() += 2; 1808*cdf0e10cSrcweir #endif 1809*cdf0e10cSrcweir #ifdef OS2 1810*cdf0e10cSrcweir aSize.Height() += 3; 1811*cdf0e10cSrcweir #endif 1812*cdf0e10cSrcweir if( aSize != aVerSBar.GetSizePixel() ) 1813*cdf0e10cSrcweir aVerSBar.SetSizePixel( aSize ); 1814*cdf0e10cSrcweir aVerSBar.SetVisibleSize( nVisibleHeight ); 1815*cdf0e10cSrcweir aVerSBar.SetPageSize( (nVisibleHeight*75)/100 ); 1816*cdf0e10cSrcweir if( nResult & 0x0001 ) 1817*cdf0e10cSrcweir { 1818*cdf0e10cSrcweir aVerSBar.SetThumbPos( nThumb ); 1819*cdf0e10cSrcweir aVerSBar.Show(); 1820*cdf0e10cSrcweir } 1821*cdf0e10cSrcweir else 1822*cdf0e10cSrcweir { 1823*cdf0e10cSrcweir aVerSBar.SetThumbPos( 0 ); 1824*cdf0e10cSrcweir aVerSBar.Hide(); 1825*cdf0e10cSrcweir } 1826*cdf0e10cSrcweir 1827*cdf0e10cSrcweir // size hor scrollbar 1828*cdf0e10cSrcweir nThumb = aHorSBar.GetThumbPos(); 1829*cdf0e10cSrcweir aSize.Width() = nRealWidth; 1830*cdf0e10cSrcweir aSize.Height() = nHorSBarHeight; 1831*cdf0e10cSrcweir #if defined(WNT) 1832*cdf0e10cSrcweir aSize.Width()++; 1833*cdf0e10cSrcweir #endif 1834*cdf0e10cSrcweir #ifdef OS2 1835*cdf0e10cSrcweir aSize.Width() += 3; 1836*cdf0e10cSrcweir if( nResult & 0x0001 ) // vertikale Scrollbar ? 1837*cdf0e10cSrcweir aSize.Width()--; 1838*cdf0e10cSrcweir #endif 1839*cdf0e10cSrcweir #if defined(WNT) 1840*cdf0e10cSrcweir if( nResult & 0x0001 ) // vertikale Scrollbar ? 1841*cdf0e10cSrcweir { 1842*cdf0e10cSrcweir aSize.Width()++; 1843*cdf0e10cSrcweir nRealWidth++; 1844*cdf0e10cSrcweir } 1845*cdf0e10cSrcweir #endif 1846*cdf0e10cSrcweir if( aSize != aHorSBar.GetSizePixel() ) 1847*cdf0e10cSrcweir aHorSBar.SetSizePixel( aSize ); 1848*cdf0e10cSrcweir aHorSBar.SetVisibleSize( nVisibleWidth ); //nRealWidth ); 1849*cdf0e10cSrcweir aHorSBar.SetPageSize( (nVisibleWidth*75)/100 ); 1850*cdf0e10cSrcweir if( nResult & 0x0002 ) 1851*cdf0e10cSrcweir { 1852*cdf0e10cSrcweir aHorSBar.SetThumbPos( nThumb ); 1853*cdf0e10cSrcweir aHorSBar.Show(); 1854*cdf0e10cSrcweir } 1855*cdf0e10cSrcweir else 1856*cdf0e10cSrcweir { 1857*cdf0e10cSrcweir aHorSBar.SetThumbPos( 0 ); 1858*cdf0e10cSrcweir aHorSBar.Hide(); 1859*cdf0e10cSrcweir } 1860*cdf0e10cSrcweir 1861*cdf0e10cSrcweir #ifdef OS2 1862*cdf0e10cSrcweir nRealWidth++; 1863*cdf0e10cSrcweir #endif 1864*cdf0e10cSrcweir aOutputSize.Width() = nRealWidth; 1865*cdf0e10cSrcweir #if defined(WNT) 1866*cdf0e10cSrcweir if( nResult & 0x0002 ) // hor scrollbar ? 1867*cdf0e10cSrcweir nRealHeight++; // weil unterer Rand geclippt wird 1868*cdf0e10cSrcweir #endif 1869*cdf0e10cSrcweir #ifdef OS2 1870*cdf0e10cSrcweir if( nResult & 0x0002 ) // hor scrollbar ? 1871*cdf0e10cSrcweir nRealHeight++; 1872*cdf0e10cSrcweir #endif 1873*cdf0e10cSrcweir aOutputSize.Height() = nRealHeight; 1874*cdf0e10cSrcweir } 1875*cdf0e10cSrcweir 1876*cdf0e10cSrcweir void __EXPORT SvImpIconView::Resize() 1877*cdf0e10cSrcweir { 1878*cdf0e10cSrcweir StopEditTimer(); 1879*cdf0e10cSrcweir Rectangle aRect; 1880*cdf0e10cSrcweir if( GetResizeRect(aRect) ) 1881*cdf0e10cSrcweir pView->Invalidate( aRect ); 1882*cdf0e10cSrcweir aOutputSize = pView->GetOutputSizePixel(); 1883*cdf0e10cSrcweir pImpCursor->Clear(); 1884*cdf0e10cSrcweir 1885*cdf0e10cSrcweir #if 1 1886*cdf0e10cSrcweir const Size& rSize = pView->Control::GetOutputSizePixel(); 1887*cdf0e10cSrcweir PositionScrollBars( rSize.Width(), rSize.Height() ); 1888*cdf0e10cSrcweir // Die ScrollBars werden asynchron ein/ausgeblendet, damit abgeleitete 1889*cdf0e10cSrcweir // Klassen im Resize ein Arrange durchfuehren koennen, ohne dass 1890*cdf0e10cSrcweir // die ScrollBars aufblitzen (SfxExplorerIconView!) 1891*cdf0e10cSrcweir nCurUserEvent = Application::PostUserEvent(LINK(this,SvImpIconView,UserEventHdl),0); 1892*cdf0e10cSrcweir #else 1893*cdf0e10cSrcweir AdjustScrollBars(); 1894*cdf0e10cSrcweir if( GetResizeRect(aRect) ) 1895*cdf0e10cSrcweir PaintResizeRect( aRect ); 1896*cdf0e10cSrcweir #endif 1897*cdf0e10cSrcweir } 1898*cdf0e10cSrcweir 1899*cdf0e10cSrcweir sal_Bool SvImpIconView::CheckHorScrollBar() 1900*cdf0e10cSrcweir { 1901*cdf0e10cSrcweir if( !pZOrderList || !aHorSBar.IsVisible() ) 1902*cdf0e10cSrcweir return sal_False; 1903*cdf0e10cSrcweir const MapMode& rMapMode = pView->GetMapMode(); 1904*cdf0e10cSrcweir Point aOrigin( rMapMode.GetOrigin() ); 1905*cdf0e10cSrcweir if(!(pView->GetStyle() & WB_HSCROLL) && !aOrigin.X() ) 1906*cdf0e10cSrcweir { 1907*cdf0e10cSrcweir long nWidth = aOutputSize.Width(); 1908*cdf0e10cSrcweir sal_uInt16 nCount = pZOrderList->Count(); 1909*cdf0e10cSrcweir long nMostRight = 0; 1910*cdf0e10cSrcweir for( sal_uInt16 nCur = 0; nCur < nCount; nCur++ ) 1911*cdf0e10cSrcweir { 1912*cdf0e10cSrcweir SvLBoxEntry* pEntry = (SvLBoxEntry*)pZOrderList->operator[](nCur); 1913*cdf0e10cSrcweir long nRight = GetBoundingRect(pEntry).Right(); 1914*cdf0e10cSrcweir if( nRight > nWidth ) 1915*cdf0e10cSrcweir return sal_False; 1916*cdf0e10cSrcweir if( nRight > nMostRight ) 1917*cdf0e10cSrcweir nMostRight = nRight; 1918*cdf0e10cSrcweir } 1919*cdf0e10cSrcweir aHorSBar.Hide(); 1920*cdf0e10cSrcweir aOutputSize.Height() += nHorSBarHeight; 1921*cdf0e10cSrcweir aVirtOutputSize.Width() = nMostRight; 1922*cdf0e10cSrcweir aHorSBar.SetThumbPos( 0 ); 1923*cdf0e10cSrcweir Range aRange; 1924*cdf0e10cSrcweir aRange.Max() = nMostRight - 1; 1925*cdf0e10cSrcweir aHorSBar.SetRange( aRange ); 1926*cdf0e10cSrcweir if( aVerSBar.IsVisible() ) 1927*cdf0e10cSrcweir { 1928*cdf0e10cSrcweir Size aSize( aVerSBar.GetSizePixel()); 1929*cdf0e10cSrcweir aSize.Height() += nHorSBarHeight; 1930*cdf0e10cSrcweir aVerSBar.SetSizePixel( aSize ); 1931*cdf0e10cSrcweir } 1932*cdf0e10cSrcweir return sal_True; 1933*cdf0e10cSrcweir } 1934*cdf0e10cSrcweir return sal_False; 1935*cdf0e10cSrcweir } 1936*cdf0e10cSrcweir 1937*cdf0e10cSrcweir sal_Bool SvImpIconView::CheckVerScrollBar() 1938*cdf0e10cSrcweir { 1939*cdf0e10cSrcweir if( !pZOrderList || !aVerSBar.IsVisible() ) 1940*cdf0e10cSrcweir return sal_False; 1941*cdf0e10cSrcweir const MapMode& rMapMode = pView->GetMapMode(); 1942*cdf0e10cSrcweir Point aOrigin( rMapMode.GetOrigin() ); 1943*cdf0e10cSrcweir if(!(pView->GetStyle() & WB_VSCROLL) && !aOrigin.Y() ) 1944*cdf0e10cSrcweir { 1945*cdf0e10cSrcweir long nDeepest = 0; 1946*cdf0e10cSrcweir long nHeight = aOutputSize.Height(); 1947*cdf0e10cSrcweir sal_uInt16 nCount = pZOrderList->Count(); 1948*cdf0e10cSrcweir for( sal_uInt16 nCur = 0; nCur < nCount; nCur++ ) 1949*cdf0e10cSrcweir { 1950*cdf0e10cSrcweir SvLBoxEntry* pEntry = (SvLBoxEntry*)pZOrderList->operator[](nCur); 1951*cdf0e10cSrcweir long nBottom = GetBoundingRect(pEntry).Bottom(); 1952*cdf0e10cSrcweir if( nBottom > nHeight ) 1953*cdf0e10cSrcweir return sal_False; 1954*cdf0e10cSrcweir if( nBottom > nDeepest ) 1955*cdf0e10cSrcweir nDeepest = nBottom; 1956*cdf0e10cSrcweir } 1957*cdf0e10cSrcweir aVerSBar.Hide(); 1958*cdf0e10cSrcweir aOutputSize.Width() += nVerSBarWidth; 1959*cdf0e10cSrcweir aVirtOutputSize.Height() = nDeepest; 1960*cdf0e10cSrcweir aVerSBar.SetThumbPos( 0 ); 1961*cdf0e10cSrcweir Range aRange; 1962*cdf0e10cSrcweir aRange.Max() = nDeepest - 1; 1963*cdf0e10cSrcweir aVerSBar.SetRange( aRange ); 1964*cdf0e10cSrcweir if( aHorSBar.IsVisible() ) 1965*cdf0e10cSrcweir { 1966*cdf0e10cSrcweir Size aSize( aHorSBar.GetSizePixel()); 1967*cdf0e10cSrcweir aSize.Width() += nVerSBarWidth; 1968*cdf0e10cSrcweir aHorSBar.SetSizePixel( aSize ); 1969*cdf0e10cSrcweir } 1970*cdf0e10cSrcweir return sal_True; 1971*cdf0e10cSrcweir } 1972*cdf0e10cSrcweir return sal_False; 1973*cdf0e10cSrcweir } 1974*cdf0e10cSrcweir 1975*cdf0e10cSrcweir 1976*cdf0e10cSrcweir // blendet Scrollbars aus, wenn sie nicht mehr benoetigt werden 1977*cdf0e10cSrcweir void SvImpIconView::CheckScrollBars() 1978*cdf0e10cSrcweir { 1979*cdf0e10cSrcweir CheckVerScrollBar(); 1980*cdf0e10cSrcweir if( CheckHorScrollBar() ) 1981*cdf0e10cSrcweir CheckVerScrollBar(); 1982*cdf0e10cSrcweir } 1983*cdf0e10cSrcweir 1984*cdf0e10cSrcweir 1985*cdf0e10cSrcweir void __EXPORT SvImpIconView::GetFocus() 1986*cdf0e10cSrcweir { 1987*cdf0e10cSrcweir if( pCursor ) 1988*cdf0e10cSrcweir { 1989*cdf0e10cSrcweir pView->SetEntryFocus( pCursor, sal_True ); 1990*cdf0e10cSrcweir ShowCursor( sal_True ); 1991*cdf0e10cSrcweir } 1992*cdf0e10cSrcweir } 1993*cdf0e10cSrcweir 1994*cdf0e10cSrcweir void __EXPORT SvImpIconView::LoseFocus() 1995*cdf0e10cSrcweir { 1996*cdf0e10cSrcweir StopEditTimer(); 1997*cdf0e10cSrcweir if( pCursor ) 1998*cdf0e10cSrcweir pView->SetEntryFocus( pCursor,sal_False ); 1999*cdf0e10cSrcweir ShowCursor( sal_False ); 2000*cdf0e10cSrcweir } 2001*cdf0e10cSrcweir 2002*cdf0e10cSrcweir void SvImpIconView::UpdateAll() 2003*cdf0e10cSrcweir { 2004*cdf0e10cSrcweir AdjustScrollBars(); 2005*cdf0e10cSrcweir pImpCursor->Clear(); 2006*cdf0e10cSrcweir pView->Invalidate(); 2007*cdf0e10cSrcweir } 2008*cdf0e10cSrcweir 2009*cdf0e10cSrcweir void SvImpIconView::PaintEntry( SvLBoxEntry* pEntry, SvIcnVwDataEntry* pViewData ) 2010*cdf0e10cSrcweir { 2011*cdf0e10cSrcweir Point aPos( GetEntryPosition( pEntry ) ); 2012*cdf0e10cSrcweir PaintEntry( pEntry, aPos, pViewData ); 2013*cdf0e10cSrcweir } 2014*cdf0e10cSrcweir 2015*cdf0e10cSrcweir void SvImpIconView::PaintEmphasis( const Rectangle& rRect, sal_Bool bSelected, 2016*cdf0e10cSrcweir sal_Bool bCursored, OutputDevice* pOut ) 2017*cdf0e10cSrcweir { 2018*cdf0e10cSrcweir // HACK fuer D&D 2019*cdf0e10cSrcweir if( nFlags & F_NO_EMPHASIS ) 2020*cdf0e10cSrcweir return; 2021*cdf0e10cSrcweir 2022*cdf0e10cSrcweir if( !pOut ) 2023*cdf0e10cSrcweir pOut = pView; 2024*cdf0e10cSrcweir 2025*cdf0e10cSrcweir // Selektion painten 2026*cdf0e10cSrcweir Color aOldFillColor = pOut->GetFillColor(); 2027*cdf0e10cSrcweir Color aOldLineColor = pOut->GetLineColor(); 2028*cdf0e10cSrcweir Color aNewColor; 2029*cdf0e10cSrcweir const StyleSettings& rStyleSettings = pOut->GetSettings().GetStyleSettings(); 2030*cdf0e10cSrcweir if( bSelected ) 2031*cdf0e10cSrcweir { 2032*cdf0e10cSrcweir aNewColor = rStyleSettings.GetHighlightColor(); 2033*cdf0e10cSrcweir } 2034*cdf0e10cSrcweir else 2035*cdf0e10cSrcweir { 2036*cdf0e10cSrcweir #ifndef OS2 2037*cdf0e10cSrcweir aNewColor =rStyleSettings.GetFieldColor(); 2038*cdf0e10cSrcweir #else 2039*cdf0e10cSrcweir aNewColor = pOut->GetBackground().GetColor(); 2040*cdf0e10cSrcweir #endif 2041*cdf0e10cSrcweir } 2042*cdf0e10cSrcweir 2043*cdf0e10cSrcweir if( bCursored ) 2044*cdf0e10cSrcweir { 2045*cdf0e10cSrcweir pOut->SetLineColor( Color( COL_BLACK ) ); 2046*cdf0e10cSrcweir } 2047*cdf0e10cSrcweir pOut->SetFillColor( aNewColor ); 2048*cdf0e10cSrcweir pOut->DrawRect( rRect ); 2049*cdf0e10cSrcweir pOut->SetFillColor( aOldFillColor ); 2050*cdf0e10cSrcweir pOut->SetLineColor( aOldLineColor ); 2051*cdf0e10cSrcweir } 2052*cdf0e10cSrcweir 2053*cdf0e10cSrcweir void SvImpIconView::PaintItem( const Rectangle& rRect, 2054*cdf0e10cSrcweir SvLBoxItem* pItem, SvLBoxEntry* pEntry, sal_uInt16 nPaintFlags, 2055*cdf0e10cSrcweir OutputDevice* pOut ) 2056*cdf0e10cSrcweir { 2057*cdf0e10cSrcweir if( nViewMode == VIEWMODE_ICON && pItem->IsA() == SV_ITEM_ID_LBOXSTRING ) 2058*cdf0e10cSrcweir { 2059*cdf0e10cSrcweir const String& rStr = ((SvLBoxString*)pItem)->GetText(); 2060*cdf0e10cSrcweir DrawText( pOut, rRect, rStr, DRAWTEXT_FLAGS ); 2061*cdf0e10cSrcweir } 2062*cdf0e10cSrcweir else 2063*cdf0e10cSrcweir { 2064*cdf0e10cSrcweir Point aPos( rRect.TopLeft() ); 2065*cdf0e10cSrcweir const Size& rSize = GetItemSize( pView, pEntry, pItem ); 2066*cdf0e10cSrcweir if( nPaintFlags & PAINTFLAG_HOR_CENTERED ) 2067*cdf0e10cSrcweir aPos.X() += (rRect.GetWidth() - rSize.Width() ) / 2; 2068*cdf0e10cSrcweir if( nPaintFlags & PAINTFLAG_VER_CENTERED ) 2069*cdf0e10cSrcweir aPos.Y() += (rRect.GetHeight() - rSize.Height() ) / 2; 2070*cdf0e10cSrcweir pItem->Paint( aPos, *(SvLBox*)pOut, 0, pEntry ); 2071*cdf0e10cSrcweir } 2072*cdf0e10cSrcweir } 2073*cdf0e10cSrcweir 2074*cdf0e10cSrcweir void SvImpIconView::PaintEntry( SvLBoxEntry* pEntry, const Point& rPos, 2075*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData, OutputDevice* pOut ) 2076*cdf0e10cSrcweir { 2077*cdf0e10cSrcweir if( !pView->IsUpdateMode() ) 2078*cdf0e10cSrcweir return; 2079*cdf0e10cSrcweir 2080*cdf0e10cSrcweir if( !pOut ) 2081*cdf0e10cSrcweir pOut = pView; 2082*cdf0e10cSrcweir 2083*cdf0e10cSrcweir SvLBoxContextBmp* pBmpItem; 2084*cdf0e10cSrcweir 2085*cdf0e10cSrcweir pView->PreparePaint( pEntry ); 2086*cdf0e10cSrcweir 2087*cdf0e10cSrcweir if( !pViewData ) 2088*cdf0e10cSrcweir pViewData = ICNVIEWDATA(pEntry); 2089*cdf0e10cSrcweir 2090*cdf0e10cSrcweir SvLBoxString* pStringItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING)); 2091*cdf0e10cSrcweir 2092*cdf0e10cSrcweir sal_Bool bSelected = pViewData->IsSelected(); 2093*cdf0e10cSrcweir sal_Bool bCursored = pViewData->IsCursored(); 2094*cdf0e10cSrcweir 2095*cdf0e10cSrcweir Font aTempFont( pOut->GetFont() ); 2096*cdf0e10cSrcweir // waehrend D&D nicht die Fontfarbe wechseln, da sonst auch die 2097*cdf0e10cSrcweir // Emphasis gezeichnet werden muss! (weisser Adler auf weissem Grund) 2098*cdf0e10cSrcweir if( bSelected && !(nFlags & F_NO_EMPHASIS) ) 2099*cdf0e10cSrcweir { 2100*cdf0e10cSrcweir const StyleSettings& rStyleSettings = pOut->GetSettings().GetStyleSettings(); 2101*cdf0e10cSrcweir Font aNewFont( aTempFont ); 2102*cdf0e10cSrcweir aNewFont.SetColor( rStyleSettings.GetHighlightTextColor() ); 2103*cdf0e10cSrcweir pOut->SetFont( aNewFont ); 2104*cdf0e10cSrcweir } 2105*cdf0e10cSrcweir Rectangle aTextRect( CalcTextRect(pEntry,pStringItem,&rPos,sal_False,pViewData)); 2106*cdf0e10cSrcweir Rectangle aBmpRect( CalcBmpRect(pEntry, &rPos, pViewData ) ); 2107*cdf0e10cSrcweir 2108*cdf0e10cSrcweir switch( nViewMode ) 2109*cdf0e10cSrcweir { 2110*cdf0e10cSrcweir case VIEWMODE_ICON: 2111*cdf0e10cSrcweir pBmpItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP)); 2112*cdf0e10cSrcweir PaintEmphasis( aBmpRect, bSelected, bCursored, pOut ); 2113*cdf0e10cSrcweir PaintItem( aBmpRect, pBmpItem, pEntry, 2114*cdf0e10cSrcweir PAINTFLAG_HOR_CENTERED | PAINTFLAG_VER_CENTERED, pOut ); 2115*cdf0e10cSrcweir PaintEmphasis( aTextRect, bSelected, sal_False, pOut ); 2116*cdf0e10cSrcweir PaintItem( aTextRect, pStringItem, pEntry, PAINTFLAG_HOR_CENTERED, pOut ); 2117*cdf0e10cSrcweir break; 2118*cdf0e10cSrcweir 2119*cdf0e10cSrcweir case VIEWMODE_NAME: 2120*cdf0e10cSrcweir pBmpItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP)); 2121*cdf0e10cSrcweir PaintEmphasis( aBmpRect, bSelected, bCursored, pOut ); 2122*cdf0e10cSrcweir PaintItem( aBmpRect, pBmpItem, pEntry, PAINTFLAG_VER_CENTERED, pOut ); 2123*cdf0e10cSrcweir PaintEmphasis( aTextRect, bSelected, sal_False, pOut ); 2124*cdf0e10cSrcweir PaintItem( aTextRect, pStringItem, pEntry,PAINTFLAG_VER_CENTERED, pOut ); 2125*cdf0e10cSrcweir break; 2126*cdf0e10cSrcweir 2127*cdf0e10cSrcweir case VIEWMODE_TEXT: 2128*cdf0e10cSrcweir PaintEmphasis( aTextRect, bSelected, bCursored, pOut ); 2129*cdf0e10cSrcweir PaintItem( aTextRect, pStringItem, pEntry, PAINTFLAG_VER_CENTERED, pOut ); 2130*cdf0e10cSrcweir break; 2131*cdf0e10cSrcweir } 2132*cdf0e10cSrcweir pOut->SetFont( aTempFont ); 2133*cdf0e10cSrcweir } 2134*cdf0e10cSrcweir 2135*cdf0e10cSrcweir void SvImpIconView::SetEntryPosition( SvLBoxEntry* pEntry, const Point& rPos, 2136*cdf0e10cSrcweir sal_Bool bAdjustAtGrid, sal_Bool bCheckScrollBars ) 2137*cdf0e10cSrcweir { 2138*cdf0e10cSrcweir if( pModel->GetParent(pEntry) == pCurParent ) 2139*cdf0e10cSrcweir { 2140*cdf0e10cSrcweir ShowCursor( sal_False ); 2141*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry); 2142*cdf0e10cSrcweir Rectangle aBoundRect( GetBoundingRect( pEntry, pViewData )); 2143*cdf0e10cSrcweir pView->Invalidate( aBoundRect ); 2144*cdf0e10cSrcweir ToTop( pEntry ); 2145*cdf0e10cSrcweir if( rPos != aBoundRect.TopLeft() ) 2146*cdf0e10cSrcweir { 2147*cdf0e10cSrcweir Point aGridOffs = pViewData->aGridRect.TopLeft() - 2148*cdf0e10cSrcweir pViewData->aRect.TopLeft(); 2149*cdf0e10cSrcweir pImpCursor->Clear(); 2150*cdf0e10cSrcweir nFlags &= ~F_GRID_INSERT; 2151*cdf0e10cSrcweir aBoundRect.SetPos( rPos ); 2152*cdf0e10cSrcweir pViewData->aRect = aBoundRect; 2153*cdf0e10cSrcweir pViewData->aGridRect.SetPos( rPos + aGridOffs ); 2154*cdf0e10cSrcweir AdjustVirtSize( aBoundRect ); 2155*cdf0e10cSrcweir } 2156*cdf0e10cSrcweir //HACK(Billigloesung, die noch verbessert werden muss) 2157*cdf0e10cSrcweir if( bAdjustAtGrid ) 2158*cdf0e10cSrcweir { 2159*cdf0e10cSrcweir AdjustAtGrid( pEntry ); 2160*cdf0e10cSrcweir ToTop( pEntry ); 2161*cdf0e10cSrcweir } 2162*cdf0e10cSrcweir if( bCheckScrollBars && pView->IsUpdateMode() ) 2163*cdf0e10cSrcweir CheckScrollBars(); 2164*cdf0e10cSrcweir 2165*cdf0e10cSrcweir PaintEntry( pEntry, pViewData ); 2166*cdf0e10cSrcweir ShowCursor( sal_True ); 2167*cdf0e10cSrcweir } 2168*cdf0e10cSrcweir } 2169*cdf0e10cSrcweir 2170*cdf0e10cSrcweir void SvImpIconView::ViewDataInitialized( SvLBoxEntry*) 2171*cdf0e10cSrcweir { 2172*cdf0e10cSrcweir } 2173*cdf0e10cSrcweir 2174*cdf0e10cSrcweir void SvImpIconView::ModelHasEntryInvalidated( SvListEntry* pEntry ) 2175*cdf0e10cSrcweir { 2176*cdf0e10cSrcweir if( pEntry == pCursor ) 2177*cdf0e10cSrcweir ShowCursor( sal_False ); 2178*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry); 2179*cdf0e10cSrcweir pView->Invalidate( pViewData->aRect ); 2180*cdf0e10cSrcweir 2181*cdf0e10cSrcweir if( nFlags & F_GRIDMODE ) 2182*cdf0e10cSrcweir Center( (SvLBoxEntry*)pEntry, pViewData ); 2183*cdf0e10cSrcweir else 2184*cdf0e10cSrcweir pViewData->aRect.SetSize( CalcBoundingSize( 2185*cdf0e10cSrcweir (SvLBoxEntry*)pEntry, pViewData ) ); 2186*cdf0e10cSrcweir 2187*cdf0e10cSrcweir ViewDataInitialized( (SvLBoxEntry*)pEntry ); 2188*cdf0e10cSrcweir pView->Invalidate( pViewData->aRect ); 2189*cdf0e10cSrcweir if( pEntry == pCursor ) 2190*cdf0e10cSrcweir ShowCursor( sal_True ); 2191*cdf0e10cSrcweir } 2192*cdf0e10cSrcweir 2193*cdf0e10cSrcweir 2194*cdf0e10cSrcweir void SvImpIconView::InvalidateEntry( SvLBoxEntry* pEntry ) 2195*cdf0e10cSrcweir { 2196*cdf0e10cSrcweir const Rectangle& rRect = GetBoundingRect( pEntry ); 2197*cdf0e10cSrcweir pView->Invalidate( rRect ); 2198*cdf0e10cSrcweir } 2199*cdf0e10cSrcweir 2200*cdf0e10cSrcweir void SvImpIconView::SetNoSelection() 2201*cdf0e10cSrcweir { 2202*cdf0e10cSrcweir } 2203*cdf0e10cSrcweir 2204*cdf0e10cSrcweir void SvImpIconView::SetDragDropMode( DragDropMode ) 2205*cdf0e10cSrcweir { 2206*cdf0e10cSrcweir } 2207*cdf0e10cSrcweir 2208*cdf0e10cSrcweir void SvImpIconView::SetSelectionMode( SelectionMode ) 2209*cdf0e10cSrcweir { 2210*cdf0e10cSrcweir } 2211*cdf0e10cSrcweir 2212*cdf0e10cSrcweir sal_Bool SvImpIconView::IsEntryInView( SvLBoxEntry* ) 2213*cdf0e10cSrcweir { 2214*cdf0e10cSrcweir return sal_False; 2215*cdf0e10cSrcweir } 2216*cdf0e10cSrcweir 2217*cdf0e10cSrcweir SvLBoxEntry* SvImpIconView::GetDropTarget( const Point& rPos ) 2218*cdf0e10cSrcweir { 2219*cdf0e10cSrcweir Point aDocPos( rPos ); 2220*cdf0e10cSrcweir CalcDocPos( aDocPos ); 2221*cdf0e10cSrcweir SvLBoxEntry* pTarget = GetEntry( aDocPos ); 2222*cdf0e10cSrcweir if( !pTarget || !pTarget->HasChilds() ) 2223*cdf0e10cSrcweir pTarget = pCurParent; 2224*cdf0e10cSrcweir return pTarget; 2225*cdf0e10cSrcweir } 2226*cdf0e10cSrcweir 2227*cdf0e10cSrcweir SvLBoxEntry* SvImpIconView::GetEntry( const Point& rDocPos ) 2228*cdf0e10cSrcweir { 2229*cdf0e10cSrcweir CheckBoundingRects(); 2230*cdf0e10cSrcweir SvLBoxEntry* pTarget = 0; 2231*cdf0e10cSrcweir // Z-Order-Liste vom Ende her absuchen 2232*cdf0e10cSrcweir sal_uInt16 nCount = pZOrderList->Count(); 2233*cdf0e10cSrcweir while( nCount ) 2234*cdf0e10cSrcweir { 2235*cdf0e10cSrcweir nCount--; 2236*cdf0e10cSrcweir SvLBoxEntry* pEntry = (SvLBoxEntry*)(pZOrderList->GetObject(nCount)); 2237*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry); 2238*cdf0e10cSrcweir if( pViewData->aRect.IsInside( rDocPos ) ) 2239*cdf0e10cSrcweir { 2240*cdf0e10cSrcweir pTarget = pEntry; 2241*cdf0e10cSrcweir break; 2242*cdf0e10cSrcweir } 2243*cdf0e10cSrcweir } 2244*cdf0e10cSrcweir return pTarget; 2245*cdf0e10cSrcweir } 2246*cdf0e10cSrcweir 2247*cdf0e10cSrcweir SvLBoxEntry* SvImpIconView::GetNextEntry( const Point& rDocPos, SvLBoxEntry* pCurEntry ) 2248*cdf0e10cSrcweir { 2249*cdf0e10cSrcweir CheckBoundingRects(); 2250*cdf0e10cSrcweir SvLBoxEntry* pTarget = 0; 2251*cdf0e10cSrcweir sal_uInt16 nStartPos = pZOrderList->GetPos( (void*)pCurEntry ); 2252*cdf0e10cSrcweir if( nStartPos != USHRT_MAX ) 2253*cdf0e10cSrcweir { 2254*cdf0e10cSrcweir sal_uInt16 nCount = pZOrderList->Count(); 2255*cdf0e10cSrcweir for( sal_uInt16 nCur = nStartPos+1; nCur < nCount; nCur++ ) 2256*cdf0e10cSrcweir { 2257*cdf0e10cSrcweir SvLBoxEntry* pEntry = (SvLBoxEntry*)(pZOrderList->GetObject(nCur)); 2258*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry); 2259*cdf0e10cSrcweir if( pViewData->aRect.IsInside( rDocPos ) ) 2260*cdf0e10cSrcweir { 2261*cdf0e10cSrcweir pTarget = pEntry; 2262*cdf0e10cSrcweir break; 2263*cdf0e10cSrcweir } 2264*cdf0e10cSrcweir } 2265*cdf0e10cSrcweir } 2266*cdf0e10cSrcweir return pTarget; 2267*cdf0e10cSrcweir } 2268*cdf0e10cSrcweir 2269*cdf0e10cSrcweir SvLBoxEntry* SvImpIconView::GetPrevEntry( const Point& rDocPos, SvLBoxEntry* pCurEntry ) 2270*cdf0e10cSrcweir { 2271*cdf0e10cSrcweir CheckBoundingRects(); 2272*cdf0e10cSrcweir SvLBoxEntry* pTarget = 0; 2273*cdf0e10cSrcweir sal_uInt16 nStartPos = pZOrderList->GetPos( (void*)pCurEntry ); 2274*cdf0e10cSrcweir if( nStartPos != USHRT_MAX && nStartPos != 0 ) 2275*cdf0e10cSrcweir { 2276*cdf0e10cSrcweir nStartPos--; 2277*cdf0e10cSrcweir do 2278*cdf0e10cSrcweir { 2279*cdf0e10cSrcweir SvLBoxEntry* pEntry = (SvLBoxEntry*)(pZOrderList->GetObject(nStartPos)); 2280*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry); 2281*cdf0e10cSrcweir if( pViewData->aRect.IsInside( rDocPos ) ) 2282*cdf0e10cSrcweir { 2283*cdf0e10cSrcweir pTarget = pEntry; 2284*cdf0e10cSrcweir break; 2285*cdf0e10cSrcweir } 2286*cdf0e10cSrcweir } while( nStartPos > 0 ); 2287*cdf0e10cSrcweir } 2288*cdf0e10cSrcweir return pTarget; 2289*cdf0e10cSrcweir } 2290*cdf0e10cSrcweir 2291*cdf0e10cSrcweir 2292*cdf0e10cSrcweir Point SvImpIconView::GetEntryPosition( SvLBoxEntry* pEntry ) 2293*cdf0e10cSrcweir { 2294*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry); 2295*cdf0e10cSrcweir DBG_ASSERT(pViewData,"Entry not in model"); 2296*cdf0e10cSrcweir return pViewData->aRect.TopLeft(); 2297*cdf0e10cSrcweir } 2298*cdf0e10cSrcweir 2299*cdf0e10cSrcweir const Rectangle& SvImpIconView::GetBoundingRect( SvLBoxEntry* pEntry, SvIcnVwDataEntry* pViewData ) 2300*cdf0e10cSrcweir { 2301*cdf0e10cSrcweir if( !pViewData ) 2302*cdf0e10cSrcweir pViewData = ICNVIEWDATA(pEntry); 2303*cdf0e10cSrcweir DBG_ASSERT(pViewData,"Entry not in model"); 2304*cdf0e10cSrcweir if( !IsBoundingRectValid( pViewData->aRect )) 2305*cdf0e10cSrcweir FindBoundingRect( pEntry, pViewData ); 2306*cdf0e10cSrcweir return pViewData->aRect; 2307*cdf0e10cSrcweir } 2308*cdf0e10cSrcweir 2309*cdf0e10cSrcweir void SvImpIconView::SetSpaceBetweenEntries( long nHor, long nVer ) 2310*cdf0e10cSrcweir { 2311*cdf0e10cSrcweir nHorDist = nHor; 2312*cdf0e10cSrcweir nVerDist = nVer; 2313*cdf0e10cSrcweir } 2314*cdf0e10cSrcweir 2315*cdf0e10cSrcweir Rectangle SvImpIconView::CalcBmpRect( SvLBoxEntry* pEntry, const Point* pPos, 2316*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData ) 2317*cdf0e10cSrcweir { 2318*cdf0e10cSrcweir if( !pViewData ) 2319*cdf0e10cSrcweir pViewData = ICNVIEWDATA(pEntry); 2320*cdf0e10cSrcweir 2321*cdf0e10cSrcweir Rectangle aBound = GetBoundingRect( pEntry, pViewData ); 2322*cdf0e10cSrcweir if( pPos ) 2323*cdf0e10cSrcweir aBound.SetPos( *pPos ); 2324*cdf0e10cSrcweir Point aPos( aBound.TopLeft() ); 2325*cdf0e10cSrcweir 2326*cdf0e10cSrcweir switch( nViewMode ) 2327*cdf0e10cSrcweir { 2328*cdf0e10cSrcweir case VIEWMODE_ICON: 2329*cdf0e10cSrcweir { 2330*cdf0e10cSrcweir aPos.X() += ( aBound.GetWidth() - nMaxBmpWidth ) / 2; 2331*cdf0e10cSrcweir Size aSize( nMaxBmpWidth, nMaxBmpHeight ); 2332*cdf0e10cSrcweir // das Bitmap-Rechteck soll nicht das TextRect beruehren 2333*cdf0e10cSrcweir aSize.Height() -= 3; 2334*cdf0e10cSrcweir return Rectangle( aPos, aSize ); 2335*cdf0e10cSrcweir } 2336*cdf0e10cSrcweir 2337*cdf0e10cSrcweir case VIEWMODE_NAME: 2338*cdf0e10cSrcweir return Rectangle( aPos, 2339*cdf0e10cSrcweir Size( nMaxBmpWidth, aBound.GetHeight() )); 2340*cdf0e10cSrcweir 2341*cdf0e10cSrcweir case VIEWMODE_TEXT: 2342*cdf0e10cSrcweir return Rectangle( aPos, aBound.GetSize() ); 2343*cdf0e10cSrcweir 2344*cdf0e10cSrcweir default: 2345*cdf0e10cSrcweir { 2346*cdf0e10cSrcweir Rectangle aRect; 2347*cdf0e10cSrcweir return aRect; 2348*cdf0e10cSrcweir } 2349*cdf0e10cSrcweir } 2350*cdf0e10cSrcweir } 2351*cdf0e10cSrcweir 2352*cdf0e10cSrcweir Rectangle SvImpIconView::CalcTextRect( SvLBoxEntry* pEntry, 2353*cdf0e10cSrcweir SvLBoxString* pItem, const Point* pPos, sal_Bool bForInplaceEdit, 2354*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData ) 2355*cdf0e10cSrcweir { 2356*cdf0e10cSrcweir long nBmpHeight, nBmpWidth; 2357*cdf0e10cSrcweir 2358*cdf0e10cSrcweir if( !pItem ) 2359*cdf0e10cSrcweir pItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING)); 2360*cdf0e10cSrcweir 2361*cdf0e10cSrcweir if( !pViewData ) 2362*cdf0e10cSrcweir pViewData = ICNVIEWDATA(pEntry); 2363*cdf0e10cSrcweir 2364*cdf0e10cSrcweir Size aTextSize( GetItemSize( pView, pEntry, pItem, pViewData )); 2365*cdf0e10cSrcweir aTextSize.Width() += 2*LROFFS_TEXT; 2366*cdf0e10cSrcweir 2367*cdf0e10cSrcweir Size aContextBmpSize(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP)->GetSize(pView,pEntry)); 2368*cdf0e10cSrcweir Rectangle aBound = GetBoundingRect( pEntry, pViewData ); 2369*cdf0e10cSrcweir if( pPos ) 2370*cdf0e10cSrcweir aBound.SetPos( *pPos ); 2371*cdf0e10cSrcweir Point aPos( aBound.TopLeft() ); 2372*cdf0e10cSrcweir 2373*cdf0e10cSrcweir switch( nViewMode ) 2374*cdf0e10cSrcweir { 2375*cdf0e10cSrcweir case VIEWMODE_ICON: 2376*cdf0e10cSrcweir nBmpHeight = aContextBmpSize.Height(); 2377*cdf0e10cSrcweir if( nBmpHeight < nMaxBmpHeight ) 2378*cdf0e10cSrcweir nBmpHeight = nMaxBmpHeight; 2379*cdf0e10cSrcweir aPos.Y() += nBmpHeight; 2380*cdf0e10cSrcweir 2381*cdf0e10cSrcweir // beim Inplace-Editieren, spendieren wir ein bisschen mehr Platz 2382*cdf0e10cSrcweir if( bForInplaceEdit ) 2383*cdf0e10cSrcweir { 2384*cdf0e10cSrcweir // 20% rauf 2385*cdf0e10cSrcweir long nMinWidth = (( (aContextBmpSize.Width()*10) / 100 ) * 2 ) + 2386*cdf0e10cSrcweir aContextBmpSize.Width(); 2387*cdf0e10cSrcweir if( nMinWidth > aBound.GetWidth() ) 2388*cdf0e10cSrcweir nMinWidth = aBound.GetWidth(); 2389*cdf0e10cSrcweir 2390*cdf0e10cSrcweir if( aTextSize.Width() < nMinWidth ) 2391*cdf0e10cSrcweir aTextSize.Width() = nMinWidth; 2392*cdf0e10cSrcweir 2393*cdf0e10cSrcweir // beim Inplace-Ed. darfs auch untere Eintraege ueberlappen 2394*cdf0e10cSrcweir Rectangle aMaxGridTextRect = CalcMaxTextRect(pEntry, pViewData); 2395*cdf0e10cSrcweir Size aOptSize = aMaxGridTextRect.GetSize(); 2396*cdf0e10cSrcweir if( aOptSize.Height() > aTextSize.Height() ) 2397*cdf0e10cSrcweir aTextSize.Height() = aOptSize.Height(); 2398*cdf0e10cSrcweir } 2399*cdf0e10cSrcweir 2400*cdf0e10cSrcweir 2401*cdf0e10cSrcweir aPos.X() += ( aBound.GetWidth() - aTextSize.Width() ) / 2; 2402*cdf0e10cSrcweir break; 2403*cdf0e10cSrcweir 2404*cdf0e10cSrcweir case VIEWMODE_NAME: 2405*cdf0e10cSrcweir nBmpWidth = aContextBmpSize.Width(); 2406*cdf0e10cSrcweir if( nBmpWidth < nMaxBmpWidth ) 2407*cdf0e10cSrcweir nBmpWidth = nMaxBmpWidth; 2408*cdf0e10cSrcweir aPos.X() += nBmpWidth; 2409*cdf0e10cSrcweir // vertikal ausrichten 2410*cdf0e10cSrcweir aPos.Y() += ( nBmpWidth - aTextSize.Height() ) / 2; 2411*cdf0e10cSrcweir break; 2412*cdf0e10cSrcweir } 2413*cdf0e10cSrcweir 2414*cdf0e10cSrcweir Rectangle aRect( aPos, aTextSize ); 2415*cdf0e10cSrcweir // KNALLT BEIM D&D, WENN GECLIPPT WIRD (In DrawText von Thomas) 2416*cdf0e10cSrcweir // ClipAtVirtOutRect( aRect ); 2417*cdf0e10cSrcweir return aRect; 2418*cdf0e10cSrcweir } 2419*cdf0e10cSrcweir 2420*cdf0e10cSrcweir 2421*cdf0e10cSrcweir long SvImpIconView::CalcBoundingWidth( SvLBoxEntry* pEntry, 2422*cdf0e10cSrcweir const SvIcnVwDataEntry* pViewData ) const 2423*cdf0e10cSrcweir { 2424*cdf0e10cSrcweir DBG_ASSERT(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP),"No Bitmaps"); 2425*cdf0e10cSrcweir DBG_ASSERT(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING),"No Text"); 2426*cdf0e10cSrcweir long nStringWidth = GetItemSize( pView, pEntry, pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING),pViewData).Width(); 2427*cdf0e10cSrcweir nStringWidth += 2*LROFFS_TEXT; 2428*cdf0e10cSrcweir long nBmpWidth = pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP)->GetSize(pView,pEntry).Width(); 2429*cdf0e10cSrcweir long nWidth = 0; 2430*cdf0e10cSrcweir 2431*cdf0e10cSrcweir switch( nViewMode ) 2432*cdf0e10cSrcweir { 2433*cdf0e10cSrcweir case VIEWMODE_ICON: 2434*cdf0e10cSrcweir nWidth = Max( nStringWidth, nBmpWidth ); 2435*cdf0e10cSrcweir nWidth = Max( nWidth, nMaxBmpWidth ); 2436*cdf0e10cSrcweir break; 2437*cdf0e10cSrcweir 2438*cdf0e10cSrcweir case VIEWMODE_NAME: 2439*cdf0e10cSrcweir nWidth = Max( nBmpWidth, nMaxBmpWidth ); 2440*cdf0e10cSrcweir nWidth += NAMEVIEW_OFFS_BMP_STRING; // Abstand Bitmap String 2441*cdf0e10cSrcweir nWidth += nStringWidth; 2442*cdf0e10cSrcweir break; 2443*cdf0e10cSrcweir 2444*cdf0e10cSrcweir case VIEWMODE_TEXT: 2445*cdf0e10cSrcweir nWidth = nStringWidth; 2446*cdf0e10cSrcweir break; 2447*cdf0e10cSrcweir } 2448*cdf0e10cSrcweir return nWidth; 2449*cdf0e10cSrcweir } 2450*cdf0e10cSrcweir 2451*cdf0e10cSrcweir long SvImpIconView::CalcBoundingHeight( SvLBoxEntry* pEntry, 2452*cdf0e10cSrcweir const SvIcnVwDataEntry* pViewData ) const 2453*cdf0e10cSrcweir { 2454*cdf0e10cSrcweir DBG_ASSERT(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP),"No Bitmaps"); 2455*cdf0e10cSrcweir DBG_ASSERT(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING),"No Text"); 2456*cdf0e10cSrcweir long nStringHeight = GetItemSize(pView,pEntry,pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING),pViewData).Height(); 2457*cdf0e10cSrcweir long nBmpHeight = pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP)->GetSize(pView,pEntry).Height(); 2458*cdf0e10cSrcweir long nHeight = 0; 2459*cdf0e10cSrcweir 2460*cdf0e10cSrcweir switch( nViewMode ) 2461*cdf0e10cSrcweir { 2462*cdf0e10cSrcweir case VIEWMODE_ICON: 2463*cdf0e10cSrcweir nHeight = Max( nBmpHeight, nMaxBmpHeight ); 2464*cdf0e10cSrcweir nHeight += ICONVIEW_OFFS_BMP_STRING; // Abstand Bitmap String 2465*cdf0e10cSrcweir nHeight += nStringHeight; 2466*cdf0e10cSrcweir break; 2467*cdf0e10cSrcweir 2468*cdf0e10cSrcweir case VIEWMODE_NAME: 2469*cdf0e10cSrcweir nHeight = Max( nBmpHeight, nMaxBmpHeight ); 2470*cdf0e10cSrcweir nHeight = Max( nHeight, nStringHeight ); 2471*cdf0e10cSrcweir break; 2472*cdf0e10cSrcweir 2473*cdf0e10cSrcweir case VIEWMODE_TEXT: 2474*cdf0e10cSrcweir nHeight = nStringHeight; 2475*cdf0e10cSrcweir break; 2476*cdf0e10cSrcweir } 2477*cdf0e10cSrcweir if( nHeight > nMaxBoundHeight ) 2478*cdf0e10cSrcweir { 2479*cdf0e10cSrcweir ((SvImpIconView*)this)->nMaxBoundHeight = nHeight; 2480*cdf0e10cSrcweir ((SvImpIconView*)this)->aHorSBar.SetLineSize( nHeight / 2 ); 2481*cdf0e10cSrcweir ((SvImpIconView*)this)->aVerSBar.SetLineSize( nHeight / 2 ); 2482*cdf0e10cSrcweir } 2483*cdf0e10cSrcweir return nHeight; 2484*cdf0e10cSrcweir } 2485*cdf0e10cSrcweir 2486*cdf0e10cSrcweir Size SvImpIconView::CalcBoundingSize( SvLBoxEntry* pEntry, 2487*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData ) const 2488*cdf0e10cSrcweir { 2489*cdf0e10cSrcweir if( !pViewData ) 2490*cdf0e10cSrcweir pViewData = ICNVIEWDATA(pEntry); 2491*cdf0e10cSrcweir return Size( CalcBoundingWidth(pEntry,pViewData), 2492*cdf0e10cSrcweir CalcBoundingHeight(pEntry,pViewData) ); 2493*cdf0e10cSrcweir } 2494*cdf0e10cSrcweir 2495*cdf0e10cSrcweir void SvImpIconView::RecalcAllBoundingRects() 2496*cdf0e10cSrcweir { 2497*cdf0e10cSrcweir nMaxBoundHeight = 0; 2498*cdf0e10cSrcweir pZOrderList->Remove(0, pZOrderList->Count() ); 2499*cdf0e10cSrcweir SvLBoxEntry* pEntry = pModel->FirstChild( pCurParent ); 2500*cdf0e10cSrcweir while( pEntry ) 2501*cdf0e10cSrcweir { 2502*cdf0e10cSrcweir FindBoundingRect( pEntry ); 2503*cdf0e10cSrcweir pZOrderList->Insert( pEntry, pZOrderList->Count() ); 2504*cdf0e10cSrcweir pEntry = pModel->NextSibling( pEntry ); 2505*cdf0e10cSrcweir } 2506*cdf0e10cSrcweir bMustRecalcBoundingRects = sal_False; 2507*cdf0e10cSrcweir AdjustScrollBars(); 2508*cdf0e10cSrcweir } 2509*cdf0e10cSrcweir 2510*cdf0e10cSrcweir void SvImpIconView::RecalcAllBoundingRectsSmart() 2511*cdf0e10cSrcweir { 2512*cdf0e10cSrcweir nMaxBoundHeight = 0; 2513*cdf0e10cSrcweir pZOrderList->Remove(0, pZOrderList->Count() ); 2514*cdf0e10cSrcweir SvLBoxEntry* pEntry = pModel->FirstChild( pCurParent ); 2515*cdf0e10cSrcweir while( pEntry ) 2516*cdf0e10cSrcweir { 2517*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry); 2518*cdf0e10cSrcweir if( IsBoundingRectValid( pViewData->aRect )) 2519*cdf0e10cSrcweir { 2520*cdf0e10cSrcweir Size aBoundSize( pViewData->aRect.GetSize() ); 2521*cdf0e10cSrcweir if( aBoundSize.Height() > nMaxBoundHeight ) 2522*cdf0e10cSrcweir nMaxBoundHeight = aBoundSize.Height(); 2523*cdf0e10cSrcweir pZOrderList->Insert( pEntry, pZOrderList->Count() ); 2524*cdf0e10cSrcweir } 2525*cdf0e10cSrcweir else 2526*cdf0e10cSrcweir { 2527*cdf0e10cSrcweir FindBoundingRect( pEntry, pViewData ); 2528*cdf0e10cSrcweir } 2529*cdf0e10cSrcweir pZOrderList->Insert( pEntry, pZOrderList->Count() ); 2530*cdf0e10cSrcweir pEntry = pModel->NextSibling( pEntry ); 2531*cdf0e10cSrcweir } 2532*cdf0e10cSrcweir AdjustScrollBars(); 2533*cdf0e10cSrcweir } 2534*cdf0e10cSrcweir 2535*cdf0e10cSrcweir void SvImpIconView::UpdateBoundingRects() 2536*cdf0e10cSrcweir { 2537*cdf0e10cSrcweir SvLBoxEntry* pEntry = pModel->FirstChild( pCurParent ); 2538*cdf0e10cSrcweir while( pEntry ) 2539*cdf0e10cSrcweir { 2540*cdf0e10cSrcweir GetBoundingRect( pEntry ); 2541*cdf0e10cSrcweir pEntry = pModel->NextSibling( pEntry ); 2542*cdf0e10cSrcweir } 2543*cdf0e10cSrcweir } 2544*cdf0e10cSrcweir 2545*cdf0e10cSrcweir void SvImpIconView::FindBoundingRect( SvLBoxEntry* pEntry, 2546*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData ) 2547*cdf0e10cSrcweir { 2548*cdf0e10cSrcweir if( !pViewData ) 2549*cdf0e10cSrcweir pViewData = ICNVIEWDATA(pEntry); 2550*cdf0e10cSrcweir 2551*cdf0e10cSrcweir Size aSize( CalcBoundingSize( pEntry, pViewData ) ); 2552*cdf0e10cSrcweir Point aPos; 2553*cdf0e10cSrcweir 2554*cdf0e10cSrcweir DBG_ASSERT(!pViewData->IsEntryPosLocked(),"Locked entry pos in FindBoundingRect"); 2555*cdf0e10cSrcweir // damits in der IconView nicht drunter & drueber geht 2556*cdf0e10cSrcweir if( pViewData->IsEntryPosLocked() && IsBoundingRectValid(pViewData->aRect) ) 2557*cdf0e10cSrcweir { 2558*cdf0e10cSrcweir AdjustVirtSize( pViewData->aRect ); 2559*cdf0e10cSrcweir return; 2560*cdf0e10cSrcweir } 2561*cdf0e10cSrcweir 2562*cdf0e10cSrcweir aPos = FindNextEntryPos( aSize ); 2563*cdf0e10cSrcweir 2564*cdf0e10cSrcweir if( nFlags & F_GRIDMODE ) 2565*cdf0e10cSrcweir { 2566*cdf0e10cSrcweir Rectangle aGridRect( aPos, Size(nGridDX, nGridDY) ); 2567*cdf0e10cSrcweir pViewData->aGridRect = aGridRect; 2568*cdf0e10cSrcweir Center( pEntry, pViewData ); 2569*cdf0e10cSrcweir AdjustVirtSize( pViewData->aRect ); 2570*cdf0e10cSrcweir pImpCursor->SetGridUsed( pViewData->aRect ); 2571*cdf0e10cSrcweir } 2572*cdf0e10cSrcweir else 2573*cdf0e10cSrcweir { 2574*cdf0e10cSrcweir pViewData->aRect = Rectangle( aPos, aSize ); 2575*cdf0e10cSrcweir AdjustVirtSize( pViewData->aRect ); 2576*cdf0e10cSrcweir } 2577*cdf0e10cSrcweir } 2578*cdf0e10cSrcweir 2579*cdf0e10cSrcweir 2580*cdf0e10cSrcweir void SvImpIconView::SetCursor( SvLBoxEntry* pEntry ) 2581*cdf0e10cSrcweir { 2582*cdf0e10cSrcweir if( pEntry == pCursor ) 2583*cdf0e10cSrcweir return; 2584*cdf0e10cSrcweir 2585*cdf0e10cSrcweir ShowCursor( sal_False ); 2586*cdf0e10cSrcweir if( pCursor ) 2587*cdf0e10cSrcweir { 2588*cdf0e10cSrcweir pView->SetEntryFocus( pCursor, sal_False ); 2589*cdf0e10cSrcweir if( pView->GetSelectionMode() == SINGLE_SELECTION ) 2590*cdf0e10cSrcweir pView->Select( pCursor, sal_False ); 2591*cdf0e10cSrcweir } 2592*cdf0e10cSrcweir pCursor = pEntry; 2593*cdf0e10cSrcweir ToTop( pCursor ); 2594*cdf0e10cSrcweir if( pCursor ) 2595*cdf0e10cSrcweir { 2596*cdf0e10cSrcweir pView->SetEntryFocus(pCursor, sal_True ); 2597*cdf0e10cSrcweir if( pView->GetSelectionMode() == SINGLE_SELECTION ) 2598*cdf0e10cSrcweir pView->Select( pCursor, sal_True ); 2599*cdf0e10cSrcweir ShowCursor( sal_True ); 2600*cdf0e10cSrcweir } 2601*cdf0e10cSrcweir } 2602*cdf0e10cSrcweir 2603*cdf0e10cSrcweir 2604*cdf0e10cSrcweir void SvImpIconView::ShowCursor( sal_Bool bShow ) 2605*cdf0e10cSrcweir { 2606*cdf0e10cSrcweir if( !pCursor || !bShow || !pView->HasFocus() ) 2607*cdf0e10cSrcweir { 2608*cdf0e10cSrcweir pView->HideFocus(); 2609*cdf0e10cSrcweir return; 2610*cdf0e10cSrcweir } 2611*cdf0e10cSrcweir Rectangle aRect ( CalcFocusRect( pCursor ) ); 2612*cdf0e10cSrcweir pView->ShowFocus( aRect ); 2613*cdf0e10cSrcweir } 2614*cdf0e10cSrcweir 2615*cdf0e10cSrcweir 2616*cdf0e10cSrcweir void SvImpIconView::HideDDIcon() 2617*cdf0e10cSrcweir { 2618*cdf0e10cSrcweir pView->Update(); 2619*cdf0e10cSrcweir ImpHideDDIcon(); 2620*cdf0e10cSrcweir pDDBufDev = pDDDev; 2621*cdf0e10cSrcweir pDDDev = 0; 2622*cdf0e10cSrcweir } 2623*cdf0e10cSrcweir 2624*cdf0e10cSrcweir void SvImpIconView::ImpHideDDIcon() 2625*cdf0e10cSrcweir { 2626*cdf0e10cSrcweir if( pDDDev ) 2627*cdf0e10cSrcweir { 2628*cdf0e10cSrcweir Size aSize( pDDDev->GetOutputSizePixel() ); 2629*cdf0e10cSrcweir // pView restaurieren 2630*cdf0e10cSrcweir pView->DrawOutDev( aDDLastRectPos, aSize, Point(), aSize, *pDDDev ); 2631*cdf0e10cSrcweir } 2632*cdf0e10cSrcweir } 2633*cdf0e10cSrcweir 2634*cdf0e10cSrcweir 2635*cdf0e10cSrcweir void SvImpIconView::ShowDDIcon( SvLBoxEntry* pRefEntry, const Point& rPosPix ) 2636*cdf0e10cSrcweir { 2637*cdf0e10cSrcweir pView->Update(); 2638*cdf0e10cSrcweir if( pRefEntry != pDDRefEntry ) 2639*cdf0e10cSrcweir { 2640*cdf0e10cSrcweir DELETEZ(pDDDev); 2641*cdf0e10cSrcweir DELETEZ(pDDBufDev); 2642*cdf0e10cSrcweir } 2643*cdf0e10cSrcweir sal_Bool bSelected = pView->SvListView::Select( pRefEntry, sal_False ); 2644*cdf0e10cSrcweir if( !pDDDev ) 2645*cdf0e10cSrcweir { 2646*cdf0e10cSrcweir if( pDDBufDev ) 2647*cdf0e10cSrcweir { 2648*cdf0e10cSrcweir // nicht bei jedem Move ein Device anlegen, da dies besonders 2649*cdf0e10cSrcweir // auf Remote-Clients zu langsam ist 2650*cdf0e10cSrcweir pDDDev = pDDBufDev; 2651*cdf0e10cSrcweir pDDBufDev = 0; 2652*cdf0e10cSrcweir } 2653*cdf0e10cSrcweir else 2654*cdf0e10cSrcweir { 2655*cdf0e10cSrcweir pDDDev = new VirtualDevice( *pView ); 2656*cdf0e10cSrcweir pDDDev->SetFont( pView->GetFont() ); 2657*cdf0e10cSrcweir } 2658*cdf0e10cSrcweir } 2659*cdf0e10cSrcweir else 2660*cdf0e10cSrcweir { 2661*cdf0e10cSrcweir ImpHideDDIcon(); 2662*cdf0e10cSrcweir } 2663*cdf0e10cSrcweir const Rectangle& rRect = GetBoundingRect( pRefEntry ); 2664*cdf0e10cSrcweir pDDDev->SetOutputSizePixel( rRect.GetSize() ); 2665*cdf0e10cSrcweir 2666*cdf0e10cSrcweir Point aPos( rPosPix ); 2667*cdf0e10cSrcweir CalcDocPos( aPos ); 2668*cdf0e10cSrcweir 2669*cdf0e10cSrcweir Size aSize( pDDDev->GetOutputSizePixel() ); 2670*cdf0e10cSrcweir pDDRefEntry = pRefEntry; 2671*cdf0e10cSrcweir aDDLastEntryPos = aPos; 2672*cdf0e10cSrcweir aDDLastRectPos = aPos; 2673*cdf0e10cSrcweir 2674*cdf0e10cSrcweir // Hintergrund sichern 2675*cdf0e10cSrcweir pDDDev->DrawOutDev( Point(), aSize, aPos, aSize, *pView ); 2676*cdf0e10cSrcweir // Icon in pView malen 2677*cdf0e10cSrcweir nFlags |= F_NO_EMPHASIS; 2678*cdf0e10cSrcweir PaintEntry( pRefEntry, aPos ); 2679*cdf0e10cSrcweir nFlags &= ~F_NO_EMPHASIS; 2680*cdf0e10cSrcweir if( bSelected ) 2681*cdf0e10cSrcweir pView->SvListView::Select( pRefEntry, sal_True ); 2682*cdf0e10cSrcweir } 2683*cdf0e10cSrcweir 2684*cdf0e10cSrcweir void SvImpIconView::HideShowDDIcon( SvLBoxEntry* pRefEntry, const Point& rPosPix ) 2685*cdf0e10cSrcweir { 2686*cdf0e10cSrcweir /* In Notfaellen folgenden flackernden Code aktivieren: 2687*cdf0e10cSrcweir 2688*cdf0e10cSrcweir HideDDIcon(); 2689*cdf0e10cSrcweir ShowDDIcon( pRefEntry, rPosPix ); 2690*cdf0e10cSrcweir return; 2691*cdf0e10cSrcweir */ 2692*cdf0e10cSrcweir if( !pDDDev ) 2693*cdf0e10cSrcweir { 2694*cdf0e10cSrcweir ShowDDIcon( pRefEntry, rPosPix ); 2695*cdf0e10cSrcweir return; 2696*cdf0e10cSrcweir } 2697*cdf0e10cSrcweir 2698*cdf0e10cSrcweir if( pRefEntry != pDDRefEntry ) 2699*cdf0e10cSrcweir { 2700*cdf0e10cSrcweir HideDDIcon(); 2701*cdf0e10cSrcweir ShowDDIcon( pRefEntry, rPosPix ); 2702*cdf0e10cSrcweir return; 2703*cdf0e10cSrcweir } 2704*cdf0e10cSrcweir 2705*cdf0e10cSrcweir Point aEmptyPoint; 2706*cdf0e10cSrcweir 2707*cdf0e10cSrcweir Point aCurEntryPos( rPosPix ); 2708*cdf0e10cSrcweir CalcDocPos( aCurEntryPos ); 2709*cdf0e10cSrcweir 2710*cdf0e10cSrcweir const Rectangle& rRect = GetBoundingRect( pRefEntry ); 2711*cdf0e10cSrcweir Size aEntrySize( rRect.GetSize() ); 2712*cdf0e10cSrcweir Rectangle aPrevEntryRect( aDDLastEntryPos, aEntrySize ); 2713*cdf0e10cSrcweir Rectangle aCurEntryRect( aCurEntryPos, aEntrySize ); 2714*cdf0e10cSrcweir 2715*cdf0e10cSrcweir if( !aPrevEntryRect.IsOver( aCurEntryRect ) ) 2716*cdf0e10cSrcweir { 2717*cdf0e10cSrcweir HideDDIcon(); 2718*cdf0e10cSrcweir ShowDDIcon( pRefEntry, rPosPix ); 2719*cdf0e10cSrcweir return; 2720*cdf0e10cSrcweir } 2721*cdf0e10cSrcweir 2722*cdf0e10cSrcweir // Ueberlappung des neuen und alten D&D-Pointers! 2723*cdf0e10cSrcweir 2724*cdf0e10cSrcweir Rectangle aFullRect( aPrevEntryRect.Union( aCurEntryRect ) ); 2725*cdf0e10cSrcweir if( !pDDTempDev ) 2726*cdf0e10cSrcweir { 2727*cdf0e10cSrcweir pDDTempDev = new VirtualDevice( *pView ); 2728*cdf0e10cSrcweir pDDTempDev->SetFont( pView->GetFont() ); 2729*cdf0e10cSrcweir } 2730*cdf0e10cSrcweir 2731*cdf0e10cSrcweir Size aFullSize( aFullRect.GetSize() ); 2732*cdf0e10cSrcweir Point aFullPos( aFullRect.TopLeft() ); 2733*cdf0e10cSrcweir 2734*cdf0e10cSrcweir pDDTempDev->SetOutputSizePixel( aFullSize ); 2735*cdf0e10cSrcweir 2736*cdf0e10cSrcweir // Hintergrund (mit dem alten D&D-Pointer!) sichern 2737*cdf0e10cSrcweir pDDTempDev->DrawOutDev( aEmptyPoint, aFullSize, aFullPos, aFullSize, *pView ); 2738*cdf0e10cSrcweir // den alten Buffer in den neuen Buffer pasten 2739*cdf0e10cSrcweir aDDLastRectPos = aDDLastRectPos - aFullPos; 2740*cdf0e10cSrcweir 2741*cdf0e10cSrcweir pDDTempDev->DrawOutDev( 2742*cdf0e10cSrcweir aDDLastRectPos, 2743*cdf0e10cSrcweir pDDDev->GetOutputSizePixel(), 2744*cdf0e10cSrcweir aEmptyPoint, 2745*cdf0e10cSrcweir pDDDev->GetOutputSizePixel(), 2746*cdf0e10cSrcweir *pDDDev ); 2747*cdf0e10cSrcweir 2748*cdf0e10cSrcweir // Swap 2749*cdf0e10cSrcweir VirtualDevice* pTemp = pDDDev; 2750*cdf0e10cSrcweir pDDDev = pDDTempDev; 2751*cdf0e10cSrcweir pDDTempDev = pTemp; 2752*cdf0e10cSrcweir 2753*cdf0e10cSrcweir // in den restaurierten Hintergrund den neuen D&D-Pointer zeichnen 2754*cdf0e10cSrcweir pDDTempDev->SetOutputSizePixel( pDDDev->GetOutputSizePixel() ); 2755*cdf0e10cSrcweir pDDTempDev->DrawOutDev( 2756*cdf0e10cSrcweir aEmptyPoint, aFullSize, aEmptyPoint, aFullSize, *pDDDev ); 2757*cdf0e10cSrcweir Point aRelPos = aCurEntryPos - aFullPos; 2758*cdf0e10cSrcweir nFlags |= F_NO_EMPHASIS; 2759*cdf0e10cSrcweir PaintEntry( pRefEntry, aRelPos, 0, pDDTempDev ); 2760*cdf0e10cSrcweir nFlags &= ~F_NO_EMPHASIS; 2761*cdf0e10cSrcweir 2762*cdf0e10cSrcweir aDDLastRectPos = aFullPos; 2763*cdf0e10cSrcweir aDDLastEntryPos = aCurEntryPos; 2764*cdf0e10cSrcweir 2765*cdf0e10cSrcweir pView->DrawOutDev( 2766*cdf0e10cSrcweir aDDLastRectPos, 2767*cdf0e10cSrcweir pDDDev->GetOutputSizePixel(), 2768*cdf0e10cSrcweir aEmptyPoint, 2769*cdf0e10cSrcweir pDDDev->GetOutputSizePixel(), 2770*cdf0e10cSrcweir *pDDTempDev ); 2771*cdf0e10cSrcweir 2772*cdf0e10cSrcweir sal_Bool bSelected = pView->SvListView::Select( pRefEntry, sal_False ); 2773*cdf0e10cSrcweir if( bSelected ) 2774*cdf0e10cSrcweir pView->SvListView::Select( pRefEntry, sal_True ); 2775*cdf0e10cSrcweir } 2776*cdf0e10cSrcweir 2777*cdf0e10cSrcweir void SvImpIconView::ShowTargetEmphasis( SvLBoxEntry* pEntry, sal_Bool ) 2778*cdf0e10cSrcweir { 2779*cdf0e10cSrcweir CheckBoundingRects(); 2780*cdf0e10cSrcweir Rectangle aRect; 2781*cdf0e10cSrcweir if( pEntry != pCurParent && 2782*cdf0e10cSrcweir (pEntry->HasChilds() || pEntry->HasChildsOnDemand()) ) 2783*cdf0e10cSrcweir aRect = CalcBmpRect( pEntry ); 2784*cdf0e10cSrcweir else 2785*cdf0e10cSrcweir { 2786*cdf0e10cSrcweir aRect.SetSize( aOutputSize ); 2787*cdf0e10cSrcweir const MapMode& rMapMode = pView->GetMapMode(); 2788*cdf0e10cSrcweir Point aOrigin( rMapMode.GetOrigin()); 2789*cdf0e10cSrcweir aOrigin *= -1; // in Doc-Koord wandeln 2790*cdf0e10cSrcweir aRect.SetPos( aOrigin ); 2791*cdf0e10cSrcweir aRect.Left()++; aRect.Top()++; 2792*cdf0e10cSrcweir aRect.Right()--; aRect.Bottom()--; 2793*cdf0e10cSrcweir } 2794*cdf0e10cSrcweir ImpDrawXORRect( aRect ); 2795*cdf0e10cSrcweir } 2796*cdf0e10cSrcweir 2797*cdf0e10cSrcweir sal_Bool SvImpIconView::NotifyMoving( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry, 2798*cdf0e10cSrcweir SvLBoxEntry*& rpNewPar, sal_uLong& rNewChildPos ) 2799*cdf0e10cSrcweir { 2800*cdf0e10cSrcweir if( pTarget == pCurParent && pModel->GetParent(pEntry) == pCurParent ) 2801*cdf0e10cSrcweir { 2802*cdf0e10cSrcweir // D&D innerhalb einer Childlist 2803*cdf0e10cSrcweir StopEditTimer(); 2804*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry); 2805*cdf0e10cSrcweir Size aSize( pViewData->aRect.GetSize() ); 2806*cdf0e10cSrcweir Point aNewPos = FindNextEntryPos( aSize ); 2807*cdf0e10cSrcweir AdjustVirtSize( Rectangle( aNewPos, aSize ) ); 2808*cdf0e10cSrcweir SetEntryPosition( pEntry, aNewPos, sal_False, sal_True ); 2809*cdf0e10cSrcweir return sal_False; 2810*cdf0e10cSrcweir } 2811*cdf0e10cSrcweir return pView->SvLBox::NotifyMoving(pTarget,pEntry,rpNewPar,rNewChildPos); 2812*cdf0e10cSrcweir } 2813*cdf0e10cSrcweir 2814*cdf0e10cSrcweir sal_Bool SvImpIconView::NotifyCopying( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry, 2815*cdf0e10cSrcweir SvLBoxEntry*& rpNewParent, sal_uLong& rNewChildPos ) 2816*cdf0e10cSrcweir { 2817*cdf0e10cSrcweir return pView->SvLBox::NotifyCopying(pTarget,pEntry,rpNewParent,rNewChildPos); 2818*cdf0e10cSrcweir } 2819*cdf0e10cSrcweir 2820*cdf0e10cSrcweir void SvImpIconView::WriteDragServerInfo( const Point& rPos, SvLBoxDDInfo* pInfo) 2821*cdf0e10cSrcweir { 2822*cdf0e10cSrcweir SvLBoxEntry* pCurEntry = GetCurEntry(); 2823*cdf0e10cSrcweir Point aEntryPos; 2824*cdf0e10cSrcweir if( pCurEntry ) 2825*cdf0e10cSrcweir { 2826*cdf0e10cSrcweir aEntryPos = rPos; 2827*cdf0e10cSrcweir aEntryPos -= GetEntryPosition( pCurEntry ); 2828*cdf0e10cSrcweir } 2829*cdf0e10cSrcweir pInfo->nMouseRelX = aEntryPos.X(); 2830*cdf0e10cSrcweir pInfo->nMouseRelY = aEntryPos.Y(); 2831*cdf0e10cSrcweir } 2832*cdf0e10cSrcweir 2833*cdf0e10cSrcweir void SvImpIconView::ReadDragServerInfo( const Point& rPos, SvLBoxDDInfo* pInfo ) 2834*cdf0e10cSrcweir { 2835*cdf0e10cSrcweir Point aDropPos( rPos ); 2836*cdf0e10cSrcweir aDropPos.X() -= pInfo->nMouseRelX; 2837*cdf0e10cSrcweir aDropPos.Y() -= pInfo->nMouseRelY; 2838*cdf0e10cSrcweir SetNextEntryPos( aDropPos ); 2839*cdf0e10cSrcweir } 2840*cdf0e10cSrcweir 2841*cdf0e10cSrcweir void SvImpIconView::InvalidateBoundingRect( SvLBoxEntry* pEntry ) 2842*cdf0e10cSrcweir { 2843*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry); 2844*cdf0e10cSrcweir InvalidateBoundingRect( pViewData->aRect ); 2845*cdf0e10cSrcweir } 2846*cdf0e10cSrcweir 2847*cdf0e10cSrcweir void SvImpIconView::PrepareCommandEvent( const Point& rPt ) 2848*cdf0e10cSrcweir { 2849*cdf0e10cSrcweir aMouseMoveTimer.Stop(); 2850*cdf0e10cSrcweir StopEditTimer(); 2851*cdf0e10cSrcweir nFlags |= F_CMD_ARRIVED; 2852*cdf0e10cSrcweir SvLBoxEntry* pEntry = pView->GetEntry( rPt, sal_True ); 2853*cdf0e10cSrcweir if( (nFlags & F_DOWN_CTRL) && pEntry && !pView->IsSelected(pEntry) ) 2854*cdf0e10cSrcweir pView->Select( pEntry, sal_True ); 2855*cdf0e10cSrcweir nFlags &= ~(F_DOWN_CTRL | F_DOWN_DESELECT); 2856*cdf0e10cSrcweir } 2857*cdf0e10cSrcweir 2858*cdf0e10cSrcweir void SvImpIconView::SttDrag( const Point& rPos ) 2859*cdf0e10cSrcweir { 2860*cdf0e10cSrcweir PrepareCommandEvent( rPos ); 2861*cdf0e10cSrcweir 2862*cdf0e10cSrcweir nFlags |= F_DRAG_SOURCE; 2863*cdf0e10cSrcweir ShowCursor( sal_False ); 2864*cdf0e10cSrcweir } 2865*cdf0e10cSrcweir 2866*cdf0e10cSrcweir void SvImpIconView::EndDrag() 2867*cdf0e10cSrcweir { 2868*cdf0e10cSrcweir ShowCursor( sal_True ); 2869*cdf0e10cSrcweir nFlags &= (~F_DRAG_SOURCE); 2870*cdf0e10cSrcweir } 2871*cdf0e10cSrcweir 2872*cdf0e10cSrcweir void SvImpIconView::ToTop( SvLBoxEntry* pEntry ) 2873*cdf0e10cSrcweir { 2874*cdf0e10cSrcweir DBG_ASSERT(pZOrderList->GetPos(pEntry)!=0xffff,"ToTop:ZOrder?"); 2875*cdf0e10cSrcweir if( pZOrderList->GetObject( pZOrderList->Count() -1 ) != pEntry ) 2876*cdf0e10cSrcweir { 2877*cdf0e10cSrcweir sal_uInt16 nPos = pZOrderList->GetPos( (void*)pEntry ); 2878*cdf0e10cSrcweir pZOrderList->Remove( nPos, 1 ); 2879*cdf0e10cSrcweir pZOrderList->Insert( pEntry, pZOrderList->Count() ); 2880*cdf0e10cSrcweir } 2881*cdf0e10cSrcweir } 2882*cdf0e10cSrcweir 2883*cdf0e10cSrcweir void SvImpIconView::SetCurParent( SvLBoxEntry* pNewParent ) 2884*cdf0e10cSrcweir { 2885*cdf0e10cSrcweir Clear(); 2886*cdf0e10cSrcweir pCurParent = pNewParent; 2887*cdf0e10cSrcweir ImpArrange(); 2888*cdf0e10cSrcweir } 2889*cdf0e10cSrcweir 2890*cdf0e10cSrcweir void SvImpIconView::ClipAtVirtOutRect( Rectangle& rRect ) const 2891*cdf0e10cSrcweir { 2892*cdf0e10cSrcweir if( rRect.Bottom() >= aVirtOutputSize.Height() ) 2893*cdf0e10cSrcweir rRect.Bottom() = aVirtOutputSize.Height() - 1; 2894*cdf0e10cSrcweir if( rRect.Right() >= aVirtOutputSize.Width() ) 2895*cdf0e10cSrcweir rRect.Right() = aVirtOutputSize.Width() - 1; 2896*cdf0e10cSrcweir if( rRect.Top() < 0 ) 2897*cdf0e10cSrcweir rRect.Top() = 0; 2898*cdf0e10cSrcweir if( rRect.Left() < 0 ) 2899*cdf0e10cSrcweir rRect.Left() = 0; 2900*cdf0e10cSrcweir } 2901*cdf0e10cSrcweir 2902*cdf0e10cSrcweir // rRect: Bereich des Dokumentes (in Dokumentkoordinaten), der 2903*cdf0e10cSrcweir // sichtbar gemacht werden soll. 2904*cdf0e10cSrcweir // bScrBar == sal_True: Das Rect wurde aufgrund eines ScrollBar-Events berechnet 2905*cdf0e10cSrcweir 2906*cdf0e10cSrcweir void SvImpIconView::MakeVisible( const Rectangle& rRect, sal_Bool bScrBar ) 2907*cdf0e10cSrcweir { 2908*cdf0e10cSrcweir Rectangle aRect( rRect ); 2909*cdf0e10cSrcweir ClipAtVirtOutRect( aRect ); 2910*cdf0e10cSrcweir MapMode aMapMode( pView->GetMapMode() ); 2911*cdf0e10cSrcweir Point aOrigin( aMapMode.GetOrigin() ); 2912*cdf0e10cSrcweir // in Dokumentkoordinate umwandeln 2913*cdf0e10cSrcweir aOrigin *= -1; 2914*cdf0e10cSrcweir 2915*cdf0e10cSrcweir Rectangle aOutputArea( aOrigin, aOutputSize ); 2916*cdf0e10cSrcweir if( aOutputArea.IsInside( aRect ) ) 2917*cdf0e10cSrcweir return; // ist schon sichtbar 2918*cdf0e10cSrcweir 2919*cdf0e10cSrcweir long nDy; 2920*cdf0e10cSrcweir if( aRect.Top() < aOutputArea.Top() ) 2921*cdf0e10cSrcweir { 2922*cdf0e10cSrcweir // nach oben scrollen (nDy < 0) 2923*cdf0e10cSrcweir nDy = aRect.Top() - aOutputArea.Top(); 2924*cdf0e10cSrcweir } 2925*cdf0e10cSrcweir else if( aRect.Bottom() > aOutputArea.Bottom() ) 2926*cdf0e10cSrcweir { 2927*cdf0e10cSrcweir // nach unten scrollen (nDy > 0) 2928*cdf0e10cSrcweir nDy = aRect.Bottom() - aOutputArea.Bottom(); 2929*cdf0e10cSrcweir } 2930*cdf0e10cSrcweir else 2931*cdf0e10cSrcweir nDy = 0; 2932*cdf0e10cSrcweir 2933*cdf0e10cSrcweir long nDx; 2934*cdf0e10cSrcweir if( aRect.Left() < aOutputArea.Left() ) 2935*cdf0e10cSrcweir { 2936*cdf0e10cSrcweir // nach links scrollen (nDx < 0) 2937*cdf0e10cSrcweir nDx = aRect.Left() - aOutputArea.Left(); 2938*cdf0e10cSrcweir } 2939*cdf0e10cSrcweir else if( aRect.Right() > aOutputArea.Right() ) 2940*cdf0e10cSrcweir { 2941*cdf0e10cSrcweir // nach rechts scrollen (nDx > 0) 2942*cdf0e10cSrcweir nDx = aRect.Right() - aOutputArea.Right(); 2943*cdf0e10cSrcweir } 2944*cdf0e10cSrcweir else 2945*cdf0e10cSrcweir nDx = 0; 2946*cdf0e10cSrcweir 2947*cdf0e10cSrcweir aOrigin.X() += nDx; 2948*cdf0e10cSrcweir aOrigin.Y() += nDy; 2949*cdf0e10cSrcweir aOutputArea.SetPos( aOrigin ); 2950*cdf0e10cSrcweir 2951*cdf0e10cSrcweir pView->Update(); 2952*cdf0e10cSrcweir 2953*cdf0e10cSrcweir // Origin fuer SV invertieren (damit wir in 2954*cdf0e10cSrcweir // Dokumentkoordinaten scrollen/painten koennen) 2955*cdf0e10cSrcweir aOrigin *= -1; 2956*cdf0e10cSrcweir aMapMode.SetOrigin( aOrigin ); 2957*cdf0e10cSrcweir pView->SetMapMode( aMapMode ); 2958*cdf0e10cSrcweir 2959*cdf0e10cSrcweir // in umgekehrte Richtung scrollen! 2960*cdf0e10cSrcweir pView->Control::Scroll( -nDx, -nDy, aOutputArea, sal_True ); 2961*cdf0e10cSrcweir if( aHorSBar.IsVisible() || aVerSBar.IsVisible() ) 2962*cdf0e10cSrcweir { 2963*cdf0e10cSrcweir if( !bScrBar ) 2964*cdf0e10cSrcweir { 2965*cdf0e10cSrcweir aOrigin *= -1; 2966*cdf0e10cSrcweir // Thumbs korrigieren 2967*cdf0e10cSrcweir if(aHorSBar.IsVisible() && aHorSBar.GetThumbPos() != aOrigin.X()) 2968*cdf0e10cSrcweir aHorSBar.SetThumbPos( aOrigin.X() ); 2969*cdf0e10cSrcweir if(aVerSBar.IsVisible() && aVerSBar.GetThumbPos() != aOrigin.Y()) 2970*cdf0e10cSrcweir aVerSBar.SetThumbPos( aOrigin.Y() ); 2971*cdf0e10cSrcweir } 2972*cdf0e10cSrcweir } 2973*cdf0e10cSrcweir // pruefen, ob ScrollBars noch benoetigt werden 2974*cdf0e10cSrcweir CheckScrollBars(); 2975*cdf0e10cSrcweir pView->Update(); 2976*cdf0e10cSrcweir } 2977*cdf0e10cSrcweir 2978*cdf0e10cSrcweir 2979*cdf0e10cSrcweir SvLBoxEntry* SvImpIconView::GetNewCursor() 2980*cdf0e10cSrcweir { 2981*cdf0e10cSrcweir SvLBoxEntry* pNewCursor; 2982*cdf0e10cSrcweir if( pCursor ) 2983*cdf0e10cSrcweir { 2984*cdf0e10cSrcweir pNewCursor = pImpCursor->GoLeftRight( pCursor, sal_False ); 2985*cdf0e10cSrcweir if( !pNewCursor ) 2986*cdf0e10cSrcweir { 2987*cdf0e10cSrcweir pNewCursor = pImpCursor->GoLeftRight( pCursor, sal_True ); 2988*cdf0e10cSrcweir if( !pNewCursor ) 2989*cdf0e10cSrcweir { 2990*cdf0e10cSrcweir pNewCursor = pImpCursor->GoUpDown( pCursor, sal_False ); 2991*cdf0e10cSrcweir if( !pNewCursor ) 2992*cdf0e10cSrcweir pNewCursor = pImpCursor->GoUpDown( pCursor, sal_True ); 2993*cdf0e10cSrcweir } 2994*cdf0e10cSrcweir } 2995*cdf0e10cSrcweir } 2996*cdf0e10cSrcweir else 2997*cdf0e10cSrcweir pNewCursor = pModel->FirstChild( pCurParent ); 2998*cdf0e10cSrcweir DBG_ASSERT(!pNewCursor|| (pCursor&&pCursor!=pNewCursor),"GetNewCursor failed"); 2999*cdf0e10cSrcweir return pNewCursor; 3000*cdf0e10cSrcweir } 3001*cdf0e10cSrcweir 3002*cdf0e10cSrcweir 3003*cdf0e10cSrcweir sal_uInt16 SvImpIconView:: GetSelectionCount() const 3004*cdf0e10cSrcweir { 3005*cdf0e10cSrcweir sal_uInt16 nSelected = 0; 3006*cdf0e10cSrcweir SvLBoxEntry* pEntry = pModel->FirstChild( pCurParent); 3007*cdf0e10cSrcweir while( pEntry ) 3008*cdf0e10cSrcweir { 3009*cdf0e10cSrcweir if( pView->IsSelected( pEntry ) ) 3010*cdf0e10cSrcweir nSelected++; 3011*cdf0e10cSrcweir pEntry = pModel->NextSibling( pEntry ); 3012*cdf0e10cSrcweir } 3013*cdf0e10cSrcweir return nSelected; 3014*cdf0e10cSrcweir } 3015*cdf0e10cSrcweir 3016*cdf0e10cSrcweir 3017*cdf0e10cSrcweir void SvImpIconView::ToggleSelection( SvLBoxEntry* pEntry ) 3018*cdf0e10cSrcweir { 3019*cdf0e10cSrcweir sal_Bool bSel; 3020*cdf0e10cSrcweir if( pView->IsSelected( pEntry ) ) 3021*cdf0e10cSrcweir bSel = sal_False; 3022*cdf0e10cSrcweir else 3023*cdf0e10cSrcweir bSel = sal_True; 3024*cdf0e10cSrcweir pView->Select( pEntry, bSel ); 3025*cdf0e10cSrcweir } 3026*cdf0e10cSrcweir 3027*cdf0e10cSrcweir void SvImpIconView::DeselectAllBut( SvLBoxEntry* pThisEntryNot ) 3028*cdf0e10cSrcweir { 3029*cdf0e10cSrcweir ClearSelectedRectList(); 3030*cdf0e10cSrcweir SvLBoxEntry* pEntry = pModel->FirstChild( pCurParent ); 3031*cdf0e10cSrcweir while( pEntry ) 3032*cdf0e10cSrcweir { 3033*cdf0e10cSrcweir if( pEntry != pThisEntryNot && pView->IsSelected( pEntry )) 3034*cdf0e10cSrcweir pView->Select( pEntry, sal_False ); 3035*cdf0e10cSrcweir pEntry = pModel->NextSibling( pEntry ); 3036*cdf0e10cSrcweir } 3037*cdf0e10cSrcweir } 3038*cdf0e10cSrcweir 3039*cdf0e10cSrcweir #define ICN_ROWS 50 3040*cdf0e10cSrcweir #define ICN_COLS 30 3041*cdf0e10cSrcweir 3042*cdf0e10cSrcweir ImpIcnCursor::ImpIcnCursor( SvImpIconView* pOwner ) 3043*cdf0e10cSrcweir { 3044*cdf0e10cSrcweir pView = pOwner; 3045*cdf0e10cSrcweir pColumns = 0; 3046*cdf0e10cSrcweir pRows = 0; 3047*cdf0e10cSrcweir pCurEntry = 0; 3048*cdf0e10cSrcweir nDeltaWidth = 0; 3049*cdf0e10cSrcweir nDeltaHeight= 0; 3050*cdf0e10cSrcweir nCols = 0; 3051*cdf0e10cSrcweir nRows = 0; 3052*cdf0e10cSrcweir nGridCols = 0; 3053*cdf0e10cSrcweir nGridRows = 0; 3054*cdf0e10cSrcweir pGridMap = 0; 3055*cdf0e10cSrcweir } 3056*cdf0e10cSrcweir 3057*cdf0e10cSrcweir ImpIcnCursor::~ImpIcnCursor() 3058*cdf0e10cSrcweir { 3059*cdf0e10cSrcweir delete[] pColumns; 3060*cdf0e10cSrcweir delete[] pRows; 3061*cdf0e10cSrcweir delete pGridMap; 3062*cdf0e10cSrcweir } 3063*cdf0e10cSrcweir 3064*cdf0e10cSrcweir sal_uInt16 ImpIcnCursor::GetSortListPos( SvPtrarr* pList, long nValue, 3065*cdf0e10cSrcweir int bVertical ) 3066*cdf0e10cSrcweir { 3067*cdf0e10cSrcweir sal_uInt16 nCount = (sal_uInt16)pList->Count(); 3068*cdf0e10cSrcweir if( !nCount ) 3069*cdf0e10cSrcweir return 0; 3070*cdf0e10cSrcweir 3071*cdf0e10cSrcweir sal_uInt16 nCurPos = 0; 3072*cdf0e10cSrcweir long nPrevValue = LONG_MIN; 3073*cdf0e10cSrcweir while( nCount ) 3074*cdf0e10cSrcweir { 3075*cdf0e10cSrcweir const Rectangle& rRect= 3076*cdf0e10cSrcweir pView->GetBoundingRect((SvLBoxEntry*)(pList->GetObject(nCurPos))); 3077*cdf0e10cSrcweir long nCurValue; 3078*cdf0e10cSrcweir if( bVertical ) 3079*cdf0e10cSrcweir nCurValue = rRect.Top(); 3080*cdf0e10cSrcweir else 3081*cdf0e10cSrcweir nCurValue = rRect.Left(); 3082*cdf0e10cSrcweir if( nValue >= nPrevValue && nValue <= nCurValue ) 3083*cdf0e10cSrcweir return (sal_uInt16)nCurPos; 3084*cdf0e10cSrcweir nPrevValue = nCurValue; 3085*cdf0e10cSrcweir nCount--; 3086*cdf0e10cSrcweir nCurPos++; 3087*cdf0e10cSrcweir } 3088*cdf0e10cSrcweir return pList->Count(); 3089*cdf0e10cSrcweir } 3090*cdf0e10cSrcweir 3091*cdf0e10cSrcweir void ImpIcnCursor::ImplCreate() 3092*cdf0e10cSrcweir { 3093*cdf0e10cSrcweir pView->CheckBoundingRects(); 3094*cdf0e10cSrcweir DBG_ASSERT(pColumns==0&&pRows==0,"ImplCreate: Not cleared"); 3095*cdf0e10cSrcweir 3096*cdf0e10cSrcweir SetDeltas(); 3097*cdf0e10cSrcweir 3098*cdf0e10cSrcweir pColumns = new SvPtrarr[ nCols ]; 3099*cdf0e10cSrcweir pRows = new SvPtrarr[ nRows ]; 3100*cdf0e10cSrcweir 3101*cdf0e10cSrcweir DELETEZ(pGridMap); 3102*cdf0e10cSrcweir 3103*cdf0e10cSrcweir SvLBoxTreeList* pModel = pView->pModel; 3104*cdf0e10cSrcweir SvLBoxEntry* pEntry = pModel->FirstChild( pView->pCurParent ); 3105*cdf0e10cSrcweir while( pEntry ) 3106*cdf0e10cSrcweir { 3107*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA2(pEntry); 3108*cdf0e10cSrcweir // const Rectangle& rRect = pView->GetBoundingRect( pEntry ); 3109*cdf0e10cSrcweir Rectangle rRect( pView->CalcBmpRect( pEntry,0,pViewData ) ); 3110*cdf0e10cSrcweir short nY = (short)( ((rRect.Top()+rRect.Bottom())/2) / nDeltaHeight ); 3111*cdf0e10cSrcweir short nX = (short)( ((rRect.Left()+rRect.Right())/2) / nDeltaWidth ); 3112*cdf0e10cSrcweir 3113*cdf0e10cSrcweir // Rundungsfehler abfangen 3114*cdf0e10cSrcweir if( nY >= nRows ) 3115*cdf0e10cSrcweir nY = sal::static_int_cast< short >(nRows - 1); 3116*cdf0e10cSrcweir if( nX >= nCols ) 3117*cdf0e10cSrcweir nX = sal::static_int_cast< short >(nCols - 1); 3118*cdf0e10cSrcweir 3119*cdf0e10cSrcweir sal_uInt16 nIns = GetSortListPos( &pColumns[nX], rRect.Top(), sal_True ); 3120*cdf0e10cSrcweir pColumns[ nX ].Insert( pEntry, nIns ); 3121*cdf0e10cSrcweir 3122*cdf0e10cSrcweir nIns = GetSortListPos( &pRows[nY], rRect.Left(), sal_False ); 3123*cdf0e10cSrcweir pRows[ nY ].Insert( pEntry, nIns ); 3124*cdf0e10cSrcweir 3125*cdf0e10cSrcweir pViewData->nX = nX; 3126*cdf0e10cSrcweir pViewData->nY = nY; 3127*cdf0e10cSrcweir 3128*cdf0e10cSrcweir pEntry = pModel->NextSibling( pEntry ); 3129*cdf0e10cSrcweir } 3130*cdf0e10cSrcweir } 3131*cdf0e10cSrcweir 3132*cdf0e10cSrcweir void ImpIcnCursor::CreateGridMap() 3133*cdf0e10cSrcweir { 3134*cdf0e10cSrcweir if( pGridMap ) 3135*cdf0e10cSrcweir return; 3136*cdf0e10cSrcweir 3137*cdf0e10cSrcweir const Size& rSize = pView->aVirtOutputSize; 3138*cdf0e10cSrcweir long nWidth = rSize.Width(); 3139*cdf0e10cSrcweir if( nWidth < pView->nMaxVirtWidth ) 3140*cdf0e10cSrcweir nWidth = pView->nMaxVirtWidth; 3141*cdf0e10cSrcweir nWidth -= 2*LROFFS_WINBORDER; 3142*cdf0e10cSrcweir if( nWidth <= 0 ) 3143*cdf0e10cSrcweir nWidth = 1; 3144*cdf0e10cSrcweir 3145*cdf0e10cSrcweir nGridDX = pView->nGridDX; 3146*cdf0e10cSrcweir nGridDY = pView->nGridDY; 3147*cdf0e10cSrcweir 3148*cdf0e10cSrcweir // Hinweis: Wegen der Abrundung bei Berechnung von nGridCols 3149*cdf0e10cSrcweir // ist es moeglich, dass Eintrage nicht im Grid liegen. Diese 3150*cdf0e10cSrcweir // wurden typischerweise manuell verschoben und gelockt 3151*cdf0e10cSrcweir nGridCols = nWidth / nGridDX; 3152*cdf0e10cSrcweir if( !nGridCols ) nGridCols = 1; 3153*cdf0e10cSrcweir 3154*cdf0e10cSrcweir nGridRows = rSize.Height() / nGridDY; 3155*cdf0e10cSrcweir // nRows nicht abrunden, da zur Vermeidung von Ueberlappungen 3156*cdf0e10cSrcweir // das gesamte BoundingRect des Eintrags zur Markierung im Grid 3157*cdf0e10cSrcweir // herangezogen wird. 3158*cdf0e10cSrcweir if( (nGridRows * nGridDY) < rSize.Height() ) 3159*cdf0e10cSrcweir nGridRows++; 3160*cdf0e10cSrcweir else if( !nGridRows ) 3161*cdf0e10cSrcweir nGridRows = 1; 3162*cdf0e10cSrcweir 3163*cdf0e10cSrcweir //XXX 3164*cdf0e10cSrcweir //nGridRows += 50; // in fuenfziger-Schritten 3165*cdf0e10cSrcweir 3166*cdf0e10cSrcweir pGridMap = new sal_Bool[ nGridRows*nGridCols]; 3167*cdf0e10cSrcweir memset( (void*)pGridMap, 0, nGridRows*nGridCols ); 3168*cdf0e10cSrcweir 3169*cdf0e10cSrcweir SvLBoxTreeList* pModel = pView->pModel; 3170*cdf0e10cSrcweir SvLBoxEntry* pEntry = pModel->FirstChild( pView->pCurParent ); 3171*cdf0e10cSrcweir while( pEntry ) 3172*cdf0e10cSrcweir { 3173*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA2(pEntry); 3174*cdf0e10cSrcweir const Rectangle& rRect = pViewData->aRect; 3175*cdf0e10cSrcweir // nur, wenn der Entry schon plaziert ist 3176*cdf0e10cSrcweir if( pView->IsBoundingRectValid( rRect )) 3177*cdf0e10cSrcweir { 3178*cdf0e10cSrcweir // Alle vom Eintrag beruehrten Grids kennzeichnen 3179*cdf0e10cSrcweir SetGridUsed( pView->GetBoundingRect( pEntry, pViewData ) ); 3180*cdf0e10cSrcweir } 3181*cdf0e10cSrcweir pEntry = pModel->NextSibling( pEntry ); 3182*cdf0e10cSrcweir } 3183*cdf0e10cSrcweir } 3184*cdf0e10cSrcweir 3185*cdf0e10cSrcweir sal_Bool ImpIcnCursor::GetGrid( const Point& rDocPos, sal_uInt16& rGridX, sal_uInt16& rGridY ) const 3186*cdf0e10cSrcweir { 3187*cdf0e10cSrcweir Point aPos( rDocPos ); 3188*cdf0e10cSrcweir aPos.X() -= LROFFS_WINBORDER; 3189*cdf0e10cSrcweir aPos.Y() -= TBOFFS_WINBORDER; 3190*cdf0e10cSrcweir rGridX = (sal_uInt16)(aPos.X() / nGridDX); 3191*cdf0e10cSrcweir rGridY = (sal_uInt16)(aPos.Y() / nGridDY); 3192*cdf0e10cSrcweir sal_Bool bInGrid = sal_True; 3193*cdf0e10cSrcweir if( rGridX >= nGridCols ) 3194*cdf0e10cSrcweir { 3195*cdf0e10cSrcweir rGridX = sal::static_int_cast< sal_uInt16 >(nGridCols - 1); 3196*cdf0e10cSrcweir bInGrid = sal_False; 3197*cdf0e10cSrcweir } 3198*cdf0e10cSrcweir if( rGridY >= nGridRows ) 3199*cdf0e10cSrcweir { 3200*cdf0e10cSrcweir rGridY = sal::static_int_cast< sal_uInt16 >(nGridRows - 1); 3201*cdf0e10cSrcweir if( !bInGrid ) 3202*cdf0e10cSrcweir return sal_False; // beide Koordinaten nicht im Grid 3203*cdf0e10cSrcweir } 3204*cdf0e10cSrcweir return sal_True; 3205*cdf0e10cSrcweir } 3206*cdf0e10cSrcweir 3207*cdf0e10cSrcweir void ImpIcnCursor::SetGridUsed( const Rectangle& rRect, sal_Bool bUsed ) 3208*cdf0e10cSrcweir { 3209*cdf0e10cSrcweir CreateGridMap(); 3210*cdf0e10cSrcweir sal_uInt16 nTLX, nTLY, nBRX, nBRY; 3211*cdf0e10cSrcweir 3212*cdf0e10cSrcweir sal_Bool bTLInGrid = GetGrid( rRect.TopLeft(), nTLX, nTLY ); 3213*cdf0e10cSrcweir sal_Bool bBRInGrid = GetGrid( rRect.BottomRight(), nBRX, nBRY ); 3214*cdf0e10cSrcweir 3215*cdf0e10cSrcweir if( !bTLInGrid && !bBRInGrid ) 3216*cdf0e10cSrcweir return; 3217*cdf0e10cSrcweir 3218*cdf0e10cSrcweir for( sal_uInt16 nCurY = nTLY; nCurY <= nBRY; nCurY++ ) 3219*cdf0e10cSrcweir { 3220*cdf0e10cSrcweir for( sal_uInt16 nCurX = nTLX; nCurX <= nBRX; nCurX++ ) 3221*cdf0e10cSrcweir { 3222*cdf0e10cSrcweir SetGridUsed( nCurX, nCurY, bUsed ); 3223*cdf0e10cSrcweir } 3224*cdf0e10cSrcweir } 3225*cdf0e10cSrcweir } 3226*cdf0e10cSrcweir 3227*cdf0e10cSrcweir void ImpIcnCursor::Clear( sal_Bool bGridToo ) 3228*cdf0e10cSrcweir { 3229*cdf0e10cSrcweir if( pColumns ) 3230*cdf0e10cSrcweir { 3231*cdf0e10cSrcweir delete[] pColumns; 3232*cdf0e10cSrcweir delete[] pRows; 3233*cdf0e10cSrcweir pColumns = 0; 3234*cdf0e10cSrcweir pRows = 0; 3235*cdf0e10cSrcweir pCurEntry = 0; 3236*cdf0e10cSrcweir nDeltaWidth = 0; 3237*cdf0e10cSrcweir nDeltaHeight = 0; 3238*cdf0e10cSrcweir } 3239*cdf0e10cSrcweir if( bGridToo && pGridMap ) 3240*cdf0e10cSrcweir { 3241*cdf0e10cSrcweir DELETEZ(pGridMap); 3242*cdf0e10cSrcweir nGridRows = 0; 3243*cdf0e10cSrcweir nGridCols = 0; 3244*cdf0e10cSrcweir } 3245*cdf0e10cSrcweir } 3246*cdf0e10cSrcweir 3247*cdf0e10cSrcweir SvLBoxEntry* ImpIcnCursor::SearchCol(sal_uInt16 nCol,sal_uInt16 nTop,sal_uInt16 nBottom, 3248*cdf0e10cSrcweir sal_uInt16, sal_Bool bDown, sal_Bool bSimple ) 3249*cdf0e10cSrcweir { 3250*cdf0e10cSrcweir DBG_ASSERT(pCurEntry,"SearchCol: No reference entry"); 3251*cdf0e10cSrcweir SvPtrarr* pList = &(pColumns[ nCol ]); 3252*cdf0e10cSrcweir sal_uInt16 nCount = pList->Count(); 3253*cdf0e10cSrcweir if( !nCount ) 3254*cdf0e10cSrcweir return 0; 3255*cdf0e10cSrcweir 3256*cdf0e10cSrcweir const Rectangle& rRefRect = pView->GetBoundingRect(pCurEntry); 3257*cdf0e10cSrcweir 3258*cdf0e10cSrcweir if( bSimple ) 3259*cdf0e10cSrcweir { 3260*cdf0e10cSrcweir sal_uInt16 nListPos = pList->GetPos( pCurEntry ); 3261*cdf0e10cSrcweir DBG_ASSERT(nListPos!=0xffff,"Entry not in Col-List"); 3262*cdf0e10cSrcweir if( bDown ) 3263*cdf0e10cSrcweir { 3264*cdf0e10cSrcweir while( nListPos < nCount-1 ) 3265*cdf0e10cSrcweir { 3266*cdf0e10cSrcweir nListPos++; 3267*cdf0e10cSrcweir SvLBoxEntry* pEntry = (SvLBoxEntry*)pList->GetObject( nListPos ); 3268*cdf0e10cSrcweir const Rectangle& rRect = pView->GetBoundingRect( pEntry ); 3269*cdf0e10cSrcweir if( rRect.Top() > rRefRect.Top() ) 3270*cdf0e10cSrcweir return pEntry; 3271*cdf0e10cSrcweir } 3272*cdf0e10cSrcweir return 0; 3273*cdf0e10cSrcweir } 3274*cdf0e10cSrcweir else 3275*cdf0e10cSrcweir { 3276*cdf0e10cSrcweir while( nListPos ) 3277*cdf0e10cSrcweir { 3278*cdf0e10cSrcweir nListPos--; 3279*cdf0e10cSrcweir if( nListPos < nCount ) 3280*cdf0e10cSrcweir { 3281*cdf0e10cSrcweir SvLBoxEntry* pEntry = (SvLBoxEntry*)pList->GetObject( nListPos ); 3282*cdf0e10cSrcweir const Rectangle& rRect = pView->GetBoundingRect( pEntry ); 3283*cdf0e10cSrcweir if( rRect.Top() < rRefRect.Top() ) 3284*cdf0e10cSrcweir return pEntry; 3285*cdf0e10cSrcweir } 3286*cdf0e10cSrcweir } 3287*cdf0e10cSrcweir return 0; 3288*cdf0e10cSrcweir } 3289*cdf0e10cSrcweir } 3290*cdf0e10cSrcweir 3291*cdf0e10cSrcweir if( nTop > nBottom ) 3292*cdf0e10cSrcweir { 3293*cdf0e10cSrcweir sal_uInt16 nTemp = nTop; 3294*cdf0e10cSrcweir nTop = nBottom; 3295*cdf0e10cSrcweir nBottom = nTemp; 3296*cdf0e10cSrcweir } 3297*cdf0e10cSrcweir long nMinDistance = LONG_MAX; 3298*cdf0e10cSrcweir SvLBoxEntry* pResult = 0; 3299*cdf0e10cSrcweir for( sal_uInt16 nCur = 0; nCur < nCount; nCur++ ) 3300*cdf0e10cSrcweir { 3301*cdf0e10cSrcweir SvLBoxEntry* pEntry = (SvLBoxEntry*)(pList->GetObject( nCur )); 3302*cdf0e10cSrcweir if( pEntry != pCurEntry ) 3303*cdf0e10cSrcweir { 3304*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA2(pEntry); 3305*cdf0e10cSrcweir sal_uInt16 nY = pViewData->nY; 3306*cdf0e10cSrcweir if( nY >= nTop && nY <= nBottom ) 3307*cdf0e10cSrcweir { 3308*cdf0e10cSrcweir const Rectangle& rRect = pView->GetBoundingRect( pEntry ); 3309*cdf0e10cSrcweir long nDistance = rRect.Top() - rRefRect.Top(); 3310*cdf0e10cSrcweir if( nDistance < 0 ) 3311*cdf0e10cSrcweir nDistance *= -1; 3312*cdf0e10cSrcweir if( nDistance && nDistance < nMinDistance ) 3313*cdf0e10cSrcweir { 3314*cdf0e10cSrcweir nMinDistance = nDistance; 3315*cdf0e10cSrcweir pResult = pEntry; 3316*cdf0e10cSrcweir } 3317*cdf0e10cSrcweir } 3318*cdf0e10cSrcweir } 3319*cdf0e10cSrcweir } 3320*cdf0e10cSrcweir return pResult; 3321*cdf0e10cSrcweir } 3322*cdf0e10cSrcweir 3323*cdf0e10cSrcweir SvLBoxEntry* ImpIcnCursor::SearchRow(sal_uInt16 nRow,sal_uInt16 nLeft,sal_uInt16 nRight, 3324*cdf0e10cSrcweir sal_uInt16, sal_Bool bRight, sal_Bool bSimple ) 3325*cdf0e10cSrcweir { 3326*cdf0e10cSrcweir DBG_ASSERT(pCurEntry,"SearchRow: No reference entry"); 3327*cdf0e10cSrcweir SvPtrarr* pList = &(pRows[ nRow ]); 3328*cdf0e10cSrcweir sal_uInt16 nCount = pList->Count(); 3329*cdf0e10cSrcweir if( !nCount ) 3330*cdf0e10cSrcweir return 0; 3331*cdf0e10cSrcweir 3332*cdf0e10cSrcweir const Rectangle& rRefRect = pView->GetBoundingRect(pCurEntry); 3333*cdf0e10cSrcweir 3334*cdf0e10cSrcweir if( bSimple ) 3335*cdf0e10cSrcweir { 3336*cdf0e10cSrcweir sal_uInt16 nListPos = pList->GetPos( pCurEntry ); 3337*cdf0e10cSrcweir DBG_ASSERT(nListPos!=0xffff,"Entry not in Row-List"); 3338*cdf0e10cSrcweir if( bRight ) 3339*cdf0e10cSrcweir { 3340*cdf0e10cSrcweir while( nListPos < nCount-1 ) 3341*cdf0e10cSrcweir { 3342*cdf0e10cSrcweir nListPos++; 3343*cdf0e10cSrcweir SvLBoxEntry* pEntry = (SvLBoxEntry*)pList->GetObject( nListPos ); 3344*cdf0e10cSrcweir const Rectangle& rRect = pView->GetBoundingRect( pEntry ); 3345*cdf0e10cSrcweir if( rRect.Left() > rRefRect.Left() ) 3346*cdf0e10cSrcweir return pEntry; 3347*cdf0e10cSrcweir } 3348*cdf0e10cSrcweir return 0; 3349*cdf0e10cSrcweir } 3350*cdf0e10cSrcweir else 3351*cdf0e10cSrcweir { 3352*cdf0e10cSrcweir while( nListPos ) 3353*cdf0e10cSrcweir { 3354*cdf0e10cSrcweir nListPos--; 3355*cdf0e10cSrcweir if( nListPos < nCount ) 3356*cdf0e10cSrcweir { 3357*cdf0e10cSrcweir SvLBoxEntry* pEntry = (SvLBoxEntry*)pList->GetObject( nListPos ); 3358*cdf0e10cSrcweir const Rectangle& rRect = pView->GetBoundingRect( pEntry ); 3359*cdf0e10cSrcweir if( rRect.Left() < rRefRect.Left() ) 3360*cdf0e10cSrcweir return pEntry; 3361*cdf0e10cSrcweir } 3362*cdf0e10cSrcweir } 3363*cdf0e10cSrcweir return 0; 3364*cdf0e10cSrcweir } 3365*cdf0e10cSrcweir 3366*cdf0e10cSrcweir } 3367*cdf0e10cSrcweir if( nRight < nLeft ) 3368*cdf0e10cSrcweir { 3369*cdf0e10cSrcweir sal_uInt16 nTemp = nRight; 3370*cdf0e10cSrcweir nRight = nLeft; 3371*cdf0e10cSrcweir nLeft = nTemp; 3372*cdf0e10cSrcweir } 3373*cdf0e10cSrcweir long nMinDistance = LONG_MAX; 3374*cdf0e10cSrcweir SvLBoxEntry* pResult = 0; 3375*cdf0e10cSrcweir for( sal_uInt16 nCur = 0; nCur < nCount; nCur++ ) 3376*cdf0e10cSrcweir { 3377*cdf0e10cSrcweir SvLBoxEntry* pEntry = (SvLBoxEntry*)(pList->GetObject( nCur )); 3378*cdf0e10cSrcweir if( pEntry != pCurEntry ) 3379*cdf0e10cSrcweir { 3380*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA2(pEntry); 3381*cdf0e10cSrcweir sal_uInt16 nX = pViewData->nX; 3382*cdf0e10cSrcweir if( nX >= nLeft && nX <= nRight ) 3383*cdf0e10cSrcweir { 3384*cdf0e10cSrcweir const Rectangle& rRect = pView->GetBoundingRect( pEntry ); 3385*cdf0e10cSrcweir long nDistance = rRect.Left() - rRefRect.Left(); 3386*cdf0e10cSrcweir if( nDistance < 0 ) 3387*cdf0e10cSrcweir nDistance *= -1; 3388*cdf0e10cSrcweir if( nDistance && nDistance < nMinDistance ) 3389*cdf0e10cSrcweir { 3390*cdf0e10cSrcweir nMinDistance = nDistance; 3391*cdf0e10cSrcweir pResult = pEntry; 3392*cdf0e10cSrcweir } 3393*cdf0e10cSrcweir } 3394*cdf0e10cSrcweir } 3395*cdf0e10cSrcweir } 3396*cdf0e10cSrcweir return pResult; 3397*cdf0e10cSrcweir } 3398*cdf0e10cSrcweir 3399*cdf0e10cSrcweir 3400*cdf0e10cSrcweir 3401*cdf0e10cSrcweir /* 3402*cdf0e10cSrcweir Sucht ab dem uebergebenen Eintrag den naechsten rechts- bzw. 3403*cdf0e10cSrcweir linksstehenden. Suchverfahren am Beispiel bRight = sal_True: 3404*cdf0e10cSrcweir 3405*cdf0e10cSrcweir c 3406*cdf0e10cSrcweir b c 3407*cdf0e10cSrcweir a b c 3408*cdf0e10cSrcweir S 1 1 1 ====> Suchrichtung 3409*cdf0e10cSrcweir a b c 3410*cdf0e10cSrcweir b c 3411*cdf0e10cSrcweir c 3412*cdf0e10cSrcweir 3413*cdf0e10cSrcweir S : Startposition 3414*cdf0e10cSrcweir 1 : erstes Suchrechteck 3415*cdf0e10cSrcweir a,b,c : 2., 3., 4. Suchrechteck 3416*cdf0e10cSrcweir */ 3417*cdf0e10cSrcweir 3418*cdf0e10cSrcweir SvLBoxEntry* ImpIcnCursor::GoLeftRight( SvLBoxEntry* pIcnEntry, sal_Bool bRight ) 3419*cdf0e10cSrcweir { 3420*cdf0e10cSrcweir SvLBoxEntry* pResult; 3421*cdf0e10cSrcweir pCurEntry = pIcnEntry; 3422*cdf0e10cSrcweir Create(); 3423*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA2(pIcnEntry); 3424*cdf0e10cSrcweir sal_uInt16 nY = pViewData->nY; 3425*cdf0e10cSrcweir sal_uInt16 nX = pViewData->nX; 3426*cdf0e10cSrcweir DBG_ASSERT(nY< nRows,"GoLeftRight:Bad column"); 3427*cdf0e10cSrcweir DBG_ASSERT(nX< nCols,"GoLeftRight:Bad row"); 3428*cdf0e10cSrcweir // Nachbar auf gleicher Zeile ? 3429*cdf0e10cSrcweir if( bRight ) 3430*cdf0e10cSrcweir pResult = SearchRow( 3431*cdf0e10cSrcweir nY, nX, sal::static_int_cast< sal_uInt16 >(nCols-1), nX, sal_True, sal_True ); 3432*cdf0e10cSrcweir else 3433*cdf0e10cSrcweir pResult = SearchRow( nY, nX ,0, nX, sal_False, sal_True ); 3434*cdf0e10cSrcweir if( pResult ) 3435*cdf0e10cSrcweir return pResult; 3436*cdf0e10cSrcweir 3437*cdf0e10cSrcweir long nCurCol = nX; 3438*cdf0e10cSrcweir 3439*cdf0e10cSrcweir long nColOffs, nLastCol; 3440*cdf0e10cSrcweir if( bRight ) 3441*cdf0e10cSrcweir { 3442*cdf0e10cSrcweir nColOffs = 1; 3443*cdf0e10cSrcweir nLastCol = nCols; 3444*cdf0e10cSrcweir } 3445*cdf0e10cSrcweir else 3446*cdf0e10cSrcweir { 3447*cdf0e10cSrcweir nColOffs = -1; 3448*cdf0e10cSrcweir nLastCol = -1; // 0-1 3449*cdf0e10cSrcweir } 3450*cdf0e10cSrcweir 3451*cdf0e10cSrcweir sal_uInt16 nRowMin = nY; 3452*cdf0e10cSrcweir sal_uInt16 nRowMax = nY; 3453*cdf0e10cSrcweir do 3454*cdf0e10cSrcweir { 3455*cdf0e10cSrcweir SvLBoxEntry* pEntry = SearchCol((sal_uInt16)nCurCol,nRowMin,nRowMax,nY,sal_True, sal_False); 3456*cdf0e10cSrcweir if( pEntry ) 3457*cdf0e10cSrcweir return pEntry; 3458*cdf0e10cSrcweir if( nRowMin ) 3459*cdf0e10cSrcweir nRowMin--; 3460*cdf0e10cSrcweir if( nRowMax < (nRows-1)) 3461*cdf0e10cSrcweir nRowMax++; 3462*cdf0e10cSrcweir nCurCol += nColOffs; 3463*cdf0e10cSrcweir } while( nCurCol != nLastCol ); 3464*cdf0e10cSrcweir return 0; 3465*cdf0e10cSrcweir } 3466*cdf0e10cSrcweir 3467*cdf0e10cSrcweir SvLBoxEntry* ImpIcnCursor::GoUpDown( SvLBoxEntry* pIcnEntry, sal_Bool bDown) 3468*cdf0e10cSrcweir { 3469*cdf0e10cSrcweir SvLBoxEntry* pResult; 3470*cdf0e10cSrcweir pCurEntry = pIcnEntry; 3471*cdf0e10cSrcweir Create(); 3472*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA2(pIcnEntry); 3473*cdf0e10cSrcweir sal_uInt16 nY = pViewData->nY; 3474*cdf0e10cSrcweir sal_uInt16 nX = pViewData->nX; 3475*cdf0e10cSrcweir DBG_ASSERT(nY<nRows,"GoUpDown:Bad column"); 3476*cdf0e10cSrcweir DBG_ASSERT(nX<nCols,"GoUpDown:Bad row"); 3477*cdf0e10cSrcweir 3478*cdf0e10cSrcweir // Nachbar in gleicher Spalte ? 3479*cdf0e10cSrcweir if( bDown ) 3480*cdf0e10cSrcweir pResult = SearchCol( 3481*cdf0e10cSrcweir nX, nY, sal::static_int_cast< sal_uInt16 >(nRows-1), nY, sal_True, sal_True ); 3482*cdf0e10cSrcweir else 3483*cdf0e10cSrcweir pResult = SearchCol( nX, nY ,0, nY, sal_False, sal_True ); 3484*cdf0e10cSrcweir if( pResult ) 3485*cdf0e10cSrcweir return pResult; 3486*cdf0e10cSrcweir 3487*cdf0e10cSrcweir long nCurRow = nY; 3488*cdf0e10cSrcweir 3489*cdf0e10cSrcweir long nRowOffs, nLastRow; 3490*cdf0e10cSrcweir if( bDown ) 3491*cdf0e10cSrcweir { 3492*cdf0e10cSrcweir nRowOffs = 1; 3493*cdf0e10cSrcweir nLastRow = nRows; 3494*cdf0e10cSrcweir } 3495*cdf0e10cSrcweir else 3496*cdf0e10cSrcweir { 3497*cdf0e10cSrcweir nRowOffs = -1; 3498*cdf0e10cSrcweir nLastRow = -1; // 0-1 3499*cdf0e10cSrcweir } 3500*cdf0e10cSrcweir 3501*cdf0e10cSrcweir sal_uInt16 nColMin = nX; 3502*cdf0e10cSrcweir sal_uInt16 nColMax = nX; 3503*cdf0e10cSrcweir do 3504*cdf0e10cSrcweir { 3505*cdf0e10cSrcweir SvLBoxEntry* pEntry = SearchRow((sal_uInt16)nCurRow,nColMin,nColMax,nX,sal_True, sal_False); 3506*cdf0e10cSrcweir if( pEntry ) 3507*cdf0e10cSrcweir return pEntry; 3508*cdf0e10cSrcweir if( nColMin ) 3509*cdf0e10cSrcweir nColMin--; 3510*cdf0e10cSrcweir if( nColMax < (nCols-1)) 3511*cdf0e10cSrcweir nColMax++; 3512*cdf0e10cSrcweir nCurRow += nRowOffs; 3513*cdf0e10cSrcweir } while( nCurRow != nLastRow ); 3514*cdf0e10cSrcweir return 0; 3515*cdf0e10cSrcweir } 3516*cdf0e10cSrcweir 3517*cdf0e10cSrcweir void ImpIcnCursor::SetDeltas() 3518*cdf0e10cSrcweir { 3519*cdf0e10cSrcweir const Size& rSize = pView->aVirtOutputSize; 3520*cdf0e10cSrcweir if( pView->nFlags & F_GRIDMODE ) 3521*cdf0e10cSrcweir { 3522*cdf0e10cSrcweir nGridDX = pView->nGridDX; 3523*cdf0e10cSrcweir nGridDY = pView->nGridDY; 3524*cdf0e10cSrcweir } 3525*cdf0e10cSrcweir else 3526*cdf0e10cSrcweir { 3527*cdf0e10cSrcweir nGridDX = 20; 3528*cdf0e10cSrcweir nGridDY = 20; 3529*cdf0e10cSrcweir } 3530*cdf0e10cSrcweir nCols = rSize.Width() / nGridDX; 3531*cdf0e10cSrcweir if( !nCols ) 3532*cdf0e10cSrcweir nCols = 1; 3533*cdf0e10cSrcweir nRows = rSize.Height() / nGridDY; 3534*cdf0e10cSrcweir if( (nRows * nGridDY) < rSize.Height() ) 3535*cdf0e10cSrcweir nRows++; 3536*cdf0e10cSrcweir if( !nRows ) 3537*cdf0e10cSrcweir nRows = 1; 3538*cdf0e10cSrcweir 3539*cdf0e10cSrcweir nDeltaWidth = (short)(rSize.Width() / nCols); 3540*cdf0e10cSrcweir nDeltaHeight = (short)(rSize.Height() / nRows); 3541*cdf0e10cSrcweir if( !nDeltaHeight ) 3542*cdf0e10cSrcweir { 3543*cdf0e10cSrcweir nDeltaHeight = 1; 3544*cdf0e10cSrcweir DBG_WARNING("SetDeltas:Bad height"); 3545*cdf0e10cSrcweir } 3546*cdf0e10cSrcweir if( !nDeltaWidth ) 3547*cdf0e10cSrcweir { 3548*cdf0e10cSrcweir nDeltaWidth = 1; 3549*cdf0e10cSrcweir DBG_WARNING("SetDeltas:Bad width"); 3550*cdf0e10cSrcweir } 3551*cdf0e10cSrcweir } 3552*cdf0e10cSrcweir 3553*cdf0e10cSrcweir 3554*cdf0e10cSrcweir void ImpIcnCursor::ExpandGrid() 3555*cdf0e10cSrcweir { 3556*cdf0e10cSrcweir if( pGridMap ) 3557*cdf0e10cSrcweir { 3558*cdf0e10cSrcweir long nNewGridRows = nGridRows + 20; 3559*cdf0e10cSrcweir unsigned char* pTempMap = new unsigned char[ nNewGridRows * nGridCols ]; 3560*cdf0e10cSrcweir memcpy( pTempMap, pGridMap, nGridRows * nGridCols ); 3561*cdf0e10cSrcweir delete pGridMap; 3562*cdf0e10cSrcweir pGridMap = pTempMap; 3563*cdf0e10cSrcweir nGridRows = nNewGridRows; 3564*cdf0e10cSrcweir } 3565*cdf0e10cSrcweir } 3566*cdf0e10cSrcweir 3567*cdf0e10cSrcweir sal_Bool ImpIcnCursor::FindEmptyGridRect( Rectangle& rRect ) 3568*cdf0e10cSrcweir { 3569*cdf0e10cSrcweir CreateGridMap(); 3570*cdf0e10cSrcweir sal_uInt16 nCount = (sal_uInt16)(nGridCols * nGridRows); 3571*cdf0e10cSrcweir if( !nCount ) 3572*cdf0e10cSrcweir return sal_False; 3573*cdf0e10cSrcweir for( sal_uInt16 nCur = 0; nCur < nCount; nCur++ ) 3574*cdf0e10cSrcweir { 3575*cdf0e10cSrcweir if( !pGridMap[ nCur ] ) 3576*cdf0e10cSrcweir { 3577*cdf0e10cSrcweir sal_uInt16 nCol = (sal_uInt16)(nCur % nGridCols); 3578*cdf0e10cSrcweir sal_uInt16 nRow = (sal_uInt16)(nCur / nGridCols); 3579*cdf0e10cSrcweir rRect.Top() = nRow * nGridDY + TBOFFS_WINBORDER; 3580*cdf0e10cSrcweir rRect.Bottom() = rRect.Top() + nGridDY; 3581*cdf0e10cSrcweir rRect.Left() = nCol * nGridDX+ LROFFS_WINBORDER; 3582*cdf0e10cSrcweir rRect.Right() = rRect.Left() + nGridDX; 3583*cdf0e10cSrcweir SetGridUsed( nCol, nRow, sal_True ); 3584*cdf0e10cSrcweir 3585*cdf0e10cSrcweir //XXX 3586*cdf0e10cSrcweir //if( nRow + 5 > nGridRows ) 3587*cdf0e10cSrcweir // ExpandGrid(); 3588*cdf0e10cSrcweir DBG_ASSERT(pGridMap[nCur],"SetGridUsed failed"); 3589*cdf0e10cSrcweir return sal_True; 3590*cdf0e10cSrcweir } 3591*cdf0e10cSrcweir } 3592*cdf0e10cSrcweir // Gridmap ist voll: Um eine Zeile erweitern 3593*cdf0e10cSrcweir rRect.Top() = nGridRows * nGridDY + TBOFFS_WINBORDER; 3594*cdf0e10cSrcweir rRect.Bottom() = rRect.Top() + nGridDY; 3595*cdf0e10cSrcweir rRect.Left() = LROFFS_WINBORDER; 3596*cdf0e10cSrcweir rRect.Right() = rRect.Left() + nGridDX; 3597*cdf0e10cSrcweir return sal_False; 3598*cdf0e10cSrcweir //XXX 3599*cdf0e10cSrcweir //ExpandGrid(); 3600*cdf0e10cSrcweir //return sal_True; 3601*cdf0e10cSrcweir } 3602*cdf0e10cSrcweir 3603*cdf0e10cSrcweir void ImpIcnCursor::CreateGridAjustData( SvPtrarr& rLists, SvLBoxEntry* pRefEntry) 3604*cdf0e10cSrcweir { 3605*cdf0e10cSrcweir if( !pRefEntry ) 3606*cdf0e10cSrcweir { 3607*cdf0e10cSrcweir sal_uInt16 nAdjustRows = (sal_uInt16)(pView->aVirtOutputSize.Height() / pView->nGridDY); 3608*cdf0e10cSrcweir nAdjustRows++; // wg. Abrundung! 3609*cdf0e10cSrcweir 3610*cdf0e10cSrcweir if( !nAdjustRows ) 3611*cdf0e10cSrcweir return; 3612*cdf0e10cSrcweir for( sal_uInt16 nCurList = 0; nCurList < nAdjustRows; nCurList++ ) 3613*cdf0e10cSrcweir { 3614*cdf0e10cSrcweir SvPtrarr* pRow = new SvPtrarr; 3615*cdf0e10cSrcweir rLists.Insert( (void*)pRow, nCurList ); 3616*cdf0e10cSrcweir } 3617*cdf0e10cSrcweir SvLBoxEntry* pEntry = pView->pModel->FirstChild( pView->pCurParent ); 3618*cdf0e10cSrcweir while( pEntry ) 3619*cdf0e10cSrcweir { 3620*cdf0e10cSrcweir const Rectangle& rRect = pView->GetBoundingRect( pEntry ); 3621*cdf0e10cSrcweir short nY = (short)( ((rRect.Top()+rRect.Bottom())/2) / pView->nGridDY ); 3622*cdf0e10cSrcweir sal_uInt16 nIns = GetSortListPos((SvPtrarr*)rLists[nY],rRect.Left(),sal_False); 3623*cdf0e10cSrcweir ((SvPtrarr*)rLists[ nY ])->Insert( pEntry, nIns ); 3624*cdf0e10cSrcweir pEntry = pView->pModel->NextSibling( pEntry ); 3625*cdf0e10cSrcweir } 3626*cdf0e10cSrcweir } 3627*cdf0e10cSrcweir else 3628*cdf0e10cSrcweir { 3629*cdf0e10cSrcweir // Aufbau eines hor. "Schlauchs" auf der RefEntry-Zeile 3630*cdf0e10cSrcweir 3631*cdf0e10cSrcweir // UEBERLEGEN: BoundingRect nehmen wg. Ueberlappungen??? 3632*cdf0e10cSrcweir 3633*cdf0e10cSrcweir Rectangle rRefRect( pView->CalcBmpRect( pRefEntry ) ); 3634*cdf0e10cSrcweir //const Rectangle& rRefRect = pView->GetBoundingRect( pRefEntry ); 3635*cdf0e10cSrcweir short nRefRow = (short)( ((rRefRect.Top()+rRefRect.Bottom())/2) / pView->nGridDY ); 3636*cdf0e10cSrcweir SvPtrarr* pRow = new SvPtrarr; 3637*cdf0e10cSrcweir rLists.Insert( (void*)pRow, 0 ); 3638*cdf0e10cSrcweir SvLBoxEntry* pEntry = pView->pModel->FirstChild( pView->pCurParent ); 3639*cdf0e10cSrcweir while( pEntry ) 3640*cdf0e10cSrcweir { 3641*cdf0e10cSrcweir Rectangle rRect( pView->CalcBmpRect(pEntry) ); 3642*cdf0e10cSrcweir //const Rectangle& rRect = pView->GetBoundingRect( pEntry ); 3643*cdf0e10cSrcweir short nY = (short)( ((rRect.Top()+rRect.Bottom())/2) / pView->nGridDY ); 3644*cdf0e10cSrcweir if( nY == nRefRow ) 3645*cdf0e10cSrcweir { 3646*cdf0e10cSrcweir sal_uInt16 nIns = GetSortListPos( pRow, rRect.Left(), sal_False ); 3647*cdf0e10cSrcweir pRow->Insert( pEntry, nIns ); 3648*cdf0e10cSrcweir } 3649*cdf0e10cSrcweir pEntry = pView->pModel->NextSibling( pEntry ); 3650*cdf0e10cSrcweir } 3651*cdf0e10cSrcweir } 3652*cdf0e10cSrcweir } 3653*cdf0e10cSrcweir 3654*cdf0e10cSrcweir //static 3655*cdf0e10cSrcweir void ImpIcnCursor::DestroyGridAdjustData( SvPtrarr& rLists ) 3656*cdf0e10cSrcweir { 3657*cdf0e10cSrcweir sal_uInt16 nCount = rLists.Count(); 3658*cdf0e10cSrcweir for( sal_uInt16 nCur = 0; nCur < nCount; nCur++ ) 3659*cdf0e10cSrcweir { 3660*cdf0e10cSrcweir SvPtrarr* pArr = (SvPtrarr*)rLists[ nCur ]; 3661*cdf0e10cSrcweir delete pArr; 3662*cdf0e10cSrcweir } 3663*cdf0e10cSrcweir rLists.Remove( 0, rLists.Count() ); 3664*cdf0e10cSrcweir } 3665*cdf0e10cSrcweir 3666*cdf0e10cSrcweir void SvImpIconView::SetGrid( long nDX, long nDY ) 3667*cdf0e10cSrcweir { 3668*cdf0e10cSrcweir nGridDX = nDX; 3669*cdf0e10cSrcweir nGridDY = nDY; 3670*cdf0e10cSrcweir nFlags |= F_GRIDMODE; 3671*cdf0e10cSrcweir } 3672*cdf0e10cSrcweir 3673*cdf0e10cSrcweir Rectangle SvImpIconView::CalcMaxTextRect( const SvLBoxEntry* pEntry, 3674*cdf0e10cSrcweir const SvIcnVwDataEntry* pViewData ) const 3675*cdf0e10cSrcweir { 3676*cdf0e10cSrcweir Rectangle aRect = pViewData->aGridRect; 3677*cdf0e10cSrcweir long nBmpHeight = ((SvLBoxEntry*)pEntry)->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP)->GetSize(pView,(SvLBoxEntry*)pEntry).Height(); 3678*cdf0e10cSrcweir aRect.Top() += nBmpHeight; 3679*cdf0e10cSrcweir aRect.Top() += ICONVIEW_OFFS_BMP_STRING; 3680*cdf0e10cSrcweir if( aRect.Top() > aRect.Bottom()) 3681*cdf0e10cSrcweir aRect.Top() = aRect.Bottom(); 3682*cdf0e10cSrcweir aRect.Left() += LROFFS_BOUND; 3683*cdf0e10cSrcweir aRect.Left()++; 3684*cdf0e10cSrcweir aRect.Right() -= LROFFS_BOUND; 3685*cdf0e10cSrcweir aRect.Right()--; 3686*cdf0e10cSrcweir if( aRect.Left() > aRect.Right()) 3687*cdf0e10cSrcweir aRect.Left() = aRect.Right(); 3688*cdf0e10cSrcweir if( GetTextMode( pEntry, pViewData ) == ShowTextFull ) 3689*cdf0e10cSrcweir aRect.Bottom() = LONG_MAX; 3690*cdf0e10cSrcweir return aRect; 3691*cdf0e10cSrcweir } 3692*cdf0e10cSrcweir 3693*cdf0e10cSrcweir void SvImpIconView::Center( SvLBoxEntry* pEntry, 3694*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData ) const 3695*cdf0e10cSrcweir { 3696*cdf0e10cSrcweir SvLBoxString* pStringItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING)); 3697*cdf0e10cSrcweir const String& rEntryText = pStringItem->GetText(); 3698*cdf0e10cSrcweir 3699*cdf0e10cSrcweir Rectangle aTextRect = CalcMaxTextRect(pEntry,pViewData); 3700*cdf0e10cSrcweir aTextRect = GetTextRect( pView, aTextRect, rEntryText, DRAWTEXT_FLAGS ); 3701*cdf0e10cSrcweir pViewData->aTextSize = aTextRect.GetSize(); 3702*cdf0e10cSrcweir 3703*cdf0e10cSrcweir pViewData->aRect = pViewData->aGridRect; 3704*cdf0e10cSrcweir Size aSize( CalcBoundingSize( pEntry, pViewData ) ); 3705*cdf0e10cSrcweir long nBorder = pViewData->aGridRect.GetWidth() - aSize.Width(); 3706*cdf0e10cSrcweir pViewData->aRect.Left() += nBorder / 2; 3707*cdf0e10cSrcweir pViewData->aRect.Right() -= nBorder / 2; 3708*cdf0e10cSrcweir pViewData->aRect.Bottom() = pViewData->aRect.Top() + aSize.Height(); 3709*cdf0e10cSrcweir } 3710*cdf0e10cSrcweir 3711*cdf0e10cSrcweir 3712*cdf0e10cSrcweir // Die Deltas entsprechen Offsets, um die die View auf dem Doc verschoben wird 3713*cdf0e10cSrcweir // links, hoch: Offsets < 0 3714*cdf0e10cSrcweir // rechts, runter: Offsets > 0 3715*cdf0e10cSrcweir void SvImpIconView::Scroll( long nDeltaX, long nDeltaY, sal_Bool bScrollBar ) 3716*cdf0e10cSrcweir { 3717*cdf0e10cSrcweir const MapMode& rMapMode = pView->GetMapMode(); 3718*cdf0e10cSrcweir Point aOrigin( rMapMode.GetOrigin() ); 3719*cdf0e10cSrcweir // in Dokumentkoordinate umwandeln 3720*cdf0e10cSrcweir aOrigin *= -1; 3721*cdf0e10cSrcweir aOrigin.Y() += nDeltaY; 3722*cdf0e10cSrcweir aOrigin.X() += nDeltaX; 3723*cdf0e10cSrcweir Rectangle aRect( aOrigin, aOutputSize ); 3724*cdf0e10cSrcweir MakeVisible( aRect, bScrollBar ); 3725*cdf0e10cSrcweir } 3726*cdf0e10cSrcweir 3727*cdf0e10cSrcweir 3728*cdf0e10cSrcweir const Size& SvImpIconView::GetItemSize( SvIconView* pIconView, 3729*cdf0e10cSrcweir SvLBoxEntry* pEntry, SvLBoxItem* pItem, const SvIcnVwDataEntry* pViewData) const 3730*cdf0e10cSrcweir { 3731*cdf0e10cSrcweir if( (nFlags & F_GRIDMODE) && pItem->IsA() == SV_ITEM_ID_LBOXSTRING ) 3732*cdf0e10cSrcweir { 3733*cdf0e10cSrcweir if( !pViewData ) 3734*cdf0e10cSrcweir pViewData = ICNVIEWDATA(pEntry); 3735*cdf0e10cSrcweir return pViewData->aTextSize; 3736*cdf0e10cSrcweir } 3737*cdf0e10cSrcweir else 3738*cdf0e10cSrcweir return pItem->GetSize( pIconView, pEntry ); 3739*cdf0e10cSrcweir } 3740*cdf0e10cSrcweir 3741*cdf0e10cSrcweir Rectangle SvImpIconView::CalcFocusRect( SvLBoxEntry* pEntry ) 3742*cdf0e10cSrcweir { 3743*cdf0e10cSrcweir #if !defined(OS2) 3744*cdf0e10cSrcweir SvLBoxString* pStringItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING)); 3745*cdf0e10cSrcweir DBG_ASSERT(pStringItem,"Text not set"); 3746*cdf0e10cSrcweir return CalcTextRect( pEntry, pStringItem ); 3747*cdf0e10cSrcweir #else 3748*cdf0e10cSrcweir return CalcBmpRect( pEntry ); 3749*cdf0e10cSrcweir #endif 3750*cdf0e10cSrcweir } 3751*cdf0e10cSrcweir 3752*cdf0e10cSrcweir 3753*cdf0e10cSrcweir void SvImpIconView::SelectRect( const Rectangle& rRect, sal_Bool bAdd, 3754*cdf0e10cSrcweir SvPtrarr* pOtherRects, short nBorderOffs ) 3755*cdf0e10cSrcweir { 3756*cdf0e10cSrcweir if( !pZOrderList || !pZOrderList->Count() ) 3757*cdf0e10cSrcweir return; 3758*cdf0e10cSrcweir 3759*cdf0e10cSrcweir CheckBoundingRects(); 3760*cdf0e10cSrcweir pView->Update(); 3761*cdf0e10cSrcweir sal_uInt16 nCount = pZOrderList->Count(); 3762*cdf0e10cSrcweir 3763*cdf0e10cSrcweir Rectangle aRect( rRect ); 3764*cdf0e10cSrcweir aRect.Justify(); 3765*cdf0e10cSrcweir if( nBorderOffs ) 3766*cdf0e10cSrcweir { 3767*cdf0e10cSrcweir aRect.Left() -= nBorderOffs; 3768*cdf0e10cSrcweir aRect.Right() += nBorderOffs; 3769*cdf0e10cSrcweir aRect.Top() -= nBorderOffs; 3770*cdf0e10cSrcweir aRect.Bottom() += nBorderOffs; 3771*cdf0e10cSrcweir } 3772*cdf0e10cSrcweir sal_Bool bCalcOverlap = (bAdd && pOtherRects && pOtherRects->Count()) ? sal_True : sal_False; 3773*cdf0e10cSrcweir 3774*cdf0e10cSrcweir for( sal_uInt16 nPos = 0; nPos < nCount; nPos++ ) 3775*cdf0e10cSrcweir { 3776*cdf0e10cSrcweir SvLBoxEntry* pEntry = (SvLBoxEntry*)(pZOrderList->GetObject(nPos )); 3777*cdf0e10cSrcweir 3778*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry); 3779*cdf0e10cSrcweir DBG_ASSERT(pViewData,"Entry not in model"); 3780*cdf0e10cSrcweir if( !IsBoundingRectValid( pViewData->aRect )) 3781*cdf0e10cSrcweir FindBoundingRect( pEntry, pViewData ); 3782*cdf0e10cSrcweir const Rectangle& rBoundRect = pViewData->aRect; 3783*cdf0e10cSrcweir sal_Bool bSelected = pViewData->IsSelected(); 3784*cdf0e10cSrcweir 3785*cdf0e10cSrcweir sal_Bool bOverlaps; 3786*cdf0e10cSrcweir if( bCalcOverlap ) 3787*cdf0e10cSrcweir bOverlaps = IsOver( pOtherRects, rBoundRect ); 3788*cdf0e10cSrcweir else 3789*cdf0e10cSrcweir bOverlaps = sal_False; 3790*cdf0e10cSrcweir sal_Bool bOver = aRect.IsOver( rBoundRect ); 3791*cdf0e10cSrcweir 3792*cdf0e10cSrcweir if( bOver && !bOverlaps ) 3793*cdf0e10cSrcweir { 3794*cdf0e10cSrcweir // Ist im neuen Selektionsrechteck und in keinem alten 3795*cdf0e10cSrcweir // => selektieren 3796*cdf0e10cSrcweir if( !bSelected ) 3797*cdf0e10cSrcweir pView->Select( pEntry, sal_True ); 3798*cdf0e10cSrcweir } 3799*cdf0e10cSrcweir else if( !bAdd ) 3800*cdf0e10cSrcweir { 3801*cdf0e10cSrcweir // ist ausserhalb des Selektionsrechtecks 3802*cdf0e10cSrcweir // => Selektion entfernen 3803*cdf0e10cSrcweir if( bSelected ) 3804*cdf0e10cSrcweir pView->Select( pEntry, sal_False ); 3805*cdf0e10cSrcweir } 3806*cdf0e10cSrcweir else if( bAdd && bOverlaps ) 3807*cdf0e10cSrcweir { 3808*cdf0e10cSrcweir // Der Eintrag befindet sich in einem alten (=>Aufspannen 3809*cdf0e10cSrcweir // mehrerer Rechtecke mit Ctrl!) Selektionsrechteck 3810*cdf0e10cSrcweir 3811*cdf0e10cSrcweir // Hier ist noch ein Bug! Der Selektionsstatus eines Eintrags 3812*cdf0e10cSrcweir // in einem vorherigen Rechteck, muss restauriert werden, wenn 3813*cdf0e10cSrcweir // er vom aktuellen Selektionsrechteck beruehrt wurde, jetzt aber 3814*cdf0e10cSrcweir // nicht mehr in ihm liegt. Ich gehe hier der Einfachheit halber 3815*cdf0e10cSrcweir // pauschal davon aus, dass die Eintraege in den alten Rechtecken 3816*cdf0e10cSrcweir // alle selektiert sind. Ebenso ist es falsch, die Schnittmenge 3817*cdf0e10cSrcweir // nur zu deselektieren. 3818*cdf0e10cSrcweir // Loesungsmoeglichkeit: Snapshot der Selektion vor dem Auf- 3819*cdf0e10cSrcweir // spannen des Rechtecks merken 3820*cdf0e10cSrcweir if( rBoundRect.IsOver( rRect)) 3821*cdf0e10cSrcweir { 3822*cdf0e10cSrcweir // Schnittmenge zwischen alten Rects & aktuellem Rect desel. 3823*cdf0e10cSrcweir if( bSelected ) 3824*cdf0e10cSrcweir pView->Select( pEntry, sal_False ); 3825*cdf0e10cSrcweir } 3826*cdf0e10cSrcweir else 3827*cdf0e10cSrcweir { 3828*cdf0e10cSrcweir // Eintrag eines alten Rects selektieren 3829*cdf0e10cSrcweir if( !bSelected ) 3830*cdf0e10cSrcweir pView->Select( pEntry, sal_True ); 3831*cdf0e10cSrcweir } 3832*cdf0e10cSrcweir } 3833*cdf0e10cSrcweir else if( !bOver && bSelected ) 3834*cdf0e10cSrcweir { 3835*cdf0e10cSrcweir // Der Eintrag liegt voellig ausserhalb und wird deshalb desel. 3836*cdf0e10cSrcweir pView->Select( pEntry, sal_False ); 3837*cdf0e10cSrcweir } 3838*cdf0e10cSrcweir } 3839*cdf0e10cSrcweir pView->Update(); 3840*cdf0e10cSrcweir } 3841*cdf0e10cSrcweir 3842*cdf0e10cSrcweir sal_Bool SvImpIconView::IsOver( SvPtrarr* pRectList, const Rectangle& rBoundRect ) const 3843*cdf0e10cSrcweir { 3844*cdf0e10cSrcweir sal_uInt16 nCount = pRectList->Count(); 3845*cdf0e10cSrcweir for( sal_uInt16 nCur = 0; nCur < nCount; nCur++ ) 3846*cdf0e10cSrcweir { 3847*cdf0e10cSrcweir Rectangle* pRect = (Rectangle*)pRectList->GetObject( nCur ); 3848*cdf0e10cSrcweir if( rBoundRect.IsOver( *pRect )) 3849*cdf0e10cSrcweir return sal_True; 3850*cdf0e10cSrcweir } 3851*cdf0e10cSrcweir return sal_False; 3852*cdf0e10cSrcweir } 3853*cdf0e10cSrcweir 3854*cdf0e10cSrcweir void SvImpIconView::AddSelectedRect( const Rectangle& rRect, short nBorderOffs ) 3855*cdf0e10cSrcweir { 3856*cdf0e10cSrcweir Rectangle* pRect = new Rectangle( rRect ); 3857*cdf0e10cSrcweir pRect->Justify(); 3858*cdf0e10cSrcweir if( nBorderOffs ) 3859*cdf0e10cSrcweir { 3860*cdf0e10cSrcweir pRect->Left() -= nBorderOffs; 3861*cdf0e10cSrcweir pRect->Right() += nBorderOffs; 3862*cdf0e10cSrcweir pRect->Top() -= nBorderOffs; 3863*cdf0e10cSrcweir pRect->Bottom() += nBorderOffs; 3864*cdf0e10cSrcweir } 3865*cdf0e10cSrcweir aSelectedRectList.Insert( (void*)pRect, aSelectedRectList.Count() ); 3866*cdf0e10cSrcweir } 3867*cdf0e10cSrcweir 3868*cdf0e10cSrcweir void SvImpIconView::ClearSelectedRectList() 3869*cdf0e10cSrcweir { 3870*cdf0e10cSrcweir sal_uInt16 nCount = aSelectedRectList.Count(); 3871*cdf0e10cSrcweir for( sal_uInt16 nCur = 0; nCur < nCount; nCur++ ) 3872*cdf0e10cSrcweir { 3873*cdf0e10cSrcweir Rectangle* pRect = (Rectangle*)aSelectedRectList.GetObject( nCur ); 3874*cdf0e10cSrcweir delete pRect; 3875*cdf0e10cSrcweir } 3876*cdf0e10cSrcweir aSelectedRectList.Remove( 0, aSelectedRectList.Count() ); 3877*cdf0e10cSrcweir } 3878*cdf0e10cSrcweir 3879*cdf0e10cSrcweir 3880*cdf0e10cSrcweir void SvImpIconView::DrawSelectionRect( const Rectangle& rRect ) 3881*cdf0e10cSrcweir { 3882*cdf0e10cSrcweir pView->HideTracking(); 3883*cdf0e10cSrcweir nFlags |= F_SELRECT_VISIBLE; 3884*cdf0e10cSrcweir pView->ShowTracking( rRect, SHOWTRACK_SMALL | SHOWTRACK_WINDOW ); 3885*cdf0e10cSrcweir aCurSelectionRect = rRect; 3886*cdf0e10cSrcweir } 3887*cdf0e10cSrcweir 3888*cdf0e10cSrcweir void SvImpIconView::HideSelectionRect() 3889*cdf0e10cSrcweir { 3890*cdf0e10cSrcweir if( nFlags & F_SELRECT_VISIBLE ) 3891*cdf0e10cSrcweir { 3892*cdf0e10cSrcweir pView->HideTracking(); 3893*cdf0e10cSrcweir nFlags &= ~F_SELRECT_VISIBLE; 3894*cdf0e10cSrcweir } 3895*cdf0e10cSrcweir } 3896*cdf0e10cSrcweir 3897*cdf0e10cSrcweir void SvImpIconView::ImpDrawXORRect( const Rectangle& rRect ) 3898*cdf0e10cSrcweir { 3899*cdf0e10cSrcweir RasterOp eOldOp = pView->GetRasterOp(); 3900*cdf0e10cSrcweir pView->SetRasterOp( ROP_XOR ); 3901*cdf0e10cSrcweir Color aOldColor = pView->GetFillColor(); 3902*cdf0e10cSrcweir pView->SetFillColor(); 3903*cdf0e10cSrcweir pView->DrawRect( rRect ); 3904*cdf0e10cSrcweir pView->SetFillColor( aOldColor ); 3905*cdf0e10cSrcweir pView->SetRasterOp( eOldOp ); 3906*cdf0e10cSrcweir } 3907*cdf0e10cSrcweir 3908*cdf0e10cSrcweir void SvImpIconView::CalcScrollOffsets( const Point& rPosPixel, 3909*cdf0e10cSrcweir long& rX, long& rY, sal_Bool bInDragDrop, sal_uInt16 nBorderWidth) 3910*cdf0e10cSrcweir { 3911*cdf0e10cSrcweir // Scrolling der View, falls sich der Mauszeiger im Grenzbereich des 3912*cdf0e10cSrcweir // Fensters befindet 3913*cdf0e10cSrcweir long nPixelToScrollX = 0; 3914*cdf0e10cSrcweir long nPixelToScrollY = 0; 3915*cdf0e10cSrcweir Size aWndSize = aOutputSize; 3916*cdf0e10cSrcweir 3917*cdf0e10cSrcweir nBorderWidth = (sal_uInt16)(Min( (long)(aWndSize.Height()-1), (long)nBorderWidth )); 3918*cdf0e10cSrcweir nBorderWidth = (sal_uInt16)(Min( (long)(aWndSize.Width()-1), (long)nBorderWidth )); 3919*cdf0e10cSrcweir 3920*cdf0e10cSrcweir if ( rPosPixel.X() < nBorderWidth ) 3921*cdf0e10cSrcweir { 3922*cdf0e10cSrcweir if( bInDragDrop ) 3923*cdf0e10cSrcweir nPixelToScrollX = -DD_SCROLL_PIXEL; 3924*cdf0e10cSrcweir else 3925*cdf0e10cSrcweir nPixelToScrollX = rPosPixel.X()- nBorderWidth; 3926*cdf0e10cSrcweir } 3927*cdf0e10cSrcweir else if ( rPosPixel.X() > aWndSize.Width() - nBorderWidth ) 3928*cdf0e10cSrcweir { 3929*cdf0e10cSrcweir if( bInDragDrop ) 3930*cdf0e10cSrcweir nPixelToScrollX = DD_SCROLL_PIXEL; 3931*cdf0e10cSrcweir else 3932*cdf0e10cSrcweir nPixelToScrollX = rPosPixel.X() - (aWndSize.Width() - nBorderWidth); 3933*cdf0e10cSrcweir } 3934*cdf0e10cSrcweir if ( rPosPixel.Y() < nBorderWidth ) 3935*cdf0e10cSrcweir { 3936*cdf0e10cSrcweir if( bInDragDrop ) 3937*cdf0e10cSrcweir nPixelToScrollY = -DD_SCROLL_PIXEL; 3938*cdf0e10cSrcweir else 3939*cdf0e10cSrcweir nPixelToScrollY = rPosPixel.Y() - nBorderWidth; 3940*cdf0e10cSrcweir } 3941*cdf0e10cSrcweir else if ( rPosPixel.Y() > aWndSize.Height() - nBorderWidth ) 3942*cdf0e10cSrcweir { 3943*cdf0e10cSrcweir if( bInDragDrop ) 3944*cdf0e10cSrcweir nPixelToScrollY = DD_SCROLL_PIXEL; 3945*cdf0e10cSrcweir else 3946*cdf0e10cSrcweir nPixelToScrollY = rPosPixel.Y() - (aWndSize.Height() - nBorderWidth); 3947*cdf0e10cSrcweir } 3948*cdf0e10cSrcweir 3949*cdf0e10cSrcweir rX = nPixelToScrollX; 3950*cdf0e10cSrcweir rY = nPixelToScrollY; 3951*cdf0e10cSrcweir } 3952*cdf0e10cSrcweir 3953*cdf0e10cSrcweir IMPL_LINK(SvImpIconView, MouseMoveTimeoutHdl, Timer*, pTimer ) 3954*cdf0e10cSrcweir { 3955*cdf0e10cSrcweir pTimer->Start(); 3956*cdf0e10cSrcweir MouseMove( aMouseMoveEvent ); 3957*cdf0e10cSrcweir return 0; 3958*cdf0e10cSrcweir } 3959*cdf0e10cSrcweir 3960*cdf0e10cSrcweir void SvImpIconView::EndTracking() 3961*cdf0e10cSrcweir { 3962*cdf0e10cSrcweir pView->ReleaseMouse(); 3963*cdf0e10cSrcweir if( nFlags & F_RUBBERING ) 3964*cdf0e10cSrcweir { 3965*cdf0e10cSrcweir aMouseMoveTimer.Stop(); 3966*cdf0e10cSrcweir nFlags &= ~(F_RUBBERING | F_ADD_MODE); 3967*cdf0e10cSrcweir } 3968*cdf0e10cSrcweir } 3969*cdf0e10cSrcweir 3970*cdf0e10cSrcweir sal_Bool SvImpIconView::IsTextHit( SvLBoxEntry* pEntry, const Point& rDocPos ) 3971*cdf0e10cSrcweir { 3972*cdf0e10cSrcweir SvLBoxString* pItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING)); 3973*cdf0e10cSrcweir if( pItem ) 3974*cdf0e10cSrcweir { 3975*cdf0e10cSrcweir Rectangle aRect( CalcTextRect( pEntry, pItem )); 3976*cdf0e10cSrcweir if( aRect.IsInside( rDocPos ) ) 3977*cdf0e10cSrcweir return sal_True; 3978*cdf0e10cSrcweir } 3979*cdf0e10cSrcweir return sal_False; 3980*cdf0e10cSrcweir } 3981*cdf0e10cSrcweir 3982*cdf0e10cSrcweir IMPL_LINK(SvImpIconView, EditTimeoutHdl, Timer*, EMPTYARG ) 3983*cdf0e10cSrcweir { 3984*cdf0e10cSrcweir SvLBoxEntry* pEntry = GetCurEntry(); 3985*cdf0e10cSrcweir if( pView->IsInplaceEditingEnabled() && pEntry && 3986*cdf0e10cSrcweir pView->IsSelected( pEntry )) 3987*cdf0e10cSrcweir { 3988*cdf0e10cSrcweir pView->EditEntry( pEntry ); 3989*cdf0e10cSrcweir } 3990*cdf0e10cSrcweir return 0; 3991*cdf0e10cSrcweir } 3992*cdf0e10cSrcweir 3993*cdf0e10cSrcweir 3994*cdf0e10cSrcweir // 3995*cdf0e10cSrcweir // Funktionen zum Ausrichten der Eintraege am Grid 3996*cdf0e10cSrcweir // 3997*cdf0e10cSrcweir 3998*cdf0e10cSrcweir // pStart == 0: Alle Eintraege werden ausgerichtet 3999*cdf0e10cSrcweir // sonst: Alle Eintraege der Zeile ab einschliesslich pStart werden ausgerichtet 4000*cdf0e10cSrcweir void SvImpIconView::AdjustAtGrid( SvLBoxEntry* pStart ) 4001*cdf0e10cSrcweir { 4002*cdf0e10cSrcweir SvPtrarr aLists; 4003*cdf0e10cSrcweir pImpCursor->CreateGridAjustData( aLists, pStart ); 4004*cdf0e10cSrcweir sal_uInt16 nCount = aLists.Count(); 4005*cdf0e10cSrcweir for( sal_uInt16 nCur = 0; nCur < nCount; nCur++ ) 4006*cdf0e10cSrcweir { 4007*cdf0e10cSrcweir AdjustAtGrid( *(SvPtrarr*)aLists[ nCur ], pStart ); 4008*cdf0e10cSrcweir } 4009*cdf0e10cSrcweir ImpIcnCursor::DestroyGridAdjustData( aLists ); 4010*cdf0e10cSrcweir CheckScrollBars(); 4011*cdf0e10cSrcweir } 4012*cdf0e10cSrcweir 4013*cdf0e10cSrcweir // Richtet eine Zeile aus, erweitert ggf. die Breite; Bricht die Zeile nicht um 4014*cdf0e10cSrcweir void SvImpIconView::AdjustAtGrid( const SvPtrarr& rRow, SvLBoxEntry* pStart ) 4015*cdf0e10cSrcweir { 4016*cdf0e10cSrcweir if( !rRow.Count() ) 4017*cdf0e10cSrcweir return; 4018*cdf0e10cSrcweir 4019*cdf0e10cSrcweir sal_Bool bGo; 4020*cdf0e10cSrcweir if( !pStart ) 4021*cdf0e10cSrcweir bGo = sal_True; 4022*cdf0e10cSrcweir else 4023*cdf0e10cSrcweir bGo = sal_False; 4024*cdf0e10cSrcweir 4025*cdf0e10cSrcweir long nCurRight = 0; 4026*cdf0e10cSrcweir for( sal_uInt16 nCur = 0; nCur < rRow.Count(); nCur++ ) 4027*cdf0e10cSrcweir { 4028*cdf0e10cSrcweir SvLBoxEntry* pCur = (SvLBoxEntry*)rRow[ nCur ]; 4029*cdf0e10cSrcweir if( !bGo && pCur == pStart ) 4030*cdf0e10cSrcweir bGo = sal_True; 4031*cdf0e10cSrcweir 4032*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pCur); 4033*cdf0e10cSrcweir // Massgebend (fuer das menschliche Auge) ist die Bitmap, da sonst 4034*cdf0e10cSrcweir // durch lange Texte der Eintrag stark springen kann 4035*cdf0e10cSrcweir const Rectangle& rBoundRect = GetBoundingRect( pCur, pViewData ); 4036*cdf0e10cSrcweir Rectangle aCenterRect( CalcBmpRect( pCur, 0, pViewData )); 4037*cdf0e10cSrcweir if( bGo && !pViewData->IsEntryPosLocked() ) 4038*cdf0e10cSrcweir { 4039*cdf0e10cSrcweir long nWidth = aCenterRect.GetSize().Width(); 4040*cdf0e10cSrcweir Point aNewPos( AdjustAtGrid( aCenterRect, rBoundRect ) ); 4041*cdf0e10cSrcweir while( aNewPos.X() < nCurRight ) 4042*cdf0e10cSrcweir aNewPos.X() += nGridDX; 4043*cdf0e10cSrcweir if( aNewPos != rBoundRect.TopLeft() ) 4044*cdf0e10cSrcweir SetEntryPosition( pCur, aNewPos ); 4045*cdf0e10cSrcweir nCurRight = aNewPos.X() + nWidth; 4046*cdf0e10cSrcweir } 4047*cdf0e10cSrcweir else 4048*cdf0e10cSrcweir { 4049*cdf0e10cSrcweir nCurRight = rBoundRect.Right(); 4050*cdf0e10cSrcweir } 4051*cdf0e10cSrcweir } 4052*cdf0e10cSrcweir } 4053*cdf0e10cSrcweir 4054*cdf0e10cSrcweir // Richtet Rect am Grid aus, garantiert jedoch nicht, dass die 4055*cdf0e10cSrcweir // neue Pos. frei ist. Die Pos. kann fuer SetEntryPos verwendet werden. 4056*cdf0e10cSrcweir // Das CenterRect beschreibt den Teil des BoundRects, der fuer 4057*cdf0e10cSrcweir // die Berechnung des Ziel-Rechtecks verwendet wird. 4058*cdf0e10cSrcweir Point SvImpIconView::AdjustAtGrid( const Rectangle& rCenterRect, 4059*cdf0e10cSrcweir const Rectangle& rBoundRect ) const 4060*cdf0e10cSrcweir { 4061*cdf0e10cSrcweir Point aPos( rCenterRect.TopLeft() ); 4062*cdf0e10cSrcweir Size aSize( rCenterRect.GetSize() ); 4063*cdf0e10cSrcweir 4064*cdf0e10cSrcweir aPos.X() -= LROFFS_WINBORDER; 4065*cdf0e10cSrcweir aPos.Y() -= TBOFFS_WINBORDER; 4066*cdf0e10cSrcweir 4067*cdf0e10cSrcweir // align (ref ist mitte des rects) 4068*cdf0e10cSrcweir short nGridX = (short)((aPos.X()+(aSize.Width()/2)) / nGridDX); 4069*cdf0e10cSrcweir short nGridY = (short)((aPos.Y()+(aSize.Height()/2)) / nGridDY); 4070*cdf0e10cSrcweir aPos.X() = nGridX * nGridDX; 4071*cdf0e10cSrcweir aPos.Y() = nGridY * nGridDY; 4072*cdf0e10cSrcweir // hor. center 4073*cdf0e10cSrcweir aPos.X() += (nGridDX - rBoundRect.GetSize().Width() ) / 2; 4074*cdf0e10cSrcweir 4075*cdf0e10cSrcweir aPos.X() += LROFFS_WINBORDER; 4076*cdf0e10cSrcweir aPos.Y() += TBOFFS_WINBORDER; 4077*cdf0e10cSrcweir 4078*cdf0e10cSrcweir return aPos; 4079*cdf0e10cSrcweir } 4080*cdf0e10cSrcweir 4081*cdf0e10cSrcweir 4082*cdf0e10cSrcweir void SvImpIconView::SetTextMode( SvIconViewTextMode eMode, SvLBoxEntry* pEntry ) 4083*cdf0e10cSrcweir { 4084*cdf0e10cSrcweir if( !pEntry ) 4085*cdf0e10cSrcweir { 4086*cdf0e10cSrcweir if( eTextMode != eMode ) 4087*cdf0e10cSrcweir { 4088*cdf0e10cSrcweir if( eTextMode == ShowTextDontKnow ) 4089*cdf0e10cSrcweir eTextMode = ShowTextShort; 4090*cdf0e10cSrcweir eTextMode = eMode; 4091*cdf0e10cSrcweir pView->Arrange(); 4092*cdf0e10cSrcweir } 4093*cdf0e10cSrcweir } 4094*cdf0e10cSrcweir else 4095*cdf0e10cSrcweir { 4096*cdf0e10cSrcweir SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry); 4097*cdf0e10cSrcweir if( pViewData->eTextMode != eMode ) 4098*cdf0e10cSrcweir { 4099*cdf0e10cSrcweir pViewData->eTextMode = eMode; 4100*cdf0e10cSrcweir pModel->InvalidateEntry( pEntry ); 4101*cdf0e10cSrcweir AdjustVirtSize( pViewData->aRect ); 4102*cdf0e10cSrcweir } 4103*cdf0e10cSrcweir } 4104*cdf0e10cSrcweir } 4105*cdf0e10cSrcweir 4106*cdf0e10cSrcweir SvIconViewTextMode SvImpIconView::GetTextMode( const SvLBoxEntry* pEntry, 4107*cdf0e10cSrcweir const SvIcnVwDataEntry* pViewData ) const 4108*cdf0e10cSrcweir { 4109*cdf0e10cSrcweir if( !pEntry ) 4110*cdf0e10cSrcweir return eTextMode; 4111*cdf0e10cSrcweir else 4112*cdf0e10cSrcweir { 4113*cdf0e10cSrcweir if( !pViewData ) 4114*cdf0e10cSrcweir pViewData = ICNVIEWDATA(((SvLBoxEntry*)pEntry)); 4115*cdf0e10cSrcweir return pViewData->GetTextMode(); 4116*cdf0e10cSrcweir } 4117*cdf0e10cSrcweir } 4118*cdf0e10cSrcweir 4119*cdf0e10cSrcweir SvIconViewTextMode SvImpIconView::GetEntryTextModeSmart( const SvLBoxEntry* pEntry, 4120*cdf0e10cSrcweir const SvIcnVwDataEntry* pViewData ) const 4121*cdf0e10cSrcweir { 4122*cdf0e10cSrcweir DBG_ASSERT(pEntry,"GetEntryTextModeSmart: Entry not set"); 4123*cdf0e10cSrcweir if( !pViewData ) 4124*cdf0e10cSrcweir pViewData = ICNVIEWDATA(((SvLBoxEntry*)pEntry)); 4125*cdf0e10cSrcweir SvIconViewTextMode eMode = pViewData->GetTextMode(); 4126*cdf0e10cSrcweir if( eMode == ShowTextDontKnow ) 4127*cdf0e10cSrcweir return eTextMode; 4128*cdf0e10cSrcweir return eMode; 4129*cdf0e10cSrcweir } 4130*cdf0e10cSrcweir 4131*cdf0e10cSrcweir void SvImpIconView::ShowFocusRect( const SvLBoxEntry* pEntry ) 4132*cdf0e10cSrcweir { 4133*cdf0e10cSrcweir if( !pEntry ) 4134*cdf0e10cSrcweir pView->HideFocus(); 4135*cdf0e10cSrcweir else 4136*cdf0e10cSrcweir { 4137*cdf0e10cSrcweir Rectangle aRect ( CalcFocusRect( (SvLBoxEntry*)pEntry ) ); 4138*cdf0e10cSrcweir pView->ShowFocus( aRect ); 4139*cdf0e10cSrcweir } 4140*cdf0e10cSrcweir } 4141*cdf0e10cSrcweir 4142*cdf0e10cSrcweir IMPL_LINK(SvImpIconView, UserEventHdl, void*, EMPTYARG ) 4143*cdf0e10cSrcweir { 4144*cdf0e10cSrcweir nCurUserEvent = 0; 4145*cdf0e10cSrcweir AdjustScrollBars(); 4146*cdf0e10cSrcweir Rectangle aRect; 4147*cdf0e10cSrcweir if( GetResizeRect(aRect) ) 4148*cdf0e10cSrcweir PaintResizeRect( aRect ); 4149*cdf0e10cSrcweir return 0; 4150*cdf0e10cSrcweir } 4151*cdf0e10cSrcweir 4152*cdf0e10cSrcweir void SvImpIconView::CancelUserEvent() 4153*cdf0e10cSrcweir { 4154*cdf0e10cSrcweir if( nCurUserEvent ) 4155*cdf0e10cSrcweir { 4156*cdf0e10cSrcweir Application::RemoveUserEvent( nCurUserEvent ); 4157*cdf0e10cSrcweir nCurUserEvent = 0; 4158*cdf0e10cSrcweir } 4159*cdf0e10cSrcweir } 4160*cdf0e10cSrcweir 4161*cdf0e10cSrcweir 4162