17a32b0c8SAndre Fischer /**************************************************************
27a32b0c8SAndre Fischer  *
37a32b0c8SAndre Fischer  * Licensed to the Apache Software Foundation (ASF) under one
47a32b0c8SAndre Fischer  * or more contributor license agreements.  See the NOTICE file
57a32b0c8SAndre Fischer  * distributed with this work for additional information
67a32b0c8SAndre Fischer  * regarding copyright ownership.  The ASF licenses this file
77a32b0c8SAndre Fischer  * to you under the Apache License, Version 2.0 (the
87a32b0c8SAndre Fischer  * "License"); you may not use this file except in compliance
97a32b0c8SAndre Fischer  * with the License.  You may obtain a copy of the License at
107a32b0c8SAndre Fischer  *
117a32b0c8SAndre Fischer  *   http://www.apache.org/licenses/LICENSE-2.0
127a32b0c8SAndre Fischer  *
137a32b0c8SAndre Fischer  * Unless required by applicable law or agreed to in writing,
147a32b0c8SAndre Fischer  * software distributed under the License is distributed on an
157a32b0c8SAndre Fischer  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
167a32b0c8SAndre Fischer  * KIND, either express or implied.  See the License for the
177a32b0c8SAndre Fischer  * specific language governing permissions and limitations
187a32b0c8SAndre Fischer  * under the License.
197a32b0c8SAndre Fischer  *
207a32b0c8SAndre Fischer  *************************************************************/
217a32b0c8SAndre Fischer 
227a32b0c8SAndre Fischer #ifndef SFX_SIDEBAR_DECK_LAYOUTER_HXX
237a32b0c8SAndre Fischer #define SFX_SIDEBAR_DECK_LAYOUTER_HXX
247a32b0c8SAndre Fischer 
25f120fe41SAndre Fischer #include "Panel.hxx"
26f120fe41SAndre Fischer 
277a32b0c8SAndre Fischer #include <tools/gen.hxx>
287a32b0c8SAndre Fischer 
297a32b0c8SAndre Fischer #include <com/sun/star/ui/LayoutSize.hpp>
307a32b0c8SAndre Fischer 
317a32b0c8SAndre Fischer #include <vector>
327a32b0c8SAndre Fischer 
337a32b0c8SAndre Fischer class ScrollBar;
347a32b0c8SAndre Fischer class Window;
357a32b0c8SAndre Fischer 
367a32b0c8SAndre Fischer namespace css = ::com::sun::star;
377a32b0c8SAndre Fischer 
387a32b0c8SAndre Fischer namespace sfx2 { namespace sidebar {
397a32b0c8SAndre Fischer 
407a32b0c8SAndre Fischer class Panel;
417a32b0c8SAndre Fischer 
427a32b0c8SAndre Fischer 
437a32b0c8SAndre Fischer /** Helper class for layouting the direct and indirect children of a
447a32b0c8SAndre Fischer     deck like title bars, panels, and scroll bars.
457a32b0c8SAndre Fischer */
467a32b0c8SAndre Fischer class DeckLayouter
477a32b0c8SAndre Fischer {
487a32b0c8SAndre Fischer public:
497a32b0c8SAndre Fischer     static void LayoutDeck (
507a32b0c8SAndre Fischer         const Rectangle aContentArea,
51f120fe41SAndre Fischer         SharedPanelContainer& rPanels,
527a32b0c8SAndre Fischer         Window& pDeckTitleBar,
537a32b0c8SAndre Fischer         Window& pScrollClipWindow,
547a32b0c8SAndre Fischer         Window& pScrollContainer,
557a32b0c8SAndre Fischer         Window& pFiller,
567a32b0c8SAndre Fischer         ScrollBar& pVerticalScrollBar);
577a32b0c8SAndre Fischer 
587a32b0c8SAndre Fischer private:
597a32b0c8SAndre Fischer     // Do not use constructor or destructor.
607a32b0c8SAndre Fischer     DeckLayouter (void);
617a32b0c8SAndre Fischer     ~DeckLayouter (void);
627a32b0c8SAndre Fischer 
637a32b0c8SAndre Fischer     enum LayoutMode
647a32b0c8SAndre Fischer     {
657a32b0c8SAndre Fischer         MinimumOrLarger,
667a32b0c8SAndre Fischer         PreferredOrLarger,
677a32b0c8SAndre Fischer         Preferred
687a32b0c8SAndre Fischer     };
697a32b0c8SAndre Fischer     class LayoutItem
707a32b0c8SAndre Fischer     {
717a32b0c8SAndre Fischer     public:
72f120fe41SAndre Fischer         SharedPanel mpPanel;
737a32b0c8SAndre Fischer         css::ui::LayoutSize maLayoutSize;
747a32b0c8SAndre Fischer         sal_Int32 mnDistributedHeight;
757a32b0c8SAndre Fischer         sal_Int32 mnWeight;
767a32b0c8SAndre Fischer         sal_Int32 mnPanelIndex;
77*54eaaa32SAndre Fischer         bool mbShowTitleBar;
787a32b0c8SAndre Fischer 
LayoutItem(void)79*54eaaa32SAndre Fischer         LayoutItem (void)
80*54eaaa32SAndre Fischer             : mpPanel(),maLayoutSize(0,0,0),mnDistributedHeight(0),mnWeight(0),mnPanelIndex(0),mbShowTitleBar(true)
81*54eaaa32SAndre Fischer         {}
827a32b0c8SAndre Fischer     };
837a32b0c8SAndre Fischer     static Rectangle LayoutPanels (
847a32b0c8SAndre Fischer         const Rectangle aContentArea,
857a32b0c8SAndre Fischer         ::std::vector<LayoutItem>& rLayoutItems,
867a32b0c8SAndre Fischer         Window& rScrollClipWindow,
877a32b0c8SAndre Fischer         Window& rScrollContainer,
887a32b0c8SAndre Fischer         ScrollBar& pVerticalScrollBar,
897a32b0c8SAndre Fischer         const bool bShowVerticalScrollBar);
907a32b0c8SAndre Fischer     static void GetRequestedSizes (
917a32b0c8SAndre Fischer         ::std::vector<LayoutItem>& rLayoutItem,
927a32b0c8SAndre Fischer         sal_Int32& rAvailableHeight,
937a32b0c8SAndre Fischer         const Rectangle& rContentBox);
947a32b0c8SAndre Fischer     static void DistributeHeights (
957a32b0c8SAndre Fischer         ::std::vector<LayoutItem>& rLayoutItems,
967a32b0c8SAndre Fischer         const sal_Int32 nHeightToDistribute,
977a32b0c8SAndre Fischer         const sal_Int32 nContainerHeight,
987a32b0c8SAndre Fischer         const bool bMinimumHeightIsBase);
997a32b0c8SAndre Fischer     static sal_Int32 PlacePanels (
1007a32b0c8SAndre Fischer         ::std::vector<LayoutItem>& rLayoutItems,
1017a32b0c8SAndre Fischer         const sal_Int32 nWidth,
1027a32b0c8SAndre Fischer         const LayoutMode eMode,
1037a32b0c8SAndre Fischer         Window& rScrollContainer);
1047a32b0c8SAndre Fischer     static Rectangle PlaceDeckTitle (
1057a32b0c8SAndre Fischer         Window& rTittleBar,
1067a32b0c8SAndre Fischer         const Rectangle& rAvailableSpace);
1077a32b0c8SAndre Fischer     static Rectangle PlaceVerticalScrollBar (
1087a32b0c8SAndre Fischer         ScrollBar& rVerticalScrollBar,
1097a32b0c8SAndre Fischer         const Rectangle& rAvailableSpace,
1107a32b0c8SAndre Fischer         const bool bShowVerticalScrollBar);
1117a32b0c8SAndre Fischer     static void SetupVerticalScrollBar(
1127a32b0c8SAndre Fischer         ScrollBar& rVerticalScrollBar,
1137a32b0c8SAndre Fischer         const sal_Int32 nContentHeight,
1147a32b0c8SAndre Fischer         const sal_Int32 nVisibleHeight);
1157a32b0c8SAndre Fischer     static void UpdateFiller (
1167a32b0c8SAndre Fischer         Window& rFiller,
1177a32b0c8SAndre Fischer         const Rectangle& rBox);
1187a32b0c8SAndre Fischer };
1197a32b0c8SAndre Fischer 
1207a32b0c8SAndre Fischer 
1217a32b0c8SAndre Fischer } } // end of namespace sfx2::sidebar
1227a32b0c8SAndre Fischer 
1237a32b0c8SAndre Fischer #endif
124