1*d1766043SAndrew Rist/************************************************************** 2cdf0e10cSrcweir * 3*d1766043SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*d1766043SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*d1766043SAndrew Rist * distributed with this work for additional information 6*d1766043SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*d1766043SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*d1766043SAndrew Rist * "License"); you may not use this file except in compliance 9*d1766043SAndrew Rist * with the License. You may obtain a copy of the License at 10*d1766043SAndrew Rist * 11*d1766043SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*d1766043SAndrew Rist * 13*d1766043SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*d1766043SAndrew Rist * software distributed under the License is distributed on an 15*d1766043SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*d1766043SAndrew Rist * KIND, either express or implied. See the License for the 17*d1766043SAndrew Rist * specific language governing permissions and limitations 18*d1766043SAndrew Rist * under the License. 19*d1766043SAndrew Rist * 20*d1766043SAndrew Rist *************************************************************/ 21*d1766043SAndrew Rist 22*d1766043SAndrew Rist 23cdf0e10cSrcweir#ifndef __com_sun_star_awt_tree_TreeControl_idl__ 24cdf0e10cSrcweir#define __com_sun_star_awt_tree_TreeControl_idl__ 25cdf0e10cSrcweir 26cdf0e10cSrcweir#ifndef __com_sun_star_awt_tree_XTreeControl_idl__ 27cdf0e10cSrcweir#include <com/sun/star/awt/tree/XTreeControl.idl> 28cdf0e10cSrcweir#endif 29cdf0e10cSrcweir 30cdf0e10cSrcweir//============================================================================= 31cdf0e10cSrcweir 32cdf0e10cSrcweirmodule com { module sun { module star { module awt { module tree { 33cdf0e10cSrcweir 34cdf0e10cSrcweir//============================================================================= 35cdf0e10cSrcweir 36cdf0e10cSrcweir/** A control that displays a set of hierarchical data as an outline. 37cdf0e10cSrcweir 38cdf0e10cSrcweir <p> 39cdf0e10cSrcweir <h4>The Data Model</h4> 40cdf0e10cSrcweir <p>A specific node in a tree is identified by a <type>XTreeNode</type>. 41cdf0e10cSrcweir A leaf node is a node without any children and that returns <FALSE/> when calling <member>XTreeNode::hasChildrenOnDemand()</member>. 42cdf0e10cSrcweir An expanded node is a non-leaf node that will displays its children when all its ancestors are expanded. 43cdf0e10cSrcweir A collapsed node is one which hides them. 44cdf0e10cSrcweir A node is visible when all parent nodes are expanded and the node itself is in the display area. 45cdf0e10cSrcweir </p> 46cdf0e10cSrcweir 47cdf0e10cSrcweir <p>The nodes are retrieved from a <type>XTreeDataModel</type>. 48cdf0e10cSrcweir You can implement it yourself or use the <type>MutableTreeDataModel</type> 49cdf0e10cSrcweir which uses <type>XMutableTreeNode</type> and <type>XMutableTreeDataModel</type> 50cdf0e10cSrcweir for a simple and mutable data model. 51cdf0e10cSrcweir 52cdf0e10cSrcweir <p>The data model must be set at the <member>TreeControlModel::TreeDataModel</member> property.</p> 53cdf0e10cSrcweir 54cdf0e10cSrcweir <h4>Selection</h4> 55cdf0e10cSrcweir <p>If you are interested in knowing when the selection changes implement a 56cdf0e10cSrcweir <type scope="com::sun::star::view">XSelectionChangeListener</type> and add the instance with the method 57cdf0e10cSrcweir <member scope="::com::sun::star::view">XSelectionSupplier::addSelectionChangeListener()</member>. 58cdf0e10cSrcweir You than will be notified for any selection change. 59cdf0e10cSrcweir </p> 60cdf0e10cSrcweir 61cdf0e10cSrcweir <p> 62cdf0e10cSrcweir If you are interested in detecting either double-click events or when a user clicks on a node, 63cdf0e10cSrcweir regardless of whether or not it was selected, you can get the <type scope="com::sun::star::awt">XWindow</type> 64cdf0e10cSrcweir and add yourself as a <type scope="com::sun::star::awt">XMouseClickHandler</type>. You can use the 65cdf0e10cSrcweir method <member>XTreeControl::getNodeForLocation()</member> to retrieve the node that was under the 66cdf0e10cSrcweir mouse at the time the event was fired. 67cdf0e10cSrcweir </p> 68cdf0e10cSrcweir 69cdf0e10cSrcweir <h4>Adding child nodes on demand</h4> 70cdf0e10cSrcweir <p>If you want to add child nodes to your tree on demand you can do the following. 71cdf0e10cSrcweir <ul> 72cdf0e10cSrcweir <li>Make sure the parent node returns <TRUE/> for <member>XTreeNode::hasChildrenOnDemand()</member> either 73cdf0e10cSrcweir by implementing <type>XTreeNode</type> yourself or if you use the <type>MutableTreeDataModel</type>, 74cdf0e10cSrcweir use <member>XMutableTreeNode::setHasChildrenOnDemand()</member>.</li> 75cdf0e10cSrcweir <li>Implement a <type>XTreeExpansionListener</type> and add the instance with the method 76cdf0e10cSrcweir <member>XTreeControl::addTreeExpansionListener()</member>.</li> 77cdf0e10cSrcweir </ul> 78cdf0e10cSrcweir Now you get called when the node will become expanded or collapsed. 79cdf0e10cSrcweir So on <member>XTreeExpansionListener::treeExpanding()</member> you can 80cdf0e10cSrcweir check the <type>TreeExpansionEvent</type> if the parent node with children on demand is going to 81cdf0e10cSrcweir be expanded and in that case add the missing child nodes. You can also veto the expansion or 82cdf0e10cSrcweir collapsing of a parent node by using the <type>ExpandVetoException</type>. 83cdf0e10cSrcweir </p> 84cdf0e10cSrcweir */ 85cdf0e10cSrcweirservice TreeControl: XTreeControl 86cdf0e10cSrcweir{ 87cdf0e10cSrcweir}; 88cdf0e10cSrcweir 89cdf0e10cSrcweir//============================================================================= 90cdf0e10cSrcweir 91cdf0e10cSrcweir}; }; }; }; }; 92cdf0e10cSrcweir 93cdf0e10cSrcweir#endif 94