update dev300-m58
[ooovba.git] / sd / source / ui / inc / taskpane / TaskPaneTreeNode.hxx
blob4dbe85e99303756a3dff0b6f2b8a163a401078db
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TaskPaneTreeNode.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_TASKPANE_TREE_NODE_HXX
32 #define SD_TASKPANE_TREE_NODE_HXX
34 #include "ILayoutableWindow.hxx"
35 #include <memory>
36 #include <vector>
37 #include <com/sun/star/accessibility/XAccessible.hpp>
38 #include <tools/link.hxx>
40 namespace sd {
41 class ObjectBarManager;
44 namespace sd { namespace toolpanel {
46 class ControlContainer;
47 class TaskPaneShellManager;
49 enum TreeNodeStateChangeEventId {
50 EID_CHILD_ADDED,
51 EID_ALL_CHILDREN_REMOVED,
52 EID_EXPANSION_STATE_CHANGED,
53 EID_FOCUSED_STATE_CHANGED,
54 EID_SHOWING_STATE_CHANGED
58 /** Base class for all members of the object hierarchy that makes up the
59 tool panel. There are usually at least three levels. At the top level
60 is the ToolPanel with one instance: the root of the tree. At the
61 middle level there are SubToolPanels and Window/Control objects. At the
62 lowest level there are only Window or Control objects.
64 This class provides the means of communication between objects on
65 different levels.
67 class TreeNode
68 : public ILayoutableWindow,
69 public ILayouter
71 public:
72 TreeNode (TreeNode* pParent);
73 virtual ~TreeNode (void);
75 /** Returns <TRUE/> if the node has no children, i.e. is a leaf of a
76 tree. In this case mpControlContainer is NULL.
78 bool IsLeaf (void);
80 /** Returns true if the node has no parent, i.e. is the root of a tree.
82 bool IsRoot (void);
84 void SetParentNode (TreeNode* pNewParent);
85 TreeNode* GetParentNode (void);
87 /** Return the Window pointer of a tree node.
89 virtual ::Window* GetWindow (void);
91 /** Return a const pointer to the window of a tree node.
93 virtual const ::Window* GetConstWindow (void) const;
95 /** Return the joined minimum width of all children, i.e. the largest of
96 the minimum widths.
98 virtual sal_Int32 GetMinimumWidth (void);
100 /** Give each node access to the object bar manager of the tool panel.
102 At least the root node has to overwrite this method since the
103 default implementation simply returns the object bar manager of the
104 parent.
106 virtual ObjectBarManager* GetObjectBarManager (void);
108 /** The default implementaion always returns <FALSE/>
110 virtual bool IsResizable (void);
112 /** Call this method whenever the size of one of the children of the
113 called node has to be changed, e.g. when the layout menu shows more
114 or less items than before. As a typical result the node will layout
115 and resize its children according to their size requirements.
117 Please remember that the size of the children can be changed in the
118 first place because scroll bars can give a node the space it needs.
120 The default implementation passes this call to its parent.
122 virtual void RequestResize (void);
124 /** The default implementation shows the window (when it exists) when
125 bExpansionState is <TRUE/>. It hides the window otherwise.
126 @return
127 Returns <TRUE/> when the expansion state changes. When an
128 expansion state is requested that is already in place then
129 <FALSE/> is returned.
131 virtual bool Expand (bool bExpansionState);
133 /** The default implementation returns whether the window is showing.
134 When there is no window then it returns <FALSE/>.
136 virtual bool IsExpanded (void) const;
138 /** Return whether the node can be expanded or collapsed. The default
139 implementation always returns <TRUE/> when there is window and
140 <FALSE/> otherwise. If <FALSE/> is returned
141 then Expand() may be called but it will not change the expansion
142 state.
144 virtual bool IsExpandable (void) const;
146 /** The default implementation calls GetWindow()->Show().
148 virtual void Show (bool bVisibilityState);
150 /** The default implementation returns GetWindow()->IsVisible().
152 virtual bool IsShowing (void) const;
154 ControlContainer& GetControlContainer (void);
156 /** Give each node access to a shell manage. This usually is the shell
157 manager of the TaskPaneViewShell.
159 At least the root node has to overwrite this method since the
160 default implementation simply returns the shell manager of its
161 parent.
163 virtual TaskPaneShellManager* GetShellManager (void);
165 /** You will rarely need to overload this method. To supply your own
166 accessible object you should overload CreateAccessible() instead.
168 virtual ::com::sun::star::uno::Reference<
169 ::com::sun::star::accessibility::XAccessible> GetAccessibleObject (void);
171 /** Overload this method in order to supply a class specific accessible
172 object.
173 The default implementation will return a new instance of
174 AccessibleTreeNode.
175 @param rxParent
176 The accessible parent of the accessible object to create. It is
177 not necessaryly the accessible object of the parent window of
178 GetWindow().
181 virtual ::com::sun::star::uno::Reference<
182 ::com::sun::star::accessibility::XAccessible> CreateAccessibleObject (
183 const ::com::sun::star::uno::Reference<
184 ::com::sun::star::accessibility::XAccessible>&rxParent);
186 /** Add a listener that will be informated in the future about state
187 changes of the tree node. This includes adding and removing
188 children as well as focus, visibility, and expansion state.
189 Multiple calls are ignored. Each listener is added only once.
191 void AddStateChangeListener (const Link& rListener);
193 /** Remove the listener form the list of state change listeners.
194 @param rListener
195 It is OK to specify a listener that is not currently
196 registered. Only when the listener is registered it is
197 removed. Otherwise the call is ignored.
199 void RemoveStateChangeListener (const Link& rListener);
201 /** Call the state change listeners and pass a state change event with
202 the specified event id. The source field is set to this.
203 @param pChild
204 This optional parameter makes sense only with the
205 EID_CHILD_ADDED event.
207 void FireStateChangeEvent (
208 TreeNodeStateChangeEventId eEventId,
209 TreeNode* pChild = NULL) const;
211 protected:
212 ::std::auto_ptr<ControlContainer> mpControlContainer;
214 private:
215 TreeNode* mpParent;
216 typedef ::std::vector<Link> StateChangeListenerContainer;
217 StateChangeListenerContainer maStateChangeListeners;
223 /** Objects of this class are sent to listeners to notify them about state
224 changes of a tree node.
226 class TreeNodeStateChangeEvent
228 public:
230 TreeNodeStateChangeEvent (
231 const TreeNode& rNode,
232 TreeNodeStateChangeEventId eEventId,
233 TreeNode* pChild = NULL);
235 const TreeNode& mrSource;
236 TreeNodeStateChangeEventId meEventId;
237 TreeNode* mpChild;
240 } } // end of namespace ::sd::toolpanel
242 #endif