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_VCL_WRAPPER_HXX 29 #define LAYOUT_VCL_WRAPPER_HXX 30 31 #include <layout/layout.hxx> 32 #include <com/sun/star/uno/Reference.hxx> 33 #include <com/sun/star/awt/XDialog2.hpp> 34 #include <com/sun/star/awt/XFocusListener.hpp> 35 #include <com/sun/star/awt/XWindow.hpp> 36 #include <com/sun/star/awt/XVclWindowPeer.hpp> 37 #include <cppuhelper/implbase1.hxx> 38 39 #include <cstring> 40 41 namespace layout 42 { 43 44 namespace css = com::sun::star; 45 46 class WindowImpl 47 { 48 public: 49 Window *mpWindow; 50 Context *mpCtx; 51 css::uno::Reference< css::awt::XWindow > mxWindow; 52 css::uno::Reference< css::awt::XVclWindowPeer > mxVclPeer; 53 ::Window *mvclWindow; 54 bool bFirstTimeVisible; 55 56 WindowImpl (Context *context, PeerHandle const &peer, Window *window); 57 virtual ~WindowImpl (); 58 59 void wrapperGone(); 60 css::uno::Any getProperty (char const *name); 61 void setProperty (char const *name, css::uno::Any any); 62 void redraw (bool resize=false); 63 64 // XFocusListener 65 virtual void SAL_CALL disposing (css::lang::EventObject const&) throw (css::uno::RuntimeException); 66 }; 67 68 class ControlImpl : public WindowImpl 69 , public ::cppu::WeakImplHelper1 <css::awt::XFocusListener> 70 { 71 public: 72 Link mGetFocusHdl; 73 Link mLoseFocusHdl; 74 75 ControlImpl( Context *context, PeerHandle const& peer, Window *window ); 76 ~ControlImpl (); 77 78 virtual void SetGetFocusHdl (Link const& link); 79 Link& GetGetFocusHdl (); 80 virtual void SetLoseFocusHdl (Link const& link); 81 Link& GetLoseFocusHdl (); 82 virtual void UpdateListening (Link const& link); 83 84 // XFocusListener 85 virtual void SAL_CALL disposing (css::lang::EventObject const&) throw (css::uno::RuntimeException); 86 void SAL_CALL focusGained (css::awt::FocusEvent const& e) throw (css::uno::RuntimeException); 87 void SAL_CALL focusLost (css::awt::FocusEvent const& e) throw (css::uno::RuntimeException); 88 }; 89 90 inline WindowImpl &Window::getImpl() const{ return *(static_cast< WindowImpl * >( mpImpl )); } 91 92 // Helpers for defining boiler-plate constructors ... 93 // Could in-line in top-level but not with safe static_casts. 94 #define IMPL_GET_IMPL(t) \ 95 inline t##Impl &t::getImpl() const \ 96 { \ 97 return *(static_cast<t##Impl *>(mpImpl)); \ 98 } 99 #define IMPL_CONSTRUCTORS_BODY(t,par,unoName,body) \ 100 t::t( Context *context, const char *pId, sal_uInt32 nId ) \ 101 : par( new t##Impl( context, context->GetPeerHandle( pId, nId ), this ) ) \ 102 { \ 103 Window *parent = dynamic_cast<Window*> (context);\ 104 body;\ 105 if (parent)\ 106 SetParent (parent);\ 107 } \ 108 t::t( Window *parent, WinBits bits) \ 109 : par( new t##Impl( parent->getContext(), Window::CreatePeer( parent, bits, unoName ), this ) ) \ 110 { \ 111 body;\ 112 if ( parent )\ 113 SetParent (parent);\ 114 } \ 115 t::t( Window *parent, ResId const& res) \ 116 : par( new t##Impl( parent->getContext(), Window::CreatePeer( parent, 0, unoName ), this ) ) \ 117 { \ 118 body;\ 119 setRes (res);\ 120 if (parent)\ 121 SetParent (parent);\ 122 } 123 #define IMPL_CONSTRUCTORS(t,par,unoName) IMPL_CONSTRUCTORS_BODY(t, par, unoName, ) 124 #define IMPL_CONSTRUCTORS_2(t,win_par,other_par,unoName) \ 125 t::t( Context *context, const char *pId, sal_uInt32 nId ) \ 126 : win_par( new t##Impl( context, context->GetPeerHandle( pId, nId ), this ) ) \ 127 , other_par( new other_par##Impl( Window::GetPeer() ) ) \ 128 { \ 129 } \ 130 t::t( Window *parent, WinBits bits) \ 131 : win_par( new t##Impl( parent->getContext(), Window::CreatePeer( parent, bits, unoName ), this ) ) \ 132 , other_par( new other_par##Impl( Window::GetPeer() ) ) \ 133 { \ 134 } 135 136 #define IMPL_IMPL(t, parent) \ 137 class t##Impl : public parent##Impl \ 138 { \ 139 public: \ 140 t##Impl( Context *context, PeerHandle const& peer, Window *window ) \ 141 : parent##Impl( context, peer, window ) \ 142 { \ 143 } \ 144 }; 145 146 147 } // namespace layout 148 149 #endif /* LAYOUT_VCL_WRAPPER_HXX */ 150