1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_dbui.hxx"
26 
27 #ifndef DBACCESS_UI_DBTREEVIEW_HXX
28 #include "dbtreeview.hxx"
29 #endif
30 #ifndef _SVTREEBOX_HXX
31 #include <svtools/svtreebx.hxx>
32 #endif
33 #ifndef DBAUI_DBTREELISTBOX_HXX
34 #include "dbtreelistbox.hxx"
35 #endif
36 #ifndef DBAUI_DBTREEMODEL_HXX
37 #include "dbtreemodel.hxx"
38 #endif
39 #include "dbaccess_helpid.hrc"
40 
41 // .........................................................................
42 namespace dbaui
43 {
44 // .........................................................................
45 
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::lang;
48 
DBG_NAME(DBTreeView)49 DBG_NAME(DBTreeView)
50 //========================================================================
51 // class DBTreeView
52 //========================================================================
53 DBTreeView::DBTreeView(	Window* pParent, const Reference< XMultiServiceFactory >& _rxORB, WinBits nBits)
54 					:	Window( pParent, nBits )
55 					, m_pTreeListBox(NULL)
56 {
57 	DBG_CTOR(DBTreeView,NULL);
58 
59 	m_pTreeListBox = new DBTreeListBox(this, _rxORB ,WB_HASLINES | WB_SORT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT,sal_True);
60 	m_pTreeListBox->EnableCheckButton(NULL);
61 	m_pTreeListBox->SetDragDropMode( 0 );
62 	m_pTreeListBox->EnableInplaceEditing( sal_True );
63 	m_pTreeListBox->SetHelpId(HID_TLB_TREELISTBOX);
64 	m_pTreeListBox->Show();
65 }
66 
67 // -----------------------------------------------------------------------------
68 
~DBTreeView()69 DBTreeView::~DBTreeView()
70 {
71 	DBG_DTOR(DBTreeView,NULL);
72 	if (m_pTreeListBox)
73 	{
74 		if (m_pTreeListBox->GetModel())
75 		{
76 			m_pTreeListBox->GetModel()->RemoveView(m_pTreeListBox);
77 			m_pTreeListBox->DisconnectFromModel();
78 		}
79 		::std::auto_ptr<Window> aTemp(m_pTreeListBox);
80 		m_pTreeListBox = NULL;
81 	}
82 }
83 
84 // -----------------------------------------------------------------------------
SetPreExpandHandler(const Link & _rHdl)85 void DBTreeView::SetPreExpandHandler(const Link& _rHdl)
86 {
87 	m_pTreeListBox->SetPreExpandHandler(_rHdl);
88 }
89 
90 // -----------------------------------------------------------------------------
setCopyHandler(const Link & _rHdl)91 void	DBTreeView::setCopyHandler(const Link& _rHdl)
92 {
93 	m_pTreeListBox->setCopyHandler(_rHdl);
94 }
95 // -----------------------------------------------------------------------------
Resize()96 void DBTreeView::Resize()
97 {
98 	Window::Resize();
99 	m_pTreeListBox->SetPosSizePixel(Point(0,0),GetOutputSizePixel());
100 }
101 // -------------------------------------------------------------------------
setModel(SvLBoxTreeList * _pTreeModel)102 void DBTreeView::setModel(SvLBoxTreeList* _pTreeModel)
103 {
104 	if (_pTreeModel)
105 		_pTreeModel->InsertView(m_pTreeListBox);
106 	m_pTreeListBox->SetModel(_pTreeModel);
107 }
108 
109 // -------------------------------------------------------------------------
setSelChangeHdl(const Link & _rHdl)110 void DBTreeView::setSelChangeHdl( const Link& _rHdl )
111 {
112 	m_pTreeListBox->SetSelChangeHdl( _rHdl );
113 }
114 // -----------------------------------------------------------------------------
GetFocus()115 void DBTreeView::GetFocus()
116 {
117 	Window::GetFocus();
118 	if ( m_pTreeListBox )//&& !m_pTreeListBox->HasChildPathFocus())
119 		m_pTreeListBox->GrabFocus();
120 }
121 
122 
123 // .........................................................................
124 }	// namespace dbaui
125 // .........................................................................
126 
127 
128