1*cdf0e10cSrcweir/************************************************************************ 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir#ifndef __com_sun_star_awt_tree_TreeControl_idl__ 28*cdf0e10cSrcweir#define __com_sun_star_awt_tree_TreeControl_idl__ 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir#ifndef __com_sun_star_awt_tree_XTreeControl_idl__ 31*cdf0e10cSrcweir#include <com/sun/star/awt/tree/XTreeControl.idl> 32*cdf0e10cSrcweir#endif 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir//============================================================================= 35*cdf0e10cSrcweir 36*cdf0e10cSrcweirmodule com { module sun { module star { module awt { module tree { 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir//============================================================================= 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir/** A control that displays a set of hierarchical data as an outline. 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir <p> 43*cdf0e10cSrcweir <h4>The Data Model</h4> 44*cdf0e10cSrcweir <p>A specific node in a tree is identified by a <type>XTreeNode</type>. 45*cdf0e10cSrcweir A leaf node is a node without any children and that returns <FALSE/> when calling <member>XTreeNode::hasChildrenOnDemand()</member>. 46*cdf0e10cSrcweir An expanded node is a non-leaf node that will displays its children when all its ancestors are expanded. 47*cdf0e10cSrcweir A collapsed node is one which hides them. 48*cdf0e10cSrcweir A node is visible when all parent nodes are expanded and the node itself is in the display area. 49*cdf0e10cSrcweir </p> 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir <p>The nodes are retrieved from a <type>XTreeDataModel</type>. 52*cdf0e10cSrcweir You can implement it yourself or use the <type>MutableTreeDataModel</type> 53*cdf0e10cSrcweir which uses <type>XMutableTreeNode</type> and <type>XMutableTreeDataModel</type> 54*cdf0e10cSrcweir for a simple and mutable data model. 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir <p>The data model must be set at the <member>TreeControlModel::TreeDataModel</member> property.</p> 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir <h4>Selection</h4> 59*cdf0e10cSrcweir <p>If you are interested in knowing when the selection changes implement a 60*cdf0e10cSrcweir <type scope="com::sun::star::view">XSelectionChangeListener</type> and add the instance with the method 61*cdf0e10cSrcweir <member scope="::com::sun::star::view">XSelectionSupplier::addSelectionChangeListener()</member>. 62*cdf0e10cSrcweir You than will be notified for any selection change. 63*cdf0e10cSrcweir </p> 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir <p> 66*cdf0e10cSrcweir If you are interested in detecting either double-click events or when a user clicks on a node, 67*cdf0e10cSrcweir regardless of whether or not it was selected, you can get the <type scope="com::sun::star::awt">XWindow</type> 68*cdf0e10cSrcweir and add yourself as a <type scope="com::sun::star::awt">XMouseClickHandler</type>. You can use the 69*cdf0e10cSrcweir method <member>XTreeControl::getNodeForLocation()</member> to retrieve the node that was under the 70*cdf0e10cSrcweir mouse at the time the event was fired. 71*cdf0e10cSrcweir </p> 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir <h4>Adding child nodes on demand</h4> 74*cdf0e10cSrcweir <p>If you want to add child nodes to your tree on demand you can do the following. 75*cdf0e10cSrcweir <ul> 76*cdf0e10cSrcweir <li>Make sure the parent node returns <TRUE/> for <member>XTreeNode::hasChildrenOnDemand()</member> either 77*cdf0e10cSrcweir by implementing <type>XTreeNode</type> yourself or if you use the <type>MutableTreeDataModel</type>, 78*cdf0e10cSrcweir use <member>XMutableTreeNode::setHasChildrenOnDemand()</member>.</li> 79*cdf0e10cSrcweir <li>Implement a <type>XTreeExpansionListener</type> and add the instance with the method 80*cdf0e10cSrcweir <member>XTreeControl::addTreeExpansionListener()</member>.</li> 81*cdf0e10cSrcweir </ul> 82*cdf0e10cSrcweir Now you get called when the node will become expanded or collapsed. 83*cdf0e10cSrcweir So on <member>XTreeExpansionListener::treeExpanding()</member> you can 84*cdf0e10cSrcweir check the <type>TreeExpansionEvent</type> if the parent node with children on demand is going to 85*cdf0e10cSrcweir be expanded and in that case add the missing child nodes. You can also veto the expansion or 86*cdf0e10cSrcweir collapsing of a parent node by using the <type>ExpandVetoException</type>. 87*cdf0e10cSrcweir </p> 88*cdf0e10cSrcweir */ 89*cdf0e10cSrcweirservice TreeControl: XTreeControl 90*cdf0e10cSrcweir{ 91*cdf0e10cSrcweir}; 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir//============================================================================= 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir}; }; }; }; }; 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir#endif 98