150e6b072SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
350e6b072SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
450e6b072SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
550e6b072SAndrew Rist  * distributed with this work for additional information
650e6b072SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
750e6b072SAndrew Rist  * to you under the Apache License, Version 2.0 (the
850e6b072SAndrew Rist  * "License"); you may not use this file except in compliance
950e6b072SAndrew Rist  * with the License.  You may obtain a copy of the License at
1050e6b072SAndrew Rist  *
1150e6b072SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
1250e6b072SAndrew Rist  *
1350e6b072SAndrew Rist  * Unless required by applicable law or agreed to in writing,
1450e6b072SAndrew Rist  * software distributed under the License is distributed on an
1550e6b072SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1650e6b072SAndrew Rist  * KIND, either express or implied.  See the License for the
1750e6b072SAndrew Rist  * specific language governing permissions and limitations
1850e6b072SAndrew Rist  * under the License.
1950e6b072SAndrew Rist  *
2050e6b072SAndrew Rist  *************************************************************/
2150e6b072SAndrew Rist 
2250e6b072SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef LAYOUT_VCL_WRAPPER_HXX
25cdf0e10cSrcweir #define LAYOUT_VCL_WRAPPER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <layout/layout.hxx>
28cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx>
29cdf0e10cSrcweir #include <com/sun/star/awt/XDialog2.hpp>
30cdf0e10cSrcweir #include <com/sun/star/awt/XFocusListener.hpp>
31cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
32cdf0e10cSrcweir #include <com/sun/star/awt/XVclWindowPeer.hpp>
33cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <cstring>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir namespace layout
38cdf0e10cSrcweir {
39cdf0e10cSrcweir 
40cdf0e10cSrcweir namespace css = com::sun::star;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir class WindowImpl
43cdf0e10cSrcweir {
44cdf0e10cSrcweir public:
45cdf0e10cSrcweir     Window *mpWindow;
46cdf0e10cSrcweir     Context *mpCtx;
47cdf0e10cSrcweir     css::uno::Reference< css::awt::XWindow > mxWindow;
48cdf0e10cSrcweir     css::uno::Reference< css::awt::XVclWindowPeer > mxVclPeer;
49cdf0e10cSrcweir     ::Window *mvclWindow;
50cdf0e10cSrcweir     bool bFirstTimeVisible;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir     WindowImpl (Context *context, PeerHandle const &peer, Window *window);
53cdf0e10cSrcweir     virtual ~WindowImpl ();
54cdf0e10cSrcweir 
55cdf0e10cSrcweir     void wrapperGone();
56cdf0e10cSrcweir     css::uno::Any getProperty (char const *name);
57cdf0e10cSrcweir     void setProperty (char const *name, css::uno::Any any);
58cdf0e10cSrcweir     void redraw (bool resize=false);
59cdf0e10cSrcweir 
60cdf0e10cSrcweir     // XFocusListener
61cdf0e10cSrcweir     virtual void SAL_CALL disposing (css::lang::EventObject const&) throw (css::uno::RuntimeException);
62cdf0e10cSrcweir };
63cdf0e10cSrcweir 
64cdf0e10cSrcweir class ControlImpl : public WindowImpl
65cdf0e10cSrcweir                   , public ::cppu::WeakImplHelper1 <css::awt::XFocusListener>
66cdf0e10cSrcweir {
67cdf0e10cSrcweir public:
68cdf0e10cSrcweir     Link mGetFocusHdl;
69cdf0e10cSrcweir     Link mLoseFocusHdl;
70cdf0e10cSrcweir 
71cdf0e10cSrcweir     ControlImpl( Context *context, PeerHandle const& peer, Window *window );
72cdf0e10cSrcweir     ~ControlImpl ();
73cdf0e10cSrcweir 
74cdf0e10cSrcweir     virtual void SetGetFocusHdl (Link const& link);
75cdf0e10cSrcweir     Link& GetGetFocusHdl ();
76cdf0e10cSrcweir     virtual void SetLoseFocusHdl (Link const& link);
77cdf0e10cSrcweir     Link& GetLoseFocusHdl ();
78cdf0e10cSrcweir     virtual void UpdateListening (Link const& link);
79cdf0e10cSrcweir 
80cdf0e10cSrcweir     // XFocusListener
81cdf0e10cSrcweir     virtual void SAL_CALL disposing (css::lang::EventObject const&) throw (css::uno::RuntimeException);
82cdf0e10cSrcweir     void SAL_CALL focusGained (css::awt::FocusEvent const& e) throw (css::uno::RuntimeException);
83cdf0e10cSrcweir     void SAL_CALL focusLost (css::awt::FocusEvent const& e) throw (css::uno::RuntimeException);
84cdf0e10cSrcweir };
85cdf0e10cSrcweir 
getImpl() const86*5e0f18e3SDon Lewis inline WindowImpl *Window::getImpl() const{ return (static_cast< WindowImpl * >( mpImpl )); }
87cdf0e10cSrcweir 
88cdf0e10cSrcweir // Helpers for defining boiler-plate constructors ...
89cdf0e10cSrcweir // Could in-line in top-level but not with safe static_casts.
90cdf0e10cSrcweir #define IMPL_GET_IMPL(t) \
91*5e0f18e3SDon Lewis     inline t##Impl* t::getImpl() const \
92cdf0e10cSrcweir     { \
93*5e0f18e3SDon Lewis         return (static_cast<t##Impl *>(mpImpl)); \
94cdf0e10cSrcweir     }
95cdf0e10cSrcweir #define IMPL_CONSTRUCTORS_BODY(t,par,unoName,body) \
96cdf0e10cSrcweir     t::t( Context *context, const char *pId, sal_uInt32 nId ) \
97cdf0e10cSrcweir         : par( new t##Impl( context, context->GetPeerHandle( pId, nId ), this ) ) \
98cdf0e10cSrcweir     { \
99cdf0e10cSrcweir         Window *parent = dynamic_cast<Window*> (context);\
100cdf0e10cSrcweir         body;\
101cdf0e10cSrcweir         if (parent)\
102cdf0e10cSrcweir             SetParent (parent);\
103cdf0e10cSrcweir     } \
104cdf0e10cSrcweir     t::t( Window *parent, WinBits bits) \
105cdf0e10cSrcweir         : par( new t##Impl( parent->getContext(), Window::CreatePeer( parent, bits, unoName ), this ) ) \
106cdf0e10cSrcweir     { \
107cdf0e10cSrcweir         body;\
108cdf0e10cSrcweir         if ( parent )\
109cdf0e10cSrcweir             SetParent (parent);\
110cdf0e10cSrcweir     } \
111cdf0e10cSrcweir     t::t( Window *parent, ResId const& res) \
112cdf0e10cSrcweir         : par( new t##Impl( parent->getContext(), Window::CreatePeer( parent, 0, unoName ), this ) ) \
113cdf0e10cSrcweir     { \
114cdf0e10cSrcweir         body;\
115cdf0e10cSrcweir         setRes (res);\
116cdf0e10cSrcweir         if (parent)\
117cdf0e10cSrcweir             SetParent (parent);\
118cdf0e10cSrcweir     }
119cdf0e10cSrcweir #define IMPL_CONSTRUCTORS(t,par,unoName) IMPL_CONSTRUCTORS_BODY(t, par, unoName, )
120cdf0e10cSrcweir #define IMPL_CONSTRUCTORS_2(t,win_par,other_par,unoName) \
121cdf0e10cSrcweir     t::t( Context *context, const char *pId, sal_uInt32 nId ) \
122cdf0e10cSrcweir         : win_par( new t##Impl( context, context->GetPeerHandle( pId, nId ), this ) ) \
123cdf0e10cSrcweir         , other_par( new other_par##Impl( Window::GetPeer() ) ) \
124cdf0e10cSrcweir     { \
125cdf0e10cSrcweir     } \
126cdf0e10cSrcweir     t::t( Window *parent, WinBits bits) \
127cdf0e10cSrcweir         : win_par( new t##Impl( parent->getContext(), Window::CreatePeer( parent, bits, unoName ), this ) ) \
128cdf0e10cSrcweir         , other_par( new other_par##Impl( Window::GetPeer() ) ) \
129cdf0e10cSrcweir     { \
130cdf0e10cSrcweir     }
131cdf0e10cSrcweir 
132cdf0e10cSrcweir #define IMPL_IMPL(t, parent) \
133cdf0e10cSrcweir     class t##Impl : public parent##Impl \
134cdf0e10cSrcweir     { \
135cdf0e10cSrcweir     public: \
136cdf0e10cSrcweir         t##Impl( Context *context, PeerHandle const& peer, Window *window ) \
137cdf0e10cSrcweir             : parent##Impl( context, peer, window ) \
138cdf0e10cSrcweir         { \
139cdf0e10cSrcweir         } \
140cdf0e10cSrcweir     };
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 
143cdf0e10cSrcweir } // namespace layout
144cdf0e10cSrcweir 
145cdf0e10cSrcweir #endif /* LAYOUT_VCL_WRAPPER_HXX */
146