bump product version to 4.1.6.2
[LibreOffice.git] / sd / source / ui / inc / taskpane / ScrollPanel.hxx
blobf3cfd1d72eb43c967c51cef956cdd4f7581b59c7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef SD_TOOLPANEL_SCROLL_PANEL_HXX
21 #define SD_TOOLPANEL_SCROLL_PANEL_HXX
23 #include "taskpane/TaskPaneTreeNode.hxx"
25 #include <vcl/ctrl.hxx>
26 #include <vcl/scrbar.hxx>
27 #include <memory>
28 #include <vector>
30 namespace sd { namespace toolpanel {
32 class TitledControl;
34 /** The scroll panel shows its controls one above the other. When their
35 total height is larger than the height of the scroll area then only a
36 part of the controls is visible. Scroll bars control which part that
37 is.
39 The scroll panel registers itself as window event listener at the
40 controls and their title bars (conceptually; it really is the
41 TitledControl) to track changes of the selection and focus rectangles.
42 On such a change it tries to move the selected or focused part into the
43 visible area. At the moment this moving into view only works with
44 valuesets and TitleBars.
46 class ScrollPanel
47 : public ::Control,
48 public TreeNode
50 public:
51 /** Create a new scroll panel which itself is the root of a TreeNode hierarchy
52 parent. This will usually be a child window.
54 ScrollPanel (::Window& i_rParentWindow);
55 virtual ~ScrollPanel (void);
57 /** Add a control to the sub panel. An title bar is added above the
58 control.
59 @param rTitle
60 The title that will be shown in the two title bars that
61 belong to the control.
62 @param nHelpId
63 The help id is set at the title bar not the actual control.
64 @return
65 The new titled control that contains the given control and a new
66 title bar as children is returned.
68 TitledControl* AddControl (
69 ::std::auto_ptr<TreeNode> pControl,
70 const String& rTitle,
71 const OString& sHelpId);
73 /** Add a control to the sub panel without a title bar.
75 void AddControl (::std::auto_ptr<TreeNode> pControl);
77 virtual void Paint (const Rectangle& rRect);
79 /** Initiate a rearrangement of the controls and title bars.
81 virtual void Resize (void);
83 virtual void RequestResize (void);
85 virtual Size GetPreferredSize (void);
86 virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeight);
87 virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth);
88 virtual bool IsResizable (void);
89 virtual ::Window* GetWindow (void);
90 virtual sal_Int32 GetMinimumWidth (void);
92 virtual void ExpandControl (
93 TreeNode* pControl,
94 bool bExpansionState);
96 bool IsVerticalScrollBarVisible (void) const;
97 bool IsHorizontalScrollBarVisible (void) const;
98 ScrollBar& GetVerticalScrollBar (void);
99 ScrollBar& GetHorizontalScrollBar (void);
101 // ::Window
102 virtual long Notify( NotifyEvent& rNEvt );
104 virtual ::com::sun::star::uno::Reference<
105 ::com::sun::star::accessibility::XAccessible> CreateAccessibleObject (
106 const ::com::sun::star::uno::Reference<
107 ::com::sun::star::accessibility::XAccessible>& rxParent);
109 /** Scroll the given rectangle into the visible area.
110 @param aRectangle
111 The box to move into the visible area in pixel coordinates
112 relative to the given window.
113 @param pWindow
114 This window is used to translate the given coordinates into ones
115 that are relative to the scroll panel.
118 void MakeRectangleVisible (
119 Rectangle& aRectangle,
120 ::Window* pWindow);
122 private:
123 ::Control maScrollWindow;
124 ScrollBar maVerticalScrollBar;
125 ScrollBar maHorizontalScrollBar;
126 ::Window maScrollBarFiller;
127 ::Window maScrollWindowFiller;
128 Point maScrollOffset;
129 bool mbIsRearrangePending;
130 bool mbIsLayoutPending;
131 sal_uInt32 mnChildrenWidth;
132 /// Border above top-most and below bottom-most control.
133 const int mnVerticalBorder;
134 /// Gap between two controls.
135 const int mnVerticalGap;
136 /// Border at the left and right of the controls.
137 const int mnHorizontalBorder;
138 /** List of horizontal stripes that is created from the gaps between
139 children when they are layouted. The stripes are painted in Paint()
140 to fill the space arround the children.
142 typedef ::std::vector< ::std::pair<int,int> > StripeList;
143 StripeList maStripeList;
145 /** Calculate position, size, and visibility of the controls.
146 Call this method after the list of controls, their expansion
147 state, or the size of the sub panel has changed.
149 void Rearrange (void);
151 /** Determine the minimal size that is necessary to show the controls
152 one over the other. It may be smaller than the available area.
154 Size GetRequiredSize (void);
156 /** Place the child windows one above the other and return the size of
157 the bounding box.
159 sal_Int32 LayoutChildren (void);
161 /** ctor-impl
163 void Construct();
165 Size SetupScrollBars (const Size& rRequiresSize);
166 sal_Int32 SetupVerticalScrollBar (bool bShow, sal_Int32 nRange);
167 sal_Int32 SetupHorizontalScrollBar (bool bShow, sal_Int32 nRange);
169 DECL_LINK(ScrollBarHandler, void *);
170 DECL_LINK(WindowEventListener, VclSimpleEvent*);
172 using Window::GetWindow;
175 } } // end of namespace ::sd::toolpanel
177 #endif
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */