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