15900e8ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
35900e8ecSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
45900e8ecSAndrew Rist * or more contributor license agreements. See the NOTICE file
55900e8ecSAndrew Rist * distributed with this work for additional information
65900e8ecSAndrew Rist * regarding copyright ownership. The ASF licenses this file
75900e8ecSAndrew Rist * to you under the Apache License, Version 2.0 (the
85900e8ecSAndrew Rist * "License"); you may not use this file except in compliance
95900e8ecSAndrew Rist * with the License. You may obtain a copy of the License at
105900e8ecSAndrew Rist *
115900e8ecSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
125900e8ecSAndrew Rist *
135900e8ecSAndrew Rist * Unless required by applicable law or agreed to in writing,
145900e8ecSAndrew Rist * software distributed under the License is distributed on an
155900e8ecSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165900e8ecSAndrew Rist * KIND, either express or implied. See the License for the
175900e8ecSAndrew Rist * specific language governing permissions and limitations
185900e8ecSAndrew Rist * under the License.
195900e8ecSAndrew Rist *
205900e8ecSAndrew Rist *************************************************************/
215900e8ecSAndrew Rist
225900e8ecSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svtools.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <limits.h>
28cdf0e10cSrcweir #include <tools/debug.hxx>
29cdf0e10cSrcweir #include <vcl/wall.hxx>
30cdf0e10cSrcweir #include <vcl/help.hxx>
31cdf0e10cSrcweir #include <vcl/decoview.hxx>
32cdf0e10cSrcweir #include <vcl/svapp.hxx>
33cdf0e10cSrcweir #include <tools/poly.hxx>
34cdf0e10cSrcweir #include <vcl/lineinfo.hxx>
35cdf0e10cSrcweir #include <vcl/i18nhelp.hxx>
36cdf0e10cSrcweir #include <vcl/mnemonic.hxx>
37cdf0e10cSrcweir #include <vcl/controllayout.hxx>
38cdf0e10cSrcweir
39cdf0e10cSrcweir #include <svtools/ivctrl.hxx>
40cdf0e10cSrcweir #include "imivctl.hxx"
41cdf0e10cSrcweir #include <svtools/svmedit.hxx>
42cdf0e10cSrcweir
43cdf0e10cSrcweir #include <algorithm>
44cdf0e10cSrcweir #include <memory>
45cdf0e10cSrcweir
46cdf0e10cSrcweir #define DD_SCROLL_PIXEL 24
47cdf0e10cSrcweir #define IMPICNVIEW_ACC_RETURN 1
48cdf0e10cSrcweir #define IMPICNVIEW_ACC_ESCAPE 2
49cdf0e10cSrcweir
50cdf0e10cSrcweir #define DRAWTEXT_FLAGS_ICON \
51cdf0e10cSrcweir ( TEXT_DRAW_CENTER | TEXT_DRAW_TOP | TEXT_DRAW_ENDELLIPSIS | \
52cdf0e10cSrcweir TEXT_DRAW_CLIP | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK | TEXT_DRAW_MNEMONIC )
53cdf0e10cSrcweir
54cdf0e10cSrcweir #define DRAWTEXT_FLAGS_SMALLICON (TEXT_DRAW_LEFT|TEXT_DRAW_ENDELLIPSIS|TEXT_DRAW_CLIP)
55cdf0e10cSrcweir
56cdf0e10cSrcweir #define EVENTID_SHOW_CURSOR ((void*)1)
57cdf0e10cSrcweir #define EVENTID_ADJUST_SCROLLBARS ((void*)2)
58cdf0e10cSrcweir
59cdf0e10cSrcweir struct SvxIconChoiceCtrlEntry_Impl
60cdf0e10cSrcweir {
61cdf0e10cSrcweir SvxIconChoiceCtrlEntry* _pEntry;
62cdf0e10cSrcweir Point _aPos;
SvxIconChoiceCtrlEntry_ImplSvxIconChoiceCtrlEntry_Impl63cdf0e10cSrcweir SvxIconChoiceCtrlEntry_Impl( SvxIconChoiceCtrlEntry* pEntry, const Rectangle& rBoundRect )
64cdf0e10cSrcweir : _pEntry( pEntry), _aPos( rBoundRect.TopLeft()) {}
65cdf0e10cSrcweir };
66cdf0e10cSrcweir
67cdf0e10cSrcweir static sal_Bool bEndScrollInvalidate = sal_True;
68cdf0e10cSrcweir
69cdf0e10cSrcweir // ----------------------------------------------------------------------------------------------
70cdf0e10cSrcweir
71cdf0e10cSrcweir class IcnViewEdit_Impl : public MultiLineEdit
72cdf0e10cSrcweir {
73cdf0e10cSrcweir Link aCallBackHdl;
74cdf0e10cSrcweir Accelerator aAccReturn;
75cdf0e10cSrcweir Accelerator aAccEscape;
76cdf0e10cSrcweir Timer aTimer;
77cdf0e10cSrcweir sal_Bool bCanceled;
78cdf0e10cSrcweir sal_Bool bAlreadyInCallback;
79cdf0e10cSrcweir sal_Bool bGrabFocus;
80cdf0e10cSrcweir
81cdf0e10cSrcweir void CallCallBackHdl_Impl();
82cdf0e10cSrcweir DECL_LINK( Timeout_Impl, Timer * );
83cdf0e10cSrcweir DECL_LINK( ReturnHdl_Impl, Accelerator * );
84cdf0e10cSrcweir DECL_LINK( EscapeHdl_Impl, Accelerator * );
85cdf0e10cSrcweir
86cdf0e10cSrcweir public:
87cdf0e10cSrcweir
88cdf0e10cSrcweir IcnViewEdit_Impl(
89cdf0e10cSrcweir SvtIconChoiceCtrl* pParent,
90cdf0e10cSrcweir const Point& rPos,
91cdf0e10cSrcweir const Size& rSize,
92cdf0e10cSrcweir const XubString& rData,
93cdf0e10cSrcweir const Link& rNotifyEditEnd );
94cdf0e10cSrcweir
95cdf0e10cSrcweir ~IcnViewEdit_Impl();
96cdf0e10cSrcweir virtual void KeyInput( const KeyEvent& rKEvt );
97cdf0e10cSrcweir virtual long PreNotify( NotifyEvent& rNEvt );
EditingCanceled() const98cdf0e10cSrcweir sal_Bool EditingCanceled() const { return bCanceled; }
99cdf0e10cSrcweir void StopEditing( sal_Bool bCancel = sal_False );
IsGrabFocus() const100cdf0e10cSrcweir sal_Bool IsGrabFocus() const { return bGrabFocus; }
101cdf0e10cSrcweir };
102cdf0e10cSrcweir
103cdf0e10cSrcweir // ----------------------------------------------------------------------------------------------
104cdf0e10cSrcweir
105cdf0e10cSrcweir // ----------------------------------------------------------------------------------------------
106cdf0e10cSrcweir
SvxIconChoiceCtrl_Impl(SvtIconChoiceCtrl * pCurView,WinBits nWinStyle)107cdf0e10cSrcweir SvxIconChoiceCtrl_Impl::SvxIconChoiceCtrl_Impl( SvtIconChoiceCtrl* pCurView,
108cdf0e10cSrcweir WinBits nWinStyle ) :
109cdf0e10cSrcweir aEntries( this ),
110cdf0e10cSrcweir aVerSBar( pCurView, WB_DRAG | WB_VSCROLL ),
111cdf0e10cSrcweir aHorSBar( pCurView, WB_DRAG | WB_HSCROLL ),
112cdf0e10cSrcweir aScrBarBox( pCurView ),
113cdf0e10cSrcweir aImageSize( 32, 32 ),
114cdf0e10cSrcweir pColumns( 0 )
115cdf0e10cSrcweir {
116cdf0e10cSrcweir bChooseWithCursor=sal_False;
117cdf0e10cSrcweir pEntryPaintDev = 0;
118cdf0e10cSrcweir pCurEditedEntry = 0;
119cdf0e10cSrcweir pCurHighlightFrame = 0;
120cdf0e10cSrcweir pEdit = 0;
121cdf0e10cSrcweir pAnchor = 0;
122cdf0e10cSrcweir pDraggedSelection = 0;
123cdf0e10cSrcweir pPrevDropTarget = 0;
124cdf0e10cSrcweir pHdlEntry = 0;
125cdf0e10cSrcweir pHead = NULL;
126cdf0e10cSrcweir pCursor = NULL;
127cdf0e10cSrcweir bUpdateMode = sal_True;
128cdf0e10cSrcweir bEntryEditingEnabled = sal_False;
129cdf0e10cSrcweir bInDragDrop = sal_False;
130cdf0e10cSrcweir bHighlightFramePressed = sal_False;
131cdf0e10cSrcweir eSelectionMode = MULTIPLE_SELECTION;
132cdf0e10cSrcweir pView = pCurView;
133cdf0e10cSrcweir pZOrderList = new List; //SvPtrarr;
134cdf0e10cSrcweir ePositionMode = IcnViewPositionModeFree;
135cdf0e10cSrcweir SetStyle( nWinStyle );
136cdf0e10cSrcweir nFlags = 0;
137cdf0e10cSrcweir nUserEventAdjustScrBars = 0;
138cdf0e10cSrcweir nUserEventShowCursor = 0;
139cdf0e10cSrcweir nMaxVirtWidth = DEFAULT_MAX_VIRT_WIDTH;
140cdf0e10cSrcweir nMaxVirtHeight = DEFAULT_MAX_VIRT_HEIGHT;
141cdf0e10cSrcweir pDDRefEntry = 0;
142cdf0e10cSrcweir pDDDev = 0;
143cdf0e10cSrcweir pDDBufDev = 0;
144cdf0e10cSrcweir pDDTempDev = 0;
145cdf0e10cSrcweir eTextMode = IcnShowTextShort;
146cdf0e10cSrcweir pImpCursor = new IcnCursor_Impl( this );
147cdf0e10cSrcweir pGridMap = new IcnGridMap_Impl( this );
148cdf0e10cSrcweir
149cdf0e10cSrcweir aVerSBar.SetScrollHdl( LINK( this, SvxIconChoiceCtrl_Impl, ScrollUpDownHdl ) );
150cdf0e10cSrcweir aHorSBar.SetScrollHdl( LINK( this, SvxIconChoiceCtrl_Impl, ScrollLeftRightHdl ) );
151cdf0e10cSrcweir Link aEndScrollHdl( LINK( this, SvxIconChoiceCtrl_Impl, EndScrollHdl ) );
152cdf0e10cSrcweir aVerSBar.SetEndScrollHdl( aEndScrollHdl );
153cdf0e10cSrcweir aHorSBar.SetEndScrollHdl( aEndScrollHdl );
154cdf0e10cSrcweir
155cdf0e10cSrcweir nHorSBarHeight = aHorSBar.GetSizePixel().Height();
156cdf0e10cSrcweir nVerSBarWidth = aVerSBar.GetSizePixel().Width();
157cdf0e10cSrcweir
158cdf0e10cSrcweir aEditTimer.SetTimeout( 800 );
159cdf0e10cSrcweir aEditTimer.SetTimeoutHdl(LINK(this,SvxIconChoiceCtrl_Impl,EditTimeoutHdl));
160cdf0e10cSrcweir aAutoArrangeTimer.SetTimeout( 100 );
161cdf0e10cSrcweir aAutoArrangeTimer.SetTimeoutHdl(LINK(this,SvxIconChoiceCtrl_Impl,AutoArrangeHdl));
162cdf0e10cSrcweir aCallSelectHdlTimer.SetTimeout( 500 );
163cdf0e10cSrcweir aCallSelectHdlTimer.SetTimeoutHdl( LINK(this,SvxIconChoiceCtrl_Impl,CallSelectHdlHdl));
164cdf0e10cSrcweir
165cdf0e10cSrcweir aDocRectChangedTimer.SetTimeout( 50 );
166cdf0e10cSrcweir aDocRectChangedTimer.SetTimeoutHdl(LINK(this,SvxIconChoiceCtrl_Impl,DocRectChangedHdl));
167cdf0e10cSrcweir aVisRectChangedTimer.SetTimeout( 50 );
168cdf0e10cSrcweir aVisRectChangedTimer.SetTimeoutHdl(LINK(this,SvxIconChoiceCtrl_Impl,VisRectChangedHdl));
169cdf0e10cSrcweir
170cdf0e10cSrcweir Clear( sal_True );
171cdf0e10cSrcweir
172cdf0e10cSrcweir SetGrid( Size(100, 70) );
173cdf0e10cSrcweir }
174cdf0e10cSrcweir
~SvxIconChoiceCtrl_Impl()175cdf0e10cSrcweir SvxIconChoiceCtrl_Impl::~SvxIconChoiceCtrl_Impl()
176cdf0e10cSrcweir {
177cdf0e10cSrcweir pCurEditedEntry = 0;
178cdf0e10cSrcweir DELETEZ(pEdit);
179cdf0e10cSrcweir Clear();
180cdf0e10cSrcweir StopEditTimer();
181cdf0e10cSrcweir CancelUserEvents();
182cdf0e10cSrcweir delete pZOrderList;
183cdf0e10cSrcweir delete pImpCursor;
184cdf0e10cSrcweir delete pGridMap;
185cdf0e10cSrcweir delete pDDDev;
186cdf0e10cSrcweir delete pDDBufDev;
187cdf0e10cSrcweir delete pDDTempDev;
188cdf0e10cSrcweir delete pDraggedSelection;
189cdf0e10cSrcweir delete pEntryPaintDev;
190cdf0e10cSrcweir ClearSelectedRectList();
191cdf0e10cSrcweir ClearColumnList();
192cdf0e10cSrcweir }
193cdf0e10cSrcweir
Clear(sal_Bool bInCtor)194cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::Clear( sal_Bool bInCtor )
195cdf0e10cSrcweir {
196cdf0e10cSrcweir StopEntryEditing( sal_True );
197cdf0e10cSrcweir nSelectionCount = 0;
198cdf0e10cSrcweir DELETEZ(pDraggedSelection);
199cdf0e10cSrcweir bInDragDrop = sal_False;
200cdf0e10cSrcweir pCurHighlightFrame = 0;
201cdf0e10cSrcweir StopEditTimer();
202cdf0e10cSrcweir CancelUserEvents();
203cdf0e10cSrcweir ShowCursor( sal_False );
204cdf0e10cSrcweir bBoundRectsDirty = sal_False;
205cdf0e10cSrcweir nMaxBoundHeight = 0;
206cdf0e10cSrcweir
207cdf0e10cSrcweir nFlags &= ~(F_PAINTED | F_MOVED_ENTRIES);
208cdf0e10cSrcweir pCursor = 0;
209cdf0e10cSrcweir if( !bInCtor )
210cdf0e10cSrcweir {
211cdf0e10cSrcweir pImpCursor->Clear();
212cdf0e10cSrcweir pGridMap->Clear();
213cdf0e10cSrcweir aVirtOutputSize.Width() = 0;
214cdf0e10cSrcweir aVirtOutputSize.Height() = 0;
215cdf0e10cSrcweir Size aSize( pView->GetOutputSizePixel() );
216cdf0e10cSrcweir nMaxVirtWidth = aSize.Width() - nVerSBarWidth;
217cdf0e10cSrcweir if( nMaxVirtWidth <= 0 )
218cdf0e10cSrcweir nMaxVirtWidth = DEFAULT_MAX_VIRT_WIDTH;
219cdf0e10cSrcweir nMaxVirtHeight = aSize.Height() - nHorSBarHeight;
220cdf0e10cSrcweir if( nMaxVirtHeight <= 0 )
221cdf0e10cSrcweir nMaxVirtHeight = DEFAULT_MAX_VIRT_HEIGHT;
222cdf0e10cSrcweir pZOrderList->Clear(); //Remove(0,pZOrderList->Count());
223cdf0e10cSrcweir SetOrigin( Point() );
224cdf0e10cSrcweir if( bUpdateMode )
225cdf0e10cSrcweir pView->Invalidate(INVALIDATE_NOCHILDREN);
226cdf0e10cSrcweir }
227cdf0e10cSrcweir AdjustScrollBars();
228cdf0e10cSrcweir sal_uLong nCount = aEntries.Count();
229cdf0e10cSrcweir for( sal_uLong nCur = 0; nCur < nCount; nCur++ )
230cdf0e10cSrcweir {
231cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pCur = (SvxIconChoiceCtrlEntry*)aEntries.GetObject( nCur );
232cdf0e10cSrcweir delete pCur;
233cdf0e10cSrcweir }
234cdf0e10cSrcweir aEntries.Clear();
235cdf0e10cSrcweir DocRectChanged();
236cdf0e10cSrcweir VisRectChanged();
237cdf0e10cSrcweir }
238cdf0e10cSrcweir
SetStyle(WinBits nWinStyle)239cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SetStyle( WinBits nWinStyle )
240cdf0e10cSrcweir {
241cdf0e10cSrcweir nWinBits = nWinStyle;
242cdf0e10cSrcweir nCurTextDrawFlags = DRAWTEXT_FLAGS_ICON;
243cdf0e10cSrcweir if( nWinBits & (WB_SMALLICON | WB_DETAILS) )
244cdf0e10cSrcweir nCurTextDrawFlags = DRAWTEXT_FLAGS_SMALLICON;
245cdf0e10cSrcweir if( nWinBits & WB_NOSELECTION )
246cdf0e10cSrcweir eSelectionMode = NO_SELECTION;
247cdf0e10cSrcweir if( !(nWinStyle & (WB_ALIGN_TOP | WB_ALIGN_LEFT)))
248cdf0e10cSrcweir nWinBits |= WB_ALIGN_LEFT;
249cdf0e10cSrcweir if( (nWinStyle & WB_DETAILS))
250cdf0e10cSrcweir {
251cdf0e10cSrcweir if( !pColumns )
252cdf0e10cSrcweir SetColumn( 0, SvxIconChoiceCtrlColumnInfo( 0, 100, IcnViewAlignLeft ));
253cdf0e10cSrcweir }
254cdf0e10cSrcweir }
255cdf0e10cSrcweir
IMPL_LINK(SvxIconChoiceCtrl_Impl,ScrollUpDownHdl,ScrollBar *,pScrollBar)256cdf0e10cSrcweir IMPL_LINK( SvxIconChoiceCtrl_Impl, ScrollUpDownHdl, ScrollBar*, pScrollBar )
257cdf0e10cSrcweir {
258cdf0e10cSrcweir StopEntryEditing( sal_True );
259cdf0e10cSrcweir // Pfeil hoch: delta=-1; Pfeil runter: delta=+1
260cdf0e10cSrcweir Scroll( 0, pScrollBar->GetDelta(), sal_True );
261cdf0e10cSrcweir bEndScrollInvalidate = sal_True;
262cdf0e10cSrcweir return 0;
263cdf0e10cSrcweir }
264cdf0e10cSrcweir
IMPL_LINK(SvxIconChoiceCtrl_Impl,ScrollLeftRightHdl,ScrollBar *,pScrollBar)265cdf0e10cSrcweir IMPL_LINK( SvxIconChoiceCtrl_Impl, ScrollLeftRightHdl, ScrollBar*, pScrollBar )
266cdf0e10cSrcweir {
267cdf0e10cSrcweir StopEntryEditing( sal_True );
268cdf0e10cSrcweir // Pfeil links: delta=-1; Pfeil rechts: delta=+1
269cdf0e10cSrcweir Scroll( pScrollBar->GetDelta(), 0, sal_True );
270cdf0e10cSrcweir bEndScrollInvalidate = sal_True;
271cdf0e10cSrcweir return 0;
272cdf0e10cSrcweir }
273cdf0e10cSrcweir
IMPL_LINK(SvxIconChoiceCtrl_Impl,EndScrollHdl,void *,EMPTYARG)274cdf0e10cSrcweir IMPL_LINK( SvxIconChoiceCtrl_Impl, EndScrollHdl, void*, EMPTYARG )
275cdf0e10cSrcweir {
276cdf0e10cSrcweir if( pView->HasBackground() && !pView->GetBackground().IsScrollable() &&
277cdf0e10cSrcweir bEndScrollInvalidate )
278cdf0e10cSrcweir {
279cdf0e10cSrcweir pView->Invalidate(INVALIDATE_NOCHILDREN);
280cdf0e10cSrcweir }
281cdf0e10cSrcweir return 0;
282cdf0e10cSrcweir }
283cdf0e10cSrcweir
FontModified()284cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::FontModified()
285cdf0e10cSrcweir {
286cdf0e10cSrcweir StopEditTimer();
287cdf0e10cSrcweir DELETEZ(pDDDev);
288cdf0e10cSrcweir DELETEZ(pDDBufDev);
289cdf0e10cSrcweir DELETEZ(pDDTempDev);
290cdf0e10cSrcweir DELETEZ(pEntryPaintDev);
291cdf0e10cSrcweir SetDefaultTextSize();
292cdf0e10cSrcweir ShowCursor( sal_False );
293cdf0e10cSrcweir ShowCursor( sal_True );
294cdf0e10cSrcweir }
295cdf0e10cSrcweir
InsertEntry(SvxIconChoiceCtrlEntry * pEntry,sal_uLong nPos,const Point * pPos)296cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::InsertEntry( SvxIconChoiceCtrlEntry* pEntry, sal_uLong nPos,
297cdf0e10cSrcweir const Point* pPos )
298cdf0e10cSrcweir {
299cdf0e10cSrcweir StopEditTimer();
300cdf0e10cSrcweir aEntries.Insert( pEntry, nPos );
301cdf0e10cSrcweir if( (nFlags & F_ENTRYLISTPOS_VALID) && nPos >= aEntries.Count() - 1 )
302cdf0e10cSrcweir pEntry->nPos = aEntries.Count() - 1;
303cdf0e10cSrcweir else
304cdf0e10cSrcweir nFlags &= ~F_ENTRYLISTPOS_VALID;
305cdf0e10cSrcweir
306cdf0e10cSrcweir pZOrderList->Insert( (void*)pEntry, LIST_APPEND ); //pZOrderList->Count() );
307cdf0e10cSrcweir pImpCursor->Clear();
308cdf0e10cSrcweir // pGridMap->Clear();
309cdf0e10cSrcweir if( pPos )
310cdf0e10cSrcweir {
311cdf0e10cSrcweir Size aSize( CalcBoundingSize( pEntry ) );
312cdf0e10cSrcweir SetBoundingRect_Impl( pEntry, *pPos, aSize );
313cdf0e10cSrcweir SetEntryPos( pEntry, *pPos, sal_False, sal_True, sal_True /*keep grid map*/ );
314cdf0e10cSrcweir pEntry->nFlags |= ICNVIEW_FLAG_POS_MOVED;
315cdf0e10cSrcweir SetEntriesMoved( sal_True );
316cdf0e10cSrcweir }
317cdf0e10cSrcweir else
318cdf0e10cSrcweir {
319cdf0e10cSrcweir // wenn der UpdateMode sal_True ist, wollen wir nicht pauschal alle
320cdf0e10cSrcweir // BoundRects auf 'zu ueberpruefen' setzen, sondern nur das des
321cdf0e10cSrcweir // neuen Eintrags. Deshalb kein InvalidateBoundingRect aufrufen!
322cdf0e10cSrcweir pEntry->aRect.Right() = LONG_MAX;
323cdf0e10cSrcweir if( bUpdateMode )
324cdf0e10cSrcweir {
325cdf0e10cSrcweir FindBoundingRect( pEntry );
326cdf0e10cSrcweir Rectangle aOutputArea( GetOutputRect() );
327cdf0e10cSrcweir pGridMap->OccupyGrids( pEntry );
328cdf0e10cSrcweir if( !aOutputArea.IsOver( pEntry->aRect ) )
329cdf0e10cSrcweir return; // ist nicht sichtbar
330cdf0e10cSrcweir pView->Invalidate( pEntry->aRect );
331cdf0e10cSrcweir }
332cdf0e10cSrcweir else
333cdf0e10cSrcweir InvalidateBoundingRect( pEntry->aRect );
334cdf0e10cSrcweir }
335cdf0e10cSrcweir }
336cdf0e10cSrcweir
CreateAutoMnemonics(MnemonicGenerator * _pGenerator)337cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::CreateAutoMnemonics( MnemonicGenerator* _pGenerator )
338cdf0e10cSrcweir {
339cdf0e10cSrcweir ::std::auto_ptr< MnemonicGenerator > pAutoDeleteOwnGenerator;
340cdf0e10cSrcweir if ( !_pGenerator )
341cdf0e10cSrcweir {
342cdf0e10cSrcweir _pGenerator = new MnemonicGenerator;
343cdf0e10cSrcweir pAutoDeleteOwnGenerator.reset( _pGenerator );
344cdf0e10cSrcweir }
345cdf0e10cSrcweir
346cdf0e10cSrcweir sal_uLong nEntryCount = GetEntryCount();
347cdf0e10cSrcweir sal_uLong i;
348cdf0e10cSrcweir
349cdf0e10cSrcweir // insert texts in generator
350cdf0e10cSrcweir for( i = 0; i < nEntryCount; ++i )
351cdf0e10cSrcweir {
352cdf0e10cSrcweir DBG_ASSERT( GetEntry( i ), "-SvxIconChoiceCtrl_Impl::CreateAutoMnemonics(): more expected than provided!" );
353cdf0e10cSrcweir
354cdf0e10cSrcweir _pGenerator->RegisterMnemonic( GetEntry( i )->GetText() );
355cdf0e10cSrcweir }
356cdf0e10cSrcweir
357cdf0e10cSrcweir // exchange texts with generated mnemonics
358cdf0e10cSrcweir for( i = 0; i < nEntryCount; ++i )
359cdf0e10cSrcweir {
360cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = GetEntry( i );
361cdf0e10cSrcweir String aTxt = pEntry->GetText();
362cdf0e10cSrcweir
363cdf0e10cSrcweir if( _pGenerator->CreateMnemonic( aTxt ) )
364cdf0e10cSrcweir pEntry->SetText( aTxt );
365cdf0e10cSrcweir }
366cdf0e10cSrcweir }
367cdf0e10cSrcweir
GetOutputRect() const368cdf0e10cSrcweir Rectangle SvxIconChoiceCtrl_Impl::GetOutputRect() const
369cdf0e10cSrcweir {
370cdf0e10cSrcweir Point aOrigin( pView->GetMapMode().GetOrigin() );
371cdf0e10cSrcweir aOrigin *= -1;
372cdf0e10cSrcweir return Rectangle( aOrigin, aOutputSize );
373cdf0e10cSrcweir }
374cdf0e10cSrcweir
SetListPositions()375cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SetListPositions()
376cdf0e10cSrcweir {
377cdf0e10cSrcweir if( nFlags & F_ENTRYLISTPOS_VALID )
378cdf0e10cSrcweir return;
379cdf0e10cSrcweir
380cdf0e10cSrcweir sal_uLong nCount = aEntries.Count();
381cdf0e10cSrcweir for( sal_uLong nCur = 0; nCur < nCount; nCur++ )
382cdf0e10cSrcweir {
383cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)aEntries.GetObject( nCur );
384cdf0e10cSrcweir pEntry->nPos = nCur;
385cdf0e10cSrcweir }
386cdf0e10cSrcweir nFlags |= F_ENTRYLISTPOS_VALID;
387cdf0e10cSrcweir }
388cdf0e10cSrcweir
RemoveEntry(SvxIconChoiceCtrlEntry * pEntry)389cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::RemoveEntry( SvxIconChoiceCtrlEntry* pEntry )
390cdf0e10cSrcweir {
391cdf0e10cSrcweir sal_Bool bSyncSingleSelection;
392cdf0e10cSrcweir // bei Single-Selection wird die Selektion beim Umsetzen des Cursors
393cdf0e10cSrcweir // mitgefuehrt. Das soll aber nur erfolgen, wenn ueberhaupt ein
394cdf0e10cSrcweir // Eintrag selektiert ist.
395cdf0e10cSrcweir if( GetSelectionCount() )
396cdf0e10cSrcweir bSyncSingleSelection = sal_True;
397cdf0e10cSrcweir else
398cdf0e10cSrcweir bSyncSingleSelection = sal_False;
399cdf0e10cSrcweir
400cdf0e10cSrcweir if( pEntry == pCurHighlightFrame )
401cdf0e10cSrcweir pCurHighlightFrame = 0;
402cdf0e10cSrcweir
403cdf0e10cSrcweir if( bInDragDrop )
404cdf0e10cSrcweir {
405cdf0e10cSrcweir DELETEZ(pDraggedSelection);
406cdf0e10cSrcweir bInDragDrop = sal_False;
407cdf0e10cSrcweir }
408cdf0e10cSrcweir
409cdf0e10cSrcweir if( pEntry->IsSelected() )
410cdf0e10cSrcweir CallSelectHandler( 0 );
411cdf0e10cSrcweir
412cdf0e10cSrcweir if( aEntries.Count() == 1 && aEntries.GetObject(0) == pEntry )
413cdf0e10cSrcweir {
414cdf0e10cSrcweir Clear();
415cdf0e10cSrcweir return;
416cdf0e10cSrcweir }
417cdf0e10cSrcweir
418cdf0e10cSrcweir StopEditTimer();
419cdf0e10cSrcweir if( pEntry == pAnchor )
420cdf0e10cSrcweir pAnchor = 0;
421cdf0e10cSrcweir if( pEntry->IsSelected() )
422cdf0e10cSrcweir nSelectionCount--;
423cdf0e10cSrcweir sal_Bool bEntryBoundValid = IsBoundingRectValid( pEntry->aRect );
424cdf0e10cSrcweir if( bEntryBoundValid )
425cdf0e10cSrcweir pView->Invalidate( pEntry->aRect );
426cdf0e10cSrcweir
427cdf0e10cSrcweir sal_Bool bSetNewCursor = sal_False;
428cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pNewCursor = NULL;
429cdf0e10cSrcweir
430cdf0e10cSrcweir if( pEntry == pCursor )
431cdf0e10cSrcweir {
432cdf0e10cSrcweir bSetNewCursor = sal_True;
433cdf0e10cSrcweir pNewCursor = FindNewCursor();
434cdf0e10cSrcweir ShowCursor( sal_False );
435cdf0e10cSrcweir pCursor = 0;
436cdf0e10cSrcweir }
437cdf0e10cSrcweir
438cdf0e10cSrcweir sal_Bool bCurEntryPosValid = (nFlags & F_ENTRYLISTPOS_VALID) ? sal_True : sal_False;
439cdf0e10cSrcweir if( bCurEntryPosValid && aEntries.GetObject(aEntries.Count()-1) != pEntry )
440cdf0e10cSrcweir nFlags &= ~F_ENTRYLISTPOS_VALID;
441cdf0e10cSrcweir sal_uLong nPos = pZOrderList->GetPos( (void*)pEntry );
442cdf0e10cSrcweir pZOrderList->Remove( nPos );
443cdf0e10cSrcweir if( bCurEntryPosValid )
444cdf0e10cSrcweir {
445cdf0e10cSrcweir DBG_ASSERT(aEntries.GetObject(pEntry->nPos)==pEntry,"RemoveEntry: Wrong nPos in entry");
446cdf0e10cSrcweir aEntries.Remove( pEntry->nPos );
447cdf0e10cSrcweir }
448cdf0e10cSrcweir else
449cdf0e10cSrcweir aEntries.Remove( pEntry );
450cdf0e10cSrcweir pImpCursor->Clear();
451cdf0e10cSrcweir pGridMap->Clear();
452cdf0e10cSrcweir delete pEntry;
453cdf0e10cSrcweir if( IsAutoArrange() && aEntries.Count() )
454cdf0e10cSrcweir aAutoArrangeTimer.Start();
455cdf0e10cSrcweir if( bSetNewCursor )
456cdf0e10cSrcweir {
457cdf0e10cSrcweir // Fokusrechteck asynchron einblenden, um das Loeschen einer
458cdf0e10cSrcweir // Multiselektion zu beschleunigen.
459cdf0e10cSrcweir SetCursor( pNewCursor, bSyncSingleSelection, sal_True );
460cdf0e10cSrcweir }
461cdf0e10cSrcweir }
462cdf0e10cSrcweir
SelectEntry(SvxIconChoiceCtrlEntry * pEntry,sal_Bool bSelect,sal_Bool bCallHdl,sal_Bool bAdd,sal_Bool bSyncPaint)463cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SelectEntry( SvxIconChoiceCtrlEntry* pEntry, sal_Bool bSelect,
464cdf0e10cSrcweir sal_Bool bCallHdl, sal_Bool bAdd, sal_Bool bSyncPaint )
465cdf0e10cSrcweir {
466cdf0e10cSrcweir if( eSelectionMode == NO_SELECTION )
467cdf0e10cSrcweir return;
468cdf0e10cSrcweir
469cdf0e10cSrcweir if( !bAdd )
470cdf0e10cSrcweir {
471cdf0e10cSrcweir if ( 0 == ( nFlags & F_CLEARING_SELECTION ) )
472cdf0e10cSrcweir {
473cdf0e10cSrcweir nFlags |= F_CLEARING_SELECTION;
474cdf0e10cSrcweir DeselectAllBut( pEntry, sal_True );
475cdf0e10cSrcweir nFlags &= ~F_CLEARING_SELECTION;
476cdf0e10cSrcweir }
477cdf0e10cSrcweir }
478cdf0e10cSrcweir if( pEntry->IsSelected() != bSelect )
479cdf0e10cSrcweir {
480cdf0e10cSrcweir pHdlEntry = pEntry;
481cdf0e10cSrcweir sal_uInt16 nEntryFlags = pEntry->GetFlags();
482cdf0e10cSrcweir if( bSelect )
483cdf0e10cSrcweir {
484cdf0e10cSrcweir nEntryFlags |= ICNVIEW_FLAG_SELECTED;
485cdf0e10cSrcweir pEntry->AssignFlags( nEntryFlags );
486cdf0e10cSrcweir nSelectionCount++;
487cdf0e10cSrcweir if( bCallHdl )
488cdf0e10cSrcweir CallSelectHandler( pEntry );
489cdf0e10cSrcweir }
490cdf0e10cSrcweir else
491cdf0e10cSrcweir {
492cdf0e10cSrcweir nEntryFlags &= ~( ICNVIEW_FLAG_SELECTED);
493cdf0e10cSrcweir pEntry->AssignFlags( nEntryFlags );
494cdf0e10cSrcweir nSelectionCount--;
495cdf0e10cSrcweir if( bCallHdl )
496cdf0e10cSrcweir CallSelectHandler( 0 );
497cdf0e10cSrcweir }
498cdf0e10cSrcweir EntrySelected( pEntry, bSelect, bSyncPaint );
499cdf0e10cSrcweir }
500cdf0e10cSrcweir }
501cdf0e10cSrcweir
EntrySelected(SvxIconChoiceCtrlEntry * pEntry,sal_Bool bSelect,sal_Bool bSyncPaint)502cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::EntrySelected( SvxIconChoiceCtrlEntry* pEntry, sal_Bool bSelect,
503cdf0e10cSrcweir sal_Bool bSyncPaint )
504cdf0e10cSrcweir {
505cdf0e10cSrcweir // bei SingleSelection dafuer sorgen, dass der Cursor immer
506cdf0e10cSrcweir // auf dem (einzigen) selektierten Eintrag steht. Aber nur,
507cdf0e10cSrcweir // wenn es bereits einen Cursor gibt
508cdf0e10cSrcweir if( bSelect && pCursor &&
509cdf0e10cSrcweir eSelectionMode == SINGLE_SELECTION &&
510cdf0e10cSrcweir pEntry != pCursor )
511cdf0e10cSrcweir {
512cdf0e10cSrcweir SetCursor( pEntry );
513cdf0e10cSrcweir //DBG_ASSERT(pView->GetSelectionCount()==1,"selection count?")
514cdf0e10cSrcweir }
515cdf0e10cSrcweir
516cdf0e10cSrcweir // beim Aufziehen nicht, da sonst die Schleife in SelectRect
517cdf0e10cSrcweir // nicht richtig funktioniert!
518cdf0e10cSrcweir if( !(nFlags & F_SELECTING_RECT) )
519cdf0e10cSrcweir ToTop( pEntry );
520cdf0e10cSrcweir if( bUpdateMode )
521cdf0e10cSrcweir {
522cdf0e10cSrcweir if( pEntry == pCursor )
523cdf0e10cSrcweir ShowCursor( sal_False );
524cdf0e10cSrcweir if( pView->IsTracking() && (bSelect || !pView->HasBackground()) ) // beim Tracken immer synchron
525cdf0e10cSrcweir PaintEntry( pEntry );
526cdf0e10cSrcweir else if( bSyncPaint ) // synchron & mit virtuellem OutDev!
527cdf0e10cSrcweir PaintEntryVirtOutDev( pEntry );
528cdf0e10cSrcweir else
529cdf0e10cSrcweir {
530cdf0e10cSrcweir pView->Invalidate( CalcFocusRect( pEntry ) );
531cdf0e10cSrcweir }
532cdf0e10cSrcweir if( pEntry == pCursor )
533cdf0e10cSrcweir ShowCursor( sal_True );
534cdf0e10cSrcweir } // if( bUpdateMode )
535cdf0e10cSrcweir
536cdf0e10cSrcweir // --> OD 2009-05-27 #i101012#
537cdf0e10cSrcweir // emit vcl event LISTBOX_SELECT only in case that the given entry is selected.
538cdf0e10cSrcweir if ( bSelect )
539cdf0e10cSrcweir {
540cdf0e10cSrcweir CallEventListeners( VCLEVENT_LISTBOX_SELECT, pEntry );
541cdf0e10cSrcweir }
542cdf0e10cSrcweir // <--
543cdf0e10cSrcweir }
544cdf0e10cSrcweir
ResetVirtSize()545cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::ResetVirtSize()
546cdf0e10cSrcweir {
547cdf0e10cSrcweir StopEditTimer();
548cdf0e10cSrcweir aVirtOutputSize.Width() = 0;
549cdf0e10cSrcweir aVirtOutputSize.Height() = 0;
550cdf0e10cSrcweir sal_Bool bLockedEntryFound = sal_False;
551cdf0e10cSrcweir const sal_uLong nCount = aEntries.Count();
552cdf0e10cSrcweir for( sal_uLong nCur = 0; nCur < nCount; nCur++ )
553cdf0e10cSrcweir {
554cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pCur = (SvxIconChoiceCtrlEntry*)aEntries.GetObject( nCur );
555cdf0e10cSrcweir pCur->ClearFlags( ICNVIEW_FLAG_POS_MOVED );
556cdf0e10cSrcweir if( pCur->IsPosLocked() )
557cdf0e10cSrcweir {
558cdf0e10cSrcweir // VirtSize u.a. anpassen
559cdf0e10cSrcweir if( !IsBoundingRectValid( pCur->aRect ) )
560cdf0e10cSrcweir FindBoundingRect( pCur );
561cdf0e10cSrcweir else
562cdf0e10cSrcweir AdjustVirtSize( pCur->aRect );
563cdf0e10cSrcweir bLockedEntryFound = sal_True;
564cdf0e10cSrcweir }
565cdf0e10cSrcweir else
566cdf0e10cSrcweir InvalidateBoundingRect( pCur->aRect );
567cdf0e10cSrcweir }
568cdf0e10cSrcweir
569cdf0e10cSrcweir if( !(nWinBits & (WB_NOVSCROLL | WB_NOHSCROLL)) )
570cdf0e10cSrcweir {
571cdf0e10cSrcweir Size aRealOutputSize( pView->GetOutputSizePixel() );
572cdf0e10cSrcweir if( aVirtOutputSize.Width() < aRealOutputSize.Width() ||
573cdf0e10cSrcweir aVirtOutputSize.Height() < aRealOutputSize.Height() )
574cdf0e10cSrcweir {
575cdf0e10cSrcweir sal_uLong nGridCount = IcnGridMap_Impl::GetGridCount(
576cdf0e10cSrcweir aRealOutputSize, (sal_uInt16)nGridDX, (sal_uInt16)nGridDY );
577cdf0e10cSrcweir if( nGridCount < nCount )
578cdf0e10cSrcweir {
579cdf0e10cSrcweir if( nWinBits & WB_ALIGN_TOP )
580cdf0e10cSrcweir nMaxVirtWidth = aRealOutputSize.Width() - nVerSBarWidth;
581cdf0e10cSrcweir else // WB_ALIGN_LEFT
582cdf0e10cSrcweir nMaxVirtHeight = aRealOutputSize.Height() - nHorSBarHeight;
583cdf0e10cSrcweir }
584cdf0e10cSrcweir }
585cdf0e10cSrcweir }
586cdf0e10cSrcweir
587cdf0e10cSrcweir pImpCursor->Clear();
588cdf0e10cSrcweir pGridMap->Clear();
589cdf0e10cSrcweir VisRectChanged();
590cdf0e10cSrcweir }
591cdf0e10cSrcweir
AdjustVirtSize(const Rectangle & rRect)592cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::AdjustVirtSize( const Rectangle& rRect )
593cdf0e10cSrcweir {
594cdf0e10cSrcweir long nHeightOffs = 0;
595cdf0e10cSrcweir long nWidthOffs = 0;
596cdf0e10cSrcweir
597cdf0e10cSrcweir if( aVirtOutputSize.Width() < (rRect.Right()+LROFFS_WINBORDER) )
598cdf0e10cSrcweir nWidthOffs = (rRect.Right()+LROFFS_WINBORDER) - aVirtOutputSize.Width();
599cdf0e10cSrcweir
600cdf0e10cSrcweir if( aVirtOutputSize.Height() < (rRect.Bottom()+TBOFFS_WINBORDER) )
601cdf0e10cSrcweir nHeightOffs = (rRect.Bottom()+TBOFFS_WINBORDER) - aVirtOutputSize.Height();
602cdf0e10cSrcweir
603cdf0e10cSrcweir if( nWidthOffs || nHeightOffs )
604cdf0e10cSrcweir {
605cdf0e10cSrcweir Range aRange;
606cdf0e10cSrcweir aVirtOutputSize.Width() += nWidthOffs;
607cdf0e10cSrcweir aRange.Max() = aVirtOutputSize.Width();
608cdf0e10cSrcweir aHorSBar.SetRange( aRange );
609cdf0e10cSrcweir
610cdf0e10cSrcweir aVirtOutputSize.Height() += nHeightOffs;
611cdf0e10cSrcweir aRange.Max() = aVirtOutputSize.Height();
612cdf0e10cSrcweir aVerSBar.SetRange( aRange );
613cdf0e10cSrcweir
614cdf0e10cSrcweir pImpCursor->Clear();
615cdf0e10cSrcweir pGridMap->OutputSizeChanged();
616cdf0e10cSrcweir AdjustScrollBars();
617cdf0e10cSrcweir DocRectChanged();
618cdf0e10cSrcweir }
619cdf0e10cSrcweir }
620cdf0e10cSrcweir
InitPredecessors()621cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::InitPredecessors()
622cdf0e10cSrcweir {
623cdf0e10cSrcweir DBG_ASSERT(!pHead,"SvxIconChoiceCtrl_Impl::InitPredecessors() >> Already initialized");
624cdf0e10cSrcweir sal_uLong nCount = aEntries.Count();
625cdf0e10cSrcweir if( nCount )
626cdf0e10cSrcweir {
627cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pPrev = (SvxIconChoiceCtrlEntry*)aEntries.GetObject( 0 );
628cdf0e10cSrcweir for( sal_uLong nCur = 1; nCur <= nCount; nCur++ )
629cdf0e10cSrcweir {
630cdf0e10cSrcweir pPrev->ClearFlags( ICNVIEW_FLAG_POS_LOCKED | ICNVIEW_FLAG_POS_MOVED |
631cdf0e10cSrcweir ICNVIEW_FLAG_PRED_SET);
632cdf0e10cSrcweir
633cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pNext;
634cdf0e10cSrcweir if( nCur == nCount )
635cdf0e10cSrcweir pNext = (SvxIconChoiceCtrlEntry*)aEntries.GetObject( 0 );
636cdf0e10cSrcweir else
637cdf0e10cSrcweir pNext = (SvxIconChoiceCtrlEntry*)aEntries.GetObject( nCur );
638cdf0e10cSrcweir pPrev->pflink = pNext;
639cdf0e10cSrcweir pNext->pblink = pPrev;
640cdf0e10cSrcweir pPrev = pNext;
641cdf0e10cSrcweir }
642cdf0e10cSrcweir pHead = (SvxIconChoiceCtrlEntry*)aEntries.GetObject( 0 );
643cdf0e10cSrcweir }
644cdf0e10cSrcweir else
645cdf0e10cSrcweir pHead = 0;
646cdf0e10cSrcweir nFlags &= ~F_MOVED_ENTRIES;
647cdf0e10cSrcweir }
648cdf0e10cSrcweir
ClearPredecessors()649cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::ClearPredecessors()
650cdf0e10cSrcweir {
651cdf0e10cSrcweir if( pHead )
652cdf0e10cSrcweir {
653cdf0e10cSrcweir sal_uLong nCount = aEntries.Count();
654cdf0e10cSrcweir for( sal_uLong nCur = 0; nCur < nCount; nCur++ )
655cdf0e10cSrcweir {
656cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pCur = (SvxIconChoiceCtrlEntry*)aEntries.GetObject( nCur );
657cdf0e10cSrcweir pCur->pflink = 0;
658cdf0e10cSrcweir pCur->pblink = 0;
659cdf0e10cSrcweir pCur->ClearFlags( ICNVIEW_FLAG_PRED_SET );
660cdf0e10cSrcweir }
661cdf0e10cSrcweir pHead = 0;
662cdf0e10cSrcweir }
663cdf0e10cSrcweir }
664cdf0e10cSrcweir
Arrange(sal_Bool bKeepPredecessors,long nSetMaxVirtWidth,long nSetMaxVirtHeight)665cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::Arrange( sal_Bool bKeepPredecessors, long nSetMaxVirtWidth, long nSetMaxVirtHeight )
666cdf0e10cSrcweir {
667cdf0e10cSrcweir if ( nSetMaxVirtWidth != 0 )
668cdf0e10cSrcweir nMaxVirtWidth = nSetMaxVirtWidth;
669cdf0e10cSrcweir else
670cdf0e10cSrcweir nMaxVirtWidth = aOutputSize.Width();
671cdf0e10cSrcweir
672cdf0e10cSrcweir if ( nSetMaxVirtHeight != 0 )
673cdf0e10cSrcweir nMaxVirtHeight = nSetMaxVirtHeight;
674cdf0e10cSrcweir else
675cdf0e10cSrcweir nMaxVirtHeight = aOutputSize.Height();
676cdf0e10cSrcweir
677cdf0e10cSrcweir ImpArrange( bKeepPredecessors );
678cdf0e10cSrcweir }
679cdf0e10cSrcweir
ImpArrange(sal_Bool bKeepPredecessors)680cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::ImpArrange( sal_Bool bKeepPredecessors )
681cdf0e10cSrcweir {
682cdf0e10cSrcweir static Point aEmptyPoint;
683cdf0e10cSrcweir
684cdf0e10cSrcweir sal_Bool bOldUpdate = bUpdateMode;
685cdf0e10cSrcweir Rectangle aCurOutputArea( GetOutputRect() );
686cdf0e10cSrcweir if( (nWinBits & WB_SMART_ARRANGE) && aCurOutputArea.TopLeft() != aEmptyPoint )
687cdf0e10cSrcweir bUpdateMode = sal_False;
688cdf0e10cSrcweir aAutoArrangeTimer.Stop();
689cdf0e10cSrcweir nFlags &= ~F_MOVED_ENTRIES;
690cdf0e10cSrcweir nFlags |= F_ARRANGING;
691cdf0e10cSrcweir StopEditTimer();
692cdf0e10cSrcweir ShowCursor( sal_False );
693cdf0e10cSrcweir ResetVirtSize();
694cdf0e10cSrcweir if( !bKeepPredecessors )
695cdf0e10cSrcweir ClearPredecessors();
696cdf0e10cSrcweir bBoundRectsDirty = sal_False;
697cdf0e10cSrcweir SetOrigin( Point() );
698cdf0e10cSrcweir VisRectChanged();
699cdf0e10cSrcweir RecalcAllBoundingRectsSmart();
700cdf0e10cSrcweir // in der Detailsview muss das Invalidieren intelligenter erfolgen
701cdf0e10cSrcweir //if( !(nWinBits & WB_DETAILS ))
702cdf0e10cSrcweir pView->Invalidate( INVALIDATE_NOCHILDREN );
703cdf0e10cSrcweir nFlags &= ~F_ARRANGING;
704cdf0e10cSrcweir if( (nWinBits & WB_SMART_ARRANGE) && aCurOutputArea.TopLeft() != aEmptyPoint )
705cdf0e10cSrcweir {
706cdf0e10cSrcweir MakeVisible( aCurOutputArea );
707cdf0e10cSrcweir SetUpdateMode( bOldUpdate );
708cdf0e10cSrcweir }
709cdf0e10cSrcweir ShowCursor( sal_True );
710cdf0e10cSrcweir }
711cdf0e10cSrcweir
Paint(const Rectangle & rRect)712cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::Paint( const Rectangle& rRect )
713cdf0e10cSrcweir {
714cdf0e10cSrcweir bEndScrollInvalidate = sal_False;
715cdf0e10cSrcweir
716cdf0e10cSrcweir #if defined(OV_DRAWGRID)
717cdf0e10cSrcweir Color aOldColor ( pView->GetLineColor() );
718cdf0e10cSrcweir Color aColor( COL_BLACK );
719cdf0e10cSrcweir pView->SetLineColor( aColor );
720cdf0e10cSrcweir Point aOffs( pView->GetMapMode().GetOrigin());
721cdf0e10cSrcweir Size aXSize( pView->GetOutputSizePixel() );
722cdf0e10cSrcweir
723cdf0e10cSrcweir {
724cdf0e10cSrcweir Point aStart( LROFFS_WINBORDER, 0 );
725cdf0e10cSrcweir Point aEnd( LROFFS_WINBORDER, aXSize.Height());
726cdf0e10cSrcweir aStart -= aOffs;
727cdf0e10cSrcweir aEnd -= aOffs;
728cdf0e10cSrcweir pView->DrawLine( aStart, aEnd );
729cdf0e10cSrcweir }
730cdf0e10cSrcweir {
731cdf0e10cSrcweir Point aStart( 0, TBOFFS_WINBORDER );
732cdf0e10cSrcweir Point aEnd( aXSize.Width(), TBOFFS_WINBORDER );
733cdf0e10cSrcweir aStart -= aOffs;
734cdf0e10cSrcweir aEnd -= aOffs;
735cdf0e10cSrcweir pView->DrawLine( aStart, aEnd );
736cdf0e10cSrcweir }
737cdf0e10cSrcweir
738cdf0e10cSrcweir for( long nDX = nGridDX; nDX <= aXSize.Width(); nDX += nGridDX )
739cdf0e10cSrcweir {
740cdf0e10cSrcweir Point aStart( nDX+LROFFS_WINBORDER, 0 );
741cdf0e10cSrcweir Point aEnd( nDX+LROFFS_WINBORDER, aXSize.Height());
742cdf0e10cSrcweir aStart -= aOffs;
743cdf0e10cSrcweir aEnd -= aOffs;
744cdf0e10cSrcweir pView->DrawLine( aStart, aEnd );
745cdf0e10cSrcweir }
746cdf0e10cSrcweir for( long nDY = nGridDY; nDY <= aXSize.Height(); nDY += nGridDY )
747cdf0e10cSrcweir {
748cdf0e10cSrcweir Point aStart( 0, nDY+TBOFFS_WINBORDER );
749cdf0e10cSrcweir Point aEnd( aXSize.Width(), nDY+TBOFFS_WINBORDER );
750cdf0e10cSrcweir aStart -= aOffs;
751cdf0e10cSrcweir aEnd -= aOffs;
752cdf0e10cSrcweir pView->DrawLine( aStart, aEnd );
753cdf0e10cSrcweir }
754cdf0e10cSrcweir pView->SetLineColor( aOldColor );
755cdf0e10cSrcweir #endif
756cdf0e10cSrcweir nFlags |= F_PAINTED;
757cdf0e10cSrcweir
758cdf0e10cSrcweir if( !aEntries.Count() )
759cdf0e10cSrcweir return;
760cdf0e10cSrcweir if( !pCursor )
761cdf0e10cSrcweir {
762cdf0e10cSrcweir // set cursor to item with focus-flag
763cdf0e10cSrcweir sal_Bool bfound = sal_False;
764cdf0e10cSrcweir for ( sal_uLong i = 0; i < pView->GetEntryCount() && !bfound; i++)
765cdf0e10cSrcweir {
766cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = pView->GetEntry ( i );
767cdf0e10cSrcweir if( pEntry->IsFocused() )
768cdf0e10cSrcweir {
769cdf0e10cSrcweir pCursor = pEntry;
770cdf0e10cSrcweir bfound=sal_True;
771cdf0e10cSrcweir }
772cdf0e10cSrcweir }
773cdf0e10cSrcweir
774cdf0e10cSrcweir if( !bfound )
775cdf0e10cSrcweir pCursor = (SvxIconChoiceCtrlEntry*)aEntries.First();
776cdf0e10cSrcweir }
777cdf0e10cSrcweir
778cdf0e10cSrcweir // Show Focus at Init-Time
779cdf0e10cSrcweir if ( pView->HasFocus() )
780cdf0e10cSrcweir GetFocus();
781cdf0e10cSrcweir
782cdf0e10cSrcweir sal_uLong nCount = pZOrderList->Count();
783cdf0e10cSrcweir if( !nCount )
784cdf0e10cSrcweir return;
785cdf0e10cSrcweir
786cdf0e10cSrcweir sal_Bool bResetClipRegion = sal_False;
787cdf0e10cSrcweir if( !pView->IsClipRegion() )
788cdf0e10cSrcweir {
789cdf0e10cSrcweir Rectangle aOutputArea( GetOutputRect() );
790cdf0e10cSrcweir bResetClipRegion = sal_True;
791cdf0e10cSrcweir pView->SetClipRegion( aOutputArea );
792cdf0e10cSrcweir }
793cdf0e10cSrcweir
794cdf0e10cSrcweir const sal_uInt16 nListInitSize = aEntries.Count() > USHRT_MAX ?
795cdf0e10cSrcweir USHRT_MAX : (sal_uInt16)aEntries.Count();
796cdf0e10cSrcweir List* pNewZOrderList = new List( nListInitSize );
797cdf0e10cSrcweir List* pPaintedEntries = new List( nListInitSize );
798cdf0e10cSrcweir
799cdf0e10cSrcweir sal_uLong nPos = 0;
800cdf0e10cSrcweir while( nCount )
801cdf0e10cSrcweir {
802cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)(pZOrderList->GetObject(nPos ));
803cdf0e10cSrcweir const Rectangle& rBoundRect = GetEntryBoundRect( pEntry );
804cdf0e10cSrcweir if( rRect.IsOver( rBoundRect ) )
805cdf0e10cSrcweir {
806cdf0e10cSrcweir PaintEntry( pEntry, rBoundRect.TopLeft(), pView, sal_True );
807cdf0e10cSrcweir // Eintraege, die neu gezeichnet werden, auf Top setzen
808cdf0e10cSrcweir pPaintedEntries->Insert( pEntry, LIST_APPEND );
809cdf0e10cSrcweir }
810cdf0e10cSrcweir else
811cdf0e10cSrcweir pNewZOrderList->Insert( pEntry, LIST_APPEND );
812cdf0e10cSrcweir
813cdf0e10cSrcweir nCount--;
814cdf0e10cSrcweir nPos++;
815cdf0e10cSrcweir }
816cdf0e10cSrcweir delete pZOrderList;
817cdf0e10cSrcweir pZOrderList = pNewZOrderList;
818cdf0e10cSrcweir nCount = pPaintedEntries->Count();
819cdf0e10cSrcweir if( nCount )
820cdf0e10cSrcweir {
821cdf0e10cSrcweir for( sal_uLong nCur = 0; nCur < nCount; nCur++ )
822cdf0e10cSrcweir pZOrderList->Insert( pPaintedEntries->GetObject(nCur), LIST_APPEND);
823cdf0e10cSrcweir }
824cdf0e10cSrcweir delete pPaintedEntries;
825cdf0e10cSrcweir
826cdf0e10cSrcweir if( bResetClipRegion )
827cdf0e10cSrcweir pView->SetClipRegion();
828cdf0e10cSrcweir }
829cdf0e10cSrcweir
RepaintEntries(sal_uInt16 nEntryFlagsMask)830cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::RepaintEntries( sal_uInt16 nEntryFlagsMask )
831cdf0e10cSrcweir {
832cdf0e10cSrcweir const sal_uLong nCount = pZOrderList->Count();
833cdf0e10cSrcweir if( !nCount )
834cdf0e10cSrcweir return;
835cdf0e10cSrcweir
836cdf0e10cSrcweir sal_Bool bResetClipRegion = sal_False;
837cdf0e10cSrcweir Rectangle aOutRect( GetOutputRect() );
838cdf0e10cSrcweir if( !pView->IsClipRegion() )
839cdf0e10cSrcweir {
840cdf0e10cSrcweir bResetClipRegion = sal_True;
841cdf0e10cSrcweir pView->SetClipRegion( aOutRect );
842cdf0e10cSrcweir }
843cdf0e10cSrcweir for( sal_uLong nCur = 0; nCur < nCount; nCur++ )
844cdf0e10cSrcweir {
845cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)(pZOrderList->GetObject(nCur));
846cdf0e10cSrcweir if( pEntry->GetFlags() & nEntryFlagsMask )
847cdf0e10cSrcweir {
848cdf0e10cSrcweir const Rectangle& rBoundRect = GetEntryBoundRect( pEntry );
849cdf0e10cSrcweir if( aOutRect.IsOver( rBoundRect ) )
850cdf0e10cSrcweir PaintEntry( pEntry, rBoundRect.TopLeft() );
851cdf0e10cSrcweir }
852cdf0e10cSrcweir }
853cdf0e10cSrcweir if( bResetClipRegion )
854cdf0e10cSrcweir pView->SetClipRegion();
855cdf0e10cSrcweir }
856cdf0e10cSrcweir
857cdf0e10cSrcweir
InitScrollBarBox()858cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::InitScrollBarBox()
859cdf0e10cSrcweir {
860cdf0e10cSrcweir aScrBarBox.SetSizePixel( Size(nVerSBarWidth-1, nHorSBarHeight-1) );
861cdf0e10cSrcweir Size aSize( pView->GetOutputSizePixel() );
862cdf0e10cSrcweir aScrBarBox.SetPosPixel( Point(aSize.Width()-nVerSBarWidth+1, aSize.Height()-nHorSBarHeight+1));
863cdf0e10cSrcweir }
864cdf0e10cSrcweir
GetItem(SvxIconChoiceCtrlEntry * pEntry,const Point & rAbsPos)865cdf0e10cSrcweir IcnViewFieldType SvxIconChoiceCtrl_Impl::GetItem( SvxIconChoiceCtrlEntry* pEntry,
866cdf0e10cSrcweir const Point& rAbsPos )
867cdf0e10cSrcweir {
868cdf0e10cSrcweir Rectangle aRect( CalcTextRect( pEntry ) );
869cdf0e10cSrcweir if( aRect.IsInside( rAbsPos ) )
870cdf0e10cSrcweir return IcnViewFieldTypeText;
871cdf0e10cSrcweir
872cdf0e10cSrcweir aRect = CalcBmpRect( pEntry );
873cdf0e10cSrcweir if( aRect.IsInside( rAbsPos ) )
874cdf0e10cSrcweir return IcnViewFieldTypeImage;
875cdf0e10cSrcweir
876cdf0e10cSrcweir return IcnViewFieldTypeDontknow;
877cdf0e10cSrcweir }
878cdf0e10cSrcweir
MouseButtonDown(const MouseEvent & rMEvt)879cdf0e10cSrcweir sal_Bool SvxIconChoiceCtrl_Impl::MouseButtonDown( const MouseEvent& rMEvt)
880cdf0e10cSrcweir {
881cdf0e10cSrcweir sal_Bool bHandled = sal_True;
882cdf0e10cSrcweir bHighlightFramePressed = sal_False;
883cdf0e10cSrcweir StopEditTimer();
884cdf0e10cSrcweir sal_Bool bGotFocus = (sal_Bool)(!pView->HasFocus() && !(nWinBits & WB_NOPOINTERFOCUS));
885cdf0e10cSrcweir if( !(nWinBits & WB_NOPOINTERFOCUS) )
886cdf0e10cSrcweir pView->GrabFocus();
887cdf0e10cSrcweir
888cdf0e10cSrcweir Point aDocPos( rMEvt.GetPosPixel() );
889cdf0e10cSrcweir if(aDocPos.X()>=aOutputSize.Width() || aDocPos.Y()>=aOutputSize.Height())
890cdf0e10cSrcweir return sal_False;
891cdf0e10cSrcweir ToDocPos( aDocPos );
892cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = GetEntry( aDocPos, sal_True );
893cdf0e10cSrcweir if( pEntry )
894cdf0e10cSrcweir MakeEntryVisible( pEntry, sal_False );
895cdf0e10cSrcweir
896cdf0e10cSrcweir if( rMEvt.IsShift() && eSelectionMode != SINGLE_SELECTION )
897cdf0e10cSrcweir {
898cdf0e10cSrcweir if( pEntry )
899cdf0e10cSrcweir SetCursor_Impl( pCursor, pEntry, rMEvt.IsMod1(), rMEvt.IsShift(), sal_True);
900cdf0e10cSrcweir return sal_True;
901cdf0e10cSrcweir }
902cdf0e10cSrcweir
903cdf0e10cSrcweir if( pAnchor && (rMEvt.IsShift() || rMEvt.IsMod1())) // Tastaturselektion?
904cdf0e10cSrcweir {
905cdf0e10cSrcweir DBG_ASSERT(eSelectionMode != SINGLE_SELECTION,"Invalid selection mode");
906cdf0e10cSrcweir if( rMEvt.IsMod1() )
907cdf0e10cSrcweir nFlags |= F_ADD_MODE;
908cdf0e10cSrcweir
909cdf0e10cSrcweir if( rMEvt.IsShift() )
910cdf0e10cSrcweir {
911cdf0e10cSrcweir Rectangle aRect( GetEntryBoundRect( pAnchor ));
912cdf0e10cSrcweir if( pEntry )
913cdf0e10cSrcweir aRect.Union( GetEntryBoundRect( pEntry ) );
914cdf0e10cSrcweir else
915cdf0e10cSrcweir {
916cdf0e10cSrcweir Rectangle aTempRect( aDocPos, Size(1,1));
917cdf0e10cSrcweir aRect.Union( aTempRect );
918cdf0e10cSrcweir }
919cdf0e10cSrcweir aCurSelectionRect = aRect;
920cdf0e10cSrcweir SelectRect( aRect, (nFlags & F_ADD_MODE)!=0, &aSelectedRectList );
921cdf0e10cSrcweir }
922cdf0e10cSrcweir else if( rMEvt.IsMod1() )
923cdf0e10cSrcweir {
924cdf0e10cSrcweir AddSelectedRect( aCurSelectionRect );
925cdf0e10cSrcweir pAnchor = 0;
926cdf0e10cSrcweir aCurSelectionRect.SetPos( aDocPos );
927cdf0e10cSrcweir }
928cdf0e10cSrcweir
929cdf0e10cSrcweir if( !pEntry && !(nWinBits & WB_NODRAGSELECTION))
930cdf0e10cSrcweir pView->StartTracking( STARTTRACK_SCROLLREPEAT );
931cdf0e10cSrcweir return sal_True;
932cdf0e10cSrcweir }
933cdf0e10cSrcweir else
934cdf0e10cSrcweir {
935cdf0e10cSrcweir if( !pEntry )
936cdf0e10cSrcweir {
937cdf0e10cSrcweir if( eSelectionMode == MULTIPLE_SELECTION )
938cdf0e10cSrcweir {
939cdf0e10cSrcweir if( !rMEvt.IsMod1() ) // Ctrl
940cdf0e10cSrcweir {
941cdf0e10cSrcweir if( !bGotFocus )
942cdf0e10cSrcweir {
943cdf0e10cSrcweir SetNoSelection();
944cdf0e10cSrcweir ClearSelectedRectList();
945cdf0e10cSrcweir }
946cdf0e10cSrcweir }
947cdf0e10cSrcweir else
948cdf0e10cSrcweir nFlags |= F_ADD_MODE;
949cdf0e10cSrcweir aCurSelectionRect.SetPos( aDocPos );
950cdf0e10cSrcweir pView->StartTracking( STARTTRACK_SCROLLREPEAT );
951cdf0e10cSrcweir }
952cdf0e10cSrcweir else
953cdf0e10cSrcweir bHandled = sal_False;
954cdf0e10cSrcweir return bHandled;
955cdf0e10cSrcweir }
956cdf0e10cSrcweir }
957cdf0e10cSrcweir sal_Bool bSelected = pEntry->IsSelected();
958cdf0e10cSrcweir sal_Bool bEditingEnabled = IsEntryEditingEnabled();
959cdf0e10cSrcweir
960cdf0e10cSrcweir if( rMEvt.GetClicks() == 2 )
961cdf0e10cSrcweir {
962cdf0e10cSrcweir DeselectAllBut( pEntry );
963cdf0e10cSrcweir SelectEntry( pEntry, sal_True, sal_True, sal_False, sal_True );
964cdf0e10cSrcweir pHdlEntry = pEntry;
965cdf0e10cSrcweir pView->ClickIcon();
966cdf0e10cSrcweir }
967cdf0e10cSrcweir else
968cdf0e10cSrcweir {
969cdf0e10cSrcweir // Inplace-Editing ?
970cdf0e10cSrcweir if( rMEvt.IsMod2() ) // Alt?
971cdf0e10cSrcweir {
972cdf0e10cSrcweir if( bEntryEditingEnabled && pEntry &&
973cdf0e10cSrcweir pEntry->IsSelected())
974cdf0e10cSrcweir {
975cdf0e10cSrcweir if( pView->EditingEntry( pEntry ))
976cdf0e10cSrcweir EditEntry( pEntry );
977cdf0e10cSrcweir }
978cdf0e10cSrcweir }
979cdf0e10cSrcweir else if( eSelectionMode == SINGLE_SELECTION )
980cdf0e10cSrcweir {
981cdf0e10cSrcweir DeselectAllBut( pEntry );
982cdf0e10cSrcweir SetCursor( pEntry );
983cdf0e10cSrcweir if( bEditingEnabled && bSelected && !rMEvt.GetModifier() &&
984cdf0e10cSrcweir rMEvt.IsLeft() && IsTextHit( pEntry, aDocPos ) )
985cdf0e10cSrcweir {
986cdf0e10cSrcweir nFlags |= F_START_EDITTIMER_IN_MOUSEUP;
987cdf0e10cSrcweir }
988cdf0e10cSrcweir }
989cdf0e10cSrcweir else if( eSelectionMode == NO_SELECTION )
990cdf0e10cSrcweir {
991cdf0e10cSrcweir if( rMEvt.IsLeft() && (nWinBits & WB_HIGHLIGHTFRAME) )
992cdf0e10cSrcweir {
993cdf0e10cSrcweir pCurHighlightFrame = 0; // Neues painten des Frames erzwingen
994cdf0e10cSrcweir bHighlightFramePressed = sal_True;
995cdf0e10cSrcweir SetEntryHighlightFrame( pEntry, sal_True );
996cdf0e10cSrcweir }
997cdf0e10cSrcweir }
998cdf0e10cSrcweir else
999cdf0e10cSrcweir {
1000cdf0e10cSrcweir if( !rMEvt.GetModifier() && rMEvt.IsLeft() )
1001cdf0e10cSrcweir {
1002cdf0e10cSrcweir if( !bSelected )
1003cdf0e10cSrcweir {
1004cdf0e10cSrcweir DeselectAllBut( pEntry, sal_True /* Synchron painten */ );
1005cdf0e10cSrcweir SetCursor( pEntry );
1006cdf0e10cSrcweir SelectEntry( pEntry, sal_True, sal_True, sal_False, sal_True );
1007cdf0e10cSrcweir }
1008cdf0e10cSrcweir else
1009cdf0e10cSrcweir {
1010cdf0e10cSrcweir // erst im Up deselektieren, falls Move per D&D!
1011cdf0e10cSrcweir nFlags |= F_DOWN_DESELECT;
1012cdf0e10cSrcweir if( bEditingEnabled && IsTextHit( pEntry, aDocPos ) &&
1013cdf0e10cSrcweir rMEvt.IsLeft())
1014cdf0e10cSrcweir {
1015cdf0e10cSrcweir nFlags |= F_START_EDITTIMER_IN_MOUSEUP;
1016cdf0e10cSrcweir }
1017cdf0e10cSrcweir }
1018cdf0e10cSrcweir }
1019cdf0e10cSrcweir else if( rMEvt.IsMod1() )
1020cdf0e10cSrcweir nFlags |= F_DOWN_CTRL;
1021cdf0e10cSrcweir }
1022cdf0e10cSrcweir }
1023cdf0e10cSrcweir return bHandled;
1024cdf0e10cSrcweir }
1025cdf0e10cSrcweir
MouseButtonUp(const MouseEvent & rMEvt)1026cdf0e10cSrcweir sal_Bool SvxIconChoiceCtrl_Impl::MouseButtonUp( const MouseEvent& rMEvt )
1027cdf0e10cSrcweir {
1028cdf0e10cSrcweir sal_Bool bHandled = sal_False;
1029cdf0e10cSrcweir if( rMEvt.IsRight() && (nFlags & (F_DOWN_CTRL | F_DOWN_DESELECT) ))
1030cdf0e10cSrcweir {
1031cdf0e10cSrcweir nFlags &= ~(F_DOWN_CTRL | F_DOWN_DESELECT);
1032cdf0e10cSrcweir bHandled = sal_True;
1033cdf0e10cSrcweir }
1034cdf0e10cSrcweir
1035cdf0e10cSrcweir Point aDocPos( rMEvt.GetPosPixel() );
1036cdf0e10cSrcweir ToDocPos( aDocPos );
1037cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pDocEntry = GetEntry( aDocPos );
1038cdf0e10cSrcweir if( pDocEntry )
1039cdf0e10cSrcweir {
1040cdf0e10cSrcweir if( nFlags & F_DOWN_CTRL )
1041cdf0e10cSrcweir {
1042cdf0e10cSrcweir // Ctrl & MultiSelection
1043cdf0e10cSrcweir ToggleSelection( pDocEntry );
1044cdf0e10cSrcweir SetCursor( pDocEntry );
1045cdf0e10cSrcweir bHandled = sal_True;
1046cdf0e10cSrcweir }
1047cdf0e10cSrcweir else if( nFlags & F_DOWN_DESELECT )
1048cdf0e10cSrcweir {
1049cdf0e10cSrcweir DeselectAllBut( pDocEntry );
1050cdf0e10cSrcweir SetCursor( pDocEntry );
1051cdf0e10cSrcweir SelectEntry( pDocEntry, sal_True, sal_True, sal_False, sal_True );
1052cdf0e10cSrcweir bHandled = sal_True;
1053cdf0e10cSrcweir }
1054cdf0e10cSrcweir }
1055cdf0e10cSrcweir
1056cdf0e10cSrcweir nFlags &= ~(F_DOWN_CTRL | F_DOWN_DESELECT);
1057cdf0e10cSrcweir if( nFlags & F_START_EDITTIMER_IN_MOUSEUP )
1058cdf0e10cSrcweir {
1059cdf0e10cSrcweir bHandled = sal_True;
1060cdf0e10cSrcweir StartEditTimer();
1061cdf0e10cSrcweir nFlags &= ~F_START_EDITTIMER_IN_MOUSEUP;
1062cdf0e10cSrcweir }
1063cdf0e10cSrcweir
1064cdf0e10cSrcweir if((nWinBits & WB_HIGHLIGHTFRAME) && bHighlightFramePressed && pCurHighlightFrame)
1065cdf0e10cSrcweir {
1066cdf0e10cSrcweir bHandled = sal_True;
1067cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = pCurHighlightFrame;
1068cdf0e10cSrcweir pCurHighlightFrame = 0; // Neues painten des Frames erzwingen
1069cdf0e10cSrcweir bHighlightFramePressed = sal_False;
1070cdf0e10cSrcweir SetEntryHighlightFrame( pEntry, sal_True );
1071cdf0e10cSrcweir #if 0
1072cdf0e10cSrcweir CallSelectHandler( pCurHighlightFrame );
1073cdf0e10cSrcweir #else
1074cdf0e10cSrcweir pHdlEntry = pCurHighlightFrame;
1075cdf0e10cSrcweir pView->ClickIcon();
1076cdf0e10cSrcweir
1077cdf0e10cSrcweir // set focus on Icon
1078cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pOldCursor = pCursor;
1079cdf0e10cSrcweir SetCursor_Impl( pOldCursor, pHdlEntry, sal_False, sal_False, sal_True );
1080cdf0e10cSrcweir #endif
1081cdf0e10cSrcweir pHdlEntry = 0;
1082cdf0e10cSrcweir }
1083cdf0e10cSrcweir return bHandled;
1084cdf0e10cSrcweir }
1085cdf0e10cSrcweir
MouseMove(const MouseEvent & rMEvt)1086cdf0e10cSrcweir sal_Bool SvxIconChoiceCtrl_Impl::MouseMove( const MouseEvent& rMEvt )
1087cdf0e10cSrcweir {
1088cdf0e10cSrcweir const Point aDocPos( pView->PixelToLogic(rMEvt.GetPosPixel()) );
1089cdf0e10cSrcweir
1090cdf0e10cSrcweir if( pView->IsTracking() )
1091cdf0e10cSrcweir return sal_False;
1092cdf0e10cSrcweir else if( nWinBits & WB_HIGHLIGHTFRAME )
1093cdf0e10cSrcweir {
1094cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = GetEntry( aDocPos, sal_True );
1095cdf0e10cSrcweir SetEntryHighlightFrame( pEntry );
1096cdf0e10cSrcweir }
1097cdf0e10cSrcweir else
1098cdf0e10cSrcweir return sal_False;
1099cdf0e10cSrcweir return sal_True;
1100cdf0e10cSrcweir }
1101cdf0e10cSrcweir
Tracking(const TrackingEvent & rTEvt)1102cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::Tracking( const TrackingEvent& rTEvt )
1103cdf0e10cSrcweir {
1104cdf0e10cSrcweir if ( rTEvt.IsTrackingEnded() )
1105cdf0e10cSrcweir {
1106cdf0e10cSrcweir // Das Rechteck darf nicht "justified" sein, da seine
1107cdf0e10cSrcweir // TopLeft-Position u.U. zur Berechnung eines Ankers
1108cdf0e10cSrcweir // benutzt wird.
1109cdf0e10cSrcweir AddSelectedRect( aCurSelectionRect );
1110cdf0e10cSrcweir pView->HideTracking();
1111cdf0e10cSrcweir nFlags &= ~(F_ADD_MODE);
1112cdf0e10cSrcweir if( rTEvt.IsTrackingCanceled() )
1113cdf0e10cSrcweir SetNoSelection();
1114cdf0e10cSrcweir }
1115cdf0e10cSrcweir else
1116cdf0e10cSrcweir {
1117cdf0e10cSrcweir Point aPosPixel = rTEvt.GetMouseEvent().GetPosPixel();
1118cdf0e10cSrcweir Point aDocPos( aPosPixel );
1119cdf0e10cSrcweir ToDocPos( aDocPos );
1120cdf0e10cSrcweir
1121cdf0e10cSrcweir long nScrollDX, nScrollDY;
1122cdf0e10cSrcweir
1123cdf0e10cSrcweir CalcScrollOffsets( aPosPixel, nScrollDX, nScrollDY, sal_False );
1124cdf0e10cSrcweir if( nScrollDX || nScrollDY )
1125cdf0e10cSrcweir {
1126cdf0e10cSrcweir pView->HideTracking();
1127cdf0e10cSrcweir pView->Scroll( nScrollDX, nScrollDY );
1128cdf0e10cSrcweir }
1129cdf0e10cSrcweir Rectangle aRect( aCurSelectionRect.TopLeft(), aDocPos );
1130cdf0e10cSrcweir if( aRect != aCurSelectionRect )
1131cdf0e10cSrcweir {
1132cdf0e10cSrcweir pView->HideTracking();
1133cdf0e10cSrcweir sal_Bool bAdd = (nFlags & F_ADD_MODE) ? sal_True : sal_False;
1134cdf0e10cSrcweir SelectRect( aRect, bAdd, &aSelectedRectList );
1135cdf0e10cSrcweir }
1136cdf0e10cSrcweir pView->ShowTracking( aRect, SHOWTRACK_SMALL | SHOWTRACK_CLIP );
1137cdf0e10cSrcweir }
1138cdf0e10cSrcweir }
1139cdf0e10cSrcweir
SetCursor_Impl(SvxIconChoiceCtrlEntry * pOldCursor,SvxIconChoiceCtrlEntry * pNewCursor,sal_Bool bMod1,sal_Bool bShift,sal_Bool bPaintSync)1140cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SetCursor_Impl( SvxIconChoiceCtrlEntry* pOldCursor,
1141cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pNewCursor, sal_Bool bMod1, sal_Bool bShift, sal_Bool bPaintSync )
1142cdf0e10cSrcweir {
1143cdf0e10cSrcweir if( pNewCursor )
1144cdf0e10cSrcweir {
1145cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pFilterEntry = 0;
1146cdf0e10cSrcweir sal_Bool bDeselectAll = sal_False;
1147cdf0e10cSrcweir if( eSelectionMode != SINGLE_SELECTION )
1148cdf0e10cSrcweir {
1149cdf0e10cSrcweir if( !bMod1 && !bShift )
1150cdf0e10cSrcweir bDeselectAll = sal_True;
1151cdf0e10cSrcweir else if( bShift && !bMod1 && !pAnchor )
1152cdf0e10cSrcweir {
1153cdf0e10cSrcweir bDeselectAll = sal_True;
1154cdf0e10cSrcweir pFilterEntry = pOldCursor;
1155cdf0e10cSrcweir }
1156cdf0e10cSrcweir }
1157cdf0e10cSrcweir if( bDeselectAll )
1158cdf0e10cSrcweir DeselectAllBut( pFilterEntry, bPaintSync );
1159cdf0e10cSrcweir ShowCursor( sal_False );
1160cdf0e10cSrcweir MakeEntryVisible( pNewCursor );
1161cdf0e10cSrcweir SetCursor( pNewCursor );
1162cdf0e10cSrcweir if( bMod1 && !bShift )
1163cdf0e10cSrcweir {
1164cdf0e10cSrcweir if( pAnchor )
1165cdf0e10cSrcweir {
1166cdf0e10cSrcweir AddSelectedRect( pAnchor, pOldCursor );
1167cdf0e10cSrcweir pAnchor = 0;
1168cdf0e10cSrcweir }
1169cdf0e10cSrcweir }
1170cdf0e10cSrcweir else if( bShift )
1171cdf0e10cSrcweir {
1172cdf0e10cSrcweir if( !pAnchor )
1173cdf0e10cSrcweir pAnchor = pOldCursor;
1174cdf0e10cSrcweir if ( nWinBits & WB_ALIGN_LEFT )
1175cdf0e10cSrcweir SelectRange( pAnchor, pNewCursor, (nFlags & F_ADD_MODE)!=0 );
1176cdf0e10cSrcweir else
1177cdf0e10cSrcweir SelectRect(pAnchor,pNewCursor,(nFlags & F_ADD_MODE)!=0,&aSelectedRectList);
1178cdf0e10cSrcweir }
1179cdf0e10cSrcweir else
1180cdf0e10cSrcweir {
1181cdf0e10cSrcweir SelectEntry( pCursor, sal_True, sal_True, sal_False, bPaintSync );
1182cdf0e10cSrcweir aCurSelectionRect = GetEntryBoundRect( pCursor );
1183*2bfcd321SSteve Yin CallEventListeners( VCLEVENT_LISTBOX_SELECT, pCursor );
1184cdf0e10cSrcweir }
1185cdf0e10cSrcweir }
1186cdf0e10cSrcweir }
1187cdf0e10cSrcweir
KeyInput(const KeyEvent & rKEvt)1188cdf0e10cSrcweir sal_Bool SvxIconChoiceCtrl_Impl::KeyInput( const KeyEvent& rKEvt )
1189cdf0e10cSrcweir {
1190cdf0e10cSrcweir StopEditTimer();
1191cdf0e10cSrcweir
1192cdf0e10cSrcweir sal_Bool bMod2 = rKEvt.GetKeyCode().IsMod2();
1193cdf0e10cSrcweir sal_Unicode cChar = rKEvt.GetCharCode();
1194cdf0e10cSrcweir sal_uLong nPos = (sal_uLong)-1;
1195cdf0e10cSrcweir if ( bMod2 && cChar && IsMnemonicChar( cChar, nPos ) )
1196cdf0e10cSrcweir {
1197cdf0e10cSrcweir // shortcut is clicked
1198cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pNewCursor = GetEntry( nPos );
1199cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pOldCursor = pCursor;
1200cdf0e10cSrcweir if ( pNewCursor != pOldCursor )
1201cdf0e10cSrcweir SetCursor_Impl( pOldCursor, pNewCursor, sal_False, sal_False, sal_False );
1202cdf0e10cSrcweir return sal_True;
1203cdf0e10cSrcweir }
1204cdf0e10cSrcweir
1205cdf0e10cSrcweir if ( bMod2 )
1206cdf0e10cSrcweir // no actions with <ALT>
1207cdf0e10cSrcweir return sal_False;
1208cdf0e10cSrcweir
1209cdf0e10cSrcweir sal_Bool bKeyUsed = sal_True;
1210cdf0e10cSrcweir sal_Bool bMod1 = rKEvt.GetKeyCode().IsMod1();
1211cdf0e10cSrcweir sal_Bool bShift = rKEvt.GetKeyCode().IsShift();
1212cdf0e10cSrcweir
1213cdf0e10cSrcweir if( eSelectionMode == SINGLE_SELECTION || eSelectionMode == NO_SELECTION)
1214cdf0e10cSrcweir {
1215cdf0e10cSrcweir bShift = sal_False;
1216cdf0e10cSrcweir bMod1 = sal_False;
1217cdf0e10cSrcweir }
1218cdf0e10cSrcweir
1219cdf0e10cSrcweir if( bMod1 )
1220cdf0e10cSrcweir nFlags |= F_ADD_MODE;
1221cdf0e10cSrcweir sal_Bool bDeselectAll = sal_False;
1222cdf0e10cSrcweir if( eSelectionMode != SINGLE_SELECTION )
1223cdf0e10cSrcweir {
1224cdf0e10cSrcweir if( !bMod1 && !bShift )
1225cdf0e10cSrcweir bDeselectAll = sal_True;
1226cdf0e10cSrcweir if( bShift && !bMod1 && !pAnchor )
1227cdf0e10cSrcweir bDeselectAll = sal_True;
1228cdf0e10cSrcweir }
1229cdf0e10cSrcweir
1230cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pNewCursor;
1231cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pOldCursor = pCursor;
1232cdf0e10cSrcweir
1233cdf0e10cSrcweir sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
1234cdf0e10cSrcweir switch( nCode )
1235cdf0e10cSrcweir {
1236cdf0e10cSrcweir case KEY_UP:
1237cdf0e10cSrcweir case KEY_PAGEUP:
1238cdf0e10cSrcweir if( pCursor )
1239cdf0e10cSrcweir {
1240cdf0e10cSrcweir MakeEntryVisible( pCursor );
1241cdf0e10cSrcweir if( nCode == KEY_UP )
1242cdf0e10cSrcweir pNewCursor = pImpCursor->GoUpDown(pCursor,sal_False);
1243cdf0e10cSrcweir else
1244cdf0e10cSrcweir pNewCursor = pImpCursor->GoPageUpDown(pCursor,sal_False);
1245cdf0e10cSrcweir SetCursor_Impl( pOldCursor, pNewCursor, bMod1, bShift, sal_True );
1246cdf0e10cSrcweir if( !pNewCursor )
1247cdf0e10cSrcweir {
1248cdf0e10cSrcweir Rectangle aRect( GetEntryBoundRect( pCursor ) );
1249cdf0e10cSrcweir if( aRect.Top())
1250cdf0e10cSrcweir {
1251cdf0e10cSrcweir aRect.Bottom() -= aRect.Top();
1252cdf0e10cSrcweir aRect.Top() = 0;
1253cdf0e10cSrcweir MakeVisible( aRect );
1254cdf0e10cSrcweir }
1255cdf0e10cSrcweir }
1256cdf0e10cSrcweir
1257cdf0e10cSrcweir if ( bChooseWithCursor && pNewCursor != NULL )
1258cdf0e10cSrcweir {
1259cdf0e10cSrcweir pHdlEntry = pNewCursor;//GetCurEntry();
1260cdf0e10cSrcweir pCurHighlightFrame = pHdlEntry;
1261cdf0e10cSrcweir pView->ClickIcon();
1262cdf0e10cSrcweir pCurHighlightFrame = NULL;
1263cdf0e10cSrcweir }
1264cdf0e10cSrcweir }
1265cdf0e10cSrcweir break;
1266cdf0e10cSrcweir
1267cdf0e10cSrcweir case KEY_DOWN:
1268cdf0e10cSrcweir case KEY_PAGEDOWN:
1269cdf0e10cSrcweir if( pCursor )
1270cdf0e10cSrcweir {
1271cdf0e10cSrcweir if( nCode == KEY_DOWN )
1272cdf0e10cSrcweir pNewCursor=pImpCursor->GoUpDown( pCursor,sal_True );
1273cdf0e10cSrcweir else
1274cdf0e10cSrcweir pNewCursor=pImpCursor->GoPageUpDown( pCursor,sal_True );
1275cdf0e10cSrcweir SetCursor_Impl( pOldCursor, pNewCursor, bMod1, bShift, sal_True );
1276cdf0e10cSrcweir
1277cdf0e10cSrcweir if ( bChooseWithCursor && pNewCursor != NULL)
1278cdf0e10cSrcweir {
1279cdf0e10cSrcweir pHdlEntry = pNewCursor;//GetCurEntry();
1280cdf0e10cSrcweir pCurHighlightFrame = pHdlEntry;
1281cdf0e10cSrcweir pView->ClickIcon();
1282cdf0e10cSrcweir pCurHighlightFrame = NULL;
1283cdf0e10cSrcweir }
1284cdf0e10cSrcweir }
1285cdf0e10cSrcweir break;
1286cdf0e10cSrcweir
1287cdf0e10cSrcweir case KEY_RIGHT:
1288cdf0e10cSrcweir if( pCursor )
1289cdf0e10cSrcweir {
1290cdf0e10cSrcweir pNewCursor=pImpCursor->GoLeftRight(pCursor,sal_True );
1291cdf0e10cSrcweir SetCursor_Impl( pOldCursor, pNewCursor, bMod1, bShift, sal_True );
1292cdf0e10cSrcweir }
1293cdf0e10cSrcweir break;
1294cdf0e10cSrcweir
1295cdf0e10cSrcweir case KEY_LEFT:
1296cdf0e10cSrcweir if( pCursor )
1297cdf0e10cSrcweir {
1298cdf0e10cSrcweir MakeEntryVisible( pCursor );
1299cdf0e10cSrcweir pNewCursor = pImpCursor->GoLeftRight(pCursor,sal_False );
1300cdf0e10cSrcweir SetCursor_Impl( pOldCursor, pNewCursor, bMod1, bShift, sal_True );
1301cdf0e10cSrcweir if( !pNewCursor )
1302cdf0e10cSrcweir {
1303cdf0e10cSrcweir Rectangle aRect( GetEntryBoundRect(pCursor));
1304cdf0e10cSrcweir if( aRect.Left() )
1305cdf0e10cSrcweir {
1306cdf0e10cSrcweir aRect.Right() -= aRect.Left();
1307cdf0e10cSrcweir aRect.Left() = 0;
1308cdf0e10cSrcweir MakeVisible( aRect );
1309cdf0e10cSrcweir }
1310cdf0e10cSrcweir }
1311cdf0e10cSrcweir }
1312cdf0e10cSrcweir break;
1313cdf0e10cSrcweir
1314cdf0e10cSrcweir // wird vom VCL-Tracking gesteuert
1315cdf0e10cSrcweir #if 0
1316cdf0e10cSrcweir case KEY_ESCAPE:
1317cdf0e10cSrcweir if( pView->IsTracking() )
1318cdf0e10cSrcweir {
1319cdf0e10cSrcweir HideSelectionRect();
1320cdf0e10cSrcweir //SelectAll( sal_False );
1321cdf0e10cSrcweir SetNoSelection();
1322cdf0e10cSrcweir ClearSelectedRectList();
1323cdf0e10cSrcweir nFlags &= ~F_TRACKING;
1324cdf0e10cSrcweir }
1325cdf0e10cSrcweir else
1326cdf0e10cSrcweir bKeyUsed = sal_False;
1327cdf0e10cSrcweir break;
1328cdf0e10cSrcweir #endif
1329cdf0e10cSrcweir
1330cdf0e10cSrcweir
1331cdf0e10cSrcweir case KEY_F2:
1332cdf0e10cSrcweir if( !bMod1 && !bShift )
1333cdf0e10cSrcweir EditTimeoutHdl( 0 );
1334cdf0e10cSrcweir else
1335cdf0e10cSrcweir bKeyUsed = sal_False;
1336cdf0e10cSrcweir break;
1337cdf0e10cSrcweir
1338cdf0e10cSrcweir case KEY_F8:
1339cdf0e10cSrcweir if( rKEvt.GetKeyCode().IsShift() )
1340cdf0e10cSrcweir {
1341cdf0e10cSrcweir if( nFlags & F_ADD_MODE )
1342cdf0e10cSrcweir nFlags &= (~F_ADD_MODE);
1343cdf0e10cSrcweir else
1344cdf0e10cSrcweir nFlags |= F_ADD_MODE;
1345cdf0e10cSrcweir }
1346cdf0e10cSrcweir else
1347cdf0e10cSrcweir bKeyUsed = sal_False;
1348cdf0e10cSrcweir break;
1349cdf0e10cSrcweir
1350cdf0e10cSrcweir case KEY_SPACE:
1351cdf0e10cSrcweir if( pCursor && eSelectionMode != SINGLE_SELECTION )
1352cdf0e10cSrcweir {
1353cdf0e10cSrcweir if( !bMod1 )
1354cdf0e10cSrcweir {
1355cdf0e10cSrcweir //SelectAll( sal_False );
1356cdf0e10cSrcweir SetNoSelection();
1357cdf0e10cSrcweir ClearSelectedRectList();
1358cdf0e10cSrcweir
1359cdf0e10cSrcweir // click Icon with spacebar
1360cdf0e10cSrcweir SetEntryHighlightFrame( GetCurEntry(), sal_True );
1361cdf0e10cSrcweir pView->ClickIcon();
1362cdf0e10cSrcweir pHdlEntry = pCurHighlightFrame;
1363cdf0e10cSrcweir pCurHighlightFrame=0;
1364cdf0e10cSrcweir }
1365cdf0e10cSrcweir else
1366cdf0e10cSrcweir ToggleSelection( pCursor );
1367cdf0e10cSrcweir }
1368cdf0e10cSrcweir break;
1369cdf0e10cSrcweir
1370cdf0e10cSrcweir #ifdef DBG_UTIL
1371cdf0e10cSrcweir case KEY_F10:
1372cdf0e10cSrcweir if( rKEvt.GetKeyCode().IsShift() )
1373cdf0e10cSrcweir {
1374cdf0e10cSrcweir if( pCursor )
1375cdf0e10cSrcweir pView->SetEntryTextMode( IcnShowTextFull, pCursor );
1376cdf0e10cSrcweir }
1377cdf0e10cSrcweir if( rKEvt.GetKeyCode().IsMod1() )
1378cdf0e10cSrcweir {
1379cdf0e10cSrcweir if( pCursor )
1380cdf0e10cSrcweir pView->SetEntryTextMode( IcnShowTextShort, pCursor );
1381cdf0e10cSrcweir }
1382cdf0e10cSrcweir break;
1383cdf0e10cSrcweir #endif
1384cdf0e10cSrcweir
1385cdf0e10cSrcweir case KEY_ADD:
1386cdf0e10cSrcweir case KEY_DIVIDE :
1387cdf0e10cSrcweir case KEY_A:
1388cdf0e10cSrcweir if( bMod1 && (eSelectionMode != SINGLE_SELECTION))
1389cdf0e10cSrcweir SelectAll( sal_True );
1390cdf0e10cSrcweir else
1391cdf0e10cSrcweir bKeyUsed = sal_False;
1392cdf0e10cSrcweir break;
1393cdf0e10cSrcweir
1394cdf0e10cSrcweir case KEY_SUBTRACT:
1395cdf0e10cSrcweir case KEY_COMMA :
1396cdf0e10cSrcweir if( bMod1 )
1397cdf0e10cSrcweir SetNoSelection();
1398cdf0e10cSrcweir else
1399cdf0e10cSrcweir bKeyUsed = sal_False;
1400cdf0e10cSrcweir break;
1401cdf0e10cSrcweir
1402cdf0e10cSrcweir case KEY_RETURN:
1403cdf0e10cSrcweir if( bMod1 )
1404cdf0e10cSrcweir {
1405cdf0e10cSrcweir if( pCursor && bEntryEditingEnabled )
1406cdf0e10cSrcweir /*pView->*/EditEntry( pCursor );
1407cdf0e10cSrcweir }
1408cdf0e10cSrcweir else
1409cdf0e10cSrcweir bKeyUsed = sal_False;
1410cdf0e10cSrcweir break;
1411cdf0e10cSrcweir
1412cdf0e10cSrcweir case KEY_END:
1413cdf0e10cSrcweir if( pCursor )
1414cdf0e10cSrcweir {
1415cdf0e10cSrcweir pNewCursor = (SvxIconChoiceCtrlEntry*)aEntries.GetObject( aEntries.Count() - 1 );
1416cdf0e10cSrcweir SetCursor_Impl( pOldCursor, pNewCursor, bMod1, bShift, sal_True );
1417cdf0e10cSrcweir }
1418cdf0e10cSrcweir break;
1419cdf0e10cSrcweir
1420cdf0e10cSrcweir case KEY_HOME:
1421cdf0e10cSrcweir if( pCursor )
1422cdf0e10cSrcweir {
1423cdf0e10cSrcweir pNewCursor = (SvxIconChoiceCtrlEntry*)aEntries.GetObject( 0 );
1424cdf0e10cSrcweir SetCursor_Impl( pOldCursor, pNewCursor, bMod1, bShift, sal_True );
1425cdf0e10cSrcweir }
1426cdf0e10cSrcweir break;
1427cdf0e10cSrcweir
1428cdf0e10cSrcweir default:
1429cdf0e10cSrcweir bKeyUsed = sal_False;
1430cdf0e10cSrcweir
1431cdf0e10cSrcweir }
1432cdf0e10cSrcweir return bKeyUsed;
1433cdf0e10cSrcweir }
1434cdf0e10cSrcweir
1435cdf0e10cSrcweir // Berechnet TopLeft der Scrollbars (nicht ihre Groessen!)
PositionScrollBars(long nRealWidth,long nRealHeight)1436cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::PositionScrollBars( long nRealWidth, long nRealHeight )
1437cdf0e10cSrcweir {
1438cdf0e10cSrcweir // hor scrollbar
1439cdf0e10cSrcweir Point aPos( 0, nRealHeight );
1440cdf0e10cSrcweir aPos.Y() -= nHorSBarHeight;
1441cdf0e10cSrcweir
1442cdf0e10cSrcweir if( aHorSBar.GetPosPixel() != aPos )
1443cdf0e10cSrcweir aHorSBar.SetPosPixel( aPos );
1444cdf0e10cSrcweir
1445cdf0e10cSrcweir // ver scrollbar
1446cdf0e10cSrcweir aPos.X() = nRealWidth; aPos.Y() = 0;
1447cdf0e10cSrcweir aPos.X() -= nVerSBarWidth;
1448cdf0e10cSrcweir aPos.X()++;
1449cdf0e10cSrcweir aPos.Y()--;
1450cdf0e10cSrcweir
1451cdf0e10cSrcweir if( aVerSBar.GetPosPixel() != aPos )
1452cdf0e10cSrcweir aVerSBar.SetPosPixel( aPos );
1453cdf0e10cSrcweir }
1454cdf0e10cSrcweir
AdjustScrollBars(sal_Bool)1455cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::AdjustScrollBars( sal_Bool )
1456cdf0e10cSrcweir {
1457cdf0e10cSrcweir Rectangle aOldOutRect( GetOutputRect() );
1458cdf0e10cSrcweir long nVirtHeight = aVirtOutputSize.Height();
1459cdf0e10cSrcweir long nVirtWidth = aVirtOutputSize.Width();
1460cdf0e10cSrcweir
1461cdf0e10cSrcweir Size aOSize( pView->Control::GetOutputSizePixel() );
1462cdf0e10cSrcweir long nRealHeight = aOSize.Height();
1463cdf0e10cSrcweir long nRealWidth = aOSize.Width();
1464cdf0e10cSrcweir
1465cdf0e10cSrcweir PositionScrollBars( nRealWidth, nRealHeight );
1466cdf0e10cSrcweir
1467cdf0e10cSrcweir const MapMode& rMapMode = pView->GetMapMode();
1468cdf0e10cSrcweir Point aOrigin( rMapMode.GetOrigin() );
1469cdf0e10cSrcweir
1470cdf0e10cSrcweir long nVisibleWidth;
1471cdf0e10cSrcweir if( nRealWidth > nVirtWidth )
1472cdf0e10cSrcweir nVisibleWidth = nVirtWidth + aOrigin.X();
1473cdf0e10cSrcweir else
1474cdf0e10cSrcweir nVisibleWidth = nRealWidth;
1475cdf0e10cSrcweir
1476cdf0e10cSrcweir long nVisibleHeight;
1477cdf0e10cSrcweir if( nRealHeight > nVirtHeight )
1478cdf0e10cSrcweir nVisibleHeight = nVirtHeight + aOrigin.Y();
1479cdf0e10cSrcweir else
1480cdf0e10cSrcweir nVisibleHeight = nRealHeight;
1481cdf0e10cSrcweir
1482cdf0e10cSrcweir sal_Bool bVerSBar = ( nWinBits & WB_VSCROLL ) != 0;
1483cdf0e10cSrcweir sal_Bool bHorSBar = ( nWinBits & WB_HSCROLL ) != 0;
1484cdf0e10cSrcweir sal_Bool bNoVerSBar = ( nWinBits & WB_NOVSCROLL ) != 0;
1485cdf0e10cSrcweir sal_Bool bNoHorSBar = ( nWinBits & WB_NOHSCROLL ) != 0;
1486cdf0e10cSrcweir
1487cdf0e10cSrcweir sal_uInt16 nResult = 0;
1488cdf0e10cSrcweir if( nVirtHeight )
1489cdf0e10cSrcweir {
1490cdf0e10cSrcweir // activate ver scrollbar ?
1491cdf0e10cSrcweir if( !bNoVerSBar && (bVerSBar || ( nVirtHeight > nVisibleHeight)) )
1492cdf0e10cSrcweir {
1493cdf0e10cSrcweir nResult = 0x0001;
1494cdf0e10cSrcweir nRealWidth -= nVerSBarWidth;
1495cdf0e10cSrcweir
1496cdf0e10cSrcweir if( nRealWidth > nVirtWidth )
1497cdf0e10cSrcweir nVisibleWidth = nVirtWidth + aOrigin.X();
1498cdf0e10cSrcweir else
1499cdf0e10cSrcweir nVisibleWidth = nRealWidth;
1500cdf0e10cSrcweir
1501cdf0e10cSrcweir nFlags |= F_HOR_SBARSIZE_WITH_VBAR;
1502cdf0e10cSrcweir }
1503cdf0e10cSrcweir // activate hor scrollbar ?
1504cdf0e10cSrcweir if( !bNoHorSBar && (bHorSBar || (nVirtWidth > nVisibleWidth)) )
1505cdf0e10cSrcweir {
1506cdf0e10cSrcweir nResult |= 0x0002;
1507cdf0e10cSrcweir nRealHeight -= nHorSBarHeight;
1508cdf0e10cSrcweir
1509cdf0e10cSrcweir if( nRealHeight > nVirtHeight )
1510cdf0e10cSrcweir nVisibleHeight = nVirtHeight + aOrigin.Y();
1511cdf0e10cSrcweir else
1512cdf0e10cSrcweir nVisibleHeight = nRealHeight;
1513cdf0e10cSrcweir
1514cdf0e10cSrcweir // brauchen wir jetzt doch eine senkrechte Scrollbar ?
1515cdf0e10cSrcweir if( !(nResult & 0x0001) && // nur wenn nicht schon da
1516cdf0e10cSrcweir ( !bNoVerSBar && ((nVirtHeight > nVisibleHeight) || bVerSBar)) )
1517cdf0e10cSrcweir {
1518cdf0e10cSrcweir nResult = 3; // beide sind an
1519cdf0e10cSrcweir nRealWidth -= nVerSBarWidth;
1520cdf0e10cSrcweir
1521cdf0e10cSrcweir if( nRealWidth > nVirtWidth )
1522cdf0e10cSrcweir nVisibleWidth = nVirtWidth + aOrigin.X();
1523cdf0e10cSrcweir else
1524cdf0e10cSrcweir nVisibleWidth = nRealWidth;
1525cdf0e10cSrcweir
1526cdf0e10cSrcweir nFlags |= F_VER_SBARSIZE_WITH_HBAR;
1527cdf0e10cSrcweir }
1528cdf0e10cSrcweir }
1529cdf0e10cSrcweir }
1530cdf0e10cSrcweir
1531cdf0e10cSrcweir // size ver scrollbar
1532cdf0e10cSrcweir long nThumb = aVerSBar.GetThumbPos();
1533cdf0e10cSrcweir Size aSize( nVerSBarWidth, nRealHeight );
1534cdf0e10cSrcweir aSize.Height() += 2;
1535cdf0e10cSrcweir if( aSize != aVerSBar.GetSizePixel() )
1536cdf0e10cSrcweir aVerSBar.SetSizePixel( aSize );
1537cdf0e10cSrcweir aVerSBar.SetVisibleSize( nVisibleHeight );
1538cdf0e10cSrcweir aVerSBar.SetPageSize( GetScrollBarPageSize( nVisibleHeight ));
1539cdf0e10cSrcweir
1540cdf0e10cSrcweir if( nResult & 0x0001 )
1541cdf0e10cSrcweir {
1542cdf0e10cSrcweir aVerSBar.SetThumbPos( nThumb );
1543cdf0e10cSrcweir aVerSBar.Show();
1544cdf0e10cSrcweir }
1545cdf0e10cSrcweir else
1546cdf0e10cSrcweir {
1547cdf0e10cSrcweir aVerSBar.SetThumbPos( 0 );
1548cdf0e10cSrcweir aVerSBar.Hide();
1549cdf0e10cSrcweir }
1550cdf0e10cSrcweir
1551cdf0e10cSrcweir // size hor scrollbar
1552cdf0e10cSrcweir nThumb = aHorSBar.GetThumbPos();
1553cdf0e10cSrcweir aSize.Width() = nRealWidth;
1554cdf0e10cSrcweir aSize.Height() = nHorSBarHeight;
1555cdf0e10cSrcweir aSize.Width()++;
1556cdf0e10cSrcweir if( nResult & 0x0001 ) // vertikale Scrollbar ?
1557cdf0e10cSrcweir {
1558cdf0e10cSrcweir aSize.Width()++;
1559cdf0e10cSrcweir nRealWidth++;
1560cdf0e10cSrcweir }
1561cdf0e10cSrcweir if( aSize != aHorSBar.GetSizePixel() )
1562cdf0e10cSrcweir aHorSBar.SetSizePixel( aSize );
1563cdf0e10cSrcweir aHorSBar.SetVisibleSize( nVisibleWidth );
1564cdf0e10cSrcweir aHorSBar.SetPageSize( GetScrollBarPageSize(nVisibleWidth ));
1565cdf0e10cSrcweir if( nResult & 0x0002 )
1566cdf0e10cSrcweir {
1567cdf0e10cSrcweir aHorSBar.SetThumbPos( nThumb );
1568cdf0e10cSrcweir aHorSBar.Show();
1569cdf0e10cSrcweir }
1570cdf0e10cSrcweir else
1571cdf0e10cSrcweir {
1572cdf0e10cSrcweir aHorSBar.SetThumbPos( 0 );
1573cdf0e10cSrcweir aHorSBar.Hide();
1574cdf0e10cSrcweir }
1575cdf0e10cSrcweir
1576cdf0e10cSrcweir aOutputSize.Width() = nRealWidth;
1577cdf0e10cSrcweir if( nResult & 0x0002 ) // hor scrollbar ?
1578cdf0e10cSrcweir nRealHeight++; // weil unterer Rand geclippt wird
1579cdf0e10cSrcweir aOutputSize.Height() = nRealHeight;
1580cdf0e10cSrcweir
1581cdf0e10cSrcweir Rectangle aNewOutRect( GetOutputRect() );
1582cdf0e10cSrcweir if( aNewOutRect != aOldOutRect && pView->HasBackground() )
1583cdf0e10cSrcweir {
1584cdf0e10cSrcweir Wallpaper aPaper( pView->GetBackground() );
1585cdf0e10cSrcweir aPaper.SetRect( aNewOutRect );
1586cdf0e10cSrcweir pView->SetBackground( aPaper );
1587cdf0e10cSrcweir }
1588cdf0e10cSrcweir
1589cdf0e10cSrcweir if( (nResult & (0x0001|0x0002)) == (0x0001|0x0002) )
1590cdf0e10cSrcweir aScrBarBox.Show();
1591cdf0e10cSrcweir else
1592cdf0e10cSrcweir aScrBarBox.Hide();
1593cdf0e10cSrcweir }
1594cdf0e10cSrcweir
Resize()1595cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::Resize()
1596cdf0e10cSrcweir {
1597cdf0e10cSrcweir StopEditTimer();
1598cdf0e10cSrcweir InitScrollBarBox();
1599cdf0e10cSrcweir aOutputSize = pView->GetOutputSizePixel();
1600cdf0e10cSrcweir pImpCursor->Clear();
1601cdf0e10cSrcweir pGridMap->OutputSizeChanged();
1602cdf0e10cSrcweir
1603cdf0e10cSrcweir const Size& rSize = pView->Control::GetOutputSizePixel();
1604cdf0e10cSrcweir PositionScrollBars( rSize.Width(), rSize.Height() );
1605cdf0e10cSrcweir // Die ScrollBars werden asynchron ein/ausgeblendet, damit abgeleitete
1606cdf0e10cSrcweir // Klassen im Resize ein Arrange durchfuehren koennen, ohne dass
1607cdf0e10cSrcweir // die ScrollBars aufblitzen
1608cdf0e10cSrcweir // Wenn schon ein Event unterwegs ist, dann braucht kein neues verschickt werden,
1609cdf0e10cSrcweir // zumindest, solange es nur einen EventTypen gibt
1610cdf0e10cSrcweir if ( ! nUserEventAdjustScrBars )
1611cdf0e10cSrcweir nUserEventAdjustScrBars =
1612cdf0e10cSrcweir Application::PostUserEvent( LINK( this, SvxIconChoiceCtrl_Impl, UserEventHdl),
1613cdf0e10cSrcweir EVENTID_ADJUST_SCROLLBARS);
1614cdf0e10cSrcweir
1615cdf0e10cSrcweir if( pView->HasBackground() && !pView->GetBackground().IsScrollable() )
1616cdf0e10cSrcweir {
1617cdf0e10cSrcweir Rectangle aRect( GetOutputRect());
1618cdf0e10cSrcweir Wallpaper aPaper( pView->GetBackground() );
1619cdf0e10cSrcweir aPaper.SetRect( aRect );
1620cdf0e10cSrcweir pView->SetBackground( aPaper );
1621cdf0e10cSrcweir }
1622cdf0e10cSrcweir VisRectChanged();
1623cdf0e10cSrcweir }
1624cdf0e10cSrcweir
CheckHorScrollBar()1625cdf0e10cSrcweir sal_Bool SvxIconChoiceCtrl_Impl::CheckHorScrollBar()
1626cdf0e10cSrcweir {
1627cdf0e10cSrcweir if( !pZOrderList || !aHorSBar.IsVisible() )
1628cdf0e10cSrcweir return sal_False;
1629cdf0e10cSrcweir const MapMode& rMapMode = pView->GetMapMode();
1630cdf0e10cSrcweir Point aOrigin( rMapMode.GetOrigin() );
1631cdf0e10cSrcweir if(!( nWinBits & WB_HSCROLL) && !aOrigin.X() )
1632cdf0e10cSrcweir {
1633cdf0e10cSrcweir long nWidth = aOutputSize.Width();
1634cdf0e10cSrcweir const sal_uLong nCount = pZOrderList->Count();
1635cdf0e10cSrcweir long nMostRight = 0;
1636cdf0e10cSrcweir for( sal_uLong nCur = 0; nCur < nCount; nCur++ )
1637cdf0e10cSrcweir {
1638cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)pZOrderList->GetObject(nCur);
1639cdf0e10cSrcweir long nRight = GetEntryBoundRect(pEntry).Right();
1640cdf0e10cSrcweir if( nRight > nWidth )
1641cdf0e10cSrcweir return sal_False;
1642cdf0e10cSrcweir if( nRight > nMostRight )
1643cdf0e10cSrcweir nMostRight = nRight;
1644cdf0e10cSrcweir }
1645cdf0e10cSrcweir aHorSBar.Hide();
1646cdf0e10cSrcweir aOutputSize.Height() += nHorSBarHeight;
1647cdf0e10cSrcweir aVirtOutputSize.Width() = nMostRight;
1648cdf0e10cSrcweir aHorSBar.SetThumbPos( 0 );
1649cdf0e10cSrcweir Range aRange;
1650cdf0e10cSrcweir aRange.Max() = nMostRight - 1;
1651cdf0e10cSrcweir aHorSBar.SetRange( aRange );
1652cdf0e10cSrcweir if( aVerSBar.IsVisible() )
1653cdf0e10cSrcweir {
1654cdf0e10cSrcweir Size aSize( aVerSBar.GetSizePixel());
1655cdf0e10cSrcweir aSize.Height() += nHorSBarHeight;
1656cdf0e10cSrcweir aVerSBar.SetSizePixel( aSize );
1657cdf0e10cSrcweir }
1658cdf0e10cSrcweir return sal_True;
1659cdf0e10cSrcweir }
1660cdf0e10cSrcweir return sal_False;
1661cdf0e10cSrcweir }
1662cdf0e10cSrcweir
CheckVerScrollBar()1663cdf0e10cSrcweir sal_Bool SvxIconChoiceCtrl_Impl::CheckVerScrollBar()
1664cdf0e10cSrcweir {
1665cdf0e10cSrcweir if( !pZOrderList || !aVerSBar.IsVisible() )
1666cdf0e10cSrcweir return sal_False;
1667cdf0e10cSrcweir const MapMode& rMapMode = pView->GetMapMode();
1668cdf0e10cSrcweir Point aOrigin( rMapMode.GetOrigin() );
1669cdf0e10cSrcweir if(!( nWinBits & WB_VSCROLL) && !aOrigin.Y() )
1670cdf0e10cSrcweir {
1671cdf0e10cSrcweir long nDeepest = 0;
1672cdf0e10cSrcweir long nHeight = aOutputSize.Height();
1673cdf0e10cSrcweir const sal_uLong nCount = pZOrderList->Count();
1674cdf0e10cSrcweir for( sal_uLong nCur = 0; nCur < nCount; nCur++ )
1675cdf0e10cSrcweir {
1676cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)pZOrderList->GetObject(nCur);
1677cdf0e10cSrcweir long nBottom = GetEntryBoundRect(pEntry).Bottom();
1678cdf0e10cSrcweir if( nBottom > nHeight )
1679cdf0e10cSrcweir return sal_False;
1680cdf0e10cSrcweir if( nBottom > nDeepest )
1681cdf0e10cSrcweir nDeepest = nBottom;
1682cdf0e10cSrcweir }
1683cdf0e10cSrcweir aVerSBar.Hide();
1684cdf0e10cSrcweir aOutputSize.Width() += nVerSBarWidth;
1685cdf0e10cSrcweir aVirtOutputSize.Height() = nDeepest;
1686cdf0e10cSrcweir aVerSBar.SetThumbPos( 0 );
1687cdf0e10cSrcweir Range aRange;
1688cdf0e10cSrcweir aRange.Max() = nDeepest - 1;
1689cdf0e10cSrcweir aVerSBar.SetRange( aRange );
1690cdf0e10cSrcweir if( aHorSBar.IsVisible() )
1691cdf0e10cSrcweir {
1692cdf0e10cSrcweir Size aSize( aHorSBar.GetSizePixel());
1693cdf0e10cSrcweir aSize.Width() += nVerSBarWidth;
1694cdf0e10cSrcweir aHorSBar.SetSizePixel( aSize );
1695cdf0e10cSrcweir }
1696cdf0e10cSrcweir return sal_True;
1697cdf0e10cSrcweir }
1698cdf0e10cSrcweir return sal_False;
1699cdf0e10cSrcweir }
1700cdf0e10cSrcweir
1701cdf0e10cSrcweir
1702cdf0e10cSrcweir // blendet Scrollbars aus, wenn sie nicht mehr benoetigt werden
CheckScrollBars()1703cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::CheckScrollBars()
1704cdf0e10cSrcweir {
1705cdf0e10cSrcweir CheckVerScrollBar();
1706cdf0e10cSrcweir if( CheckHorScrollBar() )
1707cdf0e10cSrcweir CheckVerScrollBar();
1708cdf0e10cSrcweir if( aVerSBar.IsVisible() && aHorSBar.IsVisible() )
1709cdf0e10cSrcweir aScrBarBox.Show();
1710cdf0e10cSrcweir else
1711cdf0e10cSrcweir aScrBarBox.Hide();
1712cdf0e10cSrcweir }
1713cdf0e10cSrcweir
1714cdf0e10cSrcweir
GetFocus()1715cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::GetFocus()
1716cdf0e10cSrcweir {
1717cdf0e10cSrcweir RepaintEntries( ICNVIEW_FLAG_SELECTED );
1718cdf0e10cSrcweir if( pCursor )
1719cdf0e10cSrcweir {
1720cdf0e10cSrcweir pCursor->SetFlags( ICNVIEW_FLAG_FOCUSED );
1721cdf0e10cSrcweir ShowCursor( sal_True );
1722cdf0e10cSrcweir }
1723cdf0e10cSrcweir }
1724cdf0e10cSrcweir
LoseFocus()1725cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::LoseFocus()
1726cdf0e10cSrcweir {
1727cdf0e10cSrcweir StopEditTimer();
1728cdf0e10cSrcweir if( pCursor )
1729cdf0e10cSrcweir pCursor->ClearFlags( ICNVIEW_FLAG_FOCUSED );
1730cdf0e10cSrcweir ShowCursor( sal_False );
1731cdf0e10cSrcweir
1732cdf0e10cSrcweir // HideFocus ();
1733cdf0e10cSrcweir // pView->Invalidate ( aFocus.aRect );
1734cdf0e10cSrcweir
1735cdf0e10cSrcweir RepaintEntries( ICNVIEW_FLAG_SELECTED );
1736cdf0e10cSrcweir }
1737cdf0e10cSrcweir
SetUpdateMode(sal_Bool bUpdate)1738cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SetUpdateMode( sal_Bool bUpdate )
1739cdf0e10cSrcweir {
1740cdf0e10cSrcweir if( bUpdate != bUpdateMode )
1741cdf0e10cSrcweir {
1742cdf0e10cSrcweir bUpdateMode = bUpdate;
1743cdf0e10cSrcweir if( bUpdate )
1744cdf0e10cSrcweir {
1745cdf0e10cSrcweir AdjustScrollBars();
1746cdf0e10cSrcweir pImpCursor->Clear();
1747cdf0e10cSrcweir pGridMap->Clear();
1748cdf0e10cSrcweir pView->Invalidate(INVALIDATE_NOCHILDREN);
1749cdf0e10cSrcweir }
1750cdf0e10cSrcweir }
1751cdf0e10cSrcweir }
1752cdf0e10cSrcweir
PaintEntry(SvxIconChoiceCtrlEntry * pEntry,sal_Bool bIsBackgroundPainted)1753cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::PaintEntry( SvxIconChoiceCtrlEntry* pEntry, sal_Bool bIsBackgroundPainted )
1754cdf0e10cSrcweir {
1755cdf0e10cSrcweir Point aPos( GetEntryPos( pEntry ) );
1756cdf0e10cSrcweir PaintEntry( pEntry, aPos, 0, bIsBackgroundPainted );
1757cdf0e10cSrcweir }
1758cdf0e10cSrcweir
1759cdf0e10cSrcweir // Prios der Emphasis: bDropTarget => bCursored => bSelected
PaintEmphasis(const Rectangle & rTextRect,const Rectangle & rImageRect,sal_Bool bSelected,sal_Bool bDropTarget,sal_Bool bCursored,OutputDevice * pOut,sal_Bool bIsBackgroundPainted)1760cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::PaintEmphasis(
1761cdf0e10cSrcweir const Rectangle& rTextRect, const Rectangle& rImageRect,
1762cdf0e10cSrcweir sal_Bool bSelected, sal_Bool bDropTarget, sal_Bool bCursored, OutputDevice* pOut,
1763cdf0e10cSrcweir sal_Bool bIsBackgroundPainted )
1764cdf0e10cSrcweir {
1765cdf0e10cSrcweir static Color aTransparent( COL_TRANSPARENT );
1766cdf0e10cSrcweir
1767cdf0e10cSrcweir if( !pOut )
1768cdf0e10cSrcweir pOut = pView;
1769cdf0e10cSrcweir
1770cdf0e10cSrcweir #ifdef OV_CHECK_EMPH_RECTS
1771cdf0e10cSrcweir {
1772cdf0e10cSrcweir Color aXOld( pOut->GetFillColor() );
1773cdf0e10cSrcweir pOut->SetFillColor( Color( COL_GREEN ));
1774cdf0e10cSrcweir pOut->DrawRect( rTextRect );
1775cdf0e10cSrcweir pOut->DrawRect( rImageRect );
1776cdf0e10cSrcweir pOut->SetFillColor( aXOld );
1777cdf0e10cSrcweir }
1778cdf0e10cSrcweir #endif
1779cdf0e10cSrcweir
1780cdf0e10cSrcweir const StyleSettings& rSettings = pOut->GetSettings().GetStyleSettings();
1781cdf0e10cSrcweir Color aOldFillColor( pOut->GetFillColor() );
1782cdf0e10cSrcweir
1783cdf0e10cSrcweir sal_Bool bSolidTextRect = sal_False;
1784cdf0e10cSrcweir sal_Bool bSolidImageRect = sal_False;
1785cdf0e10cSrcweir
1786cdf0e10cSrcweir if( bDropTarget && ( eSelectionMode != NO_SELECTION ) )
1787cdf0e10cSrcweir {
1788cdf0e10cSrcweir pOut->SetFillColor( rSettings.GetHighlightColor() );
1789cdf0e10cSrcweir bSolidTextRect = sal_True;
1790cdf0e10cSrcweir bSolidImageRect = sal_True;
1791cdf0e10cSrcweir }
1792cdf0e10cSrcweir else
1793cdf0e10cSrcweir {
1794cdf0e10cSrcweir if ( !bSelected || bCursored )
1795cdf0e10cSrcweir {
1796cdf0e10cSrcweir if( !pView->HasFontFillColor() )
1797cdf0e10cSrcweir pOut->SetFillColor( pOut->GetBackground().GetColor() );
1798cdf0e10cSrcweir else
1799cdf0e10cSrcweir {
1800cdf0e10cSrcweir const Color& rFillColor = pView->GetFont().GetFillColor();
1801cdf0e10cSrcweir pOut->SetFillColor( rFillColor );
1802cdf0e10cSrcweir if( rFillColor != aTransparent )
1803cdf0e10cSrcweir bSolidTextRect = sal_True;
1804cdf0e10cSrcweir }
1805cdf0e10cSrcweir }
1806cdf0e10cSrcweir }
1807cdf0e10cSrcweir
1808cdf0e10cSrcweir // Textrechteck zeichnen
1809cdf0e10cSrcweir if( !bSolidTextRect )
1810cdf0e10cSrcweir {
1811cdf0e10cSrcweir if( !bIsBackgroundPainted )
1812cdf0e10cSrcweir pOut->Erase( rTextRect );
1813cdf0e10cSrcweir }
1814cdf0e10cSrcweir else
1815cdf0e10cSrcweir {
1816cdf0e10cSrcweir Color aOldLineColor;
1817cdf0e10cSrcweir if( bCursored )
1818cdf0e10cSrcweir {
1819cdf0e10cSrcweir aOldLineColor = pOut->GetLineColor();
1820cdf0e10cSrcweir pOut->SetLineColor( Color( COL_GRAY ) );
1821cdf0e10cSrcweir }
1822cdf0e10cSrcweir pOut->DrawRect( rTextRect );
1823cdf0e10cSrcweir if( bCursored )
1824cdf0e10cSrcweir pOut->SetLineColor( aOldLineColor );
1825cdf0e10cSrcweir }
1826cdf0e10cSrcweir
1827cdf0e10cSrcweir // Bildrechteck zeichnen
1828cdf0e10cSrcweir if( !bSolidImageRect )
1829cdf0e10cSrcweir {
1830cdf0e10cSrcweir if( !bIsBackgroundPainted )
1831cdf0e10cSrcweir pOut->Erase( rImageRect );
1832cdf0e10cSrcweir }
1833cdf0e10cSrcweir // die Emphasis des Images muss von der abgeleiteten Klasse gezeichnet werden
1834cdf0e10cSrcweir // (in der virtuellen Funktion DrawEntryImage)
1835cdf0e10cSrcweir // else
1836cdf0e10cSrcweir // pOut->DrawRect( rImageRect );
1837cdf0e10cSrcweir
1838cdf0e10cSrcweir pOut->SetFillColor( aOldFillColor );
1839cdf0e10cSrcweir }
1840cdf0e10cSrcweir
1841cdf0e10cSrcweir
PaintItem(const Rectangle & rRect,IcnViewFieldType eItem,SvxIconChoiceCtrlEntry * pEntry,sal_uInt16 nPaintFlags,OutputDevice * pOut,const String * pStr,::vcl::ControlLayoutData * _pLayoutData)1842cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::PaintItem( const Rectangle& rRect,
1843cdf0e10cSrcweir IcnViewFieldType eItem, SvxIconChoiceCtrlEntry* pEntry, sal_uInt16 nPaintFlags,
1844cdf0e10cSrcweir OutputDevice* pOut, const String* pStr, ::vcl::ControlLayoutData* _pLayoutData )
1845cdf0e10cSrcweir {
1846cdf0e10cSrcweir if( eItem == IcnViewFieldTypeText )
1847cdf0e10cSrcweir {
1848cdf0e10cSrcweir String aText;
1849cdf0e10cSrcweir if( !pStr )
1850cdf0e10cSrcweir aText = pView->GetEntryText( pEntry, sal_False );
1851cdf0e10cSrcweir else
1852cdf0e10cSrcweir aText = *pStr;
1853cdf0e10cSrcweir
1854cdf0e10cSrcweir if ( _pLayoutData )
1855cdf0e10cSrcweir {
1856cdf0e10cSrcweir pOut->DrawText( rRect, aText, nCurTextDrawFlags,
1857cdf0e10cSrcweir &_pLayoutData->m_aUnicodeBoundRects, &_pLayoutData->m_aDisplayText );
1858cdf0e10cSrcweir }
1859cdf0e10cSrcweir else
1860cdf0e10cSrcweir {
1861cdf0e10cSrcweir Color aOldFontColor = pOut->GetTextColor();
1862cdf0e10cSrcweir if ( pView->AutoFontColor() )
1863cdf0e10cSrcweir {
1864cdf0e10cSrcweir Color aBkgColor( pOut->GetBackground().GetColor() );
1865cdf0e10cSrcweir Color aFontColor;
1866cdf0e10cSrcweir sal_uInt16 nColor = ( aBkgColor.GetRed() + aBkgColor.GetGreen() + aBkgColor.GetBlue() ) / 3;
1867cdf0e10cSrcweir if ( nColor > 127 )
1868cdf0e10cSrcweir aFontColor.SetColor ( COL_BLACK );
1869cdf0e10cSrcweir else
1870cdf0e10cSrcweir aFontColor.SetColor( COL_WHITE );
1871cdf0e10cSrcweir pOut->SetTextColor( aFontColor );
1872cdf0e10cSrcweir }
1873cdf0e10cSrcweir
1874cdf0e10cSrcweir pOut->DrawText( rRect, aText, nCurTextDrawFlags );
1875cdf0e10cSrcweir
1876cdf0e10cSrcweir if ( pView->AutoFontColor() )
1877cdf0e10cSrcweir pOut->SetTextColor( aOldFontColor );
1878cdf0e10cSrcweir
1879cdf0e10cSrcweir if( pEntry->IsFocused() )
1880cdf0e10cSrcweir {
1881cdf0e10cSrcweir Rectangle aRect ( CalcFocusRect( (SvxIconChoiceCtrlEntry*)pEntry ) );
1882cdf0e10cSrcweir /*pView->*/ShowFocus( aRect );
1883cdf0e10cSrcweir DrawFocusRect( pOut );
1884cdf0e10cSrcweir }
1885cdf0e10cSrcweir }
1886cdf0e10cSrcweir }
1887cdf0e10cSrcweir else
1888cdf0e10cSrcweir {
1889cdf0e10cSrcweir Point aPos( rRect.TopLeft() );
1890cdf0e10cSrcweir if( nPaintFlags & PAINTFLAG_HOR_CENTERED )
1891cdf0e10cSrcweir aPos.X() += (rRect.GetWidth() - aImageSize.Width() ) / 2;
1892cdf0e10cSrcweir if( nPaintFlags & PAINTFLAG_VER_CENTERED )
1893cdf0e10cSrcweir aPos.Y() += (rRect.GetHeight() - aImageSize.Height() ) / 2;
1894cdf0e10cSrcweir pView->DrawEntryImage( pEntry, aPos, *pOut );
1895cdf0e10cSrcweir }
1896cdf0e10cSrcweir }
1897cdf0e10cSrcweir
PaintEntryVirtOutDev(SvxIconChoiceCtrlEntry * pEntry)1898cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::PaintEntryVirtOutDev( SvxIconChoiceCtrlEntry* pEntry )
1899cdf0e10cSrcweir {
1900cdf0e10cSrcweir #ifdef OV_NO_VIRT_OUTDEV
1901cdf0e10cSrcweir PaintEntry( pEntry );
1902cdf0e10cSrcweir #else
1903cdf0e10cSrcweir if( !pEntryPaintDev )
1904cdf0e10cSrcweir {
1905cdf0e10cSrcweir pEntryPaintDev = new VirtualDevice( *pView );
1906cdf0e10cSrcweir pEntryPaintDev->SetFont( pView->GetFont() );
1907cdf0e10cSrcweir pEntryPaintDev->SetLineColor();
1908cdf0e10cSrcweir //pEntryPaintDev->SetBackground( pView->GetBackground() );
1909cdf0e10cSrcweir }
1910cdf0e10cSrcweir const Rectangle& rRect = GetEntryBoundRect( pEntry );
1911cdf0e10cSrcweir Rectangle aOutRect( GetOutputRect() );
1912cdf0e10cSrcweir if( !rRect.IsOver( aOutRect ) )
1913cdf0e10cSrcweir return;
1914cdf0e10cSrcweir Wallpaper aPaper( pView->GetBackground() );
1915cdf0e10cSrcweir Rectangle aRect( aPaper.GetRect() );
1916cdf0e10cSrcweir
1917cdf0e10cSrcweir // Rechteck verschieben, so dass das Boundrect des Entries im
1918cdf0e10cSrcweir // VirtOut-Dev bei 0,0 liegt.
1919cdf0e10cSrcweir aRect.Move( -rRect.Left(), -rRect.Top() );
1920cdf0e10cSrcweir aPaper.SetRect( aRect );
1921cdf0e10cSrcweir pEntryPaintDev->SetBackground( aPaper );
1922cdf0e10cSrcweir pEntryPaintDev->SetFont( pView->GetFont() );
1923cdf0e10cSrcweir Rectangle aPix ( pEntryPaintDev->LogicToPixel(aRect) );
1924cdf0e10cSrcweir
1925cdf0e10cSrcweir
1926cdf0e10cSrcweir Size aSize( rRect.GetSize() );
1927cdf0e10cSrcweir pEntryPaintDev->SetOutputSizePixel( aSize );
1928cdf0e10cSrcweir pEntryPaintDev->DrawOutDev(
1929cdf0e10cSrcweir Point(), aSize, rRect.TopLeft(), aSize, *pView );
1930cdf0e10cSrcweir
1931cdf0e10cSrcweir PaintEntry( pEntry, Point(), pEntryPaintDev );
1932cdf0e10cSrcweir
1933cdf0e10cSrcweir pView->DrawOutDev(
1934cdf0e10cSrcweir rRect.TopLeft(),
1935cdf0e10cSrcweir aSize,
1936cdf0e10cSrcweir Point(),
1937cdf0e10cSrcweir aSize,
1938cdf0e10cSrcweir *pEntryPaintDev );
1939cdf0e10cSrcweir #endif
1940cdf0e10cSrcweir }
1941cdf0e10cSrcweir
1942cdf0e10cSrcweir
PaintEntry(SvxIconChoiceCtrlEntry * pEntry,const Point & rPos,OutputDevice * pOut,sal_Bool bIsBackgroundPainted)1943cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::PaintEntry( SvxIconChoiceCtrlEntry* pEntry, const Point& rPos,
1944cdf0e10cSrcweir OutputDevice* pOut, sal_Bool bIsBackgroundPainted )
1945cdf0e10cSrcweir {
1946cdf0e10cSrcweir if( !pOut )
1947cdf0e10cSrcweir pOut = pView;
1948cdf0e10cSrcweir
1949cdf0e10cSrcweir sal_Bool bSelected = sal_False;
1950cdf0e10cSrcweir
1951cdf0e10cSrcweir if( eSelectionMode != NO_SELECTION )
1952cdf0e10cSrcweir bSelected = pEntry->IsSelected();
1953cdf0e10cSrcweir
1954cdf0e10cSrcweir sal_Bool bCursored = pEntry->IsCursored();
1955cdf0e10cSrcweir sal_Bool bDropTarget = pEntry->IsDropTarget();
1956cdf0e10cSrcweir sal_Bool bNoEmphasis = pEntry->IsBlockingEmphasis();
1957cdf0e10cSrcweir
1958cdf0e10cSrcweir Font aTempFont( pOut->GetFont() );
1959cdf0e10cSrcweir
1960cdf0e10cSrcweir // AutoFontColor
1961cdf0e10cSrcweir /*
1962cdf0e10cSrcweir if ( pView->AutoFontColor() )
1963cdf0e10cSrcweir {
1964cdf0e10cSrcweir aTempFont.SetColor ( aFontColor );
1965cdf0e10cSrcweir }
1966cdf0e10cSrcweir */
1967cdf0e10cSrcweir
1968cdf0e10cSrcweir String aEntryText( pView->GetEntryText( pEntry, sal_False ) );
1969cdf0e10cSrcweir Rectangle aTextRect( CalcTextRect(pEntry,&rPos,sal_False,&aEntryText));
1970cdf0e10cSrcweir Rectangle aBmpRect( CalcBmpRect(pEntry, &rPos ) );
1971cdf0e10cSrcweir
1972cdf0e10cSrcweir sal_Bool bShowSelection =
1973cdf0e10cSrcweir ( ( ( bSelected && !bCursored )
1974cdf0e10cSrcweir || bDropTarget
1975cdf0e10cSrcweir )
1976cdf0e10cSrcweir && !bNoEmphasis
1977cdf0e10cSrcweir && ( eSelectionMode != NO_SELECTION )
1978cdf0e10cSrcweir );
1979cdf0e10cSrcweir sal_Bool bActiveSelection = ( 0 != ( nWinBits & WB_NOHIDESELECTION ) ) || pView->HasFocus();
1980cdf0e10cSrcweir
1981cdf0e10cSrcweir if ( bShowSelection )
1982cdf0e10cSrcweir {
1983cdf0e10cSrcweir const StyleSettings& rSettings = pOut->GetSettings().GetStyleSettings();
1984cdf0e10cSrcweir Font aNewFont( aTempFont );
1985cdf0e10cSrcweir
1986cdf0e10cSrcweir // bei hart attributierter Font-Fuellcolor muessen wir diese
1987cdf0e10cSrcweir // hart auf die Highlight-Color setzen
1988cdf0e10cSrcweir if( pView->HasFontFillColor() )
1989cdf0e10cSrcweir {
1990cdf0e10cSrcweir if( (nWinBits & WB_NOHIDESELECTION) || pView->HasFocus() )
1991cdf0e10cSrcweir aNewFont.SetFillColor( rSettings.GetHighlightColor() );
1992cdf0e10cSrcweir else
1993cdf0e10cSrcweir aNewFont.SetFillColor( rSettings.GetDeactiveColor() );
1994cdf0e10cSrcweir }
1995cdf0e10cSrcweir
1996cdf0e10cSrcweir Color aWinCol = rSettings.GetWindowTextColor();
1997cdf0e10cSrcweir if ( !bActiveSelection && rSettings.GetFaceColor().IsBright() == aWinCol.IsBright() )
1998cdf0e10cSrcweir aNewFont.SetColor( rSettings.GetWindowTextColor() );
1999cdf0e10cSrcweir else
2000cdf0e10cSrcweir aNewFont.SetColor( rSettings.GetHighlightTextColor() );
2001cdf0e10cSrcweir
2002cdf0e10cSrcweir pOut->SetFont( aNewFont );
2003cdf0e10cSrcweir
2004cdf0e10cSrcweir pOut->SetFillColor( pOut->GetBackground().GetColor() );
2005cdf0e10cSrcweir pOut->DrawRect( CalcFocusRect( pEntry ) );
2006cdf0e10cSrcweir pOut->SetFillColor( );
2007cdf0e10cSrcweir }
2008cdf0e10cSrcweir
2009cdf0e10cSrcweir sal_Bool bResetClipRegion = sal_False;
2010cdf0e10cSrcweir if( !pView->IsClipRegion() && (aVerSBar.IsVisible() || aHorSBar.IsVisible()) )
2011cdf0e10cSrcweir {
2012cdf0e10cSrcweir Rectangle aOutputArea( GetOutputRect() );
2013cdf0e10cSrcweir if( aOutputArea.IsOver(aTextRect) || aOutputArea.IsOver(aBmpRect) )
2014cdf0e10cSrcweir {
2015cdf0e10cSrcweir pView->SetClipRegion( aOutputArea );
2016cdf0e10cSrcweir bResetClipRegion = sal_True;
2017cdf0e10cSrcweir }
2018cdf0e10cSrcweir }
2019cdf0e10cSrcweir
2020cdf0e10cSrcweir #ifdef OV_DRAWBOUNDRECT
2021cdf0e10cSrcweir {
2022cdf0e10cSrcweir Color aXOldColor = pOut->GetLineColor();
2023cdf0e10cSrcweir pOut->SetLineColor( Color( COL_LIGHTRED ) );
2024cdf0e10cSrcweir Rectangle aXRect( pEntry->aRect );
2025cdf0e10cSrcweir aXRect.SetPos( rPos );
2026cdf0e10cSrcweir pOut->DrawRect( aXRect );
2027cdf0e10cSrcweir pOut->SetLineColor( aXOldColor );
2028cdf0e10cSrcweir }
2029cdf0e10cSrcweir #endif
2030cdf0e10cSrcweir
2031cdf0e10cSrcweir sal_Bool bLargeIconMode = WB_ICON == ( nWinBits & (VIEWMODE_MASK) );
2032cdf0e10cSrcweir sal_uInt16 nBmpPaintFlags = PAINTFLAG_VER_CENTERED;
2033cdf0e10cSrcweir if ( bLargeIconMode )
2034cdf0e10cSrcweir nBmpPaintFlags |= PAINTFLAG_HOR_CENTERED;
2035cdf0e10cSrcweir sal_uInt16 nTextPaintFlags = bLargeIconMode ? PAINTFLAG_HOR_CENTERED : PAINTFLAG_VER_CENTERED;
2036cdf0e10cSrcweir
2037cdf0e10cSrcweir if( !bNoEmphasis )
2038cdf0e10cSrcweir PaintEmphasis(aTextRect,aBmpRect,bSelected,bDropTarget,bCursored,pOut,bIsBackgroundPainted);
2039cdf0e10cSrcweir
2040cdf0e10cSrcweir if ( bShowSelection )
2041cdf0e10cSrcweir pView->DrawSelectionBackground( CalcFocusRect( pEntry ),
2042cdf0e10cSrcweir bActiveSelection ? 1 : 2 /* highlight */, sal_False /* check */, sal_True /* border */, sal_False /* ext border only */ );
2043cdf0e10cSrcweir
2044cdf0e10cSrcweir PaintItem( aBmpRect, IcnViewFieldTypeImage, pEntry, nBmpPaintFlags, pOut );
2045cdf0e10cSrcweir
2046cdf0e10cSrcweir PaintItem( aTextRect, IcnViewFieldTypeText, pEntry,
2047cdf0e10cSrcweir nTextPaintFlags, pOut );
2048cdf0e10cSrcweir
2049cdf0e10cSrcweir // Highlight-Frame zeichnen
2050cdf0e10cSrcweir if( pEntry == pCurHighlightFrame && !bNoEmphasis )
2051cdf0e10cSrcweir DrawHighlightFrame( pOut, CalcFocusRect( pEntry ), sal_False );
2052cdf0e10cSrcweir
2053cdf0e10cSrcweir pOut->SetFont( aTempFont );
2054cdf0e10cSrcweir if( bResetClipRegion )
2055cdf0e10cSrcweir pView->SetClipRegion();
2056cdf0e10cSrcweir }
2057cdf0e10cSrcweir
SetEntryPos(SvxIconChoiceCtrlEntry * pEntry,const Point & rPos,sal_Bool bAdjustAtGrid,sal_Bool bCheckScrollBars,sal_Bool bKeepGridMap)2058cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SetEntryPos( SvxIconChoiceCtrlEntry* pEntry, const Point& rPos,
2059cdf0e10cSrcweir sal_Bool bAdjustAtGrid, sal_Bool bCheckScrollBars, sal_Bool bKeepGridMap )
2060cdf0e10cSrcweir {
2061cdf0e10cSrcweir ShowCursor( sal_False );
2062cdf0e10cSrcweir Rectangle aBoundRect( GetEntryBoundRect( pEntry ));
2063cdf0e10cSrcweir pView->Invalidate( aBoundRect );
2064cdf0e10cSrcweir ToTop( pEntry );
2065cdf0e10cSrcweir if( !IsAutoArrange() )
2066cdf0e10cSrcweir {
2067cdf0e10cSrcweir sal_Bool bAdjustVirtSize = sal_False;
2068cdf0e10cSrcweir if( rPos != aBoundRect.TopLeft() )
2069cdf0e10cSrcweir {
2070cdf0e10cSrcweir Point aGridOffs(
2071cdf0e10cSrcweir pEntry->aGridRect.TopLeft() - pEntry->aRect.TopLeft() );
2072cdf0e10cSrcweir pImpCursor->Clear();
2073cdf0e10cSrcweir if( !bKeepGridMap )
2074cdf0e10cSrcweir pGridMap->Clear();
2075cdf0e10cSrcweir aBoundRect.SetPos( rPos );
2076cdf0e10cSrcweir pEntry->aRect = aBoundRect;
2077cdf0e10cSrcweir pEntry->aGridRect.SetPos( rPos + aGridOffs );
2078cdf0e10cSrcweir bAdjustVirtSize = sal_True;
2079cdf0e10cSrcweir }
2080cdf0e10cSrcweir if( bAdjustAtGrid )
2081cdf0e10cSrcweir {
2082cdf0e10cSrcweir if( bAdjustVirtSize )
2083cdf0e10cSrcweir {
2084cdf0e10cSrcweir // Durch das Ausrichten des (ggf. gerade neu positionierten) Eintrags,
2085cdf0e10cSrcweir // kann er wieder komplett
2086cdf0e10cSrcweir // in den sichtbaren Bereich rutschen, so dass u.U. doch keine Scrollbar
2087cdf0e10cSrcweir // eingeblendet werden muss. Um deshalb ein 'Aufblitzen' der
2088cdf0e10cSrcweir // Scrollbar(s) zu vermeiden, wird zum Aufplustern der virtuellen
2089cdf0e10cSrcweir // Ausgabegroesse bereits das ausgerichtete Boundrect des
2090cdf0e10cSrcweir // Eintrags genommen. Die virtuelle Groesse muss angepasst werden,
2091cdf0e10cSrcweir // da AdjustEntryAtGrid von ihr abhaengt.
2092cdf0e10cSrcweir const Rectangle& rBoundRect = GetEntryBoundRect( pEntry );
2093cdf0e10cSrcweir Rectangle aCenterRect( CalcBmpRect( pEntry, 0 ));
2094cdf0e10cSrcweir Point aNewPos( AdjustAtGrid( aCenterRect, rBoundRect ) );
2095cdf0e10cSrcweir Rectangle aNewBoundRect( aNewPos, pEntry->aRect.GetSize());
2096cdf0e10cSrcweir AdjustVirtSize( aNewBoundRect );
2097cdf0e10cSrcweir bAdjustVirtSize = sal_False;
2098cdf0e10cSrcweir }
2099cdf0e10cSrcweir AdjustEntryAtGrid( pEntry );
2100cdf0e10cSrcweir ToTop( pEntry );
2101cdf0e10cSrcweir }
2102cdf0e10cSrcweir if( bAdjustVirtSize )
2103cdf0e10cSrcweir AdjustVirtSize( pEntry->aRect );
2104cdf0e10cSrcweir
2105cdf0e10cSrcweir if( bCheckScrollBars && bUpdateMode )
2106cdf0e10cSrcweir CheckScrollBars();
2107cdf0e10cSrcweir
2108cdf0e10cSrcweir pView->Invalidate( pEntry->aRect );
2109cdf0e10cSrcweir pGridMap->OccupyGrids( pEntry );
2110cdf0e10cSrcweir }
2111cdf0e10cSrcweir else
2112cdf0e10cSrcweir {
2113cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pPrev = FindEntryPredecessor( pEntry, rPos );
2114cdf0e10cSrcweir SetEntryPredecessor( pEntry, pPrev );
2115cdf0e10cSrcweir aAutoArrangeTimer.Start();
2116cdf0e10cSrcweir }
2117cdf0e10cSrcweir ShowCursor( sal_True );
2118cdf0e10cSrcweir }
2119cdf0e10cSrcweir
SetNoSelection()2120cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SetNoSelection()
2121cdf0e10cSrcweir {
2122cdf0e10cSrcweir // rekursive Aufrufe ueber SelectEntry abblocken
2123cdf0e10cSrcweir if( !(nFlags & F_CLEARING_SELECTION ))
2124cdf0e10cSrcweir {
2125cdf0e10cSrcweir nFlags |= F_CLEARING_SELECTION;
2126cdf0e10cSrcweir DeselectAllBut( 0, sal_True );
2127cdf0e10cSrcweir nFlags &= ~F_CLEARING_SELECTION;
2128cdf0e10cSrcweir }
2129cdf0e10cSrcweir }
2130cdf0e10cSrcweir
GetEntry(const Point & rDocPos,sal_Bool bHit)2131cdf0e10cSrcweir SvxIconChoiceCtrlEntry* SvxIconChoiceCtrl_Impl::GetEntry( const Point& rDocPos, sal_Bool bHit )
2132cdf0e10cSrcweir {
2133cdf0e10cSrcweir CheckBoundingRects();
2134cdf0e10cSrcweir // Z-Order-Liste vom Ende her absuchen
2135cdf0e10cSrcweir sal_uLong nCount = pZOrderList->Count();
2136cdf0e10cSrcweir while( nCount )
2137cdf0e10cSrcweir {
2138cdf0e10cSrcweir nCount--;
2139cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)(pZOrderList->GetObject(nCount));
2140cdf0e10cSrcweir if( pEntry->aRect.IsInside( rDocPos ) )
2141cdf0e10cSrcweir {
2142cdf0e10cSrcweir if( bHit )
2143cdf0e10cSrcweir {
2144cdf0e10cSrcweir Rectangle aRect = CalcBmpRect( pEntry );
2145cdf0e10cSrcweir aRect.Top() -= 3;
2146cdf0e10cSrcweir aRect.Bottom() += 3;
2147cdf0e10cSrcweir aRect.Left() -= 3;
2148cdf0e10cSrcweir aRect.Right() += 3;
2149cdf0e10cSrcweir if( aRect.IsInside( rDocPos ) )
2150cdf0e10cSrcweir return pEntry;
2151cdf0e10cSrcweir aRect = CalcTextRect( pEntry );
2152cdf0e10cSrcweir if( aRect.IsInside( rDocPos ) )
2153cdf0e10cSrcweir return pEntry;
2154cdf0e10cSrcweir }
2155cdf0e10cSrcweir else
2156cdf0e10cSrcweir return pEntry;
2157cdf0e10cSrcweir }
2158cdf0e10cSrcweir }
2159cdf0e10cSrcweir return 0;
2160cdf0e10cSrcweir }
2161cdf0e10cSrcweir
GetNextEntry(const Point & rDocPos,SvxIconChoiceCtrlEntry * pCurEntry)2162cdf0e10cSrcweir SvxIconChoiceCtrlEntry* SvxIconChoiceCtrl_Impl::GetNextEntry( const Point& rDocPos, SvxIconChoiceCtrlEntry* pCurEntry )
2163cdf0e10cSrcweir {
2164cdf0e10cSrcweir CheckBoundingRects();
2165cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pTarget = 0;
2166cdf0e10cSrcweir const sal_uLong nStartPos = pZOrderList->GetPos( (void*)pCurEntry );
2167cdf0e10cSrcweir if( nStartPos != LIST_ENTRY_NOTFOUND )
2168cdf0e10cSrcweir {
2169cdf0e10cSrcweir const sal_uLong nCount = pZOrderList->Count();
2170cdf0e10cSrcweir for( sal_uLong nCur = nStartPos+1; nCur < nCount; nCur++ )
2171cdf0e10cSrcweir {
2172cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)(pZOrderList->GetObject(nCur));
2173cdf0e10cSrcweir if( pEntry->aRect.IsInside( rDocPos ) )
2174cdf0e10cSrcweir {
2175cdf0e10cSrcweir pTarget = pEntry;
2176cdf0e10cSrcweir break;
2177cdf0e10cSrcweir }
2178cdf0e10cSrcweir }
2179cdf0e10cSrcweir }
2180cdf0e10cSrcweir return pTarget;
2181cdf0e10cSrcweir }
2182cdf0e10cSrcweir
GetPrevEntry(const Point & rDocPos,SvxIconChoiceCtrlEntry * pCurEntry)2183cdf0e10cSrcweir SvxIconChoiceCtrlEntry* SvxIconChoiceCtrl_Impl::GetPrevEntry( const Point& rDocPos, SvxIconChoiceCtrlEntry* pCurEntry )
2184cdf0e10cSrcweir {
2185cdf0e10cSrcweir CheckBoundingRects();
2186cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pTarget = 0;
2187cdf0e10cSrcweir sal_uLong nStartPos = pZOrderList->GetPos( (void*)pCurEntry );
2188cdf0e10cSrcweir if( nStartPos != LIST_ENTRY_NOTFOUND && nStartPos != 0 )
2189cdf0e10cSrcweir {
2190cdf0e10cSrcweir nStartPos--;
2191cdf0e10cSrcweir do
2192cdf0e10cSrcweir {
2193cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)(pZOrderList->GetObject(nStartPos));
2194cdf0e10cSrcweir if( pEntry->aRect.IsInside( rDocPos ) )
2195cdf0e10cSrcweir {
2196cdf0e10cSrcweir pTarget = pEntry;
2197cdf0e10cSrcweir break;
2198cdf0e10cSrcweir }
2199cdf0e10cSrcweir } while( nStartPos > 0 );
2200cdf0e10cSrcweir }
2201cdf0e10cSrcweir return pTarget;
2202cdf0e10cSrcweir }
2203cdf0e10cSrcweir
GetEntryPos(SvxIconChoiceCtrlEntry * pEntry)2204cdf0e10cSrcweir Point SvxIconChoiceCtrl_Impl::GetEntryPos( SvxIconChoiceCtrlEntry* pEntry )
2205cdf0e10cSrcweir {
2206cdf0e10cSrcweir return pEntry->aRect.TopLeft();
2207cdf0e10cSrcweir }
2208cdf0e10cSrcweir
MakeEntryVisible(SvxIconChoiceCtrlEntry * pEntry,sal_Bool bBound)2209cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::MakeEntryVisible( SvxIconChoiceCtrlEntry* pEntry, sal_Bool bBound )
2210cdf0e10cSrcweir {
2211cdf0e10cSrcweir if ( bBound )
2212cdf0e10cSrcweir {
2213cdf0e10cSrcweir const Rectangle& rRect = GetEntryBoundRect( pEntry );
2214cdf0e10cSrcweir MakeVisible( rRect );
2215cdf0e10cSrcweir }
2216cdf0e10cSrcweir else
2217cdf0e10cSrcweir {
2218cdf0e10cSrcweir Rectangle aRect = CalcBmpRect( pEntry );
2219cdf0e10cSrcweir aRect.Union( CalcTextRect( pEntry ) );
2220cdf0e10cSrcweir aRect.Top() += TBOFFS_BOUND;
2221cdf0e10cSrcweir aRect.Bottom() += TBOFFS_BOUND;
2222cdf0e10cSrcweir aRect.Left() += LROFFS_BOUND;
2223cdf0e10cSrcweir aRect.Right() += LROFFS_BOUND;
2224cdf0e10cSrcweir MakeVisible( aRect );
2225cdf0e10cSrcweir }
2226cdf0e10cSrcweir }
2227cdf0e10cSrcweir
GetEntryBoundRect(SvxIconChoiceCtrlEntry * pEntry)2228cdf0e10cSrcweir const Rectangle& SvxIconChoiceCtrl_Impl::GetEntryBoundRect( SvxIconChoiceCtrlEntry* pEntry )
2229cdf0e10cSrcweir {
2230cdf0e10cSrcweir if( !IsBoundingRectValid( pEntry->aRect ))
2231cdf0e10cSrcweir FindBoundingRect( pEntry );
2232cdf0e10cSrcweir return pEntry->aRect;
2233cdf0e10cSrcweir }
2234cdf0e10cSrcweir
CalcBmpRect(SvxIconChoiceCtrlEntry * pEntry,const Point * pPos)2235cdf0e10cSrcweir Rectangle SvxIconChoiceCtrl_Impl::CalcBmpRect( SvxIconChoiceCtrlEntry* pEntry, const Point* pPos )
2236cdf0e10cSrcweir {
2237cdf0e10cSrcweir Rectangle aBound = GetEntryBoundRect( pEntry );
2238cdf0e10cSrcweir if( pPos )
2239cdf0e10cSrcweir aBound.SetPos( *pPos );
2240cdf0e10cSrcweir Point aPos( aBound.TopLeft() );
2241cdf0e10cSrcweir
2242cdf0e10cSrcweir switch( nWinBits & (VIEWMODE_MASK) )
2243cdf0e10cSrcweir {
2244cdf0e10cSrcweir case WB_ICON:
2245cdf0e10cSrcweir {
2246cdf0e10cSrcweir aPos.X() += ( aBound.GetWidth() - aImageSize.Width() ) / 2;
2247cdf0e10cSrcweir return Rectangle( aPos, aImageSize );
2248cdf0e10cSrcweir }
2249cdf0e10cSrcweir
2250cdf0e10cSrcweir case WB_SMALLICON:
2251cdf0e10cSrcweir case WB_DETAILS:
2252cdf0e10cSrcweir aPos.Y() += ( aBound.GetHeight() - aImageSize.Height() ) / 2;
2253cdf0e10cSrcweir //todo: hor. Abstand zum BoundRect?
2254cdf0e10cSrcweir return Rectangle( aPos, aImageSize );
2255cdf0e10cSrcweir
2256cdf0e10cSrcweir default:
2257cdf0e10cSrcweir DBG_ERROR("IconView: Viewmode not set");
2258cdf0e10cSrcweir return aBound;
2259cdf0e10cSrcweir }
2260cdf0e10cSrcweir }
2261cdf0e10cSrcweir
CalcTextRect(SvxIconChoiceCtrlEntry * pEntry,const Point * pEntryPos,sal_Bool bEdit,const String * pStr)2262cdf0e10cSrcweir Rectangle SvxIconChoiceCtrl_Impl::CalcTextRect( SvxIconChoiceCtrlEntry* pEntry,
2263cdf0e10cSrcweir const Point* pEntryPos, sal_Bool bEdit, const String* pStr )
2264cdf0e10cSrcweir {
2265cdf0e10cSrcweir String aEntryText;
2266cdf0e10cSrcweir if( !pStr )
2267cdf0e10cSrcweir aEntryText = pView->GetEntryText( pEntry, bEdit );
2268cdf0e10cSrcweir else
2269cdf0e10cSrcweir aEntryText = *pStr;
2270cdf0e10cSrcweir
2271cdf0e10cSrcweir const Rectangle aMaxTextRect( CalcMaxTextRect( pEntry ) );
2272cdf0e10cSrcweir Rectangle aBound( GetEntryBoundRect( pEntry ) );
2273cdf0e10cSrcweir if( pEntryPos )
2274cdf0e10cSrcweir aBound.SetPos( *pEntryPos );
2275cdf0e10cSrcweir
2276cdf0e10cSrcweir Rectangle aTextRect( aMaxTextRect );
2277cdf0e10cSrcweir if( !bEdit )
2278cdf0e10cSrcweir aTextRect = pView->GetTextRect( aTextRect, aEntryText, nCurTextDrawFlags );
2279cdf0e10cSrcweir
2280cdf0e10cSrcweir Size aTextSize( aTextRect.GetSize() );
2281cdf0e10cSrcweir
2282cdf0e10cSrcweir Point aPos( aBound.TopLeft() );
2283cdf0e10cSrcweir long nBoundWidth = aBound.GetWidth();
2284cdf0e10cSrcweir long nBoundHeight = aBound.GetHeight();
2285cdf0e10cSrcweir
2286cdf0e10cSrcweir switch( nWinBits & (VIEWMODE_MASK) )
2287cdf0e10cSrcweir {
2288cdf0e10cSrcweir case WB_ICON:
2289cdf0e10cSrcweir aPos.Y() += aImageSize.Height();
2290cdf0e10cSrcweir aPos.Y() += VER_DIST_BMP_STRING;
2291cdf0e10cSrcweir // beim Editieren etwas mehr Platz
2292cdf0e10cSrcweir if( bEdit )
2293cdf0e10cSrcweir {
2294cdf0e10cSrcweir // 20% rauf
2295cdf0e10cSrcweir long nMinWidth = (( (aImageSize.Width()*10) / 100 ) * 2 ) +
2296cdf0e10cSrcweir aImageSize.Width();
2297cdf0e10cSrcweir if( nMinWidth > nBoundWidth )
2298cdf0e10cSrcweir nMinWidth = nBoundWidth;
2299cdf0e10cSrcweir
2300cdf0e10cSrcweir if( aTextSize.Width() < nMinWidth )
2301cdf0e10cSrcweir aTextSize.Width() = nMinWidth;
2302cdf0e10cSrcweir
2303cdf0e10cSrcweir // beim Editieren ist Ueberlappung nach unten erlaubt
2304cdf0e10cSrcweir Size aOptSize = aMaxTextRect.GetSize();
2305cdf0e10cSrcweir if( aOptSize.Height() > aTextSize.Height() )
2306cdf0e10cSrcweir aTextSize.Height() = aOptSize.Height();
2307cdf0e10cSrcweir }
2308cdf0e10cSrcweir aPos.X() += (nBoundWidth - aTextSize.Width()) / 2;
2309cdf0e10cSrcweir break;
2310cdf0e10cSrcweir
2311cdf0e10cSrcweir case WB_SMALLICON:
2312cdf0e10cSrcweir case WB_DETAILS:
2313cdf0e10cSrcweir aPos.X() += aImageSize.Width();
2314cdf0e10cSrcweir aPos.X() += HOR_DIST_BMP_STRING;
2315cdf0e10cSrcweir aPos.Y() += (nBoundHeight - aTextSize.Height()) / 2;
2316cdf0e10cSrcweir break;
2317cdf0e10cSrcweir }
2318cdf0e10cSrcweir return Rectangle( aPos, aTextSize );
2319cdf0e10cSrcweir }
2320cdf0e10cSrcweir
2321cdf0e10cSrcweir
CalcBoundingWidth(SvxIconChoiceCtrlEntry * pEntry) const2322cdf0e10cSrcweir long SvxIconChoiceCtrl_Impl::CalcBoundingWidth( SvxIconChoiceCtrlEntry* pEntry ) const
2323cdf0e10cSrcweir {
2324cdf0e10cSrcweir long nStringWidth = GetItemSize( pEntry, IcnViewFieldTypeText ).Width();
2325cdf0e10cSrcweir // nStringWidth += 2*LROFFS_TEXT;
2326cdf0e10cSrcweir long nWidth = 0;
2327cdf0e10cSrcweir
2328cdf0e10cSrcweir switch( nWinBits & (VIEWMODE_MASK) )
2329cdf0e10cSrcweir {
2330cdf0e10cSrcweir case WB_ICON:
2331cdf0e10cSrcweir nWidth = Max( nStringWidth, aImageSize.Width() );
2332cdf0e10cSrcweir break;
2333cdf0e10cSrcweir
2334cdf0e10cSrcweir case WB_SMALLICON:
2335cdf0e10cSrcweir case WB_DETAILS:
2336cdf0e10cSrcweir nWidth = aImageSize.Width();
2337cdf0e10cSrcweir nWidth += HOR_DIST_BMP_STRING;
2338cdf0e10cSrcweir nWidth += nStringWidth;
2339cdf0e10cSrcweir break;
2340cdf0e10cSrcweir }
2341cdf0e10cSrcweir return nWidth;
2342cdf0e10cSrcweir }
2343cdf0e10cSrcweir
CalcBoundingHeight(SvxIconChoiceCtrlEntry * pEntry) const2344cdf0e10cSrcweir long SvxIconChoiceCtrl_Impl::CalcBoundingHeight( SvxIconChoiceCtrlEntry* pEntry ) const
2345cdf0e10cSrcweir {
2346cdf0e10cSrcweir long nStringHeight = GetItemSize( pEntry, IcnViewFieldTypeText).Height();
2347cdf0e10cSrcweir long nHeight = 0;
2348cdf0e10cSrcweir
2349cdf0e10cSrcweir switch( nWinBits & (VIEWMODE_MASK) )
2350cdf0e10cSrcweir {
2351cdf0e10cSrcweir case WB_ICON:
2352cdf0e10cSrcweir nHeight = aImageSize.Height();
2353cdf0e10cSrcweir nHeight += VER_DIST_BMP_STRING;
2354cdf0e10cSrcweir nHeight += nStringHeight;
2355cdf0e10cSrcweir break;
2356cdf0e10cSrcweir
2357cdf0e10cSrcweir case WB_SMALLICON:
2358cdf0e10cSrcweir case WB_DETAILS:
2359cdf0e10cSrcweir nHeight = Max( aImageSize.Height(), nStringHeight );
2360cdf0e10cSrcweir break;
2361cdf0e10cSrcweir }
2362cdf0e10cSrcweir if( nHeight > nMaxBoundHeight )
2363cdf0e10cSrcweir {
2364cdf0e10cSrcweir ((SvxIconChoiceCtrl_Impl*)this)->nMaxBoundHeight = nHeight;
2365cdf0e10cSrcweir ((SvxIconChoiceCtrl_Impl*)this)->aHorSBar.SetLineSize( GetScrollBarLineSize() );
2366cdf0e10cSrcweir ((SvxIconChoiceCtrl_Impl*)this)->aVerSBar.SetLineSize( GetScrollBarLineSize() );
2367cdf0e10cSrcweir }
2368cdf0e10cSrcweir return nHeight;
2369cdf0e10cSrcweir }
2370cdf0e10cSrcweir
CalcBoundingSize(SvxIconChoiceCtrlEntry * pEntry) const2371cdf0e10cSrcweir Size SvxIconChoiceCtrl_Impl::CalcBoundingSize( SvxIconChoiceCtrlEntry* pEntry ) const
2372cdf0e10cSrcweir {
2373cdf0e10cSrcweir return Size( CalcBoundingWidth( pEntry ),
2374cdf0e10cSrcweir CalcBoundingHeight( pEntry ) );
2375cdf0e10cSrcweir }
2376cdf0e10cSrcweir
RecalcAllBoundingRects()2377cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::RecalcAllBoundingRects()
2378cdf0e10cSrcweir {
2379cdf0e10cSrcweir nMaxBoundHeight = 0;
2380cdf0e10cSrcweir pZOrderList->Clear();
2381cdf0e10cSrcweir sal_uLong nCount = aEntries.Count();
2382cdf0e10cSrcweir sal_uLong nCur;
2383cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry;
2384cdf0e10cSrcweir
2385cdf0e10cSrcweir if( !IsAutoArrange() || !pHead )
2386cdf0e10cSrcweir {
2387cdf0e10cSrcweir for( nCur = 0; nCur < nCount; nCur++ )
2388cdf0e10cSrcweir {
2389cdf0e10cSrcweir pEntry = (SvxIconChoiceCtrlEntry*)aEntries.GetObject( nCur );
2390cdf0e10cSrcweir FindBoundingRect( pEntry );
2391cdf0e10cSrcweir pZOrderList->Insert( pEntry, LIST_APPEND );
2392cdf0e10cSrcweir }
2393cdf0e10cSrcweir }
2394cdf0e10cSrcweir else
2395cdf0e10cSrcweir {
2396cdf0e10cSrcweir nCur = 0;
2397cdf0e10cSrcweir pEntry = pHead;
2398cdf0e10cSrcweir while( nCur != nCount )
2399cdf0e10cSrcweir {
2400cdf0e10cSrcweir DBG_ASSERT(pEntry->pflink&&pEntry->pblink,"SvxIconChoiceCtrl_Impl::RecalcAllBoundingRect > Bad link(s)");
2401cdf0e10cSrcweir FindBoundingRect( pEntry );
2402cdf0e10cSrcweir pZOrderList->Insert( pEntry, pZOrderList->Count() );
2403cdf0e10cSrcweir pEntry = pEntry->pflink;
2404cdf0e10cSrcweir nCur++;
2405cdf0e10cSrcweir }
2406cdf0e10cSrcweir }
2407cdf0e10cSrcweir bBoundRectsDirty = sal_False;
2408cdf0e10cSrcweir AdjustScrollBars();
2409cdf0e10cSrcweir }
2410cdf0e10cSrcweir
RecalcAllBoundingRectsSmart()2411cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::RecalcAllBoundingRectsSmart()
2412cdf0e10cSrcweir {
2413cdf0e10cSrcweir nMaxBoundHeight = 0;
2414cdf0e10cSrcweir pZOrderList->Clear();
2415cdf0e10cSrcweir sal_uLong nCur;
2416cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry;
2417cdf0e10cSrcweir const sal_uLong nCount = aEntries.Count();
2418cdf0e10cSrcweir
2419cdf0e10cSrcweir if( !IsAutoArrange() || !pHead )
2420cdf0e10cSrcweir {
2421cdf0e10cSrcweir for( nCur = 0; nCur < nCount; nCur++ )
2422cdf0e10cSrcweir {
2423cdf0e10cSrcweir pEntry = (SvxIconChoiceCtrlEntry*)aEntries.GetObject( nCur );
2424cdf0e10cSrcweir if( IsBoundingRectValid( pEntry->aRect ))
2425cdf0e10cSrcweir {
2426cdf0e10cSrcweir Size aBoundSize( pEntry->aRect.GetSize() );
2427cdf0e10cSrcweir if( aBoundSize.Height() > nMaxBoundHeight )
2428cdf0e10cSrcweir nMaxBoundHeight = aBoundSize.Height();
2429cdf0e10cSrcweir }
2430cdf0e10cSrcweir else
2431cdf0e10cSrcweir FindBoundingRect( pEntry );
2432cdf0e10cSrcweir pZOrderList->Insert( pEntry, LIST_APPEND );
2433cdf0e10cSrcweir }
2434cdf0e10cSrcweir }
2435cdf0e10cSrcweir else
2436cdf0e10cSrcweir {
2437cdf0e10cSrcweir nCur = 0;
2438cdf0e10cSrcweir pEntry = pHead;
2439cdf0e10cSrcweir while( nCur != nCount )
2440cdf0e10cSrcweir {
2441cdf0e10cSrcweir DBG_ASSERT(pEntry->pflink&&pEntry->pblink,"SvxIconChoiceCtrl_Impl::RecalcAllBoundingRect > Bad link(s)");
2442cdf0e10cSrcweir if( IsBoundingRectValid( pEntry->aRect ))
2443cdf0e10cSrcweir {
2444cdf0e10cSrcweir Size aBoundSize( pEntry->aRect.GetSize() );
2445cdf0e10cSrcweir if( aBoundSize.Height() > nMaxBoundHeight )
2446cdf0e10cSrcweir nMaxBoundHeight = aBoundSize.Height();
2447cdf0e10cSrcweir }
2448cdf0e10cSrcweir else
2449cdf0e10cSrcweir FindBoundingRect( pEntry );
2450cdf0e10cSrcweir pZOrderList->Insert( pEntry, LIST_APPEND );
2451cdf0e10cSrcweir pEntry = pEntry->pflink;
2452cdf0e10cSrcweir nCur++;
2453cdf0e10cSrcweir }
2454cdf0e10cSrcweir }
2455cdf0e10cSrcweir AdjustScrollBars();
2456cdf0e10cSrcweir }
2457cdf0e10cSrcweir
UpdateBoundingRects()2458cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::UpdateBoundingRects()
2459cdf0e10cSrcweir {
2460cdf0e10cSrcweir const sal_uLong nCount = aEntries.Count();
2461cdf0e10cSrcweir for( sal_uLong nCur = 0; nCur < nCount; nCur++ )
2462cdf0e10cSrcweir {
2463cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)aEntries.GetObject( nCur );
2464cdf0e10cSrcweir GetEntryBoundRect( pEntry );
2465cdf0e10cSrcweir }
2466cdf0e10cSrcweir }
2467cdf0e10cSrcweir
FindBoundingRect(SvxIconChoiceCtrlEntry * pEntry)2468cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::FindBoundingRect( SvxIconChoiceCtrlEntry* pEntry )
2469cdf0e10cSrcweir {
2470cdf0e10cSrcweir DBG_ASSERT(!pEntry->IsPosLocked(),"Locked entry pos in FindBoundingRect");
2471cdf0e10cSrcweir if( pEntry->IsPosLocked() && IsBoundingRectValid( pEntry->aRect) )
2472cdf0e10cSrcweir {
2473cdf0e10cSrcweir AdjustVirtSize( pEntry->aRect );
2474cdf0e10cSrcweir return;
2475cdf0e10cSrcweir }
2476cdf0e10cSrcweir Size aSize( CalcBoundingSize( pEntry ) );
2477cdf0e10cSrcweir Point aPos(pGridMap->GetGridRect(pGridMap->GetUnoccupiedGrid(sal_True)).TopLeft());
2478cdf0e10cSrcweir SetBoundingRect_Impl( pEntry, aPos, aSize );
2479cdf0e10cSrcweir }
2480cdf0e10cSrcweir
SetBoundingRect_Impl(SvxIconChoiceCtrlEntry * pEntry,const Point & rPos,const Size &)2481cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SetBoundingRect_Impl( SvxIconChoiceCtrlEntry* pEntry, const Point& rPos,
2482cdf0e10cSrcweir const Size& /*rBoundingSize*/ )
2483cdf0e10cSrcweir {
2484cdf0e10cSrcweir Rectangle aGridRect( rPos, Size(nGridDX, nGridDY) );
2485cdf0e10cSrcweir pEntry->aGridRect = aGridRect;
2486cdf0e10cSrcweir Center( pEntry );
2487cdf0e10cSrcweir AdjustVirtSize( pEntry->aRect );
2488cdf0e10cSrcweir pGridMap->OccupyGrids( pEntry );
2489cdf0e10cSrcweir }
2490cdf0e10cSrcweir
2491cdf0e10cSrcweir
SetCursor(SvxIconChoiceCtrlEntry * pEntry,sal_Bool bSyncSingleSelection,sal_Bool bShowFocusAsync)2492cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SetCursor( SvxIconChoiceCtrlEntry* pEntry, sal_Bool bSyncSingleSelection,
2493cdf0e10cSrcweir sal_Bool bShowFocusAsync )
2494cdf0e10cSrcweir {
2495cdf0e10cSrcweir if( pEntry == pCursor )
2496cdf0e10cSrcweir {
2497cdf0e10cSrcweir if( pCursor && eSelectionMode == SINGLE_SELECTION && bSyncSingleSelection &&
2498cdf0e10cSrcweir !pCursor->IsSelected() )
2499cdf0e10cSrcweir SelectEntry( pCursor, sal_True, sal_True );
2500cdf0e10cSrcweir return;
2501cdf0e10cSrcweir }
2502cdf0e10cSrcweir ShowCursor( sal_False );
2503cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pOldCursor = pCursor;
2504cdf0e10cSrcweir pCursor = pEntry;
2505cdf0e10cSrcweir if( pOldCursor )
2506cdf0e10cSrcweir {
2507cdf0e10cSrcweir pOldCursor->ClearFlags( ICNVIEW_FLAG_FOCUSED );
2508cdf0e10cSrcweir if( eSelectionMode == SINGLE_SELECTION && bSyncSingleSelection )
2509cdf0e10cSrcweir SelectEntry( pOldCursor, sal_False, sal_True ); // alten Cursor deselektieren
2510cdf0e10cSrcweir }
2511cdf0e10cSrcweir if( pCursor )
2512cdf0e10cSrcweir {
2513cdf0e10cSrcweir ToTop( pCursor );
2514cdf0e10cSrcweir pCursor->SetFlags( ICNVIEW_FLAG_FOCUSED );
2515cdf0e10cSrcweir if( eSelectionMode == SINGLE_SELECTION && bSyncSingleSelection )
2516cdf0e10cSrcweir SelectEntry( pCursor, sal_True, sal_True );
2517cdf0e10cSrcweir if( !bShowFocusAsync )
2518cdf0e10cSrcweir ShowCursor( sal_True );
2519cdf0e10cSrcweir else
2520cdf0e10cSrcweir {
2521cdf0e10cSrcweir if( !nUserEventShowCursor )
2522cdf0e10cSrcweir nUserEventShowCursor =
2523cdf0e10cSrcweir Application::PostUserEvent( LINK( this, SvxIconChoiceCtrl_Impl, UserEventHdl),
2524cdf0e10cSrcweir EVENTID_SHOW_CURSOR );
2525cdf0e10cSrcweir }
2526cdf0e10cSrcweir }
2527cdf0e10cSrcweir }
2528cdf0e10cSrcweir
2529cdf0e10cSrcweir
ShowCursor(sal_Bool bShow)2530cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::ShowCursor( sal_Bool bShow )
2531cdf0e10cSrcweir {
2532cdf0e10cSrcweir if( !pCursor || !bShow || !pView->HasFocus() )
2533cdf0e10cSrcweir {
2534cdf0e10cSrcweir pView->HideFocus();
2535cdf0e10cSrcweir return;
2536cdf0e10cSrcweir }
2537cdf0e10cSrcweir Rectangle aRect ( CalcFocusRect( pCursor ) );
2538cdf0e10cSrcweir /*pView->*/ShowFocus( aRect );
2539cdf0e10cSrcweir }
2540cdf0e10cSrcweir
2541cdf0e10cSrcweir
HideDDIcon()2542cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::HideDDIcon()
2543cdf0e10cSrcweir {
2544cdf0e10cSrcweir pView->Update();
2545cdf0e10cSrcweir ImpHideDDIcon();
2546cdf0e10cSrcweir pDDBufDev = pDDDev;
2547cdf0e10cSrcweir pDDDev = 0;
2548cdf0e10cSrcweir }
2549cdf0e10cSrcweir
ImpHideDDIcon()2550cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::ImpHideDDIcon()
2551cdf0e10cSrcweir {
2552cdf0e10cSrcweir if( pDDDev )
2553cdf0e10cSrcweir {
2554cdf0e10cSrcweir Size aSize( pDDDev->GetOutputSizePixel() );
2555cdf0e10cSrcweir // pView restaurieren
2556cdf0e10cSrcweir pView->DrawOutDev( aDDLastRectPos, aSize, Point(), aSize, *pDDDev );
2557cdf0e10cSrcweir }
2558cdf0e10cSrcweir }
2559cdf0e10cSrcweir
2560cdf0e10cSrcweir
ShowDDIcon(SvxIconChoiceCtrlEntry * pRefEntry,const Point & rPosPix)2561cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::ShowDDIcon( SvxIconChoiceCtrlEntry* pRefEntry, const Point& rPosPix )
2562cdf0e10cSrcweir {
2563cdf0e10cSrcweir pView->Update();
2564cdf0e10cSrcweir if( pRefEntry != pDDRefEntry )
2565cdf0e10cSrcweir {
2566cdf0e10cSrcweir DELETEZ(pDDDev);
2567cdf0e10cSrcweir DELETEZ(pDDBufDev);
2568cdf0e10cSrcweir }
2569cdf0e10cSrcweir sal_Bool bSelected = pRefEntry->IsSelected();
2570cdf0e10cSrcweir pRefEntry->ClearFlags( ICNVIEW_FLAG_SELECTED );
2571cdf0e10cSrcweir if( !pDDDev )
2572cdf0e10cSrcweir {
2573cdf0e10cSrcweir if( pDDBufDev )
2574cdf0e10cSrcweir {
2575cdf0e10cSrcweir // nicht bei jedem Move ein Device anlegen, da dies besonders
2576cdf0e10cSrcweir // auf Remote-Clients zu langsam ist
2577cdf0e10cSrcweir pDDDev = pDDBufDev;
2578cdf0e10cSrcweir pDDBufDev = 0;
2579cdf0e10cSrcweir }
2580cdf0e10cSrcweir else
2581cdf0e10cSrcweir {
2582cdf0e10cSrcweir pDDDev = new VirtualDevice( *pView );
2583cdf0e10cSrcweir pDDDev->SetFont( pView->GetFont() );
2584cdf0e10cSrcweir }
2585cdf0e10cSrcweir }
2586cdf0e10cSrcweir else
2587cdf0e10cSrcweir {
2588cdf0e10cSrcweir ImpHideDDIcon();
2589cdf0e10cSrcweir }
2590cdf0e10cSrcweir const Rectangle& rRect = GetEntryBoundRect( pRefEntry );
2591cdf0e10cSrcweir pDDDev->SetOutputSizePixel( rRect.GetSize() );
2592cdf0e10cSrcweir
2593cdf0e10cSrcweir Point aPos( rPosPix );
2594cdf0e10cSrcweir ToDocPos( aPos );
2595cdf0e10cSrcweir
2596cdf0e10cSrcweir Size aSize( pDDDev->GetOutputSizePixel() );
2597cdf0e10cSrcweir pDDRefEntry = pRefEntry;
2598cdf0e10cSrcweir aDDLastEntryPos = aPos;
2599cdf0e10cSrcweir aDDLastRectPos = aPos;
2600cdf0e10cSrcweir
2601cdf0e10cSrcweir // Hintergrund sichern
2602cdf0e10cSrcweir pDDDev->DrawOutDev( Point(), aSize, aPos, aSize, *pView );
2603cdf0e10cSrcweir // Icon in pView malen
2604cdf0e10cSrcweir pRefEntry->SetFlags( ICNVIEW_FLAG_BLOCK_EMPHASIS );
2605cdf0e10cSrcweir PaintEntry( pRefEntry, aPos );
2606cdf0e10cSrcweir pRefEntry->ClearFlags( ICNVIEW_FLAG_BLOCK_EMPHASIS );
2607cdf0e10cSrcweir if( bSelected )
2608cdf0e10cSrcweir pRefEntry->SetFlags( ICNVIEW_FLAG_SELECTED );
2609cdf0e10cSrcweir }
2610cdf0e10cSrcweir
HideShowDDIcon(SvxIconChoiceCtrlEntry * pRefEntry,const Point & rPosPix)2611cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::HideShowDDIcon( SvxIconChoiceCtrlEntry* pRefEntry, const Point& rPosPix )
2612cdf0e10cSrcweir {
2613cdf0e10cSrcweir /* In Notfaellen folgenden flackernden Code aktivieren:
2614cdf0e10cSrcweir
2615cdf0e10cSrcweir HideDDIcon();
2616cdf0e10cSrcweir ShowDDIcon( pRefEntry, rPosPix );
2617cdf0e10cSrcweir return;
2618cdf0e10cSrcweir */
2619cdf0e10cSrcweir if( !pDDDev )
2620cdf0e10cSrcweir {
2621cdf0e10cSrcweir ShowDDIcon( pRefEntry, rPosPix );
2622cdf0e10cSrcweir return;
2623cdf0e10cSrcweir }
2624cdf0e10cSrcweir
2625cdf0e10cSrcweir if( pRefEntry != pDDRefEntry )
2626cdf0e10cSrcweir {
2627cdf0e10cSrcweir HideDDIcon();
2628cdf0e10cSrcweir ShowDDIcon( pRefEntry, rPosPix );
2629cdf0e10cSrcweir return;
2630cdf0e10cSrcweir }
2631cdf0e10cSrcweir
2632cdf0e10cSrcweir Point aEmptyPoint;
2633cdf0e10cSrcweir
2634cdf0e10cSrcweir Point aCurEntryPos( rPosPix );
2635cdf0e10cSrcweir ToDocPos( aCurEntryPos );
2636cdf0e10cSrcweir
2637cdf0e10cSrcweir const Rectangle& rRect = GetEntryBoundRect( pRefEntry );
2638cdf0e10cSrcweir Size aEntrySize( rRect.GetSize() );
2639cdf0e10cSrcweir Rectangle aPrevEntryRect( aDDLastEntryPos, aEntrySize );
2640cdf0e10cSrcweir Rectangle aCurEntryRect( aCurEntryPos, aEntrySize );
2641cdf0e10cSrcweir
2642cdf0e10cSrcweir if( !aPrevEntryRect.IsOver( aCurEntryRect ) )
2643cdf0e10cSrcweir {
2644cdf0e10cSrcweir HideDDIcon();
2645cdf0e10cSrcweir ShowDDIcon( pRefEntry, rPosPix );
2646cdf0e10cSrcweir return;
2647cdf0e10cSrcweir }
2648cdf0e10cSrcweir
2649cdf0e10cSrcweir // Ueberlappung des neuen und alten D&D-Pointers!
2650cdf0e10cSrcweir
2651cdf0e10cSrcweir Rectangle aFullRect( aPrevEntryRect.Union( aCurEntryRect ) );
2652cdf0e10cSrcweir if( !pDDTempDev )
2653cdf0e10cSrcweir {
2654cdf0e10cSrcweir pDDTempDev = new VirtualDevice( *pView );
2655cdf0e10cSrcweir pDDTempDev->SetFont( pView->GetFont() );
2656cdf0e10cSrcweir }
2657cdf0e10cSrcweir
2658cdf0e10cSrcweir Size aFullSize( aFullRect.GetSize() );
2659cdf0e10cSrcweir Point aFullPos( aFullRect.TopLeft() );
2660cdf0e10cSrcweir
2661cdf0e10cSrcweir pDDTempDev->SetOutputSizePixel( aFullSize );
2662cdf0e10cSrcweir
2663cdf0e10cSrcweir // Hintergrund (mit dem alten D&D-Pointer!) sichern
2664cdf0e10cSrcweir pDDTempDev->DrawOutDev( aEmptyPoint, aFullSize, aFullPos, aFullSize, *pView );
2665cdf0e10cSrcweir // den alten Buffer in den neuen Buffer pasten
2666cdf0e10cSrcweir aDDLastRectPos = aDDLastRectPos - aFullPos;
2667cdf0e10cSrcweir
2668cdf0e10cSrcweir pDDTempDev->DrawOutDev(
2669cdf0e10cSrcweir aDDLastRectPos,
2670cdf0e10cSrcweir pDDDev->GetOutputSizePixel(),
2671cdf0e10cSrcweir aEmptyPoint,
2672cdf0e10cSrcweir pDDDev->GetOutputSizePixel(),
2673cdf0e10cSrcweir *pDDDev );
2674cdf0e10cSrcweir
2675cdf0e10cSrcweir // Swap
2676cdf0e10cSrcweir VirtualDevice* pTemp = pDDDev;
2677cdf0e10cSrcweir pDDDev = pDDTempDev;
2678cdf0e10cSrcweir pDDTempDev = pTemp;
2679cdf0e10cSrcweir
2680cdf0e10cSrcweir // in den restaurierten Hintergrund den neuen D&D-Pointer zeichnen
2681cdf0e10cSrcweir pDDTempDev->SetOutputSizePixel( pDDDev->GetOutputSizePixel() );
2682cdf0e10cSrcweir pDDTempDev->DrawOutDev(
2683cdf0e10cSrcweir aEmptyPoint, aFullSize, aEmptyPoint, aFullSize, *pDDDev );
2684cdf0e10cSrcweir Point aRelPos = aCurEntryPos - aFullPos;
2685cdf0e10cSrcweir pRefEntry->SetFlags( ICNVIEW_FLAG_BLOCK_EMPHASIS );
2686cdf0e10cSrcweir PaintEntry( pRefEntry, aRelPos, pDDTempDev );
2687cdf0e10cSrcweir pRefEntry->ClearFlags( ICNVIEW_FLAG_BLOCK_EMPHASIS );
2688cdf0e10cSrcweir
2689cdf0e10cSrcweir aDDLastRectPos = aFullPos;
2690cdf0e10cSrcweir aDDLastEntryPos = aCurEntryPos;
2691cdf0e10cSrcweir
2692cdf0e10cSrcweir pView->DrawOutDev(
2693cdf0e10cSrcweir aDDLastRectPos,
2694cdf0e10cSrcweir pDDDev->GetOutputSizePixel(),
2695cdf0e10cSrcweir aEmptyPoint,
2696cdf0e10cSrcweir pDDDev->GetOutputSizePixel(),
2697cdf0e10cSrcweir *pDDTempDev );
2698cdf0e10cSrcweir }
2699cdf0e10cSrcweir
InvalidateBoundingRect(SvxIconChoiceCtrlEntry * pEntry)2700cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::InvalidateBoundingRect( SvxIconChoiceCtrlEntry* pEntry )
2701cdf0e10cSrcweir {
2702cdf0e10cSrcweir InvalidateBoundingRect( pEntry->aRect );
2703cdf0e10cSrcweir }
2704cdf0e10cSrcweir
2705cdf0e10cSrcweir
HandleScrollCommand(const CommandEvent & rCmd)2706cdf0e10cSrcweir sal_Bool SvxIconChoiceCtrl_Impl::HandleScrollCommand( const CommandEvent& rCmd )
2707cdf0e10cSrcweir {
2708cdf0e10cSrcweir Rectangle aDocRect( GetDocumentRect() );
2709cdf0e10cSrcweir Rectangle aVisRect( GetVisibleRect() );
2710cdf0e10cSrcweir if( aVisRect.IsInside( aDocRect ))
2711cdf0e10cSrcweir return sal_False;
2712cdf0e10cSrcweir Size aDocSize( aDocRect.GetSize() );
2713cdf0e10cSrcweir Size aVisSize( aVisRect.GetSize() );
2714cdf0e10cSrcweir sal_Bool bHor = aDocSize.Width() > aVisSize.Width();
2715cdf0e10cSrcweir sal_Bool bVer = aDocSize.Height() > aVisSize.Height();
2716cdf0e10cSrcweir
2717cdf0e10cSrcweir long nScrollDX = 0, nScrollDY = 0;
2718cdf0e10cSrcweir
2719cdf0e10cSrcweir switch( rCmd.GetCommand() )
2720cdf0e10cSrcweir {
2721cdf0e10cSrcweir case COMMAND_STARTAUTOSCROLL:
2722cdf0e10cSrcweir {
2723cdf0e10cSrcweir pView->EndTracking();
2724cdf0e10cSrcweir sal_uInt16 nScrollFlags = 0;
2725cdf0e10cSrcweir if( bHor )
2726cdf0e10cSrcweir nScrollFlags |= AUTOSCROLL_HORZ;
2727cdf0e10cSrcweir if( bVer )
2728cdf0e10cSrcweir nScrollFlags |= AUTOSCROLL_VERT;
2729cdf0e10cSrcweir if( nScrollFlags )
2730cdf0e10cSrcweir {
2731cdf0e10cSrcweir pView->StartAutoScroll( nScrollFlags );
2732cdf0e10cSrcweir return sal_True;
2733cdf0e10cSrcweir }
2734cdf0e10cSrcweir }
2735cdf0e10cSrcweir break;
2736cdf0e10cSrcweir
2737cdf0e10cSrcweir case COMMAND_WHEEL:
2738cdf0e10cSrcweir {
2739cdf0e10cSrcweir const CommandWheelData* pData = rCmd.GetWheelData();
2740cdf0e10cSrcweir if( pData && (COMMAND_WHEEL_SCROLL == pData->GetMode()) && !pData->IsHorz() )
2741cdf0e10cSrcweir {
2742cdf0e10cSrcweir sal_uLong nScrollLines = pData->GetScrollLines();
2743cdf0e10cSrcweir if( nScrollLines == COMMAND_WHEEL_PAGESCROLL )
2744cdf0e10cSrcweir {
2745cdf0e10cSrcweir nScrollDY = GetScrollBarPageSize( aVisSize.Width() );
2746cdf0e10cSrcweir if( pData->GetDelta() < 0 )
2747cdf0e10cSrcweir nScrollDY *= -1;
2748cdf0e10cSrcweir }
2749cdf0e10cSrcweir else
2750cdf0e10cSrcweir {
2751cdf0e10cSrcweir nScrollDY = pData->GetNotchDelta() * (long)nScrollLines;
2752cdf0e10cSrcweir nScrollDY *= GetScrollBarLineSize();
2753cdf0e10cSrcweir }
2754cdf0e10cSrcweir }
2755cdf0e10cSrcweir }
2756cdf0e10cSrcweir break;
2757cdf0e10cSrcweir
2758cdf0e10cSrcweir case COMMAND_AUTOSCROLL:
2759cdf0e10cSrcweir {
2760cdf0e10cSrcweir const CommandScrollData* pData = rCmd.GetAutoScrollData();
2761cdf0e10cSrcweir if( pData )
2762cdf0e10cSrcweir {
2763cdf0e10cSrcweir nScrollDX = pData->GetDeltaX() * GetScrollBarLineSize();
2764cdf0e10cSrcweir nScrollDY = pData->GetDeltaY() * GetScrollBarLineSize();
2765cdf0e10cSrcweir }
2766cdf0e10cSrcweir }
2767cdf0e10cSrcweir break;
2768cdf0e10cSrcweir }
2769cdf0e10cSrcweir
2770cdf0e10cSrcweir if( nScrollDX || nScrollDY )
2771cdf0e10cSrcweir {
2772cdf0e10cSrcweir aVisRect.Top() -= nScrollDY;
2773cdf0e10cSrcweir aVisRect.Bottom() -= nScrollDY;
2774cdf0e10cSrcweir aVisRect.Left() -= nScrollDX;
2775cdf0e10cSrcweir aVisRect.Right() -= nScrollDX;
2776cdf0e10cSrcweir MakeVisible( aVisRect );
2777cdf0e10cSrcweir return sal_True;
2778cdf0e10cSrcweir }
2779cdf0e10cSrcweir return sal_False;
2780cdf0e10cSrcweir }
2781cdf0e10cSrcweir
2782cdf0e10cSrcweir
Command(const CommandEvent & rCEvt)2783cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::Command( const CommandEvent& rCEvt )
2784cdf0e10cSrcweir {
2785cdf0e10cSrcweir // Rollmaus-Event?
2786cdf0e10cSrcweir if( (rCEvt.GetCommand() == COMMAND_WHEEL) ||
2787cdf0e10cSrcweir (rCEvt.GetCommand() == COMMAND_STARTAUTOSCROLL) ||
2788cdf0e10cSrcweir (rCEvt.GetCommand() == COMMAND_AUTOSCROLL) )
2789cdf0e10cSrcweir {
2790cdf0e10cSrcweir #if 1
2791cdf0e10cSrcweir if( HandleScrollCommand( rCEvt ) )
2792cdf0e10cSrcweir return;
2793cdf0e10cSrcweir #else
2794cdf0e10cSrcweir ScrollBar* pHor = aHorSBar.IsVisible() ? &aHorSBar : 0;
2795cdf0e10cSrcweir ScrollBar* pVer = aVerSBar.IsVisible() ? &aVerSBar : 0;
2796cdf0e10cSrcweir if( pView->HandleScrollCommand( rCEvt, pHor, pVer ) )
2797cdf0e10cSrcweir return;
2798cdf0e10cSrcweir #endif
2799cdf0e10cSrcweir }
2800cdf0e10cSrcweir }
2801cdf0e10cSrcweir
ToTop(SvxIconChoiceCtrlEntry * pEntry)2802cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::ToTop( SvxIconChoiceCtrlEntry* pEntry )
2803cdf0e10cSrcweir {
2804cdf0e10cSrcweir if( pZOrderList->GetObject( pZOrderList->Count() - 1 ) != pEntry )
2805cdf0e10cSrcweir {
2806cdf0e10cSrcweir sal_uLong nPos = pZOrderList->GetPos( (void*)pEntry );
2807cdf0e10cSrcweir pZOrderList->Remove( nPos );
2808cdf0e10cSrcweir pZOrderList->Insert( pEntry, LIST_APPEND );
2809cdf0e10cSrcweir }
2810cdf0e10cSrcweir }
2811cdf0e10cSrcweir
ClipAtVirtOutRect(Rectangle & rRect) const2812cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::ClipAtVirtOutRect( Rectangle& rRect ) const
2813cdf0e10cSrcweir {
2814cdf0e10cSrcweir if( rRect.Bottom() >= aVirtOutputSize.Height() )
2815cdf0e10cSrcweir rRect.Bottom() = aVirtOutputSize.Height() - 1;
2816cdf0e10cSrcweir if( rRect.Right() >= aVirtOutputSize.Width() )
2817cdf0e10cSrcweir rRect.Right() = aVirtOutputSize.Width() - 1;
2818cdf0e10cSrcweir if( rRect.Top() < 0 )
2819cdf0e10cSrcweir rRect.Top() = 0;
2820cdf0e10cSrcweir if( rRect.Left() < 0 )
2821cdf0e10cSrcweir rRect.Left() = 0;
2822cdf0e10cSrcweir }
2823cdf0e10cSrcweir
2824cdf0e10cSrcweir // rRect: Bereich des Dokumentes (in Dokumentkoordinaten), der
2825cdf0e10cSrcweir // sichtbar gemacht werden soll.
2826cdf0e10cSrcweir // bScrBar == sal_True: Das Rect wurde aufgrund eines ScrollBar-Events berechnet
2827cdf0e10cSrcweir
MakeVisible(const Rectangle & rRect,sal_Bool bScrBar,sal_Bool bCallRectChangedHdl)2828cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::MakeVisible( const Rectangle& rRect, sal_Bool bScrBar,
2829cdf0e10cSrcweir sal_Bool bCallRectChangedHdl )
2830cdf0e10cSrcweir {
2831cdf0e10cSrcweir Rectangle aVirtRect( rRect );
2832cdf0e10cSrcweir ClipAtVirtOutRect( aVirtRect );
2833cdf0e10cSrcweir Point aOrigin( pView->GetMapMode().GetOrigin() );
2834cdf0e10cSrcweir // in Dokumentkoordinate umwandeln
2835cdf0e10cSrcweir aOrigin *= -1;
2836cdf0e10cSrcweir Rectangle aOutputArea( GetOutputRect() );
2837cdf0e10cSrcweir if( aOutputArea.IsInside( aVirtRect ) )
2838cdf0e10cSrcweir return; // ist schon sichtbar
2839cdf0e10cSrcweir
2840cdf0e10cSrcweir long nDy;
2841cdf0e10cSrcweir if( aVirtRect.Top() < aOutputArea.Top() )
2842cdf0e10cSrcweir {
2843cdf0e10cSrcweir // nach oben scrollen (nDy < 0)
2844cdf0e10cSrcweir nDy = aVirtRect.Top() - aOutputArea.Top();
2845cdf0e10cSrcweir }
2846cdf0e10cSrcweir else if( aVirtRect.Bottom() > aOutputArea.Bottom() )
2847cdf0e10cSrcweir {
2848cdf0e10cSrcweir // nach unten scrollen (nDy > 0)
2849cdf0e10cSrcweir nDy = aVirtRect.Bottom() - aOutputArea.Bottom();
2850cdf0e10cSrcweir }
2851cdf0e10cSrcweir else
2852cdf0e10cSrcweir nDy = 0;
2853cdf0e10cSrcweir
2854cdf0e10cSrcweir long nDx;
2855cdf0e10cSrcweir if( aVirtRect.Left() < aOutputArea.Left() )
2856cdf0e10cSrcweir {
2857cdf0e10cSrcweir // nach links scrollen (nDx < 0)
2858cdf0e10cSrcweir nDx = aVirtRect.Left() - aOutputArea.Left();
2859cdf0e10cSrcweir }
2860cdf0e10cSrcweir else if( aVirtRect.Right() > aOutputArea.Right() )
2861cdf0e10cSrcweir {
2862cdf0e10cSrcweir // nach rechts scrollen (nDx > 0)
2863cdf0e10cSrcweir nDx = aVirtRect.Right() - aOutputArea.Right();
2864cdf0e10cSrcweir }
2865cdf0e10cSrcweir else
2866cdf0e10cSrcweir nDx = 0;
2867cdf0e10cSrcweir
2868cdf0e10cSrcweir aOrigin.X() += nDx;
2869cdf0e10cSrcweir aOrigin.Y() += nDy;
2870cdf0e10cSrcweir aOutputArea.SetPos( aOrigin );
2871cdf0e10cSrcweir if( GetUpdateMode() )
2872cdf0e10cSrcweir {
2873cdf0e10cSrcweir HideDDIcon();
2874cdf0e10cSrcweir pView->Update();
2875cdf0e10cSrcweir ShowCursor( sal_False );
2876cdf0e10cSrcweir }
2877cdf0e10cSrcweir
2878cdf0e10cSrcweir // Origin fuer SV invertieren (damit wir in
2879cdf0e10cSrcweir // Dokumentkoordinaten scrollen/painten koennen)
2880cdf0e10cSrcweir aOrigin *= -1;
2881cdf0e10cSrcweir SetOrigin( aOrigin );
2882cdf0e10cSrcweir
2883cdf0e10cSrcweir sal_Bool bScrollable = pView->GetBackground().IsScrollable();
2884cdf0e10cSrcweir if( pView->HasBackground() && !bScrollable )
2885cdf0e10cSrcweir {
2886cdf0e10cSrcweir Rectangle aRect( GetOutputRect());
2887cdf0e10cSrcweir Wallpaper aPaper( pView->GetBackground() );
2888cdf0e10cSrcweir aPaper.SetRect( aRect );
2889cdf0e10cSrcweir pView->SetBackground( aPaper );
2890cdf0e10cSrcweir }
2891cdf0e10cSrcweir
2892cdf0e10cSrcweir if( bScrollable && GetUpdateMode() )
2893cdf0e10cSrcweir {
2894cdf0e10cSrcweir // in umgekehrte Richtung scrollen!
2895cdf0e10cSrcweir pView->Control::Scroll( -nDx, -nDy, aOutputArea,
2896cdf0e10cSrcweir SCROLL_NOCHILDREN | SCROLL_USECLIPREGION | SCROLL_CLIP );
2897cdf0e10cSrcweir }
2898cdf0e10cSrcweir else
2899cdf0e10cSrcweir pView->Invalidate(INVALIDATE_NOCHILDREN);
2900cdf0e10cSrcweir
2901cdf0e10cSrcweir if( aHorSBar.IsVisible() || aVerSBar.IsVisible() )
2902cdf0e10cSrcweir {
2903cdf0e10cSrcweir if( !bScrBar )
2904cdf0e10cSrcweir {
2905cdf0e10cSrcweir aOrigin *= -1;
2906cdf0e10cSrcweir // Thumbs korrigieren
2907cdf0e10cSrcweir if(aHorSBar.IsVisible() && aHorSBar.GetThumbPos() != aOrigin.X())
2908cdf0e10cSrcweir aHorSBar.SetThumbPos( aOrigin.X() );
2909cdf0e10cSrcweir if(aVerSBar.IsVisible() && aVerSBar.GetThumbPos() != aOrigin.Y())
2910cdf0e10cSrcweir aVerSBar.SetThumbPos( aOrigin.Y() );
2911cdf0e10cSrcweir }
2912cdf0e10cSrcweir }
2913cdf0e10cSrcweir
2914cdf0e10cSrcweir if( GetUpdateMode() )
2915cdf0e10cSrcweir ShowCursor( sal_True );
2916cdf0e10cSrcweir
2917cdf0e10cSrcweir // pruefen, ob ScrollBars noch benoetigt werden
2918cdf0e10cSrcweir CheckScrollBars();
2919cdf0e10cSrcweir if( bScrollable && GetUpdateMode() )
2920cdf0e10cSrcweir pView->Update();
2921cdf0e10cSrcweir
2922cdf0e10cSrcweir // kann der angeforderte Bereich nicht komplett sichtbar gemacht werden,
2923cdf0e10cSrcweir // wird auf jeden Fall der Vis-Rect-Changed-Handler gerufen. Eintreten kann der
2924cdf0e10cSrcweir // Fall z.B. wenn nur wenige Pixel des unteren Randes nicht sichtbar sind,
2925cdf0e10cSrcweir // eine ScrollBar aber eine groessere Line-Size eingestellt hat.
2926cdf0e10cSrcweir if( bCallRectChangedHdl || GetOutputRect() != rRect )
2927cdf0e10cSrcweir VisRectChanged();
2928cdf0e10cSrcweir }
2929cdf0e10cSrcweir
2930cdf0e10cSrcweir
FindNewCursor()2931cdf0e10cSrcweir SvxIconChoiceCtrlEntry* SvxIconChoiceCtrl_Impl::FindNewCursor()
2932cdf0e10cSrcweir {
2933cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pNewCursor;
2934cdf0e10cSrcweir if( pCursor )
2935cdf0e10cSrcweir {
2936cdf0e10cSrcweir pNewCursor = pImpCursor->GoLeftRight( pCursor, sal_False );
2937cdf0e10cSrcweir if( !pNewCursor )
2938cdf0e10cSrcweir {
2939cdf0e10cSrcweir pNewCursor = pImpCursor->GoLeftRight( pCursor, sal_True );
2940cdf0e10cSrcweir if( !pNewCursor )
2941cdf0e10cSrcweir {
2942cdf0e10cSrcweir pNewCursor = pImpCursor->GoUpDown( pCursor, sal_False );
2943cdf0e10cSrcweir if( !pNewCursor )
2944cdf0e10cSrcweir pNewCursor = pImpCursor->GoUpDown( pCursor, sal_True );
2945cdf0e10cSrcweir }
2946cdf0e10cSrcweir }
2947cdf0e10cSrcweir }
2948cdf0e10cSrcweir else
2949cdf0e10cSrcweir pNewCursor = (SvxIconChoiceCtrlEntry*)aEntries.First();
2950cdf0e10cSrcweir DBG_ASSERT(!pNewCursor|| (pCursor&&pCursor!=pNewCursor),"FindNewCursor failed");
2951cdf0e10cSrcweir return pNewCursor;
2952cdf0e10cSrcweir }
2953cdf0e10cSrcweir
GetSelectionCount() const2954cdf0e10cSrcweir sal_uLong SvxIconChoiceCtrl_Impl::GetSelectionCount() const
2955cdf0e10cSrcweir {
2956cdf0e10cSrcweir if( (nWinBits & WB_HIGHLIGHTFRAME) && pCurHighlightFrame )
2957cdf0e10cSrcweir return 1;
2958cdf0e10cSrcweir return nSelectionCount;
2959cdf0e10cSrcweir }
2960cdf0e10cSrcweir
ToggleSelection(SvxIconChoiceCtrlEntry * pEntry)2961cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::ToggleSelection( SvxIconChoiceCtrlEntry* pEntry )
2962cdf0e10cSrcweir {
2963cdf0e10cSrcweir sal_Bool bSel;
2964cdf0e10cSrcweir if( pEntry->IsSelected() )
2965cdf0e10cSrcweir bSel = sal_False;
2966cdf0e10cSrcweir else
2967cdf0e10cSrcweir bSel = sal_True;
2968cdf0e10cSrcweir SelectEntry( pEntry, bSel, sal_True, sal_True );
2969cdf0e10cSrcweir }
2970cdf0e10cSrcweir
DeselectAllBut(SvxIconChoiceCtrlEntry * pThisEntryNot,sal_Bool bPaintSync)2971cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::DeselectAllBut( SvxIconChoiceCtrlEntry* pThisEntryNot,
2972cdf0e10cSrcweir sal_Bool bPaintSync )
2973cdf0e10cSrcweir {
2974cdf0e10cSrcweir ClearSelectedRectList();
2975cdf0e10cSrcweir //
2976cdf0e10cSrcweir // !!!!!!! Todo: Evtl. Z-Orderlist abarbeiten !!!!!!!
2977cdf0e10cSrcweir //
2978cdf0e10cSrcweir sal_uLong nCount = aEntries.Count();
2979cdf0e10cSrcweir for( sal_uLong nCur = 0; nCur < nCount; nCur++ )
2980cdf0e10cSrcweir {
2981cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)aEntries.GetObject( nCur );
2982cdf0e10cSrcweir if( pEntry != pThisEntryNot && pEntry->IsSelected() )
2983cdf0e10cSrcweir SelectEntry( pEntry, sal_False, sal_True, sal_True, bPaintSync );
2984cdf0e10cSrcweir }
2985cdf0e10cSrcweir pAnchor = 0;
2986cdf0e10cSrcweir nFlags &= (~F_ADD_MODE);
2987cdf0e10cSrcweir }
2988cdf0e10cSrcweir
GetMinGrid() const2989cdf0e10cSrcweir Size SvxIconChoiceCtrl_Impl::GetMinGrid() const
2990cdf0e10cSrcweir {
2991cdf0e10cSrcweir Size aMinSize( aImageSize );
2992cdf0e10cSrcweir aMinSize.Width() += 2 * LROFFS_BOUND;
2993cdf0e10cSrcweir aMinSize.Height() += TBOFFS_BOUND; // PB: einmal Offset reicht (FileDlg)
2994cdf0e10cSrcweir String aStrDummy( RTL_CONSTASCII_USTRINGPARAM( "XXX" ) );
2995cdf0e10cSrcweir Size aTextSize( pView->GetTextWidth( aStrDummy ), pView->GetTextHeight() );
2996cdf0e10cSrcweir if( nWinBits & WB_ICON )
2997cdf0e10cSrcweir {
2998cdf0e10cSrcweir aMinSize.Height() += VER_DIST_BMP_STRING;
2999cdf0e10cSrcweir aMinSize.Height() += aTextSize.Height();
3000cdf0e10cSrcweir }
3001cdf0e10cSrcweir else
3002cdf0e10cSrcweir {
3003cdf0e10cSrcweir aMinSize.Width() += HOR_DIST_BMP_STRING;
3004cdf0e10cSrcweir aMinSize.Width() += aTextSize.Width();
3005cdf0e10cSrcweir }
3006cdf0e10cSrcweir return aMinSize;
3007cdf0e10cSrcweir }
3008cdf0e10cSrcweir
SetGrid(const Size & rSize)3009cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SetGrid( const Size& rSize )
3010cdf0e10cSrcweir {
3011cdf0e10cSrcweir Size aSize( rSize );
3012cdf0e10cSrcweir Size aMinSize( GetMinGrid() );
3013cdf0e10cSrcweir if( aSize.Width() < aMinSize.Width() )
3014cdf0e10cSrcweir aSize.Width() = aMinSize.Width();
3015cdf0e10cSrcweir if( aSize.Height() < aMinSize.Height() )
3016cdf0e10cSrcweir aSize.Height() = aMinSize.Height();
3017cdf0e10cSrcweir
3018cdf0e10cSrcweir nGridDX = aSize.Width();
3019cdf0e10cSrcweir // HACK(Detail-Modus ist noch nicht vollstaendig implementiert!)
3020cdf0e10cSrcweir // dieses Workaround bringts mit einer Spalte zum Fliegen
3021cdf0e10cSrcweir if( nWinBits & WB_DETAILS )
3022cdf0e10cSrcweir {
3023cdf0e10cSrcweir const SvxIconChoiceCtrlColumnInfo* pCol = GetColumn( 0 );
3024cdf0e10cSrcweir if( pCol )
3025cdf0e10cSrcweir ((SvxIconChoiceCtrlColumnInfo*)pCol)->SetWidth( nGridDX );
3026cdf0e10cSrcweir }
3027cdf0e10cSrcweir nGridDY = aSize.Height();
3028cdf0e10cSrcweir SetDefaultTextSize();
3029cdf0e10cSrcweir }
3030cdf0e10cSrcweir
3031cdf0e10cSrcweir // berechnet die maximale Groesse, die das Textrechteck innerhalb des
3032cdf0e10cSrcweir // umschliessenden Rechtecks einnehmen kann. Im Modus WB_ICON und
3033cdf0e10cSrcweir // IcnShowTextFull wird Bottom auf LONG_MAX gesetzt
3034cdf0e10cSrcweir
CalcMaxTextRect(const SvxIconChoiceCtrlEntry * pEntry) const3035cdf0e10cSrcweir Rectangle SvxIconChoiceCtrl_Impl::CalcMaxTextRect( const SvxIconChoiceCtrlEntry* pEntry ) const
3036cdf0e10cSrcweir {
3037cdf0e10cSrcweir Rectangle aBoundRect;
3038cdf0e10cSrcweir // keine Endlosrekursion! deshalb das Bound-Rect hier nicht berechnen
3039cdf0e10cSrcweir if( IsBoundingRectValid( pEntry->aRect ) )
3040cdf0e10cSrcweir aBoundRect = pEntry->aRect;
3041cdf0e10cSrcweir else
3042cdf0e10cSrcweir aBoundRect = pEntry->aGridRect;
3043cdf0e10cSrcweir
3044cdf0e10cSrcweir Rectangle aBmpRect( ((SvxIconChoiceCtrl_Impl*)this)->CalcBmpRect(
3045cdf0e10cSrcweir (SvxIconChoiceCtrlEntry*)pEntry ) );
3046cdf0e10cSrcweir if( nWinBits & WB_ICON )
3047cdf0e10cSrcweir {
3048cdf0e10cSrcweir aBoundRect.Top() = aBmpRect.Bottom();
3049cdf0e10cSrcweir aBoundRect.Top() += VER_DIST_BMP_STRING;
3050cdf0e10cSrcweir if( aBoundRect.Top() > aBoundRect.Bottom())
3051cdf0e10cSrcweir aBoundRect.Top() = aBoundRect.Bottom();
3052cdf0e10cSrcweir aBoundRect.Left() += LROFFS_BOUND;
3053cdf0e10cSrcweir aBoundRect.Left()++;
3054cdf0e10cSrcweir aBoundRect.Right() -= LROFFS_BOUND;
3055cdf0e10cSrcweir aBoundRect.Right()--;
3056cdf0e10cSrcweir if( aBoundRect.Left() > aBoundRect.Right())
3057cdf0e10cSrcweir aBoundRect.Left() = aBoundRect.Right();
3058cdf0e10cSrcweir if( GetEntryTextModeSmart( pEntry ) == IcnShowTextFull )
3059cdf0e10cSrcweir aBoundRect.Bottom() = LONG_MAX;
3060cdf0e10cSrcweir }
3061cdf0e10cSrcweir else
3062cdf0e10cSrcweir {
3063cdf0e10cSrcweir aBoundRect.Left() = aBmpRect.Right();
3064cdf0e10cSrcweir aBoundRect.Left() += HOR_DIST_BMP_STRING;
3065cdf0e10cSrcweir aBoundRect.Right() -= LROFFS_BOUND;
3066cdf0e10cSrcweir if( aBoundRect.Left() > aBoundRect.Right() )
3067cdf0e10cSrcweir aBoundRect.Left() = aBoundRect.Right();
3068cdf0e10cSrcweir long nHeight = aBoundRect.GetSize().Height();
3069cdf0e10cSrcweir nHeight = nHeight - aDefaultTextSize.Height();
3070cdf0e10cSrcweir nHeight /= 2;
3071cdf0e10cSrcweir aBoundRect.Top() += nHeight;
3072cdf0e10cSrcweir aBoundRect.Bottom() -= nHeight;
3073cdf0e10cSrcweir }
3074cdf0e10cSrcweir return aBoundRect;
3075cdf0e10cSrcweir }
3076cdf0e10cSrcweir
SetDefaultTextSize()3077cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SetDefaultTextSize()
3078cdf0e10cSrcweir {
3079cdf0e10cSrcweir long nDY = nGridDY;
3080cdf0e10cSrcweir nDY -= aImageSize.Height();
3081cdf0e10cSrcweir nDY -= VER_DIST_BMP_STRING;
3082cdf0e10cSrcweir nDY -= 2*TBOFFS_BOUND;
3083cdf0e10cSrcweir if( nDY <= 0 )
3084cdf0e10cSrcweir nDY = 2;
3085cdf0e10cSrcweir
3086cdf0e10cSrcweir long nDX = nGridDX;
3087cdf0e10cSrcweir nDX -= 2*LROFFS_BOUND;
3088cdf0e10cSrcweir nDX -= 2;
3089cdf0e10cSrcweir if( nDX <= 0 )
3090cdf0e10cSrcweir nDX = 2;
3091cdf0e10cSrcweir
3092cdf0e10cSrcweir String aStrDummy( RTL_CONSTASCII_USTRINGPARAM( "X" ) );
3093cdf0e10cSrcweir long nHeight = pView->GetTextHeight();
3094cdf0e10cSrcweir if( nDY < nHeight )
3095cdf0e10cSrcweir nDY = nHeight;
3096cdf0e10cSrcweir aDefaultTextSize = Size( nDX, nDY );
3097cdf0e10cSrcweir }
3098cdf0e10cSrcweir
3099cdf0e10cSrcweir
Center(SvxIconChoiceCtrlEntry * pEntry) const3100cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::Center( SvxIconChoiceCtrlEntry* pEntry ) const
3101cdf0e10cSrcweir {
3102cdf0e10cSrcweir pEntry->aRect = pEntry->aGridRect;
3103cdf0e10cSrcweir Size aSize( CalcBoundingSize( pEntry ) );
3104cdf0e10cSrcweir if( nWinBits & WB_ICON )
3105cdf0e10cSrcweir {
3106cdf0e10cSrcweir // horizontal zentrieren
3107cdf0e10cSrcweir long nBorder = pEntry->aGridRect.GetWidth() - aSize.Width();
3108cdf0e10cSrcweir pEntry->aRect.Left() += nBorder / 2;
3109cdf0e10cSrcweir pEntry->aRect.Right() -= nBorder / 2;
3110cdf0e10cSrcweir }
3111cdf0e10cSrcweir // vertikal zentrieren
3112cdf0e10cSrcweir pEntry->aRect.Bottom() = pEntry->aRect.Top() + aSize.Height();
3113cdf0e10cSrcweir }
3114cdf0e10cSrcweir
3115cdf0e10cSrcweir
3116cdf0e10cSrcweir // Die Deltas entsprechen Offsets, um die die View auf dem Doc verschoben wird
3117cdf0e10cSrcweir // links, hoch: Offsets < 0
3118cdf0e10cSrcweir // rechts, runter: Offsets > 0
Scroll(long nDeltaX,long nDeltaY,sal_Bool bScrollBar)3119cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::Scroll( long nDeltaX, long nDeltaY, sal_Bool bScrollBar )
3120cdf0e10cSrcweir {
3121cdf0e10cSrcweir const MapMode& rMapMode = pView->GetMapMode();
3122cdf0e10cSrcweir Point aOrigin( rMapMode.GetOrigin() );
3123cdf0e10cSrcweir // in Dokumentkoordinate umwandeln
3124cdf0e10cSrcweir aOrigin *= -1;
3125cdf0e10cSrcweir aOrigin.Y() += nDeltaY;
3126cdf0e10cSrcweir aOrigin.X() += nDeltaX;
3127cdf0e10cSrcweir Rectangle aRect( aOrigin, aOutputSize );
3128cdf0e10cSrcweir MakeVisible( aRect, bScrollBar );
3129cdf0e10cSrcweir }
3130cdf0e10cSrcweir
3131cdf0e10cSrcweir
GetItemSize(SvxIconChoiceCtrlEntry *,IcnViewFieldType eItem) const3132cdf0e10cSrcweir const Size& SvxIconChoiceCtrl_Impl::GetItemSize( SvxIconChoiceCtrlEntry*,
3133cdf0e10cSrcweir IcnViewFieldType eItem ) const
3134cdf0e10cSrcweir {
3135cdf0e10cSrcweir if( eItem == IcnViewFieldTypeText )
3136cdf0e10cSrcweir return aDefaultTextSize;
3137cdf0e10cSrcweir return aImageSize;
3138cdf0e10cSrcweir }
3139cdf0e10cSrcweir
CalcFocusRect(SvxIconChoiceCtrlEntry * pEntry)3140cdf0e10cSrcweir Rectangle SvxIconChoiceCtrl_Impl::CalcFocusRect( SvxIconChoiceCtrlEntry* pEntry )
3141cdf0e10cSrcweir {
3142cdf0e10cSrcweir Rectangle aBmpRect( CalcBmpRect( pEntry ) );
3143cdf0e10cSrcweir Rectangle aTextRect( CalcTextRect( pEntry ) );
3144cdf0e10cSrcweir Rectangle aBoundRect( GetEntryBoundRect( pEntry ) );
3145cdf0e10cSrcweir Rectangle aFocusRect( aBoundRect.Left(), aBmpRect.Top() - 1,
3146cdf0e10cSrcweir aBoundRect.Right() - 4, aTextRect.Bottom() + 1 );
3147cdf0e10cSrcweir // Das Fokusrechteck soll nicht den Text beruehren
3148cdf0e10cSrcweir if( aFocusRect.Left() - 1 >= pEntry->aRect.Left() )
3149cdf0e10cSrcweir aFocusRect.Left()--;
3150cdf0e10cSrcweir if( aFocusRect.Right() + 1 <= pEntry->aRect.Right() )
3151cdf0e10cSrcweir aFocusRect.Right()++;
3152cdf0e10cSrcweir
3153cdf0e10cSrcweir return aFocusRect;
3154cdf0e10cSrcweir }
3155cdf0e10cSrcweir
3156cdf0e10cSrcweir // Der 'Hot Spot' sind die inneren 50% der Rechteckflaeche
GetHotSpot(const Rectangle & rRect)3157cdf0e10cSrcweir static Rectangle GetHotSpot( const Rectangle& rRect )
3158cdf0e10cSrcweir {
3159cdf0e10cSrcweir Rectangle aResult( rRect );
3160cdf0e10cSrcweir aResult.Justify();
3161cdf0e10cSrcweir Size aSize( rRect.GetSize() );
3162cdf0e10cSrcweir long nDelta = aSize.Width() / 4;
3163cdf0e10cSrcweir aResult.Left() += nDelta;
3164cdf0e10cSrcweir aResult.Right() -= nDelta;
3165cdf0e10cSrcweir nDelta = aSize.Height() / 4;
3166cdf0e10cSrcweir aResult.Top() += nDelta;
3167cdf0e10cSrcweir aResult.Bottom() -= nDelta;
3168cdf0e10cSrcweir return aResult;
3169cdf0e10cSrcweir }
3170cdf0e10cSrcweir
SelectRect(SvxIconChoiceCtrlEntry * pEntry1,SvxIconChoiceCtrlEntry * pEntry2,sal_Bool bAdd,SvPtrarr * pOtherRects)3171cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SelectRect( SvxIconChoiceCtrlEntry* pEntry1, SvxIconChoiceCtrlEntry* pEntry2,
3172cdf0e10cSrcweir sal_Bool bAdd, SvPtrarr* pOtherRects )
3173cdf0e10cSrcweir {
3174cdf0e10cSrcweir DBG_ASSERT(pEntry1 && pEntry2,"SelectEntry: Invalid Entry-Ptr");
3175cdf0e10cSrcweir Rectangle aRect( GetEntryBoundRect( pEntry1 ) );
3176cdf0e10cSrcweir aRect.Union( GetEntryBoundRect( pEntry2 ) );
3177cdf0e10cSrcweir SelectRect( aRect, bAdd, pOtherRects );
3178cdf0e10cSrcweir }
3179cdf0e10cSrcweir
SelectRect(const Rectangle & rRect,sal_Bool bAdd,SvPtrarr * pOtherRects)3180cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SelectRect( const Rectangle& rRect, sal_Bool bAdd,
3181cdf0e10cSrcweir SvPtrarr* pOtherRects )
3182cdf0e10cSrcweir {
3183cdf0e10cSrcweir aCurSelectionRect = rRect;
3184cdf0e10cSrcweir if( !pZOrderList || !pZOrderList->Count() )
3185cdf0e10cSrcweir return;
3186cdf0e10cSrcweir
3187cdf0e10cSrcweir // Flag setzen, damit im Select kein ToTop gerufen wird
3188cdf0e10cSrcweir sal_Bool bAlreadySelectingRect = nFlags & F_SELECTING_RECT ? sal_True : sal_False;
3189cdf0e10cSrcweir nFlags |= F_SELECTING_RECT;
3190cdf0e10cSrcweir
3191cdf0e10cSrcweir CheckBoundingRects();
3192cdf0e10cSrcweir pView->Update();
3193cdf0e10cSrcweir const sal_uLong nCount = pZOrderList->Count();
3194cdf0e10cSrcweir
3195cdf0e10cSrcweir Rectangle aRect( rRect );
3196cdf0e10cSrcweir aRect.Justify();
3197cdf0e10cSrcweir sal_Bool bCalcOverlap = (bAdd && pOtherRects && pOtherRects->Count()) ? sal_True : sal_False;
3198cdf0e10cSrcweir
3199cdf0e10cSrcweir sal_Bool bResetClipRegion = sal_False;
3200cdf0e10cSrcweir if( !pView->IsClipRegion() )
3201cdf0e10cSrcweir {
3202cdf0e10cSrcweir bResetClipRegion = sal_True;
3203cdf0e10cSrcweir pView->SetClipRegion( GetOutputRect() );
3204cdf0e10cSrcweir }
3205cdf0e10cSrcweir
3206cdf0e10cSrcweir for( sal_uLong nPos = 0; nPos < nCount; nPos++ )
3207cdf0e10cSrcweir {
3208cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)(pZOrderList->GetObject(nPos ));
3209cdf0e10cSrcweir
3210cdf0e10cSrcweir if( !IsBoundingRectValid( pEntry->aRect ))
3211cdf0e10cSrcweir FindBoundingRect( pEntry );
3212cdf0e10cSrcweir Rectangle aBoundRect( GetHotSpot( pEntry->aRect ) );
3213cdf0e10cSrcweir sal_Bool bSelected = pEntry->IsSelected();
3214cdf0e10cSrcweir
3215cdf0e10cSrcweir sal_Bool bOverlaps;
3216cdf0e10cSrcweir if( bCalcOverlap )
3217cdf0e10cSrcweir bOverlaps = IsOver( pOtherRects, aBoundRect );
3218cdf0e10cSrcweir else
3219cdf0e10cSrcweir bOverlaps = sal_False;
3220cdf0e10cSrcweir sal_Bool bOver = aRect.IsOver( aBoundRect );
3221cdf0e10cSrcweir
3222cdf0e10cSrcweir if( bOver && !bOverlaps )
3223cdf0e10cSrcweir {
3224cdf0e10cSrcweir // Ist im neuen Selektionsrechteck und in keinem alten
3225cdf0e10cSrcweir // => selektieren
3226cdf0e10cSrcweir if( !bSelected )
3227cdf0e10cSrcweir SelectEntry( pEntry, sal_True, sal_True, sal_True );
3228cdf0e10cSrcweir }
3229cdf0e10cSrcweir else if( !bAdd )
3230cdf0e10cSrcweir {
3231cdf0e10cSrcweir // ist ausserhalb des Selektionsrechtecks
3232cdf0e10cSrcweir // => Selektion entfernen
3233cdf0e10cSrcweir if( bSelected )
3234cdf0e10cSrcweir SelectEntry( pEntry, sal_False, sal_True, sal_True );
3235cdf0e10cSrcweir }
3236cdf0e10cSrcweir else if( bAdd && bOverlaps )
3237cdf0e10cSrcweir {
3238cdf0e10cSrcweir // Der Eintrag befindet sich in einem alten (=>Aufspannen
3239cdf0e10cSrcweir // mehrerer Rechtecke mit Ctrl!) Selektionsrechteck
3240cdf0e10cSrcweir
3241cdf0e10cSrcweir // Hier ist noch ein Bug! Der Selektionsstatus eines Eintrags
3242cdf0e10cSrcweir // in einem vorherigen Rechteck, muss restauriert werden, wenn
3243cdf0e10cSrcweir // er vom aktuellen Selektionsrechteck beruehrt wurde, jetzt aber
3244cdf0e10cSrcweir // nicht mehr in ihm liegt. Ich gehe hier der Einfachheit halber
3245cdf0e10cSrcweir // pauschal davon aus, dass die Eintraege in den alten Rechtecken
3246cdf0e10cSrcweir // alle selektiert sind. Ebenso ist es falsch, die Schnittmenge
3247cdf0e10cSrcweir // nur zu deselektieren.
3248cdf0e10cSrcweir // Loesungsmoeglichkeit: Snapshot der Selektion vor dem Auf-
3249cdf0e10cSrcweir // spannen des Rechtecks merken
3250cdf0e10cSrcweir if( aBoundRect.IsOver( rRect))
3251cdf0e10cSrcweir {
3252cdf0e10cSrcweir // Schnittmenge zwischen alten Rects & aktuellem Rect desel.
3253cdf0e10cSrcweir if( bSelected )
3254cdf0e10cSrcweir SelectEntry( pEntry, sal_False, sal_True, sal_True );
3255cdf0e10cSrcweir }
3256cdf0e10cSrcweir else
3257cdf0e10cSrcweir {
3258cdf0e10cSrcweir // Eintrag eines alten Rects selektieren
3259cdf0e10cSrcweir if( !bSelected )
3260cdf0e10cSrcweir SelectEntry( pEntry, sal_True, sal_True, sal_True );
3261cdf0e10cSrcweir }
3262cdf0e10cSrcweir }
3263cdf0e10cSrcweir else if( !bOver && bSelected )
3264cdf0e10cSrcweir {
3265cdf0e10cSrcweir // Der Eintrag liegt voellig ausserhalb und wird deshalb desel.
3266cdf0e10cSrcweir SelectEntry( pEntry, sal_False, sal_True, sal_True );
3267cdf0e10cSrcweir }
3268cdf0e10cSrcweir }
3269cdf0e10cSrcweir
3270cdf0e10cSrcweir if( !bAlreadySelectingRect )
3271cdf0e10cSrcweir nFlags &= ~F_SELECTING_RECT;
3272cdf0e10cSrcweir
3273cdf0e10cSrcweir pView->Update();
3274cdf0e10cSrcweir if( bResetClipRegion )
3275cdf0e10cSrcweir pView->SetClipRegion();
3276cdf0e10cSrcweir }
3277cdf0e10cSrcweir
SelectRange(SvxIconChoiceCtrlEntry * pStart,SvxIconChoiceCtrlEntry * pEnd,sal_Bool bAdd)3278cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SelectRange(
3279cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pStart,
3280cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEnd,
3281cdf0e10cSrcweir sal_Bool bAdd )
3282cdf0e10cSrcweir {
3283cdf0e10cSrcweir sal_uLong nFront = GetEntryListPos( pStart );
3284cdf0e10cSrcweir sal_uLong nBack = GetEntryListPos( pEnd );
3285cdf0e10cSrcweir sal_uLong nFirst = std::min( nFront, nBack );
3286cdf0e10cSrcweir sal_uLong nLast = std::max( nFront, nBack );
3287cdf0e10cSrcweir sal_uLong i;
3288cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry;
3289cdf0e10cSrcweir
3290cdf0e10cSrcweir if ( ! bAdd )
3291cdf0e10cSrcweir {
3292cdf0e10cSrcweir // deselect everything before the first entry if not in
3293cdf0e10cSrcweir // adding mode
3294cdf0e10cSrcweir for ( i=0; i<nFirst; i++ )
3295cdf0e10cSrcweir {
3296cdf0e10cSrcweir pEntry = GetEntry( i );
3297cdf0e10cSrcweir if( pEntry->IsSelected() )
3298cdf0e10cSrcweir SelectEntry( pEntry, sal_False, sal_True, sal_True, sal_True );
3299cdf0e10cSrcweir }
3300cdf0e10cSrcweir }
3301cdf0e10cSrcweir
3302cdf0e10cSrcweir // select everything between nFirst and nLast
3303cdf0e10cSrcweir for ( i=nFirst; i<=nLast; i++ )
3304cdf0e10cSrcweir {
3305cdf0e10cSrcweir pEntry = GetEntry( i );
3306cdf0e10cSrcweir if( ! pEntry->IsSelected() )
3307cdf0e10cSrcweir SelectEntry( pEntry, sal_True, sal_True, sal_True, sal_True );
3308cdf0e10cSrcweir }
3309cdf0e10cSrcweir
3310cdf0e10cSrcweir if ( ! bAdd )
3311cdf0e10cSrcweir {
3312cdf0e10cSrcweir // deselect everything behind the last entry if not in
3313cdf0e10cSrcweir // adding mode
3314cdf0e10cSrcweir sal_uLong nEnd = GetEntryCount();
3315cdf0e10cSrcweir for ( ; i<nEnd; i++ )
3316cdf0e10cSrcweir {
3317cdf0e10cSrcweir pEntry = GetEntry( i );
3318cdf0e10cSrcweir if( pEntry->IsSelected() )
3319cdf0e10cSrcweir SelectEntry( pEntry, sal_False, sal_True, sal_True, sal_True );
3320cdf0e10cSrcweir }
3321cdf0e10cSrcweir }
3322cdf0e10cSrcweir }
3323cdf0e10cSrcweir
IsOver(SvPtrarr * pRectList,const Rectangle & rBoundRect) const3324cdf0e10cSrcweir sal_Bool SvxIconChoiceCtrl_Impl::IsOver( SvPtrarr* pRectList, const Rectangle& rBoundRect ) const
3325cdf0e10cSrcweir {
3326cdf0e10cSrcweir const sal_uInt16 nCount = pRectList->Count();
3327cdf0e10cSrcweir for( sal_uInt16 nCur = 0; nCur < nCount; nCur++ )
3328cdf0e10cSrcweir {
3329cdf0e10cSrcweir Rectangle* pRect = (Rectangle*)pRectList->GetObject( nCur );
3330cdf0e10cSrcweir if( rBoundRect.IsOver( *pRect ))
3331cdf0e10cSrcweir return sal_True;
3332cdf0e10cSrcweir }
3333cdf0e10cSrcweir return sal_False;
3334cdf0e10cSrcweir }
3335cdf0e10cSrcweir
AddSelectedRect(SvxIconChoiceCtrlEntry * pEntry1,SvxIconChoiceCtrlEntry * pEntry2)3336cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::AddSelectedRect( SvxIconChoiceCtrlEntry* pEntry1,
3337cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry2 )
3338cdf0e10cSrcweir {
3339cdf0e10cSrcweir DBG_ASSERT(pEntry1 && pEntry2,"SelectEntry: Invalid Entry-Ptr");
3340cdf0e10cSrcweir Rectangle aRect( GetEntryBoundRect( pEntry1 ) );
3341cdf0e10cSrcweir aRect.Union( GetEntryBoundRect( pEntry2 ) );
3342cdf0e10cSrcweir AddSelectedRect( aRect );
3343cdf0e10cSrcweir }
3344cdf0e10cSrcweir
AddSelectedRect(const Rectangle & rRect)3345cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::AddSelectedRect( const Rectangle& rRect )
3346cdf0e10cSrcweir {
3347cdf0e10cSrcweir Rectangle* pRect = new Rectangle( rRect );
3348cdf0e10cSrcweir pRect->Justify();
3349cdf0e10cSrcweir aSelectedRectList.Insert( (void*)pRect, aSelectedRectList.Count() );
3350cdf0e10cSrcweir }
3351cdf0e10cSrcweir
ClearSelectedRectList()3352cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::ClearSelectedRectList()
3353cdf0e10cSrcweir {
3354cdf0e10cSrcweir const sal_uInt16 nCount = aSelectedRectList.Count();
3355cdf0e10cSrcweir for( sal_uInt16 nCur = 0; nCur < nCount; nCur++ )
3356cdf0e10cSrcweir {
3357cdf0e10cSrcweir Rectangle* pRect = (Rectangle*)aSelectedRectList.GetObject( nCur );
3358cdf0e10cSrcweir delete pRect;
3359cdf0e10cSrcweir }
3360cdf0e10cSrcweir aSelectedRectList.Remove( 0, aSelectedRectList.Count() );
3361cdf0e10cSrcweir }
3362cdf0e10cSrcweir
CalcScrollOffsets(const Point & rPosPixel,long & rX,long & rY,sal_Bool isInDragDrop,sal_uInt16 nBorderWidth)3363cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::CalcScrollOffsets( const Point& rPosPixel,
3364cdf0e10cSrcweir long& rX, long& rY, sal_Bool isInDragDrop, sal_uInt16 nBorderWidth)
3365cdf0e10cSrcweir {
3366cdf0e10cSrcweir // Scrolling der View, falls sich der Mauszeiger im Grenzbereich des
3367cdf0e10cSrcweir // Fensters befindet
3368cdf0e10cSrcweir long nPixelToScrollX = 0;
3369cdf0e10cSrcweir long nPixelToScrollY = 0;
3370cdf0e10cSrcweir Size aWndSize = aOutputSize;
3371cdf0e10cSrcweir
3372cdf0e10cSrcweir nBorderWidth = (sal_uInt16)(Min( (long)(aWndSize.Height()-1), (long)nBorderWidth ));
3373cdf0e10cSrcweir nBorderWidth = (sal_uInt16)(Min( (long)(aWndSize.Width()-1), (long)nBorderWidth ));
3374cdf0e10cSrcweir
3375cdf0e10cSrcweir if ( rPosPixel.X() < nBorderWidth )
3376cdf0e10cSrcweir {
3377cdf0e10cSrcweir if( isInDragDrop )
3378cdf0e10cSrcweir nPixelToScrollX = -DD_SCROLL_PIXEL;
3379cdf0e10cSrcweir else
3380cdf0e10cSrcweir nPixelToScrollX = rPosPixel.X()- nBorderWidth;
3381cdf0e10cSrcweir }
3382cdf0e10cSrcweir else if ( rPosPixel.X() > aWndSize.Width() - nBorderWidth )
3383cdf0e10cSrcweir {
3384cdf0e10cSrcweir if( isInDragDrop )
3385cdf0e10cSrcweir nPixelToScrollX = DD_SCROLL_PIXEL;
3386cdf0e10cSrcweir else
3387cdf0e10cSrcweir nPixelToScrollX = rPosPixel.X() - (aWndSize.Width() - nBorderWidth);
3388cdf0e10cSrcweir }
3389cdf0e10cSrcweir if ( rPosPixel.Y() < nBorderWidth )
3390cdf0e10cSrcweir {
3391cdf0e10cSrcweir if( isInDragDrop )
3392cdf0e10cSrcweir nPixelToScrollY = -DD_SCROLL_PIXEL;
3393cdf0e10cSrcweir else
3394cdf0e10cSrcweir nPixelToScrollY = rPosPixel.Y() - nBorderWidth;
3395cdf0e10cSrcweir }
3396cdf0e10cSrcweir else if ( rPosPixel.Y() > aWndSize.Height() - nBorderWidth )
3397cdf0e10cSrcweir {
3398cdf0e10cSrcweir if( isInDragDrop )
3399cdf0e10cSrcweir nPixelToScrollY = DD_SCROLL_PIXEL;
3400cdf0e10cSrcweir else
3401cdf0e10cSrcweir nPixelToScrollY = rPosPixel.Y() - (aWndSize.Height() - nBorderWidth);
3402cdf0e10cSrcweir }
3403cdf0e10cSrcweir
3404cdf0e10cSrcweir rX = nPixelToScrollX;
3405cdf0e10cSrcweir rY = nPixelToScrollY;
3406cdf0e10cSrcweir }
3407cdf0e10cSrcweir
IMPL_LINK(SvxIconChoiceCtrl_Impl,AutoArrangeHdl,void *,EMPTYARG)3408cdf0e10cSrcweir IMPL_LINK(SvxIconChoiceCtrl_Impl, AutoArrangeHdl, void*, EMPTYARG )
3409cdf0e10cSrcweir {
3410cdf0e10cSrcweir aAutoArrangeTimer.Stop();
3411cdf0e10cSrcweir Arrange( IsAutoArrange() );
3412cdf0e10cSrcweir return 0;
3413cdf0e10cSrcweir }
3414cdf0e10cSrcweir
IMPL_LINK(SvxIconChoiceCtrl_Impl,VisRectChangedHdl,void *,EMPTYARG)3415cdf0e10cSrcweir IMPL_LINK(SvxIconChoiceCtrl_Impl, VisRectChangedHdl, void*, EMPTYARG )
3416cdf0e10cSrcweir {
3417cdf0e10cSrcweir aVisRectChangedTimer.Stop();
3418cdf0e10cSrcweir pView->VisibleRectChanged();
3419cdf0e10cSrcweir return 0;
3420cdf0e10cSrcweir }
3421cdf0e10cSrcweir
IMPL_LINK(SvxIconChoiceCtrl_Impl,DocRectChangedHdl,void *,EMPTYARG)3422cdf0e10cSrcweir IMPL_LINK(SvxIconChoiceCtrl_Impl, DocRectChangedHdl, void*, EMPTYARG )
3423cdf0e10cSrcweir {
3424cdf0e10cSrcweir aDocRectChangedTimer.Stop();
3425cdf0e10cSrcweir pView->DocumentRectChanged();
3426cdf0e10cSrcweir return 0;
3427cdf0e10cSrcweir }
3428cdf0e10cSrcweir
PrepareCommandEvent(const CommandEvent & rCEvt)3429cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::PrepareCommandEvent( const CommandEvent& rCEvt )
3430cdf0e10cSrcweir {
3431cdf0e10cSrcweir StopEditTimer();
3432cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = pView->GetEntry( rCEvt.GetMousePosPixel() );
3433cdf0e10cSrcweir if( (nFlags & F_DOWN_CTRL) && pEntry && !pEntry->IsSelected() )
3434cdf0e10cSrcweir SelectEntry( pEntry, sal_True, sal_True );
3435cdf0e10cSrcweir nFlags &= ~(F_DOWN_CTRL | F_DOWN_DESELECT);
3436cdf0e10cSrcweir }
3437cdf0e10cSrcweir
IsTextHit(SvxIconChoiceCtrlEntry * pEntry,const Point & rDocPos)3438cdf0e10cSrcweir sal_Bool SvxIconChoiceCtrl_Impl::IsTextHit( SvxIconChoiceCtrlEntry* pEntry, const Point& rDocPos )
3439cdf0e10cSrcweir {
3440cdf0e10cSrcweir Rectangle aRect( CalcTextRect( pEntry ));
3441cdf0e10cSrcweir if( aRect.IsInside( rDocPos ) )
3442cdf0e10cSrcweir return sal_True;
3443cdf0e10cSrcweir return sal_False;
3444cdf0e10cSrcweir }
3445cdf0e10cSrcweir
IMPL_LINK(SvxIconChoiceCtrl_Impl,EditTimeoutHdl,Timer *,EMPTYARG)3446cdf0e10cSrcweir IMPL_LINK(SvxIconChoiceCtrl_Impl, EditTimeoutHdl, Timer*, EMPTYARG )
3447cdf0e10cSrcweir {
3448cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = GetCurEntry();
3449cdf0e10cSrcweir if( bEntryEditingEnabled && pEntry &&
3450cdf0e10cSrcweir pEntry->IsSelected())
3451cdf0e10cSrcweir {
3452cdf0e10cSrcweir if( pView->EditingEntry( pEntry ))
3453cdf0e10cSrcweir EditEntry( pEntry );
3454cdf0e10cSrcweir }
3455cdf0e10cSrcweir return 0;
3456cdf0e10cSrcweir }
3457cdf0e10cSrcweir
3458cdf0e10cSrcweir
3459cdf0e10cSrcweir //
3460cdf0e10cSrcweir // Funktionen zum Ausrichten der Eintraege am Grid
3461cdf0e10cSrcweir //
3462cdf0e10cSrcweir
3463cdf0e10cSrcweir // pStart == 0: Alle Eintraege werden ausgerichtet
3464cdf0e10cSrcweir // sonst: Alle Eintraege der Zeile ab einschliesslich pStart werden ausgerichtet
AdjustEntryAtGrid(SvxIconChoiceCtrlEntry * pStart)3465cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::AdjustEntryAtGrid( SvxIconChoiceCtrlEntry* pStart )
3466cdf0e10cSrcweir {
3467cdf0e10cSrcweir SvPtrarr aLists;
3468cdf0e10cSrcweir pImpCursor->CreateGridAjustData( aLists, pStart );
3469cdf0e10cSrcweir const sal_uInt16 nCount = aLists.Count();
3470cdf0e10cSrcweir for( sal_uInt16 nCur = 0; nCur < nCount; nCur++ )
3471cdf0e10cSrcweir AdjustAtGrid( *(SvPtrarr*)aLists[ nCur ], pStart );
3472cdf0e10cSrcweir IcnCursor_Impl::DestroyGridAdjustData( aLists );
3473cdf0e10cSrcweir CheckScrollBars();
3474cdf0e10cSrcweir }
3475cdf0e10cSrcweir
3476cdf0e10cSrcweir // Richtet eine Zeile aus, erweitert ggf. die Breite; Bricht die Zeile nicht um
AdjustAtGrid(const SvPtrarr & rRow,SvxIconChoiceCtrlEntry * pStart)3477cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::AdjustAtGrid( const SvPtrarr& rRow, SvxIconChoiceCtrlEntry* pStart )
3478cdf0e10cSrcweir {
3479cdf0e10cSrcweir if( !rRow.Count() )
3480cdf0e10cSrcweir return;
3481cdf0e10cSrcweir
3482cdf0e10cSrcweir sal_Bool bGo;
3483cdf0e10cSrcweir if( !pStart )
3484cdf0e10cSrcweir bGo = sal_True;
3485cdf0e10cSrcweir else
3486cdf0e10cSrcweir bGo = sal_False;
3487cdf0e10cSrcweir
3488cdf0e10cSrcweir long nCurRight = 0;
3489cdf0e10cSrcweir for( sal_uInt16 nCur = 0; nCur < rRow.Count(); nCur++ )
3490cdf0e10cSrcweir {
3491cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pCur = (SvxIconChoiceCtrlEntry*)rRow[ nCur ];
3492cdf0e10cSrcweir if( !bGo && pCur == pStart )
3493cdf0e10cSrcweir bGo = sal_True;
3494cdf0e10cSrcweir
3495cdf0e10cSrcweir //SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pCur);
3496cdf0e10cSrcweir // Massgebend (fuer unser Auge) ist die Bitmap, da sonst
3497cdf0e10cSrcweir // durch lange Texte der Eintrag stark springen kann
3498cdf0e10cSrcweir const Rectangle& rBoundRect = GetEntryBoundRect( pCur );
3499cdf0e10cSrcweir Rectangle aCenterRect( CalcBmpRect( pCur, 0 ));
3500cdf0e10cSrcweir if( bGo && !pCur->IsPosLocked() )
3501cdf0e10cSrcweir {
3502cdf0e10cSrcweir long nWidth = aCenterRect.GetSize().Width();
3503cdf0e10cSrcweir Point aNewPos( AdjustAtGrid( aCenterRect, rBoundRect ) );
3504cdf0e10cSrcweir while( aNewPos.X() < nCurRight )
3505cdf0e10cSrcweir aNewPos.X() += nGridDX;
3506cdf0e10cSrcweir if( aNewPos != rBoundRect.TopLeft() )
3507cdf0e10cSrcweir {
3508cdf0e10cSrcweir SetEntryPos( pCur, aNewPos );
3509cdf0e10cSrcweir pCur->SetFlags( ICNVIEW_FLAG_POS_MOVED );
3510cdf0e10cSrcweir nFlags |= F_MOVED_ENTRIES;
3511cdf0e10cSrcweir }
3512cdf0e10cSrcweir nCurRight = aNewPos.X() + nWidth;
3513cdf0e10cSrcweir }
3514cdf0e10cSrcweir else
3515cdf0e10cSrcweir {
3516cdf0e10cSrcweir nCurRight = rBoundRect.Right();
3517cdf0e10cSrcweir }
3518cdf0e10cSrcweir }
3519cdf0e10cSrcweir }
3520cdf0e10cSrcweir
3521cdf0e10cSrcweir // Richtet Rect am Grid aus, garantiert jedoch nicht, dass die
3522cdf0e10cSrcweir // neue Pos. frei ist. Die Pos. kann fuer SetEntryPos verwendet werden.
3523cdf0e10cSrcweir // Das CenterRect beschreibt den Teil des BoundRects, der fuer
3524cdf0e10cSrcweir // die Berechnung des Ziel-Rechtecks verwendet wird.
AdjustAtGrid(const Rectangle & rCenterRect,const Rectangle & rBoundRect) const3525cdf0e10cSrcweir Point SvxIconChoiceCtrl_Impl::AdjustAtGrid( const Rectangle& rCenterRect,
3526cdf0e10cSrcweir const Rectangle& rBoundRect ) const
3527cdf0e10cSrcweir {
3528cdf0e10cSrcweir Point aPos( rCenterRect.TopLeft() );
3529cdf0e10cSrcweir Size aSize( rCenterRect.GetSize() );
3530cdf0e10cSrcweir
3531cdf0e10cSrcweir aPos.X() -= LROFFS_WINBORDER;
3532cdf0e10cSrcweir aPos.Y() -= TBOFFS_WINBORDER;
3533cdf0e10cSrcweir
3534cdf0e10cSrcweir // align (ref ist mitte des rects)
3535cdf0e10cSrcweir short nGridX = (short)((aPos.X()+(aSize.Width()/2)) / nGridDX);
3536cdf0e10cSrcweir short nGridY = (short)((aPos.Y()+(aSize.Height()/2)) / nGridDY);
3537cdf0e10cSrcweir aPos.X() = nGridX * nGridDX;
3538cdf0e10cSrcweir aPos.Y() = nGridY * nGridDY;
3539cdf0e10cSrcweir // hor. center
3540cdf0e10cSrcweir aPos.X() += (nGridDX - rBoundRect.GetSize().Width() ) / 2;
3541cdf0e10cSrcweir
3542cdf0e10cSrcweir aPos.X() += LROFFS_WINBORDER;
3543cdf0e10cSrcweir aPos.Y() += TBOFFS_WINBORDER;
3544cdf0e10cSrcweir
3545cdf0e10cSrcweir return aPos;
3546cdf0e10cSrcweir }
3547cdf0e10cSrcweir
SetEntryTextMode(SvxIconChoiceCtrlTextMode eMode,SvxIconChoiceCtrlEntry * pEntry)3548cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SetEntryTextMode( SvxIconChoiceCtrlTextMode eMode, SvxIconChoiceCtrlEntry* pEntry )
3549cdf0e10cSrcweir {
3550cdf0e10cSrcweir if( !pEntry )
3551cdf0e10cSrcweir {
3552cdf0e10cSrcweir if( eTextMode != eMode )
3553cdf0e10cSrcweir {
3554cdf0e10cSrcweir if( eTextMode == IcnShowTextDontKnow )
3555cdf0e10cSrcweir eTextMode = IcnShowTextShort;
3556cdf0e10cSrcweir eTextMode = eMode;
3557cdf0e10cSrcweir Arrange( sal_True );
3558cdf0e10cSrcweir }
3559cdf0e10cSrcweir }
3560cdf0e10cSrcweir else
3561cdf0e10cSrcweir {
3562cdf0e10cSrcweir if( pEntry->eTextMode != eMode )
3563cdf0e10cSrcweir {
3564cdf0e10cSrcweir pEntry->eTextMode = eMode;
3565cdf0e10cSrcweir InvalidateEntry( pEntry );
3566cdf0e10cSrcweir pView->Invalidate( GetEntryBoundRect( pEntry ) );
3567cdf0e10cSrcweir AdjustVirtSize( pEntry->aRect );
3568cdf0e10cSrcweir }
3569cdf0e10cSrcweir }
3570cdf0e10cSrcweir }
3571cdf0e10cSrcweir
GetTextMode(const SvxIconChoiceCtrlEntry * pEntry) const3572cdf0e10cSrcweir SvxIconChoiceCtrlTextMode SvxIconChoiceCtrl_Impl::GetTextMode( const SvxIconChoiceCtrlEntry* pEntry ) const
3573cdf0e10cSrcweir {
3574cdf0e10cSrcweir if( !pEntry )
3575cdf0e10cSrcweir return eTextMode;
3576cdf0e10cSrcweir return pEntry->GetTextMode();
3577cdf0e10cSrcweir }
3578cdf0e10cSrcweir
GetEntryTextModeSmart(const SvxIconChoiceCtrlEntry * pEntry) const3579cdf0e10cSrcweir SvxIconChoiceCtrlTextMode SvxIconChoiceCtrl_Impl::GetEntryTextModeSmart( const SvxIconChoiceCtrlEntry* pEntry ) const
3580cdf0e10cSrcweir {
3581cdf0e10cSrcweir DBG_ASSERT(pEntry,"GetEntryTextModeSmart: Entry not set");
3582cdf0e10cSrcweir SvxIconChoiceCtrlTextMode eMode = pEntry->GetTextMode();
3583cdf0e10cSrcweir if( eMode == IcnShowTextDontKnow )
3584cdf0e10cSrcweir return eTextMode;
3585cdf0e10cSrcweir return eMode;
3586cdf0e10cSrcweir }
3587cdf0e10cSrcweir
ShowEntryFocusRect(const SvxIconChoiceCtrlEntry * pEntry)3588cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::ShowEntryFocusRect( const SvxIconChoiceCtrlEntry* pEntry )
3589cdf0e10cSrcweir {
3590cdf0e10cSrcweir if( !pEntry )
3591cdf0e10cSrcweir {
3592cdf0e10cSrcweir pView->HideFocus();
3593cdf0e10cSrcweir }
3594cdf0e10cSrcweir else
3595cdf0e10cSrcweir {
3596cdf0e10cSrcweir Rectangle aRect ( CalcFocusRect( (SvxIconChoiceCtrlEntry*)pEntry ) );
3597cdf0e10cSrcweir /*pView->*/ShowFocus( aRect );
3598cdf0e10cSrcweir }
3599cdf0e10cSrcweir }
3600cdf0e10cSrcweir
3601cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////
3602cdf0e10cSrcweir //
3603cdf0e10cSrcweir // Draw my own focusrect, because the focusrect of the outputdevice has got the inverted color
3604cdf0e10cSrcweir // of the background. But what will we see, if the the backgroundcolor is gray ? - We will see
3605cdf0e10cSrcweir // a gray focusrect on a gray background !!!
3606cdf0e10cSrcweir //
ShowFocus(Rectangle & rRect)3607cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::ShowFocus ( Rectangle& rRect )
3608cdf0e10cSrcweir {
3609cdf0e10cSrcweir Color aBkgColor ( pView->GetBackground().GetColor() );
3610cdf0e10cSrcweir Color aPenColor;
3611cdf0e10cSrcweir sal_uInt16 nColor = ( aBkgColor.GetRed() + aBkgColor.GetGreen() + aBkgColor.GetBlue() ) / 3;
3612cdf0e10cSrcweir if ( nColor > 128 )
3613cdf0e10cSrcweir aPenColor.SetColor ( COL_BLACK );
3614cdf0e10cSrcweir else
3615cdf0e10cSrcweir aPenColor.SetColor( COL_WHITE );
3616cdf0e10cSrcweir
3617cdf0e10cSrcweir aFocus.bOn = sal_True;
3618cdf0e10cSrcweir aFocus.aPenColor = aPenColor;
3619cdf0e10cSrcweir aFocus.aRect = rRect;
3620cdf0e10cSrcweir }
3621cdf0e10cSrcweir
HideFocus()3622cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::HideFocus ()
3623cdf0e10cSrcweir {
3624cdf0e10cSrcweir aFocus.bOn = sal_False;
3625cdf0e10cSrcweir }
3626cdf0e10cSrcweir
DrawFocusRect(OutputDevice * pOut)3627cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::DrawFocusRect ( OutputDevice* pOut )
3628cdf0e10cSrcweir {
3629cdf0e10cSrcweir pOut->SetLineColor( aFocus.aPenColor );
3630cdf0e10cSrcweir pOut->SetFillColor();
3631cdf0e10cSrcweir Polygon aPolygon ( aFocus.aRect );
3632cdf0e10cSrcweir
3633cdf0e10cSrcweir LineInfo aLineInfo ( LINE_DASH );
3634cdf0e10cSrcweir
3635cdf0e10cSrcweir aLineInfo.SetDashLen ( 1 );
3636cdf0e10cSrcweir
3637cdf0e10cSrcweir aLineInfo.SetDotLen ( 1L );
3638cdf0e10cSrcweir aLineInfo.SetDistance ( 1L );
3639cdf0e10cSrcweir aLineInfo.SetDotCount ( 1 );
3640cdf0e10cSrcweir
3641cdf0e10cSrcweir pOut->DrawPolyLine ( aPolygon, aLineInfo );
3642cdf0e10cSrcweir }
3643cdf0e10cSrcweir
IsMnemonicChar(sal_Unicode cChar,sal_uLong & rPos) const3644cdf0e10cSrcweir sal_Bool SvxIconChoiceCtrl_Impl::IsMnemonicChar( sal_Unicode cChar, sal_uLong& rPos ) const
3645cdf0e10cSrcweir {
3646cdf0e10cSrcweir sal_Bool bRet = sal_False;
3647cdf0e10cSrcweir const vcl::I18nHelper& rI18nHelper = Application::GetSettings().GetUILocaleI18nHelper();
3648cdf0e10cSrcweir sal_uLong nEntryCount = GetEntryCount();
3649cdf0e10cSrcweir for ( sal_uLong i = 0; i < nEntryCount; ++i )
3650cdf0e10cSrcweir {
3651cdf0e10cSrcweir if ( rI18nHelper.MatchMnemonic( GetEntry( i )->GetText(), cChar ) )
3652cdf0e10cSrcweir {
3653cdf0e10cSrcweir bRet = sal_True;
3654cdf0e10cSrcweir rPos = i;
3655cdf0e10cSrcweir break;
3656cdf0e10cSrcweir }
3657cdf0e10cSrcweir }
3658cdf0e10cSrcweir
3659cdf0e10cSrcweir return bRet;
3660cdf0e10cSrcweir }
3661cdf0e10cSrcweir
3662cdf0e10cSrcweir //
3663cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////
3664cdf0e10cSrcweir
IMPL_LINK(SvxIconChoiceCtrl_Impl,UserEventHdl,void *,nId)3665cdf0e10cSrcweir IMPL_LINK(SvxIconChoiceCtrl_Impl, UserEventHdl, void*, nId )
3666cdf0e10cSrcweir {
3667cdf0e10cSrcweir if( nId == EVENTID_ADJUST_SCROLLBARS )
3668cdf0e10cSrcweir {
3669cdf0e10cSrcweir nUserEventAdjustScrBars = 0;
3670cdf0e10cSrcweir AdjustScrollBars();
3671cdf0e10cSrcweir }
3672cdf0e10cSrcweir else if( nId == EVENTID_SHOW_CURSOR )
3673cdf0e10cSrcweir {
3674cdf0e10cSrcweir nUserEventShowCursor = 0;
3675cdf0e10cSrcweir ShowCursor( sal_True );
3676cdf0e10cSrcweir }
3677cdf0e10cSrcweir return 0;
3678cdf0e10cSrcweir }
3679cdf0e10cSrcweir
CancelUserEvents()3680cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::CancelUserEvents()
3681cdf0e10cSrcweir {
3682cdf0e10cSrcweir if( nUserEventAdjustScrBars )
3683cdf0e10cSrcweir {
3684cdf0e10cSrcweir Application::RemoveUserEvent( nUserEventAdjustScrBars );
3685cdf0e10cSrcweir nUserEventAdjustScrBars = 0;
3686cdf0e10cSrcweir }
3687cdf0e10cSrcweir if( nUserEventShowCursor )
3688cdf0e10cSrcweir {
3689cdf0e10cSrcweir Application::RemoveUserEvent( nUserEventShowCursor );
3690cdf0e10cSrcweir nUserEventShowCursor = 0;
3691cdf0e10cSrcweir }
3692cdf0e10cSrcweir }
3693cdf0e10cSrcweir
InvalidateEntry(SvxIconChoiceCtrlEntry * pEntry)3694cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::InvalidateEntry( SvxIconChoiceCtrlEntry* pEntry )
3695cdf0e10cSrcweir {
3696cdf0e10cSrcweir if( pEntry == pCursor )
3697cdf0e10cSrcweir ShowCursor( sal_False );
3698cdf0e10cSrcweir pView->Invalidate( pEntry->aRect );
3699cdf0e10cSrcweir Center( pEntry );
3700cdf0e10cSrcweir pView->Invalidate( pEntry->aRect );
3701cdf0e10cSrcweir if( pEntry == pCursor )
3702cdf0e10cSrcweir ShowCursor( sal_True );
3703cdf0e10cSrcweir }
3704cdf0e10cSrcweir
EditEntry(SvxIconChoiceCtrlEntry * pEntry)3705cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::EditEntry( SvxIconChoiceCtrlEntry* pEntry )
3706cdf0e10cSrcweir {
3707cdf0e10cSrcweir DBG_ASSERT(pEntry,"EditEntry: Entry not set");
3708cdf0e10cSrcweir if( !pEntry )
3709cdf0e10cSrcweir return;
3710cdf0e10cSrcweir
3711cdf0e10cSrcweir StopEntryEditing( sal_True );
3712cdf0e10cSrcweir DELETEZ(pEdit);
3713cdf0e10cSrcweir SetNoSelection();
3714cdf0e10cSrcweir
3715cdf0e10cSrcweir pCurEditedEntry = pEntry;
3716cdf0e10cSrcweir String aEntryText( pView->GetEntryText( pEntry, sal_True ) );
3717cdf0e10cSrcweir Rectangle aRect( CalcTextRect( pEntry, 0, sal_True, &aEntryText ) );
3718cdf0e10cSrcweir MakeVisible( aRect );
3719cdf0e10cSrcweir Point aPos( aRect.TopLeft() );
3720cdf0e10cSrcweir aPos = pView->GetPixelPos( aPos );
3721cdf0e10cSrcweir aRect.SetPos( aPos );
3722cdf0e10cSrcweir pView->HideFocus();
3723cdf0e10cSrcweir pEdit = new IcnViewEdit_Impl(
3724cdf0e10cSrcweir pView,
3725cdf0e10cSrcweir aRect.TopLeft(),
3726cdf0e10cSrcweir aRect.GetSize(),
3727cdf0e10cSrcweir aEntryText,
3728cdf0e10cSrcweir LINK( this, SvxIconChoiceCtrl_Impl, TextEditEndedHdl ) );
3729cdf0e10cSrcweir }
3730cdf0e10cSrcweir
IMPL_LINK(SvxIconChoiceCtrl_Impl,TextEditEndedHdl,IcnViewEdit_Impl *,EMPTYARG)3731cdf0e10cSrcweir IMPL_LINK( SvxIconChoiceCtrl_Impl, TextEditEndedHdl, IcnViewEdit_Impl*, EMPTYARG )
3732cdf0e10cSrcweir {
3733cdf0e10cSrcweir DBG_ASSERT(pEdit,"TextEditEnded: pEdit not set");
3734cdf0e10cSrcweir if( !pEdit )
3735cdf0e10cSrcweir {
3736cdf0e10cSrcweir pCurEditedEntry = 0;
3737cdf0e10cSrcweir return 0;
3738cdf0e10cSrcweir }
3739cdf0e10cSrcweir DBG_ASSERT(pCurEditedEntry,"TextEditEnded: pCurEditedEntry not set");
3740cdf0e10cSrcweir
3741cdf0e10cSrcweir if( !pCurEditedEntry )
3742cdf0e10cSrcweir {
3743cdf0e10cSrcweir pEdit->Hide();
3744cdf0e10cSrcweir if( pEdit->IsGrabFocus() )
3745cdf0e10cSrcweir pView->GrabFocus();
3746cdf0e10cSrcweir return 0;
3747cdf0e10cSrcweir }
3748cdf0e10cSrcweir
3749cdf0e10cSrcweir String aText;
3750cdf0e10cSrcweir if ( !pEdit->EditingCanceled() )
3751cdf0e10cSrcweir aText = pEdit->GetText();
3752cdf0e10cSrcweir else
3753cdf0e10cSrcweir aText = pEdit->GetSavedValue();
3754cdf0e10cSrcweir
3755cdf0e10cSrcweir if( pView->EditedEntry( pCurEditedEntry, aText, pEdit->EditingCanceled() ) )
3756cdf0e10cSrcweir InvalidateEntry( pCurEditedEntry );
3757cdf0e10cSrcweir if( !GetSelectionCount() )
3758cdf0e10cSrcweir SelectEntry( pCurEditedEntry, sal_True );
3759cdf0e10cSrcweir
3760cdf0e10cSrcweir pEdit->Hide();
3761cdf0e10cSrcweir if( pEdit->IsGrabFocus() )
3762cdf0e10cSrcweir pView->GrabFocus();
3763cdf0e10cSrcweir // Das Edit kann nicht hier geloescht werden, weil es noch in einem
3764cdf0e10cSrcweir // Handler steht. Es wird im Dtor oder im naechsten EditEntry geloescht.
3765cdf0e10cSrcweir pCurEditedEntry = 0;
3766cdf0e10cSrcweir return 0;
3767cdf0e10cSrcweir }
3768cdf0e10cSrcweir
StopEntryEditing(sal_Bool bCancel)3769cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::StopEntryEditing( sal_Bool bCancel )
3770cdf0e10cSrcweir {
3771cdf0e10cSrcweir if( pEdit )
3772cdf0e10cSrcweir pEdit->StopEditing( bCancel );
3773cdf0e10cSrcweir }
3774cdf0e10cSrcweir
LockEntryPos(SvxIconChoiceCtrlEntry * pEntry,sal_Bool bLock)3775cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::LockEntryPos( SvxIconChoiceCtrlEntry* pEntry, sal_Bool bLock )
3776cdf0e10cSrcweir {
3777cdf0e10cSrcweir if( bLock )
3778cdf0e10cSrcweir pEntry->SetFlags( ICNVIEW_FLAG_POS_LOCKED );
3779cdf0e10cSrcweir else
3780cdf0e10cSrcweir pEntry->ClearFlags( ICNVIEW_FLAG_POS_LOCKED );
3781cdf0e10cSrcweir }
3782cdf0e10cSrcweir
GetFirstSelectedEntry(sal_uLong & rPos) const3783cdf0e10cSrcweir SvxIconChoiceCtrlEntry* SvxIconChoiceCtrl_Impl::GetFirstSelectedEntry( sal_uLong& rPos ) const
3784cdf0e10cSrcweir {
3785cdf0e10cSrcweir if( !GetSelectionCount() )
3786cdf0e10cSrcweir return 0;
3787cdf0e10cSrcweir
3788cdf0e10cSrcweir if( (nWinBits & WB_HIGHLIGHTFRAME) && (eSelectionMode == NO_SELECTION) )
3789cdf0e10cSrcweir {
3790cdf0e10cSrcweir rPos = pView->GetEntryListPos( pCurHighlightFrame );
3791cdf0e10cSrcweir return pCurHighlightFrame;
3792cdf0e10cSrcweir }
3793cdf0e10cSrcweir
3794cdf0e10cSrcweir sal_uLong nCount = aEntries.Count();
3795cdf0e10cSrcweir if( !pHead )
3796cdf0e10cSrcweir {
3797cdf0e10cSrcweir for( sal_uLong nCur = 0; nCur < nCount; nCur++ )
3798cdf0e10cSrcweir {
3799cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)aEntries.GetObject( nCur );
3800cdf0e10cSrcweir if( pEntry->IsSelected() )
3801cdf0e10cSrcweir {
3802cdf0e10cSrcweir rPos = nCur;
3803cdf0e10cSrcweir return pEntry;
3804cdf0e10cSrcweir }
3805cdf0e10cSrcweir }
3806cdf0e10cSrcweir }
3807cdf0e10cSrcweir else
3808cdf0e10cSrcweir {
3809cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = pHead;
3810cdf0e10cSrcweir while( nCount-- )
3811cdf0e10cSrcweir {
3812cdf0e10cSrcweir if( pEntry->IsSelected() )
3813cdf0e10cSrcweir {
3814cdf0e10cSrcweir rPos = GetEntryListPos( pEntry );
3815cdf0e10cSrcweir return pEntry;
3816cdf0e10cSrcweir }
3817cdf0e10cSrcweir pEntry = pEntry->pflink;
3818cdf0e10cSrcweir if( nCount && pEntry == pHead )
3819cdf0e10cSrcweir {
3820cdf0e10cSrcweir DBG_ERROR("SvxIconChoiceCtrl_Impl::GetFirstSelectedEntry > Endlosschleife!");
3821cdf0e10cSrcweir return 0;
3822cdf0e10cSrcweir }
3823cdf0e10cSrcweir }
3824cdf0e10cSrcweir }
3825cdf0e10cSrcweir return 0;
3826cdf0e10cSrcweir }
3827cdf0e10cSrcweir
3828cdf0e10cSrcweir // kein Round Robin!
GetNextSelectedEntry(sal_uLong & rStartPos) const3829cdf0e10cSrcweir SvxIconChoiceCtrlEntry* SvxIconChoiceCtrl_Impl::GetNextSelectedEntry( sal_uLong& rStartPos ) const
3830cdf0e10cSrcweir {
3831cdf0e10cSrcweir sal_uLong nCount = aEntries.Count();
3832cdf0e10cSrcweir if( rStartPos > nCount || !GetSelectionCount() )
3833cdf0e10cSrcweir return 0;
3834cdf0e10cSrcweir if( !pHead )
3835cdf0e10cSrcweir {
3836cdf0e10cSrcweir for( sal_uLong nCur = rStartPos+1; nCur < nCount; nCur++ )
3837cdf0e10cSrcweir {
3838cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)aEntries.GetObject( nCur );
3839cdf0e10cSrcweir if( pEntry->IsSelected() )
3840cdf0e10cSrcweir {
3841cdf0e10cSrcweir rStartPos = nCur;
3842cdf0e10cSrcweir return pEntry;
3843cdf0e10cSrcweir }
3844cdf0e10cSrcweir }
3845cdf0e10cSrcweir }
3846cdf0e10cSrcweir else
3847cdf0e10cSrcweir {
3848cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)aEntries.GetObject( rStartPos );
3849cdf0e10cSrcweir pEntry = pEntry->pflink;
3850cdf0e10cSrcweir while( pEntry != pHead )
3851cdf0e10cSrcweir {
3852cdf0e10cSrcweir if( pEntry->IsSelected() )
3853cdf0e10cSrcweir {
3854cdf0e10cSrcweir rStartPos = GetEntryListPos( pEntry );
3855cdf0e10cSrcweir return pEntry;
3856cdf0e10cSrcweir }
3857cdf0e10cSrcweir pEntry = pEntry->pflink;
3858cdf0e10cSrcweir }
3859cdf0e10cSrcweir }
3860cdf0e10cSrcweir
3861cdf0e10cSrcweir rStartPos = 0xffffffff;
3862cdf0e10cSrcweir return 0;
3863cdf0e10cSrcweir }
3864cdf0e10cSrcweir
SelectAll(sal_Bool bSelect,sal_Bool bPaint)3865cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SelectAll( sal_Bool bSelect, sal_Bool bPaint )
3866cdf0e10cSrcweir {
3867cdf0e10cSrcweir bPaint = sal_True;
3868cdf0e10cSrcweir
3869cdf0e10cSrcweir sal_uLong nCount = aEntries.Count();
3870cdf0e10cSrcweir for( sal_uLong nCur = 0; nCur < nCount && (bSelect || GetSelectionCount() ); nCur++ )
3871cdf0e10cSrcweir {
3872cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)aEntries.GetObject( nCur );
3873cdf0e10cSrcweir SelectEntry( pEntry, bSelect, sal_True, sal_True, bPaint );
3874cdf0e10cSrcweir }
3875cdf0e10cSrcweir nFlags &= (~F_ADD_MODE);
3876cdf0e10cSrcweir pAnchor = 0;
3877cdf0e10cSrcweir }
3878cdf0e10cSrcweir
SaveSelection(List ** ppList)3879cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SaveSelection( List** ppList )
3880cdf0e10cSrcweir {
3881cdf0e10cSrcweir if( !*ppList )
3882cdf0e10cSrcweir *ppList = new List;
3883cdf0e10cSrcweir sal_uLong nPos;
3884cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = GetFirstSelectedEntry( nPos );
3885cdf0e10cSrcweir while( pEntry && GetSelectionCount() != (*ppList)->Count() )
3886cdf0e10cSrcweir {
3887cdf0e10cSrcweir (*ppList)->Insert( pEntry, LIST_APPEND );
3888cdf0e10cSrcweir pEntry = GetNextSelectedEntry( nPos );
3889cdf0e10cSrcweir }
3890cdf0e10cSrcweir }
3891cdf0e10cSrcweir
IcnViewEdit_Impl(SvtIconChoiceCtrl * pParent,const Point & rPos,const Size & rSize,const XubString & rData,const Link & rNotifyEditEnd)3892cdf0e10cSrcweir IcnViewEdit_Impl::IcnViewEdit_Impl( SvtIconChoiceCtrl* pParent, const Point& rPos,
3893cdf0e10cSrcweir const Size& rSize, const XubString& rData, const Link& rNotifyEditEnd ) :
3894cdf0e10cSrcweir MultiLineEdit( pParent, (pParent->GetStyle() & WB_ICON) ? WB_CENTER : WB_LEFT),
3895cdf0e10cSrcweir aCallBackHdl( rNotifyEditEnd ),
3896cdf0e10cSrcweir bCanceled( sal_False ),
3897cdf0e10cSrcweir bAlreadyInCallback( sal_False ),
3898cdf0e10cSrcweir bGrabFocus( sal_False )
3899cdf0e10cSrcweir {
3900cdf0e10cSrcweir Font aFont( pParent->GetPointFont() );
3901cdf0e10cSrcweir aFont.SetTransparent( sal_False );
3902cdf0e10cSrcweir SetControlFont( aFont );
3903cdf0e10cSrcweir if( !pParent->HasFontFillColor() )
3904cdf0e10cSrcweir {
3905cdf0e10cSrcweir Color aColor( pParent->GetBackground().GetColor() );
3906cdf0e10cSrcweir SetControlBackground( aColor );
3907cdf0e10cSrcweir }
3908cdf0e10cSrcweir else
3909cdf0e10cSrcweir SetControlBackground( aFont.GetFillColor() );
3910cdf0e10cSrcweir SetControlForeground( aFont.GetColor() );
3911cdf0e10cSrcweir SetPosPixel( rPos );
3912cdf0e10cSrcweir SetSizePixel( CalcAdjustedSize(rSize) );
3913cdf0e10cSrcweir SetText( rData );
3914cdf0e10cSrcweir SaveValue();
3915cdf0e10cSrcweir
3916cdf0e10cSrcweir aAccReturn.InsertItem( IMPICNVIEW_ACC_RETURN, KeyCode(KEY_RETURN) );
3917cdf0e10cSrcweir aAccEscape.InsertItem( IMPICNVIEW_ACC_ESCAPE, KeyCode(KEY_ESCAPE) );
3918cdf0e10cSrcweir
3919cdf0e10cSrcweir aAccReturn.SetActivateHdl( LINK( this, IcnViewEdit_Impl, ReturnHdl_Impl) );
3920cdf0e10cSrcweir aAccEscape.SetActivateHdl( LINK( this, IcnViewEdit_Impl, EscapeHdl_Impl) );
3921cdf0e10cSrcweir GetpApp()->InsertAccel( &aAccReturn);//, ACCEL_ALWAYS );
3922cdf0e10cSrcweir GetpApp()->InsertAccel( &aAccEscape);//, ACCEL_ALWAYS );
3923cdf0e10cSrcweir Show();
3924cdf0e10cSrcweir GrabFocus();
3925cdf0e10cSrcweir }
3926cdf0e10cSrcweir
~IcnViewEdit_Impl()3927cdf0e10cSrcweir IcnViewEdit_Impl::~IcnViewEdit_Impl()
3928cdf0e10cSrcweir {
3929cdf0e10cSrcweir if( !bAlreadyInCallback )
3930cdf0e10cSrcweir {
3931cdf0e10cSrcweir GetpApp()->RemoveAccel( &aAccReturn );
3932cdf0e10cSrcweir GetpApp()->RemoveAccel( &aAccEscape );
3933cdf0e10cSrcweir }
3934cdf0e10cSrcweir }
3935cdf0e10cSrcweir
CallCallBackHdl_Impl()3936cdf0e10cSrcweir void IcnViewEdit_Impl::CallCallBackHdl_Impl()
3937cdf0e10cSrcweir {
3938cdf0e10cSrcweir aTimer.Stop();
3939cdf0e10cSrcweir if ( !bAlreadyInCallback )
3940cdf0e10cSrcweir {
3941cdf0e10cSrcweir bAlreadyInCallback = sal_True;
3942cdf0e10cSrcweir GetpApp()->RemoveAccel( &aAccReturn );
3943cdf0e10cSrcweir GetpApp()->RemoveAccel( &aAccEscape );
3944cdf0e10cSrcweir Hide();
3945cdf0e10cSrcweir aCallBackHdl.Call( this );
3946cdf0e10cSrcweir }
3947cdf0e10cSrcweir }
3948cdf0e10cSrcweir
IMPL_LINK(IcnViewEdit_Impl,Timeout_Impl,Timer *,EMPTYARG)3949cdf0e10cSrcweir IMPL_LINK( IcnViewEdit_Impl, Timeout_Impl, Timer*, EMPTYARG )
3950cdf0e10cSrcweir {
3951cdf0e10cSrcweir CallCallBackHdl_Impl();
3952cdf0e10cSrcweir return 0;
3953cdf0e10cSrcweir }
3954cdf0e10cSrcweir
IMPL_LINK(IcnViewEdit_Impl,ReturnHdl_Impl,Accelerator *,EMPTYARG)3955cdf0e10cSrcweir IMPL_LINK( IcnViewEdit_Impl, ReturnHdl_Impl, Accelerator*, EMPTYARG )
3956cdf0e10cSrcweir {
3957cdf0e10cSrcweir bCanceled = sal_False;
3958cdf0e10cSrcweir bGrabFocus = sal_True;
3959cdf0e10cSrcweir CallCallBackHdl_Impl();
3960cdf0e10cSrcweir return 1;
3961cdf0e10cSrcweir }
3962cdf0e10cSrcweir
IMPL_LINK(IcnViewEdit_Impl,EscapeHdl_Impl,Accelerator *,EMPTYARG)3963cdf0e10cSrcweir IMPL_LINK( IcnViewEdit_Impl, EscapeHdl_Impl, Accelerator*, EMPTYARG )
3964cdf0e10cSrcweir {
3965cdf0e10cSrcweir bCanceled = sal_True;
3966cdf0e10cSrcweir bGrabFocus = sal_True;
3967cdf0e10cSrcweir CallCallBackHdl_Impl();
3968cdf0e10cSrcweir return 1;
3969cdf0e10cSrcweir }
3970cdf0e10cSrcweir
KeyInput(const KeyEvent & rKEvt)3971cdf0e10cSrcweir void IcnViewEdit_Impl::KeyInput( const KeyEvent& rKEvt )
3972cdf0e10cSrcweir {
3973cdf0e10cSrcweir KeyCode aCode = rKEvt.GetKeyCode();
3974cdf0e10cSrcweir sal_uInt16 nCode = aCode.GetCode();
3975cdf0e10cSrcweir
3976cdf0e10cSrcweir switch ( nCode )
3977cdf0e10cSrcweir {
3978cdf0e10cSrcweir case KEY_ESCAPE:
3979cdf0e10cSrcweir bCanceled = sal_True;
3980cdf0e10cSrcweir bGrabFocus = sal_True;
3981cdf0e10cSrcweir CallCallBackHdl_Impl();
3982cdf0e10cSrcweir break;
3983cdf0e10cSrcweir
3984cdf0e10cSrcweir case KEY_RETURN:
3985cdf0e10cSrcweir bCanceled = sal_False;
3986cdf0e10cSrcweir bGrabFocus = sal_True;
3987cdf0e10cSrcweir CallCallBackHdl_Impl();
3988cdf0e10cSrcweir break;
3989cdf0e10cSrcweir
3990cdf0e10cSrcweir default:
3991cdf0e10cSrcweir MultiLineEdit::KeyInput( rKEvt );
3992cdf0e10cSrcweir }
3993cdf0e10cSrcweir }
3994cdf0e10cSrcweir
PreNotify(NotifyEvent & rNEvt)3995cdf0e10cSrcweir long IcnViewEdit_Impl::PreNotify( NotifyEvent& rNEvt )
3996cdf0e10cSrcweir {
3997cdf0e10cSrcweir if( rNEvt.GetType() == EVENT_LOSEFOCUS )
3998cdf0e10cSrcweir {
3999cdf0e10cSrcweir if ( !bAlreadyInCallback &&
4000cdf0e10cSrcweir ((!Application::GetFocusWindow()) || !IsChild(Application::GetFocusWindow())))
4001cdf0e10cSrcweir {
4002cdf0e10cSrcweir bCanceled = sal_False;
4003cdf0e10cSrcweir aTimer.SetTimeout(10);
4004cdf0e10cSrcweir aTimer.SetTimeoutHdl(LINK(this,IcnViewEdit_Impl,Timeout_Impl));
4005cdf0e10cSrcweir aTimer.Start();
4006cdf0e10cSrcweir }
4007cdf0e10cSrcweir }
4008cdf0e10cSrcweir return 0;
4009cdf0e10cSrcweir }
4010cdf0e10cSrcweir
StopEditing(sal_Bool bCancel)4011cdf0e10cSrcweir void IcnViewEdit_Impl::StopEditing( sal_Bool bCancel )
4012cdf0e10cSrcweir {
4013cdf0e10cSrcweir if ( !bAlreadyInCallback )
4014cdf0e10cSrcweir {
4015cdf0e10cSrcweir bCanceled = bCancel;
4016cdf0e10cSrcweir CallCallBackHdl_Impl();
4017cdf0e10cSrcweir }
4018cdf0e10cSrcweir }
4019cdf0e10cSrcweir
GetEntryListPos(SvxIconChoiceCtrlEntry * pEntry) const4020cdf0e10cSrcweir sal_uLong SvxIconChoiceCtrl_Impl::GetEntryListPos( SvxIconChoiceCtrlEntry* pEntry ) const
4021cdf0e10cSrcweir {
4022cdf0e10cSrcweir if( !(nFlags & F_ENTRYLISTPOS_VALID ))
4023cdf0e10cSrcweir ((SvxIconChoiceCtrl_Impl*)this)->SetListPositions();
4024cdf0e10cSrcweir return pEntry->nPos;
4025cdf0e10cSrcweir }
4026cdf0e10cSrcweir
SetEntryListPos(SvxIconChoiceCtrlEntry * pListEntry,sal_uLong nNewPos)4027cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SetEntryListPos( SvxIconChoiceCtrlEntry* pListEntry, sal_uLong nNewPos )
4028cdf0e10cSrcweir {
4029cdf0e10cSrcweir sal_uLong nCurPos = GetEntryListPos( pListEntry );
4030cdf0e10cSrcweir if( nCurPos == nNewPos )
4031cdf0e10cSrcweir return;
4032cdf0e10cSrcweir aEntries.List::Remove( nCurPos );
4033cdf0e10cSrcweir aEntries.List::Insert( (void*)pListEntry, nNewPos );
4034cdf0e10cSrcweir // Eintragspositionen anpassen
4035cdf0e10cSrcweir sal_uLong nStart, nEnd;
4036cdf0e10cSrcweir if( nNewPos < nCurPos )
4037cdf0e10cSrcweir {
4038cdf0e10cSrcweir nStart = nNewPos;
4039cdf0e10cSrcweir nEnd = nCurPos;
4040cdf0e10cSrcweir }
4041cdf0e10cSrcweir else
4042cdf0e10cSrcweir {
4043cdf0e10cSrcweir nStart = nCurPos;
4044cdf0e10cSrcweir nEnd = nNewPos;
4045cdf0e10cSrcweir }
4046cdf0e10cSrcweir for( ; nStart <= nEnd; nStart++ )
4047cdf0e10cSrcweir {
4048cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)aEntries.GetObject( nStart );
4049cdf0e10cSrcweir pEntry->nPos = nStart;
4050cdf0e10cSrcweir }
4051cdf0e10cSrcweir }
4052cdf0e10cSrcweir
SetEntryFlags(SvxIconChoiceCtrlEntry * pEntry,sal_uInt16 nEntryFlags)4053cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SetEntryFlags( SvxIconChoiceCtrlEntry* pEntry, sal_uInt16 nEntryFlags )
4054cdf0e10cSrcweir {
4055cdf0e10cSrcweir pEntry->nFlags = nEntryFlags;
4056cdf0e10cSrcweir if( nEntryFlags & ICNVIEW_FLAG_POS_MOVED )
4057cdf0e10cSrcweir nFlags |= F_MOVED_ENTRIES;
4058cdf0e10cSrcweir }
4059cdf0e10cSrcweir
GoLeftRight(SvxIconChoiceCtrlEntry * pStart,sal_Bool bRight)4060cdf0e10cSrcweir SvxIconChoiceCtrlEntry* SvxIconChoiceCtrl_Impl::GoLeftRight( SvxIconChoiceCtrlEntry* pStart, sal_Bool bRight )
4061cdf0e10cSrcweir {
4062cdf0e10cSrcweir return pImpCursor->GoLeftRight( pStart, bRight );
4063cdf0e10cSrcweir }
4064cdf0e10cSrcweir
GoUpDown(SvxIconChoiceCtrlEntry * pStart,sal_Bool bDown)4065cdf0e10cSrcweir SvxIconChoiceCtrlEntry* SvxIconChoiceCtrl_Impl::GoUpDown( SvxIconChoiceCtrlEntry* pStart, sal_Bool bDown )
4066cdf0e10cSrcweir {
4067cdf0e10cSrcweir return pImpCursor->GoUpDown( pStart, bDown );
4068cdf0e10cSrcweir }
4069cdf0e10cSrcweir
InitSettings()4070cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::InitSettings()
4071cdf0e10cSrcweir {
4072cdf0e10cSrcweir const StyleSettings& rStyleSettings = pView->GetSettings().GetStyleSettings();
4073cdf0e10cSrcweir
4074cdf0e10cSrcweir if( !pView->HasFont() )
4075cdf0e10cSrcweir {
4076cdf0e10cSrcweir // Unit aus den Settings ist Point
4077cdf0e10cSrcweir Font aFont( rStyleSettings.GetFieldFont() );
4078cdf0e10cSrcweir //const Font& rFont = pView->GetFont();
4079cdf0e10cSrcweir //if( pView->HasFontTextColor() )
4080cdf0e10cSrcweir aFont.SetColor( rStyleSettings.GetWindowTextColor() );
4081cdf0e10cSrcweir //if( pView->HasFontFillColor() )
4082cdf0e10cSrcweir //aFont.SetFillColor( rFont.GetFillColor() );
4083cdf0e10cSrcweir pView->SetPointFont( aFont );
4084cdf0e10cSrcweir SetDefaultTextSize();
4085cdf0e10cSrcweir }
4086cdf0e10cSrcweir
4087cdf0e10cSrcweir //if( !pView->HasFontTextColor() )
4088cdf0e10cSrcweir pView->SetTextColor( rStyleSettings.GetFieldTextColor() );
4089cdf0e10cSrcweir //if( !pView->HasFontFillColor() )
4090cdf0e10cSrcweir pView->SetTextFillColor();
4091cdf0e10cSrcweir
4092cdf0e10cSrcweir //if( !pView->HasBackground() )
4093cdf0e10cSrcweir pView->SetBackground( rStyleSettings.GetFieldColor());
4094cdf0e10cSrcweir
4095cdf0e10cSrcweir long nScrBarSize = rStyleSettings.GetScrollBarSize();
4096cdf0e10cSrcweir if( nScrBarSize != nHorSBarHeight || nScrBarSize != nVerSBarWidth )
4097cdf0e10cSrcweir {
4098cdf0e10cSrcweir nHorSBarHeight = nScrBarSize;
4099cdf0e10cSrcweir Size aSize( aHorSBar.GetSizePixel() );
4100cdf0e10cSrcweir aSize.Height() = nScrBarSize;
4101cdf0e10cSrcweir aHorSBar.Hide();
4102cdf0e10cSrcweir aHorSBar.SetSizePixel( aSize );
4103cdf0e10cSrcweir
4104cdf0e10cSrcweir nVerSBarWidth = nScrBarSize;
4105cdf0e10cSrcweir aSize = aVerSBar.GetSizePixel();
4106cdf0e10cSrcweir aSize.Width() = nScrBarSize;
4107cdf0e10cSrcweir aVerSBar.Hide();
4108cdf0e10cSrcweir aVerSBar.SetSizePixel( aSize );
4109cdf0e10cSrcweir
4110cdf0e10cSrcweir Size aOSize( pView->Control::GetOutputSizePixel() );
4111cdf0e10cSrcweir PositionScrollBars( aOSize.Width(), aOSize.Height() );
4112cdf0e10cSrcweir AdjustScrollBars();
4113cdf0e10cSrcweir }
4114cdf0e10cSrcweir }
4115cdf0e10cSrcweir
EntryList_Impl(SvxIconChoiceCtrl_Impl * pOwner,sal_uInt16 _nInitSize,sal_uInt16 _nReSize)4116cdf0e10cSrcweir EntryList_Impl::EntryList_Impl( SvxIconChoiceCtrl_Impl* pOwner, sal_uInt16 _nInitSize , sal_uInt16 _nReSize ) :
4117cdf0e10cSrcweir List( _nInitSize, _nReSize ),
4118cdf0e10cSrcweir _pOwner( pOwner )
4119cdf0e10cSrcweir {
4120cdf0e10cSrcweir _pOwner->pHead = 0;
4121cdf0e10cSrcweir }
4122cdf0e10cSrcweir
EntryList_Impl(SvxIconChoiceCtrl_Impl * pOwner,sal_uInt16 _nBlockSize,sal_uInt16 _nInitSize,sal_uInt16 _nReSize)4123cdf0e10cSrcweir EntryList_Impl::EntryList_Impl( SvxIconChoiceCtrl_Impl* pOwner, sal_uInt16 _nBlockSize, sal_uInt16 _nInitSize, sal_uInt16 _nReSize ) :
4124cdf0e10cSrcweir List( _nBlockSize, _nInitSize, _nReSize ),
4125cdf0e10cSrcweir _pOwner( pOwner )
4126cdf0e10cSrcweir {
4127cdf0e10cSrcweir _pOwner->pHead = 0;
4128cdf0e10cSrcweir }
4129cdf0e10cSrcweir
~EntryList_Impl()4130cdf0e10cSrcweir EntryList_Impl::~EntryList_Impl()
4131cdf0e10cSrcweir {
4132cdf0e10cSrcweir _pOwner->pHead = 0;
4133cdf0e10cSrcweir }
4134cdf0e10cSrcweir
Clear()4135cdf0e10cSrcweir void EntryList_Impl::Clear()
4136cdf0e10cSrcweir {
4137cdf0e10cSrcweir _pOwner->pHead = 0;
4138cdf0e10cSrcweir List::Clear();
4139cdf0e10cSrcweir }
4140cdf0e10cSrcweir
Insert(SvxIconChoiceCtrlEntry * pEntry,sal_uLong nPos)4141cdf0e10cSrcweir void EntryList_Impl::Insert( SvxIconChoiceCtrlEntry* pEntry, sal_uLong nPos )
4142cdf0e10cSrcweir {
4143cdf0e10cSrcweir List::Insert( pEntry, nPos );
4144cdf0e10cSrcweir if( _pOwner->pHead )
4145cdf0e10cSrcweir pEntry->SetBacklink( _pOwner->pHead->pblink );
4146cdf0e10cSrcweir }
4147cdf0e10cSrcweir
Remove(sal_uLong nPos)4148cdf0e10cSrcweir SvxIconChoiceCtrlEntry* EntryList_Impl::Remove( sal_uLong nPos )
4149cdf0e10cSrcweir {
4150cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)List::Remove( nPos );
4151cdf0e10cSrcweir DBG_ASSERT(pEntry,"EntryList_Impl::Remove > Entry not found");
4152cdf0e10cSrcweir Removed_Impl( pEntry );
4153cdf0e10cSrcweir return pEntry;
4154cdf0e10cSrcweir }
4155cdf0e10cSrcweir
Remove(SvxIconChoiceCtrlEntry * pEntry)4156cdf0e10cSrcweir void EntryList_Impl::Remove( SvxIconChoiceCtrlEntry* pEntry )
4157cdf0e10cSrcweir {
4158cdf0e10cSrcweir List::Remove( (void*)pEntry );
4159cdf0e10cSrcweir Removed_Impl( pEntry );
4160cdf0e10cSrcweir }
4161cdf0e10cSrcweir
Removed_Impl(SvxIconChoiceCtrlEntry * pEntry)4162cdf0e10cSrcweir void EntryList_Impl::Removed_Impl( SvxIconChoiceCtrlEntry* pEntry )
4163cdf0e10cSrcweir {
4164cdf0e10cSrcweir if( _pOwner->pHead )
4165cdf0e10cSrcweir {
4166cdf0e10cSrcweir if( _pOwner->pHead == pEntry )
4167cdf0e10cSrcweir {
4168cdf0e10cSrcweir if( _pOwner->pHead != pEntry->pflink )
4169cdf0e10cSrcweir _pOwner->pHead = pEntry->pflink;
4170cdf0e10cSrcweir else
4171cdf0e10cSrcweir {
4172cdf0e10cSrcweir DBG_ASSERT(!Count(),"EntryList_Impl::Remove > Invalid predecessor" );
4173cdf0e10cSrcweir _pOwner->pHead = 0;
4174cdf0e10cSrcweir }
4175cdf0e10cSrcweir }
4176cdf0e10cSrcweir pEntry->Unlink();
4177cdf0e10cSrcweir }
4178cdf0e10cSrcweir }
4179cdf0e10cSrcweir
SetPositionMode(SvxIconChoiceCtrlPositionMode eMode)4180cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SetPositionMode( SvxIconChoiceCtrlPositionMode eMode )
4181cdf0e10cSrcweir {
4182cdf0e10cSrcweir sal_uLong nCur;
4183cdf0e10cSrcweir
4184cdf0e10cSrcweir if( eMode == ePositionMode )
4185cdf0e10cSrcweir return;
4186cdf0e10cSrcweir
4187cdf0e10cSrcweir SvxIconChoiceCtrlPositionMode eOldMode = ePositionMode;
4188cdf0e10cSrcweir ePositionMode = eMode;
4189cdf0e10cSrcweir sal_uLong nCount = aEntries.Count();
4190cdf0e10cSrcweir
4191cdf0e10cSrcweir if( eOldMode == IcnViewPositionModeAutoArrange )
4192cdf0e10cSrcweir {
4193cdf0e10cSrcweir // positionieren wir verschobene Eintraege 'hart' gibts noch Probleme
4194cdf0e10cSrcweir // mit ungewollten Ueberlappungen, da diese Eintrage im Arrange
4195cdf0e10cSrcweir // nicht beruecksichtigt werden.
4196cdf0e10cSrcweir #if 1
4197cdf0e10cSrcweir if( aEntries.Count() )
4198cdf0e10cSrcweir aAutoArrangeTimer.Start();
4199cdf0e10cSrcweir #else
4200cdf0e10cSrcweir if( pHead )
4201cdf0e10cSrcweir {
4202cdf0e10cSrcweir // verschobene Eintraege 'hart' auf ihre Position setzen
4203cdf0e10cSrcweir nCur = nCount;
4204cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = pHead;
4205cdf0e10cSrcweir while( nCur )
4206cdf0e10cSrcweir {
4207cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pPred;
4208cdf0e10cSrcweir if( GetEntryPredecessor( pEntry, &pPred ))
4209cdf0e10cSrcweir SetEntryFlags( pEntry, ICNVIEW_FLAG_POS_MOVED );
4210cdf0e10cSrcweir pEntry = pEntry->pflink;
4211cdf0e10cSrcweir nCur--;
4212cdf0e10cSrcweir }
4213cdf0e10cSrcweir ClearPredecessors();
4214cdf0e10cSrcweir }
4215cdf0e10cSrcweir #endif
4216cdf0e10cSrcweir return;
4217cdf0e10cSrcweir }
4218cdf0e10cSrcweir
4219cdf0e10cSrcweir if( ePositionMode == IcnViewPositionModeAutoArrange )
4220cdf0e10cSrcweir {
4221cdf0e10cSrcweir List aMovedEntries;
4222cdf0e10cSrcweir for( nCur = 0; nCur < nCount; nCur++ )
4223cdf0e10cSrcweir {
4224cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)aEntries.GetObject( nCur );
4225cdf0e10cSrcweir if( pEntry->GetFlags() & (ICNVIEW_FLAG_POS_LOCKED | ICNVIEW_FLAG_POS_MOVED))
4226cdf0e10cSrcweir {
4227cdf0e10cSrcweir SvxIconChoiceCtrlEntry_Impl* pE = new SvxIconChoiceCtrlEntry_Impl(
4228cdf0e10cSrcweir pEntry, GetEntryBoundRect( pEntry ));
4229cdf0e10cSrcweir aMovedEntries.Insert( pE, LIST_APPEND );
4230cdf0e10cSrcweir }
4231cdf0e10cSrcweir }
4232cdf0e10cSrcweir nCount = aMovedEntries.Count();
4233cdf0e10cSrcweir for( nCur = 0; nCur < nCount; nCur++ )
4234cdf0e10cSrcweir {
4235cdf0e10cSrcweir SvxIconChoiceCtrlEntry_Impl* pE = (SvxIconChoiceCtrlEntry_Impl*)aMovedEntries.GetObject(nCur);
4236cdf0e10cSrcweir SetEntryPos( pE->_pEntry, pE->_aPos );
4237cdf0e10cSrcweir }
4238cdf0e10cSrcweir for( nCur = 0; nCur < nCount; nCur++ )
4239cdf0e10cSrcweir delete (SvxIconChoiceCtrlEntry_Impl*)aMovedEntries.GetObject( nCur );
4240cdf0e10cSrcweir if( aEntries.Count() )
4241cdf0e10cSrcweir aAutoArrangeTimer.Start();
4242cdf0e10cSrcweir }
4243cdf0e10cSrcweir else if( ePositionMode == IcnViewPositionModeAutoAdjust )
4244cdf0e10cSrcweir {
4245cdf0e10cSrcweir AdjustEntryAtGrid( 0 );
4246cdf0e10cSrcweir }
4247cdf0e10cSrcweir }
4248cdf0e10cSrcweir
SetEntryPredecessor(SvxIconChoiceCtrlEntry * pEntry,SvxIconChoiceCtrlEntry * pPredecessor)4249cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SetEntryPredecessor( SvxIconChoiceCtrlEntry* pEntry,
4250cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pPredecessor )
4251cdf0e10cSrcweir {
4252cdf0e10cSrcweir if( !IsAutoArrange() )
4253cdf0e10cSrcweir return;
4254cdf0e10cSrcweir
4255cdf0e10cSrcweir if( pEntry == pPredecessor )
4256cdf0e10cSrcweir return;
4257cdf0e10cSrcweir
4258cdf0e10cSrcweir sal_uLong nPos1 = GetEntryListPos( pEntry );
4259cdf0e10cSrcweir if( !pHead )
4260cdf0e10cSrcweir {
4261cdf0e10cSrcweir if( pPredecessor )
4262cdf0e10cSrcweir {
4263cdf0e10cSrcweir sal_uLong nPos2 = GetEntryListPos( pPredecessor );
4264cdf0e10cSrcweir if( nPos1 == (nPos2 + 1) )
4265cdf0e10cSrcweir return; // ist schon Vorgaenger
4266cdf0e10cSrcweir }
4267cdf0e10cSrcweir else if( !nPos1 )
4268cdf0e10cSrcweir return;
4269cdf0e10cSrcweir }
4270cdf0e10cSrcweir
4271cdf0e10cSrcweir if( !pHead )
4272cdf0e10cSrcweir InitPredecessors();
4273cdf0e10cSrcweir
4274cdf0e10cSrcweir if( !pPredecessor && pHead == pEntry )
4275cdf0e10cSrcweir return; // ist schon der Erste
4276cdf0e10cSrcweir
4277cdf0e10cSrcweir sal_Bool bSetHead = sal_False;
4278cdf0e10cSrcweir if( !pPredecessor )
4279cdf0e10cSrcweir {
4280cdf0e10cSrcweir bSetHead = sal_True;
4281cdf0e10cSrcweir pPredecessor = pHead->pblink;
4282cdf0e10cSrcweir }
4283cdf0e10cSrcweir if( pEntry == pHead )
4284cdf0e10cSrcweir {
4285cdf0e10cSrcweir pHead = pHead->pflink;
4286cdf0e10cSrcweir bSetHead = sal_False;
4287cdf0e10cSrcweir }
4288cdf0e10cSrcweir if( pEntry != pPredecessor )
4289cdf0e10cSrcweir {
4290cdf0e10cSrcweir pEntry->Unlink();
4291cdf0e10cSrcweir pEntry->SetBacklink( pPredecessor );
4292cdf0e10cSrcweir }
4293cdf0e10cSrcweir if( bSetHead )
4294cdf0e10cSrcweir pHead = pEntry;
4295cdf0e10cSrcweir pEntry->SetFlags( ICNVIEW_FLAG_PRED_SET );
4296cdf0e10cSrcweir aAutoArrangeTimer.Start();
4297cdf0e10cSrcweir }
4298cdf0e10cSrcweir
GetEntryPredecessor(SvxIconChoiceCtrlEntry * pEntry,SvxIconChoiceCtrlEntry ** ppPredecessor)4299cdf0e10cSrcweir sal_Bool SvxIconChoiceCtrl_Impl::GetEntryPredecessor( SvxIconChoiceCtrlEntry* pEntry,
4300cdf0e10cSrcweir SvxIconChoiceCtrlEntry** ppPredecessor )
4301cdf0e10cSrcweir {
4302cdf0e10cSrcweir *ppPredecessor = 0;
4303cdf0e10cSrcweir if( !pHead )
4304cdf0e10cSrcweir return sal_False;
4305cdf0e10cSrcweir DBG_ASSERT(pEntry->pblink,"GetEntryPredecessor: Backward link not set");
4306cdf0e10cSrcweir DBG_ASSERT(pEntry->pflink,"GetEntryPredecessor: Forward link not set");
4307cdf0e10cSrcweir
4308cdf0e10cSrcweir if( pEntry == pHead )
4309cdf0e10cSrcweir {
4310cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pFirst = (SvxIconChoiceCtrlEntry*)aEntries.GetObject(0);
4311cdf0e10cSrcweir if( pFirst != pEntry )
4312cdf0e10cSrcweir return sal_True;
4313cdf0e10cSrcweir return sal_False;
4314cdf0e10cSrcweir }
4315cdf0e10cSrcweir *ppPredecessor = pEntry->pblink;
4316cdf0e10cSrcweir if( !(pEntry->nFlags & ICNVIEW_FLAG_PRED_SET) &&
4317cdf0e10cSrcweir (GetEntryListPos( *ppPredecessor ) + 1) == GetEntryListPos( pEntry ))
4318cdf0e10cSrcweir return sal_False;
4319cdf0e10cSrcweir return sal_True;
4320cdf0e10cSrcweir }
4321cdf0e10cSrcweir
FindEntryPredecessor(SvxIconChoiceCtrlEntry * pEntry,const Point & rPosTopLeft)4322cdf0e10cSrcweir SvxIconChoiceCtrlEntry* SvxIconChoiceCtrl_Impl::FindEntryPredecessor( SvxIconChoiceCtrlEntry* pEntry,
4323cdf0e10cSrcweir const Point& rPosTopLeft )
4324cdf0e10cSrcweir {
4325cdf0e10cSrcweir Point aPos( rPosTopLeft ); //TopLeft
4326cdf0e10cSrcweir Rectangle aCenterRect( CalcBmpRect( pEntry, &aPos ));
4327cdf0e10cSrcweir Point aNewPos( aCenterRect.Center() );
4328cdf0e10cSrcweir sal_uLong nGrid = GetPredecessorGrid( aNewPos );
4329cdf0e10cSrcweir sal_uLong nCount = aEntries.Count();
4330cdf0e10cSrcweir if( nGrid == ULONG_MAX )
4331cdf0e10cSrcweir return 0;
4332cdf0e10cSrcweir if( nGrid >= nCount )
4333cdf0e10cSrcweir nGrid = nCount - 1;
4334cdf0e10cSrcweir if( !pHead )
4335cdf0e10cSrcweir return (SvxIconChoiceCtrlEntry*)aEntries.GetObject( nGrid );
4336cdf0e10cSrcweir
4337cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pCur = pHead; // Grid 0
4338cdf0e10cSrcweir // todo: Liste von hinten aufrollen wenn nGrid > nCount/2
4339cdf0e10cSrcweir for( sal_uLong nCur = 0; nCur < nGrid; nCur++ )
4340cdf0e10cSrcweir pCur = pCur->pflink;
4341cdf0e10cSrcweir
4342cdf0e10cSrcweir return pCur;
4343cdf0e10cSrcweir }
4344cdf0e10cSrcweir
GetPredecessorGrid(const Point & rPos) const4345cdf0e10cSrcweir sal_uLong SvxIconChoiceCtrl_Impl::GetPredecessorGrid( const Point& rPos) const
4346cdf0e10cSrcweir {
4347cdf0e10cSrcweir Point aPos( rPos );
4348cdf0e10cSrcweir aPos.X() -= LROFFS_WINBORDER;
4349cdf0e10cSrcweir aPos.Y() -= TBOFFS_WINBORDER;
4350cdf0e10cSrcweir sal_uInt16 nMaxCol = (sal_uInt16)(aVirtOutputSize.Width() / nGridDX);
4351cdf0e10cSrcweir if( nMaxCol )
4352cdf0e10cSrcweir nMaxCol--;
4353cdf0e10cSrcweir sal_uInt16 nGridX = (sal_uInt16)(aPos.X() / nGridDX);
4354cdf0e10cSrcweir if( nGridX > nMaxCol )
4355cdf0e10cSrcweir nGridX = nMaxCol;
4356cdf0e10cSrcweir sal_uInt16 nGridY = (sal_uInt16)(aPos.Y() / nGridDY);
4357cdf0e10cSrcweir sal_uInt16 nGridsX = (sal_uInt16)(aOutputSize.Width() / nGridDX);
4358cdf0e10cSrcweir sal_uLong nGrid = (nGridY * nGridsX) + nGridX;
4359cdf0e10cSrcweir long nMiddle = (nGridX * nGridDX) + (nGridDX / 2);
4360cdf0e10cSrcweir if( rPos.X() < nMiddle )
4361cdf0e10cSrcweir {
4362cdf0e10cSrcweir if( !nGrid )
4363cdf0e10cSrcweir nGrid = ULONG_MAX;
4364cdf0e10cSrcweir else
4365cdf0e10cSrcweir nGrid--;
4366cdf0e10cSrcweir }
4367cdf0e10cSrcweir return nGrid;
4368cdf0e10cSrcweir }
4369cdf0e10cSrcweir
Flush()4370cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::Flush()
4371cdf0e10cSrcweir {
4372cdf0e10cSrcweir if( aAutoArrangeTimer.IsActive() )
4373cdf0e10cSrcweir {
4374cdf0e10cSrcweir AutoArrangeHdl( 0 );
4375cdf0e10cSrcweir }
4376cdf0e10cSrcweir }
4377cdf0e10cSrcweir
RequestHelp(const HelpEvent & rHEvt)4378cdf0e10cSrcweir sal_Bool SvxIconChoiceCtrl_Impl::RequestHelp( const HelpEvent& rHEvt )
4379cdf0e10cSrcweir {
4380cdf0e10cSrcweir if ( !(rHEvt.GetMode() & HELPMODE_QUICK ) )
4381cdf0e10cSrcweir return sal_False;
4382cdf0e10cSrcweir
4383cdf0e10cSrcweir Point aPos( pView->ScreenToOutputPixel(rHEvt.GetMousePosPixel() ) );
4384cdf0e10cSrcweir aPos -= pView->GetMapMode().GetOrigin();
4385cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = GetEntry( aPos, sal_True );
4386cdf0e10cSrcweir
4387cdf0e10cSrcweir if ( !pEntry )
4388cdf0e10cSrcweir return sal_False;
4389cdf0e10cSrcweir
4390cdf0e10cSrcweir String sQuickHelpText = pEntry->GetQuickHelpText();
4391cdf0e10cSrcweir String aEntryText( pView->GetEntryText( pEntry, sal_False ) );
4392cdf0e10cSrcweir Rectangle aTextRect( CalcTextRect( pEntry, 0, sal_False, &aEntryText ) );
4393cdf0e10cSrcweir if ( ( !aTextRect.IsInside( aPos ) || !aEntryText.Len() ) && !sQuickHelpText.Len() )
4394cdf0e10cSrcweir return sal_False;
4395cdf0e10cSrcweir
4396cdf0e10cSrcweir Rectangle aOptTextRect( aTextRect );
4397cdf0e10cSrcweir aOptTextRect.Bottom() = LONG_MAX;
4398cdf0e10cSrcweir sal_uInt16 nNewFlags = nCurTextDrawFlags;
4399cdf0e10cSrcweir nNewFlags &= ~( TEXT_DRAW_CLIP | TEXT_DRAW_ENDELLIPSIS );
4400cdf0e10cSrcweir aOptTextRect = pView->GetTextRect( aOptTextRect, aEntryText, nNewFlags );
4401cdf0e10cSrcweir if ( aOptTextRect != aTextRect || sQuickHelpText.Len() > 0 )
4402cdf0e10cSrcweir {
4403cdf0e10cSrcweir //aTextRect.Right() = aTextRect.Left() + aRealSize.Width() + 4;
4404cdf0e10cSrcweir Point aPt( aOptTextRect.TopLeft() );
4405cdf0e10cSrcweir aPt += pView->GetMapMode().GetOrigin();
4406cdf0e10cSrcweir aPt = pView->OutputToScreenPixel( aPt );
4407cdf0e10cSrcweir // Border der Tiphilfe abziehen
4408cdf0e10cSrcweir aPt.Y() -= 1;
4409cdf0e10cSrcweir aPt.X() -= 3;
4410cdf0e10cSrcweir aOptTextRect.SetPos( aPt );
4411cdf0e10cSrcweir String sHelpText;
4412cdf0e10cSrcweir if ( sQuickHelpText.Len() > 0 )
4413cdf0e10cSrcweir sHelpText = sQuickHelpText;
4414cdf0e10cSrcweir else
4415cdf0e10cSrcweir sHelpText = aEntryText;
4416cdf0e10cSrcweir Help::ShowQuickHelp( (Window*)pView, aOptTextRect, sHelpText, QUICKHELP_LEFT | QUICKHELP_VCENTER );
4417cdf0e10cSrcweir }
4418cdf0e10cSrcweir
4419cdf0e10cSrcweir return sal_True;
4420cdf0e10cSrcweir }
4421cdf0e10cSrcweir
ClearColumnList()4422cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::ClearColumnList()
4423cdf0e10cSrcweir {
4424cdf0e10cSrcweir if( !pColumns )
4425cdf0e10cSrcweir return;
4426cdf0e10cSrcweir
4427cdf0e10cSrcweir const sal_uInt16 nCount = pColumns->Count();
4428cdf0e10cSrcweir for( sal_uInt16 nCur = 0; nCur < nCount; nCur++ )
4429cdf0e10cSrcweir {
4430cdf0e10cSrcweir SvxIconChoiceCtrlColumnInfo* pInfo = (SvxIconChoiceCtrlColumnInfo*)
4431cdf0e10cSrcweir pColumns->GetObject( nCur );
4432cdf0e10cSrcweir delete pInfo;
4433cdf0e10cSrcweir }
4434cdf0e10cSrcweir DELETEZ(pColumns);
4435cdf0e10cSrcweir }
4436cdf0e10cSrcweir
SetColumn(sal_uInt16 nIndex,const SvxIconChoiceCtrlColumnInfo & rInfo)4437cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SetColumn( sal_uInt16 nIndex, const SvxIconChoiceCtrlColumnInfo& rInfo)
4438cdf0e10cSrcweir {
4439cdf0e10cSrcweir if( !pColumns )
4440cdf0e10cSrcweir pColumns = new SvPtrarr;
4441cdf0e10cSrcweir while( pColumns->Count() < nIndex + 1 )
4442cdf0e10cSrcweir pColumns->Insert( (void*)0, pColumns->Count() );
4443cdf0e10cSrcweir
4444cdf0e10cSrcweir SvxIconChoiceCtrlColumnInfo* pInfo =
4445cdf0e10cSrcweir (SvxIconChoiceCtrlColumnInfo*)pColumns->GetObject(nIndex);
4446cdf0e10cSrcweir if( !pInfo )
4447cdf0e10cSrcweir {
4448cdf0e10cSrcweir pInfo = new SvxIconChoiceCtrlColumnInfo( rInfo );
4449cdf0e10cSrcweir pColumns->Insert( (void*)pInfo, nIndex );
4450cdf0e10cSrcweir }
4451cdf0e10cSrcweir else
4452cdf0e10cSrcweir {
4453cdf0e10cSrcweir delete pInfo;
4454cdf0e10cSrcweir pInfo = new SvxIconChoiceCtrlColumnInfo( rInfo );
4455cdf0e10cSrcweir pColumns->Replace( pInfo, nIndex );
4456cdf0e10cSrcweir }
4457cdf0e10cSrcweir
4458cdf0e10cSrcweir // HACK(Detail-Modus ist noch nicht vollstaendig implementiert!)
4459cdf0e10cSrcweir // dieses Workaround bringts mit einer Spalte zum Fliegen
4460cdf0e10cSrcweir if( !nIndex && (nWinBits & WB_DETAILS) )
4461cdf0e10cSrcweir nGridDX = pInfo->GetWidth();
4462cdf0e10cSrcweir
4463cdf0e10cSrcweir if( GetUpdateMode() )
4464cdf0e10cSrcweir Arrange( IsAutoArrange() );
4465cdf0e10cSrcweir }
4466cdf0e10cSrcweir
GetColumn(sal_uInt16 nIndex) const4467cdf0e10cSrcweir const SvxIconChoiceCtrlColumnInfo* SvxIconChoiceCtrl_Impl::GetColumn( sal_uInt16 nIndex ) const
4468cdf0e10cSrcweir {
4469cdf0e10cSrcweir if( !pColumns || nIndex >= pColumns->Count() )
4470cdf0e10cSrcweir return 0;
4471cdf0e10cSrcweir return (const SvxIconChoiceCtrlColumnInfo*)pColumns->GetObject( nIndex );
4472cdf0e10cSrcweir }
4473cdf0e10cSrcweir
GetItemColumn(sal_uInt16 nSubItem,long & rLeft) const4474cdf0e10cSrcweir const SvxIconChoiceCtrlColumnInfo* SvxIconChoiceCtrl_Impl::GetItemColumn( sal_uInt16 nSubItem,
4475cdf0e10cSrcweir long& rLeft ) const
4476cdf0e10cSrcweir {
4477cdf0e10cSrcweir rLeft = 0;
4478cdf0e10cSrcweir if( !pColumns )
4479cdf0e10cSrcweir return 0;
4480cdf0e10cSrcweir const sal_uInt16 nCount = pColumns->Count();
4481cdf0e10cSrcweir const SvxIconChoiceCtrlColumnInfo* pCol = 0;
4482cdf0e10cSrcweir for( sal_uInt16 nCur = 0; nCur < nCount; nCur++ )
4483cdf0e10cSrcweir {
4484cdf0e10cSrcweir pCol = (const SvxIconChoiceCtrlColumnInfo*)pColumns->GetObject( nCur );
4485cdf0e10cSrcweir if( !pCol || pCol->GetSubItem() == nSubItem )
4486cdf0e10cSrcweir return pCol;
4487cdf0e10cSrcweir rLeft += pCol->GetWidth();
4488cdf0e10cSrcweir }
4489cdf0e10cSrcweir return pCol;
4490cdf0e10cSrcweir }
4491cdf0e10cSrcweir
DrawHighlightFrame(OutputDevice * pOut,const Rectangle & rBmpRect,sal_Bool bHide)4492cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::DrawHighlightFrame(
4493cdf0e10cSrcweir OutputDevice* pOut, const Rectangle& rBmpRect, sal_Bool bHide )
4494cdf0e10cSrcweir {
4495cdf0e10cSrcweir Rectangle aBmpRect( rBmpRect );
4496cdf0e10cSrcweir long nBorder = 2;
4497cdf0e10cSrcweir if( aImageSize.Width() < 32 )
4498cdf0e10cSrcweir nBorder = 1;
4499cdf0e10cSrcweir aBmpRect.Right() += nBorder;
4500cdf0e10cSrcweir aBmpRect.Left() -= nBorder;
4501cdf0e10cSrcweir aBmpRect.Bottom() += nBorder;
4502cdf0e10cSrcweir aBmpRect.Top() -= nBorder;
4503cdf0e10cSrcweir
4504cdf0e10cSrcweir if ( bHide )
4505cdf0e10cSrcweir pView->Invalidate( aBmpRect );
4506cdf0e10cSrcweir else
4507cdf0e10cSrcweir {
4508cdf0e10cSrcweir DecorationView aDecoView( pOut );
4509cdf0e10cSrcweir sal_uInt16 nDecoFlags;
4510cdf0e10cSrcweir if ( bHighlightFramePressed )
4511cdf0e10cSrcweir nDecoFlags = FRAME_HIGHLIGHT_TESTBACKGROUND | FRAME_HIGHLIGHT_IN;
4512cdf0e10cSrcweir else
4513cdf0e10cSrcweir nDecoFlags = FRAME_HIGHLIGHT_TESTBACKGROUND | FRAME_HIGHLIGHT_OUT;
4514cdf0e10cSrcweir aDecoView.DrawHighlightFrame( aBmpRect, nDecoFlags );
4515cdf0e10cSrcweir }
4516cdf0e10cSrcweir }
4517cdf0e10cSrcweir
SetEntryHighlightFrame(SvxIconChoiceCtrlEntry * pEntry,sal_Bool bKeepHighlightFlags)4518cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SetEntryHighlightFrame( SvxIconChoiceCtrlEntry* pEntry,
4519cdf0e10cSrcweir sal_Bool bKeepHighlightFlags )
4520cdf0e10cSrcweir {
4521cdf0e10cSrcweir if( pEntry == pCurHighlightFrame )
4522cdf0e10cSrcweir return;
4523cdf0e10cSrcweir
4524cdf0e10cSrcweir if( !bKeepHighlightFlags )
4525cdf0e10cSrcweir bHighlightFramePressed = sal_False;
4526cdf0e10cSrcweir
4527cdf0e10cSrcweir HideEntryHighlightFrame();
4528cdf0e10cSrcweir pCurHighlightFrame = pEntry;
4529cdf0e10cSrcweir if( pEntry )
4530cdf0e10cSrcweir {
4531cdf0e10cSrcweir Rectangle aBmpRect( CalcFocusRect(pEntry) );
4532cdf0e10cSrcweir DrawHighlightFrame( pView, aBmpRect, sal_False );
4533cdf0e10cSrcweir }
4534cdf0e10cSrcweir }
4535cdf0e10cSrcweir
HideEntryHighlightFrame()4536cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::HideEntryHighlightFrame()
4537cdf0e10cSrcweir {
4538cdf0e10cSrcweir if( !pCurHighlightFrame )
4539cdf0e10cSrcweir return;
4540cdf0e10cSrcweir
4541cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = pCurHighlightFrame;
4542cdf0e10cSrcweir pCurHighlightFrame = 0;
4543cdf0e10cSrcweir Rectangle aBmpRect( CalcFocusRect(pEntry) );
4544cdf0e10cSrcweir DrawHighlightFrame( pView, aBmpRect, sal_True );
4545cdf0e10cSrcweir }
4546cdf0e10cSrcweir
CallSelectHandler(SvxIconChoiceCtrlEntry *)4547cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::CallSelectHandler( SvxIconChoiceCtrlEntry* )
4548cdf0e10cSrcweir {
4549cdf0e10cSrcweir // Bei aktiviertem Single-Click-Modus sollte der Selektionshandler
4550cdf0e10cSrcweir // synchron gerufen werden, weil die Selektion automatisch
4551cdf0e10cSrcweir // weggenommen wird, wenn der Mauszeiger nicht mehr das Objekt
4552cdf0e10cSrcweir // beruehrt. Es kann sonst zu fehlenden Select-Aufrufen kommen,
4553cdf0e10cSrcweir // wenn das Objekt aus einer Mausbewegung heraus selektiert wird,
4554cdf0e10cSrcweir // weil beim Ausloesen des Timers der Mauszeiger das Objekt u.U.
4555cdf0e10cSrcweir // schon verlassen hat.
4556cdf0e10cSrcweir // Fuer spezielle Faelle (=>SfxFileDialog!) koennen synchrone
4557cdf0e10cSrcweir // Aufrufe auch per WB_NOASYNCSELECTHDL erzwungen werden.
4558cdf0e10cSrcweir if( nWinBits & (WB_NOASYNCSELECTHDL | WB_HIGHLIGHTFRAME) )
4559cdf0e10cSrcweir {
4560cdf0e10cSrcweir pHdlEntry = 0;
4561cdf0e10cSrcweir pView->ClickIcon();
4562cdf0e10cSrcweir //pView->Select();
4563cdf0e10cSrcweir }
4564cdf0e10cSrcweir else
4565cdf0e10cSrcweir aCallSelectHdlTimer.Start();
4566cdf0e10cSrcweir }
4567cdf0e10cSrcweir
IMPL_LINK(SvxIconChoiceCtrl_Impl,CallSelectHdlHdl,void *,EMPTYARG)4568cdf0e10cSrcweir IMPL_LINK( SvxIconChoiceCtrl_Impl, CallSelectHdlHdl, void*, EMPTYARG )
4569cdf0e10cSrcweir {
4570cdf0e10cSrcweir pHdlEntry = 0;
4571cdf0e10cSrcweir pView->ClickIcon();
4572cdf0e10cSrcweir //pView->Select();
4573cdf0e10cSrcweir return 0;
4574cdf0e10cSrcweir }
4575cdf0e10cSrcweir
GetPopupMenuPosPixel() const4576cdf0e10cSrcweir Point SvxIconChoiceCtrl_Impl::GetPopupMenuPosPixel() const
4577cdf0e10cSrcweir {
4578cdf0e10cSrcweir Point aResult;
4579cdf0e10cSrcweir if( !GetSelectionCount() )
4580cdf0e10cSrcweir return aResult;
4581cdf0e10cSrcweir
4582cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = GetCurEntry();
4583cdf0e10cSrcweir if( !pEntry || !pEntry->IsSelected() )
4584cdf0e10cSrcweir {
4585cdf0e10cSrcweir sal_uLong nNext;
4586cdf0e10cSrcweir pEntry = GetFirstSelectedEntry( nNext );
4587cdf0e10cSrcweir }
4588cdf0e10cSrcweir if( pEntry )
4589cdf0e10cSrcweir {
4590cdf0e10cSrcweir Rectangle aRect( ((SvxIconChoiceCtrl_Impl*)this)->CalcBmpRect( pEntry ) );
4591cdf0e10cSrcweir aResult = aRect.Center();
4592cdf0e10cSrcweir aResult = pView->GetPixelPos( aResult );
4593cdf0e10cSrcweir }
4594cdf0e10cSrcweir return aResult;
4595cdf0e10cSrcweir }
4596cdf0e10cSrcweir
SetOrigin(const Point & rPos,sal_Bool bDoNotUpdateWallpaper)4597cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::SetOrigin( const Point& rPos, sal_Bool bDoNotUpdateWallpaper )
4598cdf0e10cSrcweir {
4599cdf0e10cSrcweir MapMode aMapMode( pView->GetMapMode() );
4600cdf0e10cSrcweir aMapMode.SetOrigin( rPos );
4601cdf0e10cSrcweir pView->SetMapMode( aMapMode );
4602cdf0e10cSrcweir if( !bDoNotUpdateWallpaper )
4603cdf0e10cSrcweir {
4604cdf0e10cSrcweir sal_Bool bScrollable = pView->GetBackground().IsScrollable();
4605cdf0e10cSrcweir if( pView->HasBackground() && !bScrollable )
4606cdf0e10cSrcweir {
4607cdf0e10cSrcweir Rectangle aRect( GetOutputRect());
4608cdf0e10cSrcweir Wallpaper aPaper( pView->GetBackground() );
4609cdf0e10cSrcweir aPaper.SetRect( aRect );
4610cdf0e10cSrcweir pView->SetBackground( aPaper );
4611cdf0e10cSrcweir }
4612cdf0e10cSrcweir }
4613cdf0e10cSrcweir }
4614cdf0e10cSrcweir
GetGridCount(const Size & rSize,sal_Bool bCheckScrBars,sal_Bool bSmartScrBar) const4615cdf0e10cSrcweir sal_uLong SvxIconChoiceCtrl_Impl::GetGridCount( const Size& rSize, sal_Bool bCheckScrBars,
4616cdf0e10cSrcweir sal_Bool bSmartScrBar ) const
4617cdf0e10cSrcweir {
4618cdf0e10cSrcweir Size aSize( rSize );
4619cdf0e10cSrcweir if( bCheckScrBars && aHorSBar.IsVisible() )
4620cdf0e10cSrcweir aSize.Height() -= nHorSBarHeight;
4621cdf0e10cSrcweir else if( bSmartScrBar && (nWinBits & WB_ALIGN_LEFT) )
4622cdf0e10cSrcweir aSize.Height() -= nHorSBarHeight;
4623cdf0e10cSrcweir
4624cdf0e10cSrcweir if( bCheckScrBars && aVerSBar.IsVisible() )
4625cdf0e10cSrcweir aSize.Width() -= nVerSBarWidth;
4626cdf0e10cSrcweir else if( bSmartScrBar && (nWinBits & WB_ALIGN_TOP) )
4627cdf0e10cSrcweir aSize.Width() -= nVerSBarWidth;
4628cdf0e10cSrcweir
4629cdf0e10cSrcweir if( aSize.Width() < 0 )
4630cdf0e10cSrcweir aSize.Width() = 0;
4631cdf0e10cSrcweir if( aSize.Height() < 0 )
4632cdf0e10cSrcweir aSize.Height() = 0;
4633cdf0e10cSrcweir
4634cdf0e10cSrcweir return IcnGridMap_Impl::GetGridCount( aSize, (sal_uInt16)nGridDX, (sal_uInt16)nGridDY );
4635cdf0e10cSrcweir }
4636cdf0e10cSrcweir
HandleShortCutKey(const KeyEvent & rKEvt)4637cdf0e10cSrcweir sal_Bool SvxIconChoiceCtrl_Impl::HandleShortCutKey( const KeyEvent& rKEvt )
4638cdf0e10cSrcweir {
4639cdf0e10cSrcweir StopEditTimer();
4640cdf0e10cSrcweir
4641cdf0e10cSrcweir sal_Bool bRet = sal_False;
4642cdf0e10cSrcweir
4643cdf0e10cSrcweir DBG_ASSERT( rKEvt.GetKeyCode().IsMod2(), "*SvxIconChoiceCtrl_Impl::HandleShortCutKey(): no <ALT> pressed!?" );
4644cdf0e10cSrcweir
4645cdf0e10cSrcweir sal_Unicode cChar = rKEvt.GetCharCode();
4646cdf0e10cSrcweir sal_uLong nPos = (sal_uLong)-1;
4647cdf0e10cSrcweir
4648cdf0e10cSrcweir if( cChar && IsMnemonicChar( cChar, nPos ) )
4649cdf0e10cSrcweir {
4650cdf0e10cSrcweir // shortcut is clicked
4651cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pNewCursor = GetEntry( nPos );
4652cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pOldCursor = pCursor;
4653cdf0e10cSrcweir if( pNewCursor != pOldCursor )
4654cdf0e10cSrcweir {
4655cdf0e10cSrcweir SetCursor_Impl( pOldCursor, pNewCursor, sal_False, sal_False, sal_False );
4656cdf0e10cSrcweir
4657cdf0e10cSrcweir if( pNewCursor != NULL )
4658cdf0e10cSrcweir {
4659cdf0e10cSrcweir pHdlEntry = pNewCursor;
4660cdf0e10cSrcweir pCurHighlightFrame = pHdlEntry;
4661cdf0e10cSrcweir pView->ClickIcon();
4662cdf0e10cSrcweir pCurHighlightFrame = NULL;
4663cdf0e10cSrcweir }
4664cdf0e10cSrcweir }
4665cdf0e10cSrcweir bRet = sal_True;
4666cdf0e10cSrcweir }
4667cdf0e10cSrcweir
4668cdf0e10cSrcweir return bRet;
4669cdf0e10cSrcweir }
4670cdf0e10cSrcweir
4671cdf0e10cSrcweir // -----------------------------------------------------------------------
4672cdf0e10cSrcweir
CallEventListeners(sal_uLong nEvent,void * pData)4673cdf0e10cSrcweir void SvxIconChoiceCtrl_Impl::CallEventListeners( sal_uLong nEvent, void* pData )
4674cdf0e10cSrcweir {
4675cdf0e10cSrcweir pView->CallImplEventListeners( nEvent, pData );
4676cdf0e10cSrcweir }
4677cdf0e10cSrcweir
4678cdf0e10cSrcweir
4679