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 ************************************************************************/
32 #ifndef LAYOUT_CORE_BOX_HXX
33 #define LAYOUT_CORE_BOX_HXX
35 #include <layout/core/box-base.hxx>
37 #include <com/sun/star/awt/Point.hpp>
42 class Box
: public Box_Base
45 // Box properties (i.e. affect all children)
47 sal_Bool mbHomogeneous
;
48 sal_Bool mbHorizontal
; // false for Vertical
49 bool mbHasFlowChildren
;
52 // Children properties
53 struct ChildData
: public Box_Base::ChildData
58 ChildData( css::uno::Reference
< css::awt::XLayoutConstrains
> const& xChild
);
61 struct ChildProps
: public Box_Base::ChildProps
63 ChildProps( ChildData
*pData
);
67 ChildData
*createChild( css::uno::Reference
< css::awt::XLayoutConstrains
> const& xChild
);
68 ChildProps
*createChildProps( Box_Base::ChildData
* pData
);
71 Box( bool horizontal
);
73 virtual void SAL_CALL
allocateArea( const css::awt::Rectangle
&rArea
)
74 throw (css::uno::RuntimeException
);
76 virtual css::awt::Size SAL_CALL
getMinimumSize()
77 throw(css::uno::RuntimeException
);
78 virtual sal_Bool SAL_CALL
hasHeightForWidth()
79 throw(css::uno::RuntimeException
);
80 virtual sal_Int32 SAL_CALL
getHeightForWidth( sal_Int32 nWidth
)
81 throw(css::uno::RuntimeException
);
83 // helper: mix of getMinimumSize() and getHeightForWidth()
84 css::awt::Size
calculateSize( long nWidth
= 0 );
87 /* Helpers to deal with the joint Box directions. */
88 inline int primDim (const css::awt::Size
&size
)
89 { if (mbHorizontal
) return size
.Width
; else return size
.Height
; }
90 inline int secDim (const css::awt::Size
&size
)
91 { if (mbHorizontal
) return size
.Height
; else return size
.Width
; }
92 inline int primDim (const css::awt::Point
&point
)
93 { if (mbHorizontal
) return point
.X
; else return point
.Y
; }
94 inline int secDim (const css::awt::Point
&point
)
95 { if (mbHorizontal
) return point
.Y
; else return point
.X
; }
98 struct VBox
: public Box
99 { VBox() : Box (false) {} };
101 struct HBox
: public Box
102 { HBox() : Box (true) {} };
104 } // namespace layoutimpl
106 #endif /* LAYOUT_CORE_BOX_HXX */