Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_SVTOOLS_TREELISTBOX_HXX
21 : #define INCLUDED_SVTOOLS_TREELISTBOX_HXX
22 :
23 : #include <svtools/svtdllapi.h>
24 :
25 : #include <deque>
26 : #include <vector>
27 :
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>
40 :
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;
54 :
55 : namespace utl {
56 : class AccessibleStateSetHelper;
57 : }
58 :
59 : enum SvLBoxButtonKind
60 : {
61 : SvLBoxButtonKind_enabledCheckbox,
62 : SvLBoxButtonKind_disabledCheckbox,
63 : SvLBoxButtonKind_staticImage
64 : };
65 :
66 : enum SvButtonState { SV_BUTTON_UNCHECKED, SV_BUTTON_CHECKED, SV_BUTTON_TRISTATE };
67 :
68 : // *********************************************************************
69 : // *************************** Tabulators ******************************
70 : // *********************************************************************
71 :
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)
77 :
78 : // Is not supported anymore! The focus is now controlled by selection!
79 : #define SV_LBOXTAB_SHOW_FOCUS 0x0020 // Visualize focus
80 :
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
90 :
91 : #define SV_TAB_BORDER 8
92 :
93 : #define SV_ENTRYHEIGHTOFFS_PIXEL 2
94 :
95 : #define TREEFLAG_CHKBTN 0x0001
96 : #define TREEFLAG_USESEL 0x0002
97 : #define TREEFLAG_MANINS 0x0004
98 : #define TREEFLAG_RECALCTABS 0x0008
99 :
100 : #define TREEBOX_ALLITEM_ACCROLE_TYPE_NOTSET 0x00
101 : #define TREEBOX_ALLITEM_ACCROLE_TYPE_LIST 0x01
102 : #define TREEBOX_ALLITEM_ACCROLE_TYPE_TREE 0x02
103 :
104 : typedef sal_Int64 ExtendedWinBits;
105 :
106 : // disable the behavior of automatically selecting a "CurEntry" upon painting the control
107 : #define EWB_NO_AUTO_CURENTRY 0x00000001
108 :
109 : #define SV_ITEM_ID_LBOXSTRING 1
110 : #define SV_ITEM_ID_LBOXBMP 2
111 : #define SV_ITEM_ID_LBOXBUTTON 3
112 : #define SV_ITEM_ID_LBOXCONTEXTBMP 4
113 : #define SV_ITEM_ID_EXTENDRLBOXSTRING 5
114 :
115 : class SvLBoxTab
116 : {
117 : long nPos;
118 : void* pUserData;
119 : public:
120 : SvLBoxTab();
121 : SvLBoxTab( long nPos, sal_uInt16 nFlags=SV_LBOXTAB_ADJUST_LEFT );
122 : SvLBoxTab( const SvLBoxTab& );
123 : ~SvLBoxTab();
124 :
125 : sal_uInt16 nFlags;
126 :
127 3664 : void SetUserData( void* pPtr ) { pUserData = pPtr; }
128 : void* GetUserData() const { return pUserData; }
129 350 : bool IsDynamic() const { return ((nFlags & SV_LBOXTAB_DYNAMIC)!=0); }
130 0 : void SetPos( long nNewPos) { nPos = nNewPos; }
131 9611 : long GetPos() const { return nPos; }
132 : long CalcOffset( long nItemLength, long nTabWidth );
133 0 : bool IsEditable() const { return ((nFlags & SV_LBOXTAB_EDITABLE)!=0); }
134 : bool IsPushable() const { return ((nFlags & SV_LBOXTAB_PUSHABLE)!=0); }
135 : };
136 :
137 : // *********************************************************************
138 : // ****************************** Items ********************************
139 : // *********************************************************************
140 :
141 : class SVT_DLLPUBLIC SvLBoxItem
142 : {
143 : public:
144 : SvLBoxItem( SvTreeListEntry*, sal_uInt16 nFlags );
145 : SvLBoxItem();
146 : virtual ~SvLBoxItem();
147 : virtual sal_uInt16 GetType() const = 0;
148 : const Size& GetSize(const SvTreeListBox* pView, const SvTreeListEntry* pEntry) const;
149 : const Size& GetSize(const SvViewDataEntry* pData, sal_uInt16 nItemPos) const;
150 :
151 : virtual void Paint(
152 : const Point& rPos, SvTreeListBox& rOutDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry) = 0;
153 :
154 : virtual void InitViewData( SvTreeListBox* pView, SvTreeListEntry* pEntry,
155 : // If != 0: this Pointer must be used!
156 : // If == 0: it needs to be retrieved via the View
157 : SvViewDataItem* pViewData = 0) = 0;
158 : virtual SvLBoxItem* Create() const = 0;
159 : // View-dependent data is not cloned
160 : virtual void Clone( SvLBoxItem* pSource ) = 0;
161 : };
162 :
163 : inline SvLBoxItem* new_clone(const SvLBoxItem& rSrc)
164 : {
165 : SvLBoxItem* p = rSrc.Create();
166 : p->Clone(const_cast<SvLBoxItem*>(&rSrc));
167 : return p;
168 : }
169 :
170 4350 : inline void delete_clone(const SvLBoxItem* p)
171 : {
172 4350 : delete p;
173 4350 : }
174 :
175 : // *********************************************************************
176 : // ****************************** SvTreeListBox ************************
177 : // *********************************************************************
178 :
179 : #define WB_FORCE_SELECTION ((WinBits)0x8000)
180 :
181 : #define DragDropMode sal_uInt16
182 : #define SV_DRAGDROP_NONE (DragDropMode)0x0000
183 : #define SV_DRAGDROP_CTRL_MOVE (DragDropMode)0x0001
184 : #define SV_DRAGDROP_CTRL_COPY (DragDropMode)0x0002
185 : #define SV_DRAGDROP_APP_MOVE (DragDropMode)0x0004
186 : #define SV_DRAGDROP_APP_COPY (DragDropMode)0x0008
187 : #define SV_DRAGDROP_APP_DROP (DragDropMode)0x0010
188 : // Entries may be dropped via the uppermost Entry
189 : // The DropTarget is 0 in that case
190 : #define SV_DRAGDROP_ENABLE_TOP (DragDropMode)0x0020
191 :
192 : #define SVLISTBOX_ID_LBOX 0 // for SvTreeListBox::GetType()
193 :
194 : #define SVLBOX_IN_EDT 0x0001
195 : #define SVLBOX_EDT_ENABLED 0x0002
196 : #define SVLBOX_IS_EXPANDING 0x0004
197 : #define SVLBOX_IS_TRAVELSELECT 0x0008
198 : #define SVLBOX_TARGEMPH_VIS 0x0010
199 : #define SVLBOX_EDTEND_CALLED 0x0020
200 :
201 : struct SvTreeListBoxImpl;
202 :
203 : class SVT_DLLPUBLIC SvTreeListBox
204 : :public Control
205 : ,public SvListView
206 : ,public DropTargetHelper
207 : ,public DragSourceHelper
208 : ,public ::vcl::IMnemonicEntryList
209 : ,public ::vcl::ISearchableStringList
210 : {
211 : friend class SvImpLBox;
212 : friend class TreeControlPeer;
213 :
214 : SvTreeListBoxImpl* mpImpl;
215 : SvImpLBox* pImp;
216 : Link aCheckButtonHdl;
217 : Link aScrolledHdl;
218 : Link aExpandedHdl;
219 : Link aExpandingHdl;
220 : Link aSelectHdl;
221 : Link aDeselectHdl;
222 :
223 : Accelerator aInpEditAcc;
224 : Image aPrevInsertedExpBmp;
225 : Image aPrevInsertedColBmp;
226 : Image aCurInsertedExpBmp;
227 : Image aCurInsertedColBmp;
228 :
229 : short nContextBmpWidthMax;
230 : short nEntryHeight;
231 : short nEntryHeightOffs;
232 : short nIndent;
233 : short nFocusWidth;
234 : short nAllItemAccRoleType;
235 : sal_uInt16 nFirstSelTab;
236 : sal_uInt16 nLastSelTab;
237 : long mnCheckboxItemWidth;
238 : bool mbContextBmpExpanded;
239 : bool mbAlternatingRowColors;
240 :
241 : SvTreeListEntry* pHdlEntry;
242 : SvLBoxItem* pHdlItem;
243 :
244 : DragDropMode nDragDropMode;
245 : DragDropMode nOldDragMode;
246 : SelectionMode eSelMode;
247 : sal_Int8 nDragOptions;
248 : sal_Int32 nMinWidthInChars;
249 :
250 : SvTreeListEntry* pEdEntry;
251 : SvLBoxItem* pEdItem;
252 :
253 : protected:
254 : Link aDoubleClickHdl;
255 : SvTreeListEntry* pTargetEntry;
256 : SvLBoxButtonData* pCheckButtonData;
257 : std::vector<SvLBoxTab*> aTabs;
258 : sal_uInt16 nTreeFlags;
259 : sal_uInt16 nImpFlags;
260 : // Move/CopySelection: Position of the current Entry in SelectionList
261 : sal_uInt16 nCurEntrySelPos;
262 :
263 : private:
264 : void SetBaseModel(SvTreeList* pNewModel);
265 :
266 : DECL_DLLPRIVATE_LINK( CheckButtonClick, SvLBoxButtonData * );
267 : DECL_DLLPRIVATE_LINK( TextEditEndedHdl_Impl, void * );
268 : // Handler that is called by TreeList to clone an Entry
269 : DECL_DLLPRIVATE_LINK( CloneHdl_Impl, SvTreeListEntry* );
270 :
271 : // Handler and methods for Drag - finished handler.
272 : // The Handle retrieved by GetDragFinishedHdl can be set on the
273 : // TransferDataContainer. This link is a callback for the DragFinished
274 : // call. The AddBox method is called from the GetDragFinishedHdl() and the
275 : // remove is called in the link callback and in the dtor. So it can't be
276 : // called for a deleted object.
277 : SVT_DLLPRIVATE static void AddBoxToDDList_Impl( const SvTreeListBox& rB );
278 : SVT_DLLPRIVATE static void RemoveBoxFromDDList_Impl( const SvTreeListBox& rB );
279 : DECL_DLLPRIVATE_STATIC_LINK( SvTreeListBox, DragFinishHdl_Impl, sal_Int8* );
280 :
281 : protected:
282 :
283 : bool CheckDragAndDropMode( SvTreeListBox* pSource, sal_Int8 );
284 : void ImplShowTargetEmphasis( SvTreeListEntry* pEntry, bool bShow);
285 : void EnableSelectionAsDropTarget( bool bEnable = true,
286 : bool bWithChildren = true );
287 : // Standard impl returns 0; must be overloaded by derived classes which support D'n'D
288 : using Window::GetDropTarget;
289 : virtual SvTreeListEntry* GetDropTarget( const Point& );
290 :
291 : // Put View-specific data into the Dragserver
292 : // Is called at the SourceView (in BeginDrag Handler)
293 : virtual void WriteDragServerInfo( const Point&, SvLBoxDDInfo* );
294 : // Is called at the TargetView (in Drop Handler)
295 : virtual void ReadDragServerInfo( const Point&,SvLBoxDDInfo* );
296 :
297 : // Invalidate children on enable/disable
298 : virtual void StateChanged( StateChangedType eType ) SAL_OVERRIDE;
299 :
300 : virtual sal_uLong Insert( SvTreeListEntry* pEnt,SvTreeListEntry* pPar,sal_uLong nPos=TREELIST_APPEND);
301 : virtual sal_uLong Insert( SvTreeListEntry* pEntry,sal_uLong nRootPos = TREELIST_APPEND );
302 :
303 : // In-place editing
304 : SvInplaceEdit2* pEdCtrl;
305 : void EditText( const OUString&, const Rectangle&,const Selection&);
306 : void EditText( const OUString&, const Rectangle&,const Selection&, bool bMulti);
307 : void EditTextMultiLine( const OUString&, const Rectangle&,const Selection&);
308 : void CancelTextEditing();
309 : bool EditingCanceled() const;
310 : bool IsEmptyTextAllowed() const;
311 :
312 : // Return value must be derived from SvViewDataEntry!
313 : virtual SvViewDataEntry* CreateViewData( SvTreeListEntry* ) SAL_OVERRIDE;
314 : // InitViewData is called right after CreateViewData
315 : // The Entry is has not yet been added to the View in InitViewData!
316 : virtual void InitViewData( SvViewDataEntry*, SvTreeListEntry* pEntry ) SAL_OVERRIDE;
317 : // Calls InitViewData for all Items
318 : void RecalcViewData();
319 : // Callback of RecalcViewData
320 : virtual void ViewDataInitialized( SvTreeListEntry* );
321 :
322 : // Handler and methods for Drag - finished handler. This link can be set
323 : // to the TransferDataContainer. The AddBox/RemoveBox methods must be
324 : // called before the StartDrag call.
325 : // The Remove will be called from the handler, which then calls DragFinish.
326 : // The Remove is also called in the DTOR of the SvTreeListBox -
327 : // so it can't be called for a deleted object.
328 : Link GetDragFinishedHdl() const;
329 :
330 : // For asynchronous D'n'D
331 : sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt, SvTreeListBox* pSourceView );
332 :
333 : void OnCurrentEntryChanged();
334 :
335 : // IMnemonicEntryList
336 : virtual const void* FirstSearchEntry( OUString& _rEntryText ) const SAL_OVERRIDE;
337 : virtual const void* NextSearchEntry( const void* _pCurrentSearchEntry, OUString& _rEntryText ) const SAL_OVERRIDE;
338 : virtual void SelectSearchEntry( const void* _pEntry ) SAL_OVERRIDE;
339 : virtual void ExecuteSearchEntry( const void* _pEntry ) const SAL_OVERRIDE;
340 :
341 : // ISearchableStringList
342 : virtual ::vcl::StringEntryIdentifier CurrentEntry( OUString& _out_entryText ) const SAL_OVERRIDE;
343 : virtual ::vcl::StringEntryIdentifier NextEntry( ::vcl::StringEntryIdentifier _currentEntry, OUString& _out_entryText ) const SAL_OVERRIDE;
344 : virtual void SelectEntry( ::vcl::StringEntryIdentifier _entry ) SAL_OVERRIDE;
345 :
346 : public:
347 :
348 : SvTreeListBox( vcl::Window* pParent, WinBits nWinStyle=0 );
349 : SvTreeListBox( vcl::Window* pParent, const ResId& rResId );
350 : virtual ~SvTreeListBox();
351 :
352 3619 : SvTreeList* GetModel() const { return pModel; }
353 : using SvListView::SetModel;
354 : void SetModel(SvTreeList* pNewModel) SAL_OVERRIDE;
355 :
356 2166 : sal_uLong GetEntryCount() const {return pModel->GetEntryCount();}
357 2136 : SvTreeListEntry* First() const { return pModel->First(); }
358 582 : SvTreeListEntry* Next( SvTreeListEntry* pEntry, sal_uInt16* pDepth=0 ) const { return pModel->Next(pEntry,pDepth); }
359 0 : SvTreeListEntry* Prev( SvTreeListEntry* pEntry, sal_uInt16* pDepth=0 ) const { return pModel->Prev(pEntry,pDepth); }
360 0 : SvTreeListEntry* Last() const { return pModel->Last(); }
361 :
362 : SvTreeListEntry* FirstChild( SvTreeListEntry* pParent ) const;
363 : SvTreeListEntry* NextSibling( SvTreeListEntry* pEntry ) const;
364 : SvTreeListEntry* PrevSibling( SvTreeListEntry* pEntry ) const;
365 :
366 : bool CopySelection( SvTreeListBox* pSource, SvTreeListEntry* pTarget );
367 : bool MoveSelection( SvTreeListBox* pSource, SvTreeListEntry* pTarget );
368 : bool MoveSelectionCopyFallbackPossible( SvTreeListBox* pSource, SvTreeListEntry* pTarget, bool bAllowCopyFallback );
369 : void RemoveSelection();
370 :
371 0 : DragDropMode GetDragDropMode() const { return nDragDropMode; }
372 10 : SelectionMode GetSelectionMode() const { return eSelMode; }
373 :
374 : // pParent == 0 -> Root level
375 : SvTreeListEntry* GetEntry( SvTreeListEntry* pParent, sal_uLong nPos ) const;
376 : SvTreeListEntry* GetEntry( sal_uLong nRootPos ) const;
377 :
378 : SvTreeListEntry* GetEntryFromPath( const ::std::deque< sal_Int32 >& _rPath ) const;
379 : void FillEntryPath( SvTreeListEntry* pEntry, ::std::deque< sal_Int32 >& _rPath ) const;
380 :
381 : using Window::GetParent;
382 : const SvTreeListEntry* GetParent( const SvTreeListEntry* pEntry ) const;
383 : SvTreeListEntry* GetParent( SvTreeListEntry* pEntry ) const;
384 : SvTreeListEntry* GetRootLevelParent(SvTreeListEntry* pEntry ) const;
385 :
386 : using Window::GetChildCount;
387 : sal_uLong GetChildCount( SvTreeListEntry* pParent ) const;
388 : sal_uLong GetLevelChildCount( SvTreeListEntry* pParent ) const;
389 :
390 : SvViewDataEntry* GetViewDataEntry( SvTreeListEntry* pEntry ) const;
391 : SvViewDataItem* GetViewDataItem(SvTreeListEntry*, SvLBoxItem*);
392 : const SvViewDataItem* GetViewDataItem(const SvTreeListEntry*, const SvLBoxItem*) const;
393 :
394 0 : bool IsInplaceEditingEnabled() const { return ((nImpFlags & SVLBOX_EDT_ENABLED) != 0); }
395 2471 : bool IsEditingActive() const { return ((nImpFlags & SVLBOX_IN_EDT) != 0); }
396 : void EndEditing( bool bCancel = false );
397 : void ForbidEmptyText();
398 :
399 : void Clear();
400 :
401 : /** Enables or disables mnemonic characters in the entry texts.
402 :
403 : If mnemonics are enabled, then entries are selected and made current when
404 : there mnemonic character is pressed. If there are multiple entries with the
405 : same mnemonic, the selection cycles between them.
406 :
407 : Entries with an collapsed ancestor are not included in the calculation of
408 : mnemonics. That is, if you press the accelerator key of an invisible
409 : entry, then this entry is *not* selected.
410 :
411 : Be aware that enabling mnemonics gets more expensive as you add to the list.
412 : */
413 : void EnableEntryMnemonics( bool _bEnable = true );
414 : bool IsEntryMnemonicsEnabled() const;
415 :
416 : /** Handles the given key event.
417 :
418 : At the moment this merely checks for accelerator keys, if entry mnemonics
419 : are enabled.
420 :
421 : This method may come in handy if you want to use keyboard acceleration
422 : while the control does not have the focus.
423 :
424 : If the key event describes the pressing of a shortcut for an entry,
425 : then SelectSearchEntry resp. ExecuteSearchEntry are called.
426 :
427 : @see IMnemonicEntryList
428 : @see MnemonicEngine
429 :
430 : @return
431 : <TRUE/> if the event has been consumed, <FALSE/> otherwise.
432 : */
433 : bool HandleKeyInput( const KeyEvent& rKEvt );
434 :
435 16 : void SetSelectHdl( const Link& rNewHdl ) {aSelectHdl=rNewHdl; }
436 0 : void SetDeselectHdl( const Link& rNewHdl ) {aDeselectHdl=rNewHdl; }
437 248 : void SetDoubleClickHdl(const Link& rNewHdl) {aDoubleClickHdl=rNewHdl;}
438 0 : const Link& GetSelectHdl() const { return aSelectHdl; }
439 0 : const Link& GetDeselectHdl() const { return aDeselectHdl; }
440 0 : const Link& GetDoubleClickHdl() const { return aDoubleClickHdl; }
441 0 : void SetExpandingHdl(const Link& rNewHdl){aExpandingHdl=rNewHdl;}
442 0 : void SetExpandedHdl(const Link& rNewHdl){aExpandedHdl=rNewHdl;}
443 : const Link& GetExpandingHdl() const { return aExpandingHdl; }
444 :
445 : virtual void ExpandedHdl();
446 : virtual bool ExpandingHdl();
447 : virtual void SelectHdl();
448 : virtual void DeselectHdl();
449 : virtual bool DoubleClickHdl();
450 : bool IsTravelSelect() const { return ((nImpFlags&SVLBOX_IS_TRAVELSELECT)!=0);}
451 6 : SvTreeListEntry* GetHdlEntry() const { return pHdlEntry; }
452 : SvLBoxItem* GetHdlItem() const;
453 :
454 : // Is called for an Entry that gets expanded with the Flag
455 : // ENTRYFLAG_CHILDREN_ON_DEMAND set.
456 : virtual void RequestingChildren( SvTreeListEntry* pParent );
457 :
458 : // Drag & Drop
459 : // New D'n'D API
460 : virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
461 : virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
462 : virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) SAL_OVERRIDE;
463 : virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData,
464 : SvTreeListEntry* );
465 : virtual void DragFinished( sal_Int8 nDropAction );
466 : virtual bool NotifyAcceptDrop( SvTreeListEntry* );
467 :
468 0 : void SetDragOptions( sal_Int8 nOptions ) { nDragOptions = nOptions; }
469 : sal_Int8 GetDragOptions() const { return nDragOptions; }
470 :
471 : SvTreeListBox* GetSourceView() const;
472 :
473 : virtual void NotifyRemoving( SvTreeListEntry* );
474 : virtual SvTreeListEntry* CloneEntry( SvTreeListEntry* pSource );
475 : virtual SvTreeListEntry* CreateEntry() const; // To create new Entries
476 :
477 : // Return value: TRISTATE_TRUE == Ok, TRISTATE_FALSE == Cancel, TRISTATE_INDET == Ok and Make visible moved entry
478 : virtual TriState NotifyMoving(
479 : SvTreeListEntry* pTarget, // D'n'D DropPosition in this->GetModel()
480 : SvTreeListEntry* pEntry, // Entry to be moved from GetSourceListBox()->GetModel()
481 : SvTreeListEntry*& rpNewParent, // New TargetParent
482 : sal_uLong& rNewChildPos); // The TargetParent's position in Childlist
483 :
484 : // Return value: TRISTATE_TRUE == Ok, TRISTATE_FALSE == Cancel, TRISTATE_INDET == Ok and Make visible moved entry
485 : virtual TriState NotifyCopying(
486 : SvTreeListEntry* pTarget, // D'n'D DropPosition in this->GetModel()
487 : SvTreeListEntry* pEntry, // Entry to be copied from GetSourceListBox()->GetModel()
488 : SvTreeListEntry*& rpNewParent, // New TargetParent
489 : sal_uLong& rNewChildPos); // The TargetParent's position in Childlist
490 :
491 : // ACCESSIBILITY ==========================================================
492 :
493 : /** Creates and returns the accessible object of the Box. */
494 : virtual ::com::sun::star::uno::Reference<
495 : ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
496 :
497 : /** Fills the StateSet with all states (except DEFUNC, done by the accessible object). */
498 : virtual void FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& rStateSet ) const;
499 :
500 : /** Fills the StateSet of one entry. */
501 : virtual void FillAccessibleEntryStateSet( SvTreeListEntry* pEntry, ::utl::AccessibleStateSetHelper& rStateSet ) const;
502 :
503 : /** Calculate and return the bounding rectangle of an entry.
504 : @param pEntry
505 : The entry.
506 : @return The bounding rectangle of an entry. */
507 : virtual Rectangle GetBoundingRect( SvTreeListEntry* pEntry );
508 :
509 : /** Enables, that one cell of a tablistbox entry can be focused */
510 : void EnableCellFocus();
511 :
512 : // For overwriting accessible role for all entries - normally 0, so each entry can be different
513 0 : void SetAllEntriesAccessibleRoleType( short n ) { nAllItemAccRoleType = n; }
514 186 : short GetAllEntriesAccessibleRoleType() const { return nAllItemAccRoleType; }
515 :
516 330 : sal_uInt16 GetTreeFlags() const {return nTreeFlags;}
517 :
518 : OUString headString;
519 : OUString SearchEntryTextWithHeadTitle(SvTreeListEntry* pEntry);
520 : virtual OUString GetEntryAltText(SvTreeListEntry* pEntry) const;
521 : virtual OUString GetEntryLongDescription(SvTreeListEntry* pEntry) const;
522 :
523 : void set_min_width_in_chars(sal_Int32 nChars);
524 :
525 : virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
526 :
527 : protected:
528 : using SvListView::SelectAll;
529 :
530 : SVT_DLLPRIVATE short GetHeightOffset( const Image& rBmp, Size& rLogicSize);
531 : SVT_DLLPRIVATE short GetHeightOffset( const vcl::Font& rFont, Size& rLogicSize);
532 :
533 : SVT_DLLPRIVATE void SetEntryHeight( SvTreeListEntry* pEntry );
534 : SVT_DLLPRIVATE void AdjustEntryHeight( const Image& rBmp );
535 : SVT_DLLPRIVATE void AdjustEntryHeight( const vcl::Font& rFont );
536 :
537 : SVT_DLLPRIVATE void ImpEntryInserted( SvTreeListEntry* pEntry );
538 : SVT_DLLPRIVATE long PaintEntry1( SvTreeListEntry*, long nLine,
539 : sal_uInt16 nTabFlagMask=0xffff,
540 : bool bHasClipRegion=false );
541 :
542 : SVT_DLLPRIVATE void InitTreeView();
543 : SVT_DLLPRIVATE SvLBoxItem* GetItem_Impl( SvTreeListEntry*, long nX, SvLBoxTab** ppTab,
544 : sal_uInt16 nEmptyWidth );
545 : SVT_DLLPRIVATE void ImplInitStyle();
546 :
547 : protected:
548 :
549 : void EditItemText( SvTreeListEntry* pEntry, SvLBoxString* pItem,
550 : const Selection& );
551 : void EditedText(const OUString&);
552 :
553 : // Recalculate all tabs depending on TreeListStyle and Bitmap sizes
554 : // Is called automatically when inserting/changing Bitmaps, changing the Model etc.
555 : virtual void SetTabs();
556 : void SetTabs_Impl();
557 : void AddTab( long nPos,sal_uInt16 nFlags=SV_LBOXTAB_ADJUST_LEFT,
558 : void* pUserData = 0 );
559 0 : sal_uInt16 TabCount() const { return aTabs.size(); }
560 : SvLBoxTab* GetFirstDynamicTab() const;
561 : SvLBoxTab* GetFirstDynamicTab( sal_uInt16& rTabPos ) const;
562 : SvLBoxTab* GetFirstTab( sal_uInt16 nFlagMask, sal_uInt16& rTabPos );
563 : SvLBoxTab* GetLastTab( sal_uInt16 nFlagMask, sal_uInt16& rTabPos );
564 : SvLBoxTab* GetTab( SvTreeListEntry*, SvLBoxItem* ) const;
565 : void ClearTabList();
566 :
567 : virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&, SvLBoxButtonKind);
568 :
569 : virtual void NotifyBeginScroll();
570 : virtual void NotifyEndScroll();
571 : // nLines == 0 => horizontal Scrolling
572 : virtual void NotifyScrolling( long nLines );
573 : virtual void NotifyScrolled();
574 0 : void SetScrolledHdl( const Link& rLink ) { aScrolledHdl = rLink; }
575 : const Link& GetScrolledHdl() const { return aScrolledHdl; }
576 0 : long GetXOffset() const { return GetMapMode().GetOrigin().X(); }
577 :
578 : // Is called _before_ Areas in the Control are invalidated.
579 : // This can be used to hide Elements which are painted from outside into the Control
580 : virtual void NotifyInvalidating();
581 :
582 : virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
583 :
584 : virtual void RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
585 : virtual void CursorMoved( SvTreeListEntry* pNewCursor );
586 : virtual void PreparePaint( SvTreeListEntry* );
587 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
588 :
589 : void InitSettings(bool bFont, bool bForeground, bool bBackground);
590 : bool IsCellFocusEnabled() const;
591 : bool SetCurrentTabPos( sal_uInt16 _nNewPos );
592 : sal_uInt16 GetCurrentTabPos() const;
593 : void CallImplEventListeners(sal_uLong nEvent, void* pData);
594 :
595 : void ImplEditEntry( SvTreeListEntry* pEntry );
596 :
597 : bool AreChildrenTransient() const;
598 : void SetChildrenNotTransient();
599 :
600 : void AdjustEntryHeightAndRecalc( const vcl::Font& rFont );
601 : public:
602 :
603 : void SetExtendedWinBits( ExtendedWinBits _nBits );
604 :
605 : void DisconnectFromModel();
606 :
607 : void EnableCheckButton( SvLBoxButtonData* );
608 : void SetCheckButtonData( SvLBoxButtonData* );
609 : void SetNodeBitmaps( const Image& rCollapsedNodeBmp, const Image& rExpandedNodeBmp );
610 :
611 : /** Returns the default image which clients should use for expanded nodes, to have a consistent user
612 : interface experience in the whole product.
613 : */
614 : static const Image& GetDefaultExpandedNodeImage( );
615 :
616 : /** Returns the default image which clients should use for expanded nodes, to have a consistent user
617 : interface experience in the whole product.
618 : */
619 : static const Image& GetDefaultCollapsedNodeImage( );
620 :
621 : /** Sets default bitmaps for collapsed and expanded nodes.
622 : */
623 144 : inline void SetNodeDefaultImages( )
624 : {
625 : SetNodeBitmaps(
626 144 : GetDefaultCollapsedNodeImage( ),
627 144 : GetDefaultExpandedNodeImage( )
628 144 : );
629 144 : }
630 :
631 : virtual SvTreeListEntry* InsertEntry( const OUString& rText, SvTreeListEntry* pParent = 0,
632 : bool bChildrenOnDemand = false,
633 : sal_uLong nPos=TREELIST_APPEND, void* pUserData = 0,
634 : SvLBoxButtonKind eButtonKind = SvLBoxButtonKind_enabledCheckbox );
635 :
636 : virtual SvTreeListEntry* InsertEntry( const OUString& rText,
637 : const Image& rExpandedEntryBmp,
638 : const Image& rCollapsedEntryBmp,
639 : SvTreeListEntry* pParent = 0,
640 : bool bChildrenOnDemand = false,
641 : sal_uLong nPos = TREELIST_APPEND, void* pUserData = 0,
642 : SvLBoxButtonKind eButtonKind = SvLBoxButtonKind_enabledCheckbox );
643 :
644 : const Image& GetDefaultExpandedEntryBmp( ) const;
645 : const Image& GetDefaultCollapsedEntryBmp( ) const;
646 :
647 : void SetDefaultExpandedEntryBmp( const Image& rBmp );
648 : void SetDefaultCollapsedEntryBmp( const Image& rBmp );
649 :
650 : void SetCheckButtonState( SvTreeListEntry*, SvButtonState );
651 : void SetCheckButtonInvisible( SvTreeListEntry* );
652 : SvButtonState GetCheckButtonState( SvTreeListEntry* ) const;
653 :
654 : void SetEntryText(SvTreeListEntry*, const OUString& );
655 : void SetExpandedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage );
656 : void SetCollapsedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage );
657 :
658 : virtual OUString GetEntryText( SvTreeListEntry* pEntry ) const;
659 : const Image& GetExpandedEntryBmp(const SvTreeListEntry* _pEntry ) const;
660 : const Image& GetCollapsedEntryBmp(const SvTreeListEntry* _pEntry ) const;
661 :
662 0 : void SetCheckButtonHdl( const Link& rLink ) { aCheckButtonHdl=rLink; }
663 0 : Link GetCheckButtonHdl() const { return aCheckButtonHdl; }
664 : virtual void CheckButtonHdl();
665 :
666 : void SetSublistOpenWithReturn( bool bMode = true ); // open/close sublist with return/enter
667 : void SetSublistOpenWithLeftRight( bool bMode = true ); // open/close sublist with cursor left/right
668 :
669 : void EnableInplaceEditing( bool bEnable );
670 : // Edits the Entry's first StringItem, 0 == Cursor
671 : void EditEntry( SvTreeListEntry* pEntry = NULL );
672 : virtual bool EditingEntry( SvTreeListEntry* pEntry, Selection& );
673 : virtual bool EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText );
674 :
675 : virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
676 : virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
677 : virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
678 : virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
679 : virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
680 : virtual void Resize() SAL_OVERRIDE;
681 : virtual void GetFocus() SAL_OVERRIDE;
682 : virtual void LoseFocus() SAL_OVERRIDE;
683 : void SetUpdateMode( bool );
684 :
685 : virtual void ModelHasCleared() SAL_OVERRIDE;
686 : virtual void ModelHasInserted( SvTreeListEntry* pEntry ) SAL_OVERRIDE;
687 : virtual void ModelHasInsertedTree( SvTreeListEntry* pEntry ) SAL_OVERRIDE;
688 : virtual void ModelIsMoving(SvTreeListEntry* pSource,
689 : SvTreeListEntry* pTargetParent, sal_uLong nChildPos ) SAL_OVERRIDE;
690 : virtual void ModelHasMoved(SvTreeListEntry* pSource ) SAL_OVERRIDE;
691 : virtual void ModelIsRemoving( SvTreeListEntry* pEntry ) SAL_OVERRIDE;
692 : virtual void ModelHasRemoved( SvTreeListEntry* pEntry ) SAL_OVERRIDE;
693 : void ModelHasEntryInvalidated( SvTreeListEntry* pEntry ) SAL_OVERRIDE;
694 :
695 : void ShowTargetEmphasis( SvTreeListEntry*, bool bShow );
696 : void ScrollOutputArea( short nDeltaEntries );
697 :
698 16836 : short GetEntryHeight() const { return nEntryHeight; }
699 : void SetEntryHeight( short nHeight, bool bAlways = false );
700 : Size GetOutputSizePixel() const;
701 167 : short GetIndent() const { return nIndent; }
702 : void SetIndent( short nIndent );
703 : // Place the expander checkitem at the optimal indent for hierarchical lists
704 0 : void SetOptimalImageIndent() { SetIndent(12); }
705 : void SetSpaceBetweenEntries( short nSpace );
706 0 : short GetSpaceBetweenEntries() const {return nEntryHeightOffs;}
707 : Point GetEntryPosition( SvTreeListEntry* ) const;
708 : void ShowEntry( SvTreeListEntry* ); // !!!OBSOLETE, use MakeVisible
709 : void MakeVisible( SvTreeListEntry* pEntry );
710 : void MakeVisible( SvTreeListEntry* pEntry, bool bMoveToTop );
711 :
712 : void SetCollapsedNodeBmp( const Image& );
713 : void SetExpandedNodeBmp( const Image& );
714 : Image GetExpandedNodeBmp( ) const;
715 :
716 : void SetFont( const vcl::Font& rFont );
717 :
718 : using Window::SetCursor;
719 : void SetCursor( SvTreeListEntry* pEntry, bool bForceNoSelect = false );
720 :
721 : SvTreeListEntry* GetEntry( const Point& rPos, bool bHit = false ) const;
722 :
723 : void PaintEntry( SvTreeListEntry* );
724 : long PaintEntry( SvTreeListEntry*, long nLine,
725 : sal_uInt16 nTabFlagMask=0xffff );
726 : virtual Rectangle GetFocusRect( SvTreeListEntry*, long nLine );
727 : // Respects indentation
728 : virtual sal_IntPtr GetTabPos( SvTreeListEntry*, SvLBoxTab* );
729 : void InvalidateEntry( SvTreeListEntry* );
730 : SvLBoxItem* GetItem( SvTreeListEntry*, long nX, SvLBoxTab** ppTab);
731 : SvLBoxItem* GetItem( SvTreeListEntry*, long nX );
732 :
733 : void SetDragDropMode( DragDropMode );
734 : void SetSelectionMode( SelectionMode );
735 :
736 : virtual bool Expand( SvTreeListEntry* pParent );
737 : virtual bool Collapse( SvTreeListEntry* pParent );
738 : virtual bool Select( SvTreeListEntry* pEntry, bool bSelect=true );
739 : sal_uLong SelectChildren( SvTreeListEntry* pParent, bool bSelect );
740 : virtual void SelectAll( bool bSelect, bool bPaint = true ) SAL_OVERRIDE;
741 :
742 : void SetCurEntry( SvTreeListEntry* _pEntry );
743 : SvTreeListEntry* GetCurEntry() const;
744 :
745 : using Window::Invalidate;
746 : virtual void Invalidate( sal_uInt16 nFlags = 0) SAL_OVERRIDE;
747 : virtual void Invalidate( const Rectangle&, sal_uInt16 nFlags = 0 ) SAL_OVERRIDE;
748 :
749 : void SetHighlightRange(sal_uInt16 nFirstTab=0,sal_uInt16 nLastTab=0xffff);
750 :
751 : // A Parent's Children are turned into Children of the Parent which comes next in hierarchy
752 : void RemoveParentKeepChildren( SvTreeListEntry* pParent );
753 :
754 : DECL_LINK( DefaultCompare, SvSortData* );
755 : virtual void ModelNotification( SvListAction nActionId, SvTreeListEntry* pEntry1,
756 : SvTreeListEntry* pEntry2, sal_uLong nPos ) SAL_OVERRIDE;
757 :
758 : void EndSelection();
759 : void RepaintScrollBars() const;
760 : ScrollBar* GetVScroll();
761 : ScrollBar* GetHScroll();
762 : void EnableAsyncDrag( bool b );
763 :
764 : SvTreeListEntry* GetFirstEntryInView() const;
765 : SvTreeListEntry* GetNextEntryInView(SvTreeListEntry*) const;
766 : SvTreeListEntry* GetLastEntryInView() const;
767 : void ScrollToAbsPos( long nPos );
768 :
769 : void ShowFocusRect( const SvTreeListEntry* pEntry );
770 : void InitStartEntry();
771 :
772 : virtual PopupMenu* CreateContextMenu( void );
773 : virtual void ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry );
774 :
775 : void EnableContextMenuHandling( void );
776 :
777 : void EnableList( bool _bEnable );
778 :
779 : long getPreferredDimensions(std::vector<long> &rWidths) const;
780 :
781 : virtual Size GetOptimalSize() const SAL_OVERRIDE;
782 :
783 : void SetAlternatingRowColors( const bool bEnable );
784 : bool IsAlternatingRowColors() const { return mbAlternatingRowColors; }
785 : };
786 :
787 : #define SV_LBOX_DD_FORMAT "SV_LBOX_DD_FORMAT"
788 : struct SvLBoxDDInfo
789 : {
790 : Application* pApp;
791 : SvTreeListBox* pSource;
792 : SvTreeListEntry* pDDStartEntry;
793 : // Relative position in the Entry at DragBeginn (IconView)
794 : long nMouseRelX,nMouseRelY;
795 : sal_uLong nRes1,nRes2,nRes3,nRes4;
796 : };
797 :
798 : class SvInplaceEdit2
799 : {
800 : Link aCallBackHdl;
801 : Accelerator aAccReturn;
802 : Accelerator aAccEscape;
803 : Timer aTimer;
804 : Edit* pEdit;
805 : bool bCanceled;
806 : bool bAlreadyInCallBack;
807 :
808 : void CallCallBackHdl_Impl();
809 : DECL_LINK( Timeout_Impl, void * );
810 : DECL_LINK( ReturnHdl_Impl, void * );
811 : DECL_LINK( EscapeHdl_Impl, void * );
812 :
813 : public:
814 : SvInplaceEdit2( vcl::Window* pParent, const Point& rPos, const Size& rSize,
815 : const OUString& rData, const Link& rNotifyEditEnd,
816 : const Selection&, bool bMultiLine = false );
817 : ~SvInplaceEdit2();
818 : bool KeyInput( const KeyEvent& rKEvt );
819 : void LoseFocus();
820 0 : bool EditingCanceled() const { return bCanceled; }
821 : OUString GetText() const;
822 : OUString GetSavedValue() const;
823 : void StopEditing( bool bCancel = false );
824 : void Hide();
825 : };
826 :
827 : #endif
828 :
829 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|