merge the formfield patch from ooo-build
[ooovba.git] / toolkit / source / layout / vcl / wrapper.cxx
blob08676c29f0b58cfe710a6612e5845d8667516cf5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile$
11 * $Revision$
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #include <tools/rc.h>
33 //#define RESOURCE_PUBLISH_PROTECTED 1
34 #if RESOURCE_PUBLISH_PROTECTED
35 // ugh, override non-helpful proctection
36 #define protected public
37 #endif /* RESOURCE_PUBLISH_PROTECTED */
38 #include <tools/rc.hxx>
39 #undef protected
42 #include "wrapper.hxx"
44 #include <awt/vclxplugin.hxx>
45 #include <awt/vclxtabcontrol.hxx>
46 #include <com/sun/star/awt/PosSize.hpp>
47 #include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
48 #include <com/sun/star/awt/WindowAttribute.hpp>
49 #include <com/sun/star/awt/XDialog2.hpp>
50 #include <com/sun/star/awt/XProgressBar.hpp>
51 #include <com/sun/star/awt/XSimpleTabController.hpp>
52 #include <com/sun/star/awt/XTabListener.hpp>
53 #include <com/sun/star/graphic/XGraphic.hpp>
54 #include <comphelper/processfactory.hxx>
55 #include <layout/core/factory.hxx>
56 #include <layout/core/localized-string.hxx>
57 #include <layout/core/root.hxx>
58 #include <toolkit/awt/vclxwindow.hxx>
59 #include <vcl/ctrl.hxx>
60 #include <vcl/dialog.hxx>
61 #include <vcl/image.hxx>
62 #include <vcl/tabctrl.hxx>
63 #include <vcl/tabpage.hxx>
64 #include <vcl/window.hxx>
66 using namespace ::com::sun::star;
67 using rtl::OUString;
69 namespace layout
72 // Context bits ...
73 class ContextImpl
75 uno::Reference< awt::XLayoutRoot > mxRoot;
76 uno::Reference< container::XNameAccess > mxNameAccess;
77 PeerHandle mxTopLevel;
79 public:
80 ContextImpl( char const *pPath )
82 uno::Sequence< uno::Any > aParams( 1 );
83 aParams[0] <<= OUString( pPath, strlen( pPath ), RTL_TEXTENCODING_UTF8 );
85 uno::Reference< lang::XSingleServiceFactory > xFactory(
86 comphelper::createProcessComponent(
87 OUString::createFromAscii( "com.sun.star.awt.Layout" ) ),
88 uno::UNO_QUERY );
89 if ( !xFactory.is() )
91 throw uno::RuntimeException(
92 OUString( RTL_CONSTASCII_USTRINGPARAM( "Layout engine not installed" ) ),
93 uno::Reference< uno::XInterface >() );
95 mxRoot = uno::Reference< awt::XLayoutRoot >(
96 xFactory->createInstanceWithArguments( aParams ),
97 uno::UNO_QUERY );
99 mxNameAccess = uno::Reference< container::XNameAccess >( mxRoot, uno::UNO_QUERY );
102 ~ContextImpl()
106 PeerHandle getByName( const OUString &rName )
108 uno::Any val = mxNameAccess->getByName( rName );
109 PeerHandle xRet;
110 val >>= xRet;
111 return xRet;
113 PeerHandle getTopLevel()
115 return mxTopLevel;
117 void setTopLevel( PeerHandle xToplevel )
119 mxTopLevel = xToplevel;
121 PeerHandle getRoot()
123 return mxRoot;
127 Context::Context( const char *pPath )
128 : pImpl( new ContextImpl( pPath ) )
131 Context::~Context()
133 delete pImpl;
134 pImpl = NULL;
137 void Context::setToplevel( PeerHandle xToplevel )
139 pImpl->setTopLevel( xToplevel );
142 PeerHandle Context::getToplevel()
144 return pImpl->getTopLevel();
146 PeerHandle Context::getRoot()
148 return pImpl->getRoot();
151 PeerHandle Context::GetPeerHandle( const char *id, sal_uInt32 nId ) const
153 PeerHandle xHandle;
154 xHandle = pImpl->getByName( OUString( id, strlen( id ), RTL_TEXTENCODING_UTF8 ) );
155 if ( !xHandle.is() )
157 DBG_ERROR1( "Failed to fetch widget '%s'", id );
160 if ( nId != 0 )
162 rtl::OString aStr = rtl::OString::valueOf( (sal_Int32) nId );
163 xHandle = GetPeerHandle( aStr, 0 );
165 return xHandle;
168 WindowImpl::WindowImpl (Context *context, const PeerHandle &peer, Window *window)
169 : mpWindow (window)
170 , mpCtx (context)
171 , mxWindow (peer, uno::UNO_QUERY)
172 , mxVclPeer (peer, uno::UNO_QUERY)
173 , mvclWindow (0)
174 , bFirstTimeVisible (true)
178 WindowImpl::~WindowImpl ()
180 if (mpWindow)
182 mpWindow->GetWindow ()->SetAccessible (0);
183 mpWindow->mpImpl = 0;
185 if (mvclWindow)
187 VCLXWindow *v = mvclWindow->GetWindowPeer ();
188 v->SetWindow (0);
189 mvclWindow->SetComponentInterface (uno::Reference <awt::XWindowPeer> ());
190 mvclWindow->SetWindowPeer (uno::Reference <awt::XWindowPeer> (), 0);
191 delete mvclWindow;
192 mvclWindow = 0;
196 void WindowImpl::wrapperGone ()
198 mvclWindow = 0;
199 mpWindow->mpImpl = 0;
200 mpWindow = 0;
201 mpCtx = 0;
202 if ( mxWindow.is() )
204 uno::Reference< lang::XComponent > xComp( mxWindow, uno::UNO_QUERY );
205 mxWindow.clear ();
206 if ( xComp.is() )
207 xComp->dispose();
211 void SAL_CALL WindowImpl::disposing (lang::EventObject const&)
212 throw (uno::RuntimeException)
214 if (mxWindow.is ())
215 mxWindow.clear ();
218 uno::Any WindowImpl::getProperty (char const* name)
220 if ( !this || !mxVclPeer.is() )
221 return css::uno::Any();
222 return mxVclPeer->getProperty
223 ( rtl::OUString( name, strlen( name ), RTL_TEXTENCODING_ASCII_US ) );
226 void WindowImpl::setProperty (char const *name, uno::Any any)
228 if ( !this || !mxVclPeer.is() )
229 return;
230 mxVclPeer->setProperty
231 ( rtl::OUString( name, strlen( name ), RTL_TEXTENCODING_ASCII_US ), any );
234 void WindowImpl::redraw (bool resize)
236 uno::Reference <awt::XWindow> ref (mxWindow, uno::UNO_QUERY);
237 ::Window* window = VCLXWindow::GetImplementation (ref)->GetWindow ();
238 ::Window* parent = window->GetParent();
239 ::Rectangle r = Rectangle (parent->GetPosPixel (),
240 parent->GetSizePixel ());
241 parent->Invalidate (r, INVALIDATE_CHILDREN | INVALIDATE_NOCHILDREN );
242 if (resize)
243 parent->SetPosSizePixel (0, 0, 1, 1, awt::PosSize::SIZE);
244 else
245 parent->SetPosSizePixel (0, 0, r.nRight - r.nLeft, r.nBottom - r.nTop,
246 awt::PosSize::SIZE);
249 Window::Window( WindowImpl *pImpl )
250 : mpImpl( pImpl )
252 mpImpl->mvclWindow = GetVCLXWindow () ? GetWindow () : 0;
255 Window::~Window()
257 /* likely to be an UNO object - with floating references */
258 if (mpImpl)
259 mpImpl->wrapperGone ();
260 mpImpl = 0;
263 ///IMPL_GET_IMPL( Control );
265 static ControlImpl* null_control_impl = 0;
267 ControlImpl &Control::getImpl () const
269 if (ControlImpl* c = static_cast<ControlImpl *>(mpImpl))
270 return *c;
271 return *null_control_impl;
274 Control::~Control ()
276 SetGetFocusHdl (Link ());
277 SetLoseFocusHdl (Link ());
280 void Window::setRes (ResId const& res)
282 #if RESOURCE_PUBLISH_PROTECTED
283 // Resources are shut-off from use. Is that really necessary?
284 Resource &r = *GetWindow ();
285 r.GetRes (res);
286 #else /* !RESOURCE_PUBLISH_PROTECTED */
287 //We *must* derive. Is this also really necessary?
288 //Resource r (res);
290 // ugh, I wonder which solution is cleaner...
291 class Resource_open_up : public Resource
293 public:
294 Resource_open_up (ResId const& r)
295 : Resource (r)
298 static sal_Int32 GetLongRes (void *p)
300 return Resource::GetLongRes (p);
302 void* GetClassRes ()
304 return Resource::GetClassRes ();
306 sal_Int32 ReadLongRes ()
308 return Resource::ReadLongRes ();
310 UniString ReadStringRes ()
312 return Resource::ReadStringRes ();
316 Resource_open_up r (res);
317 #endif /* !RESOURCE_PUBLISH_PROTECTED */
318 if (sal_uInt32 help_id = (sal_uInt32)r.GetLongRes (static_cast<char *> (r.GetClassRes ()) + 12))
319 SetHelpId (help_id);
320 sal_uInt32 mask = r.ReadLongRes ();
321 if ( mask & WINDOW_TEXT )
322 SetText( r.ReadStringRes ());
325 void Window::SetParent( ::Window *parent )
327 uno::Reference <awt::XWindow> ref( GetPeer(), uno::UNO_QUERY );
328 if (VCLXWindow *vcl = VCLXWindow::GetImplementation( ref ))
329 if (::Window *window = vcl->GetWindow())
330 window->SetParent( parent );
333 void Window::SetParent( Window *parent )
335 /* Let's hear it for C++: poor man's dynamic binding. */
336 parent->ParentSet (this);
339 void Window::ParentSet (Window *window)
341 window->SetParent (GetWindow ());
344 Context *Window::getContext()
346 return this && mpImpl ? mpImpl->mpCtx : NULL;
349 PeerHandle Window::GetPeer() const
351 if ( !mpImpl )
352 return PeerHandle();
353 return mpImpl->mxWindow;
356 uno::Reference<awt::XWindow> Window::GetRef() const
358 return uno::Reference <awt::XWindow> ( GetPeer(), uno::UNO_QUERY );
361 VCLXWindow* Window::GetVCLXWindow() const
363 return VCLXWindow::GetImplementation( GetRef() );
366 ::Window* Window::GetWindow() const
368 return GetVCLXWindow()->GetWindow();
371 ::Window* Window::GetParent() const
373 return GetWindow()->GetParent();
376 void Window::SetHelpId( sal_uIntPtr id )
378 GetWindow()->SetHelpId( id );
381 sal_uIntPtr Window::GetHelpId() const
383 return GetWindow()->GetHelpId();
386 void Window::SetSmartHelpId( SmartId const& id, SmartIdUpdateMode mode )
388 GetWindow()->SetSmartHelpId( id, mode );
391 SmartId Window::GetSmartHelpId() const
393 return GetWindow()->GetSmartHelpId();
396 void Window::EnterWait ()
398 GetWindow()->EnterWait ();
400 void Window::LeaveWait ()
402 GetWindow()->LeaveWait ();
404 bool Window::IsWait () const
406 return GetWindow()->IsWait ();
409 bool Window::IsVisible () const
411 if (GetWindow ())
412 return GetWindow()->IsVisible ();
413 return false;
416 bool Window::HasChildPathFocus (bool systemWindow) const
418 return GetWindow()->HasChildPathFocus (systemWindow);
421 void Window::SetPosPixel (Point const&)
425 Point Window::GetPosPixel () const
427 return Point ();
430 void Window::SetSizePixel (Size const&)
434 void Window::SetPosSizePixel (Point const&, Size const&)
438 Size Window::GetSizePixel () const
440 return Size ();
443 // void Window::Enable (bool enable, bool child);
444 // {
445 // GetWindow ()->Enable (enable, child);
446 // }
448 // void Window::Disable (bool child)
449 // {
450 // GetWindow ()->Disable (child);
451 // }
453 bool Window::IsEnabled () const
455 return GetWindow ()->IsEnabled ();
456 // if (getImpl().mxWindow.is ())
457 // return getImpl ().mxWindow->isEnabled ();
458 // return false;
461 void Window::EnableInput (bool enable, bool child)
463 GetWindow ()->EnableInput (enable, child);
466 bool Window::IsInputEnabled () const
468 return GetWindow ()->IsInputEnabled ();
471 bool Window::HasFocus () const
473 return GetWindow ()->HasFocus ();
476 Font& Window::GetFont () const
478 return const_cast <Font&> (GetWindow ()->GetFont ());
481 void Window::SetFont (Font const& font)
483 GetWindow ()->SetFont (font);
486 void Window::Invalidate (sal_uInt8 flags)
488 GetWindow ()->Invalidate (flags);
491 struct ToolkitVclPropsMap
493 WinBits vclStyle;
494 long initAttr;
495 const char *propName;
497 // the value to give the prop to enable/disable it -- not the most brilliant
498 // type declaration and storage, but does the work... properties are
499 // either a boolean or a short since they are either a directly wrappers for
500 // a WinBit, or aggregates related (like Align for WB_LEFT, _RIGHT and _CENTER).
501 bool isBoolean;
502 short enableProp, disableProp;
505 #define TYPE_BOOL true
506 #define TYPE_SHORT false
507 #define NOTYPE 0
508 static const ToolkitVclPropsMap toolkitVclPropsMap[] =
510 { WB_BORDER, awt::WindowAttribute::BORDER, "Border", TYPE_SHORT, 1, 0 },
511 { WB_NOBORDER, awt::VclWindowPeerAttribute::NOBORDER, "Border", TYPE_SHORT, 0, 1 },
512 { WB_SIZEABLE, awt::WindowAttribute::SIZEABLE, NULL, NOTYPE, 0, 0 },
513 { WB_MOVEABLE, awt::WindowAttribute::MOVEABLE, NULL, NOTYPE, 0, 0 },
514 { WB_CLOSEABLE, awt::WindowAttribute::CLOSEABLE, NULL, NOTYPE, 0, 0 },
516 { WB_HSCROLL, awt::VclWindowPeerAttribute::HSCROLL, NULL, NOTYPE, 0, 0 },
517 { WB_VSCROLL, awt::VclWindowPeerAttribute::VSCROLL, NULL, NOTYPE, 0, 0 },
518 { WB_LEFT, awt::VclWindowPeerAttribute::LEFT, "Align", TYPE_SHORT, 0, 0 },
519 { WB_CENTER, awt::VclWindowPeerAttribute::CENTER, "Align", TYPE_SHORT, 1, 0 },
520 { WB_RIGHT, awt::VclWindowPeerAttribute::RIGHT, "Align", TYPE_SHORT, 2, 0 },
521 { WB_SPIN, awt::VclWindowPeerAttribute::SPIN, NULL, NOTYPE, 0, 0 },
522 { WB_SORT, awt::VclWindowPeerAttribute::SORT, NULL, NOTYPE, 0, 0 },
523 { WB_DROPDOWN, awt::VclWindowPeerAttribute::DROPDOWN, "Dropdown", TYPE_BOOL, 1, 0 },
524 { WB_DEFBUTTON, awt::VclWindowPeerAttribute::DEFBUTTON, "DefaultButton", TYPE_BOOL, 1, 0 },
525 { WB_READONLY, awt::VclWindowPeerAttribute::READONLY, NULL, NOTYPE, 0, 0 },
526 { WB_CLIPCHILDREN, awt::VclWindowPeerAttribute::CLIPCHILDREN, NULL, NOTYPE, 0, 0 },
527 { WB_GROUP, awt::VclWindowPeerAttribute::GROUP, NULL, NOTYPE, 0, 0 },
529 { WB_OK, awt::VclWindowPeerAttribute::OK, NULL, NOTYPE, 0, 0 },
530 { WB_OK_CANCEL, awt::VclWindowPeerAttribute::OK_CANCEL, NULL, NOTYPE, 0, 0 },
531 { WB_YES_NO, awt::VclWindowPeerAttribute::YES_NO, NULL, NOTYPE, 0, 0 },
532 { WB_YES_NO_CANCEL, awt::VclWindowPeerAttribute::YES_NO_CANCEL, NULL, NOTYPE, 1, 0 },
533 { WB_RETRY_CANCEL, awt::VclWindowPeerAttribute::RETRY_CANCEL, NULL, NOTYPE, 1, 0 },
534 { WB_DEF_OK, awt::VclWindowPeerAttribute::DEF_OK, NULL, NOTYPE, 0, 0 },
535 { WB_DEF_CANCEL, awt::VclWindowPeerAttribute::DEF_CANCEL, NULL, NOTYPE, 1, 0 },
536 { WB_DEF_RETRY, awt::VclWindowPeerAttribute::DEF_RETRY, NULL, NOTYPE, 0, 0 },
537 { WB_DEF_YES, awt::VclWindowPeerAttribute::DEF_YES, NULL, NOTYPE, 0, 0 },
538 { WB_DEF_NO, awt::VclWindowPeerAttribute::DEF_NO, NULL, NOTYPE, 0, 0 },
540 { WB_AUTOHSCROLL, awt::VclWindowPeerAttribute::AUTOHSCROLL, "AutoHScroll", TYPE_BOOL, 1, 0 },
541 { WB_AUTOVSCROLL, awt::VclWindowPeerAttribute::AUTOVSCROLL, "AutoVScroll", TYPE_BOOL, 1, 0 },
543 { WB_WORDBREAK, 0, "MultiLine", TYPE_BOOL, 1, 0 },
544 { WB_NOPOINTERFOCUS, 0, "FocusOnClick", TYPE_BOOL, 1, 0 },
545 { WB_TOGGLE, 0, "Toggle", TYPE_BOOL, 1, 0 },
546 { WB_REPEAT, 0, "Repeat", TYPE_BOOL, 1, 0 },
547 { WB_NOHIDESELECTION, 0, "HideInactiveSelection", TYPE_BOOL, 1, 0 },
549 #undef TYPE_BOOL
550 #undef TYPE_SHORT
551 #undef NOTYPE
553 static const int toolkitVclPropsMapLen =
554 sizeof( toolkitVclPropsMap ) / sizeof( ToolkitVclPropsMap );
556 void Window::SetStyle( WinBits nStyle )
558 uno::Reference< awt::XVclWindowPeer > xPeer = mpImpl->mxVclPeer;
559 for (int i = 0; i < toolkitVclPropsMapLen; i++)
561 if ( toolkitVclPropsMap[ i ].propName )
563 short nValue;
564 if ( nStyle & toolkitVclPropsMap[ i ].vclStyle )
565 nValue = toolkitVclPropsMap[ i ].enableProp;
566 else
567 nValue = toolkitVclPropsMap[ i ].disableProp;
568 uno::Any aValue;
569 if ( toolkitVclPropsMap[ i ].isBoolean )
570 aValue = uno::makeAny( (bool) nValue );
571 else
572 aValue = uno::makeAny( (short) nValue );
573 mpImpl->setProperty( toolkitVclPropsMap[ i ].propName, aValue );
578 WinBits Window::GetStyle()
580 uno::Reference< awt::XVclWindowPeer > xPeer = mpImpl->mxVclPeer;
581 WinBits ret = 0;
582 for (int i = 0; i < toolkitVclPropsMapLen; i++)
584 if ( toolkitVclPropsMap[ i ].propName )
586 short nValue = 0;
587 if ( toolkitVclPropsMap[ i ].isBoolean )
589 bool bValue = false;
590 mpImpl->getProperty( toolkitVclPropsMap[ i ].propName ) >>= bValue;
591 nValue = bValue ? 1 : 0;
593 else
594 mpImpl->getProperty( toolkitVclPropsMap[ i ].propName ) >>= nValue;
595 if ( nValue == toolkitVclPropsMap[ i ].enableProp )
596 ret |= toolkitVclPropsMap[i].vclStyle;
599 return ret;
602 /* Unpleasant way to get an xToolkit pointer ... */
603 uno::Reference< awt::XToolkit > getToolkit()
605 static uno::Reference< awt::XToolkit > xToolkit;
606 if (!xToolkit.is())
608 // Urgh ...
609 xToolkit = uno::Reference< awt::XToolkit >(
610 ::comphelper::getProcessServiceFactory()->createInstance(
611 OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.Toolkit" ) ) ),
612 uno::UNO_QUERY );
613 if ( !xToolkit.is() )
614 throw uno::RuntimeException(
615 OUString( RTL_CONSTASCII_USTRINGPARAM( "failed to create toolkit!") ),
616 uno::Reference< uno::XInterface >() );
618 return xToolkit;
621 PeerHandle Window::CreatePeer( Window *parent, WinBits nStyle, const char *pName)
623 long nWinAttrbs = 0;
624 for (int i = 0; i < toolkitVclPropsMapLen; i++)
625 if ( nStyle & toolkitVclPropsMap[ i ].vclStyle )
626 nWinAttrbs |= toolkitVclPropsMap[ i ].initAttr;
628 return layoutimpl::WidgetFactory::createWidget (getToolkit(), parent->GetPeer(), OUString::createFromAscii( pName ), nWinAttrbs);
631 void Window::Enable( bool bEnable )
633 if ( !getImpl().mxWindow.is() )
634 return;
635 getImpl().mxWindow->setEnable( bEnable );
638 void Window::Show( bool bVisible )
640 if ( !getImpl().mxWindow.is() )
641 return;
642 getImpl().mxWindow->setVisible( bVisible );
643 if (!bVisible)
644 getImpl ().bFirstTimeVisible = true;
645 else if (GetParent() && getImpl().bFirstTimeVisible)
647 getImpl().redraw ();
648 getImpl().bFirstTimeVisible = false;
652 void Window::GrabFocus()
654 if ( !getImpl().mxWindow.is() )
655 return;
656 getImpl().mxWindow->setFocus();
659 void Window::SetUpdateMode(bool mode)
661 GetWindow()->SetUpdateMode( mode );
664 void Window::SetPointer( Pointer const& pointer )
666 GetWindow()->SetPointer( pointer );
669 Pointer const& Window::GetPointer() const
671 return GetWindow()->GetPointer();
674 void Window::SetText( OUString const& str )
676 GetWindow()->SetText( str );
679 String Window::GetText() const
681 return GetWindow()->GetText();
684 sal_Int32 Window::GetCtrlTextWidth (OUString const&) const
686 return 0;
689 sal_Int32 Window::GetTextHeight () const
691 return 0;
694 Size Window::LogicToPixel( Size const& size, MapMode const&) const
696 return size;
699 ControlImpl::ControlImpl (Context *context, const PeerHandle &peer, Window *window)
700 : WindowImpl( context, peer, window )
704 ControlImpl::~ControlImpl ()
708 void ControlImpl::SetGetFocusHdl (Link const& link)
710 if (!mLoseFocusHdl || !link)
711 UpdateListening (link);
712 mGetFocusHdl = link;
715 Link& ControlImpl::GetGetFocusHdl ()
717 return mGetFocusHdl;
720 void ControlImpl::SetLoseFocusHdl (Link const& link)
722 if (!mGetFocusHdl || !link)
723 UpdateListening (link);
724 mLoseFocusHdl = link;
727 Link& ControlImpl::GetLoseFocusHdl ()
729 return mLoseFocusHdl;
732 void ControlImpl::UpdateListening (Link const& link)
734 if (!link && (!!mGetFocusHdl || !!mLoseFocusHdl)
735 && (!mGetFocusHdl || !mLoseFocusHdl))
736 mxWindow->removeFocusListener (this);
737 else if (!!link && !mGetFocusHdl && !mLoseFocusHdl)
738 mxWindow->addFocusListener (this);
741 void SAL_CALL ControlImpl::disposing (lang::EventObject const& e)
742 throw (uno::RuntimeException)
744 WindowImpl::disposing (e);
747 void SAL_CALL ControlImpl::focusGained (awt::FocusEvent const&)
748 throw (uno::RuntimeException)
750 mGetFocusHdl.Call (mpWindow);
753 void SAL_CALL ControlImpl::focusLost (awt::FocusEvent const&)
754 throw (uno::RuntimeException)
756 mLoseFocusHdl.Call (mpWindow);
759 Link& Control::GetGetFocusHdl ()
761 return getImpl ().GetGetFocusHdl ();
764 void Control::SetGetFocusHdl (Link const& link)
766 if (&getImpl () && getImpl().mxWindow.is ())
767 getImpl ().SetGetFocusHdl (link);
770 Link& Control::GetLoseFocusHdl ()
772 return getImpl ().GetLoseFocusHdl ();
775 void Control::SetLoseFocusHdl (Link const& link)
777 if (&getImpl () && getImpl().mxWindow.is ())
778 getImpl ().SetLoseFocusHdl (link);
781 class DialogImpl : public WindowImpl
783 public:
784 uno::Reference< awt::XDialog2 > mxDialog;
785 DialogImpl( Context *context, PeerHandle const &peer, Window *window );
788 DialogImpl::DialogImpl( Context *context, const PeerHandle &peer, Window *window )
789 : WindowImpl( context, peer, window )
790 , mxDialog( peer, uno::UNO_QUERY )
794 Dialog::Dialog( Window *parent, const char *xml_file, const char *id, sal_uInt32 nId )
795 : Context( xml_file )
796 , Window( new DialogImpl( this, Context::GetPeerHandle( id, nId ), this ) )
797 , bConstruct (true)
799 if ( parent )
800 SetParent( parent );
803 Dialog::Dialog( ::Window *parent, const char *xml_file, const char *id, sal_uInt32 nId )
804 : Context( xml_file )
805 , Window( new DialogImpl( this, Context::GetPeerHandle( id, nId ), this ) )
807 if ( parent )
808 SetParent( parent );
811 Dialog::~Dialog ()
815 IMPL_GET_WINDOW (Dialog);
816 IMPL_GET_IMPL (Dialog);
818 #define MX_DIALOG if (getImpl ().mxDialog.is ()) getImpl ().mxDialog
819 #define RETURN_MX_DIALOG if (getImpl ().mxDialog.is ()) return getImpl ().mxDialog
821 short Dialog::Execute()
823 RETURN_MX_DIALOG->execute ();
824 return -1;
827 void Dialog::EndDialog( long result )
829 MX_DIALOG->endDialog (result);
832 void Dialog::SetText( OUString const& str )
834 SetTitle (str);
837 void Dialog::SetTitle( OUString const& str )
839 MX_DIALOG->setTitle (str);
842 bool Dialog::Close ()
844 EndDialog (false);
845 return true;
848 long Dialog::Notify (NotifyEvent& event)
850 return GetDialog ()->Notify (event);
853 void Dialog::Initialize (SfxChildWinInfo*)
857 #define MESSAGE_BOX_MEMBER_INIT\
858 Dialog (parent, xml_file, id)\
859 , imageError (this, "FI_ERROR")\
860 , imageInfo (this, "FI_INFO")\
861 , imageQuery (this, "FI_QUERY")\
862 , imageWarning (this, "FI_WARNING")\
863 , messageText (this, "FT_MESSAGE")\
864 , cancelButton (this, "BTN_CANCEL")\
865 , helpButton (this, "BTN_HELP")\
866 , ignoreButton (this, "BTN_IGNORE")\
867 , noButton (this, "BTN_NO")\
868 , retryButton (this, "BTN_RETRY")\
869 , yesButton (this, "BTN_YES")
871 MessageBox::MessageBox (::Window *parent, char const* message,
872 char const* yes, char const* no, sal_uIntPtr help_id,
873 char const* xml_file, char const* id)
874 : MESSAGE_BOX_MEMBER_INIT
876 ignoreButton.Hide ();
877 retryButton.Hide ();
878 init (message, yes, no, help_id);
881 MessageBox::MessageBox (::Window *parent, OUString const& message,
882 OUString yes, OUString no, sal_uIntPtr help_id,
883 char const* xml_file, char const* id)
884 : MESSAGE_BOX_MEMBER_INIT
886 ignoreButton.Hide ();
887 retryButton.Hide ();
888 init (message, yes, no, help_id);
891 #if !defined (__GNUC__)
892 #define __PRETTY_FUNCTION__ __FUNCTION__
893 #endif /* !__GNUC__ */
895 MessageBox::MessageBox (::Window *parent, WinBits bits, char const* message,
896 char const* yes, char const* no, sal_uIntPtr help_id,
897 char const* xml_file, char const* id)
898 : MESSAGE_BOX_MEMBER_INIT
900 // HIG suggests using verbs instead of yes/no/retry etc.
901 // This constructor provides client-code compatibility: Client code should be fixed.
902 #ifndef __SUNPRO_CC
903 OSL_TRACE ("%s: warning, deprecated vcl/Messbox compatibility", __PRETTY_FUNCTION__);
904 #endif
905 bits_init (bits, OUString::createFromAscii (message), OUString::createFromAscii (yes), OUString::createFromAscii (no), help_id);
908 MessageBox::MessageBox (::Window *parent, WinBits bits, OUString const& message,
909 OUString yes, OUString no, sal_uIntPtr help_id,
910 char const* xml_file, char const* id)
911 : MESSAGE_BOX_MEMBER_INIT
913 // HIG suggests using verbs instead of yes/no/retry etc.
914 // This constructor provides client-code compatibility: Client code should be fixed.
915 #ifndef __SUNPRO_CC
916 OSL_TRACE ("%s: warning, deprecated vcl/Messbox compatibility", __PRETTY_FUNCTION__);
917 #endif
918 bits_init (bits, message, yes, no, help_id);
921 void MessageBox::bits_init (WinBits bits, OUString const& message,
922 OUString yes, OUString no, sal_uIntPtr help_id)
924 if ( bits & ( WB_OK_CANCEL | WB_OK ))
925 yes = Button::GetStandardText ( BUTTON_OK );
926 if ( bits & (WB_YES_NO | WB_YES_NO_CANCEL ))
928 yes = Button::GetStandardText ( BUTTON_YES );
929 no = Button::GetStandardText ( BUTTON_NO );
931 if (! (bits & (WB_RETRY_CANCEL | WB_YES_NO_CANCEL | WB_ABORT_RETRY_IGNORE )))
932 cancelButton.Hide ();
933 if (! (bits & (WB_RETRY_CANCEL | WB_ABORT_RETRY_IGNORE)))
934 retryButton.Hide ();
935 if ( bits & WB_ABORT_RETRY_IGNORE )
936 cancelButton.SetText ( Button::GetStandardText (BUTTON_ABORT));
937 else
938 ignoreButton.Hide ();
939 if ( !(bits & ( WB_OK | WB_OK_CANCEL | WB_YES_NO | WB_YES_NO_CANCEL)))
940 yesButton.Hide ();
941 if ( !(bits & ( WB_YES_NO | WB_YES_NO_CANCEL)))
942 noButton.Hide ();
944 init (message, yes, no, help_id);
947 void MessageBox::init (char const* message, char const* yes, char const* no, sal_uIntPtr help_id)
949 init ( OUString::createFromAscii (message), OUString::createFromAscii (yes), OUString::createFromAscii (no), help_id);
952 void MessageBox::init (OUString const& message, OUString const& yes, OUString const& no, sal_uIntPtr help_id)
954 imageError.Hide ();
955 imageInfo.Hide ();
956 imageQuery.Hide ();
957 imageWarning.Hide ();
958 if (message.getLength ())
959 messageText.SetText (message);
960 if (yes.getLength ())
962 yesButton.SetText (yes);
963 if (yes != OUString (Button::GetStandardText (BUTTON_OK))
964 && yes != OUString (Button::GetStandardText (BUTTON_YES)))
965 SetTitle (yes);
966 if (no.getLength ())
967 noButton.SetText (no);
968 else
969 noButton.Hide ();
971 if (help_id)
972 SetHelpId (help_id);
973 else
974 helpButton.Hide ();
977 #undef MESSAGE_BOX_IMPL
978 #define MESSAGE_BOX_IMPL(Name)\
979 Name##Box::Name##Box (::Window *parent, char const* message,\
980 char const* yes, char const* no, sal_uIntPtr help_id,\
981 char const* xml_file, char const* id)\
982 : MessageBox (parent, message, yes, no, help_id, xml_file, id)\
984 image##Name.Show ();\
986 Name##Box::Name##Box (::Window *parent, OUString const& message,\
987 OUString yes, OUString no, sal_uIntPtr help_id,\
988 char const* xml_file, char const* id)\
989 : MessageBox (parent, message, yes, no, help_id, xml_file, id)\
991 image##Name.Show ();\
993 Name##Box::Name##Box (::Window *parent, WinBits bits, char const* message,\
994 char const* yes, char const* no, sal_uIntPtr help_id,\
995 char const* xml_file, char const* id)\
996 : MessageBox (parent, bits, message, yes, no, help_id, xml_file, id)\
998 image##Name.Show ();\
1000 Name##Box::Name##Box (::Window *parent, WinBits bits, OUString const& message,\
1001 OUString yes, OUString no, sal_uIntPtr help_id,\
1002 char const* xml_file, char const* id)\
1003 : MessageBox (parent, bits, message, yes, no, help_id, xml_file, id)\
1005 image##Name.Show ();\
1008 MESSAGE_BOX_IMPL (Error);
1009 MESSAGE_BOX_IMPL (Info);
1010 MESSAGE_BOX_IMPL (Query);
1011 MESSAGE_BOX_IMPL (Warning);
1013 class TabControlImpl
1014 : public ControlImpl
1015 , public ::cppu::WeakImplHelper1 <awt::XTabListener>
1017 Link mActivatePageHdl;
1018 Link mDeactivatePageHdl;
1020 public:
1021 uno::Reference <awt::XSimpleTabController> mxTabControl;
1022 TabControlImpl (Context *context, const PeerHandle &peer, Window *window)
1023 : ControlImpl (context, peer, window)
1024 , mxTabControl (peer, uno::UNO_QUERY)
1028 virtual void SAL_CALL disposing (lang::EventObject const& e)
1029 throw (uno::RuntimeException)
1031 ControlImpl::disposing (e);
1032 mxTabControl.clear ();
1035 Link& GetActivatePageHdl ()
1037 return mActivatePageHdl;
1040 void SetActivatePageHdl (Link const& link)
1042 if (!mDeactivatePageHdl || !link)
1043 UpdateListening (link);
1044 mActivatePageHdl = link;
1047 Link& GetDeactivatePageHdl ()
1049 return mDeactivatePageHdl;
1052 void SetDeactivatePageHdl (Link const& link)
1054 if (!mActivatePageHdl || !link)
1055 UpdateListening (link);
1056 mDeactivatePageHdl = link;
1059 void UpdateListening (Link const& link)
1061 if (!link && (!!mActivatePageHdl || !!mDeactivatePageHdl))
1062 mxTabControl->removeTabListener (this);
1063 else if (!!link && !mActivatePageHdl && !mDeactivatePageHdl)
1064 mxTabControl->addTabListener (this);
1067 void SAL_CALL activated (sal_Int32)
1068 throw (uno::RuntimeException)
1070 mActivatePageHdl.Call (mpWindow);
1073 void SAL_CALL deactivated (sal_Int32)
1074 throw (uno::RuntimeException)
1076 mDeactivatePageHdl.Call (mpWindow);
1079 void SAL_CALL inserted (sal_Int32)
1080 throw (uno::RuntimeException)
1084 void SAL_CALL removed (sal_Int32)
1085 throw (uno::RuntimeException)
1089 void SAL_CALL changed (sal_Int32, uno::Sequence <beans::NamedValue> const&)
1090 throw (uno::RuntimeException)
1095 IMPL_GET_WINDOW (TabControl);
1096 IMPL_GET_LAYOUT_VCLXWINDOW (TabControl);
1098 #define MX_TABCONTROL if (getImpl ().mxTabControl.is ()) getImpl ().mxTabControl
1099 #define RETURN_MX_TABCONTROL if (getImpl ().mxTabControl.is ()) return getImpl ().mxTabControl
1101 TabControl::~TabControl ()
1103 SetActivatePageHdl (Link ());
1104 SetDeactivatePageHdl (Link ());
1107 void TabControl::InsertPage (sal_uInt16 id, OUString const& title, sal_uInt16 pos)
1109 (void) pos;
1110 // GetTabControl ()->InsertPage (id, title, pos);
1111 // GetTabControl ()->SetTabPage (id, new ::TabPage (GetTabControl ()));
1113 MX_TABCONTROL->insertTab ();
1114 SetCurPageId (id);
1116 #if 1 // colour me loc productive -- NOT
1117 #define ADD_PROP( seq, i, name, val )\
1119 beans::NamedValue value; \
1120 value.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( name ) ); \
1121 value.Value = uno::makeAny( val ); \
1122 seq[i] = value; \
1125 uno::Sequence< beans::NamedValue > seq (1);
1126 ADD_PROP ( seq, 0, "Title", OUString (title) );
1127 MX_TABCONTROL->setTabProps (id, seq);
1128 #else
1129 GetTabPage (id)->SetText (title);
1130 #endif
1132 #if 0
1133 /// This so seems the right solution, but it makes the buttons of the
1134 /// tabdialog move up
1136 ::TabPage *page = GetTabPage (id);
1137 if (Window *w = dynamic_cast <Window*> (page))
1139 w->SetParent (this);
1140 //GetVCLXTabControl ()->Box_Base::addChild (uno::Reference <awt::XLayoutConstrains> (w->GetPeer (), uno::UNO_QUERY));
1141 //GetVCLXTabControl ()->Box_Base::AddChild (uno::Reference <awt::XLayoutConstrains> (w->GetPeer (), uno::UNO_QUERY));
1142 //GetVCLXTabControl ()->AddChild (w);
1143 //GetVCLXTabControl ()->AddChild (uno::Reference <awt::XLayoutConstrains> (w->GetPeer (), uno::UNO_QUERY));
1144 //uno::Reference <uno::XInterface> x (page->GetWindowPeer());
1145 //GetVCLXTabControl ()->AddChild (uno::Reference <awt::XLayoutConstrains> (page->::Window::GetWindowPeer (), uno::UNO_QUERY));
1146 //GetVCLXTabControl ()->AddChild (uno::Reference <awt::XLayoutConstrains> (page->GetComponentInterface (), uno::UNO_QUERY));
1148 getImpl ().redraw ();
1149 #endif
1151 void TabControl::RemovePage (sal_uInt16 id)
1153 GetTabControl ()->RemovePage (id);
1155 sal_uInt16 TabControl::GetPageCount () const
1157 return GetTabControl ()->GetPageCount ();
1159 sal_uInt16 TabControl::GetPageId (sal_uInt16 pos) const
1161 return GetTabControl ()->GetPageId (pos);
1163 sal_uInt16 TabControl::GetPagePos (sal_uInt16 id) const
1165 getImpl ().redraw ();
1166 return GetTabControl ()->GetPagePos (id);
1168 void TabControl::SetCurPageId (sal_uInt16 id)
1170 getImpl ().redraw ();
1171 GetTabControl ()->SetCurPageId (id);
1173 sal_uInt16 TabControl::GetCurPageId () const
1175 return GetTabControl ()->GetCurPageId ();
1177 void TabControl::SetTabPage (sal_uInt16 id, ::TabPage* page)
1179 GetTabControl ()->SetTabPage (id, page);
1181 #if 0
1182 /// This so seems the right solution, but it makes the buttons of the
1183 /// tabdialog move up
1184 if (Window *w = dynamic_cast <Window*> (page))
1186 w->SetParent (this);
1187 //GetVCLXTabControl ()->Box_Base::addChild (uno::Reference <awt::XLayoutConstrains> (w->GetPeer (), uno::UNO_QUERY));
1188 //GetVCLXTabControl ()->Box_Base::AddChild (uno::Reference <awt::XLayoutConstrains> (w->GetPeer (), uno::UNO_QUERY));
1189 //GetVCLXTabControl ()->AddChild (w);
1190 //GetVCLXTabControl ()->AddChild (uno::Reference <awt::XLayoutConstrains> (w->GetPeer (), uno::UNO_QUERY));
1191 //GetVCLXTabControl ()->AddChild (uno::Reference <awt::XLayoutConstrains> (page->GetWindowPeer (), uno::UNO_QUERY));
1192 //GetVCLXTabControl ()->AddChild (uno::Reference <awt::XLayoutConstrains> (page->GetComponentInterface (), uno::UNO_QUERY));
1194 #endif
1195 getImpl ().redraw ();
1197 ::TabPage* TabControl::GetTabPage (sal_uInt16 id) const
1199 return GetTabControl ()->GetTabPage (id);
1201 void TabControl::SetActivatePageHdl (Link const& link)
1203 if (&getImpl () && getImpl().mxTabControl.is ())
1204 getImpl ().SetActivatePageHdl (link);
1206 Link& TabControl::GetActivatePageHdl () const
1208 return getImpl ().GetActivatePageHdl ();
1210 void TabControl::SetDeactivatePageHdl (Link const& link)
1212 if (&getImpl () && getImpl().mxTabControl.is ())
1213 getImpl ().SetDeactivatePageHdl (link);
1215 Link& TabControl::GetDeactivatePageHdl () const
1217 return getImpl ().GetDeactivatePageHdl ();
1219 void TabControl::SetTabPageSizePixel (Size const& size)
1221 GetTabControl ()->SetTabPageSizePixel (size);
1222 // GetParent()->SetSizePixel (size);
1223 // GetWindow()->SetSizePixel (size);
1224 //GetVCLXTabControl->SetTabSize (size);
1226 Size TabControl::GetTabPageSizePixel () const
1228 #if 0
1229 //return GetTabControl ()->GetTabPageSizePixel ();
1230 static size_t const tab_page_first_index = 1;
1231 for (size_t i = 0; i < GetPageCount (); i++)
1233 ::TabPage *p = GetTabPage (i + tab_page_first_index);
1234 //if (dynamic_cast<Windowt*> (p))
1235 if (i) // URG
1236 return p->GetOptimalSize (WINDOWSIZE_MINIMUM);
1238 #endif
1239 return GetTabControl ()->GetTabPageSizePixel ();
1242 IMPL_CONSTRUCTORS (TabControl, Control, "tabcontrol");
1243 IMPL_GET_IMPL (TabControl);
1245 class TabPageImpl : public WindowImpl
1247 public:
1248 uno::Reference< awt::XWindow > mxTabPage;
1249 TabPageImpl( Context *context, const PeerHandle &peer, Window *window )
1250 : WindowImpl( context, peer, window )
1251 , mxTabPage( peer, uno::UNO_QUERY )
1256 ::Window* TabPage::global_parent = 0;
1257 TabControl* TabPage::global_tabcontrol = 0;
1259 IMPL_GET_IMPL( TabPage );
1261 TabPage::TabPage( Window *parent, const char *xml_file, const char *id, sal_uInt32 nId)
1262 : Context( xml_file )
1263 , Window( new TabPageImpl( this, Context::GetPeerHandle( id, nId ), this ) )
1265 if ( parent )
1266 SetParent( parent );
1269 TabPage::TabPage( ::Window *parent, const char *xml_file, const char *id, sal_uInt32 nId)
1270 : Context( xml_file )
1271 , Window( new TabPageImpl( this, Context::GetPeerHandle( id, nId ), this ) )
1273 if ( parent )
1274 SetParent( parent );
1277 TabPage::~TabPage()
1279 delete GetTabPage();
1282 IMPL_GET_WINDOW( TabPage );
1284 void TabPage::ActivatePage()
1288 void TabPage::DeactivatePage()
1292 class FixedLineImpl : public ControlImpl
1294 public:
1295 FixedLineImpl( Context *context, const PeerHandle &peer, Window *window )
1296 : ControlImpl( context, peer, window )
1301 IMPL_CONSTRUCTORS( FixedLine, Control, "hfixedline" );
1302 IMPL_GET_IMPL( FixedLine );
1304 bool FixedLine::IsEnabled() const
1306 //FIXME
1307 return true;
1310 class FixedTextImpl : public ControlImpl
1312 public:
1313 uno::Reference< awt::XFixedText > mxFixedText;
1314 FixedTextImpl( Context *context, const PeerHandle &peer, Window *window )
1315 : ControlImpl( context, peer, window )
1316 , mxFixedText( peer, uno::UNO_QUERY )
1320 ~FixedTextImpl ();
1322 virtual void SAL_CALL disposing( lang::EventObject const& e )
1323 throw (uno::RuntimeException);
1326 FixedTextImpl::~FixedTextImpl ()
1330 void SAL_CALL FixedTextImpl::disposing( lang::EventObject const& e )
1331 throw (uno::RuntimeException)
1333 ControlImpl::disposing (e);
1334 mxFixedText.clear ();
1337 FixedText::~FixedText ()
1341 IMPL_CONSTRUCTORS( FixedText, Control, "fixedtext" );
1342 IMPL_GET_IMPL( FixedText );
1344 void FixedText::SetText( OUString const& rStr )
1346 if ( !getImpl().mxFixedText.is() )
1347 return;
1348 getImpl().mxFixedText->setText( rStr );
1351 class FixedInfoImpl : public FixedTextImpl
1353 public:
1354 FixedInfoImpl( Context *context, const PeerHandle &peer, Window *window )
1355 : FixedTextImpl( context, peer, window )
1360 IMPL_CONSTRUCTORS( FixedInfo, FixedText, "fixedinfo" );
1361 IMPL_GET_IMPL( FixedInfo );
1363 class ProgressBarImpl : public ControlImpl
1365 public:
1366 uno::Reference< awt::XProgressBar > mxProgressBar;
1367 ProgressBarImpl( Context *context, const PeerHandle &peer, Window *window )
1368 : ControlImpl( context, peer, window )
1369 , mxProgressBar( peer, uno::UNO_QUERY )
1373 virtual void SAL_CALL disposing( lang::EventObject const& e )
1374 throw (uno::RuntimeException)
1376 ControlImpl::disposing (e);
1377 mxProgressBar.clear ();
1382 class FixedImageImpl: public ControlImpl
1384 public:
1385 uno::Reference< graphic::XGraphic > mxGraphic;
1386 FixedImageImpl( Context *context, const PeerHandle &peer, Window *window)
1387 // const char *pName )
1388 : ControlImpl( context, peer, window )
1389 //, mxGraphic( layoutimpl::loadGraphic( pName ) )
1390 , mxGraphic( peer, uno::UNO_QUERY )
1392 if ( !mxGraphic.is() )
1394 DBG_ERROR( "ERROR: failed to load image: `%s'" /*, pName*/ );
1396 #if 0
1397 else
1398 getImpl().mxGraphic->...();
1399 #endif
1403 IMPL_CONSTRUCTORS( FixedImage, Control, "fixedimage" );
1404 IMPL_GET_IMPL( FixedImage )
1406 void FixedImage::setImage( ::Image const& i )
1408 (void) i;
1409 if ( !getImpl().mxGraphic.is() )
1410 return;
1411 //FIXME: hack moved to proplist
1412 //getImpl().mxGraphic =
1415 #if 0
1417 FixedImage::FixedImage( const char *pName )
1418 : pImpl( new FixedImageImpl( pName ) )
1422 FixedImage::~FixedImage()
1424 delete pImpl;
1427 #endif
1430 IMPL_CONSTRUCTORS( ProgressBar, Control, "ProgressBar" );
1431 IMPL_GET_IMPL( ProgressBar );
1433 void ProgressBar::SetForegroundColor( util::Color color )
1435 if ( !getImpl().mxProgressBar.is() )
1436 return;
1437 getImpl().mxProgressBar->setForegroundColor( color );
1440 void ProgressBar::SetBackgroundColor( util::Color color )
1442 if ( !getImpl().mxProgressBar.is() )
1443 return;
1444 getImpl().mxProgressBar->setBackgroundColor( color );
1447 void ProgressBar::SetValue( sal_Int32 i )
1449 if ( !getImpl().mxProgressBar.is() )
1450 return;
1451 getImpl().mxProgressBar->setValue( i );
1454 void ProgressBar::SetRange( sal_Int32 min, sal_Int32 max )
1456 if ( !getImpl().mxProgressBar.is() )
1457 return;
1458 getImpl().mxProgressBar->setRange( min, max );
1461 sal_Int32 ProgressBar::GetValue()
1463 if ( !getImpl().mxProgressBar.is() )
1464 return 0;
1465 return getImpl().mxProgressBar->getValue();
1468 class PluginImpl: public ControlImpl
1470 public:
1471 ::Control *mpPlugin;
1473 PluginImpl( Context *context, const PeerHandle &peer, Window *window, :: Control *plugin )
1474 : ControlImpl( context, peer, window )
1475 , mpPlugin( plugin )
1477 uno::Reference <awt::XWindow> ref( mxWindow, uno::UNO_QUERY );
1478 layoutimpl::VCLXPlugin *vcl
1479 = static_cast<layoutimpl::VCLXPlugin*>( VCLXWindow::GetImplementation( ref ) );
1480 ::Window *parent = vcl->mpWindow->GetParent();
1481 vcl->SetWindow( plugin );
1482 vcl->SetPlugin( mpPlugin );
1483 plugin->SetParent( parent );
1484 plugin->SetStyle( vcl->mStyle );
1485 plugin->SetCreatedWithToolkit( true );
1486 plugin->SetComponentInterface( vcl );
1487 plugin->Show();
1491 Plugin::Plugin( Context *context, char const *id, ::Control *plugin )
1492 : Control( new PluginImpl( context, context->GetPeerHandle( id, 0 ), this, plugin ) )
1493 , mpPlugin( plugin )
1497 IMPL_GET_IMPL( Plugin );
1499 class LocalizedStringImpl : public WindowImpl
1501 public:
1502 layoutimpl::LocalizedString *mpString;
1503 OUString maString;
1504 LocalizedStringImpl( Context *context, const PeerHandle &peer, Window *window )
1505 : WindowImpl( context, peer, window )
1506 , mpString( static_cast<layoutimpl::LocalizedString*>( VCLXWindow::GetImplementation( uno::Reference <awt::XWindow> ( mxWindow, uno::UNO_QUERY ) ) ) )
1507 , maString ()
1510 OUString getText()
1512 if (mpString)
1513 maString = mpString->getText ();
1514 return maString;
1516 void setText( OUString const& s )
1518 if (mpString)
1519 mpString->setText( s );
1523 IMPL_GET_IMPL( LocalizedString );
1525 LocalizedString::LocalizedString( Context *context, char const* id )
1526 : Window( new LocalizedStringImpl( context, context->GetPeerHandle( id, 0 ), this ) )
1530 String LocalizedString::getString ()
1532 return getImpl ().getText ();
1535 OUString LocalizedString::getOUString ()
1537 return getImpl ().getText ();
1540 LocalizedString::operator OUString ()
1542 return getOUString ();
1545 LocalizedString::operator OUString const& ()
1547 getOUString ();
1548 return getImpl ().maString;
1551 LocalizedString::operator String()
1553 getOUString ();
1554 return getImpl ().maString;
1557 String LocalizedString::GetToken (USHORT i, sal_Char c)
1559 return getString ().GetToken (i, c);
1562 OUString LocalizedString::operator= (OUString const& s)
1564 getImpl().setText( s );
1565 return getImpl().getText();
1568 OUString LocalizedString::operator+= (OUString const& b)
1570 OUString a = getImpl ().getText ();
1571 a += b;
1572 getImpl ().setText (a);
1573 return getImpl ().getText ();
1576 OUString LocalizedString::operator+= (sal_Unicode const b)
1578 String a = getImpl ().getText ();
1579 a += b;
1580 getImpl ().setText (a);
1581 return getImpl ().getText ();
1584 class InPlugImpl : public WindowImpl
1586 public:
1587 InPlugImpl (Context *context, const PeerHandle &peer, Window *window)
1588 : WindowImpl (context, peer, window)
1593 IMPL_GET_IMPL (InPlug);
1595 static char const *FIXME_set_parent (::Window *parent, char const *xml_file)
1597 layout::TabPage::global_parent = parent;
1598 return xml_file;
1601 InPlug::InPlug (Window *parent, char const* xml_file, char const* id, sal_uInt32 nId)
1602 : Context (FIXME_set_parent (parent ? parent->GetWindow () : 0, xml_file))
1603 , layout::Window (new InPlugImpl (this, Context::GetPeerHandle (id, nId), this))
1605 if (parent)
1606 SetParent (parent);
1607 if (::Window *w = dynamic_cast< ::Window* > (this))
1608 w->SetComponentInterface (GetVCLXWindow ());
1611 InPlug::InPlug (::Window *parent, char const* xml_file, char const* id, sal_uInt32 nId)
1612 : Context (FIXME_set_parent (parent, xml_file))
1613 , layout::Window (new InPlugImpl (this, Context::GetPeerHandle (id, nId), this))
1615 if (parent)
1616 layout::Window::SetParent (parent);
1617 if (::Window *w = dynamic_cast< ::Window* > (this))
1618 w->SetComponentInterface (GetVCLXWindow ());
1621 void InPlug::ParentSet (Window *window)
1623 window->SetParent (dynamic_cast< ::Window* > (this));
1625 /// FIXME: for standalone run of layout::SfxTabDialog
1626 SetParent (window->GetParent ());
1629 } // namespace layout