1*0b4ced1dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*0b4ced1dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*0b4ced1dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*0b4ced1dSAndrew Rist * distributed with this work for additional information 6*0b4ced1dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*0b4ced1dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*0b4ced1dSAndrew Rist * "License"); you may not use this file except in compliance 9*0b4ced1dSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*0b4ced1dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*0b4ced1dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*0b4ced1dSAndrew Rist * software distributed under the License is distributed on an 15*0b4ced1dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*0b4ced1dSAndrew Rist * KIND, either express or implied. See the License for the 17*0b4ced1dSAndrew Rist * specific language governing permissions and limitations 18*0b4ced1dSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*0b4ced1dSAndrew Rist *************************************************************/ 21*0b4ced1dSAndrew Rist 22*0b4ced1dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir //____________________________________________________________________________________________________________ 25cdf0e10cSrcweir // my own includes 26cdf0e10cSrcweir //____________________________________________________________________________________________________________ 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include "statusindicator.hxx" 29cdf0e10cSrcweir 30cdf0e10cSrcweir //____________________________________________________________________________________________________________ 31cdf0e10cSrcweir // includes of other projects 32cdf0e10cSrcweir //____________________________________________________________________________________________________________ 33cdf0e10cSrcweir #include <com/sun/star/awt/InvalidateStyle.hpp> 34cdf0e10cSrcweir #include <com/sun/star/awt/WindowAttribute.hpp> 35cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 36cdf0e10cSrcweir #include <tools/debug.hxx> 37cdf0e10cSrcweir 38cdf0e10cSrcweir //____________________________________________________________________________________________________________ 39cdf0e10cSrcweir // includes of my project 40cdf0e10cSrcweir //____________________________________________________________________________________________________________ 41cdf0e10cSrcweir #include "progressbar.hxx" 42cdf0e10cSrcweir 43cdf0e10cSrcweir //____________________________________________________________________________________________________________ 44cdf0e10cSrcweir // namespace 45cdf0e10cSrcweir //____________________________________________________________________________________________________________ 46cdf0e10cSrcweir 47cdf0e10cSrcweir using namespace ::cppu ; 48cdf0e10cSrcweir using namespace ::osl ; 49cdf0e10cSrcweir using namespace ::rtl ; 50cdf0e10cSrcweir using namespace ::com::sun::star::uno ; 51cdf0e10cSrcweir using namespace ::com::sun::star::lang ; 52cdf0e10cSrcweir using namespace ::com::sun::star::awt ; 53cdf0e10cSrcweir using namespace ::com::sun::star::task ; 54cdf0e10cSrcweir 55cdf0e10cSrcweir namespace unocontrols{ 56cdf0e10cSrcweir 57cdf0e10cSrcweir //____________________________________________________________________________________________________________ 58cdf0e10cSrcweir // construct/destruct 59cdf0e10cSrcweir //____________________________________________________________________________________________________________ 60cdf0e10cSrcweir 61cdf0e10cSrcweir StatusIndicator::StatusIndicator( const Reference< XMultiServiceFactory >& xFactory ) 62cdf0e10cSrcweir : BaseContainerControl ( xFactory ) 63cdf0e10cSrcweir { 64cdf0e10cSrcweir // Its not allowed to work with member in this method (refcounter !!!) 65cdf0e10cSrcweir // But with a HACK (++refcount) its "OK" :-( 66cdf0e10cSrcweir ++m_refCount ; 67cdf0e10cSrcweir 68cdf0e10cSrcweir // Create instances for fixedtext and progress ... 69cdf0e10cSrcweir m_xText = Reference< XFixedText > ( xFactory->createInstance( OUString::createFromAscii( FIXEDTEXT_SERVICENAME ) ), UNO_QUERY ); 70cdf0e10cSrcweir m_xProgressBar = Reference< XProgressBar > ( xFactory->createInstance( OUString::createFromAscii( SERVICENAME_PROGRESSBAR ) ), UNO_QUERY ); 71cdf0e10cSrcweir // ... cast controls to Reference< XControl > and set model ... 72cdf0e10cSrcweir // ( ProgressBar has no model !!! ) 73cdf0e10cSrcweir Reference< XControl > xTextControl ( m_xText , UNO_QUERY ); 74cdf0e10cSrcweir Reference< XControl > xProgressControl ( m_xProgressBar, UNO_QUERY ); 75cdf0e10cSrcweir xTextControl->setModel( Reference< XControlModel >( xFactory->createInstance( OUString::createFromAscii( FIXEDTEXT_MODELNAME ) ), UNO_QUERY ) ); 76cdf0e10cSrcweir // ... and add controls to basecontainercontrol! 77cdf0e10cSrcweir addControl( OUString::createFromAscii( CONTROLNAME_TEXT ), xTextControl ); 78cdf0e10cSrcweir addControl( OUString::createFromAscii( CONTROLNAME_PROGRESSBAR ), xProgressControl ); 79cdf0e10cSrcweir // FixedText make it automaticly visible by himself ... but not the progressbar !!! 80cdf0e10cSrcweir // it must be set explicitly 81cdf0e10cSrcweir Reference< XWindow > xProgressWindow( m_xProgressBar, UNO_QUERY ); 82cdf0e10cSrcweir xProgressWindow->setVisible( sal_True ); 83cdf0e10cSrcweir // Reset to defaults !!! 84cdf0e10cSrcweir // (progressbar take automaticly its own defaults) 85cdf0e10cSrcweir m_xText->setText( OUString::createFromAscii( DEFAULT_TEXT ) ); 86cdf0e10cSrcweir 87cdf0e10cSrcweir --m_refCount ; 88cdf0e10cSrcweir } 89cdf0e10cSrcweir 90cdf0e10cSrcweir StatusIndicator::~StatusIndicator() 91cdf0e10cSrcweir { 92cdf0e10cSrcweir // Release all references 93cdf0e10cSrcweir m_xText = Reference< XFixedText >(); 94cdf0e10cSrcweir m_xProgressBar = Reference< XProgressBar >(); 95cdf0e10cSrcweir } 96cdf0e10cSrcweir 97cdf0e10cSrcweir //____________________________________________________________________________________________________________ 98cdf0e10cSrcweir // XInterface 99cdf0e10cSrcweir //____________________________________________________________________________________________________________ 100cdf0e10cSrcweir 101cdf0e10cSrcweir Any SAL_CALL StatusIndicator::queryInterface( const Type& rType ) throw( RuntimeException ) 102cdf0e10cSrcweir { 103cdf0e10cSrcweir // Attention: 104cdf0e10cSrcweir // Don't use mutex or guard in this method!!! Is a method of XInterface. 105cdf0e10cSrcweir Any aReturn ; 106cdf0e10cSrcweir Reference< XInterface > xDel = BaseContainerControl::impl_getDelegator(); 107cdf0e10cSrcweir if ( xDel.is() ) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir // If an delegator exist, forward question to his queryInterface. 110cdf0e10cSrcweir // Delegator will ask his own queryAggregation! 111cdf0e10cSrcweir aReturn = xDel->queryInterface( rType ); 112cdf0e10cSrcweir } 113cdf0e10cSrcweir else 114cdf0e10cSrcweir { 115cdf0e10cSrcweir // If an delegator unknown, forward question to own queryAggregation. 116cdf0e10cSrcweir aReturn = queryAggregation( rType ); 117cdf0e10cSrcweir } 118cdf0e10cSrcweir 119cdf0e10cSrcweir return aReturn ; 120cdf0e10cSrcweir } 121cdf0e10cSrcweir 122cdf0e10cSrcweir //____________________________________________________________________________________________________________ 123cdf0e10cSrcweir // XInterface 124cdf0e10cSrcweir //____________________________________________________________________________________________________________ 125cdf0e10cSrcweir 126cdf0e10cSrcweir void SAL_CALL StatusIndicator::acquire() throw() 127cdf0e10cSrcweir { 128cdf0e10cSrcweir // Attention: 129cdf0e10cSrcweir // Don't use mutex or guard in this method!!! Is a method of XInterface. 130cdf0e10cSrcweir 131cdf0e10cSrcweir // Forward to baseclass 132cdf0e10cSrcweir BaseControl::acquire(); 133cdf0e10cSrcweir } 134cdf0e10cSrcweir 135cdf0e10cSrcweir //____________________________________________________________________________________________________________ 136cdf0e10cSrcweir // XInterface 137cdf0e10cSrcweir //____________________________________________________________________________________________________________ 138cdf0e10cSrcweir 139cdf0e10cSrcweir void SAL_CALL StatusIndicator::release() throw() 140cdf0e10cSrcweir { 141cdf0e10cSrcweir // Attention: 142cdf0e10cSrcweir // Don't use mutex or guard in this method!!! Is a method of XInterface. 143cdf0e10cSrcweir 144cdf0e10cSrcweir // Forward to baseclass 145cdf0e10cSrcweir BaseControl::release(); 146cdf0e10cSrcweir } 147cdf0e10cSrcweir 148cdf0e10cSrcweir //____________________________________________________________________________________________________________ 149cdf0e10cSrcweir // XTypeProvider 150cdf0e10cSrcweir //____________________________________________________________________________________________________________ 151cdf0e10cSrcweir 152cdf0e10cSrcweir Sequence< Type > SAL_CALL StatusIndicator::getTypes() throw( RuntimeException ) 153cdf0e10cSrcweir { 154cdf0e10cSrcweir // Optimize this method ! 155cdf0e10cSrcweir // We initialize a static variable only one time. And we don't must use a mutex at every call! 156cdf0e10cSrcweir // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL! 157cdf0e10cSrcweir static OTypeCollection* pTypeCollection = NULL ; 158cdf0e10cSrcweir 159cdf0e10cSrcweir if ( pTypeCollection == NULL ) 160cdf0e10cSrcweir { 161cdf0e10cSrcweir // Ready for multithreading; get global mutex for first call of this method only! see before 162cdf0e10cSrcweir MutexGuard aGuard( Mutex::getGlobalMutex() ); 163cdf0e10cSrcweir 164cdf0e10cSrcweir // Control these pointer again ... it can be, that another instance will be faster then these! 165cdf0e10cSrcweir if ( pTypeCollection == NULL ) 166cdf0e10cSrcweir { 167cdf0e10cSrcweir // Create a static typecollection ... 168cdf0e10cSrcweir static OTypeCollection aTypeCollection ( ::getCppuType(( const Reference< XLayoutConstrains >*)NULL ) , 169cdf0e10cSrcweir ::getCppuType(( const Reference< XStatusIndicator >*)NULL ) , 170cdf0e10cSrcweir BaseContainerControl::getTypes() 171cdf0e10cSrcweir ); 172cdf0e10cSrcweir // ... and set his address to static pointer! 173cdf0e10cSrcweir pTypeCollection = &aTypeCollection ; 174cdf0e10cSrcweir } 175cdf0e10cSrcweir } 176cdf0e10cSrcweir 177cdf0e10cSrcweir return pTypeCollection->getTypes(); 178cdf0e10cSrcweir } 179cdf0e10cSrcweir 180cdf0e10cSrcweir //____________________________________________________________________________________________________________ 181cdf0e10cSrcweir // XAggregation 182cdf0e10cSrcweir //____________________________________________________________________________________________________________ 183cdf0e10cSrcweir 184cdf0e10cSrcweir Any SAL_CALL StatusIndicator::queryAggregation( const Type& aType ) throw( RuntimeException ) 185cdf0e10cSrcweir { 186cdf0e10cSrcweir // Ask for my own supported interfaces ... 187cdf0e10cSrcweir // Attention: XTypeProvider and XInterface are supported by OComponentHelper! 188cdf0e10cSrcweir Any aReturn ( ::cppu::queryInterface( aType , 189cdf0e10cSrcweir static_cast< XLayoutConstrains* > ( this ) , 190cdf0e10cSrcweir static_cast< XStatusIndicator* > ( this ) 191cdf0e10cSrcweir ) 192cdf0e10cSrcweir ); 193cdf0e10cSrcweir 194cdf0e10cSrcweir // If searched interface not supported by this class ... 195cdf0e10cSrcweir if ( aReturn.hasValue() == sal_False ) 196cdf0e10cSrcweir { 197cdf0e10cSrcweir // ... ask baseclasses. 198cdf0e10cSrcweir aReturn = BaseControl::queryAggregation( aType ); 199cdf0e10cSrcweir } 200cdf0e10cSrcweir 201cdf0e10cSrcweir return aReturn ; 202cdf0e10cSrcweir } 203cdf0e10cSrcweir 204cdf0e10cSrcweir //____________________________________________________________________________________________________________ 205cdf0e10cSrcweir // XStatusIndicator 206cdf0e10cSrcweir //____________________________________________________________________________________________________________ 207cdf0e10cSrcweir 208cdf0e10cSrcweir void SAL_CALL StatusIndicator::start( const OUString& sText, sal_Int32 nRange ) throw( RuntimeException ) 209cdf0e10cSrcweir { 210cdf0e10cSrcweir // Ready for multithreading 211cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 212cdf0e10cSrcweir 213cdf0e10cSrcweir // Initialize status controls with given values. 214cdf0e10cSrcweir m_xText->setText( sText ); 215cdf0e10cSrcweir m_xProgressBar->setRange( 0, nRange ); 216cdf0e10cSrcweir // force repaint ... fixedtext has changed ! 217cdf0e10cSrcweir impl_recalcLayout ( WindowEvent(static_cast< OWeakObject* >(this),0,0,impl_getWidth(),impl_getHeight(),0,0,0,0) ) ; 218cdf0e10cSrcweir } 219cdf0e10cSrcweir 220cdf0e10cSrcweir //____________________________________________________________________________________________________________ 221cdf0e10cSrcweir // XStatusIndicator 222cdf0e10cSrcweir //____________________________________________________________________________________________________________ 223cdf0e10cSrcweir 224cdf0e10cSrcweir void SAL_CALL StatusIndicator::end() throw( RuntimeException ) 225cdf0e10cSrcweir { 226cdf0e10cSrcweir // Ready for multithreading 227cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 228cdf0e10cSrcweir 229cdf0e10cSrcweir // Clear values of status controls. 230cdf0e10cSrcweir m_xText->setText( OUString() ); 231cdf0e10cSrcweir m_xProgressBar->setValue( 0 ); 232cdf0e10cSrcweir setVisible( sal_False ); 233cdf0e10cSrcweir } 234cdf0e10cSrcweir 235cdf0e10cSrcweir //____________________________________________________________________________________________________________ 236cdf0e10cSrcweir // XStatusIndicator 237cdf0e10cSrcweir //____________________________________________________________________________________________________________ 238cdf0e10cSrcweir 239cdf0e10cSrcweir void SAL_CALL StatusIndicator::setText( const OUString& sText ) throw( RuntimeException ) 240cdf0e10cSrcweir { 241cdf0e10cSrcweir // Ready for multithreading 242cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 243cdf0e10cSrcweir 244cdf0e10cSrcweir // Take text on right control 245cdf0e10cSrcweir m_xText->setText( sText ); 246cdf0e10cSrcweir } 247cdf0e10cSrcweir 248cdf0e10cSrcweir //____________________________________________________________________________________________________________ 249cdf0e10cSrcweir // XStatusIndicator 250cdf0e10cSrcweir //____________________________________________________________________________________________________________ 251cdf0e10cSrcweir 252cdf0e10cSrcweir void SAL_CALL StatusIndicator::setValue( sal_Int32 nValue ) throw( RuntimeException ) 253cdf0e10cSrcweir { 254cdf0e10cSrcweir // Ready for multithreading 255cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 256cdf0e10cSrcweir 257cdf0e10cSrcweir // Take value on right control 258cdf0e10cSrcweir m_xProgressBar->setValue( nValue ); 259cdf0e10cSrcweir } 260cdf0e10cSrcweir 261cdf0e10cSrcweir //____________________________________________________________________________________________________________ 262cdf0e10cSrcweir // XStatusIndicator 263cdf0e10cSrcweir //____________________________________________________________________________________________________________ 264cdf0e10cSrcweir 265cdf0e10cSrcweir void SAL_CALL StatusIndicator::reset() throw( RuntimeException ) 266cdf0e10cSrcweir { 267cdf0e10cSrcweir // Ready for multithreading 268cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 269cdf0e10cSrcweir 270cdf0e10cSrcweir // Clear values of status controls. 271cdf0e10cSrcweir // (Don't hide the window! User will reset current values ... but he will not finish using of indicator!) 272cdf0e10cSrcweir m_xText->setText( OUString() ); 273cdf0e10cSrcweir m_xProgressBar->setValue( 0 ); 274cdf0e10cSrcweir } 275cdf0e10cSrcweir 276cdf0e10cSrcweir //____________________________________________________________________________________________________________ 277cdf0e10cSrcweir // XLayoutConstrains 278cdf0e10cSrcweir //____________________________________________________________________________________________________________ 279cdf0e10cSrcweir 280cdf0e10cSrcweir Size SAL_CALL StatusIndicator::getMinimumSize () throw( RuntimeException ) 281cdf0e10cSrcweir { 282cdf0e10cSrcweir return Size (DEFAULT_WIDTH, DEFAULT_HEIGHT) ; 283cdf0e10cSrcweir } 284cdf0e10cSrcweir 285cdf0e10cSrcweir //____________________________________________________________________________________________________________ 286cdf0e10cSrcweir // XLayoutConstrains 287cdf0e10cSrcweir //____________________________________________________________________________________________________________ 288cdf0e10cSrcweir 289cdf0e10cSrcweir Size SAL_CALL StatusIndicator::getPreferredSize () throw( RuntimeException ) 290cdf0e10cSrcweir { 291cdf0e10cSrcweir // Ready for multithreading 292cdf0e10cSrcweir ClearableMutexGuard aGuard ( m_aMutex ) ; 293cdf0e10cSrcweir 294cdf0e10cSrcweir // get information about required place of child controls 295cdf0e10cSrcweir Reference< XLayoutConstrains > xTextLayout ( m_xText, UNO_QUERY ); 296cdf0e10cSrcweir Size aTextSize = xTextLayout->getPreferredSize(); 297cdf0e10cSrcweir 298cdf0e10cSrcweir aGuard.clear () ; 299cdf0e10cSrcweir 300cdf0e10cSrcweir // calc preferred size of status indicator 301cdf0e10cSrcweir sal_Int32 nWidth = impl_getWidth() ; 302cdf0e10cSrcweir sal_Int32 nHeight = (2*FREEBORDER)+aTextSize.Height ; 303cdf0e10cSrcweir 304cdf0e10cSrcweir // norm to minimum 305cdf0e10cSrcweir if ( nWidth<DEFAULT_WIDTH ) 306cdf0e10cSrcweir { 307cdf0e10cSrcweir nWidth = DEFAULT_WIDTH ; 308cdf0e10cSrcweir } 309cdf0e10cSrcweir if ( nHeight<DEFAULT_HEIGHT ) 310cdf0e10cSrcweir { 311cdf0e10cSrcweir nHeight = DEFAULT_HEIGHT ; 312cdf0e10cSrcweir } 313cdf0e10cSrcweir 314cdf0e10cSrcweir // return to caller 315cdf0e10cSrcweir return Size ( nWidth, nHeight ) ; 316cdf0e10cSrcweir } 317cdf0e10cSrcweir 318cdf0e10cSrcweir //____________________________________________________________________________________________________________ 319cdf0e10cSrcweir // XLayoutConstrains 320cdf0e10cSrcweir //____________________________________________________________________________________________________________ 321cdf0e10cSrcweir 322cdf0e10cSrcweir Size SAL_CALL StatusIndicator::calcAdjustedSize ( const Size& /*rNewSize*/ ) throw( RuntimeException ) 323cdf0e10cSrcweir { 324cdf0e10cSrcweir return getPreferredSize () ; 325cdf0e10cSrcweir } 326cdf0e10cSrcweir 327cdf0e10cSrcweir //____________________________________________________________________________________________________________ 328cdf0e10cSrcweir // XControl 329cdf0e10cSrcweir //____________________________________________________________________________________________________________ 330cdf0e10cSrcweir 331cdf0e10cSrcweir void SAL_CALL StatusIndicator::createPeer ( const Reference< XToolkit > & rToolkit, const Reference< XWindowPeer > & rParent ) throw( RuntimeException ) 332cdf0e10cSrcweir { 333cdf0e10cSrcweir if( getPeer().is() == sal_False ) 334cdf0e10cSrcweir { 335cdf0e10cSrcweir BaseContainerControl::createPeer( rToolkit, rParent ); 336cdf0e10cSrcweir 337cdf0e10cSrcweir // If user forget to call "setPosSize()", we have still a correct size. 338cdf0e10cSrcweir // And a "MinimumSize" IS A "MinimumSize"! 339cdf0e10cSrcweir // We change not the position of control at this point. 340cdf0e10cSrcweir Size aDefaultSize = getMinimumSize () ; 341cdf0e10cSrcweir setPosSize ( 0, 0, aDefaultSize.Width, aDefaultSize.Height, PosSize::SIZE ) ; 342cdf0e10cSrcweir } 343cdf0e10cSrcweir } 344cdf0e10cSrcweir 345cdf0e10cSrcweir //____________________________________________________________________________________________________________ 346cdf0e10cSrcweir // XControl 347cdf0e10cSrcweir //____________________________________________________________________________________________________________ 348cdf0e10cSrcweir 349cdf0e10cSrcweir sal_Bool SAL_CALL StatusIndicator::setModel ( const Reference< XControlModel > & /*rModel*/ ) throw( RuntimeException ) 350cdf0e10cSrcweir { 351cdf0e10cSrcweir // We have no model. 352cdf0e10cSrcweir return sal_False ; 353cdf0e10cSrcweir } 354cdf0e10cSrcweir 355cdf0e10cSrcweir //____________________________________________________________________________________________________________ 356cdf0e10cSrcweir // XControl 357cdf0e10cSrcweir //____________________________________________________________________________________________________________ 358cdf0e10cSrcweir 359cdf0e10cSrcweir Reference< XControlModel > SAL_CALL StatusIndicator::getModel () throw( RuntimeException ) 360cdf0e10cSrcweir { 361cdf0e10cSrcweir // We have no model. 362cdf0e10cSrcweir // return (XControlModel*)this ; 363cdf0e10cSrcweir return Reference< XControlModel > () ; 364cdf0e10cSrcweir } 365cdf0e10cSrcweir 366cdf0e10cSrcweir //____________________________________________________________________________________________________________ 367cdf0e10cSrcweir // XComponent 368cdf0e10cSrcweir //____________________________________________________________________________________________________________ 369cdf0e10cSrcweir 370cdf0e10cSrcweir void SAL_CALL StatusIndicator::dispose () throw( RuntimeException ) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir // Ready for multithreading 373cdf0e10cSrcweir MutexGuard aGuard ( m_aMutex ) ; 374cdf0e10cSrcweir 375cdf0e10cSrcweir // "removeControl()" control the state of a reference 376cdf0e10cSrcweir Reference< XControl > xTextControl ( m_xText , UNO_QUERY ); 377cdf0e10cSrcweir Reference< XControl > xProgressControl ( m_xProgressBar, UNO_QUERY ); 378cdf0e10cSrcweir 379cdf0e10cSrcweir removeControl( xTextControl ); 380cdf0e10cSrcweir removeControl( xProgressControl ); 381cdf0e10cSrcweir 382cdf0e10cSrcweir // do'nt use "...->clear ()" or "... = XFixedText ()" 383cdf0e10cSrcweir // when other hold a reference at this object !!! 384cdf0e10cSrcweir xTextControl->dispose(); 385cdf0e10cSrcweir xProgressControl->dispose(); 386cdf0e10cSrcweir BaseContainerControl::dispose(); 387cdf0e10cSrcweir } 388cdf0e10cSrcweir 389cdf0e10cSrcweir //____________________________________________________________________________________________________________ 390cdf0e10cSrcweir // XWindow 391cdf0e10cSrcweir //____________________________________________________________________________________________________________ 392cdf0e10cSrcweir 393cdf0e10cSrcweir void SAL_CALL StatusIndicator::setPosSize ( sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nFlags ) throw( RuntimeException ) 394cdf0e10cSrcweir { 395cdf0e10cSrcweir Rectangle aBasePosSize = getPosSize () ; 396cdf0e10cSrcweir BaseContainerControl::setPosSize (nX, nY, nWidth, nHeight, nFlags) ; 397cdf0e10cSrcweir 398cdf0e10cSrcweir // if position or size changed 399cdf0e10cSrcweir if ( 400cdf0e10cSrcweir ( nWidth != aBasePosSize.Width ) || 401cdf0e10cSrcweir ( nHeight != aBasePosSize.Height) 402cdf0e10cSrcweir ) 403cdf0e10cSrcweir { 404cdf0e10cSrcweir // calc new layout for controls 405cdf0e10cSrcweir impl_recalcLayout ( WindowEvent(static_cast< OWeakObject* >(this),0,0,nWidth,nHeight,0,0,0,0) ) ; 406cdf0e10cSrcweir // clear background (!) 407cdf0e10cSrcweir // [Childs was repainted in "recalcLayout" by setPosSize() automaticly!] 408cdf0e10cSrcweir getPeer()->invalidate(2); 409cdf0e10cSrcweir // and repaint the control 410cdf0e10cSrcweir impl_paint ( 0, 0, impl_getGraphicsPeer() ) ; 411cdf0e10cSrcweir } 412cdf0e10cSrcweir } 413cdf0e10cSrcweir 414cdf0e10cSrcweir //____________________________________________________________________________________________________________ 415cdf0e10cSrcweir // impl but public method to register service 416cdf0e10cSrcweir //____________________________________________________________________________________________________________ 417cdf0e10cSrcweir 418cdf0e10cSrcweir const Sequence< OUString > StatusIndicator::impl_getStaticSupportedServiceNames() 419cdf0e10cSrcweir { 420cdf0e10cSrcweir MutexGuard aGuard( Mutex::getGlobalMutex() ); 421cdf0e10cSrcweir Sequence< OUString > seqServiceNames( 1 ); 422cdf0e10cSrcweir seqServiceNames.getArray() [0] = OUString::createFromAscii( SERVICENAME_STATUSINDICATOR ); 423cdf0e10cSrcweir return seqServiceNames ; 424cdf0e10cSrcweir } 425cdf0e10cSrcweir 426cdf0e10cSrcweir //____________________________________________________________________________________________________________ 427cdf0e10cSrcweir // impl but public method to register service 428cdf0e10cSrcweir //____________________________________________________________________________________________________________ 429cdf0e10cSrcweir 430cdf0e10cSrcweir const OUString StatusIndicator::impl_getStaticImplementationName() 431cdf0e10cSrcweir { 432cdf0e10cSrcweir return OUString::createFromAscii( IMPLEMENTATIONNAME_STATUSINDICATOR ); 433cdf0e10cSrcweir } 434cdf0e10cSrcweir 435cdf0e10cSrcweir //____________________________________________________________________________________________________________ 436cdf0e10cSrcweir // protected method 437cdf0e10cSrcweir //____________________________________________________________________________________________________________ 438cdf0e10cSrcweir 439cdf0e10cSrcweir WindowDescriptor* StatusIndicator::impl_getWindowDescriptor( const Reference< XWindowPeer >& xParentPeer ) 440cdf0e10cSrcweir { 441cdf0e10cSrcweir // - used from "createPeer()" to set the values of an ::com::sun::star::awt::WindowDescriptor !!! 442cdf0e10cSrcweir // - if you will change the descriptor-values, you must override this virtuell function 443cdf0e10cSrcweir // - the caller must release the memory for this dynamical descriptor !!! 444cdf0e10cSrcweir 445cdf0e10cSrcweir WindowDescriptor* pDescriptor = new WindowDescriptor ; 446cdf0e10cSrcweir 447cdf0e10cSrcweir pDescriptor->Type = WindowClass_SIMPLE ; 448cdf0e10cSrcweir pDescriptor->WindowServiceName = OUString::createFromAscii( "floatingwindow" ) ; 449cdf0e10cSrcweir pDescriptor->ParentIndex = -1 ; 450cdf0e10cSrcweir pDescriptor->Parent = xParentPeer ; 451cdf0e10cSrcweir pDescriptor->Bounds = getPosSize () ; 452cdf0e10cSrcweir 453cdf0e10cSrcweir return pDescriptor ; 454cdf0e10cSrcweir } 455cdf0e10cSrcweir 456cdf0e10cSrcweir //____________________________________________________________________________________________________________ 457cdf0e10cSrcweir // protected method 458cdf0e10cSrcweir //____________________________________________________________________________________________________________ 459cdf0e10cSrcweir 460cdf0e10cSrcweir void StatusIndicator::impl_paint ( sal_Int32 nX, sal_Int32 nY, const Reference< XGraphics > & rGraphics ) 461cdf0e10cSrcweir { 462cdf0e10cSrcweir // This paint method ist not buffered !! 463cdf0e10cSrcweir // Every request paint the completely control. ( but only, if peer exist ) 464cdf0e10cSrcweir if ( rGraphics.is () ) 465cdf0e10cSrcweir { 466cdf0e10cSrcweir MutexGuard aGuard (m_aMutex) ; 467cdf0e10cSrcweir 468cdf0e10cSrcweir // background = gray 469cdf0e10cSrcweir Reference< XWindowPeer > xPeer( impl_getPeerWindow(), UNO_QUERY ); 470cdf0e10cSrcweir if( xPeer.is() == sal_True ) 471cdf0e10cSrcweir xPeer->setBackground( BACKGROUNDCOLOR ); 472cdf0e10cSrcweir 473cdf0e10cSrcweir // FixedText background = gray 474cdf0e10cSrcweir Reference< XControl > xTextControl( m_xText, UNO_QUERY ); 475cdf0e10cSrcweir xPeer = xTextControl->getPeer(); 476cdf0e10cSrcweir if( xPeer.is() == sal_True ) 477cdf0e10cSrcweir xPeer->setBackground( BACKGROUNDCOLOR ); 478cdf0e10cSrcweir 479cdf0e10cSrcweir // Progress background = gray 480cdf0e10cSrcweir xPeer = Reference< XWindowPeer >( m_xProgressBar, UNO_QUERY ); 481cdf0e10cSrcweir if( xPeer.is() == sal_True ) 482cdf0e10cSrcweir xPeer->setBackground( BACKGROUNDCOLOR ); 483cdf0e10cSrcweir 484cdf0e10cSrcweir // paint shadow border 485cdf0e10cSrcweir rGraphics->setLineColor ( LINECOLOR_BRIGHT ); 486cdf0e10cSrcweir rGraphics->drawLine ( nX, nY, impl_getWidth(), nY ); 487cdf0e10cSrcweir rGraphics->drawLine ( nX, nY, nX , impl_getHeight() ); 488cdf0e10cSrcweir 489cdf0e10cSrcweir rGraphics->setLineColor ( LINECOLOR_SHADOW ); 490cdf0e10cSrcweir rGraphics->drawLine ( impl_getWidth()-1, impl_getHeight()-1, impl_getWidth()-1, nY ); 491cdf0e10cSrcweir rGraphics->drawLine ( impl_getWidth()-1, impl_getHeight()-1, nX , impl_getHeight()-1 ); 492cdf0e10cSrcweir } 493cdf0e10cSrcweir } 494cdf0e10cSrcweir 495cdf0e10cSrcweir //____________________________________________________________________________________________________________ 496cdf0e10cSrcweir // protected method 497cdf0e10cSrcweir //____________________________________________________________________________________________________________ 498cdf0e10cSrcweir 499cdf0e10cSrcweir void StatusIndicator::impl_recalcLayout ( const WindowEvent& aEvent ) 500cdf0e10cSrcweir { 501cdf0e10cSrcweir sal_Int32 nX_ProgressBar ; 502cdf0e10cSrcweir sal_Int32 nY_ProgressBar ; 503cdf0e10cSrcweir sal_Int32 nWidth_ProgressBar ; 504cdf0e10cSrcweir sal_Int32 nHeight_ProgressBar ; 505cdf0e10cSrcweir sal_Int32 nX_Text ; 506cdf0e10cSrcweir sal_Int32 nY_Text ; 507cdf0e10cSrcweir sal_Int32 nWidth_Text ; 508cdf0e10cSrcweir sal_Int32 nHeight_Text ; 509cdf0e10cSrcweir 510cdf0e10cSrcweir // Ready for multithreading 511cdf0e10cSrcweir MutexGuard aGuard ( m_aMutex ) ; 512cdf0e10cSrcweir 513cdf0e10cSrcweir // get information about required place of child controls 514cdf0e10cSrcweir Size aWindowSize ( aEvent.Width, aEvent.Height ); 515cdf0e10cSrcweir Reference< XLayoutConstrains > xTextLayout ( m_xText, UNO_QUERY ); 516cdf0e10cSrcweir Size aTextSize = xTextLayout->getPreferredSize(); 517cdf0e10cSrcweir 518cdf0e10cSrcweir if( aWindowSize.Width < DEFAULT_WIDTH ) 519cdf0e10cSrcweir { 520cdf0e10cSrcweir aWindowSize.Width = DEFAULT_WIDTH; 521cdf0e10cSrcweir } 522cdf0e10cSrcweir if( aWindowSize.Height < DEFAULT_HEIGHT ) 523cdf0e10cSrcweir { 524cdf0e10cSrcweir aWindowSize.Height = DEFAULT_HEIGHT; 525cdf0e10cSrcweir } 526cdf0e10cSrcweir 527cdf0e10cSrcweir // calc position and size of child controls 528cdf0e10cSrcweir nX_Text = FREEBORDER ; 529cdf0e10cSrcweir nY_Text = FREEBORDER ; 530cdf0e10cSrcweir nWidth_Text = aTextSize.Width ; 531cdf0e10cSrcweir nHeight_Text = aTextSize.Height ; 532cdf0e10cSrcweir 533cdf0e10cSrcweir nX_ProgressBar = nX_Text+nWidth_Text+FREEBORDER ; 534cdf0e10cSrcweir nY_ProgressBar = nY_Text ; 535cdf0e10cSrcweir nWidth_ProgressBar = aWindowSize.Width-nWidth_Text-(3*FREEBORDER) ; 536cdf0e10cSrcweir nHeight_ProgressBar = nHeight_Text ; 537cdf0e10cSrcweir 538cdf0e10cSrcweir // Set new position and size on all controls 539cdf0e10cSrcweir Reference< XWindow > xTextWindow ( m_xText , UNO_QUERY ); 540cdf0e10cSrcweir Reference< XWindow > xProgressWindow ( m_xProgressBar, UNO_QUERY ); 541cdf0e10cSrcweir 542cdf0e10cSrcweir xTextWindow->setPosSize ( nX_Text , nY_Text , nWidth_Text , nHeight_Text , 15 ) ; 543cdf0e10cSrcweir xProgressWindow->setPosSize ( nX_ProgressBar, nY_ProgressBar, nWidth_ProgressBar, nHeight_ProgressBar , 15 ) ; 544cdf0e10cSrcweir } 545cdf0e10cSrcweir 546cdf0e10cSrcweir //____________________________________________________________________________________________________________ 547cdf0e10cSrcweir // debug methods 548cdf0e10cSrcweir //____________________________________________________________________________________________________________ 549cdf0e10cSrcweir 550cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 551cdf0e10cSrcweir 552cdf0e10cSrcweir #endif // #if OSL_DEBUG_LEVEL > 1 553cdf0e10cSrcweir 554cdf0e10cSrcweir } // namespace unocontrols 555