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