summaryrefslogtreecommitdiff
path: root/svtools/source/inc/svimpicn.hxx
blob: 105e81d16f565d7007d204b69505da34ae3649bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 * 
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/
#ifndef _SVIMPICN_HXX
#define _SVIMPICN_HXX

#include <vcl/virdev.hxx>

#include <vcl/scrbar.hxx>
#include <limits.h>

class SvLBoxEntry;
class SvLBoxTreeList;
class SvImpIconView;
class ImpIcnCursor;
class SvPtrarr;

#define PAINTFLAG_HOR_CENTERED	0x0001
#define PAINTFLAG_VER_CENTERED	0x0002

#define SELRECT_BORDER_OFFS	-7
// Flags
#define F_VER_SBARSIZE_WITH_HBAR		0x00000001
#define F_HOR_SBARSIZE_WITH_VBAR		0x00000002
#define F_IGNORE_NEXT_MOUSEMOVE			0x00000004	// OS/2 only
#define F_ENTRY_REMOVED					0x00000008
// ist gesetzt, wenn nach Clear oder Ctor mind. einmal gepaintet wurde
#define F_PAINTED						0x00000010
#define F_ADD_MODE						0x00000020
#define F_MOVING_SIBLING				0x00000040
#define F_SELRECT_VISIBLE				0x00000080
#define F_CMD_ARRIVED					0x00000100
#define F_DRAG_SOURCE					0x00000200
#define F_GRIDMODE						0x00000400
// beim Einfuegen eines Eintrags ergibt sich dessen Position
// durch simples Addieren auf die Position des zuletzt eingefuegten Eintrags
#define F_GRID_INSERT					0x00000800
#define F_DOWN_CTRL						0x00001000
#define F_DOWN_DESELECT					0x00002000
// Hack fuer D&D: Hintergrund des Entries nicht painten
#define F_NO_EMPHASIS					0x00004000
// Selektion per Gummiband
#define F_RUBBERING						0x00008000
#define F_START_EDITTIMER_IN_MOUSEUP	0x00010000

class SvImpIconView
{
    friend class ImpIcnCursor;
    ScrollBar   	aVerSBar;
    ScrollBar   	aHorSBar;
    Rectangle		aCurSelectionRect;
    SvPtrarr		aSelectedRectList;
    MouseEvent		aMouseMoveEvent;
    Timer			aEditTimer;  // fuer Inplace-Editieren
    Timer			aMouseMoveTimer; // generiert MouseMoves bei Gummibandselektion
    // Boundrect des zuletzt eingefuegten Entries
    Rectangle		aPrevBoundRect;
    Size			aOutputSize;		// Pixel
    Size			aVirtOutputSize;    // expandiert automatisch
    Point			aDDLastEntryPos;
    Point			aDDLastRectPos;

    SvLBoxTreeList* pModel;
    SvIconView*		pView;
    ImpIcnCursor*	pImpCursor;
    long			nMaxVirtWidth;      // max.breite aVirtOutputSize
    SvPtrarr*		pZOrderList;
    long			nGridDX,
                    nGridDY;
    long			nHorSBarHeight,
                    nVerSBarWidth;
    int				nViewMode;
    long			nHorDist;
    long			nVerDist;
    long			nMaxBmpWidth;
    long			nMaxBmpHeight;
    long			nMaxTextWidth;
    long			nMaxBoundHeight; // Hoehe des hoechsten BoundRects
    sal_uLong			nFlags;
    sal_uLong			nCurUserEvent;
    SvLBoxEntry*	pCurParent;
    SvLBoxEntry* 	pCursor;
    SvLBoxEntry*	pNextCursor; // wird in MovingEntry gesetzt und ist
                                 // nur in EntryMoved gueltig!
    SvLBoxEntry*	pDDRefEntry;
    VirtualDevice*	pDDDev;
    VirtualDevice*	pDDBufDev;
    VirtualDevice*  pDDTempDev;

