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