1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef LAYOUT_AWT_VCLXTABCONTROLLER_HXX 25 #define LAYOUT_AWT_VCLXTABCONTROLLER_HXX 26 27 #include <com/sun/star/awt/XSimpleTabController.hpp> 28 #include <comphelper/uno3.hxx> 29 #include <layout/core/box-base.hxx> 30 #include <map> 31 #include <toolkit/awt/vclxwindow.hxx> 32 33 class TabControl; 34 35 namespace layoutimpl 36 { 37 38 typedef ::cppu::ImplHelper1 < ::com::sun::star::awt::XSimpleTabController 39 > VCLXTabControl_Base; 40 41 class VCLXTabControl :public VCLXWindow 42 ,public VCLXTabControl_Base 43 ,public Box_Base 44 { 45 int mTabId; 46 bool bRealized; 47 48 public: 49 VCLXTabControl(); 50 51 void AddChild (css::uno::Reference <css::awt::XLayoutConstrains> const &); 52 53 protected: 54 ~VCLXTabControl(); 55 56 // XInterface 57 DECLARE_XINTERFACE() 58 59 // XTypeProvider 60 DECLARE_XTYPEPROVIDER() 61 62 // XComponent 63 void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); 64 65 virtual void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) throw (::com::sun::star::uno::RuntimeException); 66 67 // XSimpleTabController 68 virtual ::sal_Int32 SAL_CALL insertTab() throw (::com::sun::star::uno::RuntimeException); 69 virtual void SAL_CALL removeTab( ::sal_Int32 ID ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 70 71 virtual void SAL_CALL setTabProps( ::sal_Int32 ID, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& Properties ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 72 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > SAL_CALL getTabProps( ::sal_Int32 ID ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 73 74 virtual void SAL_CALL activateTab( ::sal_Int32 ID ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 75 virtual ::sal_Int32 SAL_CALL getActiveTabID() throw (::com::sun::star::uno::RuntimeException); 76 77 virtual void SAL_CALL addTabListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); 78 virtual void SAL_CALL removeTabListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); 79 80 // ::com::sun::star::awt::XLayoutContainer 81 virtual void SAL_CALL addChild( 82 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XLayoutConstrains >& Child ) 83 throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::awt::MaxChildrenException); 84 virtual void SAL_CALL removeChild( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XLayoutConstrains >& Child ) 85 throw (::com::sun::star::uno::RuntimeException); 86 87 virtual void SAL_CALL allocateArea( const ::com::sun::star::awt::Rectangle &rArea ) 88 throw (::com::sun::star::uno::RuntimeException); 89 90 virtual ::com::sun::star::awt::Size SAL_CALL getMinimumSize() 91 throw(::com::sun::star::uno::RuntimeException); 92 93 // unimplemented: hasHeightForWidth()94 virtual sal_Bool SAL_CALL hasHeightForWidth() 95 throw(css::uno::RuntimeException) 96 { return false; } getHeightForWidth(sal_Int32)97 virtual sal_Int32 SAL_CALL getHeightForWidth( sal_Int32 /*nWidth*/ ) 98 throw(css::uno::RuntimeException) 99 { return maRequisition.Height; } 100 101 // VclWindowPeer 102 virtual void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); 103 virtual ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); 104 105 // VCLXWindow 106 void ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ); 107 108 public: 109 // Maps page ids to child references 110 struct ChildData : public Box_Base::ChildData 111 { 112 rtl::OUString maTitle; 113 ChildData( css::uno::Reference< css::awt::XLayoutConstrains > const& xChild ); 114 }; 115 116 struct ChildProps : public Box_Base::ChildProps 117 { 118 ChildProps( VCLXTabControl::ChildData *pData ); 119 }; 120 121 protected: 122 ChildData *createChild( css::uno::Reference< css::awt::XLayoutConstrains > const& xChild ); 123 ChildProps *createChildProps( Box_Base::ChildData* pData ); 124 125 126 std::map< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XLayoutConstrains >, sal_Int32 > mIdMap; 127 // FIXME: we might want to use a Multiplexer 128 std::list< ::com::sun::star::uno::Reference 129 < ::com::sun::star::awt::XTabListener > > mxTabListeners; 130 131 inline TabControl *getTabControl() const throw (::com::sun::star::uno::RuntimeException); 132 133 private: 134 VCLXTabControl( const VCLXTabControl& ); // never implemented 135 VCLXTabControl& operator=( const VCLXTabControl& ); // never implemented 136 }; 137 138 } // namespace layoutimpl 139 140 #endif /* LAYOUT_AWT_VCLXTABCONTROLLER_HXX */ 141