GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / svtools / source / contnr / imivctl.hxx
blob6d73828684a65a6bec359f0c6eeb90a133320ffd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SVTOOLS_SOURCE_CONTNR_IMIVCTL_HXX
21 #define INCLUDED_SVTOOLS_SOURCE_CONTNR_IMIVCTL_HXX
23 #include <vcl/virdev.hxx>
24 #include <vcl/scrbar.hxx>
25 #include <vcl/timer.hxx>
26 #include <vcl/seleng.hxx>
27 #include <tools/debug.hxx>
28 #include "svtaccessiblefactory.hxx"
30 #include <limits.h>
32 #include <svtools/ivctrl.hxx>
33 #include <boost/ptr_container/ptr_map.hpp>
35 class IcnCursor_Impl;
36 class SvtIconChoiceCtrl;
37 class SvxIconChoiceCtrlEntry;
38 class IcnViewEdit_Impl;
39 class IcnGridMap_Impl;
41 ///////////////////////////////////////////////////////////////////////////////
43 // some defines
45 #define PAINTFLAG_HOR_CENTERED 0x0001
46 #define PAINTFLAG_VER_CENTERED 0x0002
48 #define F_VER_SBARSIZE_WITH_HBAR 0x0001
49 #define F_HOR_SBARSIZE_WITH_VBAR 0x0002
50 #define F_PAINTED 0x0004 // sal_True after first paint
51 #define F_ADD_MODE 0x0008
52 #define F_SELECTING_RECT 0x0020
53 #define F_DOWN_CTRL 0x0080
54 #define F_DOWN_DESELECT 0x0100
55 #define F_START_EDITTIMER_IN_MOUSEUP 0x0400
56 #define F_MOVED_ENTRIES 0x0800
57 #define F_ENTRYLISTPOS_VALID 0x1000
58 #define F_CLEARING_SELECTION 0x2000
59 #define F_ARRANGING 0x4000
61 // unit = pixels
62 // distances from window borders
63 #define LROFFS_WINBORDER 4
64 #define TBOFFS_WINBORDER 4
65 // for the bounding rectangle
66 #define LROFFS_BOUND 2
67 #define TBOFFS_BOUND 2
68 // distance icon to text
69 #define HOR_DIST_BMP_STRING 3
70 #define VER_DIST_BMP_STRING 3
71 // width offset of highlight rectangle for Text
72 #define LROFFS_TEXT 2
74 #define DEFAULT_MAX_VIRT_WIDTH 200
75 #define DEFAULT_MAX_VIRT_HEIGHT 200
77 #define VIEWMODE_MASK (WB_ICON | WB_SMALLICON | WB_DETAILS)
79 ///////////////////////////////////////////////////////////////////////////////
83 enum IcnViewFieldType
85 IcnViewFieldTypeDontknow = 0,
86 IcnViewFieldTypeImage = 1,
87 IcnViewFieldTypeText = 2
90 ///////////////////////////////////////////////////////////////////////////////
92 // Data about the focus of entries
94 struct LocalFocus
96 sal_Bool bOn;
97 Rectangle aRect;
98 Color aPenColor;
100 LocalFocus() { bOn = sal_False; }
103 ///////////////////////////////////////////////////////////////////////////////
105 // Entry-List
107 typedef ::std::vector< SvxIconChoiceCtrlEntry* > SvxIconChoiceCtrlEntryList_impl;
109 class EntryList_Impl
111 private:
112 SvxIconChoiceCtrlEntryList_impl maIconChoiceCtrlEntryList;
113 SvxIconChoiceCtrl_Impl* _pOwner;
115 public:
116 EntryList_Impl( SvxIconChoiceCtrl_Impl* );
117 ~EntryList_Impl();
119 void clear();
121 size_t size()
123 return maIconChoiceCtrlEntryList.size();
125 size_t size() const
127 return maIconChoiceCtrlEntryList.size();
130 SvxIconChoiceCtrlEntry* operator[]( size_t nPos )
132 return ( nPos < maIconChoiceCtrlEntryList.size() )
133 ? maIconChoiceCtrlEntryList[ nPos ]
134 : NULL;
136 SvxIconChoiceCtrlEntry* operator[]( size_t nPos ) const
138 return ( nPos < maIconChoiceCtrlEntryList.size() )
139 ? maIconChoiceCtrlEntryList[ nPos ]
140 : NULL;
142 void insert( size_t nPos, SvxIconChoiceCtrlEntry* pEntry );
146 ///////////////////////////////////////////////////////////////////////////////
148 // Implementation-class of IconChoiceCtrl
151 typedef boost::ptr_map<sal_uInt16, SvxIconChoiceCtrlColumnInfo> SvxIconChoiceCtrlColumnInfoMap;
152 typedef std::vector<SvxIconChoiceCtrlEntry*> SvxIconChoiceCtrlEntryPtrVec;
154 class SvxIconChoiceCtrl_Impl
156 friend class IcnCursor_Impl;
157 friend class EntryList_Impl;
158 friend class IcnGridMap_Impl;
160 sal_Bool bChooseWithCursor;
161 EntryList_Impl aEntries;
162 ScrollBar aVerSBar;
163 ScrollBar aHorSBar;
164 ScrollBarBox aScrBarBox;
165 Rectangle aCurSelectionRect;
166 std::vector<Rectangle*> aSelectedRectList;
167 Timer aEditTimer; // for editing in place
168 Timer aAutoArrangeTimer;
169 Timer aDocRectChangedTimer;
170 Timer aVisRectChangedTimer;
171 Timer aCallSelectHdlTimer;
172 Size aVirtOutputSize;
173 Size aImageSize;
174 Size aDefaultTextSize;
175 Size aOutputSize; // Pixel
176 Point aDDLastEntryPos;
177 Point aDDLastRectPos;
178 Point aDDPaintOffs;
179 Point aDDStartPos;
180 SvtIconChoiceCtrl* pView;
181 IcnCursor_Impl* pImpCursor;
182 IcnGridMap_Impl* pGridMap;
183 long nMaxVirtWidth; // max. width aVirtOutputSize for ALIGN_TOP
184 long nMaxVirtHeight; // max. height aVirtOutputSize for ALIGN_LEFT
185 SvxIconChoiceCtrlEntryList_impl* pZOrderList;
186 SvxIconChoiceCtrlColumnInfoMap* pColumns;
187 IcnViewEdit_Impl* pEdit;
188 WinBits nWinBits;
189 long nMaxBoundHeight; // height of highest BoundRects
190 sal_uInt16 nFlags;
191 sal_uInt16 nCurTextDrawFlags;
192 sal_uLong nUserEventAdjustScrBars;
193 sal_uLong nUserEventShowCursor;
194 SvxIconChoiceCtrlEntry* pCurHighlightFrame;
195 sal_Bool bHighlightFramePressed;
196 SvxIconChoiceCtrlEntry* pHead; // top left entry
197 SvxIconChoiceCtrlEntry* pCursor;
198 SvxIconChoiceCtrlEntry* pPrevDropTarget;
199 SvxIconChoiceCtrlEntry* pHdlEntry;
200 SvxIconChoiceCtrlEntry* pDDRefEntry;
201 VirtualDevice* pDDDev;
202 VirtualDevice* pDDBufDev;
203 VirtualDevice* pDDTempDev;
204 VirtualDevice* pEntryPaintDev;
205 SvxIconChoiceCtrlEntry* pAnchor; // for selection
206 LocalFocus aFocus; // Data for focusrect
207 ::svt::AccessibleFactoryAccess aAccFactory;
209 SvxIconChoiceCtrlEntry* pCurEditedEntry;
210 SvxIconChoiceCtrlTextMode eTextMode;
211 SelectionMode eSelectionMode;
212 sal_uLong nSelectionCount;
213 SvxIconChoiceCtrlPositionMode ePositionMode;
214 sal_Bool bBoundRectsDirty;
215 sal_Bool bUpdateMode;
216 sal_Bool bEntryEditingEnabled;
218 void ShowCursor( sal_Bool bShow );
220 void ImpArrange( sal_Bool bKeepPredecessors = sal_False );
221 void AdjustVirtSize( const Rectangle& );
222 void ResetVirtSize();
223 void CheckScrollBars();
225 DECL_LINK( ScrollUpDownHdl, ScrollBar * );
226 DECL_LINK( ScrollLeftRightHdl, ScrollBar * );
227 DECL_LINK(EditTimeoutHdl, void *);
228 DECL_LINK( UserEventHdl, void* );
229 DECL_LINK( EndScrollHdl, void* );
230 DECL_LINK( AutoArrangeHdl, void* );
231 DECL_LINK( DocRectChangedHdl, void* );
232 DECL_LINK( VisRectChangedHdl, void* );
233 DECL_LINK( CallSelectHdlHdl, void* );
235 void AdjustScrollBars( sal_Bool bVirtSizeGrowedOnly = sal_False);
236 void PositionScrollBars( long nRealWidth, long nRealHeight );
237 long GetScrollBarPageSize( long nVisibleRange ) const
239 return ((nVisibleRange*75)/100);
241 long GetScrollBarLineSize() const
243 return nMaxBoundHeight / 2;
245 sal_Bool HandleScrollCommand( const CommandEvent& rCmd );
246 void ToDocPos( Point& rPosPixel )
248 rPosPixel -= pView->GetMapMode().GetOrigin();
250 void InitScrollBarBox();
251 void ToggleSelection( SvxIconChoiceCtrlEntry* );
252 void DeselectAllBut( SvxIconChoiceCtrlEntry*, sal_Bool bPaintSync=sal_False );
253 void Center( SvxIconChoiceCtrlEntry* pEntry ) const;
254 void StopEditTimer() { aEditTimer.Stop(); }
255 void StartEditTimer() { aEditTimer.Start(); }
256 void ImpHideDDIcon();
257 void CallSelectHandler( SvxIconChoiceCtrlEntry* );
258 void SelectRect(
259 SvxIconChoiceCtrlEntry* pEntry1,
260 SvxIconChoiceCtrlEntry* pEntry2,
261 sal_Bool bAdd = sal_True,
262 std::vector<Rectangle*>* pOtherRects = 0
265 void SelectRange(
266 SvxIconChoiceCtrlEntry* pStart,
267 SvxIconChoiceCtrlEntry* pEnd,
268 sal_Bool bAdd = sal_True
271 void AddSelectedRect( const Rectangle& );
272 void AddSelectedRect(
273 SvxIconChoiceCtrlEntry* pEntry1,
274 SvxIconChoiceCtrlEntry* pEntry2
277 void ClearSelectedRectList();
278 void ClearColumnList();
279 Rectangle CalcMaxTextRect( const SvxIconChoiceCtrlEntry* pEntry ) const;
281 void ClipAtVirtOutRect( Rectangle& rRect ) const;
282 void AdjustAtGrid( const SvxIconChoiceCtrlEntryPtrVec& rRow, SvxIconChoiceCtrlEntry* pStart=0 );
283 Point AdjustAtGrid(
284 const Rectangle& rCenterRect, // balance point of object (typically Bmp-Rect)
285 const Rectangle& rBoundRect
286 ) const;
287 sal_uLong GetPredecessorGrid( const Point& rDocPos) const;
289 void InitPredecessors();
290 void ClearPredecessors();
292 sal_Bool CheckVerScrollBar();
293 sal_Bool CheckHorScrollBar();
294 void CancelUserEvents();
295 void EntrySelected(
296 SvxIconChoiceCtrlEntry* pEntry,
297 sal_Bool bSelect,
298 sal_Bool bSyncPaint
300 void RepaintEntries( sal_uInt16 nEntryFlagsMask );
301 void SetListPositions();
302 void SetDefaultTextSize();
303 sal_Bool IsAutoArrange() const
305 return (sal_Bool)(ePositionMode == IcnViewPositionModeAutoArrange);
307 sal_Bool IsAutoAdjust() const
309 return (sal_Bool)(ePositionMode == IcnViewPositionModeAutoAdjust);
311 void DocRectChanged() { aDocRectChangedTimer.Start(); }
312 void VisRectChanged() { aVisRectChangedTimer.Start(); }
313 void SetOrigin( const Point&, sal_Bool bDoNotUpdateWallpaper = sal_False );
315 DECL_LINK(TextEditEndedHdl, void *);
317 void ShowFocus ( Rectangle& rRect );
318 void DrawFocusRect ( OutputDevice* pOut );
320 sal_Bool IsMnemonicChar( sal_Unicode cChar, sal_uLong& rPos ) const;
322 public:
324 long nGridDX;
325 long nGridDY;
326 long nHorSBarHeight;
327 long nVerSBarWidth;
329 SvxIconChoiceCtrl_Impl( SvtIconChoiceCtrl* pView, WinBits nWinStyle );
330 ~SvxIconChoiceCtrl_Impl();
332 sal_Bool SetChoiceWithCursor ( sal_Bool bDo = sal_True ) { sal_Bool bOld=bChooseWithCursor; bChooseWithCursor = bDo; return bOld; }
333 void Clear( sal_Bool bInCtor = sal_False );
334 void SetStyle( WinBits nWinStyle );
335 WinBits GetStyle() const { return nWinBits; }
336 void InsertEntry( SvxIconChoiceCtrlEntry*, size_t nPos, const Point* pPos=0 );
337 void CreateAutoMnemonics( MnemonicGenerator* _pGenerator = NULL );
338 void FontModified();
339 void SelectAll( sal_Bool bSelect = sal_True, sal_Bool bPaint = sal_True );
340 void SelectEntry(
341 SvxIconChoiceCtrlEntry*,
342 sal_Bool bSelect,
343 sal_Bool bCallHdl = sal_True,
344 sal_Bool bAddToSelection = sal_False,
345 sal_Bool bSyncPaint = sal_False
347 void Paint( const Rectangle& rRect );
348 sal_Bool MouseButtonDown( const MouseEvent& );
349 sal_Bool MouseButtonUp( const MouseEvent& );
350 sal_Bool MouseMove( const MouseEvent&);
351 sal_Bool RequestHelp( const HelpEvent& rHEvt );
352 void SetCursor_Impl(
353 SvxIconChoiceCtrlEntry* pOldCursor,
354 SvxIconChoiceCtrlEntry* pNewCursor,
355 sal_Bool bMod1,
356 sal_Bool bShift,
357 sal_Bool bPaintSync = sal_False
359 sal_Bool KeyInput( const KeyEvent& );
360 void Resize();
361 void GetFocus();
362 void LoseFocus();
363 void SetUpdateMode( sal_Bool bUpdate );
364 sal_Bool GetUpdateMode() const { return bUpdateMode; }
365 void PaintEntry(
366 SvxIconChoiceCtrlEntry* pEntry,
367 sal_Bool bIsBackgroundPainted=sal_False
369 void PaintEntry(
370 SvxIconChoiceCtrlEntry*,
371 const Point&,
372 OutputDevice* pOut = 0,
373 sal_Bool bIsBackgroundPainted = sal_False
375 void PaintEntryVirtOutDev( SvxIconChoiceCtrlEntry* );
377 void SetEntryPos(
378 SvxIconChoiceCtrlEntry* pEntry,
379 const Point& rPos,
380 sal_Bool bAdjustRow = sal_False,
381 sal_Bool bCheckScrollBars = sal_False,
382 sal_Bool bKeepGridMap = sal_False
385 void InvalidateEntry( SvxIconChoiceCtrlEntry* );
387 void SetNoSelection();
389 SvxIconChoiceCtrlEntry* GetCurEntry() const { return pCursor; }
390 void SetCursor(
391 SvxIconChoiceCtrlEntry*,
392 // sal_True == carry selection when single-selecting
393 sal_Bool bSyncSingleSelection = sal_True,
394 sal_Bool bShowFocusAsync = sal_False
397 SvxIconChoiceCtrlEntry* GetEntry( const Point& rDocPos, sal_Bool bHit = sal_False );
399 Point GetEntryPos( SvxIconChoiceCtrlEntry* );
400 void MakeEntryVisible( SvxIconChoiceCtrlEntry* pEntry, sal_Bool bBound = sal_True );
402 void Arrange(
403 sal_Bool bKeepPredecessors = sal_False,
404 long nSetMaxVirtWidth =0,
405 long nSetMaxVirtHeight =0
408 Rectangle CalcFocusRect( SvxIconChoiceCtrlEntry* );
409 Rectangle CalcBmpRect( SvxIconChoiceCtrlEntry*, const Point* pPos = 0 );
410 Rectangle CalcTextRect(
411 SvxIconChoiceCtrlEntry*,
412 const Point* pPos = 0,
413 sal_Bool bForInplaceEdit = sal_False,
414 const OUString* pStr = 0
417 long CalcBoundingWidth( SvxIconChoiceCtrlEntry* ) const;
418 long CalcBoundingHeight( SvxIconChoiceCtrlEntry* ) const;
419 Size CalcBoundingSize( SvxIconChoiceCtrlEntry* ) const;
420 void FindBoundingRect( SvxIconChoiceCtrlEntry* pEntry );
421 void SetBoundingRect_Impl(
422 SvxIconChoiceCtrlEntry* pEntry,
423 const Point& rPos,
424 const Size& rBoundingSize
426 // recalculates all invalid BoundRects
427 void RecalcAllBoundingRectsSmart();
428 const Rectangle& GetEntryBoundRect( SvxIconChoiceCtrlEntry* );
429 void InvalidateBoundingRect( Rectangle& rRect )
431 rRect.Right() = LONG_MAX;
432 bBoundRectsDirty = sal_True;
434 sal_Bool IsBoundingRectValid( const Rectangle& rRect ) const { return (sal_Bool)( rRect.Right() != LONG_MAX ); }
436 void PaintEmphasis(
437 const Rectangle& rRect1,
438 const Rectangle& rRect2,
439 sal_Bool bSelected,
440 sal_Bool bDropTarget,
441 sal_Bool bCursored,
442 OutputDevice* pOut,
443 sal_Bool bIsBackgroundPainted = sal_False
446 void PaintItem(
447 const Rectangle& rRect,
448 IcnViewFieldType eItem,
449 SvxIconChoiceCtrlEntry* pEntry,
450 sal_uInt16 nPaintFlags,
451 OutputDevice* pOut,
452 const OUString* pStr = 0,
453 ::vcl::ControlLayoutData* _pLayoutData = NULL
456 // recalculates all BoundingRects if bMustRecalcBoundingRects == sal_True
457 void CheckBoundingRects() { if (bBoundRectsDirty) RecalcAllBoundingRectsSmart(); }
458 // recalculates all invalidated BoundingRects
459 void ShowTargetEmphasis( SvxIconChoiceCtrlEntry* pEntry, sal_Bool bShow );
460 void Command( const CommandEvent& rCEvt );
461 void ToTop( SvxIconChoiceCtrlEntry* );
463 sal_uLong GetSelectionCount() const;
464 void SetGrid( const Size& );
465 Size GetMinGrid() const;
466 void Scroll( long nDeltaX, long nDeltaY, sal_Bool bScrollBar = sal_False );
467 const Size& GetItemSize( SvxIconChoiceCtrlEntry*, IcnViewFieldType ) const;
469 void HideDDIcon();
471 bool IsOver(
472 std::vector<Rectangle*>* pSelectedRectList,
473 const Rectangle& rEntryBoundRect
474 ) const;
476 void SelectRect(
477 const Rectangle&,
478 bool bAdd = true,
479 std::vector<Rectangle*>* pOtherRects = 0
482 sal_Bool IsTextHit( SvxIconChoiceCtrlEntry* pEntry, const Point& rDocPos );
483 void MakeVisible(
484 const Rectangle& rDocPos,
485 sal_Bool bInScrollBarEvent=sal_False,
486 sal_Bool bCallRectChangedHdl = sal_True
489 void AdjustEntryAtGrid( SvxIconChoiceCtrlEntry* pStart = 0 );
490 void SetEntryTextMode(
491 SvxIconChoiceCtrlTextMode,
492 SvxIconChoiceCtrlEntry* pEntry = 0
494 void EnableEntryEditing( sal_Bool bEnable ) { bEntryEditingEnabled = bEnable; }
495 sal_Bool IsEntryEditingEnabled() const { return bEntryEditingEnabled; }
496 sal_Bool IsEntryEditing() const { return (sal_Bool)(pCurEditedEntry!=0); }
497 void EditEntry( SvxIconChoiceCtrlEntry* pEntry );
498 void StopEntryEditing( sal_Bool bCancel );
499 size_t GetEntryCount() const { return aEntries.size(); }
500 SvxIconChoiceCtrlEntry* GetEntry( size_t nPos )
502 return aEntries[ nPos ];
504 SvxIconChoiceCtrlEntry* GetEntry( size_t nPos ) const
506 return aEntries[ nPos ];
508 SvxIconChoiceCtrlEntry* GetFirstSelectedEntry( sal_uLong& ) const;
509 SvxIconChoiceCtrlEntry* GetHdlEntry() const { return pHdlEntry; }
510 void SetHdlEntry( SvxIconChoiceCtrlEntry* pEntry ) { pHdlEntry = pEntry; }
512 SvxIconChoiceCtrlTextMode GetEntryTextModeSmart( const SvxIconChoiceCtrlEntry* pEntry ) const;
513 void SetSelectionMode( SelectionMode eMode ) { eSelectionMode=eMode; }
514 SelectionMode GetSelectionMode() const { return eSelectionMode; }
515 sal_Bool AreEntriesMoved() const { return (sal_Bool)((nFlags & F_MOVED_ENTRIES)!=0); }
516 void SetEntriesMoved( sal_Bool bMoved )
518 if( bMoved )
519 nFlags |= F_MOVED_ENTRIES;
520 else
521 nFlags &= ~(F_MOVED_ENTRIES);
523 sal_uLong GetEntryListPos( SvxIconChoiceCtrlEntry* ) const;
524 void SetEntryImageSize( const Size& rSize ) { aImageSize = rSize; }
525 void InitSettings();
526 Rectangle GetOutputRect() const;
528 sal_Bool ArePredecessorsSet() const { return (sal_Bool)(pHead != 0); }
529 SvxIconChoiceCtrlEntry* GetPredecessorHead() const { return pHead; }
530 void SetEntryPredecessor(SvxIconChoiceCtrlEntry* pEntry,SvxIconChoiceCtrlEntry* pPredecessor);
531 // only delivers valid results when in AutoArrange mode!
532 SvxIconChoiceCtrlEntry* FindEntryPredecessor( SvxIconChoiceCtrlEntry* pEntry, const Point& );
534 void SetPositionMode( SvxIconChoiceCtrlPositionMode );
535 SvxIconChoiceCtrlPositionMode GetPositionMode() const { return ePositionMode;}
537 void SetColumn( sal_uInt16 nIndex, const SvxIconChoiceCtrlColumnInfo& );
538 const SvxIconChoiceCtrlColumnInfo* GetColumn( sal_uInt16 nIndex ) const;
540 Rectangle GetDocumentRect() const { return Rectangle( Point(), aVirtOutputSize ); }
541 Rectangle GetVisibleRect() const { return GetOutputRect(); }
543 void SetEntryHighlightFrame(
544 SvxIconChoiceCtrlEntry* pEntry,
545 sal_Bool bKeepHighlightFlags=sal_False
547 void HideEntryHighlightFrame();
548 void DrawHighlightFrame(
549 OutputDevice* pOut,
550 const Rectangle& rBmpRect,
551 sal_Bool bHide
553 void StopSelectTimer() { aCallSelectHdlTimer.Stop(); }
555 void CallEventListeners( sal_uLong nEvent, void* pData = NULL );
557 inline ::svt::IAccessibleFactory& GetAccessibleFactory()
559 return aAccFactory.getFactory();
563 // ----------------------------------------------------------------------------------------------
565 typedef std::map<sal_uInt16, SvxIconChoiceCtrlEntryPtrVec> IconChoiceMap;
567 class IcnCursor_Impl
569 SvxIconChoiceCtrl_Impl* pView;
570 boost::scoped_ptr<IconChoiceMap> pColumns;
571 boost::scoped_ptr<IconChoiceMap> pRows;
572 long nCols;
573 long nRows;
574 short nDeltaWidth;
575 short nDeltaHeight;
576 SvxIconChoiceCtrlEntry* pCurEntry;
577 void SetDeltas();
578 void ImplCreate();
579 void Create() { if( !pColumns ) ImplCreate(); }
581 sal_uInt16 GetSortListPos(
582 SvxIconChoiceCtrlEntryPtrVec& rList,
583 long nValue,
584 int bVertical);
585 SvxIconChoiceCtrlEntry* SearchCol(
586 sal_uInt16 nCol,
587 sal_uInt16 nTop,
588 sal_uInt16 nBottom,
589 sal_uInt16 nPref,
590 bool bDown,
591 bool bSimple
594 SvxIconChoiceCtrlEntry* SearchRow(
595 sal_uInt16 nRow,
596 sal_uInt16 nRight,
597 sal_uInt16 nLeft,
598 sal_uInt16 nPref,
599 bool bRight,
600 bool bSimple
603 public:
604 IcnCursor_Impl( SvxIconChoiceCtrl_Impl* pOwner );
605 ~IcnCursor_Impl();
606 void Clear();
608 // for Cursortravelling etc.
609 SvxIconChoiceCtrlEntry* GoLeftRight( SvxIconChoiceCtrlEntry*, sal_Bool bRight );
610 SvxIconChoiceCtrlEntry* GoUpDown( SvxIconChoiceCtrlEntry*, sal_Bool bDown );
611 SvxIconChoiceCtrlEntry* GoPageUpDown( SvxIconChoiceCtrlEntry*, sal_Bool bDown );
613 // Creates a list of entries for every row (height = nGridDY) sorted by
614 // BoundRect.Left(). A list may be empty. The lists become the property of
615 // the caller and have to be deleted with DestroyGridAdjustData.
616 void CreateGridAjustData( IconChoiceMap& pLists, SvxIconChoiceCtrlEntry* pRow=0);
617 static void DestroyGridAdjustData( IconChoiceMap& rLists );
620 // ----------------------------------------------------------------------------------------------
622 typedef sal_uLong GridId;
624 #define GRID_NOT_FOUND ((GridId)ULONG_MAX)
626 class IcnGridMap_Impl
628 Rectangle _aLastOccupiedGrid;
629 SvxIconChoiceCtrl_Impl* _pView;
630 sal_Bool* _pGridMap;
631 sal_uInt16 _nGridCols, _nGridRows;
633 void Expand();
634 void Create_Impl();
635 void Create() { if(!_pGridMap) Create_Impl(); }
637 void GetMinMapSize( sal_uInt16& rDX, sal_uInt16& rDY ) const;
639 public:
640 IcnGridMap_Impl(SvxIconChoiceCtrl_Impl* pView);
641 ~IcnGridMap_Impl();
643 void Clear();
645 GridId GetGrid( const Point& rDocPos, sal_Bool* pbClipped = 0 );
646 GridId GetGrid( sal_uInt16 nGridX, sal_uInt16 nGridY );
647 GridId GetUnoccupiedGrid( sal_Bool bOccupyFound=sal_True );
649 void OccupyGrids( const SvxIconChoiceCtrlEntry*, sal_Bool bOccupy = sal_True );
650 void OccupyGrid( GridId nId, sal_Bool bOccupy = sal_True )
652 DBG_ASSERT(!_pGridMap || nId<(sal_uLong)(_nGridCols*_nGridRows),"OccupyGrid: Bad GridId");
653 if(_pGridMap && nId < (sal_uLong)(_nGridCols *_nGridRows) )
654 _pGridMap[ nId ] = bOccupy;
657 Rectangle GetGridRect( GridId );
658 void GetGridCoord( GridId, sal_uInt16& rGridX, sal_uInt16& rGridY );
659 static sal_uLong GetGridCount(
660 const Size& rSizePixel,
661 sal_uInt16 nGridWidth,
662 sal_uInt16 nGridHeight
665 void OutputSizeChanged();
668 #endif
670 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */