LCOV - code coverage report
Current view: top level - include/svtools - treelistbox.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 28 52 53.8 %
Date: 2015-06-13 12:38:46 Functions: 18 40 45.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11