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
10*0b4ced1dSAndrew Rist *
11*0b4ced1dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*0b4ced1dSAndrew Rist *
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.
19*0b4ced1dSAndrew Rist *
20*0b4ced1dSAndrew Rist *************************************************************/
21*0b4ced1dSAndrew Rist
22*0b4ced1dSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir //____________________________________________________________________________________________________________
25cdf0e10cSrcweir // my own include
26cdf0e10cSrcweir //____________________________________________________________________________________________________________
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include "basecontrol.hxx"
29cdf0e10cSrcweir
30cdf0e10cSrcweir //____________________________________________________________________________________________________________
31cdf0e10cSrcweir // includes of other projects
32cdf0e10cSrcweir //____________________________________________________________________________________________________________
33cdf0e10cSrcweir #include <com/sun/star/awt/XDevice.hpp>
34cdf0e10cSrcweir #include <com/sun/star/awt/XDisplayBitmap.hpp>
35cdf0e10cSrcweir #include <com/sun/star/awt/DeviceInfo.hpp>
36cdf0e10cSrcweir #include <com/sun/star/awt/WindowAttribute.hpp>
37cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp>
38cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
39cdf0e10cSrcweir
40cdf0e10cSrcweir //____________________________________________________________________________________________________________
41cdf0e10cSrcweir // includes of my own project
42cdf0e10cSrcweir //____________________________________________________________________________________________________________
43cdf0e10cSrcweir
44cdf0e10cSrcweir //____________________________________________________________________________________________________________
45cdf0e10cSrcweir // namespaces
46cdf0e10cSrcweir //____________________________________________________________________________________________________________
47cdf0e10cSrcweir
48cdf0e10cSrcweir using namespace ::cppu ;
49cdf0e10cSrcweir using namespace ::osl ;
50cdf0e10cSrcweir using namespace ::rtl ;
51cdf0e10cSrcweir using namespace ::com::sun::star::uno ;
52cdf0e10cSrcweir using namespace ::com::sun::star::lang ;
53cdf0e10cSrcweir using namespace ::com::sun::star::awt ;
54cdf0e10cSrcweir
55cdf0e10cSrcweir namespace unocontrols{
56cdf0e10cSrcweir
57cdf0e10cSrcweir //____________________________________________________________________________________________________________
58cdf0e10cSrcweir // defines
59cdf0e10cSrcweir //____________________________________________________________________________________________________________
60cdf0e10cSrcweir
61cdf0e10cSrcweir #define DEFAULT_PMULTIPLEXER NULL
62cdf0e10cSrcweir #define DEFAULT_X 0
63cdf0e10cSrcweir #define DEFAULT_Y 0
64cdf0e10cSrcweir #define DEFAULT_WIDTH 100
65cdf0e10cSrcweir #define DEFAULT_HEIGHT 100
66cdf0e10cSrcweir #define DEFAULT_VISIBLE sal_False
67cdf0e10cSrcweir #define DEFAULT_INDESIGNMODE sal_False
68cdf0e10cSrcweir #define DEFAULT_ENABLE sal_True
69cdf0e10cSrcweir #define SERVICE_VCLTOOLKIT "com.sun.star.awt.Toolkit"
70cdf0e10cSrcweir
71cdf0e10cSrcweir //____________________________________________________________________________________________________________
72cdf0e10cSrcweir // construct/destruct
73cdf0e10cSrcweir //____________________________________________________________________________________________________________
74cdf0e10cSrcweir
BaseControl(const Reference<XMultiServiceFactory> & xFactory)75cdf0e10cSrcweir BaseControl::BaseControl( const Reference< XMultiServiceFactory >& xFactory )
76cdf0e10cSrcweir : IMPL_MutexContainer ( )
77cdf0e10cSrcweir , OComponentHelper ( m_aMutex )
78cdf0e10cSrcweir , m_xFactory ( xFactory )
79cdf0e10cSrcweir , m_pMultiplexer ( DEFAULT_PMULTIPLEXER )
80cdf0e10cSrcweir , m_nX ( DEFAULT_X )
81cdf0e10cSrcweir , m_nY ( DEFAULT_Y )
82cdf0e10cSrcweir , m_nWidth ( DEFAULT_WIDTH )
83cdf0e10cSrcweir , m_nHeight ( DEFAULT_HEIGHT )
84cdf0e10cSrcweir , m_bVisible ( DEFAULT_VISIBLE )
85cdf0e10cSrcweir , m_bInDesignMode ( DEFAULT_INDESIGNMODE )
86cdf0e10cSrcweir , m_bEnable ( DEFAULT_ENABLE )
87cdf0e10cSrcweir {
88cdf0e10cSrcweir }
89cdf0e10cSrcweir
~BaseControl()90cdf0e10cSrcweir BaseControl::~BaseControl()
91cdf0e10cSrcweir {
92cdf0e10cSrcweir }
93cdf0e10cSrcweir
94cdf0e10cSrcweir //____________________________________________________________________________________________________________
95cdf0e10cSrcweir // XInterface
96cdf0e10cSrcweir //____________________________________________________________________________________________________________
97cdf0e10cSrcweir
queryInterface(const Type & rType)98cdf0e10cSrcweir Any SAL_CALL BaseControl::queryInterface( const Type& rType ) throw( RuntimeException )
99cdf0e10cSrcweir {
100cdf0e10cSrcweir Any aReturn ;
101cdf0e10cSrcweir if ( m_xDelegator.is() == sal_True )
102cdf0e10cSrcweir {
103cdf0e10cSrcweir // If an delegator exist, forward question to his queryInterface.
104cdf0e10cSrcweir // Delegator will ask his own queryAggregation!
105cdf0e10cSrcweir aReturn = m_xDelegator->queryInterface( rType );
106cdf0e10cSrcweir }
107cdf0e10cSrcweir else
108cdf0e10cSrcweir {
109cdf0e10cSrcweir // If an delegator unknown, forward question to own queryAggregation.
110cdf0e10cSrcweir aReturn = queryAggregation( rType );
111cdf0e10cSrcweir }
112cdf0e10cSrcweir
113cdf0e10cSrcweir return aReturn ;
114cdf0e10cSrcweir }
115cdf0e10cSrcweir
116cdf0e10cSrcweir //____________________________________________________________________________________________________________
117cdf0e10cSrcweir // XInterface
118cdf0e10cSrcweir //____________________________________________________________________________________________________________
119cdf0e10cSrcweir
acquire()120cdf0e10cSrcweir void SAL_CALL BaseControl::acquire() throw()
121cdf0e10cSrcweir {
122cdf0e10cSrcweir // Attention:
123cdf0e10cSrcweir // Don't use mutex or guard in this method!!! Is a method of XInterface.
124cdf0e10cSrcweir
125cdf0e10cSrcweir // Forward to baseclass
126cdf0e10cSrcweir OComponentHelper::acquire();
127cdf0e10cSrcweir }
128cdf0e10cSrcweir
129cdf0e10cSrcweir //____________________________________________________________________________________________________________
130cdf0e10cSrcweir // XInterface
131cdf0e10cSrcweir //____________________________________________________________________________________________________________
132cdf0e10cSrcweir
release()133cdf0e10cSrcweir void SAL_CALL BaseControl::release() throw()
134cdf0e10cSrcweir {
135cdf0e10cSrcweir // Attention:
136cdf0e10cSrcweir // Don't use mutex or guard in this method!!! Is a method of XInterface.
137cdf0e10cSrcweir
138cdf0e10cSrcweir // Forward to baseclass
139cdf0e10cSrcweir OComponentHelper::release();
140cdf0e10cSrcweir }
141cdf0e10cSrcweir
142cdf0e10cSrcweir //____________________________________________________________________________________________________________
143cdf0e10cSrcweir // XTypeProvider
144cdf0e10cSrcweir //____________________________________________________________________________________________________________
145cdf0e10cSrcweir
getTypes()146cdf0e10cSrcweir Sequence< Type > SAL_CALL BaseControl::getTypes() throw( RuntimeException )
147cdf0e10cSrcweir {
148cdf0e10cSrcweir // Optimize this method !
149cdf0e10cSrcweir // We initialize a static variable only one time. And we don't must use a mutex at every call!
150cdf0e10cSrcweir // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL!
151cdf0e10cSrcweir static OTypeCollection* pTypeCollection = NULL ;
152cdf0e10cSrcweir
153cdf0e10cSrcweir if ( pTypeCollection == NULL )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir // Ready for multithreading; get global mutex for first call of this method only! see before
156cdf0e10cSrcweir MutexGuard aGuard( Mutex::getGlobalMutex() );
157cdf0e10cSrcweir
158cdf0e10cSrcweir // Control these pointer again ... it can be, that another instance will be faster then these!
159cdf0e10cSrcweir if ( pTypeCollection == NULL )
160cdf0e10cSrcweir {
161cdf0e10cSrcweir // Create a static typecollection ...
162cdf0e10cSrcweir static OTypeCollection aTypeCollection ( ::getCppuType(( const Reference< XPaintListener >*)NULL ) ,
163cdf0e10cSrcweir ::getCppuType(( const Reference< XWindowListener>*)NULL ) ,
164cdf0e10cSrcweir ::getCppuType(( const Reference< XView >*)NULL ) ,
165cdf0e10cSrcweir ::getCppuType(( const Reference< XWindow >*)NULL ) ,
166cdf0e10cSrcweir ::getCppuType(( const Reference< XServiceInfo >*)NULL ) ,
167cdf0e10cSrcweir ::getCppuType(( const Reference< XControl >*)NULL ) ,
168cdf0e10cSrcweir OComponentHelper::getTypes()
169cdf0e10cSrcweir );
170cdf0e10cSrcweir
171cdf0e10cSrcweir // ... and set his address to static pointer!
172cdf0e10cSrcweir pTypeCollection = &aTypeCollection ;
173cdf0e10cSrcweir }
174cdf0e10cSrcweir }
175cdf0e10cSrcweir
176cdf0e10cSrcweir return pTypeCollection->getTypes();
177cdf0e10cSrcweir }
178cdf0e10cSrcweir
179cdf0e10cSrcweir //____________________________________________________________________________________________________________
180cdf0e10cSrcweir // XTypeProvider
181cdf0e10cSrcweir //____________________________________________________________________________________________________________
182cdf0e10cSrcweir
getImplementationId()183cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL BaseControl::getImplementationId() throw( RuntimeException )
184cdf0e10cSrcweir {
185cdf0e10cSrcweir // Create one Id for all instances of this class.
186cdf0e10cSrcweir // Use ethernet address to do this! (sal_True)
187cdf0e10cSrcweir
188cdf0e10cSrcweir // Optimize this method
189cdf0e10cSrcweir // We initialize a static variable only one time. And we don't must use a mutex at every call!
190cdf0e10cSrcweir // For the first call; pID is NULL - for the second call pID is different from NULL!
191cdf0e10cSrcweir static OImplementationId* pID = NULL ;
192cdf0e10cSrcweir
193cdf0e10cSrcweir if ( pID == NULL )
194cdf0e10cSrcweir {
195cdf0e10cSrcweir // Ready for multithreading; get global mutex for first call of this method only! see before
196cdf0e10cSrcweir MutexGuard aGuard( Mutex::getGlobalMutex() );
197cdf0e10cSrcweir
198cdf0e10cSrcweir // Control these pointer again ... it can be, that another instance will be faster then these!
199cdf0e10cSrcweir if ( pID == NULL )
200cdf0e10cSrcweir {
201cdf0e10cSrcweir // Create a new static ID ...
202cdf0e10cSrcweir static OImplementationId aID( sal_False );
203cdf0e10cSrcweir // ... and set his address to static pointer!
204cdf0e10cSrcweir pID = &aID ;
205cdf0e10cSrcweir }
206cdf0e10cSrcweir }
207cdf0e10cSrcweir
208cdf0e10cSrcweir return pID->getImplementationId();
209cdf0e10cSrcweir }
210cdf0e10cSrcweir
211cdf0e10cSrcweir //____________________________________________________________________________________________________________
212cdf0e10cSrcweir // XAggregation
213cdf0e10cSrcweir //____________________________________________________________________________________________________________
214cdf0e10cSrcweir
setDelegator(const Reference<XInterface> & xDel)215cdf0e10cSrcweir void SAL_CALL BaseControl::setDelegator( const Reference< XInterface >& xDel ) throw( RuntimeException )
216cdf0e10cSrcweir {
217cdf0e10cSrcweir // Ready for multithreading
218cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
219cdf0e10cSrcweir m_xDelegator = xDel;
220cdf0e10cSrcweir }
221cdf0e10cSrcweir
222cdf0e10cSrcweir //____________________________________________________________________________________________________________
223cdf0e10cSrcweir // XAggregation
224cdf0e10cSrcweir //____________________________________________________________________________________________________________
225cdf0e10cSrcweir
queryAggregation(const Type & aType)226cdf0e10cSrcweir Any SAL_CALL BaseControl::queryAggregation( const Type& aType ) throw( RuntimeException )
227cdf0e10cSrcweir {
228cdf0e10cSrcweir // Ask for my own supported interfaces ...
229cdf0e10cSrcweir // Attention: XTypeProvider and XInterface are supported by OComponentHelper!
230cdf0e10cSrcweir Any aReturn ( ::cppu::queryInterface( aType ,
231cdf0e10cSrcweir static_cast< XPaintListener*> ( this ) ,
232cdf0e10cSrcweir static_cast< XWindowListener*> ( this ) ,
233cdf0e10cSrcweir static_cast< XView* > ( this ) ,
234cdf0e10cSrcweir static_cast< XWindow* > ( this ) ,
235cdf0e10cSrcweir static_cast< XServiceInfo* > ( this ) ,
236cdf0e10cSrcweir static_cast< XControl* > ( this )
237cdf0e10cSrcweir )
238cdf0e10cSrcweir );
239cdf0e10cSrcweir
240cdf0e10cSrcweir // If searched interface supported by this class ...
241cdf0e10cSrcweir if ( aReturn.hasValue() == sal_True )
242cdf0e10cSrcweir {
243cdf0e10cSrcweir // ... return this information.
244cdf0e10cSrcweir return aReturn ;
245cdf0e10cSrcweir }
246cdf0e10cSrcweir else
247cdf0e10cSrcweir {
248cdf0e10cSrcweir // Else; ... ask baseclass for interfaces!
249cdf0e10cSrcweir return OComponentHelper::queryAggregation( aType );
250cdf0e10cSrcweir }
251cdf0e10cSrcweir }
252cdf0e10cSrcweir
253cdf0e10cSrcweir //____________________________________________________________________________________________________________
254cdf0e10cSrcweir // XServiceInfo
255cdf0e10cSrcweir //____________________________________________________________________________________________________________
256cdf0e10cSrcweir
getImplementationName()257cdf0e10cSrcweir OUString SAL_CALL BaseControl::getImplementationName() throw( RuntimeException )
258cdf0e10cSrcweir {
259cdf0e10cSrcweir return impl_getStaticImplementationName();
260cdf0e10cSrcweir }
261cdf0e10cSrcweir
262cdf0e10cSrcweir //____________________________________________________________________________________________________________
263cdf0e10cSrcweir // XServiceInfo
264cdf0e10cSrcweir //____________________________________________________________________________________________________________
265cdf0e10cSrcweir
supportsService(const OUString & sServiceName)266cdf0e10cSrcweir sal_Bool SAL_CALL BaseControl::supportsService( const OUString& sServiceName ) throw( RuntimeException )
267cdf0e10cSrcweir {
268cdf0e10cSrcweir Sequence< OUString > seqServiceNames = getSupportedServiceNames();
269cdf0e10cSrcweir const OUString* pArray = seqServiceNames.getConstArray();
270cdf0e10cSrcweir for ( sal_Int32 nCounter=0; nCounter<seqServiceNames.getLength(); nCounter++ )
271cdf0e10cSrcweir {
272cdf0e10cSrcweir if ( pArray[nCounter] == sServiceName )
273cdf0e10cSrcweir {
274cdf0e10cSrcweir return sal_True ;
275cdf0e10cSrcweir }
276cdf0e10cSrcweir }
277cdf0e10cSrcweir return sal_False ;
278cdf0e10cSrcweir }
279cdf0e10cSrcweir
280cdf0e10cSrcweir //____________________________________________________________________________________________________________
281cdf0e10cSrcweir // XServiceInfo
282cdf0e10cSrcweir //____________________________________________________________________________________________________________
283cdf0e10cSrcweir
getSupportedServiceNames()284cdf0e10cSrcweir Sequence< OUString > SAL_CALL BaseControl::getSupportedServiceNames() throw( RuntimeException )
285cdf0e10cSrcweir {
286cdf0e10cSrcweir return impl_getStaticSupportedServiceNames();
287cdf0e10cSrcweir }
288cdf0e10cSrcweir
289cdf0e10cSrcweir //____________________________________________________________________________________________________________
290cdf0e10cSrcweir // XComponent
291cdf0e10cSrcweir //____________________________________________________________________________________________________________
292cdf0e10cSrcweir
dispose()293cdf0e10cSrcweir void SAL_CALL BaseControl::dispose() throw( RuntimeException )
294cdf0e10cSrcweir {
295cdf0e10cSrcweir // Ready for multithreading
296cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
297cdf0e10cSrcweir
298cdf0e10cSrcweir if ( m_pMultiplexer != NULL )
299cdf0e10cSrcweir {
300cdf0e10cSrcweir // to all other paint, focus, etc.
301cdf0e10cSrcweir m_pMultiplexer->disposeAndClear();
302cdf0e10cSrcweir }
303cdf0e10cSrcweir
304cdf0e10cSrcweir // set the service manager to disposed
305cdf0e10cSrcweir OComponentHelper::dispose();
306cdf0e10cSrcweir
307cdf0e10cSrcweir // release context and peer
308cdf0e10cSrcweir m_xContext = Reference< XInterface >();
309cdf0e10cSrcweir impl_releasePeer();
310cdf0e10cSrcweir
311cdf0e10cSrcweir // release view
312cdf0e10cSrcweir if ( m_xGraphicsView.is() == sal_True )
313cdf0e10cSrcweir {
314cdf0e10cSrcweir m_xGraphicsView = Reference< XGraphics >();
315cdf0e10cSrcweir }
316cdf0e10cSrcweir }
317cdf0e10cSrcweir
318cdf0e10cSrcweir //____________________________________________________________________________________________________________
319cdf0e10cSrcweir // XComponent
320cdf0e10cSrcweir //____________________________________________________________________________________________________________
321cdf0e10cSrcweir
addEventListener(const Reference<XEventListener> & xListener)322cdf0e10cSrcweir void SAL_CALL BaseControl::addEventListener( const Reference< XEventListener >& xListener ) throw( RuntimeException )
323cdf0e10cSrcweir {
324cdf0e10cSrcweir // Ready for multithreading
325cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
326cdf0e10cSrcweir OComponentHelper::addEventListener( xListener );
327cdf0e10cSrcweir }
328cdf0e10cSrcweir
329cdf0e10cSrcweir //____________________________________________________________________________________________________________
330cdf0e10cSrcweir // XComponent
331cdf0e10cSrcweir //____________________________________________________________________________________________________________
332cdf0e10cSrcweir
removeEventListener(const Reference<XEventListener> & xListener)333cdf0e10cSrcweir void SAL_CALL BaseControl::removeEventListener( const Reference< XEventListener >& xListener ) throw( RuntimeException )
334cdf0e10cSrcweir {
335cdf0e10cSrcweir // Ready for multithreading
336cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
337cdf0e10cSrcweir OComponentHelper::removeEventListener( xListener );
338cdf0e10cSrcweir }
339cdf0e10cSrcweir
340cdf0e10cSrcweir //____________________________________________________________________________________________________________
341cdf0e10cSrcweir // XControl
342cdf0e10cSrcweir //____________________________________________________________________________________________________________
343cdf0e10cSrcweir
createPeer(const Reference<XToolkit> & xToolkit,const Reference<XWindowPeer> & xParentPeer)344cdf0e10cSrcweir void SAL_CALL BaseControl::createPeer( const Reference< XToolkit >& xToolkit ,
345cdf0e10cSrcweir const Reference< XWindowPeer >& xParentPeer ) throw( RuntimeException )
346cdf0e10cSrcweir {
347cdf0e10cSrcweir // Ready for multithreading
348cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
349cdf0e10cSrcweir
350cdf0e10cSrcweir if ( m_xPeer.is() == sal_False )
351cdf0e10cSrcweir {
352cdf0e10cSrcweir // use method "BaseControl::getWindowDescriptor()" fot change window attributes !!!
353cdf0e10cSrcweir WindowDescriptor* pDescriptor = impl_getWindowDescriptor( xParentPeer );
354cdf0e10cSrcweir
355cdf0e10cSrcweir if ( m_bVisible == sal_True )
356cdf0e10cSrcweir {
357cdf0e10cSrcweir pDescriptor->WindowAttributes |= WindowAttribute::SHOW ;
358cdf0e10cSrcweir }
359cdf0e10cSrcweir
360cdf0e10cSrcweir // very slow under remote conditions!
361cdf0e10cSrcweir // create the window on the server
362cdf0e10cSrcweir Reference< XToolkit > xLocalToolkit = xToolkit ;
363cdf0e10cSrcweir if ( xLocalToolkit.is() == sal_False )
364cdf0e10cSrcweir {
365cdf0e10cSrcweir // but first create wellknown toolkit, if it not exist
366cdf0e10cSrcweir xLocalToolkit = Reference< XToolkit > ( m_xFactory->createInstance( OUString::createFromAscii( SERVICE_VCLTOOLKIT ) ), UNO_QUERY );
367cdf0e10cSrcweir }
368cdf0e10cSrcweir m_xPeer = xLocalToolkit->createWindow( *pDescriptor );
369cdf0e10cSrcweir m_xPeerWindow = Reference< XWindow >( m_xPeer, UNO_QUERY );
370cdf0e10cSrcweir
371cdf0e10cSrcweir // don't forget to release the memory!
372cdf0e10cSrcweir delete pDescriptor ;
373cdf0e10cSrcweir
374cdf0e10cSrcweir if ( m_xPeerWindow.is() == sal_True )
375cdf0e10cSrcweir {
376cdf0e10cSrcweir if ( m_pMultiplexer != NULL )
377cdf0e10cSrcweir {
378cdf0e10cSrcweir m_pMultiplexer->setPeer( m_xPeerWindow );
379cdf0e10cSrcweir }
380cdf0e10cSrcweir
381cdf0e10cSrcweir // create new referenz to xgraphics for painting on a peer
382cdf0e10cSrcweir // and add a paint listener
383cdf0e10cSrcweir Reference< XDevice > xDevice( m_xPeerWindow, UNO_QUERY );
384cdf0e10cSrcweir
385cdf0e10cSrcweir if ( xDevice.is() == sal_True )
386cdf0e10cSrcweir {
387cdf0e10cSrcweir m_xGraphicsPeer = xDevice->createGraphics();
388cdf0e10cSrcweir }
389cdf0e10cSrcweir
390cdf0e10cSrcweir if ( m_xGraphicsPeer.is() == sal_True )
391cdf0e10cSrcweir {
392cdf0e10cSrcweir addPaintListener( this );
393cdf0e10cSrcweir addWindowListener( this );
394cdf0e10cSrcweir }
395cdf0e10cSrcweir
396cdf0e10cSrcweir // PosSize_POSSIZE defined in <stardiv/uno/awt/window.hxx>
397cdf0e10cSrcweir m_xPeerWindow->setPosSize( m_nX, m_nY, m_nWidth, m_nHeight, PosSize::POSSIZE );
398cdf0e10cSrcweir m_xPeerWindow->setEnable( m_bEnable );
399cdf0e10cSrcweir m_xPeerWindow->setVisible( m_bVisible && !m_bInDesignMode );
400cdf0e10cSrcweir }
401cdf0e10cSrcweir }
402cdf0e10cSrcweir }
403cdf0e10cSrcweir
404cdf0e10cSrcweir //____________________________________________________________________________________________________________
405cdf0e10cSrcweir // XControl
406cdf0e10cSrcweir //____________________________________________________________________________________________________________
407cdf0e10cSrcweir
setContext(const Reference<XInterface> & xContext)408cdf0e10cSrcweir void SAL_CALL BaseControl::setContext( const Reference< XInterface >& xContext ) throw( RuntimeException )
409cdf0e10cSrcweir {
410cdf0e10cSrcweir // Ready for multithreading
411cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
412cdf0e10cSrcweir m_xContext = xContext ;
413cdf0e10cSrcweir }
414cdf0e10cSrcweir
415cdf0e10cSrcweir //____________________________________________________________________________________________________________
416cdf0e10cSrcweir // XControl
417cdf0e10cSrcweir //____________________________________________________________________________________________________________
418cdf0e10cSrcweir
setDesignMode(sal_Bool bOn)419cdf0e10cSrcweir void SAL_CALL BaseControl::setDesignMode( sal_Bool bOn ) throw( RuntimeException )
420cdf0e10cSrcweir {
421cdf0e10cSrcweir // Ready for multithreading
422cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
423cdf0e10cSrcweir m_bInDesignMode = bOn ;
424cdf0e10cSrcweir }
425cdf0e10cSrcweir
426cdf0e10cSrcweir //____________________________________________________________________________________________________________
427cdf0e10cSrcweir // XControl
428cdf0e10cSrcweir //____________________________________________________________________________________________________________
429cdf0e10cSrcweir
getContext()430cdf0e10cSrcweir Reference< XInterface > SAL_CALL BaseControl::getContext() throw( RuntimeException )
431cdf0e10cSrcweir {
432cdf0e10cSrcweir // Ready for multithreading
433cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
434cdf0e10cSrcweir return m_xContext ;
435cdf0e10cSrcweir }
436cdf0e10cSrcweir
437cdf0e10cSrcweir //____________________________________________________________________________________________________________
438cdf0e10cSrcweir // XControl
439cdf0e10cSrcweir //____________________________________________________________________________________________________________
440cdf0e10cSrcweir
getPeer()441cdf0e10cSrcweir Reference< XWindowPeer > SAL_CALL BaseControl::getPeer() throw( RuntimeException )
442cdf0e10cSrcweir {
443cdf0e10cSrcweir // Ready for multithreading
444cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
445cdf0e10cSrcweir return m_xPeer ;
446cdf0e10cSrcweir }
447cdf0e10cSrcweir
448cdf0e10cSrcweir //____________________________________________________________________________________________________________
449cdf0e10cSrcweir // XControl
450cdf0e10cSrcweir //____________________________________________________________________________________________________________
451cdf0e10cSrcweir
getView()452cdf0e10cSrcweir Reference< XView > SAL_CALL BaseControl::getView() throw( RuntimeException )
453cdf0e10cSrcweir {
454cdf0e10cSrcweir // Ready for multithreading
455cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
456cdf0e10cSrcweir return Reference< XView >( (OWeakObject*)this, UNO_QUERY );
457cdf0e10cSrcweir }
458cdf0e10cSrcweir
459cdf0e10cSrcweir //____________________________________________________________________________________________________________
460cdf0e10cSrcweir // XControl
461cdf0e10cSrcweir //____________________________________________________________________________________________________________
462cdf0e10cSrcweir
isDesignMode()463cdf0e10cSrcweir sal_Bool SAL_CALL BaseControl::isDesignMode() throw( RuntimeException )
464cdf0e10cSrcweir {
465cdf0e10cSrcweir // Ready for multithreading
466cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
467cdf0e10cSrcweir return m_bInDesignMode ;
468cdf0e10cSrcweir }
469cdf0e10cSrcweir
470cdf0e10cSrcweir //____________________________________________________________________________________________________________
471cdf0e10cSrcweir // XControl
472cdf0e10cSrcweir //____________________________________________________________________________________________________________
473cdf0e10cSrcweir
isTransparent()474cdf0e10cSrcweir sal_Bool SAL_CALL BaseControl::isTransparent() throw( RuntimeException )
475cdf0e10cSrcweir {
476cdf0e10cSrcweir return sal_False ;
477cdf0e10cSrcweir }
478cdf0e10cSrcweir
479cdf0e10cSrcweir //____________________________________________________________________________________________________________
480cdf0e10cSrcweir // XWindow
481cdf0e10cSrcweir //____________________________________________________________________________________________________________
482cdf0e10cSrcweir
setPosSize(sal_Int32 nX,sal_Int32 nY,sal_Int32 nWidth,sal_Int32 nHeight,sal_Int16 nFlags)483cdf0e10cSrcweir void SAL_CALL BaseControl::setPosSize( sal_Int32 nX ,
484cdf0e10cSrcweir sal_Int32 nY ,
485cdf0e10cSrcweir sal_Int32 nWidth ,
486cdf0e10cSrcweir sal_Int32 nHeight ,
487cdf0e10cSrcweir sal_Int16 nFlags ) throw( RuntimeException )
488cdf0e10cSrcweir {
489cdf0e10cSrcweir // - change size and position of window and save the values
490cdf0e10cSrcweir // - "nFlags" declared in <stardiv/uno/awt/window.hxx> ("#define PosSize_X .....")
491cdf0e10cSrcweir
492cdf0e10cSrcweir // Ready for multithreading
493cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
494cdf0e10cSrcweir
495cdf0e10cSrcweir sal_Bool bChanged = sal_False ;
496cdf0e10cSrcweir
497cdf0e10cSrcweir if ( nFlags & PosSize::X )
498cdf0e10cSrcweir {
499cdf0e10cSrcweir bChanged |= m_nX != nX, m_nX = nX ;
500cdf0e10cSrcweir }
501cdf0e10cSrcweir
502cdf0e10cSrcweir if ( nFlags & PosSize::Y )
503cdf0e10cSrcweir {
504cdf0e10cSrcweir bChanged |= m_nY != nY, m_nY = nY ;
505cdf0e10cSrcweir }
506cdf0e10cSrcweir
507cdf0e10cSrcweir if ( nFlags & PosSize::WIDTH )
508cdf0e10cSrcweir {
509cdf0e10cSrcweir bChanged |= m_nWidth != nWidth, m_nWidth = nWidth ;
510cdf0e10cSrcweir }
511cdf0e10cSrcweir
512cdf0e10cSrcweir if ( nFlags & PosSize::HEIGHT )
513cdf0e10cSrcweir {
514cdf0e10cSrcweir bChanged |= m_nHeight != nHeight, m_nHeight = nHeight ;
515cdf0e10cSrcweir }
516cdf0e10cSrcweir
517cdf0e10cSrcweir if ( bChanged && m_xPeerWindow.is() )
518cdf0e10cSrcweir {
519cdf0e10cSrcweir m_xPeerWindow->setPosSize( m_nX, m_nY, m_nWidth, m_nHeight, nFlags );
520cdf0e10cSrcweir }
521cdf0e10cSrcweir }
522cdf0e10cSrcweir
523cdf0e10cSrcweir //____________________________________________________________________________________________________________
524cdf0e10cSrcweir // XWindow
525cdf0e10cSrcweir //____________________________________________________________________________________________________________
526cdf0e10cSrcweir
setVisible(sal_Bool bVisible)527cdf0e10cSrcweir void SAL_CALL BaseControl::setVisible( sal_Bool bVisible ) throw( RuntimeException )
528cdf0e10cSrcweir {
529cdf0e10cSrcweir // Ready for multithreading
530cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
531cdf0e10cSrcweir
532cdf0e10cSrcweir // Set new state of flag
533cdf0e10cSrcweir m_bVisible = bVisible ;
534cdf0e10cSrcweir
535cdf0e10cSrcweir if ( m_xPeerWindow.is() == sal_True )
536cdf0e10cSrcweir {
537cdf0e10cSrcweir // Set it also on peerwindow
538cdf0e10cSrcweir m_xPeerWindow->setVisible( m_bVisible );
539cdf0e10cSrcweir }
540cdf0e10cSrcweir }
541cdf0e10cSrcweir
542cdf0e10cSrcweir //____________________________________________________________________________________________________________
543cdf0e10cSrcweir // XWindow
544cdf0e10cSrcweir //____________________________________________________________________________________________________________
545cdf0e10cSrcweir
setEnable(sal_Bool bEnable)546cdf0e10cSrcweir void SAL_CALL BaseControl::setEnable( sal_Bool bEnable ) throw( RuntimeException )
547cdf0e10cSrcweir {
548cdf0e10cSrcweir // Ready for multithreading
549cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
550cdf0e10cSrcweir
551cdf0e10cSrcweir // Set new state of flag
552cdf0e10cSrcweir m_bEnable = bEnable ;
553cdf0e10cSrcweir
554cdf0e10cSrcweir if ( m_xPeerWindow.is() == sal_True )
555cdf0e10cSrcweir {
556cdf0e10cSrcweir // Set it also on peerwindow
557cdf0e10cSrcweir m_xPeerWindow->setEnable( m_bEnable );
558cdf0e10cSrcweir }
559cdf0e10cSrcweir }
560cdf0e10cSrcweir
561cdf0e10cSrcweir //____________________________________________________________________________________________________________
562cdf0e10cSrcweir // XWindow
563cdf0e10cSrcweir //____________________________________________________________________________________________________________
564cdf0e10cSrcweir
setFocus()565cdf0e10cSrcweir void SAL_CALL BaseControl::setFocus() throw( RuntimeException )
566cdf0e10cSrcweir {
567cdf0e10cSrcweir // Ready for multithreading
568cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
569cdf0e10cSrcweir
570cdf0e10cSrcweir if ( m_xPeerWindow.is() == sal_True )
571cdf0e10cSrcweir {
572cdf0e10cSrcweir m_xPeerWindow->setFocus();
573cdf0e10cSrcweir }
574cdf0e10cSrcweir }
575cdf0e10cSrcweir
576cdf0e10cSrcweir //____________________________________________________________________________________________________________
577cdf0e10cSrcweir // XWindow
578cdf0e10cSrcweir //____________________________________________________________________________________________________________
579cdf0e10cSrcweir
getPosSize()580cdf0e10cSrcweir Rectangle SAL_CALL BaseControl::getPosSize() throw( RuntimeException )
581cdf0e10cSrcweir {
582cdf0e10cSrcweir // Ready for multithreading
583cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
584cdf0e10cSrcweir return Rectangle( m_nX, m_nY , m_nWidth, m_nHeight );
585cdf0e10cSrcweir }
586cdf0e10cSrcweir
587cdf0e10cSrcweir //____________________________________________________________________________________________________________
588cdf0e10cSrcweir // XWindow
589cdf0e10cSrcweir //____________________________________________________________________________________________________________
590cdf0e10cSrcweir
addWindowListener(const Reference<XWindowListener> & xListener)591cdf0e10cSrcweir void SAL_CALL BaseControl::addWindowListener( const Reference< XWindowListener >& xListener ) throw( RuntimeException )
592cdf0e10cSrcweir {
593cdf0e10cSrcweir impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XWindowListener >*)0), xListener );
594cdf0e10cSrcweir }
595cdf0e10cSrcweir
596cdf0e10cSrcweir //____________________________________________________________________________________________________________
597cdf0e10cSrcweir // XWindow
598cdf0e10cSrcweir //____________________________________________________________________________________________________________
599cdf0e10cSrcweir
addFocusListener(const Reference<XFocusListener> & xListener)600cdf0e10cSrcweir void SAL_CALL BaseControl::addFocusListener( const Reference< XFocusListener >& xListener ) throw( RuntimeException )
601cdf0e10cSrcweir {
602cdf0e10cSrcweir impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XFocusListener >*)0), xListener );
603cdf0e10cSrcweir }
604cdf0e10cSrcweir
605cdf0e10cSrcweir //____________________________________________________________________________________________________________
606cdf0e10cSrcweir // XWindow
607cdf0e10cSrcweir //____________________________________________________________________________________________________________
608cdf0e10cSrcweir
addKeyListener(const Reference<XKeyListener> & xListener)609cdf0e10cSrcweir void SAL_CALL BaseControl::addKeyListener( const Reference< XKeyListener >& xListener ) throw( RuntimeException )
610cdf0e10cSrcweir {
611cdf0e10cSrcweir impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XKeyListener >*)0), xListener );
612cdf0e10cSrcweir }
613cdf0e10cSrcweir
614cdf0e10cSrcweir //____________________________________________________________________________________________________________
615cdf0e10cSrcweir // XWindow
616cdf0e10cSrcweir //____________________________________________________________________________________________________________
617cdf0e10cSrcweir
addMouseListener(const Reference<XMouseListener> & xListener)618cdf0e10cSrcweir void SAL_CALL BaseControl::addMouseListener( const Reference< XMouseListener >& xListener ) throw( RuntimeException )
619cdf0e10cSrcweir {
620cdf0e10cSrcweir impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XMouseListener >*)0), xListener );
621cdf0e10cSrcweir }
622cdf0e10cSrcweir
623cdf0e10cSrcweir //____________________________________________________________________________________________________________
624cdf0e10cSrcweir // XWindow
625cdf0e10cSrcweir //____________________________________________________________________________________________________________
626cdf0e10cSrcweir
addMouseMotionListener(const Reference<XMouseMotionListener> & xListener)627cdf0e10cSrcweir void SAL_CALL BaseControl::addMouseMotionListener( const Reference< XMouseMotionListener >& xListener ) throw( RuntimeException )
628cdf0e10cSrcweir {
629cdf0e10cSrcweir impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XMouseMotionListener >*)0), xListener );
630cdf0e10cSrcweir }
631cdf0e10cSrcweir
632cdf0e10cSrcweir //____________________________________________________________________________________________________________
633cdf0e10cSrcweir // XWindow
634cdf0e10cSrcweir //____________________________________________________________________________________________________________
635cdf0e10cSrcweir
addPaintListener(const Reference<XPaintListener> & xListener)636cdf0e10cSrcweir void SAL_CALL BaseControl::addPaintListener( const Reference< XPaintListener >& xListener ) throw( RuntimeException )
637cdf0e10cSrcweir {
638cdf0e10cSrcweir impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XPaintListener >*)0), xListener );
639cdf0e10cSrcweir }
640cdf0e10cSrcweir
641cdf0e10cSrcweir //____________________________________________________________________________________________________________
642cdf0e10cSrcweir // XWindow
643cdf0e10cSrcweir //____________________________________________________________________________________________________________
644cdf0e10cSrcweir
removeWindowListener(const Reference<XWindowListener> & xListener)645cdf0e10cSrcweir void SAL_CALL BaseControl::removeWindowListener( const Reference< XWindowListener >& xListener ) throw( RuntimeException )
646cdf0e10cSrcweir {
647cdf0e10cSrcweir impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XWindowListener >*)0), xListener );
648cdf0e10cSrcweir }
649cdf0e10cSrcweir
650cdf0e10cSrcweir //____________________________________________________________________________________________________________
651cdf0e10cSrcweir // XWindow
652cdf0e10cSrcweir //____________________________________________________________________________________________________________
653cdf0e10cSrcweir
removeFocusListener(const Reference<XFocusListener> & xListener)654cdf0e10cSrcweir void SAL_CALL BaseControl::removeFocusListener( const Reference< XFocusListener >& xListener ) throw( RuntimeException )
655cdf0e10cSrcweir {
656cdf0e10cSrcweir impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XFocusListener >*)0), xListener );
657cdf0e10cSrcweir }
658cdf0e10cSrcweir
659cdf0e10cSrcweir //____________________________________________________________________________________________________________
660cdf0e10cSrcweir // XWindow
661cdf0e10cSrcweir //____________________________________________________________________________________________________________
662cdf0e10cSrcweir
removeKeyListener(const Reference<XKeyListener> & xListener)663cdf0e10cSrcweir void SAL_CALL BaseControl::removeKeyListener( const Reference< XKeyListener >& xListener ) throw( RuntimeException )
664cdf0e10cSrcweir {
665cdf0e10cSrcweir impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XKeyListener >*)0), xListener );
666cdf0e10cSrcweir }
667cdf0e10cSrcweir
668cdf0e10cSrcweir //____________________________________________________________________________________________________________
669cdf0e10cSrcweir // XWindow
670cdf0e10cSrcweir //____________________________________________________________________________________________________________
671cdf0e10cSrcweir
removeMouseListener(const Reference<XMouseListener> & xListener)672cdf0e10cSrcweir void SAL_CALL BaseControl::removeMouseListener( const Reference< XMouseListener >& xListener ) throw( RuntimeException )
673cdf0e10cSrcweir {
674cdf0e10cSrcweir impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XMouseListener >*)0), xListener );
675cdf0e10cSrcweir }
676cdf0e10cSrcweir
677cdf0e10cSrcweir //____________________________________________________________________________________________________________
678cdf0e10cSrcweir // XWindow
679cdf0e10cSrcweir //____________________________________________________________________________________________________________
680cdf0e10cSrcweir
removeMouseMotionListener(const Reference<XMouseMotionListener> & xListener)681cdf0e10cSrcweir void SAL_CALL BaseControl::removeMouseMotionListener( const Reference< XMouseMotionListener >& xListener ) throw( RuntimeException )
682cdf0e10cSrcweir {
683cdf0e10cSrcweir impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XMouseMotionListener >*)0), xListener );
684cdf0e10cSrcweir }
685cdf0e10cSrcweir
686cdf0e10cSrcweir //____________________________________________________________________________________________________________
687cdf0e10cSrcweir // XWindow
688cdf0e10cSrcweir //____________________________________________________________________________________________________________
689cdf0e10cSrcweir
removePaintListener(const Reference<XPaintListener> & xListener)690cdf0e10cSrcweir void SAL_CALL BaseControl::removePaintListener( const Reference< XPaintListener >& xListener ) throw( RuntimeException )
691cdf0e10cSrcweir {
692cdf0e10cSrcweir impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XPaintListener >*)0), xListener );
693cdf0e10cSrcweir }
694cdf0e10cSrcweir
695cdf0e10cSrcweir //____________________________________________________________________________________________________________
696cdf0e10cSrcweir // XView
697cdf0e10cSrcweir //____________________________________________________________________________________________________________
698cdf0e10cSrcweir
draw(sal_Int32 nX,sal_Int32 nY)699cdf0e10cSrcweir void SAL_CALL BaseControl::draw( sal_Int32 nX ,
700cdf0e10cSrcweir sal_Int32 nY ) throw( RuntimeException )
701cdf0e10cSrcweir {
702cdf0e10cSrcweir // Ready for multithreading
703cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
704cdf0e10cSrcweir
705cdf0e10cSrcweir // - paint to an view
706cdf0e10cSrcweir // - use the method "paint()"
707cdf0e10cSrcweir // - see also "windowPaint()"
708cdf0e10cSrcweir impl_paint( nX, nY, m_xGraphicsView );
709cdf0e10cSrcweir }
710cdf0e10cSrcweir
711cdf0e10cSrcweir //____________________________________________________________________________________________________________
712cdf0e10cSrcweir // XView
713cdf0e10cSrcweir //____________________________________________________________________________________________________________
714cdf0e10cSrcweir
setGraphics(const Reference<XGraphics> & xDevice)715cdf0e10cSrcweir sal_Bool SAL_CALL BaseControl::setGraphics( const Reference< XGraphics >& xDevice ) throw( RuntimeException )
716cdf0e10cSrcweir {
717cdf0e10cSrcweir // - set the graphics for an view
718cdf0e10cSrcweir // - in this class exist 2 graphics-member ... one for peer[_xGraphicsPeer] and one for view[_xGraphicsView]
719cdf0e10cSrcweir // - they are used by "windowPaint() and draw()", forwarded to "paint ()"
720cdf0e10cSrcweir sal_Bool bReturn = sal_False ;
721cdf0e10cSrcweir if ( xDevice.is() == sal_True )
722cdf0e10cSrcweir {
723cdf0e10cSrcweir // Ready for multithreading
724cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
725cdf0e10cSrcweir
726cdf0e10cSrcweir m_xGraphicsView = xDevice ;
727cdf0e10cSrcweir bReturn = sal_True ;
728cdf0e10cSrcweir }
729cdf0e10cSrcweir
730cdf0e10cSrcweir return bReturn ;
731cdf0e10cSrcweir }
732cdf0e10cSrcweir
733cdf0e10cSrcweir //____________________________________________________________________________________________________________
734cdf0e10cSrcweir // XView
735cdf0e10cSrcweir //____________________________________________________________________________________________________________
736cdf0e10cSrcweir
setZoom(float,float)737cdf0e10cSrcweir void SAL_CALL BaseControl::setZoom( float /*fZoomX*/ ,
738cdf0e10cSrcweir float /*fZoomY*/ ) throw( RuntimeException )
739cdf0e10cSrcweir {
740cdf0e10cSrcweir // Not implemented yet
741cdf0e10cSrcweir }
742cdf0e10cSrcweir
743cdf0e10cSrcweir //____________________________________________________________________________________________________________
744cdf0e10cSrcweir // XView
745cdf0e10cSrcweir //____________________________________________________________________________________________________________
746cdf0e10cSrcweir
getGraphics()747cdf0e10cSrcweir Reference< XGraphics > SAL_CALL BaseControl::getGraphics() throw( RuntimeException )
748cdf0e10cSrcweir {
749cdf0e10cSrcweir // Ready for multithreading
750cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
751cdf0e10cSrcweir return m_xGraphicsView ;
752cdf0e10cSrcweir }
753cdf0e10cSrcweir
754cdf0e10cSrcweir //____________________________________________________________________________________________________________
755cdf0e10cSrcweir // XView
756cdf0e10cSrcweir //____________________________________________________________________________________________________________
757cdf0e10cSrcweir
getSize()758cdf0e10cSrcweir Size SAL_CALL BaseControl::getSize() throw( RuntimeException )
759cdf0e10cSrcweir {
760cdf0e10cSrcweir // Ready for multithreading
761cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
762cdf0e10cSrcweir return Size( m_nWidth, m_nHeight );
763cdf0e10cSrcweir }
764cdf0e10cSrcweir
765cdf0e10cSrcweir //____________________________________________________________________________________________________________
766cdf0e10cSrcweir // XEventListener
767cdf0e10cSrcweir //____________________________________________________________________________________________________________
768cdf0e10cSrcweir
disposing(const EventObject &)769cdf0e10cSrcweir void SAL_CALL BaseControl::disposing( const EventObject& /*aSource*/ ) throw( RuntimeException )
770cdf0e10cSrcweir {
771cdf0e10cSrcweir // Ready for multithreading
772cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
773cdf0e10cSrcweir
774cdf0e10cSrcweir // - release ALL references
775cdf0e10cSrcweir // - it must be !!!
776cdf0e10cSrcweir if ( m_xGraphicsPeer.is() == sal_True )
777cdf0e10cSrcweir {
778cdf0e10cSrcweir removePaintListener( this );
779cdf0e10cSrcweir removeWindowListener( this );
780cdf0e10cSrcweir m_xGraphicsPeer = Reference< XGraphics >();
781cdf0e10cSrcweir }
782cdf0e10cSrcweir
783cdf0e10cSrcweir if ( m_xGraphicsView.is() == sal_True )
784cdf0e10cSrcweir {
785cdf0e10cSrcweir m_xGraphicsView = Reference< XGraphics >();
786cdf0e10cSrcweir }
787cdf0e10cSrcweir }
788cdf0e10cSrcweir
789cdf0e10cSrcweir //____________________________________________________________________________________________________________
790cdf0e10cSrcweir // XPaintListener
791cdf0e10cSrcweir //____________________________________________________________________________________________________________
792cdf0e10cSrcweir
windowPaint(const PaintEvent &)793cdf0e10cSrcweir void SAL_CALL BaseControl::windowPaint( const PaintEvent& /*aEvent*/ ) throw( RuntimeException )
794cdf0e10cSrcweir {
795cdf0e10cSrcweir // Ready for multithreading
796cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
797cdf0e10cSrcweir
798cdf0e10cSrcweir // - repaint the peer
799cdf0e10cSrcweir // - use the method "paint ()" for painting on a peer and a print device !!!
800cdf0e10cSrcweir // - see also "draw ()"
801cdf0e10cSrcweir impl_paint( 0, 0, m_xGraphicsPeer );
802cdf0e10cSrcweir }
803cdf0e10cSrcweir
804cdf0e10cSrcweir //____________________________________________________________________________________________________________
805cdf0e10cSrcweir // XWindowListener
806cdf0e10cSrcweir //____________________________________________________________________________________________________________
807cdf0e10cSrcweir
windowResized(const WindowEvent & aEvent)808cdf0e10cSrcweir void SAL_CALL BaseControl::windowResized( const WindowEvent& aEvent ) throw( RuntimeException )
809cdf0e10cSrcweir {
810cdf0e10cSrcweir // Ready for multithreading
811cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
812cdf0e10cSrcweir
813cdf0e10cSrcweir m_nWidth = aEvent.Width ;
814cdf0e10cSrcweir m_nHeight = aEvent.Height ;
815cdf0e10cSrcweir WindowEvent aMappedEvent = aEvent;
816cdf0e10cSrcweir aMappedEvent.X = 0;
817cdf0e10cSrcweir aMappedEvent.Y = 0;
818cdf0e10cSrcweir impl_recalcLayout( aMappedEvent );
819cdf0e10cSrcweir }
820cdf0e10cSrcweir
821cdf0e10cSrcweir //____________________________________________________________________________________________________________
822cdf0e10cSrcweir // XWindowListener
823cdf0e10cSrcweir //____________________________________________________________________________________________________________
824cdf0e10cSrcweir
windowMoved(const WindowEvent & aEvent)825cdf0e10cSrcweir void SAL_CALL BaseControl::windowMoved( const WindowEvent& aEvent ) throw( RuntimeException )
826cdf0e10cSrcweir {
827cdf0e10cSrcweir // Ready for multithreading
828cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
829cdf0e10cSrcweir
830cdf0e10cSrcweir m_nWidth = aEvent.Width ;
831cdf0e10cSrcweir m_nHeight = aEvent.Height ;
832cdf0e10cSrcweir WindowEvent aMappedEvent = aEvent;
833cdf0e10cSrcweir aMappedEvent.X = 0;
834cdf0e10cSrcweir aMappedEvent.Y = 0;
835cdf0e10cSrcweir impl_recalcLayout( aMappedEvent );
836cdf0e10cSrcweir }
837cdf0e10cSrcweir
838cdf0e10cSrcweir //____________________________________________________________________________________________________________
839cdf0e10cSrcweir // XWindowListener
840cdf0e10cSrcweir //____________________________________________________________________________________________________________
841cdf0e10cSrcweir
windowShown(const EventObject &)842cdf0e10cSrcweir void SAL_CALL BaseControl::windowShown( const EventObject& /*aEvent*/ ) throw( RuntimeException )
843cdf0e10cSrcweir {
844cdf0e10cSrcweir }
845cdf0e10cSrcweir
846cdf0e10cSrcweir //____________________________________________________________________________________________________________
847cdf0e10cSrcweir // XWindowListener
848cdf0e10cSrcweir //____________________________________________________________________________________________________________
849cdf0e10cSrcweir
windowHidden(const EventObject &)850cdf0e10cSrcweir void SAL_CALL BaseControl::windowHidden( const EventObject& /*aEvent*/ ) throw( RuntimeException )
851cdf0e10cSrcweir {
852cdf0e10cSrcweir }
853cdf0e10cSrcweir
854cdf0e10cSrcweir //____________________________________________________________________________________________________________
855cdf0e10cSrcweir // impl but public method to register service in DLL
856cdf0e10cSrcweir // (In this BASE-implementation not implemented! Overwrite it in derived classes.)
857cdf0e10cSrcweir //____________________________________________________________________________________________________________
858cdf0e10cSrcweir
impl_getStaticSupportedServiceNames()859cdf0e10cSrcweir const Sequence< OUString > BaseControl::impl_getStaticSupportedServiceNames()
860cdf0e10cSrcweir {
861cdf0e10cSrcweir return Sequence< OUString >();
862cdf0e10cSrcweir }
863cdf0e10cSrcweir
864cdf0e10cSrcweir //____________________________________________________________________________________________________________
865cdf0e10cSrcweir // impl but public method to register service in DLL
866cdf0e10cSrcweir // (In this BASE-implementation not implemented! Overwrite it in derived classes.)
867cdf0e10cSrcweir //____________________________________________________________________________________________________________
868cdf0e10cSrcweir
impl_getStaticImplementationName()869cdf0e10cSrcweir const OUString BaseControl::impl_getStaticImplementationName()
870cdf0e10cSrcweir {
871cdf0e10cSrcweir return OUString();
872cdf0e10cSrcweir }
873cdf0e10cSrcweir
874cdf0e10cSrcweir //____________________________________________________________________________________________________________
875cdf0e10cSrcweir // protected method
876cdf0e10cSrcweir //____________________________________________________________________________________________________________
877cdf0e10cSrcweir
impl_getMultiServiceFactory()878cdf0e10cSrcweir const Reference< XMultiServiceFactory > BaseControl::impl_getMultiServiceFactory()
879cdf0e10cSrcweir {
880cdf0e10cSrcweir return m_xFactory ;
881cdf0e10cSrcweir }
882cdf0e10cSrcweir
883cdf0e10cSrcweir //____________________________________________________________________________________________________________
884cdf0e10cSrcweir // protected method
885cdf0e10cSrcweir //____________________________________________________________________________________________________________
886cdf0e10cSrcweir
impl_getPeerWindow()887cdf0e10cSrcweir const Reference< XWindow > BaseControl::impl_getPeerWindow()
888cdf0e10cSrcweir {
889cdf0e10cSrcweir return m_xPeerWindow ;
890cdf0e10cSrcweir }
891cdf0e10cSrcweir
892cdf0e10cSrcweir //____________________________________________________________________________________________________________
893cdf0e10cSrcweir // protected method
894cdf0e10cSrcweir //____________________________________________________________________________________________________________
895cdf0e10cSrcweir
impl_getGraphicsPeer()896cdf0e10cSrcweir const Reference< XGraphics > BaseControl::impl_getGraphicsPeer()
897cdf0e10cSrcweir {
898cdf0e10cSrcweir return m_xGraphicsPeer ;
899cdf0e10cSrcweir }
900cdf0e10cSrcweir
901cdf0e10cSrcweir //____________________________________________________________________________________________________________
902cdf0e10cSrcweir // protected method
903cdf0e10cSrcweir //____________________________________________________________________________________________________________
904cdf0e10cSrcweir
impl_getWidth()905cdf0e10cSrcweir const sal_Int32& BaseControl::impl_getWidth()
906cdf0e10cSrcweir {
907cdf0e10cSrcweir return m_nWidth ;
908cdf0e10cSrcweir }
909cdf0e10cSrcweir
910cdf0e10cSrcweir //____________________________________________________________________________________________________________
911cdf0e10cSrcweir // protected method
912cdf0e10cSrcweir //____________________________________________________________________________________________________________
913cdf0e10cSrcweir
impl_getHeight()914cdf0e10cSrcweir const sal_Int32& BaseControl::impl_getHeight()
915cdf0e10cSrcweir {
916cdf0e10cSrcweir return m_nHeight ;
917cdf0e10cSrcweir }
918cdf0e10cSrcweir
919cdf0e10cSrcweir //____________________________________________________________________________________________________________
920cdf0e10cSrcweir // protected method
921cdf0e10cSrcweir //____________________________________________________________________________________________________________
922cdf0e10cSrcweir
impl_getWindowDescriptor(const Reference<XWindowPeer> & xParentPeer)923cdf0e10cSrcweir WindowDescriptor* BaseControl::impl_getWindowDescriptor( const Reference< XWindowPeer >& xParentPeer )
924cdf0e10cSrcweir {
925cdf0e10cSrcweir // - used from "createPeer()" to set the values of an ::com::sun::star::awt::WindowDescriptor !!!
926cdf0e10cSrcweir // - if you will change the descriptor-values, you must override this virtuell function
927cdf0e10cSrcweir // - the caller must release the memory for this dynamical descriptor !!!
928cdf0e10cSrcweir
929cdf0e10cSrcweir WindowDescriptor* pDescriptor = new WindowDescriptor ;
930cdf0e10cSrcweir
931cdf0e10cSrcweir pDescriptor->Type = WindowClass_SIMPLE ;
932cdf0e10cSrcweir pDescriptor->WindowServiceName = OUString::createFromAscii( "window" ) ;
933cdf0e10cSrcweir pDescriptor->ParentIndex = -1 ;
934cdf0e10cSrcweir pDescriptor->Parent = xParentPeer ;
935cdf0e10cSrcweir pDescriptor->Bounds = getPosSize () ;
936cdf0e10cSrcweir pDescriptor->WindowAttributes = 0 ;
937cdf0e10cSrcweir
938cdf0e10cSrcweir return pDescriptor ;
939cdf0e10cSrcweir }
940cdf0e10cSrcweir
941cdf0e10cSrcweir //____________________________________________________________________________________________________________
942cdf0e10cSrcweir // protected method
943cdf0e10cSrcweir //____________________________________________________________________________________________________________
944cdf0e10cSrcweir
impl_paint(sal_Int32,sal_Int32,const Reference<XGraphics> &)945cdf0e10cSrcweir void BaseControl::impl_paint( sal_Int32 /*nX*/ ,
946cdf0e10cSrcweir sal_Int32 /*nY*/ ,
947cdf0e10cSrcweir const Reference< XGraphics >& /*xGraphics*/ )
948cdf0e10cSrcweir {
949cdf0e10cSrcweir // - one paint method for peer AND view !!!
950cdf0e10cSrcweir // (see also => "windowPaint()" and "draw()")
951cdf0e10cSrcweir // - not used in this implementation, but its not necessary to make it pure virtual !!!
952cdf0e10cSrcweir }
953cdf0e10cSrcweir
954cdf0e10cSrcweir //____________________________________________________________________________________________________________
955cdf0e10cSrcweir // protected method
956cdf0e10cSrcweir //____________________________________________________________________________________________________________
957cdf0e10cSrcweir
impl_recalcLayout(const WindowEvent &)958cdf0e10cSrcweir void BaseControl::impl_recalcLayout( const WindowEvent& /*aEvent*/ )
959cdf0e10cSrcweir {
960cdf0e10cSrcweir // We need as virtual function to support automaticly resizing of derived controls!
961cdf0e10cSrcweir // But we make it not pure virtual because it's not neccessary for all derived classes!
962cdf0e10cSrcweir }
963cdf0e10cSrcweir
964cdf0e10cSrcweir //____________________________________________________________________________________________________________
965cdf0e10cSrcweir // protected method
966cdf0e10cSrcweir //____________________________________________________________________________________________________________
967cdf0e10cSrcweir
impl_getDelegator()968cdf0e10cSrcweir Reference< XInterface > BaseControl::impl_getDelegator()
969cdf0e10cSrcweir {
970cdf0e10cSrcweir return m_xDelegator ;
971cdf0e10cSrcweir }
972cdf0e10cSrcweir
973cdf0e10cSrcweir //____________________________________________________________________________________________________________
974cdf0e10cSrcweir // private method
975cdf0e10cSrcweir //____________________________________________________________________________________________________________
976cdf0e10cSrcweir
impl_releasePeer()977cdf0e10cSrcweir void BaseControl::impl_releasePeer()
978cdf0e10cSrcweir {
979cdf0e10cSrcweir if ( m_xPeer.is() == sal_True )
980cdf0e10cSrcweir {
981cdf0e10cSrcweir if ( m_xGraphicsPeer.is() == sal_True )
982cdf0e10cSrcweir {
983cdf0e10cSrcweir removePaintListener( this );
984cdf0e10cSrcweir removeWindowListener( this );
985cdf0e10cSrcweir m_xGraphicsPeer = Reference< XGraphics >();
986cdf0e10cSrcweir }
987cdf0e10cSrcweir
988cdf0e10cSrcweir m_xPeer->dispose();
989cdf0e10cSrcweir m_xPeerWindow = Reference< XWindow >();
990cdf0e10cSrcweir m_xPeer = Reference< XWindowPeer >();
991cdf0e10cSrcweir
992cdf0e10cSrcweir if ( m_pMultiplexer != NULL )
993cdf0e10cSrcweir {
994cdf0e10cSrcweir // take changes on multiplexer
995cdf0e10cSrcweir m_pMultiplexer->setPeer( Reference< XWindow >() );
996cdf0e10cSrcweir }
997cdf0e10cSrcweir }
998cdf0e10cSrcweir }
999cdf0e10cSrcweir
1000cdf0e10cSrcweir //____________________________________________________________________________________________________________
1001cdf0e10cSrcweir // private method
1002cdf0e10cSrcweir //____________________________________________________________________________________________________________
1003cdf0e10cSrcweir
impl_getMultiplexer()1004cdf0e10cSrcweir OMRCListenerMultiplexerHelper* BaseControl::impl_getMultiplexer()
1005cdf0e10cSrcweir {
1006cdf0e10cSrcweir if ( m_pMultiplexer == NULL )
1007cdf0e10cSrcweir {
1008cdf0e10cSrcweir m_pMultiplexer = new OMRCListenerMultiplexerHelper( (XWindow*)this, m_xPeerWindow );
1009cdf0e10cSrcweir m_xMultiplexer = Reference< XInterface >( (OWeakObject*)m_pMultiplexer, UNO_QUERY );
1010cdf0e10cSrcweir }
1011cdf0e10cSrcweir
1012cdf0e10cSrcweir return m_pMultiplexer ;
1013cdf0e10cSrcweir }
1014cdf0e10cSrcweir
1015cdf0e10cSrcweir } // namespace unocontrols
1016