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>
48 #define PAINTFLAG_HOR_CENTERED 0x0001
49 #define PAINTFLAG_VER_CENTERED 0x0002
51 #define SELRECT_BORDER_OFFS -7
53 #define F_VER_SBARSIZE_WITH_HBAR 0x00000001
54 #define F_HOR_SBARSIZE_WITH_VBAR 0x00000002
55 #define F_IGNORE_NEXT_MOUSEMOVE 0x00000004 // OS/2 only
56 #define F_ENTRY_REMOVED 0x00000008
57 // ist gesetzt, wenn nach Clear oder Ctor mind. einmal gepaintet wurde
58 #define F_PAINTED 0x00000010
59 #define F_ADD_MODE 0x00000020
60 #define F_MOVING_SIBLING 0x00000040
61 #define F_SELRECT_VISIBLE 0x00000080
62 #define F_CMD_ARRIVED 0x00000100
63 #define F_DRAG_SOURCE 0x00000200
64 #define F_GRIDMODE 0x00000400
65 // beim Einfuegen eines Eintrags ergibt sich dessen Position
66 // durch simples Addieren auf die Position des zuletzt eingefuegten Eintrags
67 #define F_GRID_INSERT 0x00000800
68 #define F_DOWN_CTRL 0x00001000
69 #define F_DOWN_DESELECT 0x00002000
70 // Hack fuer D&D: Hintergrund des Entries nicht painten
71 #define F_NO_EMPHASIS 0x00004000
72 // Selektion per Gummiband
73 #define F_RUBBERING 0x00008000
74 #define F_START_EDITTIMER_IN_MOUSEUP 0x00010000
78 friend class ImpIcnCursor
;
81 Rectangle aCurSelectionRect
;
82 SvPtrarr aSelectedRectList
;
83 MouseEvent aMouseMoveEvent
;
84 Timer aEditTimer
; // fuer Inplace-Editieren
85 Timer aMouseMoveTimer
; // generiert MouseMoves bei Gummibandselektion
86 // Boundrect des zuletzt eingefuegten Entries
87 Rectangle aPrevBoundRect
;
88 Size aOutputSize
; // Pixel
89 Size aVirtOutputSize
; // expandiert automatisch
90 Point aDDLastEntryPos
;
93 SvLBoxTreeList
* pModel
;
95 ImpIcnCursor
* pImpCursor
;
96 long nMaxVirtWidth
; // max.breite aVirtOutputSize
97 SvPtrarr
* pZOrderList
;
109 long nMaxBoundHeight
; // Hoehe des hoechsten BoundRects
112 SvLBoxEntry
* pCurParent
;
113 SvLBoxEntry
* pCursor
;
114 SvLBoxEntry
* pNextCursor
; // wird in MovingEntry gesetzt und ist
115 // nur in EntryMoved gueltig!
116 SvLBoxEntry
* pDDRefEntry
;
117 VirtualDevice
* pDDDev
;
118 VirtualDevice
* pDDBufDev
;
119 VirtualDevice
* pDDTempDev
;
121 SvIconViewTextMode eTextMode
;
122 BOOL bMustRecalcBoundingRects
;
124 void CheckAllSizes();
125 void CheckSizes( SvLBoxEntry
* pEntry
,
126 const SvIcnVwDataEntry
* pViewData
= 0 );
127 void ShowCursor( BOOL bShow
);
129 void SetNextEntryPos(const Point
& rPos
);
130 Point
FindNextEntryPos( const Size
& rBoundSize
);
132 void AdjustVirtSize( const Rectangle
& );
133 void ResetVirtSize();
134 void CheckScrollBars();
136 DECL_LINK( ScrollUpDownHdl
, ScrollBar
* );
137 DECL_LINK( ScrollLeftRightHdl
, ScrollBar
* );
138 DECL_LINK( MouseMoveTimeoutHdl
, Timer
* );
139 DECL_LINK( EditTimeoutHdl
, Timer
* );
140 DECL_LINK( UserEventHdl
, void* );
141 void AdjustScrollBars();
142 void PositionScrollBars( long nRealWidth
, long nRealHeight
);
143 void CalcDocPos( Point
& aMousePos
);
144 BOOL
GetResizeRect( Rectangle
& );
145 void PaintResizeRect( const Rectangle
& );
146 SvLBoxEntry
* GetNewCursor();
147 void ToggleSelection( SvLBoxEntry
* );
148 void DeselectAllBut( SvLBoxEntry
* );
149 void Center( SvLBoxEntry
* pEntry
, SvIcnVwDataEntry
* ) const;
150 void StopEditTimer() { aEditTimer
.Stop(); }
151 void StartEditTimer() { aEditTimer
.Start(); }
152 void ImpHideDDIcon();
153 void ImpDrawXORRect( const Rectangle
& rRect
);
154 void AddSelectedRect( const Rectangle
&, short nOffset
= SELRECT_BORDER_OFFS
);
155 void ClearSelectedRectList();
156 Rectangle
CalcMaxTextRect( const SvLBoxEntry
* pEntry
,
157 const SvIcnVwDataEntry
* pViewData
) const;
159 void ClipAtVirtOutRect( Rectangle
& rRect
) const;
160 void AdjustAtGrid( const SvPtrarr
& rRow
, SvLBoxEntry
* pStart
=0 );
162 const Rectangle
& rCenterRect
, // "Schwerpunkt" des Objekts (typ. Bmp-Rect)
163 const Rectangle
& rBoundRect
) const;
164 SvIconViewTextMode
GetEntryTextModeSmart( const SvLBoxEntry
* pEntry
,
165 const SvIcnVwDataEntry
* pViewData
) const;
167 BOOL
CheckVerScrollBar();
168 BOOL
CheckHorScrollBar();
169 void CancelUserEvent();
173 SvImpIconView( SvIconView
* pView
, SvLBoxTreeList
*, WinBits nWinStyle
);
176 void Clear( BOOL bInCtor
= FALSE
);
177 void SetWindowBits( WinBits nWinStyle
);
178 void SetModel( SvLBoxTreeList
* pTree
, SvLBoxEntry
* pParent
)
179 { pModel
= pTree
; SetCurParent(pParent
); }
180 void EntryInserted( SvLBoxEntry
*);
181 void RemovingEntry( SvLBoxEntry
* pEntry
);
183 void MovingEntry( SvLBoxEntry
* pEntry
);
184 void EntryMoved( SvLBoxEntry
* pEntry
);
185 void TreeInserted( SvLBoxEntry
* pEntry
);
187 void ModelHasEntryInvalidated( SvListEntry
* );
188 void EntryExpanded( SvLBoxEntry
* pEntry
);
189 void EntryCollapsed( SvLBoxEntry
* pEntry
);
190 void CollapsingEntry( SvLBoxEntry
* pEntry
);
191 void EntrySelected( SvLBoxEntry
*, BOOL bSelect
);
193 void Paint( const Rectangle
& rRect
);
194 void RepaintSelectionItems();
195 void MouseButtonDown( const MouseEvent
& );
196 void MouseButtonUp( const MouseEvent
& );
197 void MouseMove( const MouseEvent
&);
198 BOOL
KeyInput( const KeyEvent
& );
203 void PaintEntry( SvLBoxEntry
* pEntry
,
204 SvIcnVwDataEntry
* pViewData
= 0 );
205 void PaintEntry( SvLBoxEntry
*, const Point
&,
206 SvIcnVwDataEntry
* pViewData
= 0, OutputDevice
* pOut
= 0);
207 void SetEntryPosition( SvLBoxEntry
* pEntry
, const Point
& rPos
,
208 BOOL bAdjustRow
= FALSE
,
209 BOOL bCheckScrollBars
= FALSE
);
210 void InvalidateEntry( SvLBoxEntry
* );
211 void ViewDataInitialized( SvLBoxEntry
* pEntry
);
212 SvLBoxItem
* GetItem( SvLBoxEntry
*, const Point
& rAbsPos
);
214 void SetNoSelection();
215 void SetDragDropMode( DragDropMode eDDMode
);
216 void SetSelectionMode( SelectionMode eSelMode
);
218 void SttDrag( const Point
& rPos
);
221 SvLBoxEntry
* GetCurEntry() const { return pCursor
; }
222 void SetCursor( SvLBoxEntry
* );
224 BOOL
IsEntryInView( SvLBoxEntry
* );
225 SvLBoxEntry
* GetEntry( const Point
& rDocPos
);
226 SvLBoxEntry
* GetNextEntry( const Point
& rDocPos
, SvLBoxEntry
* pCurEntry
);
227 SvLBoxEntry
* GetPrevEntry( const Point
& rDocPos
, SvLBoxEntry
* pCurEntry
);
229 Point
GetEntryPosition( SvLBoxEntry
* );
230 void MakeVisible( SvLBoxEntry
* pEntry
);
234 void SetSpaceBetweenEntries( long nHor
, long Ver
);
235 long GetHorSpaceBetweenEntries() const { return nHorDist
; }
236 long GetVerSpaceBetweenEntries() const { return nVerDist
; }
238 Rectangle
CalcFocusRect( SvLBoxEntry
* );
240 Rectangle
CalcBmpRect( SvLBoxEntry
*, const Point
* pPos
= 0,
241 SvIcnVwDataEntry
* pViewData
=0 );
242 Rectangle
CalcTextRect( SvLBoxEntry
*, SvLBoxString
* pItem
= 0,
243 const Point
* pPos
= 0,
244 BOOL bForInplaceEdit
= FALSE
,
245 SvIcnVwDataEntry
* pViewData
= 0 );
247 long CalcBoundingWidth( SvLBoxEntry
*, const SvIcnVwDataEntry
* pViewData
= 0) const;
248 long CalcBoundingHeight( SvLBoxEntry
*, const SvIcnVwDataEntry
* pViewData
= 0 ) const;
249 Size
CalcBoundingSize( SvLBoxEntry
*,
250 SvIcnVwDataEntry
* pViewData
= 0 ) const;
251 void FindBoundingRect( SvLBoxEntry
* pEntry
,
252 SvIcnVwDataEntry
* pViewData
= 0 );
253 // berechnet alle BoundRects neu
254 void RecalcAllBoundingRects();
255 // berechnet alle ungueltigen BoundRects neu
256 void RecalcAllBoundingRectsSmart();
257 const Rectangle
& GetBoundingRect( SvLBoxEntry
*,
258 SvIcnVwDataEntry
* pViewData
=0);
259 void InvalidateBoundingRect( SvLBoxEntry
* );
260 void InvalidateBoundingRect( Rectangle
& rRect
) { rRect
.Right() = LONG_MAX
; }
261 BOOL
IsBoundingRectValid( const Rectangle
& rRect
) const { return (BOOL
)( rRect
.Right() != LONG_MAX
); }
263 void PaintEmphasis( const Rectangle
&, BOOL bSelected
,
264 BOOL bCursored
, OutputDevice
* pOut
= 0 );
265 void PaintItem( const Rectangle
& rRect
, SvLBoxItem
* pItem
,
266 SvLBoxEntry
* pEntry
, USHORT nPaintFlags
, OutputDevice
* pOut
= 0 );
267 // berechnet alle BoundingRects neu, wenn bMustRecalcBoundingRects == TRUE
268 void CheckBoundingRects() { if (bMustRecalcBoundingRects
) RecalcAllBoundingRects(); }
269 // berechnet alle invalidierten BoundingRects neu
270 void UpdateBoundingRects();
271 void ShowTargetEmphasis( SvLBoxEntry
* pEntry
, BOOL bShow
);
272 SvLBoxEntry
* GetDropTarget( const Point
& rPosPixel
);
273 BOOL
NotifyMoving( SvLBoxEntry
* pTarget
, SvLBoxEntry
* pEntry
,
274 SvLBoxEntry
*& rpNewParent
, ULONG
& rNewChildPos
);
275 BOOL
NotifyCopying( SvLBoxEntry
* pTarget
, SvLBoxEntry
* pEntry
,
276 SvLBoxEntry
*& rpNewParent
, ULONG
& rNewChildPos
);
278 void WriteDragServerInfo( const Point
&, SvLBoxDDInfo
* );
279 void ReadDragServerInfo( const Point
&, SvLBoxDDInfo
* );
280 void ToTop( SvLBoxEntry
* );
282 void SetCurParent( SvLBoxEntry
* pNewParent
);
283 SvLBoxEntry
* GetCurParent() const { return pCurParent
; }
284 USHORT
GetSelectionCount() const;
285 void SetGrid( long nDX
, long nDY
);
286 void Scroll( long nDeltaX
, long nDeltaY
, BOOL bScrollBar
= FALSE
);
287 const Size
& GetItemSize( SvIconView
* pView
, SvLBoxEntry
*, SvLBoxItem
*,
288 const SvIcnVwDataEntry
* pViewData
= 0 ) const;
289 void PrepareCommandEvent( const Point
& rPt
);
292 void ShowDDIcon( SvLBoxEntry
* pRefEntry
, const Point
& rPos
);
293 void HideShowDDIcon( SvLBoxEntry
* pRefEntry
, const Point
& rPos
);
295 SvLBoxEntry
* mpViewData
;
297 BOOL
IsOver( SvPtrarr
* pSelectedRectList
, const Rectangle
& rEntryBoundRect
) const;
298 void SelectRect( const Rectangle
&, BOOL bAdd
= TRUE
,
299 SvPtrarr
* pOtherRects
= 0,
300 short nOffs
= SELRECT_BORDER_OFFS
);
301 void DrawSelectionRect( const Rectangle
& );
302 void HideSelectionRect();
303 void CalcScrollOffsets( const Point
& rRefPosPixel
,
304 long& rX
, long& rY
, BOOL bDragDrop
= FALSE
,
305 USHORT nBorderWidth
= 10 );
307 BOOL
IsTextHit( SvLBoxEntry
* pEntry
, const Point
& rDocPos
);
308 void MakeVisible( const Rectangle
& rDocPos
,BOOL bInScrollBarEvent
=FALSE
);
309 void AdjustAtGrid( SvLBoxEntry
* pStart
= 0 );
310 void SetTextMode( SvIconViewTextMode
, SvLBoxEntry
* pEntry
= 0 );
311 SvIconViewTextMode
GetTextMode( const SvLBoxEntry
* pEntry
= 0,
312 const SvIcnVwDataEntry
* pViewData
= 0 ) const;
313 void ShowFocusRect( const SvLBoxEntry
* pEntry
);
316 inline void SvImpIconView::MakeVisible( SvLBoxEntry
* pEntry
)
318 const Rectangle
& rRect
= GetBoundingRect( pEntry
);
319 MakeVisible( rRect
);
322 #endif // #ifndef _SVIMPICN_HXX