/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: cfgtreelstbox.hxx,v $
 *
 *  $Revision: 1.5 $
 *
 *  last change: $Author: rt $ $Date: 2006/10/27 19:33:58 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library 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 for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#ifndef _SFXCFGTREELSTBOX_HXX
#define _SFXCFGTREELSTBOX_HXX

#ifndef _SV_LSTBOX_HXX //autogen
#include <vcl/lstbox.hxx>
#endif
#ifndef _SV_FIXED_HXX //autogen
#include <vcl/fixed.hxx>
#endif
#ifndef _SV_GROUP_HXX //autogen
#include <vcl/group.hxx>
#endif
#ifndef _SVTABBX_HXX //autogen
#include <svtools/svtabbx.hxx>
#endif
#ifndef _SVTREEBOX_HXX //autogen
#include <svtools/svtreebx.hxx>
#endif
#ifndef _TOOLBOX_HXX //autogen
#include <vcl/toolbox.hxx>
#endif

#define _SVSTDARR_USHORTS
#define _SVSTDARR_STRINGSDTOR
#include <svtools/svstdarr.hxx>		// SvUShorts
namespace binfilter {

#define SFX_CFGGROUP_FUNCTION 1
#define SFX_CFGGROUP_BASICMGR 2
#define SFX_CFGGROUP_DOCBASICMGR 3
#define SFX_CFGGROUP_BASICLIB 4
#define SFX_CFGGROUP_BASICMOD 5
#define SFX_CFGFUNCTION_MACRO 6
#define SFX_CFGFUNCTION_SLOT  7
#define SFX_CFGFUNCTION_SEPARATOR 8
#define SFX_CFGFUNCTION_SPACE 9

#define IBX_FUNCTION_ALREADY_IN_TOOLBOX	(RID_SFX_DIALOG_START + 104 )

class SfxMacroInfoArr_Impl;
class SfxMacroInfoItem;
class SfxMacroInfo;
class SfxConfigManager;

struct SfxCfgGroupInfo_Impl
{
	USHORT 		nKind;
	USHORT 		nOrd;
	void*		pObject;
	BOOL		bWasOpened;

				SfxCfgGroupInfo_Impl( USHORT n, USHORT nr, void* pObj = 0 ) :
					nKind( n ), nOrd( nr ), pObject( pObj ), bWasOpened(FALSE) {}
};

typedef SfxCfgGroupInfo_Impl* SfxCfgGroupInfoPtr;

class SfxSlotPool;
class SfxBindings;

struct SfxToolbarEntryInfo_Impl
{
	BOOL			bVisible;
	USHORT 			nId;
	ToolBoxItemType	nKind;
	SfxMacroInfo*	pMacroInfo;

	SfxToolbarEntryInfo_Impl( ToolBoxItemType n, USHORT nID, BOOL bVis = TRUE, SfxMacroInfo* pInfo = 0 ) : 
		nKind( n ), nId( nID ), bVisible( bVis ), pMacroInfo( pInfo ) {}
};

typedef SfxToolbarEntryInfo_Impl* SfxToolbarEntryInfoPtr;
SV_DECL_PTRARR_DEL(SfxToolbarEntryInfoArr_Impl, SfxToolbarEntryInfoPtr, 5, 5)//STRIP008 ;

class SfxToolBoxManager;
class SfxBindings;
class SfxInterface;
class SfxToolbarTreeListBox_Impl : public SvTreeListBox
{
	Timer							m_aTimer;
	SvLBox*							m_pSVLBoxFunctions;
	SvLBoxEntry*					m_pCurEntry;
	SfxToolbarEntryInfoArr_Impl		m_aArr;
	SfxToolBoxManager*				m_pTbxMgr;
	SfxBindings*					m_pBindings;
	SfxInterface*					m_pIFace;
	BOOL							m_bDragSource;
	Size							m_aCheckBoxImageSizePixel;
	String							m_aSeparator;
	String							m_aSpace;
	Link							m_aChangedListener;
	SvLBoxButtonData*				m_pButtonData;
	BOOL							m_bHiContrastMode;

	DECL_LINK(						TimerHdl, Timer* );
	DECL_LINK(						AsyncInfoMsg, String* );

	virtual void 					MouseMove( const MouseEvent& rMEvt );
	virtual void					KeyInput( const KeyEvent& rKEvt );
	void							CommitChanges();
	USHORT							FindToolBoxPosition( const ToolBox& rToolBox, ULONG nPos );

protected:
	// new d&d
	virtual DragDropMode			NotifyStartDrag( TransferDataContainer&, SvLBoxEntry* );
	virtual BOOL					NotifyAcceptDrop( SvLBoxEntry* );
	virtual sal_Int8				AcceptDrop( const AcceptDropEvent& rEvt );
	virtual sal_Int8				ExecuteDrop( const ExecuteDropEvent& rEvt );
	virtual void					DragFinished( sal_Int8 nDropAction );
	virtual BOOL					NotifyMoving( SvLBoxEntry*  pTarget,
												  SvLBoxEntry*  pEntry,
												  SvLBoxEntry*& rpNewParent,
												  ULONG&		rNewChildPos );
	virtual BOOL					NotifyCopying( SvLBoxEntry*  pTarget,		 
												   SvLBoxEntry*  pEntry,		 
												   SvLBoxEntry*& rpNewParent,   
												   ULONG&        rNewChildPos );
	virtual void					CheckButtonHdl();
	virtual void					InitEntry( SvLBoxEntry*, const XubString&, const Image&, const Image& );
	virtual void					DataChanged( const DataChangedEvent& rDCEvt );
	void							BuildCheckBoxButtonImages( SvLBoxButtonData* );
	Image							GetSizedImage( VirtualDevice& aDev, const Size& aNewSize, const Image& aImage );

public:
									SfxToolbarTreeListBox_Impl ( Window* pParent, const ResId&, SfxBindings* pBindings );
									~SfxToolbarTreeListBox_Impl();
	
	void							Init( SfxToolBoxManager*, SfxInterface* pIFace, SfxSlotPool* pSlotPool = 0 );
	void							SetChangedListener( const Link& aChangedListener ) { m_aChangedListener = aChangedListener; }
	const Link&						GetChangedListener() const { return m_aChangedListener; }
	void							SetDragSourcePartner( SvLBox* pDragSourcePartner ) { m_pSVLBoxFunctions = pDragSourcePartner; }
	void							ClearAll();

	Size							GetCheckBoxPixelSize() const { return m_aCheckBoxImageSizePixel; }
	BOOL							RemoveItem( SvLBoxEntry* pEntry );
	BOOL							AddFunction( SvLBoxEntry* pEntry, USHORT nKind, USHORT nId, SfxMacroInfo* pMacroInfo, BOOL bFront = FALSE);
	void							AddSeparator( SvLBoxEntry* pEntry, ToolBoxItemType nType, BOOL bFront = FALSE );
	void							MoveUpCurEntry();
	void							MoveDownCurEntry();

	BOOL							GetPos( ULONG& nPos, SvLBoxEntry* pEntry );
	USHORT							GetId( SvLBoxEntry *pEntry );
	String							GetHelpText( SvLBoxEntry *pEntry );
	USHORT							GetCurId()
									{ return GetId( FirstSelected() ); }
};


}//end of namespace binfilter
#endif // _SFXCFGTREELSTBOX_HXX
