xref: /aoo42x/main/svtools/source/contnr/svicnvw.cxx (revision 5900e8ec)
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 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svtools.hxx"
26 
27 #include <svtools/svlbox.hxx>
28 #include <svtools/svicnvw.hxx>
29 #include <svimpicn.hxx>
30 #include <svtools/svlbitm.hxx>
31 
32 #ifndef GCC
33 #endif
34 
35 #define ICNVW_BLOCK_ENTRYINS	0x0001
36 
SvIcnVwDataEntry()37 SvIcnVwDataEntry::SvIcnVwDataEntry()
38 	: nIcnVwFlags(0),eTextMode(ShowTextDontKnow)
39 {
40 }
41 
~SvIcnVwDataEntry()42 SvIcnVwDataEntry::~SvIcnVwDataEntry()
43 {
44 }
45 
SvIconView(Window * pParent,WinBits nWinStyle)46 SvIconView::SvIconView( Window* pParent, WinBits nWinStyle ) :
47 	SvLBox( pParent, nWinStyle | WB_BORDER )
48 {
49 	nIcnVwFlags = 0;
50 	pImp = new SvImpIconView( this, GetModel(), nWinStyle | WB_ICON );
51 	pImp->mpViewData = 0;
52 	SetSelectionMode( SINGLE_SELECTION );
53 	SetLineColor();
54 	const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
55 	SetBackground( Wallpaper( rStyleSettings.GetFieldColor() ) );
56 	SetDefaultFont();
57 }
58 
SvIconView(Window * pParent,const ResId & rResId)59 SvIconView::SvIconView( Window* pParent , const ResId& rResId ) :
60 	SvLBox( pParent, rResId )
61 {
62 	pImp = new SvImpIconView( this, GetModel(), WB_BORDER | WB_ICON );
63 	nIcnVwFlags = 0;
64 	pImp->mpViewData = 0;
65 	SetLineColor();
66 	const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
67 	SetBackground( Wallpaper( rStyleSettings.GetFieldColor() ) );
68 	SetDefaultFont();
69 	pImp->SetSelectionMode( GetSelectionMode() );
70 }
71 
~SvIconView()72 SvIconView::~SvIconView()
73 {
74 	delete pImp;
75 }
76 
SetDefaultFont()77 void SvIconView::SetDefaultFont()
78 {
79 	SetFont( GetFont() );
80 }
81 
CreateEntry(const XubString & rStr,const Image & rCollEntryBmp,const Image & rExpEntryBmp)82 SvLBoxEntry* SvIconView::CreateEntry( const XubString& rStr,
83 	const Image& rCollEntryBmp, const Image& rExpEntryBmp )
84 {
85 	SvLBoxEntry* pEntry = new SvLBoxEntry;
86 
87 	SvLBoxContextBmp* pContextBmp =
88 	  new SvLBoxContextBmp( pEntry,0, rCollEntryBmp,rExpEntryBmp, 0xffff );
89 	pEntry->AddItem( pContextBmp );
90 
91 	SvLBoxString* pString = new SvLBoxString( pEntry, 0, rStr );
92 	pEntry->AddItem( pString );
93 
94 	return pEntry;
95 }
96 
DisconnectFromModel()97 void SvIconView::DisconnectFromModel()
98 {
99 	SvLBox::DisconnectFromModel();
100 	pImp->SetModel( GetModel(), 0 );
101 }
102 
103 
InsertEntry(const XubString & rText,SvLBoxEntry * pParent,sal_Bool bChildsOnDemand,sal_uLong nPos)104 SvLBoxEntry* SvIconView::InsertEntry( const XubString& rText,
105 	SvLBoxEntry* pParent, sal_Bool bChildsOnDemand, sal_uLong nPos )
106 {
107 	SvLBoxEntry* pEntry = CreateEntry(
108 		rText, aCollapsedEntryBmp, aExpandedEntryBmp );
109 	pEntry->EnableChildsOnDemand( bChildsOnDemand );
110 
111 	if ( !pParent )
112 		SvLBox::Insert( pEntry, nPos );
113 	else
114 		SvLBox::Insert( pEntry, pParent, nPos );
115 	return pEntry;
116 }
117 
InsertEntry(const XubString & rText,const Image & rExpEntryBmp,const Image & rCollEntryBmp,SvLBoxEntry * pParent,sal_Bool bChildsOnDemand,sal_uLong nPos)118 SvLBoxEntry* SvIconView::InsertEntry( const XubString& rText,
119 	const Image& rExpEntryBmp,
120 	const Image& rCollEntryBmp,
121 	SvLBoxEntry* pParent, sal_Bool bChildsOnDemand, sal_uLong nPos)
122 {
123 	SvLBoxEntry* pEntry = CreateEntry(
124 		rText, rCollEntryBmp, rExpEntryBmp );
125 
126 	pEntry->EnableChildsOnDemand( bChildsOnDemand );
127 	if ( !pParent )
128 		SvLBox::Insert( pEntry, nPos );
129 	else
130 		SvLBox::Insert( pEntry, pParent, nPos );
131 	return pEntry;
132 }
133 
134 
SetEntryText(SvLBoxEntry * pEntry,const XubString & rStr)135 void SvIconView::SetEntryText(SvLBoxEntry* pEntry, const XubString& rStr)
136 {
137 	SvLBoxString* pItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
138 	if ( pItem )
139 	{
140 		pItem->SetText( pEntry, rStr );
141 		GetModel()->InvalidateEntry( pEntry );
142 	}
143 }
144 
SetExpandedEntryBmp(SvLBoxEntry * pEntry,const Image & rBmp)145 void SvIconView::SetExpandedEntryBmp(SvLBoxEntry* pEntry, const Image& rBmp)
146 {
147 	SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
148 	if ( pItem )
149 	{
150 		pItem->SetBitmap2( rBmp );
151 		GetModel()->InvalidateEntry( pEntry );
152 	}
153 }
154 
SetCollapsedEntryBmp(SvLBoxEntry * pEntry,const Image & rBmp)155 void SvIconView::SetCollapsedEntryBmp(SvLBoxEntry* pEntry,
156 	const Image& rBmp )
157 {
158 	SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
159 	if ( pItem )
160 	{
161 		pItem->SetBitmap1( rBmp );
162 		GetModel()->InvalidateEntry( pEntry );
163 	}
164 }
165 
GetEntryText(SvLBoxEntry * pEntry) const166 XubString SvIconView::GetEntryText(SvLBoxEntry* pEntry ) const
167 {
168 	XubString aStr;
169 	SvLBoxString* pItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
170 	if ( pItem )
171 		aStr = pItem->GetText();
172 	return aStr;
173 }
174 
GetExpandedEntryBmp(SvLBoxEntry * pEntry) const175 Image SvIconView::GetExpandedEntryBmp(SvLBoxEntry* pEntry) const
176 {
177 	Image aBmp;
178 	SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
179 	if ( pItem )
180 		aBmp = pItem->GetBitmap2();
181 	return aBmp;
182 }
183 
GetCollapsedEntryBmp(SvLBoxEntry * pEntry) const184 Image SvIconView::GetCollapsedEntryBmp(SvLBoxEntry* pEntry) const
185 {
186 	Image aBmp;
187 	SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
188 	if ( pItem )
189 		aBmp = pItem->GetBitmap1();
190 	return aBmp;
191 }
192 
193 
CloneEntry(SvLBoxEntry * pSource)194 SvLBoxEntry* SvIconView::CloneEntry( SvLBoxEntry* pSource )
195 {
196 	XubString aStr;
197 	Image aCollEntryBmp;
198 	Image aExpEntryBmp;
199 
200 	SvLBoxString* pStringItem = (SvLBoxString*)(pSource->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
201 	if ( pStringItem )
202 		aStr = pStringItem->GetText();
203 	SvLBoxContextBmp* pBmpItem =(SvLBoxContextBmp*)(pSource->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
204 	if ( pBmpItem )
205 	{
206 		aCollEntryBmp = pBmpItem->GetBitmap1();
207 		aExpEntryBmp  = pBmpItem->GetBitmap2();
208 	}
209 	SvLBoxEntry* pEntry = CreateEntry( aStr, aCollEntryBmp, aExpEntryBmp );
210 	pEntry->SvListEntry::Clone( pSource );
211 	pEntry->EnableChildsOnDemand( pSource->HasChildsOnDemand() );
212 	pEntry->SetUserData( pSource->GetUserData() );
213 	return pEntry;
214 }
215 
216 
IsA()217 sal_uInt16 SvIconView::IsA()
218 {
219 	return SV_LISTBOX_ID_ICONVIEW;
220 }
221 
RequestingChilds(SvLBoxEntry * pParent)222 void SvIconView::RequestingChilds( SvLBoxEntry* pParent )
223 {
224 	if ( !pParent->HasChilds() )
225 		InsertEntry( String::CreateFromAscii("<dummy>"), pParent, sal_False, LIST_APPEND );
226 }
227 
Paint(const Rectangle & rRect)228 void __EXPORT SvIconView::Paint( const Rectangle& rRect )
229 {
230 	pImp->Paint( rRect );
231 }
232 
MouseButtonDown(const MouseEvent & rMEvt)233 void __EXPORT SvIconView::MouseButtonDown( const MouseEvent& rMEvt )
234 {
235 	pImp->MouseButtonDown( rMEvt );
236 }
237 
MouseButtonUp(const MouseEvent & rMEvt)238 void __EXPORT SvIconView::MouseButtonUp( const MouseEvent& rMEvt )
239 {
240 	pImp->MouseButtonUp( rMEvt );
241 }
242 
MouseMove(const MouseEvent & rMEvt)243 void __EXPORT SvIconView::MouseMove( const MouseEvent& rMEvt )
244 {
245 	pImp->MouseMove( rMEvt );
246 }
247 
KeyInput(const KeyEvent & rKEvt)248 void __EXPORT SvIconView::KeyInput( const KeyEvent& rKEvt )
249 {
250 	// unter OS/2 bekommen wir auch beim Editieren Key-Up/Down
251 	if( IsEditingActive() )
252 		return;
253 
254 	nImpFlags |= SVLBOX_IS_TRAVELSELECT;
255 	sal_Bool bKeyUsed = pImp->KeyInput( rKEvt );
256 	if ( !bKeyUsed )
257 		SvLBox::KeyInput( rKEvt );
258 	nImpFlags &= ~SVLBOX_IS_TRAVELSELECT;
259 }
260 
Resize()261 void __EXPORT SvIconView::Resize()
262 {
263 	pImp->Resize();
264 	SvLBox::Resize();
265 }
266 
GetFocus()267 void __EXPORT SvIconView::GetFocus()
268 {
269 	pImp->GetFocus();
270 	SvLBox::GetFocus();
271 }
272 
LoseFocus()273 void __EXPORT SvIconView::LoseFocus()
274 {
275 	pImp->LoseFocus();
276 	SvLBox::LoseFocus();
277 }
278 
SetUpdateMode(sal_Bool bUpdate)279 void SvIconView::SetUpdateMode( sal_Bool bUpdate )
280 {
281 	Control::SetUpdateMode( bUpdate );
282 	if ( bUpdate )
283 		pImp->UpdateAll();
284 }
285 
SetModel(SvLBoxTreeList *)286 void SvIconView::SetModel( SvLBoxTreeList* )
287 {
288 }
289 
SetModel(SvLBoxTreeList * pNewModel,SvLBoxEntry * pParent)290 void SvIconView::SetModel( SvLBoxTreeList* pNewModel, SvLBoxEntry* pParent )
291 {
292 	nIcnVwFlags |= ICNVW_BLOCK_ENTRYINS;
293 	SvLBox::SetModel( pNewModel );
294 	nIcnVwFlags &= (~ICNVW_BLOCK_ENTRYINS);
295 	if ( pParent && pParent->HasChildsOnDemand() )
296 		RequestingChilds( pParent );
297 	pImp->SetModel( pNewModel, pParent );
298 }
299 
ModelHasCleared()300 void __EXPORT SvIconView::ModelHasCleared()
301 {
302 	SvLBox::ModelHasCleared();
303 	pImp->Clear();
304 }
305 
ModelHasInserted(SvListEntry * pEntry)306 void __EXPORT SvIconView::ModelHasInserted( SvListEntry* pEntry )
307 {
308 	if( !(nIcnVwFlags & ICNVW_BLOCK_ENTRYINS ) )
309 		pImp->EntryInserted( (SvLBoxEntry*)pEntry );
310 }
311 
ModelHasInsertedTree(SvListEntry * pEntry)312 void __EXPORT SvIconView::ModelHasInsertedTree( SvListEntry* pEntry )
313 {
314 	pImp->TreeInserted( (SvLBoxEntry*)pEntry );
315 }
316 
ModelIsMoving(SvListEntry * pSource,SvListEntry *,sal_uLong)317 void __EXPORT SvIconView::ModelIsMoving(SvListEntry* pSource,
318 		SvListEntry* /* pTargetParent */ , sal_uLong /* nChildPos */ )
319 {
320 	pImp->MovingEntry( (SvLBoxEntry*)pSource );
321 }
322 
ModelHasMoved(SvListEntry * pSource)323 void __EXPORT SvIconView::ModelHasMoved(SvListEntry* pSource )
324 {
325 	pImp->EntryMoved( (SvLBoxEntry*)pSource );
326 }
327 
ModelIsRemoving(SvListEntry * pEntry)328 void __EXPORT SvIconView::ModelIsRemoving( SvListEntry* pEntry )
329 {
330 	pImp->RemovingEntry( (SvLBoxEntry*)pEntry );
331 	NotifyRemoving( (SvLBoxEntry*)pEntry );
332 }
333 
ModelHasRemoved(SvListEntry *)334 void __EXPORT SvIconView::ModelHasRemoved( SvListEntry* /* pEntry */ )
335 {
336 	pImp->EntryRemoved();
337 }
338 
ModelHasEntryInvalidated(SvListEntry * pEntry)339 void __EXPORT SvIconView::ModelHasEntryInvalidated( SvListEntry* pEntry )
340 {
341 	// die einzelnen Items des Entries reinitialisieren
342 	SvLBox::ModelHasEntryInvalidated( pEntry );
343 	// painten
344 	pImp->ModelHasEntryInvalidated( pEntry );
345 }
346 
ShowTargetEmphasis(SvLBoxEntry * pEntry,sal_Bool bShow)347 void SvIconView::ShowTargetEmphasis( SvLBoxEntry* pEntry, sal_Bool bShow )
348 {
349 	pImp->ShowTargetEmphasis( pEntry, bShow );
350 }
351 
GetEntryPosition(SvLBoxEntry * pEntry) const352 Point SvIconView::GetEntryPosition( SvLBoxEntry* pEntry ) const
353 {
354 	return ((SvIconView*)this)->pImp->GetEntryPosition( pEntry );
355 }
356 
SetEntryPosition(SvLBoxEntry * pEntry,const Point & rPos)357 void SvIconView::SetEntryPosition( SvLBoxEntry* pEntry, const Point& rPos)
358 {
359 	pImp->SetEntryPosition( pEntry, rPos, sal_False, sal_True );
360 }
361 
SetEntryPosition(SvLBoxEntry * pEntry,const Point & rPos,sal_Bool bAdjustAtGrid)362 void SvIconView::SetEntryPosition( SvLBoxEntry* pEntry, const Point& rPos, sal_Bool bAdjustAtGrid )
363 {
364 	pImp->SetEntryPosition( pEntry, rPos, bAdjustAtGrid );
365 }
366 
SetFont(const Font & rFont)367 void SvIconView::SetFont( const Font& rFont )
368 {
369 	Font aTempFont( rFont );
370 	aTempFont.SetTransparent( sal_True );
371 	SvLBox::SetFont( aTempFont );
372 	RecalcViewData();
373 	pImp->ChangedFont();
374 }
375 
ViewDataInitialized(SvLBoxEntry * pEntry)376 void SvIconView::ViewDataInitialized( SvLBoxEntry* pEntry )
377 {
378 	pImp->ViewDataInitialized( pEntry );
379 }
380 
GetDropTarget(const Point & rPos)381 SvLBoxEntry* SvIconView::GetDropTarget( const Point& rPos )
382 {
383 	return pImp->GetDropTarget( rPos );
384 }
385 
GetEntry(const Point & rPixPos,sal_Bool) const386 SvLBoxEntry* SvIconView::GetEntry( const Point& rPixPos, sal_Bool ) const
387 {
388 	Point aPos( rPixPos );
389 	aPos -= GetMapMode().GetOrigin();
390 	return ((SvIconView*)this)->pImp->GetEntry( aPos );
391 }
392 
GetEntryFromLogicPos(const Point & rDocPos) const393 SvLBoxEntry* SvIconView::GetEntryFromLogicPos( const Point& rDocPos ) const
394 {
395 	return ((SvIconView*)this)->pImp->GetEntry( rDocPos );
396 }
397 
398 
StateChanged(StateChangedType i_nStateChange)399 void SvIconView::StateChanged( StateChangedType i_nStateChange )
400 {
401     SvLBox::StateChanged( i_nStateChange );
402     if ( i_nStateChange == STATE_CHANGE_STYLE )
403 	    pImp->SetStyle( GetStyle() );
404 }
405 
PaintEntry(SvLBoxEntry * pEntry)406 void SvIconView::PaintEntry( SvLBoxEntry* pEntry )
407 {
408 	pImp->PaintEntry( pEntry );
409 }
410 
411 
PaintEntry(SvLBoxEntry * pEntry,const Point & rPos)412 void SvIconView::PaintEntry( SvLBoxEntry* pEntry, const Point& rPos )
413 {
414 	pImp->PaintEntry( pEntry, rPos );
415 }
416 
GetFocusRect(SvLBoxEntry * pEntry)417 Rectangle SvIconView::GetFocusRect( SvLBoxEntry* pEntry )
418 {
419 	return pImp->CalcFocusRect( pEntry );
420 }
421 
InvalidateEntry(SvLBoxEntry * pEntry)422 void SvIconView::InvalidateEntry( SvLBoxEntry* pEntry )
423 {
424 	pImp->InvalidateEntry( pEntry );
425 }
426 
SetDragDropMode(DragDropMode nDDMode)427 void SvIconView::SetDragDropMode( DragDropMode nDDMode )
428 {
429 	SvLBox::SetDragDropMode( nDDMode );
430 	pImp->SetDragDropMode( nDDMode );
431 }
432 
SetSelectionMode(SelectionMode eSelectMode)433 void SvIconView::SetSelectionMode( SelectionMode eSelectMode )
434 {
435 	SvLBox::SetSelectionMode( eSelectMode );
436 	pImp->SetSelectionMode( eSelectMode );
437 }
438 
Select(SvLBoxEntry * pEntry,sal_Bool bSelect)439 sal_Bool SvIconView::Select( SvLBoxEntry* pEntry, sal_Bool bSelect )
440 {
441 	EndEditing();
442 	sal_Bool bRetVal = SvListView::Select( pEntry, bSelect );
443 	if( bRetVal )
444 	{
445 		pImp->EntrySelected( pEntry, bSelect );
446 		pHdlEntry = pEntry;
447 		SelectHdl();
448 	}
449 	return bRetVal;
450 }
451 
SelectAll(sal_Bool bSelect,sal_Bool)452 void SvIconView::SelectAll( sal_Bool bSelect, sal_Bool )
453 {
454 	SvLBoxEntry* pEntry = pImp->GetCurParent();
455 	pEntry = FirstChild( pEntry );
456 	while( pEntry )
457 	{
458 		Select( pEntry, bSelect );
459 		pEntry = NextSibling( pEntry );
460 	}
461 }
462 
SetCurEntry(SvLBoxEntry * _pEntry)463 void SvIconView::SetCurEntry( SvLBoxEntry* _pEntry )
464 {
465     pImp->SetCursor( _pEntry );
466     OnCurrentEntryChanged();
467 }
468 
GetCurEntry() const469 SvLBoxEntry* SvIconView::GetCurEntry() const
470 {
471 	return pImp->GetCurEntry();
472 }
473 
Arrange()474 void SvIconView::Arrange()
475 {
476 #ifdef DBG_UTIL
477 	sal_uInt16 n=1;
478 	if( n == 1 && n-1 == 0 )
479 	{
480 		pImp->Arrange();
481 	}
482 	else
483 	{
484 		pImp->AdjustAtGrid();
485 	}
486 #else
487 	pImp->Arrange();
488 #endif
489 }
490 
491 
SetSpaceBetweenEntries(long nX,long nY)492 void SvIconView::SetSpaceBetweenEntries( long nX, long nY )
493 {
494 	pImp->SetSpaceBetweenEntries( nX, nY );
495 }
496 
NotifyMoving(SvLBoxEntry * pTarget,SvLBoxEntry * pEntry,SvLBoxEntry * & rpNewParent,sal_uLong & rNewChildPos)497 sal_Bool SvIconView::NotifyMoving( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
498 	SvLBoxEntry*& rpNewParent, sal_uLong& rNewChildPos )
499 {
500 	return pImp->NotifyMoving(pTarget,pEntry,rpNewParent,rNewChildPos);
501 }
502 
NotifyCopying(SvLBoxEntry * pTarget,SvLBoxEntry * pEntry,SvLBoxEntry * & rpNewParent,sal_uLong & rNewChildPos)503 sal_Bool SvIconView::NotifyCopying( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
504 	SvLBoxEntry*& rpNewParent, sal_uLong& rNewChildPos )
505 {
506 	return pImp->NotifyCopying(pTarget,pEntry,rpNewParent,rNewChildPos);
507 }
508 
509 
EnableInplaceEditing(sal_Bool bEnable)510 void SvIconView::EnableInplaceEditing( sal_Bool bEnable )
511 {
512 	SvLBox::EnableInplaceEditing( bEnable );
513 }
514 
EditingRequest(SvLBoxEntry * pEntry,SvLBoxItem * pItem,const Point &)515 void SvIconView::EditingRequest( SvLBoxEntry* pEntry, SvLBoxItem* pItem,
516 								 const Point& )
517 {
518 	if ( pItem->IsA() == SV_ITEM_ID_LBOXSTRING )
519 	{
520 		Selection aSel( SELECTION_MIN, SELECTION_MAX );
521 		if ( EditingEntry( pEntry, aSel ) )
522 		{
523 			SelectAll( sal_False );
524 			EditItemText( pEntry, (SvLBoxString*)pItem, aSel );
525 		}
526 	}
527 }
528 
529 
EditItemText(SvLBoxEntry * pEntry,SvLBoxItem * pItem,const Selection & rSel)530 void SvIconView::EditItemText( SvLBoxEntry* pEntry, SvLBoxItem* pItem,
531 	const Selection& rSel )
532 {
533 	DBG_ASSERT(pEntry&&pItem,"EditItemText:Params?");
534 	pCurEdEntry = pEntry;
535 	pCurEdItem = pItem;
536 	Rectangle aRect( pImp->CalcTextRect( pEntry, (SvLBoxString*)pItem,0,sal_True ));
537 
538 	aRect.Bottom() += 4;
539 	pImp->MakeVisible( aRect ); // vor der Umrechnung in Pixel-Koord. rufen!
540 	aRect.Bottom() -= 4;
541 
542 	Point aPos( aRect.TopLeft() );
543 	aPos += GetMapMode().GetOrigin(); // Dok-Koord. -> Window-Koord.
544 	aRect.SetPos( aPos );
545 
546 	aRect.Bottom() += 2; // sieht huebscher aus
547 
548 #ifdef OS2
549 
550 #if OS2_SINGLE_LINE_EDIT
551 	aRect.Left() -= 3;
552 	aRect.Right() += 3;
553 	aRect.Top() -= 3;
554 	aRect.Bottom() += 3;
555 #else
556 	aRect.Left() -= 10;
557 	aRect.Right() += 10;
558 	aRect.Top() -= 5;
559 	aRect.Bottom() += 5;
560 #endif
561 
562 #endif // OS2
563 	EditText( ((SvLBoxString*)pItem)->GetText(), aRect, rSel, sal_True );
564 }
565 
EditEntry(SvLBoxEntry * pEntry)566 void SvIconView::EditEntry( SvLBoxEntry* pEntry )
567 {
568 	if( !pEntry )
569 		pEntry = pImp->GetCurEntry();
570 	if( pEntry )
571 	{
572 		SvLBoxString* pItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
573 		if( pItem )
574 		{
575 			Selection aSel( SELECTION_MIN, SELECTION_MAX );
576 			if( EditingEntry( pEntry, aSel ) )
577 			{
578 				SelectAll( sal_False );
579 				EditItemText( pEntry, pItem, aSel );
580 			}
581 		}
582 	}
583 }
584 
EditedText(const XubString & rStr)585 void SvIconView::EditedText( const XubString& rStr )
586 {
587 	XubString aRefStr( ((SvLBoxString*)pCurEdItem)->GetText() );
588 	if ( EditedEntry( pCurEdEntry, rStr ) )
589 	{
590 		((SvLBoxString*)pCurEdItem)->SetText( pCurEdEntry, rStr );
591 		pModel->InvalidateEntry( pCurEdEntry );
592 	}
593 	if( GetSelectionMode()==SINGLE_SELECTION && !GetSelectionCount())
594 		Select( pCurEdEntry );
595 }
596 
597 
EditingEntry(SvLBoxEntry *,Selection &)598 sal_Bool SvIconView::EditingEntry( SvLBoxEntry*, Selection& )
599 {
600 	return sal_True;
601 }
602 
EditedEntry(SvLBoxEntry *,const XubString &)603 sal_Bool SvIconView::EditedEntry( SvLBoxEntry*, const XubString& )
604 {
605 	return sal_True;
606 }
607 
608 
WriteDragServerInfo(const Point & rPos,SvLBoxDDInfo * pInfo)609 void SvIconView::WriteDragServerInfo( const Point& rPos, SvLBoxDDInfo* pInfo)
610 {
611 	pImp->WriteDragServerInfo( rPos, pInfo );
612 }
613 
ReadDragServerInfo(const Point & rPos,SvLBoxDDInfo * pInfo)614 void SvIconView::ReadDragServerInfo( const Point& rPos, SvLBoxDDInfo* pInfo )
615 {
616 	pImp->ReadDragServerInfo( rPos, pInfo );
617 }
618 
Command(const CommandEvent & rCEvt)619 void SvIconView::Command( const CommandEvent& rCEvt )
620 {
621 	pImp->PrepareCommandEvent( rCEvt.GetMousePosPixel() );
622 }
623 
SetCurParent(SvLBoxEntry * pNewParent)624 void SvIconView::SetCurParent( SvLBoxEntry* pNewParent )
625 {
626 	if ( pNewParent && pNewParent->HasChildsOnDemand() )
627 		RequestingChilds( pNewParent );
628 	pImp->SetCurParent( pNewParent );
629 }
630 
GetCurParent() const631 SvLBoxEntry* SvIconView::GetCurParent() const
632 {
633 	return pImp->GetCurParent();
634 }
635 
CreateViewData(SvListEntry *)636 SvViewData* SvIconView::CreateViewData( SvListEntry* )
637 {
638 	SvIcnVwDataEntry* pEntryData = new SvIcnVwDataEntry;
639 	return (SvViewData*)pEntryData;
640 }
641 
InitViewData(SvViewData * pData,SvListEntry * pEntry)642 void SvIconView::InitViewData( SvViewData* pData, SvListEntry* pEntry )
643 {
644 	SvLBox::InitViewData( pData, pEntry );
645 	pImp->InvalidateBoundingRect( ((SvIcnVwDataEntry*)pData)->aRect );
646 }
647 
GetDragRegion() const648 Region SvIconView::GetDragRegion() const
649 {
650 	Rectangle aRect;
651 	SvLBoxEntry* pEntry = GetCurEntry();
652 	if( pEntry )
653 		aRect = pImp->GetBoundingRect( pEntry );
654 	Region aRegion( aRect );
655 	return aRegion;
656 }
657 
GetSelectionCount() const658 sal_uLong SvIconView::GetSelectionCount() const
659 {
660 	return (sal_uLong)(pImp->GetSelectionCount());
661 }
662 
SetGrid(long nDX,long nDY)663 void SvIconView::SetGrid( long nDX, long nDY )
664 {
665 	pImp->SetGrid( nDX, nDY );
666 }
667 
ModelNotification(sal_uInt16 nActionId,SvListEntry * pEntry1,SvListEntry * pEntry2,sal_uLong nPos)668 void SvIconView::ModelNotification( sal_uInt16 nActionId, SvListEntry* pEntry1,
669 	SvListEntry* pEntry2, sal_uLong nPos )
670 {
671 	SvLBox::ModelNotification( nActionId, pEntry1, pEntry2, nPos );
672 	switch( nActionId )
673 	{
674 		case LISTACTION_RESORTING:
675 			SetUpdateMode( sal_False );
676 			break;
677 
678 		case LISTACTION_RESORTED:
679 			SetUpdateMode( sal_True );
680 			Arrange();
681 			break;
682 
683 		case LISTACTION_CLEARED:
684 			if( IsUpdateMode() )
685 				Update();
686 			break;
687 	}
688 }
689 
690 
Scroll(long nDeltaX,long nDeltaY,sal_uInt16)691 void SvIconView::Scroll( long nDeltaX, long nDeltaY, sal_uInt16 )
692 {
693 	pImp->Scroll( nDeltaX, nDeltaY, sal_False );
694 }
695 
PrepareCommandEvent(const CommandEvent & rCEvt)696 void SvIconView::PrepareCommandEvent( const CommandEvent& rCEvt )
697 {
698 	pImp->PrepareCommandEvent( rCEvt.GetMousePosPixel() );
699 }
700 
StartDrag(sal_Int8 nAction,const Point & rPos)701 void SvIconView::StartDrag( sal_Int8 nAction, const Point& rPos )
702 {
703 	pImp->SttDrag( rPos );
704 	SvLBoxEntry* pEntry = GetEntry( rPos, sal_True );
705 	pImp->mpViewData = pEntry;
706 	SvLBox::StartDrag( nAction, rPos );
707 }
708 
DragFinished(sal_Int8)709 void SvIconView::DragFinished( sal_Int8 )
710 {
711 	pImp->EndDrag();
712 }
713 
AcceptDrop(const AcceptDropEvent & rEvt)714 sal_Int8 SvIconView::AcceptDrop( const AcceptDropEvent& rEvt )
715 {
716 	if( pImp->mpViewData )
717 		pImp->HideDDIcon();
718 	sal_Int8 nRet = SvLBox::AcceptDrop( rEvt );
719 	if( DND_ACTION_NONE != nRet )
720 		pImp->ShowDDIcon( pImp->mpViewData, rEvt.maPosPixel );
721 
722 	return nRet;
723 }
724 
ExecuteDrop(const ExecuteDropEvent & rEvt)725 sal_Int8 SvIconView::ExecuteDrop( const ExecuteDropEvent& rEvt )
726 {
727 	if( pImp->mpViewData )
728 	{
729 		pImp->HideDDIcon();
730 		pImp->mpViewData = 0;
731 	}
732 	return SvLBox::ExecuteDrop( rEvt );
733 }
734 
ShowDDIcon(SvLBoxEntry * pRefEntry,const Point & rPos)735 void SvIconView::ShowDDIcon( SvLBoxEntry* pRefEntry, const Point& rPos )
736 {
737 	pImp->ShowDDIcon( pRefEntry, rPos );
738 }
739 
HideDDIcon()740 void SvIconView::HideDDIcon()
741 {
742 	pImp->HideDDIcon();
743 }
744 
HideShowDDIcon(SvLBoxEntry * pRefEntry,const Point & rPos)745 void SvIconView::HideShowDDIcon( SvLBoxEntry* pRefEntry, const Point& rPos )
746 {
747 	pImp->HideShowDDIcon( pRefEntry, rPos );
748 }
749 
SelectRect(const Rectangle & rRect,sal_Bool bAdd,SvPtrarr * pRects,short nOffs)750 void SvIconView::SelectRect( const Rectangle& rRect, sal_Bool bAdd,
751 	SvPtrarr* pRects, short nOffs )
752 {
753 	pImp->SelectRect( rRect, bAdd, pRects, nOffs );
754 }
755 
CalcScrollOffsets(const Point & rRefPosPixel,long & rX,long & rY,sal_Bool b,sal_uInt16 nBorderWidth)756 void SvIconView::CalcScrollOffsets( const Point& rRefPosPixel, long& rX, long& rY,
757 	sal_Bool b, sal_uInt16 nBorderWidth )
758 {
759 	pImp->CalcScrollOffsets( rRefPosPixel, rX, rY, b, nBorderWidth );
760 }
761 
EndTracking()762 void SvIconView::EndTracking()
763 {
764 	pImp->EndTracking();
765 }
766 
MakeVisible(SvLBoxEntry * pEntry)767 void SvIconView::MakeVisible( SvLBoxEntry* pEntry )
768 {
769 	pImp->MakeVisible( pEntry );
770 }
771 
PreparePaint(SvLBoxEntry *)772 void SvIconView::PreparePaint( SvLBoxEntry* )
773 {
774 }
775 
AdjustAtGrid(SvLBoxEntry * pEntry)776 void SvIconView::AdjustAtGrid( SvLBoxEntry* pEntry )
777 {
778 	pImp->AdjustAtGrid( pEntry );
779 }
780 
LockEntryPos(SvLBoxEntry * pEntry,sal_Bool bLock)781 void SvIconView::LockEntryPos( SvLBoxEntry* pEntry, sal_Bool bLock )
782 {
783 	SvIcnVwDataEntry* pViewData = (SvIcnVwDataEntry*)GetViewData( pEntry );
784 	if( bLock )
785 		pViewData->SetVwFlags( ICNVW_FLAG_POS_LOCKED );
786 	else
787 		pViewData->ClearVwFlags( ICNVW_FLAG_POS_LOCKED );
788 }
789 
IsEntryPosLocked(const SvLBoxEntry * pEntry) const790 sal_Bool SvIconView::IsEntryPosLocked( const SvLBoxEntry* pEntry ) const
791 {
792 	const SvIcnVwDataEntry* pViewData = (const SvIcnVwDataEntry*)GetViewData( (SvListEntry*)pEntry );
793 	return pViewData->IsEntryPosLocked();
794 }
795 
SetTextMode(SvIconViewTextMode eMode,SvLBoxEntry * pEntry)796 void SvIconView::SetTextMode( SvIconViewTextMode eMode, SvLBoxEntry* pEntry )
797 {
798 	pImp->SetTextMode( eMode, pEntry );
799 }
800 
GetTextMode(const SvLBoxEntry * pEntry) const801 SvIconViewTextMode SvIconView::GetTextMode( const SvLBoxEntry* pEntry ) const
802 {
803 	return pImp->GetTextMode( pEntry );
804 }
805 
GetNextEntry(const Point & rPixPos,SvLBoxEntry * pCurEntry,sal_Bool) const806 SvLBoxEntry* SvIconView::GetNextEntry( const Point& rPixPos, SvLBoxEntry* pCurEntry, sal_Bool  ) const
807 {
808 	Point aPos( rPixPos );
809 	aPos -= GetMapMode().GetOrigin();
810 	return ((SvIconView*)this)->pImp->GetNextEntry( aPos, pCurEntry );
811 }
812 
GetPrevEntry(const Point & rPixPos,SvLBoxEntry * pCurEntry,sal_Bool) const813 SvLBoxEntry* SvIconView::GetPrevEntry( const Point& rPixPos, SvLBoxEntry* pCurEntry, sal_Bool  ) const
814 {
815 	Point aPos( rPixPos );
816 	aPos -= GetMapMode().GetOrigin();
817 	return ((SvIconView*)this)->pImp->GetPrevEntry( aPos, pCurEntry );
818 }
819 
ShowFocusRect(const SvLBoxEntry * pEntry)820 void SvIconView::ShowFocusRect( const SvLBoxEntry* pEntry )
821 {
822 	pImp->ShowFocusRect( pEntry );
823 }
824 
825 
826