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 "Panel.hxx" 26 27 #include <tools/gen.hxx> 28 29 #include <com/sun/star/ui/LayoutSize.hpp> 30 31 #include <vector> 32 33 class ScrollBar; 34 class Window; 35 36 namespace css = ::com::sun::star; 37 38 namespace sfx2 { namespace sidebar { 39 40 class Panel; 41 42 43 /** Helper class for layouting the direct and indirect children of a 44 deck like title bars, panels, and scroll bars. 45 */ 46 class DeckLayouter 47 { 48 public: 49 static void LayoutDeck ( 50 const Rectangle aContentArea, 51 SharedPanelContainer& rPanels, 52 Window& pDeckTitleBar, 53 Window& pScrollClipWindow, 54 Window& pScrollContainer, 55 Window& pFiller, 56 ScrollBar& pVerticalScrollBar); 57 58 private: 59 // Do not use constructor or destructor. 60 DeckLayouter (void); 61 ~DeckLayouter (void); 62 63 enum LayoutMode 64 { 65 MinimumOrLarger, 66 PreferredOrLarger, 67 Preferred 68 }; 69 class LayoutItem 70 { 71 public: 72 SharedPanel mpPanel; 73 css::ui::LayoutSize maLayoutSize; 74 sal_Int32 mnDistributedHeight; 75 sal_Int32 mnWeight; 76 sal_Int32 mnPanelIndex; 77 78 LayoutItem (void) : mpPanel(),maLayoutSize(0,0,0),mnDistributedHeight(0),mnWeight(0),mnPanelIndex(0) {} 79 }; 80 static Rectangle LayoutPanels ( 81 const Rectangle aContentArea, 82 ::std::vector<LayoutItem>& rLayoutItems, 83 Window& rScrollClipWindow, 84 Window& rScrollContainer, 85 ScrollBar& pVerticalScrollBar, 86 const bool bShowVerticalScrollBar); 87 static void GetRequestedSizes ( 88 ::std::vector<LayoutItem>& rLayoutItem, 89 sal_Int32& rAvailableHeight, 90 const Rectangle& rContentBox); 91 static void DistributeHeights ( 92 ::std::vector<LayoutItem>& rLayoutItems, 93 const sal_Int32 nHeightToDistribute, 94 const sal_Int32 nContainerHeight, 95 const bool bMinimumHeightIsBase); 96 static sal_Int32 PlacePanels ( 97 ::std::vector<LayoutItem>& rLayoutItems, 98 const sal_Int32 nWidth, 99 const LayoutMode eMode, 100 Window& rScrollContainer); 101 static Rectangle PlaceDeckTitle ( 102 Window& rTittleBar, 103 const Rectangle& rAvailableSpace); 104 static Rectangle PlaceVerticalScrollBar ( 105 ScrollBar& rVerticalScrollBar, 106 const Rectangle& rAvailableSpace, 107 const bool bShowVerticalScrollBar); 108 static void SetupVerticalScrollBar( 109 ScrollBar& rVerticalScrollBar, 110 const sal_Int32 nContentHeight, 111 const sal_Int32 nVisibleHeight); 112 static void UpdateFiller ( 113 Window& rFiller, 114 const Rectangle& rBox); 115 }; 116 117 118 } } // end of namespace sfx2::sidebar 119 120 #endif 121