    SvIconViewTextMode eTextMode;
    sal_Bool			bMustRecalcBoundingRects;

    void			CheckAllSizes();
    void 			CheckSizes( SvLBoxEntry* pEntry,
                        const SvIcnVwDataEntry* pViewData = 0  );
    void 			ShowCursor( sal_Bool bShow );

    void			SetNextEntryPos(const Point& rPos);
    Point			FindNextEntryPos( const Size& rBoundSize );
    void			ImpArrange();
    void			AdjustVirtSize( const Rectangle& );
    void			ResetVirtSize();
    void			CheckScrollBars();

                    DECL_LINK( ScrollUpDownHdl, ScrollBar * );
                    DECL_LINK( ScrollLeftRightHdl, ScrollBar * );
                    DECL_LINK( MouseMoveTimeoutHdl, Timer* );
                    DECL_LINK( EditTimeoutHdl, Timer* );
                    DECL_LINK( UserEventHdl, void* );
    void			AdjustScrollBars();
    void			PositionScrollBars( long nRealWidth, long nRealHeight );
    void			CalcDocPos( Point& aMousePos );
    sal_Bool			GetResizeRect( Rectangle& );
    void			PaintResizeRect( const Rectangle& );
    SvLBoxEntry*	GetNewCursor();
    void			ToggleSelection( SvLBoxEntry* );
    void			DeselectAllBut( SvLBoxEntry* );
    void			Center( SvLBoxEntry* pEntry, SvIcnVwDataEntry* ) const;
    void			StopEditTimer() { aEditTimer.Stop(); }
    void			StartEditTimer() { aEditTimer.Start(); }
    void 			ImpHideDDIcon();
    void 			ImpDrawXORRect( const Rectangle& rRect );
    void			AddSelectedRect( const Rectangle&, short nOffset = SELRECT_BORDER_OFFS );
    void			ClearSelectedRectList();
    Rectangle		CalcMaxTextRect( const SvLBoxEntry* pEntry,
                                    const SvIcnVwDataEntry* pViewData ) const;

    void			ClipAtVirtOutRect( Rectangle& rRect ) const;
    void 			AdjustAtGrid( const SvPtrarr& rRow, SvLBoxEntry* pStart=0 );
    Point			AdjustAtGrid(
                        const Rectangle& rCenterRect, // "Schwerpunkt" des Objekts (typ. Bmp-Rect)
                        const Rectangle& rBoundRect ) const;
    SvIconViewTextMode GetEntryTextModeSmart( const SvLBoxEntry* pEntry,
                        const SvIcnVwDataEntry* pViewData ) const;

    sal_Bool			CheckVerScrollBar();
    sal_Bool			CheckHorScrollBar();
    void 			CancelUserEvent();

public:

                    SvImpIconView( SvIconView* pView, SvLBoxTreeList*, WinBits nWinStyle );
                    ~SvImpIconView();

    void 			Clear( sal_Bool bInCtor = sal_False );
    void 			SetStyle( const WinBits i_nWinStyle );
    void 			SetModel( SvLBoxTreeList* pTree, SvLBoxEntry* pParent )
                        { pModel = pTree; SetCurParent(pParent); }
    void 			EntryInserted( SvLBoxEntry*);
    void 			RemovingEntry( SvLBoxEntry* pEntry );
    void 			EntryRemoved();
    void 			MovingEntry( SvLBoxEntry* pEntry );
    void 			EntryMoved( SvLBoxEntry* pEntry );
    void 			TreeInserted( SvLBoxEntry* pEntry );
    void 			ChangedFont();
    void 			ModelHasEntryInvalidated( SvListEntry* );
    void 			EntryExpanded( SvLBoxEntry* pEntry );
    void 			EntryCollapsed( SvLBoxEntry* pEntry );
    void 			CollapsingEntry( SvLBoxEntry* pEntry );
    void 			EntrySelected( SvLBoxEntry*, sal_Bool bSelect );

