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