xref: /AOO42X/main/toolkit/source/layout/core/container.hxx (revision 9bce9b0d387299c68bd81d539e1478357a103de5)
1*50e6b072SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*50e6b072SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*50e6b072SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*50e6b072SAndrew Rist  * distributed with this work for additional information
6*50e6b072SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*50e6b072SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*50e6b072SAndrew Rist  * "License"); you may not use this file except in compliance
9*50e6b072SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*50e6b072SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*50e6b072SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*50e6b072SAndrew Rist  * software distributed under the License is distributed on an
15*50e6b072SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*50e6b072SAndrew Rist  * KIND, either express or implied.  See the License for the
17*50e6b072SAndrew Rist  * specific language governing permissions and limitations
18*50e6b072SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*50e6b072SAndrew Rist  *************************************************************/
21*50e6b072SAndrew Rist 
22*50e6b072SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef LAYOUT_CORE_CONTAINER_HXX
25cdf0e10cSrcweir #define LAYOUT_CORE_CONTAINER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <layout/core/helper.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx>
30cdf0e10cSrcweir #include <com/sun/star/awt/MaxChildrenException.hpp>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir namespace layoutimpl
33cdf0e10cSrcweir {
34cdf0e10cSrcweir namespace css = ::com::sun::star;
35cdf0e10cSrcweir 
36cdf0e10cSrcweir typedef ::cppu::WeakImplHelper2< css::awt::XLayoutContainer,
37cdf0e10cSrcweir                                  css::awt::XLayoutConstrains > Container_Base;
38cdf0e10cSrcweir 
39cdf0e10cSrcweir class TOOLKIT_DLLPUBLIC Container : public Container_Base, public PropHelper, public PropHelper::Listener
40cdf0e10cSrcweir {
41cdf0e10cSrcweir     friend class ChildProps;
42cdf0e10cSrcweir protected:
43cdf0e10cSrcweir     // Widget properties
44cdf0e10cSrcweir     css::uno::Reference< css::awt::XLayoutContainer > mxParent;
45cdf0e10cSrcweir     css::uno::Reference< css::awt::XLayoutUnit > mxLayoutUnit;
46cdf0e10cSrcweir     css::awt::Size maRequisition;
47cdf0e10cSrcweir     css::awt::Rectangle maAllocation;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir     // Container properties
50cdf0e10cSrcweir     sal_Int32 mnBorderWidth;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir     // Utilities
53cdf0e10cSrcweir     void allocateChildAt( const css::uno::Reference< css::awt::XLayoutConstrains > &xChild,
54cdf0e10cSrcweir                           const css::awt::Rectangle &rArea )
55cdf0e10cSrcweir         throw (css::uno::RuntimeException);
56cdf0e10cSrcweir     static css::uno::Sequence< css::uno::Reference< css::awt::XLayoutConstrains > >
57cdf0e10cSrcweir     getSingleChild (const css::uno::Reference< css::awt::XLayoutConstrains > &xChildOrNil);
58cdf0e10cSrcweir     void setChildParent( const css::uno::Reference< css::awt::XLayoutConstrains >& xChild );
59cdf0e10cSrcweir     void unsetChildParent( const css::uno::Reference< css::awt::XLayoutConstrains >& xChild );
60cdf0e10cSrcweir 
61cdf0e10cSrcweir     void queueResize();
forceRecalc()62cdf0e10cSrcweir     void forceRecalc() { allocateArea( maAllocation ); }
63cdf0e10cSrcweir 
64cdf0e10cSrcweir public:
65cdf0e10cSrcweir     Container();
~Container()66cdf0e10cSrcweir     virtual ~Container() {}
67cdf0e10cSrcweir 
68cdf0e10cSrcweir     virtual bool emptyVisible ();
69cdf0e10cSrcweir 
70cdf0e10cSrcweir     // XInterface
acquire()71cdf0e10cSrcweir     virtual void SAL_CALL acquire() throw() { PropHelper::acquire(); }
release()72cdf0e10cSrcweir     virtual void SAL_CALL release() throw() { PropHelper::release(); }
73cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
74cdf0e10cSrcweir 
75cdf0e10cSrcweir     // css::awt::XLayoutContainer
76cdf0e10cSrcweir     virtual void SAL_CALL addChild( const css::uno::Reference< css::awt::XLayoutConstrains >& Child )
77cdf0e10cSrcweir         throw (css::uno::RuntimeException, css::awt::MaxChildrenException) = 0;
78cdf0e10cSrcweir     virtual void SAL_CALL removeChild( const css::uno::Reference< css::awt::XLayoutConstrains >& Child )
79cdf0e10cSrcweir         throw (css::uno::RuntimeException) = 0;
80cdf0e10cSrcweir 
81cdf0e10cSrcweir     virtual css::uno::Sequence< css::uno::Reference
82cdf0e10cSrcweir                                 < css::awt::XLayoutConstrains > > SAL_CALL getChildren()
83cdf0e10cSrcweir         throw (css::uno::RuntimeException) = 0;
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getChildProperties(
86cdf0e10cSrcweir         const css::uno::Reference< css::awt::XLayoutConstrains >& Child )
87cdf0e10cSrcweir         throw (css::uno::RuntimeException) = 0;
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     virtual void SAL_CALL allocateArea( const css::awt::Rectangle &rArea )
90cdf0e10cSrcweir         throw (css::uno::RuntimeException) = 0;
91cdf0e10cSrcweir 
setLayoutUnit(const css::uno::Reference<css::awt::XLayoutUnit> & xUnit)92cdf0e10cSrcweir     void SAL_CALL setLayoutUnit( const css::uno::Reference< css::awt::XLayoutUnit > &xUnit )
93cdf0e10cSrcweir         throw(css::uno::RuntimeException)
94cdf0e10cSrcweir     { mxLayoutUnit = xUnit; }
getLayoutUnit()95cdf0e10cSrcweir     css::uno::Reference< css::awt::XLayoutUnit > SAL_CALL getLayoutUnit()
96cdf0e10cSrcweir         throw(css::uno::RuntimeException)
97cdf0e10cSrcweir     { return mxLayoutUnit; }
98cdf0e10cSrcweir 
getRequestedSize()99cdf0e10cSrcweir     css::awt::Size SAL_CALL getRequestedSize() throw(css::uno::RuntimeException)
100cdf0e10cSrcweir     { return maRequisition; }
getAllocatedArea()101cdf0e10cSrcweir     com::sun::star::awt::Rectangle SAL_CALL getAllocatedArea() throw(css::uno::RuntimeException)
102cdf0e10cSrcweir     { return maAllocation; }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     virtual sal_Bool SAL_CALL hasHeightForWidth()
105cdf0e10cSrcweir         throw(css::uno::RuntimeException) = 0;
106cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getHeightForWidth( sal_Int32 nWidth )
107cdf0e10cSrcweir         throw(css::uno::RuntimeException) = 0;
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     // css::awt::XLayoutContainer: css::container::XChild
getParent()110cdf0e10cSrcweir     css::uno::Reference< css::uno::XInterface > SAL_CALL getParent()
111cdf0e10cSrcweir         throw (css::uno::RuntimeException)
112cdf0e10cSrcweir     { return mxParent; }
setParent(const css::uno::Reference<css::uno::XInterface> & xParent)113cdf0e10cSrcweir     void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface > &xParent )
114cdf0e10cSrcweir         throw (css::uno::RuntimeException)
115cdf0e10cSrcweir     { mxParent = css::uno::Reference< css::awt::XLayoutContainer >( xParent, css::uno::UNO_QUERY ); }
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     // css::awt::XLayoutConstrains
118cdf0e10cSrcweir     virtual css::awt::Size SAL_CALL getMinimumSize()
119cdf0e10cSrcweir         throw(css::uno::RuntimeException) = 0;
120cdf0e10cSrcweir     // (not properly implemented in toolkit, ignore it.)
getPreferredSize()121cdf0e10cSrcweir     css::awt::Size SAL_CALL getPreferredSize()
122cdf0e10cSrcweir         throw(css::uno::RuntimeException) { return getMinimumSize(); } // TODO: use this for flow?
calcAdjustedSize(const css::awt::Size & rNewSize)123cdf0e10cSrcweir     css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& rNewSize )
124cdf0e10cSrcweir         throw(css::uno::RuntimeException) { return rNewSize; }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir protected:
127cdf0e10cSrcweir     void propertiesChanged();
128cdf0e10cSrcweir };
129cdf0e10cSrcweir 
130cdf0e10cSrcweir } //  namespace layoutimpl
131cdf0e10cSrcweir 
132cdf0e10cSrcweir #endif /* LAYOUT_CORE_CONTAINER_HXX */
133