1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include <boost/ptr_container/ptr_vector.hpp>
32 #include <com/sun/star/beans/PropertyAttribute.hpp>
39 #include <com/sun/star/awt/ImageScaleMode.hpp>
40 #include <com/sun/star/awt/WindowAttribute.hpp>
41 #include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
42 #include <com/sun/star/awt/WindowClass.hpp>
43 #include <com/sun/star/awt/MessageBoxButtons.hpp>
44 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
45 #include <com/sun/star/lang/SystemDependent.hpp>
46 #include <com/sun/star/awt/FocusEvent.hpp>
47 #include <com/sun/star/awt/KeyEvent.hpp>
48 #include <com/sun/star/awt/KeyModifier.hpp>
49 #include <com/sun/star/lang/EventObject.hpp>
50 #include <com/sun/star/uno/Reference.hxx>
51 #include <com/sun/star/uno/Sequence.hxx>
52 #include <com/sun/star/uno/XInterface.hpp>
53 #include <com/sun/star/beans/NamedValue.hpp>
54 #include <cppuhelper/typeprovider.hxx>
55 #include <osl/conditn.hxx>
56 #include <rtl/memory.h>
58 #include <rtl/process.h>
62 #include <Cocoa/Cocoa.h>
68 #include <UIKit/UIKit.h>
72 #include <vcl/sysdata.hxx>
74 #include <toolkit/awt/vclxwindows.hxx>
75 #include <toolkit/awt/vclxsystemdependentwindow.hxx>
76 #include <toolkit/awt/vclxregion.hxx>
77 #include <toolkit/awt/vclxtoolkit.hxx>
78 #include <toolkit/awt/vclxtabpagecontainer.hxx>
79 #include <toolkit/awt/vclxtabpagemodel.hxx>
81 #include <toolkit/awt/xsimpleanimation.hxx>
82 #include <toolkit/awt/xthrobber.hxx>
83 #include <toolkit/awt/animatedimagespeer.hxx>
84 #include <toolkit/awt/vclxtopwindow.hxx>
85 #include <toolkit/awt/vclxwindow.hxx>
86 #include <toolkit/helper/vclunohelper.hxx>
87 #include <toolkit/helper/unowrapper.hxx>
88 #include <toolkit/helper/servicenames.hxx>
90 #include <toolkit/helper/macros.hxx>
91 #include <toolkit/helper/convert.hxx>
92 #include <vcl/unohelp.hxx>
93 #include <vcl/btndlg.hxx>
94 #include <vcl/button.hxx>
95 #include <vcl/combobox.hxx>
96 #include <vcl/ctrl.hxx>
97 #include <vcl/dialog.hxx>
98 #include <vcl/dockingarea.hxx>
99 #include <vcl/dockwin.hxx>
100 #include <vcl/edit.hxx>
101 #include <vcl/field.hxx>
102 #include <vcl/fixed.hxx>
103 #include <vcl/floatwin.hxx>
104 #include <vcl/group.hxx>
105 #include <vcl/imgctrl.hxx>
106 #include <vcl/longcurr.hxx>
107 #include <vcl/lstbox.hxx>
108 #include <vcl/menubtn.hxx>
109 #include <vcl/morebtn.hxx>
110 #include <vcl/msgbox.hxx>
111 #include <vcl/scrbar.hxx>
112 #include <vcl/spin.hxx>
113 #include <vcl/split.hxx>
114 #include <vcl/splitwin.hxx>
115 #include <vcl/status.hxx>
116 #include <vcl/svapp.hxx>
117 #include <vcl/syschild.hxx>
118 #include <vcl/tabctrl.hxx>
119 #include <vcl/tabdlg.hxx>
120 #include <vcl/tabpage.hxx>
121 #include <vcl/toolbox.hxx>
122 #include <vcl/virdev.hxx>
123 #include <vcl/window.hxx>
124 #include <vcl/wrkwin.hxx>
125 #include <vcl/throbber.hxx>
126 #include "toolkit/awt/vclxspinbutton.hxx"
128 #include <tools/debug.hxx>
129 #include <comphelper/processfactory.hxx>
131 namespace css
= ::com::sun::star
;
133 #define VCLWINDOW_FRAMEWINDOW 0x1000
134 #define VCLWINDOW_SYSTEMCHILDWINDOW 0x1001
137 #define SYSTEM_DEPENDENT_TYPE ::com::sun::star::lang::SystemDependent::SYSTEM_WIN32
138 #elif (defined QUARTZ)
139 #define SYSTEM_DEPENDENT_TYPE ::com::sun::star::lang::SystemDependent::SYSTEM_MAC
141 #define SYSTEM_DEPENDENT_TYPE ::com::sun::star::lang::SystemDependent::SYSTEM_XWINDOW
144 TOOLKIT_DLLPUBLIC WinBits
ImplGetWinBits( sal_uInt32 nComponentAttribs
, sal_uInt16 nCompType
)
146 WinBits nWinBits
= 0;
148 sal_Bool bMessBox
= sal_False
;
149 if ( ( nCompType
== WINDOW_INFOBOX
) ||
150 ( nCompType
== WINDOW_MESSBOX
) ||
151 ( nCompType
== WINDOW_QUERYBOX
) ||
152 ( nCompType
== WINDOW_WARNINGBOX
) ||
153 ( nCompType
== WINDOW_ERRORBOX
) )
158 bool bDecoratedWindow
= false;
160 || ( nCompType
== WINDOW_DIALOG
)
161 || ( nCompType
== WINDOW_MODELESSDIALOG
)
162 || ( nCompType
== WINDOW_MODALDIALOG
)
163 || ( nCompType
== WINDOW_SYSTEMDIALOG
)
164 || ( nCompType
== WINDOW_PATHDIALOG
)
165 || ( nCompType
== WINDOW_FILEDIALOG
)
166 || ( nCompType
== WINDOW_PRINTERSETUPDIALOG
)
167 || ( nCompType
== WINDOW_PRINTDIALOG
)
168 || ( nCompType
== WINDOW_COLORDIALOG
)
169 || ( nCompType
== WINDOW_FONTDIALOG
)
170 || ( nCompType
== WINDOW_DOCKINGWINDOW
)
171 || ( nCompType
== WINDOW_TABDIALOG
)
172 || ( nCompType
== WINDOW_BUTTONDIALOG
)
173 || ( nCompType
== WINDOW_SYSTEMCHILDWINDOW
)
176 bDecoratedWindow
= true;
179 if( nComponentAttribs
& ::com::sun::star::awt::WindowAttribute::BORDER
)
180 nWinBits
|= WB_BORDER
;
181 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::NOBORDER
)
182 nWinBits
|= WB_NOBORDER
;
183 if( nComponentAttribs
& ::com::sun::star::awt::WindowAttribute::SIZEABLE
)
184 nWinBits
|= WB_SIZEABLE
;
185 if( nComponentAttribs
& ::com::sun::star::awt::WindowAttribute::MOVEABLE
)
186 nWinBits
|= WB_MOVEABLE
;
187 if( nComponentAttribs
& ::com::sun::star::awt::WindowAttribute::CLOSEABLE
)
188 nWinBits
|= WB_CLOSEABLE
;
189 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::HSCROLL
)
190 nWinBits
|= WB_HSCROLL
;
191 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::VSCROLL
)
192 nWinBits
|= WB_VSCROLL
;
193 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::LEFT
)
195 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::CENTER
)
196 nWinBits
|= WB_CENTER
;
197 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::RIGHT
)
198 nWinBits
|= WB_RIGHT
;
199 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::SPIN
)
201 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::SORT
)
203 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::DROPDOWN
)
204 nWinBits
|= WB_DROPDOWN
;
205 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::DEFBUTTON
)
206 nWinBits
|= WB_DEFBUTTON
;
207 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::READONLY
)
208 nWinBits
|= WB_READONLY
;
209 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::CLIPCHILDREN
)
210 nWinBits
|= WB_CLIPCHILDREN
;
211 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::GROUP
)
212 nWinBits
|= WB_GROUP
;
213 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::NOLABEL
) //added for issue79712
214 nWinBits
|= WB_NOLABEL
;
216 // These bits are not uniqe
219 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::OK
)
221 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::OK_CANCEL
)
222 nWinBits
|= WB_OK_CANCEL
;
223 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::YES_NO
)
224 nWinBits
|= WB_YES_NO
;
225 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::YES_NO_CANCEL
)
226 nWinBits
|= WB_YES_NO_CANCEL
;
227 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::RETRY_CANCEL
)
228 nWinBits
|= WB_RETRY_CANCEL
;
229 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::DEF_OK
)
230 nWinBits
|= WB_DEF_OK
;
231 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::DEF_CANCEL
)
232 nWinBits
|= WB_DEF_CANCEL
;
233 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::DEF_RETRY
)
234 nWinBits
|= WB_DEF_RETRY
;
235 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::DEF_YES
)
236 nWinBits
|= WB_DEF_YES
;
237 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::DEF_NO
)
238 nWinBits
|= WB_DEF_NO
;
240 if ( nCompType
== WINDOW_MULTILINEEDIT
)
242 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::AUTOHSCROLL
)
243 nWinBits
|= WB_AUTOHSCROLL
;
244 if( nComponentAttribs
& ::com::sun::star::awt::VclWindowPeerAttribute::AUTOVSCROLL
)
245 nWinBits
|= WB_AUTOVSCROLL
;
249 if ( bDecoratedWindow
)
251 if( nComponentAttribs
& ::com::sun::star::awt::WindowAttribute::NODECORATION
)
253 // No decoration removes several window attributes and must
255 nWinBits
&= ~WB_BORDER
;
256 nWinBits
&= ~WB_SIZEABLE
;
257 nWinBits
&= ~WB_MOVEABLE
;
258 nWinBits
&= ~WB_CLOSEABLE
;
259 nWinBits
|= WB_NOBORDER
;
272 static ComponentInfo aComponentInfos
[] =
274 { "buttondialog", WINDOW_BUTTONDIALOG
},
275 { "cancelbutton", WINDOW_CANCELBUTTON
},
276 { "checkbox", WINDOW_CHECKBOX
},
277 { "combobox", WINDOW_COMBOBOX
},
278 { "control", WINDOW_CONTROL
},
279 { "currencybox", WINDOW_CURRENCYBOX
},
280 { "currencyfield", WINDOW_CURRENCYFIELD
},
281 { "datebox", WINDOW_DATEBOX
},
282 { "datefield", WINDOW_DATEFIELD
},
283 { "dialog", WINDOW_DIALOG
},
284 { "dockingarea", WINDOW_DOCKINGAREA
},
285 { "dockingwindow", WINDOW_DOCKINGWINDOW
},
286 { "edit", WINDOW_EDIT
},
287 { "errorbox", WINDOW_ERRORBOX
},
288 { "fixedbitmap", WINDOW_FIXEDBITMAP
},
289 { "fixedimage", WINDOW_FIXEDIMAGE
},
290 { "fixedline", WINDOW_FIXEDLINE
},
291 { "fixedtext", WINDOW_FIXEDTEXT
},
292 { "floatingwindow", WINDOW_FLOATINGWINDOW
},
293 { "framewindow", VCLWINDOW_FRAMEWINDOW
},
294 { "groupbox", WINDOW_GROUPBOX
},
295 { "frame", WINDOW_GROUPBOX
},
296 { "helpbutton", WINDOW_HELPBUTTON
},
297 { "imagebutton", WINDOW_IMAGEBUTTON
},
298 { "imageradiobutton", WINDOW_IMAGERADIOBUTTON
},
299 { "infobox", WINDOW_INFOBOX
},
300 { "listbox", WINDOW_LISTBOX
},
301 { "longcurrencybox", WINDOW_LONGCURRENCYBOX
},
302 { "longcurrencyfield", WINDOW_LONGCURRENCYFIELD
},
303 { "menubutton", WINDOW_MENUBUTTON
},
304 { "messbox", WINDOW_MESSBOX
},
305 { "metricbox", WINDOW_METRICBOX
},
306 { "metricfield", WINDOW_METRICFIELD
},
307 { "modaldialog", WINDOW_MODALDIALOG
},
308 { "modelessdialog", WINDOW_MODELESSDIALOG
},
309 { "morebutton", WINDOW_MOREBUTTON
},
310 { "multilineedit", WINDOW_MULTILINEEDIT
},
311 { "multilistbox", WINDOW_MULTILISTBOX
},
312 { "numericbox", WINDOW_NUMERICBOX
},
313 { "numericfield", WINDOW_NUMERICFIELD
},
314 { "okbutton", WINDOW_OKBUTTON
},
315 { "patternbox", WINDOW_PATTERNBOX
},
316 { "patternfield", WINDOW_PATTERNFIELD
},
317 { "pushbutton", WINDOW_PUSHBUTTON
},
318 { "querybox", WINDOW_QUERYBOX
},
319 { "radiobutton", WINDOW_RADIOBUTTON
},
320 { "scrollbar", WINDOW_SCROLLBAR
},
321 { "scrollbarbox", WINDOW_SCROLLBARBOX
},
322 { "simpleanimation", WINDOW_CONTROL
},
323 { "animatedimages", WINDOW_CONTROL
},
324 { "spinbutton", WINDOW_SPINBUTTON
},
325 { "spinfield", WINDOW_SPINFIELD
},
326 { "throbber", WINDOW_CONTROL
},
327 { "splitter", WINDOW_SPLITTER
},
328 { "splitwindow", WINDOW_SPLITWINDOW
},
329 { "statusbar", WINDOW_STATUSBAR
},
330 { "systemchildwindow", VCLWINDOW_SYSTEMCHILDWINDOW
},
331 { "tabcontrol", WINDOW_TABCONTROL
},
332 { "tabdialog", WINDOW_TABDIALOG
},
333 { "tabpage", WINDOW_TABPAGE
},
334 { "timebox", WINDOW_TIMEBOX
},
335 { "timefield", WINDOW_TIMEFIELD
},
336 { "toolbox", WINDOW_TOOLBOX
},
337 { "tristatebox", WINDOW_TRISTATEBOX
},
338 { "warningbox", WINDOW_WARNINGBOX
},
339 { "window", WINDOW_WINDOW
},
340 { "workwindow", WINDOW_WORKWINDOW
},
341 { "tabpagecontainer", WINDOW_CONTROL
},
342 { "tabpagemodel", WINDOW_TABPAGE
}
347 static int SAL_CALL
ComponentInfoCompare( const void* pFirst
, const void* pSecond
)
349 return( strcmp( ((ComponentInfo
*)pFirst
)->pName
,
350 ((ComponentInfo
*)pSecond
)->pName
) );
354 sal_uInt16
ImplGetComponentType( const String
& rServiceName
)
356 static sal_Bool bSorted
= sal_False
;
359 qsort( (void*) aComponentInfos
,
360 sizeof( aComponentInfos
) / sizeof( ComponentInfo
),
361 sizeof( ComponentInfo
),
362 ComponentInfoCompare
);
367 ComponentInfo aSearch
;
368 rtl::OString
aServiceName(rtl::OUStringToOString(rServiceName
, osl_getThreadTextEncoding()).toAsciiLowerCase());
369 if ( !aServiceName
.isEmpty() )
370 aSearch
.pName
= aServiceName
.getStr();
372 aSearch
.pName
= "window";
374 ComponentInfo
* pInf
= (ComponentInfo
*) bsearch( &aSearch
,
375 (void*) aComponentInfos
,
376 sizeof( aComponentInfos
) / sizeof( ComponentInfo
),
377 sizeof( ComponentInfo
),
378 ComponentInfoCompare
);
380 return pInf
? pInf
->nWinType
: 0;
384 // ----------------------------------------------------
386 // ----------------------------------------------------
388 static sal_Int32 nVCLToolkitInstanceCount
= 0;
389 static sal_Bool bInitedByVCLToolkit
= sal_False
;
390 //static cppu::OInterfaceContainerHelper * pToolkits = 0;
392 static osl::Mutex
& getInitMutex()
394 static osl::Mutex
* pM
;
397 osl::Guard
< osl::Mutex
> aGuard( osl::Mutex::getGlobalMutex() );
400 static osl::Mutex aMutex
;
407 static osl::Condition
& getInitCondition()
409 static osl::Condition
* pC
= 0;
412 osl::Guard
< osl::Mutex
> aGuard( osl::Mutex::getGlobalMutex() );
415 static osl::Condition aCondition
;
422 struct ToolkitThreadData
425 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> xSMgr
;
427 ToolkitThreadData( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> & rSMgr
, VCLXToolkit
* pTk_
)
436 static void SAL_CALL
ToolkitWorkerFunction( void* pArgs
)
438 ToolkitThreadData
* pTTD
= (ToolkitThreadData
*)pArgs
;
439 bInitedByVCLToolkit
= InitVCL( pTTD
->xSMgr
);
440 if( bInitedByVCLToolkit
)
442 UnoWrapper
* pUnoWrapper
= new UnoWrapper( pTTD
->pTk
);
443 Application::SetUnoWrapper( pUnoWrapper
);
445 getInitCondition().set();
446 if( bInitedByVCLToolkit
)
449 SolarMutexGuard aGuard
;
450 Application::Execute();
454 pTTD
->pTk
->dispose();
456 catch( com::sun::star::uno::Exception
& )
462 cppu::OInterfaceIteratorHelper aIt( *pToolkits );
463 ::com::sun::star::uno::XInterface * pI;
464 while( pI = aIt.next() )
465 ((::com::sun::star::lang::XComponent *)pI)->dispose();
467 // delete toolkit container
468 osl::Guard< osl::Mutex > aGuard( getInitMutex() );
477 JoinMainLoopThread();
483 // contructor, which might initialize VCL
484 VCLXToolkit::VCLXToolkit( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> & rSMgr
):
485 cppu::WeakComponentImplHelper7
<
486 ::com::sun::star::awt::XToolkit
,
487 ::com::sun::star::lang::XServiceInfo
,
488 ::com::sun::star::awt::XSystemChildFactory
,
489 ::com::sun::star::awt::XMessageBoxFactory
,
490 ::com::sun::star::awt::XDataTransferProviderAccess
,
491 ::com::sun::star::awt::XExtendedToolkit
,
492 ::com::sun::star::awt::XReschedule
>( GetMutex() ),
493 m_aTopWindowListeners(rBHelper
.rMutex
),
494 m_aKeyHandlers(rBHelper
.rMutex
),
495 m_aFocusListeners(rBHelper
.rMutex
),
496 m_aEventListenerLink(LINK(this, VCLXToolkit
, eventListenerHandler
)),
497 m_aKeyListenerLink(LINK(this, VCLXToolkit
, keyListenerHandler
)),
498 m_bEventListener(false),
499 m_bKeyListener(false)
502 fnSvtCreateWindow
= NULL
;
504 osl::Guard
< osl::Mutex
> aGuard( getInitMutex() );
505 nVCLToolkitInstanceCount
++;
506 if( ( nVCLToolkitInstanceCount
== 1 ) && ( !Application::IsInMain() ) )
508 // setup execute thread
509 CreateMainLoopThread( ToolkitWorkerFunction
, new ToolkitThreadData( rSMgr
, this ) );
510 getInitCondition().wait();
512 if( bInitedByVCLToolkit )
514 // insert in disposing list
516 pToolkits = new cppu::OInterfaceContainerHelper( getInitMutex() );
517 pToolkits->addInterface( (::com::sun::star::lang::XComponent *)this );
523 VCLXToolkit::~VCLXToolkit()
528 void SAL_CALL
VCLXToolkit::disposing()
532 osl_unloadModule( hSvToolsLib
);
534 fnSvtCreateWindow
= NULL
;
538 osl::Guard
< osl::Mutex
> aGuard( getInitMutex() );
539 if( --nVCLToolkitInstanceCount
== 0 )
541 if( bInitedByVCLToolkit
)
544 JoinMainLoopThread();
545 bInitedByVCLToolkit
= sal_False
;
550 if (m_bEventListener
)
552 ::Application::RemoveEventListener(m_aEventListenerLink
);
553 m_bEventListener
= false;
557 ::Application::RemoveKeyListener(m_aKeyListenerLink
);
558 m_bKeyListener
= false;
560 ::css::lang::EventObject
aEvent(
561 static_cast< ::cppu::OWeakObject
* >(this));
562 m_aTopWindowListeners
.disposeAndClear(aEvent
);
563 m_aKeyHandlers
.disposeAndClear(aEvent
);
564 m_aFocusListeners
.disposeAndClear(aEvent
);
567 osl::Guard< osl::Mutex > aGuard( getInitMutex() );
568 // insert in disposing list
571 // remove from the disposing list
572 pToolkits->removeInterface( (::com::sun::star::lang::XComponent *)this );
578 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowPeer
> VCLXToolkit::getDesktopWindow( ) throw(::com::sun::star::uno::RuntimeException
)
580 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowPeer
> xRef
;
581 // 07/00: AppWindow doesn't exist anymore...
585 ::com::sun::star::awt::Rectangle
VCLXToolkit::getWorkArea( ) throw(::com::sun::star::uno::RuntimeException
)
587 ::com::sun::star::awt::Rectangle aRect
;
588 // 07/00: AppWindow doesn't exist anymore...
592 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowPeer
> VCLXToolkit::createWindow( const ::com::sun::star::awt::WindowDescriptor
& rDescriptor
) throw(::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
)
594 return ImplCreateWindow( rDescriptor
, WinBits(0) );
597 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XDevice
> VCLXToolkit::createScreenCompatibleDevice( sal_Int32 Width
, sal_Int32 Height
) throw(::com::sun::star::uno::RuntimeException
)
599 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
601 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XDevice
> xRef
;
602 VCLXVirtualDevice
* pVDev
= new VCLXVirtualDevice
;
604 SolarMutexGuard aSolarGuard
;
606 VirtualDevice
* pV
= new VirtualDevice
;
607 pV
->SetOutputSizePixel( Size( Width
, Height
) );
608 pVDev
->SetVirtualDevice( pV
);
614 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XRegion
> VCLXToolkit::createRegion( ) throw(::com::sun::star::uno::RuntimeException
)
616 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
618 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XRegion
> xRef
= new VCLXRegion
;
622 Window
* VCLXToolkit::ImplCreateWindow( VCLXWindow
** ppNewComp
,
623 const ::com::sun::star::awt::WindowDescriptor
& rDescriptor
,
624 Window
* pParent
, WinBits nWinBits
)
626 String
aServiceName( rDescriptor
.WindowServiceName
);
627 aServiceName
.ToLowerAscii();
629 Window
* pNewWindow
= NULL
;
630 sal_uInt16 nType
= ImplGetComponentType( aServiceName
);
631 bool bFrameControl
= false;
632 if ( aServiceName
== String( RTL_CONSTASCII_USTRINGPARAM("frame") ) )
633 bFrameControl
= true;
634 if ( aServiceName
== String( RTL_CONSTASCII_USTRINGPARAM("tabcontrolnotabs") ) )
636 nWinBits
|= WB_NOBORDER
;
637 nType
= ImplGetComponentType( String( RTL_CONSTASCII_USTRINGPARAM("tabcontrol") ) );
641 // Wenn die Component einen Parent braucht, dann NULL zurueckgeben,
642 // spaeter mal ::com::sun::star::uno::Exception...
643 sal_Bool bException
= sal_True
;
644 if ( ( nType
== WINDOW_DIALOG
)
645 || ( nType
== WINDOW_MODALDIALOG
)
646 || ( nType
== WINDOW_MODELESSDIALOG
)
647 || ( nType
== WINDOW_MESSBOX
)
648 || ( nType
== WINDOW_INFOBOX
)
649 || ( nType
== WINDOW_WARNINGBOX
)
650 || ( nType
== WINDOW_ERRORBOX
)
651 || ( nType
== WINDOW_QUERYBOX
)
653 bException
= sal_False
;
654 else if ( ( nType
== WINDOW_WINDOW
) ||
655 ( nType
== WINDOW_WORKWINDOW
) ||
656 ( nType
== VCLWINDOW_FRAMEWINDOW
) )
658 if ( rDescriptor
.Type
== ::com::sun::star::awt::WindowClass_TOP
)
659 bException
= sal_False
;
671 SolarMutexGuard aVclGuard
;
672 switch ( (WindowType
)nType
)
674 case WINDOW_CANCELBUTTON
:
675 pNewWindow
= new CancelButton( pParent
, nWinBits
);
676 *ppNewComp
= new VCLXButton
;
678 case WINDOW_CHECKBOX
:
679 pNewWindow
= new CheckBox( pParent
, nWinBits
);
680 *ppNewComp
= new VCLXCheckBox
;
682 case WINDOW_COMBOBOX
:
683 pNewWindow
= new ComboBox( pParent
, nWinBits
|WB_AUTOHSCROLL
);
684 ((ComboBox
*)pNewWindow
)->EnableAutoSize( sal_False
);
685 *ppNewComp
= new VCLXComboBox
;
687 case WINDOW_CURRENCYBOX
:
688 pNewWindow
= new CurrencyBox( pParent
, nWinBits
);
690 case WINDOW_CURRENCYFIELD
:
691 pNewWindow
= new CurrencyField( pParent
, nWinBits
);
692 static_cast<CurrencyField
*>(pNewWindow
)->EnableEmptyFieldValue( sal_True
);
693 *ppNewComp
= new VCLXNumericField
;
694 ((VCLXFormattedSpinField
*)*ppNewComp
)->SetFormatter( (FormatterBase
*)(CurrencyField
*)pNewWindow
);
697 pNewWindow
= new DateBox( pParent
, nWinBits
);
699 case WINDOW_DATEFIELD
:
700 pNewWindow
= new DateField( pParent
, nWinBits
);
701 static_cast<DateField
*>(pNewWindow
)->EnableEmptyFieldValue( sal_True
);
702 *ppNewComp
= new VCLXDateField
;
703 ((VCLXFormattedSpinField
*)*ppNewComp
)->SetFormatter( (FormatterBase
*)(DateField
*)pNewWindow
);
705 case WINDOW_DOCKINGAREA
:
706 pNewWindow
= new DockingAreaWindow( pParent
);
708 case WINDOW_MULTILINEEDIT
:
710 pNewWindow
= new Edit( pParent
, nWinBits
);
711 *ppNewComp
= new VCLXEdit
;
713 case WINDOW_ERRORBOX
:
714 pNewWindow
= new ErrorBox( pParent
, nWinBits
, String() );
715 *ppNewComp
= new VCLXMessageBox
;
717 case WINDOW_FIXEDBITMAP
:
718 pNewWindow
= new FixedBitmap( pParent
, nWinBits
);
720 case WINDOW_FIXEDIMAGE
:
721 pNewWindow
= new ImageControl( pParent
, nWinBits
);
722 *ppNewComp
= new VCLXImageControl
;
724 case WINDOW_FIXEDLINE
:
725 pNewWindow
= new FixedLine( pParent
, nWinBits
);
727 case WINDOW_FIXEDTEXT
:
728 pNewWindow
= new FixedText( pParent
, nWinBits
);
729 *ppNewComp
= new VCLXFixedText
;
731 case WINDOW_FLOATINGWINDOW
:
732 pNewWindow
= new FloatingWindow( pParent
, nWinBits
);
734 case WINDOW_GROUPBOX
:
736 pNewWindow
= new GroupBox( pParent
, nWinBits
);
739 GroupBox
* pGroupBox
= static_cast< GroupBox
* >( pNewWindow
);
740 *ppNewComp
= new VCLXFrame
;
741 // Frame control needs to recieve
743 pGroupBox
->SetMouseTransparent( sal_False
);
747 case WINDOW_HELPBUTTON
:
748 pNewWindow
= new HelpButton( pParent
, nWinBits
);
749 *ppNewComp
= new VCLXButton
;
751 case WINDOW_IMAGEBUTTON
:
752 pNewWindow
= new ImageButton( pParent
, nWinBits
);
753 *ppNewComp
= new VCLXButton
;
755 case WINDOW_IMAGERADIOBUTTON
:
756 pNewWindow
= new ImageRadioButton( pParent
, nWinBits
);
757 *ppNewComp
= new VCLXButton
;
760 pNewWindow
= new InfoBox( pParent
, String() );
761 *ppNewComp
= new VCLXMessageBox
;
764 pNewWindow
= new ListBox( pParent
, nWinBits
|WB_SIMPLEMODE
|WB_AUTOHSCROLL
);
765 ((ListBox
*)pNewWindow
)->EnableAutoSize( sal_False
);
766 *ppNewComp
= new VCLXListBox
;
768 case WINDOW_LONGCURRENCYBOX
:
769 pNewWindow
= new LongCurrencyBox( pParent
, nWinBits
);
771 case WINDOW_LONGCURRENCYFIELD
:
772 pNewWindow
= new LongCurrencyField( pParent
, nWinBits
);
773 *ppNewComp
= new VCLXCurrencyField
;
774 ((VCLXFormattedSpinField
*)*ppNewComp
)->SetFormatter( (FormatterBase
*)(LongCurrencyField
*)pNewWindow
);
776 case WINDOW_MENUBUTTON
:
777 pNewWindow
= new MenuButton( pParent
, nWinBits
);
778 *ppNewComp
= new VCLXButton
;
781 pNewWindow
= new MessBox( pParent
, nWinBits
, String(), String() );
782 *ppNewComp
= new VCLXMessageBox
;
784 case WINDOW_METRICBOX
:
785 pNewWindow
= new MetricBox( pParent
, nWinBits
);
787 case WINDOW_METRICFIELD
:
788 pNewWindow
= new MetricField( pParent
, nWinBits
);
789 *ppNewComp
= new VCLXMetricField
;
790 ((VCLXFormattedSpinField
*)*ppNewComp
)->SetFormatter( (FormatterBase
*)(MetricField
*)pNewWindow
);
793 case WINDOW_MODALDIALOG
:
794 case WINDOW_MODELESSDIALOG
:
796 // Modal/Modeless nur durch Show/Execute
797 if ( (pParent
== NULL
) && ( rDescriptor
.ParentIndex
== -1 ) )
798 pParent
= DIALOG_NO_PARENT
;
799 pNewWindow
= new Dialog( pParent
, nWinBits
);
800 // #i70217# Don't always create a new component object. It's possible that VCL has called
801 // GetComponentInterface( sal_True ) in the Dialog ctor itself (see Window::IsTopWindow() )
802 // which creates a component object.
803 css::uno::Reference
< css::awt::XWindowPeer
> xWinPeer
= pNewWindow
->GetComponentInterface( sal_False
);
805 *ppNewComp
= dynamic_cast< VCLXDialog
* >( xWinPeer
.get() );
807 *ppNewComp
= new VCLXDialog
;
810 case WINDOW_MOREBUTTON
:
811 pNewWindow
= new MoreButton( pParent
, nWinBits
);
812 *ppNewComp
= new VCLXButton
;
814 case WINDOW_MULTILISTBOX
:
815 pNewWindow
= new MultiListBox( pParent
, nWinBits
);
816 *ppNewComp
= new VCLXListBox
;
818 case WINDOW_NUMERICBOX
:
819 pNewWindow
= new NumericBox( pParent
, nWinBits
);
821 case WINDOW_NUMERICFIELD
:
822 pNewWindow
= new NumericField( pParent
, nWinBits
);
823 static_cast<NumericField
*>(pNewWindow
)->EnableEmptyFieldValue( sal_True
);
824 *ppNewComp
= new VCLXNumericField
;
825 ((VCLXFormattedSpinField
*)*ppNewComp
)->SetFormatter( (FormatterBase
*)(NumericField
*)pNewWindow
);
827 case WINDOW_OKBUTTON
:
828 pNewWindow
= new OKButton( pParent
, nWinBits
);
829 *ppNewComp
= new VCLXButton
;
831 case WINDOW_PATTERNBOX
:
832 pNewWindow
= new PatternBox( pParent
, nWinBits
);
834 case WINDOW_PATTERNFIELD
:
835 pNewWindow
= new PatternField( pParent
, nWinBits
);
836 *ppNewComp
= new VCLXPatternField
;
837 ((VCLXFormattedSpinField
*)*ppNewComp
)->SetFormatter( (FormatterBase
*)(PatternField
*)pNewWindow
);
839 case WINDOW_PUSHBUTTON
:
840 pNewWindow
= new PushButton( pParent
, nWinBits
);
841 *ppNewComp
= new VCLXButton
;
843 case WINDOW_QUERYBOX
:
844 pNewWindow
= new QueryBox( pParent
, nWinBits
, String() );
845 *ppNewComp
= new VCLXMessageBox
;
847 case WINDOW_RADIOBUTTON
:
848 pNewWindow
= new RadioButton( pParent
, nWinBits
);
849 *ppNewComp
= new VCLXRadioButton
;
851 // by default, disable RadioCheck
852 // Since the VCLXRadioButton really cares for it's RadioCheck settings, this is important:
853 // if we enable it, the VCLXRadioButton will use RadioButton::Check instead of RadioButton::SetState
854 // This leads to a strange behaviour if the control is newly created: when settings the initial
855 // state to "checked", the RadioButton::Check (called because RadioCheck=sal_True) will uncheck
856 // _all_other_ radio buttons in the same group. However, at this moment the grouping of the controls
857 // is not really valid: the controls are grouped after they have been created, but we're still in
858 // the creation process, so the RadioButton::Check relies on invalid grouping information.
859 // 07.08.2001 - #87254# - frank.schoenheit@sun.com
860 static_cast<RadioButton
*>(pNewWindow
)->EnableRadioCheck( sal_False
);
862 case WINDOW_SCROLLBAR
:
863 pNewWindow
= new ScrollBar( pParent
, nWinBits
);
864 *ppNewComp
= new VCLXScrollBar
;
866 case WINDOW_SCROLLBARBOX
:
867 pNewWindow
= new ScrollBarBox( pParent
, nWinBits
);
869 case WINDOW_SPINBUTTON
:
870 pNewWindow
= new SpinButton( pParent
, nWinBits
);
871 *ppNewComp
= new ::toolkit::VCLXSpinButton
;
873 case WINDOW_SPINFIELD
:
874 pNewWindow
= new SpinField( pParent
, nWinBits
);
875 *ppNewComp
= new VCLXNumericField
;
877 case WINDOW_SPLITTER
:
878 pNewWindow
= new Splitter( pParent
, nWinBits
);
880 case WINDOW_SPLITWINDOW
:
881 pNewWindow
= new SplitWindow( pParent
, nWinBits
);
883 case WINDOW_STATUSBAR
:
884 pNewWindow
= new StatusBar( pParent
, nWinBits
);
886 case VCLWINDOW_SYSTEMCHILDWINDOW
:
887 pNewWindow
= new SystemChildWindow( pParent
, nWinBits
);
888 *ppNewComp
= new VCLXSystemDependentWindow();
890 case WINDOW_TABCONTROL
:
891 pNewWindow
= new TabControl( pParent
, nWinBits
);
892 *ppNewComp
= new VCLXMultiPage
;
894 case WINDOW_TABDIALOG
:
895 pNewWindow
= new TabDialog( pParent
, nWinBits
);
899 if ( rDescriptor.WindowServiceName.equalsIgnoreAsciiCaseAsciiL(
900 RTL_CONSTASCII_STRINGPARAM("tabpagemodel") ) )
902 pNewWindow = new TabControl( pParent, nWinBits );
903 *ppNewComp = new VCLXTabPageContainer;
908 pNewWindow
= new TabPage( pParent
, nWinBits
);
909 *ppNewComp
= new VCLXTabPage
;
913 pNewWindow
= new TimeBox( pParent
, nWinBits
);
915 case WINDOW_TIMEFIELD
:
916 pNewWindow
= new TimeField( pParent
, nWinBits
);
917 static_cast<TimeField
*>(pNewWindow
)->EnableEmptyFieldValue( sal_True
);
918 *ppNewComp
= new VCLXTimeField
;
919 ((VCLXFormattedSpinField
*)*ppNewComp
)->SetFormatter( (FormatterBase
*)(TimeField
*)pNewWindow
);
922 pNewWindow
= new ToolBox( pParent
, nWinBits
);
923 *ppNewComp
= new VCLXToolBox
;
925 case WINDOW_TRISTATEBOX
:
926 pNewWindow
= new TriStateBox( pParent
, nWinBits
);
928 case WINDOW_WARNINGBOX
:
929 pNewWindow
= new WarningBox( pParent
, nWinBits
, String() );
930 *ppNewComp
= new VCLXMessageBox
;
932 case WINDOW_WORKWINDOW
:
934 case VCLWINDOW_FRAMEWINDOW
:
935 case WINDOW_DOCKINGWINDOW
:
936 if ( rDescriptor
.Type
== ::com::sun::star::awt::WindowClass_TOP
)
938 if (nType
== WINDOW_DOCKINGWINDOW
)
939 pNewWindow
= new DockingWindow( pParent
, nWinBits
);
942 if ((pParent
== NULL
) && rDescriptor
.Parent
.is())
944 // try to get a system dependent window handle
945 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XSystemDependentWindowPeer
> xSystemDepParent(rDescriptor
.Parent
, ::com::sun::star::uno::UNO_QUERY
);
947 if (xSystemDepParent
.is())
949 sal_Int8 processID
[16];
951 rtl_getGlobalProcessId( (sal_uInt8
*)processID
);
953 ::com::sun::star::uno::Sequence
<sal_Int8
> processIdSeq(processID
, 16);
955 ::com::sun::star::uno::Any anyHandle
= xSystemDepParent
->getWindowHandle(processIdSeq
, SYSTEM_DEPENDENT_TYPE
);
957 // use sal_Int64 here to accomodate all int types
958 // uno::Any shift operator whill upcast if necessary
959 sal_Int64 nWindowHandle
= 0;
960 sal_Bool bXEmbed
= sal_False
;
962 bool bUseParentData
= true;
963 if( ! (anyHandle
>>= nWindowHandle
) )
965 css::uno::Sequence
< css::beans::NamedValue
> aProps
;
966 if( anyHandle
>>= aProps
)
968 const int nProps
= aProps
.getLength();
969 const css::beans::NamedValue
* pProps
= aProps
.getConstArray();
970 for( int i
= 0; i
< nProps
; i
++ )
972 if ( pProps
[i
].Name
== "WINDOW" )
973 pProps
[i
].Value
>>= nWindowHandle
;
974 else if ( pProps
[i
].Name
== "XEMBED" )
975 pProps
[i
].Value
>>= bXEmbed
;
979 bUseParentData
= false;
984 SystemParentData aParentData
;
985 aParentData
.nSize
= sizeof( aParentData
);
987 aParentData
.pView
= reinterpret_cast<NSView
*>(nWindowHandle
);
989 aParentData
.pView
= reinterpret_cast<UIView
*>(nWindowHandle
);
991 aParentData
.aWindow
= nWindowHandle
;
992 aParentData
.bXEmbedSupport
= bXEmbed
;
994 aParentData
.hWnd
= reinterpret_cast<HWND
>(nWindowHandle
);
996 pNewWindow
= new WorkWindow( &aParentData
);
1002 pNewWindow
= new WorkWindow( pParent
, nWinBits
);
1005 *ppNewComp
= new VCLXTopWindow( pNewWindow
->GetType() == WINDOW_WORKWINDOW
);
1007 else if ( rDescriptor
.Type
== ::com::sun::star::awt::WindowClass_CONTAINER
)
1009 if (nType
== WINDOW_DOCKINGWINDOW
)
1010 pNewWindow
= new DockingWindow( pParent
, nWinBits
);
1012 pNewWindow
= new Window( pParent
, nWinBits
);
1013 *ppNewComp
= new VCLXContainer
;
1017 if (nType
== WINDOW_DOCKINGWINDOW
)
1018 pNewWindow
= new DockingWindow( pParent
, nWinBits
);
1020 pNewWindow
= new Window( pParent
, nWinBits
);
1021 *ppNewComp
= new VCLXWindow
;
1024 case WINDOW_CONTROL
:
1025 if ( aServiceName
.EqualsAscii( "simpleanimation" ) )
1027 pNewWindow
= new Throbber( pParent
, nWinBits
, Throbber::IMAGES_NONE
);
1028 ((Throbber
*)pNewWindow
)->SetScaleMode( css::awt::ImageScaleMode::Anisotropic
);
1030 *ppNewComp
= new ::toolkit::XSimpleAnimation
;
1032 else if ( aServiceName
.EqualsAscii( "throbber" ) )
1034 pNewWindow
= new Throbber( pParent
, nWinBits
, Throbber::IMAGES_NONE
);
1035 ((Throbber
*)pNewWindow
)->SetScaleMode( css::awt::ImageScaleMode::Anisotropic
);
1037 *ppNewComp
= new ::toolkit::XThrobber
;
1039 else if ( rDescriptor
.WindowServiceName
.equalsIgnoreAsciiCaseAsciiL(
1040 RTL_CONSTASCII_STRINGPARAM("tabpagecontainer") ) )
1042 pNewWindow
= new TabControl( pParent
, nWinBits
);
1043 *ppNewComp
= new VCLXTabPageContainer
;
1045 else if ( aServiceName
.EqualsAscii( "animatedimages" ) )
1047 pNewWindow
= new Throbber( pParent
, nWinBits
);
1048 *ppNewComp
= new ::toolkit::AnimatedImagesPeer
;
1052 OSL_ENSURE( false, "VCLXToolkit::ImplCreateWindow: unknown window type!" );
1060 extern "C" { static void SAL_CALL
thisModule() {} }
1062 css::uno::Reference
< css::awt::XWindowPeer
> VCLXToolkit::ImplCreateWindow(
1063 const css::awt::WindowDescriptor
& rDescriptor
,
1064 WinBits nForceWinBits
)
1066 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
1068 SolarMutexGuard aSolarGuard
;
1070 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowPeer
> xRef
;
1072 Window
* pParent
= NULL
;
1073 if ( rDescriptor
.Parent
.is() )
1075 VCLXWindow
* pParentComponent
= VCLXWindow::GetImplementation( rDescriptor
.Parent
);
1077 // #103939# Don't throw assertion, may be it's a system dependend window, used in ImplCreateWindow.
1078 // DBG_ASSERT( pParentComponent, "ParentComponent not valid" );
1080 if ( pParentComponent
)
1081 pParent
= pParentComponent
->GetWindow();
1084 WinBits nWinBits
= ImplGetWinBits( rDescriptor
.WindowAttributes
,
1085 ImplGetComponentType( rDescriptor
.WindowServiceName
) );
1086 nWinBits
|= nForceWinBits
;
1088 VCLXWindow
* pNewComp
= NULL
;
1090 Window
* pNewWindow
= NULL
;
1091 // Try to create the window with SvTools
1092 // (do this _before_ creating it on our own: The old mechanism (extended toolkit in SvTools) did it this way,
1093 // and we need to stay compatible)
1094 // try to load the lib
1095 if ( !fnSvtCreateWindow
&& !hSvToolsLib
)
1097 ::rtl::OUString aLibName
= ::vcl::unohelper::CreateLibraryName(
1098 #ifdef LIBO_MERGELIBS
1104 hSvToolsLib
= osl_loadModuleRelative(
1105 &thisModule
, aLibName
.pData
, SAL_LOADMODULE_DEFAULT
);
1108 ::rtl::OUString
aFunctionName( "CreateWindow" );
1109 fnSvtCreateWindow
= (FN_SvtCreateWindow
)osl_getFunctionSymbol( hSvToolsLib
, aFunctionName
.pData
);
1112 // ask the SvTool creation function
1113 if ( fnSvtCreateWindow
)
1114 pNewWindow
= fnSvtCreateWindow( &pNewComp
, &rDescriptor
, pParent
, nWinBits
);
1116 // if SvTools could not provide a window, create it ourself
1118 pNewWindow
= ImplCreateWindow( &pNewComp
, rDescriptor
, pParent
, nWinBits
);
1120 DBG_ASSERT( pNewWindow
, "createWindow: Unknown Component!" );
1121 DBG_ASSERTWARNING( pNewComp
, "createWindow: No special Interface!" );
1125 pNewWindow
->SetCreatedWithToolkit( sal_True
);
1126 //pNewWindow->SetPosPixel( Point() ); // do not force (0,0) position, keep default pos instead
1128 if ( rDescriptor
.WindowAttributes
& ::com::sun::star::awt::WindowAttribute::MINSIZE
)
1130 pNewWindow
->SetSizePixel( Size() );
1132 else if ( rDescriptor
.WindowAttributes
& ::com::sun::star::awt::WindowAttribute::FULLSIZE
)
1135 pNewWindow
->SetSizePixel( pParent
->GetOutputSizePixel() );
1137 else if ( !VCLUnoHelper::IsZero( rDescriptor
.Bounds
) )
1139 Rectangle aRect
= VCLRectangle( rDescriptor
.Bounds
);
1140 pNewWindow
->SetPosSizePixel( aRect
.TopLeft(), aRect
.GetSize() );
1145 // Default-Interface
1146 xRef
= pNewWindow
->GetComponentInterface( sal_True
);
1150 pNewComp
->SetCreatedWithToolkit( sal_True
);
1152 pNewWindow
->SetComponentInterface( xRef
);
1154 DBG_ASSERT( pNewWindow
->GetComponentInterface( sal_False
) == xRef
,
1155 "VCLXToolkit::createWindow: did #133706# resurge?" );
1157 if ( rDescriptor
.WindowAttributes
& ::com::sun::star::awt::WindowAttribute::SHOW
)
1164 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowPeer
> > VCLXToolkit::createWindows( const ::com::sun::star::uno::Sequence
< ::com::sun::star::awt::WindowDescriptor
>& rDescriptors
) throw(::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
)
1166 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
1168 sal_uInt32 nComponents
= rDescriptors
.getLength();
1169 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowPeer
> > aSeq( nComponents
);
1170 for ( sal_uInt32 n
= 0; n
< nComponents
; n
++ )
1172 ::com::sun::star::awt::WindowDescriptor aDescr
= rDescriptors
.getConstArray()[n
];
1174 if ( aDescr
.ParentIndex
== (-1) )
1175 aDescr
.Parent
= NULL
;
1176 else if ( ( aDescr
.ParentIndex
>= 0 ) && ( aDescr
.ParentIndex
< (short)n
) )
1177 aDescr
.Parent
= aSeq
.getConstArray()[aDescr
.ParentIndex
];
1178 aSeq
.getArray()[n
] = createWindow( aDescr
);
1183 // ::com::sun::star::awt::XSystemChildFactory
1184 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowPeer
> VCLXToolkit::createSystemChild( const ::com::sun::star::uno::Any
& Parent
, const ::com::sun::star::uno::Sequence
< sal_Int8
>& /*ProcessId*/, sal_Int16 nSystemType
) throw(::com::sun::star::uno::RuntimeException
)
1186 Window
* pChildWindow
= NULL
;
1187 if ( nSystemType
== SYSTEM_DEPENDENT_TYPE
)
1189 // use sal_Int64 here to accomodate all int types
1190 // uno::Any shift operator whill upcast if necessary
1191 sal_Int64 nWindowHandle
= 0;
1192 sal_Bool bXEmbed
= sal_False
;
1194 bool bUseParentData
= true;
1195 if( ! (Parent
>>= nWindowHandle
) )
1197 css::uno::Sequence
< css::beans::NamedValue
> aProps
;
1198 if( Parent
>>= aProps
)
1200 const int nProps
= aProps
.getLength();
1201 const css::beans::NamedValue
* pProps
= aProps
.getConstArray();
1202 for( int i
= 0; i
< nProps
; i
++ )
1204 if ( pProps
[i
].Name
== "WINDOW" )
1205 pProps
[i
].Value
>>= nWindowHandle
;
1206 else if ( pProps
[i
].Name
== "XEMBED" )
1207 pProps
[i
].Value
>>= bXEmbed
;
1211 bUseParentData
= false;
1214 if( bUseParentData
)
1216 SystemParentData aParentData
;
1217 aParentData
.nSize
= sizeof( aParentData
);
1219 aParentData
.pView
= reinterpret_cast<NSView
*>(nWindowHandle
);
1221 aParentData
.pView
= reinterpret_cast<UIView
*>(nWindowHandle
);
1223 aParentData
.aWindow
= nWindowHandle
;
1224 aParentData
.bXEmbedSupport
= bXEmbed
;
1226 aParentData
.hWnd
= reinterpret_cast<HWND
>(nWindowHandle
);
1228 SolarMutexGuard aGuard
;
1231 pChildWindow
= new WorkWindow( &aParentData
);
1233 catch ( const ::com::sun::star::uno::RuntimeException
& rEx
)
1235 // system child window could not be created
1237 "VCLXToolkit::createSystemChild: caught %s\n",
1238 ::rtl::OUStringToOString(
1239 rEx
.Message
, RTL_TEXTENCODING_UTF8
).getStr());
1240 pChildWindow
= NULL
;
1244 else if (nSystemType
== com::sun::star::lang::SystemDependent::SYSTEM_JAVA
)
1246 SolarMutexGuard aGuard
;
1247 pChildWindow
= new WorkWindow(0, Parent
);
1250 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowPeer
> xPeer
;
1253 VCLXTopWindow
* pPeer
= new VCLXTopWindow(true);
1254 SolarMutexGuard aGuard
;
1255 pPeer
->SetWindow( pChildWindow
);
1262 // ::com::sun::star::awt::XMessageBoxFactory
1263 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XMessageBox
> SAL_CALL
VCLXToolkit::createMessageBox(
1264 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowPeer
>& aParent
,
1265 const ::com::sun::star::awt::Rectangle
& aPosSize
,
1266 const ::rtl::OUString
& aType
,
1267 ::sal_Int32 aButtons
,
1268 const ::rtl::OUString
& aTitle
,
1269 const ::rtl::OUString
& aMessage
) throw (::com::sun::star::uno::RuntimeException
)
1271 ::com::sun::star::awt::WindowDescriptor aDescriptor
;
1273 sal_Int32 nWindowAttributes
= css::awt::WindowAttribute::BORDER
|css::awt::WindowAttribute::MOVEABLE
|css::awt::WindowAttribute::CLOSEABLE
;
1275 // Map button definitions to window attributes
1276 if (( aButtons
& 0x0000ffffL
) == css::awt::MessageBoxButtons::BUTTONS_OK
)
1277 nWindowAttributes
|= css::awt::VclWindowPeerAttribute::OK
;
1278 else if (( aButtons
& 0x0000ffffL
) == css::awt::MessageBoxButtons::BUTTONS_OK_CANCEL
)
1279 nWindowAttributes
|= css::awt::VclWindowPeerAttribute::OK_CANCEL
;
1280 else if (( aButtons
& 0x0000ffffL
) == css::awt::MessageBoxButtons::BUTTONS_YES_NO
)
1281 nWindowAttributes
|= css::awt::VclWindowPeerAttribute::YES_NO
;
1282 else if (( aButtons
& 0x0000ffffL
) == css::awt::MessageBoxButtons::BUTTONS_YES_NO_CANCEL
)
1283 nWindowAttributes
|= css::awt::VclWindowPeerAttribute::YES_NO_CANCEL
;
1284 else if (( aButtons
& 0x0000ffffL
) == css::awt::MessageBoxButtons::BUTTONS_RETRY_CANCEL
)
1285 nWindowAttributes
|= css::awt::VclWindowPeerAttribute::RETRY_CANCEL
;
1287 // Map default button definitions to window attributes
1288 if (sal_Int32( aButtons
& 0xffff0000L
) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_OK
)
1289 nWindowAttributes
|= css::awt::VclWindowPeerAttribute::DEF_OK
;
1290 else if (sal_Int32( aButtons
& 0xffff0000L
) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_CANCEL
)
1291 nWindowAttributes
|= css::awt::VclWindowPeerAttribute::DEF_CANCEL
;
1292 else if (sal_Int32( aButtons
& 0xffff0000L
) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_YES
)
1293 nWindowAttributes
|= css::awt::VclWindowPeerAttribute::DEF_YES
;
1294 else if (sal_Int32( aButtons
& 0xffff0000L
) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_NO
)
1295 nWindowAttributes
|= css::awt::VclWindowPeerAttribute::DEF_NO
;
1296 else if (sal_Int32( aButtons
& 0xffff0000L
) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_RETRY
)
1297 nWindowAttributes
|= css::awt::VclWindowPeerAttribute::DEF_RETRY
;
1299 // No more bits for VclWindowPeerAttribute possible. Mapping must be
1300 // done explicitly using VCL methods
1301 WinBits
nAddWinBits( 0 );
1302 if (( aButtons
& 0x0000ffffL
) == css::awt::MessageBoxButtons::BUTTONS_ABORT_IGNORE_RETRY
)
1303 nAddWinBits
|= WB_ABORT_RETRY_IGNORE
;
1304 if ( sal_Int32( aButtons
& 0xffff0000L
) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_IGNORE
)
1305 nAddWinBits
|= WB_DEF_IGNORE
;
1307 aDescriptor
.Type
= css::awt::WindowClass_MODALTOP
;
1308 aDescriptor
.WindowServiceName
= aType
;
1309 aDescriptor
.ParentIndex
= -1;
1310 aDescriptor
.Parent
= aParent
;
1311 aDescriptor
.Bounds
= aPosSize
;
1312 aDescriptor
.WindowAttributes
= nWindowAttributes
;
1313 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XMessageBox
> xMsgBox(
1314 ImplCreateWindow( aDescriptor
, nAddWinBits
), css::uno::UNO_QUERY
);
1315 css::uno::Reference
< css::awt::XWindow
> xWindow( xMsgBox
, css::uno::UNO_QUERY
);
1316 if ( xMsgBox
.is() && xWindow
.is() )
1318 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
1321 SolarMutexGuard aGuard
;
1322 xMsgBox
->setCaptionText( aTitle
);
1323 xMsgBox
->setMessageText( aMessage
);
1330 ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::dnd::XDragGestureRecognizer
> SAL_CALL
VCLXToolkit::getDragGestureRecognizer( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
>& window
) throw(::com::sun::star::uno::RuntimeException
)
1332 Window
* pWindow
= VCLUnoHelper::GetWindow( window
);
1335 return pWindow
->GetDragGestureRecognizer();
1337 return ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::dnd::XDragGestureRecognizer
>();
1340 ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::dnd::XDragSource
> SAL_CALL
VCLXToolkit::getDragSource( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
>& window
) throw(::com::sun::star::uno::RuntimeException
)
1342 Window
* pWindow
= VCLUnoHelper::GetWindow( window
);
1345 return pWindow
->GetDragSource();
1347 return ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::dnd::XDragSource
>();
1350 ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::dnd::XDropTarget
> SAL_CALL
VCLXToolkit::getDropTarget( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
>& window
) throw(::com::sun::star::uno::RuntimeException
)
1352 Window
* pWindow
= VCLUnoHelper::GetWindow( window
);
1355 return pWindow
->GetDropTarget();
1357 return ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::dnd::XDropTarget
>();
1360 ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::clipboard::XClipboard
> SAL_CALL
VCLXToolkit::getClipboard( const ::rtl::OUString
& clipboardName
) throw(::com::sun::star::uno::RuntimeException
)
1362 if( clipboardName
.isEmpty() )
1364 if( !mxClipboard
.is() )
1366 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> xFactory
= ::comphelper::getProcessServiceFactory();
1367 if ( xFactory
.is() )
1369 // remember clipboard here
1370 mxClipboard
= ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::clipboard::XClipboard
> (
1371 xFactory
->createInstance( ::rtl::OUString("com.sun.star.datatransfer.clipboard.SystemClipboard") ), ::com::sun::star::uno::UNO_QUERY
);
1378 else if( clipboardName
== "Selection" )
1383 return ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::clipboard::XClipboard
>();
1387 ::rtl::OUString
VCLXToolkit::getImplementationName() throw(::com::sun::star::uno::RuntimeException
)
1389 return rtl::OUString("stardiv.Toolkit.VCLXToolkit");
1392 sal_Bool
VCLXToolkit::supportsService( const ::rtl::OUString
& rServiceName
) throw(::com::sun::star::uno::RuntimeException
)
1394 ::osl::MutexGuard
aGuard( GetMutex() );
1396 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> aSNL
= getSupportedServiceNames();
1397 const ::rtl::OUString
* pArray
= aSNL
.getConstArray();
1398 const ::rtl::OUString
* pArrayEnd
= aSNL
.getConstArray();
1399 for (; pArray
!= pArrayEnd
; ++pArray
)
1400 if( *pArray
== rServiceName
)
1403 return pArray
!= pArrayEnd
;
1406 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> VCLXToolkit::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException
)
1408 ::rtl::OUString
aServiceName( ::rtl::OUString::createFromAscii( szServiceName2_Toolkit
) );
1409 return ::com::sun::star::uno::Sequence
< ::rtl::OUString
>( &aServiceName
, 1);
1412 // css::awt::XExtendedToolkit:
1415 ::sal_Int32 SAL_CALL
VCLXToolkit::getTopWindowCount()
1416 throw (::css::uno::RuntimeException
)
1418 return static_cast< ::sal_Int32
>(::Application::GetTopWindowCount());
1419 // XXX numeric overflow
1423 ::css::uno::Reference
< ::css::awt::XTopWindow
> SAL_CALL
1424 VCLXToolkit::getTopWindow(::sal_Int32 nIndex
)
1425 throw (::css::uno::RuntimeException
)
1427 ::Window
* p
= ::Application::GetTopWindow(static_cast< long >(nIndex
));
1428 // XXX numeric overflow
1429 return ::css::uno::Reference
< ::css::awt::XTopWindow
>(
1430 p
== 0 ? 0 : static_cast< ::css::awt::XWindow
* >(p
->GetWindowPeer()),
1431 ::css::uno::UNO_QUERY
);
1435 ::css::uno::Reference
< ::css::awt::XTopWindow
> SAL_CALL
1436 VCLXToolkit::getActiveTopWindow() throw (::css::uno::RuntimeException
)
1438 ::Window
* p
= ::Application::GetActiveTopWindow();
1439 return ::css::uno::Reference
< ::css::awt::XTopWindow
>(
1440 p
== 0 ? 0 : static_cast< ::css::awt::XWindow
* >(p
->GetWindowPeer()),
1441 ::css::uno::UNO_QUERY
);
1445 void SAL_CALL
VCLXToolkit::addTopWindowListener(
1446 ::css::uno::Reference
< ::css::awt::XTopWindowListener
> const & rListener
)
1447 throw (::css::uno::RuntimeException
)
1449 OSL_ENSURE(rListener
.is(), "Null rListener");
1450 ::osl::ClearableMutexGuard
aGuard(rBHelper
.rMutex
);
1451 if (rBHelper
.bDisposed
|| rBHelper
.bInDispose
)
1454 rListener
->disposing(
1455 ::css::lang::EventObject(
1456 static_cast< ::cppu::OWeakObject
* >(this)));
1458 else if (m_aTopWindowListeners
.addInterface(rListener
) == 1
1459 && !m_bEventListener
)
1461 m_bEventListener
= true;
1462 ::Application::AddEventListener(m_aEventListenerLink
);
1467 void SAL_CALL
VCLXToolkit::removeTopWindowListener(
1468 ::css::uno::Reference
< ::css::awt::XTopWindowListener
> const & rListener
)
1469 throw (::css::uno::RuntimeException
)
1471 ::osl::MutexGuard
aGuard(rBHelper
.rMutex
);
1472 if (!(rBHelper
.bDisposed
|| rBHelper
.bInDispose
)
1473 && m_aTopWindowListeners
.removeInterface(rListener
) == 0
1474 && m_aFocusListeners
.getLength() == 0 && m_bEventListener
)
1476 ::Application::RemoveEventListener(m_aEventListenerLink
);
1477 m_bEventListener
= false;
1482 void SAL_CALL
VCLXToolkit::addKeyHandler(
1483 ::css::uno::Reference
< ::css::awt::XKeyHandler
> const & rHandler
)
1484 throw (::css::uno::RuntimeException
)
1486 OSL_ENSURE(rHandler
.is(), "Null rHandler");
1487 ::osl::ClearableMutexGuard
aGuard(rBHelper
.rMutex
);
1488 if (rBHelper
.bDisposed
|| rBHelper
.bInDispose
)
1491 rHandler
->disposing(
1492 ::css::lang::EventObject(
1493 static_cast< ::cppu::OWeakObject
* >(this)));
1495 else if (m_aKeyHandlers
.addInterface(rHandler
) == 1 && !m_bKeyListener
)
1497 m_bKeyListener
= true;
1498 ::Application::AddKeyListener(m_aKeyListenerLink
);
1503 void SAL_CALL
VCLXToolkit::removeKeyHandler(
1504 ::css::uno::Reference
< ::css::awt::XKeyHandler
> const & rHandler
)
1505 throw (::css::uno::RuntimeException
)
1507 ::osl::MutexGuard
aGuard(rBHelper
.rMutex
);
1508 if (!(rBHelper
.bDisposed
|| rBHelper
.bInDispose
)
1509 && m_aKeyHandlers
.removeInterface(rHandler
) == 0 && m_bKeyListener
)
1511 ::Application::RemoveKeyListener(m_aKeyListenerLink
);
1512 m_bKeyListener
= false;
1517 void SAL_CALL
VCLXToolkit::addFocusListener(
1518 ::css::uno::Reference
< ::css::awt::XFocusListener
> const & rListener
)
1519 throw (::css::uno::RuntimeException
)
1521 OSL_ENSURE(rListener
.is(), "Null rListener");
1522 ::osl::ClearableMutexGuard
aGuard(rBHelper
.rMutex
);
1523 if (rBHelper
.bDisposed
|| rBHelper
.bInDispose
)
1526 rListener
->disposing(
1527 ::css::lang::EventObject(
1528 static_cast< ::cppu::OWeakObject
* >(this)));
1530 else if (m_aFocusListeners
.addInterface(rListener
) == 1
1531 && !m_bEventListener
)
1533 m_bEventListener
= true;
1534 ::Application::AddEventListener(m_aEventListenerLink
);
1539 void SAL_CALL
VCLXToolkit::removeFocusListener(
1540 ::css::uno::Reference
< ::css::awt::XFocusListener
> const & rListener
)
1541 throw (::css::uno::RuntimeException
)
1543 ::osl::MutexGuard
aGuard(rBHelper
.rMutex
);
1544 if (!(rBHelper
.bDisposed
|| rBHelper
.bInDispose
)
1545 && m_aFocusListeners
.removeInterface(rListener
) == 0
1546 && m_aTopWindowListeners
.getLength() == 0 && m_bEventListener
)
1548 ::Application::RemoveEventListener(m_aEventListenerLink
);
1549 m_bEventListener
= false;
1554 void SAL_CALL
VCLXToolkit::fireFocusGained(
1555 ::com::sun::star::uno::Reference
<
1556 ::com::sun::star::uno::XInterface
> const &)
1557 throw (::com::sun::star::uno::RuntimeException
)
1562 void SAL_CALL
VCLXToolkit::fireFocusLost(
1563 ::com::sun::star::uno::Reference
<
1564 ::com::sun::star::uno::XInterface
> const &)
1565 throw (::com::sun::star::uno::RuntimeException
)
1570 IMPL_LINK(VCLXToolkit
, eventListenerHandler
, ::VclSimpleEvent
const *, pEvent
)
1572 switch (pEvent
->GetId())
1574 case VCLEVENT_WINDOW_SHOW
:
1575 callTopWindowListeners(
1576 pEvent
, &::css::awt::XTopWindowListener::windowOpened
);
1578 case VCLEVENT_WINDOW_HIDE
:
1579 callTopWindowListeners(
1580 pEvent
, &::css::awt::XTopWindowListener::windowClosed
);
1582 case VCLEVENT_WINDOW_ACTIVATE
:
1583 callTopWindowListeners(
1584 pEvent
, &::css::awt::XTopWindowListener::windowActivated
);
1586 case VCLEVENT_WINDOW_DEACTIVATE
:
1587 callTopWindowListeners(
1588 pEvent
, &::css::awt::XTopWindowListener::windowDeactivated
);
1590 case VCLEVENT_WINDOW_CLOSE
:
1591 callTopWindowListeners(
1592 pEvent
, &::css::awt::XTopWindowListener::windowClosing
);
1594 case VCLEVENT_WINDOW_GETFOCUS
:
1595 callFocusListeners(pEvent
, true);
1597 case VCLEVENT_WINDOW_LOSEFOCUS
:
1598 callFocusListeners(pEvent
, false);
1600 case VCLEVENT_WINDOW_MINIMIZE
:
1601 callTopWindowListeners(
1602 pEvent
, &::css::awt::XTopWindowListener::windowMinimized
);
1604 case VCLEVENT_WINDOW_NORMALIZE
:
1605 callTopWindowListeners(
1606 pEvent
, &::css::awt::XTopWindowListener::windowNormalized
);
1612 IMPL_LINK(VCLXToolkit
, keyListenerHandler
, ::VclSimpleEvent
const *, pEvent
)
1614 switch (pEvent
->GetId())
1616 case VCLEVENT_WINDOW_KEYINPUT
:
1617 return callKeyHandlers(pEvent
, true);
1618 case VCLEVENT_WINDOW_KEYUP
:
1619 return callKeyHandlers(pEvent
, false);
1624 void VCLXToolkit::callTopWindowListeners(
1625 ::VclSimpleEvent
const * pEvent
,
1626 void (SAL_CALL ::css::awt::XTopWindowListener::* pFn
)(
1627 ::css::lang::EventObject
const &))
1630 = static_cast< ::VclWindowEvent
const * >(pEvent
)->GetWindow();
1631 if (pWindow
->IsTopWindow())
1633 ::css::uno::Sequence
< ::css::uno::Reference
< ::css::uno::XInterface
> >
1634 aListeners(m_aTopWindowListeners
.getElements());
1635 if (aListeners
.hasElements())
1637 ::css::lang::EventObject
aAwtEvent(
1638 static_cast< ::css::awt::XWindow
* >(pWindow
->GetWindowPeer()));
1639 for (::sal_Int32 i
= 0; i
< aListeners
.getLength(); ++i
)
1641 ::css::uno::Reference
< ::css::awt::XTopWindowListener
>
1642 xListener(aListeners
[i
], ::css::uno::UNO_QUERY
);
1645 (xListener
.get()->*pFn
)(aAwtEvent
);
1647 catch (const ::css::uno::RuntimeException
& rEx
)
1650 "VCLXToolkit::callTopWindowListeners: caught %s\n",
1651 ::rtl::OUStringToOString(
1652 rEx
.Message
, RTL_TEXTENCODING_UTF8
).getStr());
1659 long VCLXToolkit::callKeyHandlers(::VclSimpleEvent
const * pEvent
,
1662 ::css::uno::Sequence
< ::css::uno::Reference
< ::css::uno::XInterface
> >
1663 aHandlers(m_aKeyHandlers
.getElements());
1665 if (aHandlers
.hasElements())
1667 ::Window
* pWindow
= static_cast< ::VclWindowEvent
const * >(pEvent
)->GetWindow();
1669 // See implementation in vclxwindow.cxx for mapping between VCL and UNO AWT event
1670 ::KeyEvent
* pKeyEvent
= static_cast< ::KeyEvent
* >(
1671 static_cast< ::VclWindowEvent
const * >(pEvent
)->GetData());
1672 ::css::awt::KeyEvent
aAwtEvent(
1673 static_cast< ::css::awt::XWindow
* >(pWindow
->GetWindowPeer()),
1674 (pKeyEvent
->GetKeyCode().IsShift()
1675 ? ::css::awt::KeyModifier::SHIFT
: 0)
1676 | (pKeyEvent
->GetKeyCode().IsMod1()
1677 ? ::css::awt::KeyModifier::MOD1
: 0)
1678 | (pKeyEvent
->GetKeyCode().IsMod2()
1679 ? ::css::awt::KeyModifier::MOD2
: 0)
1680 | (pKeyEvent
->GetKeyCode().IsMod3()
1681 ? ::css::awt::KeyModifier::MOD3
: 0),
1682 pKeyEvent
->GetKeyCode().GetCode(), pKeyEvent
->GetCharCode(),
1683 sal::static_int_cast
< sal_Int16
>(
1684 pKeyEvent
->GetKeyCode().GetFunction()));
1685 for (::sal_Int32 i
= 0; i
< aHandlers
.getLength(); ++i
)
1687 ::css::uno::Reference
< ::css::awt::XKeyHandler
> xHandler(
1688 aHandlers
[i
], ::css::uno::UNO_QUERY
);
1691 if ((bPressed
? xHandler
->keyPressed(aAwtEvent
)
1692 : xHandler
->keyReleased(aAwtEvent
)))
1695 catch (const ::css::uno::RuntimeException
& rEx
)
1698 "VCLXToolkit::callKeyHandlers: caught %s\n",
1699 ::rtl::OUStringToOString(
1700 rEx
.Message
, RTL_TEXTENCODING_UTF8
).getStr());
1707 void VCLXToolkit::callFocusListeners(::VclSimpleEvent
const * pEvent
,
1711 = static_cast< ::VclWindowEvent
const * >(pEvent
)->GetWindow();
1712 if (pWindow
->IsTopWindow())
1714 ::css::uno::Sequence
< ::css::uno::Reference
< ::css::uno::XInterface
> >
1715 aListeners(m_aFocusListeners
.getElements());
1716 if (aListeners
.hasElements())
1718 // Ignore the interior of compound controls when determining the
1719 // window that gets the focus next (see implementation in
1720 // vclxwindow.cxx for mapping between VCL and UNO AWT event):
1721 ::css::uno::Reference
< css::uno::XInterface
> xNext
;
1722 ::Window
* pFocus
= ::Application::GetFocusWindow();
1723 for (::Window
* p
= pFocus
; p
!= 0; p
= p
->GetParent())
1724 if (!p
->IsCompoundControl())
1730 xNext
= pFocus
->GetComponentInterface(true);
1731 ::css::awt::FocusEvent
aAwtEvent(
1732 static_cast< ::css::awt::XWindow
* >(pWindow
->GetWindowPeer()),
1733 pWindow
->GetGetFocusFlags(), xNext
, false);
1734 for (::sal_Int32 i
= 0; i
< aListeners
.getLength(); ++i
)
1736 ::css::uno::Reference
< ::css::awt::XFocusListener
> xListener(
1737 aListeners
[i
], ::css::uno::UNO_QUERY
);
1740 bGained
? xListener
->focusGained(aAwtEvent
)
1741 : xListener
->focusLost(aAwtEvent
);
1743 catch (const ::css::uno::RuntimeException
& rEx
)
1746 "VCLXToolkit::callFocusListeners: caught %s\n",
1747 ::rtl::OUStringToOString(
1748 rEx
.Message
, RTL_TEXTENCODING_UTF8
).getStr());
1755 // css::awt::XReschedule:
1757 void SAL_CALL
VCLXToolkit::reschedule()
1758 throw (::com::sun::star::uno::RuntimeException
)
1760 Application::Reschedule(true);
1763 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */