update dev300-m58
[ooovba.git] / sd / source / ui / inc / taskpane / ScrollPanel.hxx
blob8111d397549f852c58a10ecd5840ff3a7e6e9739
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: ScrollPanel.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_TOOLPANEL_SCROLL_PANEL_HXX
32 #define SD_TOOLPANEL_SCROLL_PANEL_HXX
34 #include "taskpane/TaskPaneTreeNode.hxx"
36 #include <vcl/ctrl.hxx>
37 #include <vcl/scrbar.hxx>
38 #include <memory>
39 #include <vector>
41 namespace sd { namespace toolpanel {
43 class TitledControl;
45 /** The scroll panel shows its controls one above the other. When their
46 total height is larger than the height of the scroll area then only a
47 part of the controls is visible. Scroll bars control which part that
48 is.
50 The scroll panel registers itself as window event listener at the
51 controls and their title bars (conceptually; it really is the
52 TitledControl) to track changes of the selection and focus rectangles.
53 On such a change it tries to move the selected or focused part into the
54 visible area. At the moment this moving into view only works with
55 valuesets and TitleBars.
57 class ScrollPanel
58 : public ::Control,
59 public TreeNode
61 public:
62 /** Create a new sub tool panel with the given window as its
63 parent. This will usually be a child window.
65 ScrollPanel (TreeNode* pParent);
66 virtual ~ScrollPanel (void);
68 /** Add a control to the sub panel. An title bar is added above the
69 control.
70 @param rTitle
71 The title that will be shown in the two title bars that
72 belong to the control.
73 @param nHelpId
74 The help id is set at the title bar not the actual control.
75 @return
76 The new titled control that contains the given control and a new
77 title bar as children is returned.
79 TitledControl* AddControl (
80 ::std::auto_ptr<TreeNode> pControl,
81 const String& rTitle,
82 ULONG nHelpId);
84 /** Add a control to the sub panel without a title bar.
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 bool IsVerticalScrollBarVisible (void) const;
108 bool IsHorizontalScrollBarVisible (void) const;
109 ScrollBar& GetVerticalScrollBar (void);
110 ScrollBar& GetHorizontalScrollBar (void);
112 // ::Window
113 virtual long Notify( NotifyEvent& rNEvt );
115 virtual ::com::sun::star::uno::Reference<
116 ::com::sun::star::accessibility::XAccessible> CreateAccessibleObject (
117 const ::com::sun::star::uno::Reference<
118 ::com::sun::star::accessibility::XAccessible>& rxParent);
120 /** Scroll the given rectangle into the visible area.
121 @param aRectangle
122 The box to move into the visible area in pixel coordinates
123 relative to the given window.
124 @param pWindow
125 This window is used to translate the given coordinates into ones
126 that are relative to the scroll panel.
129 void MakeRectangleVisible (
130 Rectangle& aRectangle,
131 ::Window* pWindow);
133 protected:
134 /** Initiate a rearrangement of the controls.
136 void ListHasChanged (void);
138 private:
139 ::Control maScrollWindow;
140 ScrollBar maVerticalScrollBar;
141 ScrollBar maHorizontalScrollBar;
142 ::Window maScrollBarFiller;
143 ::Window maScrollWindowFiller;
144 Point maScrollOffset;
145 bool mbIsRearrangePending;
146 bool mbIsLayoutPending;
147 sal_uInt32 mnChildrenWidth;
148 /// Border above top-most and below bottom-most control.
149 const int mnVerticalBorder;
150 /// Gap between two controls.
151 const int mnVerticalGap;
152 /// Border at the left and right of the controls.
153 const int mnHorizontalBorder;
154 /** List of horizontal stripes that is created from the gaps between
155 children when they are layouted. The stripes are painted in Paint()
156 to fill the space arround the children.
158 typedef ::std::vector< ::std::pair<int,int> > StripeList;
159 StripeList maStripeList;
161 /** Calculate position, size, and visibility of the controls.
162 Call this method after the list of controls, their expansion
163 state, or the size of the sub panel has changed.
165 void Rearrange (void);
167 /** Determine the minimal size that is necessary to show the controls
168 one over the other. It may be smaller than the available area.
170 Size GetRequiredSize (void);
172 /** Place the child windows one above the other and return the size of
173 the bounding box.
175 sal_Int32 LayoutChildren (void);
177 Size SetupScrollBars (const Size& rRequiresSize);
178 sal_Int32 SetupVerticalScrollBar (bool bShow, sal_Int32 nRange);
179 sal_Int32 SetupHorizontalScrollBar (bool bShow, sal_Int32 nRange);
181 DECL_LINK(ScrollBarHandler, ScrollBar*);
182 DECL_LINK(WindowEventListener, VclSimpleEvent*);
184 using Window::GetWindow;
187 } } // end of namespace ::sd::toolpanel
189 #endif