1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef DBAUI_DBTREELISTBOX_HXX
20 #define DBAUI_DBTREELISTBOX_HXX
22 #include "ScrollHelper.hxx"
23 #include "moduledbu.hxx"
25 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 #include <svtools/treelistbox.hxx>
28 #include <vcl/timer.hxx>
35 struct DBTreeEditedEntry
37 SvTreeListEntry
* pEntry
;
44 virtual bool includeEntry( SvTreeListEntry
* _pEntry
) const = 0;
50 //========================================================================
51 class IControlActionListener
;
52 class IContextMenuProvider
;
53 class DBTreeListBox
:public SvTreeListBox
55 OModuleClient m_aModuleClient
;
56 OScrollHelper m_aScrollHelper
;
57 Timer m_aTimer
; // is needed for table updates
59 std::set
<SvTreeListEntry
*> m_aSelectedEntries
;
60 SvTreeListEntry
* m_pDragedEntry
;
61 IControlActionListener
* m_pActionListener
;
63 m_pContextMenuProvider
;
65 Link m_aPreExpandHandler
; // handler to be called before a node is expanded
66 Link m_aSelChangeHdl
; // handlet to be called (asynchronously) when the selection changes in any way
67 Link m_aCutHandler
; // called when someone press CTRL+X
68 Link m_aCopyHandler
; // called when someone press CTRL+C
69 Link m_aPasteHandler
; // called when someone press CTRL+V
70 Link m_aDeleteHandler
; // called when someone press DELETE Key
71 Link m_aEditingHandler
; // called before someone will edit an entry
72 Link m_aEditedHandler
; // called after someone edited an entry
76 sal_Bool m_bHandleEnterKey
;
80 DECL_LINK( OnTimeOut
, void* );
81 DECL_LINK( OnResetEntry
, SvTreeListEntry
* );
82 DECL_LINK( ScrollUpHdl
, SvTreeListBox
* );
83 DECL_LINK( ScrollDownHdl
, SvTreeListBox
* );
86 DBTreeListBox( Window
* pParent
88 ,sal_Bool _bHandleEnterKey
= sal_False
);
89 DBTreeListBox( Window
* pParent
91 ,sal_Bool _bHandleEnterKey
= sal_False
);
94 void setControlActionListener( IControlActionListener
* _pListener
) { m_pActionListener
= _pListener
; }
95 void setContextMenuProvider( IContextMenuProvider
* _pContextMenuProvider
) { m_pContextMenuProvider
= _pContextMenuProvider
; }
97 void SetPreExpandHandler(const Link
& _rHdl
) { m_aPreExpandHandler
= _rHdl
; }
98 void SetSelChangeHdl( const Link
& _rHdl
) { m_aSelChangeHdl
= _rHdl
; }
99 void setCutHandler(const Link
& _rHdl
) { m_aCutHandler
= _rHdl
; }
100 void setCopyHandler(const Link
& _rHdl
) { m_aCopyHandler
= _rHdl
; }
101 void setPasteHandler(const Link
& _rHdl
) { m_aPasteHandler
= _rHdl
; }
102 void setDeleteHandler(const Link
& _rHdl
) { m_aDeleteHandler
= _rHdl
; }
103 void setEditingHandler(const Link
& _rHdl
) { m_aEditingHandler
= _rHdl
; }
104 void setEditedHandler(const Link
& _rHdl
) { m_aEditedHandler
= _rHdl
; }
106 // modified the given entry so that the expand handler is called whenever the entry is expanded
107 // (normally, the expand handler is called only once)
108 void EnableExpandHandler(SvTreeListEntry
* _pEntry
);
110 SvTreeListEntry
* GetEntryPosByName( const String
& aName
, SvTreeListEntry
* pStart
= NULL
, const IEntryFilter
* _pFilter
= NULL
) const;
111 virtual void RequestingChildren( SvTreeListEntry
* pParent
);
112 virtual void SelectHdl();
113 virtual void DeselectHdl();
115 virtual void KeyInput( const KeyEvent
& rKEvt
);
117 virtual void StateChanged( StateChangedType nStateChange
);
118 virtual void InitEntry(SvTreeListEntry
* pEntry
, const OUString
& aStr
, const Image
& aCollEntryBmp
, const Image
& aExpEntryBmp
, SvLBoxButtonKind eButtonKind
);
120 // enable editing for tables/views and queries
121 virtual sal_Bool
EditingEntry( SvTreeListEntry
* pEntry
, Selection
& );
122 virtual sal_Bool
EditedEntry( SvTreeListEntry
* pEntry
, const OUString
& rNewText
);
124 virtual sal_Bool
DoubleClickHdl();
126 virtual PopupMenu
* CreateContextMenu( void );
127 virtual void ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry
);
129 void SetEnterKeyHdl(const Link
& rNewHdl
) {m_aEnterKeyHdl
= rNewHdl
;}
131 void clearCurrentSelection() { m_aSelectedEntries
.clear(); }
134 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
135 virtual void RequestHelp( const HelpEvent
& rHEvt
);
137 // DragSourceHelper overridables
138 virtual void StartDrag( sal_Int8 nAction
, const Point
& rPosPixel
);
139 // DropTargetHelper overridables
140 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& _rEvt
);
141 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& _rEvt
);
143 virtual void ModelHasRemoved( SvTreeListEntry
* pEntry
);
144 virtual void ModelHasEntryInvalidated( SvTreeListEntry
* pEntry
);
146 void implStopSelectionTimer();
147 void implStartSelectionTimer();
150 using SvTreeListBox::ExecuteDrop
;
154 #endif // DBAUI_DBTREELISTBOX_HXX
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */