1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef LAYOUT_CORE_CONTAINER_HXX 29 #define LAYOUT_CORE_CONTAINER_HXX 30 31 #include <layout/core/helper.hxx> 32 33 #include <cppuhelper/implbase2.hxx> 34 #include <com/sun/star/awt/MaxChildrenException.hpp> 35 36 namespace layoutimpl 37 { 38 namespace css = ::com::sun::star; 39 40 typedef ::cppu::WeakImplHelper2< css::awt::XLayoutContainer, 41 css::awt::XLayoutConstrains > Container_Base; 42 43 class TOOLKIT_DLLPUBLIC Container : public Container_Base, public PropHelper, public PropHelper::Listener 44 { 45 friend class ChildProps; 46 protected: 47 // Widget properties 48 css::uno::Reference< css::awt::XLayoutContainer > mxParent; 49 css::uno::Reference< css::awt::XLayoutUnit > mxLayoutUnit; 50 css::awt::Size maRequisition; 51 css::awt::Rectangle maAllocation; 52 53 // Container properties 54 sal_Int32 mnBorderWidth; 55 56 // Utilities 57 void allocateChildAt( const css::uno::Reference< css::awt::XLayoutConstrains > &xChild, 58 const css::awt::Rectangle &rArea ) 59 throw (css::uno::RuntimeException); 60 static css::uno::Sequence< css::uno::Reference< css::awt::XLayoutConstrains > > 61 getSingleChild (const css::uno::Reference< css::awt::XLayoutConstrains > &xChildOrNil); 62 void setChildParent( const css::uno::Reference< css::awt::XLayoutConstrains >& xChild ); 63 void unsetChildParent( const css::uno::Reference< css::awt::XLayoutConstrains >& xChild ); 64 65 void queueResize(); 66 void forceRecalc() { allocateArea( maAllocation ); } 67 68 public: 69 Container(); 70 virtual ~Container() {} 71 72 virtual bool emptyVisible (); 73 74 // XInterface 75 virtual void SAL_CALL acquire() throw() { PropHelper::acquire(); } 76 virtual void SAL_CALL release() throw() { PropHelper::release(); } 77 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); 78 79 // css::awt::XLayoutContainer 80 virtual void SAL_CALL addChild( const css::uno::Reference< css::awt::XLayoutConstrains >& Child ) 81 throw (css::uno::RuntimeException, css::awt::MaxChildrenException) = 0; 82 virtual void SAL_CALL removeChild( const css::uno::Reference< css::awt::XLayoutConstrains >& Child ) 83 throw (css::uno::RuntimeException) = 0; 84 85 virtual css::uno::Sequence< css::uno::Reference 86 < css::awt::XLayoutConstrains > > SAL_CALL getChildren() 87 throw (css::uno::RuntimeException) = 0; 88 89 virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getChildProperties( 90 const css::uno::Reference< css::awt::XLayoutConstrains >& Child ) 91 throw (css::uno::RuntimeException) = 0; 92 93 virtual void SAL_CALL allocateArea( const css::awt::Rectangle &rArea ) 94 throw (css::uno::RuntimeException) = 0; 95 96 void SAL_CALL setLayoutUnit( const css::uno::Reference< css::awt::XLayoutUnit > &xUnit ) 97 throw(css::uno::RuntimeException) 98 { mxLayoutUnit = xUnit; } 99 css::uno::Reference< css::awt::XLayoutUnit > SAL_CALL getLayoutUnit() 100 throw(css::uno::RuntimeException) 101 { return mxLayoutUnit; } 102 103 css::awt::Size SAL_CALL getRequestedSize() throw(css::uno::RuntimeException) 104 { return maRequisition; } 105 com::sun::star::awt::Rectangle SAL_CALL getAllocatedArea() throw(css::uno::RuntimeException) 106 { return maAllocation; } 107 108 virtual sal_Bool SAL_CALL hasHeightForWidth() 109 throw(css::uno::RuntimeException) = 0; 110 virtual sal_Int32 SAL_CALL getHeightForWidth( sal_Int32 nWidth ) 111 throw(css::uno::RuntimeException) = 0; 112 113 // css::awt::XLayoutContainer: css::container::XChild 114 css::uno::Reference< css::uno::XInterface > SAL_CALL getParent() 115 throw (css::uno::RuntimeException) 116 { return mxParent; } 117 void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface > &xParent ) 118 throw (css::uno::RuntimeException) 119 { mxParent = css::uno::Reference< css::awt::XLayoutContainer >( xParent, css::uno::UNO_QUERY ); } 120 121 // css::awt::XLayoutConstrains 122 virtual css::awt::Size SAL_CALL getMinimumSize() 123 throw(css::uno::RuntimeException) = 0; 124 // (not properly implemented in toolkit, ignore it.) 125 css::awt::Size SAL_CALL getPreferredSize() 126 throw(css::uno::RuntimeException) { return getMinimumSize(); } // TODO: use this for flow? 127 css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& rNewSize ) 128 throw(css::uno::RuntimeException) { return rNewSize; } 129 130 protected: 131 void propertiesChanged(); 132 }; 133 134 } // namespace layoutimpl 135 136 #endif /* LAYOUT_CORE_CONTAINER_HXX */ 137