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