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