1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_dbaccess.hxx"
30 
31 #ifndef DBACCESS_UI_DBTREEVIEW_HXX
32 #include "dbtreeview.hxx"
33 #endif
34 #ifndef _SVTREEBOX_HXX
35 #include <svtools/svtreebx.hxx>
36 #endif
37 #ifndef DBAUI_DBTREELISTBOX_HXX
38 #include "dbtreelistbox.hxx"
39 #endif
40 #ifndef DBAUI_DBTREEMODEL_HXX
41 #include "dbtreemodel.hxx"
42 #endif
43 #include "dbaccess_helpid.hrc"
44 
45 // .........................................................................
46 namespace dbaui
47 {
48 // .........................................................................
49 
50 using namespace ::com::sun::star::uno;
51 using namespace ::com::sun::star::lang;
52 
53 DBG_NAME(DBTreeView)
54 //========================================================================
55 // class DBTreeView
56 //========================================================================
57 DBTreeView::DBTreeView(	Window* pParent, const Reference< XMultiServiceFactory >& _rxORB, WinBits nBits)
58 					:	Window( pParent, nBits )
59 					, m_pTreeListBox(NULL)
60 {
61 	DBG_CTOR(DBTreeView,NULL);
62 
63 	m_pTreeListBox = new DBTreeListBox(this, _rxORB ,WB_HASLINES | WB_SORT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT,sal_True);
64 	m_pTreeListBox->EnableCheckButton(NULL);
65 	m_pTreeListBox->SetDragDropMode( 0 );
66 	m_pTreeListBox->EnableInplaceEditing( sal_True );
67 	m_pTreeListBox->SetHelpId(HID_TLB_TREELISTBOX);
68 	m_pTreeListBox->Show();
69 }
70 
71 // -----------------------------------------------------------------------------
72 
73 DBTreeView::~DBTreeView()
74 {
75 	DBG_DTOR(DBTreeView,NULL);
76 	if (m_pTreeListBox)
77 	{
78 		if (m_pTreeListBox->GetModel())
79 		{
80 			m_pTreeListBox->GetModel()->RemoveView(m_pTreeListBox);
81 			m_pTreeListBox->DisconnectFromModel();
82 		}
83 		::std::auto_ptr<Window> aTemp(m_pTreeListBox);
84 		m_pTreeListBox = NULL;
85 	}
86 }
87 
88 // -----------------------------------------------------------------------------
89 void DBTreeView::SetPreExpandHandler(const Link& _rHdl)
90 {
91 	m_pTreeListBox->SetPreExpandHandler(_rHdl);
92 }
93 
94 // -----------------------------------------------------------------------------
95 void	DBTreeView::setCopyHandler(const Link& _rHdl)
96 {
97 	m_pTreeListBox->setCopyHandler(_rHdl);
98 }
99 // -----------------------------------------------------------------------------
100 void DBTreeView::Resize()
101 {
102 	Window::Resize();
103 	m_pTreeListBox->SetPosSizePixel(Point(0,0),GetOutputSizePixel());
104 }
105 // -------------------------------------------------------------------------
106 void DBTreeView::setModel(SvLBoxTreeList* _pTreeModel)
107 {
108 	if (_pTreeModel)
109 		_pTreeModel->InsertView(m_pTreeListBox);
110 	m_pTreeListBox->SetModel(_pTreeModel);
111 }
112 
113 // -------------------------------------------------------------------------
114 void DBTreeView::setSelChangeHdl( const Link& _rHdl )
115 {
116 	m_pTreeListBox->SetSelChangeHdl( _rHdl );
117 }
118 // -----------------------------------------------------------------------------
119 void DBTreeView::GetFocus()
120 {
121 	Window::GetFocus();
122 	if ( m_pTreeListBox )//&& !m_pTreeListBox->HasChildPathFocus())
123 		m_pTreeListBox->GrabFocus();
124 }
125 
126 
127 // .........................................................................
128 }	// namespace dbaui
129 // .........................................................................
130 
131 
132