1*01aa44aaSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*01aa44aaSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*01aa44aaSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*01aa44aaSAndrew Rist * distributed with this work for additional information 6*01aa44aaSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*01aa44aaSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*01aa44aaSAndrew Rist * "License"); you may not use this file except in compliance 9*01aa44aaSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*01aa44aaSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*01aa44aaSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*01aa44aaSAndrew Rist * software distributed under the License is distributed on an 15*01aa44aaSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*01aa44aaSAndrew Rist * KIND, either express or implied. See the License for the 17*01aa44aaSAndrew Rist * specific language governing permissions and limitations 18*01aa44aaSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*01aa44aaSAndrew Rist *************************************************************/ 21*01aa44aaSAndrew Rist 22*01aa44aaSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _SVICNVW_HXX 25cdf0e10cSrcweir #define _SVICNVW_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #ifndef _IMAGE_HXX 28cdf0e10cSrcweir #include <vcl/image.hxx> 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir #include <svtools/svlbox.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir class SvImpIconView; 33cdf0e10cSrcweir class SvLBoxEntry; 34cdf0e10cSrcweir class SvLBoxItem; 35cdf0e10cSrcweir class SvLBoxString; 36cdf0e10cSrcweir class SvLBoxContextBmp; 37cdf0e10cSrcweir class SvPtrarr; 38cdf0e10cSrcweir 39cdf0e10cSrcweir #define WB_ICON 0x0001 40cdf0e10cSrcweir #define WB_NAME 0x0002 41cdf0e10cSrcweir #define WB_TEXT 0x0004 42cdf0e10cSrcweir #define WB_FLOW 0x0008 43cdf0e10cSrcweir 44cdf0e10cSrcweir #define ICNVW_FLAG_POS_LOCKED 0x0001 45cdf0e10cSrcweir #define ICNVW_FLAG_USER1 0x1000 46cdf0e10cSrcweir #define ICNVW_FLAG_USER2 0x2000 47cdf0e10cSrcweir #define ICNVW_FLAG_USER3 0x4000 48cdf0e10cSrcweir #define ICNVW_FLAG_USER4 0x8000 49cdf0e10cSrcweir 50cdf0e10cSrcweir enum SvIconViewTextMode 51cdf0e10cSrcweir { 52cdf0e10cSrcweir ShowTextFull = 1, 53cdf0e10cSrcweir ShowTextShort, 54cdf0e10cSrcweir ShowTextSmart, // not implemented 55cdf0e10cSrcweir ShowTextDontKnow // nur fuer Eintraege (->Einstellung der View 56cdf0e10cSrcweir // wird genommen) 57cdf0e10cSrcweir }; 58cdf0e10cSrcweir 59cdf0e10cSrcweir class SvIcnVwDataEntry : public SvViewDataEntry 60cdf0e10cSrcweir { 61cdf0e10cSrcweir friend class SvImpIconView; 62cdf0e10cSrcweir sal_uInt16 nIcnVwFlags; 63cdf0e10cSrcweir SvIconViewTextMode eTextMode; 64cdf0e10cSrcweir public: 65cdf0e10cSrcweir Rectangle aRect; // Bounding-Rect des Entries 66cdf0e10cSrcweir Rectangle aGridRect; // gesetzt im Grid-Modus 67cdf0e10cSrcweir Size aTextSize; // nur gesetzt im Grid-Modus 68cdf0e10cSrcweir sal_uInt16 nX,nY; // fuer Tastatursteuerung 69cdf0e10cSrcweir SvIcnVwDataEntry(); 70cdf0e10cSrcweir virtual ~SvIcnVwDataEntry(); 71cdf0e10cSrcweir IsEntryPosLocked() const72cdf0e10cSrcweir sal_Bool IsEntryPosLocked() const { return (sal_Bool)((nIcnVwFlags & ICNVW_FLAG_POS_LOCKED) !=0); } ClearVwFlags(sal_uInt16 nMask)73cdf0e10cSrcweir void ClearVwFlags( sal_uInt16 nMask ) { nIcnVwFlags &= (~nMask); } SetVwFlags(sal_uInt16 nMask)74cdf0e10cSrcweir void SetVwFlags( sal_uInt16 nMask ) { nIcnVwFlags |= nMask; } GetVwFlags() const75cdf0e10cSrcweir sal_uInt16 GetVwFlags() const { return nIcnVwFlags; } GetTextMode() const76cdf0e10cSrcweir SvIconViewTextMode GetTextMode() const { return eTextMode; } 77cdf0e10cSrcweir }; 78cdf0e10cSrcweir 79cdf0e10cSrcweir #define SV_LISTBOX_ID_ICONVIEW 2 80cdf0e10cSrcweir 81cdf0e10cSrcweir class SvIconView : public SvLBox 82cdf0e10cSrcweir { 83cdf0e10cSrcweir friend class SvImpIconView; 84cdf0e10cSrcweir 85cdf0e10cSrcweir SvImpIconView* pImp; 86cdf0e10cSrcweir Image aCollapsedEntryBmp; 87cdf0e10cSrcweir Image aExpandedEntryBmp; 88cdf0e10cSrcweir sal_uInt16 nIcnVwFlags; 89cdf0e10cSrcweir void SetModel( SvLBoxTreeList* ); 90cdf0e10cSrcweir 91cdf0e10cSrcweir protected: 92cdf0e10cSrcweir 93cdf0e10cSrcweir using SvLBox::CreateEntry; 94cdf0e10cSrcweir SvLBoxEntry* CreateEntry( const XubString&, const Image&, const Image&); 95cdf0e10cSrcweir void ViewDataInitialized( SvLBoxEntry* ); 96cdf0e10cSrcweir virtual SvViewData* CreateViewData( SvListEntry* ); 97cdf0e10cSrcweir virtual void InitViewData( SvViewData* pData, SvListEntry* pEntry ); 98cdf0e10cSrcweir 99cdf0e10cSrcweir void EditingRequest(SvLBoxEntry*,SvLBoxItem*,const Point& ); 100cdf0e10cSrcweir void EditedText( const XubString& ); 101cdf0e10cSrcweir void EditItemText( SvLBoxEntry*,SvLBoxItem*,const Selection& ); 102cdf0e10cSrcweir SvLBoxEntry* pCurEdEntry; 103cdf0e10cSrcweir SvLBoxItem* pCurEdItem; 104cdf0e10cSrcweir 105cdf0e10cSrcweir virtual void WriteDragServerInfo( const Point&, SvLBoxDDInfo* ); 106cdf0e10cSrcweir virtual void ReadDragServerInfo( const Point&, SvLBoxDDInfo* ); 107cdf0e10cSrcweir virtual void Command( const CommandEvent& rCEvt ); 108cdf0e10cSrcweir virtual void PreparePaint( SvLBoxEntry* ); 109cdf0e10cSrcweir virtual void StateChanged( StateChangedType nStateChange ); 110cdf0e10cSrcweir 111cdf0e10cSrcweir public: 112cdf0e10cSrcweir 113cdf0e10cSrcweir SvIconView( Window* pParent,WinBits nWinStyle=0 ); 114cdf0e10cSrcweir SvIconView( Window* pParent,const ResId& rResId ); 115cdf0e10cSrcweir ~SvIconView(); 116cdf0e10cSrcweir 117cdf0e10cSrcweir void DisconnectFromModel(); 118cdf0e10cSrcweir 119cdf0e10cSrcweir SvLBoxEntry* InsertEntry( const XubString& rText, SvLBoxEntry* pParent = 0, 120cdf0e10cSrcweir sal_Bool bChildsOnDemand = sal_False, 121cdf0e10cSrcweir sal_uLong nPos=LIST_APPEND ); 122cdf0e10cSrcweir 123cdf0e10cSrcweir SvLBoxEntry* InsertEntry( const XubString& rText, 124cdf0e10cSrcweir const Image& rExpandedEntryBmp, 125cdf0e10cSrcweir const Image& rCollapsedEntryBmp, 126cdf0e10cSrcweir SvLBoxEntry* pParent = 0, 127cdf0e10cSrcweir sal_Bool bChildsOnDemand = sal_False, 128cdf0e10cSrcweir sal_uLong nPos = LIST_APPEND ); 129cdf0e10cSrcweir GetDefaultExpandedEntryBmp() const130cdf0e10cSrcweir const Image& GetDefaultExpandedEntryBmp() const { return aExpandedEntryBmp;} GetDefaultCollapsedEntryBmp() const131cdf0e10cSrcweir const Image& GetDefaultCollapsedEntryBmp() const { return aCollapsedEntryBmp;} SetDefaultExpandedEntryBmp(const Image & rBmp)132cdf0e10cSrcweir void SetDefaultExpandedEntryBmp( const Image& rBmp) { aExpandedEntryBmp=rBmp;} SetDefaultCollapsedEntryBmp(const Image & rBmp)133cdf0e10cSrcweir void SetDefaultCollapsedEntryBmp( const Image& rBmp ) { aCollapsedEntryBmp=rBmp;} 134cdf0e10cSrcweir 135cdf0e10cSrcweir void SetEntryText(SvLBoxEntry*, const XubString& ); 136cdf0e10cSrcweir void SetExpandedEntryBmp(SvLBoxEntry*, const Image& ); 137cdf0e10cSrcweir void SetCollapsedEntryBmp(SvLBoxEntry*, const Image& ); 138cdf0e10cSrcweir 139cdf0e10cSrcweir XubString GetEntryText(SvLBoxEntry*) const; 140cdf0e10cSrcweir Image GetExpandedEntryBmp(SvLBoxEntry*) const; 141cdf0e10cSrcweir Image GetCollapsedEntryBmp(SvLBoxEntry*) const; 142cdf0e10cSrcweir 143cdf0e10cSrcweir virtual SvLBoxEntry* CloneEntry( SvLBoxEntry* pSource ); 144cdf0e10cSrcweir 145cdf0e10cSrcweir virtual sal_uInt16 IsA(); 146cdf0e10cSrcweir 147cdf0e10cSrcweir virtual void RequestingChilds( SvLBoxEntry* pParent ); 148cdf0e10cSrcweir 149cdf0e10cSrcweir virtual void Paint( const Rectangle& rRect ); 150cdf0e10cSrcweir virtual void MouseButtonDown( const MouseEvent& rMEvt ); 151cdf0e10cSrcweir virtual void MouseButtonUp( const MouseEvent& rMEvt ); 152cdf0e10cSrcweir virtual void MouseMove( const MouseEvent& rMEvt ); 153cdf0e10cSrcweir virtual void KeyInput( const KeyEvent& rKEvt ); 154cdf0e10cSrcweir virtual void Resize(); 155cdf0e10cSrcweir virtual void GetFocus(); 156cdf0e10cSrcweir virtual void LoseFocus(); 157cdf0e10cSrcweir void SetUpdateMode( sal_Bool ); 158cdf0e10cSrcweir 159cdf0e10cSrcweir using SvListView::SetModel; 160cdf0e10cSrcweir virtual void SetModel( SvLBoxTreeList*, SvLBoxEntry* pParent ); 161cdf0e10cSrcweir virtual void ModelHasCleared(); 162cdf0e10cSrcweir virtual void ModelHasInserted( SvListEntry* pEntry ); 163cdf0e10cSrcweir virtual void ModelHasInsertedTree( SvListEntry* pEntry ); 164cdf0e10cSrcweir virtual void ModelIsMoving(SvListEntry* pSource, 165cdf0e10cSrcweir SvListEntry* pTargetParent, sal_uLong nChildPos ); 166cdf0e10cSrcweir virtual void ModelHasMoved(SvListEntry* pSource ); 167cdf0e10cSrcweir virtual void ModelIsRemoving( SvListEntry* pEntry ); 168cdf0e10cSrcweir virtual void ModelHasRemoved( SvListEntry* pEntry ); 169cdf0e10cSrcweir virtual void ModelHasEntryInvalidated( SvListEntry* pEntry ); 170cdf0e10cSrcweir 171cdf0e10cSrcweir virtual void ShowTargetEmphasis( SvLBoxEntry*, sal_Bool bShow ); 172cdf0e10cSrcweir using Window::GetDropTarget; 173cdf0e10cSrcweir virtual SvLBoxEntry* GetDropTarget( const Point& ); 174cdf0e10cSrcweir virtual Region GetDragRegion() const; 175cdf0e10cSrcweir // NotifyMoving/Copying ueberladen, da wir bei GetDropTarget 176cdf0e10cSrcweir // einen "magic pointer" zurueckgeben, falls in einen leeren 177cdf0e10cSrcweir // Bereich auf der IconView gedroppt wird. 178cdf0e10cSrcweir virtual sal_Bool NotifyMoving( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry, 179cdf0e10cSrcweir SvLBoxEntry*& rpNewParent, sal_uLong& rNewChildPos); 180cdf0e10cSrcweir virtual sal_Bool NotifyCopying( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry, 181cdf0e10cSrcweir SvLBoxEntry*& rpNewParent, sal_uLong& rNewChildPos); 182cdf0e10cSrcweir 183cdf0e10cSrcweir // gibt TopLeft des BoundingRects zurueck 184cdf0e10cSrcweir // Konvertierung in Fensterposition: MapMode.Origin addieren 185cdf0e10cSrcweir Point GetEntryPosition( SvLBoxEntry* ) const; 186cdf0e10cSrcweir void SetEntryPosition( SvLBoxEntry*, const Point& rDocPos); 187cdf0e10cSrcweir void SetEntryPosition( SvLBoxEntry*, const Point& rDocPos, 188cdf0e10cSrcweir sal_Bool bAdjustAtGrid ); 189cdf0e10cSrcweir 190cdf0e10cSrcweir void SetFont( const Font& rFont ); 191cdf0e10cSrcweir void SetDefaultFont(); 192cdf0e10cSrcweir 193cdf0e10cSrcweir using SvLBox::GetEntry; 194cdf0e10cSrcweir SvLBoxEntry* GetEntry( const Point& rPixPos, sal_Bool ) const; 195cdf0e10cSrcweir // Gibt den naechsten ueber pCurEntry liegenden Eintrag (ZOrder) 196cdf0e10cSrcweir SvLBoxEntry* GetNextEntry( const Point& rPixPos, SvLBoxEntry* pCurEntry, sal_Bool ) const; 197cdf0e10cSrcweir // Gibt den naechsten unter pCurEntry liegenden Eintrag (ZOrder) 198cdf0e10cSrcweir SvLBoxEntry* GetPrevEntry( const Point& rPixPos, SvLBoxEntry* pCurEntry, sal_Bool ) const; 199cdf0e10cSrcweir 200cdf0e10cSrcweir SvLBoxEntry* GetEntryFromLogicPos( const Point& rDocPos ) const; 201cdf0e10cSrcweir 202cdf0e10cSrcweir virtual void PaintEntry( SvLBoxEntry* ); 203cdf0e10cSrcweir virtual void PaintEntry( SvLBoxEntry*, const Point& rDocPos ); 204cdf0e10cSrcweir Rectangle GetFocusRect( SvLBoxEntry* ); 205cdf0e10cSrcweir void InvalidateEntry( SvLBoxEntry* ); 206cdf0e10cSrcweir void MakeVisible( SvLBoxEntry* ); 207cdf0e10cSrcweir 208cdf0e10cSrcweir void SetDragDropMode( DragDropMode ); 209cdf0e10cSrcweir void SetSelectionMode( SelectionMode ); 210cdf0e10cSrcweir 211cdf0e10cSrcweir using SvListView::Select; 212cdf0e10cSrcweir sal_Bool Select( SvLBoxEntry* pEntry, sal_Bool bSelect=sal_True ); 213cdf0e10cSrcweir void SelectAll( sal_Bool bSelect, sal_Bool bPaint=sal_True ); 214cdf0e10cSrcweir virtual void SetCurEntry( SvLBoxEntry* _pEntry ); 215cdf0e10cSrcweir virtual SvLBoxEntry* 216cdf0e10cSrcweir GetCurEntry() const; 217cdf0e10cSrcweir 218cdf0e10cSrcweir // logische Koordinaten 219cdf0e10cSrcweir void SelectRect( 220cdf0e10cSrcweir const Rectangle& rRect, 221cdf0e10cSrcweir sal_Bool bAdd = sal_False, 222cdf0e10cSrcweir // die Schnittmenge mit rRect wird invertiert 223cdf0e10cSrcweir // wird bei bAdd == sal_False ignoriert 224cdf0e10cSrcweir SvPtrarr* pOtherRects = 0, 225cdf0e10cSrcweir short nBorderOffs = -5 ); 226cdf0e10cSrcweir sal_uLong GetSelectionCount() const; 227cdf0e10cSrcweir 228cdf0e10cSrcweir virtual void Arrange(); 229cdf0e10cSrcweir void SetSpaceBetweenEntries( long nHor, long Ver ); 230cdf0e10cSrcweir long GetHorSpaceBetweenEntries(); 231cdf0e10cSrcweir long GetVerSpaceBetweenEntries(); 232cdf0e10cSrcweir 233cdf0e10cSrcweir void EnableInplaceEditing( sal_Bool bEnable ); 234cdf0e10cSrcweir void EditEntry( SvLBoxEntry* pEntry = 0 ); 235cdf0e10cSrcweir virtual sal_Bool EditingEntry( SvLBoxEntry* pEntry, Selection& ); 236cdf0e10cSrcweir virtual sal_Bool EditedEntry( SvLBoxEntry*, const XubString& rNewText ); 237cdf0e10cSrcweir 238cdf0e10cSrcweir void SetCurParent( SvLBoxEntry* pNewParent ); 239cdf0e10cSrcweir SvLBoxEntry* GetCurParent() const; 240cdf0e10cSrcweir 241cdf0e10cSrcweir virtual void ModelNotification( sal_uInt16 nActionId, SvListEntry* pEntry1, 242cdf0e10cSrcweir SvListEntry* pEntry2, sal_uLong nPos ); 243cdf0e10cSrcweir 244cdf0e10cSrcweir // 0,0: Grid-Modus ausschalten 245cdf0e10cSrcweir void SetGrid( long nDX, long nDY ); 246cdf0e10cSrcweir 247cdf0e10cSrcweir // nDeltaY < 0 : View bewegt sich auf dem Doc nach oben 248cdf0e10cSrcweir // nDeltaY > 0 : View bewegt sich auf dem Doc nach unten 249cdf0e10cSrcweir // nDeltaX < 0 : View bewegt sich auf dem Doc nach links 250cdf0e10cSrcweir // nDeltaX > 0 : View bewegt sich auf dem Doc nach rechts 251cdf0e10cSrcweir using Window::Scroll; 252cdf0e10cSrcweir virtual void Scroll( long nDeltaX, long nDeltaY, sal_uInt16 nFlags = 0 ); 253cdf0e10cSrcweir 254cdf0e10cSrcweir virtual void PrepareCommandEvent( const CommandEvent& ); 255cdf0e10cSrcweir virtual void StartDrag( sal_Int8 nAction, const Point& ); 256cdf0e10cSrcweir virtual void DragFinished( sal_Int8 ); 257cdf0e10cSrcweir virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ); 258cdf0e10cSrcweir using SvLBox::ExecuteDrop; 259cdf0e10cSrcweir virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ); 260cdf0e10cSrcweir 261cdf0e10cSrcweir void ShowDDIcon( SvLBoxEntry* pRefEntry, const Point& rPos ); 262cdf0e10cSrcweir void HideDDIcon(); 263cdf0e10cSrcweir void HideShowDDIcon( SvLBoxEntry* pRefEntry, const Point& rPos ); 264cdf0e10cSrcweir 265cdf0e10cSrcweir // fuers Scrollen beim D&D 266cdf0e10cSrcweir void CalcScrollOffsets( 267cdf0e10cSrcweir const Point& rRefPosPixel, 268cdf0e10cSrcweir long& rScrollX, 269cdf0e10cSrcweir long& rScrollY, 270cdf0e10cSrcweir sal_Bool bInDragDrop = sal_False, 271cdf0e10cSrcweir sal_uInt16 nBorderWidth = 10 ); 272cdf0e10cSrcweir 273cdf0e10cSrcweir using Window::EndTracking; 274cdf0e10cSrcweir void EndTracking(); 275cdf0e10cSrcweir void AdjustAtGrid( SvLBoxEntry* pEntry = 0 ); 276cdf0e10cSrcweir void LockEntryPos( SvLBoxEntry* pEntry, sal_Bool bLock = sal_True ); 277cdf0e10cSrcweir sal_Bool IsEntryPosLocked( const SvLBoxEntry* pEntry ) const; 278cdf0e10cSrcweir 279cdf0e10cSrcweir void SetTextMode( SvIconViewTextMode, SvLBoxEntry* pEntry = 0 ); 280cdf0e10cSrcweir SvIconViewTextMode GetTextMode( const SvLBoxEntry* pEntry = 0 ) const; 281cdf0e10cSrcweir 282cdf0e10cSrcweir void ShowFocusRect( const SvLBoxEntry* pEntry ); 283cdf0e10cSrcweir }; 284cdf0e10cSrcweir 285cdf0e10cSrcweir #endif 286