merge the formfield patch from ooo-build
[ooovba.git] / toolkit / source / layout / vcl / wrapper.hxx
blobd42caf9167c47053a61e140df7db45e8ac175617
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile$
11 * $Revision$
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_VCL_WRAPPER_HXX
33 #define LAYOUT_VCL_WRAPPER_HXX
35 #include <layout/layout.hxx>
36 #include <com/sun/star/uno/Reference.hxx>
37 #include <com/sun/star/awt/XDialog2.hpp>
38 #include <com/sun/star/awt/XFocusListener.hpp>
39 #include <com/sun/star/awt/XWindow.hpp>
40 #include <com/sun/star/awt/XVclWindowPeer.hpp>
41 #include <cppuhelper/implbase1.hxx>
43 #include <cstring>
45 namespace layout
48 namespace css = com::sun::star;
50 class WindowImpl
52 public:
53 Window *mpWindow;
54 Context *mpCtx;
55 css::uno::Reference< css::awt::XWindow > mxWindow;
56 css::uno::Reference< css::awt::XVclWindowPeer > mxVclPeer;
57 ::Window *mvclWindow;
58 bool bFirstTimeVisible;
60 WindowImpl (Context *context, PeerHandle const &peer, Window *window);
61 virtual ~WindowImpl ();
63 void wrapperGone();
64 css::uno::Any getProperty (char const *name);
65 void setProperty (char const *name, css::uno::Any any);
66 void redraw (bool resize=false);
68 // XFocusListener
69 virtual void SAL_CALL disposing (css::lang::EventObject const&) throw (css::uno::RuntimeException);
72 class ControlImpl : public WindowImpl
73 , public ::cppu::WeakImplHelper1 <css::awt::XFocusListener>
75 public:
76 Link mGetFocusHdl;
77 Link mLoseFocusHdl;
79 ControlImpl( Context *context, PeerHandle const& peer, Window *window );
80 ~ControlImpl ();
82 virtual void SetGetFocusHdl (Link const& link);
83 Link& GetGetFocusHdl ();
84 virtual void SetLoseFocusHdl (Link const& link);
85 Link& GetLoseFocusHdl ();
86 virtual void UpdateListening (Link const& link);
88 // XFocusListener
89 virtual void SAL_CALL disposing (css::lang::EventObject const&) throw (css::uno::RuntimeException);
90 void SAL_CALL focusGained (css::awt::FocusEvent const& e) throw (css::uno::RuntimeException);
91 void SAL_CALL focusLost (css::awt::FocusEvent const& e) throw (css::uno::RuntimeException);
94 inline WindowImpl &Window::getImpl() const{ return *(static_cast< WindowImpl * >( mpImpl )); }
96 // Helpers for defining boiler-plate constructors ...
97 // Could in-line in top-level but not with safe static_casts.
98 #define IMPL_GET_IMPL(t) \
99 inline t##Impl &t::getImpl() const \
101 return *(static_cast<t##Impl *>(mpImpl)); \
103 #define IMPL_CONSTRUCTORS_BODY(t,par,unoName,body) \
104 t::t( Context *context, const char *pId, sal_uInt32 nId ) \
105 : par( new t##Impl( context, context->GetPeerHandle( pId, nId ), this ) ) \
107 Window *parent = dynamic_cast<Window*> (context);\
108 body;\
109 if (parent)\
110 SetParent (parent);\
112 t::t( Window *parent, WinBits bits) \
113 : par( new t##Impl( parent->getContext(), Window::CreatePeer( parent, bits, unoName ), this ) ) \
115 body;\
116 if ( parent )\
117 SetParent (parent);\
119 t::t( Window *parent, ResId const& res) \
120 : par( new t##Impl( parent->getContext(), Window::CreatePeer( parent, 0, unoName ), this ) ) \
122 body;\
123 setRes (res);\
124 if (parent)\
125 SetParent (parent);\
127 #define IMPL_CONSTRUCTORS(t,par,unoName) IMPL_CONSTRUCTORS_BODY(t, par, unoName, )
128 #define IMPL_CONSTRUCTORS_2(t,win_par,other_par,unoName) \
129 t::t( Context *context, const char *pId, sal_uInt32 nId ) \
130 : win_par( new t##Impl( context, context->GetPeerHandle( pId, nId ), this ) ) \
131 , other_par( new other_par##Impl( Window::GetPeer() ) ) \
134 t::t( Window *parent, WinBits bits) \
135 : win_par( new t##Impl( parent->getContext(), Window::CreatePeer( parent, bits, unoName ), this ) ) \
136 , other_par( new other_par##Impl( Window::GetPeer() ) ) \
140 #define IMPL_IMPL(t, parent) \
141 class t##Impl : public parent##Impl \
143 public: \
144 t##Impl( Context *context, PeerHandle const& peer, Window *window ) \
145 : parent##Impl( context, peer, window ) \
151 } // namespace layout
153 #endif /* LAYOUT_VCL_WRAPPER_HXX */