1*01aa44aaSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*01aa44aaSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*01aa44aaSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*01aa44aaSAndrew Rist * distributed with this work for additional information 6*01aa44aaSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*01aa44aaSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*01aa44aaSAndrew Rist * "License"); you may not use this file except in compliance 9*01aa44aaSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*01aa44aaSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*01aa44aaSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*01aa44aaSAndrew Rist * software distributed under the License is distributed on an 15*01aa44aaSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*01aa44aaSAndrew Rist * KIND, either express or implied. See the License for the 17*01aa44aaSAndrew Rist * specific language governing permissions and limitations 18*01aa44aaSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*01aa44aaSAndrew Rist *************************************************************/ 21*01aa44aaSAndrew Rist 22*01aa44aaSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef TABBARGEOMETRY_HXX 25cdf0e10cSrcweir #define TABBARGEOMETRY_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "svtools/toolpanel/tabalignment.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "tabitemdescriptor.hxx" 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <tools/gen.hxx> 32cdf0e10cSrcweir #include <tools/svborder.hxx> 33cdf0e10cSrcweir 34cdf0e10cSrcweir //...................................................................................................................... 35cdf0e10cSrcweir namespace svt 36cdf0e10cSrcweir { 37cdf0e10cSrcweir //...................................................................................................................... 38cdf0e10cSrcweir 39cdf0e10cSrcweir //================================================================================================================== 40cdf0e10cSrcweir //= NormalizedArea 41cdf0e10cSrcweir //================================================================================================================== 42cdf0e10cSrcweir /** a rectangle which automatically translates between unrotated and rotated geometry. 43cdf0e10cSrcweir 44cdf0e10cSrcweir It can be operated as if it were an unrotated area, but is able to provide corrdinates of rotated objects, 45cdf0e10cSrcweir relative to its playground. 46cdf0e10cSrcweir */ 47cdf0e10cSrcweir class NormalizedArea 48cdf0e10cSrcweir { 49cdf0e10cSrcweir public: 50cdf0e10cSrcweir NormalizedArea(); 51cdf0e10cSrcweir NormalizedArea( const Rectangle& i_rReference, const bool i_bIsVertical ); 52cdf0e10cSrcweir 53cdf0e10cSrcweir /** transforms a rectangle, relative to our playground, into a coordinate system defined by the given alignment 54cdf0e10cSrcweir @param i_rArea 55cdf0e10cSrcweir the area which is to be transformed. 56cdf0e10cSrcweir */ 57cdf0e10cSrcweir Rectangle getTransformed( 58cdf0e10cSrcweir const Rectangle& i_rArea, 59cdf0e10cSrcweir const TabAlignment i_eTargetAlignment 60cdf0e10cSrcweir ) const; 61cdf0e10cSrcweir 62cdf0e10cSrcweir /** normalizes an already transformed rectangle 63cdf0e10cSrcweir @param i_rArea 64cdf0e10cSrcweir the area which is to be normalized. 65cdf0e10cSrcweir */ 66cdf0e10cSrcweir Rectangle getNormalized( 67cdf0e10cSrcweir const Rectangle& i_rArea, 68cdf0e10cSrcweir const TabAlignment i_eTargetAlignment 69cdf0e10cSrcweir ) const; 70cdf0e10cSrcweir 71cdf0e10cSrcweir getReferenceSize() const72cdf0e10cSrcweir Size getReferenceSize() const { return m_aReference.GetSize(); } 73cdf0e10cSrcweir const Rectangle& getReference() const74cdf0e10cSrcweir getReference() const { return m_aReference; } 75cdf0e10cSrcweir 76cdf0e10cSrcweir private: 77cdf0e10cSrcweir // the normalized reference area 78cdf0e10cSrcweir Rectangle m_aReference; 79cdf0e10cSrcweir }; 80cdf0e10cSrcweir 81cdf0e10cSrcweir //================================================================================================================== 82cdf0e10cSrcweir //= TabBarGeometry 83cdf0e10cSrcweir //================================================================================================================== 84cdf0e10cSrcweir class TabBarGeometry_Impl; 85cdf0e10cSrcweir class TabBarGeometry 86cdf0e10cSrcweir { 87cdf0e10cSrcweir public: 88cdf0e10cSrcweir TabBarGeometry( const TabItemContent i_eItemContent ); 89cdf0e10cSrcweir ~TabBarGeometry(); 90cdf0e10cSrcweir 91cdf0e10cSrcweir // retrieves the rectangle to be occupied by the button for scrolling backward through the items getButtonBackRect() const92cdf0e10cSrcweir const Rectangle& getButtonBackRect() const { return m_aButtonBackRect; } 93cdf0e10cSrcweir // retrieves the rectangle to be occupied by the items getItemsRect() const94cdf0e10cSrcweir const Rectangle& getItemsRect() const { return m_aItemsRect; } 95cdf0e10cSrcweir // retrieves the rectangle to be occupied by the button for scrolling forward through the items getButtonForwardRect() const96cdf0e10cSrcweir const Rectangle& getButtonForwardRect() const { return m_aButtonForwardRect; } 97cdf0e10cSrcweir 98cdf0e10cSrcweir inline TabItemContent getItemContent() const99cdf0e10cSrcweir getItemContent() const { return m_eTabItemContent; } setItemContent(const TabItemContent i_eItemContent)100cdf0e10cSrcweir inline void setItemContent( const TabItemContent i_eItemContent ) { m_eTabItemContent = i_eItemContent; } 101cdf0e10cSrcweir 102cdf0e10cSrcweir /** adjusts the sizes of the buttons and the item's playground, plus the sizes of the items 103cdf0e10cSrcweir */ 104cdf0e10cSrcweir void relayout( const Size& i_rActualOutputSize, ItemDescriptors& io_rItems ); 105cdf0e10cSrcweir 106cdf0e10cSrcweir /** calculates the optimal size of the tab bar, depending on the item's sizes 107cdf0e10cSrcweir */ 108cdf0e10cSrcweir Size getOptimalSize( ItemDescriptors& io_rItems, const bool i_bMinimalSize ) const; 109cdf0e10cSrcweir 110cdf0e10cSrcweir /** retrieves the position where the first item should start, relative to the item rect 111cdf0e10cSrcweir */ 112cdf0e10cSrcweir Point getFirstItemPosition() const; 113cdf0e10cSrcweir 114cdf0e10cSrcweir private: 115cdf0e10cSrcweir bool impl_fitItems( ItemDescriptors& io_rItems ) const; 116cdf0e10cSrcweir 117cdf0e10cSrcweir private: 118cdf0e10cSrcweir /// specifies the content to be displayed in the tab items 119cdf0e10cSrcweir TabItemContent m_eTabItemContent; 120cdf0e10cSrcweir /// specifies the inset to be used in the items area, depends on the actual alignment 121cdf0e10cSrcweir SvBorder m_aItemsInset; 122cdf0e10cSrcweir // the (logical) rectangle to be used for the "back" button, empty if the button is not needed 123cdf0e10cSrcweir Rectangle m_aButtonBackRect; 124cdf0e10cSrcweir // the (logical) rectangle to be used for the items 125cdf0e10cSrcweir Rectangle m_aItemsRect; 126cdf0e10cSrcweir // the (logical) rectangle to be used for the "forward" button, empty if the button is not needed 127cdf0e10cSrcweir Rectangle m_aButtonForwardRect; 128cdf0e10cSrcweir }; 129cdf0e10cSrcweir 130cdf0e10cSrcweir //...................................................................................................................... 131cdf0e10cSrcweir } // namespace svt 132cdf0e10cSrcweir //...................................................................................................................... 133cdf0e10cSrcweir 134cdf0e10cSrcweir #endif // TABBARGEOMETRY_HXX 135