1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #include <tools/rc.h>
29*cdf0e10cSrcweir //#define RESOURCE_PUBLISH_PROTECTED 1
30*cdf0e10cSrcweir #if RESOURCE_PUBLISH_PROTECTED
31*cdf0e10cSrcweir // ugh, override non-helpful proctection
32*cdf0e10cSrcweir #define protected public
33*cdf0e10cSrcweir #endif /* RESOURCE_PUBLISH_PROTECTED */
34*cdf0e10cSrcweir #include <tools/rc.hxx>
35*cdf0e10cSrcweir #undef protected
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include "wrapper.hxx"
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir #include <awt/vclxplugin.hxx>
41*cdf0e10cSrcweir #include <awt/vclxtabcontrol.hxx>
42*cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/awt/WindowAttribute.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/awt/XDialog2.hpp>
46*cdf0e10cSrcweir #include <com/sun/star/awt/XProgressBar.hpp>
47*cdf0e10cSrcweir #include <com/sun/star/awt/XSimpleTabController.hpp>
48*cdf0e10cSrcweir #include <com/sun/star/awt/XTabListener.hpp>
49*cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphic.hpp>
50*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
51*cdf0e10cSrcweir #include <layout/core/factory.hxx>
52*cdf0e10cSrcweir #include <layout/core/localized-string.hxx>
53*cdf0e10cSrcweir #include <layout/core/root.hxx>
54*cdf0e10cSrcweir #include <toolkit/awt/vclxwindow.hxx>
55*cdf0e10cSrcweir #include <vcl/ctrl.hxx>
56*cdf0e10cSrcweir #include <vcl/dialog.hxx>
57*cdf0e10cSrcweir #include <vcl/image.hxx>
58*cdf0e10cSrcweir #include <vcl/tabctrl.hxx>
59*cdf0e10cSrcweir #include <vcl/tabpage.hxx>
60*cdf0e10cSrcweir #include <vcl/window.hxx>
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir using namespace ::com::sun::star;
63*cdf0e10cSrcweir using rtl::OUString;
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir namespace layout
66*cdf0e10cSrcweir {
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir // Context bits ...
69*cdf0e10cSrcweir class ContextImpl
70*cdf0e10cSrcweir {
71*cdf0e10cSrcweir     uno::Reference< awt::XLayoutRoot > mxRoot;
72*cdf0e10cSrcweir     uno::Reference< container::XNameAccess > mxNameAccess;
73*cdf0e10cSrcweir     PeerHandle mxTopLevel;
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir public:
76*cdf0e10cSrcweir     ContextImpl( char const *pPath )
77*cdf0e10cSrcweir     {
78*cdf0e10cSrcweir         uno::Sequence< uno::Any > aParams( 1 );
79*cdf0e10cSrcweir         aParams[0] <<= OUString( pPath, strlen( pPath ), RTL_TEXTENCODING_UTF8 );
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir         uno::Reference< lang::XSingleServiceFactory > xFactory(
82*cdf0e10cSrcweir             comphelper::createProcessComponent(
83*cdf0e10cSrcweir                 OUString::createFromAscii( "com.sun.star.awt.Layout" ) ),
84*cdf0e10cSrcweir             uno::UNO_QUERY );
85*cdf0e10cSrcweir         if ( !xFactory.is() )
86*cdf0e10cSrcweir         {
87*cdf0e10cSrcweir             throw uno::RuntimeException(
88*cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM( "Layout engine not installed" ) ),
89*cdf0e10cSrcweir                 uno::Reference< uno::XInterface >() );
90*cdf0e10cSrcweir         }
91*cdf0e10cSrcweir         mxRoot = uno::Reference< awt::XLayoutRoot >(
92*cdf0e10cSrcweir             xFactory->createInstanceWithArguments( aParams ),
93*cdf0e10cSrcweir             uno::UNO_QUERY );
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir         mxNameAccess = uno::Reference< container::XNameAccess >( mxRoot, uno::UNO_QUERY );
96*cdf0e10cSrcweir     }
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir     ~ContextImpl()
99*cdf0e10cSrcweir     {
100*cdf0e10cSrcweir     }
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir     PeerHandle getByName( const OUString &rName )
103*cdf0e10cSrcweir     {
104*cdf0e10cSrcweir         uno::Any val = mxNameAccess->getByName( rName );
105*cdf0e10cSrcweir         PeerHandle xRet;
106*cdf0e10cSrcweir         val >>= xRet;
107*cdf0e10cSrcweir         return xRet;
108*cdf0e10cSrcweir     }
109*cdf0e10cSrcweir     PeerHandle getTopLevel()
110*cdf0e10cSrcweir     {
111*cdf0e10cSrcweir         return mxTopLevel;
112*cdf0e10cSrcweir     }
113*cdf0e10cSrcweir     void setTopLevel( PeerHandle xToplevel )
114*cdf0e10cSrcweir     {
115*cdf0e10cSrcweir         mxTopLevel = xToplevel;
116*cdf0e10cSrcweir     }
117*cdf0e10cSrcweir     PeerHandle getRoot()
118*cdf0e10cSrcweir     {
119*cdf0e10cSrcweir         return mxRoot;
120*cdf0e10cSrcweir     }
121*cdf0e10cSrcweir };
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir Context::Context( const char *pPath )
124*cdf0e10cSrcweir     : pImpl( new ContextImpl( pPath ) )
125*cdf0e10cSrcweir {
126*cdf0e10cSrcweir }
127*cdf0e10cSrcweir Context::~Context()
128*cdf0e10cSrcweir {
129*cdf0e10cSrcweir     delete pImpl;
130*cdf0e10cSrcweir     pImpl = NULL;
131*cdf0e10cSrcweir }
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir void Context::setToplevel( PeerHandle xToplevel )
134*cdf0e10cSrcweir {
135*cdf0e10cSrcweir     pImpl->setTopLevel( xToplevel );
136*cdf0e10cSrcweir }
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir PeerHandle Context::getToplevel()
139*cdf0e10cSrcweir {
140*cdf0e10cSrcweir     return pImpl->getTopLevel();
141*cdf0e10cSrcweir }
142*cdf0e10cSrcweir PeerHandle Context::getRoot()
143*cdf0e10cSrcweir {
144*cdf0e10cSrcweir     return pImpl->getRoot();
145*cdf0e10cSrcweir }
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir PeerHandle Context::GetPeerHandle( const char *id, sal_uInt32 nId ) const
148*cdf0e10cSrcweir {
149*cdf0e10cSrcweir     PeerHandle xHandle;
150*cdf0e10cSrcweir     xHandle = pImpl->getByName( OUString( id, strlen( id ), RTL_TEXTENCODING_UTF8 ) );
151*cdf0e10cSrcweir     if ( !xHandle.is() )
152*cdf0e10cSrcweir     {
153*cdf0e10cSrcweir         DBG_ERROR1( "Failed to fetch widget '%s'", id );
154*cdf0e10cSrcweir     }
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir     if ( nId != 0 )
157*cdf0e10cSrcweir     {
158*cdf0e10cSrcweir         rtl::OString aStr = rtl::OString::valueOf( (sal_Int32) nId );
159*cdf0e10cSrcweir         xHandle = GetPeerHandle( aStr, 0 );
160*cdf0e10cSrcweir     }
161*cdf0e10cSrcweir     return xHandle;
162*cdf0e10cSrcweir }
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir WindowImpl::WindowImpl (Context *context, const PeerHandle &peer, Window *window)
165*cdf0e10cSrcweir     : mpWindow (window)
166*cdf0e10cSrcweir     , mpCtx (context)
167*cdf0e10cSrcweir     , mxWindow (peer, uno::UNO_QUERY)
168*cdf0e10cSrcweir     , mxVclPeer (peer, uno::UNO_QUERY)
169*cdf0e10cSrcweir     , mvclWindow (0)
170*cdf0e10cSrcweir     , bFirstTimeVisible (true)
171*cdf0e10cSrcweir {
172*cdf0e10cSrcweir }
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir WindowImpl::~WindowImpl ()
175*cdf0e10cSrcweir {
176*cdf0e10cSrcweir     if (mpWindow)
177*cdf0e10cSrcweir         mpWindow->mpImpl = 0;
178*cdf0e10cSrcweir     if (mvclWindow)
179*cdf0e10cSrcweir     {
180*cdf0e10cSrcweir         VCLXWindow *v = mvclWindow->GetWindowPeer ();
181*cdf0e10cSrcweir         v->SetWindow (0);
182*cdf0e10cSrcweir         mvclWindow->SetComponentInterface (uno::Reference <awt::XWindowPeer> ());
183*cdf0e10cSrcweir         mvclWindow->SetWindowPeer (uno::Reference <awt::XWindowPeer> (), 0);
184*cdf0e10cSrcweir         delete mvclWindow;
185*cdf0e10cSrcweir         mvclWindow = 0;
186*cdf0e10cSrcweir     }
187*cdf0e10cSrcweir }
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir void WindowImpl::wrapperGone ()
190*cdf0e10cSrcweir {
191*cdf0e10cSrcweir     mvclWindow = 0;
192*cdf0e10cSrcweir     mpWindow->mpImpl = 0;
193*cdf0e10cSrcweir     mpWindow = 0;
194*cdf0e10cSrcweir     mpCtx = 0;
195*cdf0e10cSrcweir     if ( mxWindow.is() )
196*cdf0e10cSrcweir     {
197*cdf0e10cSrcweir         uno::Reference< lang::XComponent > xComp( mxWindow, uno::UNO_QUERY );
198*cdf0e10cSrcweir         mxWindow.clear ();
199*cdf0e10cSrcweir         if ( xComp.is() )
200*cdf0e10cSrcweir             xComp->dispose();
201*cdf0e10cSrcweir     }
202*cdf0e10cSrcweir }
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir void SAL_CALL WindowImpl::disposing (lang::EventObject const&)
205*cdf0e10cSrcweir     throw (uno::RuntimeException)
206*cdf0e10cSrcweir {
207*cdf0e10cSrcweir     if (mxWindow.is ())
208*cdf0e10cSrcweir         mxWindow.clear ();
209*cdf0e10cSrcweir }
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir uno::Any WindowImpl::getProperty (char const* name)
212*cdf0e10cSrcweir {
213*cdf0e10cSrcweir     if ( !this || !mxVclPeer.is() )
214*cdf0e10cSrcweir         return css::uno::Any();
215*cdf0e10cSrcweir     return mxVclPeer->getProperty
216*cdf0e10cSrcweir         ( rtl::OUString( name, strlen( name ), RTL_TEXTENCODING_ASCII_US ) );
217*cdf0e10cSrcweir }
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir void WindowImpl::setProperty (char const *name, uno::Any any)
220*cdf0e10cSrcweir {
221*cdf0e10cSrcweir     if ( !this || !mxVclPeer.is() )
222*cdf0e10cSrcweir         return;
223*cdf0e10cSrcweir     mxVclPeer->setProperty
224*cdf0e10cSrcweir         ( rtl::OUString( name, strlen( name ), RTL_TEXTENCODING_ASCII_US ), any );
225*cdf0e10cSrcweir }
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir void WindowImpl::redraw (bool resize)
228*cdf0e10cSrcweir {
229*cdf0e10cSrcweir     uno::Reference <awt::XWindow> ref (mxWindow, uno::UNO_QUERY);
230*cdf0e10cSrcweir     ::Window* window = VCLXWindow::GetImplementation (ref)->GetWindow ();
231*cdf0e10cSrcweir     ::Window* parent = window->GetParent();
232*cdf0e10cSrcweir     ::Rectangle r = Rectangle (parent->GetPosPixel (),
233*cdf0e10cSrcweir                                parent->GetSizePixel ());
234*cdf0e10cSrcweir     parent->Invalidate (r, INVALIDATE_CHILDREN | INVALIDATE_NOCHILDREN );
235*cdf0e10cSrcweir     if (resize)
236*cdf0e10cSrcweir         parent->SetPosSizePixel (0, 0, 1, 1, awt::PosSize::SIZE);
237*cdf0e10cSrcweir     else
238*cdf0e10cSrcweir         parent->SetPosSizePixel (0, 0, r.nRight - r.nLeft, r.nBottom - r.nTop,
239*cdf0e10cSrcweir                                  awt::PosSize::SIZE);
240*cdf0e10cSrcweir }
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir Window::Window( WindowImpl *pImpl )
243*cdf0e10cSrcweir     : mpImpl( pImpl )
244*cdf0e10cSrcweir {
245*cdf0e10cSrcweir     mpImpl->mvclWindow = GetVCLXWindow () ? GetWindow () : 0;
246*cdf0e10cSrcweir }
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir Window::~Window()
249*cdf0e10cSrcweir {
250*cdf0e10cSrcweir     /* likely to be an UNO object - with floating references */
251*cdf0e10cSrcweir     if (mpImpl)
252*cdf0e10cSrcweir         mpImpl->wrapperGone ();
253*cdf0e10cSrcweir     mpImpl = 0;
254*cdf0e10cSrcweir }
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir ///IMPL_GET_IMPL( Control );
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir static ControlImpl* null_control_impl = 0;
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir ControlImpl &Control::getImpl () const
261*cdf0e10cSrcweir {
262*cdf0e10cSrcweir     if (ControlImpl* c = static_cast<ControlImpl *>(mpImpl))
263*cdf0e10cSrcweir         return *c;
264*cdf0e10cSrcweir     return *null_control_impl;
265*cdf0e10cSrcweir }
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir Control::~Control ()
268*cdf0e10cSrcweir {
269*cdf0e10cSrcweir     SetGetFocusHdl (Link ());
270*cdf0e10cSrcweir     SetLoseFocusHdl (Link ());
271*cdf0e10cSrcweir }
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir void Window::setRes (ResId const& res)
274*cdf0e10cSrcweir {
275*cdf0e10cSrcweir #if RESOURCE_PUBLISH_PROTECTED
276*cdf0e10cSrcweir     // Resources are shut-off from use.  Is that really necessary?
277*cdf0e10cSrcweir     Resource &r = *GetWindow ();
278*cdf0e10cSrcweir     r.GetRes (res);
279*cdf0e10cSrcweir #else /* !RESOURCE_PUBLISH_PROTECTED */
280*cdf0e10cSrcweir     //We *must* derive.  Is this also really necessary?
281*cdf0e10cSrcweir     //Resource r (res);
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir     // ugh, I wonder which solution is cleaner...
284*cdf0e10cSrcweir     class Resource_open_up : public Resource
285*cdf0e10cSrcweir     {
286*cdf0e10cSrcweir     public:
287*cdf0e10cSrcweir         Resource_open_up (ResId const& r)
288*cdf0e10cSrcweir             : Resource (r)
289*cdf0e10cSrcweir         {
290*cdf0e10cSrcweir         }
291*cdf0e10cSrcweir         static sal_Int32 GetLongRes (void *p)
292*cdf0e10cSrcweir         {
293*cdf0e10cSrcweir             return Resource::GetLongRes (p);
294*cdf0e10cSrcweir         }
295*cdf0e10cSrcweir         void* GetClassRes ()
296*cdf0e10cSrcweir         {
297*cdf0e10cSrcweir             return Resource::GetClassRes ();
298*cdf0e10cSrcweir         }
299*cdf0e10cSrcweir         sal_Int32 ReadLongRes ()
300*cdf0e10cSrcweir         {
301*cdf0e10cSrcweir             return Resource::ReadLongRes ();
302*cdf0e10cSrcweir         }
303*cdf0e10cSrcweir         UniString ReadStringRes ()
304*cdf0e10cSrcweir         {
305*cdf0e10cSrcweir             return Resource::ReadStringRes ();
306*cdf0e10cSrcweir         }
307*cdf0e10cSrcweir         rtl::OString ReadByteStringRes()
308*cdf0e10cSrcweir         {
309*cdf0e10cSrcweir             return Resource::ReadByteStringRes();
310*cdf0e10cSrcweir         }
311*cdf0e10cSrcweir     };
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir     Resource_open_up r (res);
314*cdf0e10cSrcweir #endif /* !RESOURCE_PUBLISH_PROTECTED */
315*cdf0e10cSrcweir     sal_uInt32 mask = r.ReadLongRes ();
316*cdf0e10cSrcweir     if (mask & WINDOW_HELPID)
317*cdf0e10cSrcweir         SetHelpId (r.ReadByteStringRes());
318*cdf0e10cSrcweir     if ( mask & WINDOW_TEXT )
319*cdf0e10cSrcweir         SetText( r.ReadStringRes ());
320*cdf0e10cSrcweir }
321*cdf0e10cSrcweir 
322*cdf0e10cSrcweir void Window::SetParent( ::Window *parent )
323*cdf0e10cSrcweir {
324*cdf0e10cSrcweir     uno::Reference <awt::XWindow> ref( GetPeer(), uno::UNO_QUERY );
325*cdf0e10cSrcweir     if (VCLXWindow *vcl = VCLXWindow::GetImplementation( ref ))
326*cdf0e10cSrcweir         if (::Window *window = vcl->GetWindow())
327*cdf0e10cSrcweir             window->SetParent( parent );
328*cdf0e10cSrcweir }
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir void Window::SetParent( Window *parent )
331*cdf0e10cSrcweir {
332*cdf0e10cSrcweir     /* Let's hear it for C++: poor man's dynamic binding.  */
333*cdf0e10cSrcweir     parent->ParentSet (this);
334*cdf0e10cSrcweir }
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir void Window::ParentSet (Window *window)
337*cdf0e10cSrcweir {
338*cdf0e10cSrcweir     window->SetParent (GetWindow ());
339*cdf0e10cSrcweir }
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir Context *Window::getContext()
342*cdf0e10cSrcweir {
343*cdf0e10cSrcweir     return this && mpImpl ? mpImpl->mpCtx : NULL;
344*cdf0e10cSrcweir }
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir PeerHandle Window::GetPeer() const
347*cdf0e10cSrcweir {
348*cdf0e10cSrcweir     if ( !mpImpl )
349*cdf0e10cSrcweir         return PeerHandle();
350*cdf0e10cSrcweir     return mpImpl->mxWindow;
351*cdf0e10cSrcweir }
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir uno::Reference<awt::XWindow> Window::GetRef() const
354*cdf0e10cSrcweir {
355*cdf0e10cSrcweir     return uno::Reference <awt::XWindow> ( GetPeer(), uno::UNO_QUERY );
356*cdf0e10cSrcweir }
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir VCLXWindow* Window::GetVCLXWindow() const
359*cdf0e10cSrcweir {
360*cdf0e10cSrcweir     return VCLXWindow::GetImplementation( GetRef() );
361*cdf0e10cSrcweir }
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir ::Window* Window::GetWindow() const
364*cdf0e10cSrcweir {
365*cdf0e10cSrcweir     return GetVCLXWindow()->GetWindow();
366*cdf0e10cSrcweir }
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir ::Window* Window::GetParent() const
369*cdf0e10cSrcweir {
370*cdf0e10cSrcweir     return GetWindow()->GetParent();
371*cdf0e10cSrcweir }
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir void Window::SetHelpId( const rtl::OString& id )
374*cdf0e10cSrcweir {
375*cdf0e10cSrcweir     GetWindow()->SetHelpId( id );
376*cdf0e10cSrcweir }
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir const rtl::OString& Window::GetHelpId() const
379*cdf0e10cSrcweir {
380*cdf0e10cSrcweir     return GetWindow()->GetHelpId();
381*cdf0e10cSrcweir }
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir void Window::EnterWait ()
384*cdf0e10cSrcweir {
385*cdf0e10cSrcweir     GetWindow()->EnterWait ();
386*cdf0e10cSrcweir }
387*cdf0e10cSrcweir void Window::LeaveWait ()
388*cdf0e10cSrcweir {
389*cdf0e10cSrcweir     GetWindow()->LeaveWait ();
390*cdf0e10cSrcweir }
391*cdf0e10cSrcweir bool Window::IsWait () const
392*cdf0e10cSrcweir {
393*cdf0e10cSrcweir     return GetWindow()->IsWait ();
394*cdf0e10cSrcweir }
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir bool Window::IsVisible () const
397*cdf0e10cSrcweir {
398*cdf0e10cSrcweir     if (GetWindow ())
399*cdf0e10cSrcweir         return GetWindow()->IsVisible ();
400*cdf0e10cSrcweir     return false;
401*cdf0e10cSrcweir }
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir bool Window::HasChildPathFocus (bool systemWindow) const
404*cdf0e10cSrcweir {
405*cdf0e10cSrcweir     return GetWindow()->HasChildPathFocus (systemWindow);
406*cdf0e10cSrcweir }
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir void Window::SetPosPixel (Point const&)
409*cdf0e10cSrcweir {
410*cdf0e10cSrcweir }
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir Point Window::GetPosPixel () const
413*cdf0e10cSrcweir {
414*cdf0e10cSrcweir     return Point ();
415*cdf0e10cSrcweir }
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir void Window::SetSizePixel (Size const&)
418*cdf0e10cSrcweir {
419*cdf0e10cSrcweir }
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir void Window::SetPosSizePixel (Point const&, Size const&)
422*cdf0e10cSrcweir {
423*cdf0e10cSrcweir }
424*cdf0e10cSrcweir 
425*cdf0e10cSrcweir Size Window::GetSizePixel () const
426*cdf0e10cSrcweir {
427*cdf0e10cSrcweir     return Size ();
428*cdf0e10cSrcweir }
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir // void Window::Enable (bool enable, bool child);
431*cdf0e10cSrcweir // {
432*cdf0e10cSrcweir //     GetWindow ()->Enable (enable, child);
433*cdf0e10cSrcweir // }
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir // void Window::Disable (bool child)
436*cdf0e10cSrcweir // {
437*cdf0e10cSrcweir //     GetWindow ()->Disable (child);
438*cdf0e10cSrcweir // }
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir bool Window::IsEnabled () const
441*cdf0e10cSrcweir {
442*cdf0e10cSrcweir     return GetWindow ()->IsEnabled ();
443*cdf0e10cSrcweir //     if (getImpl().mxWindow.is ())
444*cdf0e10cSrcweir //         return getImpl ().mxWindow->isEnabled ();
445*cdf0e10cSrcweir //     return false;
446*cdf0e10cSrcweir }
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir void Window::EnableInput (bool enable, bool child)
449*cdf0e10cSrcweir {
450*cdf0e10cSrcweir     GetWindow ()->EnableInput (enable, child);
451*cdf0e10cSrcweir }
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir bool Window::IsInputEnabled () const
454*cdf0e10cSrcweir {
455*cdf0e10cSrcweir     return GetWindow ()->IsInputEnabled ();
456*cdf0e10cSrcweir }
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir bool Window::HasFocus () const
459*cdf0e10cSrcweir {
460*cdf0e10cSrcweir     return GetWindow ()->HasFocus ();
461*cdf0e10cSrcweir }
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir Font& Window::GetFont () const
464*cdf0e10cSrcweir {
465*cdf0e10cSrcweir     return const_cast <Font&> (GetWindow ()->GetFont ());
466*cdf0e10cSrcweir }
467*cdf0e10cSrcweir 
468*cdf0e10cSrcweir void Window::SetFont (Font const& font)
469*cdf0e10cSrcweir {
470*cdf0e10cSrcweir     GetWindow ()->SetFont (font);
471*cdf0e10cSrcweir }
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir void Window::Invalidate (sal_uInt8 flags)
474*cdf0e10cSrcweir {
475*cdf0e10cSrcweir     GetWindow ()->Invalidate (flags);
476*cdf0e10cSrcweir }
477*cdf0e10cSrcweir 
478*cdf0e10cSrcweir struct ToolkitVclPropsMap
479*cdf0e10cSrcweir {
480*cdf0e10cSrcweir     WinBits vclStyle;
481*cdf0e10cSrcweir     long initAttr;
482*cdf0e10cSrcweir     const char *propName;
483*cdf0e10cSrcweir 
484*cdf0e10cSrcweir     // the value to give the prop to enable/disable it -- not the most brilliant
485*cdf0e10cSrcweir     // type declaration and storage, but does the work... properties are
486*cdf0e10cSrcweir     // either a boolean or a short since they are either a directly wrappers for
487*cdf0e10cSrcweir     // a WinBit, or aggregates related (like Align for WB_LEFT, _RIGHT and _CENTER).
488*cdf0e10cSrcweir     bool isBoolean;
489*cdf0e10cSrcweir     short enableProp, disableProp;
490*cdf0e10cSrcweir };
491*cdf0e10cSrcweir 
492*cdf0e10cSrcweir #define TYPE_BOOL  true
493*cdf0e10cSrcweir #define TYPE_SHORT false
494*cdf0e10cSrcweir #define NOTYPE     0
495*cdf0e10cSrcweir static const ToolkitVclPropsMap toolkitVclPropsMap[] =
496*cdf0e10cSrcweir {
497*cdf0e10cSrcweir     { WB_BORDER,    awt::WindowAttribute::BORDER,    "Border", TYPE_SHORT, 1, 0 },
498*cdf0e10cSrcweir     { WB_NOBORDER,    awt::VclWindowPeerAttribute::NOBORDER,    "Border", TYPE_SHORT, 0, 1 },
499*cdf0e10cSrcweir     { WB_SIZEABLE,    awt::WindowAttribute::SIZEABLE,    NULL, NOTYPE, 0, 0 },
500*cdf0e10cSrcweir     { WB_MOVEABLE,    awt::WindowAttribute::MOVEABLE,    NULL, NOTYPE, 0, 0 },
501*cdf0e10cSrcweir     { WB_CLOSEABLE,    awt::WindowAttribute::CLOSEABLE,    NULL, NOTYPE, 0, 0 },
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir     { WB_HSCROLL,    awt::VclWindowPeerAttribute::HSCROLL,    NULL, NOTYPE, 0, 0 },
504*cdf0e10cSrcweir     { WB_VSCROLL,    awt::VclWindowPeerAttribute::VSCROLL,    NULL, NOTYPE, 0, 0 },
505*cdf0e10cSrcweir     { WB_LEFT,    awt::VclWindowPeerAttribute::LEFT,    "Align", TYPE_SHORT, 0, 0 },
506*cdf0e10cSrcweir     { WB_CENTER,    awt::VclWindowPeerAttribute::CENTER,    "Align", TYPE_SHORT, 1, 0 },
507*cdf0e10cSrcweir     { WB_RIGHT,    awt::VclWindowPeerAttribute::RIGHT,    "Align", TYPE_SHORT, 2, 0 },
508*cdf0e10cSrcweir     { WB_SPIN,    awt::VclWindowPeerAttribute::SPIN,    NULL, NOTYPE, 0, 0 },
509*cdf0e10cSrcweir     { WB_SORT,    awt::VclWindowPeerAttribute::SORT,    NULL, NOTYPE, 0, 0 },
510*cdf0e10cSrcweir     { WB_DROPDOWN,    awt::VclWindowPeerAttribute::DROPDOWN,    "Dropdown",    TYPE_BOOL, 1, 0 },
511*cdf0e10cSrcweir     { WB_DEFBUTTON,    awt::VclWindowPeerAttribute::DEFBUTTON,    "DefaultButton", TYPE_BOOL, 1, 0 },
512*cdf0e10cSrcweir     { WB_READONLY,    awt::VclWindowPeerAttribute::READONLY,    NULL, NOTYPE, 0, 0 },
513*cdf0e10cSrcweir     { WB_CLIPCHILDREN,    awt::VclWindowPeerAttribute::CLIPCHILDREN,    NULL, NOTYPE, 0, 0 },
514*cdf0e10cSrcweir     { WB_GROUP,    awt::VclWindowPeerAttribute::GROUP,    NULL, NOTYPE, 0, 0 },
515*cdf0e10cSrcweir 
516*cdf0e10cSrcweir     { WB_OK,    awt::VclWindowPeerAttribute::OK,    NULL, NOTYPE, 0, 0 },
517*cdf0e10cSrcweir     { WB_OK_CANCEL,    awt::VclWindowPeerAttribute::OK_CANCEL,    NULL, NOTYPE, 0, 0 },
518*cdf0e10cSrcweir     { WB_YES_NO,    awt::VclWindowPeerAttribute::YES_NO,    NULL, NOTYPE, 0, 0 },
519*cdf0e10cSrcweir     { WB_YES_NO_CANCEL,    awt::VclWindowPeerAttribute::YES_NO_CANCEL,    NULL, NOTYPE, 1, 0 },
520*cdf0e10cSrcweir     { WB_RETRY_CANCEL,    awt::VclWindowPeerAttribute::RETRY_CANCEL,    NULL, NOTYPE, 1, 0 },
521*cdf0e10cSrcweir     { WB_DEF_OK,    awt::VclWindowPeerAttribute::DEF_OK,    NULL, NOTYPE, 0, 0 },
522*cdf0e10cSrcweir     { WB_DEF_CANCEL,    awt::VclWindowPeerAttribute::DEF_CANCEL,    NULL, NOTYPE, 1, 0 },
523*cdf0e10cSrcweir     { WB_DEF_RETRY,    awt::VclWindowPeerAttribute::DEF_RETRY,    NULL, NOTYPE, 0, 0 },
524*cdf0e10cSrcweir     { WB_DEF_YES,    awt::VclWindowPeerAttribute::DEF_YES,    NULL, NOTYPE, 0, 0 },
525*cdf0e10cSrcweir     { WB_DEF_NO,    awt::VclWindowPeerAttribute::DEF_NO,    NULL, NOTYPE, 0, 0 },
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir     { WB_AUTOHSCROLL, awt::VclWindowPeerAttribute::AUTOHSCROLL, "AutoHScroll", TYPE_BOOL, 1, 0 },
528*cdf0e10cSrcweir     { WB_AUTOVSCROLL, awt::VclWindowPeerAttribute::AUTOVSCROLL, "AutoVScroll",    TYPE_BOOL, 1, 0 },
529*cdf0e10cSrcweir 
530*cdf0e10cSrcweir     { WB_WORDBREAK,    0,    "MultiLine", TYPE_BOOL, 1, 0 },
531*cdf0e10cSrcweir     { WB_NOPOINTERFOCUS,    0,    "FocusOnClick", TYPE_BOOL, 1, 0 },
532*cdf0e10cSrcweir     { WB_TOGGLE,    0,    "Toggle", TYPE_BOOL, 1, 0 },
533*cdf0e10cSrcweir     { WB_REPEAT,    0,    "Repeat", TYPE_BOOL, 1, 0 },
534*cdf0e10cSrcweir     { WB_NOHIDESELECTION,    0,    "HideInactiveSelection", TYPE_BOOL, 1, 0 },
535*cdf0e10cSrcweir };
536*cdf0e10cSrcweir #undef TYPE_BOOL
537*cdf0e10cSrcweir #undef TYPE_SHORT
538*cdf0e10cSrcweir #undef NOTYPE
539*cdf0e10cSrcweir 
540*cdf0e10cSrcweir static const int toolkitVclPropsMapLen =
541*cdf0e10cSrcweir     sizeof( toolkitVclPropsMap ) / sizeof( ToolkitVclPropsMap );
542*cdf0e10cSrcweir 
543*cdf0e10cSrcweir void Window::SetStyle( WinBits nStyle )
544*cdf0e10cSrcweir {
545*cdf0e10cSrcweir     uno::Reference< awt::XVclWindowPeer > xPeer = mpImpl->mxVclPeer;
546*cdf0e10cSrcweir     for (int i = 0; i < toolkitVclPropsMapLen; i++)
547*cdf0e10cSrcweir     {
548*cdf0e10cSrcweir         if ( toolkitVclPropsMap[ i ].propName )
549*cdf0e10cSrcweir         {
550*cdf0e10cSrcweir             short nValue;
551*cdf0e10cSrcweir             if ( nStyle & toolkitVclPropsMap[ i ].vclStyle )
552*cdf0e10cSrcweir                 nValue = toolkitVclPropsMap[ i ].enableProp;
553*cdf0e10cSrcweir             else
554*cdf0e10cSrcweir                 nValue = toolkitVclPropsMap[ i ].disableProp;
555*cdf0e10cSrcweir             uno::Any aValue;
556*cdf0e10cSrcweir             if ( toolkitVclPropsMap[ i ].isBoolean )
557*cdf0e10cSrcweir                 aValue = uno::makeAny( (bool) nValue );
558*cdf0e10cSrcweir             else
559*cdf0e10cSrcweir                 aValue = uno::makeAny( (short) nValue );
560*cdf0e10cSrcweir             mpImpl->setProperty( toolkitVclPropsMap[ i ].propName, aValue );
561*cdf0e10cSrcweir         }
562*cdf0e10cSrcweir     }
563*cdf0e10cSrcweir }
564*cdf0e10cSrcweir 
565*cdf0e10cSrcweir WinBits Window::GetStyle()
566*cdf0e10cSrcweir {
567*cdf0e10cSrcweir     uno::Reference< awt::XVclWindowPeer > xPeer = mpImpl->mxVclPeer;
568*cdf0e10cSrcweir     WinBits ret = 0;
569*cdf0e10cSrcweir     for (int i = 0; i < toolkitVclPropsMapLen; i++)
570*cdf0e10cSrcweir     {
571*cdf0e10cSrcweir         if ( toolkitVclPropsMap[ i ].propName )
572*cdf0e10cSrcweir         {
573*cdf0e10cSrcweir             short nValue = 0;
574*cdf0e10cSrcweir             if ( toolkitVclPropsMap[ i ].isBoolean )
575*cdf0e10cSrcweir             {
576*cdf0e10cSrcweir                 bool bValue = false;
577*cdf0e10cSrcweir                 mpImpl->getProperty( toolkitVclPropsMap[ i ].propName ) >>= bValue;
578*cdf0e10cSrcweir                 nValue = bValue ? 1 : 0;
579*cdf0e10cSrcweir             }
580*cdf0e10cSrcweir             else
581*cdf0e10cSrcweir                 mpImpl->getProperty( toolkitVclPropsMap[ i ].propName ) >>= nValue;
582*cdf0e10cSrcweir             if ( nValue == toolkitVclPropsMap[ i ].enableProp )
583*cdf0e10cSrcweir                 ret |= toolkitVclPropsMap[i].vclStyle;
584*cdf0e10cSrcweir         }
585*cdf0e10cSrcweir     }
586*cdf0e10cSrcweir     return ret;
587*cdf0e10cSrcweir }
588*cdf0e10cSrcweir 
589*cdf0e10cSrcweir /* Unpleasant way to get an xToolkit pointer ... */
590*cdf0e10cSrcweir uno::Reference< awt::XToolkit > getToolkit()
591*cdf0e10cSrcweir {
592*cdf0e10cSrcweir     static uno::Reference< awt::XToolkit > xToolkit;
593*cdf0e10cSrcweir     if (!xToolkit.is())
594*cdf0e10cSrcweir     {
595*cdf0e10cSrcweir         // Urgh ...
596*cdf0e10cSrcweir         xToolkit = uno::Reference< awt::XToolkit >(
597*cdf0e10cSrcweir             ::comphelper::getProcessServiceFactory()->createInstance(
598*cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.Toolkit" ) ) ),
599*cdf0e10cSrcweir             uno::UNO_QUERY );
600*cdf0e10cSrcweir         if ( !xToolkit.is() )
601*cdf0e10cSrcweir             throw uno::RuntimeException(
602*cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM( "failed to create toolkit!") ),
603*cdf0e10cSrcweir                 uno::Reference< uno::XInterface >() );
604*cdf0e10cSrcweir     }
605*cdf0e10cSrcweir     return xToolkit;
606*cdf0e10cSrcweir }
607*cdf0e10cSrcweir 
608*cdf0e10cSrcweir PeerHandle Window::CreatePeer( Window *parent, WinBits nStyle, const char *pName)
609*cdf0e10cSrcweir {
610*cdf0e10cSrcweir     long nWinAttrbs = 0;
611*cdf0e10cSrcweir     for (int i = 0; i < toolkitVclPropsMapLen; i++)
612*cdf0e10cSrcweir         if ( nStyle & toolkitVclPropsMap[ i ].vclStyle )
613*cdf0e10cSrcweir             nWinAttrbs |= toolkitVclPropsMap[ i ].initAttr;
614*cdf0e10cSrcweir 
615*cdf0e10cSrcweir     return layoutimpl::WidgetFactory::createWidget (getToolkit(), parent->GetPeer(), OUString::createFromAscii( pName ), nWinAttrbs);
616*cdf0e10cSrcweir }
617*cdf0e10cSrcweir 
618*cdf0e10cSrcweir void Window::Enable( bool bEnable )
619*cdf0e10cSrcweir {
620*cdf0e10cSrcweir     if ( !getImpl().mxWindow.is() )
621*cdf0e10cSrcweir         return;
622*cdf0e10cSrcweir     getImpl().mxWindow->setEnable( bEnable );
623*cdf0e10cSrcweir }
624*cdf0e10cSrcweir 
625*cdf0e10cSrcweir void Window::Show( bool bVisible )
626*cdf0e10cSrcweir {
627*cdf0e10cSrcweir     if ( !getImpl().mxWindow.is() )
628*cdf0e10cSrcweir         return;
629*cdf0e10cSrcweir     getImpl().mxWindow->setVisible( bVisible );
630*cdf0e10cSrcweir     if (!bVisible)
631*cdf0e10cSrcweir         getImpl ().bFirstTimeVisible = true;
632*cdf0e10cSrcweir     else if (GetParent() && getImpl().bFirstTimeVisible)
633*cdf0e10cSrcweir     {
634*cdf0e10cSrcweir         getImpl().redraw ();
635*cdf0e10cSrcweir         getImpl().bFirstTimeVisible = false;
636*cdf0e10cSrcweir     }
637*cdf0e10cSrcweir }
638*cdf0e10cSrcweir 
639*cdf0e10cSrcweir void Window::GrabFocus()
640*cdf0e10cSrcweir {
641*cdf0e10cSrcweir     if ( !getImpl().mxWindow.is() )
642*cdf0e10cSrcweir         return;
643*cdf0e10cSrcweir     getImpl().mxWindow->setFocus();
644*cdf0e10cSrcweir }
645*cdf0e10cSrcweir 
646*cdf0e10cSrcweir void Window::SetUpdateMode(bool mode)
647*cdf0e10cSrcweir {
648*cdf0e10cSrcweir     GetWindow()->SetUpdateMode( mode );
649*cdf0e10cSrcweir }
650*cdf0e10cSrcweir 
651*cdf0e10cSrcweir void Window::SetPointer( Pointer const& pointer )
652*cdf0e10cSrcweir {
653*cdf0e10cSrcweir     GetWindow()->SetPointer( pointer );
654*cdf0e10cSrcweir }
655*cdf0e10cSrcweir 
656*cdf0e10cSrcweir Pointer const& Window::GetPointer() const
657*cdf0e10cSrcweir {
658*cdf0e10cSrcweir     return GetWindow()->GetPointer();
659*cdf0e10cSrcweir }
660*cdf0e10cSrcweir 
661*cdf0e10cSrcweir void Window::SetText( OUString const& str )
662*cdf0e10cSrcweir {
663*cdf0e10cSrcweir     GetWindow()->SetText( str );
664*cdf0e10cSrcweir }
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir String Window::GetText() const
667*cdf0e10cSrcweir {
668*cdf0e10cSrcweir     return GetWindow()->GetText();
669*cdf0e10cSrcweir }
670*cdf0e10cSrcweir 
671*cdf0e10cSrcweir sal_Int32 Window::GetCtrlTextWidth (OUString const&) const
672*cdf0e10cSrcweir {
673*cdf0e10cSrcweir     return 0;
674*cdf0e10cSrcweir }
675*cdf0e10cSrcweir 
676*cdf0e10cSrcweir sal_Int32 Window::GetTextHeight () const
677*cdf0e10cSrcweir {
678*cdf0e10cSrcweir     return 0;
679*cdf0e10cSrcweir }
680*cdf0e10cSrcweir 
681*cdf0e10cSrcweir Size Window::LogicToPixel( Size const& size, MapMode const&) const
682*cdf0e10cSrcweir {
683*cdf0e10cSrcweir     return size;
684*cdf0e10cSrcweir }
685*cdf0e10cSrcweir 
686*cdf0e10cSrcweir ControlImpl::ControlImpl (Context *context, const PeerHandle &peer, Window *window)
687*cdf0e10cSrcweir     : WindowImpl( context, peer, window )
688*cdf0e10cSrcweir {
689*cdf0e10cSrcweir }
690*cdf0e10cSrcweir 
691*cdf0e10cSrcweir ControlImpl::~ControlImpl ()
692*cdf0e10cSrcweir {
693*cdf0e10cSrcweir     if ((!!mGetFocusHdl || !!mLoseFocusHdl) && mxWindow.is ())
694*cdf0e10cSrcweir         /* Disposing will be done @ VCLXWindow::dispose () maFocusListeners.disposeAndClear()
695*cdf0e10cSrcweir            don't do it twice */
696*cdf0e10cSrcweir         mxWindow.clear ();
697*cdf0e10cSrcweir }
698*cdf0e10cSrcweir 
699*cdf0e10cSrcweir void ControlImpl::SetGetFocusHdl (Link const& link)
700*cdf0e10cSrcweir {
701*cdf0e10cSrcweir     if (!mLoseFocusHdl || !link)
702*cdf0e10cSrcweir         UpdateListening (link);
703*cdf0e10cSrcweir     mGetFocusHdl = link;
704*cdf0e10cSrcweir }
705*cdf0e10cSrcweir 
706*cdf0e10cSrcweir Link& ControlImpl::GetGetFocusHdl ()
707*cdf0e10cSrcweir {
708*cdf0e10cSrcweir     return mGetFocusHdl;
709*cdf0e10cSrcweir }
710*cdf0e10cSrcweir 
711*cdf0e10cSrcweir void ControlImpl::SetLoseFocusHdl (Link const& link)
712*cdf0e10cSrcweir {
713*cdf0e10cSrcweir     if (!mGetFocusHdl || !link)
714*cdf0e10cSrcweir         UpdateListening (link);
715*cdf0e10cSrcweir     mLoseFocusHdl = link;
716*cdf0e10cSrcweir }
717*cdf0e10cSrcweir 
718*cdf0e10cSrcweir Link& ControlImpl::GetLoseFocusHdl ()
719*cdf0e10cSrcweir {
720*cdf0e10cSrcweir     return mGetFocusHdl;
721*cdf0e10cSrcweir }
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir void ControlImpl::UpdateListening (Link const& link)
724*cdf0e10cSrcweir {
725*cdf0e10cSrcweir     if (!link && (!!mGetFocusHdl || !!mLoseFocusHdl)
726*cdf0e10cSrcweir         && (!mGetFocusHdl || !mLoseFocusHdl))
727*cdf0e10cSrcweir         mxWindow->removeFocusListener (this);
728*cdf0e10cSrcweir     else if (!!link && !mGetFocusHdl && !mLoseFocusHdl)
729*cdf0e10cSrcweir         mxWindow->addFocusListener (this);
730*cdf0e10cSrcweir }
731*cdf0e10cSrcweir 
732*cdf0e10cSrcweir void SAL_CALL ControlImpl::disposing (lang::EventObject const&)
733*cdf0e10cSrcweir     throw (uno::RuntimeException)
734*cdf0e10cSrcweir {
735*cdf0e10cSrcweir ///    mxWindow.clear ();
736*cdf0e10cSrcweir }
737*cdf0e10cSrcweir 
738*cdf0e10cSrcweir void SAL_CALL ControlImpl::focusGained (awt::FocusEvent const&)
739*cdf0e10cSrcweir     throw (uno::RuntimeException)
740*cdf0e10cSrcweir {
741*cdf0e10cSrcweir     mGetFocusHdl.Call (mpWindow);
742*cdf0e10cSrcweir }
743*cdf0e10cSrcweir 
744*cdf0e10cSrcweir void SAL_CALL ControlImpl::focusLost (awt::FocusEvent const&)
745*cdf0e10cSrcweir     throw (uno::RuntimeException)
746*cdf0e10cSrcweir {
747*cdf0e10cSrcweir     mLoseFocusHdl.Call (mpWindow);
748*cdf0e10cSrcweir }
749*cdf0e10cSrcweir 
750*cdf0e10cSrcweir Link& Control::GetGetFocusHdl ()
751*cdf0e10cSrcweir {
752*cdf0e10cSrcweir     return getImpl ().GetGetFocusHdl ();
753*cdf0e10cSrcweir }
754*cdf0e10cSrcweir 
755*cdf0e10cSrcweir void Control::SetGetFocusHdl (Link const& link)
756*cdf0e10cSrcweir {
757*cdf0e10cSrcweir     if (&getImpl () && getImpl().mxWindow.is ())
758*cdf0e10cSrcweir         getImpl ().SetGetFocusHdl (link);
759*cdf0e10cSrcweir }
760*cdf0e10cSrcweir 
761*cdf0e10cSrcweir Link& Control::GetLoseFocusHdl ()
762*cdf0e10cSrcweir {
763*cdf0e10cSrcweir     return getImpl ().GetLoseFocusHdl ();
764*cdf0e10cSrcweir }
765*cdf0e10cSrcweir 
766*cdf0e10cSrcweir void Control::SetLoseFocusHdl (Link const& link)
767*cdf0e10cSrcweir {
768*cdf0e10cSrcweir     if (&getImpl () && getImpl().mxWindow.is ())
769*cdf0e10cSrcweir         getImpl ().SetLoseFocusHdl (link);
770*cdf0e10cSrcweir }
771*cdf0e10cSrcweir 
772*cdf0e10cSrcweir class DialogImpl : public WindowImpl
773*cdf0e10cSrcweir {
774*cdf0e10cSrcweir public:
775*cdf0e10cSrcweir     uno::Reference< awt::XDialog2 > mxDialog;
776*cdf0e10cSrcweir     DialogImpl( Context *context, PeerHandle const &peer, Window *window );
777*cdf0e10cSrcweir };
778*cdf0e10cSrcweir 
779*cdf0e10cSrcweir DialogImpl::DialogImpl( Context *context, const PeerHandle &peer, Window *window )
780*cdf0e10cSrcweir     : WindowImpl( context, peer, window )
781*cdf0e10cSrcweir     , mxDialog( peer, uno::UNO_QUERY )
782*cdf0e10cSrcweir {
783*cdf0e10cSrcweir }
784*cdf0e10cSrcweir 
785*cdf0e10cSrcweir Dialog::Dialog( Window *parent, const char *xml_file, const char *id, sal_uInt32 nId )
786*cdf0e10cSrcweir     : Context( xml_file )
787*cdf0e10cSrcweir     , Window( new DialogImpl( this, Context::GetPeerHandle( id, nId ), this ) )
788*cdf0e10cSrcweir     , bConstruct (true)
789*cdf0e10cSrcweir {
790*cdf0e10cSrcweir     if ( parent )
791*cdf0e10cSrcweir         SetParent( parent );
792*cdf0e10cSrcweir }
793*cdf0e10cSrcweir 
794*cdf0e10cSrcweir Dialog::Dialog( ::Window *parent, const char *xml_file, const char *id, sal_uInt32 nId )
795*cdf0e10cSrcweir     : Context( xml_file )
796*cdf0e10cSrcweir     , Window( new DialogImpl( this, Context::GetPeerHandle( id, nId ), this ) )
797*cdf0e10cSrcweir {
798*cdf0e10cSrcweir     if ( parent )
799*cdf0e10cSrcweir         SetParent( parent );
800*cdf0e10cSrcweir }
801*cdf0e10cSrcweir 
802*cdf0e10cSrcweir Dialog::~Dialog ()
803*cdf0e10cSrcweir {
804*cdf0e10cSrcweir }
805*cdf0e10cSrcweir 
806*cdf0e10cSrcweir IMPL_GET_WINDOW (Dialog);
807*cdf0e10cSrcweir IMPL_GET_IMPL (Dialog);
808*cdf0e10cSrcweir 
809*cdf0e10cSrcweir #define MX_DIALOG if (getImpl ().mxDialog.is ()) getImpl ().mxDialog
810*cdf0e10cSrcweir #define RETURN_MX_DIALOG if (getImpl ().mxDialog.is ()) return getImpl ().mxDialog
811*cdf0e10cSrcweir 
812*cdf0e10cSrcweir short Dialog::Execute()
813*cdf0e10cSrcweir {
814*cdf0e10cSrcweir     RETURN_MX_DIALOG->execute ();
815*cdf0e10cSrcweir     return -1;
816*cdf0e10cSrcweir }
817*cdf0e10cSrcweir 
818*cdf0e10cSrcweir void Dialog::EndDialog( long result )
819*cdf0e10cSrcweir {
820*cdf0e10cSrcweir     MX_DIALOG->endDialog (result);
821*cdf0e10cSrcweir }
822*cdf0e10cSrcweir 
823*cdf0e10cSrcweir void Dialog::SetText( OUString const& str )
824*cdf0e10cSrcweir {
825*cdf0e10cSrcweir     SetTitle (str);
826*cdf0e10cSrcweir }
827*cdf0e10cSrcweir 
828*cdf0e10cSrcweir void Dialog::SetTitle( OUString const& str )
829*cdf0e10cSrcweir {
830*cdf0e10cSrcweir     MX_DIALOG->setTitle (str);
831*cdf0e10cSrcweir }
832*cdf0e10cSrcweir 
833*cdf0e10cSrcweir bool Dialog::Close ()
834*cdf0e10cSrcweir {
835*cdf0e10cSrcweir     EndDialog (false);
836*cdf0e10cSrcweir     return true;
837*cdf0e10cSrcweir }
838*cdf0e10cSrcweir 
839*cdf0e10cSrcweir long Dialog::Notify (NotifyEvent& event)
840*cdf0e10cSrcweir {
841*cdf0e10cSrcweir     return GetDialog ()->Notify (event);
842*cdf0e10cSrcweir }
843*cdf0e10cSrcweir 
844*cdf0e10cSrcweir void Dialog::Initialize (SfxChildWinInfo*)
845*cdf0e10cSrcweir {
846*cdf0e10cSrcweir }
847*cdf0e10cSrcweir 
848*cdf0e10cSrcweir #define MESSAGE_BOX_MEMBER_INIT\
849*cdf0e10cSrcweir     Dialog (parent, xml_file, id)\
850*cdf0e10cSrcweir         , imageError (this, "FI_ERROR")\
851*cdf0e10cSrcweir         , imageInfo (this, "FI_INFO")\
852*cdf0e10cSrcweir         , imageQuery (this, "FI_QUERY")\
853*cdf0e10cSrcweir         , imageWarning (this, "FI_WARNING")\
854*cdf0e10cSrcweir         , messageText (this, "FT_MESSAGE")\
855*cdf0e10cSrcweir         , cancelButton (this, "BTN_CANCEL")\
856*cdf0e10cSrcweir         , helpButton (this, "BTN_HELP")\
857*cdf0e10cSrcweir         , ignoreButton (this, "BTN_IGNORE")\
858*cdf0e10cSrcweir         , noButton (this, "BTN_NO")\
859*cdf0e10cSrcweir         , retryButton (this, "BTN_RETRY")\
860*cdf0e10cSrcweir         , yesButton (this, "BTN_YES")
861*cdf0e10cSrcweir 
862*cdf0e10cSrcweir MessageBox::MessageBox (::Window *parent, char const* message,
863*cdf0e10cSrcweir                         char const* yes, char const* no, const rtl::OString& help_id,
864*cdf0e10cSrcweir                         char const* xml_file, char const* id)
865*cdf0e10cSrcweir     : MESSAGE_BOX_MEMBER_INIT
866*cdf0e10cSrcweir {
867*cdf0e10cSrcweir     ignoreButton.Hide ();
868*cdf0e10cSrcweir     retryButton.Hide ();
869*cdf0e10cSrcweir     init (message, yes, no, help_id);
870*cdf0e10cSrcweir }
871*cdf0e10cSrcweir 
872*cdf0e10cSrcweir MessageBox::MessageBox (::Window *parent, OUString const& message,
873*cdf0e10cSrcweir                         OUString yes, OUString no, const rtl::OString& help_id,
874*cdf0e10cSrcweir                         char const* xml_file, char const* id)
875*cdf0e10cSrcweir     : MESSAGE_BOX_MEMBER_INIT
876*cdf0e10cSrcweir {
877*cdf0e10cSrcweir     ignoreButton.Hide ();
878*cdf0e10cSrcweir     retryButton.Hide ();
879*cdf0e10cSrcweir     init (message, yes, no, help_id);
880*cdf0e10cSrcweir }
881*cdf0e10cSrcweir 
882*cdf0e10cSrcweir #if !defined (__GNUC__)
883*cdf0e10cSrcweir #define __PRETTY_FUNCTION__ __FUNCTION__
884*cdf0e10cSrcweir #endif /* !__GNUC__ */
885*cdf0e10cSrcweir 
886*cdf0e10cSrcweir MessageBox::MessageBox (::Window *parent, WinBits bits, char const* message,
887*cdf0e10cSrcweir                         char const* yes, char const* no, const rtl::OString& help_id,
888*cdf0e10cSrcweir                         char const* xml_file, char const* id)
889*cdf0e10cSrcweir     : MESSAGE_BOX_MEMBER_INIT
890*cdf0e10cSrcweir {
891*cdf0e10cSrcweir     // HIG suggests using verbs instead of yes/no/retry etc.
892*cdf0e10cSrcweir     // This constructor provides client-code compatibility: Client code should be fixed.
893*cdf0e10cSrcweir #ifndef __SUNPRO_CC
894*cdf0e10cSrcweir     OSL_TRACE ("%s: warning, deprecated vcl/Messbox compatibility", __PRETTY_FUNCTION__);
895*cdf0e10cSrcweir #endif
896*cdf0e10cSrcweir     bits_init (bits, OUString::createFromAscii (message), OUString::createFromAscii (yes), OUString::createFromAscii (no), help_id);
897*cdf0e10cSrcweir }
898*cdf0e10cSrcweir 
899*cdf0e10cSrcweir MessageBox::MessageBox (::Window *parent, WinBits bits, OUString const& message,
900*cdf0e10cSrcweir                         OUString yes, OUString no, const rtl::OString& help_id,
901*cdf0e10cSrcweir                         char const* xml_file, char const* id)
902*cdf0e10cSrcweir     : MESSAGE_BOX_MEMBER_INIT
903*cdf0e10cSrcweir {
904*cdf0e10cSrcweir     // HIG suggests using verbs instead of yes/no/retry etc.
905*cdf0e10cSrcweir     // This constructor provides client-code compatibility: Client code should be fixed.
906*cdf0e10cSrcweir #ifndef __SUNPRO_CC
907*cdf0e10cSrcweir     OSL_TRACE ("%s: warning, deprecated vcl/Messbox compatibility", __PRETTY_FUNCTION__);
908*cdf0e10cSrcweir #endif
909*cdf0e10cSrcweir     bits_init (bits, message, yes, no, help_id);
910*cdf0e10cSrcweir }
911*cdf0e10cSrcweir 
912*cdf0e10cSrcweir void MessageBox::bits_init (WinBits bits, OUString const& message,
913*cdf0e10cSrcweir                             OUString yes, OUString no, const rtl::OString& help_id)
914*cdf0e10cSrcweir {
915*cdf0e10cSrcweir 	if ( bits & ( WB_OK_CANCEL | WB_OK ))
916*cdf0e10cSrcweir         yes = Button::GetStandardText ( BUTTON_OK );
917*cdf0e10cSrcweir 	if ( bits & (WB_YES_NO | WB_YES_NO_CANCEL ))
918*cdf0e10cSrcweir 	{
919*cdf0e10cSrcweir         yes = Button::GetStandardText ( BUTTON_YES );
920*cdf0e10cSrcweir         no =  Button::GetStandardText ( BUTTON_NO );
921*cdf0e10cSrcweir 	}
922*cdf0e10cSrcweir     if (! (bits & (WB_RETRY_CANCEL | WB_YES_NO_CANCEL | WB_ABORT_RETRY_IGNORE )))
923*cdf0e10cSrcweir         cancelButton.Hide ();
924*cdf0e10cSrcweir     if (! (bits & (WB_RETRY_CANCEL | WB_ABORT_RETRY_IGNORE)))
925*cdf0e10cSrcweir         retryButton.Hide ();
926*cdf0e10cSrcweir     if ( bits & WB_ABORT_RETRY_IGNORE )
927*cdf0e10cSrcweir         cancelButton.SetText ( Button::GetStandardText (BUTTON_ABORT));
928*cdf0e10cSrcweir     else
929*cdf0e10cSrcweir         ignoreButton.Hide ();
930*cdf0e10cSrcweir 	if ( !(bits & ( WB_OK | WB_OK_CANCEL | WB_YES_NO | WB_YES_NO_CANCEL)))
931*cdf0e10cSrcweir         yesButton.Hide ();
932*cdf0e10cSrcweir 	if ( !(bits & ( WB_YES_NO | WB_YES_NO_CANCEL)))
933*cdf0e10cSrcweir         noButton.Hide ();
934*cdf0e10cSrcweir 
935*cdf0e10cSrcweir     init (message, yes, no, help_id);
936*cdf0e10cSrcweir }
937*cdf0e10cSrcweir 
938*cdf0e10cSrcweir void MessageBox::init (char const* message, char const* yes, char const* no, const rtl::OString& help_id)
939*cdf0e10cSrcweir {
940*cdf0e10cSrcweir     init ( OUString::createFromAscii (message), OUString::createFromAscii (yes), OUString::createFromAscii (no), help_id);
941*cdf0e10cSrcweir }
942*cdf0e10cSrcweir 
943*cdf0e10cSrcweir void MessageBox::init (OUString const& message, OUString const& yes, OUString const& no, const rtl::OString& help_id)
944*cdf0e10cSrcweir {
945*cdf0e10cSrcweir     imageError.Hide ();
946*cdf0e10cSrcweir     imageInfo.Hide ();
947*cdf0e10cSrcweir     imageQuery.Hide ();
948*cdf0e10cSrcweir     imageWarning.Hide ();
949*cdf0e10cSrcweir     if (message.getLength ())
950*cdf0e10cSrcweir         messageText.SetText (message);
951*cdf0e10cSrcweir     if (yes.getLength ())
952*cdf0e10cSrcweir     {
953*cdf0e10cSrcweir         yesButton.SetText (yes);
954*cdf0e10cSrcweir         if (yes != OUString (Button::GetStandardText (BUTTON_OK))
955*cdf0e10cSrcweir             && yes != OUString (Button::GetStandardText (BUTTON_YES)))
956*cdf0e10cSrcweir             SetTitle (yes);
957*cdf0e10cSrcweir         if (no.getLength ())
958*cdf0e10cSrcweir             noButton.SetText (no);
959*cdf0e10cSrcweir         else
960*cdf0e10cSrcweir             noButton.Hide ();
961*cdf0e10cSrcweir     }
962*cdf0e10cSrcweir     if (help_id)
963*cdf0e10cSrcweir         SetHelpId (help_id);
964*cdf0e10cSrcweir     else
965*cdf0e10cSrcweir         helpButton.Hide ();
966*cdf0e10cSrcweir }
967*cdf0e10cSrcweir 
968*cdf0e10cSrcweir #undef MESSAGE_BOX_IMPL
969*cdf0e10cSrcweir #define MESSAGE_BOX_IMPL(Name)\
970*cdf0e10cSrcweir     Name##Box::Name##Box (::Window *parent, char const* message,\
971*cdf0e10cSrcweir                           char const* yes, char const* no, const rtl::OString& help_id,\
972*cdf0e10cSrcweir                           char const* xml_file, char const* id)\
973*cdf0e10cSrcweir     : MessageBox (parent, message, yes, no, help_id, xml_file, id)\
974*cdf0e10cSrcweir     {\
975*cdf0e10cSrcweir         image##Name.Show ();\
976*cdf0e10cSrcweir     }\
977*cdf0e10cSrcweir     Name##Box::Name##Box (::Window *parent, OUString const& message,\
978*cdf0e10cSrcweir                           OUString yes, OUString no, const rtl::OString& help_id,\
979*cdf0e10cSrcweir                           char const* xml_file, char const* id)\
980*cdf0e10cSrcweir     : MessageBox (parent, message, yes, no, help_id, xml_file, id)\
981*cdf0e10cSrcweir     {\
982*cdf0e10cSrcweir         image##Name.Show ();\
983*cdf0e10cSrcweir     }\
984*cdf0e10cSrcweir     Name##Box::Name##Box (::Window *parent, WinBits bits, char const* message,\
985*cdf0e10cSrcweir                           char const* yes, char const* no, const rtl::OString& help_id,\
986*cdf0e10cSrcweir                           char const* xml_file, char const* id)\
987*cdf0e10cSrcweir     : MessageBox (parent, bits, message, yes, no, help_id, xml_file, id)\
988*cdf0e10cSrcweir     {\
989*cdf0e10cSrcweir         image##Name.Show ();\
990*cdf0e10cSrcweir     }\
991*cdf0e10cSrcweir     Name##Box::Name##Box (::Window *parent, WinBits bits, OUString const& message,\
992*cdf0e10cSrcweir                           OUString yes, OUString no, const rtl::OString& help_id,\
993*cdf0e10cSrcweir                           char const* xml_file, char const* id)\
994*cdf0e10cSrcweir     : MessageBox (parent, bits, message, yes, no, help_id, xml_file, id)\
995*cdf0e10cSrcweir     {\
996*cdf0e10cSrcweir         image##Name.Show ();\
997*cdf0e10cSrcweir     }
998*cdf0e10cSrcweir 
999*cdf0e10cSrcweir MESSAGE_BOX_IMPL (Error);
1000*cdf0e10cSrcweir MESSAGE_BOX_IMPL (Info);
1001*cdf0e10cSrcweir MESSAGE_BOX_IMPL (Query);
1002*cdf0e10cSrcweir MESSAGE_BOX_IMPL (Warning);
1003*cdf0e10cSrcweir 
1004*cdf0e10cSrcweir class TabControlImpl
1005*cdf0e10cSrcweir     : public ControlImpl
1006*cdf0e10cSrcweir     , public ::cppu::WeakImplHelper1 <awt::XTabListener>
1007*cdf0e10cSrcweir {
1008*cdf0e10cSrcweir     Link mActivatePageHdl;
1009*cdf0e10cSrcweir     Link mDeactivatePageHdl;
1010*cdf0e10cSrcweir 
1011*cdf0e10cSrcweir public:
1012*cdf0e10cSrcweir     uno::Reference <awt::XSimpleTabController> mxTabControl;
1013*cdf0e10cSrcweir     TabControlImpl (Context *context, const PeerHandle &peer, Window *window)
1014*cdf0e10cSrcweir         : ControlImpl (context, peer, window)
1015*cdf0e10cSrcweir         ,  mxTabControl (peer, uno::UNO_QUERY)
1016*cdf0e10cSrcweir     {
1017*cdf0e10cSrcweir     }
1018*cdf0e10cSrcweir 
1019*cdf0e10cSrcweir     virtual void SAL_CALL disposing (lang::EventObject const& e)
1020*cdf0e10cSrcweir         throw (uno::RuntimeException)
1021*cdf0e10cSrcweir     {
1022*cdf0e10cSrcweir         ControlImpl::disposing (e);
1023*cdf0e10cSrcweir         mxTabControl.clear ();
1024*cdf0e10cSrcweir     }
1025*cdf0e10cSrcweir 
1026*cdf0e10cSrcweir     Link& GetActivatePageHdl ()
1027*cdf0e10cSrcweir     {
1028*cdf0e10cSrcweir         return mActivatePageHdl;
1029*cdf0e10cSrcweir     }
1030*cdf0e10cSrcweir 
1031*cdf0e10cSrcweir     void SetActivatePageHdl (Link const& link)
1032*cdf0e10cSrcweir     {
1033*cdf0e10cSrcweir         if (!mDeactivatePageHdl || !link)
1034*cdf0e10cSrcweir             UpdateListening (link);
1035*cdf0e10cSrcweir         mActivatePageHdl = link;
1036*cdf0e10cSrcweir     }
1037*cdf0e10cSrcweir 
1038*cdf0e10cSrcweir     Link& GetDeactivatePageHdl ()
1039*cdf0e10cSrcweir     {
1040*cdf0e10cSrcweir         return mDeactivatePageHdl;
1041*cdf0e10cSrcweir     }
1042*cdf0e10cSrcweir 
1043*cdf0e10cSrcweir     void SetDeactivatePageHdl (Link const& link)
1044*cdf0e10cSrcweir     {
1045*cdf0e10cSrcweir         if (!mActivatePageHdl || !link)
1046*cdf0e10cSrcweir             UpdateListening (link);
1047*cdf0e10cSrcweir         mDeactivatePageHdl = link;
1048*cdf0e10cSrcweir     }
1049*cdf0e10cSrcweir 
1050*cdf0e10cSrcweir     void UpdateListening (Link const& link)
1051*cdf0e10cSrcweir     {
1052*cdf0e10cSrcweir         if (!link && (!!mActivatePageHdl || !!mDeactivatePageHdl))
1053*cdf0e10cSrcweir             mxTabControl->removeTabListener (this);
1054*cdf0e10cSrcweir         else if (!!link && !mActivatePageHdl && !mDeactivatePageHdl)
1055*cdf0e10cSrcweir             mxTabControl->addTabListener (this);
1056*cdf0e10cSrcweir     }
1057*cdf0e10cSrcweir 
1058*cdf0e10cSrcweir     void SAL_CALL activated (sal_Int32)
1059*cdf0e10cSrcweir         throw (uno::RuntimeException)
1060*cdf0e10cSrcweir     {
1061*cdf0e10cSrcweir         mActivatePageHdl.Call (mpWindow);
1062*cdf0e10cSrcweir     }
1063*cdf0e10cSrcweir 
1064*cdf0e10cSrcweir     void SAL_CALL deactivated (sal_Int32)
1065*cdf0e10cSrcweir         throw (uno::RuntimeException)
1066*cdf0e10cSrcweir     {
1067*cdf0e10cSrcweir         mDeactivatePageHdl.Call (mpWindow);
1068*cdf0e10cSrcweir     }
1069*cdf0e10cSrcweir 
1070*cdf0e10cSrcweir     void SAL_CALL inserted (sal_Int32)
1071*cdf0e10cSrcweir         throw (uno::RuntimeException)
1072*cdf0e10cSrcweir     {
1073*cdf0e10cSrcweir     }
1074*cdf0e10cSrcweir 
1075*cdf0e10cSrcweir     void SAL_CALL removed (sal_Int32)
1076*cdf0e10cSrcweir         throw (uno::RuntimeException)
1077*cdf0e10cSrcweir     {
1078*cdf0e10cSrcweir     }
1079*cdf0e10cSrcweir 
1080*cdf0e10cSrcweir     void SAL_CALL changed (sal_Int32, uno::Sequence <beans::NamedValue> const&)
1081*cdf0e10cSrcweir         throw (uno::RuntimeException)
1082*cdf0e10cSrcweir     {
1083*cdf0e10cSrcweir     }
1084*cdf0e10cSrcweir };
1085*cdf0e10cSrcweir 
1086*cdf0e10cSrcweir IMPL_GET_WINDOW (TabControl);
1087*cdf0e10cSrcweir IMPL_GET_LAYOUT_VCLXWINDOW (TabControl);
1088*cdf0e10cSrcweir 
1089*cdf0e10cSrcweir #define MX_TABCONTROL if (getImpl ().mxTabControl.is ()) getImpl ().mxTabControl
1090*cdf0e10cSrcweir #define RETURN_MX_TABCONTROL if (getImpl ().mxTabControl.is ()) return getImpl ().mxTabControl
1091*cdf0e10cSrcweir 
1092*cdf0e10cSrcweir TabControl::~TabControl ()
1093*cdf0e10cSrcweir {
1094*cdf0e10cSrcweir     SetActivatePageHdl (Link ());
1095*cdf0e10cSrcweir     SetDeactivatePageHdl (Link ());
1096*cdf0e10cSrcweir }
1097*cdf0e10cSrcweir 
1098*cdf0e10cSrcweir void TabControl::InsertPage (sal_uInt16 id, OUString const& title, sal_uInt16 pos)
1099*cdf0e10cSrcweir {
1100*cdf0e10cSrcweir     (void) pos;
1101*cdf0e10cSrcweir //    GetTabControl ()->InsertPage (id, title, pos);
1102*cdf0e10cSrcweir //    GetTabControl ()->SetTabPage (id, new ::TabPage (GetTabControl ()));
1103*cdf0e10cSrcweir 
1104*cdf0e10cSrcweir     MX_TABCONTROL->insertTab ();
1105*cdf0e10cSrcweir     SetCurPageId (id);
1106*cdf0e10cSrcweir 
1107*cdf0e10cSrcweir #if 1 // colour me loc productive -- NOT
1108*cdf0e10cSrcweir #define ADD_PROP( seq, i, name, val )\
1109*cdf0e10cSrcweir     { \
1110*cdf0e10cSrcweir         beans::NamedValue value; \
1111*cdf0e10cSrcweir         value.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( name ) ); \
1112*cdf0e10cSrcweir         value.Value = uno::makeAny( val ); \
1113*cdf0e10cSrcweir         seq[i] = value; \
1114*cdf0e10cSrcweir     }
1115*cdf0e10cSrcweir 
1116*cdf0e10cSrcweir     uno::Sequence< beans::NamedValue > seq (1);
1117*cdf0e10cSrcweir     ADD_PROP ( seq, 0, "Title", OUString (title) );
1118*cdf0e10cSrcweir     MX_TABCONTROL->setTabProps (id, seq);
1119*cdf0e10cSrcweir #else
1120*cdf0e10cSrcweir     GetTabPage (id)->SetText (title);
1121*cdf0e10cSrcweir #endif
1122*cdf0e10cSrcweir 
1123*cdf0e10cSrcweir #if 0
1124*cdf0e10cSrcweir     /// This so seems the right solution, but it makes the buttons of the
1125*cdf0e10cSrcweir     /// tabdialog move up
1126*cdf0e10cSrcweir 
1127*cdf0e10cSrcweir     ::TabPage *page = GetTabPage (id);
1128*cdf0e10cSrcweir     if (Window *w = dynamic_cast <Window*> (page))
1129*cdf0e10cSrcweir     {
1130*cdf0e10cSrcweir         w->SetParent (this);
1131*cdf0e10cSrcweir         //GetVCLXTabControl ()->Box_Base::addChild (uno::Reference <awt::XLayoutConstrains> (w->GetPeer (), uno::UNO_QUERY));
1132*cdf0e10cSrcweir         //GetVCLXTabControl ()->Box_Base::AddChild (uno::Reference <awt::XLayoutConstrains> (w->GetPeer (), uno::UNO_QUERY));
1133*cdf0e10cSrcweir         //GetVCLXTabControl ()->AddChild (w);
1134*cdf0e10cSrcweir         //GetVCLXTabControl ()->AddChild (uno::Reference <awt::XLayoutConstrains> (w->GetPeer (), uno::UNO_QUERY));
1135*cdf0e10cSrcweir         //uno::Reference <uno::XInterface> x (page->GetWindowPeer());
1136*cdf0e10cSrcweir         //GetVCLXTabControl ()->AddChild (uno::Reference <awt::XLayoutConstrains> (page->::Window::GetWindowPeer (), uno::UNO_QUERY));
1137*cdf0e10cSrcweir         //GetVCLXTabControl ()->AddChild (uno::Reference <awt::XLayoutConstrains> (page->GetComponentInterface (), uno::UNO_QUERY));
1138*cdf0e10cSrcweir     }
1139*cdf0e10cSrcweir     getImpl ().redraw ();
1140*cdf0e10cSrcweir #endif
1141*cdf0e10cSrcweir }
1142*cdf0e10cSrcweir void TabControl::RemovePage (sal_uInt16 id)
1143*cdf0e10cSrcweir {
1144*cdf0e10cSrcweir     GetTabControl ()->RemovePage (id);
1145*cdf0e10cSrcweir }
1146*cdf0e10cSrcweir sal_uInt16 TabControl::GetPageCount () const
1147*cdf0e10cSrcweir {
1148*cdf0e10cSrcweir     return GetTabControl ()->GetPageCount ();
1149*cdf0e10cSrcweir }
1150*cdf0e10cSrcweir sal_uInt16 TabControl::GetPageId (sal_uInt16 pos) const
1151*cdf0e10cSrcweir {
1152*cdf0e10cSrcweir     return GetTabControl ()->GetPageId (pos);
1153*cdf0e10cSrcweir }
1154*cdf0e10cSrcweir sal_uInt16 TabControl::GetPagePos (sal_uInt16 id) const
1155*cdf0e10cSrcweir {
1156*cdf0e10cSrcweir     getImpl ().redraw ();
1157*cdf0e10cSrcweir     return GetTabControl ()->GetPagePos (id);
1158*cdf0e10cSrcweir }
1159*cdf0e10cSrcweir void TabControl::SetCurPageId (sal_uInt16 id)
1160*cdf0e10cSrcweir {
1161*cdf0e10cSrcweir     getImpl ().redraw ();
1162*cdf0e10cSrcweir     GetTabControl ()->SetCurPageId (id);
1163*cdf0e10cSrcweir }
1164*cdf0e10cSrcweir sal_uInt16 TabControl::GetCurPageId () const
1165*cdf0e10cSrcweir {
1166*cdf0e10cSrcweir     return GetTabControl ()->GetCurPageId ();
1167*cdf0e10cSrcweir }
1168*cdf0e10cSrcweir void TabControl::SetTabPage (sal_uInt16 id, ::TabPage* page)
1169*cdf0e10cSrcweir {
1170*cdf0e10cSrcweir     GetTabControl ()->SetTabPage (id, page);
1171*cdf0e10cSrcweir 
1172*cdf0e10cSrcweir #if 0
1173*cdf0e10cSrcweir     /// This so seems the right solution, but it makes the buttons of the
1174*cdf0e10cSrcweir     /// tabdialog move up
1175*cdf0e10cSrcweir     if (Window *w = dynamic_cast <Window*> (page))
1176*cdf0e10cSrcweir     {
1177*cdf0e10cSrcweir         w->SetParent (this);
1178*cdf0e10cSrcweir         //GetVCLXTabControl ()->Box_Base::addChild (uno::Reference <awt::XLayoutConstrains> (w->GetPeer (), uno::UNO_QUERY));
1179*cdf0e10cSrcweir         //GetVCLXTabControl ()->Box_Base::AddChild (uno::Reference <awt::XLayoutConstrains> (w->GetPeer (), uno::UNO_QUERY));
1180*cdf0e10cSrcweir         //GetVCLXTabControl ()->AddChild (w);
1181*cdf0e10cSrcweir         //GetVCLXTabControl ()->AddChild (uno::Reference <awt::XLayoutConstrains> (w->GetPeer (), uno::UNO_QUERY));
1182*cdf0e10cSrcweir         //GetVCLXTabControl ()->AddChild (uno::Reference <awt::XLayoutConstrains> (page->GetWindowPeer (), uno::UNO_QUERY));
1183*cdf0e10cSrcweir         //GetVCLXTabControl ()->AddChild (uno::Reference <awt::XLayoutConstrains> (page->GetComponentInterface (), uno::UNO_QUERY));
1184*cdf0e10cSrcweir     }
1185*cdf0e10cSrcweir #endif
1186*cdf0e10cSrcweir     getImpl ().redraw ();
1187*cdf0e10cSrcweir }
1188*cdf0e10cSrcweir ::TabPage* TabControl::GetTabPage (sal_uInt16 id) const
1189*cdf0e10cSrcweir {
1190*cdf0e10cSrcweir     return GetTabControl ()->GetTabPage (id);
1191*cdf0e10cSrcweir }
1192*cdf0e10cSrcweir void TabControl::SetActivatePageHdl (Link const& link)
1193*cdf0e10cSrcweir {
1194*cdf0e10cSrcweir     if (&getImpl () && getImpl().mxTabControl.is ())
1195*cdf0e10cSrcweir         getImpl ().SetActivatePageHdl (link);
1196*cdf0e10cSrcweir }
1197*cdf0e10cSrcweir Link& TabControl::GetActivatePageHdl () const
1198*cdf0e10cSrcweir {
1199*cdf0e10cSrcweir     return getImpl ().GetActivatePageHdl ();
1200*cdf0e10cSrcweir }
1201*cdf0e10cSrcweir void TabControl::SetDeactivatePageHdl (Link const& link)
1202*cdf0e10cSrcweir {
1203*cdf0e10cSrcweir     if (&getImpl () && getImpl().mxTabControl.is ())
1204*cdf0e10cSrcweir         getImpl ().SetDeactivatePageHdl (link);
1205*cdf0e10cSrcweir }
1206*cdf0e10cSrcweir Link& TabControl::GetDeactivatePageHdl () const
1207*cdf0e10cSrcweir {
1208*cdf0e10cSrcweir     return getImpl ().GetDeactivatePageHdl ();
1209*cdf0e10cSrcweir }
1210*cdf0e10cSrcweir void TabControl::SetTabPageSizePixel (Size const& size)
1211*cdf0e10cSrcweir {
1212*cdf0e10cSrcweir     GetTabControl ()->SetTabPageSizePixel (size);
1213*cdf0e10cSrcweir //    GetParent()->SetSizePixel (size);
1214*cdf0e10cSrcweir //    GetWindow()->SetSizePixel (size);
1215*cdf0e10cSrcweir     //GetVCLXTabControl->SetTabSize (size);
1216*cdf0e10cSrcweir }
1217*cdf0e10cSrcweir Size TabControl::GetTabPageSizePixel () const
1218*cdf0e10cSrcweir {
1219*cdf0e10cSrcweir #if 0
1220*cdf0e10cSrcweir     //return GetTabControl ()->GetTabPageSizePixel ();
1221*cdf0e10cSrcweir     static size_t const tab_page_first_index = 1;
1222*cdf0e10cSrcweir     for (size_t i = 0; i < GetPageCount (); i++)
1223*cdf0e10cSrcweir     {
1224*cdf0e10cSrcweir         ::TabPage *p = GetTabPage (i + tab_page_first_index);
1225*cdf0e10cSrcweir         //if (dynamic_cast<Windowt*> (p))
1226*cdf0e10cSrcweir         if (i) // URG
1227*cdf0e10cSrcweir             return p->GetOptimalSize (WINDOWSIZE_MINIMUM);
1228*cdf0e10cSrcweir     }
1229*cdf0e10cSrcweir #endif
1230*cdf0e10cSrcweir     return GetTabControl ()->GetTabPageSizePixel ();
1231*cdf0e10cSrcweir }
1232*cdf0e10cSrcweir 
1233*cdf0e10cSrcweir IMPL_CONSTRUCTORS (TabControl, Control, "tabcontrol");
1234*cdf0e10cSrcweir IMPL_GET_IMPL (TabControl);
1235*cdf0e10cSrcweir 
1236*cdf0e10cSrcweir class TabPageImpl : public WindowImpl
1237*cdf0e10cSrcweir {
1238*cdf0e10cSrcweir public:
1239*cdf0e10cSrcweir     uno::Reference< awt::XWindow > mxTabPage;
1240*cdf0e10cSrcweir     TabPageImpl( Context *context, const PeerHandle &peer, Window *window )
1241*cdf0e10cSrcweir         : WindowImpl( context, peer, window )
1242*cdf0e10cSrcweir         , mxTabPage( peer, uno::UNO_QUERY )
1243*cdf0e10cSrcweir     {
1244*cdf0e10cSrcweir     }
1245*cdf0e10cSrcweir };
1246*cdf0e10cSrcweir 
1247*cdf0e10cSrcweir ::Window* TabPage::global_parent = 0;
1248*cdf0e10cSrcweir TabControl* TabPage::global_tabcontrol = 0;
1249*cdf0e10cSrcweir 
1250*cdf0e10cSrcweir IMPL_GET_IMPL( TabPage );
1251*cdf0e10cSrcweir 
1252*cdf0e10cSrcweir TabPage::TabPage( Window *parent, const char *xml_file, const char *id, sal_uInt32 nId)
1253*cdf0e10cSrcweir     : Context( xml_file )
1254*cdf0e10cSrcweir     , Window( new TabPageImpl( this, Context::GetPeerHandle( id, nId ), this ) )
1255*cdf0e10cSrcweir {
1256*cdf0e10cSrcweir     if ( parent )
1257*cdf0e10cSrcweir         SetParent( parent );
1258*cdf0e10cSrcweir }
1259*cdf0e10cSrcweir 
1260*cdf0e10cSrcweir TabPage::TabPage( ::Window *parent, const char *xml_file, const char *id, sal_uInt32 nId)
1261*cdf0e10cSrcweir     : Context( xml_file )
1262*cdf0e10cSrcweir     , Window( new TabPageImpl( this, Context::GetPeerHandle( id, nId ), this ) )
1263*cdf0e10cSrcweir {
1264*cdf0e10cSrcweir     if ( parent )
1265*cdf0e10cSrcweir         SetParent( parent );
1266*cdf0e10cSrcweir }
1267*cdf0e10cSrcweir 
1268*cdf0e10cSrcweir TabPage::~TabPage()
1269*cdf0e10cSrcweir {
1270*cdf0e10cSrcweir     delete GetTabPage();
1271*cdf0e10cSrcweir }
1272*cdf0e10cSrcweir 
1273*cdf0e10cSrcweir IMPL_GET_WINDOW( TabPage );
1274*cdf0e10cSrcweir 
1275*cdf0e10cSrcweir void TabPage::ActivatePage()
1276*cdf0e10cSrcweir {
1277*cdf0e10cSrcweir }
1278*cdf0e10cSrcweir 
1279*cdf0e10cSrcweir void TabPage::DeactivatePage()
1280*cdf0e10cSrcweir {
1281*cdf0e10cSrcweir }
1282*cdf0e10cSrcweir 
1283*cdf0e10cSrcweir class FixedLineImpl : public ControlImpl
1284*cdf0e10cSrcweir {
1285*cdf0e10cSrcweir public:
1286*cdf0e10cSrcweir     FixedLineImpl( Context *context, const PeerHandle &peer, Window *window )
1287*cdf0e10cSrcweir         : ControlImpl( context, peer, window )
1288*cdf0e10cSrcweir     {
1289*cdf0e10cSrcweir     }
1290*cdf0e10cSrcweir };
1291*cdf0e10cSrcweir 
1292*cdf0e10cSrcweir IMPL_CONSTRUCTORS( FixedLine, Control, "hfixedline" );
1293*cdf0e10cSrcweir IMPL_GET_IMPL( FixedLine );
1294*cdf0e10cSrcweir 
1295*cdf0e10cSrcweir bool FixedLine::IsEnabled() const
1296*cdf0e10cSrcweir {
1297*cdf0e10cSrcweir     //FIXME
1298*cdf0e10cSrcweir     return true;
1299*cdf0e10cSrcweir }
1300*cdf0e10cSrcweir 
1301*cdf0e10cSrcweir class FixedTextImpl : public ControlImpl
1302*cdf0e10cSrcweir {
1303*cdf0e10cSrcweir public:
1304*cdf0e10cSrcweir     uno::Reference< awt::XFixedText > mxFixedText;
1305*cdf0e10cSrcweir     FixedTextImpl( Context *context, const PeerHandle &peer, Window *window )
1306*cdf0e10cSrcweir         : ControlImpl( context, peer, window )
1307*cdf0e10cSrcweir         , mxFixedText( peer, uno::UNO_QUERY )
1308*cdf0e10cSrcweir     {
1309*cdf0e10cSrcweir     }
1310*cdf0e10cSrcweir 
1311*cdf0e10cSrcweir     ~FixedTextImpl ();
1312*cdf0e10cSrcweir 
1313*cdf0e10cSrcweir     virtual void SAL_CALL disposing( lang::EventObject const& e )
1314*cdf0e10cSrcweir         throw (uno::RuntimeException);
1315*cdf0e10cSrcweir };
1316*cdf0e10cSrcweir 
1317*cdf0e10cSrcweir FixedTextImpl::~FixedTextImpl ()
1318*cdf0e10cSrcweir {
1319*cdf0e10cSrcweir }
1320*cdf0e10cSrcweir 
1321*cdf0e10cSrcweir void SAL_CALL FixedTextImpl::disposing( lang::EventObject const& e )
1322*cdf0e10cSrcweir     throw (uno::RuntimeException)
1323*cdf0e10cSrcweir {
1324*cdf0e10cSrcweir     ControlImpl::disposing (e);
1325*cdf0e10cSrcweir     mxFixedText.clear ();
1326*cdf0e10cSrcweir }
1327*cdf0e10cSrcweir 
1328*cdf0e10cSrcweir FixedText::~FixedText ()
1329*cdf0e10cSrcweir {
1330*cdf0e10cSrcweir }
1331*cdf0e10cSrcweir 
1332*cdf0e10cSrcweir IMPL_CONSTRUCTORS( FixedText, Control, "fixedtext" );
1333*cdf0e10cSrcweir IMPL_GET_IMPL( FixedText );
1334*cdf0e10cSrcweir 
1335*cdf0e10cSrcweir void FixedText::SetText( OUString const& rStr )
1336*cdf0e10cSrcweir {
1337*cdf0e10cSrcweir     if ( !getImpl().mxFixedText.is() )
1338*cdf0e10cSrcweir         return;
1339*cdf0e10cSrcweir     getImpl().mxFixedText->setText( rStr );
1340*cdf0e10cSrcweir }
1341*cdf0e10cSrcweir 
1342*cdf0e10cSrcweir class FixedInfoImpl : public FixedTextImpl
1343*cdf0e10cSrcweir {
1344*cdf0e10cSrcweir public:
1345*cdf0e10cSrcweir     FixedInfoImpl( Context *context, const PeerHandle &peer, Window *window )
1346*cdf0e10cSrcweir         : FixedTextImpl( context, peer, window )
1347*cdf0e10cSrcweir     {
1348*cdf0e10cSrcweir     }
1349*cdf0e10cSrcweir };
1350*cdf0e10cSrcweir 
1351*cdf0e10cSrcweir IMPL_CONSTRUCTORS( FixedInfo, FixedText, "fixedinfo" );
1352*cdf0e10cSrcweir IMPL_GET_IMPL( FixedInfo );
1353*cdf0e10cSrcweir 
1354*cdf0e10cSrcweir class ProgressBarImpl : public ControlImpl
1355*cdf0e10cSrcweir {
1356*cdf0e10cSrcweir public:
1357*cdf0e10cSrcweir     uno::Reference< awt::XProgressBar > mxProgressBar;
1358*cdf0e10cSrcweir     ProgressBarImpl( Context *context, const PeerHandle &peer, Window *window )
1359*cdf0e10cSrcweir         : ControlImpl( context, peer, window )
1360*cdf0e10cSrcweir         , mxProgressBar( peer, uno::UNO_QUERY )
1361*cdf0e10cSrcweir     {
1362*cdf0e10cSrcweir     }
1363*cdf0e10cSrcweir 
1364*cdf0e10cSrcweir     virtual void SAL_CALL disposing( lang::EventObject const& e )
1365*cdf0e10cSrcweir         throw (uno::RuntimeException)
1366*cdf0e10cSrcweir     {
1367*cdf0e10cSrcweir         ControlImpl::disposing (e);
1368*cdf0e10cSrcweir         mxProgressBar.clear ();
1369*cdf0e10cSrcweir     }
1370*cdf0e10cSrcweir };
1371*cdf0e10cSrcweir 
1372*cdf0e10cSrcweir 
1373*cdf0e10cSrcweir class FixedImageImpl: public ControlImpl
1374*cdf0e10cSrcweir {
1375*cdf0e10cSrcweir public:
1376*cdf0e10cSrcweir     uno::Reference< graphic::XGraphic > mxGraphic;
1377*cdf0e10cSrcweir     FixedImageImpl( Context *context, const PeerHandle &peer, Window *window)
1378*cdf0e10cSrcweir //                    const char *pName )
1379*cdf0e10cSrcweir         : ControlImpl( context, peer, window )
1380*cdf0e10cSrcweir           //, mxGraphic( layoutimpl::loadGraphic( pName ) )
1381*cdf0e10cSrcweir         , mxGraphic( peer, uno::UNO_QUERY )
1382*cdf0e10cSrcweir     {
1383*cdf0e10cSrcweir         if ( !mxGraphic.is() )
1384*cdf0e10cSrcweir         {
1385*cdf0e10cSrcweir             DBG_ERROR( "ERROR: failed to load image: `%s'" /*, pName*/ );
1386*cdf0e10cSrcweir         }
1387*cdf0e10cSrcweir #if 0
1388*cdf0e10cSrcweir         else
1389*cdf0e10cSrcweir             getImpl().mxGraphic->...();
1390*cdf0e10cSrcweir #endif
1391*cdf0e10cSrcweir     }
1392*cdf0e10cSrcweir };
1393*cdf0e10cSrcweir 
1394*cdf0e10cSrcweir IMPL_CONSTRUCTORS( FixedImage, Control, "fixedimage" );
1395*cdf0e10cSrcweir IMPL_GET_IMPL( FixedImage )
1396*cdf0e10cSrcweir 
1397*cdf0e10cSrcweir void FixedImage::setImage( ::Image const& i )
1398*cdf0e10cSrcweir {
1399*cdf0e10cSrcweir     (void) i;
1400*cdf0e10cSrcweir     if ( !getImpl().mxGraphic.is() )
1401*cdf0e10cSrcweir         return;
1402*cdf0e10cSrcweir     //FIXME: hack moved to proplist
1403*cdf0e10cSrcweir     //getImpl().mxGraphic =
1404*cdf0e10cSrcweir }
1405*cdf0e10cSrcweir 
1406*cdf0e10cSrcweir #if 0
1407*cdf0e10cSrcweir 
1408*cdf0e10cSrcweir FixedImage::FixedImage( const char *pName )
1409*cdf0e10cSrcweir     : pImpl( new FixedImageImpl( pName ) )
1410*cdf0e10cSrcweir {
1411*cdf0e10cSrcweir }
1412*cdf0e10cSrcweir 
1413*cdf0e10cSrcweir FixedImage::~FixedImage()
1414*cdf0e10cSrcweir {
1415*cdf0e10cSrcweir     delete pImpl;
1416*cdf0e10cSrcweir }
1417*cdf0e10cSrcweir 
1418*cdf0e10cSrcweir #endif
1419*cdf0e10cSrcweir 
1420*cdf0e10cSrcweir 
1421*cdf0e10cSrcweir IMPL_CONSTRUCTORS( ProgressBar, Control, "ProgressBar" );
1422*cdf0e10cSrcweir IMPL_GET_IMPL( ProgressBar );
1423*cdf0e10cSrcweir 
1424*cdf0e10cSrcweir void ProgressBar::SetForegroundColor( util::Color color )
1425*cdf0e10cSrcweir {
1426*cdf0e10cSrcweir     if ( !getImpl().mxProgressBar.is() )
1427*cdf0e10cSrcweir         return;
1428*cdf0e10cSrcweir     getImpl().mxProgressBar->setForegroundColor( color );
1429*cdf0e10cSrcweir }
1430*cdf0e10cSrcweir 
1431*cdf0e10cSrcweir void ProgressBar::SetBackgroundColor( util::Color color )
1432*cdf0e10cSrcweir {
1433*cdf0e10cSrcweir     if ( !getImpl().mxProgressBar.is() )
1434*cdf0e10cSrcweir         return;
1435*cdf0e10cSrcweir     getImpl().mxProgressBar->setBackgroundColor( color );
1436*cdf0e10cSrcweir }
1437*cdf0e10cSrcweir 
1438*cdf0e10cSrcweir void ProgressBar::SetValue( sal_Int32 i )
1439*cdf0e10cSrcweir {
1440*cdf0e10cSrcweir     if ( !getImpl().mxProgressBar.is() )
1441*cdf0e10cSrcweir         return;
1442*cdf0e10cSrcweir     getImpl().mxProgressBar->setValue( i );
1443*cdf0e10cSrcweir }
1444*cdf0e10cSrcweir 
1445*cdf0e10cSrcweir void ProgressBar::SetRange( sal_Int32 min, sal_Int32 max )
1446*cdf0e10cSrcweir {
1447*cdf0e10cSrcweir     if ( !getImpl().mxProgressBar.is() )
1448*cdf0e10cSrcweir         return;
1449*cdf0e10cSrcweir     getImpl().mxProgressBar->setRange( min, max );
1450*cdf0e10cSrcweir }
1451*cdf0e10cSrcweir 
1452*cdf0e10cSrcweir sal_Int32 ProgressBar::GetValue()
1453*cdf0e10cSrcweir {
1454*cdf0e10cSrcweir     if ( !getImpl().mxProgressBar.is() )
1455*cdf0e10cSrcweir         return 0;
1456*cdf0e10cSrcweir     return getImpl().mxProgressBar->getValue();
1457*cdf0e10cSrcweir }
1458*cdf0e10cSrcweir 
1459*cdf0e10cSrcweir class PluginImpl: public ControlImpl
1460*cdf0e10cSrcweir {
1461*cdf0e10cSrcweir public:
1462*cdf0e10cSrcweir     ::Control *mpPlugin;
1463*cdf0e10cSrcweir 
1464*cdf0e10cSrcweir     PluginImpl( Context *context, const PeerHandle &peer, Window *window, :: Control *plugin )
1465*cdf0e10cSrcweir         : ControlImpl( context, peer, window )
1466*cdf0e10cSrcweir         , mpPlugin( plugin )
1467*cdf0e10cSrcweir     {
1468*cdf0e10cSrcweir         uno::Reference <awt::XWindow> ref( mxWindow, uno::UNO_QUERY );
1469*cdf0e10cSrcweir         layoutimpl::VCLXPlugin *vcl
1470*cdf0e10cSrcweir             = static_cast<layoutimpl::VCLXPlugin*>( VCLXWindow::GetImplementation( ref ) );
1471*cdf0e10cSrcweir         ::Window *parent = vcl->mpWindow->GetParent();
1472*cdf0e10cSrcweir         vcl->SetWindow( plugin );
1473*cdf0e10cSrcweir         vcl->SetPlugin( mpPlugin );
1474*cdf0e10cSrcweir         plugin->SetParent( parent );
1475*cdf0e10cSrcweir         plugin->SetStyle( vcl->mStyle );
1476*cdf0e10cSrcweir         plugin->SetCreatedWithToolkit( true );
1477*cdf0e10cSrcweir         plugin->SetComponentInterface( vcl );
1478*cdf0e10cSrcweir         plugin->Show();
1479*cdf0e10cSrcweir     }
1480*cdf0e10cSrcweir };
1481*cdf0e10cSrcweir 
1482*cdf0e10cSrcweir Plugin::Plugin( Context *context, char const *id, ::Control *plugin )
1483*cdf0e10cSrcweir     : Control( new PluginImpl( context, context->GetPeerHandle( id, 0 ), this, plugin ) )
1484*cdf0e10cSrcweir     , mpPlugin( plugin )
1485*cdf0e10cSrcweir {
1486*cdf0e10cSrcweir }
1487*cdf0e10cSrcweir 
1488*cdf0e10cSrcweir IMPL_GET_IMPL( Plugin );
1489*cdf0e10cSrcweir 
1490*cdf0e10cSrcweir class LocalizedStringImpl : public WindowImpl
1491*cdf0e10cSrcweir {
1492*cdf0e10cSrcweir public:
1493*cdf0e10cSrcweir     layoutimpl::LocalizedString *mpString;
1494*cdf0e10cSrcweir     OUString maString;
1495*cdf0e10cSrcweir     LocalizedStringImpl( Context *context, const PeerHandle &peer, Window *window )
1496*cdf0e10cSrcweir         : WindowImpl( context, peer, window )
1497*cdf0e10cSrcweir         , mpString( static_cast<layoutimpl::LocalizedString*>( VCLXWindow::GetImplementation( uno::Reference <awt::XWindow> ( mxWindow, uno::UNO_QUERY ) ) ) )
1498*cdf0e10cSrcweir         , maString ()
1499*cdf0e10cSrcweir     {
1500*cdf0e10cSrcweir     }
1501*cdf0e10cSrcweir     OUString getText()
1502*cdf0e10cSrcweir     {
1503*cdf0e10cSrcweir         if (mpString)
1504*cdf0e10cSrcweir             maString = mpString->getText ();
1505*cdf0e10cSrcweir         return maString;
1506*cdf0e10cSrcweir     }
1507*cdf0e10cSrcweir     void setText( OUString const& s )
1508*cdf0e10cSrcweir     {
1509*cdf0e10cSrcweir         if (mpString)
1510*cdf0e10cSrcweir             mpString->setText( s );
1511*cdf0e10cSrcweir     }
1512*cdf0e10cSrcweir };
1513*cdf0e10cSrcweir 
1514*cdf0e10cSrcweir IMPL_GET_IMPL( LocalizedString );
1515*cdf0e10cSrcweir 
1516*cdf0e10cSrcweir LocalizedString::LocalizedString( Context *context, char const* id )
1517*cdf0e10cSrcweir     : Window( new LocalizedStringImpl( context, context->GetPeerHandle( id, 0 ), this ) )
1518*cdf0e10cSrcweir {
1519*cdf0e10cSrcweir }
1520*cdf0e10cSrcweir 
1521*cdf0e10cSrcweir String LocalizedString::getString ()
1522*cdf0e10cSrcweir {
1523*cdf0e10cSrcweir     return getImpl ().getText ();
1524*cdf0e10cSrcweir }
1525*cdf0e10cSrcweir 
1526*cdf0e10cSrcweir OUString LocalizedString::getOUString ()
1527*cdf0e10cSrcweir {
1528*cdf0e10cSrcweir     return getImpl ().getText ();
1529*cdf0e10cSrcweir }
1530*cdf0e10cSrcweir 
1531*cdf0e10cSrcweir LocalizedString::operator OUString ()
1532*cdf0e10cSrcweir {
1533*cdf0e10cSrcweir     return getOUString ();
1534*cdf0e10cSrcweir }
1535*cdf0e10cSrcweir 
1536*cdf0e10cSrcweir LocalizedString::operator OUString const& ()
1537*cdf0e10cSrcweir {
1538*cdf0e10cSrcweir     getOUString ();
1539*cdf0e10cSrcweir     return getImpl ().maString;
1540*cdf0e10cSrcweir }
1541*cdf0e10cSrcweir 
1542*cdf0e10cSrcweir LocalizedString::operator String()
1543*cdf0e10cSrcweir {
1544*cdf0e10cSrcweir     getOUString ();
1545*cdf0e10cSrcweir     return getImpl ().maString;
1546*cdf0e10cSrcweir }
1547*cdf0e10cSrcweir 
1548*cdf0e10cSrcweir String LocalizedString::GetToken (sal_uInt16 i, sal_Char c)
1549*cdf0e10cSrcweir {
1550*cdf0e10cSrcweir     return getString ().GetToken (i, c);
1551*cdf0e10cSrcweir }
1552*cdf0e10cSrcweir 
1553*cdf0e10cSrcweir OUString LocalizedString::operator= (OUString const& s)
1554*cdf0e10cSrcweir {
1555*cdf0e10cSrcweir     getImpl().setText( s );
1556*cdf0e10cSrcweir     return getImpl().getText();
1557*cdf0e10cSrcweir }
1558*cdf0e10cSrcweir 
1559*cdf0e10cSrcweir OUString LocalizedString::operator+= (OUString const& b)
1560*cdf0e10cSrcweir {
1561*cdf0e10cSrcweir     OUString a = getImpl ().getText ();
1562*cdf0e10cSrcweir     a += b;
1563*cdf0e10cSrcweir     getImpl ().setText (a);
1564*cdf0e10cSrcweir     return getImpl ().getText ();
1565*cdf0e10cSrcweir }
1566*cdf0e10cSrcweir 
1567*cdf0e10cSrcweir OUString LocalizedString::operator+= (sal_Unicode const b)
1568*cdf0e10cSrcweir {
1569*cdf0e10cSrcweir     String a = getImpl ().getText ();
1570*cdf0e10cSrcweir     a += b;
1571*cdf0e10cSrcweir     getImpl ().setText (a);
1572*cdf0e10cSrcweir     return getImpl ().getText ();
1573*cdf0e10cSrcweir }
1574*cdf0e10cSrcweir 
1575*cdf0e10cSrcweir class InPlugImpl : public WindowImpl
1576*cdf0e10cSrcweir {
1577*cdf0e10cSrcweir public:
1578*cdf0e10cSrcweir     InPlugImpl (Context *context, const PeerHandle &peer, Window *window)
1579*cdf0e10cSrcweir         : WindowImpl (context, peer, window)
1580*cdf0e10cSrcweir     {
1581*cdf0e10cSrcweir     }
1582*cdf0e10cSrcweir };
1583*cdf0e10cSrcweir 
1584*cdf0e10cSrcweir IMPL_GET_IMPL (InPlug);
1585*cdf0e10cSrcweir 
1586*cdf0e10cSrcweir static char const *FIXME_set_parent (::Window *parent, char const *xml_file)
1587*cdf0e10cSrcweir {
1588*cdf0e10cSrcweir     layout::TabPage::global_parent = parent;
1589*cdf0e10cSrcweir     return xml_file;
1590*cdf0e10cSrcweir }
1591*cdf0e10cSrcweir 
1592*cdf0e10cSrcweir InPlug::InPlug (Window *parent, char const* xml_file, char const* id, sal_uInt32 nId)
1593*cdf0e10cSrcweir     : Context (FIXME_set_parent (parent ? parent->GetWindow () : 0, xml_file))
1594*cdf0e10cSrcweir     , layout::Window (new InPlugImpl (this, Context::GetPeerHandle (id, nId), this))
1595*cdf0e10cSrcweir {
1596*cdf0e10cSrcweir     if (parent)
1597*cdf0e10cSrcweir         SetParent (parent);
1598*cdf0e10cSrcweir     if (::Window *w = dynamic_cast< ::Window* > (this))
1599*cdf0e10cSrcweir         w->SetComponentInterface (GetVCLXWindow ());
1600*cdf0e10cSrcweir }
1601*cdf0e10cSrcweir 
1602*cdf0e10cSrcweir InPlug::InPlug (::Window *parent, char const* xml_file, char const* id, sal_uInt32 nId)
1603*cdf0e10cSrcweir     : Context (FIXME_set_parent (parent, xml_file))
1604*cdf0e10cSrcweir     , layout::Window (new InPlugImpl (this, Context::GetPeerHandle (id, nId), this))
1605*cdf0e10cSrcweir {
1606*cdf0e10cSrcweir     if (parent)
1607*cdf0e10cSrcweir         layout::Window::SetParent (parent);
1608*cdf0e10cSrcweir     if (::Window *w = dynamic_cast< ::Window* > (this))
1609*cdf0e10cSrcweir         w->SetComponentInterface (GetVCLXWindow ());
1610*cdf0e10cSrcweir }
1611*cdf0e10cSrcweir 
1612*cdf0e10cSrcweir void InPlug::ParentSet (Window *window)
1613*cdf0e10cSrcweir {
1614*cdf0e10cSrcweir     window->SetParent (dynamic_cast< ::Window* > (this));
1615*cdf0e10cSrcweir 
1616*cdf0e10cSrcweir     /// FIXME: for standalone run of layout::SfxTabDialog
1617*cdf0e10cSrcweir     SetParent (window->GetParent ());
1618*cdf0e10cSrcweir }
1619*cdf0e10cSrcweir 
1620*cdf0e10cSrcweir } // namespace layout
1621