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 
23 
24 #ifndef TABBARGEOMETRY_HXX
25 #define TABBARGEOMETRY_HXX
26 
27 #include "svtools/toolpanel/tabalignment.hxx"
28 
29 #include "tabitemdescriptor.hxx"
30 
31 #include <tools/gen.hxx>
32 #include <tools/svborder.hxx>
33 
34 //......................................................................................................................
35 namespace svt
36 {
37 //......................................................................................................................
38 
39 	//==================================================================================================================
40 	//= NormalizedArea
41 	//==================================================================================================================
42     /** a rectangle which automatically translates between unrotated and rotated geometry.
43 
44         It can be operated as if it were an unrotated area, but is able to provide corrdinates of rotated objects,
45         relative to its playground.
46     */
47 	class NormalizedArea
48 	{
49     public:
50         NormalizedArea();
51         NormalizedArea( const Rectangle& i_rReference, const bool i_bIsVertical );
52 
53         /** transforms a rectangle, relative to our playground, into a coordinate system defined by the given alignment
54             @param i_rArea
55                 the area which is to be transformed.
56         */
57         Rectangle   getTransformed(
58                         const Rectangle& i_rArea,
59                         const TabAlignment i_eTargetAlignment
60                     ) const;
61 
62         /** normalizes an already transformed rectangle
63             @param i_rArea
64                 the area which is to be normalized.
65         */
66         Rectangle   getNormalized(
67                         const Rectangle& i_rArea,
68                         const TabAlignment i_eTargetAlignment
69                     ) const;
70 
71 
getReferenceSize() const72         Size        getReferenceSize() const { return m_aReference.GetSize(); }
73         const Rectangle&
getReference() const74                     getReference() const { return m_aReference; }
75 
76     private:
77         // the normalized reference area
78         Rectangle   m_aReference;
79 	};
80 
81 	//==================================================================================================================
82 	//= TabBarGeometry
83 	//==================================================================================================================
84     class TabBarGeometry_Impl;
85     class TabBarGeometry
86     {
87     public:
88         TabBarGeometry( const TabItemContent i_eItemContent );
89         ~TabBarGeometry();
90 
91         // retrieves the rectangle to be occupied by the button for scrolling backward through the items
getButtonBackRect() const92         const Rectangle&    getButtonBackRect() const { return m_aButtonBackRect; }
93         // retrieves the rectangle to be occupied by the items
getItemsRect() const94         const Rectangle&    getItemsRect() const { return m_aItemsRect; }
95         // retrieves the rectangle to be occupied by the button for scrolling forward through the items
getButtonForwardRect() const96         const Rectangle&    getButtonForwardRect() const { return m_aButtonForwardRect; }
97 
98         inline TabItemContent
getItemContent() const99                             getItemContent() const { return m_eTabItemContent; }
setItemContent(const TabItemContent i_eItemContent)100         inline void         setItemContent( const TabItemContent i_eItemContent ) { m_eTabItemContent = i_eItemContent; }
101 
102         /** adjusts the sizes of the buttons and the item's playground, plus the sizes of the items
103         */
104         void    relayout( const Size& i_rActualOutputSize, ItemDescriptors& io_rItems );
105 
106         /** calculates the optimal size of the tab bar, depending on the item's sizes
107         */
108         Size    getOptimalSize( ItemDescriptors& io_rItems, const bool i_bMinimalSize ) const;
109 
110         /** retrieves the position where the first item should start, relative to the item rect
111         */
112         Point   getFirstItemPosition() const;
113 
114     private:
115         bool    impl_fitItems( ItemDescriptors& io_rItems ) const;
116 
117     private:
118         /// specifies the content to be displayed in the tab items
119         TabItemContent      m_eTabItemContent;
120         /// specifies the inset to be used in the items area, depends on the actual alignment
121         SvBorder            m_aItemsInset;
122         // the (logical) rectangle to be used for the "back" button, empty if the button is not needed
123         Rectangle           m_aButtonBackRect;
124         // the (logical) rectangle to be used for the items
125         Rectangle           m_aItemsRect;
126         // the (logical) rectangle to be used for the "forward" button, empty if the button is not needed
127         Rectangle           m_aButtonForwardRect;
128     };
129 
130 //......................................................................................................................
131 } // namespace svt
132 //......................................................................................................................
133 
134 #endif // TABBARGEOMETRY_HXX
135