2010-10-27 12:33:13 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-14 17:39:53 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2004-08-02 14:57:37 +00:00
|
|
|
#ifndef DBAUI_DBTREELISTBOX_HXX
|
|
|
|
#define DBAUI_DBTREELISTBOX_HXX
|
|
|
|
|
|
|
|
#include "ScrollHelper.hxx"
|
2007-07-06 07:27:45 +00:00
|
|
|
#include "moduledbu.hxx"
|
2008-12-01 12:31:27 +00:00
|
|
|
|
|
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
|
|
|
|
2012-10-11 16:13:12 -04:00
|
|
|
#include <svtools/treelistbox.hxx>
|
2008-12-01 12:31:27 +00:00
|
|
|
#include <vcl/timer.hxx>
|
|
|
|
|
|
|
|
#include <set>
|
2007-07-06 07:27:45 +00:00
|
|
|
|
2004-08-02 14:57:37 +00:00
|
|
|
|
|
|
|
namespace dbaui
|
|
|
|
{
|
|
|
|
struct DBTreeEditedEntry
|
|
|
|
{
|
|
|
|
SvLBoxEntry* pEntry;
|
|
|
|
XubString aNewText;
|
|
|
|
};
|
2004-10-22 11:06:14 +00:00
|
|
|
|
|
|
|
class IEntryFilter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual bool includeEntry( SvLBoxEntry* _pEntry ) const = 0;
|
2012-03-14 13:27:56 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
~IEntryFilter() {}
|
2004-10-22 11:06:14 +00:00
|
|
|
};
|
|
|
|
|
2004-08-02 14:57:37 +00:00
|
|
|
//========================================================================
|
|
|
|
class IControlActionListener;
|
2008-06-25 11:49:26 +00:00
|
|
|
class IContextMenuProvider;
|
2004-08-02 14:57:37 +00:00
|
|
|
class DBTreeListBox :public SvTreeListBox
|
|
|
|
{
|
2008-06-25 11:49:26 +00:00
|
|
|
OModuleClient m_aModuleClient;
|
2004-08-02 14:57:37 +00:00
|
|
|
OScrollHelper m_aScrollHelper;
|
|
|
|
Timer m_aTimer; // is needed for table updates
|
|
|
|
Point m_aMousePos;
|
2012-10-15 16:42:43 -04:00
|
|
|
std::set<SvLBoxEntry*> m_aSelectedEntries;
|
2004-09-09 08:45:24 +00:00
|
|
|
SvLBoxEntry* m_pDragedEntry;
|
2004-08-02 14:57:37 +00:00
|
|
|
IControlActionListener* m_pActionListener;
|
2008-06-25 11:49:26 +00:00
|
|
|
IContextMenuProvider*
|
|
|
|
m_pContextMenuProvider;
|
2004-08-02 14:57:37 +00:00
|
|
|
|
|
|
|
Link m_aPreExpandHandler; // handler to be called before a node is expanded
|
2008-12-01 12:31:27 +00:00
|
|
|
Link m_aSelChangeHdl; // handlet to be called (asynchronously) when the selection changes in any way
|
2004-08-02 14:57:37 +00:00
|
|
|
Link m_aCutHandler; // called when someone press CTRL+X
|
|
|
|
Link m_aCopyHandler; // called when someone press CTRL+C
|
|
|
|
Link m_aPasteHandler; // called when someone press CTRL+V
|
|
|
|
Link m_aDeleteHandler; // called when someone press DELETE Key
|
|
|
|
Link m_aEditingHandler; // called before someone will edit an entry
|
|
|
|
Link m_aEditedHandler; // called after someone edited an entry
|
|
|
|
Link m_aEnterKeyHdl;
|
|
|
|
|
|
|
|
|
|
|
|
sal_Bool m_bHandleEnterKey;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void init();
|
|
|
|
DECL_LINK( OnTimeOut, void* );
|
|
|
|
DECL_LINK( OnResetEntry, SvLBoxEntry* );
|
|
|
|
DECL_LINK( ScrollUpHdl, SvTreeListBox* );
|
|
|
|
DECL_LINK( ScrollDownHdl, SvTreeListBox* );
|
|
|
|
|
|
|
|
public:
|
|
|
|
DBTreeListBox( Window* pParent
|
|
|
|
,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
|
|
|
|
,WinBits nWinStyle=0
|
|
|
|
,sal_Bool _bHandleEnterKey = sal_False);
|
|
|
|
DBTreeListBox( Window* pParent
|
|
|
|
,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
|
|
|
|
,const ResId& rResId
|
|
|
|
,sal_Bool _bHandleEnterKey = sal_False);
|
|
|
|
~DBTreeListBox();
|
|
|
|
|
|
|
|
void setControlActionListener( IControlActionListener* _pListener ) { m_pActionListener = _pListener; }
|
2008-06-25 11:49:26 +00:00
|
|
|
void setContextMenuProvider( IContextMenuProvider* _pContextMenuProvider ) { m_pContextMenuProvider = _pContextMenuProvider; }
|
2004-08-02 14:57:37 +00:00
|
|
|
|
|
|
|
inline void setORB(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB) { m_xORB = _xORB; }
|
|
|
|
|
|
|
|
|
2008-12-01 12:31:27 +00:00
|
|
|
void SetPreExpandHandler(const Link& _rHdl) { m_aPreExpandHandler = _rHdl; }
|
|
|
|
void SetSelChangeHdl( const Link& _rHdl ) { m_aSelChangeHdl = _rHdl; }
|
|
|
|
void setCutHandler(const Link& _rHdl) { m_aCutHandler = _rHdl; }
|
|
|
|
void setCopyHandler(const Link& _rHdl) { m_aCopyHandler = _rHdl; }
|
|
|
|
void setPasteHandler(const Link& _rHdl) { m_aPasteHandler = _rHdl; }
|
|
|
|
void setDeleteHandler(const Link& _rHdl) { m_aDeleteHandler = _rHdl; }
|
|
|
|
void setEditingHandler(const Link& _rHdl) { m_aEditingHandler = _rHdl; }
|
|
|
|
void setEditedHandler(const Link& _rHdl) { m_aEditedHandler = _rHdl; }
|
2004-08-02 14:57:37 +00:00
|
|
|
|
|
|
|
// modified the given entry so that the expand handler is called whenever the entry is expanded
|
|
|
|
// (normally, the expand handler is called only once)
|
|
|
|
void EnableExpandHandler(SvLBoxEntry* _pEntry);
|
|
|
|
|
2004-10-22 11:06:14 +00:00
|
|
|
SvLBoxEntry* GetEntryPosByName( const String& aName, SvLBoxEntry* pStart = NULL, const IEntryFilter* _pFilter = NULL ) const;
|
2011-12-07 02:33:51 -08:00
|
|
|
virtual void RequestingChildren( SvLBoxEntry* pParent );
|
2004-08-02 14:57:37 +00:00
|
|
|
virtual void SelectHdl();
|
|
|
|
virtual void DeselectHdl();
|
|
|
|
// Window
|
|
|
|
virtual void KeyInput( const KeyEvent& rKEvt );
|
|
|
|
|
2007-01-25 11:00:37 +00:00
|
|
|
virtual void StateChanged( StateChangedType nStateChange );
|
2006-12-20 13:14:33 +00:00
|
|
|
virtual void InitEntry( SvLBoxEntry* pEntry, const XubString& aStr, const Image& aCollEntryBmp, const Image& aExpEntryBmp, SvLBoxButtonKind eButtonKind);
|
2004-08-02 14:57:37 +00:00
|
|
|
|
|
|
|
// enable editing for tables/views and queries
|
2011-01-14 15:00:11 +01:00
|
|
|
virtual sal_Bool EditingEntry( SvLBoxEntry* pEntry, Selection& );
|
2012-03-17 10:06:47 +00:00
|
|
|
virtual sal_Bool EditedEntry( SvLBoxEntry* pEntry, const rtl::OUString& rNewText );
|
2004-08-02 14:57:37 +00:00
|
|
|
|
2011-01-14 15:00:11 +01:00
|
|
|
virtual sal_Bool DoubleClickHdl();
|
2006-12-01 16:31:11 +00:00
|
|
|
|
2004-08-02 14:57:37 +00:00
|
|
|
virtual PopupMenu* CreateContextMenu( void );
|
2011-01-14 15:00:11 +01:00
|
|
|
virtual void ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry );
|
2004-08-02 14:57:37 +00:00
|
|
|
|
|
|
|
void SetEnterKeyHdl(const Link& rNewHdl) {m_aEnterKeyHdl = rNewHdl;}
|
|
|
|
|
2008-12-01 12:31:27 +00:00
|
|
|
void clearCurrentSelection() { m_aSelectedEntries.clear(); }
|
2004-08-02 14:57:37 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void MouseButtonDown( const MouseEvent& rMEvt );
|
2004-10-22 11:06:14 +00:00
|
|
|
virtual void RequestHelp( const HelpEvent& rHEvt );
|
2004-08-02 14:57:37 +00:00
|
|
|
|
|
|
|
// DragSourceHelper overridables
|
|
|
|
virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
|
|
|
|
// DropTargetHelper overridables
|
|
|
|
virtual sal_Int8 AcceptDrop( const AcceptDropEvent& _rEvt );
|
|
|
|
virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& _rEvt );
|
|
|
|
|
|
|
|
virtual void ModelHasRemoved( SvListEntry* pEntry );
|
|
|
|
virtual void ModelHasEntryInvalidated( SvListEntry* pEntry );
|
|
|
|
|
2008-12-01 12:31:27 +00:00
|
|
|
void implStopSelectionTimer();
|
|
|
|
void implStartSelectionTimer();
|
2006-06-20 02:17:00 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
using SvTreeListBox::ExecuteDrop;
|
2004-08-02 14:57:37 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // DBAUI_DBTREELISTBOX_HXX
|
2010-10-27 12:33:13 +01:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|