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

Generated by: LCOV version 1.10