xref: /trunk/main/svtools/source/contnr/imivctl.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _IMPICNVW_HXX
29 #define _IMPICNVW_HXX
30 
31 #ifndef _VIRDEV_HXX
32 #include <vcl/virdev.hxx>
33 #endif
34 #ifndef _SCRBAR_HXX
35 #include <vcl/scrbar.hxx>
36 #endif
37 #include <vcl/timer.hxx>
38 #include <vcl/seleng.hxx>
39 #include <tools/debug.hxx>
40 #include "svtaccessiblefactory.hxx"
41 
42 #include <limits.h>
43 
44 #include <svtools/ivctrl.hxx>
45 #include <svl/svarray.hxx>
46 
47 class IcnCursor_Impl;
48 class SvtIconChoiceCtrl;
49 class SvxIconChoiceCtrlEntry;
50 class IcnViewEdit_Impl;
51 class IcnGridMap_Impl;
52 
53 ///////////////////////////////////////////////////////////////////////////////
54 //
55 // some defines
56 //
57 #define PAINTFLAG_HOR_CENTERED  0x0001
58 #define PAINTFLAG_VER_CENTERED  0x0002
59 
60 #define F_VER_SBARSIZE_WITH_HBAR        0x0001
61 #define F_HOR_SBARSIZE_WITH_VBAR        0x0002
62 #define F_PAINTED                       0x0004  // sal_True nach erstem Paint
63 #define F_ADD_MODE                      0x0008
64 #define F_SELECTING_RECT                0x0020
65 #define F_DOWN_CTRL                     0x0080
66 #define F_DOWN_DESELECT                 0x0100
67 #define F_START_EDITTIMER_IN_MOUSEUP    0x0400
68 #define F_MOVED_ENTRIES                 0x0800
69 #define F_ENTRYLISTPOS_VALID            0x1000
70 #define F_CLEARING_SELECTION            0x2000
71 #define F_ARRANGING                     0x4000
72 
73 // alle Angaben in Pixel
74 // Abstaende von Fensterraendern
75 #define LROFFS_WINBORDER            4
76 #define TBOFFS_WINBORDER            4
77 // fuer das Bounding-Rectangle
78 #define LROFFS_BOUND                2
79 #define TBOFFS_BOUND                2
80 // Abstand Fokusrechteck - Icon
81 #define LROFFS_ICON                 2
82 #define TBOFFS_ICON                 2
83 // Abstaende Icon - Text
84 #define HOR_DIST_BMP_STRING         3
85 #define VER_DIST_BMP_STRING         3
86 // Breitenoffset Highlight-Rect bei Text
87 #define LROFFS_TEXT                 2
88 
89 #define DEFAULT_MAX_VIRT_WIDTH  200
90 #define DEFAULT_MAX_VIRT_HEIGHT 200
91 
92 #define VIEWMODE_MASK   (WB_ICON | WB_SMALLICON | WB_DETAILS)
93 
94 ///////////////////////////////////////////////////////////////////////////////
95 //
96 //
97 //
98 enum IcnViewFieldType
99 {
100     IcnViewFieldTypeDontknow = 0,
101     IcnViewFieldTypeImage = 1,
102     IcnViewFieldTypeText = 2
103 };
104 
105 ///////////////////////////////////////////////////////////////////////////////
106 //
107 // Data about the focus of entries
108 //
109 struct LocalFocus
110 {
111     sal_Bool        bOn;
112     Rectangle   aRect;
113     Color       aPenColor;
114 
115     LocalFocus() { bOn = sal_False; }
116 };
117 
118 ///////////////////////////////////////////////////////////////////////////////
119 //
120 // Entry-List
121 //
122 class EntryList_Impl : public List
123 {
124 private:
125 
126     using List::Replace;
127 
128     SvxIconChoiceCtrl_Impl*         _pOwner;
129 
130     void                    Removed_Impl( SvxIconChoiceCtrlEntry* pEntry );
131 
132 public:
133                             EntryList_Impl(
134                                 SvxIconChoiceCtrl_Impl*,
135                                 sal_uInt16 _nInitSize = 1024,
136                                 sal_uInt16 _nReSize = 1024 );
137                             EntryList_Impl(
138                                 SvxIconChoiceCtrl_Impl*,
139                                 sal_uInt16 _nBlockSize,
140                                 sal_uInt16 _nInitSize,
141                                 sal_uInt16 _nReSize );
142                             ~EntryList_Impl();
143 
144     void                    Clear();
145     void                    Insert( SvxIconChoiceCtrlEntry* pEntry, sal_uLong nPos );
146     SvxIconChoiceCtrlEntry*         Remove( sal_uLong nPos );
147     void                    Remove( SvxIconChoiceCtrlEntry* pEntry );
148 };
149 
150 
151 ///////////////////////////////////////////////////////////////////////////////
152 //
153 // Implementation-class of IconChoiceCtrl
154 //
155 class SvxIconChoiceCtrl_Impl
156 {
157     friend class IcnCursor_Impl;
158     friend class EntryList_Impl;
159     friend class IcnGridMap_Impl;
160 
161     sal_Bool            bChooseWithCursor;
162     EntryList_Impl  aEntries;
163     ScrollBar       aVerSBar;
164     ScrollBar       aHorSBar;
165     ScrollBarBox    aScrBarBox;
166     Rectangle       aCurSelectionRect;
167     SvPtrarr        aSelectedRectList;
168     Timer           aEditTimer;                 // fuer Inplace-Editieren
169     Timer           aAutoArrangeTimer;
170     Timer           aDocRectChangedTimer;
171     Timer           aVisRectChangedTimer;
172     Timer           aCallSelectHdlTimer;
173     Size            aVirtOutputSize;
174     Size            aImageSize;
175     Size            aDefaultTextSize;
176     Size            aOutputSize; // Pixel
177     Point           aDDLastEntryPos;
178     Point           aDDLastRectPos;
179     Point           aDDPaintOffs;
180     Point           aDDStartPos;
181     SvtIconChoiceCtrl*      pView;
182     IcnCursor_Impl* pImpCursor;
183     IcnGridMap_Impl* pGridMap;
184     long            nMaxVirtWidth;  // max. Breite aVirtOutputSize bei ALIGN_TOP
185     long            nMaxVirtHeight; // max. Hoehe aVirtOutputSize bei ALIGN_LEFT
186     List*           pZOrderList;
187     SvPtrarr*       pColumns;
188     IcnViewEdit_Impl* pEdit;
189     WinBits         nWinBits;
190     long            nMaxBoundHeight;            // Hoehe des hoechsten BoundRects
191     sal_uInt16          nFlags;
192     sal_uInt16          nCurTextDrawFlags;
193     sal_uLong           nUserEventAdjustScrBars;
194     sal_uLong           nUserEventShowCursor;
195     SvxIconChoiceCtrlEntry* pCurHighlightFrame;
196     sal_Bool            bHighlightFramePressed;
197     SvxIconChoiceCtrlEntry* pHead;                      // Eintrag oben links
198     SvxIconChoiceCtrlEntry* pCursor;
199     SvxIconChoiceCtrlEntry* pPrevDropTarget;
200     SvxIconChoiceCtrlEntry* pHdlEntry;
201     SvxIconChoiceCtrlEntry* pDDRefEntry;
202     VirtualDevice*  pDDDev;
203     VirtualDevice*  pDDBufDev;
204     VirtualDevice*  pDDTempDev;
205     VirtualDevice*  pEntryPaintDev;
206     SvxIconChoiceCtrlEntry* pAnchor;                    // fuer Selektion
207     LocalFocus      aFocus;                             // Data for focusrect
208     ::svt::AccessibleFactoryAccess aAccFactory;
209 
210     List*           pDraggedSelection;
211     SvxIconChoiceCtrlEntry* pCurEditedEntry;
212     SvxIconChoiceCtrlTextMode eTextMode;
213     SelectionMode   eSelectionMode;
214     sal_uLong           nSelectionCount;
215     SvxIconChoiceCtrlPositionMode ePositionMode;
216     sal_Bool            bBoundRectsDirty;
217     sal_Bool            bUpdateMode;
218     sal_Bool            bEntryEditingEnabled;
219     sal_Bool            bInDragDrop;
220 
221     void            ShowCursor( sal_Bool bShow );
222 
223     void            ImpArrange( sal_Bool bKeepPredecessors = sal_False );
224     void            AdjustVirtSize( const Rectangle& );
225     void            ResetVirtSize();
226     void            CheckScrollBars();
227 
228                     DECL_LINK( ScrollUpDownHdl, ScrollBar * );
229                     DECL_LINK( ScrollLeftRightHdl, ScrollBar * );
230                     DECL_LINK( EditTimeoutHdl, Timer* );
231                     DECL_LINK( UserEventHdl, void* );
232                     DECL_LINK( EndScrollHdl, void* );
233                     DECL_LINK( AutoArrangeHdl, void* );
234                     DECL_LINK( DocRectChangedHdl, void* );
235                     DECL_LINK( VisRectChangedHdl, void* );
236                     DECL_LINK( CallSelectHdlHdl, void* );
237 
238     void            AdjustScrollBars( sal_Bool bVirtSizeGrowedOnly = sal_False);
239     void            PositionScrollBars( long nRealWidth, long nRealHeight );
240     long            GetScrollBarPageSize( long nVisibleRange ) const { return ((nVisibleRange*75)/100); }
241     long            GetScrollBarLineSize() const { return nMaxBoundHeight / 2; }
242     sal_Bool            HandleScrollCommand( const CommandEvent& rCmd );
243     void            ToDocPos( Point& rPosPixel ) { rPosPixel -= pView->GetMapMode().GetOrigin(); }
244     void            InitScrollBarBox();
245     SvxIconChoiceCtrlEntry* FindNewCursor();
246     void            ToggleSelection( SvxIconChoiceCtrlEntry* );
247     void            DeselectAllBut( SvxIconChoiceCtrlEntry*, sal_Bool bPaintSync=sal_False );
248     void            Center( SvxIconChoiceCtrlEntry* pEntry ) const;
249     void            StopEditTimer() { aEditTimer.Stop(); }
250     void            StartEditTimer() { aEditTimer.Start(); }
251     void            ImpHideDDIcon();
252     void            CallSelectHandler( SvxIconChoiceCtrlEntry* );
253     void            SelectRect(
254                         SvxIconChoiceCtrlEntry* pEntry1,
255                         SvxIconChoiceCtrlEntry* pEntry2,
256                         sal_Bool bAdd = sal_True,
257                         SvPtrarr* pOtherRects = 0 );
258 
259     void            SelectRange(
260                         SvxIconChoiceCtrlEntry* pStart,
261                         SvxIconChoiceCtrlEntry* pEnd,
262                         sal_Bool bAdd = sal_True );
263 
264     void            AddSelectedRect( const Rectangle& );
265     void            AddSelectedRect(
266                         SvxIconChoiceCtrlEntry* pEntry1,
267                         SvxIconChoiceCtrlEntry* pEntry2 );
268 
269     void            ClearSelectedRectList();
270     void            ClearColumnList();
271     Rectangle       CalcMaxTextRect( const SvxIconChoiceCtrlEntry* pEntry ) const;
272 
273     void            ClipAtVirtOutRect( Rectangle& rRect ) const;
274     void            AdjustAtGrid( const SvPtrarr& rRow, SvxIconChoiceCtrlEntry* pStart=0 );
275     Point           AdjustAtGrid(
276                         const Rectangle& rCenterRect, // "Schwerpunkt" des Objekts (typ. Bmp-Rect)
277                         const Rectangle& rBoundRect ) const;
278     sal_uLong           GetPredecessorGrid( const Point& rDocPos) const;
279 
280     void            InitPredecessors();
281     void            ClearPredecessors();
282 
283     sal_Bool            CheckVerScrollBar();
284     sal_Bool            CheckHorScrollBar();
285     void            CancelUserEvents();
286     void            EntrySelected( SvxIconChoiceCtrlEntry* pEntry, sal_Bool bSelect,
287                         sal_Bool bSyncPaint );
288     void            SaveSelection( List** );
289     void            RepaintEntries( sal_uInt16 nEntryFlagsMask );
290     void            SetListPositions();
291     void            SetDefaultTextSize();
292     sal_Bool            IsAutoArrange() const {
293                         return (sal_Bool)(ePositionMode == IcnViewPositionModeAutoArrange); }
294     sal_Bool            IsAutoAdjust() const {
295                         return (sal_Bool)(ePositionMode == IcnViewPositionModeAutoAdjust); }
296     void            DocRectChanged() { aDocRectChangedTimer.Start(); }
297     void            VisRectChanged() { aVisRectChangedTimer.Start(); }
298     void            SetOrigin( const Point&, sal_Bool bDoNotUpdateWallpaper = sal_False );
299 
300                     DECL_LINK( TextEditEndedHdl, IcnViewEdit_Impl* );
301 
302     void ShowFocus ( Rectangle& rRect );
303     void HideFocus ();
304     void DrawFocusRect ( OutputDevice* pOut );
305 
306     sal_Bool            IsMnemonicChar( sal_Unicode cChar, sal_uLong& rPos ) const;
307 
308 public:
309 
310     long            nGridDX,
311                     nGridDY;
312     long            nHorSBarHeight,
313                     nVerSBarWidth;
314 
315                     SvxIconChoiceCtrl_Impl( SvtIconChoiceCtrl* pView, WinBits nWinStyle );
316                     ~SvxIconChoiceCtrl_Impl();
317 
318     sal_Bool            SetChoiceWithCursor ( sal_Bool bDo = sal_True ) { sal_Bool bOld=bChooseWithCursor; bChooseWithCursor = bDo; return bOld; }
319     void            Clear( sal_Bool bInCtor = sal_False );
320     void            SetStyle( WinBits nWinStyle );
321     WinBits         GetStyle() const { return nWinBits; }
322     void            InsertEntry( SvxIconChoiceCtrlEntry*, sal_uLong nPos, const Point* pPos=0 );
323     void            CreateAutoMnemonics( MnemonicGenerator* _pGenerator = NULL );
324     void            RemoveEntry( SvxIconChoiceCtrlEntry* pEntry );
325     void            FontModified();
326     void            SelectAll( sal_Bool bSelect = sal_True, sal_Bool bPaint = sal_True );
327     void            SelectEntry(
328                         SvxIconChoiceCtrlEntry*,
329                         sal_Bool bSelect,
330                         sal_Bool bCallHdl = sal_True,
331                         sal_Bool bAddToSelection = sal_False,
332                         sal_Bool bSyncPaint = sal_False );
333     void            Paint( const Rectangle& rRect );
334     sal_Bool            MouseButtonDown( const MouseEvent& );
335     sal_Bool            MouseButtonUp( const MouseEvent& );
336     sal_Bool            MouseMove( const MouseEvent&);
337     sal_Bool            RequestHelp( const HelpEvent& rHEvt );
338     void            SetCursor_Impl(
339                         SvxIconChoiceCtrlEntry* pOldCursor,
340                         SvxIconChoiceCtrlEntry* pNewCursor,
341                         sal_Bool bMod1,
342                         sal_Bool bShift,
343                         sal_Bool bPaintSync = sal_False);
344     sal_Bool            KeyInput( const KeyEvent& );
345     void            Resize();
346     void            GetFocus();
347     void            LoseFocus();
348     void            SetUpdateMode( sal_Bool bUpdate );
349     sal_Bool            GetUpdateMode() const { return bUpdateMode; }
350     void            PaintEntry( SvxIconChoiceCtrlEntry* pEntry, sal_Bool bIsBackgroundPainted=sal_False );
351     void            PaintEntry(
352                         SvxIconChoiceCtrlEntry*,
353                         const Point&,
354                         OutputDevice* pOut = 0,
355                         sal_Bool bIsBackgroundPainted = sal_False);
356     void            PaintEntryVirtOutDev( SvxIconChoiceCtrlEntry* );
357 
358     void            SetEntryPos(
359                         SvxIconChoiceCtrlEntry* pEntry,
360                         const Point& rPos,
361                         sal_Bool bAdjustRow = sal_False,
362                         sal_Bool bCheckScrollBars = sal_False,
363                         sal_Bool bKeepGridMap = sal_False );
364 
365     void            InvalidateEntry( SvxIconChoiceCtrlEntry* );
366     IcnViewFieldType    GetItem( SvxIconChoiceCtrlEntry*, const Point& rAbsPos );
367 
368     void            SetNoSelection();
369 
370     SvxIconChoiceCtrlEntry* GetCurEntry() const { return pCursor; }
371     void            SetCursor(
372                         SvxIconChoiceCtrlEntry*,
373                         // sal_True == bei Single-Selection die Sel. mitfuehren
374                         sal_Bool bSyncSingleSelection = sal_True,
375                         sal_Bool bShowFocusAsync = sal_False );
376 
377     SvxIconChoiceCtrlEntry* GetEntry( const Point& rDocPos, sal_Bool bHit = sal_False );
378     SvxIconChoiceCtrlEntry* GetNextEntry( const Point& rDocPos, SvxIconChoiceCtrlEntry* pCurEntry );
379     SvxIconChoiceCtrlEntry* GetPrevEntry( const Point& rDocPos, SvxIconChoiceCtrlEntry* pCurEntry  );
380 
381     Point           GetEntryPos( SvxIconChoiceCtrlEntry* );
382     void            MakeEntryVisible( SvxIconChoiceCtrlEntry* pEntry, sal_Bool bBound = sal_True );
383 
384     void            Arrange(sal_Bool bKeepPredecessors = sal_False, long nSetMaxVirtWidth =0, long nSetMaxVirtHeight =0 );
385 
386     Rectangle       CalcFocusRect( SvxIconChoiceCtrlEntry* );
387     Rectangle       CalcBmpRect( SvxIconChoiceCtrlEntry*, const Point* pPos = 0 );
388     Rectangle       CalcTextRect(
389                         SvxIconChoiceCtrlEntry*,
390                         const Point* pPos = 0,
391                         sal_Bool bForInplaceEdit = sal_False,
392                         const String* pStr = 0 );
393 
394     long            CalcBoundingWidth( SvxIconChoiceCtrlEntry* ) const;
395     long            CalcBoundingHeight( SvxIconChoiceCtrlEntry* ) const;
396     Size            CalcBoundingSize( SvxIconChoiceCtrlEntry* ) const;
397     void            FindBoundingRect( SvxIconChoiceCtrlEntry* pEntry );
398     void            SetBoundingRect_Impl(
399                         SvxIconChoiceCtrlEntry* pEntry,
400                         const Point& rPos,
401                         const Size& rBoundingSize );
402     // berechnet alle BoundRects neu
403     void            RecalcAllBoundingRects();
404     // berechnet alle ungueltigen BoundRects neu
405     void            RecalcAllBoundingRectsSmart();
406     const Rectangle&  GetEntryBoundRect( SvxIconChoiceCtrlEntry* );
407     void            InvalidateBoundingRect( SvxIconChoiceCtrlEntry* );
408     void            InvalidateBoundingRect( Rectangle& rRect ) { rRect.Right() = LONG_MAX; bBoundRectsDirty = sal_True; }
409     sal_Bool            IsBoundingRectValid( const Rectangle& rRect ) const { return (sal_Bool)( rRect.Right() != LONG_MAX ); }
410 
411     void            PaintEmphasis(
412                         const Rectangle& rRect1,
413                         const Rectangle& rRect2,
414                         sal_Bool bSelected,
415                         sal_Bool bDropTarget,
416                         sal_Bool bCursored,
417                         OutputDevice* pOut,
418                         sal_Bool bIsBackgroundPainted = sal_False);
419 
420     void            PaintItem(
421                         const Rectangle& rRect,
422                         IcnViewFieldType eItem,
423                         SvxIconChoiceCtrlEntry* pEntry,
424                         sal_uInt16 nPaintFlags,
425                         OutputDevice* pOut,
426                         const String* pStr = 0,
427                         ::vcl::ControlLayoutData* _pLayoutData = NULL );
428 
429     // berechnet alle BoundingRects neu, wenn bMustRecalcBoundingRects == sal_True
430     void            CheckBoundingRects() { if (bBoundRectsDirty) RecalcAllBoundingRectsSmart(); }
431     // berechnet alle invalidierten BoundingRects neu
432     void            UpdateBoundingRects();
433     void            ShowTargetEmphasis( SvxIconChoiceCtrlEntry* pEntry, sal_Bool bShow );
434     void            PrepareCommandEvent( const CommandEvent& );
435     void            Command( const CommandEvent& rCEvt );
436     void            ToTop( SvxIconChoiceCtrlEntry* );
437 
438     sal_uLong           GetSelectionCount() const;
439     void            SetGrid( const Size& );
440     Size            GetMinGrid() const;
441     sal_uLong           GetGridCount(
442                         const Size& rSize,
443                         sal_Bool bCheckScrBars,
444                         sal_Bool bSmartScrBar ) const;
445     void            Scroll( long nDeltaX, long nDeltaY, sal_Bool bScrollBar = sal_False );
446     const Size&     GetItemSize( SvxIconChoiceCtrlEntry*, IcnViewFieldType ) const;
447 
448     void            HideDDIcon();
449     void            ShowDDIcon( SvxIconChoiceCtrlEntry* pRefEntry, const Point& rPos );
450     void            HideShowDDIcon(
451                         SvxIconChoiceCtrlEntry* pRefEntry,
452                         const Point& rPos );
453 
454     sal_Bool            IsOver(
455                         SvPtrarr* pSelectedRectList,
456                         const Rectangle& rEntryBoundRect ) const;
457 
458     void            SelectRect(
459                         const Rectangle&,
460                         sal_Bool bAdd = sal_True,
461                         SvPtrarr* pOtherRects = 0 );
462 
463     void            CalcScrollOffsets(
464                         const Point& rRefPosPixel,
465                         long& rX,
466                         long& rY,
467                         sal_Bool bDragDrop = sal_False,
468                         sal_uInt16 nBorderWidth = 10 );
469 
470     sal_Bool            IsTextHit( SvxIconChoiceCtrlEntry* pEntry, const Point& rDocPos );
471     void            MakeVisible(
472                         const Rectangle& rDocPos,
473                         sal_Bool bInScrollBarEvent=sal_False,
474                         sal_Bool bCallRectChangedHdl = sal_True );
475 
476     void            AdjustEntryAtGrid( SvxIconChoiceCtrlEntry* pStart = 0 );
477     void            SetEntryTextMode( SvxIconChoiceCtrlTextMode, SvxIconChoiceCtrlEntry* pEntry = 0 );
478     SvxIconChoiceCtrlTextMode GetTextMode( const SvxIconChoiceCtrlEntry* pEntry = 0 ) const;
479     void            ShowEntryFocusRect( const SvxIconChoiceCtrlEntry* pEntry );
480     void            EnableEntryEditing( sal_Bool bEnable ) { bEntryEditingEnabled = bEnable; }
481     sal_Bool            IsEntryEditingEnabled() const { return bEntryEditingEnabled; }
482     sal_Bool            IsEntryEditing() const { return (sal_Bool)(pCurEditedEntry!=0); }
483     void            EditEntry( SvxIconChoiceCtrlEntry* pEntry );
484     void            StopEntryEditing( sal_Bool bCancel );
485     void            LockEntryPos( SvxIconChoiceCtrlEntry* pEntry, sal_Bool bLock );
486     sal_uLong           GetEntryCount() const { return aEntries.Count(); }
487     SvxIconChoiceCtrlEntry* GetEntry( sal_uLong nPos ) const { return (SvxIconChoiceCtrlEntry*)aEntries.GetObject(nPos); }
488     SvxIconChoiceCtrlEntry* GetFirstSelectedEntry( sal_uLong& ) const;
489     SvxIconChoiceCtrlEntry* GetNextSelectedEntry( sal_uLong& ) const;
490     SvxIconChoiceCtrlEntry* GetHdlEntry() const { return pHdlEntry; }
491     void            SetHdlEntry( SvxIconChoiceCtrlEntry* pEntry ) { pHdlEntry = pEntry; }
492 
493     SvxIconChoiceCtrlTextMode GetEntryTextModeSmart( const SvxIconChoiceCtrlEntry* pEntry ) const;
494     void            SetSelectionMode( SelectionMode eMode ) { eSelectionMode=eMode; }
495     SelectionMode   GetSelectionMode() const { return eSelectionMode; }
496     sal_Bool            AreEntriesMoved() const { return (sal_Bool)((nFlags & F_MOVED_ENTRIES)!=0); }
497     void            SetEntriesMoved( sal_Bool bMoved )
498                     {
499                         if( bMoved ) nFlags |= F_MOVED_ENTRIES;
500                         else nFlags &= ~(F_MOVED_ENTRIES);
501                     }
502     sal_uLong           GetEntryListPos( SvxIconChoiceCtrlEntry* ) const;
503     void            SetEntryListPos( SvxIconChoiceCtrlEntry* pEntry, sal_uLong nNewPos );
504     void            SetEntryImageSize( const Size& rSize ) { aImageSize = rSize; }
505     void            SetEntryFlags( SvxIconChoiceCtrlEntry* pEntry, sal_uInt16 nFlags );
506     SvxIconChoiceCtrlEntry* GoLeftRight( SvxIconChoiceCtrlEntry*, sal_Bool bRight );
507     SvxIconChoiceCtrlEntry* GoUpDown( SvxIconChoiceCtrlEntry*, sal_Bool bDown );
508     void            InitSettings();
509     Rectangle       GetOutputRect() const;
510 
511     sal_Bool            ArePredecessorsSet() const { return (sal_Bool)(pHead != 0); }
512     SvxIconChoiceCtrlEntry* GetPredecessorHead() const { return pHead; }
513     void            SetEntryPredecessor(SvxIconChoiceCtrlEntry* pEntry,SvxIconChoiceCtrlEntry* pPredecessor);
514     sal_Bool            GetEntryPredecessor(SvxIconChoiceCtrlEntry* pEntry,SvxIconChoiceCtrlEntry** ppPredecessor);
515     // liefert gueltige Ergebnisse nur im AutoArrange-Modus!
516     SvxIconChoiceCtrlEntry* FindEntryPredecessor( SvxIconChoiceCtrlEntry* pEntry, const Point& );
517 
518     void            SetPositionMode( SvxIconChoiceCtrlPositionMode );
519     SvxIconChoiceCtrlPositionMode GetPositionMode() const { return ePositionMode;}
520 
521     void            Flush();
522     void            SetColumn( sal_uInt16 nIndex, const SvxIconChoiceCtrlColumnInfo& );
523     const SvxIconChoiceCtrlColumnInfo* GetColumn( sal_uInt16 nIndex ) const;
524     const SvxIconChoiceCtrlColumnInfo* GetItemColumn( sal_uInt16 nSubItem, long& rLeft ) const;
525 
526     Rectangle       GetDocumentRect() const { return Rectangle( Point(), aVirtOutputSize ); }
527     Rectangle       GetVisibleRect() const { return GetOutputRect(); }
528 
529     void            SetEntryHighlightFrame( SvxIconChoiceCtrlEntry* pEntry,sal_Bool bKeepHighlightFlags=sal_False );
530     void            HideEntryHighlightFrame();
531     void            DrawHighlightFrame( OutputDevice* pOut,
532                         const Rectangle& rBmpRect, sal_Bool bHide );
533     void            StopSelectTimer() { aCallSelectHdlTimer.Stop(); }
534     void            Tracking( const TrackingEvent& rTEvt );
535     Point           GetPopupMenuPosPixel() const;
536 
537     sal_Bool            HandleShortCutKey( const KeyEvent& rKeyEvent );
538 
539     void            CallEventListeners( sal_uLong nEvent, void* pData = NULL );
540 
541     inline ::svt::IAccessibleFactory&
542         GetAccessibleFactory() { return aAccFactory.getFactory(); }
543 };
544 
545 // ----------------------------------------------------------------------------------------------
546 
547 class IcnCursor_Impl
548 {
549     SvxIconChoiceCtrl_Impl* pView;
550     SvPtrarr*       pColumns;
551     SvPtrarr*       pRows;
552     long            nCols;
553     long            nRows;
554     short           nDeltaWidth;
555     short           nDeltaHeight;
556     SvxIconChoiceCtrlEntry* pCurEntry;
557     void            SetDeltas();
558     void            ImplCreate();
559     void            Create() {  if( !pColumns ) ImplCreate(); }
560 
561     sal_uInt16          GetSortListPos( SvPtrarr* pList, long nValue, int bVertical);
562     SvxIconChoiceCtrlEntry* SearchCol(sal_uInt16 nCol,sal_uInt16 nTop,sal_uInt16 nBottom,sal_uInt16 nPref,
563                         sal_Bool bDown, sal_Bool bSimple );
564 
565     SvxIconChoiceCtrlEntry* SearchRow(sal_uInt16 nRow,sal_uInt16 nRight,sal_uInt16 nLeft,sal_uInt16 nPref,
566                         sal_Bool bRight, sal_Bool bSimple );
567 
568 public:
569                     IcnCursor_Impl( SvxIconChoiceCtrl_Impl* pOwner );
570                     ~IcnCursor_Impl();
571     void            Clear();
572 
573     // fuer Cursortravelling usw.
574     SvxIconChoiceCtrlEntry* GoLeftRight( SvxIconChoiceCtrlEntry*, sal_Bool bRight );
575     SvxIconChoiceCtrlEntry* GoUpDown( SvxIconChoiceCtrlEntry*, sal_Bool bDown );
576     SvxIconChoiceCtrlEntry* GoPageUpDown( SvxIconChoiceCtrlEntry*, sal_Bool bDown );
577 
578     // Erzeugt fuer jede Zeile (Hoehe=nGridDY) eine nach BoundRect.Left()
579     // sortierte Liste der Eintraege, die in ihr stehen. Eine Liste kann
580     // leer sein. Die Listen gehen in das Eigentum des Rufenden ueber und
581     // muessen mit DestroyGridAdjustData geloescht werden
582     void            CreateGridAjustData( SvPtrarr& pLists, SvxIconChoiceCtrlEntry* pRow=0);
583     static void     DestroyGridAdjustData( SvPtrarr& rLists );
584 };
585 
586 // ----------------------------------------------------------------------------------------------
587 
588 typedef sal_uLong GridId;
589 
590 #define GRID_NOT_FOUND  ((GridId)ULONG_MAX)
591 
592 class IcnGridMap_Impl
593 {
594     Rectangle       _aLastOccupiedGrid;
595     SvxIconChoiceCtrl_Impl* _pView;
596     sal_Bool*           _pGridMap;
597     sal_uInt16          _nGridCols, _nGridRows;
598 
599     void            Expand();
600     void            Create_Impl();
601     void            Create() { if(!_pGridMap) Create_Impl(); }
602 
603     void            GetMinMapSize( sal_uInt16& rDX, sal_uInt16& rDY ) const;
604 
605 public:
606                     IcnGridMap_Impl(SvxIconChoiceCtrl_Impl* pView);
607                     ~IcnGridMap_Impl();
608 
609     void            Clear();
610 
611     GridId          GetGrid( const Point& rDocPos, sal_Bool* pbClipped = 0 );
612     GridId          GetGrid( sal_uInt16 nGridX, sal_uInt16 nGridY );
613     GridId          GetUnoccupiedGrid( sal_Bool bOccupyFound=sal_True );
614 
615     void            OccupyGrids( const Rectangle&, sal_Bool bOccupy = sal_True );
616     void            OccupyGrids( const SvxIconChoiceCtrlEntry*, sal_Bool bOccupy = sal_True );
617     void            OccupyGrid( GridId nId, sal_Bool bOccupy = sal_True )
618                     {
619                         DBG_ASSERT(!_pGridMap || nId<(sal_uLong)(_nGridCols*_nGridRows),"OccupyGrid: Bad GridId");
620                         if(_pGridMap && nId < (sal_uLong)(_nGridCols *_nGridRows) )
621                             _pGridMap[ nId ] = bOccupy;
622                     }
623 
624     Rectangle       GetGridRect( GridId );
625     void            GetGridCoord( GridId, sal_uInt16& rGridX, sal_uInt16& rGridY );
626     static sal_uLong    GetGridCount( const Size& rSizePixel, sal_uInt16 nGridWidth, sal_uInt16 nGridHeight );
627 
628     void            OutputSizeChanged();
629 };
630 
631 
632 
633 
634 
635 #endif
636 
637 
638