xref: /AOO41X/main/sd/source/ui/inc/taskpane/TaskPaneTreeNode.hxx (revision 67e470dafe1997e73f56ff7ff4878983707e3e07)
1*c45d927aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*c45d927aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*c45d927aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*c45d927aSAndrew Rist  * distributed with this work for additional information
6*c45d927aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*c45d927aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*c45d927aSAndrew Rist  * "License"); you may not use this file except in compliance
9*c45d927aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*c45d927aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*c45d927aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*c45d927aSAndrew Rist  * software distributed under the License is distributed on an
15*c45d927aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c45d927aSAndrew Rist  * KIND, either express or implied.  See the License for the
17*c45d927aSAndrew Rist  * specific language governing permissions and limitations
18*c45d927aSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*c45d927aSAndrew Rist  *************************************************************/
21*c45d927aSAndrew Rist 
22*c45d927aSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SD_TASKPANE_TREE_NODE_HXX
25cdf0e10cSrcweir #define SD_TASKPANE_TREE_NODE_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "ILayoutableWindow.hxx"
28cdf0e10cSrcweir #include <memory>
29cdf0e10cSrcweir #include <vector>
30cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessible.hpp>
31cdf0e10cSrcweir #include <tools/link.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir namespace sd {
34cdf0e10cSrcweir class ObjectBarManager;
35cdf0e10cSrcweir }
36cdf0e10cSrcweir 
37cdf0e10cSrcweir namespace sd { namespace toolpanel {
38cdf0e10cSrcweir 
39cdf0e10cSrcweir class ControlContainer;
40cdf0e10cSrcweir class TaskPaneShellManager;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir enum TreeNodeStateChangeEventId {
43cdf0e10cSrcweir     EID_CHILD_ADDED,
44cdf0e10cSrcweir     EID_ALL_CHILDREN_REMOVED,
45cdf0e10cSrcweir     EID_EXPANSION_STATE_CHANGED,
46cdf0e10cSrcweir     EID_FOCUSED_STATE_CHANGED,
47cdf0e10cSrcweir     EID_SHOWING_STATE_CHANGED
48cdf0e10cSrcweir };
49cdf0e10cSrcweir 
50cdf0e10cSrcweir 
51cdf0e10cSrcweir /** Base class for all members of the object hierarchy that makes up the
52cdf0e10cSrcweir     tool panel. In the task pane, there are multiple hierarchies of such nodes,
53cdf0e10cSrcweir     with every panel having an own tree. The pane node is the root of the tree, below
54cdf0e10cSrcweir     that there are SubToolPanels and Window/Control objects. At the
55cdf0e10cSrcweir     lowest level there are only Window or Control objects.
56cdf0e10cSrcweir 
57cdf0e10cSrcweir     This class provides the means of communication between objects on
58cdf0e10cSrcweir     different levels.
59cdf0e10cSrcweir */
60cdf0e10cSrcweir class TreeNode
61cdf0e10cSrcweir     : public ILayoutableWindow,
62cdf0e10cSrcweir       public ILayouter
63cdf0e10cSrcweir {
64cdf0e10cSrcweir public:
65cdf0e10cSrcweir     TreeNode (TreeNode* pParent);
66cdf0e10cSrcweir     virtual ~TreeNode (void);
67cdf0e10cSrcweir 
68cdf0e10cSrcweir     void SetParentNode (TreeNode* pNewParent);
69cdf0e10cSrcweir     TreeNode* GetParentNode (void);
70cdf0e10cSrcweir 
71cdf0e10cSrcweir     /** Return the Window pointer of a tree node.
72cdf0e10cSrcweir     */
73cdf0e10cSrcweir     virtual ::Window* GetWindow (void);
74cdf0e10cSrcweir 
75cdf0e10cSrcweir     /** Return a const pointer to the window of a tree node.
76cdf0e10cSrcweir     */
77cdf0e10cSrcweir     virtual const ::Window* GetConstWindow (void) const;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     /** Return the joined minimum width of all children, i.e. the largest of
80cdf0e10cSrcweir         the minimum widths.
81cdf0e10cSrcweir     */
82cdf0e10cSrcweir     virtual sal_Int32 GetMinimumWidth (void);
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     /** The default implementaion always returns <FALSE/>
85cdf0e10cSrcweir     */
86cdf0e10cSrcweir     virtual bool IsResizable (void);
87cdf0e10cSrcweir 
88cdf0e10cSrcweir     /** Call this method whenever the size of one of the children of the
89cdf0e10cSrcweir         called node has to be changed, e.g. when the layout menu shows more
90cdf0e10cSrcweir         or less items than before.  As a typical result the node will layout
91cdf0e10cSrcweir         and resize its children according to their size requirements.
92cdf0e10cSrcweir 
93cdf0e10cSrcweir         Please remember that the size of the children can be changed in the
94cdf0e10cSrcweir         first place because scroll bars can give a node the space it needs.
95cdf0e10cSrcweir 
96cdf0e10cSrcweir         The default implementation passes this call to its parent.
97cdf0e10cSrcweir     */
98cdf0e10cSrcweir     virtual void RequestResize (void);
99cdf0e10cSrcweir 
100cdf0e10cSrcweir     /** The default implementation shows the window (when it exists) when
101cdf0e10cSrcweir         bExpansionState is <TRUE/>.  It hides the window otherwise.
102cdf0e10cSrcweir         @return
103cdf0e10cSrcweir             Returns <TRUE/> when the expansion state changes.  When an
104cdf0e10cSrcweir             expansion state is requested that is already in place then
105cdf0e10cSrcweir             <FALSE/> is returned.
106cdf0e10cSrcweir     */
107cdf0e10cSrcweir     virtual bool Expand (bool bExpansionState);
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     /** The default implementation returns whether the window is showing.
110cdf0e10cSrcweir         When there is no window then it returns <FALSE/>.
111cdf0e10cSrcweir     */
112cdf0e10cSrcweir     virtual bool IsExpanded (void) const;
113cdf0e10cSrcweir 
114cdf0e10cSrcweir     /** Return whether the node can be expanded or collapsed.  The default
115cdf0e10cSrcweir         implementation always returns <TRUE/> when there is window and
116cdf0e10cSrcweir         <FALSE/> otherwise.  If <FALSE/> is returned
117cdf0e10cSrcweir         then Expand() may be called but it will not change the expansion
118cdf0e10cSrcweir         state.
119cdf0e10cSrcweir     */
120cdf0e10cSrcweir     virtual bool IsExpandable (void) const;
121cdf0e10cSrcweir 
122cdf0e10cSrcweir     /** The default implementation calls GetWindow()->Show().
123cdf0e10cSrcweir     */
124cdf0e10cSrcweir     virtual void Show (bool bVisibilityState);
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     /** The default implementation returns GetWindow()->IsVisible().
127cdf0e10cSrcweir     */
128cdf0e10cSrcweir     virtual bool IsShowing (void) const;
129cdf0e10cSrcweir 
130cdf0e10cSrcweir     ControlContainer& GetControlContainer (void);
131cdf0e10cSrcweir 
132cdf0e10cSrcweir     /** Give each node access to a shell manage.  This usually is the shell
133cdf0e10cSrcweir         manager of the ToolPanelViewShell.
134cdf0e10cSrcweir 
135cdf0e10cSrcweir         At least the root node has to overwrite this method since the
136cdf0e10cSrcweir         default implementation simply returns the shell manager of its
137cdf0e10cSrcweir         parent.
138cdf0e10cSrcweir     */
139cdf0e10cSrcweir     virtual TaskPaneShellManager* GetShellManager (void);
140cdf0e10cSrcweir 
141cdf0e10cSrcweir     /** You will rarely need to overload this method.  To supply your own
142cdf0e10cSrcweir         accessible object you should overload CreateAccessible() instead.
143cdf0e10cSrcweir     */
144cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
145cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessible> GetAccessibleObject (void);
146cdf0e10cSrcweir 
147cdf0e10cSrcweir     /** Overload this method in order to supply a class specific accessible
148cdf0e10cSrcweir         object.
149cdf0e10cSrcweir         The default implementation will return a new instance of
150cdf0e10cSrcweir         AccessibleTreeNode.
151cdf0e10cSrcweir         @param rxParent
152cdf0e10cSrcweir             The accessible parent of the accessible object to create.  It is
153cdf0e10cSrcweir             not necessaryly the accessible object of the parent window of
154cdf0e10cSrcweir             GetWindow().
155cdf0e10cSrcweir 
156cdf0e10cSrcweir     */
157cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
158cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessible> CreateAccessibleObject (
159cdf0e10cSrcweir             const ::com::sun::star::uno::Reference<
160cdf0e10cSrcweir             ::com::sun::star::accessibility::XAccessible>&rxParent);
161cdf0e10cSrcweir 
162cdf0e10cSrcweir     /** Add a listener that will be informated in the future about state
163cdf0e10cSrcweir         changes of the tree node.  This includes adding and removing
164cdf0e10cSrcweir         children as well as focus, visibility, and expansion state.
165cdf0e10cSrcweir         Multiple calls are ignored.  Each listener is added only once.
166cdf0e10cSrcweir     */
167cdf0e10cSrcweir     void AddStateChangeListener (const Link& rListener);
168cdf0e10cSrcweir 
169cdf0e10cSrcweir     /** Call the state change listeners and pass a state change event with
170cdf0e10cSrcweir         the specified event id.  The source field is set to this.
171cdf0e10cSrcweir         @param pChild
172cdf0e10cSrcweir             This optional parameter makes sense only with the
173cdf0e10cSrcweir             EID_CHILD_ADDED event.
174cdf0e10cSrcweir     */
175cdf0e10cSrcweir     void FireStateChangeEvent (
176cdf0e10cSrcweir         TreeNodeStateChangeEventId eEventId,
177cdf0e10cSrcweir         TreeNode* pChild = NULL) const;
178cdf0e10cSrcweir 
179cdf0e10cSrcweir protected:
180cdf0e10cSrcweir     ::std::auto_ptr<ControlContainer> mpControlContainer;
181cdf0e10cSrcweir 
182cdf0e10cSrcweir private:
183cdf0e10cSrcweir     TreeNode* mpParent;
184cdf0e10cSrcweir     typedef ::std::vector<Link> StateChangeListenerContainer;
185cdf0e10cSrcweir     StateChangeListenerContainer maStateChangeListeners;
186cdf0e10cSrcweir };
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 
191cdf0e10cSrcweir /** Objects of this class are sent to listeners to notify them about state
192cdf0e10cSrcweir     changes of a tree node.
193cdf0e10cSrcweir */
194cdf0e10cSrcweir class TreeNodeStateChangeEvent
195cdf0e10cSrcweir {
196cdf0e10cSrcweir public:
197cdf0e10cSrcweir 
198cdf0e10cSrcweir     TreeNodeStateChangeEvent (
199cdf0e10cSrcweir         const TreeNode& rNode,
200cdf0e10cSrcweir         TreeNodeStateChangeEventId eEventId,
201cdf0e10cSrcweir         TreeNode* pChild = NULL);
202cdf0e10cSrcweir 
203cdf0e10cSrcweir     const TreeNode& mrSource;
204cdf0e10cSrcweir     TreeNodeStateChangeEventId meEventId;
205cdf0e10cSrcweir     TreeNode* mpChild;
206cdf0e10cSrcweir };
207cdf0e10cSrcweir 
208cdf0e10cSrcweir } } // end of namespace ::sd::toolpanel
209cdf0e10cSrcweir 
210cdf0e10cSrcweir #endif
211