1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23 #ifndef _SVIMPICN_HXX
24 #define _SVIMPICN_HXX
25
26 #ifndef _VIRDEV_HXX
27 #include <vcl/virdev.hxx>
28 #endif
29
30 #ifndef _SCRBAR_HXX
31 #include <vcl/scrbar.hxx>
32 #endif
33 #include <limits.h>
34
35 class SvLBoxEntry;
36 class SvLBoxTreeList;
37 class SvImpIconView;
38 class ImpIcnCursor;
39 class SvPtrarr;
40
41 #define PAINTFLAG_HOR_CENTERED 0x0001
42 #define PAINTFLAG_VER_CENTERED 0x0002
43
44 #define SELRECT_BORDER_OFFS -7
45 // Flags
46 #define F_VER_SBARSIZE_WITH_HBAR 0x00000001
47 #define F_HOR_SBARSIZE_WITH_VBAR 0x00000002
48 #define F_IGNORE_NEXT_MOUSEMOVE 0x00000004 // OS/2 only
49 #define F_ENTRY_REMOVED 0x00000008
50 // ist gesetzt, wenn nach Clear oder Ctor mind. einmal gepaintet wurde
51 #define F_PAINTED 0x00000010
52 #define F_ADD_MODE 0x00000020
53 #define F_MOVING_SIBLING 0x00000040
54 #define F_SELRECT_VISIBLE 0x00000080
55 #define F_CMD_ARRIVED 0x00000100
56 #define F_DRAG_SOURCE 0x00000200
57 #define F_GRIDMODE 0x00000400
58 // beim Einfuegen eines Eintrags ergibt sich dessen Position
59 // durch simples Addieren auf die Position des zuletzt eingefuegten Eintrags
60 #define F_GRID_INSERT 0x00000800
61 #define F_DOWN_CTRL 0x00001000
62 #define F_DOWN_DESELECT 0x00002000
63 // Hack fuer D&D: Hintergrund des Entries nicht painten
64 #define F_NO_EMPHASIS 0x00004000
65 // Selektion per Gummiband
66 #define F_RUBBERING 0x00008000
67 #define F_START_EDITTIMER_IN_MOUSEUP 0x00010000
68
69 class SvImpIconView
70 {
71 friend class ImpIcnCursor;
72 ScrollBar aVerSBar;
73 ScrollBar aHorSBar;
74 Rectangle aCurSelectionRect;
75 SvPtrarr aSelectedRectList;
76 MouseEvent aMouseMoveEvent;
77 Timer aEditTimer; // fuer Inplace-Editieren
78 Timer aMouseMoveTimer; // generiert MouseMoves bei Gummibandselektion
79 // Boundrect des zuletzt eingefuegten Entries
80 Rectangle aPrevBoundRect;
81 Size aOutputSize; // Pixel
82 Size aVirtOutputSize; // expandiert automatisch
83 Point aDDLastEntryPos;
84 Point aDDLastRectPos;
85
86 SvLBoxTreeList* pModel;
87 SvIconView* pView;
88 ImpIcnCursor* pImpCursor;
89 long nMaxVirtWidth; // max.breite aVirtOutputSize
90 SvPtrarr* pZOrderList;
91 long nGridDX,
92 nGridDY;
93 long nHorSBarHeight,
94 nVerSBarWidth;
95 int nViewMode;
96 long nHorDist;
97 long nVerDist;
98 long nMaxBmpWidth;
99 long nMaxBmpHeight;
100 long nMaxTextWidth;
101 long nMaxBoundHeight; // Hoehe des hoechsten BoundRects
102 sal_uLong nFlags;
103 sal_uLong nCurUserEvent;
104 SvLBoxEntry* pCurParent;
105 SvLBoxEntry* pCursor;
106 SvLBoxEntry* pNextCursor; // wird in MovingEntry gesetzt und ist
107 // nur in EntryMoved gueltig!
108 SvLBoxEntry* pDDRefEntry;
109 VirtualDevice* pDDDev;
110 VirtualDevice* pDDBufDev;
111 VirtualDevice* pDDTempDev;
112
113 SvIconViewTextMode eTextMode;
114 sal_Bool bMustRecalcBoundingRects;
115
116 void CheckAllSizes();
117 void CheckSizes( SvLBoxEntry* pEntry,
118 const SvIcnVwDataEntry* pViewData = 0 );
119 void ShowCursor( sal_Bool bShow );
120
121 void SetNextEntryPos(const Point& rPos);
122 Point FindNextEntryPos( const Size& rBoundSize );
123 void ImpArrange();
124 void AdjustVirtSize( const Rectangle& );
125 void ResetVirtSize();
126 void CheckScrollBars();
127
128 DECL_LINK( ScrollUpDownHdl, ScrollBar * );
129 DECL_LINK( ScrollLeftRightHdl, ScrollBar * );
130 DECL_LINK( MouseMoveTimeoutHdl, Timer* );
131 DECL_LINK( EditTimeoutHdl, Timer* );
132 DECL_LINK( UserEventHdl, void* );
133 void AdjustScrollBars();
134 void PositionScrollBars( long nRealWidth, long nRealHeight );
135 void CalcDocPos( Point& aMousePos );
136 sal_Bool GetResizeRect( Rectangle& );
137 void PaintResizeRect( const Rectangle& );
138 SvLBoxEntry* GetNewCursor();
139 void ToggleSelection( SvLBoxEntry* );
140 void DeselectAllBut( SvLBoxEntry* );
141 void Center( SvLBoxEntry* pEntry, SvIcnVwDataEntry* ) const;
StopEditTimer()142 void StopEditTimer() { aEditTimer.Stop(); }
StartEditTimer()143 void StartEditTimer() { aEditTimer.Start(); }
144 void ImpHideDDIcon();
145 void ImpDrawXORRect( const Rectangle& rRect );
146 void AddSelectedRect( const Rectangle&, short nOffset = SELRECT_BORDER_OFFS );
147 void ClearSelectedRectList();
148 Rectangle CalcMaxTextRect( const SvLBoxEntry* pEntry,
149 const SvIcnVwDataEntry* pViewData ) const;
150
151 void ClipAtVirtOutRect( Rectangle& rRect ) const;
152 void AdjustAtGrid( const SvPtrarr& rRow, SvLBoxEntry* pStart=0 );
153 Point AdjustAtGrid(
154 const Rectangle& rCenterRect, // "Schwerpunkt" des Objekts (typ. Bmp-Rect)
155 const Rectangle& rBoundRect ) const;
156 SvIconViewTextMode GetEntryTextModeSmart( const SvLBoxEntry* pEntry,
157 const SvIcnVwDataEntry* pViewData ) const;
158
159 sal_Bool CheckVerScrollBar();
160 sal_Bool CheckHorScrollBar();
161 void CancelUserEvent();
162
163 public:
164
165 SvImpIconView( SvIconView* pView, SvLBoxTreeList*, WinBits nWinStyle );
166 ~SvImpIconView();
167
168 void Clear( sal_Bool bInCtor = sal_False );
169 void SetStyle( const WinBits i_nWinStyle );
SetModel(SvLBoxTreeList * pTree,SvLBoxEntry * pParent)170 void SetModel( SvLBoxTreeList* pTree, SvLBoxEntry* pParent )
171 { pModel = pTree; SetCurParent(pParent); }
172 void EntryInserted( SvLBoxEntry*);
173 void RemovingEntry( SvLBoxEntry* pEntry );
174 void EntryRemoved();
175 void MovingEntry( SvLBoxEntry* pEntry );
176 void EntryMoved( SvLBoxEntry* pEntry );
177 void TreeInserted( SvLBoxEntry* pEntry );
178 void ChangedFont();
179 void ModelHasEntryInvalidated( SvListEntry* );
180 void EntryExpanded( SvLBoxEntry* pEntry );
181 void EntryCollapsed( SvLBoxEntry* pEntry );
182 void CollapsingEntry( SvLBoxEntry* pEntry );
183 void EntrySelected( SvLBoxEntry*, sal_Bool bSelect );
184
185 void Paint( const Rectangle& rRect );
186 void RepaintSelectionItems();
187 void MouseButtonDown( const MouseEvent& );
188 void MouseButtonUp( const MouseEvent& );
189 void MouseMove( const MouseEvent&);
190 sal_Bool KeyInput( const KeyEvent& );
191 void Resize();
192 void GetFocus();
193 void LoseFocus();
194 void UpdateAll();
195 void PaintEntry( SvLBoxEntry* pEntry,
196 SvIcnVwDataEntry* pViewData = 0 );
197 void PaintEntry( SvLBoxEntry*, const Point&,
198 SvIcnVwDataEntry* pViewData = 0, OutputDevice* pOut = 0);
199 void SetEntryPosition( SvLBoxEntry* pEntry, const Point& rPos,
200 sal_Bool bAdjustRow = sal_False,
201 sal_Bool bCheckScrollBars = sal_False );
202 void InvalidateEntry( SvLBoxEntry* );
203 void ViewDataInitialized( SvLBoxEntry* pEntry );
204 SvLBoxItem* GetItem( SvLBoxEntry*, const Point& rAbsPos );
205
206 void SetNoSelection();
207 void SetDragDropMode( DragDropMode eDDMode );
208 void SetSelectionMode( SelectionMode eSelMode );
209
210 void SttDrag( const Point& rPos );
211 void EndDrag();
212
GetCurEntry() const213 SvLBoxEntry* GetCurEntry() const { return pCursor; }
214 void SetCursor( SvLBoxEntry* );
215
216 sal_Bool IsEntryInView( SvLBoxEntry* );
217 SvLBoxEntry* GetEntry( const Point& rDocPos );
218 SvLBoxEntry* GetNextEntry( const Point& rDocPos, SvLBoxEntry* pCurEntry );
219 SvLBoxEntry* GetPrevEntry( const Point& rDocPos, SvLBoxEntry* pCurEntry );
220
221 Point GetEntryPosition( SvLBoxEntry* );
222 void MakeVisible( SvLBoxEntry* pEntry );
223
224 void Arrange();
225
226 void SetSpaceBetweenEntries( long nHor, long Ver );
GetHorSpaceBetweenEntries() const227 long GetHorSpaceBetweenEntries() const { return nHorDist; }
GetVerSpaceBetweenEntries() const228 long GetVerSpaceBetweenEntries() const { return nVerDist; }
229
230 Rectangle CalcFocusRect( SvLBoxEntry* );
231
232 Rectangle CalcBmpRect( SvLBoxEntry*, const Point* pPos = 0,
233 SvIcnVwDataEntry* pViewData=0 );
234 Rectangle CalcTextRect( SvLBoxEntry*, SvLBoxString* pItem = 0,
235 const Point* pPos = 0,
236 sal_Bool bForInplaceEdit = sal_False,
237 SvIcnVwDataEntry* pViewData = 0 );
238
239 long CalcBoundingWidth( SvLBoxEntry*, const SvIcnVwDataEntry* pViewData = 0) const;
240 long CalcBoundingHeight( SvLBoxEntry*, const SvIcnVwDataEntry* pViewData= 0 ) const;
241 Size CalcBoundingSize( SvLBoxEntry*,
242 SvIcnVwDataEntry* pViewData = 0 ) const;
243 void FindBoundingRect( SvLBoxEntry* pEntry,
244 SvIcnVwDataEntry* pViewData = 0 );
245 // berechnet alle BoundRects neu
246 void RecalcAllBoundingRects();
247 // berechnet alle ungueltigen BoundRects neu
248 void RecalcAllBoundingRectsSmart();
249 const Rectangle& GetBoundingRect( SvLBoxEntry*,
250 SvIcnVwDataEntry* pViewData=0);
251 void InvalidateBoundingRect( SvLBoxEntry* );
InvalidateBoundingRect(Rectangle & rRect)252 void InvalidateBoundingRect( Rectangle& rRect ) { rRect.Right() = LONG_MAX; }
IsBoundingRectValid(const Rectangle & rRect) const253 sal_Bool IsBoundingRectValid( const Rectangle& rRect ) const { return (sal_Bool)( rRect.Right() != LONG_MAX ); }
254
255 void PaintEmphasis( const Rectangle&, sal_Bool bSelected,
256 sal_Bool bCursored, OutputDevice* pOut = 0 );
257 void PaintItem( const Rectangle& rRect, SvLBoxItem* pItem,
258 SvLBoxEntry* pEntry, sal_uInt16 nPaintFlags, OutputDevice* pOut = 0 );
259 // berechnet alle BoundingRects neu, wenn bMustRecalcBoundingRects == sal_True
CheckBoundingRects()260 void CheckBoundingRects() { if (bMustRecalcBoundingRects) RecalcAllBoundingRects(); }
261 // berechnet alle invalidierten BoundingRects neu
262 void UpdateBoundingRects();
263 void ShowTargetEmphasis( SvLBoxEntry* pEntry, sal_Bool bShow );
264 SvLBoxEntry* GetDropTarget( const Point& rPosPixel );
265 sal_Bool NotifyMoving( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
266 SvLBoxEntry*& rpNewParent, sal_uLong& rNewChildPos );
267 sal_Bool NotifyCopying( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
268 SvLBoxEntry*& rpNewParent, sal_uLong& rNewChildPos );
269
270 void WriteDragServerInfo( const Point&, SvLBoxDDInfo* );
271 void ReadDragServerInfo( const Point&, SvLBoxDDInfo* );
272 void ToTop( SvLBoxEntry* );
273
274 void SetCurParent( SvLBoxEntry* pNewParent );
GetCurParent() const275 SvLBoxEntry* GetCurParent() const { return pCurParent; }
276 sal_uInt16 GetSelectionCount() const;
277 void SetGrid( long nDX, long nDY );
278 void Scroll( long nDeltaX, long nDeltaY, sal_Bool bScrollBar = sal_False );
279 const Size& GetItemSize( SvIconView* pView, SvLBoxEntry*, SvLBoxItem*,
280 const SvIcnVwDataEntry* pViewData = 0 ) const;
281 void PrepareCommandEvent( const Point& rPt );
282
283 void HideDDIcon();
284 void ShowDDIcon( SvLBoxEntry* pRefEntry, const Point& rPos );
285 void HideShowDDIcon( SvLBoxEntry* pRefEntry, const Point& rPos );
286
287 SvLBoxEntry* mpViewData;
288
289 sal_Bool IsOver( SvPtrarr* pSelectedRectList, const Rectangle& rEntryBoundRect ) const;
290 void SelectRect( const Rectangle&, sal_Bool bAdd = sal_True,
291 SvPtrarr* pOtherRects = 0,
292 short nOffs = SELRECT_BORDER_OFFS );
293 void DrawSelectionRect( const Rectangle& );
294 void HideSelectionRect();
295 void CalcScrollOffsets( const Point& rRefPosPixel,
296 long& rX, long& rY, sal_Bool bDragDrop = sal_False,
297 sal_uInt16 nBorderWidth = 10 );
298 void EndTracking();
299 sal_Bool IsTextHit( SvLBoxEntry* pEntry, const Point& rDocPos );
300 void MakeVisible( const Rectangle& rDocPos,sal_Bool bInScrollBarEvent=sal_False);
301 void AdjustAtGrid( SvLBoxEntry* pStart = 0 );
302 void SetTextMode( SvIconViewTextMode, SvLBoxEntry* pEntry = 0 );
303 SvIconViewTextMode GetTextMode( const SvLBoxEntry* pEntry = 0,
304 const SvIcnVwDataEntry* pViewData = 0 ) const;
305 void ShowFocusRect( const SvLBoxEntry* pEntry );
306 };
307
MakeVisible(SvLBoxEntry * pEntry)308 inline void SvImpIconView::MakeVisible( SvLBoxEntry* pEntry )
309 {
310 const Rectangle& rRect = GetBoundingRect( pEntry );
311 MakeVisible( rRect );
312 }
313
314 #endif // #ifndef _SVIMPICN_HXX
315
316
317