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