merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / inc / taskpane / SubToolPanel.hxx
blobd9b8dc8c6ae969812406361bbb010dd623100ac9
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: SubToolPanel.hxx,v $
10 * $Revision: 1.6 $
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_SUB_TOOL_PANEL_HXX
32 #define SD_TASKPANE_SUB_TOOL_PANEL_HXX
34 #include "taskpane/TaskPaneTreeNode.hxx"
36 #include <vcl/ctrl.hxx>
37 #include <vcl/scrbar.hxx>
38 #include <memory>
39 #include <vector>
42 class Window;
44 namespace sd { namespace toolpanel {
46 class ToolPanel;
48 /** The sub tool panel is in function similar to the tool panel. It
49 differes in two points. First, it is a control that can be used
50 as element in a tool panel and thus is actually a nested tool
51 panel.
53 <p>Secondly, it formats its elements differently. The actual controls
54 are placed one below the other with a title bar above each control.
55 Clicking on the title bar expands or collapses the control. When there
56 is not enough space then scroll bars are shown.</p>
58 <p>To avoid flickering when painting the sub tool panel the background
59 is made transparent and painting it is done by this class. While
60 layouting its children it remembers the gaps between children and stores
61 them in maStripeList. In Paint() those gaps as well as the border
62 arround all children are painted in the background color.</p>
64 class SubToolPanel
65 : public Control,
66 public TreeNode
68 public:
69 /** Create a new sub tool panel with the given window as its
70 parent. This will usually be a child window.
72 SubToolPanel (TreeNode* pParent);
73 virtual ~SubToolPanel (void);
75 /** Add a control to the sub panel.
76 @param rTitle
77 The title that will be shown in the two title bars that
78 belong to the control.
79 @param nHelpId
80 The help id is set at the title bar not the actual control.
82 void AddControl (
83 ::std::auto_ptr<TreeNode> pControl,
84 const String& rTitle,
85 ULONG nHelpId);
86 void AddControl (::std::auto_ptr<TreeNode> pControl);
88 virtual void Paint (const Rectangle& rRect);
90 /** Initiate a rearrangement of the controls and title bars.
92 virtual void Resize (void);
94 virtual void RequestResize (void);
96 virtual Size GetPreferredSize (void);
97 virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeight);
98 virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth);
99 virtual bool IsResizable (void);
100 virtual ::Window* GetWindow (void);
101 virtual sal_Int32 GetMinimumWidth (void);
103 virtual void ExpandControl (
104 TreeNode* pControl,
105 bool bExpansionState);
107 virtual ::com::sun::star::uno::Reference<
108 ::com::sun::star::accessibility::XAccessible> CreateAccessibleObject (
109 const ::com::sun::star::uno::Reference<
110 ::com::sun::star::accessibility::XAccessible>& rxParent);
112 using Window::GetWindow;
113 protected:
114 /** Initiate a rearrangement of the controls.
116 void ListHasChanged (void);
118 private:
119 ::Window maWindowFiller;
120 bool mbIsRearrangePending;
121 bool mbIsLayoutPending;
122 sal_uInt32 mnChildrenWidth;
123 /// Border above top-most and below bottom-most control.
124 const int mnVerticalBorder;
125 /// Gap between two controls.
126 const int mnVerticalGap;
127 /// Border at the left and right of the controls.
128 const int mnHorizontalBorder;
129 /** List of horizontal stripes that is created from the gaps between
130 children when they are layouted. The stripes are painted in Paint()
131 to fill the space arround the children.
133 typedef ::std::vector< ::std::pair<int,int> > StripeList;
134 StripeList maStripeList;
136 /** Calculate position, size, and visibility of the controls.
137 Call this method after the list of controls, their expansion
138 state, or the size of the sub panel has changed.
140 void Rearrange (void);
142 /** Determine the minimal size that is necessary to show the controls
143 one over the other. It may be smaller than the available area.
145 Size GetRequiredSize (void);
147 /** Place the child windows one above the other and return the size of
148 the bounding box.
150 sal_Int32 LayoutChildren (void);
152 DECL_LINK(WindowEventListener, VclSimpleEvent*);
155 } } // end of namespace ::sd::toolpanel
157 #endif