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