summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-10-11 16:13:12 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-10-11 23:35:15 -0400
commitac7acb0ab1329913b0cec79790adcde0263960be (patch)
treed9d01baa97e42524c280e6e31f768e3d6119f41a /svtools
parentddf31912ddb5573a085b8601669cf31bf4b1f690 (diff)
Merged SvTreeListBox and SvLBox.
There is no reason to keep SvLBox separate. Change-Id: I0b34aa8f8ca539d4f4f0f9cea9fa9b8faec241e8
Diffstat (limited to 'svtools')
-rw-r--r--svtools/Library_svt.mk3
-rw-r--r--svtools/Package_inc.mk3
-rw-r--r--svtools/inc/svtools/svlbitm.hxx33
-rw-r--r--svtools/inc/svtools/svtabbx.hxx2
-rw-r--r--svtools/inc/svtools/svtreebx.hxx403
-rw-r--r--svtools/inc/svtools/treelistbox.hxx (renamed from svtools/inc/svtools/svlbox.hxx)425
-rw-r--r--svtools/source/contnr/svimpbox.cxx6
-rw-r--r--svtools/source/contnr/svlbitm.cxx22
-rw-r--r--svtools/source/contnr/svlbox.cxx1794
-rw-r--r--svtools/source/contnr/svtabbx.cxx5
-rw-r--r--svtools/source/contnr/treelistbox.cxx (renamed from svtools/source/contnr/svtreebx.cxx)1697
-rw-r--r--svtools/source/uno/treecontrolpeer.cxx12
-rw-r--r--svtools/source/uno/unoiface.cxx2
13 files changed, 2046 insertions, 2361 deletions
diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk
index d78caa23be90..89d3f184a4f9 100644
--- a/svtools/Library_svt.mk
+++ b/svtools/Library_svt.mk
@@ -101,11 +101,10 @@ $(eval $(call gb_Library_add_exception_objects,svt,\
svtools/source/contnr/ivctrl \
svtools/source/contnr/svimpbox \
svtools/source/contnr/svlbitm \
- svtools/source/contnr/svlbox \
svtools/source/contnr/svtabbx \
- svtools/source/contnr/svtreebx \
svtools/source/contnr/templwin \
svtools/source/contnr/treelist \
+ svtools/source/contnr/treelistbox \
svtools/source/control/asynclink \
svtools/source/control/calendar \
svtools/source/control/collatorres \
diff --git a/svtools/Package_inc.mk b/svtools/Package_inc.mk
index d06053c0f0ec..c1ed7e1ad6fa 100644
--- a/svtools/Package_inc.mk
+++ b/svtools/Package_inc.mk
@@ -138,7 +138,7 @@ $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/stdctrl.hxx,svtools/st
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/stdmenu.hxx,svtools/stdmenu.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/stringtransfer.hxx,svtools/stringtransfer.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/svlbitm.hxx,svtools/svlbitm.hxx))
-$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/svlbox.hxx,svtools/svlbox.hxx))
+$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/treelistbox.hxx,svtools/treelistbox.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/svmedit.hxx,svtools/svmedit.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/svmedit2.hxx,svtools/svmedit2.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/svparser.hxx,svtools/svparser.hxx))
@@ -146,7 +146,6 @@ $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/svtabbx.hxx,svtools/sv
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/svtresid.hxx,svtools/svtresid.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/svtdllapi.h,svtools/svtdllapi.h))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/svtools.hrc,svtools/svtools.hrc))
-$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/svtreebx.hxx,svtools/svtreebx.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/syntaxhighlight.hxx,svtools/syntaxhighlight.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/tabbar.hxx,svtools/tabbar.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/tablecontrolinterface.hxx,svtools/table/tablecontrolinterface.hxx))
diff --git a/svtools/inc/svtools/svlbitm.hxx b/svtools/inc/svtools/svlbitm.hxx
index 727a0a5ce5c4..6bca37e7f492 100644
--- a/svtools/inc/svtools/svlbitm.hxx
+++ b/svtools/inc/svtools/svlbitm.hxx
@@ -35,16 +35,10 @@
#include <tools/link.hxx>
#include <vcl/image.hxx>
-#include <svtools/svlbox.hxx>
+#include <svtools/treelistbox.hxx>
class SvLBoxEntry;
-#define SV_ITEM_ID_LBOXSTRING 1
-#define SV_ITEM_ID_LBOXBMP 2
-#define SV_ITEM_ID_LBOXBUTTON 3
-#define SV_ITEM_ID_LBOXCONTEXTBMP 4
-
-enum SvButtonState { SV_BUTTON_UNCHECKED, SV_BUTTON_CHECKED, SV_BUTTON_TRISTATE };
#define SV_BMP_UNCHECKED 0
#define SV_BMP_CHECKED 1
@@ -129,10 +123,10 @@ public:
SvLBoxString();
virtual ~SvLBoxString();
virtual sal_uInt16 IsA();
- virtual void InitViewData(SvLBox*, SvLBoxEntry*, SvViewDataItem*);
+ virtual void InitViewData(SvTreeListBox*, SvLBoxEntry*, SvViewDataItem*);
rtl::OUString GetText() const { return maText; }
void SetText( const rtl::OUString& rText ) { maText = rText; }
- virtual void Paint( const Point&, SvLBox& rDev, sal_uInt16 nFlags,SvLBoxEntry* );
+ virtual void Paint( const Point&, SvTreeListBox& rDev, sal_uInt16 nFlags,SvLBoxEntry* );
virtual SvLBoxItem* Create() const;
virtual void Clone( SvLBoxItem* pSource );
};
@@ -144,8 +138,8 @@ public:
SvLBoxBmp();
virtual ~SvLBoxBmp();
virtual sal_uInt16 IsA();
- virtual void InitViewData( SvLBox*,SvLBoxEntry*,SvViewDataItem* );
- virtual void Paint( const Point&, SvLBox& rView, sal_uInt16 nFlags,SvLBoxEntry* );
+ virtual void InitViewData( SvTreeListBox*,SvLBoxEntry*,SvViewDataItem* );
+ virtual void Paint( const Point&, SvTreeListBox& rView, sal_uInt16 nFlags,SvLBoxEntry* );
virtual SvLBoxItem* Create() const;
virtual void Clone( SvLBoxItem* pSource );
};
@@ -157,13 +151,6 @@ public:
#define SV_ITEMSTATE_HILIGHTED 0x0008
#define SV_STATE_MASK 0xFFF8 // zum Loeschen von UNCHECKED,CHECKED,TRISTATE
-enum SvLBoxButtonKind
-{
- SvLBoxButtonKind_enabledCheckbox,
- SvLBoxButtonKind_disabledCheckbox,
- SvLBoxButtonKind_staticImage
-};
-
class SVT_DLLPUBLIC SvLBoxButton : public SvLBoxItem
{
SvLBoxButtonData* pData;
@@ -183,10 +170,10 @@ public:
SvLBoxButtonData* pBData );
SvLBoxButton();
virtual ~SvLBoxButton();
- virtual void InitViewData( SvLBox*,SvLBoxEntry*,SvViewDataItem* );
+ virtual void InitViewData( SvTreeListBox*,SvLBoxEntry*,SvViewDataItem* );
virtual sal_uInt16 IsA();
- virtual sal_Bool ClickHdl(SvLBox* pView, SvLBoxEntry* );
- virtual void Paint( const Point&, SvLBox& rView, sal_uInt16 nFlags,SvLBoxEntry* );
+ virtual sal_Bool ClickHdl(SvTreeListBox* pView, SvLBoxEntry* );
+ virtual void Paint( const Point&, SvTreeListBox& rView, sal_uInt16 nFlags,SvLBoxEntry* );
virtual SvLBoxItem* Create() const;
virtual void Clone( SvLBoxItem* pSource );
sal_uInt16 GetButtonFlags() const { return nItemFlags; }
@@ -243,8 +230,8 @@ public:
SvLBoxContextBmp();
virtual ~SvLBoxContextBmp();
virtual sal_uInt16 IsA();
- virtual void InitViewData( SvLBox*,SvLBoxEntry*,SvViewDataItem* );
- virtual void Paint( const Point&, SvLBox& rView, sal_uInt16 nFlags,SvLBoxEntry* );
+ virtual void InitViewData( SvTreeListBox*,SvLBoxEntry*,SvViewDataItem* );
+ virtual void Paint( const Point&, SvTreeListBox& rView, sal_uInt16 nFlags,SvLBoxEntry* );
virtual SvLBoxItem* Create() const;
virtual void Clone( SvLBoxItem* pSource );
diff --git a/svtools/inc/svtools/svtabbx.hxx b/svtools/inc/svtools/svtabbx.hxx
index e4537d4d6cc8..ef9a2d1b1c3f 100644
--- a/svtools/inc/svtools/svtabbx.hxx
+++ b/svtools/inc/svtools/svtabbx.hxx
@@ -29,7 +29,7 @@
#define _SVTABBX_HXX
#include "svtools/svtdllapi.h"
-#include <svtools/svtreebx.hxx>
+#include <svtools/treelistbox.hxx>
#include <svtools/accessibletableprovider.hxx>
#include <vector>
diff --git a/svtools/inc/svtools/svtreebx.hxx b/svtools/inc/svtools/svtreebx.hxx
deleted file mode 100644
index 02c223e6e44c..000000000000
--- a/svtools/inc/svtools/svtreebx.hxx
+++ /dev/null
@@ -1,403 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef _SVTREEBOX_HXX
-#define _SVTREEBOX_HXX
-
-#include "svtools/svtdllapi.h"
-#include <svtools/svlbox.hxx>
-#include <svtools/svlbitm.hxx>
-
-// forward and defines ---------------------------------------------------
-
-class SvImpLBox;
-
-#define SV_TAB_BORDER 8
-
-#define SV_LISTBOX_ID_TREEBOX 1 // fuer SvLBox::IsA()
-#define SV_ENTRYHEIGHTOFFS_PIXEL 2
-
-#define TREEFLAG_CHKBTN 0x0001
-#define TREEFLAG_USESEL 0x0002
-#define TREEFLAG_MANINS 0x0004
-#define TREEFLAG_RECALCTABS 0x0008
-
-typedef sal_Int64 ExtendedWinBits;
-
-// disable the behavior of automatically selecting a "CurEntry" upon painting the control
-#define EWB_NO_AUTO_CURENTRY 0x00000001
-
-// class SvTreeListBox ---------------------------------------------------
-
-class SVT_DLLPUBLIC SvTreeListBox : public SvLBox
-{
- friend class SvImpLBox;
- friend class ImpLBSelEng;
- friend class TreeControlPeer;
-
- SvImpLBox* pImp;
- Link aCheckButtonHdl;
- Link aScrolledHdl;
- Accelerator aInpEditAcc;
- Image aPrevInsertedExpBmp;
- Image aPrevInsertedColBmp;
- Image aCurInsertedExpBmp;
- Image aCurInsertedColBmp;
-
- short nContextBmpWidthMax;
- sal_uInt16 nFirstSelTab, nLastSelTab;
- short nEntryHeight;
- short nEntryHeightOffs;
- short nIndent;
- short nFocusWidth;
- sal_uInt16 aContextBmpMode;
-
- long mnCheckboxItemWidth;
-
-#ifdef _SVTREEBX_CXX
- DECL_DLLPRIVATE_LINK( CheckButtonClick, SvLBoxButtonData * );
-
- SVT_DLLPRIVATE short GetHeightOffset( const Image& rBmp, Size& rLogicSize);
- SVT_DLLPRIVATE short GetHeightOffset( const Font& rFont, Size& rLogicSize);
-
- SVT_DLLPRIVATE void SetEntryHeight( SvLBoxEntry* pEntry );
- SVT_DLLPRIVATE void AdjustEntryHeight( const Image& rBmp );
- SVT_DLLPRIVATE void AdjustEntryHeight( const Font& rFont );
-
- SVT_DLLPRIVATE void ImpEntryInserted( SvLBoxEntry* pEntry );
- SVT_DLLPRIVATE long PaintEntry1( SvLBoxEntry*, long nLine,
- sal_uInt16 nTabFlagMask=0xffff,
- sal_Bool bHasClipRegion=sal_False );
-
- SVT_DLLPRIVATE void InitTreeView();
- SVT_DLLPRIVATE SvLBoxItem* GetItem_Impl( SvLBoxEntry*, long nX, SvLBoxTab** ppTab,
- sal_uInt16 nEmptyWidth );
- SVT_DLLPRIVATE void ImplInitStyle();
-
-#endif
-
-protected:
- SvLBoxButtonData* pCheckButtonData;
- sal_uInt16 nTreeFlags;
-
- SvLBoxEntry* pEdEntry;
- SvLBoxItem* pEdItem;
-
- void EditItemText( SvLBoxEntry* pEntry, SvLBoxString* pItem,
- const Selection& );
- void EditedText( const XubString& );
- void EditingRequest( SvLBoxEntry* pEntry, SvLBoxItem* pItem,
- const Point& rMousePos );
-
- std::vector<SvLBoxTab*> aTabs;
-
- // berechnet abhaengig von TreeList-Style & Bitmap-Groessen
- // alle Tabulatoren neu; wird beim Einfuegen/Austauschen von
- // Bitmaps, beim Wechsel des Models usw. automatisch gerufen
- virtual void SetTabs();
- void SetTabs_Impl();
- void AddTab( long nPos,sal_uInt16 nFlags=SV_LBOXTAB_ADJUST_LEFT,
- void* pUserData = 0 );
- sal_uInt16 TabCount() const { return aTabs.size(); }
- SvLBoxTab* GetFirstDynamicTab() const;
- SvLBoxTab* GetFirstDynamicTab( sal_uInt16& rTabPos ) const;
- SvLBoxTab* GetFirstTab( sal_uInt16 nFlagMask, sal_uInt16& rTabPos );
- SvLBoxTab* GetLastTab( sal_uInt16 nFlagMask, sal_uInt16& rTabPos );
- SvLBoxTab* GetTab( SvLBoxEntry*, SvLBoxItem* ) const;
- void ClearTabList();
-
- virtual void InitEntry(SvLBoxEntry*,const XubString&,const Image&,const Image&,SvLBoxButtonKind);
-
- virtual void NotifyBeginScroll();
- virtual void NotifyEndScroll();
- // nLines == 0 => horizontales Scrolling
- virtual void NotifyScrolling( long nLines );
- virtual void NotifyScrolled();
- void SetScrolledHdl( const Link& rLink ) { aScrolledHdl = rLink; }
- const Link& GetScrolledHdl() const { return aScrolledHdl; }
- long GetXOffset() const { return GetMapMode().GetOrigin().X(); }
-
- // wird aufgerufen, _bevor_ Bereiche im Control invalidiert werden,
- // kann zum Hiden von Elementen benutzt werden, die von aussen
- // in das Control hineingezeichnet werden
- virtual void NotifyInvalidating();
-
- virtual sal_uLong GetAscInsertionPos( SvLBoxEntry*, SvLBoxEntry* pParent );
- virtual sal_uLong GetDescInsertionPos( SvLBoxEntry*, SvLBoxEntry* pParent );
- virtual void Command( const CommandEvent& rCEvt );
-
- virtual void RequestHelp( const HelpEvent& rHEvt );
- virtual void CursorMoved( SvLBoxEntry* pNewCursor );
- virtual void PreparePaint( SvLBoxEntry* );
- virtual void DataChanged( const DataChangedEvent& rDCEvt );
- virtual void StateChanged( StateChangedType nStateChange );
-
- void InitSettings(sal_Bool bFont,sal_Bool bForeground,sal_Bool bBackground);
- sal_Bool IsCellFocusEnabled() const;
- bool SetCurrentTabPos( sal_uInt16 _nNewPos );
- sal_uInt16 GetCurrentTabPos() const;
- void CallImplEventListeners(sal_uLong nEvent, void* pData);
-
- void ImplEditEntry( SvLBoxEntry* pEntry );
-
- sal_Bool AreChildrenTransient() const;
- void SetChildrenNotTransient();
-
-public:
- SvTreeListBox( Window* pParent, WinBits nWinStyle=0 );
- SvTreeListBox( Window* pParent, const ResId& rResId );
- ~SvTreeListBox();
-
- void SetExtendedWinBits( ExtendedWinBits _nBits );
-
- void DisconnectFromModel();
-
- void EnableCheckButton( SvLBoxButtonData* );
- void SetCheckButtonData( SvLBoxButtonData* );
- void SetNodeBitmaps( const Image& rCollapsedNodeBmp, const Image& rExpandedNodeBmp );
-
- /** returns the default image which clients should use for expanded nodes, to have a consistent user
- interface experience in the whole product.
- */
- static const Image& GetDefaultExpandedNodeImage( );
-
- /** returns the default image which clients should use for expanded nodes, to have a consistent user
- interface experience in the whole product.
- */
- static const Image& GetDefaultCollapsedNodeImage( );
-
- /** sets default bitmaps for collapsed and expanded nodes.
- */
- inline void SetNodeDefaultImages( )
- {
- SetNodeBitmaps(
- GetDefaultCollapsedNodeImage( ),
- GetDefaultExpandedNodeImage( )
- );
- }
-
- virtual SvLBoxEntry* InsertEntry( const XubString& rText, SvLBoxEntry* pParent = 0,
- sal_Bool bChildrenOnDemand = sal_False,
- sal_uLong nPos=LIST_APPEND, void* pUserData = 0,
- SvLBoxButtonKind eButtonKind = SvLBoxButtonKind_enabledCheckbox );
-
- virtual SvLBoxEntry* InsertEntry( const XubString& rText,
- const Image& rExpandedEntryBmp,
- const Image& rCollapsedEntryBmp,
- SvLBoxEntry* pParent = 0,
- sal_Bool bChildrenOnDemand = sal_False,
- sal_uLong nPos = LIST_APPEND, void* pUserData = 0,
- SvLBoxButtonKind eButtonKind = SvLBoxButtonKind_enabledCheckbox );
-
- const Image& GetDefaultExpandedEntryBmp( ) const;
- const Image& GetDefaultCollapsedEntryBmp( ) const;
-
- void SetDefaultExpandedEntryBmp( const Image& rBmp );
- void SetDefaultCollapsedEntryBmp( const Image& rBmp );
-
- void SetCheckButtonState( SvLBoxEntry*, SvButtonState );
- SvButtonState GetCheckButtonState( SvLBoxEntry* ) const;
-
- sal_Bool IsExpandBitmapOnCursor() const { return (sal_Bool)(aContextBmpMode & SVLISTENTRYFLAG_FOCUSED)!=0; }
-
- void SetEntryText(SvLBoxEntry*, const XubString& );
- void SetExpandedEntryBmp( SvLBoxEntry* _pEntry, const Image& _rImage );
- void SetCollapsedEntryBmp( SvLBoxEntry* _pEntry, const Image& _rImage );
-
- virtual String GetEntryText( SvLBoxEntry* pEntry ) const;
- String SearchEntryText( SvLBoxEntry* pEntry ) const;
- const Image& GetExpandedEntryBmp(SvLBoxEntry* _pEntry ) const;
- const Image& GetCollapsedEntryBmp(SvLBoxEntry* _pEntry ) const;
-
- void SetCheckButtonHdl( const Link& rLink ) { aCheckButtonHdl=rLink; }
- Link GetCheckButtonHdl() const { return aCheckButtonHdl; }
- virtual void CheckButtonHdl();
-
- virtual SvLBoxEntry* CloneEntry( SvLBoxEntry* pSource );
-
- virtual sal_uInt16 IsA();
-
- void SetSublistOpenWithReturn( sal_Bool bMode = sal_True ); // open/close sublist with return/enter
- void SetSublistOpenWithLeftRight( sal_Bool bMode = sal_True ); // open/close sublist with cursor left/right
-
- void EnableInplaceEditing( sal_Bool bEnable );
- sal_Bool IsInplaceEditingEnabled() const { return SvLBox::IsInplaceEditingEnabled(); }
- inline void ForbidEmptyText() { SvLBox::ForbidEmptyText(); }
- // Editiert das erste StringItem des Entries, 0==Cursor
- void EditEntry( SvLBoxEntry* pEntry = NULL );
- virtual sal_Bool EditingEntry( SvLBoxEntry* pEntry, Selection& );
- virtual sal_Bool EditedEntry( SvLBoxEntry* pEntry, const rtl::OUString& rNewText );
- sal_Bool IsEditingActive() const { return SvLBox::IsEditingActive(); }
- void EndEditing( sal_Bool bCancel = sal_False ) { SvLBox::EndEditing( bCancel ); }
- sal_Bool EditingCanceled() const { return SvLBox::EditingCanceled(); }
-
- virtual void RequestingChildren( SvLBoxEntry* pParent );
-
- virtual void Paint( const Rectangle& rRect );
- virtual void MouseButtonDown( const MouseEvent& rMEvt );
- virtual void MouseButtonUp( const MouseEvent& rMEvt );
- virtual void MouseMove( const MouseEvent& rMEvt );
- virtual void KeyInput( const KeyEvent& rKEvt );
- virtual void Resize();
- virtual void GetFocus();
- virtual void LoseFocus();
- void SetUpdateMode( sal_Bool );
-
- using SvListView::SetModel;
- void SetModel( SvLBoxTreeList* );
- virtual void ModelHasCleared();
- virtual void ModelHasInserted( SvListEntry* pEntry );
- virtual void ModelHasInsertedTree( SvListEntry* pEntry );
- virtual void ModelIsMoving(SvListEntry* pSource,
- SvListEntry* pTargetParent, sal_uLong nChildPos );
- virtual void ModelHasMoved(SvListEntry* pSource );
- virtual void ModelIsRemoving( SvListEntry* pEntry );
- virtual void ModelHasRemoved( SvListEntry* pEntry );
- virtual void ModelHasEntryInvalidated( SvListEntry* pEntry );
-
- void ShowTargetEmphasis( SvLBoxEntry*, sal_Bool bShow );
- using Window::GetDropTarget;
- SvLBoxEntry* GetDropTarget( const Point& );
- void ScrollOutputArea( short nDeltaEntries );
-
- short GetEntryHeight() const { return nEntryHeight; }
- void SetEntryHeight( short nHeight, sal_Bool bAlways = sal_False );
- Size GetOutputSizePixel() const;
- short GetIndent() const { return nIndent; }
- void SetIndent( short nIndent );
- void SetSpaceBetweenEntries( short nSpace );
- short GetSpaceBetweenEntries() const {return nEntryHeightOffs;}
- Point GetEntryPosition( SvLBoxEntry* ) const;
- void ShowEntry( SvLBoxEntry* ); // !!!OBSOLETE, use MakeVisible
- virtual void MakeVisible( SvLBoxEntry* );
- void MakeVisible( SvLBoxEntry*, sal_Bool bMoveToTop );
-
- void SetCollapsedNodeBmp( const Image& );
- void SetExpandedNodeBmp( const Image& );
- Image GetExpandedNodeBmp( ) const;
-
- void SetFont( const Font& rFont );
-
- using Window::SetCursor;
- void SetCursor( SvLBoxEntry* pEntry, sal_Bool bForceNoSelect = sal_False );
-
- SvLBoxEntry* GetEntry( const Point& rPos, sal_Bool bHit = sal_False ) const;
- SvLBoxEntry* GetEntry( SvLBoxEntry* pParent, sal_uLong nPos ) const { return SvLBox::GetEntry(pParent,nPos); }
- SvLBoxEntry* GetEntry( sal_uLong nRootPos ) const { return SvLBox::GetEntry(nRootPos);}
-
- void PaintEntry( SvLBoxEntry* );
- long PaintEntry( SvLBoxEntry*, long nLine,
- sal_uInt16 nTabFlagMask=0xffff );
- virtual Rectangle GetFocusRect( SvLBoxEntry*, long nLine );
- // Beruecksichtigt Einrueckung
- virtual long GetTabPos( SvLBoxEntry*, SvLBoxTab* );
- void InvalidateEntry( SvLBoxEntry* );
- SvLBoxItem* GetItem( SvLBoxEntry*, long nX, SvLBoxTab** ppTab);
- SvLBoxItem* GetItem( SvLBoxEntry*, long nX );
-
- void SetDragDropMode( DragDropMode );
- void SetSelectionMode( SelectionMode );
-
- virtual sal_Bool Expand( SvLBoxEntry* pParent );
- virtual sal_Bool Collapse( SvLBoxEntry* pParent );
- virtual sal_Bool Select( SvLBoxEntry* pEntry, sal_Bool bSelect=sal_True );
- virtual sal_uLong SelectChildren( SvLBoxEntry* pParent, sal_Bool bSelect );
- virtual void SelectAll( sal_Bool bSelect, sal_Bool bPaint = sal_True );
- virtual void SetCurEntry( SvLBoxEntry* _pEntry );
- virtual SvLBoxEntry*
- GetCurEntry() const;
-
- using Window::Invalidate;
- virtual void Invalidate( sal_uInt16 nFlags = 0);
- virtual void Invalidate( const Rectangle&, sal_uInt16 nFlags = 0 );
-
- void SetHighlightRange(sal_uInt16 nFirstTab=0,sal_uInt16 nLastTab=0xffff);
-
- virtual Region GetDragRegion() const;
-
- // Children des Parents werden Children des naechstoberen Parents
- void RemoveParentKeepChildren( SvLBoxEntry* pParent );
-
- DECL_LINK( DefaultCompare, SvSortData* );
- virtual void ModelNotification( sal_uInt16 nActionId, SvListEntry* pEntry1,
- SvListEntry* pEntry2, sal_uLong nPos );
-
- void EndSelection();
- void RepaintScrollBars() const;
- ScrollBar* GetVScroll();
- ScrollBar* GetHScroll();
- void EnableAsyncDrag( sal_Bool b );
-
- SvLBoxEntry* GetFirstEntryInView() const;
- SvLBoxEntry* GetNextEntryInView(SvLBoxEntry*) const;
- SvLBoxEntry* GetLastEntryInView() const;
- void ScrollToAbsPos( long nPos );
-
- void ShowFocusRect( const SvLBoxEntry* pEntry );
- void InitStartEntry();
-
- virtual PopupMenu* CreateContextMenu( void );
- virtual void ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry );
-
- void EnableContextMenuHandling( void );
- void EnableContextMenuHandling( sal_Bool bEnable );
- sal_Bool IsContextMenuHandlingEnabled( void ) const;
-
- void EnableList( bool _bEnable );
-
- // ACCESSIBILITY ==========================================================
-
- /** Creates and returns the accessible object of the Box. */
- virtual ::com::sun::star::uno::Reference<
- ::com::sun::star::accessibility::XAccessible > CreateAccessible();
-
- /** Fills the StateSet with all states (except DEFUNC, done by the accessible object). */
- virtual void FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& rStateSet ) const;
-
- /** Fills the StateSet of one entry. */
- virtual void FillAccessibleEntryStateSet( SvLBoxEntry* pEntry, ::utl::AccessibleStateSetHelper& rStateSet ) const;
-
- /** Calculate and returns the bounding rectangle of an entry.
- @param pEntry
- The entry.
- @return The bounding rectangle of an entry. */
- virtual Rectangle GetBoundingRect( SvLBoxEntry* pEntry );
-
- /** Enables, that one cell of a tablistbox entry can be focused */
- void EnableCellFocus();
-
-protected:
- using SvListView::Expand;
- using SvListView::Collapse;
- using SvListView::Select;
- using SvListView::SelectAll;
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/inc/svtools/svlbox.hxx b/svtools/inc/svtools/treelistbox.hxx
index b582806aa5d0..ced8c5c5f980 100644
--- a/svtools/inc/svtools/svlbox.hxx
+++ b/svtools/inc/svtools/treelistbox.hxx
@@ -26,8 +26,8 @@
*
************************************************************************/
-#ifndef _SVLBOX_HXX
-#define _SVLBOX_HXX
+#ifndef __SVTOOLS_TREELISTBOX_HXX__
+#define __SVTOOLS_TREELISTBOX_HXX__
#include "svtools/svtdllapi.h"
@@ -40,13 +40,14 @@
#include <vcl/accel.hxx>
#include <vcl/mnemonicengine.hxx>
#include <vcl/quickselectionengine.hxx>
+#include <vcl/image.hxx>
#include <tools/gen.hxx>
#include <tools/contnr.hxx>
#include <svtools/treelist.hxx>
#include <svtools/transfer.hxx>
class Application;
-class SvLBox;
+class SvTreeListBox;
class SvLBoxEntry;
class SvViewDataItem;
class SvViewDataEntry;
@@ -55,12 +56,23 @@ class SvLBoxString;
class SvLBoxButton;
class SvLBoxContextBmp;
class SvLBoxBmp;
+class SvImpLBox;
+class SvLBoxButtonData;
struct SvLBoxDDInfo;
namespace utl {
class AccessibleStateSetHelper;
}
+enum SvLBoxButtonKind
+{
+ SvLBoxButtonKind_enabledCheckbox,
+ SvLBoxButtonKind_disabledCheckbox,
+ SvLBoxButtonKind_staticImage
+};
+
+enum SvButtonState { SV_BUTTON_UNCHECKED, SV_BUTTON_CHECKED, SV_BUTTON_TRISTATE };
+
// *********************************************************************
// *************************** Tabulatoren *****************************
// *********************************************************************
@@ -87,6 +99,26 @@ namespace utl {
// Tabs entspricht jetzt exakt den eingestellten Flags &
// Spaltenbreiten.
+#define SV_TAB_BORDER 8
+
+#define SV_LISTBOX_ID_TREEBOX 1 // fuer SvLBox::IsA()
+#define SV_ENTRYHEIGHTOFFS_PIXEL 2
+
+#define TREEFLAG_CHKBTN 0x0001
+#define TREEFLAG_USESEL 0x0002
+#define TREEFLAG_MANINS 0x0004
+#define TREEFLAG_RECALCTABS 0x0008
+
+typedef sal_Int64 ExtendedWinBits;
+
+// disable the behavior of automatically selecting a "CurEntry" upon painting the control
+#define EWB_NO_AUTO_CURENTRY 0x00000001
+
+#define SV_ITEM_ID_LBOXSTRING 1
+#define SV_ITEM_ID_LBOXBMP 2
+#define SV_ITEM_ID_LBOXBUTTON 3
+#define SV_ITEM_ID_LBOXCONTEXTBMP 4
+
class SvLBoxTab
{
long nPos;
@@ -123,7 +155,7 @@ public:
};
// View-abhaengige Daten fuer einen Entry werden in virtueller Fkt.
-// SvLBox::CreateViewData erzeugt. Die ViewDaten-Erzeugung von
+// SvTreeListBox::CreateViewData erzeugt. Die ViewDaten-Erzeugung von
// Items kann nicht veraendert werden (wg. Array)
class SvViewDataEntry : public SvViewData
{
@@ -146,18 +178,18 @@ public:
SvLBoxItem();
virtual ~SvLBoxItem();
virtual sal_uInt16 IsA() = 0;
- const Size& GetSize( SvLBox* pView, SvLBoxEntry* pEntry );
+ const Size& GetSize( SvTreeListBox* pView, SvLBoxEntry* pEntry );
const Size& GetSize( SvViewDataEntry* pData, sal_uInt16 nItemPos )
{
SvViewDataItem* pIData=pData->pItemData+nItemPos;
return pIData->aSize;
}
- virtual void Paint( const Point& rPos, SvLBox& rOutDev,
+ virtual void Paint( const Point& rPos, SvTreeListBox& rOutDev,
sal_uInt16 nViewDataEntryFlags,
SvLBoxEntry* pEntry ) = 0;
- virtual void InitViewData( SvLBox* pView, SvLBoxEntry* pEntry,
+ virtual void InitViewData( SvTreeListBox* pView, SvLBoxEntry* pEntry,
// wenn != 0 muss dieser Pointer benutzt werden!
// wenn == 0 muss er ueber die View geholt werden
SvViewDataItem* pViewData = 0) = 0;
@@ -180,7 +212,7 @@ public:
class SVT_DLLPUBLIC SvLBoxEntry : public SvListEntry
{
- friend class SvLBox;
+ friend class SvTreeListBox;
std::vector<SvLBoxItem*> aItems;
void* pUserData;
@@ -234,7 +266,7 @@ public:
};
// *********************************************************************
-// ****************************** SvLBox *******************************
+// ****************************** SvTreeListBox *******************************
// *********************************************************************
#define WB_FORCE_SELECTION ((WinBits)0x8000)
@@ -250,7 +282,7 @@ public:
// Das Drop-Target ist in diesem Fall 0
#define SV_DRAGDROP_ENABLE_TOP (DragDropMode)0x0020
-#define SVLISTBOX_ID_LBOX 0 // fuer SvLBox::IsA()
+#define SVLISTBOX_ID_LBOX 0 // fuer SvTreeListBox::IsA()
#define SVLBOX_IN_EDT 0x0001
#define SVLBOX_EDT_ENABLED 0x0002
@@ -259,7 +291,7 @@ public:
#define SVLBOX_TARGEMPH_VIS 0x0010
#define SVLBOX_EDTEND_CALLED 0x0020
-class SvLBox;
+class SvTreeListBox;
struct SvLBox_Impl
{
bool m_bIsEmptyTextAllowed;
@@ -269,10 +301,10 @@ struct SvLBox_Impl
::vcl::MnemonicEngine m_aMnemonicEngine;
::vcl::QuickSelectionEngine m_aQuickSelectionEngine;
- SvLBox_Impl( SvLBox& _rBox );
+ SvLBox_Impl( SvTreeListBox& _rBox );
};
-class SVT_DLLPUBLIC SvLBox
+class SVT_DLLPUBLIC SvTreeListBox
:public Control
,public SvListView
,public DropTargetHelper
@@ -292,9 +324,9 @@ class SVT_DLLPUBLIC SvLBox
// call. AddBox method is called from the GetDragFinishedHdl() and the
// remove is called in link callback and in the destructor. So it can't
// called to a deleted object.
- SVT_DLLPRIVATE static void AddBoxToDDList_Impl( const SvLBox& rB );
- SVT_DLLPRIVATE static void RemoveBoxFromDDList_Impl( const SvLBox& rB );
- DECL_DLLPRIVATE_STATIC_LINK( SvLBox, DragFinishHdl_Impl, sal_Int8* );
+ SVT_DLLPRIVATE static void AddBoxToDDList_Impl( const SvTreeListBox& rB );
+ SVT_DLLPRIVATE static void RemoveBoxFromDDList_Impl( const SvTreeListBox& rB );
+ DECL_DLLPRIVATE_STATIC_LINK( SvTreeListBox, DragFinishHdl_Impl, sal_Int8* );
DragDropMode nOldDragMode;
@@ -319,7 +351,7 @@ protected:
SelectionMode eSelMode;
sal_Int8 nDragOptions;
- sal_Bool CheckDragAndDropMode( SvLBox* pSource, sal_Int8 );
+ sal_Bool CheckDragAndDropMode( SvTreeListBox* pSource, sal_Int8 );
void ImplShowTargetEmphasis( SvLBoxEntry* pEntry, sal_Bool bShow);
void EnableSelectionAsDropTarget( sal_Bool bEnable = sal_True,
sal_Bool bWithChildren = sal_True );
@@ -335,28 +367,19 @@ protected:
virtual void ReadDragServerInfo( const Point&,SvLBoxDDInfo* );
// invalidate children on enable/disable
- virtual void StateChanged( StateChangedType );
+ virtual void StateChanged( StateChangedType eType );
virtual sal_uLong Insert( SvLBoxEntry* pEnt,SvLBoxEntry* pPar,sal_uLong nPos=LIST_APPEND);
virtual sal_uLong Insert( SvLBoxEntry* pEntry,sal_uLong nRootPos = LIST_APPEND );
// Inplace-Editing
SvInplaceEdit2* pEdCtrl;
- void EnableInplaceEditing( sal_Bool bEnable){if(bEnable)nImpFlags|=SVLBOX_EDT_ENABLED; else nImpFlags&=~SVLBOX_EDT_ENABLED;}
- sal_Bool IsInplaceEditingEnabled() const { return (sal_Bool)((nImpFlags&SVLBOX_EDT_ENABLED)!=0); }
- virtual void EditingRequest( SvLBoxEntry* pEntry, SvLBoxItem* pItem,
- const Point& rMousePos );
void EditText( const String&, const Rectangle&,const Selection&);
void EditText( const String&, const Rectangle&,const Selection&, sal_Bool bMulti);
void EditTextMultiLine( const String&, const Rectangle&,const Selection&);
void CancelTextEditing();
- sal_Bool IsEditingActive() const { return (sal_Bool)((nImpFlags & SVLBOX_IN_EDT)!=0); }
sal_Bool EditingCanceled() const;
- void EndEditing( sal_Bool bCancel = sal_False );
bool IsEmptyTextAllowed() const;
- void ForbidEmptyText();
- // Callback EditText
- virtual void EditedText( const String& );
// Rueckgabewert muss von SvViewDataEntry abgeleitet sein!
virtual SvViewData* CreateViewData( SvListEntry* );
@@ -368,21 +391,16 @@ protected:
// Callback von RecalcViewData
virtual void ViewDataInitialized( SvLBoxEntry* );
- virtual void Command( const CommandEvent& rCEvt );
- virtual void KeyInput( const KeyEvent& rKEvt );
- virtual SvLBoxEntry* GetEntry( const Point& rPos, sal_Bool bHit=sal_False ) const;
- virtual void ModelHasEntryInvalidated( SvListEntry* pEntry );
-
// handler and methods for Drag - finished handler. This link can be set
// to the TransferDataContainer. The AddBox/RemoveBox methods must be
// called before the StartDrag call.
// The Remove will be called from the handler, which then called
- // DragFinish method. The Remove also called in the DTOR of the SvLBox -
+ // DragFinish method. The Remove also called in the DTOR of the SvTreeListBox -
// so it can't called to a deleted object.
Link GetDragFinishedHdl() const;
// for asynchronous D&D
- sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt, SvLBox* pSourceView );
+ sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt, SvTreeListBox* pSourceView );
void OnCurrentEntryChanged();
@@ -399,16 +417,15 @@ protected:
public:
- SvLBox( Window* pParent, WinBits nWinStyle=0 );
- SvLBox( Window* pParent, const ResId& rResId );
- ~SvLBox();
+ SvTreeListBox( Window* pParent, WinBits nWinStyle=0 );
+ SvTreeListBox( Window* pParent, const ResId& rResId );
+ ~SvTreeListBox();
SvLBoxTreeList* GetModel() const { return (SvLBoxTreeList*)pModel; }
using SvListView::SetModel;
void SetModel( SvLBoxTreeList* );
- void DisconnectFromModel();
- virtual sal_uInt16 IsA();
+ sal_uInt16 IsA();
sal_uLong GetEntryCount() const {return pModel->GetEntryCount();}
SvLBoxEntry* First() const { return (SvLBoxEntry*)(pModel->First()); }
SvLBoxEntry* Next( SvLBoxEntry* pEntry, sal_uInt16* pDepth=0 ) const { return (SvLBoxEntry*)(pModel->Next(pEntry,pDepth));}
@@ -426,15 +443,13 @@ public:
SvLBoxEntry* PrevSelected( SvLBoxEntry* pEntry ) const { return (SvLBoxEntry*)(SvListView::PrevSelected(pEntry)); }
SvLBoxEntry* LastSelected() const { return (SvLBoxEntry*)(SvListView::LastSelected()); }
- sal_Bool CopySelection( SvLBox* pSource, SvLBoxEntry* pTarget );
- sal_Bool MoveSelection( SvLBox* pSource, SvLBoxEntry* pTarget );
- sal_Bool MoveSelectionCopyFallbackPossible( SvLBox* pSource, SvLBoxEntry* pTarget, sal_Bool bAllowCopyFallback );
+ sal_Bool CopySelection( SvTreeListBox* pSource, SvLBoxEntry* pTarget );
+ sal_Bool MoveSelection( SvTreeListBox* pSource, SvLBoxEntry* pTarget );
+ sal_Bool MoveSelectionCopyFallbackPossible( SvTreeListBox* pSource, SvLBoxEntry* pTarget, sal_Bool bAllowCopyFallback );
void RemoveSelection();
DragDropMode GetDragDropMode() const { return nDragDropMode; }
- virtual void SetDragDropMode( DragDropMode );
SelectionMode GetSelectionMode() const { return eSelMode; }
- virtual void SetSelectionMode( SelectionMode );
// pParent==0 -> Root-Ebene
SvLBoxEntry* GetEntry( SvLBoxEntry* pParent, sal_uLong nPos ) const { return (SvLBoxEntry*)(pModel->GetEntry(pParent,nPos)); }
@@ -442,7 +457,6 @@ public:
SvLBoxEntry* GetEntryFromPath( const ::std::deque< sal_Int32 >& _rPath ) const;
void FillEntryPath( SvLBoxEntry* pEntry, ::std::deque< sal_Int32 >& _rPath ) const;
- virtual String GetEntryText( SvLBoxEntry* pEntry ) const;
using Window::GetParent;
SvLBoxEntry* GetParent( SvLBoxEntry* pEntry ) const { return (SvLBoxEntry*)(pModel->GetParent(pEntry)); }
@@ -455,7 +469,11 @@ public:
SvViewDataEntry* GetViewDataEntry( SvListEntry* pEntry ) const { return (SvViewDataEntry*)SvListView::GetViewData(pEntry); }
SvViewDataItem* GetViewDataItem( SvListEntry*, SvLBoxItem* ) const;
- virtual void MakeVisible( SvLBoxEntry* pEntry );
+ bool IsInplaceEditingEnabled() const { return ((nImpFlags & SVLBOX_EDT_ENABLED) != 0); }
+ bool IsEditingActive() const { return ((nImpFlags & SVLBOX_IN_EDT) != 0); }
+ void EndEditing( bool bCancel = false );
+ void ForbidEmptyText();
+
void Clear();
/** enables or disables mnemonic characters in the entry texts.
@@ -493,16 +511,6 @@ public:
*/
bool HandleKeyInput( const KeyEvent& rKEvt );
- virtual sal_Bool Expand( SvLBoxEntry* pParent );
- virtual sal_Bool Collapse( SvLBoxEntry* pParent );
- virtual sal_Bool Select( SvLBoxEntry* pEntry, sal_Bool bSelect=sal_True );
- virtual sal_uLong SelectChildren( SvLBoxEntry* pParent, sal_Bool bSelect );
- virtual void SelectAll( sal_Bool bSelect, sal_Bool bPaint=sal_True );
-
- virtual void SetCurEntry( SvLBoxEntry* _pEntry ) = 0;
- virtual SvLBoxEntry*
- GetCurEntry() const = 0;
-
void SetSelectHdl( const Link& rNewHdl ) {aSelectHdl=rNewHdl; }
void SetDeselectHdl( const Link& rNewHdl ) {aDeselectHdl=rNewHdl; }
void SetDoubleClickHdl(const Link& rNewHdl) {aDoubleClickHdl=rNewHdl;}
@@ -540,10 +548,9 @@ public:
void SetDragOptions( sal_Int8 nOptions ) { nDragOptions = nOptions; }
sal_Int8 GetDragOptions() const { return nDragOptions; }
- SvLBox* GetSourceView() const;
+ SvTreeListBox* GetSourceView() const;
virtual void NotifyRemoving( SvLBoxEntry* );
- virtual void ShowTargetEmphasis( SvLBoxEntry*, sal_Bool bShow );
virtual SvLBoxEntry* CloneEntry( SvLBoxEntry* pSource );
virtual SvLBoxEntry* CreateEntry() const; // zum 'new'en von Entries
@@ -572,24 +579,322 @@ public:
/** Fills the StateSet with all states (except DEFUNC, done by the accessible object). */
virtual void FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& rStateSet ) const;
+ /** Fills the StateSet of one entry. */
+ virtual void FillAccessibleEntryStateSet( SvLBoxEntry* pEntry, ::utl::AccessibleStateSetHelper& rStateSet ) const;
+
/** Calculate and returns the bounding rectangle of an entry.
@param pEntry
The entry.
@return The bounding rectangle of an entry. */
virtual Rectangle GetBoundingRect( SvLBoxEntry* pEntry );
+ /** Enables, that one cell of a tablistbox entry can be focused */
+ void EnableCellFocus();
+
protected:
using SvListView::Expand;
using SvListView::Collapse;
using SvListView::Select;
using SvListView::SelectAll;
+
+// boundary ----- former SvTreeListBox ends here.
+
+ friend class SvImpLBox;
+ friend class ImpLBSelEng;
+ friend class TreeControlPeer;
+
+ SvImpLBox* pImp;
+ Link aCheckButtonHdl;
+ Link aScrolledHdl;
+ Accelerator aInpEditAcc;
+ Image aPrevInsertedExpBmp;
+ Image aPrevInsertedColBmp;
+ Image aCurInsertedExpBmp;
+ Image aCurInsertedColBmp;
+
+ short nContextBmpWidthMax;
+ sal_uInt16 nFirstSelTab, nLastSelTab;
+ short nEntryHeight;
+ short nEntryHeightOffs;
+ short nIndent;
+ short nFocusWidth;
+ sal_uInt16 aContextBmpMode;
+
+ long mnCheckboxItemWidth;
+
+ DECL_DLLPRIVATE_LINK( CheckButtonClick, SvLBoxButtonData * );
+
+ SVT_DLLPRIVATE short GetHeightOffset( const Image& rBmp, Size& rLogicSize);
+ SVT_DLLPRIVATE short GetHeightOffset( const Font& rFont, Size& rLogicSize);
+
+ SVT_DLLPRIVATE void SetEntryHeight( SvLBoxEntry* pEntry );
+ SVT_DLLPRIVATE void AdjustEntryHeight( const Image& rBmp );
+ SVT_DLLPRIVATE void AdjustEntryHeight( const Font& rFont );
+
+ SVT_DLLPRIVATE void ImpEntryInserted( SvLBoxEntry* pEntry );
+ SVT_DLLPRIVATE long PaintEntry1( SvLBoxEntry*, long nLine,
+ sal_uInt16 nTabFlagMask=0xffff,
+ sal_Bool bHasClipRegion=sal_False );
+
+ SVT_DLLPRIVATE void InitTreeView();
+ SVT_DLLPRIVATE SvLBoxItem* GetItem_Impl( SvLBoxEntry*, long nX, SvLBoxTab** ppTab,
+ sal_uInt16 nEmptyWidth );
+ SVT_DLLPRIVATE void ImplInitStyle();
+
+protected:
+ SvLBoxButtonData* pCheckButtonData;
+ sal_uInt16 nTreeFlags;
+
+ SvLBoxEntry* pEdEntry;
+ SvLBoxItem* pEdItem;
+
+ void EditItemText( SvLBoxEntry* pEntry, SvLBoxString* pItem,
+ const Selection& );
+ void EditedText( const XubString& );
+ void EditingRequest( SvLBoxEntry* pEntry, SvLBoxItem* pItem,
+ const Point& rMousePos );
+
+ std::vector<SvLBoxTab*> aTabs;
+
+ // berechnet abhaengig von TreeList-Style & Bitmap-Groessen
+ // alle Tabulatoren neu; wird beim Einfuegen/Austauschen von
+ // Bitmaps, beim Wechsel des Models usw. automatisch gerufen
+ virtual void SetTabs();
+ void SetTabs_Impl();
+ void AddTab( long nPos,sal_uInt16 nFlags=SV_LBOXTAB_ADJUST_LEFT,
+ void* pUserData = 0 );
+ sal_uInt16 TabCount() const { return aTabs.size(); }
+ SvLBoxTab* GetFirstDynamicTab() const;
+ SvLBoxTab* GetFirstDynamicTab( sal_uInt16& rTabPos ) const;
+ SvLBoxTab* GetFirstTab( sal_uInt16 nFlagMask, sal_uInt16& rTabPos );
+ SvLBoxTab* GetLastTab( sal_uInt16 nFlagMask, sal_uInt16& rTabPos );
+ SvLBoxTab* GetTab( SvLBoxEntry*, SvLBoxItem* ) const;
+ void ClearTabList();
+
+ virtual void InitEntry(SvLBoxEntry*,const XubString&,const Image&,const Image&,SvLBoxButtonKind);
+
+ virtual void NotifyBeginScroll();
+ virtual void NotifyEndScroll();
+ // nLines == 0 => horizontales Scrolling
+ virtual void NotifyScrolling( long nLines );
+ virtual void NotifyScrolled();
+ void SetScrolledHdl( const Link& rLink ) { aScrolledHdl = rLink; }
+ const Link& GetScrolledHdl() const { return aScrolledHdl; }
+ long GetXOffset() const { return GetMapMode().GetOrigin().X(); }
+
+ // wird aufgerufen, _bevor_ Bereiche im Control invalidiert werden,
+ // kann zum Hiden von Elementen benutzt werden, die von aussen
+ // in das Control hineingezeichnet werden
+ virtual void NotifyInvalidating();
+
+ virtual sal_uLong GetAscInsertionPos( SvLBoxEntry*, SvLBoxEntry* pParent );
+ virtual sal_uLong GetDescInsertionPos( SvLBoxEntry*, SvLBoxEntry* pParent );
+ virtual void Command( const CommandEvent& rCEvt );
+
+ virtual void RequestHelp( const HelpEvent& rHEvt );
+ virtual void CursorMoved( SvLBoxEntry* pNewCursor );
+ virtual void PreparePaint( SvLBoxEntry* );
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+ void InitSettings(sal_Bool bFont,sal_Bool bForeground,sal_Bool bBackground);
+ sal_Bool IsCellFocusEnabled() const;
+ bool SetCurrentTabPos( sal_uInt16 _nNewPos );
+ sal_uInt16 GetCurrentTabPos() const;
+ void CallImplEventListeners(sal_uLong nEvent, void* pData);
+
+ void ImplEditEntry( SvLBoxEntry* pEntry );
+
+ sal_Bool AreChildrenTransient() const;
+ void SetChildrenNotTransient();
+
+public:
+
+ void SetExtendedWinBits( ExtendedWinBits _nBits );
+
+ void DisconnectFromModel();
+
+ void EnableCheckButton( SvLBoxButtonData* );
+ void SetCheckButtonData( SvLBoxButtonData* );
+ void SetNodeBitmaps( const Image& rCollapsedNodeBmp, const Image& rExpandedNodeBmp );
+
+ /** returns the default image which clients should use for expanded nodes, to have a consistent user
+ interface experience in the whole product.
+ */
+ static const Image& GetDefaultExpandedNodeImage( );
+
+ /** returns the default image which clients should use for expanded nodes, to have a consistent user
+ interface experience in the whole product.
+ */
+ static const Image& GetDefaultCollapsedNodeImage( );
+
+ /** sets default bitmaps for collapsed and expanded nodes.
+ */
+ inline void SetNodeDefaultImages( )
+ {
+ SetNodeBitmaps(
+ GetDefaultCollapsedNodeImage( ),
+ GetDefaultExpandedNodeImage( )
+ );
+ }
+
+ virtual SvLBoxEntry* InsertEntry( const XubString& rText, SvLBoxEntry* pParent = 0,
+ sal_Bool bChildrenOnDemand = sal_False,
+ sal_uLong nPos=LIST_APPEND, void* pUserData = 0,
+ SvLBoxButtonKind eButtonKind = SvLBoxButtonKind_enabledCheckbox );
+
+ virtual SvLBoxEntry* InsertEntry( const XubString& rText,
+ const Image& rExpandedEntryBmp,
+ const Image& rCollapsedEntryBmp,
+ SvLBoxEntry* pParent = 0,
+ sal_Bool bChildrenOnDemand = sal_False,
+ sal_uLong nPos = LIST_APPEND, void* pUserData = 0,
+ SvLBoxButtonKind eButtonKind = SvLBoxButtonKind_enabledCheckbox );
+
+ const Image& GetDefaultExpandedEntryBmp( ) const;
+ const Image& GetDefaultCollapsedEntryBmp( ) const;
+
+ void SetDefaultExpandedEntryBmp( const Image& rBmp );
+ void SetDefaultCollapsedEntryBmp( const Image& rBmp );
+
+ void SetCheckButtonState( SvLBoxEntry*, SvButtonState );
+ SvButtonState GetCheckButtonState( SvLBoxEntry* ) const;
+
+ sal_Bool IsExpandBitmapOnCursor() const { return (sal_Bool)(aContextBmpMode & SVLISTENTRYFLAG_FOCUSED)!=0; }
+
+ void SetEntryText(SvLBoxEntry*, const XubString& );
+ void SetExpandedEntryBmp( SvLBoxEntry* _pEntry, const Image& _rImage );
+ void SetCollapsedEntryBmp( SvLBoxEntry* _pEntry, const Image& _rImage );
+
+ virtual String GetEntryText( SvLBoxEntry* pEntry ) const;
+ String SearchEntryText( SvLBoxEntry* pEntry ) const;
+ const Image& GetExpandedEntryBmp(SvLBoxEntry* _pEntry ) const;
+ const Image& GetCollapsedEntryBmp(SvLBoxEntry* _pEntry ) const;
+
+ void SetCheckButtonHdl( const Link& rLink ) { aCheckButtonHdl=rLink; }
+ Link GetCheckButtonHdl() const { return aCheckButtonHdl; }
+ virtual void CheckButtonHdl();
+
+ void SetSublistOpenWithReturn( sal_Bool bMode = sal_True ); // open/close sublist with return/enter
+ void SetSublistOpenWithLeftRight( sal_Bool bMode = sal_True ); // open/close sublist with cursor left/right
+
+ void EnableInplaceEditing( bool bEnable );
+ // Editiert das erste StringItem des Entries, 0==Cursor
+ void EditEntry( SvLBoxEntry* pEntry = NULL );
+ virtual sal_Bool EditingEntry( SvLBoxEntry* pEntry, Selection& );
+ virtual sal_Bool EditedEntry( SvLBoxEntry* pEntry, const rtl::OUString& rNewText );
+
+ virtual void Paint( const Rectangle& rRect );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual void Resize();
+ virtual void GetFocus();
+ virtual void LoseFocus();
+ void SetUpdateMode( sal_Bool );
+
+ virtual void ModelHasCleared();
+ virtual void ModelHasInserted( SvListEntry* pEntry );
+ virtual void ModelHasInsertedTree( SvListEntry* pEntry );
+ virtual void ModelIsMoving(SvListEntry* pSource,
+ SvListEntry* pTargetParent, sal_uLong nChildPos );
+ virtual void ModelHasMoved(SvListEntry* pSource );
+ virtual void ModelIsRemoving( SvListEntry* pEntry );
+ virtual void ModelHasRemoved( SvListEntry* pEntry );
+ void ModelHasEntryInvalidated( SvListEntry* pEntry );
+
+ void ShowTargetEmphasis( SvLBoxEntry*, sal_Bool bShow );
+ void ScrollOutputArea( short nDeltaEntries );
+
+ short GetEntryHeight() const { return nEntryHeight; }
+ void SetEntryHeight( short nHeight, sal_Bool bAlways = sal_False );
+ Size GetOutputSizePixel() const;
+ short GetIndent() const { return nIndent; }
+ void SetIndent( short nIndent );
+ void SetSpaceBetweenEntries( short nSpace );
+ short GetSpaceBetweenEntries() const {return nEntryHeightOffs;}
+ Point GetEntryPosition( SvLBoxEntry* ) const;
+ void ShowEntry( SvLBoxEntry* ); // !!!OBSOLETE, use MakeVisible
+ void MakeVisible( SvLBoxEntry* pEntry );
+ void MakeVisible( SvLBoxEntry* pEntry, sal_Bool bMoveToTop );
+
+ void SetCollapsedNodeBmp( const Image& );
+ void SetExpandedNodeBmp( const Image& );
+ Image GetExpandedNodeBmp( ) const;
+
+ void SetFont( const Font& rFont );
+
+ using Window::SetCursor;
+ void SetCursor( SvLBoxEntry* pEntry, sal_Bool bForceNoSelect = sal_False );
+
+ SvLBoxEntry* GetEntry( const Point& rPos, sal_Bool bHit = sal_False ) const;
+
+ void PaintEntry( SvLBoxEntry* );
+ long PaintEntry( SvLBoxEntry*, long nLine,
+ sal_uInt16 nTabFlagMask=0xffff );
+ virtual Rectangle GetFocusRect( SvLBoxEntry*, long nLine );
+ // Beruecksichtigt Einrueckung
+ virtual long GetTabPos( SvLBoxEntry*, SvLBoxTab* );
+ void InvalidateEntry( SvLBoxEntry* );
+ SvLBoxItem* GetItem( SvLBoxEntry*, long nX, SvLBoxTab** ppTab);
+ SvLBoxItem* GetItem( SvLBoxEntry*, long nX );
+
+ void SetDragDropMode( DragDropMode );
+ void SetSelectionMode( SelectionMode );
+
+ sal_Bool Expand( SvLBoxEntry* pParent );
+ sal_Bool Collapse( SvLBoxEntry* pParent );
+ sal_Bool Select( SvLBoxEntry* pEntry, sal_Bool bSelect=sal_True );
+ sal_uLong SelectChildren( SvLBoxEntry* pParent, sal_Bool bSelect );
+ virtual void SelectAll( sal_Bool bSelect, sal_Bool bPaint = sal_True );
+
+ void SetCurEntry( SvLBoxEntry* _pEntry );
+ SvLBoxEntry* GetCurEntry() const;
+
+ using Window::Invalidate;
+ virtual void Invalidate( sal_uInt16 nFlags = 0);
+ virtual void Invalidate( const Rectangle&, sal_uInt16 nFlags = 0 );
+
+ void SetHighlightRange(sal_uInt16 nFirstTab=0,sal_uInt16 nLastTab=0xffff);
+
+ virtual Region GetDragRegion() const;
+
+ // Children des Parents werden Children des naechstoberen Parents
+ void RemoveParentKeepChildren( SvLBoxEntry* pParent );
+
+ DECL_LINK( DefaultCompare, SvSortData* );
+ virtual void ModelNotification( sal_uInt16 nActionId, SvListEntry* pEntry1,
+ SvListEntry* pEntry2, sal_uLong nPos );
+
+ void EndSelection();
+ void RepaintScrollBars() const;
+ ScrollBar* GetVScroll();
+ ScrollBar* GetHScroll();
+ void EnableAsyncDrag( sal_Bool b );
+
+ SvLBoxEntry* GetFirstEntryInView() const;
+ SvLBoxEntry* GetNextEntryInView(SvLBoxEntry*) const;
+ SvLBoxEntry* GetLastEntryInView() const;
+ void ScrollToAbsPos( long nPos );
+
+ void ShowFocusRect( const SvLBoxEntry* pEntry );
+ void InitStartEntry();
+
+ virtual PopupMenu* CreateContextMenu( void );
+ virtual void ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry );
+
+ void EnableContextMenuHandling( void );
+ void EnableContextMenuHandling( sal_Bool bEnable );
+ sal_Bool IsContextMenuHandlingEnabled( void ) const;
+
+ void EnableList( bool _bEnable );
};
#define SV_LBOX_DD_FORMAT "SV_LBOX_DD_FORMAT"
struct SvLBoxDDInfo
{
Application* pApp;
- SvLBox* pSource;
+ SvTreeListBox* pSource;
SvLBoxEntry* pDDStartEntry;
// relative Position im Eintrag bei Drag-Beginn (IconView)
long nMouseRelX,nMouseRelY;
@@ -625,7 +930,7 @@ public:
void Hide();
};
-inline SvViewDataItem* SvLBox::GetViewDataItem( SvListEntry* pEntry,
+inline SvViewDataItem* SvTreeListBox::GetViewDataItem( SvListEntry* pEntry,
SvLBoxItem* pItem) const
{
SvViewDataEntry* pEntryData =
diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx
index 6149811e00c5..a2b230604088 100644
--- a/svtools/source/contnr/svimpbox.cxx
+++ b/svtools/source/contnr/svimpbox.cxx
@@ -32,9 +32,9 @@
#include <stack>
-#define _SVTREEBX_CXX
-#include <svtools/svtreebx.hxx>
-#include <svtools/svlbox.hxx>
+#include <svtools/treelistbox.hxx>
+#include <svtools/treelistbox.hxx>
+#include <svtools/svlbitm.hxx>
#include <svimpbox.hxx>
#include <rtl/instance.hxx>
#include <svtools/svtresid.hxx>
diff --git a/svtools/source/contnr/svlbitm.cxx b/svtools/source/contnr/svlbitm.cxx
index 17d3c9804901..0d3e4e8b7085 100644
--- a/svtools/source/contnr/svlbitm.cxx
+++ b/svtools/source/contnr/svlbitm.cxx
@@ -26,7 +26,7 @@
*
************************************************************************/
-#include <svtools/svlbox.hxx>
+#include <svtools/treelistbox.hxx>
#include <svtools/svlbitm.hxx>
#include <vcl/svapp.hxx>
#include <vcl/button.hxx>
@@ -219,7 +219,7 @@ sal_uInt16 SvLBoxString::IsA()
return SV_ITEM_ID_LBOXSTRING;
}
-void SvLBoxString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 /* nFlags */,
+void SvLBoxString::Paint( const Point& rPos, SvTreeListBox& rDev, sal_uInt16 /* nFlags */,
SvLBoxEntry* _pEntry)
{
DBG_CHKTHIS(SvLBoxString,0);
@@ -247,8 +247,8 @@ void SvLBoxString::Clone( SvLBoxItem* pSource )
maText = ((SvLBoxString*)pSource)->maText;
}
-void SvLBoxString::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry,
- SvViewDataItem* pViewData)
+void SvLBoxString::InitViewData(
+ SvTreeListBox* pView, SvLBoxEntry* pEntry, SvViewDataItem* pViewData)
{
DBG_CHKTHIS(SvLBoxString,0);
if( !pViewData )
@@ -278,7 +278,7 @@ sal_uInt16 SvLBoxBmp::IsA()
return SV_ITEM_ID_LBOXBMP;
}
-void SvLBoxBmp::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry,
+void SvLBoxBmp::InitViewData( SvTreeListBox* pView,SvLBoxEntry* pEntry,
SvViewDataItem* pViewData)
{
DBG_CHKTHIS(SvLBoxBmp,0);
@@ -287,7 +287,7 @@ void SvLBoxBmp::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry,
pViewData->aSize = aBmp.GetSizePixel();
}
-void SvLBoxBmp::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 /* nFlags */,
+void SvLBoxBmp::Paint( const Point& rPos, SvTreeListBox& rDev, sal_uInt16 /* nFlags */,
SvLBoxEntry* )
{
DBG_CHKTHIS(SvLBoxBmp,0);
@@ -344,7 +344,7 @@ sal_uInt16 SvLBoxButton::IsA()
return SV_ITEM_ID_LBOXBUTTON;
}
-sal_Bool SvLBoxButton::ClickHdl( SvLBox*, SvLBoxEntry* pEntry )
+sal_Bool SvLBoxButton::ClickHdl( SvTreeListBox*, SvLBoxEntry* pEntry )
{
DBG_CHKTHIS(SvLBoxButton,0);
if ( CheckModification() )
@@ -359,7 +359,7 @@ sal_Bool SvLBoxButton::ClickHdl( SvLBox*, SvLBoxEntry* pEntry )
return sal_False;
}
-void SvLBoxButton::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 /* nFlags */,
+void SvLBoxButton::Paint( const Point& rPos, SvTreeListBox& rDev, sal_uInt16 /* nFlags */,
SvLBoxEntry* /*pEntry*/ )
{
DBG_CHKTHIS(SvLBoxButton,0);
@@ -444,7 +444,7 @@ void SvLBoxButton::ImplAdjustBoxSize( Size& io_rSize, ControlType i_eType, Windo
}
}
-void SvLBoxButton::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry,
+void SvLBoxButton::InitViewData( SvTreeListBox* pView,SvLBoxEntry* pEntry,
SvViewDataItem* pViewData )
{
DBG_CHKTHIS(SvLBoxButton,0);
@@ -527,7 +527,7 @@ Image& SvLBoxContextBmp::implGetImageStore( sal_Bool _bFirst )
return _bFirst ? m_pImpl->m_aImage1 : m_pImpl->m_aImage2;
}
-void SvLBoxContextBmp::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry,
+void SvLBoxContextBmp::InitViewData( SvTreeListBox* pView,SvLBoxEntry* pEntry,
SvViewDataItem* pViewData)
{
DBG_CHKTHIS(SvLBoxContextBmp,0);
@@ -536,7 +536,7 @@ void SvLBoxContextBmp::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry,
pViewData->aSize = m_pImpl->m_aImage1.GetSizePixel();
}
-void SvLBoxContextBmp::Paint( const Point& _rPos, SvLBox& _rDev,
+void SvLBoxContextBmp::Paint( const Point& _rPos, SvTreeListBox& _rDev,
sal_uInt16 _nViewDataEntryFlags, SvLBoxEntry* _pEntry )
{
DBG_CHKTHIS(SvLBoxContextBmp,0);
diff --git a/svtools/source/contnr/svlbox.cxx b/svtools/source/contnr/svlbox.cxx
deleted file mode 100644
index a16e72328471..000000000000
--- a/svtools/source/contnr/svlbox.cxx
+++ /dev/null
@@ -1,1794 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-
-/*
- TODO:
- - delete anchor in SelectionEngine when selecting manually
- - SelectAll( sal_False ) => only repaint the delselected entries
-*/
-
-#include <string.h>
-#include <svtools/svlbox.hxx>
-#include <com/sun/star/accessibility/AccessibleStateType.hpp>
-#include <vcl/svapp.hxx>
-#include <vcl/accel.hxx>
-#include <vcl/i18nhelp.hxx>
-#include <sot/formats.hxx>
-#include <unotools/accessiblestatesethelper.hxx>
-#include <rtl/instance.hxx>
-
-#include <svtools/svmedit.hxx>
-#include <svtools/svlbitm.hxx>
-
-#include <set>
-
-using namespace ::com::sun::star::accessibility;
-
-// Drag&Drop
-static SvLBox* pDDSource = NULL;
-static SvLBox* pDDTarget = NULL;
-
-DBG_NAME(SvInplaceEdit2)
-
-#define SVLBOX_ACC_RETURN 1
-#define SVLBOX_ACC_ESCAPE 2
-
-// ***************************************************************
-
-class MyEdit_Impl : public Edit
-{
- SvInplaceEdit2* pOwner;
-public:
- MyEdit_Impl( Window* pParent, SvInplaceEdit2* pOwner );
- virtual void KeyInput( const KeyEvent& rKEvt );
- virtual void LoseFocus();
-};
-
-class MyMultiEdit_Impl : public MultiLineEdit
-{
- SvInplaceEdit2* pOwner;
-public:
- MyMultiEdit_Impl( Window* pParent, SvInplaceEdit2* pOwner );
- virtual void KeyInput( const KeyEvent& rKEvt );
- virtual void LoseFocus();
-};
-
-MyEdit_Impl::MyEdit_Impl( Window* pParent, SvInplaceEdit2* _pOwner ) :
-
- Edit( pParent, WB_LEFT ),
-
- pOwner( _pOwner )
-
-{
-}
-
-void MyEdit_Impl::KeyInput( const KeyEvent& rKEvt )
-{
- if( !pOwner->KeyInput( rKEvt ))
- Edit::KeyInput( rKEvt );
-}
-
-void MyEdit_Impl::LoseFocus()
-{
- pOwner->LoseFocus();
-}
-
-MyMultiEdit_Impl::MyMultiEdit_Impl( Window* pParent, SvInplaceEdit2* _pOwner )
- : MultiLineEdit( pParent,
- WB_CENTER
- ), pOwner(_pOwner)
-{
-}
-
-void MyMultiEdit_Impl::KeyInput( const KeyEvent& rKEvt )
-{
- if( !pOwner->KeyInput( rKEvt ))
- MultiLineEdit::KeyInput( rKEvt );
-}
-
-void MyMultiEdit_Impl::LoseFocus()
-{
- pOwner->LoseFocus();
-}
-
-
-SvInplaceEdit2::SvInplaceEdit2
-(
- Window* pParent, const Point& rPos,
- const Size& rSize,
- const String& rData,
- const Link& rNotifyEditEnd,
- const Selection& rSelection,
- sal_Bool bMulti
-) :
-
- aCallBackHdl ( rNotifyEditEnd ),
- bCanceled ( sal_False ),
- bAlreadyInCallBack ( sal_False )
-
-{
- DBG_CTOR(SvInplaceEdit2,0);
-
- if( bMulti )
- pEdit = new MyMultiEdit_Impl( pParent, this );
- else
- pEdit = new MyEdit_Impl( pParent, this );
-
- Font aFont( pParent->GetFont() );
- aFont.SetTransparent( sal_False );
- Color aColor( pParent->GetBackground().GetColor() );
- aFont.SetFillColor(aColor );
- pEdit->SetFont( aFont );
- pEdit->SetBackground( pParent->GetBackground() );
- pEdit->SetPosPixel( rPos );
- pEdit->SetSizePixel( rSize );
- pEdit->SetText( rData );
- pEdit->SetSelection( rSelection );
- pEdit->SaveValue();
-
- aAccReturn.InsertItem( SVLBOX_ACC_RETURN, KeyCode(KEY_RETURN) );
- aAccEscape.InsertItem( SVLBOX_ACC_ESCAPE, KeyCode(KEY_ESCAPE) );
-
- aAccReturn.SetActivateHdl( LINK( this, SvInplaceEdit2, ReturnHdl_Impl) );
- aAccEscape.SetActivateHdl( LINK( this, SvInplaceEdit2, EscapeHdl_Impl) );
- GetpApp()->InsertAccel( &aAccReturn );
- GetpApp()->InsertAccel( &aAccEscape );
-
- pEdit->Show();
- pEdit->GrabFocus();
-}
-
-SvInplaceEdit2::~SvInplaceEdit2()
-{
- DBG_DTOR(SvInplaceEdit2,0);
- if( !bAlreadyInCallBack )
- {
- GetpApp()->RemoveAccel( &aAccReturn );
- GetpApp()->RemoveAccel( &aAccEscape );
- }
- delete pEdit;
-}
-
-String SvInplaceEdit2::GetSavedValue() const
-{
- return pEdit->GetSavedValue();
-}
-
-void SvInplaceEdit2::Hide()
-{
- pEdit->Hide();
-}
-
-
-IMPL_LINK_NOARG_INLINE_START(SvInplaceEdit2, ReturnHdl_Impl)
-{
- DBG_CHKTHIS(SvInplaceEdit2,0);
- bCanceled = sal_False;
- CallCallBackHdl_Impl();
- return 1;
-}
-IMPL_LINK_NOARG_INLINE_END(SvInplaceEdit2, ReturnHdl_Impl)
-
-IMPL_LINK_NOARG_INLINE_START(SvInplaceEdit2, EscapeHdl_Impl)
-{
- DBG_CHKTHIS(SvInplaceEdit2,0);
- bCanceled = sal_True;
- CallCallBackHdl_Impl();
- return 1;
-}
-IMPL_LINK_NOARG_INLINE_END(SvInplaceEdit2, EscapeHdl_Impl)
-
-
-sal_Bool SvInplaceEdit2::KeyInput( const KeyEvent& rKEvt )
-{
- DBG_CHKTHIS(SvInplaceEdit2,0);
- KeyCode aCode = rKEvt.GetKeyCode();
- sal_uInt16 nCode = aCode.GetCode();
-
- switch ( nCode )
- {
- case KEY_ESCAPE:
- bCanceled = sal_True;
- CallCallBackHdl_Impl();
- return sal_True;
-
- case KEY_RETURN:
- bCanceled = sal_False;
- CallCallBackHdl_Impl();
- return sal_True;
- }
- return sal_False;
-}
-
-void SvInplaceEdit2::StopEditing( sal_Bool bCancel )
-{
- DBG_CHKTHIS(SvInplaceEdit2,0);
- if ( !bAlreadyInCallBack )
- {
- bCanceled = bCancel;
- CallCallBackHdl_Impl();
- }
-}
-
-void SvInplaceEdit2::LoseFocus()
-{
- DBG_CHKTHIS(SvInplaceEdit2,0);
- if ( !bAlreadyInCallBack
- && ((!Application::GetFocusWindow()) || !pEdit->IsChild( Application::GetFocusWindow()) )
- )
- {
- bCanceled = sal_False;
- aTimer.SetTimeout(10);
- aTimer.SetTimeoutHdl(LINK(this,SvInplaceEdit2,Timeout_Impl));
- aTimer.Start();
- }
-}
-
-IMPL_LINK_NOARG_INLINE_START(SvInplaceEdit2, Timeout_Impl)
-{
- DBG_CHKTHIS(SvInplaceEdit2,0);
- CallCallBackHdl_Impl();
- return 0;
-}
-IMPL_LINK_NOARG_INLINE_END(SvInplaceEdit2, Timeout_Impl)
-
-void SvInplaceEdit2::CallCallBackHdl_Impl()
-{
- DBG_CHKTHIS(SvInplaceEdit2,0);
- aTimer.Stop();
- if ( !bAlreadyInCallBack )
- {
- bAlreadyInCallBack = sal_True;
- GetpApp()->RemoveAccel( &aAccReturn );
- GetpApp()->RemoveAccel( &aAccEscape );
- pEdit->Hide();
- aCallBackHdl.Call( this );
- }
-}
-
-String SvInplaceEdit2::GetText() const
-{
- return pEdit->GetText();
-}
-
-// ***************************************************************
-// class SvLBoxTab
-// ***************************************************************
-
-DBG_NAME(SvLBoxTab);
-
-SvLBoxTab::SvLBoxTab()
-{
- DBG_CTOR(SvLBoxTab,0);
- nPos = 0;
- pUserData = 0;
- nFlags = 0;
-}
-
-SvLBoxTab::SvLBoxTab( long nPosition, sal_uInt16 nTabFlags )
-{
- DBG_CTOR(SvLBoxTab,0);
- nPos = nPosition;
- pUserData = 0;
- nFlags = nTabFlags;
-}
-
-SvLBoxTab::SvLBoxTab( const SvLBoxTab& rTab )
-{
- DBG_CTOR(SvLBoxTab,0);
- nPos = rTab.nPos;
- pUserData = rTab.pUserData;
- nFlags = rTab.nFlags;
-}
-
-SvLBoxTab::~SvLBoxTab()
-{
- DBG_DTOR(SvLBoxTab,0);
-}
-
-
-long SvLBoxTab::CalcOffset( long nItemWidth, long nTabWidth )
-{
- DBG_CHKTHIS(SvLBoxTab,0);
- long nOffset = 0;
- if ( nFlags & SV_LBOXTAB_ADJUST_RIGHT )
- {
- nOffset = nTabWidth - nItemWidth;
- if( nOffset < 0 )
- nOffset = 0;
- }
- else if ( nFlags & SV_LBOXTAB_ADJUST_CENTER )
- {
- if( nFlags & SV_LBOXTAB_FORCE )
- {
- // correct implementation of centering
- nOffset = ( nTabWidth - nItemWidth ) / 2;
- if( nOffset < 0 )
- nOffset = 0;
- }
- else
- {
- // historically grown, wrong calculation of tabs which is needed by
- // Abo-Tabbox, Tools/Options/Customize etc.
- nItemWidth++;
- nOffset = -( nItemWidth / 2 );
- }
- }
- return nOffset;
-}
-
-// ***************************************************************
-// class SvLBoxItem
-// ***************************************************************
-
-DBG_NAME(SvLBoxItem);
-
-SvLBoxItem::SvLBoxItem( SvLBoxEntry*, sal_uInt16 )
-{
- DBG_CTOR(SvLBoxItem,0);
-}
-
-SvLBoxItem::SvLBoxItem()
-{
- DBG_CTOR(SvLBoxItem,0);
-}
-
-SvLBoxItem::~SvLBoxItem()
-{
- DBG_DTOR(SvLBoxItem,0);
-}
-
-const Size& SvLBoxItem::GetSize( SvLBox* pView,SvLBoxEntry* pEntry )
-{
- DBG_CHKTHIS(SvLBoxItem,0);
- SvViewDataItem* pViewData = pView->GetViewDataItem( pEntry, this );
- return pViewData->aSize;
-}
-
-DBG_NAME(SvViewDataItem);
-
-SvViewDataItem::SvViewDataItem()
-{
- DBG_CTOR(SvViewDataItem,0);
-}
-
-SvViewDataItem::~SvViewDataItem()
-{
- DBG_DTOR(SvViewDataItem,0);
-}
-
-
-
-// ***************************************************************
-// class SvLBoxEntry
-// ***************************************************************
-
-DBG_NAME(SvLBoxEntry);
-
-SvLBoxEntry::SvLBoxEntry() : aItems()
-{
- DBG_CTOR(SvLBoxEntry,0);
- nEntryFlags = 0;
- pUserData = 0;
-}
-
-SvLBoxEntry::~SvLBoxEntry()
-{
- DBG_DTOR(SvLBoxEntry,0);
- DeleteItems_Impl();
-}
-
-void SvLBoxEntry::DeleteItems_Impl()
-{
- DBG_CHKTHIS(SvLBoxEntry,0);
- sal_uInt16 nCount = aItems.size();
- while( nCount )
- {
- nCount--;
- SvLBoxItem* pItem = aItems[ nCount ];
- delete pItem;
- }
- aItems.clear();
-}
-
-
-void SvLBoxEntry::AddItem( SvLBoxItem* pItem )
-{
- DBG_CHKTHIS(SvLBoxEntry,0);
- aItems.push_back( pItem );
-}
-
-void SvLBoxEntry::Clone( SvListEntry* pSource )
-{
- DBG_CHKTHIS(SvLBoxEntry,0);
- SvListEntry::Clone( pSource );
- SvLBoxItem* pNewItem;
- DeleteItems_Impl();
- sal_uInt16 nCount = ((SvLBoxEntry*)pSource)->ItemCount();
- sal_uInt16 nCurPos = 0;
- while( nCurPos < nCount )
- {
- SvLBoxItem* pItem = ((SvLBoxEntry*)pSource)->GetItem( nCurPos );
- pNewItem = pItem->Create();
- pNewItem->Clone( pItem );
- AddItem( pNewItem );
- nCurPos++;
- }
- pUserData = ((SvLBoxEntry*)pSource)->GetUserData();
- nEntryFlags = ((SvLBoxEntry*)pSource)->nEntryFlags;
-}
-
-void SvLBoxEntry::EnableChildrenOnDemand( sal_Bool bEnable )
-{
- DBG_CHKTHIS(SvLBoxEntry,0);
- if ( bEnable )
- nEntryFlags |= SV_ENTRYFLAG_CHILDREN_ON_DEMAND;
- else
- nEntryFlags &= (~SV_ENTRYFLAG_CHILDREN_ON_DEMAND);
-}
-
-void SvLBoxEntry::ReplaceItem( SvLBoxItem* pNewItem, sal_uInt16 nPos )
-{
- DBG_CHKTHIS(SvLBoxEntry,0);
- DBG_ASSERT(pNewItem,"ReplaceItem:No Item");
- SvLBoxItem* pOld = GetItem( nPos );
- if ( pOld )
- {
- aItems[ nPos ] = pNewItem;
- delete pOld;
- }
-}
-
-SvLBoxItem* SvLBoxEntry::GetFirstItem( sal_uInt16 nId )
-{
- sal_uInt16 nCount = aItems.size();
- sal_uInt16 nCur = 0;
- SvLBoxItem* pItem;
- while( nCur < nCount )
- {
- pItem = GetItem( nCur );
- if( pItem->IsA() == nId )
- return pItem;
- nCur++;
- }
- return 0;
-}
-
-SvLBoxEntry* SvLBoxTreeList::First() const
-{
- return (SvLBoxEntry*)SvTreeList::First();
-}
-
-SvLBoxEntry* SvLBoxTreeList::Next( SvListEntry* pEntry, sal_uInt16* pDepth ) const
-{
- return (SvLBoxEntry*)SvTreeList::Next(pEntry,pDepth);
-}
-
-SvLBoxEntry* SvLBoxTreeList::Prev( SvListEntry* pEntry, sal_uInt16* pDepth ) const
-{
- return (SvLBoxEntry*)SvTreeList::Prev(pEntry,pDepth);
-}
-
-SvLBoxEntry* SvLBoxTreeList::Last() const
-{
- return (SvLBoxEntry*)SvTreeList::Last();
-}
-
-SvLBoxEntry* SvLBoxTreeList::Clone( SvListEntry* pEntry, sal_uLong& nCloneCount ) const
-{
- return (SvLBoxEntry*)SvTreeList::Clone(pEntry,nCloneCount);
-}
-
-SvLBoxEntry* SvLBoxTreeList::GetEntry( SvListEntry* pParent, sal_uLong nPos ) const
-{
- return (SvLBoxEntry*)SvTreeList::GetEntry(pParent,nPos);
-}
-
-SvLBoxEntry* SvLBoxTreeList::GetEntry( sal_uLong nRootPos ) const
-{
- return (SvLBoxEntry*)SvTreeList::GetEntry(nRootPos);
-}
-
-SvLBoxEntry* SvLBoxTreeList::GetParent( SvListEntry* pEntry ) const
-{
- return (SvLBoxEntry*)SvTreeList::GetParent(pEntry);
-}
-
-SvLBoxEntry* SvLBoxTreeList::FirstChild( SvLBoxEntry* pParent ) const
-{
- return (SvLBoxEntry*)SvTreeList::FirstChild(pParent);
-}
-
-SvLBoxEntry* SvLBoxTreeList::NextSibling( SvLBoxEntry* pEntry ) const
-{
- return (SvLBoxEntry*)SvTreeList::NextSibling(pEntry);
-}
-
-SvLBoxEntry* SvLBoxTreeList::PrevSibling( SvLBoxEntry* pEntry ) const
-{
- return (SvLBoxEntry*)SvTreeList::PrevSibling(pEntry);
-}
-
-SvLBoxEntry* SvLBoxTreeList::LastSibling( SvLBoxEntry* pEntry ) const
-{
- return (SvLBoxEntry*)SvTreeList::LastSibling(pEntry);
-}
-
-SvLBoxEntry* SvLBoxTreeList::GetEntryAtAbsPos( sal_uLong nAbsPos ) const
-{
- return (SvLBoxEntry*)SvTreeList::GetEntryAtAbsPos( nAbsPos);
-}
-
-// ***************************************************************
-// class SvLBoxViewData
-// ***************************************************************
-
-DBG_NAME(SvViewDataEntry);
-
-SvViewDataEntry::SvViewDataEntry()
- : SvViewData()
-{
- DBG_CTOR(SvViewDataEntry,0);
- pItemData = 0;
-}
-
-SvViewDataEntry::~SvViewDataEntry()
-{
- DBG_DTOR(SvViewDataEntry,0);
- delete [] pItemData;
-}
-
-// ***************************************************************
-// struct SvLBox_Impl
-// ***************************************************************
-SvLBox_Impl::SvLBox_Impl( SvLBox& _rBox )
- :m_bIsEmptyTextAllowed( true )
- ,m_bEntryMnemonicsEnabled( false )
- ,m_bDoingQuickSelection( false )
- ,m_pLink( NULL )
- ,m_aMnemonicEngine( _rBox )
- ,m_aQuickSelectionEngine( _rBox )
-{
-}
-
-// ***************************************************************
-// class SvLBox
-// ***************************************************************
-
-DBG_NAME(SvLBox);
-
-SvLBox::SvLBox( Window* pParent, WinBits nWinStyle ) :
- Control( pParent, nWinStyle | WB_CLIPCHILDREN ),
- DropTargetHelper( this ), DragSourceHelper( this ), eSelMode( NO_SELECTION )
-{
- DBG_CTOR(SvLBox,0);
- nDragOptions = DND_ACTION_COPYMOVE | DND_ACTION_LINK;
- nImpFlags = 0;
- pTargetEntry = 0;
- nDragDropMode = 0;
- pLBoxImpl = new SvLBox_Impl( *this );
- SvLBoxTreeList* pTempModel = new SvLBoxTreeList;
- pTempModel->SetRefCount( 0 );
- SetModel( pTempModel );
- pModel->SetCloneLink( LINK(this, SvLBox, CloneHdl_Impl ));
- pModel->InsertView( this );
- pHdlEntry = 0;
- pEdCtrl = 0;
- SetSelectionMode( SINGLE_SELECTION ); // check if TreeListBox is called
- SetDragDropMode( SV_DRAGDROP_NONE );
- SetType(WINDOW_TREELISTBOX);
-}
-
-SvLBox::SvLBox( Window* pParent, const ResId& rResId ) :
- Control( pParent, rResId ),
- DropTargetHelper( this ), DragSourceHelper( this ), eSelMode( NO_SELECTION )
-{
- DBG_CTOR(SvLBox,0);
- pTargetEntry = 0;
- nImpFlags = 0;
- pLBoxImpl = new SvLBox_Impl( *this );
- nDragOptions = DND_ACTION_COPYMOVE | DND_ACTION_LINK;
- nDragDropMode = 0;
- SvLBoxTreeList* pTempModel = new SvLBoxTreeList;
- pTempModel->SetRefCount( 0 );
- SetModel( pTempModel );
- pModel->InsertView( this );
- pHdlEntry = 0;
- pEdCtrl = 0;
- pModel->SetCloneLink( LINK(this, SvLBox, CloneHdl_Impl ));
- SetType(WINDOW_TREELISTBOX);
-}
-
-SvLBox::~SvLBox()
-{
- DBG_DTOR(SvLBox,0);
- delete pEdCtrl;
- pEdCtrl = 0;
- pModel->RemoveView( this );
- if ( pModel->GetRefCount() == 0 )
- {
- pModel->Clear();
- delete pModel;
- pModel = NULL;
- }
-
- SvLBox::RemoveBoxFromDDList_Impl( *this );
-
- if( this == pDDSource )
- pDDSource = 0;
- if( this == pDDTarget )
- pDDTarget = 0;
- delete pLBoxImpl;
-}
-
-void SvLBox::SetModel( SvLBoxTreeList* pNewModel )
-{
- DBG_CHKTHIS(SvLBox,0);
- // does the CleanUp
- SvListView::SetModel( pNewModel );
- pModel->SetCloneLink( LINK(this, SvLBox, CloneHdl_Impl ));
- SvLBoxEntry* pEntry = First();
- while( pEntry )
- {
- ModelHasInserted( pEntry );
- pEntry = Next( pEntry );
- }
-}
-
-void SvLBox::DisconnectFromModel()
-{
- DBG_CHKTHIS(SvLBox,0);
- SvLBoxTreeList* pNewModel = new SvLBoxTreeList;
- pNewModel->SetRefCount( 0 ); // else this will never be deleted
- SvListView::SetModel( pNewModel );
-}
-
-void SvLBox::Clear()
-{
- DBG_CHKTHIS(SvLBox,0);
- pModel->Clear(); // Model calls SvLBox::ModelHasCleared()
-}
-
-void SvLBox::EnableEntryMnemonics( bool _bEnable )
-{
- if ( _bEnable == IsEntryMnemonicsEnabled() )
- return;
-
- pLBoxImpl->m_bEntryMnemonicsEnabled = _bEnable;
- Invalidate();
-}
-
-bool SvLBox::IsEntryMnemonicsEnabled() const
-{
- return pLBoxImpl->m_bEntryMnemonicsEnabled;
-}
-
-sal_uInt16 SvLBox::IsA()
-{
- DBG_CHKTHIS(SvLBox,0);
- return SVLISTBOX_ID_LBOX;
-}
-
-IMPL_LINK_INLINE_START( SvLBox, CloneHdl_Impl, SvListEntry*, pEntry )
-{
- DBG_CHKTHIS(SvLBox,0);
- return (long)(CloneEntry((SvLBoxEntry*)pEntry));
-}
-IMPL_LINK_INLINE_END( SvLBox, CloneHdl_Impl, SvListEntry*, pEntry )
-
-sal_uLong SvLBox::Insert( SvLBoxEntry* pEntry, SvLBoxEntry* pParent, sal_uLong nPos )
-{
- DBG_CHKTHIS(SvLBox,0);
- sal_uLong nInsPos = pModel->Insert( pEntry, pParent, nPos );
- return nInsPos;
-}
-
-sal_uLong SvLBox::Insert( SvLBoxEntry* pEntry,sal_uLong nRootPos )
-{
- DBG_CHKTHIS(SvLBox,0);
- sal_uLong nInsPos = pModel->Insert( pEntry, nRootPos );
- return nInsPos;
-}
-
-long SvLBox::ExpandingHdl()
-{
- DBG_CHKTHIS(SvLBox,0);
- return aExpandingHdl.IsSet() ? aExpandingHdl.Call( this ) : 1;
-}
-
-void SvLBox::ExpandedHdl()
-{
- DBG_CHKTHIS(SvLBox,0);
- aExpandedHdl.Call( this );
-}
-
-void SvLBox::SelectHdl()
-{
- DBG_CHKTHIS(SvLBox,0);
- aSelectHdl.Call( this );
-}
-
-void SvLBox::DeselectHdl()
-{
- DBG_CHKTHIS(SvLBox,0);
- aDeselectHdl.Call( this );
-}
-
-sal_Bool SvLBox::DoubleClickHdl()
-{
- DBG_CHKTHIS(SvLBox,0);
- aDoubleClickHdl.Call( this );
- return sal_True;
-}
-
-
-sal_Bool SvLBox::CheckDragAndDropMode( SvLBox* pSource, sal_Int8 nAction )
-{
- DBG_CHKTHIS(SvLBox,0);
- if ( pSource == this )
- {
- if ( !(nDragDropMode & (SV_DRAGDROP_CTRL_MOVE | SV_DRAGDROP_CTRL_COPY) ) )
- return sal_False; // D&D locked within list
- if( DND_ACTION_MOVE == nAction )
- {
- if ( !(nDragDropMode & SV_DRAGDROP_CTRL_MOVE) )
- return sal_False; // no local move
- }
- else
- {
- if ( !(nDragDropMode & SV_DRAGDROP_CTRL_COPY))
- return sal_False; // no local copy
- }
- }
- else
- {
- if ( !(nDragDropMode & SV_DRAGDROP_APP_DROP ) )
- return sal_False; // no drop
- if ( DND_ACTION_MOVE == nAction )
- {
- if ( !(nDragDropMode & SV_DRAGDROP_APP_MOVE) )
- return sal_False; // no global move
- }
- else
- {
- if ( !(nDragDropMode & SV_DRAGDROP_APP_COPY))
- return sal_False; // no global copy
- }
- }
- return sal_True;
-}
-
-
-
-
-void SvLBox::NotifyRemoving( SvLBoxEntry* )
-{
- DBG_CHKTHIS(SvLBox,0);
-}
-
-/*
- NotifyMoving/Copying
- ====================
-
- default behavior:
-
- 1. target doesn't have children
- - entry becomes sibling of target. entry comes after target
- (->Window: below the target)
- 2. target is an expanded parent
- - entry inserted at the beginning of the target childlist
- 3. target is a collapsed parent
- - entry is inserted at the end of the target childlist
-*/
-#ifdef DBG_UTIL
-sal_Bool SvLBox::NotifyMoving(
- SvLBoxEntry* pTarget, // D&D dropping position in this->GetModel()
- SvLBoxEntry* pEntry, // entry that we want to move, from
- // GetSourceListBox()->GetModel()
- SvLBoxEntry*& rpNewParent, // new target parent
- sal_uLong& rNewChildPos) // position in childlist of target parent
-#else
-sal_Bool SvLBox::NotifyMoving(
- SvLBoxEntry* pTarget, // D&D dropping position in this->GetModel()
- SvLBoxEntry*, // entry that we want to move, from
- // GetSourceListBox()->GetModel()
- SvLBoxEntry*& rpNewParent, // new target parent
- sal_uLong& rNewChildPos) // position in childlist of target parent
-#endif
-{
- DBG_CHKTHIS(SvLBox,0);
- DBG_ASSERT(pEntry,"NotifyMoving:SoureEntry?");
- if( !pTarget )
- {
- rpNewParent = 0;
- rNewChildPos = 0;
- return sal_True;
- }
- if ( !pTarget->HasChildren() && !pTarget->HasChildrenOnDemand() )
- {
- // case 1
- rpNewParent = GetParent( pTarget );
- rNewChildPos = pModel->GetRelPos( pTarget ) + 1;
- rNewChildPos += nCurEntrySelPos;
- nCurEntrySelPos++;
- }
- else
- {
- // cases 2 & 3
- rpNewParent = pTarget;
- if( IsExpanded(pTarget))
- rNewChildPos = 0;
- else
- rNewChildPos = LIST_APPEND;
- }
- return sal_True;
-}
-
-sal_Bool SvLBox::NotifyCopying(
- SvLBoxEntry* pTarget, // D&D dropping position in this->GetModel()
- SvLBoxEntry* pEntry, // entry that we want to move, from
- // GetSourceListBox()->GetModel()
- SvLBoxEntry*& rpNewParent, // new target parent
- sal_uLong& rNewChildPos) // position in childlist of target parent
-{
- DBG_CHKTHIS(SvLBox,0);
- return NotifyMoving(pTarget,pEntry,rpNewParent,rNewChildPos);
-}
-
-SvLBoxEntry* SvLBox::CloneEntry( SvLBoxEntry* pSource )
-{
- DBG_CHKTHIS(SvLBox,0);
- SvLBoxEntry* pEntry = (SvLBoxEntry*)CreateEntry(); // new SvLBoxEntry;
- pEntry->Clone( (SvListEntry*)pSource );
- return pEntry;
-}
-
-
-// return: all entries copied
-sal_Bool SvLBox::CopySelection( SvLBox* pSource, SvLBoxEntry* pTarget )
-{
- DBG_CHKTHIS(SvLBox,0);
- nCurEntrySelPos = 0; // selection counter for NotifyMoving/Copying
- sal_Bool bSuccess = sal_True;
- SvTreeEntryList aList;
- sal_Bool bClone = (sal_Bool)( (sal_uLong)(pSource->GetModel()) != (sal_uLong)GetModel() );
- Link aCloneLink( pModel->GetCloneLink() );
- pModel->SetCloneLink( LINK(this, SvLBox, CloneHdl_Impl ));
-
- // cache selection to simplify iterating over the selection when doing a D&D
- // exchange within the same listbox
- SvLBoxEntry* pSourceEntry = pSource->FirstSelected();
- while ( pSourceEntry )
- {
- // children are copied automatically
- pSource->SelectChildren( pSourceEntry, sal_False );
- aList.push_back( pSourceEntry );
- pSourceEntry = pSource->NextSelected( pSourceEntry );
- }
-
- SvTreeEntryList::iterator it = aList.begin(), itEnd = aList.end();
- for (; it != itEnd; ++it)
- {
- pSourceEntry = static_cast<SvLBoxEntry*>(*it);
- SvLBoxEntry* pNewParent = 0;
- sal_uLong nInsertionPos = ULONG_MAX;
- sal_Bool bOk=NotifyCopying(pTarget,pSourceEntry,pNewParent,nInsertionPos);
- if ( bOk )
- {
- if ( bClone )
- {
- sal_uLong nCloneCount = 0;
- pSourceEntry = (SvLBoxEntry*)
- pModel->Clone( (SvListEntry*)pSourceEntry, nCloneCount );
- pModel->InsertTree( (SvListEntry*)pSourceEntry,
- (SvListEntry*)pNewParent, nInsertionPos );
- }
- else
- {
- sal_uLong nListPos = pModel->Copy( (SvListEntry*)pSourceEntry,
- (SvListEntry*)pNewParent, nInsertionPos );
- pSourceEntry = GetEntry( pNewParent, nListPos );
- }
- }
- else
- bSuccess = sal_False;
-
- if( bOk == (sal_Bool)2 ) // HACK: make visible moved entry?
- MakeVisible( pSourceEntry );
- }
- pModel->SetCloneLink( aCloneLink );
- return bSuccess;
-}
-
-// return: all entries were moved
-sal_Bool SvLBox::MoveSelection( SvLBox* pSource, SvLBoxEntry* pTarget )
-{
- return MoveSelectionCopyFallbackPossible( pSource, pTarget, sal_False );
-}
-
-sal_Bool SvLBox::MoveSelectionCopyFallbackPossible( SvLBox* pSource, SvLBoxEntry* pTarget, sal_Bool bAllowCopyFallback )
-{
- DBG_CHKTHIS(SvLBox,0);
- nCurEntrySelPos = 0; // selection counter for NotifyMoving/Copying
- sal_Bool bSuccess = sal_True;
- SvTreeEntryList aList;
- sal_Bool bClone = (sal_Bool)( (sal_uLong)(pSource->GetModel()) != (sal_uLong)GetModel() );
- Link aCloneLink( pModel->GetCloneLink() );
- if ( bClone )
- pModel->SetCloneLink( LINK(this, SvLBox, CloneHdl_Impl ));
-
- SvLBoxEntry* pSourceEntry = pSource->FirstSelected();
- while ( pSourceEntry )
- {
- // children are automatically moved
- pSource->SelectChildren( pSourceEntry, sal_False );
- aList.push_back( pSourceEntry );
- pSourceEntry = pSource->NextSelected( pSourceEntry );
- }
-
- SvTreeEntryList::iterator it = aList.begin(), itEnd = aList.end();
- for (; it != itEnd; ++it)
- {
- pSourceEntry = static_cast<SvLBoxEntry*>(*it);
-
- SvLBoxEntry* pNewParent = 0;
- sal_uLong nInsertionPos = ULONG_MAX;
- sal_Bool bOk = NotifyMoving(pTarget,pSourceEntry,pNewParent,nInsertionPos);
- sal_Bool bCopyOk = bOk;
- if ( !bOk && bAllowCopyFallback )
- {
- nInsertionPos = LIST_APPEND;
- bCopyOk = NotifyCopying(pTarget,pSourceEntry,pNewParent,nInsertionPos);
- }
-
- if ( bOk || bCopyOk )
- {
- if ( bClone )
- {
- sal_uLong nCloneCount = 0;
- pSourceEntry = (SvLBoxEntry*)
- pModel->Clone( (SvListEntry*)pSourceEntry, nCloneCount );
- pModel->InsertTree( (SvListEntry*)pSourceEntry,
- (SvListEntry*)pNewParent, nInsertionPos );
- }
- else
- {
- if ( bOk )
- pModel->Move( (SvListEntry*)pSourceEntry,
- (SvListEntry*)pNewParent, nInsertionPos );
- else
- pModel->Copy( (SvListEntry*)pSourceEntry,
- (SvListEntry*)pNewParent, nInsertionPos );
- }
- }
- else
- bSuccess = sal_False;
-
- if( bOk == (sal_Bool)2 ) // HACK: make moved entry visible?
- MakeVisible( pSourceEntry );
- }
- pModel->SetCloneLink( aCloneLink );
- return bSuccess;
-}
-
-void SvLBox::RemoveSelection()
-{
- DBG_CHKTHIS(SvLBox,0);
- SvTreeEntryList aList;
- // cache selection, as the implementation deselects everything on the first
- // remove
- SvLBoxEntry* pEntry = FirstSelected();
- while ( pEntry )
- {
- aList.push_back( pEntry );
- if ( pEntry->HasChildren() )
- // remove deletes all children automatically
- SelectChildren( pEntry, sal_False );
- pEntry = NextSelected( pEntry );
- }
-
- SvTreeEntryList::iterator it = aList.begin(), itEnd = aList.end();
- for (; it != itEnd; ++it)
- {
- pEntry = static_cast<SvLBoxEntry*>(*it);
- pModel->Remove(pEntry);
- }
-}
-
-SvLBox* SvLBox::GetSourceView() const
-{
- return pDDSource;
-}
-
-void SvLBox::RequestingChildren( SvLBoxEntry* )
-{
- DBG_CHKTHIS(SvLBox,0);
- OSL_FAIL("Child-Request-Hdl not implemented!");
-}
-
-void SvLBox::RecalcViewData()
-{
- DBG_CHKTHIS(SvLBox,0);
- SvLBoxEntry* pEntry = First();
- while( pEntry )
- {
- sal_uInt16 nCount = pEntry->ItemCount();
- sal_uInt16 nCurPos = 0;
- while ( nCurPos < nCount )
- {
- SvLBoxItem* pItem = pEntry->GetItem( nCurPos );
- pItem->InitViewData( this, pEntry );
- nCurPos++;
- }
- ViewDataInitialized( pEntry );
- pEntry = Next( pEntry );
- }
-}
-
-void SvLBox::ViewDataInitialized( SvLBoxEntry* )
-{
- DBG_CHKTHIS(SvLBox,0);
-}
-
-void SvLBox::StateChanged( StateChangedType eType )
-{
- if( eType == STATE_CHANGE_ENABLE )
- Invalidate( INVALIDATE_CHILDREN );
- Control::StateChanged( eType );
-}
-
-void SvLBox::ImplShowTargetEmphasis( SvLBoxEntry* pEntry, sal_Bool bShow)
-{
- DBG_CHKTHIS(SvLBox,0);
- if ( bShow && (nImpFlags & SVLBOX_TARGEMPH_VIS) )
- return;
- if ( !bShow && !(nImpFlags & SVLBOX_TARGEMPH_VIS) )
- return;
- ShowTargetEmphasis( pEntry, bShow );
- if( bShow )
- nImpFlags |= SVLBOX_TARGEMPH_VIS;
- else
- nImpFlags &= ~SVLBOX_TARGEMPH_VIS;
-}
-
-void SvLBox::ShowTargetEmphasis( SvLBoxEntry*, sal_Bool /* bShow */ )
-{
- DBG_CHKTHIS(SvLBox,0);
-}
-
-
-sal_Bool SvLBox::Expand( SvLBoxEntry* )
-{
- DBG_CHKTHIS(SvLBox,0);
- return sal_True;
-}
-
-sal_Bool SvLBox::Collapse( SvLBoxEntry* )
-{
- DBG_CHKTHIS(SvLBox,0);
- return sal_True;
-}
-
-sal_Bool SvLBox::Select( SvLBoxEntry*, sal_Bool )
-{
- DBG_CHKTHIS(SvLBox,0);
- return sal_False;
-}
-
-sal_uLong SvLBox::SelectChildren( SvLBoxEntry* , sal_Bool )
-{
- DBG_CHKTHIS(SvLBox,0);
- return 0;
-}
-
-void SvLBox::OnCurrentEntryChanged()
-{
- if ( !pLBoxImpl->m_bDoingQuickSelection )
- pLBoxImpl->m_aQuickSelectionEngine.Reset();
-}
-
-void SvLBox::SelectAll( sal_Bool /* bSelect */ , sal_Bool /* bPaint */ )
-{
- DBG_CHKTHIS(SvLBox,0);
-}
-
-SvLBoxEntry* SvLBox::GetEntryFromPath( const ::std::deque< sal_Int32 >& _rPath ) const
-{
- DBG_CHKTHIS(SvLBox,0);
-
- SvLBoxEntry* pEntry = NULL;
- SvLBoxEntry* pParent = NULL;
- for( ::std::deque< sal_Int32 >::const_iterator pItem = _rPath.begin(); pItem != _rPath.end(); ++pItem )
- {
- pEntry = GetEntry( pParent, *pItem );
- if ( !pEntry )
- break;
- pParent = pEntry;
- }
-
- return pEntry;
-}
-
-void SvLBox::FillEntryPath( SvLBoxEntry* pEntry, ::std::deque< sal_Int32 >& _rPath ) const
-{
- DBG_CHKTHIS(SvLBox,0);
-
- if ( pEntry )
- {
- SvLBoxEntry* pParentEntry = GetParent( pEntry );
- while ( sal_True )
- {
- sal_uLong i, nCount = GetLevelChildCount( pParentEntry );
- for ( i = 0; i < nCount; ++i )
- {
- SvLBoxEntry* pTemp = GetEntry( pParentEntry, i );
- DBG_ASSERT( pEntry, "invalid entry" );
- if ( pEntry == pTemp )
- {
- _rPath.push_front( (sal_Int32)i );
- break;
- }
- }
-
- if ( pParentEntry )
- {
- pEntry = pParentEntry;
- pParentEntry = GetParent( pParentEntry );
- }
- else
- break;
- }
- }
-}
-
-String SvLBox::GetEntryText( SvLBoxEntry* ) const
-{
- DBG_CHKTHIS(SvLBox,0);
-
- return String();
-}
-
-sal_uLong SvLBox::GetLevelChildCount( SvLBoxEntry* _pParent ) const
-{
- DBG_CHKTHIS(SvLBox,0);
-
- sal_uLong nCount = 0;
- SvLBoxEntry* pEntry = FirstChild( _pParent );
- while ( pEntry )
- {
- ++nCount;
- pEntry = NextSibling( pEntry );
- }
-
- return nCount;
-}
-
-void SvLBox::SetSelectionMode( SelectionMode eSelectMode )
-{
- DBG_CHKTHIS(SvLBox,0);
- eSelMode = eSelectMode;
-}
-
-void SvLBox::SetDragDropMode( DragDropMode nDDMode )
-{
- DBG_CHKTHIS(SvLBox,0);
- nDragDropMode = nDDMode;
-}
-
-SvViewData* SvLBox::CreateViewData( SvListEntry* )
-{
- DBG_CHKTHIS(SvLBox,0);
- SvViewDataEntry* pEntryData = new SvViewDataEntry;
- return (SvViewData*)pEntryData;
-}
-
-void SvLBox::InitViewData( SvViewData* pData, SvListEntry* pEntry )
-{
- DBG_CHKTHIS(SvLBox,0);
- SvLBoxEntry* pInhEntry = (SvLBoxEntry*)pEntry;
- SvViewDataEntry* pEntryData = (SvViewDataEntry*)pData;
-
- pEntryData->pItemData = new SvViewDataItem[ pInhEntry->ItemCount() ];
- SvViewDataItem* pItemData = pEntryData->pItemData;
- pEntryData->nItmCnt = pInhEntry->ItemCount(); // number of items to delete
- sal_uInt16 nCount = pInhEntry->ItemCount();
- sal_uInt16 nCurPos = 0;
- while( nCurPos < nCount )
- {
- SvLBoxItem* pItem = pInhEntry->GetItem( nCurPos );
- pItem->InitViewData( this, pInhEntry, pItemData );
- pItemData++;
- nCurPos++;
- }
-}
-
-
-
-void SvLBox::EnableSelectionAsDropTarget( sal_Bool bEnable, sal_Bool bWithChildren )
-{
- DBG_CHKTHIS(SvLBox,0);
- sal_uInt16 nRefDepth;
- SvLBoxEntry* pTemp;
-
- SvLBoxEntry* pSelEntry = FirstSelected();
- while( pSelEntry )
- {
- if ( !bEnable )
- {
- pSelEntry->nEntryFlags |= SV_ENTRYFLAG_DISABLE_DROP;
- if ( bWithChildren )
- {
- nRefDepth = pModel->GetDepth( pSelEntry );
- pTemp = Next( pSelEntry );
- while( pTemp && pModel->GetDepth( pTemp ) > nRefDepth )
- {
- pTemp->nEntryFlags |= SV_ENTRYFLAG_DISABLE_DROP;
- pTemp = Next( pTemp );
- }
- }
- }
- else
- {
- pSelEntry->nEntryFlags &= (~SV_ENTRYFLAG_DISABLE_DROP);
- if ( bWithChildren )
- {
- nRefDepth = pModel->GetDepth( pSelEntry );
- pTemp = Next( pSelEntry );
- while( pTemp && pModel->GetDepth( pTemp ) > nRefDepth )
- {
- pTemp->nEntryFlags &= (~SV_ENTRYFLAG_DISABLE_DROP);
- pTemp = Next( pTemp );
- }
- }
- }
- pSelEntry = NextSelected( pSelEntry );
- }
-}
-
-SvLBoxEntry* SvLBox::GetDropTarget( const Point& )
-{
- DBG_CHKTHIS(SvLBox,0);
- return 0;
-}
-
-// ******************************************************************
-// InplaceEditing
-// ******************************************************************
-
-void SvLBox::EditText( const String& rStr, const Rectangle& rRect,
- const Selection& rSel )
-{
- EditText( rStr, rRect, rSel, sal_False );
-}
-
-void SvLBox::EditText( const String& rStr, const Rectangle& rRect,
- const Selection& rSel, sal_Bool bMulti )
-{
- DBG_CHKTHIS(SvLBox,0);
- if( pEdCtrl )
- delete pEdCtrl;
- nImpFlags |= SVLBOX_IN_EDT;
- nImpFlags &= ~SVLBOX_EDTEND_CALLED;
- HideFocus();
- pEdCtrl = new SvInplaceEdit2(
- this, rRect.TopLeft(), rRect.GetSize(), rStr,
- LINK( this, SvLBox, TextEditEndedHdl_Impl ),
- rSel, bMulti );
-}
-
-IMPL_LINK_NOARG(SvLBox, TextEditEndedHdl_Impl)
-{
- DBG_CHKTHIS(SvLBox,0);
- if ( nImpFlags & SVLBOX_EDTEND_CALLED ) // avoid nesting
- return 0;
- nImpFlags |= SVLBOX_EDTEND_CALLED;
- String aStr;
- if ( !pEdCtrl->EditingCanceled() )
- aStr = pEdCtrl->GetText();
- else
- aStr = pEdCtrl->GetSavedValue();
- if ( IsEmptyTextAllowed() || aStr.Len() > 0 )
- EditedText( aStr );
- // Hide may only be called after the new text was put into the entry, so
- // that we don't call the selection handler in the GetFocus of the listbox
- // with the old entry text.
- pEdCtrl->Hide();
- // delete pEdCtrl;
- // pEdCtrl = 0;
- nImpFlags &= (~SVLBOX_IN_EDT);
- GrabFocus();
- return 0;
-}
-
-void SvLBox::CancelTextEditing()
-{
- DBG_CHKTHIS(SvLBox,0);
- if ( pEdCtrl )
- pEdCtrl->StopEditing( sal_True );
- nImpFlags &= (~SVLBOX_IN_EDT);
-}
-
-void SvLBox::EndEditing( sal_Bool bCancel )
-{
- DBG_CHKTHIS(SvLBox,0);
- if( pEdCtrl )
- pEdCtrl->StopEditing( bCancel );
- nImpFlags &= (~SVLBOX_IN_EDT);
-}
-
-
-bool SvLBox::IsEmptyTextAllowed() const
-{
- DBG_CHKTHIS(SvLBox,0);
- return pLBoxImpl->m_bIsEmptyTextAllowed;
-}
-
-void SvLBox::ForbidEmptyText()
-{
- DBG_CHKTHIS(SvLBox,0);
- pLBoxImpl->m_bIsEmptyTextAllowed = false;
-}
-
-void SvLBox::EditedText( const String& )
-{
- DBG_CHKTHIS(SvLBox,0);
-}
-
-void SvLBox::EditingRequest( SvLBoxEntry*, SvLBoxItem*,const Point& )
-{
- DBG_CHKTHIS(SvLBox,0);
-}
-
-
-SvLBoxEntry* SvLBox::CreateEntry() const
-{
- DBG_CHKTHIS(SvLBox,0);
- return new SvLBoxEntry;
-}
-
-void SvLBox::MakeVisible( SvLBoxEntry* )
-{
- DBG_CHKTHIS(SvLBox,0);
-}
-
-void SvLBox::Command( const CommandEvent& i_rCommandEvent )
-{
- DBG_CHKTHIS(SvLBox,0);
-
- if ( COMMAND_STARTDRAG == i_rCommandEvent.GetCommand() )
- {
- Point aEventPos( i_rCommandEvent.GetMousePosPixel() );
- MouseEvent aMouseEvt( aEventPos, 1, MOUSE_SELECT, MOUSE_LEFT );
- MouseButtonUp( aMouseEvt );
- }
- Control::Command( i_rCommandEvent );
-}
-
-void SvLBox::KeyInput( const KeyEvent& rKEvt )
-{
- bool bHandled = HandleKeyInput( rKEvt );
- if ( !bHandled )
- Control::KeyInput( rKEvt );
-}
-
-const void* SvLBox::FirstSearchEntry( String& _rEntryText ) const
-{
- SvLBoxEntry* pEntry = GetCurEntry();
- if ( pEntry )
- pEntry = const_cast< SvLBoxEntry* >( static_cast< const SvLBoxEntry* >( NextSearchEntry( pEntry, _rEntryText ) ) );
- else
- {
- pEntry = FirstSelected();
- if ( !pEntry )
- pEntry = First();
- }
-
- if ( pEntry )
- _rEntryText = GetEntryText( pEntry );
-
- return pEntry;
-}
-
-const void* SvLBox::NextSearchEntry( const void* _pCurrentSearchEntry, String& _rEntryText ) const
-{
- SvLBoxEntry* pEntry = const_cast< SvLBoxEntry* >( static_cast< const SvLBoxEntry* >( _pCurrentSearchEntry ) );
-
- if ( ( ( GetChildCount( pEntry ) > 0 )
- || ( pEntry->HasChildrenOnDemand() )
- )
- && !IsExpanded( pEntry )
- )
- {
- pEntry = NextSibling( pEntry );
- }
- else
- {
- pEntry = Next( pEntry );
- }
-
- if ( !pEntry )
- pEntry = First();
-
- if ( pEntry )
- _rEntryText = GetEntryText( pEntry );
-
- return pEntry;
-}
-
-void SvLBox::SelectSearchEntry( const void* _pEntry )
-{
- SvLBoxEntry* pEntry = const_cast< SvLBoxEntry* >( static_cast< const SvLBoxEntry* >( _pEntry ) );
- DBG_ASSERT( pEntry, "SvLBox::SelectSearchEntry: invalid entry!" );
- if ( !pEntry )
- return;
-
- SelectAll( sal_False );
- SetCurEntry( pEntry );
- Select( pEntry );
-}
-
-void SvLBox::ExecuteSearchEntry( const void* /*_pEntry*/ ) const
-{
- // nothing to do here, we have no "execution"
-}
-
-::vcl::StringEntryIdentifier SvLBox::CurrentEntry( String& _out_entryText ) const
-{
- // always accept the current entry if there is one
- SvLBoxEntry* pCurrentEntry( GetCurEntry() );
- if ( pCurrentEntry )
- {
- _out_entryText = GetEntryText( pCurrentEntry );
- return pCurrentEntry;
- }
- return FirstSearchEntry( _out_entryText );
-}
-
-::vcl::StringEntryIdentifier SvLBox::NextEntry( ::vcl::StringEntryIdentifier _currentEntry, String& _out_entryText ) const
-{
- return NextSearchEntry( _currentEntry, _out_entryText );
-}
-
-void SvLBox::SelectEntry( ::vcl::StringEntryIdentifier _entry )
-{
- SelectSearchEntry( _entry );
-}
-
-bool SvLBox::HandleKeyInput( const KeyEvent& _rKEvt )
-{
- if ( IsEntryMnemonicsEnabled()
- && pLBoxImpl->m_aMnemonicEngine.HandleKeyEvent( _rKEvt )
- )
- return true;
-
- if ( ( GetStyle() & WB_QUICK_SEARCH ) != 0 )
- {
- pLBoxImpl->m_bDoingQuickSelection = true;
- const bool bHandled = pLBoxImpl->m_aQuickSelectionEngine.HandleKeyEvent( _rKEvt );
- pLBoxImpl->m_bDoingQuickSelection = false;
- if ( bHandled )
- return true;
- }
-
- return false;
-}
-
-SvLBoxEntry* SvLBox::GetEntry( const Point&, sal_Bool ) const
-{
- DBG_CHKTHIS(SvLBox,0);
- return 0;
-}
-
-void SvLBox::ModelHasEntryInvalidated( SvListEntry* pEntry )
-{
- DBG_CHKTHIS(SvLBox,0);
- sal_uInt16 nCount = ((SvLBoxEntry*)pEntry)->ItemCount();
- for( sal_uInt16 nIdx = 0; nIdx < nCount; nIdx++ )
- {
- SvLBoxItem* pItem = ((SvLBoxEntry*)pEntry)->GetItem( nIdx );
- pItem->InitViewData( this, (SvLBoxEntry*)pEntry, 0 );
- }
-}
-
-void SvLBox::WriteDragServerInfo( const Point&, SvLBoxDDInfo* )
-{
- DBG_CHKTHIS(SvLBox,0);
-}
-
-void SvLBox::ReadDragServerInfo(const Point&, SvLBoxDDInfo* )
-{
- DBG_CHKTHIS(SvLBox,0);
-}
-
-sal_Bool SvLBox::EditingCanceled() const
-{
- if( pEdCtrl && pEdCtrl->EditingCanceled() )
- return sal_True;
- return sal_False;
-}
-
-
-//JP 28.3.2001: new Drag & Drop API
-sal_Int8 SvLBox::AcceptDrop( const AcceptDropEvent& rEvt )
-{
- DBG_CHKTHIS(SvLBox,0);
- sal_Int8 nRet = DND_ACTION_NONE;
-
- if( rEvt.mbLeaving || !CheckDragAndDropMode( pDDSource, rEvt.mnAction ) )
- {
- ImplShowTargetEmphasis( pTargetEntry, sal_False );
- }
- else if( !nDragDropMode )
- {
- SAL_WARN( "svtools.contnr", "SvLBox::QueryDrop(): no target" );
- }
- else
- {
- SvLBoxEntry* pEntry = GetDropTarget( rEvt.maPosPixel );
- if( !IsDropFormatSupported( SOT_FORMATSTR_ID_TREELISTBOX ) )
- {
- SAL_WARN( "svtools.contnr", "SvLBox::QueryDrop(): no format" );
- }
- else
- {
- DBG_ASSERT( pDDSource, "SvLBox::QueryDrop(): SourceBox == 0" );
- if( !( pEntry && pDDSource->GetModel() == this->GetModel()
- && DND_ACTION_MOVE == rEvt.mnAction
- && ( pEntry->nEntryFlags & SV_ENTRYFLAG_DISABLE_DROP ) ))
- {
- if( NotifyAcceptDrop( pEntry ))
- nRet = rEvt.mnAction;
- }
- }
-
- // **** draw emphasis ****
- if( DND_ACTION_NONE == nRet )
- ImplShowTargetEmphasis( pTargetEntry, sal_False );
- else if( pEntry != pTargetEntry || !(nImpFlags & SVLBOX_TARGEMPH_VIS) )
- {
- ImplShowTargetEmphasis( pTargetEntry, sal_False );
- pTargetEntry = pEntry;
- ImplShowTargetEmphasis( pTargetEntry, sal_True );
- }
- }
- return nRet;
-}
-
-sal_Int8 SvLBox::ExecuteDrop( const ExecuteDropEvent& rEvt, SvLBox* pSourceView )
-{
- DBG_CHKTHIS(SvLBox,0);
- sal_Int8 nRet = DND_ACTION_NONE;
-
- DBG_ASSERT( pSourceView, "SvLBox::ExecuteDrop(): no source view" );
- pSourceView->EnableSelectionAsDropTarget( sal_True, sal_True );
-
- ImplShowTargetEmphasis( pTargetEntry, sal_False );
- pDDTarget = this;
-
- SvLBoxDDInfo aDDInfo;
-
- TransferableDataHelper aData( rEvt.maDropEvent.Transferable );
- if( aData.HasFormat( SOT_FORMATSTR_ID_TREELISTBOX ))
- {
- ::com::sun::star::uno::Sequence< sal_Int8 > aSeq;
- if( aData.GetSequence( SOT_FORMATSTR_ID_TREELISTBOX, aSeq ) &&
- sizeof(SvLBoxDDInfo) == aSeq.getLength() )
- {
- memcpy( &aDDInfo, aSeq.getConstArray(), sizeof(SvLBoxDDInfo) );
- nRet = rEvt.mnAction;
- }
- }
-
- if( DND_ACTION_NONE != nRet )
- {
- nRet = DND_ACTION_NONE;
-
- ReadDragServerInfo( rEvt.maPosPixel, &aDDInfo );
-
- SvLBoxEntry* pTarget = pTargetEntry; // may be 0!
-
- if( DND_ACTION_COPY == rEvt.mnAction )
- {
- if ( CopySelection( aDDInfo.pSource, pTarget ) )
- nRet = rEvt.mnAction;
- }
- else if( DND_ACTION_MOVE == rEvt.mnAction )
- {
- if ( MoveSelection( aDDInfo.pSource, pTarget ) )
- nRet = rEvt.mnAction;
- }
- else if( DND_ACTION_COPYMOVE == rEvt.mnAction )
- {
- if ( MoveSelectionCopyFallbackPossible( aDDInfo.pSource, pTarget, sal_True ) )
- nRet = rEvt.mnAction;
- }
- }
- return nRet;
-}
-
-sal_Int8 SvLBox::ExecuteDrop( const ExecuteDropEvent& rEvt )
-{
- DBG_CHKTHIS(SvLBox,0);
- return ExecuteDrop( rEvt, GetSourceView() );
-}
-
-void SvLBox::StartDrag( sal_Int8, const Point& rPosPixel )
-{
- DBG_CHKTHIS(SvLBox,0);
-
- Point aEventPos( rPosPixel );
- MouseEvent aMouseEvt( aEventPos, 1, MOUSE_SELECT, MOUSE_LEFT );
- MouseButtonUp( aMouseEvt );
-
- nOldDragMode = GetDragDropMode();
- if ( !nOldDragMode )
- return;
-
- ReleaseMouse();
-
- SvLBoxEntry* pEntry = GetEntry( rPosPixel ); // GetDropTarget( rPos );
- if( !pEntry )
- {
- DragFinished( DND_ACTION_NONE );
- return;
- }
-
- TransferDataContainer* pContainer = new TransferDataContainer;
- ::com::sun::star::uno::Reference<
- ::com::sun::star::datatransfer::XTransferable > xRef( pContainer );
-
- nDragDropMode = NotifyStartDrag( *pContainer, pEntry );
- if( !nDragDropMode || 0 == GetSelectionCount() )
- {
- nDragDropMode = nOldDragMode;
- DragFinished( DND_ACTION_NONE );
- return;
- }
-
- SvLBoxDDInfo aDDInfo;
- memset(&aDDInfo,0,sizeof(SvLBoxDDInfo));
- aDDInfo.pApp = GetpApp();
- aDDInfo.pSource = this;
- aDDInfo.pDDStartEntry = pEntry;
- // let derived views do their thing
- WriteDragServerInfo( rPosPixel, &aDDInfo );
-
- pContainer->CopyAnyData( SOT_FORMATSTR_ID_TREELISTBOX,
- (sal_Char*)&aDDInfo, sizeof(SvLBoxDDInfo) );
- pDDSource = this;
- pDDTarget = 0;
-
- sal_Bool bOldUpdateMode = Control::IsUpdateMode();
- Control::SetUpdateMode( sal_True );
- Update();
- Control::SetUpdateMode( bOldUpdateMode );
-
- // Disallow using the selection and its children as drop targets.
- // Important: If the selection of the SourceListBox is changed in the
- // DropHandler, the entries have to be allowed as drop targets again:
- // (GetSourceListBox()->EnableSelectionAsDropTarget( sal_True, sal_True );)
- EnableSelectionAsDropTarget( sal_False, sal_True /* with children */ );
-
- pContainer->StartDrag( this, nDragOptions, GetDragFinishedHdl() );
-}
-
-void SvLBox::DragFinished( sal_Int8
-#ifndef UNX
-nAction
-#endif
-)
-{
- EnableSelectionAsDropTarget( sal_True, sal_True );
-
-#ifndef UNX
- if( (nAction == DND_ACTION_MOVE) && ( (pDDTarget &&
- ((sal_uLong)(pDDTarget->GetModel())!=(sal_uLong)(this->GetModel()))) ||
- !pDDTarget ))
- {
- RemoveSelection();
- }
-#endif
-
- ImplShowTargetEmphasis( pTargetEntry, sal_False );
- pDDSource = 0;
- pDDTarget = 0;
- pTargetEntry = 0;
- nDragDropMode = nOldDragMode;
-}
-
-DragDropMode SvLBox::NotifyStartDrag( TransferDataContainer&, SvLBoxEntry* )
-{
- DBG_CHKTHIS(SvLBox,0);
- return (DragDropMode)0xffff;
-}
-
-sal_Bool SvLBox::NotifyAcceptDrop( SvLBoxEntry* )
-{
- DBG_CHKTHIS(SvLBox,0);
- return sal_True;
-}
-
-// Handler and methods for Drag - finished handler.
-// The with get GetDragFinishedHdl() get link can set on the
-// TransferDataContainer. This link is a callback for the DragFinished
-// call. AddBox method is called from the GetDragFinishedHdl() and the
-// remove is called in link callback and in the destructor. So it can't
-// called to a deleted object.
-
-namespace
-{
- struct SortLBoxes : public rtl::Static<std::set<sal_uLong>, SortLBoxes> {};
-}
-
-void SvLBox::AddBoxToDDList_Impl( const SvLBox& rB )
-{
- sal_uLong nVal = (sal_uLong)&rB;
- SortLBoxes::get().insert( nVal );
-}
-
-void SvLBox::RemoveBoxFromDDList_Impl( const SvLBox& rB )
-{
- sal_uLong nVal = (sal_uLong)&rB;
- SortLBoxes::get().erase( nVal );
-}
-
-IMPL_STATIC_LINK( SvLBox, DragFinishHdl_Impl, sal_Int8*, pAction )
-{
- sal_uLong nVal = (sal_uLong)pThis;
- std::set<sal_uLong> &rSortLBoxes = SortLBoxes::get();
- std::set<sal_uLong>::const_iterator it = rSortLBoxes.find(nVal);
- if( it != rSortLBoxes.end() )
- {
- pThis->DragFinished( *pAction );
- rSortLBoxes.erase( it );
- }
- return 0;
-}
-
-Link SvLBox::GetDragFinishedHdl() const
-{
- AddBoxToDDList_Impl( *this );
- return STATIC_LINK( this, SvLBox, DragFinishHdl_Impl );
-}
-
-void SvLBox::FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& ) const
-{
-}
-
-::com::sun::star::uno::Reference< XAccessible > SvLBox::CreateAccessible()
-{
- return ::com::sun::star::uno::Reference< XAccessible >();
-}
-
-Rectangle SvLBox::GetBoundingRect( SvLBoxEntry* )
-{
- return Rectangle();
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/contnr/svtabbx.cxx b/svtools/source/contnr/svtabbx.cxx
index eba80955ff27..6f410fa4e846 100644
--- a/svtools/source/contnr/svtabbx.cxx
+++ b/svtools/source/contnr/svtabbx.cxx
@@ -29,6 +29,7 @@
#include <svtools/svtabbx.hxx>
#include <svtools/headbar.hxx>
#include <svtools/svtresid.hxx>
+#include <svtools/svlbitm.hxx>
#include <svtools/svtools.hrc>
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
@@ -838,12 +839,12 @@ sal_Bool SvHeaderTabListBox::GoToCell( sal_Int32 _nRow, sal_uInt16 _nColumn )
// -----------------------------------------------------------------------
void SvHeaderTabListBox::SetNoSelection()
{
- SvLBox::SelectAll( sal_False );
+ SvTreeListBox::SelectAll(false);
}
// -----------------------------------------------------------------------
void SvHeaderTabListBox::SelectAll()
{
- SvLBox::SelectAll( sal_True );
+ SvTreeListBox::SelectAll(true);
}
// -----------------------------------------------------------------------
void SvHeaderTabListBox::SelectAll( sal_Bool bSelect, sal_Bool bPaint )
diff --git a/svtools/source/contnr/svtreebx.cxx b/svtools/source/contnr/treelistbox.cxx
index 92d91d2e188a..ad75c6497a00 100644
--- a/svtools/source/contnr/svtreebx.cxx
+++ b/svtools/source/contnr/treelistbox.cxx
@@ -26,48 +26,609 @@
*
************************************************************************/
-#define _SVTREEBX_CXX
+
+/*
+ TODO:
+ - delete anchor in SelectionEngine when selecting manually
+ - SelectAll( sal_False ) => only repaint the delselected entries
+*/
+
+#include <svtools/treelistbox.hxx>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <vcl/svapp.hxx>
+#include <vcl/accel.hxx>
+#include <vcl/i18nhelp.hxx>
+#include <sot/formats.hxx>
+#include <unotools/accessiblestatesethelper.hxx>
+#include <rtl/instance.hxx>
+#include <comphelper/string.hxx>
-#include <svtools/svlbox.hxx>
+#include <svtools/svmedit.hxx>
#include <svtools/svlbitm.hxx>
-#include <svtools/svtreebx.hxx>
-#include <comphelper/string.hxx>
-#include <svimpbox.hxx>
-#include <unotools/accessiblestatesethelper.hxx>
-#include <com/sun/star/accessibility/AccessibleStateType.hpp>
-#include <com/sun/star/awt/XWindowPeer.hpp>
+#include "svimpbox.hxx"
+#include <set>
+#include <string.h>
using namespace ::com::sun::star::accessibility;
-/*
- Bugs/TODO
+// Drag&Drop
+static SvTreeListBox* pDDSource = NULL;
+static SvTreeListBox* pDDTarget = NULL;
- - calculate rectangle when editing in-place (bug with some fonts)
- - SetSpaceBetweenEntries: offset is not taken into account in SetEntryHeight
-*/
+DBG_NAME(SvInplaceEdit2)
-#define TREEFLAG_FIXEDHEIGHT 0x0010
+#define SVLBOX_ACC_RETURN 1
+#define SVLBOX_ACC_ESCAPE 2
+// ***************************************************************
-DBG_NAME(SvTreeListBox)
+class MyEdit_Impl : public Edit
+{
+ SvInplaceEdit2* pOwner;
+public:
+ MyEdit_Impl( Window* pParent, SvInplaceEdit2* pOwner );
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual void LoseFocus();
+};
-#define SV_LBOX_DEFAULT_INDENT_PIXEL 20
+class MyMultiEdit_Impl : public MultiLineEdit
+{
+ SvInplaceEdit2* pOwner;
+public:
+ MyMultiEdit_Impl( Window* pParent, SvInplaceEdit2* pOwner );
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual void LoseFocus();
+};
+
+MyEdit_Impl::MyEdit_Impl( Window* pParent, SvInplaceEdit2* _pOwner ) :
+
+ Edit( pParent, WB_LEFT ),
+
+ pOwner( _pOwner )
+
+{
+}
+
+void MyEdit_Impl::KeyInput( const KeyEvent& rKEvt )
+{
+ if( !pOwner->KeyInput( rKEvt ))
+ Edit::KeyInput( rKEvt );
+}
+
+void MyEdit_Impl::LoseFocus()
+{
+ pOwner->LoseFocus();
+}
+
+MyMultiEdit_Impl::MyMultiEdit_Impl( Window* pParent, SvInplaceEdit2* _pOwner )
+ : MultiLineEdit( pParent,
+ WB_CENTER
+ ), pOwner(_pOwner)
+{
+}
+
+void MyMultiEdit_Impl::KeyInput( const KeyEvent& rKEvt )
+{
+ if( !pOwner->KeyInput( rKEvt ))
+ MultiLineEdit::KeyInput( rKEvt );
+}
+
+void MyMultiEdit_Impl::LoseFocus()
+{
+ pOwner->LoseFocus();
+}
+
+
+SvInplaceEdit2::SvInplaceEdit2
+(
+ Window* pParent, const Point& rPos,
+ const Size& rSize,
+ const String& rData,
+ const Link& rNotifyEditEnd,
+ const Selection& rSelection,
+ sal_Bool bMulti
+) :
+
+ aCallBackHdl ( rNotifyEditEnd ),
+ bCanceled ( sal_False ),
+ bAlreadyInCallBack ( sal_False )
+
+{
+ DBG_CTOR(SvInplaceEdit2,0);
+
+ if( bMulti )
+ pEdit = new MyMultiEdit_Impl( pParent, this );
+ else
+ pEdit = new MyEdit_Impl( pParent, this );
+
+ Font aFont( pParent->GetFont() );
+ aFont.SetTransparent( sal_False );
+ Color aColor( pParent->GetBackground().GetColor() );
+ aFont.SetFillColor(aColor );
+ pEdit->SetFont( aFont );
+ pEdit->SetBackground( pParent->GetBackground() );
+ pEdit->SetPosPixel( rPos );
+ pEdit->SetSizePixel( rSize );
+ pEdit->SetText( rData );
+ pEdit->SetSelection( rSelection );
+ pEdit->SaveValue();
+
+ aAccReturn.InsertItem( SVLBOX_ACC_RETURN, KeyCode(KEY_RETURN) );
+ aAccEscape.InsertItem( SVLBOX_ACC_ESCAPE, KeyCode(KEY_ESCAPE) );
+
+ aAccReturn.SetActivateHdl( LINK( this, SvInplaceEdit2, ReturnHdl_Impl) );
+ aAccEscape.SetActivateHdl( LINK( this, SvInplaceEdit2, EscapeHdl_Impl) );
+ GetpApp()->InsertAccel( &aAccReturn );
+ GetpApp()->InsertAccel( &aAccEscape );
+
+ pEdit->Show();
+ pEdit->GrabFocus();
+}
+
+SvInplaceEdit2::~SvInplaceEdit2()
+{
+ DBG_DTOR(SvInplaceEdit2,0);
+ if( !bAlreadyInCallBack )
+ {
+ GetpApp()->RemoveAccel( &aAccReturn );
+ GetpApp()->RemoveAccel( &aAccEscape );
+ }
+ delete pEdit;
+}
+
+String SvInplaceEdit2::GetSavedValue() const
+{
+ return pEdit->GetSavedValue();
+}
+
+void SvInplaceEdit2::Hide()
+{
+ pEdit->Hide();
+}
+
+
+IMPL_LINK_NOARG_INLINE_START(SvInplaceEdit2, ReturnHdl_Impl)
+{
+ DBG_CHKTHIS(SvInplaceEdit2,0);
+ bCanceled = sal_False;
+ CallCallBackHdl_Impl();
+ return 1;
+}
+IMPL_LINK_NOARG_INLINE_END(SvInplaceEdit2, ReturnHdl_Impl)
+
+IMPL_LINK_NOARG_INLINE_START(SvInplaceEdit2, EscapeHdl_Impl)
+{
+ DBG_CHKTHIS(SvInplaceEdit2,0);
+ bCanceled = sal_True;
+ CallCallBackHdl_Impl();
+ return 1;
+}
+IMPL_LINK_NOARG_INLINE_END(SvInplaceEdit2, EscapeHdl_Impl)
+
+
+sal_Bool SvInplaceEdit2::KeyInput( const KeyEvent& rKEvt )
+{
+ DBG_CHKTHIS(SvInplaceEdit2,0);
+ KeyCode aCode = rKEvt.GetKeyCode();
+ sal_uInt16 nCode = aCode.GetCode();
+
+ switch ( nCode )
+ {
+ case KEY_ESCAPE:
+ bCanceled = sal_True;
+ CallCallBackHdl_Impl();
+ return sal_True;
+
+ case KEY_RETURN:
+ bCanceled = sal_False;
+ CallCallBackHdl_Impl();
+ return sal_True;
+ }
+ return sal_False;
+}
+
+void SvInplaceEdit2::StopEditing( sal_Bool bCancel )
+{
+ DBG_CHKTHIS(SvInplaceEdit2,0);
+ if ( !bAlreadyInCallBack )
+ {
+ bCanceled = bCancel;
+ CallCallBackHdl_Impl();
+ }
+}
+
+void SvInplaceEdit2::LoseFocus()
+{
+ DBG_CHKTHIS(SvInplaceEdit2,0);
+ if ( !bAlreadyInCallBack
+ && ((!Application::GetFocusWindow()) || !pEdit->IsChild( Application::GetFocusWindow()) )
+ )
+ {
+ bCanceled = sal_False;
+ aTimer.SetTimeout(10);
+ aTimer.SetTimeoutHdl(LINK(this,SvInplaceEdit2,Timeout_Impl));
+ aTimer.Start();
+ }
+}
+
+IMPL_LINK_NOARG_INLINE_START(SvInplaceEdit2, Timeout_Impl)
+{
+ DBG_CHKTHIS(SvInplaceEdit2,0);
+ CallCallBackHdl_Impl();
+ return 0;
+}
+IMPL_LINK_NOARG_INLINE_END(SvInplaceEdit2, Timeout_Impl)
+
+void SvInplaceEdit2::CallCallBackHdl_Impl()
+{
+ DBG_CHKTHIS(SvInplaceEdit2,0);
+ aTimer.Stop();
+ if ( !bAlreadyInCallBack )
+ {
+ bAlreadyInCallBack = sal_True;
+ GetpApp()->RemoveAccel( &aAccReturn );
+ GetpApp()->RemoveAccel( &aAccEscape );
+ pEdit->Hide();
+ aCallBackHdl.Call( this );
+ }
+}
+
+String SvInplaceEdit2::GetText() const
+{
+ return pEdit->GetText();
+}
+
+// ***************************************************************
+// class SvLBoxTab
+// ***************************************************************
+
+DBG_NAME(SvLBoxTab);
+
+SvLBoxTab::SvLBoxTab()
+{
+ DBG_CTOR(SvLBoxTab,0);
+ nPos = 0;
+ pUserData = 0;
+ nFlags = 0;
+}
+
+SvLBoxTab::SvLBoxTab( long nPosition, sal_uInt16 nTabFlags )
+{
+ DBG_CTOR(SvLBoxTab,0);
+ nPos = nPosition;
+ pUserData = 0;
+ nFlags = nTabFlags;
+}
+
+SvLBoxTab::SvLBoxTab( const SvLBoxTab& rTab )
+{
+ DBG_CTOR(SvLBoxTab,0);
+ nPos = rTab.nPos;
+ pUserData = rTab.pUserData;
+ nFlags = rTab.nFlags;
+}
+
+SvLBoxTab::~SvLBoxTab()
+{
+ DBG_DTOR(SvLBoxTab,0);
+}
+
+
+long SvLBoxTab::CalcOffset( long nItemWidth, long nTabWidth )
+{
+ DBG_CHKTHIS(SvLBoxTab,0);
+ long nOffset = 0;
+ if ( nFlags & SV_LBOXTAB_ADJUST_RIGHT )
+ {
+ nOffset = nTabWidth - nItemWidth;
+ if( nOffset < 0 )
+ nOffset = 0;
+ }
+ else if ( nFlags & SV_LBOXTAB_ADJUST_CENTER )
+ {
+ if( nFlags & SV_LBOXTAB_FORCE )
+ {
+ // correct implementation of centering
+ nOffset = ( nTabWidth - nItemWidth ) / 2;
+ if( nOffset < 0 )
+ nOffset = 0;
+ }
+ else
+ {
+ // historically grown, wrong calculation of tabs which is needed by
+ // Abo-Tabbox, Tools/Options/Customize etc.
+ nItemWidth++;
+ nOffset = -( nItemWidth / 2 );
+ }
+ }
+ return nOffset;
+}
+
+// ***************************************************************
+// class SvLBoxItem
+// ***************************************************************
+
+DBG_NAME(SvLBoxItem);
+
+SvLBoxItem::SvLBoxItem( SvLBoxEntry*, sal_uInt16 )
+{
+ DBG_CTOR(SvLBoxItem,0);
+}
+
+SvLBoxItem::SvLBoxItem()
+{
+ DBG_CTOR(SvLBoxItem,0);
+}
+
+SvLBoxItem::~SvLBoxItem()
+{
+ DBG_DTOR(SvLBoxItem,0);
+}
+
+const Size& SvLBoxItem::GetSize( SvTreeListBox* pView,SvLBoxEntry* pEntry )
+{
+ DBG_CHKTHIS(SvLBoxItem,0);
+ SvViewDataItem* pViewData = pView->GetViewDataItem( pEntry, this );
+ return pViewData->aSize;
+}
+
+DBG_NAME(SvViewDataItem);
+
+SvViewDataItem::SvViewDataItem()
+{
+ DBG_CTOR(SvViewDataItem,0);
+}
+
+SvViewDataItem::~SvViewDataItem()
+{
+ DBG_DTOR(SvViewDataItem,0);
+}
+
+
+
+// ***************************************************************
+// class SvLBoxEntry
+// ***************************************************************
+
+DBG_NAME(SvLBoxEntry);
+
+SvLBoxEntry::SvLBoxEntry() : aItems()
+{
+ DBG_CTOR(SvLBoxEntry,0);
+ nEntryFlags = 0;
+ pUserData = 0;
+}
+
+SvLBoxEntry::~SvLBoxEntry()
+{
+ DBG_DTOR(SvLBoxEntry,0);
+ DeleteItems_Impl();
+}
+
+void SvLBoxEntry::DeleteItems_Impl()
+{
+ DBG_CHKTHIS(SvLBoxEntry,0);
+ sal_uInt16 nCount = aItems.size();
+ while( nCount )
+ {
+ nCount--;
+ SvLBoxItem* pItem = aItems[ nCount ];
+ delete pItem;
+ }
+ aItems.clear();
+}
+
+
+void SvLBoxEntry::AddItem( SvLBoxItem* pItem )
+{
+ DBG_CHKTHIS(SvLBoxEntry,0);
+ aItems.push_back( pItem );
+}
+
+void SvLBoxEntry::Clone( SvListEntry* pSource )
+{
+ DBG_CHKTHIS(SvLBoxEntry,0);
+ SvListEntry::Clone( pSource );
+ SvLBoxItem* pNewItem;
+ DeleteItems_Impl();
+ sal_uInt16 nCount = ((SvLBoxEntry*)pSource)->ItemCount();
+ sal_uInt16 nCurPos = 0;
+ while( nCurPos < nCount )
+ {
+ SvLBoxItem* pItem = ((SvLBoxEntry*)pSource)->GetItem( nCurPos );
+ pNewItem = pItem->Create();
+ pNewItem->Clone( pItem );
+ AddItem( pNewItem );
+ nCurPos++;
+ }
+ pUserData = ((SvLBoxEntry*)pSource)->GetUserData();
+ nEntryFlags = ((SvLBoxEntry*)pSource)->nEntryFlags;
+}
+
+void SvLBoxEntry::EnableChildrenOnDemand( sal_Bool bEnable )
+{
+ DBG_CHKTHIS(SvLBoxEntry,0);
+ if ( bEnable )
+ nEntryFlags |= SV_ENTRYFLAG_CHILDREN_ON_DEMAND;
+ else
+ nEntryFlags &= (~SV_ENTRYFLAG_CHILDREN_ON_DEMAND);
+}
+
+void SvLBoxEntry::ReplaceItem( SvLBoxItem* pNewItem, sal_uInt16 nPos )
+{
+ DBG_CHKTHIS(SvLBoxEntry,0);
+ DBG_ASSERT(pNewItem,"ReplaceItem:No Item");
+ SvLBoxItem* pOld = GetItem( nPos );
+ if ( pOld )
+ {
+ aItems[ nPos ] = pNewItem;
+ delete pOld;
+ }
+}
+
+SvLBoxItem* SvLBoxEntry::GetFirstItem( sal_uInt16 nId )
+{
+ sal_uInt16 nCount = aItems.size();
+ sal_uInt16 nCur = 0;
+ SvLBoxItem* pItem;
+ while( nCur < nCount )
+ {
+ pItem = GetItem( nCur );
+ if( pItem->IsA() == nId )
+ return pItem;
+ nCur++;
+ }
+ return 0;
+}
+
+SvLBoxEntry* SvLBoxTreeList::First() const
+{
+ return (SvLBoxEntry*)SvTreeList::First();
+}
+
+SvLBoxEntry* SvLBoxTreeList::Next( SvListEntry* pEntry, sal_uInt16* pDepth ) const
+{
+ return (SvLBoxEntry*)SvTreeList::Next(pEntry,pDepth);
+}
+
+SvLBoxEntry* SvLBoxTreeList::Prev( SvListEntry* pEntry, sal_uInt16* pDepth ) const
+{
+ return (SvLBoxEntry*)SvTreeList::Prev(pEntry,pDepth);
+}
+
+SvLBoxEntry* SvLBoxTreeList::Last() const
+{
+ return (SvLBoxEntry*)SvTreeList::Last();
+}
+
+SvLBoxEntry* SvLBoxTreeList::Clone( SvListEntry* pEntry, sal_uLong& nCloneCount ) const
+{
+ return (SvLBoxEntry*)SvTreeList::Clone(pEntry,nCloneCount);
+}
+
+SvLBoxEntry* SvLBoxTreeList::GetEntry( SvListEntry* pParent, sal_uLong nPos ) const
+{
+ return (SvLBoxEntry*)SvTreeList::GetEntry(pParent,nPos);
+}
+
+SvLBoxEntry* SvLBoxTreeList::GetEntry( sal_uLong nRootPos ) const
+{
+ return (SvLBoxEntry*)SvTreeList::GetEntry(nRootPos);
+}
+
+SvLBoxEntry* SvLBoxTreeList::GetParent( SvListEntry* pEntry ) const
+{
+ return (SvLBoxEntry*)SvTreeList::GetParent(pEntry);
+}
+
+SvLBoxEntry* SvLBoxTreeList::FirstChild( SvLBoxEntry* pParent ) const
+{
+ return (SvLBoxEntry*)SvTreeList::FirstChild(pParent);
+}
+
+SvLBoxEntry* SvLBoxTreeList::NextSibling( SvLBoxEntry* pEntry ) const
+{
+ return (SvLBoxEntry*)SvTreeList::NextSibling(pEntry);
+}
+
+SvLBoxEntry* SvLBoxTreeList::PrevSibling( SvLBoxEntry* pEntry ) const
+{
+ return (SvLBoxEntry*)SvTreeList::PrevSibling(pEntry);
+}
+
+SvLBoxEntry* SvLBoxTreeList::LastSibling( SvLBoxEntry* pEntry ) const
+{
+ return (SvLBoxEntry*)SvTreeList::LastSibling(pEntry);
+}
+
+SvLBoxEntry* SvLBoxTreeList::GetEntryAtAbsPos( sal_uLong nAbsPos ) const
+{
+ return (SvLBoxEntry*)SvTreeList::GetEntryAtAbsPos( nAbsPos);
+}
+
+// ***************************************************************
+// class SvLBoxViewData
+// ***************************************************************
-SvTreeListBox::SvTreeListBox( Window* pParent, WinBits nWinStyle )
- : SvLBox( pParent, nWinStyle )
+DBG_NAME(SvViewDataEntry);
+
+SvViewDataEntry::SvViewDataEntry()
+ : SvViewData()
+{
+ DBG_CTOR(SvViewDataEntry,0);
+ pItemData = 0;
+}
+
+SvViewDataEntry::~SvViewDataEntry()
+{
+ DBG_DTOR(SvViewDataEntry,0);
+ delete [] pItemData;
+}
+
+// ***************************************************************
+// struct SvLBox_Impl
+// ***************************************************************
+SvLBox_Impl::SvLBox_Impl( SvTreeListBox& _rBox )
+ :m_bIsEmptyTextAllowed( true )
+ ,m_bEntryMnemonicsEnabled( false )
+ ,m_bDoingQuickSelection( false )
+ ,m_pLink( NULL )
+ ,m_aMnemonicEngine( _rBox )
+ ,m_aQuickSelectionEngine( _rBox )
+{
+}
+
+// ***************************************************************
+// class SvTreeListBox
+// ***************************************************************
+
+DBG_NAME(SvTreeListBox);
+
+SvTreeListBox::SvTreeListBox( Window* pParent, WinBits nWinStyle ) :
+ Control( pParent, nWinStyle | WB_CLIPCHILDREN ),
+ DropTargetHelper( this ), DragSourceHelper( this ), eSelMode( NO_SELECTION )
{
DBG_CTOR(SvTreeListBox,0);
+ nDragOptions = DND_ACTION_COPYMOVE | DND_ACTION_LINK;
+ nImpFlags = 0;
+ pTargetEntry = 0;
+ nDragDropMode = 0;
+ pLBoxImpl = new SvLBox_Impl( *this );
+ SvLBoxTreeList* pTempModel = new SvLBoxTreeList;
+ pTempModel->SetRefCount( 0 );
+ SetModel( pTempModel );
+ pModel->SetCloneLink( LINK(this, SvTreeListBox, CloneHdl_Impl ));
+ pModel->InsertView( this );
+ pHdlEntry = 0;
+ pEdCtrl = 0;
+ SetSelectionMode( SINGLE_SELECTION ); // check if TreeListBox is called
+ SetDragDropMode( SV_DRAGDROP_NONE );
+ SetType(WINDOW_TREELISTBOX);
+
InitTreeView();
SetSublistOpenWithLeftRight();
}
-SvTreeListBox::SvTreeListBox( Window* pParent , const ResId& rResId )
- : SvLBox( pParent,rResId )
+SvTreeListBox::SvTreeListBox( Window* pParent, const ResId& rResId ) :
+ Control( pParent, rResId ),
+ DropTargetHelper( this ), DragSourceHelper( this ), eSelMode( NO_SELECTION )
{
DBG_CTOR(SvTreeListBox,0);
+ pTargetEntry = 0;
+ nImpFlags = 0;
+ pLBoxImpl = new SvLBox_Impl( *this );
+ nDragOptions = DND_ACTION_COPYMOVE | DND_ACTION_LINK;
+ nDragDropMode = 0;
+ SvLBoxTreeList* pTempModel = new SvLBoxTreeList;
+ pTempModel->SetRefCount( 0 );
+ SetModel( pTempModel );
+ pModel->InsertView( this );
+ pHdlEntry = 0;
+ pEdCtrl = 0;
+ pModel->SetCloneLink( LINK(this, SvTreeListBox, CloneHdl_Impl ));
+ SetType(WINDOW_TREELISTBOX);
InitTreeView();
Resize();
@@ -75,6 +636,989 @@ SvTreeListBox::SvTreeListBox( Window* pParent , const ResId& rResId )
SetSublistOpenWithLeftRight();
}
+void SvTreeListBox::Clear()
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ pModel->Clear(); // Model calls SvTreeListBox::ModelHasCleared()
+}
+
+void SvTreeListBox::EnableEntryMnemonics( bool _bEnable )
+{
+ if ( _bEnable == IsEntryMnemonicsEnabled() )
+ return;
+
+ pLBoxImpl->m_bEntryMnemonicsEnabled = _bEnable;
+ Invalidate();
+}
+
+bool SvTreeListBox::IsEntryMnemonicsEnabled() const
+{
+ return pLBoxImpl->m_bEntryMnemonicsEnabled;
+}
+
+IMPL_LINK_INLINE_START( SvTreeListBox, CloneHdl_Impl, SvListEntry*, pEntry )
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ return (long)(CloneEntry((SvLBoxEntry*)pEntry));
+}
+IMPL_LINK_INLINE_END( SvTreeListBox, CloneHdl_Impl, SvListEntry*, pEntry )
+
+sal_uLong SvTreeListBox::Insert( SvLBoxEntry* pEntry, SvLBoxEntry* pParent, sal_uLong nPos )
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ sal_uLong nInsPos = pModel->Insert( pEntry, pParent, nPos );
+ return nInsPos;
+}
+
+sal_uLong SvTreeListBox::Insert( SvLBoxEntry* pEntry,sal_uLong nRootPos )
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ sal_uLong nInsPos = pModel->Insert( pEntry, nRootPos );
+ return nInsPos;
+}
+
+long SvTreeListBox::ExpandingHdl()
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ return aExpandingHdl.IsSet() ? aExpandingHdl.Call( this ) : 1;
+}
+
+void SvTreeListBox::ExpandedHdl()
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ aExpandedHdl.Call( this );
+}
+
+void SvTreeListBox::SelectHdl()
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ aSelectHdl.Call( this );
+}
+
+void SvTreeListBox::DeselectHdl()
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ aDeselectHdl.Call( this );
+}
+
+sal_Bool SvTreeListBox::DoubleClickHdl()
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ aDoubleClickHdl.Call( this );
+ return sal_True;
+}
+
+
+sal_Bool SvTreeListBox::CheckDragAndDropMode( SvTreeListBox* pSource, sal_Int8 nAction )
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ if ( pSource == this )
+ {
+ if ( !(nDragDropMode & (SV_DRAGDROP_CTRL_MOVE | SV_DRAGDROP_CTRL_COPY) ) )
+ return sal_False; // D&D locked within list
+ if( DND_ACTION_MOVE == nAction )
+ {
+ if ( !(nDragDropMode & SV_DRAGDROP_CTRL_MOVE) )
+ return sal_False; // no local move
+ }
+ else
+ {
+ if ( !(nDragDropMode & SV_DRAGDROP_CTRL_COPY))
+ return sal_False; // no local copy
+ }
+ }
+ else
+ {
+ if ( !(nDragDropMode & SV_DRAGDROP_APP_DROP ) )
+ return sal_False; // no drop
+ if ( DND_ACTION_MOVE == nAction )
+ {
+ if ( !(nDragDropMode & SV_DRAGDROP_APP_MOVE) )
+ return sal_False; // no global move
+ }
+ else
+ {
+ if ( !(nDragDropMode & SV_DRAGDROP_APP_COPY))
+ return sal_False; // no global copy
+ }
+ }
+ return sal_True;
+}
+
+
+
+
+void SvTreeListBox::NotifyRemoving( SvLBoxEntry* )
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+}
+
+/*
+ NotifyMoving/Copying
+ ====================
+
+ default behavior:
+
+ 1. target doesn't have children
+ - entry becomes sibling of target. entry comes after target
+ (->Window: below the target)
+ 2. target is an expanded parent
+ - entry inserted at the beginning of the target childlist
+ 3. target is a collapsed parent
+ - entry is inserted at the end of the target childlist
+*/
+#ifdef DBG_UTIL
+sal_Bool SvTreeListBox::NotifyMoving(
+ SvLBoxEntry* pTarget, // D&D dropping position in this->GetModel()
+ SvLBoxEntry* pEntry, // entry that we want to move, from
+ // GetSourceListBox()->GetModel()
+ SvLBoxEntry*& rpNewParent, // new target parent
+ sal_uLong& rNewChildPos) // position in childlist of target parent
+#else
+sal_Bool SvTreeListBox::NotifyMoving(
+ SvLBoxEntry* pTarget, // D&D dropping position in this->GetModel()
+ SvLBoxEntry*, // entry that we want to move, from
+ // GetSourceListBox()->GetModel()
+ SvLBoxEntry*& rpNewParent, // new target parent
+ sal_uLong& rNewChildPos) // position in childlist of target parent
+#endif
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ DBG_ASSERT(pEntry,"NotifyMoving:SoureEntry?");
+ if( !pTarget )
+ {
+ rpNewParent = 0;
+ rNewChildPos = 0;
+ return sal_True;
+ }
+ if ( !pTarget->HasChildren() && !pTarget->HasChildrenOnDemand() )
+ {
+ // case 1
+ rpNewParent = GetParent( pTarget );
+ rNewChildPos = pModel->GetRelPos( pTarget ) + 1;
+ rNewChildPos += nCurEntrySelPos;
+ nCurEntrySelPos++;
+ }
+ else
+ {
+ // cases 2 & 3
+ rpNewParent = pTarget;
+ if( IsExpanded(pTarget))
+ rNewChildPos = 0;
+ else
+ rNewChildPos = LIST_APPEND;
+ }
+ return sal_True;
+}
+
+sal_Bool SvTreeListBox::NotifyCopying(
+ SvLBoxEntry* pTarget, // D&D dropping position in this->GetModel()
+ SvLBoxEntry* pEntry, // entry that we want to move, from
+ // GetSourceListBox()->GetModel()
+ SvLBoxEntry*& rpNewParent, // new target parent
+ sal_uLong& rNewChildPos) // position in childlist of target parent
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ return NotifyMoving(pTarget,pEntry,rpNewParent,rNewChildPos);
+}
+
+// return: all entries copied
+sal_Bool SvTreeListBox::CopySelection( SvTreeListBox* pSource, SvLBoxEntry* pTarget )
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ nCurEntrySelPos = 0; // selection counter for NotifyMoving/Copying
+ sal_Bool bSuccess = sal_True;
+ SvTreeEntryList aList;
+ sal_Bool bClone = (sal_Bool)( (sal_uLong)(pSource->GetModel()) != (sal_uLong)GetModel() );
+ Link aCloneLink( pModel->GetCloneLink() );
+ pModel->SetCloneLink( LINK(this, SvTreeListBox, CloneHdl_Impl ));
+
+ // cache selection to simplify iterating over the selection when doing a D&D
+ // exchange within the same listbox
+ SvLBoxEntry* pSourceEntry = pSource->FirstSelected();
+ while ( pSourceEntry )
+ {
+ // children are copied automatically
+ pSource->SelectChildren( pSourceEntry, sal_False );
+ aList.push_back( pSourceEntry );
+ pSourceEntry = pSource->NextSelected( pSourceEntry );
+ }
+
+ SvTreeEntryList::iterator it = aList.begin(), itEnd = aList.end();
+ for (; it != itEnd; ++it)
+ {
+ pSourceEntry = static_cast<SvLBoxEntry*>(*it);
+ SvLBoxEntry* pNewParent = 0;
+ sal_uLong nInsertionPos = ULONG_MAX;
+ sal_Bool bOk=NotifyCopying(pTarget,pSourceEntry,pNewParent,nInsertionPos);
+ if ( bOk )
+ {
+ if ( bClone )
+ {
+ sal_uLong nCloneCount = 0;
+ pSourceEntry = (SvLBoxEntry*)
+ pModel->Clone( (SvListEntry*)pSourceEntry, nCloneCount );
+ pModel->InsertTree( (SvListEntry*)pSourceEntry,
+ (SvListEntry*)pNewParent, nInsertionPos );
+ }
+ else
+ {
+ sal_uLong nListPos = pModel->Copy( (SvListEntry*)pSourceEntry,
+ (SvListEntry*)pNewParent, nInsertionPos );
+ pSourceEntry = GetEntry( pNewParent, nListPos );
+ }
+ }
+ else
+ bSuccess = sal_False;
+
+ if( bOk == (sal_Bool)2 ) // HACK: make visible moved entry?
+ MakeVisible( pSourceEntry );
+ }
+ pModel->SetCloneLink( aCloneLink );
+ return bSuccess;
+}
+
+// return: all entries were moved
+sal_Bool SvTreeListBox::MoveSelection( SvTreeListBox* pSource, SvLBoxEntry* pTarget )
+{
+ return MoveSelectionCopyFallbackPossible( pSource, pTarget, sal_False );
+}
+
+sal_Bool SvTreeListBox::MoveSelectionCopyFallbackPossible( SvTreeListBox* pSource, SvLBoxEntry* pTarget, sal_Bool bAllowCopyFallback )
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ nCurEntrySelPos = 0; // selection counter for NotifyMoving/Copying
+ sal_Bool bSuccess = sal_True;
+ SvTreeEntryList aList;
+ sal_Bool bClone = (sal_Bool)( (sal_uLong)(pSource->GetModel()) != (sal_uLong)GetModel() );
+ Link aCloneLink( pModel->GetCloneLink() );
+ if ( bClone )
+ pModel->SetCloneLink( LINK(this, SvTreeListBox, CloneHdl_Impl ));
+
+ SvLBoxEntry* pSourceEntry = pSource->FirstSelected();
+ while ( pSourceEntry )
+ {
+ // children are automatically moved
+ pSource->SelectChildren( pSourceEntry, sal_False );
+ aList.push_back( pSourceEntry );
+ pSourceEntry = pSource->NextSelected( pSourceEntry );
+ }
+
+ SvTreeEntryList::iterator it = aList.begin(), itEnd = aList.end();
+ for (; it != itEnd; ++it)
+ {
+ pSourceEntry = static_cast<SvLBoxEntry*>(*it);
+
+ SvLBoxEntry* pNewParent = 0;
+ sal_uLong nInsertionPos = ULONG_MAX;
+ sal_Bool bOk = NotifyMoving(pTarget,pSourceEntry,pNewParent,nInsertionPos);
+ sal_Bool bCopyOk = bOk;
+ if ( !bOk && bAllowCopyFallback )
+ {
+ nInsertionPos = LIST_APPEND;
+ bCopyOk = NotifyCopying(pTarget,pSourceEntry,pNewParent,nInsertionPos);
+ }
+
+ if ( bOk || bCopyOk )
+ {
+ if ( bClone )
+ {
+ sal_uLong nCloneCount = 0;
+ pSourceEntry = (SvLBoxEntry*)
+ pModel->Clone( (SvListEntry*)pSourceEntry, nCloneCount );
+ pModel->InsertTree( (SvListEntry*)pSourceEntry,
+ (SvListEntry*)pNewParent, nInsertionPos );
+ }
+ else
+ {
+ if ( bOk )
+ pModel->Move( (SvListEntry*)pSourceEntry,
+ (SvListEntry*)pNewParent, nInsertionPos );
+ else
+ pModel->Copy( (SvListEntry*)pSourceEntry,
+ (SvListEntry*)pNewParent, nInsertionPos );
+ }
+ }
+ else
+ bSuccess = sal_False;
+
+ if( bOk == (sal_Bool)2 ) // HACK: make moved entry visible?
+ MakeVisible( pSourceEntry );
+ }
+ pModel->SetCloneLink( aCloneLink );
+ return bSuccess;
+}
+
+void SvTreeListBox::RemoveSelection()
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ SvTreeEntryList aList;
+ // cache selection, as the implementation deselects everything on the first
+ // remove
+ SvLBoxEntry* pEntry = FirstSelected();
+ while ( pEntry )
+ {
+ aList.push_back( pEntry );
+ if ( pEntry->HasChildren() )
+ // remove deletes all children automatically
+ SelectChildren( pEntry, sal_False );
+ pEntry = NextSelected( pEntry );
+ }
+
+ SvTreeEntryList::iterator it = aList.begin(), itEnd = aList.end();
+ for (; it != itEnd; ++it)
+ {
+ pEntry = static_cast<SvLBoxEntry*>(*it);
+ pModel->Remove(pEntry);
+ }
+}
+
+SvTreeListBox* SvTreeListBox::GetSourceView() const
+{
+ return pDDSource;
+}
+
+void SvTreeListBox::RecalcViewData()
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ SvLBoxEntry* pEntry = First();
+ while( pEntry )
+ {
+ sal_uInt16 nCount = pEntry->ItemCount();
+ sal_uInt16 nCurPos = 0;
+ while ( nCurPos < nCount )
+ {
+ SvLBoxItem* pItem = pEntry->GetItem( nCurPos );
+ pItem->InitViewData( this, pEntry );
+ nCurPos++;
+ }
+ ViewDataInitialized( pEntry );
+ pEntry = Next( pEntry );
+ }
+}
+
+void SvTreeListBox::ViewDataInitialized( SvLBoxEntry* )
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+}
+
+void SvTreeListBox::ImplShowTargetEmphasis( SvLBoxEntry* pEntry, sal_Bool bShow)
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ if ( bShow && (nImpFlags & SVLBOX_TARGEMPH_VIS) )
+ return;
+ if ( !bShow && !(nImpFlags & SVLBOX_TARGEMPH_VIS) )
+ return;
+ ShowTargetEmphasis( pEntry, bShow );
+ if( bShow )
+ nImpFlags |= SVLBOX_TARGEMPH_VIS;
+ else
+ nImpFlags &= ~SVLBOX_TARGEMPH_VIS;
+}
+
+void SvTreeListBox::OnCurrentEntryChanged()
+{
+ if ( !pLBoxImpl->m_bDoingQuickSelection )
+ pLBoxImpl->m_aQuickSelectionEngine.Reset();
+}
+
+SvLBoxEntry* SvTreeListBox::GetEntryFromPath( const ::std::deque< sal_Int32 >& _rPath ) const
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+
+ SvLBoxEntry* pEntry = NULL;
+ SvLBoxEntry* pParent = NULL;
+ for( ::std::deque< sal_Int32 >::const_iterator pItem = _rPath.begin(); pItem != _rPath.end(); ++pItem )
+ {
+ pEntry = GetEntry( pParent, *pItem );
+ if ( !pEntry )
+ break;
+ pParent = pEntry;
+ }
+
+ return pEntry;
+}
+
+void SvTreeListBox::FillEntryPath( SvLBoxEntry* pEntry, ::std::deque< sal_Int32 >& _rPath ) const
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+
+ if ( pEntry )
+ {
+ SvLBoxEntry* pParentEntry = GetParent( pEntry );
+ while ( sal_True )
+ {
+ sal_uLong i, nCount = GetLevelChildCount( pParentEntry );
+ for ( i = 0; i < nCount; ++i )
+ {
+ SvLBoxEntry* pTemp = GetEntry( pParentEntry, i );
+ DBG_ASSERT( pEntry, "invalid entry" );
+ if ( pEntry == pTemp )
+ {
+ _rPath.push_front( (sal_Int32)i );
+ break;
+ }
+ }
+
+ if ( pParentEntry )
+ {
+ pEntry = pParentEntry;
+ pParentEntry = GetParent( pParentEntry );
+ }
+ else
+ break;
+ }
+ }
+}
+
+sal_uLong SvTreeListBox::GetLevelChildCount( SvLBoxEntry* _pParent ) const
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+
+ sal_uLong nCount = 0;
+ SvLBoxEntry* pEntry = FirstChild( _pParent );
+ while ( pEntry )
+ {
+ ++nCount;
+ pEntry = NextSibling( pEntry );
+ }
+
+ return nCount;
+}
+
+SvViewData* SvTreeListBox::CreateViewData( SvListEntry* )
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ SvViewDataEntry* pEntryData = new SvViewDataEntry;
+ return (SvViewData*)pEntryData;
+}
+
+void SvTreeListBox::InitViewData( SvViewData* pData, SvListEntry* pEntry )
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ SvLBoxEntry* pInhEntry = (SvLBoxEntry*)pEntry;
+ SvViewDataEntry* pEntryData = (SvViewDataEntry*)pData;
+
+ pEntryData->pItemData = new SvViewDataItem[ pInhEntry->ItemCount() ];
+ SvViewDataItem* pItemData = pEntryData->pItemData;
+ pEntryData->nItmCnt = pInhEntry->ItemCount(); // number of items to delete
+ sal_uInt16 nCount = pInhEntry->ItemCount();
+ sal_uInt16 nCurPos = 0;
+ while( nCurPos < nCount )
+ {
+ SvLBoxItem* pItem = pInhEntry->GetItem( nCurPos );
+ pItem->InitViewData( this, pInhEntry, pItemData );
+ pItemData++;
+ nCurPos++;
+ }
+}
+
+
+
+void SvTreeListBox::EnableSelectionAsDropTarget( sal_Bool bEnable, sal_Bool bWithChildren )
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ sal_uInt16 nRefDepth;
+ SvLBoxEntry* pTemp;
+
+ SvLBoxEntry* pSelEntry = FirstSelected();
+ while( pSelEntry )
+ {
+ if ( !bEnable )
+ {
+ pSelEntry->nEntryFlags |= SV_ENTRYFLAG_DISABLE_DROP;
+ if ( bWithChildren )
+ {
+ nRefDepth = pModel->GetDepth( pSelEntry );
+ pTemp = Next( pSelEntry );
+ while( pTemp && pModel->GetDepth( pTemp ) > nRefDepth )
+ {
+ pTemp->nEntryFlags |= SV_ENTRYFLAG_DISABLE_DROP;
+ pTemp = Next( pTemp );
+ }
+ }
+ }
+ else
+ {
+ pSelEntry->nEntryFlags &= (~SV_ENTRYFLAG_DISABLE_DROP);
+ if ( bWithChildren )
+ {
+ nRefDepth = pModel->GetDepth( pSelEntry );
+ pTemp = Next( pSelEntry );
+ while( pTemp && pModel->GetDepth( pTemp ) > nRefDepth )
+ {
+ pTemp->nEntryFlags &= (~SV_ENTRYFLAG_DISABLE_DROP);
+ pTemp = Next( pTemp );
+ }
+ }
+ }
+ pSelEntry = NextSelected( pSelEntry );
+ }
+}
+
+// ******************************************************************
+// InplaceEditing
+// ******************************************************************
+
+void SvTreeListBox::EditText( const String& rStr, const Rectangle& rRect,
+ const Selection& rSel )
+{
+ EditText( rStr, rRect, rSel, sal_False );
+}
+
+void SvTreeListBox::EditText( const String& rStr, const Rectangle& rRect,
+ const Selection& rSel, sal_Bool bMulti )
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ if( pEdCtrl )
+ delete pEdCtrl;
+ nImpFlags |= SVLBOX_IN_EDT;
+ nImpFlags &= ~SVLBOX_EDTEND_CALLED;
+ HideFocus();
+ pEdCtrl = new SvInplaceEdit2(
+ this, rRect.TopLeft(), rRect.GetSize(), rStr,
+ LINK( this, SvTreeListBox, TextEditEndedHdl_Impl ),
+ rSel, bMulti );
+}
+
+IMPL_LINK_NOARG(SvTreeListBox, TextEditEndedHdl_Impl)
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ if ( nImpFlags & SVLBOX_EDTEND_CALLED ) // avoid nesting
+ return 0;
+ nImpFlags |= SVLBOX_EDTEND_CALLED;
+ String aStr;
+ if ( !pEdCtrl->EditingCanceled() )
+ aStr = pEdCtrl->GetText();
+ else
+ aStr = pEdCtrl->GetSavedValue();
+ if ( IsEmptyTextAllowed() || aStr.Len() > 0 )
+ EditedText( aStr );
+ // Hide may only be called after the new text was put into the entry, so
+ // that we don't call the selection handler in the GetFocus of the listbox
+ // with the old entry text.
+ pEdCtrl->Hide();
+ // delete pEdCtrl;
+ // pEdCtrl = 0;
+ nImpFlags &= (~SVLBOX_IN_EDT);
+ GrabFocus();
+ return 0;
+}
+
+void SvTreeListBox::CancelTextEditing()
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ if ( pEdCtrl )
+ pEdCtrl->StopEditing( sal_True );
+ nImpFlags &= (~SVLBOX_IN_EDT);
+}
+
+void SvTreeListBox::EndEditing( bool bCancel )
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ if( pEdCtrl )
+ pEdCtrl->StopEditing( bCancel );
+ nImpFlags &= (~SVLBOX_IN_EDT);
+}
+
+
+bool SvTreeListBox::IsEmptyTextAllowed() const
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ return pLBoxImpl->m_bIsEmptyTextAllowed;
+}
+
+void SvTreeListBox::ForbidEmptyText()
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ pLBoxImpl->m_bIsEmptyTextAllowed = false;
+}
+
+SvLBoxEntry* SvTreeListBox::CreateEntry() const
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ return new SvLBoxEntry;
+}
+
+const void* SvTreeListBox::FirstSearchEntry( String& _rEntryText ) const
+{
+ SvLBoxEntry* pEntry = GetCurEntry();
+ if ( pEntry )
+ pEntry = const_cast< SvLBoxEntry* >( static_cast< const SvLBoxEntry* >( NextSearchEntry( pEntry, _rEntryText ) ) );
+ else
+ {
+ pEntry = FirstSelected();
+ if ( !pEntry )
+ pEntry = First();
+ }
+
+ if ( pEntry )
+ _rEntryText = GetEntryText( pEntry );
+
+ return pEntry;
+}
+
+const void* SvTreeListBox::NextSearchEntry( const void* _pCurrentSearchEntry, String& _rEntryText ) const
+{
+ SvLBoxEntry* pEntry = const_cast< SvLBoxEntry* >( static_cast< const SvLBoxEntry* >( _pCurrentSearchEntry ) );
+
+ if ( ( ( GetChildCount( pEntry ) > 0 )
+ || ( pEntry->HasChildrenOnDemand() )
+ )
+ && !IsExpanded( pEntry )
+ )
+ {
+ pEntry = NextSibling( pEntry );
+ }
+ else
+ {
+ pEntry = Next( pEntry );
+ }
+
+ if ( !pEntry )
+ pEntry = First();
+
+ if ( pEntry )
+ _rEntryText = GetEntryText( pEntry );
+
+ return pEntry;
+}
+
+void SvTreeListBox::SelectSearchEntry( const void* _pEntry )
+{
+ SvLBoxEntry* pEntry = const_cast< SvLBoxEntry* >( static_cast< const SvLBoxEntry* >( _pEntry ) );
+ DBG_ASSERT( pEntry, "SvTreeListBox::SelectSearchEntry: invalid entry!" );
+ if ( !pEntry )
+ return;
+
+ SelectAll( sal_False );
+ SetCurEntry( pEntry );
+ Select( pEntry );
+}
+
+void SvTreeListBox::ExecuteSearchEntry( const void* /*_pEntry*/ ) const
+{
+ // nothing to do here, we have no "execution"
+}
+
+::vcl::StringEntryIdentifier SvTreeListBox::CurrentEntry( String& _out_entryText ) const
+{
+ // always accept the current entry if there is one
+ SvLBoxEntry* pCurrentEntry( GetCurEntry() );
+ if ( pCurrentEntry )
+ {
+ _out_entryText = GetEntryText( pCurrentEntry );
+ return pCurrentEntry;
+ }
+ return FirstSearchEntry( _out_entryText );
+}
+
+::vcl::StringEntryIdentifier SvTreeListBox::NextEntry( ::vcl::StringEntryIdentifier _currentEntry, String& _out_entryText ) const
+{
+ return NextSearchEntry( _currentEntry, _out_entryText );
+}
+
+void SvTreeListBox::SelectEntry( ::vcl::StringEntryIdentifier _entry )
+{
+ SelectSearchEntry( _entry );
+}
+
+bool SvTreeListBox::HandleKeyInput( const KeyEvent& _rKEvt )
+{
+ if ( IsEntryMnemonicsEnabled()
+ && pLBoxImpl->m_aMnemonicEngine.HandleKeyEvent( _rKEvt )
+ )
+ return true;
+
+ if ( ( GetStyle() & WB_QUICK_SEARCH ) != 0 )
+ {
+ pLBoxImpl->m_bDoingQuickSelection = true;
+ const bool bHandled = pLBoxImpl->m_aQuickSelectionEngine.HandleKeyEvent( _rKEvt );
+ pLBoxImpl->m_bDoingQuickSelection = false;
+ if ( bHandled )
+ return true;
+ }
+
+ return false;
+}
+
+void SvTreeListBox::WriteDragServerInfo( const Point&, SvLBoxDDInfo* )
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+}
+
+void SvTreeListBox::ReadDragServerInfo(const Point&, SvLBoxDDInfo* )
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+}
+
+sal_Bool SvTreeListBox::EditingCanceled() const
+{
+ if( pEdCtrl && pEdCtrl->EditingCanceled() )
+ return sal_True;
+ return sal_False;
+}
+
+
+//JP 28.3.2001: new Drag & Drop API
+sal_Int8 SvTreeListBox::AcceptDrop( const AcceptDropEvent& rEvt )
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ sal_Int8 nRet = DND_ACTION_NONE;
+
+ if( rEvt.mbLeaving || !CheckDragAndDropMode( pDDSource, rEvt.mnAction ) )
+ {
+ ImplShowTargetEmphasis( pTargetEntry, sal_False );
+ }
+ else if( !nDragDropMode )
+ {
+ SAL_WARN( "svtools.contnr", "SvTreeListBox::QueryDrop(): no target" );
+ }
+ else
+ {
+ SvLBoxEntry* pEntry = GetDropTarget( rEvt.maPosPixel );
+ if( !IsDropFormatSupported( SOT_FORMATSTR_ID_TREELISTBOX ) )
+ {
+ SAL_WARN( "svtools.contnr", "SvTreeListBox::QueryDrop(): no format" );
+ }
+ else
+ {
+ DBG_ASSERT( pDDSource, "SvTreeListBox::QueryDrop(): SourceBox == 0" );
+ if( !( pEntry && pDDSource->GetModel() == this->GetModel()
+ && DND_ACTION_MOVE == rEvt.mnAction
+ && ( pEntry->nEntryFlags & SV_ENTRYFLAG_DISABLE_DROP ) ))
+ {
+ if( NotifyAcceptDrop( pEntry ))
+ nRet = rEvt.mnAction;
+ }
+ }
+
+ // **** draw emphasis ****
+ if( DND_ACTION_NONE == nRet )
+ ImplShowTargetEmphasis( pTargetEntry, sal_False );
+ else if( pEntry != pTargetEntry || !(nImpFlags & SVLBOX_TARGEMPH_VIS) )
+ {
+ ImplShowTargetEmphasis( pTargetEntry, sal_False );
+ pTargetEntry = pEntry;
+ ImplShowTargetEmphasis( pTargetEntry, sal_True );
+ }
+ }
+ return nRet;
+}
+
+sal_Int8 SvTreeListBox::ExecuteDrop( const ExecuteDropEvent& rEvt, SvTreeListBox* pSourceView )
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ sal_Int8 nRet = DND_ACTION_NONE;
+
+ DBG_ASSERT( pSourceView, "SvTreeListBox::ExecuteDrop(): no source view" );
+ pSourceView->EnableSelectionAsDropTarget( sal_True, sal_True );
+
+ ImplShowTargetEmphasis( pTargetEntry, sal_False );
+ pDDTarget = this;
+
+ SvLBoxDDInfo aDDInfo;
+
+ TransferableDataHelper aData( rEvt.maDropEvent.Transferable );
+ if( aData.HasFormat( SOT_FORMATSTR_ID_TREELISTBOX ))
+ {
+ ::com::sun::star::uno::Sequence< sal_Int8 > aSeq;
+ if( aData.GetSequence( SOT_FORMATSTR_ID_TREELISTBOX, aSeq ) &&
+ sizeof(SvLBoxDDInfo) == aSeq.getLength() )
+ {
+ memcpy( &aDDInfo, aSeq.getConstArray(), sizeof(SvLBoxDDInfo) );
+ nRet = rEvt.mnAction;
+ }
+ }
+
+ if( DND_ACTION_NONE != nRet )
+ {
+ nRet = DND_ACTION_NONE;
+
+ ReadDragServerInfo( rEvt.maPosPixel, &aDDInfo );
+
+ SvLBoxEntry* pTarget = pTargetEntry; // may be 0!
+
+ if( DND_ACTION_COPY == rEvt.mnAction )
+ {
+ if ( CopySelection( aDDInfo.pSource, pTarget ) )
+ nRet = rEvt.mnAction;
+ }
+ else if( DND_ACTION_MOVE == rEvt.mnAction )
+ {
+ if ( MoveSelection( aDDInfo.pSource, pTarget ) )
+ nRet = rEvt.mnAction;
+ }
+ else if( DND_ACTION_COPYMOVE == rEvt.mnAction )
+ {
+ if ( MoveSelectionCopyFallbackPossible( aDDInfo.pSource, pTarget, sal_True ) )
+ nRet = rEvt.mnAction;
+ }
+ }
+ return nRet;
+}
+
+sal_Int8 SvTreeListBox::ExecuteDrop( const ExecuteDropEvent& rEvt )
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ return ExecuteDrop( rEvt, GetSourceView() );
+}
+
+void SvTreeListBox::StartDrag( sal_Int8, const Point& rPosPixel )
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+
+ Point aEventPos( rPosPixel );
+ MouseEvent aMouseEvt( aEventPos, 1, MOUSE_SELECT, MOUSE_LEFT );
+ MouseButtonUp( aMouseEvt );
+
+ nOldDragMode = GetDragDropMode();
+ if ( !nOldDragMode )
+ return;
+
+ ReleaseMouse();
+
+ SvLBoxEntry* pEntry = GetEntry( rPosPixel ); // GetDropTarget( rPos );
+ if( !pEntry )
+ {
+ DragFinished( DND_ACTION_NONE );
+ return;
+ }
+
+ TransferDataContainer* pContainer = new TransferDataContainer;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::datatransfer::XTransferable > xRef( pContainer );
+
+ nDragDropMode = NotifyStartDrag( *pContainer, pEntry );
+ if( !nDragDropMode || 0 == GetSelectionCount() )
+ {
+ nDragDropMode = nOldDragMode;
+ DragFinished( DND_ACTION_NONE );
+ return;
+ }
+
+ SvLBoxDDInfo aDDInfo;
+ memset(&aDDInfo,0,sizeof(SvLBoxDDInfo));
+ aDDInfo.pApp = GetpApp();
+ aDDInfo.pSource = this;
+ aDDInfo.pDDStartEntry = pEntry;
+ // let derived views do their thing
+ WriteDragServerInfo( rPosPixel, &aDDInfo );
+
+ pContainer->CopyAnyData( SOT_FORMATSTR_ID_TREELISTBOX,
+ (sal_Char*)&aDDInfo, sizeof(SvLBoxDDInfo) );
+ pDDSource = this;
+ pDDTarget = 0;
+
+ sal_Bool bOldUpdateMode = Control::IsUpdateMode();
+ Control::SetUpdateMode( sal_True );
+ Update();
+ Control::SetUpdateMode( bOldUpdateMode );
+
+ // Disallow using the selection and its children as drop targets.
+ // Important: If the selection of the SourceListBox is changed in the
+ // DropHandler, the entries have to be allowed as drop targets again:
+ // (GetSourceListBox()->EnableSelectionAsDropTarget( sal_True, sal_True );)
+ EnableSelectionAsDropTarget( sal_False, sal_True /* with children */ );
+
+ pContainer->StartDrag( this, nDragOptions, GetDragFinishedHdl() );
+}
+
+void SvTreeListBox::DragFinished( sal_Int8
+#ifndef UNX
+nAction
+#endif
+)
+{
+ EnableSelectionAsDropTarget( sal_True, sal_True );
+
+#ifndef UNX
+ if( (nAction == DND_ACTION_MOVE) && ( (pDDTarget &&
+ ((sal_uLong)(pDDTarget->GetModel())!=(sal_uLong)(this->GetModel()))) ||
+ !pDDTarget ))
+ {
+ RemoveSelection();
+ }
+#endif
+
+ ImplShowTargetEmphasis( pTargetEntry, sal_False );
+ pDDSource = 0;
+ pDDTarget = 0;
+ pTargetEntry = 0;
+ nDragDropMode = nOldDragMode;
+}
+
+DragDropMode SvTreeListBox::NotifyStartDrag( TransferDataContainer&, SvLBoxEntry* )
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ return (DragDropMode)0xffff;
+}
+
+sal_Bool SvTreeListBox::NotifyAcceptDrop( SvLBoxEntry* )
+{
+ DBG_CHKTHIS(SvTreeListBox,0);
+ return sal_True;
+}
+
+// Handler and methods for Drag - finished handler.
+// The with get GetDragFinishedHdl() get link can set on the
+// TransferDataContainer. This link is a callback for the DragFinished
+// call. AddBox method is called from the GetDragFinishedHdl() and the
+// remove is called in link callback and in the destructor. So it can't
+// called to a deleted object.
+
+namespace
+{
+ struct SortLBoxes : public rtl::Static<std::set<sal_uLong>, SortLBoxes> {};
+}
+
+void SvTreeListBox::AddBoxToDDList_Impl( const SvTreeListBox& rB )
+{
+ sal_uLong nVal = (sal_uLong)&rB;
+ SortLBoxes::get().insert( nVal );
+}
+
+void SvTreeListBox::RemoveBoxFromDDList_Impl( const SvTreeListBox& rB )
+{
+ sal_uLong nVal = (sal_uLong)&rB;
+ SortLBoxes::get().erase( nVal );
+}
+
+IMPL_STATIC_LINK( SvTreeListBox, DragFinishHdl_Impl, sal_Int8*, pAction )
+{
+ sal_uLong nVal = (sal_uLong)pThis;
+ std::set<sal_uLong> &rSortLBoxes = SortLBoxes::get();
+ std::set<sal_uLong>::const_iterator it = rSortLBoxes.find(nVal);
+ if( it != rSortLBoxes.end() )
+ {
+ pThis->DragFinished( *pAction );
+ rSortLBoxes.erase( it );
+ }
+ return 0;
+}
+
+Link SvTreeListBox::GetDragFinishedHdl() const
+{
+ AddBoxToDDList_Impl( *this );
+ return STATIC_LINK( this, SvTreeListBox, DragFinishHdl_Impl );
+}
+
+// --- boundary of former SvLBox ---
+
+/*
+ Bugs/TODO
+
+ - calculate rectangle when editing in-place (bug with some fonts)
+ - SetSpaceBetweenEntries: offset is not taken into account in SetEntryHeight
+*/
+
+#define TREEFLAG_FIXEDHEIGHT 0x0010
+
+
+DBG_NAME(SvTreeListBox)
+
+#define SV_LBOX_DEFAULT_INDENT_PIXEL 20
+
void SvTreeListBox::InitTreeView()
{
DBG_CHKTHIS(SvTreeListBox,0);
@@ -110,6 +1654,24 @@ void SvTreeListBox::InitTreeView()
SvTreeListBox::~SvTreeListBox()
{
DBG_DTOR(SvTreeListBox,0);
+ delete pEdCtrl;
+ pEdCtrl = 0;
+ pModel->RemoveView( this );
+ if ( pModel->GetRefCount() == 0 )
+ {
+ pModel->Clear();
+ delete pModel;
+ pModel = NULL;
+ }
+
+ SvTreeListBox::RemoveBoxFromDDList_Impl( *this );
+
+ if( this == pDDSource )
+ pDDSource = 0;
+ if( this == pDDTarget )
+ pDDTarget = 0;
+ delete pLBoxImpl;
+
pImp->CallEventListeners( VCLEVENT_OBJECT_DYING );
delete pImp;
delete pLBoxImpl->m_pLink;
@@ -125,13 +1687,25 @@ void SvTreeListBox::SetModel( SvLBoxTreeList* pNewModel )
{
DBG_CHKTHIS(SvTreeListBox,0);
pImp->SetModel( pNewModel );
- SvLBox::SetModel( pNewModel );
+
+ // does the CleanUp
+ SvListView::SetModel( pNewModel );
+ pModel->SetCloneLink( LINK(this, SvTreeListBox, CloneHdl_Impl ));
+ SvLBoxEntry* pEntry = First();
+ while( pEntry )
+ {
+ ModelHasInserted( pEntry );
+ pEntry = Next( pEntry );
+ }
}
void SvTreeListBox::DisconnectFromModel()
{
DBG_CHKTHIS(SvTreeListBox,0);
- SvLBox::DisconnectFromModel();
+ SvLBoxTreeList* pNewModel = new SvLBoxTreeList;
+ pNewModel->SetRefCount( 0 ); // else this will never be deleted
+ SvListView::SetModel( pNewModel );
+
pImp->SetModel( GetModel() );
}
@@ -157,7 +1731,9 @@ void SvTreeListBox::Resize()
DBG_CHKTHIS(SvTreeListBox,0);
if( IsEditingActive() )
EndEditing( sal_True );
- SvLBox::Resize();
+
+ Control::Resize();
+
pImp->Resize();
nFocusWidth = -1;
pImp->ShowCursor( sal_False );
@@ -399,9 +1975,9 @@ SvLBoxEntry* SvTreeListBox::InsertEntry(
pEntry->EnableChildrenOnDemand( bChildrenOnDemand );
if( !pParent )
- SvLBox::Insert( pEntry, nPos );
+ Insert( pEntry, nPos );
else
- SvLBox::Insert( pEntry, pParent, nPos );
+ Insert( pEntry, pParent, nPos );
aPrevInsertedExpBmp = rDefExpBmp;
aPrevInsertedColBmp = rDefColBmp;
@@ -429,9 +2005,9 @@ SvLBoxEntry* SvTreeListBox::InsertEntry( const XubString& aText,
pEntry->EnableChildrenOnDemand( bChildrenOnDemand );
if( !pParent )
- SvLBox::Insert( pEntry, nPos );
+ Insert( pEntry, nPos );
else
- SvLBox::Insert( pEntry, pParent, nPos );
+ Insert( pEntry, pParent, nPos );
aPrevInsertedExpBmp = aExpEntryBmp;
aPrevInsertedColBmp = aCollEntryBmp;
@@ -718,10 +2294,13 @@ sal_Bool SvTreeListBox::EditedEntry( SvLBoxEntry* /*pEntry*/,const rtl::OUString
return sal_True;
}
-void SvTreeListBox::EnableInplaceEditing( sal_Bool bOn )
+void SvTreeListBox::EnableInplaceEditing( bool bOn )
{
DBG_CHKTHIS(SvTreeListBox,0);
- SvLBox::EnableInplaceEditing( bOn );
+ if (bOn)
+ nImpFlags |= SVLBOX_EDT_ENABLED;
+ else
+ nImpFlags &= ~SVLBOX_EDT_ENABLED;
}
void SvTreeListBox::KeyInput( const KeyEvent& rKEvt )
@@ -748,7 +2327,11 @@ void SvTreeListBox::KeyInput( const KeyEvent& rKEvt )
#endif
if( !pImp->KeyInput( rKEvt ) )
- SvLBox::KeyInput( rKEvt );
+ {
+ bool bHandled = HandleKeyInput( rKEvt );
+ if ( !bHandled )
+ Control::KeyInput( rKEvt );
+ }
nImpFlags &= ~SVLBOX_IS_TRAVELSELECT;
}
@@ -764,7 +2347,7 @@ void SvTreeListBox::GetFocus()
{
DBG_CHKTHIS(SvTreeListBox,0);
pImp->GetFocus();
- SvLBox::GetFocus();
+ Control::GetFocus();
SvLBoxEntry* pEntry = FirstSelected();
if ( pEntry )
@@ -776,7 +2359,7 @@ void SvTreeListBox::LoseFocus()
{
DBG_CHKTHIS(SvTreeListBox,0);
pImp->LoseFocus();
- SvLBox::LoseFocus();
+ Control::LoseFocus();
}
void SvTreeListBox::ModelHasCleared()
@@ -798,10 +2381,10 @@ void SvTreeListBox::ModelHasCleared()
AdjustEntryHeight( GetDefaultExpandedEntryBmp() );
AdjustEntryHeight( GetDefaultCollapsedEntryBmp() );
- SvLBox::ModelHasCleared();
+ SvListView::ModelHasCleared();
}
-void SvTreeListBox::ShowTargetEmphasis( SvLBoxEntry* pEntry, sal_Bool /* bShow */ )
+void SvTreeListBox::ShowTargetEmphasis( SvLBoxEntry* pEntry, sal_Bool /*bShow*/ )
{
DBG_CHKTHIS(SvTreeListBox,0);
pImp->PaintDDCursor( pEntry );
@@ -845,14 +2428,14 @@ void SvTreeListBox::ScrollToAbsPos( long nPos )
void SvTreeListBox::SetSelectionMode( SelectionMode eSelectMode )
{
DBG_CHKTHIS(SvTreeListBox,0);
- SvLBox::SetSelectionMode( eSelectMode );
+ eSelMode = eSelectMode;
pImp->SetSelectionMode( eSelectMode );
}
void SvTreeListBox::SetDragDropMode( DragDropMode nDDMode )
{
DBG_CHKTHIS(SvTreeListBox,0);
- SvLBox::SetDragDropMode( nDDMode );
+ nDragDropMode = nDDMode;
pImp->SetDragDropMode( nDDMode );
}
@@ -895,7 +2478,7 @@ void SvTreeListBox::SetEntryHeight( SvLBoxEntry* pEntry )
if( nHeightMax > nEntryHeight )
{
nEntryHeight = nHeightMax;
- SvLBox::SetFont( GetFont() );
+ Control::SetFont( GetFont() );
pImp->SetEntryHeight( nHeightMax );
}
}
@@ -911,7 +2494,7 @@ void SvTreeListBox::SetEntryHeight( short nHeight, sal_Bool bAlways )
nTreeFlags |= TREEFLAG_FIXEDHEIGHT;
else
nTreeFlags &= ~TREEFLAG_FIXEDHEIGHT;
- SvLBox::SetFont( GetFont() );
+ Control::SetFont( GetFont() );
pImp->SetEntryHeight( nHeight );
}
}
@@ -1138,7 +2721,7 @@ void SvTreeListBox::SetFont( const Font& rFont )
void SvTreeListBox::Paint( const Rectangle& rRect )
{
DBG_CHKTHIS(SvTreeListBox,0);
- SvLBox::Paint( rRect );
+ Control::Paint( rRect );
if( nTreeFlags & TREEFLAG_RECALCTABS )
SetTabs();
pImp->Paint( rRect );
@@ -1223,8 +2806,15 @@ void SvTreeListBox::MakeVisible( SvLBoxEntry* pEntry, sal_Bool bMoveToTop )
void SvTreeListBox::ModelHasEntryInvalidated( SvListEntry* pEntry )
{
DBG_CHKTHIS(SvTreeListBox,0);
+
// reinitialize the separate items of the entries
- SvLBox::ModelHasEntryInvalidated( pEntry );
+ sal_uInt16 nCount = ((SvLBoxEntry*)pEntry)->ItemCount();
+ for( sal_uInt16 nIdx = 0; nIdx < nCount; nIdx++ )
+ {
+ SvLBoxItem* pItem = ((SvLBoxEntry*)pEntry)->GetItem( nIdx );
+ pItem->InitViewData( this, (SvLBoxEntry*)pEntry, 0 );
+ }
+
// repaint
pImp->InvalidateEntry( (SvLBoxEntry*)pEntry );
}
@@ -1370,15 +2960,13 @@ void SvTreeListBox::EditingRequest( SvLBoxEntry* pEntry, SvLBoxItem* pItem,
}
}
-
-
SvLBoxEntry* SvTreeListBox::GetDropTarget( const Point& rPos )
{
DBG_CHKTHIS(SvTreeListBox,0);
// scroll
if( rPos.Y() < 12 )
{
- SvLBox::ImplShowTargetEmphasis( SvLBox::pTargetEntry, sal_False );
+ ImplShowTargetEmphasis(pTargetEntry, false);
ScrollOutputArea( +1 );
}
else
@@ -1386,7 +2974,7 @@ SvLBoxEntry* SvTreeListBox::GetDropTarget( const Point& rPos )
Size aSize( pImp->GetOutputSize() );
if( rPos.Y() > aSize.Height() - 12 )
{
- SvLBox::ImplShowTargetEmphasis( SvLBox::pTargetEntry, sal_False );
+ ImplShowTargetEmphasis(pTargetEntry, false);
ScrollOutputArea( -1 );
}
}
@@ -2064,7 +3652,7 @@ void SvTreeListBox::Invalidate( sal_uInt16 nInvalidateFlags )
// after painting
pImp->RecalcFocusRect();
NotifyInvalidating();
- SvLBox::Invalidate( nInvalidateFlags );
+ Control::Invalidate( nInvalidateFlags );
pImp->Invalidate();
}
@@ -2076,7 +3664,7 @@ void SvTreeListBox::Invalidate( const Rectangle& rRect, sal_uInt16 nInvalidateFl
// after painting
pImp->RecalcFocusRect();
NotifyInvalidating();
- SvLBox::Invalidate( rRect, nInvalidateFlags );
+ Control::Invalidate( rRect, nInvalidateFlags );
}
@@ -2186,7 +3774,7 @@ SvLBoxTab* SvTreeListBox::GetLastTab( sal_uInt16 nFlagMask, sal_uInt16& rTabPos
void SvTreeListBox::RequestHelp( const HelpEvent& rHEvt )
{
if( !pImp->RequestHelp( rHEvt ) )
- SvLBox::RequestHelp( rHEvt );
+ Control::RequestHelp( rHEvt );
}
void SvTreeListBox::CursorMoved( SvLBoxEntry* )
@@ -2209,7 +3797,7 @@ void SvTreeListBox::ModelNotification( sal_uInt16 nActionId, SvListEntry* pEntry
if( nActionId == LISTACTION_CLEARING )
CancelTextEditing();
- SvLBox::ModelNotification( nActionId, pEntry1, pEntry2, nPos );
+ SvListView::ModelNotification( nActionId, pEntry1, pEntry2, nPos );
switch( nActionId )
{
case LISTACTION_INSERTED:
@@ -2337,10 +3925,14 @@ void SvTreeListBox::DataChanged( const DataChangedEvent& rDCEvt )
Control::DataChanged( rDCEvt );
}
-void SvTreeListBox::StateChanged( StateChangedType i_nStateChange )
+void SvTreeListBox::StateChanged( StateChangedType eType )
{
- SvLBox::StateChanged( i_nStateChange );
- if ( i_nStateChange == STATE_CHANGE_STYLE )
+ if( eType == STATE_CHANGE_ENABLE )
+ Invalidate( INVALIDATE_CHILDREN );
+
+ Control::StateChanged( eType );
+
+ if ( eType == STATE_CHANGE_STYLE )
ImplInitStyle();
}
@@ -2486,9 +4078,8 @@ void SvTreeListBox::CallImplEventListeners(sal_uLong nEvent, void* pData)
CallEventListeners(nEvent, pData);
}
-void SvTreeListBox::FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& rStateSet ) const
+void SvTreeListBox::FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& /*rStateSet*/ ) const
{
- SvLBox::FillAccessibleStateSet( rStateSet );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/uno/treecontrolpeer.cxx b/svtools/source/uno/treecontrolpeer.cxx
index 8e77362b08f3..3e8648ccad95 100644
--- a/svtools/source/uno/treecontrolpeer.cxx
+++ b/svtools/source/uno/treecontrolpeer.cxx
@@ -27,7 +27,6 @@
************************************************************************/
-#define _SVTREEBX_CXX
#include <com/sun/star/graphic/GraphicProvider.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
@@ -42,7 +41,8 @@
#include <rtl/ref.hxx>
#include <vcl/graph.hxx>
#include <vcl/svapp.hxx>
-#include <svtools/svtreebx.hxx>
+#include <svtools/treelistbox.hxx>
+#include <svtools/svlbitm.hxx>
#include <map>
@@ -118,12 +118,12 @@ public:
UnoTreeListItem( SvLBoxEntry* );
UnoTreeListItem();
virtual ~UnoTreeListItem();
- void InitViewData( SvLBox*,SvLBoxEntry*,SvViewDataItem* );
+ void InitViewData( SvTreeListBox*,SvLBoxEntry*,SvViewDataItem* );
Image GetImage() const;
void SetImage( const Image& rImage );
OUString GetGraphicURL() const;
void SetGraphicURL( const OUString& rGraphicURL );
- void Paint( const Point&, SvLBox& rDev, sal_uInt16 nFlags,SvLBoxEntry* );
+ void Paint( const Point&, SvTreeListBox& rDev, sal_uInt16 nFlags,SvLBoxEntry* );
SvLBoxItem* Create() const;
void Clone( SvLBoxItem* pSource );
@@ -1608,7 +1608,7 @@ UnoTreeListItem::~UnoTreeListItem()
// --------------------------------------------------------------------
-void UnoTreeListItem::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 /* nFlags */, SvLBoxEntry* _pEntry)
+void UnoTreeListItem::Paint( const Point& rPos, SvTreeListBox& rDev, sal_uInt16 /* nFlags */, SvLBoxEntry* _pEntry)
{
Point aPos( rPos );
if( _pEntry )
@@ -1676,7 +1676,7 @@ void UnoTreeListItem::SetGraphicURL( const OUString& rGraphicURL )
// --------------------------------------------------------------------
-void UnoTreeListItem::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry, SvViewDataItem* pViewData)
+void UnoTreeListItem::InitViewData( SvTreeListBox* pView,SvLBoxEntry* pEntry, SvViewDataItem* pViewData)
{
if( !pViewData )
pViewData = pView->GetViewDataItem( pEntry, this );
diff --git a/svtools/source/uno/unoiface.cxx b/svtools/source/uno/unoiface.cxx
index cdb58e639bb9..cd1688c392dc 100644
--- a/svtools/source/uno/unoiface.cxx
+++ b/svtools/source/uno/unoiface.cxx
@@ -44,7 +44,7 @@
#include <svl/numuno.hxx>
#include <svtools/calendar.hxx>
#include <svtools/prgsbar.hxx>
-#include <svtools/svtreebx.hxx>
+#include <svtools/treelistbox.hxx>
#include "treecontrolpeer.hxx"
#include "svtxgridcontrol.hxx"
#include <svtools/table/tablecontrol.hxx>