merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / ui / inc / dbtreelistbox.hxx
blobc3328f05c0e54403df70597400ffb0cbfb81fccc
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dbtreelistbox.hxx,v $
10 * $Revision: 1.13 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef DBAUI_DBTREELISTBOX_HXX
31 #define DBAUI_DBTREELISTBOX_HXX
33 #include "ScrollHelper.hxx"
34 #include "moduledbu.hxx"
36 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 #include <svtools/svtreebx.hxx>
39 #include <vcl/timer.hxx>
41 #include <set>
44 namespace dbaui
46 struct DBTreeEditedEntry
48 SvLBoxEntry* pEntry;
49 XubString aNewText;
52 class IEntryFilter
54 public:
55 virtual bool includeEntry( SvLBoxEntry* _pEntry ) const = 0;
58 //========================================================================
59 class IControlActionListener;
60 class IContextMenuProvider;
61 class DBTreeListBox :public SvTreeListBox
63 OModuleClient m_aModuleClient;
64 OScrollHelper m_aScrollHelper;
65 Timer m_aTimer; // is needed for table updates
66 Point m_aMousePos;
67 ::std::set< SvListEntry* > m_aSelectedEntries;
68 SvLBoxEntry* m_pDragedEntry;
69 IControlActionListener* m_pActionListener;
70 IContextMenuProvider*
71 m_pContextMenuProvider;
73 Link m_aPreExpandHandler; // handler to be called before a node is expanded
74 Link m_aSelChangeHdl; // handlet to be called (asynchronously) when the selection changes in any way
75 Link m_aCutHandler; // called when someone press CTRL+X
76 Link m_aCopyHandler; // called when someone press CTRL+C
77 Link m_aPasteHandler; // called when someone press CTRL+V
78 Link m_aDeleteHandler; // called when someone press DELETE Key
79 Link m_aEditingHandler; // called before someone will edit an entry
80 Link m_aEditedHandler; // called after someone edited an entry
81 Link m_aEnterKeyHdl;
84 sal_Bool m_bHandleEnterKey;
86 protected:
87 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB;
89 private:
90 void init();
91 DECL_LINK( OnTimeOut, void* );
92 DECL_LINK( OnResetEntry, SvLBoxEntry* );
93 DECL_LINK( ScrollUpHdl, SvTreeListBox* );
94 DECL_LINK( ScrollDownHdl, SvTreeListBox* );
96 public:
97 DBTreeListBox( Window* pParent
98 ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
99 ,WinBits nWinStyle=0
100 ,sal_Bool _bHandleEnterKey = sal_False);
101 DBTreeListBox( Window* pParent
102 ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
103 ,const ResId& rResId
104 ,sal_Bool _bHandleEnterKey = sal_False);
105 ~DBTreeListBox();
107 void setControlActionListener( IControlActionListener* _pListener ) { m_pActionListener = _pListener; }
108 void setContextMenuProvider( IContextMenuProvider* _pContextMenuProvider ) { m_pContextMenuProvider = _pContextMenuProvider; }
110 inline void setORB(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB) { m_xORB = _xORB; }
113 void SetPreExpandHandler(const Link& _rHdl) { m_aPreExpandHandler = _rHdl; }
114 void SetSelChangeHdl( const Link& _rHdl ) { m_aSelChangeHdl = _rHdl; }
115 void setCutHandler(const Link& _rHdl) { m_aCutHandler = _rHdl; }
116 void setCopyHandler(const Link& _rHdl) { m_aCopyHandler = _rHdl; }
117 void setPasteHandler(const Link& _rHdl) { m_aPasteHandler = _rHdl; }
118 void setDeleteHandler(const Link& _rHdl) { m_aDeleteHandler = _rHdl; }
119 void setEditingHandler(const Link& _rHdl) { m_aEditingHandler = _rHdl; }
120 void setEditedHandler(const Link& _rHdl) { m_aEditedHandler = _rHdl; }
122 // modified the given entry so that the expand handler is called whenever the entry is expanded
123 // (normally, the expand handler is called only once)
124 void EnableExpandHandler(SvLBoxEntry* _pEntry);
126 SvLBoxEntry* GetEntryPosByName( const String& aName, SvLBoxEntry* pStart = NULL, const IEntryFilter* _pFilter = NULL ) const;
127 virtual void RequestingChilds( SvLBoxEntry* pParent );
128 virtual void SelectHdl();
129 virtual void DeselectHdl();
130 // Window
131 virtual void KeyInput( const KeyEvent& rKEvt );
133 virtual void StateChanged( StateChangedType nStateChange );
134 virtual void InitEntry( SvLBoxEntry* pEntry, const XubString& aStr, const Image& aCollEntryBmp, const Image& aExpEntryBmp, SvLBoxButtonKind eButtonKind);
136 // enable editing for tables/views and queries
137 virtual BOOL EditingEntry( SvLBoxEntry* pEntry, Selection& );
138 virtual BOOL EditedEntry( SvLBoxEntry* pEntry, const XubString& rNewText );
140 virtual BOOL DoubleClickHdl();
142 virtual PopupMenu* CreateContextMenu( void );
143 virtual void ExcecuteContextMenuAction( USHORT nSelectedPopupEntry );
145 void SetEnterKeyHdl(const Link& rNewHdl) {m_aEnterKeyHdl = rNewHdl;}
147 void clearCurrentSelection() { m_aSelectedEntries.clear(); }
149 protected:
150 virtual void MouseButtonDown( const MouseEvent& rMEvt );
151 virtual void RequestHelp( const HelpEvent& rHEvt );
153 // DragSourceHelper overridables
154 virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
155 // DropTargetHelper overridables
156 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& _rEvt );
157 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& _rEvt );
159 virtual void ModelHasRemoved( SvListEntry* pEntry );
160 virtual void ModelHasEntryInvalidated( SvListEntry* pEntry );
162 void implStopSelectionTimer();
163 void implStartSelectionTimer();
165 protected:
166 using SvTreeListBox::ExecuteDrop;
170 #endif // DBAUI_DBTREELISTBOX_HXX