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 bool mbShowTitleBar; 78 LayoutItem(void)79 LayoutItem (void) 80 : mpPanel(),maLayoutSize(0,0,0),mnDistributedHeight(0),mnWeight(0),mnPanelIndex(0),mbShowTitleBar(true) 81 {} 82 }; 83 static Rectangle LayoutPanels ( 84 const Rectangle aContentArea, 85 ::std::vector<LayoutItem>& rLayoutItems, 86 Window& rScrollClipWindow, 87 Window& rScrollContainer, 88 ScrollBar& pVerticalScrollBar, 89 const bool bShowVerticalScrollBar); 90 static void GetRequestedSizes ( 91 ::std::vector<LayoutItem>& rLayoutItem, 92 sal_Int32& rAvailableHeight, 93 const Rectangle& rContentBox); 94 static void DistributeHeights ( 95 ::std::vector<LayoutItem>& rLayoutItems, 96 const sal_Int32 nHeightToDistribute, 97 const sal_Int32 nContainerHeight, 98 const bool bMinimumHeightIsBase); 99 static sal_Int32 PlacePanels ( 100 ::std::vector<LayoutItem>& rLayoutItems, 101 const sal_Int32 nWidth, 102 const LayoutMode eMode, 103 Window& rScrollContainer); 104 static Rectangle PlaceDeckTitle ( 105 Window& rTittleBar, 106 const Rectangle& rAvailableSpace); 107 static Rectangle PlaceVerticalScrollBar ( 108 ScrollBar& rVerticalScrollBar, 109 const Rectangle& rAvailableSpace, 110 const bool bShowVerticalScrollBar); 111 static void SetupVerticalScrollBar( 112 ScrollBar& rVerticalScrollBar, 113 const sal_Int32 nContentHeight, 114 const sal_Int32 nVisibleHeight); 115 static void UpdateFiller ( 116 Window& rFiller, 117 const Rectangle& rBox); 118 }; 119 120 121 } } // end of namespace sfx2::sidebar 122 123 #endif 124