1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svimpicn.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #include <vcl/virdev.hxx>
38 #include <vcl/scrbar.hxx>
51 #define PAINTFLAG_HOR_CENTERED 0x0001
52 #define PAINTFLAG_VER_CENTERED 0x0002
54 #define SELRECT_BORDER_OFFS -7
56 #define F_VER_SBARSIZE_WITH_HBAR 0x00000001
57 #define F_HOR_SBARSIZE_WITH_VBAR 0x00000002
58 #define F_IGNORE_NEXT_MOUSEMOVE 0x00000004 // OS/2 only
59 #define F_ENTRY_REMOVED 0x00000008
60 // ist gesetzt, wenn nach Clear oder Ctor mind. einmal gepaintet wurde
61 #define F_PAINTED 0x00000010
62 #define F_ADD_MODE 0x00000020
63 #define F_MOVING_SIBLING 0x00000040
64 #define F_SELRECT_VISIBLE 0x00000080
65 #define F_CMD_ARRIVED 0x00000100
66 #define F_DRAG_SOURCE 0x00000200
67 #define F_GRIDMODE 0x00000400
68 // beim Einfuegen eines Eintrags ergibt sich dessen Position
69 // durch simples Addieren auf die Position des zuletzt eingefuegten Eintrags
70 #define F_GRID_INSERT 0x00000800
71 #define F_DOWN_CTRL 0x00001000
72 #define F_DOWN_DESELECT 0x00002000
73 // Hack fuer D&D: Hintergrund des Entries nicht painten
74 #define F_NO_EMPHASIS 0x00004000
75 // Selektion per Gummiband
76 #define F_RUBBERING 0x00008000
77 #define F_START_EDITTIMER_IN_MOUSEUP 0x00010000
81 friend class ImpIcnCursor
;
84 Rectangle aCurSelectionRect
;
85 SvPtrarr aSelectedRectList
;
86 MouseEvent aMouseMoveEvent
;
87 Timer aEditTimer
; // fuer Inplace-Editieren
88 Timer aMouseMoveTimer
; // generiert MouseMoves bei Gummibandselektion
89 // Boundrect des zuletzt eingefuegten Entries
90 Rectangle aPrevBoundRect
;
91 Size aOutputSize
; // Pixel
92 Size aVirtOutputSize
; // expandiert automatisch
93 Point aDDLastEntryPos
;
96 SvLBoxTreeList
* pModel
;
98 ImpIcnCursor
* pImpCursor
;
99 long nMaxVirtWidth
; // max.breite aVirtOutputSize
100 SvPtrarr
* pZOrderList
;
112 long nMaxBoundHeight
; // Hoehe des hoechsten BoundRects
115 SvLBoxEntry
* pCurParent
;
116 SvLBoxEntry
* pCursor
;
117 SvLBoxEntry
* pNextCursor
; // wird in MovingEntry gesetzt und ist
118 // nur in EntryMoved gueltig!
119 SvLBoxEntry
* pDDRefEntry
;
120 VirtualDevice
* pDDDev
;
121 VirtualDevice
* pDDBufDev
;
122 VirtualDevice
* pDDTempDev
;
124 SvIconViewTextMode eTextMode
;
125 BOOL bMustRecalcBoundingRects
;
127 void CheckAllSizes();
128 void CheckSizes( SvLBoxEntry
* pEntry
,
129 const SvIcnVwDataEntry
* pViewData
= 0 );
130 void ShowCursor( BOOL bShow
);
132 void SetNextEntryPos(const Point
& rPos
);
133 Point
FindNextEntryPos( const Size
& rBoundSize
);
135 void AdjustVirtSize( const Rectangle
& );
136 void ResetVirtSize();
137 void CheckScrollBars();
139 DECL_LINK( ScrollUpDownHdl
, ScrollBar
* );
140 DECL_LINK( ScrollLeftRightHdl
, ScrollBar
* );
141 DECL_LINK( MouseMoveTimeoutHdl
, Timer
* );
142 DECL_LINK( EditTimeoutHdl
, Timer
* );
143 DECL_LINK( UserEventHdl
, void* );
144 void AdjustScrollBars();
145 void PositionScrollBars( long nRealWidth
, long nRealHeight
);
146 void CalcDocPos( Point
& aMousePos
);
147 BOOL
GetResizeRect( Rectangle
& );
148 void PaintResizeRect( const Rectangle
& );
149 SvLBoxEntry
* GetNewCursor();
150 void ToggleSelection( SvLBoxEntry
* );
151 void DeselectAllBut( SvLBoxEntry
* );
152 void Center( SvLBoxEntry
* pEntry
, SvIcnVwDataEntry
* ) const;
153 void StopEditTimer() { aEditTimer
.Stop(); }
154 void StartEditTimer() { aEditTimer
.Start(); }
155 void ImpHideDDIcon();
156 void ImpDrawXORRect( const Rectangle
& rRect
);
157 void AddSelectedRect( const Rectangle
&, short nOffset
= SELRECT_BORDER_OFFS
);
158 void ClearSelectedRectList();
159 Rectangle
CalcMaxTextRect( const SvLBoxEntry
* pEntry
,
160 const SvIcnVwDataEntry
* pViewData
) const;
162 void ClipAtVirtOutRect( Rectangle
& rRect
) const;
163 void AdjustAtGrid( const SvPtrarr
& rRow
, SvLBoxEntry
* pStart
=0 );
165 const Rectangle
& rCenterRect
, // "Schwerpunkt" des Objekts (typ. Bmp-Rect)
166 const Rectangle
& rBoundRect
) const;
167 SvIconViewTextMode
GetEntryTextModeSmart( const SvLBoxEntry
* pEntry
,
168 const SvIcnVwDataEntry
* pViewData
) const;
170 BOOL
CheckVerScrollBar();
171 BOOL
CheckHorScrollBar();
172 void CancelUserEvent();
176 SvImpIconView( SvIconView
* pView
, SvLBoxTreeList
*, WinBits nWinStyle
);
179 void Clear( BOOL bInCtor
= FALSE
);
180 void SetWindowBits( WinBits nWinStyle
);
181 void SetModel( SvLBoxTreeList
* pTree
, SvLBoxEntry
* pParent
)
182 { pModel
= pTree
; SetCurParent(pParent
); }
183 void EntryInserted( SvLBoxEntry
*);
184 void RemovingEntry( SvLBoxEntry
* pEntry
);
186 void MovingEntry( SvLBoxEntry
* pEntry
);
187 void EntryMoved( SvLBoxEntry
* pEntry
);
188 void TreeInserted( SvLBoxEntry
* pEntry
);
190 void ModelHasEntryInvalidated( SvListEntry
* );
191 void EntryExpanded( SvLBoxEntry
* pEntry
);
192 void EntryCollapsed( SvLBoxEntry
* pEntry
);
193 void CollapsingEntry( SvLBoxEntry
* pEntry
);
194 void EntrySelected( SvLBoxEntry
*, BOOL bSelect
);
196 void Paint( const Rectangle
& rRect
);
197 void RepaintSelectionItems();
198 void MouseButtonDown( const MouseEvent
& );
199 void MouseButtonUp( const MouseEvent
& );
200 void MouseMove( const MouseEvent
&);
201 BOOL
KeyInput( const KeyEvent
& );
206 void PaintEntry( SvLBoxEntry
* pEntry
,
207 SvIcnVwDataEntry
* pViewData
= 0 );
208 void PaintEntry( SvLBoxEntry
*, const Point
&,
209 SvIcnVwDataEntry
* pViewData
= 0, OutputDevice
* pOut
= 0);
210 void SetEntryPosition( SvLBoxEntry
* pEntry
, const Point
& rPos
,
211 BOOL bAdjustRow
= FALSE
,
212 BOOL bCheckScrollBars
= FALSE
);
213 void InvalidateEntry( SvLBoxEntry
* );
214 void ViewDataInitialized( SvLBoxEntry
* pEntry
);
215 SvLBoxItem
* GetItem( SvLBoxEntry
*, const Point
& rAbsPos
);
217 void SetNoSelection();
218 void SetDragDropMode( DragDropMode eDDMode
);
219 void SetSelectionMode( SelectionMode eSelMode
);
221 void SttDrag( const Point
& rPos
);
224 SvLBoxEntry
* GetCurEntry() const { return pCursor
; }
225 void SetCursor( SvLBoxEntry
* );
227 BOOL
IsEntryInView( SvLBoxEntry
* );
228 SvLBoxEntry
* GetEntry( const Point
& rDocPos
);
229 SvLBoxEntry
* GetNextEntry( const Point
& rDocPos
, SvLBoxEntry
* pCurEntry
);
230 SvLBoxEntry
* GetPrevEntry( const Point
& rDocPos
, SvLBoxEntry
* pCurEntry
);
232 Point
GetEntryPosition( SvLBoxEntry
* );
233 void MakeVisible( SvLBoxEntry
* pEntry
);
237 void SetSpaceBetweenEntries( long nHor
, long Ver
);
238 long GetHorSpaceBetweenEntries() const { return nHorDist
; }
239 long GetVerSpaceBetweenEntries() const { return nVerDist
; }
241 Rectangle
CalcFocusRect( SvLBoxEntry
* );
243 Rectangle
CalcBmpRect( SvLBoxEntry
*, const Point
* pPos
= 0,
244 SvIcnVwDataEntry
* pViewData
=0 );
245 Rectangle
CalcTextRect( SvLBoxEntry
*, SvLBoxString
* pItem
= 0,
246 const Point
* pPos
= 0,
247 BOOL bForInplaceEdit
= FALSE
,
248 SvIcnVwDataEntry
* pViewData
= 0 );
250 long CalcBoundingWidth( SvLBoxEntry
*, const SvIcnVwDataEntry
* pViewData
= 0) const;
251 long CalcBoundingHeight( SvLBoxEntry
*, const SvIcnVwDataEntry
* pViewData
= 0 ) const;
252 Size
CalcBoundingSize( SvLBoxEntry
*,
253 SvIcnVwDataEntry
* pViewData
= 0 ) const;
254 void FindBoundingRect( SvLBoxEntry
* pEntry
,
255 SvIcnVwDataEntry
* pViewData
= 0 );
256 // berechnet alle BoundRects neu
257 void RecalcAllBoundingRects();
258 // berechnet alle ungueltigen BoundRects neu
259 void RecalcAllBoundingRectsSmart();
260 const Rectangle
& GetBoundingRect( SvLBoxEntry
*,
261 SvIcnVwDataEntry
* pViewData
=0);
262 void InvalidateBoundingRect( SvLBoxEntry
* );
263 void InvalidateBoundingRect( Rectangle
& rRect
) { rRect
.Right() = LONG_MAX
; }
264 BOOL
IsBoundingRectValid( const Rectangle
& rRect
) const { return (BOOL
)( rRect
.Right() != LONG_MAX
); }
266 void PaintEmphasis( const Rectangle
&, BOOL bSelected
,
267 BOOL bCursored
, OutputDevice
* pOut
= 0 );
268 void PaintItem( const Rectangle
& rRect
, SvLBoxItem
* pItem
,
269 SvLBoxEntry
* pEntry
, USHORT nPaintFlags
, OutputDevice
* pOut
= 0 );
270 // berechnet alle BoundingRects neu, wenn bMustRecalcBoundingRects == TRUE
271 void CheckBoundingRects() { if (bMustRecalcBoundingRects
) RecalcAllBoundingRects(); }
272 // berechnet alle invalidierten BoundingRects neu
273 void UpdateBoundingRects();
274 void ShowTargetEmphasis( SvLBoxEntry
* pEntry
, BOOL bShow
);
275 SvLBoxEntry
* GetDropTarget( const Point
& rPosPixel
);
276 BOOL
NotifyMoving( SvLBoxEntry
* pTarget
, SvLBoxEntry
* pEntry
,
277 SvLBoxEntry
*& rpNewParent
, ULONG
& rNewChildPos
);
278 BOOL
NotifyCopying( SvLBoxEntry
* pTarget
, SvLBoxEntry
* pEntry
,
279 SvLBoxEntry
*& rpNewParent
, ULONG
& rNewChildPos
);
281 void WriteDragServerInfo( const Point
&, SvLBoxDDInfo
* );
282 void ReadDragServerInfo( const Point
&, SvLBoxDDInfo
* );
283 void ToTop( SvLBoxEntry
* );
285 void SetCurParent( SvLBoxEntry
* pNewParent
);
286 SvLBoxEntry
* GetCurParent() const { return pCurParent
; }
287 USHORT
GetSelectionCount() const;
288 void SetGrid( long nDX
, long nDY
);
289 void Scroll( long nDeltaX
, long nDeltaY
, BOOL bScrollBar
= FALSE
);
290 const Size
& GetItemSize( SvIconView
* pView
, SvLBoxEntry
*, SvLBoxItem
*,
291 const SvIcnVwDataEntry
* pViewData
= 0 ) const;
292 void PrepareCommandEvent( const Point
& rPt
);
295 void ShowDDIcon( SvLBoxEntry
* pRefEntry
, const Point
& rPos
);
296 void HideShowDDIcon( SvLBoxEntry
* pRefEntry
, const Point
& rPos
);
298 SvLBoxEntry
* mpViewData
;
300 BOOL
IsOver( SvPtrarr
* pSelectedRectList
, const Rectangle
& rEntryBoundRect
) const;
301 void SelectRect( const Rectangle
&, BOOL bAdd
= TRUE
,
302 SvPtrarr
* pOtherRects
= 0,
303 short nOffs
= SELRECT_BORDER_OFFS
);
304 void DrawSelectionRect( const Rectangle
& );
305 void HideSelectionRect();
306 void CalcScrollOffsets( const Point
& rRefPosPixel
,
307 long& rX
, long& rY
, BOOL bDragDrop
= FALSE
,
308 USHORT nBorderWidth
= 10 );
310 BOOL
IsTextHit( SvLBoxEntry
* pEntry
, const Point
& rDocPos
);
311 void MakeVisible( const Rectangle
& rDocPos
,BOOL bInScrollBarEvent
=FALSE
);
312 void AdjustAtGrid( SvLBoxEntry
* pStart
= 0 );
313 void SetTextMode( SvIconViewTextMode
, SvLBoxEntry
* pEntry
= 0 );
314 SvIconViewTextMode
GetTextMode( const SvLBoxEntry
* pEntry
= 0,
315 const SvIcnVwDataEntry
* pViewData
= 0 ) const;
316 void ShowFocusRect( const SvLBoxEntry
* pEntry
);
319 inline void SvImpIconView::MakeVisible( SvLBoxEntry
* pEntry
)
321 const Rectangle
& rRect
= GetBoundingRect( pEntry
);
322 MakeVisible( rRect
);
327 #endif // #ifndef _SVIMPICN_HXX