1 /*************************************************************************
2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3  *
4  * Copyright 2000, 2010 Oracle and/or its affiliates.
5  *
6  * OpenOffice.org - a multi-platform office productivity suite
7  *
8  * This file is part of OpenOffice.org.
9  *
10  * OpenOffice.org is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Lesser General Public License version 3
12  * only, as published by the Free Software Foundation.
13  *
14  * OpenOffice.org is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Lesser General Public License version 3 for more details
18  * (a copy is included in the LICENSE file that accompanied this code).
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with OpenOffice.org.  If not, see
22  * <http://www.openoffice.org/license.html>
23  * for a copy of the LGPLv3 License.
24  *
25 ************************************************************************/
26 
27 #ifndef TABBARGEOMETRY_HXX
28 #define TABBARGEOMETRY_HXX
29 
30 #include "svtools/toolpanel/tabalignment.hxx"
31 
32 #include "tabitemdescriptor.hxx"
33 
34 #include <tools/gen.hxx>
35 #include <tools/svborder.hxx>
36 
37 //......................................................................................................................
38 namespace svt
39 {
40 //......................................................................................................................
41 
42 	//==================================================================================================================
43 	//= NormalizedArea
44 	//==================================================================================================================
45     /** a rectangle which automatically translates between unrotated and rotated geometry.
46 
47         It can be operated as if it were an unrotated area, but is able to provide corrdinates of rotated objects,
48         relative to its playground.
49     */
50 	class NormalizedArea
51 	{
52     public:
53         NormalizedArea();
54         NormalizedArea( const Rectangle& i_rReference, const bool i_bIsVertical );
55 
56         /** transforms a rectangle, relative to our playground, into a coordinate system defined by the given alignment
57             @param i_rArea
58                 the area which is to be transformed.
59         */
60         Rectangle   getTransformed(
61                         const Rectangle& i_rArea,
62                         const TabAlignment i_eTargetAlignment
63                     ) const;
64 
65         /** normalizes an already transformed rectangle
66             @param i_rArea
67                 the area which is to be normalized.
68         */
69         Rectangle   getNormalized(
70                         const Rectangle& i_rArea,
71                         const TabAlignment i_eTargetAlignment
72                     ) const;
73 
74 
75         Size        getReferenceSize() const { return m_aReference.GetSize(); }
76         const Rectangle&
77                     getReference() const { return m_aReference; }
78 
79     private:
80         // the normalized reference area
81         Rectangle   m_aReference;
82 	};
83 
84 	//==================================================================================================================
85 	//= TabBarGeometry
86 	//==================================================================================================================
87     class TabBarGeometry_Impl;
88     class TabBarGeometry
89     {
90     public:
91         TabBarGeometry( const TabItemContent i_eItemContent );
92         ~TabBarGeometry();
93 
94         // retrieves the rectangle to be occupied by the button for scrolling backward through the items
95         const Rectangle&    getButtonBackRect() const { return m_aButtonBackRect; }
96         // retrieves the rectangle to be occupied by the items
97         const Rectangle&    getItemsRect() const { return m_aItemsRect; }
98         // retrieves the rectangle to be occupied by the button for scrolling forward through the items
99         const Rectangle&    getButtonForwardRect() const { return m_aButtonForwardRect; }
100 
101         inline TabItemContent
102                             getItemContent() const { return m_eTabItemContent; }
103         inline void         setItemContent( const TabItemContent i_eItemContent ) { m_eTabItemContent = i_eItemContent; }
104 
105         /** adjusts the sizes of the buttons and the item's playground, plus the sizes of the items
106         */
107         void    relayout( const Size& i_rActualOutputSize, ItemDescriptors& io_rItems );
108 
109         /** calculates the optimal size of the tab bar, depending on the item's sizes
110         */
111         Size    getOptimalSize( ItemDescriptors& io_rItems, const bool i_bMinimalSize ) const;
112 
113         /** retrieves the position where the first item should start, relative to the item rect
114         */
115         Point   getFirstItemPosition() const;
116 
117     private:
118         bool    impl_fitItems( ItemDescriptors& io_rItems ) const;
119 
120     private:
121         /// specifies the content to be displayed in the tab items
122         TabItemContent      m_eTabItemContent;
123         /// specifies the inset to be used in the items area, depends on the actual alignment
124         SvBorder            m_aItemsInset;
125         // the (logical) rectangle to be used for the "back" button, empty if the button is not needed
126         Rectangle           m_aButtonBackRect;
127         // the (logical) rectangle to be used for the items
128         Rectangle           m_aItemsRect;
129         // the (logical) rectangle to be used for the "forward" button, empty if the button is not needed
130         Rectangle           m_aButtonForwardRect;
131     };
132 
133 //......................................................................................................................
134 } // namespace svt
135 //......................................................................................................................
136 
137 #endif // TABBARGEOMETRY_HXX
138