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