1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef __SVTOOLS_TREELISTBOX_HXX__
21 #define __SVTOOLS_TREELISTBOX_HXX__
23 #include "svtools/svtdllapi.h"
28 #include <vcl/ctrl.hxx>
29 #include <vcl/seleng.hxx>
30 #include <vcl/edit.hxx>
31 #include <vcl/timer.hxx>
32 #include <vcl/accel.hxx>
33 #include <vcl/mnemonicengine.hxx>
34 #include <vcl/quickselectionengine.hxx>
35 #include <vcl/image.hxx>
36 #include <tools/gen.hxx>
37 #include <tools/contnr.hxx>
38 #include <svtools/treelist.hxx>
39 #include <svtools/transfer.hxx>
43 class SvTreeListEntry
;
44 struct SvViewDataItem
;
45 class SvViewDataEntry
;
49 class SvLBoxContextBmp
;
52 class SvLBoxButtonData
;
56 class AccessibleStateSetHelper
;
61 SvLBoxButtonKind_enabledCheckbox
,
62 SvLBoxButtonKind_disabledCheckbox
,
63 SvLBoxButtonKind_staticImage
66 enum SvButtonState
{ SV_BUTTON_UNCHECKED
, SV_BUTTON_CHECKED
, SV_BUTTON_TRISTATE
};
68 // *********************************************************************
69 // *************************** Tabulators ******************************
70 // *********************************************************************
72 #define SV_LBOXTAB_DYNAMIC 0x0001 // Item's output column changes according to the Child Depth
73 #define SV_LBOXTAB_ADJUST_RIGHT 0x0002 // Item's right margin at the tabulator
74 #define SV_LBOXTAB_ADJUST_LEFT 0x0004 // Left margin
75 #define SV_LBOXTAB_ADJUST_CENTER 0x0008 // Center the item at the tabulator
76 #define SV_LBOXTAB_ADJUST_NUMERIC 0x0010 // Decimal point at the tabulator (strings)
78 // Is not supported anymore! The focus is now controlled by selection!
79 #define SV_LBOXTAB_SHOW_FOCUS 0x0020 // Visualize focus
81 #define SV_LBOXTAB_SHOW_SELECTION 0x0040 // Visualize selection state
82 // Item needs to be able to return the surrounding polygon (D'n'D cursor)
83 #define SV_LBOXTAB_EDITABLE 0x0100 // Item editable at the tabulator
84 #define SV_LBOXTAB_PUSHABLE 0x0200 // Item acts like a Button
85 #define SV_LBOXTAB_INV_ALWAYS 0x0400 // Always delete the background
86 #define SV_LBOXTAB_FORCE 0x0800 // Switch off the default calculation of the first tabulator
87 // (on which Abo Tabpage/Extras/Option/Customize, etc. rely on)
88 // The first tab's position corresponds precisely to the Flags set
91 #define SV_TAB_BORDER 8
93 #define SV_ENTRYHEIGHTOFFS_PIXEL 2
95 #define TREEFLAG_CHKBTN 0x0001
96 #define TREEFLAG_USESEL 0x0002
97 #define TREEFLAG_MANINS 0x0004
98 #define TREEFLAG_RECALCTABS 0x0008
100 typedef sal_Int64 ExtendedWinBits
;
102 // disable the behavior of automatically selecting a "CurEntry" upon painting the control
103 #define EWB_NO_AUTO_CURENTRY 0x00000001
105 #define SV_ITEM_ID_LBOXSTRING 1
106 #define SV_ITEM_ID_LBOXBMP 2
107 #define SV_ITEM_ID_LBOXBUTTON 3
108 #define SV_ITEM_ID_LBOXCONTEXTBMP 4
116 SvLBoxTab( long nPos
, sal_uInt16 nFlags
=SV_LBOXTAB_ADJUST_LEFT
);
117 SvLBoxTab( const SvLBoxTab
& );
122 void SetUserData( void* pPtr
) { pUserData
= pPtr
; }
123 void* GetUserData() const { return pUserData
; }
124 sal_Bool
IsDynamic() const { return (sal_Bool
)((nFlags
& SV_LBOXTAB_DYNAMIC
)!=0); }
125 void SetPos( long nNewPos
) { nPos
= nNewPos
; }
126 long GetPos() const { return nPos
; }
127 long CalcOffset( long nItemLength
, long nTabWidth
);
128 // long CalcOffset( const String&, const OutputDevice& );
129 sal_Bool
IsEditable() const { return (sal_Bool
)((nFlags
& SV_LBOXTAB_EDITABLE
)!=0); }
130 sal_Bool
IsPushable() const { return (sal_Bool
)((nFlags
& SV_LBOXTAB_PUSHABLE
)!=0); }
133 // *********************************************************************
134 // ****************************** Items ********************************
135 // *********************************************************************
137 class SVT_DLLPUBLIC SvLBoxItem
140 SvLBoxItem( SvTreeListEntry
*, sal_uInt16 nFlags
);
142 virtual ~SvLBoxItem();
143 virtual sal_uInt16
GetType() const = 0;
144 const Size
& GetSize(const SvTreeListBox
* pView
, const SvTreeListEntry
* pEntry
) const;
145 const Size
& GetSize(const SvViewDataEntry
* pData
, sal_uInt16 nItemPos
) const;
148 const Point
& rPos
, SvTreeListBox
& rOutDev
, const SvViewDataEntry
* pView
, const SvTreeListEntry
* pEntry
) = 0;
150 virtual void InitViewData( SvTreeListBox
* pView
, SvTreeListEntry
* pEntry
,
151 // If != 0: this Pointer must be used!
152 // If == 0: it needs to be retrieved via the View
153 SvViewDataItem
* pViewData
= 0) = 0;
154 virtual SvLBoxItem
* Create() const = 0;
155 // View-dependent data is not cloned
156 virtual void Clone( SvLBoxItem
* pSource
) = 0;
159 inline SvLBoxItem
* new_clone(const SvLBoxItem
& rSrc
)
161 SvLBoxItem
* p
= rSrc
.Create();
162 p
->Clone(const_cast<SvLBoxItem
*>(&rSrc
));
166 inline void delete_clone(const SvLBoxItem
* p
)
171 // *********************************************************************
172 // ****************************** SvTreeListBox ************************
173 // *********************************************************************
175 #define WB_FORCE_SELECTION ((WinBits)0x8000)
177 #define DragDropMode sal_uInt16
178 #define SV_DRAGDROP_NONE (DragDropMode)0x0000
179 #define SV_DRAGDROP_CTRL_MOVE (DragDropMode)0x0001
180 #define SV_DRAGDROP_CTRL_COPY (DragDropMode)0x0002
181 #define SV_DRAGDROP_APP_MOVE (DragDropMode)0x0004
182 #define SV_DRAGDROP_APP_COPY (DragDropMode)0x0008
183 #define SV_DRAGDROP_APP_DROP (DragDropMode)0x0010
184 // Entries may be dropped via the uppermost Entry
185 // The DropTarget is 0 in that case
186 #define SV_DRAGDROP_ENABLE_TOP (DragDropMode)0x0020
188 #define SVLISTBOX_ID_LBOX 0 // for SvTreeListBox::GetType()
190 #define SVLBOX_IN_EDT 0x0001
191 #define SVLBOX_EDT_ENABLED 0x0002
192 #define SVLBOX_IS_EXPANDING 0x0004
193 #define SVLBOX_IS_TRAVELSELECT 0x0008
194 #define SVLBOX_TARGEMPH_VIS 0x0010
195 #define SVLBOX_EDTEND_CALLED 0x0020
197 struct SvTreeListBoxImpl
;
199 class SVT_DLLPUBLIC SvTreeListBox
202 ,public DropTargetHelper
203 ,public DragSourceHelper
204 ,public ::vcl::IMnemonicEntryList
205 ,public ::vcl::ISearchableStringList
207 friend class SvImpLBox
;
208 friend class TreeControlPeer
;
210 SvTreeListBoxImpl
* mpImpl
;
212 Link aCheckButtonHdl
;
219 Accelerator aInpEditAcc
;
220 Image aPrevInsertedExpBmp
;
221 Image aPrevInsertedColBmp
;
222 Image aCurInsertedExpBmp
;
223 Image aCurInsertedColBmp
;
225 short nContextBmpWidthMax
;
227 short nEntryHeightOffs
;
230 sal_uInt16 nFirstSelTab
;
231 sal_uInt16 nLastSelTab
;
232 long mnCheckboxItemWidth
;
233 bool mbContextBmpExpanded
;
235 SvTreeListEntry
* pHdlEntry
;
236 SvLBoxItem
* pHdlItem
;
238 DragDropMode nDragDropMode
;
239 DragDropMode nOldDragMode
;
240 SelectionMode eSelMode
;
241 sal_Int8 nDragOptions
;
243 SvTreeListEntry
* pEdEntry
;
247 Link aDoubleClickHdl
;
248 SvTreeListEntry
* pTargetEntry
;
249 SvLBoxButtonData
* pCheckButtonData
;
250 std::vector
<SvLBoxTab
*> aTabs
;
251 sal_uInt16 nTreeFlags
;
252 sal_uInt16 nImpFlags
;
253 // Move/CopySelection: Position of the current Entry in SelectionList
254 sal_uInt16 nCurEntrySelPos
;
257 void SetBaseModel(SvTreeList
* pNewModel
);
259 DECL_DLLPRIVATE_LINK( CheckButtonClick
, SvLBoxButtonData
* );
260 DECL_DLLPRIVATE_LINK( TextEditEndedHdl_Impl
, void * );
261 // Handler that is called by TreeList to clone an Entry
262 DECL_DLLPRIVATE_LINK( CloneHdl_Impl
, SvTreeListEntry
* );
264 // Handler and methods for Drag - finished handler.
265 // The Handle retrieved by GetDragFinishedHdl can be set on the
266 // TransferDataContainer. This link is a callback for the DragFinished
267 // call. The AddBox method is called from the GetDragFinishedHdl() and the
268 // remove is called in the link callback and in the dtor. So it can't be
269 // called for a deleted object.
270 SVT_DLLPRIVATE
static void AddBoxToDDList_Impl( const SvTreeListBox
& rB
);
271 SVT_DLLPRIVATE
static void RemoveBoxFromDDList_Impl( const SvTreeListBox
& rB
);
272 DECL_DLLPRIVATE_STATIC_LINK( SvTreeListBox
, DragFinishHdl_Impl
, sal_Int8
* );
276 sal_Bool
CheckDragAndDropMode( SvTreeListBox
* pSource
, sal_Int8
);
277 void ImplShowTargetEmphasis( SvTreeListEntry
* pEntry
, sal_Bool bShow
);
278 void EnableSelectionAsDropTarget( sal_Bool bEnable
= sal_True
,
279 sal_Bool bWithChildren
= sal_True
);
280 // Standard impl returns 0; must be overloaded by derived classes which support D'n'D
281 using Window::GetDropTarget
;
282 virtual SvTreeListEntry
* GetDropTarget( const Point
& );
284 // Put View-specific data into the Dragserver
285 // Is called at the SourceView (in BeginDrag Handler)
286 virtual void WriteDragServerInfo( const Point
&, SvLBoxDDInfo
* );
287 // Is called at the TargetView (in Drop Handler)
288 virtual void ReadDragServerInfo( const Point
&,SvLBoxDDInfo
* );
290 // Invalidate children on enable/disable
291 virtual void StateChanged( StateChangedType eType
);
293 virtual sal_uLong
Insert( SvTreeListEntry
* pEnt
,SvTreeListEntry
* pPar
,sal_uLong nPos
=LIST_APPEND
);
294 virtual sal_uLong
Insert( SvTreeListEntry
* pEntry
,sal_uLong nRootPos
= LIST_APPEND
);
297 SvInplaceEdit2
* pEdCtrl
;
298 void EditText( const String
&, const Rectangle
&,const Selection
&);
299 void EditText( const String
&, const Rectangle
&,const Selection
&, sal_Bool bMulti
);
300 void EditTextMultiLine( const String
&, const Rectangle
&,const Selection
&);
301 void CancelTextEditing();
302 sal_Bool
EditingCanceled() const;
303 bool IsEmptyTextAllowed() const;
305 // Return value must be derived from SvViewDataEntry!
306 virtual SvViewDataEntry
* CreateViewData( SvTreeListEntry
* );
307 // InitViewData is called right after CreateViewData
308 // The Entry is has not yet been added to the View in InitViewData!
309 virtual void InitViewData( SvViewDataEntry
*, SvTreeListEntry
* pEntry
);
310 // Calls InitViewData for all Items
311 void RecalcViewData();
312 // Callback of RecalcViewData
313 virtual void ViewDataInitialized( SvTreeListEntry
* );
315 // Handler and methods for Drag - finished handler. This link can be set
316 // to the TransferDataContainer. The AddBox/RemoveBox methods must be
317 // called before the StartDrag call.
318 // The Remove will be called from the handler, which then calls DragFinish.
319 // The Remove is also called in the DTOR of the SvTreeListBox -
320 // so it can't be called for a deleted object.
321 Link
GetDragFinishedHdl() const;
323 // For asynchronous D'n'D
324 sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
, SvTreeListBox
* pSourceView
);
326 void OnCurrentEntryChanged();
328 // IMnemonicEntryList
329 virtual const void* FirstSearchEntry( String
& _rEntryText
) const;
330 virtual const void* NextSearchEntry( const void* _pCurrentSearchEntry
, String
& _rEntryText
) const;
331 virtual void SelectSearchEntry( const void* _pEntry
);
332 virtual void ExecuteSearchEntry( const void* _pEntry
) const;
334 // ISearchableStringList
335 virtual ::vcl::StringEntryIdentifier
CurrentEntry( String
& _out_entryText
) const;
336 virtual ::vcl::StringEntryIdentifier
NextEntry( ::vcl::StringEntryIdentifier _currentEntry
, String
& _out_entryText
) const;
337 virtual void SelectEntry( ::vcl::StringEntryIdentifier _entry
);
341 SvTreeListBox( Window
* pParent
, WinBits nWinStyle
=0 );
342 SvTreeListBox( Window
* pParent
, const ResId
& rResId
);
343 virtual ~SvTreeListBox();
345 SvTreeList
* GetModel() const { return pModel
; }
346 using SvListView::SetModel
;
347 void SetModel(SvTreeList
* pNewModel
);
349 sal_uLong
GetEntryCount() const {return pModel
->GetEntryCount();}
350 SvTreeListEntry
* First() const { return pModel
->First(); }
351 SvTreeListEntry
* Next( SvTreeListEntry
* pEntry
, sal_uInt16
* pDepth
=0 ) const { return pModel
->Next(pEntry
,pDepth
); }
352 SvTreeListEntry
* Prev( SvTreeListEntry
* pEntry
, sal_uInt16
* pDepth
=0 ) const { return pModel
->Prev(pEntry
,pDepth
); }
353 SvTreeListEntry
* Last() const { return pModel
->Last(); }
355 SvTreeListEntry
* FirstChild( SvTreeListEntry
* pParent
) const;
356 SvTreeListEntry
* NextSibling( SvTreeListEntry
* pEntry
) const;
357 SvTreeListEntry
* PrevSibling( SvTreeListEntry
* pEntry
) const;
359 sal_Bool
CopySelection( SvTreeListBox
* pSource
, SvTreeListEntry
* pTarget
);
360 sal_Bool
MoveSelection( SvTreeListBox
* pSource
, SvTreeListEntry
* pTarget
);
361 sal_Bool
MoveSelectionCopyFallbackPossible( SvTreeListBox
* pSource
, SvTreeListEntry
* pTarget
, sal_Bool bAllowCopyFallback
);
362 void RemoveSelection();
364 DragDropMode
GetDragDropMode() const { return nDragDropMode
; }
365 SelectionMode
GetSelectionMode() const { return eSelMode
; }
367 // pParent == 0 -> Root level
368 SvTreeListEntry
* GetEntry( SvTreeListEntry
* pParent
, sal_uLong nPos
) const;
369 SvTreeListEntry
* GetEntry( sal_uLong nRootPos
) const;
371 SvTreeListEntry
* GetEntryFromPath( const ::std::deque
< sal_Int32
>& _rPath
) const;
372 void FillEntryPath( SvTreeListEntry
* pEntry
, ::std::deque
< sal_Int32
>& _rPath
) const;
374 using Window::GetParent
;
375 const SvTreeListEntry
* GetParent( const SvTreeListEntry
* pEntry
) const;
376 SvTreeListEntry
* GetParent( SvTreeListEntry
* pEntry
) const;
377 SvTreeListEntry
* GetRootLevelParent(SvTreeListEntry
* pEntry
) const;
379 using Window::GetChildCount
;
380 sal_uLong
GetChildCount( SvTreeListEntry
* pParent
) const;
381 sal_uLong
GetLevelChildCount( SvTreeListEntry
* pParent
) const;
383 SvViewDataEntry
* GetViewDataEntry( SvTreeListEntry
* pEntry
) const;
384 SvViewDataItem
* GetViewDataItem(SvTreeListEntry
*, SvLBoxItem
*);
385 const SvViewDataItem
* GetViewDataItem(const SvTreeListEntry
*, const SvLBoxItem
*) const;
387 bool IsInplaceEditingEnabled() const { return ((nImpFlags
& SVLBOX_EDT_ENABLED
) != 0); }
388 bool IsEditingActive() const { return ((nImpFlags
& SVLBOX_IN_EDT
) != 0); }
389 void EndEditing( bool bCancel
= false );
390 void ForbidEmptyText();
394 /** Enables or disables mnemonic characters in the entry texts.
396 If mnemonics are enabled, then entries are selected and made current when
397 there mnemonic character is pressed. If there are multiple entries with the
398 same mnemonic, the selection cycles between them.
400 Entries with an collapsed ancestor are not included in the calculation of
401 mnemonics. That is, if you press the accelerator key of an invisible
402 entry, then this entry is *not* selected.
404 Be aware that enabling mnemonics gets more expensive as you add to the list.
406 void EnableEntryMnemonics( bool _bEnable
= true );
407 bool IsEntryMnemonicsEnabled() const;
409 /** Handles the given key event.
411 At the moment this merely checks for accelerator keys, if entry mnemonics
414 This method may come in handy if you want to use keyboard acceleration
415 while the control does not have the focus.
417 If the key event describes the pressing of a shortcut for an entry,
418 then SelectSearchEntry resp. ExecuteSearchEntry are called.
420 @see IMnemonicEntryList
424 <TRUE/> if the event has been consumed, <FALSE/> otherwise.
426 bool HandleKeyInput( const KeyEvent
& rKEvt
);
428 void SetSelectHdl( const Link
& rNewHdl
) {aSelectHdl
=rNewHdl
; }
429 void SetDeselectHdl( const Link
& rNewHdl
) {aDeselectHdl
=rNewHdl
; }
430 void SetDoubleClickHdl(const Link
& rNewHdl
) {aDoubleClickHdl
=rNewHdl
;}
431 const Link
& GetSelectHdl() const { return aSelectHdl
; }
432 const Link
& GetDeselectHdl() const { return aDeselectHdl
; }
433 const Link
& GetDoubleClickHdl() const { return aDoubleClickHdl
; }
434 void SetExpandingHdl(const Link
& rNewHdl
){aExpandingHdl
=rNewHdl
;}
435 void SetExpandedHdl(const Link
& rNewHdl
){aExpandedHdl
=rNewHdl
;}
436 const Link
& GetExpandingHdl() const { return aExpandingHdl
; }
438 virtual void ExpandedHdl();
439 virtual long ExpandingHdl();
440 virtual void SelectHdl();
441 virtual void DeselectHdl();
442 virtual sal_Bool
DoubleClickHdl();
443 sal_Bool
IsTravelSelect() const { return (sal_Bool
)((nImpFlags
&SVLBOX_IS_TRAVELSELECT
)!=0);}
444 SvTreeListEntry
* GetHdlEntry() const { return pHdlEntry
; }
445 SvLBoxItem
* GetHdlItem() const;
447 // Is called for an Entry that gets expanded with the Flag
448 // ENTRYFLAG_CHILDREN_ON_DEMAND set.
449 virtual void RequestingChildren( SvTreeListEntry
* pParent
);
453 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
);
454 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
);
455 virtual void StartDrag( sal_Int8 nAction
, const Point
& rPosPixel
);
456 virtual DragDropMode
NotifyStartDrag( TransferDataContainer
& rData
,
458 virtual void DragFinished( sal_Int8 nDropAction
);
459 virtual sal_Bool
NotifyAcceptDrop( SvTreeListEntry
* );
461 void SetDragOptions( sal_Int8 nOptions
) { nDragOptions
= nOptions
; }
462 sal_Int8
GetDragOptions() const { return nDragOptions
; }
464 SvTreeListBox
* GetSourceView() const;
466 virtual void NotifyRemoving( SvTreeListEntry
* );
467 virtual SvTreeListEntry
* CloneEntry( SvTreeListEntry
* pSource
);
468 virtual SvTreeListEntry
* CreateEntry() const; // To create new Entries
470 // Return value: sal_True == Ok, sal_False == Cancel
471 virtual sal_Bool
NotifyMoving(
472 SvTreeListEntry
* pTarget
, // D'n'D DropPosition in this->GetModel()
473 SvTreeListEntry
* pEntry
, // Entry to be moved from GetSourceListBox()->GetModel()
474 SvTreeListEntry
*& rpNewParent
, // New TargetParent
475 sal_uLong
& rNewChildPos
); // The TargetParent's position in Childlist
477 // Return value: sal_True == Ok, sal_False == Cancel
478 virtual sal_Bool
NotifyCopying(
479 SvTreeListEntry
* pTarget
, // D'n'D DropPosition in this->GetModel()
480 SvTreeListEntry
* pEntry
, // Entry to be copied from GetSourceListBox()->GetModel()
481 SvTreeListEntry
*& rpNewParent
, // New TargetParent
482 sal_uLong
& rNewChildPos
); // The TargetParent's position in Childlist
484 // ACCESSIBILITY ==========================================================
486 /** Creates and returns the accessible object of the Box. */
487 virtual ::com::sun::star::uno::Reference
<
488 ::com::sun::star::accessibility::XAccessible
> CreateAccessible();
490 /** Fills the StateSet with all states (except DEFUNC, done by the accessible object). */
491 virtual void FillAccessibleStateSet( ::utl::AccessibleStateSetHelper
& rStateSet
) const;
493 /** Fills the StateSet of one entry. */
494 virtual void FillAccessibleEntryStateSet( SvTreeListEntry
* pEntry
, ::utl::AccessibleStateSetHelper
& rStateSet
) const;
496 /** Calculate and return the bounding rectangle of an entry.
499 @return The bounding rectangle of an entry. */
500 virtual Rectangle
GetBoundingRect( SvTreeListEntry
* pEntry
);
502 /** Enables, that one cell of a tablistbox entry can be focused */
503 void EnableCellFocus();
506 using SvListView::Expand
;
507 using SvListView::Collapse
;
508 using SvListView::Select
;
509 using SvListView::SelectAll
;
511 SVT_DLLPRIVATE
short GetHeightOffset( const Image
& rBmp
, Size
& rLogicSize
);
512 SVT_DLLPRIVATE
short GetHeightOffset( const Font
& rFont
, Size
& rLogicSize
);
514 SVT_DLLPRIVATE
void SetEntryHeight( SvTreeListEntry
* pEntry
);
515 SVT_DLLPRIVATE
void AdjustEntryHeight( const Image
& rBmp
);
516 SVT_DLLPRIVATE
void AdjustEntryHeight( const Font
& rFont
);
518 SVT_DLLPRIVATE
void ImpEntryInserted( SvTreeListEntry
* pEntry
);
519 SVT_DLLPRIVATE
long PaintEntry1( SvTreeListEntry
*, long nLine
,
520 sal_uInt16 nTabFlagMask
=0xffff,
521 sal_Bool bHasClipRegion
=sal_False
);
523 SVT_DLLPRIVATE
void InitTreeView();
524 SVT_DLLPRIVATE SvLBoxItem
* GetItem_Impl( SvTreeListEntry
*, long nX
, SvLBoxTab
** ppTab
,
525 sal_uInt16 nEmptyWidth
);
526 SVT_DLLPRIVATE
void ImplInitStyle();
530 void EditItemText( SvTreeListEntry
* pEntry
, SvLBoxString
* pItem
,
532 void EditedText( const XubString
& );
534 // Recalculate all tabs depending on TreeListStyle and Bitmap sizes
535 // Is called automatically when inserting/changing Bitmaps, changing the Model etc.
536 virtual void SetTabs();
538 void AddTab( long nPos
,sal_uInt16 nFlags
=SV_LBOXTAB_ADJUST_LEFT
,
539 void* pUserData
= 0 );
540 sal_uInt16
TabCount() const { return aTabs
.size(); }
541 SvLBoxTab
* GetFirstDynamicTab() const;
542 SvLBoxTab
* GetFirstDynamicTab( sal_uInt16
& rTabPos
) const;
543 SvLBoxTab
* GetFirstTab( sal_uInt16 nFlagMask
, sal_uInt16
& rTabPos
);
544 SvLBoxTab
* GetLastTab( sal_uInt16 nFlagMask
, sal_uInt16
& rTabPos
);
545 SvLBoxTab
* GetTab( SvTreeListEntry
*, SvLBoxItem
* ) const;
548 virtual void InitEntry(SvTreeListEntry
*, const OUString
&, const Image
&, const Image
&, SvLBoxButtonKind
);
550 virtual void NotifyBeginScroll();
551 virtual void NotifyEndScroll();
552 // nLines == 0 => horizontal Scrolling
553 virtual void NotifyScrolling( long nLines
);
554 virtual void NotifyScrolled();
555 void SetScrolledHdl( const Link
& rLink
) { aScrolledHdl
= rLink
; }
556 const Link
& GetScrolledHdl() const { return aScrolledHdl
; }
557 long GetXOffset() const { return GetMapMode().GetOrigin().X(); }
559 // Is called _before_ Areas in the Control are invalidated.
560 // This can be used to hide Elements which are painted from outside into the Control
561 virtual void NotifyInvalidating();
563 virtual void Command( const CommandEvent
& rCEvt
);
565 virtual void RequestHelp( const HelpEvent
& rHEvt
);
566 virtual void CursorMoved( SvTreeListEntry
* pNewCursor
);
567 virtual void PreparePaint( SvTreeListEntry
* );
568 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
570 void InitSettings(sal_Bool bFont
,sal_Bool bForeground
,sal_Bool bBackground
);
571 sal_Bool
IsCellFocusEnabled() const;
572 bool SetCurrentTabPos( sal_uInt16 _nNewPos
);
573 sal_uInt16
GetCurrentTabPos() const;
574 void CallImplEventListeners(sal_uLong nEvent
, void* pData
);
576 void ImplEditEntry( SvTreeListEntry
* pEntry
);
578 sal_Bool
AreChildrenTransient() const;
579 void SetChildrenNotTransient();
581 void AdjustEntryHeightAndRecalc( const Font
& rFont
);
584 void SetExtendedWinBits( ExtendedWinBits _nBits
);
586 void DisconnectFromModel();
588 void EnableCheckButton( SvLBoxButtonData
* );
589 void SetCheckButtonData( SvLBoxButtonData
* );
590 void SetNodeBitmaps( const Image
& rCollapsedNodeBmp
, const Image
& rExpandedNodeBmp
);
592 /** Returns the default image which clients should use for expanded nodes, to have a consistent user
593 interface experience in the whole product.
595 static const Image
& GetDefaultExpandedNodeImage( );
597 /** Returns the default image which clients should use for expanded nodes, to have a consistent user
598 interface experience in the whole product.
600 static const Image
& GetDefaultCollapsedNodeImage( );
602 /** Sets default bitmaps for collapsed and expanded nodes.
604 inline void SetNodeDefaultImages( )
607 GetDefaultCollapsedNodeImage( ),
608 GetDefaultExpandedNodeImage( )
612 virtual SvTreeListEntry
* InsertEntry( const XubString
& rText
, SvTreeListEntry
* pParent
= 0,
613 sal_Bool bChildrenOnDemand
= sal_False
,
614 sal_uLong nPos
=LIST_APPEND
, void* pUserData
= 0,
615 SvLBoxButtonKind eButtonKind
= SvLBoxButtonKind_enabledCheckbox
);
617 virtual SvTreeListEntry
* InsertEntry( const XubString
& rText
,
618 const Image
& rExpandedEntryBmp
,
619 const Image
& rCollapsedEntryBmp
,
620 SvTreeListEntry
* pParent
= 0,
621 sal_Bool bChildrenOnDemand
= sal_False
,
622 sal_uLong nPos
= LIST_APPEND
, void* pUserData
= 0,
623 SvLBoxButtonKind eButtonKind
= SvLBoxButtonKind_enabledCheckbox
);
625 const Image
& GetDefaultExpandedEntryBmp( ) const;
626 const Image
& GetDefaultCollapsedEntryBmp( ) const;
628 void SetDefaultExpandedEntryBmp( const Image
& rBmp
);
629 void SetDefaultCollapsedEntryBmp( const Image
& rBmp
);
631 void SetCheckButtonState( SvTreeListEntry
*, SvButtonState
);
632 SvButtonState
GetCheckButtonState( SvTreeListEntry
* ) const;
634 void SetEntryText(SvTreeListEntry
*, const XubString
& );
635 void SetExpandedEntryBmp( SvTreeListEntry
* _pEntry
, const Image
& _rImage
);
636 void SetCollapsedEntryBmp( SvTreeListEntry
* _pEntry
, const Image
& _rImage
);
638 virtual String
GetEntryText( SvTreeListEntry
* pEntry
) const;
639 String
SearchEntryText( SvTreeListEntry
* pEntry
) const;
640 const Image
& GetExpandedEntryBmp(const SvTreeListEntry
* _pEntry
) const;
641 const Image
& GetCollapsedEntryBmp(const SvTreeListEntry
* _pEntry
) const;
643 void SetCheckButtonHdl( const Link
& rLink
) { aCheckButtonHdl
=rLink
; }
644 Link
GetCheckButtonHdl() const { return aCheckButtonHdl
; }
645 virtual void CheckButtonHdl();
647 void SetSublistOpenWithReturn( sal_Bool bMode
= sal_True
); // open/close sublist with return/enter
648 void SetSublistOpenWithLeftRight( sal_Bool bMode
= sal_True
); // open/close sublist with cursor left/right
650 void EnableInplaceEditing( bool bEnable
);
651 // Edits the Entry's first StringItem, 0 == Cursor
652 void EditEntry( SvTreeListEntry
* pEntry
= NULL
);
653 virtual sal_Bool
EditingEntry( SvTreeListEntry
* pEntry
, Selection
& );
654 virtual sal_Bool
EditedEntry( SvTreeListEntry
* pEntry
, const OUString
& rNewText
);
656 virtual void Paint( const Rectangle
& rRect
);
657 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
658 virtual void MouseButtonUp( const MouseEvent
& rMEvt
);
659 virtual void MouseMove( const MouseEvent
& rMEvt
);
660 virtual void KeyInput( const KeyEvent
& rKEvt
);
661 virtual void Resize();
662 virtual void GetFocus();
663 virtual void LoseFocus();
664 void SetUpdateMode( sal_Bool
);
666 virtual void ModelHasCleared();
667 virtual void ModelHasInserted( SvTreeListEntry
* pEntry
);
668 virtual void ModelHasInsertedTree( SvTreeListEntry
* pEntry
);
669 virtual void ModelIsMoving(SvTreeListEntry
* pSource
,
670 SvTreeListEntry
* pTargetParent
, sal_uLong nChildPos
);
671 virtual void ModelHasMoved(SvTreeListEntry
* pSource
);
672 virtual void ModelIsRemoving( SvTreeListEntry
* pEntry
);
673 virtual void ModelHasRemoved( SvTreeListEntry
* pEntry
);
674 void ModelHasEntryInvalidated( SvTreeListEntry
* pEntry
);
676 void ShowTargetEmphasis( SvTreeListEntry
*, sal_Bool bShow
);
677 void ScrollOutputArea( short nDeltaEntries
);
679 short GetEntryHeight() const { return nEntryHeight
; }
680 void SetEntryHeight( short nHeight
, sal_Bool bAlways
= sal_False
);
681 Size
GetOutputSizePixel() const;
682 short GetIndent() const { return nIndent
; }
683 void SetIndent( short nIndent
);
684 void SetSpaceBetweenEntries( short nSpace
);
685 short GetSpaceBetweenEntries() const {return nEntryHeightOffs
;}
686 Point
GetEntryPosition( SvTreeListEntry
* ) const;
687 void ShowEntry( SvTreeListEntry
* ); // !!!OBSOLETE, use MakeVisible
688 void MakeVisible( SvTreeListEntry
* pEntry
);
689 void MakeVisible( SvTreeListEntry
* pEntry
, sal_Bool bMoveToTop
);
691 void SetCollapsedNodeBmp( const Image
& );
692 void SetExpandedNodeBmp( const Image
& );
693 Image
GetExpandedNodeBmp( ) const;
695 void SetFont( const Font
& rFont
);
697 using Window::SetCursor
;
698 void SetCursor( SvTreeListEntry
* pEntry
, sal_Bool bForceNoSelect
= sal_False
);
700 SvTreeListEntry
* GetEntry( const Point
& rPos
, sal_Bool bHit
= sal_False
) const;
702 void PaintEntry( SvTreeListEntry
* );
703 long PaintEntry( SvTreeListEntry
*, long nLine
,
704 sal_uInt16 nTabFlagMask
=0xffff );
705 virtual Rectangle
GetFocusRect( SvTreeListEntry
*, long nLine
);
706 // Respects indentation
707 virtual long GetTabPos( SvTreeListEntry
*, SvLBoxTab
* );
708 void InvalidateEntry( SvTreeListEntry
* );
709 SvLBoxItem
* GetItem( SvTreeListEntry
*, long nX
, SvLBoxTab
** ppTab
);
710 SvLBoxItem
* GetItem( SvTreeListEntry
*, long nX
);
712 void SetDragDropMode( DragDropMode
);
713 void SetSelectionMode( SelectionMode
);
715 sal_Bool
Expand( SvTreeListEntry
* pParent
);
716 sal_Bool
Collapse( SvTreeListEntry
* pParent
);
717 virtual sal_Bool
Select( SvTreeListEntry
* pEntry
, sal_Bool bSelect
=sal_True
);
718 sal_uLong
SelectChildren( SvTreeListEntry
* pParent
, sal_Bool bSelect
);
719 virtual void SelectAll( sal_Bool bSelect
, sal_Bool bPaint
= sal_True
);
721 void SetCurEntry( SvTreeListEntry
* _pEntry
);
722 SvTreeListEntry
* GetCurEntry() const;
724 using Window::Invalidate
;
725 virtual void Invalidate( sal_uInt16 nFlags
= 0);
726 virtual void Invalidate( const Rectangle
&, sal_uInt16 nFlags
= 0 );
728 void SetHighlightRange(sal_uInt16 nFirstTab
=0,sal_uInt16 nLastTab
=0xffff);
730 // A Parent's Children are turned into Children of the Parent which comes next in hierarchy
731 void RemoveParentKeepChildren( SvTreeListEntry
* pParent
);
733 DECL_LINK( DefaultCompare
, SvSortData
* );
734 virtual void ModelNotification( sal_uInt16 nActionId
, SvTreeListEntry
* pEntry1
,
735 SvTreeListEntry
* pEntry2
, sal_uLong nPos
);
738 void RepaintScrollBars() const;
739 ScrollBar
* GetVScroll();
740 ScrollBar
* GetHScroll();
741 void EnableAsyncDrag( sal_Bool b
);
743 SvTreeListEntry
* GetFirstEntryInView() const;
744 SvTreeListEntry
* GetNextEntryInView(SvTreeListEntry
*) const;
745 SvTreeListEntry
* GetLastEntryInView() const;
746 void ScrollToAbsPos( long nPos
);
748 void ShowFocusRect( const SvTreeListEntry
* pEntry
);
749 void InitStartEntry();
751 virtual PopupMenu
* CreateContextMenu( void );
752 virtual void ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry
);
754 void EnableContextMenuHandling( void );
755 void EnableContextMenuHandling( sal_Bool bEnable
);
756 sal_Bool
IsContextMenuHandlingEnabled( void ) const;
758 void EnableList( bool _bEnable
);
760 long getPreferredDimensions(std::vector
<long> &rWidths
) const;
762 virtual Size
GetOptimalSize() const;
765 #define SV_LBOX_DD_FORMAT "SV_LBOX_DD_FORMAT"
769 SvTreeListBox
* pSource
;
770 SvTreeListEntry
* pDDStartEntry
;
771 // Relative position in the Entry at DragBeginn (IconView)
772 long nMouseRelX
,nMouseRelY
;
773 sal_uLong nRes1
,nRes2
,nRes3
,nRes4
;
779 Accelerator aAccReturn
;
780 Accelerator aAccEscape
;
784 sal_Bool bAlreadyInCallBack
;
786 void CallCallBackHdl_Impl();
787 DECL_LINK( Timeout_Impl
, void * );
788 DECL_LINK( ReturnHdl_Impl
, void * );
789 DECL_LINK( EscapeHdl_Impl
, void * );
792 SvInplaceEdit2( Window
* pParent
, const Point
& rPos
, const Size
& rSize
,
793 const String
& rData
, const Link
& rNotifyEditEnd
,
794 const Selection
&, sal_Bool bMultiLine
= sal_False
);
796 sal_Bool
KeyInput( const KeyEvent
& rKEvt
);
798 sal_Bool
EditingCanceled() const { return bCanceled
; }
799 OUString
GetText() const;
800 String
GetSavedValue() const;
801 void StopEditing( sal_Bool bCancel
= sal_False
);
807 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */