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