1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #ifndef SFX_SIDEBAR_DECK_LAYOUTER_HXX
23 #define SFX_SIDEBAR_DECK_LAYOUTER_HXX
24 
25 #include <tools/gen.hxx>
26 
27 #include <com/sun/star/ui/LayoutSize.hpp>
28 
29 #include <vector>
30 
31 class ScrollBar;
32 class Window;
33 
34 namespace css = ::com::sun::star;
35 
36 namespace sfx2 { namespace sidebar {
37 
38 class Panel;
39 
40 
41 /** Helper class for layouting the direct and indirect children of a
42     deck like title bars, panels, and scroll bars.
43 */
44 class DeckLayouter
45 {
46 public:
47     static void LayoutDeck (
48         const Rectangle aContentArea,
49         ::std::vector<Panel*>& rPanels,
50         Window& pDeckTitleBar,
51         Window& pScrollClipWindow,
52         Window& pScrollContainer,
53         Window& pFiller,
54         ScrollBar& pVerticalScrollBar);
55 
56 private:
57     // Do not use constructor or destructor.
58     DeckLayouter (void);
59     ~DeckLayouter (void);
60 
61     enum LayoutMode
62     {
63         MinimumOrLarger,
64         PreferredOrLarger,
65         Preferred
66     };
67     class LayoutItem
68     {
69     public:
70         Panel* mpPanel;
71         css::ui::LayoutSize maLayoutSize;
72         sal_Int32 mnDistributedHeight;
73         sal_Int32 mnWeight;
74         sal_Int32 mnPanelIndex;
75 
76         LayoutItem (void) : mpPanel(NULL),maLayoutSize(0,0,0),mnDistributedHeight(0),mnWeight(0),mnPanelIndex(0) {}
77     };
78     static Rectangle LayoutPanels (
79         const Rectangle aContentArea,
80         ::std::vector<LayoutItem>& rLayoutItems,
81         Window& rScrollClipWindow,
82         Window& rScrollContainer,
83         ScrollBar& pVerticalScrollBar,
84         const bool bShowVerticalScrollBar);
85     static void GetRequestedSizes (
86         ::std::vector<LayoutItem>& rLayoutItem,
87         sal_Int32& rAvailableHeight,
88         const Rectangle& rContentBox);
89     static void DistributeHeights (
90         ::std::vector<LayoutItem>& rLayoutItems,
91         const sal_Int32 nHeightToDistribute,
92         const sal_Int32 nContainerHeight,
93         const bool bMinimumHeightIsBase);
94     static sal_Int32 PlacePanels (
95         ::std::vector<LayoutItem>& rLayoutItems,
96         const sal_Int32 nWidth,
97         const LayoutMode eMode,
98         Window& rScrollContainer);
99     static Rectangle PlaceDeckTitle (
100         Window& rTittleBar,
101         const Rectangle& rAvailableSpace);
102     static Rectangle PlaceVerticalScrollBar (
103         ScrollBar& rVerticalScrollBar,
104         const Rectangle& rAvailableSpace,
105         const bool bShowVerticalScrollBar);
106     static void SetupVerticalScrollBar(
107         ScrollBar& rVerticalScrollBar,
108         const sal_Int32 nContentHeight,
109         const sal_Int32 nVisibleHeight);
110     static void UpdateFiller (
111         Window& rFiller,
112         const Rectangle& rBox);
113 };
114 
115 
116 } } // end of namespace sfx2::sidebar
117 
118 #endif
119