    void 			Paint( const Rectangle& rRect );
    void 			RepaintSelectionItems();
    void 			MouseButtonDown( const MouseEvent& );
    void 			MouseButtonUp( const MouseEvent& );
    void 			MouseMove( const MouseEvent&);
    sal_Bool 			KeyInput( const KeyEvent& );
    void 			Resize();
    void 			GetFocus();
    void 			LoseFocus();
    void 			UpdateAll();
    void 			PaintEntry( SvLBoxEntry* pEntry,
                        SvIcnVwDataEntry* pViewData = 0 );
    void 			PaintEntry( SvLBoxEntry*, const Point&,
                        SvIcnVwDataEntry* pViewData = 0, OutputDevice* pOut = 0);
    void 			SetEntryPosition( SvLBoxEntry* pEntry, const Point& rPos,
                                      sal_Bool bAdjustRow = sal_False,
                                      sal_Bool bCheckScrollBars = sal_False );
    void 			InvalidateEntry( SvLBoxEntry* );
    void 			ViewDataInitialized( SvLBoxEntry* pEntry );
    SvLBoxItem* 	GetItem( SvLBoxEntry*, const Point& rAbsPos );

    void 			SetNoSelection();
    void 			SetDragDropMode( DragDropMode eDDMode );
    void 			SetSelectionMode( SelectionMode eSelMode  );

    void 			SttDrag( const Point& rPos );
    void 			EndDrag();

    SvLBoxEntry* 	GetCurEntry() const { return pCursor; }
    void 			SetCursor( SvLBoxEntry* );

    sal_Bool			IsEntryInView( SvLBoxEntry* );
    SvLBoxEntry* 	GetEntry( const Point& rDocPos );
    SvLBoxEntry*	GetNextEntry( const Point& rDocPos, SvLBoxEntry* pCurEntry );
    SvLBoxEntry*	GetPrevEntry( const Point& rDocPos, SvLBoxEntry* pCurEntry  );

    Point 			GetEntryPosition( SvLBoxEntry* );
    void 			MakeVisible( SvLBoxEntry* pEntry );

    void			Arrange();

    void			SetSpaceBetweenEntries( long nHor, long Ver );
    long			GetHorSpaceBetweenEntries() const { return nHorDist; }
    long			GetVerSpaceBetweenEntries() const { return nVerDist; }

    Rectangle		CalcFocusRect( SvLBoxEntry* );

    Rectangle		CalcBmpRect( SvLBoxEntry*, const Point* pPos = 0,
                        SvIcnVwDataEntry* pViewData=0 );
    Rectangle		CalcTextRect( SvLBoxEntry*, SvLBoxString* pItem = 0,
                                  const Point* pPos = 0,
                                  sal_Bool bForInplaceEdit = sal_False,
                                  SvIcnVwDataEntry* pViewData = 0 );

    long			CalcBoundingWidth( SvLBoxEntry*, const SvIcnVwDataEntry* pViewData = 0) const;
    long			CalcBoundingHeight( SvLBoxEntry*, const SvIcnVwDataEntry* pViewData= 0 ) const;
    Size			CalcBoundingSize( SvLBoxEntry*,
                        SvIcnVwDataEntry* pViewData = 0 ) const;
    void			FindBoundingRect( SvLBoxEntry* pEntry,
                        SvIcnVwDataEntry* pViewData = 0 );
    // berechnet alle BoundRects neu
    void			RecalcAllBoundingRects();
    // berechnet alle ungueltigen BoundRects neu
    void			RecalcAllBoundingRectsSmart();
    const Rectangle&  GetBoundingRect( SvLBoxEntry*,
                        SvIcnVwDataEntry* pViewData=0);
    void			InvalidateBoundingRect( SvLBoxEntry* );
    void			InvalidateBoundingRect( Rectangle& rRect ) { rRect.Right() = LONG_MAX; }
    sal_Bool			IsBoundingRectValid( const Rectangle& rRect ) const { return (sal_Bool)( rRect.Right() != LONG_MAX ); }

    void 			PaintEmphasis( const Rectangle&, sal_Bool bSelected,
                                   sal_Bool bCursored, OutputDevice* pOut = 0 );
    void 			PaintItem( const Rectangle& rRect, SvLBoxItem* pItem,
                        SvLBoxEntry* pEntry, sal_uInt16 nPaintFlags, OutputDevice* pOut = 0 );
    // berechnet alle BoundingRects neu, wenn bMustRecalcBoundingRects == sal_True
    void			CheckBoundingRects() { if (bMustRecalcBoundingRects) RecalcAllBoundingRects(); }
    // berechnet alle invalidierten BoundingRects neu
    void			UpdateBoundingRects();
    void			ShowTargetEmphasis( SvLBoxEntry* pEntry, sal_Bool bShow );
    SvLBoxEntry* 	GetDropTarget( const Point& rPosPixel );
    sal_Bool			NotifyMoving( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
                        SvLBoxEntry*& rpNewParent, sal_uLong& rNewChildPos );
    sal_Bool			NotifyCopying( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
                        SvLBoxEntry*& rpNewParent, sal_uLong& rNewChildPos );

    void 			WriteDragServerInfo( const Point&, SvLBoxDDInfo* );
    void 			ReadDragServerInfo( const Point&, SvLBoxDDInfo* );
    void			ToTop( SvLBoxEntry* );

    void			SetCurParent( SvLBoxEntry* pNewParent );
    SvLBoxEntry* 	GetCurParent() const { return pCurParent; }
    sal_uInt16			GetSelectionCount() const;
    void			SetGrid( long nDX, long nDY );
    void			Scroll( long nDeltaX, long nDeltaY, sal_Bool bScrollBar = sal_False );
    const Size&		GetItemSize( SvIconView* pView, SvLBoxEntry*, SvLBoxItem*,
                        const SvIcnVwDataEntry* pViewData = 0 ) const;
    void			PrepareCommandEvent( const Point& rPt );

    void 			HideDDIcon();
    void 			ShowDDIcon( SvLBoxEntry* pRefEntry, const Point& rPos );
    void			HideShowDDIcon( SvLBoxEntry* pRefEntry, const Point& rPos );

    SvLBoxEntry* 	mpViewData;

    sal_Bool			IsOver(	SvPtrarr* pSelectedRectList, const Rectangle& rEntryBoundRect ) const;
    void			SelectRect( const Rectangle&, sal_Bool bAdd = sal_True,
                        SvPtrarr* pOtherRects = 0,
                        short nOffs = SELRECT_BORDER_OFFS );
    void			DrawSelectionRect( const Rectangle& );
    void			HideSelectionRect();
    void			CalcScrollOffsets( const Point& rRefPosPixel,
                        long& rX, long& rY, sal_Bool bDragDrop = sal_False,
                        sal_uInt16 nBorderWidth = 10 );
    void			EndTracking();
    sal_Bool			IsTextHit( SvLBoxEntry* pEntry, const Point& rDocPos );
    void			MakeVisible( const Rectangle& rDocPos,sal_Bool bInScrollBarEvent=sal_False);
    void			AdjustAtGrid( SvLBoxEntry* pStart = 0 );
    void			SetTextMode( SvIconViewTextMode, SvLBoxEntry* pEntry = 0 );
    SvIconViewTextMode GetTextMode( const SvLBoxEntry* pEntry = 0,
                    const SvIcnVwDataEntry* pViewData = 0 ) const;
    void			ShowFocusRect( const SvLBoxEntry* pEntry );
};

inline void SvImpIconView::MakeVisible( SvLBoxEntry* pEntry )
{
    const Rectangle& rRect = GetBoundingRect( pEntry );
    MakeVisible( rRect );
}

#endif // #ifndef _SVIMPICN_HXX


/* vim:set shiftwidth=4 softtabstop=4 expandtab: */