Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "dbtreeview.hxx"
21 : #include <svtools/treelistbox.hxx>
22 : #include "dbtreelistbox.hxx"
23 : #include "dbtreemodel.hxx"
24 : #include "dbaccess_helpid.hrc"
25 : #include <boost/scoped_ptr.hpp>
26 :
27 : namespace dbaui
28 : {
29 :
30 : using namespace ::com::sun::star::uno;
31 : using namespace ::com::sun::star::lang;
32 :
33 : // class DBTreeView
34 1 : DBTreeView::DBTreeView( vcl::Window* pParent, WinBits nBits)
35 : : Window( pParent, nBits )
36 1 : , m_pTreeListBox(NULL)
37 : {
38 :
39 1 : m_pTreeListBox = VclPtr<DBTreeListBox>::Create(this, WB_BORDER | WB_HASLINES | WB_HASLINESATROOT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT);
40 1 : m_pTreeListBox->EnableCheckButton(NULL);
41 1 : m_pTreeListBox->SetDragDropMode( DragDropMode::NONE );
42 1 : m_pTreeListBox->EnableInplaceEditing( true );
43 1 : m_pTreeListBox->SetHelpId(HID_TLB_TREELISTBOX);
44 1 : m_pTreeListBox->Show();
45 1 : }
46 :
47 3 : DBTreeView::~DBTreeView()
48 : {
49 1 : disposeOnce();
50 2 : }
51 :
52 1 : void DBTreeView::dispose()
53 : {
54 1 : if (m_pTreeListBox)
55 : {
56 1 : if (m_pTreeListBox->GetModel())
57 : {
58 1 : m_pTreeListBox->GetModel()->RemoveView(m_pTreeListBox);
59 1 : m_pTreeListBox->DisconnectFromModel();
60 : }
61 : }
62 1 : m_pTreeListBox.disposeAndClear();
63 1 : vcl::Window::dispose();
64 1 : }
65 :
66 1 : void DBTreeView::SetPreExpandHandler(const Link<>& _rHdl)
67 : {
68 1 : m_pTreeListBox->SetPreExpandHandler(_rHdl);
69 1 : }
70 :
71 1 : void DBTreeView::setCopyHandler(const Link<>& _rHdl)
72 : {
73 1 : m_pTreeListBox->setCopyHandler(_rHdl);
74 1 : }
75 :
76 7 : void DBTreeView::Resize()
77 : {
78 7 : Window::Resize();
79 7 : m_pTreeListBox->SetPosSizePixel(Point(0,0),GetOutputSizePixel());
80 7 : }
81 :
82 1 : void DBTreeView::setModel(SvTreeList* _pTreeModel)
83 : {
84 1 : if (_pTreeModel)
85 1 : _pTreeModel->InsertView(m_pTreeListBox);
86 1 : m_pTreeListBox->SetModel(_pTreeModel);
87 1 : }
88 :
89 1 : void DBTreeView::setSelChangeHdl( const Link<>& _rHdl )
90 : {
91 1 : m_pTreeListBox->SetSelChangeHdl( _rHdl );
92 1 : }
93 :
94 0 : void DBTreeView::GetFocus()
95 : {
96 0 : Window::GetFocus();
97 0 : if ( m_pTreeListBox )//&& !m_pTreeListBox->HasChildPathFocus())
98 0 : m_pTreeListBox->GrabFocus();
99 0 : }
100 :
101 36 : } // namespace dbaui
102 :
103 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|