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