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 _SVLBOX_HXX
30 : : #define _SVLBOX_HXX
31 : :
32 : : #include "svtools/svtdllapi.h"
33 : :
34 : : #include <deque>
35 : :
36 : : #include <vcl/ctrl.hxx>
37 : : #include <vcl/seleng.hxx>
38 : : #include <vcl/edit.hxx>
39 : : #include <vcl/timer.hxx>
40 : : #include <vcl/accel.hxx>
41 : : #include <vcl/mnemonicengine.hxx>
42 : : #include <vcl/quickselectionengine.hxx>
43 : : #include <tools/gen.hxx>
44 : : #include <tools/contnr.hxx>
45 : : #include <svtools/treelist.hxx>
46 : : #include <svtools/transfer.hxx>
47 : :
48 : : class Application;
49 : : class SvLBox;
50 : : class SvLBoxEntry;
51 : : class SvViewDataItem;
52 : : class SvViewDataEntry;
53 : : class SvInplaceEdit2;
54 : : class SvLBoxString;
55 : : class SvLBoxButton;
56 : : class SvLBoxContextBmp;
57 : : class SvLBoxBmp;
58 : : struct SvLBoxDDInfo;
59 : :
60 : : namespace utl {
61 : : class AccessibleStateSetHelper;
62 : : }
63 : :
64 : : // *********************************************************************
65 : : // *************************** Tabulatoren *****************************
66 : : // *********************************************************************
67 : :
68 : : #define SV_LBOXTAB_DYNAMIC 0x0001 // Ausgabespalte des Items verschiebt
69 : : // sich entsprechend Child-Tiefe
70 : : #define SV_LBOXTAB_ADJUST_RIGHT 0x0002 // rechter Rand des Items am Tabulator
71 : : #define SV_LBOXTAB_ADJUST_LEFT 0x0004 // linker Rand ...
72 : : #define SV_LBOXTAB_ADJUST_CENTER 0x0008 // Item am Tabulator zentrieren
73 : : #define SV_LBOXTAB_ADJUST_NUMERIC 0x0010 // Dezimalpunkt am Tabulator (Strings)
74 : :
75 : : // wird nicht mehr unterstuetzt! Fokus richtet sich jetzt nach Selektion!
76 : : #define SV_LBOXTAB_SHOW_FOCUS 0x0020 // Fokus visualisieren
77 : :
78 : : #define SV_LBOXTAB_SHOW_SELECTION 0x0040 // Selektionszustand visualisieren
79 : : // Item muss umschliessendes Polygon
80 : : // zurueckgeben koennen (D&D-Cursor)
81 : : #define SV_LBOXTAB_EDITABLE 0x0100 // Item an Tabulator editierbar
82 : : #define SV_LBOXTAB_PUSHABLE 0x0200 // Item verhaelt sich wie ein Button
83 : : #define SV_LBOXTAB_INV_ALWAYS 0x0400 // Hintergrund immer loeschen
84 : : #define SV_LBOXTAB_FORCE 0x0800 // Default-Berechnung des ersten Tabulators
85 : : // (auf die sich Abo-Tabpage, Extras/Optionen/Anpassen,
86 : : // etc. verlassen) ausschalten. Die Position des ersten
87 : : // Tabs entspricht jetzt exakt den eingestellten Flags &
88 : : // Spaltenbreiten.
89 : :
90 : : class SvLBoxTab
91 : : {
92 : : long nPos;
93 : : void* pUserData;
94 : : public:
95 : : SvLBoxTab();
96 : : SvLBoxTab( long nPos, sal_uInt16 nFlags=SV_LBOXTAB_ADJUST_LEFT );
97 : : SvLBoxTab( const SvLBoxTab& );
98 : : ~SvLBoxTab();
99 : :
100 : : sal_uInt16 nFlags;
101 : :
102 : 752 : void SetUserData( void* pPtr ) { pUserData = pPtr; }
103 : : void* GetUserData() const { return pUserData; }
104 : 16091 : sal_Bool IsDynamic() const { return (sal_Bool)((nFlags & SV_LBOXTAB_DYNAMIC)!=0); }
105 : 0 : void SetPos( long nNewPos) { nPos = nNewPos; }
106 : 16057 : long GetPos() const { return nPos; }
107 : : long CalcOffset( long nItemLength, long nTabWidth );
108 : : // long CalcOffset( const String&, const OutputDevice& );
109 : 0 : sal_Bool IsEditable() const { return (sal_Bool)((nFlags & SV_LBOXTAB_EDITABLE)!=0); }
110 : : sal_Bool IsPushable() const { return (sal_Bool)((nFlags & SV_LBOXTAB_PUSHABLE)!=0); }
111 : : };
112 : :
113 : : // *********************************************************************
114 : : // *********************** View-abhaengige Daten ***********************
115 : : // *********************************************************************
116 : :
117 : : class SvViewDataItem
118 : : {
119 : : public:
120 : : Size aSize;
121 : : SvViewDataItem();
122 : : ~SvViewDataItem();
123 : : };
124 : :
125 : : // View-abhaengige Daten fuer einen Entry werden in virtueller Fkt.
126 : : // SvLBox::CreateViewData erzeugt. Die ViewDaten-Erzeugung von
127 : : // Items kann nicht veraendert werden (wg. Array)
128 : : class SvViewDataEntry : public SvViewData
129 : : {
130 : : public:
131 : : SvViewDataItem* pItemData; // ein Array von SvViewDataItems
132 : : sal_uInt16 nItmCnt; // Anzahl Items fuer delete-operator
133 : :
134 : : SvViewDataEntry();
135 : : virtual ~SvViewDataEntry();
136 : : };
137 : :
138 : : // *********************************************************************
139 : : // ****************************** Items ********************************
140 : : // *********************************************************************
141 : :
142 : : class SVT_DLLPUBLIC SvLBoxItem
143 : : {
144 : : public:
145 : : SvLBoxItem( SvLBoxEntry*, sal_uInt16 nFlags );
146 : : SvLBoxItem();
147 : : virtual ~SvLBoxItem();
148 : : virtual sal_uInt16 IsA() = 0;
149 : : const Size& GetSize( SvLBox* pView, SvLBoxEntry* pEntry );
150 : 11522 : const Size& GetSize( SvViewDataEntry* pData, sal_uInt16 nItemPos )
151 : : {
152 : 11522 : SvViewDataItem* pIData=pData->pItemData+nItemPos;
153 : 11522 : return pIData->aSize;
154 : : }
155 : :
156 : : virtual void Paint( const Point& rPos, SvLBox& rOutDev,
157 : : sal_uInt16 nViewDataEntryFlags,
158 : : SvLBoxEntry* pEntry ) = 0;
159 : :
160 : : virtual void InitViewData( SvLBox* pView, SvLBoxEntry* pEntry,
161 : : // wenn != 0 muss dieser Pointer benutzt werden!
162 : : // wenn == 0 muss er ueber die View geholt werden
163 : : SvViewDataItem* pViewData = 0) = 0;
164 : : virtual SvLBoxItem* Create() const = 0;
165 : : // view-abhaengige Daten werden nicht geklont
166 : : virtual void Clone( SvLBoxItem* pSource ) = 0;
167 : : };
168 : :
169 : : // Flags, die am Model haengen
170 : : #define SV_ENTRYFLAG_CHILDREN_ON_DEMAND 0x0001
171 : : #define SV_ENTRYFLAG_DISABLE_DROP 0x0002
172 : : #define SV_ENTRYFLAG_IN_USE 0x0004
173 : : // wird gesetzt, wenn RequestingChildren keine Children gestzt hat
174 : : #define SV_ENTRYFLAG_NO_NODEBMP 0x0008
175 : : // Eintrag hatte oder hat Kinder
176 : : #define SV_ENTRYFLAG_HAD_CHILDREN 0x0010
177 : :
178 : : #define SV_ENTRYFLAG_USER_FLAGS 0xF000
179 : : #define SV_ENTRYFLAG_SEMITRANSPARENT 0x8000 // draw semi-transparent entry bitmaps
180 : :
181 : : class SVT_DLLPUBLIC SvLBoxEntry : public SvListEntry
182 : : {
183 : : friend class SvLBox;
184 : :
185 : : std::vector<SvLBoxItem*> aItems;
186 : : void* pUserData;
187 : : sal_uInt16 nEntryFlags;
188 : : SVT_DLLPRIVATE void DeleteItems_Impl();
189 : : public:
190 : :
191 : : SvLBoxEntry();
192 : : virtual ~SvLBoxEntry();
193 : :
194 : 26607 : sal_uInt16 ItemCount() const { return (sal_uInt16)aItems.size(); }
195 : : // DARF NUR GERUFEN WERDEN, WENN DER EINTRAG NOCH NICHT IM MODEL
196 : : // EINGEFUEGT IST, DA SONST FUER DAS ITEM KEINE VIEW-ABHAENGIGEN
197 : : // DATEN ALLOZIERT WERDEN!
198 : : void AddItem( SvLBoxItem* pItem );
199 : : void ReplaceItem( SvLBoxItem* pNewItem, sal_uInt16 nPos );
200 : 90776 : SvLBoxItem* GetItem( sal_uInt16 nPos ) const { return aItems[nPos]; }
201 : : SvLBoxItem* GetFirstItem( sal_uInt16 nId );
202 : 28160 : sal_uInt16 GetPos( SvLBoxItem* pItem ) const
203 : : {
204 [ + - ]: 28160 : std::vector<SvLBoxItem*>::const_iterator it = std::find( aItems.begin(), aItems.end(), pItem );
205 [ + - ][ - + ]: 28160 : return it == aItems.end() ? USHRT_MAX : it - aItems.begin();
[ + - ][ + - ]
[ # # ]
206 : : }
207 : 185 : void* GetUserData() const { return pUserData; }
208 : 2408 : void SetUserData( void* pPtr ) { pUserData = pPtr; }
209 : : virtual void Clone( SvListEntry* pSource );
210 : : void EnableChildrenOnDemand( sal_Bool bEnable=sal_True );
211 : 160 : sal_Bool HasChildrenOnDemand() const { return (sal_Bool)((nEntryFlags & SV_ENTRYFLAG_CHILDREN_ON_DEMAND)!=0); }
212 : 3359 : sal_Bool HasInUseEmphasis() const { return (sal_Bool)((nEntryFlags & SV_ENTRYFLAG_IN_USE)!=0); }
213 : :
214 : 6741 : sal_uInt16 GetFlags() const { return nEntryFlags; }
215 : 10 : void SetFlags( sal_uInt16 nFlags ) { nEntryFlags = nFlags; }
216 : : };
217 : :
218 : : // *********************************************************************
219 : : // ****************************** SvLBox *******************************
220 : : // *********************************************************************
221 : :
222 : : #define WB_FORCE_SELECTION ((WinBits)0x8000)
223 : :
224 : : #define DragDropMode sal_uInt16
225 : : #define SV_DRAGDROP_NONE (DragDropMode)0x0000
226 : : #define SV_DRAGDROP_CTRL_MOVE (DragDropMode)0x0001
227 : : #define SV_DRAGDROP_CTRL_COPY (DragDropMode)0x0002
228 : : #define SV_DRAGDROP_APP_MOVE (DragDropMode)0x0004
229 : : #define SV_DRAGDROP_APP_COPY (DragDropMode)0x0008
230 : : #define SV_DRAGDROP_APP_DROP (DragDropMode)0x0010
231 : : // Entries duerfen ueber den obersten Eintrag gedroppt werden.
232 : : // Das Drop-Target ist in diesem Fall 0
233 : : #define SV_DRAGDROP_ENABLE_TOP (DragDropMode)0x0020
234 : :
235 [ - + ]: 442 : DECLARE_SVTREELIST(SvLBoxTreeList, SvLBoxEntry*)
236 : :
237 : : #define SVLISTBOX_ID_LBOX 0 // fuer SvLBox::IsA()
238 : :
239 : : #define SVLBOX_IN_EDT 0x0001
240 : : #define SVLBOX_EDT_ENABLED 0x0002
241 : : #define SVLBOX_IS_EXPANDING 0x0004
242 : : #define SVLBOX_IS_TRAVELSELECT 0x0008
243 : : #define SVLBOX_TARGEMPH_VIS 0x0010
244 : : #define SVLBOX_EDTEND_CALLED 0x0020
245 : :
246 : : class SvLBox;
247 [ + - ]: 122 : struct SvLBox_Impl
248 : : {
249 : : bool m_bIsEmptyTextAllowed;
250 : : bool m_bEntryMnemonicsEnabled;
251 : : bool m_bDoingQuickSelection;
252 : : Link* m_pLink;
253 : : ::vcl::MnemonicEngine m_aMnemonicEngine;
254 : : ::vcl::QuickSelectionEngine m_aQuickSelectionEngine;
255 : :
256 : : SvLBox_Impl( SvLBox& _rBox );
257 : : };
258 : :
259 : : class SVT_DLLPUBLIC SvLBox
260 : : :public Control
261 : : ,public SvListView
262 : : ,public DropTargetHelper
263 : : ,public DragSourceHelper
264 : : ,public ::vcl::IMnemonicEntryList
265 : : ,public ::vcl::ISearchableStringList
266 : : {
267 : : friend class SvLBoxEntry;
268 : :
269 : : DECL_DLLPRIVATE_LINK( TextEditEndedHdl_Impl, void * );
270 : : // Handler, der von TreeList zum Clonen eines Entries aufgerufen wird
271 : : DECL_DLLPRIVATE_LINK( CloneHdl_Impl, SvListEntry* );
272 : :
273 : : // handler and methods for Drag - finished handler.
274 : : // The with get GetDragFinishedHdl() get link can set on the
275 : : // TransferDataContainer. This link is a callback for the DragFinished
276 : : // call. AddBox method is called from the GetDragFinishedHdl() and the
277 : : // remove is called in link callback and in the destructor. So it can't
278 : : // called to a deleted object.
279 : : SVT_DLLPRIVATE static void AddBoxToDDList_Impl( const SvLBox& rB );
280 : : SVT_DLLPRIVATE static void RemoveBoxFromDDList_Impl( const SvLBox& rB );
281 : : DECL_DLLPRIVATE_STATIC_LINK( SvLBox, DragFinishHdl_Impl, sal_Int8* );
282 : :
283 : : DragDropMode nOldDragMode;
284 : :
285 : : protected:
286 : :
287 : : Link aExpandedHdl;
288 : : Link aExpandingHdl;
289 : : Link aSelectHdl;
290 : : Link aDeselectHdl;
291 : : Link aDoubleClickHdl;
292 : : SvLBoxEntry* pHdlEntry;
293 : : SvLBoxItem* pHdlItem;
294 : : SvLBoxEntry* pTargetEntry;
295 : :
296 : : SvLBox_Impl* pLBoxImpl;
297 : :
298 : : sal_uInt16 nImpFlags;
299 : : // Move/CopySelection: Position des aktuellen Eintrags in Selektionsliste
300 : : sal_uInt16 nCurEntrySelPos;
301 : :
302 : : DragDropMode nDragDropMode;
303 : : SelectionMode eSelMode;
304 : : sal_Int8 nDragOptions;
305 : :
306 : : sal_Bool CheckDragAndDropMode( SvLBox* pSource, sal_Int8 );
307 : : void ImplShowTargetEmphasis( SvLBoxEntry* pEntry, sal_Bool bShow);
308 : : void EnableSelectionAsDropTarget( sal_Bool bEnable = sal_True,
309 : : sal_Bool bWithChildren = sal_True );
310 : : // standard impl gibt 0 zurueck; muss von abgeleiteten Klassen, die
311 : : // D&D unterstuetzen, ueberladen werden
312 : : using Window::GetDropTarget;
313 : : virtual SvLBoxEntry* GetDropTarget( const Point& );
314 : :
315 : : // view-spezifische Daten in den Dragserver stellen
316 : : // wird an der Source-View aufgerufen (im BeginDrag-Handler)
317 : : virtual void WriteDragServerInfo( const Point&, SvLBoxDDInfo* );
318 : : // wird an der Target-View aufgerufen (im Drop-Handler)
319 : : virtual void ReadDragServerInfo( const Point&,SvLBoxDDInfo* );
320 : :
321 : : // invalidate children on enable/disable
322 : : virtual void StateChanged( StateChangedType );
323 : :
324 : : virtual sal_uLong Insert( SvLBoxEntry* pEnt,SvLBoxEntry* pPar,sal_uLong nPos=LIST_APPEND);
325 : : virtual sal_uLong Insert( SvLBoxEntry* pEntry,sal_uLong nRootPos = LIST_APPEND );
326 : :
327 : : // Inplace-Editing
328 : : SvInplaceEdit2* pEdCtrl;
329 [ + - ]: 2 : void EnableInplaceEditing( sal_Bool bEnable){if(bEnable)nImpFlags|=SVLBOX_EDT_ENABLED; else nImpFlags&=~SVLBOX_EDT_ENABLED;}
330 : 120 : sal_Bool IsInplaceEditingEnabled() const { return (sal_Bool)((nImpFlags&SVLBOX_EDT_ENABLED)!=0); }
331 : : virtual void EditingRequest( SvLBoxEntry* pEntry, SvLBoxItem* pItem,
332 : : const Point& rMousePos );
333 : : void EditText( const String&, const Rectangle&,const Selection&);
334 : : void EditText( const String&, const Rectangle&,const Selection&, sal_Bool bMulti);
335 : : void EditTextMultiLine( const String&, const Rectangle&,const Selection&);
336 : : void CancelTextEditing();
337 : 631 : sal_Bool IsEditingActive() const { return (sal_Bool)((nImpFlags & SVLBOX_IN_EDT)!=0); }
338 : : sal_Bool EditingCanceled() const;
339 : : void EndEditing( sal_Bool bCancel = sal_False );
340 : : bool IsEmptyTextAllowed() const;
341 : : void ForbidEmptyText();
342 : : // Callback EditText
343 : : virtual void EditedText( const String& );
344 : :
345 : : // Rueckgabewert muss von SvViewDataEntry abgeleitet sein!
346 : : virtual SvViewData* CreateViewData( SvListEntry* );
347 : : // InitViewData wird direkt nach CreateViewData aufgerufen
348 : : // In InitViewData ist der Entry noch nicht in die View eingefuegt!
349 : : virtual void InitViewData( SvViewData*, SvListEntry* pEntry );
350 : : // ruft fuer Items aller Entries InitViewData auf
351 : : void RecalcViewData();
352 : : // Callback von RecalcViewData
353 : : virtual void ViewDataInitialized( SvLBoxEntry* );
354 : :
355 : : virtual void Command( const CommandEvent& rCEvt );
356 : : virtual void KeyInput( const KeyEvent& rKEvt );
357 : : virtual SvLBoxEntry* GetEntry( const Point& rPos, sal_Bool bHit=sal_False ) const;
358 : : virtual void ModelHasEntryInvalidated( SvListEntry* pEntry );
359 : :
360 : : // handler and methods for Drag - finished handler. This link can be set
361 : : // to the TransferDataContainer. The AddBox/RemoveBox methods must be
362 : : // called before the StartDrag call.
363 : : // The Remove will be called from the handler, which then called
364 : : // DragFinish method. The Remove also called in the DTOR of the SvLBox -
365 : : // so it can't called to a deleted object.
366 : : Link GetDragFinishedHdl() const;
367 : :
368 : : // for asynchronous D&D
369 : : sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt, SvLBox* pSourceView );
370 : :
371 : : void OnCurrentEntryChanged();
372 : :
373 : : // IMnemonicEntryList
374 : : virtual const void* FirstSearchEntry( String& _rEntryText ) const;
375 : : virtual const void* NextSearchEntry( const void* _pCurrentSearchEntry, String& _rEntryText ) const;
376 : : virtual void SelectSearchEntry( const void* _pEntry );
377 : : virtual void ExecuteSearchEntry( const void* _pEntry ) const;
378 : :
379 : : // ISearchableStringList
380 : : virtual ::vcl::StringEntryIdentifier CurrentEntry( String& _out_entryText ) const;
381 : : virtual ::vcl::StringEntryIdentifier NextEntry( ::vcl::StringEntryIdentifier _currentEntry, String& _out_entryText ) const;
382 : : virtual void SelectEntry( ::vcl::StringEntryIdentifier _entry );
383 : :
384 : : public:
385 : :
386 : : SvLBox( Window* pParent, WinBits nWinStyle=0 );
387 : : SvLBox( Window* pParent, const ResId& rResId );
388 : : ~SvLBox();
389 : :
390 : 746 : SvLBoxTreeList* GetModel() const { return (SvLBoxTreeList*)pModel; }
391 : : using SvListView::SetModel;
392 : : void SetModel( SvLBoxTreeList* );
393 : : void DisconnectFromModel();
394 : :
395 : : virtual sal_uInt16 IsA();
396 : 0 : sal_uLong GetEntryCount() const {return pModel->GetEntryCount();}
397 : 1741 : SvLBoxEntry* First() const { return (SvLBoxEntry*)(pModel->First()); }
398 : 15938 : SvLBoxEntry* Next( SvLBoxEntry* pEntry, sal_uInt16* pDepth=0 ) const { return (SvLBoxEntry*)(pModel->Next(pEntry,pDepth));}
399 : 0 : SvLBoxEntry* Prev( SvLBoxEntry* pEntry, sal_uInt16* pDepth=0 ) const { return (SvLBoxEntry*)(pModel->Prev(pEntry,pDepth));}
400 : 0 : SvLBoxEntry* Last() const { return (SvLBoxEntry*)(pModel->Last()); }
401 : :
402 : 450 : SvLBoxEntry* FirstChild(SvLBoxEntry* pParent ) const { return (SvLBoxEntry*)(pModel->FirstChild(pParent)); }
403 : 2742 : SvLBoxEntry* NextSibling(SvLBoxEntry* pEntry ) const { return (SvLBoxEntry*)(pModel->NextSibling( pEntry )); }
404 : 0 : SvLBoxEntry* PrevSibling(SvLBoxEntry* pEntry ) const { return (SvLBoxEntry*)(pModel->PrevSibling( pEntry )); }
405 : :
406 : 1206 : SvLBoxEntry* FirstSelected() const { return (SvLBoxEntry*)SvListView::FirstSelected(); }
407 : : using SvListView::NextSelected;
408 : 2 : SvLBoxEntry* NextSelected( SvLBoxEntry* pEntry ) const { return (SvLBoxEntry*)(SvListView::NextSelected(pEntry)); }
409 : : using SvListView::PrevSelected;
410 : 0 : SvLBoxEntry* PrevSelected( SvLBoxEntry* pEntry ) const { return (SvLBoxEntry*)(SvListView::PrevSelected(pEntry)); }
411 : 0 : SvLBoxEntry* LastSelected() const { return (SvLBoxEntry*)(SvListView::LastSelected()); }
412 : :
413 : : sal_Bool CopySelection( SvLBox* pSource, SvLBoxEntry* pTarget );
414 : : sal_Bool MoveSelection( SvLBox* pSource, SvLBoxEntry* pTarget );
415 : : sal_Bool MoveSelectionCopyFallbackPossible( SvLBox* pSource, SvLBoxEntry* pTarget, sal_Bool bAllowCopyFallback );
416 : : void RemoveSelection();
417 : :
418 : 0 : DragDropMode GetDragDropMode() const { return nDragDropMode; }
419 : : virtual void SetDragDropMode( DragDropMode );
420 : 8 : SelectionMode GetSelectionMode() const { return eSelMode; }
421 : : virtual void SetSelectionMode( SelectionMode );
422 : :
423 : : // pParent==0 -> Root-Ebene
424 : 1876 : SvLBoxEntry* GetEntry( SvLBoxEntry* pParent, sal_uLong nPos ) const { return (SvLBoxEntry*)(pModel->GetEntry(pParent,nPos)); }
425 : 120 : SvLBoxEntry* GetEntry( sal_uLong nRootPos ) const { return (SvLBoxEntry*)(pModel->GetEntry(nRootPos)); }
426 : :
427 : : SvLBoxEntry* GetEntryFromPath( const ::std::deque< sal_Int32 >& _rPath ) const;
428 : : void FillEntryPath( SvLBoxEntry* pEntry, ::std::deque< sal_Int32 >& _rPath ) const;
429 : : virtual String GetEntryText( SvLBoxEntry* pEntry ) const;
430 : :
431 : : using Window::GetParent;
432 : 246 : SvLBoxEntry* GetParent( SvLBoxEntry* pEntry ) const { return (SvLBoxEntry*)(pModel->GetParent(pEntry)); }
433 : 12 : SvLBoxEntry* GetRootLevelParent(SvLBoxEntry* pEntry ) const { return (SvLBoxEntry*)(pModel->GetRootLevelParent( pEntry ));}
434 : :
435 : : using Window::GetChildCount;
436 : 0 : sal_uLong GetChildCount( SvLBoxEntry* pParent ) const { return pModel->GetChildCount(pParent); }
437 : : sal_uLong GetLevelChildCount( SvLBoxEntry* pParent ) const;
438 : :
439 : 5885 : SvViewDataEntry* GetViewDataEntry( SvListEntry* pEntry ) const { return (SvViewDataEntry*)SvListView::GetViewData(pEntry); }
440 : : SvViewDataItem* GetViewDataItem( SvListEntry*, SvLBoxItem* ) const;
441 : :
442 : : virtual void MakeVisible( SvLBoxEntry* pEntry );
443 : : void Clear();
444 : :
445 : : /** enables or disables mnemonic characters in the entry texts.
446 : :
447 : : If mnemonics are enabled, then entries are selected and made current when
448 : : there mnemonic character is pressed. If there are multiple entries with the
449 : : same mnemonic, the selection cycles between them.
450 : :
451 : : Entries with an collapsed ancestor are not included in the calculation of
452 : : mnemonics. That is, if you press the accelerator key of an invisible
453 : : entry, then this entry is *not* selected.
454 : :
455 : : Be aware that enabling mnemonics is the more expensive the more
456 : : entries you have in your list.
457 : : */
458 : : void EnableEntryMnemonics( bool _bEnable = true );
459 : : bool IsEntryMnemonicsEnabled() const;
460 : :
461 : : /** handles the given key event.
462 : :
463 : : At the moment, this merely checks for accelerator keys, if entry mnemonics
464 : : are enabled.
465 : :
466 : : The method might come handy when you want to use keyboard acceleration
467 : : while the control does not have the focus.
468 : :
469 : : When the key event describes the pressing of a shortcut for an entry,
470 : : then SelectSearchEntry resp. ExecuteSearchEntry are called.
471 : :
472 : : @see IMnemonicEntryList
473 : : @see MnemonicEngine
474 : :
475 : : @return
476 : : <TRUE/> if the event has been consumed, <FALSE/> otherwise.
477 : : */
478 : : bool HandleKeyInput( const KeyEvent& rKEvt );
479 : :
480 : : virtual sal_Bool Expand( SvLBoxEntry* pParent );
481 : : virtual sal_Bool Collapse( SvLBoxEntry* pParent );
482 : : virtual sal_Bool Select( SvLBoxEntry* pEntry, sal_Bool bSelect=sal_True );
483 : : virtual sal_uLong SelectChildren( SvLBoxEntry* pParent, sal_Bool bSelect );
484 : : virtual void SelectAll( sal_Bool bSelect, sal_Bool bPaint=sal_True );
485 : :
486 : : virtual void SetCurEntry( SvLBoxEntry* _pEntry ) = 0;
487 : : virtual SvLBoxEntry*
488 : : GetCurEntry() const = 0;
489 : :
490 : 120 : void SetSelectHdl( const Link& rNewHdl ) {aSelectHdl=rNewHdl; }
491 : 0 : void SetDeselectHdl( const Link& rNewHdl ) {aDeselectHdl=rNewHdl; }
492 : 120 : void SetDoubleClickHdl(const Link& rNewHdl) {aDoubleClickHdl=rNewHdl;}
493 : 0 : const Link& GetSelectHdl() const { return aSelectHdl; }
494 : 0 : const Link& GetDeselectHdl() const { return aDeselectHdl; }
495 : 0 : const Link& GetDoubleClickHdl() const { return aDoubleClickHdl; }
496 : 0 : void SetExpandingHdl(const Link& rNewHdl){aExpandingHdl=rNewHdl;}
497 : 0 : void SetExpandedHdl(const Link& rNewHdl){aExpandedHdl=rNewHdl;}
498 : : const Link& GetExpandingHdl() const { return aExpandingHdl; }
499 : :
500 : : virtual void ExpandedHdl();
501 : : virtual long ExpandingHdl();
502 : : virtual void SelectHdl();
503 : : virtual void DeselectHdl();
504 : : virtual sal_Bool DoubleClickHdl();
505 : : sal_Bool IsTravelSelect() const { return (sal_Bool)((nImpFlags&SVLBOX_IS_TRAVELSELECT)!=0);}
506 : 6 : SvLBoxEntry* GetHdlEntry() const { return pHdlEntry; }
507 : : SvLBoxItem* GetHdlItem() const;
508 : :
509 : : // wird aufgerufen, wenn ein Eintrag mit gesetztem
510 : : // ENTRYFLAG_CHILDREN_ON_DEMAND expandiert wird.
511 : : virtual void RequestingChildren( SvLBoxEntry* pParent );
512 : :
513 : : // Drag & Drop
514 : :
515 : : //JP 28.3.2001: new Drag & Drop API
516 : : virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
517 : : virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
518 : : virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
519 : : virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData,
520 : : SvLBoxEntry* );
521 : : virtual void DragFinished( sal_Int8 nDropAction );
522 : : virtual sal_Bool NotifyAcceptDrop( SvLBoxEntry* );
523 : :
524 : 0 : void SetDragOptions( sal_Int8 nOptions ) { nDragOptions = nOptions; }
525 : : sal_Int8 GetDragOptions() const { return nDragOptions; }
526 : :
527 : : SvLBox* GetSourceView() const;
528 : :
529 : : virtual void NotifyRemoving( SvLBoxEntry* );
530 : : virtual void ShowTargetEmphasis( SvLBoxEntry*, sal_Bool bShow );
531 : : virtual SvLBoxEntry* CloneEntry( SvLBoxEntry* pSource );
532 : : virtual SvLBoxEntry* CreateEntry() const; // zum 'new'en von Entries
533 : :
534 : : // Rueckgabe: sal_True==Ok, sal_False==Abbrechen
535 : : virtual sal_Bool NotifyMoving(
536 : : SvLBoxEntry* pTarget, // D&D-Drop-Position in this->GetModel()
537 : : SvLBoxEntry* pEntry, // Zu verschiebender Entry aus
538 : : // GetSourceListBox()->GetModel()
539 : : SvLBoxEntry*& rpNewParent, // Neuer Target-Parent
540 : : sal_uLong& rNewChildPos); // Position in Childlist des Target-Parents
541 : :
542 : : // Rueckgabe: sal_True==Ok, sal_False==Abbrechen
543 : : virtual sal_Bool NotifyCopying(
544 : : SvLBoxEntry* pTarget, // D&D-Drop-Position in this->GetModel()
545 : : SvLBoxEntry* pEntry, // Zu kopierender Entry aus
546 : : // GetSourceListBox()->GetModel()
547 : : SvLBoxEntry*& rpNewParent, // Neuer Target-Parent
548 : : sal_uLong& rNewChildPos); // Position in Childlist des Target-Parents
549 : :
550 : : // ACCESSIBILITY ==========================================================
551 : :
552 : : /** Creates and returns the accessible object of the Box. */
553 : : virtual ::com::sun::star::uno::Reference<
554 : : ::com::sun::star::accessibility::XAccessible > CreateAccessible();
555 : :
556 : : /** Fills the StateSet with all states (except DEFUNC, done by the accessible object). */
557 : : virtual void FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& rStateSet ) const;
558 : :
559 : : /** Calculate and returns the bounding rectangle of an entry.
560 : : @param pEntry
561 : : The entry.
562 : : @return The bounding rectangle of an entry. */
563 : : virtual Rectangle GetBoundingRect( SvLBoxEntry* pEntry );
564 : :
565 : : protected:
566 : : using SvListView::Expand;
567 : : using SvListView::Collapse;
568 : : using SvListView::Select;
569 : : using SvListView::SelectAll;
570 : : };
571 : :
572 : : #define SV_LBOX_DD_FORMAT "SV_LBOX_DD_FORMAT"
573 : : struct SvLBoxDDInfo
574 : : {
575 : : Application* pApp;
576 : : SvLBox* pSource;
577 : : SvLBoxEntry* pDDStartEntry;
578 : : // relative Position im Eintrag bei Drag-Beginn (IconView)
579 : : long nMouseRelX,nMouseRelY;
580 : : sal_uLong nRes1,nRes2,nRes3,nRes4;
581 : : };
582 : :
583 : : class SvInplaceEdit2
584 : : {
585 : : Link aCallBackHdl;
586 : : Accelerator aAccReturn;
587 : : Accelerator aAccEscape;
588 : : Timer aTimer;
589 : : Edit* pEdit;
590 : : sal_Bool bCanceled;
591 : : sal_Bool bAlreadyInCallBack;
592 : :
593 : : void CallCallBackHdl_Impl();
594 : : DECL_LINK( Timeout_Impl, void * );
595 : : DECL_LINK( ReturnHdl_Impl, void * );
596 : : DECL_LINK( EscapeHdl_Impl, void * );
597 : :
598 : : public:
599 : : SvInplaceEdit2( Window* pParent, const Point& rPos, const Size& rSize,
600 : : const String& rData, const Link& rNotifyEditEnd,
601 : : const Selection&, sal_Bool bMultiLine = sal_False );
602 : : ~SvInplaceEdit2();
603 : : sal_Bool KeyInput( const KeyEvent& rKEvt );
604 : : void LoseFocus();
605 : 0 : sal_Bool EditingCanceled() const { return bCanceled; }
606 : : String GetText() const;
607 : : String GetSavedValue() const;
608 : : void StopEditing( sal_Bool bCancel = sal_False );
609 : : void Hide();
610 : : };
611 : :
612 : 28152 : inline SvViewDataItem* SvLBox::GetViewDataItem( SvListEntry* pEntry,
613 : : SvLBoxItem* pItem) const
614 : : {
615 : : SvViewDataEntry* pEntryData =
616 : 28152 : (SvViewDataEntry*)SvListView::GetViewData(pEntry);
617 : : DBG_ASSERT(pEntryData,"Entry not in View");
618 : : DBG_ASSERT(pEntryData->pItemData,"No ItemData");
619 : 28152 : sal_uInt16 nItemPos = ((SvLBoxEntry*)pEntry)->GetPos( pItem );
620 : 28152 : return (pEntryData->pItemData+nItemPos);
621 : : }
622 : :
623 : : #endif
624 : :
625 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|