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 INCLUDED_DBACCESS_SOURCE_UI_INC_DBTREELISTBOX_HXX
20 #define INCLUDED_DBACCESS_SOURCE_UI_INC_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>
34 struct DBTreeEditedEntry
36 SvTreeListEntry
* pEntry
;
43 virtual bool includeEntry( SvTreeListEntry
* _pEntry
) const = 0;
49 class IControlActionListener
;
50 class IContextMenuProvider
;
51 class DBTreeListBox
:public SvTreeListBox
53 OModuleClient m_aModuleClient
;
54 OScrollHelper m_aScrollHelper
;
55 Timer m_aTimer
; // is needed for table updates
57 std::set
<SvTreeListEntry
*> m_aSelectedEntries
;
58 SvTreeListEntry
* m_pDragedEntry
;
59 IControlActionListener
* m_pActionListener
;
61 m_pContextMenuProvider
;
63 Link
<> m_aPreExpandHandler
; // handler to be called before a node is expanded
64 Link
<> m_aSelChangeHdl
; // handlet to be called (asynchronously) when the selection changes in any way
65 Link
<> m_aCutHandler
; // called when someone press CTRL+X
66 Link
<> m_aCopyHandler
; // called when someone press CTRL+C
67 Link
<> m_aPasteHandler
; // called when someone press CTRL+V
68 Link
<> m_aDeleteHandler
; // called when someone press DELETE Key
69 Link
<> m_aEditingHandler
; // called before someone will edit an entry
70 Link
<> m_aEditedHandler
; // called after someone edited an entry
71 Link
<> m_aEnterKeyHdl
;
73 bool m_bHandleEnterKey
;
77 DECL_LINK_TYPED( OnTimeOut
, Timer
*, void );
78 DECL_LINK( OnResetEntry
, SvTreeListEntry
* );
79 DECL_LINK( ScrollUpHdl
, SvTreeListBox
* );
80 DECL_LINK( ScrollDownHdl
, SvTreeListBox
* );
83 DBTreeListBox( vcl::Window
* pParent
85 ,bool _bHandleEnterKey
= false);
86 virtual ~DBTreeListBox();
87 virtual void dispose() SAL_OVERRIDE
;
89 void setControlActionListener( IControlActionListener
* _pListener
) { m_pActionListener
= _pListener
; }
90 void setContextMenuProvider( IContextMenuProvider
* _pContextMenuProvider
) { m_pContextMenuProvider
= _pContextMenuProvider
; }
92 void SetPreExpandHandler(const Link
<>& _rHdl
) { m_aPreExpandHandler
= _rHdl
; }
93 void SetSelChangeHdl( const Link
<>& _rHdl
) { m_aSelChangeHdl
= _rHdl
; }
94 void setCutHandler(const Link
<>& _rHdl
) { m_aCutHandler
= _rHdl
; }
95 void setCopyHandler(const Link
<>& _rHdl
) { m_aCopyHandler
= _rHdl
; }
96 void setPasteHandler(const Link
<>& _rHdl
) { m_aPasteHandler
= _rHdl
; }
97 void setDeleteHandler(const Link
<>& _rHdl
) { m_aDeleteHandler
= _rHdl
; }
98 void setEditingHandler(const Link
<>& _rHdl
) { m_aEditingHandler
= _rHdl
; }
99 void setEditedHandler(const Link
<>& _rHdl
) { m_aEditedHandler
= _rHdl
; }
101 // modified the given entry so that the expand handler is called whenever the entry is expanded
102 // (normally, the expand handler is called only once)
103 void EnableExpandHandler(SvTreeListEntry
* _pEntry
);
105 SvTreeListEntry
* GetEntryPosByName( const OUString
& aName
, SvTreeListEntry
* pStart
= NULL
, const IEntryFilter
* _pFilter
= NULL
) const;
106 virtual void RequestingChildren( SvTreeListEntry
* pParent
) SAL_OVERRIDE
;
107 virtual void SelectHdl() SAL_OVERRIDE
;
108 virtual void DeselectHdl() SAL_OVERRIDE
;
110 virtual void KeyInput( const KeyEvent
& rKEvt
) SAL_OVERRIDE
;
112 virtual void StateChanged( StateChangedType nStateChange
) SAL_OVERRIDE
;
113 virtual void InitEntry(SvTreeListEntry
* pEntry
, const OUString
& aStr
, const Image
& aCollEntryBmp
, const Image
& aExpEntryBmp
, SvLBoxButtonKind eButtonKind
) SAL_OVERRIDE
;
115 // enable editing for tables/views and queries
116 virtual bool EditingEntry( SvTreeListEntry
* pEntry
, Selection
& ) SAL_OVERRIDE
;
117 virtual bool EditedEntry( SvTreeListEntry
* pEntry
, const OUString
& rNewText
) SAL_OVERRIDE
;
119 virtual bool DoubleClickHdl() SAL_OVERRIDE
;
121 virtual PopupMenu
* CreateContextMenu() SAL_OVERRIDE
;
122 virtual void ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry
) SAL_OVERRIDE
;
124 void SetEnterKeyHdl(const Link
<>& rNewHdl
) {m_aEnterKeyHdl
= rNewHdl
;}
126 void clearCurrentSelection() { m_aSelectedEntries
.clear(); }
129 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
130 virtual void RequestHelp( const HelpEvent
& rHEvt
) SAL_OVERRIDE
;
132 // DragSourceHelper overridables
133 virtual void StartDrag( sal_Int8 nAction
, const Point
& rPosPixel
) SAL_OVERRIDE
;
134 // DropTargetHelper overridables
135 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& _rEvt
) SAL_OVERRIDE
;
136 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& _rEvt
) SAL_OVERRIDE
;
138 virtual void ModelHasRemoved( SvTreeListEntry
* pEntry
) SAL_OVERRIDE
;
139 virtual void ModelHasEntryInvalidated( SvTreeListEntry
* pEntry
) SAL_OVERRIDE
;
141 void implStopSelectionTimer();
142 void implStartSelectionTimer();
145 using SvTreeListBox::ExecuteDrop
;
149 #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_DBTREELISTBOX_HXX
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */