bump product version to 4.2.0.1
[LibreOffice.git] / include / svtools / treelistbox.hxx
blob980f88ce9a53d4ef3f4bdbb61140683d80829907
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 INCLUDED_SVTOOLS_TREELISTBOX_HXX
21 #define INCLUDED_SVTOOLS_TREELISTBOX_HXX
23 #include <svtools/svtdllapi.h>
25 #include <deque>
26 #include <vector>
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>
41 class Application;
42 class SvTreeListBox;
43 class SvTreeListEntry;
44 struct SvViewDataItem;
45 class SvViewDataEntry;
46 class SvInplaceEdit2;
47 class SvLBoxString;
48 class SvLBoxButton;
49 class SvLBoxContextBmp;
50 class SvLBoxBmp;
51 class SvImpLBox;
52 class SvLBoxButtonData;
53 struct SvLBoxDDInfo;
55 namespace utl {
56 class AccessibleStateSetHelper;
59 enum SvLBoxButtonKind
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
89 // and column widths
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
110 class SvLBoxTab
112 long nPos;
113 void* pUserData;
114 public:
115 SvLBoxTab();
116 SvLBoxTab( long nPos, sal_uInt16 nFlags=SV_LBOXTAB_ADJUST_LEFT );
117 SvLBoxTab( const SvLBoxTab& );
118 ~SvLBoxTab();
120 sal_uInt16 nFlags;
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 sal_Bool IsEditable() const { return (sal_Bool)((nFlags & SV_LBOXTAB_EDITABLE)!=0); }
129 sal_Bool IsPushable() const { return (sal_Bool)((nFlags & SV_LBOXTAB_PUSHABLE)!=0); }
132 // *********************************************************************
133 // ****************************** Items ********************************
134 // *********************************************************************
136 class SVT_DLLPUBLIC SvLBoxItem
138 public:
139 SvLBoxItem( SvTreeListEntry*, sal_uInt16 nFlags );
140 SvLBoxItem();
141 virtual ~SvLBoxItem();
142 virtual sal_uInt16 GetType() const = 0;
143 const Size& GetSize(const SvTreeListBox* pView, const SvTreeListEntry* pEntry) const;
144 const Size& GetSize(const SvViewDataEntry* pData, sal_uInt16 nItemPos) const;
146 virtual void Paint(
147 const Point& rPos, SvTreeListBox& rOutDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry) = 0;
149 virtual void InitViewData( SvTreeListBox* pView, SvTreeListEntry* pEntry,
150 // If != 0: this Pointer must be used!
151 // If == 0: it needs to be retrieved via the View
152 SvViewDataItem* pViewData = 0) = 0;
153 virtual SvLBoxItem* Create() const = 0;
154 // View-dependent data is not cloned
155 virtual void Clone( SvLBoxItem* pSource ) = 0;
158 inline SvLBoxItem* new_clone(const SvLBoxItem& rSrc)
160 SvLBoxItem* p = rSrc.Create();
161 p->Clone(const_cast<SvLBoxItem*>(&rSrc));
162 return p;
165 inline void delete_clone(const SvLBoxItem* p)
167 delete p;
170 // *********************************************************************
171 // ****************************** SvTreeListBox ************************
172 // *********************************************************************
174 #define WB_FORCE_SELECTION ((WinBits)0x8000)
176 #define DragDropMode sal_uInt16
177 #define SV_DRAGDROP_NONE (DragDropMode)0x0000
178 #define SV_DRAGDROP_CTRL_MOVE (DragDropMode)0x0001
179 #define SV_DRAGDROP_CTRL_COPY (DragDropMode)0x0002
180 #define SV_DRAGDROP_APP_MOVE (DragDropMode)0x0004
181 #define SV_DRAGDROP_APP_COPY (DragDropMode)0x0008
182 #define SV_DRAGDROP_APP_DROP (DragDropMode)0x0010
183 // Entries may be dropped via the uppermost Entry
184 // The DropTarget is 0 in that case
185 #define SV_DRAGDROP_ENABLE_TOP (DragDropMode)0x0020
187 #define SVLISTBOX_ID_LBOX 0 // for SvTreeListBox::GetType()
189 #define SVLBOX_IN_EDT 0x0001
190 #define SVLBOX_EDT_ENABLED 0x0002
191 #define SVLBOX_IS_EXPANDING 0x0004
192 #define SVLBOX_IS_TRAVELSELECT 0x0008
193 #define SVLBOX_TARGEMPH_VIS 0x0010
194 #define SVLBOX_EDTEND_CALLED 0x0020
196 struct SvTreeListBoxImpl;
198 class SVT_DLLPUBLIC SvTreeListBox
199 :public Control
200 ,public SvListView
201 ,public DropTargetHelper
202 ,public DragSourceHelper
203 ,public ::vcl::IMnemonicEntryList
204 ,public ::vcl::ISearchableStringList
206 friend class SvImpLBox;
207 friend class TreeControlPeer;
209 SvTreeListBoxImpl* mpImpl;
210 SvImpLBox* pImp;
211 Link aCheckButtonHdl;
212 Link aScrolledHdl;
213 Link aExpandedHdl;
214 Link aExpandingHdl;
215 Link aSelectHdl;
216 Link aDeselectHdl;
218 Accelerator aInpEditAcc;
219 Image aPrevInsertedExpBmp;
220 Image aPrevInsertedColBmp;
221 Image aCurInsertedExpBmp;
222 Image aCurInsertedColBmp;
224 short nContextBmpWidthMax;
225 short nEntryHeight;
226 short nEntryHeightOffs;
227 short nIndent;
228 short nFocusWidth;
229 sal_uInt16 nFirstSelTab;
230 sal_uInt16 nLastSelTab;
231 long mnCheckboxItemWidth;
232 bool mbContextBmpExpanded;
234 SvTreeListEntry* pHdlEntry;
235 SvLBoxItem* pHdlItem;
237 DragDropMode nDragDropMode;
238 DragDropMode nOldDragMode;
239 SelectionMode eSelMode;
240 sal_Int8 nDragOptions;
241 sal_Int32 nMinWidthInChars;
243 SvTreeListEntry* pEdEntry;
244 SvLBoxItem* pEdItem;
246 protected:
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;
256 private:
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* );
274 protected:
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 );
296 // In-place editing
297 SvInplaceEdit2* pEdCtrl;
298 void EditText( const OUString&, const Rectangle&,const Selection&);
299 void EditText( const OUString&, const Rectangle&,const Selection&, sal_Bool bMulti);
300 void EditTextMultiLine( const OUString&, 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( OUString& _rEntryText ) const;
330 virtual const void* NextSearchEntry( const void* _pCurrentSearchEntry, OUString& _rEntryText ) const;
331 virtual void SelectSearchEntry( const void* _pEntry );
332 virtual void ExecuteSearchEntry( const void* _pEntry ) const;
334 // ISearchableStringList
335 virtual ::vcl::StringEntryIdentifier CurrentEntry( OUString& _out_entryText ) const;
336 virtual ::vcl::StringEntryIdentifier NextEntry( ::vcl::StringEntryIdentifier _currentEntry, OUString& _out_entryText ) const;
337 virtual void SelectEntry( ::vcl::StringEntryIdentifier _entry );
339 public:
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();
392 void Clear();
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
412 are enabled.
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
421 @see MnemonicEngine
423 @return
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 );
451 // Drag & Drop
452 // New D'n'D API
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,
457 SvTreeListEntry* );
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.
497 @param pEntry
498 The 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();
505 void set_min_width_in_chars(sal_Int32 nChars);
507 virtual bool set_property(const OString &rKey, const OString &rValue);
509 protected:
510 using SvListView::Expand;
511 using SvListView::Collapse;
512 using SvListView::Select;
513 using SvListView::SelectAll;
515 SVT_DLLPRIVATE short GetHeightOffset( const Image& rBmp, Size& rLogicSize);
516 SVT_DLLPRIVATE short GetHeightOffset( const Font& rFont, Size& rLogicSize);
518 SVT_DLLPRIVATE void SetEntryHeight( SvTreeListEntry* pEntry );
519 SVT_DLLPRIVATE void AdjustEntryHeight( const Image& rBmp );
520 SVT_DLLPRIVATE void AdjustEntryHeight( const Font& rFont );
522 SVT_DLLPRIVATE void ImpEntryInserted( SvTreeListEntry* pEntry );
523 SVT_DLLPRIVATE long PaintEntry1( SvTreeListEntry*, long nLine,
524 sal_uInt16 nTabFlagMask=0xffff,
525 sal_Bool bHasClipRegion=sal_False );
527 SVT_DLLPRIVATE void InitTreeView();
528 SVT_DLLPRIVATE SvLBoxItem* GetItem_Impl( SvTreeListEntry*, long nX, SvLBoxTab** ppTab,
529 sal_uInt16 nEmptyWidth );
530 SVT_DLLPRIVATE void ImplInitStyle();
532 protected:
534 void EditItemText( SvTreeListEntry* pEntry, SvLBoxString* pItem,
535 const Selection& );
536 void EditedText(const OUString&);
538 // Recalculate all tabs depending on TreeListStyle and Bitmap sizes
539 // Is called automatically when inserting/changing Bitmaps, changing the Model etc.
540 virtual void SetTabs();
541 void SetTabs_Impl();
542 void AddTab( long nPos,sal_uInt16 nFlags=SV_LBOXTAB_ADJUST_LEFT,
543 void* pUserData = 0 );
544 sal_uInt16 TabCount() const { return aTabs.size(); }
545 SvLBoxTab* GetFirstDynamicTab() const;
546 SvLBoxTab* GetFirstDynamicTab( sal_uInt16& rTabPos ) const;
547 SvLBoxTab* GetFirstTab( sal_uInt16 nFlagMask, sal_uInt16& rTabPos );
548 SvLBoxTab* GetLastTab( sal_uInt16 nFlagMask, sal_uInt16& rTabPos );
549 SvLBoxTab* GetTab( SvTreeListEntry*, SvLBoxItem* ) const;
550 void ClearTabList();
552 virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&, SvLBoxButtonKind);
554 virtual void NotifyBeginScroll();
555 virtual void NotifyEndScroll();
556 // nLines == 0 => horizontal Scrolling
557 virtual void NotifyScrolling( long nLines );
558 virtual void NotifyScrolled();
559 void SetScrolledHdl( const Link& rLink ) { aScrolledHdl = rLink; }
560 const Link& GetScrolledHdl() const { return aScrolledHdl; }
561 long GetXOffset() const { return GetMapMode().GetOrigin().X(); }
563 // Is called _before_ Areas in the Control are invalidated.
564 // This can be used to hide Elements which are painted from outside into the Control
565 virtual void NotifyInvalidating();
567 virtual void Command( const CommandEvent& rCEvt );
569 virtual void RequestHelp( const HelpEvent& rHEvt );
570 virtual void CursorMoved( SvTreeListEntry* pNewCursor );
571 virtual void PreparePaint( SvTreeListEntry* );
572 virtual void DataChanged( const DataChangedEvent& rDCEvt );
574 void InitSettings(sal_Bool bFont,sal_Bool bForeground,sal_Bool bBackground);
575 sal_Bool IsCellFocusEnabled() const;
576 bool SetCurrentTabPos( sal_uInt16 _nNewPos );
577 sal_uInt16 GetCurrentTabPos() const;
578 void CallImplEventListeners(sal_uLong nEvent, void* pData);
580 void ImplEditEntry( SvTreeListEntry* pEntry );
582 sal_Bool AreChildrenTransient() const;
583 void SetChildrenNotTransient();
585 void AdjustEntryHeightAndRecalc( const Font& rFont );
586 public:
588 void SetExtendedWinBits( ExtendedWinBits _nBits );
590 void DisconnectFromModel();
592 void EnableCheckButton( SvLBoxButtonData* );
593 void SetCheckButtonData( SvLBoxButtonData* );
594 void SetNodeBitmaps( const Image& rCollapsedNodeBmp, const Image& rExpandedNodeBmp );
596 /** Returns the default image which clients should use for expanded nodes, to have a consistent user
597 interface experience in the whole product.
599 static const Image& GetDefaultExpandedNodeImage( );
601 /** Returns the default image which clients should use for expanded nodes, to have a consistent user
602 interface experience in the whole product.
604 static const Image& GetDefaultCollapsedNodeImage( );
606 /** Sets default bitmaps for collapsed and expanded nodes.
608 inline void SetNodeDefaultImages( )
610 SetNodeBitmaps(
611 GetDefaultCollapsedNodeImage( ),
612 GetDefaultExpandedNodeImage( )
616 virtual SvTreeListEntry* InsertEntry( const OUString& rText, SvTreeListEntry* pParent = 0,
617 sal_Bool bChildrenOnDemand = sal_False,
618 sal_uLong nPos=LIST_APPEND, void* pUserData = 0,
619 SvLBoxButtonKind eButtonKind = SvLBoxButtonKind_enabledCheckbox );
621 virtual SvTreeListEntry* InsertEntry( const OUString& rText,
622 const Image& rExpandedEntryBmp,
623 const Image& rCollapsedEntryBmp,
624 SvTreeListEntry* pParent = 0,
625 sal_Bool bChildrenOnDemand = sal_False,
626 sal_uLong nPos = LIST_APPEND, void* pUserData = 0,
627 SvLBoxButtonKind eButtonKind = SvLBoxButtonKind_enabledCheckbox );
629 const Image& GetDefaultExpandedEntryBmp( ) const;
630 const Image& GetDefaultCollapsedEntryBmp( ) const;
632 void SetDefaultExpandedEntryBmp( const Image& rBmp );
633 void SetDefaultCollapsedEntryBmp( const Image& rBmp );
635 void SetCheckButtonState( SvTreeListEntry*, SvButtonState );
636 void SetCheckButtonInvisible( SvTreeListEntry* );
637 SvButtonState GetCheckButtonState( SvTreeListEntry* ) const;
639 void SetEntryText(SvTreeListEntry*, const OUString& );
640 void SetExpandedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage );
641 void SetCollapsedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage );
643 virtual OUString GetEntryText( SvTreeListEntry* pEntry ) const;
644 OUString SearchEntryText( SvTreeListEntry* pEntry ) const;
645 const Image& GetExpandedEntryBmp(const SvTreeListEntry* _pEntry ) const;
646 const Image& GetCollapsedEntryBmp(const SvTreeListEntry* _pEntry ) const;
648 void SetCheckButtonHdl( const Link& rLink ) { aCheckButtonHdl=rLink; }
649 Link GetCheckButtonHdl() const { return aCheckButtonHdl; }
650 virtual void CheckButtonHdl();
652 void SetSublistOpenWithReturn( sal_Bool bMode = sal_True ); // open/close sublist with return/enter
653 void SetSublistOpenWithLeftRight( sal_Bool bMode = sal_True ); // open/close sublist with cursor left/right
655 void EnableInplaceEditing( bool bEnable );
656 // Edits the Entry's first StringItem, 0 == Cursor
657 void EditEntry( SvTreeListEntry* pEntry = NULL );
658 virtual sal_Bool EditingEntry( SvTreeListEntry* pEntry, Selection& );
659 virtual sal_Bool EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText );
661 virtual void Paint( const Rectangle& rRect );
662 virtual void MouseButtonDown( const MouseEvent& rMEvt );
663 virtual void MouseButtonUp( const MouseEvent& rMEvt );
664 virtual void MouseMove( const MouseEvent& rMEvt );
665 virtual void KeyInput( const KeyEvent& rKEvt );
666 virtual void Resize();
667 virtual void GetFocus();
668 virtual void LoseFocus();
669 void SetUpdateMode( sal_Bool );
671 virtual void ModelHasCleared();
672 virtual void ModelHasInserted( SvTreeListEntry* pEntry );
673 virtual void ModelHasInsertedTree( SvTreeListEntry* pEntry );
674 virtual void ModelIsMoving(SvTreeListEntry* pSource,
675 SvTreeListEntry* pTargetParent, sal_uLong nChildPos );
676 virtual void ModelHasMoved(SvTreeListEntry* pSource );
677 virtual void ModelIsRemoving( SvTreeListEntry* pEntry );
678 virtual void ModelHasRemoved( SvTreeListEntry* pEntry );
679 void ModelHasEntryInvalidated( SvTreeListEntry* pEntry );
681 void ShowTargetEmphasis( SvTreeListEntry*, sal_Bool bShow );
682 void ScrollOutputArea( short nDeltaEntries );
684 short GetEntryHeight() const { return nEntryHeight; }
685 void SetEntryHeight( short nHeight, sal_Bool bAlways = sal_False );
686 Size GetOutputSizePixel() const;
687 short GetIndent() const { return nIndent; }
688 void SetIndent( short nIndent );
689 // Place the expander checkitem at the optimal indent for hierarchical lists
690 void SetOptimalImageIndent() { SetIndent(12); }
691 void SetSpaceBetweenEntries( short nSpace );
692 short GetSpaceBetweenEntries() const {return nEntryHeightOffs;}
693 Point GetEntryPosition( SvTreeListEntry* ) const;
694 void ShowEntry( SvTreeListEntry* ); // !!!OBSOLETE, use MakeVisible
695 void MakeVisible( SvTreeListEntry* pEntry );
696 void MakeVisible( SvTreeListEntry* pEntry, sal_Bool bMoveToTop );
698 void SetCollapsedNodeBmp( const Image& );
699 void SetExpandedNodeBmp( const Image& );
700 Image GetExpandedNodeBmp( ) const;
702 void SetFont( const Font& rFont );
704 using Window::SetCursor;
705 void SetCursor( SvTreeListEntry* pEntry, sal_Bool bForceNoSelect = sal_False );
707 SvTreeListEntry* GetEntry( const Point& rPos, sal_Bool bHit = sal_False ) const;
709 void PaintEntry( SvTreeListEntry* );
710 long PaintEntry( SvTreeListEntry*, long nLine,
711 sal_uInt16 nTabFlagMask=0xffff );
712 virtual Rectangle GetFocusRect( SvTreeListEntry*, long nLine );
713 // Respects indentation
714 virtual sal_IntPtr GetTabPos( SvTreeListEntry*, SvLBoxTab* );
715 void InvalidateEntry( SvTreeListEntry* );
716 SvLBoxItem* GetItem( SvTreeListEntry*, long nX, SvLBoxTab** ppTab);
717 SvLBoxItem* GetItem( SvTreeListEntry*, long nX );
719 void SetDragDropMode( DragDropMode );
720 void SetSelectionMode( SelectionMode );
722 sal_Bool Expand( SvTreeListEntry* pParent );
723 sal_Bool Collapse( SvTreeListEntry* pParent );
724 virtual sal_Bool Select( SvTreeListEntry* pEntry, sal_Bool bSelect=sal_True );
725 sal_uLong SelectChildren( SvTreeListEntry* pParent, sal_Bool bSelect );
726 virtual void SelectAll( sal_Bool bSelect, sal_Bool bPaint = sal_True );
728 void SetCurEntry( SvTreeListEntry* _pEntry );
729 SvTreeListEntry* GetCurEntry() const;
731 using Window::Invalidate;
732 virtual void Invalidate( sal_uInt16 nFlags = 0);
733 virtual void Invalidate( const Rectangle&, sal_uInt16 nFlags = 0 );
735 void SetHighlightRange(sal_uInt16 nFirstTab=0,sal_uInt16 nLastTab=0xffff);
737 // A Parent's Children are turned into Children of the Parent which comes next in hierarchy
738 void RemoveParentKeepChildren( SvTreeListEntry* pParent );
740 DECL_LINK( DefaultCompare, SvSortData* );
741 virtual void ModelNotification( sal_uInt16 nActionId, SvTreeListEntry* pEntry1,
742 SvTreeListEntry* pEntry2, sal_uLong nPos );
744 void EndSelection();
745 void RepaintScrollBars() const;
746 ScrollBar* GetVScroll();
747 ScrollBar* GetHScroll();
748 void EnableAsyncDrag( sal_Bool b );
750 SvTreeListEntry* GetFirstEntryInView() const;
751 SvTreeListEntry* GetNextEntryInView(SvTreeListEntry*) const;
752 SvTreeListEntry* GetLastEntryInView() const;
753 void ScrollToAbsPos( long nPos );
755 void ShowFocusRect( const SvTreeListEntry* pEntry );
756 void InitStartEntry();
758 virtual PopupMenu* CreateContextMenu( void );
759 virtual void ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry );
761 void EnableContextMenuHandling( void );
762 void EnableContextMenuHandling( sal_Bool bEnable );
763 sal_Bool IsContextMenuHandlingEnabled( void ) const;
765 void EnableList( bool _bEnable );
767 long getPreferredDimensions(std::vector<long> &rWidths) const;
769 virtual Size GetOptimalSize() const;
772 #define SV_LBOX_DD_FORMAT "SV_LBOX_DD_FORMAT"
773 struct SvLBoxDDInfo
775 Application* pApp;
776 SvTreeListBox* pSource;
777 SvTreeListEntry* pDDStartEntry;
778 // Relative position in the Entry at DragBeginn (IconView)
779 long nMouseRelX,nMouseRelY;
780 sal_uLong nRes1,nRes2,nRes3,nRes4;
783 class SvInplaceEdit2
785 Link aCallBackHdl;
786 Accelerator aAccReturn;
787 Accelerator aAccEscape;
788 Timer aTimer;
789 Edit* pEdit;
790 sal_Bool bCanceled;
791 sal_Bool bAlreadyInCallBack;
793 void CallCallBackHdl_Impl();
794 DECL_LINK( Timeout_Impl, void * );
795 DECL_LINK( ReturnHdl_Impl, void * );
796 DECL_LINK( EscapeHdl_Impl, void * );
798 public:
799 SvInplaceEdit2( Window* pParent, const Point& rPos, const Size& rSize,
800 const OUString& rData, const Link& rNotifyEditEnd,
801 const Selection&, sal_Bool bMultiLine = sal_False );
802 ~SvInplaceEdit2();
803 sal_Bool KeyInput( const KeyEvent& rKEvt );
804 void LoseFocus();
805 sal_Bool EditingCanceled() const { return bCanceled; }
806 OUString GetText() const;
807 OUString GetSavedValue() const;
808 void StopEditing( sal_Bool bCancel = sal_False );
809 void Hide();
812 #endif
814 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */