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