1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
34 #include <sal/macros.h>
43 Bin::Bin() : Container()
48 Bin::addChild( const uno::Reference
< awt::XLayoutConstrains
>& xChild
)
49 throw (uno::RuntimeException
, awt::MaxChildrenException
)
52 throw awt::MaxChildrenException();
56 setChildParent( xChild
);
62 Bin::removeChild( const uno::Reference
< awt::XLayoutConstrains
>& xChild
)
63 throw (uno::RuntimeException
)
65 if ( xChild
== mxChild
)
67 mxChild
= uno::Reference
< awt::XLayoutConstrains
>();
68 unsetChildParent( xChild
);
73 uno::Sequence
< uno::Reference
< awt::XLayoutConstrains
> > SAL_CALL
75 throw (uno::RuntimeException
)
77 return getSingleChild (mxChild
);
81 Bin::allocateArea( const awt::Rectangle
&rArea
)
82 throw (uno::RuntimeException
)
86 allocateChildAt( mxChild
, rArea
);
91 throw(uno::RuntimeException
)
94 return maRequisition
= maChildRequisition
= mxChild
->getMinimumSize();
95 return maRequisition
= awt::Size( 0, 0 );
98 uno::Reference
< beans::XPropertySet
> SAL_CALL
99 Bin::getChildProperties( const uno::Reference
< awt::XLayoutConstrains
>& )
100 throw (uno::RuntimeException
)
102 return uno::Reference
< beans::XPropertySet
>();
106 Bin::hasHeightForWidth()
107 throw(uno::RuntimeException
)
109 uno::Reference
< awt::XLayoutContainer
> xChildCont( mxChild
, uno::UNO_QUERY
);
110 if ( xChildCont
.is() )
111 return xChildCont
->hasHeightForWidth();
116 Bin::getHeightForWidth( sal_Int32 nWidth
)
117 throw(uno::RuntimeException
)
119 uno::Reference
< awt::XLayoutContainer
> xChildCont( mxChild
, uno::UNO_QUERY
);
120 if ( xChildCont
.is() )
121 return xChildCont
->getHeightForWidth( nWidth
);
122 return maRequisition
.Height
;
127 Align::Align() : Bin()
129 addProp( RTL_CONSTASCII_USTRINGPARAM( "Halign" ),
130 ::getCppuType( static_cast< const float* >( NULL
) ),
132 addProp( RTL_CONSTASCII_USTRINGPARAM( "Valign" ),
133 ::getCppuType( static_cast< const float* >( NULL
) ),
135 addProp( RTL_CONSTASCII_USTRINGPARAM( "Hfill" ),
136 ::getCppuType( static_cast< const float* >( NULL
) ),
138 addProp( RTL_CONSTASCII_USTRINGPARAM( "Vfill" ),
139 ::getCppuType( static_cast< const float* >( NULL
) ),
142 fHorAlign
= fVerAlign
= 0.5;
143 fHorFill
= fVerFill
= 0;
147 Align::allocateArea( const awt::Rectangle
&rArea
)
148 throw (uno::RuntimeException
)
150 maAllocation
= rArea
;
154 awt::Rectangle aChildArea
;
155 aChildArea
.Width
= SAL_MIN( rArea
.Width
, maChildRequisition
.Width
);
156 aChildArea
.Width
+= (sal_Int32
) SAL_MAX(
157 0, (rArea
.Width
- maChildRequisition
.Width
) * fHorFill
);
158 aChildArea
.Height
= SAL_MIN( rArea
.Height
, maChildRequisition
.Height
);
159 aChildArea
.Height
+= (sal_Int32
) SAL_MAX(
160 0, (rArea
.Height
- maChildRequisition
.Height
) * fVerFill
);
162 aChildArea
.X
= rArea
.X
+ (sal_Int32
)( (rArea
.Width
- aChildArea
.Width
) * fHorAlign
);
163 aChildArea
.Y
= rArea
.Y
+ (sal_Int32
)( (rArea
.Height
- aChildArea
.Height
) * fVerAlign
);
165 allocateChildAt( mxChild
, aChildArea
);
169 Align::emptyVisible ()
176 MinSize::MinSize() : Bin()
178 mnMinWidth
= mnMinHeight
= 0;
179 addProp( RTL_CONSTASCII_USTRINGPARAM( "MinWidth" ),
180 ::getCppuType( static_cast< const long* >( NULL
) ),
182 addProp( RTL_CONSTASCII_USTRINGPARAM( "MinHeight" ),
183 ::getCppuType( static_cast< const long* >( NULL
) ),
188 MinSize::emptyVisible ()
193 awt::Size SAL_CALL
MinSize::getMinimumSize()
194 throw(uno::RuntimeException
)
196 Bin::getMinimumSize();
197 maRequisition
.Width
= SAL_MAX( maRequisition
.Width
, mnMinWidth
);
198 maRequisition
.Height
= SAL_MAX( maRequisition
.Height
, mnMinHeight
);
199 return maRequisition
;
202 } // namespace layoutimpl