summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/inc/dbtreelistbox.hxx
blob: 599d63d664c4f6810b72a4e17b14df4622c737a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: dbtreelistbox.hxx,v $
 * $Revision: 1.12 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org 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 version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/
#ifndef DBAUI_DBTREELISTBOX_HXX
#define DBAUI_DBTREELISTBOX_HXX

#ifndef _SVTREEBOX_HXX
#include <svtools/svtreebx.hxx>
#endif
#ifndef _SV_TIMER_HXX
#include <vcl/timer.hxx>
#endif
#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#endif
#ifndef DBAUI_SCROLLHELPER_HXX
#include "ScrollHelper.hxx"
#endif
#ifndef _DBAUI_MODULE_DBU_HXX_
#include "moduledbu.hxx"
#endif


namespace dbaui
{
    #define FOLDER_INDICATOR 1

    struct DBTreeEditedEntry
    {
        SvLBoxEntry*    pEntry;
        XubString       aNewText;
    };

    class IEntryFilter
    {
    public:
        virtual bool    includeEntry( SvLBoxEntry* _pEntry ) const = 0;
    };

    //========================================================================
    class IControlActionListener;
    class IController;
    class DBTreeListBox     :public SvTreeListBox
    {
        OModuleClient        m_aModuleClient;
        OScrollHelper               m_aScrollHelper;
        Timer                       m_aTimer; // is needed for table updates
        Point                       m_aMousePos;
        SvLBoxEntry*                m_pSelectedEntry;
        SvLBoxEntry*                m_pDragedEntry;
        IControlActionListener*     m_pActionListener;
        IController*                m_pContextMenuActionListener;

        Link                        m_aPreExpandHandler;    // handler to be called before a node is expanded
        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_Int32                   m_nSelectLock;
        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; }
        IControlActionListener* getControlActionListener( ) const { return m_pActionListener; }

        void            setContextMenuActionListener( IController* _pConextListener) { m_pContextMenuActionListener = _pConextListener; }
        IController*    getContextMenuActionListener( ) const { return m_pContextMenuActionListener; }

        inline void setORB(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB) { m_xORB = _xORB; }


        void    SetPreExpandHandler(const Link& _rHdl) { m_aPreExpandHandler = _rHdl; }
        Link    GetPreExpandHandler() const         { return m_aPreExpandHandler; }

        void    setCutHandler(const Link& _rHdl)    { m_aCutHandler = _rHdl; }
        Link    getCutHandler() const               { return m_aCutHandler; }

        void    setCopyHandler(const Link& _rHdl)   { m_aCopyHandler = _rHdl; }
        Link    getCopyHandler() const              { return m_aCopyHandler; }

        void    setPasteHandler(const Link& _rHdl)  { m_aPasteHandler = _rHdl; }
        Link    getPasteHandler() const             { return m_aPasteHandler; }

        void    setDeleteHandler(const Link& _rHdl) { m_aDeleteHandler = _rHdl; }
        Link    getDeleteHandler() const            { return m_aDeleteHandler; }

        void    setEditingHandler(const Link& _rHdl){ m_aEditingHandler = _rHdl; }
        Link    getEditingHandler() const           { return m_aEditingHandler; }

        void    setEditedHandler(const Link& _rHdl) { m_aEditedHandler = _rHdl; }
        Link    getEditedHandler() const            { return m_aEditedHandler; }

        inline SvLBoxEntry* GetSelectedEntry() const { return m_pSelectedEntry; }
        // 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);

        SvLBoxEntry*    GetEntryPosByName( const String& aName, SvLBoxEntry* pStart = NULL, const IEntryFilter* _pFilter = NULL ) const;
        virtual void    RequestingChilds( SvLBoxEntry* pParent );
        virtual void    SelectHdl();
        virtual void    DeselectHdl();
        // Window
        virtual void    KeyInput( const KeyEvent& rKEvt );

        virtual void    StateChanged( StateChangedType nStateChange );
        virtual void    InitEntry( SvLBoxEntry* pEntry, const XubString& aStr, const Image& aCollEntryBmp, const Image& aExpEntryBmp, SvLBoxButtonKind eButtonKind);

        virtual void    SelectEntry(SvLBoxEntry* _pEntry);
        // enable editing for tables/views and queries
        virtual BOOL    EditingEntry( SvLBoxEntry* pEntry, Selection& );
        virtual BOOL    EditedEntry( SvLBoxEntry* pEntry, const XubString& rNewText );

        virtual BOOL    DoubleClickHdl();

        virtual PopupMenu* CreateContextMenu( void );
        virtual void    ExcecuteContextMenuAction( USHORT nSelectedPopupEntry );

        sal_Int32       lockAutoSelect();
        sal_Int32       unlockAutoSelect();
        sal_Int32       locked() const { return m_nSelectLock; }

        void            SetEnterKeyHdl(const Link& rNewHdl) {m_aEnterKeyHdl = rNewHdl;}

        inline void     clearCurrentSelectionEntry() { m_pSelectedEntry = NULL; }

    protected:
        virtual void        MouseButtonDown( const MouseEvent& rMEvt );
        virtual void        Command( const CommandEvent& rCEvt );
        virtual void        RequestHelp( const HelpEvent& rHEvt );

        // 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 );

        void                implSelected(SvLBoxEntry* _pSelected);

    protected:
        using SvTreeListBox::ExecuteDrop;
    };
}

#endif // DBAUI_DBTREELISTBOX_HXX