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