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_CONTAINER_HXX
33 #define LAYOUT_CORE_CONTAINER_HXX
35 #include <layout/core/helper.hxx>
37 #include <cppuhelper/implbase2.hxx>
38 #include <com/sun/star/awt/MaxChildrenException.hpp>
42 namespace css
= ::com::sun::star
;
44 typedef ::cppu::WeakImplHelper2
< css::awt::XLayoutContainer
,
45 css::awt::XLayoutConstrains
> Container_Base
;
47 class TOOLKIT_DLLPUBLIC Container
: public Container_Base
, public PropHelper
, public PropHelper::Listener
49 friend class ChildProps
;
52 css::uno::Reference
< css::awt::XLayoutContainer
> mxParent
;
53 css::uno::Reference
< css::awt::XLayoutUnit
> mxLayoutUnit
;
54 css::awt::Size maRequisition
;
55 css::awt::Rectangle maAllocation
;
57 // Container properties
58 sal_Int32 mnBorderWidth
;
61 void allocateChildAt( const css::uno::Reference
< css::awt::XLayoutConstrains
> &xChild
,
62 const css::awt::Rectangle
&rArea
)
63 throw (css::uno::RuntimeException
);
64 static css::uno::Sequence
< css::uno::Reference
< css::awt::XLayoutConstrains
> >
65 getSingleChild (const css::uno::Reference
< css::awt::XLayoutConstrains
> &xChildOrNil
);
66 void setChildParent( const css::uno::Reference
< css::awt::XLayoutConstrains
>& xChild
);
67 void unsetChildParent( const css::uno::Reference
< css::awt::XLayoutConstrains
>& xChild
);
70 void forceRecalc() { allocateArea( maAllocation
); }
74 virtual ~Container() {}
76 virtual bool emptyVisible ();
79 virtual void SAL_CALL
acquire() throw() { PropHelper::acquire(); }
80 virtual void SAL_CALL
release() throw() { PropHelper::release(); }
81 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
);
83 // css::awt::XLayoutContainer
84 virtual void SAL_CALL
addChild( const css::uno::Reference
< css::awt::XLayoutConstrains
>& Child
)
85 throw (css::uno::RuntimeException
, css::awt::MaxChildrenException
) = 0;
86 virtual void SAL_CALL
removeChild( const css::uno::Reference
< css::awt::XLayoutConstrains
>& Child
)
87 throw (css::uno::RuntimeException
) = 0;
89 virtual css::uno::Sequence
< css::uno::Reference
90 < css::awt::XLayoutConstrains
> > SAL_CALL
getChildren()
91 throw (css::uno::RuntimeException
) = 0;
93 virtual css::uno::Reference
< css::beans::XPropertySet
> SAL_CALL
getChildProperties(
94 const css::uno::Reference
< css::awt::XLayoutConstrains
>& Child
)
95 throw (css::uno::RuntimeException
) = 0;
97 virtual void SAL_CALL
allocateArea( const css::awt::Rectangle
&rArea
)
98 throw (css::uno::RuntimeException
) = 0;
100 void SAL_CALL
setLayoutUnit( const css::uno::Reference
< css::awt::XLayoutUnit
> &xUnit
)
101 throw(css::uno::RuntimeException
)
102 { mxLayoutUnit
= xUnit
; }
103 css::uno::Reference
< css::awt::XLayoutUnit
> SAL_CALL
getLayoutUnit()
104 throw(css::uno::RuntimeException
)
105 { return mxLayoutUnit
; }
107 css::awt::Size SAL_CALL
getRequestedSize() throw(css::uno::RuntimeException
)
108 { return maRequisition
; }
109 com::sun::star::awt::Rectangle SAL_CALL
getAllocatedArea() throw(css::uno::RuntimeException
)
110 { return maAllocation
; }
112 virtual sal_Bool SAL_CALL
hasHeightForWidth()
113 throw(css::uno::RuntimeException
) = 0;
114 virtual sal_Int32 SAL_CALL
getHeightForWidth( sal_Int32 nWidth
)
115 throw(css::uno::RuntimeException
) = 0;
117 // css::awt::XLayoutContainer: css::container::XChild
118 css::uno::Reference
< css::uno::XInterface
> SAL_CALL
getParent()
119 throw (css::uno::RuntimeException
)
121 void SAL_CALL
setParent( const css::uno::Reference
< css::uno::XInterface
> &xParent
)
122 throw (css::uno::RuntimeException
)
123 { mxParent
= css::uno::Reference
< css::awt::XLayoutContainer
>( xParent
, css::uno::UNO_QUERY
); }
125 // css::awt::XLayoutConstrains
126 virtual css::awt::Size SAL_CALL
getMinimumSize()
127 throw(css::uno::RuntimeException
) = 0;
128 // (not properly implemented in toolkit, ignore it.)
129 css::awt::Size SAL_CALL
getPreferredSize()
130 throw(css::uno::RuntimeException
) { return getMinimumSize(); } // TODO: use this for flow?
131 css::awt::Size SAL_CALL
calcAdjustedSize( const css::awt::Size
& rNewSize
)
132 throw(css::uno::RuntimeException
) { return rNewSize
; }
135 void propertiesChanged();
138 } // namespace layoutimpl
140 #endif /* LAYOUT_CORE_CONTAINER_HXX */