xref: /AOO41X/main/vcl/source/window/window.cxx (revision cf06609a76eaffdf47841de059b75febb88787ac)
19f62ea84SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
39f62ea84SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
49f62ea84SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
59f62ea84SAndrew Rist  * distributed with this work for additional information
69f62ea84SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
79f62ea84SAndrew Rist  * to you under the Apache License, Version 2.0 (the
89f62ea84SAndrew Rist  * "License"); you may not use this file except in compliance
99f62ea84SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
119f62ea84SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
139f62ea84SAndrew Rist  * Unless required by applicable law or agreed to in writing,
149f62ea84SAndrew Rist  * software distributed under the License is distributed on an
159f62ea84SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169f62ea84SAndrew Rist  * KIND, either express or implied.  See the License for the
179f62ea84SAndrew Rist  * specific language governing permissions and limitations
189f62ea84SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
209f62ea84SAndrew Rist  *************************************************************/
219f62ea84SAndrew Rist 
229f62ea84SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "tools/time.hxx"
28cdf0e10cSrcweir #include "tools/debug.hxx"
29cdf0e10cSrcweir #include "tools/rc.h"
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include "unotools/fontcfg.hxx"
32cdf0e10cSrcweir #include "unotools/confignode.hxx"
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include "vcl/unohelp.hxx"
35cdf0e10cSrcweir #include "vcl/salgtype.hxx"
36cdf0e10cSrcweir #include "vcl/event.hxx"
37cdf0e10cSrcweir #include "vcl/help.hxx"
38cdf0e10cSrcweir #include "vcl/cursor.hxx"
39cdf0e10cSrcweir #include "vcl/svapp.hxx"
40cdf0e10cSrcweir #include "vcl/window.hxx"
41cdf0e10cSrcweir #include "vcl/syswin.hxx"
42cdf0e10cSrcweir #include "vcl/syschild.hxx"
43cdf0e10cSrcweir #include "vcl/dockwin.hxx"
44cdf0e10cSrcweir #include "vcl/menu.hxx"
45cdf0e10cSrcweir #include "vcl/wrkwin.hxx"
46cdf0e10cSrcweir #include "vcl/wall.hxx"
47cdf0e10cSrcweir #include "vcl/gradient.hxx"
48cdf0e10cSrcweir #include "vcl/salctype.hxx"
49cdf0e10cSrcweir #include "vcl/button.hxx"
50cdf0e10cSrcweir #include "vcl/taskpanelist.hxx"
51cdf0e10cSrcweir #include "vcl/dialog.hxx"
52cdf0e10cSrcweir #include "vcl/unowrap.hxx"
53cdf0e10cSrcweir #include "vcl/gdimtf.hxx"
54cdf0e10cSrcweir #include "vcl/pdfextoutdevdata.hxx"
55cdf0e10cSrcweir #include "vcl/lazydelete.hxx"
56cdf0e10cSrcweir 
57cdf0e10cSrcweir // declare system types in sysdata.hxx
58cdf0e10cSrcweir #include "svsys.h"
59cdf0e10cSrcweir #include "vcl/sysdata.hxx"
60cdf0e10cSrcweir 
61cdf0e10cSrcweir #include "salframe.hxx"
62cdf0e10cSrcweir #include "salobj.hxx"
63cdf0e10cSrcweir #include "salinst.hxx"
64cdf0e10cSrcweir #include "salgdi.hxx"
65cdf0e10cSrcweir #include "svdata.hxx"
66cdf0e10cSrcweir #include "dbggui.hxx"
67cdf0e10cSrcweir #include "outfont.hxx"
68cdf0e10cSrcweir #include "window.h"
69cdf0e10cSrcweir #include "toolbox.h"
70cdf0e10cSrcweir #include "outdev.h"
71cdf0e10cSrcweir #include "region.h"
72cdf0e10cSrcweir #include "brdwin.hxx"
73cdf0e10cSrcweir #include "helpwin.hxx"
74cdf0e10cSrcweir #include "sallayout.hxx"
75cdf0e10cSrcweir #include "dndlcon.hxx"
76cdf0e10cSrcweir #include "dndevdis.hxx"
77cdf0e10cSrcweir 
78cdf0e10cSrcweir #include "com/sun/star/awt/XWindowPeer.hpp"
79cdf0e10cSrcweir #include "com/sun/star/rendering/XCanvas.hpp"
80cdf0e10cSrcweir #include "com/sun/star/rendering/XSpriteCanvas.hpp"
81cdf0e10cSrcweir #include "com/sun/star/awt/XWindow.hpp"
82cdf0e10cSrcweir #include "comphelper/processfactory.hxx"
83cdf0e10cSrcweir #include "com/sun/star/datatransfer/dnd/XDragSource.hpp"
84cdf0e10cSrcweir #include "com/sun/star/datatransfer/dnd/XDropTarget.hpp"
85cdf0e10cSrcweir #include "com/sun/star/datatransfer/clipboard/XClipboard.hpp"
86cdf0e10cSrcweir #include "com/sun/star/awt/XTopWindow.hpp"
87cdf0e10cSrcweir #include "com/sun/star/awt/XDisplayConnection.hpp"
88cdf0e10cSrcweir #include "com/sun/star/lang/XInitialization.hpp"
89cdf0e10cSrcweir #include "com/sun/star/lang/XComponent.hpp"
90cdf0e10cSrcweir #include "com/sun/star/lang/XServiceName.hpp"
91cdf0e10cSrcweir #include "com/sun/star/accessibility/XAccessible.hpp"
92cdf0e10cSrcweir #include "com/sun/star/accessibility/AccessibleRole.hpp"
93cdf0e10cSrcweir 
94cdf0e10cSrcweir #include <set>
95cdf0e10cSrcweir #include <typeinfo>
96cdf0e10cSrcweir 
97cdf0e10cSrcweir using namespace rtl;
98cdf0e10cSrcweir using namespace ::com::sun::star::uno;
99cdf0e10cSrcweir using namespace ::com::sun::star::lang;
100cdf0e10cSrcweir using namespace ::com::sun::star::datatransfer::clipboard;
101cdf0e10cSrcweir using namespace ::com::sun::star::datatransfer::dnd;
102cdf0e10cSrcweir using namespace ::com::sun::star;
103cdf0e10cSrcweir using namespace com::sun;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir using ::com::sun::star::awt::XTopWindow;
106cdf0e10cSrcweir 
107cdf0e10cSrcweir // =======================================================================
108cdf0e10cSrcweir 
109cdf0e10cSrcweir DBG_NAME( Window )
110cdf0e10cSrcweir 
111cdf0e10cSrcweir // =======================================================================
112cdf0e10cSrcweir 
113cdf0e10cSrcweir #define IMPL_PAINT_PAINT            ((sal_uInt16)0x0001)
114cdf0e10cSrcweir #define IMPL_PAINT_PAINTALL         ((sal_uInt16)0x0002)
115cdf0e10cSrcweir #define IMPL_PAINT_PAINTALLCHILDS   ((sal_uInt16)0x0004)
116cdf0e10cSrcweir #define IMPL_PAINT_PAINTCHILDS      ((sal_uInt16)0x0008)
117cdf0e10cSrcweir #define IMPL_PAINT_ERASE            ((sal_uInt16)0x0010)
118cdf0e10cSrcweir #define IMPL_PAINT_CHECKRTL         ((sal_uInt16)0x0020)
119cdf0e10cSrcweir 
120cdf0e10cSrcweir // -----------------------------------------------------------------------
121cdf0e10cSrcweir 
122cdf0e10cSrcweir typedef Window* PWINDOW;
123cdf0e10cSrcweir 
124cdf0e10cSrcweir // -----------------------------------------------------------------------
125cdf0e10cSrcweir 
126cdf0e10cSrcweir struct ImplCalcToTopData
127cdf0e10cSrcweir {
128cdf0e10cSrcweir     ImplCalcToTopData*  mpNext;
129cdf0e10cSrcweir     Window*             mpWindow;
130cdf0e10cSrcweir     Region*             mpInvalidateRegion;
131cdf0e10cSrcweir };
132cdf0e10cSrcweir 
133cdf0e10cSrcweir ImplAccessibleInfos::ImplAccessibleInfos()
134cdf0e10cSrcweir {
135cdf0e10cSrcweir     nAccessibleRole = 0xFFFF;
136cdf0e10cSrcweir     pAccessibleName = NULL;
137cdf0e10cSrcweir     pAccessibleDescription = NULL;
138cdf0e10cSrcweir 	pLabeledByWindow = NULL;
139cdf0e10cSrcweir 	pLabelForWindow = NULL;
140cdf0e10cSrcweir 	pMemberOfWindow = NULL;
141cdf0e10cSrcweir }
142cdf0e10cSrcweir 
143cdf0e10cSrcweir ImplAccessibleInfos::~ImplAccessibleInfos()
144cdf0e10cSrcweir {
145cdf0e10cSrcweir     delete pAccessibleName;
146cdf0e10cSrcweir     delete pAccessibleDescription;
147cdf0e10cSrcweir }
148cdf0e10cSrcweir 
149cdf0e10cSrcweir // -----------------------------------------------------------------------
150cdf0e10cSrcweir 
151*cf06609aSHerbert Dürr WindowImpl::WindowImpl( WindowType nType )
152cdf0e10cSrcweir {
153*cf06609aSHerbert Dürr 	maZoom              = Fraction( 1, 1 );
154*cf06609aSHerbert Dürr 	maWinRegion         = Region( REGION_NULL );
155*cf06609aSHerbert Dürr 	maWinClipRegion                   = Region( REGION_NULL );
156*cf06609aSHerbert Dürr 	mpWinData           = NULL;         // Extra Window Data, that we dont need for all windows
157*cf06609aSHerbert Dürr 	mpOverlapData       = NULL;         // Overlap Data
158*cf06609aSHerbert Dürr 	mpFrameData         = NULL;         // Frame Data
159*cf06609aSHerbert Dürr 	mpFrame             = NULL;         // Pointer to frame window
160*cf06609aSHerbert Dürr 	mpSysObj            = NULL;
161*cf06609aSHerbert Dürr 	mpFrameWindow       = NULL;         // window to top level parent (same as frame window)
162*cf06609aSHerbert Dürr 	mpOverlapWindow     = NULL;         // first overlap parent
163*cf06609aSHerbert Dürr 	mpBorderWindow      = NULL;         // Border-Window
164*cf06609aSHerbert Dürr 	mpClientWindow      = NULL;         // Client-Window of a FrameWindow
165*cf06609aSHerbert Dürr 	mpParent            = NULL;         // parent (inkl. BorderWindow)
166*cf06609aSHerbert Dürr 	mpRealParent        = NULL;         // real parent (exkl. BorderWindow)
167*cf06609aSHerbert Dürr 	mpFirstChild        = NULL;         // first child window
168*cf06609aSHerbert Dürr 	mpLastChild         = NULL;         // last child window
169*cf06609aSHerbert Dürr 	mpFirstOverlap      = NULL;         // first overlap window (only set in overlap windows)
170*cf06609aSHerbert Dürr 	mpLastOverlap       = NULL;         // last overlap window (only set in overlap windows)
171*cf06609aSHerbert Dürr 	mpPrev              = NULL;         // prev window
172*cf06609aSHerbert Dürr 	mpNext              = NULL;         // next window
173*cf06609aSHerbert Dürr 	mpNextOverlap       = NULL;         // next overlap window of frame
174*cf06609aSHerbert Dürr 	mpLastFocusWindow   = NULL;         // window for focus restore
175*cf06609aSHerbert Dürr 	mpDlgCtrlDownWindow = NULL;         // window for dialog control
176*cf06609aSHerbert Dürr 	mpFirstDel          = NULL;         // Dtor notification list
177*cf06609aSHerbert Dürr 	mpUserData          = NULL;         // user data
178*cf06609aSHerbert Dürr 	mpExtImpl           = NULL;         // extended implementation data
179*cf06609aSHerbert Dürr 	mpCursor            = NULL;         // cursor
180*cf06609aSHerbert Dürr 	mpControlFont       = NULL;         // font propertie
181*cf06609aSHerbert Dürr 	mpVCLXWindow        = NULL;
182*cf06609aSHerbert Dürr 	mpAccessibleInfos   = NULL;
183*cf06609aSHerbert Dürr 	maControlForeground = Color( COL_TRANSPARENT );     // foreground color not set
184*cf06609aSHerbert Dürr 	maControlBackground = Color( COL_TRANSPARENT );     // background color not set
185*cf06609aSHerbert Dürr 	mnLeftBorder        = 0;            // left border
186*cf06609aSHerbert Dürr 	mnTopBorder         = 0;            // top border
187*cf06609aSHerbert Dürr 	mnRightBorder       = 0;            // right border
188*cf06609aSHerbert Dürr 	mnBottomBorder      = 0;            // bottom border
189*cf06609aSHerbert Dürr 	mnX                 = 0;            // X-Position to Parent
190*cf06609aSHerbert Dürr 	mnY                 = 0;            // Y-Position to Parent
191*cf06609aSHerbert Dürr 	mnAbsScreenX        = 0;            // absolute X-position on screen, used for RTL window positioning
192*cf06609aSHerbert Dürr 	mpChildClipRegion   = NULL;         // Child-Clip-Region when ClipChildren
193*cf06609aSHerbert Dürr 	mpPaintRegion       = NULL;         // Paint-ClipRegion
194*cf06609aSHerbert Dürr 	mnStyle             = 0;            // style (init in ImplInitWindow)
195*cf06609aSHerbert Dürr 	mnPrevStyle         = 0;            // prevstyle (set in SetStyle)
196*cf06609aSHerbert Dürr 	mnExtendedStyle     = 0;            // extended style (init in ImplInitWindow)
197*cf06609aSHerbert Dürr 	mnPrevExtendedStyle = 0;            // prevstyle (set in SetExtendedStyle)
198*cf06609aSHerbert Dürr 	mnType              = nType;        // window type
199*cf06609aSHerbert Dürr 	mnGetFocusFlags     = 0;            // Flags fuer GetFocus()-Aufruf
200*cf06609aSHerbert Dürr 	mnWaitCount         = 0;            // Wait-Count (>1 == Warte-MousePointer)
201*cf06609aSHerbert Dürr 	mnPaintFlags        = 0;            // Flags for ImplCallPaint
202*cf06609aSHerbert Dürr 	mnParentClipMode    = 0;            // Flags for Parent-ClipChildren-Mode
203*cf06609aSHerbert Dürr 	mnActivateMode      = 0;            // Wird bei System/Overlap-Windows umgesetzt
204*cf06609aSHerbert Dürr 	mnDlgCtrlFlags      = 0;            // DialogControl-Flags
205*cf06609aSHerbert Dürr 	mnLockCount         = 0;            // LockCount
206*cf06609aSHerbert Dürr 	meAlwaysInputMode   = AlwaysInputNone; // neither AlwaysEnableInput nor AlwaysDisableInput called
207*cf06609aSHerbert Dürr 	mbFrame             = sal_False;        // sal_True: Window is a frame window
208*cf06609aSHerbert Dürr 	mbBorderWin         = sal_False;        // sal_True: Window is a border window
209*cf06609aSHerbert Dürr 	mbOverlapWin        = sal_False;        // sal_True: Window is a overlap window
210*cf06609aSHerbert Dürr 	mbSysWin            = sal_False;        // sal_True: SystemWindow is the base class
211*cf06609aSHerbert Dürr 	mbDialog            = sal_False;        // sal_True: Dialog is the base class
212*cf06609aSHerbert Dürr 	mbDockWin           = sal_False;        // sal_True: DockingWindow is the base class
213*cf06609aSHerbert Dürr 	mbFloatWin          = sal_False;        // sal_True: FloatingWindow is the base class
214*cf06609aSHerbert Dürr 	mbPushButton        = sal_False;        // sal_True: PushButton is the base class
215*cf06609aSHerbert Dürr 	mbToolBox			= sal_False;		// sal_True: ToolBox is the base class
216*cf06609aSHerbert Dürr 	mbMenuFloatingWindow= sal_False;		// sal_True: MenuFloatingWindow is the base class
217*cf06609aSHerbert Dürr 	mbToolbarFloatingWindow= sal_False;		// sal_True: ImplPopupFloatWin is the base class, used for subtoolbars
218*cf06609aSHerbert Dürr 	mbSplitter			= sal_False;		// sal_True: Splitter is the base class
219*cf06609aSHerbert Dürr 	mbVisible           = sal_False;        // sal_True: Show( sal_True ) called
220*cf06609aSHerbert Dürr 	mbOverlapVisible    = sal_False;        // sal_True: Hide called for visible window from ImplHideAllOverlapWindow()
221*cf06609aSHerbert Dürr 	mbDisabled          = sal_False;        // sal_True: Enable( sal_False ) called
222*cf06609aSHerbert Dürr 	mbInputDisabled     = sal_False;        // sal_True: EnableInput( sal_False ) called
223*cf06609aSHerbert Dürr 	mbDropDisabled      = sal_False;        // sal_True: Drop is enabled
224*cf06609aSHerbert Dürr 	mbNoUpdate          = sal_False;        // sal_True: SetUpdateMode( sal_False ) called
225*cf06609aSHerbert Dürr 	mbNoParentUpdate    = sal_False;        // sal_True: SetParentUpdateMode( sal_False ) called
226*cf06609aSHerbert Dürr 	mbActive            = sal_False;        // sal_True: Window Active
227*cf06609aSHerbert Dürr 	mbParentActive      = sal_False;        // sal_True: OverlapActive from Parent
228*cf06609aSHerbert Dürr 	mbReallyVisible     = sal_False;        // sal_True: this and all parents to an overlaped window are visible
229*cf06609aSHerbert Dürr 	mbReallyShown       = sal_False;        // sal_True: this and all parents to an overlaped window are shown
230*cf06609aSHerbert Dürr 	mbInInitShow        = sal_False;        // sal_True: we are in InitShow
231*cf06609aSHerbert Dürr 	mbChildNotify       = sal_False;        // sal_True: ChildNotify
232*cf06609aSHerbert Dürr 	mbChildPtrOverwrite = sal_False;        // sal_True: PointerStyle overwrites Child-Pointer
233*cf06609aSHerbert Dürr 	mbNoPtrVisible      = sal_False;        // sal_True: ShowPointer( sal_False ) called
234*cf06609aSHerbert Dürr 	mbMouseMove         = sal_False;        // sal_True: BaseMouseMove called
235*cf06609aSHerbert Dürr 	mbPaintFrame        = sal_False;        // sal_True: Paint is visible, but not painted
236*cf06609aSHerbert Dürr 	mbInPaint           = sal_False;        // sal_True: Inside PaintHdl
237*cf06609aSHerbert Dürr 	mbMouseButtonDown   = sal_False;        // sal_True: BaseMouseButtonDown called
238*cf06609aSHerbert Dürr 	mbMouseButtonUp     = sal_False;        // sal_True: BaseMouseButtonUp called
239*cf06609aSHerbert Dürr 	mbKeyInput          = sal_False;        // sal_True: BaseKeyInput called
240*cf06609aSHerbert Dürr 	mbKeyUp             = sal_False;        // sal_True: BaseKeyUp called
241*cf06609aSHerbert Dürr 	mbCommand           = sal_False;        // sal_True: BaseCommand called
242*cf06609aSHerbert Dürr 	mbDefPos            = sal_True;         // sal_True: Position is not Set
243*cf06609aSHerbert Dürr 	mbDefSize           = sal_True;         // sal_True: Size is not Set
244*cf06609aSHerbert Dürr 	mbCallMove          = sal_True;         // sal_True: Move must be called by Show
245*cf06609aSHerbert Dürr 	mbCallResize        = sal_True;         // sal_True: Resize must be called by Show
246*cf06609aSHerbert Dürr 	mbWaitSystemResize  = sal_True;         // sal_True: Wait for System-Resize
247*cf06609aSHerbert Dürr 	mbInitWinClipRegion = sal_True;         // sal_True: Calc Window Clip Region
248*cf06609aSHerbert Dürr 	mbInitChildRegion   = sal_False;        // sal_True: InitChildClipRegion
249*cf06609aSHerbert Dürr 	mbWinRegion         = sal_False;        // sal_True: Window Region
250*cf06609aSHerbert Dürr 	mbClipChildren      = sal_False;        // sal_True: request that child-windows get clipped
251*cf06609aSHerbert Dürr 	mbClipSiblings      = sal_False;        // sal_True: request that sibling child-windows get clipped
252*cf06609aSHerbert Dürr 	mbChildTransparent  = sal_False;        // sal_True: allow child-windows to enable transparency (incl. Parent-CLIPCHILDREN)
253*cf06609aSHerbert Dürr 	mbPaintTransparent  = sal_False;        // sal_True: Paints muessen auf Parent ausgeloest werden
254*cf06609aSHerbert Dürr 	mbMouseTransparent  = sal_False;        // sal_True: Window is transparent for Mouse
255*cf06609aSHerbert Dürr 	mbDlgCtrlStart      = sal_False;        // sal_True: Ab hier eigenes Dialog-Control
256*cf06609aSHerbert Dürr 	mbFocusVisible      = sal_False;        // sal_True: Focus Visible
257*cf06609aSHerbert Dürr 	mbUseNativeFocus    = sal_False;
258*cf06609aSHerbert Dürr 	mbNativeFocusVisible= sal_False;        // sal_True: native Focus Visible
259*cf06609aSHerbert Dürr 	mbInShowFocus       = sal_False;        // prevent recursion
260*cf06609aSHerbert Dürr 	mbInHideFocus       = sal_False;        // prevent recursion
261*cf06609aSHerbert Dürr 	mbTrackVisible      = sal_False;        // sal_True: Tracking Visible
262*cf06609aSHerbert Dürr 	mbControlForeground = sal_False;        // sal_True: Foreground-Property set
263*cf06609aSHerbert Dürr 	mbControlBackground = sal_False;        // sal_True: Background-Property set
264*cf06609aSHerbert Dürr 	mbAlwaysOnTop       = sal_False;        // sal_True: window is always on top
265*cf06609aSHerbert Dürr 	mbCompoundControl   = sal_False;        // sal_True: Zusammengesetztes Control => Listener...
266*cf06609aSHerbert Dürr 	mbCompoundControlHasFocus = sal_False;  // sal_True: Zusammengesetztes Control hat irgendwo den Focus
267*cf06609aSHerbert Dürr 	mbPaintDisabled     = sal_False;        // sal_True: to disable paint events
268*cf06609aSHerbert Dürr 	mbAllResize         = sal_False;        // sal_True: to enable sending of ResizeEvents with both height=0 and width=0
269*cf06609aSHerbert Dürr 	mbInDtor            = sal_False;        // sal_True: is set when the window is being destructed
270*cf06609aSHerbert Dürr 	mbExtTextInput      = sal_False;        // sal_True: ExtTextInput-Mode is active
271*cf06609aSHerbert Dürr 	mbInFocusHdl        = sal_False;        // sal_True: is set when inside a  GetFocus-Handler context
272*cf06609aSHerbert Dürr 	mbCreatedWithToolkit = sal_False;
273*cf06609aSHerbert Dürr 	mbSuppressAccessibilityEvents = sal_False; // sal_True: do not send any accessibility events
274*cf06609aSHerbert Dürr 	mbDrawSelectionBackground = sal_False;    // sal_True: draws transparent window background to indicate (toolbox) selection
275*cf06609aSHerbert Dürr 	mbIsInTaskPaneList = sal_False;           // sal_True: window was added to the taskpanelist in the topmost system window
276*cf06609aSHerbert Dürr 	mnNativeBackground  = 0;              // initialize later, depends on type
277*cf06609aSHerbert Dürr 	mbCallHandlersDuringInputDisabled = sal_False; // sal_True: call event handlers even if input is disabled
278*cf06609aSHerbert Dürr 	mbDisableAccessibleLabelForRelation = sal_False; // sal_True: do not set LabelFor relation on accessible objects
279*cf06609aSHerbert Dürr 	mbDisableAccessibleLabeledByRelation = sal_False; // sal_True: do not set LabeledBy relation on accessible objects
280*cf06609aSHerbert Dürr 	mbHelpTextDynamic = sal_False;          // sal_True: append help id in HELP_DEBUG case
281*cf06609aSHerbert Dürr 	mbFakeFocusSet = sal_False; // sal_True: pretend as if the window has focus.
282cdf0e10cSrcweir }
283cdf0e10cSrcweir 
284cdf0e10cSrcweir WindowImpl::~WindowImpl()
285cdf0e10cSrcweir {
286*cf06609aSHerbert Dürr 	delete mpChildClipRegion;
287*cf06609aSHerbert Dürr 	delete mpAccessibleInfos;
288*cf06609aSHerbert Dürr 	delete mpControlFont;
289cdf0e10cSrcweir }
290cdf0e10cSrcweir 
291cdf0e10cSrcweir 
292cdf0e10cSrcweir // -----------------------------------------------------------------------
293cdf0e10cSrcweir 
294cdf0e10cSrcweir // helper method to allow inline constructor even for pWindow!=NULL case
295cdf0e10cSrcweir void ImplDelData::AttachToWindow( const Window* pWindow )
296cdf0e10cSrcweir {
297cdf0e10cSrcweir     if( pWindow )
298cdf0e10cSrcweir         const_cast<Window*>(pWindow)->ImplAddDel( this );
299cdf0e10cSrcweir }
300cdf0e10cSrcweir 
301cdf0e10cSrcweir // -----------------------------------------------------------------------
302cdf0e10cSrcweir 
303cdf0e10cSrcweir // define dtor for ImplDelData
304cdf0e10cSrcweir ImplDelData::~ImplDelData()
305cdf0e10cSrcweir {
306cdf0e10cSrcweir     // #112873# auto remove of ImplDelData
307cdf0e10cSrcweir     // due to this code actively calling ImplRemoveDel() is not mandatory anymore
308cdf0e10cSrcweir     if( !mbDel && mpWindow )
309cdf0e10cSrcweir     {
310cdf0e10cSrcweir         // the window still exists but we were not removed
311cdf0e10cSrcweir         const_cast<Window*>(mpWindow)->ImplRemoveDel( this );
312cdf0e10cSrcweir         mpWindow = NULL;
313cdf0e10cSrcweir     }
314cdf0e10cSrcweir }
315cdf0e10cSrcweir 
316cdf0e10cSrcweir // -----------------------------------------------------------------------
317cdf0e10cSrcweir 
318cdf0e10cSrcweir #ifdef DBG_UTIL
319cdf0e10cSrcweir const char* ImplDbgCheckWindow( const void* pObj )
320cdf0e10cSrcweir {
321cdf0e10cSrcweir     DBG_TESTSOLARMUTEX();
322cdf0e10cSrcweir 
323cdf0e10cSrcweir     const Window* pWindow = (Window*)pObj;
324cdf0e10cSrcweir 
325cdf0e10cSrcweir     if ( (pWindow->GetType() < WINDOW_FIRST) || (pWindow->GetType() > WINDOW_LAST) )
326cdf0e10cSrcweir         return "Window data overwrite";
327cdf0e10cSrcweir 
328cdf0e10cSrcweir     // Fenster-Verkettung ueberpruefen
329cdf0e10cSrcweir     Window* pChild = pWindow->mpWindowImpl->mpFirstChild;
330cdf0e10cSrcweir     while ( pChild )
331cdf0e10cSrcweir     {
332cdf0e10cSrcweir         if ( pChild->mpWindowImpl->mpParent != pWindow )
333cdf0e10cSrcweir             return "Child-Window-Parent wrong";
334cdf0e10cSrcweir         pChild = pChild->mpWindowImpl->mpNext;
335cdf0e10cSrcweir     }
336cdf0e10cSrcweir 
337cdf0e10cSrcweir     return NULL;
338cdf0e10cSrcweir }
339cdf0e10cSrcweir #endif
340cdf0e10cSrcweir 
341cdf0e10cSrcweir // =======================================================================
342cdf0e10cSrcweir 
343cdf0e10cSrcweir void Window::ImplInitAppFontData( Window* pWindow )
344cdf0e10cSrcweir {
345cdf0e10cSrcweir     ImplSVData* pSVData = ImplGetSVData();
346cdf0e10cSrcweir     long nTextHeight = pWindow->GetTextHeight();
347cdf0e10cSrcweir     long nTextWidth = pWindow->GetTextWidth( XubString( RTL_CONSTASCII_USTRINGPARAM( "aemnnxEM" ) ) );
348cdf0e10cSrcweir     long nSymHeight = nTextHeight*4;
349cdf0e10cSrcweir     // Falls Font zu schmal ist, machen wir die Basis breiter,
350cdf0e10cSrcweir     // damit die Dialoge symetrisch aussehen und nicht zu schmal
351cdf0e10cSrcweir     // werden. Wenn der Dialog die gleiche breite hat, geben wir
352cdf0e10cSrcweir     // noch etwas Spielraum dazu, da etwas mehr Platz besser ist.
353cdf0e10cSrcweir     if ( nSymHeight > nTextWidth )
354cdf0e10cSrcweir         nTextWidth = nSymHeight;
355cdf0e10cSrcweir     else if ( nSymHeight+5 > nTextWidth )
356cdf0e10cSrcweir         nTextWidth = nSymHeight+5;
357cdf0e10cSrcweir     pSVData->maGDIData.mnAppFontX = nTextWidth * 10 / 8;
358cdf0e10cSrcweir     pSVData->maGDIData.mnAppFontY = nTextHeight * 10;
359cdf0e10cSrcweir 
360cdf0e10cSrcweir     // FIXME: this is currently only on aqua, check with other
361cdf0e10cSrcweir     // platforms
362cdf0e10cSrcweir     if( pSVData->maNWFData.mbNoFocusRects )
363cdf0e10cSrcweir     {
364cdf0e10cSrcweir         // try to find out wether there is a large correction
365cdf0e10cSrcweir         // of control sizes, if yes, make app font scalings larger
366cdf0e10cSrcweir         // so dialog positioning is not completely off
367cdf0e10cSrcweir         ImplControlValue aControlValue;
368cdf0e10cSrcweir         Rectangle aCtrlRegion( Point(), Size( nTextWidth < 10 ? 10 : nTextWidth, nTextHeight < 10 ? 10 : nTextHeight ) );
369cdf0e10cSrcweir         Rectangle aBoundingRgn( aCtrlRegion );
370cdf0e10cSrcweir         Rectangle aContentRgn( aCtrlRegion );
371cdf0e10cSrcweir         if( pWindow->GetNativeControlRegion( CTRL_EDITBOX, PART_ENTIRE_CONTROL, aCtrlRegion,
372cdf0e10cSrcweir                                              CTRL_STATE_ENABLED, aControlValue, rtl::OUString(),
373cdf0e10cSrcweir                                              aBoundingRgn, aContentRgn ) )
374cdf0e10cSrcweir         {
375cdf0e10cSrcweir             // comment: the magical +6 is for the extra border in bordered
376cdf0e10cSrcweir             // (which is the standard) edit fields
377cdf0e10cSrcweir             if( aContentRgn.GetHeight() - nTextHeight > (nTextHeight+4)/4 )
378cdf0e10cSrcweir                 pSVData->maGDIData.mnAppFontY = (aContentRgn.GetHeight()-4) * 10;
379cdf0e10cSrcweir         }
380cdf0e10cSrcweir     }
381cdf0e10cSrcweir 
382cdf0e10cSrcweir 
383cdf0e10cSrcweir     pSVData->maGDIData.mnRealAppFontX = pSVData->maGDIData.mnAppFontX;
384cdf0e10cSrcweir     if ( pSVData->maAppData.mnDialogScaleX )
385cdf0e10cSrcweir         pSVData->maGDIData.mnAppFontX += (pSVData->maGDIData.mnAppFontX*pSVData->maAppData.mnDialogScaleX)/100;
386cdf0e10cSrcweir }
387cdf0e10cSrcweir 
388cdf0e10cSrcweir // -----------------------------------------------------------------------
389cdf0e10cSrcweir 
390cdf0e10cSrcweir bool Window::ImplCheckUIFont( const Font& rFont )
391cdf0e10cSrcweir {
392cdf0e10cSrcweir     if( ImplGetSVData()->maGDIData.mbNativeFontConfig )
393cdf0e10cSrcweir         return true;
394cdf0e10cSrcweir 
395cdf0e10cSrcweir 	// create a text string using the localized text of important buttons
396cdf0e10cSrcweir 	String aTestText;
397cdf0e10cSrcweir 	static const StandardButtonType aTestButtons[] =
398cdf0e10cSrcweir 	{
399cdf0e10cSrcweir 		BUTTON_OK, BUTTON_CANCEL, BUTTON_CLOSE, BUTTON_ABORT,
400cdf0e10cSrcweir 		BUTTON_YES, BUTTON_NO, BUTTON_MORE, BUTTON_IGNORE,
401cdf0e10cSrcweir 		BUTTON_RETRY, BUTTON_HELP
402cdf0e10cSrcweir 	};
403cdf0e10cSrcweir 
404cdf0e10cSrcweir 	const int nTestButtonCount = sizeof(aTestButtons)/sizeof(*aTestButtons);
405cdf0e10cSrcweir 	for( int n = 0; n < nTestButtonCount; ++n )
406cdf0e10cSrcweir 	{
407cdf0e10cSrcweir 		String aButtonStr = Button::GetStandardText( aTestButtons[n] );
408cdf0e10cSrcweir 		// #i115432# ignore mnemonic+accelerator part of each string
409cdf0e10cSrcweir 		// TODO: use a string filtering method when it becomes available
410cdf0e10cSrcweir 		const int nLen = aButtonStr.Len();
411cdf0e10cSrcweir 		bool bInside = false;
412cdf0e10cSrcweir 		for( int i = 0; i < nLen; ++i ) {
413cdf0e10cSrcweir 			const sal_Unicode c = aButtonStr.GetChar( i );
414cdf0e10cSrcweir 			if( (c == '('))
415cdf0e10cSrcweir 				bInside = true;
416cdf0e10cSrcweir 			if( (c == ')'))
417cdf0e10cSrcweir 				bInside = false;
418cdf0e10cSrcweir 			if( (c == '~')
419cdf0e10cSrcweir 			||  (c == '(') || (c == ')')
420cdf0e10cSrcweir 			|| ((c >= 'A') && (c <= 'Z') && bInside) )
421cdf0e10cSrcweir 				aButtonStr.SetChar( i, ' ' );
422cdf0e10cSrcweir 		}
423cdf0e10cSrcweir 		// append sanitized button text to test string
424cdf0e10cSrcweir 		aTestText.Append( aButtonStr );
425cdf0e10cSrcweir 	}
426cdf0e10cSrcweir 
427cdf0e10cSrcweir 	const int nFirstChar = HasGlyphs( rFont, aTestText );
428cdf0e10cSrcweir 	const bool bUIFontOk = (nFirstChar >= aTestText.Len());
429cdf0e10cSrcweir 	return bUIFontOk;
430cdf0e10cSrcweir }
431cdf0e10cSrcweir 
432cdf0e10cSrcweir // -----------------------------------------------------------------------
433cdf0e10cSrcweir 
434cdf0e10cSrcweir void Window::ImplUpdateGlobalSettings( AllSettings& rSettings, sal_Bool bCallHdl )
435cdf0e10cSrcweir {
436cdf0e10cSrcweir     // reset high contrast to false, so the system can either update it
437cdf0e10cSrcweir     // or AutoDetectSystemHC can kick in (see below)
438cdf0e10cSrcweir     StyleSettings aTmpSt( rSettings.GetStyleSettings() );
439cdf0e10cSrcweir     aTmpSt.SetHighContrastMode( sal_False );
440cdf0e10cSrcweir     rSettings.SetStyleSettings( aTmpSt );
441cdf0e10cSrcweir     ImplGetFrame()->UpdateSettings( rSettings );
442cdf0e10cSrcweir     // reset default border width for layouters
443cdf0e10cSrcweir     ImplGetSVData()->maAppData.mnDefaultLayoutBorder = -1;
444cdf0e10cSrcweir 
445cdf0e10cSrcweir     // Verify availability of the configured UI font, otherwise choose "Andale Sans UI"
446cdf0e10cSrcweir     String aUserInterfaceFont;
447cdf0e10cSrcweir     bool bUseSystemFont = rSettings.GetStyleSettings().GetUseSystemUIFonts();
448cdf0e10cSrcweir 
449cdf0e10cSrcweir     // check whether system UI font can display a typical UI text
450cdf0e10cSrcweir     if( bUseSystemFont )
451cdf0e10cSrcweir         bUseSystemFont = ImplCheckUIFont( rSettings.GetStyleSettings().GetAppFont() );
452cdf0e10cSrcweir 
453cdf0e10cSrcweir     if ( !bUseSystemFont )
454cdf0e10cSrcweir     {
455cdf0e10cSrcweir         ImplInitFontList();
456cdf0e10cSrcweir         String aConfigFont = utl::DefaultFontConfiguration::get()->getUserInterfaceFont( rSettings.GetUILocale() );
457cdf0e10cSrcweir         xub_StrLen nIndex = 0;
458cdf0e10cSrcweir         while( nIndex != STRING_NOTFOUND )
459cdf0e10cSrcweir         {
460cdf0e10cSrcweir             String aName( aConfigFont.GetToken( 0, ';', nIndex ) );
461cdf0e10cSrcweir             if ( aName.Len() && mpWindowImpl->mpFrameData->mpFontList->FindFontFamily( aName ) )
462cdf0e10cSrcweir             {
463cdf0e10cSrcweir                 aUserInterfaceFont = aConfigFont;
464cdf0e10cSrcweir                 break;
465cdf0e10cSrcweir             }
466cdf0e10cSrcweir         }
467cdf0e10cSrcweir 
468cdf0e10cSrcweir         if ( ! aUserInterfaceFont.Len() )
469cdf0e10cSrcweir         {
470cdf0e10cSrcweir             String aFallbackFont (RTL_CONSTASCII_USTRINGPARAM( "Andale Sans UI" ));
471cdf0e10cSrcweir             if ( mpWindowImpl->mpFrameData->mpFontList->FindFontFamily( aFallbackFont ) )
472cdf0e10cSrcweir                 aUserInterfaceFont = aFallbackFont;
473cdf0e10cSrcweir         }
474cdf0e10cSrcweir     }
475cdf0e10cSrcweir 
476cdf0e10cSrcweir     if ( !bUseSystemFont && aUserInterfaceFont.Len() )
477cdf0e10cSrcweir     {
478cdf0e10cSrcweir         StyleSettings aStyleSettings = rSettings.GetStyleSettings();
479cdf0e10cSrcweir         Font aFont = aStyleSettings.GetAppFont();
480cdf0e10cSrcweir         aFont.SetName( aUserInterfaceFont );
481cdf0e10cSrcweir         aStyleSettings.SetAppFont( aFont );
482cdf0e10cSrcweir         aFont = aStyleSettings.GetHelpFont();
483cdf0e10cSrcweir         aFont.SetName( aUserInterfaceFont );
484cdf0e10cSrcweir         aStyleSettings.SetHelpFont( aFont );
485cdf0e10cSrcweir         aFont = aStyleSettings.GetTitleFont();
486cdf0e10cSrcweir         aFont.SetName( aUserInterfaceFont );
487cdf0e10cSrcweir         aStyleSettings.SetTitleFont( aFont );
488cdf0e10cSrcweir         aFont = aStyleSettings.GetFloatTitleFont();
489cdf0e10cSrcweir         aFont.SetName( aUserInterfaceFont );
490cdf0e10cSrcweir         aStyleSettings.SetFloatTitleFont( aFont );
491cdf0e10cSrcweir         aFont = aStyleSettings.GetMenuFont();
492cdf0e10cSrcweir         aFont.SetName( aUserInterfaceFont );
493cdf0e10cSrcweir         aStyleSettings.SetMenuFont( aFont );
494cdf0e10cSrcweir         aFont = aStyleSettings.GetToolFont();
495cdf0e10cSrcweir         aFont.SetName( aUserInterfaceFont );
496cdf0e10cSrcweir         aStyleSettings.SetToolFont( aFont );
497cdf0e10cSrcweir         aFont = aStyleSettings.GetLabelFont();
498cdf0e10cSrcweir         aFont.SetName( aUserInterfaceFont );
499cdf0e10cSrcweir         aStyleSettings.SetLabelFont( aFont );
500cdf0e10cSrcweir         aFont = aStyleSettings.GetInfoFont();
501cdf0e10cSrcweir         aFont.SetName( aUserInterfaceFont );
502cdf0e10cSrcweir         aStyleSettings.SetInfoFont( aFont );
503cdf0e10cSrcweir         aFont = aStyleSettings.GetRadioCheckFont();
504cdf0e10cSrcweir         aFont.SetName( aUserInterfaceFont );
505cdf0e10cSrcweir         aStyleSettings.SetRadioCheckFont( aFont );
506cdf0e10cSrcweir         aFont = aStyleSettings.GetPushButtonFont();
507cdf0e10cSrcweir         aFont.SetName( aUserInterfaceFont );
508cdf0e10cSrcweir         aStyleSettings.SetPushButtonFont( aFont );
509cdf0e10cSrcweir         aFont = aStyleSettings.GetFieldFont();
510cdf0e10cSrcweir         aFont.SetName( aUserInterfaceFont );
511cdf0e10cSrcweir         aStyleSettings.SetFieldFont( aFont );
512cdf0e10cSrcweir         aFont = aStyleSettings.GetIconFont();
513cdf0e10cSrcweir         aFont.SetName( aUserInterfaceFont );
514cdf0e10cSrcweir         aStyleSettings.SetIconFont( aFont );
515cdf0e10cSrcweir         aFont = aStyleSettings.GetGroupFont();
516cdf0e10cSrcweir         aFont.SetName( aUserInterfaceFont );
517cdf0e10cSrcweir         aStyleSettings.SetGroupFont( aFont );
518cdf0e10cSrcweir         rSettings.SetStyleSettings( aStyleSettings );
519cdf0e10cSrcweir     }
520cdf0e10cSrcweir 
521cdf0e10cSrcweir     StyleSettings aStyleSettings = rSettings.GetStyleSettings();
522cdf0e10cSrcweir     // #97047: Force all fonts except Menu and Help to a fixed height
523cdf0e10cSrcweir     // to avoid UI scaling due to large fonts
524cdf0e10cSrcweir     // - but allow bigger fonts on bigger screens (i16682, i21238)
525cdf0e10cSrcweir     //   dialogs were designed to fit 800x600 with an 8pt font, so scale accordingly
526cdf0e10cSrcweir     int maxFontheight = 9; // #107886#: 9 is default for some asian systems, so always allow if requested
527cdf0e10cSrcweir     if( GetDesktopRectPixel().getHeight() > 600 )
528cdf0e10cSrcweir         maxFontheight = (int) ((( 8.0 * (double) GetDesktopRectPixel().getHeight()) / 600.0) + 1.5);
529cdf0e10cSrcweir 
530cdf0e10cSrcweir     Font aFont = aStyleSettings.GetMenuFont();
531cdf0e10cSrcweir     int defFontheight = aFont.GetHeight();
532cdf0e10cSrcweir     if( defFontheight > maxFontheight )
533cdf0e10cSrcweir         defFontheight = maxFontheight;
534cdf0e10cSrcweir 
535cdf0e10cSrcweir     // if the UI is korean, chinese or another locale
536cdf0e10cSrcweir     // where the system font size is kown to be often too small to
537cdf0e10cSrcweir     // generate readable fonts enforce a minimum font size of 9 points
538cdf0e10cSrcweir     bool bBrokenLangFontHeight = false;
539cdf0e10cSrcweir     static const LanguageType eBrokenSystemFontSizeLanguages[] =
540cdf0e10cSrcweir     { LANGUAGE_KOREAN, LANGUAGE_KOREAN_JOHAB,
541cdf0e10cSrcweir       LANGUAGE_CHINESE_HONGKONG, LANGUAGE_CHINESE_MACAU, LANGUAGE_CHINESE_SIMPLIFIED, LANGUAGE_CHINESE_SINGAPORE, LANGUAGE_CHINESE_TRADITIONAL
542cdf0e10cSrcweir     };
543cdf0e10cSrcweir     static std::set< LanguageType > aBrokenSystemFontSizeLanguagesSet(
544cdf0e10cSrcweir         eBrokenSystemFontSizeLanguages,
545cdf0e10cSrcweir         eBrokenSystemFontSizeLanguages +
546cdf0e10cSrcweir         (sizeof(eBrokenSystemFontSizeLanguages)/sizeof(eBrokenSystemFontSizeLanguages[0]))
547cdf0e10cSrcweir         );
548cdf0e10cSrcweir     LanguageType aLang = Application::GetSettings().GetUILanguage();
549cdf0e10cSrcweir     if( aBrokenSystemFontSizeLanguagesSet.find( aLang ) != aBrokenSystemFontSizeLanguagesSet.end() )
550cdf0e10cSrcweir     {
551cdf0e10cSrcweir         defFontheight = Max(9, defFontheight);
552cdf0e10cSrcweir         bBrokenLangFontHeight = true;
553cdf0e10cSrcweir     }
554cdf0e10cSrcweir 
555cdf0e10cSrcweir     // i22098, toolfont will be scaled differently to avoid bloated rulers and status bars for big fonts
556cdf0e10cSrcweir     int toolfontheight = defFontheight;
557cdf0e10cSrcweir     if( toolfontheight > 9 )
558cdf0e10cSrcweir         toolfontheight = (defFontheight+8) / 2;
559cdf0e10cSrcweir 
560cdf0e10cSrcweir     aFont = aStyleSettings.GetAppFont();
561cdf0e10cSrcweir     aFont.SetHeight( defFontheight );
562cdf0e10cSrcweir     aStyleSettings.SetAppFont( aFont );
563cdf0e10cSrcweir     aFont = aStyleSettings.GetTitleFont();
564cdf0e10cSrcweir     aFont.SetHeight( defFontheight );
565cdf0e10cSrcweir     aStyleSettings.SetTitleFont( aFont );
566cdf0e10cSrcweir     aFont = aStyleSettings.GetFloatTitleFont();
567cdf0e10cSrcweir     aFont.SetHeight( defFontheight );
568cdf0e10cSrcweir     aStyleSettings.SetFloatTitleFont( aFont );
569cdf0e10cSrcweir     // keep menu and help font size from system unless in broken locale size
570cdf0e10cSrcweir     if( bBrokenLangFontHeight )
571cdf0e10cSrcweir     {
572cdf0e10cSrcweir         aFont = aStyleSettings.GetMenuFont();
573cdf0e10cSrcweir         if( aFont.GetHeight() < defFontheight )
574cdf0e10cSrcweir         {
575cdf0e10cSrcweir             aFont.SetHeight( defFontheight );
576cdf0e10cSrcweir             aStyleSettings.SetMenuFont( aFont );
577cdf0e10cSrcweir         }
578cdf0e10cSrcweir         aFont = aStyleSettings.GetHelpFont();
579cdf0e10cSrcweir         if( aFont.GetHeight() < defFontheight )
580cdf0e10cSrcweir         {
581cdf0e10cSrcweir             aFont.SetHeight( defFontheight );
582cdf0e10cSrcweir             aStyleSettings.SetHelpFont( aFont );
583cdf0e10cSrcweir         }
584cdf0e10cSrcweir     }
585cdf0e10cSrcweir 
586cdf0e10cSrcweir     // use different height for toolfont
587cdf0e10cSrcweir     aFont = aStyleSettings.GetToolFont();
588cdf0e10cSrcweir     aFont.SetHeight( toolfontheight );
589cdf0e10cSrcweir     aStyleSettings.SetToolFont( aFont );
590cdf0e10cSrcweir 
591cdf0e10cSrcweir     aFont = aStyleSettings.GetLabelFont();
592cdf0e10cSrcweir     aFont.SetHeight( defFontheight );
593cdf0e10cSrcweir     aStyleSettings.SetLabelFont( aFont );
594cdf0e10cSrcweir     aFont = aStyleSettings.GetInfoFont();
595cdf0e10cSrcweir     aFont.SetHeight( defFontheight );
596cdf0e10cSrcweir     aStyleSettings.SetInfoFont( aFont );
597cdf0e10cSrcweir     aFont = aStyleSettings.GetRadioCheckFont();
598cdf0e10cSrcweir     aFont.SetHeight( defFontheight );
599cdf0e10cSrcweir     aStyleSettings.SetRadioCheckFont( aFont );
600cdf0e10cSrcweir     aFont = aStyleSettings.GetPushButtonFont();
601cdf0e10cSrcweir     aFont.SetHeight( defFontheight );
602cdf0e10cSrcweir     aStyleSettings.SetPushButtonFont( aFont );
603cdf0e10cSrcweir     aFont = aStyleSettings.GetFieldFont();
604cdf0e10cSrcweir     aFont.SetHeight( defFontheight );
605cdf0e10cSrcweir     aStyleSettings.SetFieldFont( aFont );
606cdf0e10cSrcweir     aFont = aStyleSettings.GetIconFont();
607cdf0e10cSrcweir     aFont.SetHeight( defFontheight );
608cdf0e10cSrcweir     aStyleSettings.SetIconFont( aFont );
609cdf0e10cSrcweir     aFont = aStyleSettings.GetGroupFont();
610cdf0e10cSrcweir     aFont.SetHeight( defFontheight );
611cdf0e10cSrcweir     aStyleSettings.SetGroupFont( aFont );
612cdf0e10cSrcweir 
613cdf0e10cSrcweir     // set workspace gradient to black in dark themes
614cdf0e10cSrcweir     if( aStyleSettings.GetWindowColor().IsDark() )
615cdf0e10cSrcweir         aStyleSettings.SetWorkspaceGradient( Wallpaper( Color( COL_BLACK ) ) );
616cdf0e10cSrcweir     else
617cdf0e10cSrcweir     {
618cdf0e10cSrcweir         Gradient aGrad( GRADIENT_LINEAR, DEFAULT_WORKSPACE_GRADIENT_START_COLOR, DEFAULT_WORKSPACE_GRADIENT_END_COLOR );
619cdf0e10cSrcweir         aStyleSettings.SetWorkspaceGradient( Wallpaper( aGrad ) );
620cdf0e10cSrcweir     }
621cdf0e10cSrcweir 
622cdf0e10cSrcweir     rSettings.SetStyleSettings( aStyleSettings );
623cdf0e10cSrcweir 
624cdf0e10cSrcweir 
625cdf0e10cSrcweir     // auto detect HC mode; if the system already set it to "yes"
626cdf0e10cSrcweir     // (see above) then accept that
627cdf0e10cSrcweir     if( !rSettings.GetStyleSettings().GetHighContrastMode() )
628cdf0e10cSrcweir     {
629cdf0e10cSrcweir         sal_Bool bTmp = sal_False, bAutoHCMode = sal_True;
630cdf0e10cSrcweir         utl::OConfigurationNode aNode = utl::OConfigurationTreeRoot::tryCreateWithServiceFactory(
631cdf0e10cSrcweir             vcl::unohelper::GetMultiServiceFactory(),
632cdf0e10cSrcweir             OUString::createFromAscii( "org.openoffice.Office.Common/Accessibility" ) );    // note: case sensisitive !
633cdf0e10cSrcweir         if ( aNode.isValid() )
634cdf0e10cSrcweir         {
635cdf0e10cSrcweir             ::com::sun::star::uno::Any aValue = aNode.getNodeValue( OUString::createFromAscii( "AutoDetectSystemHC" ) );
636cdf0e10cSrcweir             if( aValue >>= bTmp )
637cdf0e10cSrcweir                 bAutoHCMode = bTmp;
638cdf0e10cSrcweir         }
639cdf0e10cSrcweir         if( bAutoHCMode )
640cdf0e10cSrcweir         {
641cdf0e10cSrcweir             if( rSettings.GetStyleSettings().GetFaceColor().IsDark()
642cdf0e10cSrcweir              || rSettings.GetStyleSettings().GetWindowColor().IsDark() )
643cdf0e10cSrcweir             {
644cdf0e10cSrcweir                 aStyleSettings = rSettings.GetStyleSettings();
645cdf0e10cSrcweir                 aStyleSettings.SetHighContrastMode( sal_True );
646cdf0e10cSrcweir                 rSettings.SetStyleSettings( aStyleSettings );
647cdf0e10cSrcweir             }
648cdf0e10cSrcweir         }
649cdf0e10cSrcweir     }
650cdf0e10cSrcweir 
651cdf0e10cSrcweir     static const char* pEnvHC = getenv( "SAL_FORCE_HC" );
652cdf0e10cSrcweir     if( pEnvHC && *pEnvHC )
653cdf0e10cSrcweir     {
654cdf0e10cSrcweir         aStyleSettings.SetHighContrastMode( sal_True );
655cdf0e10cSrcweir         rSettings.SetStyleSettings( aStyleSettings );
656cdf0e10cSrcweir     }
657cdf0e10cSrcweir 
658cdf0e10cSrcweir #ifdef DBG_UTIL
659cdf0e10cSrcweir     // Evt. AppFont auf Fett schalten, damit man feststellen kann,
660cdf0e10cSrcweir     // ob fuer die Texte auf anderen Systemen genuegend Platz
661cdf0e10cSrcweir     // vorhanden ist
662cdf0e10cSrcweir     if ( DbgIsBoldAppFont() )
663cdf0e10cSrcweir     {
664cdf0e10cSrcweir         aStyleSettings = rSettings.GetStyleSettings();
665cdf0e10cSrcweir         aFont = aStyleSettings.GetAppFont();
666cdf0e10cSrcweir         aFont.SetWeight( WEIGHT_BOLD );
667cdf0e10cSrcweir         aStyleSettings.SetAppFont( aFont );
668cdf0e10cSrcweir         aFont = aStyleSettings.GetGroupFont();
669cdf0e10cSrcweir         aFont.SetWeight( WEIGHT_BOLD );
670cdf0e10cSrcweir         aStyleSettings.SetGroupFont( aFont );
671cdf0e10cSrcweir         aFont = aStyleSettings.GetLabelFont();
672cdf0e10cSrcweir         aFont.SetWeight( WEIGHT_BOLD );
673cdf0e10cSrcweir         aStyleSettings.SetLabelFont( aFont );
674cdf0e10cSrcweir         aFont = aStyleSettings.GetRadioCheckFont();
675cdf0e10cSrcweir         aFont.SetWeight( WEIGHT_BOLD );
676cdf0e10cSrcweir         aStyleSettings.SetRadioCheckFont( aFont );
677cdf0e10cSrcweir         aFont = aStyleSettings.GetPushButtonFont();
678cdf0e10cSrcweir         aFont.SetWeight( WEIGHT_BOLD );
679cdf0e10cSrcweir         aStyleSettings.SetPushButtonFont( aFont );
680cdf0e10cSrcweir         aFont = aStyleSettings.GetFieldFont();
681cdf0e10cSrcweir         aFont.SetWeight( WEIGHT_BOLD );
682cdf0e10cSrcweir         aStyleSettings.SetFieldFont( aFont );
683cdf0e10cSrcweir         aFont = aStyleSettings.GetIconFont();
684cdf0e10cSrcweir         aFont.SetWeight( WEIGHT_BOLD );
685cdf0e10cSrcweir         aStyleSettings.SetIconFont( aFont );
686cdf0e10cSrcweir         rSettings.SetStyleSettings( aStyleSettings );
687cdf0e10cSrcweir     }
688cdf0e10cSrcweir #endif
689cdf0e10cSrcweir 
690cdf0e10cSrcweir     if ( bCallHdl )
691cdf0e10cSrcweir         GetpApp()->SystemSettingsChanging( rSettings, this );
692cdf0e10cSrcweir }
693cdf0e10cSrcweir 
694cdf0e10cSrcweir // -----------------------------------------------------------------------
695cdf0e10cSrcweir 
696cdf0e10cSrcweir MouseEvent ImplTranslateMouseEvent( const MouseEvent& rE, Window* pSource, Window* pDest )
697cdf0e10cSrcweir {
698cdf0e10cSrcweir     Point aPos = pSource->OutputToScreenPixel( rE.GetPosPixel() );
699cdf0e10cSrcweir     aPos = pDest->ScreenToOutputPixel( aPos );
700cdf0e10cSrcweir     return MouseEvent( aPos, rE.GetClicks(), rE.GetMode(), rE.GetButtons(), rE.GetModifier() );
701cdf0e10cSrcweir }
702cdf0e10cSrcweir 
703cdf0e10cSrcweir // -----------------------------------------------------------------------
704cdf0e10cSrcweir 
705cdf0e10cSrcweir CommandEvent ImplTranslateCommandEvent( const CommandEvent& rCEvt, Window* pSource, Window* pDest )
706cdf0e10cSrcweir {
707cdf0e10cSrcweir     if ( !rCEvt.IsMouseEvent() )
708cdf0e10cSrcweir         return rCEvt;
709cdf0e10cSrcweir 
710cdf0e10cSrcweir     Point aPos = pSource->OutputToScreenPixel( rCEvt.GetMousePosPixel() );
711cdf0e10cSrcweir     aPos = pDest->ScreenToOutputPixel( aPos );
712cdf0e10cSrcweir     return CommandEvent( aPos, rCEvt.GetCommand(), rCEvt.IsMouseEvent(), rCEvt.GetData() );
713cdf0e10cSrcweir }
714cdf0e10cSrcweir 
715cdf0e10cSrcweir // =======================================================================
716cdf0e10cSrcweir 
717cdf0e10cSrcweir void Window::ImplInitWindowData( WindowType nType )
718cdf0e10cSrcweir {
719*cf06609aSHerbert Dürr     mpWindowImpl = new WindowImpl( nType );
720cdf0e10cSrcweir 
721cdf0e10cSrcweir     meOutDevType        = OUTDEV_WINDOW;
722cdf0e10cSrcweir 
723cdf0e10cSrcweir     mbEnableRTL         = Application::GetSettings().GetLayoutRTL();         // sal_True: this outdev will be mirrored if RTL window layout (UI mirroring) is globally active
724cdf0e10cSrcweir }
725cdf0e10cSrcweir 
726cdf0e10cSrcweir // -----------------------------------------------------------------------
727cdf0e10cSrcweir 
728cdf0e10cSrcweir void Window::ImplInit( Window* pParent, WinBits nStyle, const ::com::sun::star::uno::Any& /*aSystemWorkWindowToken*/ )
729cdf0e10cSrcweir {
730cdf0e10cSrcweir     ImplInit( pParent, nStyle, NULL );
731cdf0e10cSrcweir }
732cdf0e10cSrcweir 
733cdf0e10cSrcweir // -----------------------------------------------------------------------
734cdf0e10cSrcweir 
735cdf0e10cSrcweir void Window::ImplInit( Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData )
736cdf0e10cSrcweir {
737cdf0e10cSrcweir     DBG_ASSERT( mpWindowImpl->mbFrame || pParent, "Window::Window(): pParent == NULL" );
738cdf0e10cSrcweir 
739cdf0e10cSrcweir     ImplSVData* pSVData = ImplGetSVData();
740cdf0e10cSrcweir     Window*     pRealParent = pParent;
741cdf0e10cSrcweir 
742cdf0e10cSrcweir     // 3D-Look vererben
743cdf0e10cSrcweir     if ( !mpWindowImpl->mbOverlapWin && pParent && (pParent->GetStyle() & WB_3DLOOK) )
744cdf0e10cSrcweir         nStyle |= WB_3DLOOK;
745cdf0e10cSrcweir 
746cdf0e10cSrcweir     // create border window if necessary
747cdf0e10cSrcweir     if ( !mpWindowImpl->mbFrame && !mpWindowImpl->mbBorderWin && !mpWindowImpl->mpBorderWindow
748cdf0e10cSrcweir          && (nStyle & (WB_BORDER | WB_SYSTEMCHILDWINDOW) ) )
749cdf0e10cSrcweir     {
750cdf0e10cSrcweir         sal_uInt16 nBorderTypeStyle = 0;
751cdf0e10cSrcweir         if( (nStyle & WB_SYSTEMCHILDWINDOW) )
752cdf0e10cSrcweir         {
753cdf0e10cSrcweir             // handle WB_SYSTEMCHILDWINDOW
754cdf0e10cSrcweir             // these should be analogous to a top level frame; meaning they
755cdf0e10cSrcweir             // should have a border window with style BORDERWINDOW_STYLE_FRAME
756cdf0e10cSrcweir             // which controls their size
757cdf0e10cSrcweir             nBorderTypeStyle |= BORDERWINDOW_STYLE_FRAME;
758cdf0e10cSrcweir             nStyle |= WB_BORDER;
759cdf0e10cSrcweir         }
760cdf0e10cSrcweir         ImplBorderWindow* pBorderWin = new ImplBorderWindow( pParent, nStyle & (WB_BORDER | WB_DIALOGCONTROL | WB_NODIALOGCONTROL | WB_NEEDSFOCUS), nBorderTypeStyle );
761cdf0e10cSrcweir         ((Window*)pBorderWin)->mpWindowImpl->mpClientWindow = this;
762cdf0e10cSrcweir         pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
763cdf0e10cSrcweir         mpWindowImpl->mpBorderWindow  = pBorderWin;
764cdf0e10cSrcweir         pParent = mpWindowImpl->mpBorderWindow;
765cdf0e10cSrcweir     }
766cdf0e10cSrcweir     else if( !mpWindowImpl->mbFrame && ! pParent )
767cdf0e10cSrcweir     {
768cdf0e10cSrcweir         mpWindowImpl->mbOverlapWin  = sal_True;
769cdf0e10cSrcweir         mpWindowImpl->mbFrame = sal_True;
770cdf0e10cSrcweir     }
771cdf0e10cSrcweir 
772cdf0e10cSrcweir     // insert window in list
773cdf0e10cSrcweir     ImplInsertWindow( pParent );
774cdf0e10cSrcweir     mpWindowImpl->mnStyle = nStyle;
775cdf0e10cSrcweir 
776cdf0e10cSrcweir     // Overlap-Window-Daten
777cdf0e10cSrcweir     if ( mpWindowImpl->mbOverlapWin )
778cdf0e10cSrcweir     {
779cdf0e10cSrcweir         mpWindowImpl->mpOverlapData                   = new ImplOverlapData;
780cdf0e10cSrcweir         mpWindowImpl->mpOverlapData->mpSaveBackDev    = NULL;
781cdf0e10cSrcweir         mpWindowImpl->mpOverlapData->mpSaveBackRgn    = NULL;
782cdf0e10cSrcweir         mpWindowImpl->mpOverlapData->mpNextBackWin    = NULL;
783cdf0e10cSrcweir         mpWindowImpl->mpOverlapData->mnSaveBackSize   = 0;
784cdf0e10cSrcweir         mpWindowImpl->mpOverlapData->mbSaveBack       = sal_False;
785cdf0e10cSrcweir         mpWindowImpl->mpOverlapData->mnTopLevel       = 1;
786cdf0e10cSrcweir     }
787cdf0e10cSrcweir 
788cdf0e10cSrcweir     if( pParent && ! mpWindowImpl->mbFrame )
789cdf0e10cSrcweir         mbEnableRTL = pParent->mbEnableRTL;
790cdf0e10cSrcweir 
791cdf0e10cSrcweir     // test for frame creation
792cdf0e10cSrcweir     if ( mpWindowImpl->mbFrame )
793cdf0e10cSrcweir     {
794cdf0e10cSrcweir         // create frame
795cdf0e10cSrcweir         sal_uLong nFrameStyle = 0;
796cdf0e10cSrcweir 
797cdf0e10cSrcweir         if ( nStyle & WB_MOVEABLE )
798cdf0e10cSrcweir             nFrameStyle |= SAL_FRAME_STYLE_MOVEABLE;
799cdf0e10cSrcweir         if ( nStyle & WB_SIZEABLE )
800cdf0e10cSrcweir             nFrameStyle |= SAL_FRAME_STYLE_SIZEABLE;
801cdf0e10cSrcweir         if ( nStyle & WB_CLOSEABLE )
802cdf0e10cSrcweir             nFrameStyle |= SAL_FRAME_STYLE_CLOSEABLE;
803cdf0e10cSrcweir         if ( nStyle & WB_APP )
804cdf0e10cSrcweir             nFrameStyle |= SAL_FRAME_STYLE_DEFAULT;
805cdf0e10cSrcweir         // check for undecorated floating window
806cdf0e10cSrcweir         if( // 1. floating windows that are not moveable/sizeable (only closeable allowed)
807cdf0e10cSrcweir             ( !(nFrameStyle & ~SAL_FRAME_STYLE_CLOSEABLE) &&
808cdf0e10cSrcweir             ( mpWindowImpl->mbFloatWin || ((GetType() == WINDOW_BORDERWINDOW) && ((ImplBorderWindow*)this)->mbFloatWindow) || (nStyle & WB_SYSTEMFLOATWIN) ) ) ||
809cdf0e10cSrcweir             // 2. borderwindows of floaters with ownerdraw decoration
810cdf0e10cSrcweir             ( ((GetType() == WINDOW_BORDERWINDOW) && ((ImplBorderWindow*)this)->mbFloatWindow && (nStyle & WB_OWNERDRAWDECORATION) ) ) )
811cdf0e10cSrcweir         {
812cdf0e10cSrcweir             nFrameStyle = SAL_FRAME_STYLE_FLOAT;
813cdf0e10cSrcweir             if( nStyle & WB_OWNERDRAWDECORATION )
814cdf0e10cSrcweir                 nFrameStyle |= (SAL_FRAME_STYLE_OWNERDRAWDECORATION | SAL_FRAME_STYLE_NOSHADOW);
815cdf0e10cSrcweir             if( nStyle & WB_NEEDSFOCUS )
816cdf0e10cSrcweir                 nFrameStyle |= SAL_FRAME_STYLE_FLOAT_FOCUSABLE;
817cdf0e10cSrcweir         }
818cdf0e10cSrcweir         else if( mpWindowImpl->mbFloatWin )
819cdf0e10cSrcweir             nFrameStyle |= SAL_FRAME_STYLE_TOOLWINDOW;
820cdf0e10cSrcweir 
821cdf0e10cSrcweir         if( nStyle & WB_INTROWIN )
822cdf0e10cSrcweir             nFrameStyle |= SAL_FRAME_STYLE_INTRO;
823cdf0e10cSrcweir         if( nStyle & WB_TOOLTIPWIN )
824cdf0e10cSrcweir             nFrameStyle |= SAL_FRAME_STYLE_TOOLTIP;
825cdf0e10cSrcweir 
826cdf0e10cSrcweir         if( nStyle & WB_NOSHADOW )
827cdf0e10cSrcweir             nFrameStyle |= SAL_FRAME_STYLE_NOSHADOW;
828cdf0e10cSrcweir 
829cdf0e10cSrcweir         if( nStyle & WB_SYSTEMCHILDWINDOW )
830cdf0e10cSrcweir             nFrameStyle |= SAL_FRAME_STYLE_SYSTEMCHILD;
831cdf0e10cSrcweir 
832cdf0e10cSrcweir         switch (mpWindowImpl->mnType)
833cdf0e10cSrcweir         {
834cdf0e10cSrcweir             case WINDOW_DIALOG:
835cdf0e10cSrcweir             case WINDOW_TABDIALOG:
836cdf0e10cSrcweir             case WINDOW_MODALDIALOG:
837cdf0e10cSrcweir             case WINDOW_MODELESSDIALOG:
838cdf0e10cSrcweir             case WINDOW_MESSBOX:
839cdf0e10cSrcweir             case WINDOW_INFOBOX:
840cdf0e10cSrcweir             case WINDOW_WARNINGBOX:
841cdf0e10cSrcweir             case WINDOW_ERRORBOX:
842cdf0e10cSrcweir             case WINDOW_QUERYBOX:
843cdf0e10cSrcweir                 nFrameStyle |= SAL_FRAME_STYLE_DIALOG;
844cdf0e10cSrcweir             default:
845cdf0e10cSrcweir                 break;
846cdf0e10cSrcweir         }
847cdf0e10cSrcweir 
848cdf0e10cSrcweir         SalFrame* pParentFrame = NULL;
849cdf0e10cSrcweir         if ( pParent )
850cdf0e10cSrcweir             pParentFrame = pParent->mpWindowImpl->mpFrame;
851cdf0e10cSrcweir         SalFrame* pFrame;
852cdf0e10cSrcweir         if ( pSystemParentData )
853cdf0e10cSrcweir             pFrame = pSVData->mpDefInst->CreateChildFrame( pSystemParentData, nFrameStyle | SAL_FRAME_STYLE_PLUG );
854cdf0e10cSrcweir         else
855cdf0e10cSrcweir             pFrame = pSVData->mpDefInst->CreateFrame( pParentFrame, nFrameStyle );
856cdf0e10cSrcweir         if ( !pFrame )
857cdf0e10cSrcweir         {
858cdf0e10cSrcweir             // do not abort but throw an exception, may be the current thread terminates anyway (plugin-scenario)
859cdf0e10cSrcweir             throw ::com::sun::star::uno::RuntimeException(
860cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM( "Could not create system window!" ) ),
861cdf0e10cSrcweir                 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() );
862cdf0e10cSrcweir             //GetpApp()->Exception( EXC_SYSOBJNOTCREATED );
863cdf0e10cSrcweir         }
864cdf0e10cSrcweir 
865cdf0e10cSrcweir         pFrame->SetCallback( this, ImplWindowFrameProc );
866cdf0e10cSrcweir 
867cdf0e10cSrcweir         // set window frame data
868cdf0e10cSrcweir         mpWindowImpl->mpFrameData     = new ImplFrameData;
869cdf0e10cSrcweir         mpWindowImpl->mpFrame         = pFrame;
870cdf0e10cSrcweir         mpWindowImpl->mpFrameWindow   = this;
871cdf0e10cSrcweir         mpWindowImpl->mpOverlapWindow = this;
872cdf0e10cSrcweir 
873cdf0e10cSrcweir         // set frame data
874cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mpNextFrame        = pSVData->maWinData.mpFirstFrame;
875cdf0e10cSrcweir         pSVData->maWinData.mpFirstFrame = this;
876cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mpFirstOverlap     = NULL;
877cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mpFocusWin         = NULL;
878cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mpMouseMoveWin     = NULL;
879cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mpMouseDownWin     = NULL;
880cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mpFirstBackWin     = NULL;
881cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mpFontList         = pSVData->maGDIData.mpScreenFontList;
882cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mpFontCache        = pSVData->maGDIData.mpScreenFontCache;
883cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mnAllSaveBackSize  = 0;
884cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mnFocusId          = 0;
885cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mnMouseMoveId      = 0;
886cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mnLastMouseX       = -1;
887cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mnLastMouseY       = -1;
888cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mnBeforeLastMouseX = -1;
889cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mnBeforeLastMouseY = -1;
890cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mnFirstMouseX      = -1;
891cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mnFirstMouseY      = -1;
892cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mnLastMouseWinX    = -1;
893cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mnLastMouseWinY    = -1;
894cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mnModalMode        = 0;
895cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mnMouseDownTime    = 0;
896cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mnClickCount       = 0;
897cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mnFirstMouseCode   = 0;
898cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mnMouseCode        = 0;
899cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mnMouseMode        = 0;
900cdf0e10cSrcweir         mpWindowImpl->mpFrameData->meMapUnit          = MAP_PIXEL;
901cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mbHasFocus         = sal_False;
902cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mbInMouseMove      = sal_False;
903cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mbMouseIn          = sal_False;
904cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mbStartDragCalled  = sal_False;
905cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mbNeedSysWindow    = sal_False;
906cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mbMinimized        = sal_False;
907cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mbStartFocusState  = sal_False;
908cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mbInSysObjFocusHdl = sal_False;
909cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mbInSysObjToTopHdl = sal_False;
910cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mbSysObjFocus      = sal_False;
911cdf0e10cSrcweir         mpWindowImpl->mpFrameData->maPaintTimer.SetTimeout( 30 );
912cdf0e10cSrcweir         mpWindowImpl->mpFrameData->maPaintTimer.SetTimeoutHdl( LINK( this, Window, ImplHandlePaintHdl ) );
913cdf0e10cSrcweir         mpWindowImpl->mpFrameData->maResizeTimer.SetTimeout( 50 );
914cdf0e10cSrcweir         mpWindowImpl->mpFrameData->maResizeTimer.SetTimeoutHdl( LINK( this, Window, ImplHandleResizeTimerHdl ) );
915cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mbInternalDragGestureRecognizer = sal_False;
916cdf0e10cSrcweir 
917cdf0e10cSrcweir         if ( pRealParent && IsTopWindow() )
918cdf0e10cSrcweir         {
919cdf0e10cSrcweir             ImplWinData* pParentWinData = pRealParent->ImplGetWinData();
920cdf0e10cSrcweir             pParentWinData->maTopWindowChildren.push_back( this );
921cdf0e10cSrcweir         }
922cdf0e10cSrcweir     }
923cdf0e10cSrcweir 
924cdf0e10cSrcweir     // init data
925cdf0e10cSrcweir     mpWindowImpl->mpRealParent = pRealParent;
926cdf0e10cSrcweir 
927cdf0e10cSrcweir     // #99318: make sure fontcache and list is available before call to SetSettings
928cdf0e10cSrcweir     mpFontList      = mpWindowImpl->mpFrameData->mpFontList;
929cdf0e10cSrcweir     mpFontCache     = mpWindowImpl->mpFrameData->mpFontCache;
930cdf0e10cSrcweir 
931cdf0e10cSrcweir     if ( mpWindowImpl->mbFrame )
932cdf0e10cSrcweir     {
933cdf0e10cSrcweir         if ( pParent )
934cdf0e10cSrcweir         {
935cdf0e10cSrcweir             mpWindowImpl->mpFrameData->mnDPIX     = pParent->mpWindowImpl->mpFrameData->mnDPIX;
936cdf0e10cSrcweir             mpWindowImpl->mpFrameData->mnDPIY     = pParent->mpWindowImpl->mpFrameData->mnDPIY;
937cdf0e10cSrcweir         }
938cdf0e10cSrcweir         else
939cdf0e10cSrcweir         {
940cdf0e10cSrcweir             if ( ImplGetGraphics() )
941cdf0e10cSrcweir             {
942cdf0e10cSrcweir                 mpGraphics->GetResolution( mpWindowImpl->mpFrameData->mnDPIX, mpWindowImpl->mpFrameData->mnDPIY );
943cdf0e10cSrcweir             }
944cdf0e10cSrcweir         }
945cdf0e10cSrcweir 
946cdf0e10cSrcweir         // add ownerdraw decorated frame windows to list in the top-most frame window
947cdf0e10cSrcweir         // so they can be hidden on lose focus
948cdf0e10cSrcweir         if( nStyle & WB_OWNERDRAWDECORATION )
949cdf0e10cSrcweir             ImplGetOwnerDrawList().push_back( this );
950cdf0e10cSrcweir 
951cdf0e10cSrcweir         // delay settings initialization until first "real" frame
952cdf0e10cSrcweir         // this relies on the IntroWindow not needing any system settings
953cdf0e10cSrcweir         if ( !pSVData->maAppData.mbSettingsInit &&
954cdf0e10cSrcweir              ! (nStyle & (WB_INTROWIN|WB_DEFAULTWIN))
955cdf0e10cSrcweir              )
956cdf0e10cSrcweir         {
957cdf0e10cSrcweir             // side effect: ImplUpdateGlobalSettings does an ImplGetFrame()->UpdateSettings
958cdf0e10cSrcweir             ImplUpdateGlobalSettings( *pSVData->maAppData.mpSettings );
959cdf0e10cSrcweir             OutputDevice::SetSettings( *pSVData->maAppData.mpSettings );
960cdf0e10cSrcweir             pSVData->maAppData.mbSettingsInit = sal_True;
961cdf0e10cSrcweir         }
962cdf0e10cSrcweir 
963cdf0e10cSrcweir         // If we create a Window with default size, query this
964cdf0e10cSrcweir         // size directly, because we want resize all Controls to
965cdf0e10cSrcweir         // the correct size before we display the window
966cdf0e10cSrcweir         if ( nStyle & (WB_MOVEABLE | WB_SIZEABLE | WB_APP) )
967cdf0e10cSrcweir             mpWindowImpl->mpFrame->GetClientSize( mnOutWidth, mnOutHeight );
968cdf0e10cSrcweir     }
969cdf0e10cSrcweir     else
970cdf0e10cSrcweir     {
971cdf0e10cSrcweir         if ( pParent )
972cdf0e10cSrcweir         {
973cdf0e10cSrcweir             if ( !ImplIsOverlapWindow() )
974cdf0e10cSrcweir             {
975cdf0e10cSrcweir                 mpWindowImpl->mbDisabled          = pParent->mpWindowImpl->mbDisabled;
976cdf0e10cSrcweir                 mpWindowImpl->mbInputDisabled     = pParent->mpWindowImpl->mbInputDisabled;
977cdf0e10cSrcweir                 mpWindowImpl->meAlwaysInputMode   = pParent->mpWindowImpl->meAlwaysInputMode;
978cdf0e10cSrcweir             }
979cdf0e10cSrcweir 
980cdf0e10cSrcweir             OutputDevice::SetSettings( pParent->GetSettings() );
981cdf0e10cSrcweir         }
982cdf0e10cSrcweir 
983cdf0e10cSrcweir     }
984cdf0e10cSrcweir 
985cdf0e10cSrcweir     const StyleSettings& rStyleSettings = maSettings.GetStyleSettings();
986cdf0e10cSrcweir     sal_uInt16 nScreenZoom = rStyleSettings.GetScreenZoom();
987cdf0e10cSrcweir     mnDPIX          = (mpWindowImpl->mpFrameData->mnDPIX*nScreenZoom)/100;
988cdf0e10cSrcweir     mnDPIY          = (mpWindowImpl->mpFrameData->mnDPIY*nScreenZoom)/100;
989cdf0e10cSrcweir     maFont          = rStyleSettings.GetAppFont();
990cdf0e10cSrcweir     ImplPointToLogic( maFont );
991cdf0e10cSrcweir 
992cdf0e10cSrcweir     if ( nStyle & WB_3DLOOK )
993cdf0e10cSrcweir     {
994cdf0e10cSrcweir         SetTextColor( rStyleSettings.GetButtonTextColor() );
995cdf0e10cSrcweir         SetBackground( Wallpaper( rStyleSettings.GetFaceColor() ) );
996cdf0e10cSrcweir     }
997cdf0e10cSrcweir     else
998cdf0e10cSrcweir     {
999cdf0e10cSrcweir         SetTextColor( rStyleSettings.GetWindowTextColor() );
1000cdf0e10cSrcweir         SetBackground( Wallpaper( rStyleSettings.GetWindowColor() ) );
1001cdf0e10cSrcweir     }
1002cdf0e10cSrcweir 
1003cdf0e10cSrcweir     ImplUpdatePos();
1004cdf0e10cSrcweir 
1005cdf0e10cSrcweir     // calculate app font res (except for the Intro Window or the default window)
1006cdf0e10cSrcweir     if ( mpWindowImpl->mbFrame && !pSVData->maGDIData.mnAppFontX && ! (nStyle & (WB_INTROWIN|WB_DEFAULTWIN)) )
1007cdf0e10cSrcweir         ImplInitAppFontData( this );
1008cdf0e10cSrcweir 
1009cdf0e10cSrcweir     if ( GetAccessibleParentWindow()  && GetParent() != Application::GetDefDialogParent() )
1010cdf0e10cSrcweir         GetAccessibleParentWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_CHILDCREATED, this );
1011cdf0e10cSrcweir }
1012cdf0e10cSrcweir 
1013cdf0e10cSrcweir // -----------------------------------------------------------------------
1014cdf0e10cSrcweir 
1015cdf0e10cSrcweir void Window::ImplSetFrameParent( const Window* pParent )
1016cdf0e10cSrcweir {
1017cdf0e10cSrcweir     Window* pFrameWindow = ImplGetSVData()->maWinData.mpFirstFrame;
1018cdf0e10cSrcweir     while( pFrameWindow )
1019cdf0e10cSrcweir     {
1020cdf0e10cSrcweir         // search all frames that are children of this window
1021cdf0e10cSrcweir         // and reparent them
1022cdf0e10cSrcweir         if( ImplIsRealParentPath( pFrameWindow ) )
1023cdf0e10cSrcweir         {
1024cdf0e10cSrcweir             DBG_ASSERT( mpWindowImpl->mpFrame != pFrameWindow->mpWindowImpl->mpFrame, "SetFrameParent to own" );
1025cdf0e10cSrcweir             DBG_ASSERT( mpWindowImpl->mpFrame, "no frame" );
1026cdf0e10cSrcweir             SalFrame* pParentFrame = pParent ? pParent->mpWindowImpl->mpFrame : NULL;
1027cdf0e10cSrcweir             pFrameWindow->mpWindowImpl->mpFrame->SetParent( pParentFrame );
1028cdf0e10cSrcweir         }
1029cdf0e10cSrcweir         pFrameWindow = pFrameWindow->mpWindowImpl->mpFrameData->mpNextFrame;
1030cdf0e10cSrcweir     }
1031cdf0e10cSrcweir }
1032cdf0e10cSrcweir 
1033cdf0e10cSrcweir // -----------------------------------------------------------------------
1034cdf0e10cSrcweir 
1035cdf0e10cSrcweir void Window::ImplInsertWindow( Window* pParent )
1036cdf0e10cSrcweir {
1037cdf0e10cSrcweir     mpWindowImpl->mpParent            = pParent;
1038cdf0e10cSrcweir     mpWindowImpl->mpRealParent        = pParent;
1039cdf0e10cSrcweir 
1040cdf0e10cSrcweir     if ( pParent && !mpWindowImpl->mbFrame )
1041cdf0e10cSrcweir     {
1042cdf0e10cSrcweir         // search frame window and set window frame data
1043cdf0e10cSrcweir         Window* pFrameParent = pParent->mpWindowImpl->mpFrameWindow;
1044cdf0e10cSrcweir         mpWindowImpl->mpFrameData     = pFrameParent->mpWindowImpl->mpFrameData;
1045cdf0e10cSrcweir         mpWindowImpl->mpFrame         = pFrameParent->mpWindowImpl->mpFrame;
1046cdf0e10cSrcweir         mpWindowImpl->mpFrameWindow   = pFrameParent;
1047cdf0e10cSrcweir         mpWindowImpl->mbFrame         = sal_False;
1048cdf0e10cSrcweir 
1049cdf0e10cSrcweir         // search overlap window and insert window in list
1050cdf0e10cSrcweir         if ( ImplIsOverlapWindow() )
1051cdf0e10cSrcweir         {
1052cdf0e10cSrcweir             Window* pFirstOverlapParent = pParent;
1053cdf0e10cSrcweir             while ( !pFirstOverlapParent->ImplIsOverlapWindow() )
1054cdf0e10cSrcweir                 pFirstOverlapParent = pFirstOverlapParent->ImplGetParent();
1055cdf0e10cSrcweir             mpWindowImpl->mpOverlapWindow = pFirstOverlapParent;
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir             mpWindowImpl->mpNextOverlap = mpWindowImpl->mpFrameData->mpFirstOverlap;
1058cdf0e10cSrcweir             mpWindowImpl->mpFrameData->mpFirstOverlap = this;
1059cdf0e10cSrcweir 
1060cdf0e10cSrcweir             // Overlap-Windows sind per default die obersten
1061cdf0e10cSrcweir             mpWindowImpl->mpNext = pFirstOverlapParent->mpWindowImpl->mpFirstOverlap;
1062cdf0e10cSrcweir             pFirstOverlapParent->mpWindowImpl->mpFirstOverlap = this;
1063cdf0e10cSrcweir             if ( !pFirstOverlapParent->mpWindowImpl->mpLastOverlap )
1064cdf0e10cSrcweir                 pFirstOverlapParent->mpWindowImpl->mpLastOverlap = this;
1065cdf0e10cSrcweir             else
1066cdf0e10cSrcweir                 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = this;
1067cdf0e10cSrcweir         }
1068cdf0e10cSrcweir         else
1069cdf0e10cSrcweir         {
1070cdf0e10cSrcweir             if ( pParent->ImplIsOverlapWindow() )
1071cdf0e10cSrcweir                 mpWindowImpl->mpOverlapWindow = pParent;
1072cdf0e10cSrcweir             else
1073cdf0e10cSrcweir                 mpWindowImpl->mpOverlapWindow = pParent->mpWindowImpl->mpOverlapWindow;
1074cdf0e10cSrcweir             mpWindowImpl->mpPrev = pParent->mpWindowImpl->mpLastChild;
1075cdf0e10cSrcweir             pParent->mpWindowImpl->mpLastChild = this;
1076cdf0e10cSrcweir             if ( !pParent->mpWindowImpl->mpFirstChild )
1077cdf0e10cSrcweir                 pParent->mpWindowImpl->mpFirstChild = this;
1078cdf0e10cSrcweir             else
1079cdf0e10cSrcweir                 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = this;
1080cdf0e10cSrcweir         }
1081cdf0e10cSrcweir     }
1082cdf0e10cSrcweir }
1083cdf0e10cSrcweir 
1084cdf0e10cSrcweir // -----------------------------------------------------------------------
1085cdf0e10cSrcweir 
1086cdf0e10cSrcweir void Window::ImplRemoveWindow( sal_Bool bRemoveFrameData )
1087cdf0e10cSrcweir {
1088cdf0e10cSrcweir     // Fenster aus den Listen austragen
1089cdf0e10cSrcweir     if ( !mpWindowImpl->mbFrame )
1090cdf0e10cSrcweir     {
1091cdf0e10cSrcweir         if ( ImplIsOverlapWindow() )
1092cdf0e10cSrcweir         {
1093cdf0e10cSrcweir             if ( mpWindowImpl->mpFrameData->mpFirstOverlap == this )
1094cdf0e10cSrcweir                 mpWindowImpl->mpFrameData->mpFirstOverlap = mpWindowImpl->mpNextOverlap;
1095cdf0e10cSrcweir             else
1096cdf0e10cSrcweir             {
1097cdf0e10cSrcweir                 Window* pTempWin = mpWindowImpl->mpFrameData->mpFirstOverlap;
1098cdf0e10cSrcweir                 while ( pTempWin->mpWindowImpl->mpNextOverlap != this )
1099cdf0e10cSrcweir                     pTempWin = pTempWin->mpWindowImpl->mpNextOverlap;
1100cdf0e10cSrcweir                 pTempWin->mpWindowImpl->mpNextOverlap = mpWindowImpl->mpNextOverlap;
1101cdf0e10cSrcweir             }
1102cdf0e10cSrcweir 
1103cdf0e10cSrcweir             if ( mpWindowImpl->mpPrev )
1104cdf0e10cSrcweir                 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext;
1105cdf0e10cSrcweir             else
1106cdf0e10cSrcweir                 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap = mpWindowImpl->mpNext;
1107cdf0e10cSrcweir             if ( mpWindowImpl->mpNext )
1108cdf0e10cSrcweir                 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev;
1109cdf0e10cSrcweir             else
1110cdf0e10cSrcweir                 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap = mpWindowImpl->mpPrev;
1111cdf0e10cSrcweir         }
1112cdf0e10cSrcweir         else
1113cdf0e10cSrcweir         {
1114cdf0e10cSrcweir             if ( mpWindowImpl->mpPrev )
1115cdf0e10cSrcweir                 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext;
1116cdf0e10cSrcweir             else
1117cdf0e10cSrcweir                 mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild = mpWindowImpl->mpNext;
1118cdf0e10cSrcweir             if ( mpWindowImpl->mpNext )
1119cdf0e10cSrcweir                 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev;
1120cdf0e10cSrcweir             else
1121cdf0e10cSrcweir                 mpWindowImpl->mpParent->mpWindowImpl->mpLastChild = mpWindowImpl->mpPrev;
1122cdf0e10cSrcweir         }
1123cdf0e10cSrcweir 
1124cdf0e10cSrcweir         mpWindowImpl->mpPrev = NULL;
1125cdf0e10cSrcweir         mpWindowImpl->mpNext = NULL;
1126cdf0e10cSrcweir     }
1127cdf0e10cSrcweir 
1128cdf0e10cSrcweir     if ( bRemoveFrameData )
1129cdf0e10cSrcweir     {
1130cdf0e10cSrcweir         // Graphic freigeben
1131cdf0e10cSrcweir         ImplReleaseGraphics();
1132cdf0e10cSrcweir     }
1133cdf0e10cSrcweir }
1134cdf0e10cSrcweir 
1135cdf0e10cSrcweir // -----------------------------------------------------------------------
1136cdf0e10cSrcweir 
1137cdf0e10cSrcweir void Window::ImplCallResize()
1138cdf0e10cSrcweir {
1139cdf0e10cSrcweir     mpWindowImpl->mbCallResize = sal_False;
1140cdf0e10cSrcweir 
1141cdf0e10cSrcweir     if( GetBackground().IsGradient() )
1142cdf0e10cSrcweir         Invalidate();
1143cdf0e10cSrcweir 
1144cdf0e10cSrcweir     Resize();
1145cdf0e10cSrcweir 
1146cdf0e10cSrcweir     // #88419# Most classes don't call the base class in Resize() and Move(),
1147cdf0e10cSrcweir     // => Call ImpleResize/Move instead of Resize/Move directly...
1148cdf0e10cSrcweir     ImplCallEventListeners( VCLEVENT_WINDOW_RESIZE );
1149cdf0e10cSrcweir 
1150cdf0e10cSrcweir     ImplExtResize();
1151cdf0e10cSrcweir }
1152cdf0e10cSrcweir 
1153cdf0e10cSrcweir // -----------------------------------------------------------------------
1154cdf0e10cSrcweir 
1155cdf0e10cSrcweir void Window::ImplCallMove()
1156cdf0e10cSrcweir {
1157cdf0e10cSrcweir     mpWindowImpl->mbCallMove = sal_False;
1158cdf0e10cSrcweir 
1159cdf0e10cSrcweir     if( mpWindowImpl->mbFrame )
1160cdf0e10cSrcweir     {
1161cdf0e10cSrcweir         // update frame position
1162cdf0e10cSrcweir         SalFrame *pParentFrame = NULL;
1163cdf0e10cSrcweir         Window *pParent = ImplGetParent();
1164cdf0e10cSrcweir         while( pParent )
1165cdf0e10cSrcweir         {
1166cdf0e10cSrcweir             if( pParent->mpWindowImpl->mpFrame != mpWindowImpl->mpFrame )
1167cdf0e10cSrcweir             {
1168cdf0e10cSrcweir                 pParentFrame = pParent->mpWindowImpl->mpFrame;
1169cdf0e10cSrcweir                 break;
1170cdf0e10cSrcweir             }
1171cdf0e10cSrcweir             pParent = pParent->GetParent();
1172cdf0e10cSrcweir         }
1173cdf0e10cSrcweir 
1174cdf0e10cSrcweir         SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry();
1175cdf0e10cSrcweir         mpWindowImpl->maPos = Point( g.nX, g.nY );
1176cdf0e10cSrcweir         if( pParentFrame )
1177cdf0e10cSrcweir         {
1178cdf0e10cSrcweir             g = pParentFrame->GetGeometry();
1179cdf0e10cSrcweir             mpWindowImpl->maPos -= Point( g.nX, g.nY );
1180cdf0e10cSrcweir         }
1181cdf0e10cSrcweir         // the client window and and all its subclients have the same position as the borderframe
1182cdf0e10cSrcweir         // this is important for floating toolbars where the borderwindow is a floating window
1183cdf0e10cSrcweir         // which has another borderwindow (ie the system floating window)
1184cdf0e10cSrcweir         Window *pClientWin = mpWindowImpl->mpClientWindow;
1185cdf0e10cSrcweir         while( pClientWin )
1186cdf0e10cSrcweir         {
1187cdf0e10cSrcweir             pClientWin->mpWindowImpl->maPos = mpWindowImpl->maPos;
1188cdf0e10cSrcweir             pClientWin = pClientWin->mpWindowImpl->mpClientWindow;
1189cdf0e10cSrcweir         }
1190cdf0e10cSrcweir     }
1191cdf0e10cSrcweir 
1192cdf0e10cSrcweir     Move();
1193cdf0e10cSrcweir 
1194cdf0e10cSrcweir     ImplCallEventListeners( VCLEVENT_WINDOW_MOVE );
1195cdf0e10cSrcweir }
1196cdf0e10cSrcweir 
1197cdf0e10cSrcweir // -----------------------------------------------------------------------
1198cdf0e10cSrcweir 
1199cdf0e10cSrcweir static rtl::OString ImplAutoHelpID( ResMgr* pResMgr )
1200cdf0e10cSrcweir {
1201cdf0e10cSrcweir     rtl::OString aRet;
1202cdf0e10cSrcweir 
1203cdf0e10cSrcweir     if( pResMgr && Application::IsAutoHelpIdEnabled() )
1204cdf0e10cSrcweir         aRet = pResMgr->GetAutoHelpId();
1205cdf0e10cSrcweir 
1206cdf0e10cSrcweir     return aRet;
1207cdf0e10cSrcweir }
1208cdf0e10cSrcweir 
1209cdf0e10cSrcweir // -----------------------------------------------------------------------
1210cdf0e10cSrcweir 
1211cdf0e10cSrcweir WinBits Window::ImplInitRes( const ResId& rResId )
1212cdf0e10cSrcweir {
1213cdf0e10cSrcweir     GetRes( rResId );
1214cdf0e10cSrcweir 
1215cdf0e10cSrcweir     char* pRes = (char*)GetClassRes();
1216cdf0e10cSrcweir     pRes += 8;
1217cdf0e10cSrcweir     sal_uInt32 nStyle = (sal_uInt32)GetLongRes( (void*)pRes );
1218cdf0e10cSrcweir     rResId.SetWinBits( nStyle );
1219cdf0e10cSrcweir     return nStyle;
1220cdf0e10cSrcweir }
1221cdf0e10cSrcweir 
1222cdf0e10cSrcweir // -----------------------------------------------------------------------
1223cdf0e10cSrcweir 
1224cdf0e10cSrcweir void Window::ImplLoadRes( const ResId& rResId )
1225cdf0e10cSrcweir {
1226cdf0e10cSrcweir     sal_uLong nObjMask = ReadLongRes();
1227cdf0e10cSrcweir 
1228cdf0e10cSrcweir     // we need to calculate auto helpids before the resource gets closed
1229cdf0e10cSrcweir     // if the resource  only contains flags, it will be closed before we try to read a help id
1230cdf0e10cSrcweir     // so we always create an auto help id that might be overwritten later
1231cdf0e10cSrcweir     // HelpId
1232cdf0e10cSrcweir     rtl::OString aHelpId = ImplAutoHelpID( rResId.GetResMgr() );
1233cdf0e10cSrcweir 
1234cdf0e10cSrcweir     // ResourceStyle
1235cdf0e10cSrcweir     sal_uLong nRSStyle = ReadLongRes();
1236cdf0e10cSrcweir     // WinBits
1237cdf0e10cSrcweir     ReadLongRes();
1238cdf0e10cSrcweir 
1239cdf0e10cSrcweir     if( nObjMask & WINDOW_HELPID )
1240cdf0e10cSrcweir         aHelpId = ReadByteStringRes();
1241cdf0e10cSrcweir 
1242cdf0e10cSrcweir     SetHelpId( aHelpId );
1243cdf0e10cSrcweir 
1244cdf0e10cSrcweir     sal_Bool  bPos  = sal_False;
1245cdf0e10cSrcweir     sal_Bool  bSize = sal_False;
1246cdf0e10cSrcweir     Point aPos;
1247cdf0e10cSrcweir     Size  aSize;
1248cdf0e10cSrcweir 
1249cdf0e10cSrcweir     if ( nObjMask & (WINDOW_XYMAPMODE | WINDOW_X | WINDOW_Y) )
1250cdf0e10cSrcweir     {
1251cdf0e10cSrcweir         // Groessenangabe aus der Resource verwenden
1252cdf0e10cSrcweir         MapUnit ePosMap = MAP_PIXEL;
1253cdf0e10cSrcweir 
1254cdf0e10cSrcweir         bPos = sal_True;
1255cdf0e10cSrcweir 
1256cdf0e10cSrcweir         if ( nObjMask & WINDOW_XYMAPMODE )
1257cdf0e10cSrcweir             ePosMap = (MapUnit)ReadLongRes();
1258cdf0e10cSrcweir         if ( nObjMask & WINDOW_X )
1259cdf0e10cSrcweir             aPos.X() = ImplLogicUnitToPixelX( ReadLongRes(), ePosMap );
1260cdf0e10cSrcweir         if ( nObjMask & WINDOW_Y )
1261cdf0e10cSrcweir             aPos.Y() = ImplLogicUnitToPixelY( ReadLongRes(), ePosMap );
1262cdf0e10cSrcweir     }
1263cdf0e10cSrcweir 
1264cdf0e10cSrcweir     if ( nObjMask & (WINDOW_WHMAPMODE | WINDOW_WIDTH | WINDOW_HEIGHT) )
1265cdf0e10cSrcweir     {
1266cdf0e10cSrcweir         // Groessenangabe aus der Resource verwenden
1267cdf0e10cSrcweir         MapUnit eSizeMap = MAP_PIXEL;
1268cdf0e10cSrcweir 
1269cdf0e10cSrcweir         bSize = sal_True;
1270cdf0e10cSrcweir 
1271cdf0e10cSrcweir         if ( nObjMask & WINDOW_WHMAPMODE )
1272cdf0e10cSrcweir             eSizeMap = (MapUnit)ReadLongRes();
1273cdf0e10cSrcweir         if ( nObjMask & WINDOW_WIDTH )
1274cdf0e10cSrcweir             aSize.Width() = ImplLogicUnitToPixelX( ReadLongRes(), eSizeMap );
1275cdf0e10cSrcweir         if ( nObjMask & WINDOW_HEIGHT )
1276cdf0e10cSrcweir             aSize.Height() = ImplLogicUnitToPixelY( ReadLongRes(), eSizeMap );
1277cdf0e10cSrcweir     }
1278cdf0e10cSrcweir 
1279cdf0e10cSrcweir     // Wegen Optimierung so schlimm aussehend
1280cdf0e10cSrcweir     if ( nRSStyle & RSWND_CLIENTSIZE )
1281cdf0e10cSrcweir     {
1282cdf0e10cSrcweir         if ( bPos )
1283cdf0e10cSrcweir             SetPosPixel( aPos );
1284cdf0e10cSrcweir         if ( bSize )
1285cdf0e10cSrcweir             SetOutputSizePixel( aSize );
1286cdf0e10cSrcweir     }
1287cdf0e10cSrcweir     else if ( bPos && bSize )
1288cdf0e10cSrcweir         SetPosSizePixel( aPos, aSize );
1289cdf0e10cSrcweir     else if ( bPos )
1290cdf0e10cSrcweir         SetPosPixel( aPos );
1291cdf0e10cSrcweir     else if ( bSize )
1292cdf0e10cSrcweir         SetSizePixel( aSize );
1293cdf0e10cSrcweir 
1294cdf0e10cSrcweir     if ( nRSStyle & RSWND_DISABLED )
1295cdf0e10cSrcweir         Enable( sal_False );
1296cdf0e10cSrcweir 
1297cdf0e10cSrcweir     if ( nObjMask & WINDOW_TEXT )
1298cdf0e10cSrcweir         SetText( ReadStringRes() );
1299cdf0e10cSrcweir     if ( nObjMask & WINDOW_HELPTEXT )
1300cdf0e10cSrcweir     {
1301cdf0e10cSrcweir         SetHelpText( ReadStringRes() );
1302cdf0e10cSrcweir         mpWindowImpl->mbHelpTextDynamic = sal_True;
1303cdf0e10cSrcweir     }
1304cdf0e10cSrcweir     if ( nObjMask & WINDOW_QUICKTEXT )
1305cdf0e10cSrcweir         SetQuickHelpText( ReadStringRes() );
1306cdf0e10cSrcweir     if ( nObjMask & WINDOW_EXTRALONG )
1307cdf0e10cSrcweir         SetData( (void*)ReadLongRes() );
1308cdf0e10cSrcweir     if ( nObjMask & WINDOW_UNIQUEID )
1309cdf0e10cSrcweir         SetUniqueId( ReadByteStringRes() );
1310cdf0e10cSrcweir 
1311cdf0e10cSrcweir     if ( nObjMask & WINDOW_BORDER_STYLE )
1312cdf0e10cSrcweir     {
1313cdf0e10cSrcweir         sal_uInt16 nBorderStyle = (sal_uInt16)ReadLongRes();
1314cdf0e10cSrcweir         SetBorderStyle( nBorderStyle );
1315cdf0e10cSrcweir     }
1316cdf0e10cSrcweir }
1317cdf0e10cSrcweir 
1318cdf0e10cSrcweir // -----------------------------------------------------------------------
1319cdf0e10cSrcweir 
1320cdf0e10cSrcweir ImplWinData* Window::ImplGetWinData() const
1321cdf0e10cSrcweir {
1322cdf0e10cSrcweir     if ( !mpWindowImpl->mpWinData )
1323cdf0e10cSrcweir     {
1324cdf0e10cSrcweir         static const char* pNoNWF = getenv( "SAL_NO_NWF" );
1325cdf0e10cSrcweir 
1326cdf0e10cSrcweir         ((Window*)this)->mpWindowImpl->mpWinData = new ImplWinData;
1327cdf0e10cSrcweir         mpWindowImpl->mpWinData->mpExtOldText     = NULL;
1328cdf0e10cSrcweir         mpWindowImpl->mpWinData->mpExtOldAttrAry  = NULL;
1329cdf0e10cSrcweir         mpWindowImpl->mpWinData->mpCursorRect     = 0;
1330cdf0e10cSrcweir         mpWindowImpl->mpWinData->mnCursorExtWidth = 0;
1331cdf0e10cSrcweir         mpWindowImpl->mpWinData->mpFocusRect      = NULL;
1332cdf0e10cSrcweir         mpWindowImpl->mpWinData->mpTrackRect      = NULL;
1333cdf0e10cSrcweir         mpWindowImpl->mpWinData->mnTrackFlags     = 0;
1334cdf0e10cSrcweir         mpWindowImpl->mpWinData->mnIsTopWindow	= (sal_uInt16) ~0;  // not initialized yet, 0/1 will indicate TopWindow (see IsTopWindow())
1335cdf0e10cSrcweir         mpWindowImpl->mpWinData->mbMouseOver      = sal_False;
1336cdf0e10cSrcweir         mpWindowImpl->mpWinData->mbEnableNativeWidget = (pNoNWF && *pNoNWF) ? sal_False : sal_True; // sal_True: try to draw this control with native theme API
1337cdf0e10cSrcweir    }
1338cdf0e10cSrcweir 
1339cdf0e10cSrcweir     return mpWindowImpl->mpWinData;
1340cdf0e10cSrcweir }
1341cdf0e10cSrcweir 
1342cdf0e10cSrcweir // -----------------------------------------------------------------------
1343cdf0e10cSrcweir 
1344cdf0e10cSrcweir SalGraphics* Window::ImplGetFrameGraphics() const
1345cdf0e10cSrcweir {
1346cdf0e10cSrcweir     if ( mpWindowImpl->mpFrameWindow->mpGraphics )
1347cdf0e10cSrcweir         mpWindowImpl->mpFrameWindow->mbInitClipRegion = sal_True;
1348cdf0e10cSrcweir     else
1349cdf0e10cSrcweir         mpWindowImpl->mpFrameWindow->ImplGetGraphics();
1350cdf0e10cSrcweir     mpWindowImpl->mpFrameWindow->mpGraphics->ResetClipRegion();
1351cdf0e10cSrcweir     return mpWindowImpl->mpFrameWindow->mpGraphics;
1352cdf0e10cSrcweir }
1353cdf0e10cSrcweir 
1354cdf0e10cSrcweir // -----------------------------------------------------------------------
1355cdf0e10cSrcweir 
1356cdf0e10cSrcweir Window* Window::ImplFindWindow( const Point& rFramePos )
1357cdf0e10cSrcweir {
1358cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1359cdf0e10cSrcweir 
1360cdf0e10cSrcweir     Window* pTempWindow;
1361cdf0e10cSrcweir     Window* pFindWindow;
1362cdf0e10cSrcweir 
1363cdf0e10cSrcweir     // Zuerst alle ueberlappenden Fenster ueberpruefen
1364cdf0e10cSrcweir     pTempWindow = mpWindowImpl->mpFirstOverlap;
1365cdf0e10cSrcweir     while ( pTempWindow )
1366cdf0e10cSrcweir     {
1367cdf0e10cSrcweir         pFindWindow = pTempWindow->ImplFindWindow( rFramePos );
1368cdf0e10cSrcweir         if ( pFindWindow )
1369cdf0e10cSrcweir             return pFindWindow;
1370cdf0e10cSrcweir         pTempWindow = pTempWindow->mpWindowImpl->mpNext;
1371cdf0e10cSrcweir     }
1372cdf0e10cSrcweir 
1373cdf0e10cSrcweir     // dann testen wir unser Fenster
1374cdf0e10cSrcweir     if ( !mpWindowImpl->mbVisible )
1375cdf0e10cSrcweir         return NULL;
1376cdf0e10cSrcweir 
1377cdf0e10cSrcweir     sal_uInt16 nHitTest = ImplHitTest( rFramePos );
1378cdf0e10cSrcweir     if ( nHitTest & WINDOW_HITTEST_INSIDE )
1379cdf0e10cSrcweir     {
1380cdf0e10cSrcweir         // und danach gehen wir noch alle Child-Fenster durch
1381cdf0e10cSrcweir         pTempWindow = mpWindowImpl->mpFirstChild;
1382cdf0e10cSrcweir         while ( pTempWindow )
1383cdf0e10cSrcweir         {
1384cdf0e10cSrcweir             pFindWindow = pTempWindow->ImplFindWindow( rFramePos );
1385cdf0e10cSrcweir             if ( pFindWindow )
1386cdf0e10cSrcweir                 return pFindWindow;
1387cdf0e10cSrcweir             pTempWindow = pTempWindow->mpWindowImpl->mpNext;
1388cdf0e10cSrcweir         }
1389cdf0e10cSrcweir 
1390cdf0e10cSrcweir         if ( nHitTest & WINDOW_HITTEST_TRANSPARENT )
1391cdf0e10cSrcweir             return NULL;
1392cdf0e10cSrcweir         else
1393cdf0e10cSrcweir             return this;
1394cdf0e10cSrcweir     }
1395cdf0e10cSrcweir 
1396cdf0e10cSrcweir     return NULL;
1397cdf0e10cSrcweir }
1398cdf0e10cSrcweir 
1399cdf0e10cSrcweir // -----------------------------------------------------------------------
1400cdf0e10cSrcweir 
1401cdf0e10cSrcweir sal_uInt16 Window::ImplHitTest( const Point& rFramePos )
1402cdf0e10cSrcweir {
1403cdf0e10cSrcweir     Point aFramePos( rFramePos );
1404cdf0e10cSrcweir     if( ImplIsAntiparallel() )
1405cdf0e10cSrcweir     {
1406cdf0e10cSrcweir         // - RTL - re-mirror frame pos at this window
1407cdf0e10cSrcweir         ImplReMirror( aFramePos );
1408cdf0e10cSrcweir     }
1409cdf0e10cSrcweir     Rectangle aRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
1410cdf0e10cSrcweir     if ( !aRect.IsInside( aFramePos ) )
1411cdf0e10cSrcweir         return 0;
1412cdf0e10cSrcweir     if ( mpWindowImpl->mbWinRegion )
1413cdf0e10cSrcweir     {
1414cdf0e10cSrcweir         Point aTempPos = aFramePos;
1415cdf0e10cSrcweir         aTempPos.X() -= mnOutOffX;
1416cdf0e10cSrcweir         aTempPos.Y() -= mnOutOffY;
1417cdf0e10cSrcweir         if ( !mpWindowImpl->maWinRegion.IsInside( aTempPos ) )
1418cdf0e10cSrcweir             return 0;
1419cdf0e10cSrcweir     }
1420cdf0e10cSrcweir 
1421cdf0e10cSrcweir     sal_uInt16 nHitTest = WINDOW_HITTEST_INSIDE;
1422cdf0e10cSrcweir     if ( mpWindowImpl->mbMouseTransparent )
1423cdf0e10cSrcweir         nHitTest |= WINDOW_HITTEST_TRANSPARENT;
1424cdf0e10cSrcweir     return nHitTest;
1425cdf0e10cSrcweir }
1426cdf0e10cSrcweir 
1427cdf0e10cSrcweir // -----------------------------------------------------------------------
1428cdf0e10cSrcweir 
1429cdf0e10cSrcweir sal_Bool Window::ImplIsRealParentPath( const Window* pWindow ) const
1430cdf0e10cSrcweir {
1431cdf0e10cSrcweir     pWindow = pWindow->GetParent();
1432cdf0e10cSrcweir     while ( pWindow )
1433cdf0e10cSrcweir     {
1434cdf0e10cSrcweir         if ( pWindow == this )
1435cdf0e10cSrcweir             return sal_True;
1436cdf0e10cSrcweir         pWindow = pWindow->GetParent();
1437cdf0e10cSrcweir     }
1438cdf0e10cSrcweir 
1439cdf0e10cSrcweir     return sal_False;
1440cdf0e10cSrcweir }
1441cdf0e10cSrcweir 
1442cdf0e10cSrcweir // -----------------------------------------------------------------------
1443cdf0e10cSrcweir 
1444cdf0e10cSrcweir sal_Bool Window::ImplIsChild( const Window* pWindow, sal_Bool bSystemWindow ) const
1445cdf0e10cSrcweir {
1446cdf0e10cSrcweir     do
1447cdf0e10cSrcweir     {
1448cdf0e10cSrcweir         if ( !bSystemWindow && pWindow->ImplIsOverlapWindow() )
1449cdf0e10cSrcweir             break;
1450cdf0e10cSrcweir 
1451cdf0e10cSrcweir         pWindow = pWindow->ImplGetParent();
1452cdf0e10cSrcweir 
1453cdf0e10cSrcweir         if ( pWindow == this )
1454cdf0e10cSrcweir             return sal_True;
1455cdf0e10cSrcweir     }
1456cdf0e10cSrcweir     while ( pWindow );
1457cdf0e10cSrcweir 
1458cdf0e10cSrcweir     return sal_False;
1459cdf0e10cSrcweir }
1460cdf0e10cSrcweir 
1461cdf0e10cSrcweir // -----------------------------------------------------------------------
1462cdf0e10cSrcweir 
1463cdf0e10cSrcweir sal_Bool Window::ImplIsWindowOrChild( const Window* pWindow, sal_Bool bSystemWindow ) const
1464cdf0e10cSrcweir {
1465cdf0e10cSrcweir     if ( this == pWindow )
1466cdf0e10cSrcweir         return sal_True;
1467cdf0e10cSrcweir     return ImplIsChild( pWindow, bSystemWindow );
1468cdf0e10cSrcweir }
1469cdf0e10cSrcweir 
1470cdf0e10cSrcweir // -----------------------------------------------------------------------
1471cdf0e10cSrcweir 
1472cdf0e10cSrcweir Window* Window::ImplGetSameParent( const Window* pWindow ) const
1473cdf0e10cSrcweir {
1474cdf0e10cSrcweir     if ( mpWindowImpl->mpFrameWindow != pWindow->mpWindowImpl->mpFrameWindow )
1475cdf0e10cSrcweir         return NULL;
1476cdf0e10cSrcweir     else
1477cdf0e10cSrcweir     {
1478cdf0e10cSrcweir         if ( pWindow->ImplIsChild( this ) )
1479cdf0e10cSrcweir             return (Window*)pWindow;
1480cdf0e10cSrcweir         else
1481cdf0e10cSrcweir         {
1482cdf0e10cSrcweir             Window* pTestWindow = (Window*)this;
1483cdf0e10cSrcweir             while ( (pTestWindow == pWindow) || pTestWindow->ImplIsChild( pWindow ) )
1484cdf0e10cSrcweir                 pTestWindow = pTestWindow->ImplGetParent();
1485cdf0e10cSrcweir             return pTestWindow;
1486cdf0e10cSrcweir         }
1487cdf0e10cSrcweir     }
1488cdf0e10cSrcweir }
1489cdf0e10cSrcweir 
1490cdf0e10cSrcweir // -----------------------------------------------------------------------
1491cdf0e10cSrcweir 
1492cdf0e10cSrcweir int Window::ImplTestMousePointerSet()
1493cdf0e10cSrcweir {
1494cdf0e10cSrcweir     // Wenn Mouse gecaptured ist, dann soll MousePointer umgeschaltet werden
1495cdf0e10cSrcweir     if ( IsMouseCaptured() )
1496cdf0e10cSrcweir         return sal_True;
1497cdf0e10cSrcweir 
1498cdf0e10cSrcweir     // Wenn sich Mouse ueber dem Fenster befindet, dann soll MousePointer
1499cdf0e10cSrcweir     // umgeschaltet werden
1500cdf0e10cSrcweir     Rectangle aClientRect( Point( 0, 0 ), GetOutputSizePixel() );
1501cdf0e10cSrcweir     if ( aClientRect.IsInside( GetPointerPosPixel() ) )
1502cdf0e10cSrcweir         return sal_True;
1503cdf0e10cSrcweir 
1504cdf0e10cSrcweir     return sal_False;
1505cdf0e10cSrcweir }
1506cdf0e10cSrcweir 
1507cdf0e10cSrcweir // -----------------------------------------------------------------------
1508cdf0e10cSrcweir 
1509cdf0e10cSrcweir PointerStyle Window::ImplGetMousePointer() const
1510cdf0e10cSrcweir {
1511cdf0e10cSrcweir     PointerStyle    ePointerStyle;
1512cdf0e10cSrcweir     sal_Bool            bWait = sal_False;
1513cdf0e10cSrcweir 
1514cdf0e10cSrcweir     if ( IsEnabled() && IsInputEnabled() && ! IsInModalMode() )
1515cdf0e10cSrcweir         ePointerStyle = GetPointer().GetStyle();
1516cdf0e10cSrcweir     else
1517cdf0e10cSrcweir         ePointerStyle = POINTER_ARROW;
1518cdf0e10cSrcweir 
1519cdf0e10cSrcweir     const Window* pWindow = this;
1520cdf0e10cSrcweir     do
1521cdf0e10cSrcweir     {
1522cdf0e10cSrcweir         // Wenn Pointer nicht sichtbar, dann wird suche abgebrochen, da
1523cdf0e10cSrcweir         // dieser Status nicht ueberschrieben werden darf
1524cdf0e10cSrcweir         if ( pWindow->mpWindowImpl->mbNoPtrVisible )
1525cdf0e10cSrcweir             return POINTER_NULL;
1526cdf0e10cSrcweir 
1527cdf0e10cSrcweir         if ( !bWait )
1528cdf0e10cSrcweir         {
1529cdf0e10cSrcweir             if ( pWindow->mpWindowImpl->mnWaitCount )
1530cdf0e10cSrcweir             {
1531cdf0e10cSrcweir                 ePointerStyle = POINTER_WAIT;
1532cdf0e10cSrcweir                 bWait = sal_True;
1533cdf0e10cSrcweir             }
1534cdf0e10cSrcweir             else
1535cdf0e10cSrcweir             {
1536cdf0e10cSrcweir                 if ( pWindow->mpWindowImpl->mbChildPtrOverwrite )
1537cdf0e10cSrcweir                     ePointerStyle = pWindow->GetPointer().GetStyle();
1538cdf0e10cSrcweir             }
1539cdf0e10cSrcweir         }
1540cdf0e10cSrcweir 
1541cdf0e10cSrcweir         if ( pWindow->ImplIsOverlapWindow() )
1542cdf0e10cSrcweir             break;
1543cdf0e10cSrcweir 
1544cdf0e10cSrcweir         pWindow = pWindow->ImplGetParent();
1545cdf0e10cSrcweir     }
1546cdf0e10cSrcweir     while ( pWindow );
1547cdf0e10cSrcweir 
1548cdf0e10cSrcweir     return ePointerStyle;
1549cdf0e10cSrcweir }
1550cdf0e10cSrcweir 
1551cdf0e10cSrcweir // -----------------------------------------------------------------------
1552cdf0e10cSrcweir 
1553cdf0e10cSrcweir void Window::ImplResetReallyVisible()
1554cdf0e10cSrcweir {
1555cdf0e10cSrcweir     sal_Bool bBecameReallyInvisible = mpWindowImpl->mbReallyVisible;
1556cdf0e10cSrcweir 
1557cdf0e10cSrcweir     mbDevOutput     = sal_False;
1558cdf0e10cSrcweir     mpWindowImpl->mbReallyVisible = sal_False;
1559cdf0e10cSrcweir     mpWindowImpl->mbReallyShown   = sal_False;
1560cdf0e10cSrcweir 
1561cdf0e10cSrcweir     // the SHOW/HIDE events serve as indicators to send child creation/destroy events to the access bridge.
1562cdf0e10cSrcweir     // For this, the data member of the event must not be NULL.
1563cdf0e10cSrcweir     // Previously, we did this in Window::Show, but there some events got lost in certain situations.
1564cdf0e10cSrcweir     // #104887# - 2004-08-10 - fs@openoffice.org
1565cdf0e10cSrcweir 	if( bBecameReallyInvisible && ImplIsAccessibleCandidate() )
1566cdf0e10cSrcweir         ImplCallEventListeners( VCLEVENT_WINDOW_HIDE, this );
1567cdf0e10cSrcweir         // TODO. It's kind of a hack that we're re-using the VCLEVENT_WINDOW_HIDE. Normally, we should
1568cdf0e10cSrcweir         // introduce another event which explicitly triggers the Accessibility implementations.
1569cdf0e10cSrcweir 
1570cdf0e10cSrcweir     Window* pWindow = mpWindowImpl->mpFirstOverlap;
1571cdf0e10cSrcweir     while ( pWindow )
1572cdf0e10cSrcweir     {
1573cdf0e10cSrcweir         if ( pWindow->mpWindowImpl->mbReallyVisible )
1574cdf0e10cSrcweir             pWindow->ImplResetReallyVisible();
1575cdf0e10cSrcweir         pWindow = pWindow->mpWindowImpl->mpNext;
1576cdf0e10cSrcweir     }
1577cdf0e10cSrcweir 
1578cdf0e10cSrcweir     pWindow = mpWindowImpl->mpFirstChild;
1579cdf0e10cSrcweir     while ( pWindow )
1580cdf0e10cSrcweir     {
1581cdf0e10cSrcweir         if ( pWindow->mpWindowImpl->mbReallyVisible )
1582cdf0e10cSrcweir             pWindow->ImplResetReallyVisible();
1583cdf0e10cSrcweir         pWindow = pWindow->mpWindowImpl->mpNext;
1584cdf0e10cSrcweir     }
1585cdf0e10cSrcweir }
1586cdf0e10cSrcweir 
1587cdf0e10cSrcweir // -----------------------------------------------------------------------
1588cdf0e10cSrcweir 
1589cdf0e10cSrcweir void Window::ImplSetReallyVisible()
1590cdf0e10cSrcweir {
1591cdf0e10cSrcweir     // #i43594# it is possible that INITSHOW was never send, because the visibility state changed between
1592cdf0e10cSrcweir     // ImplCallInitShow() and ImplSetReallyVisible() when called from Show()
1593cdf0e10cSrcweir     // mbReallyShown is a useful indicator
1594cdf0e10cSrcweir     if( !mpWindowImpl->mbReallyShown )
1595cdf0e10cSrcweir         ImplCallInitShow();
1596cdf0e10cSrcweir 
1597cdf0e10cSrcweir     sal_Bool bBecameReallyVisible = !mpWindowImpl->mbReallyVisible;
1598cdf0e10cSrcweir 
1599cdf0e10cSrcweir     mbDevOutput     = sal_True;
1600cdf0e10cSrcweir     mpWindowImpl->mbReallyVisible = sal_True;
1601cdf0e10cSrcweir     mpWindowImpl->mbReallyShown   = sal_True;
1602cdf0e10cSrcweir 
1603cdf0e10cSrcweir     // the SHOW/HIDE events serve as indicators to send child creation/destroy events to the access bridge.
1604cdf0e10cSrcweir     // For this, the data member of the event must not be NULL.
1605cdf0e10cSrcweir     // Previously, we did this in Window::Show, but there some events got lost in certain situations. Now
1606cdf0e10cSrcweir     // we're doing it when the visibility really changes
1607cdf0e10cSrcweir     // #104887# - 2004-08-10 - fs@openoffice.org
1608cdf0e10cSrcweir 	if( bBecameReallyVisible && ImplIsAccessibleCandidate() )
1609cdf0e10cSrcweir         ImplCallEventListeners( VCLEVENT_WINDOW_SHOW, this );
1610cdf0e10cSrcweir         // TODO. It's kind of a hack that we're re-using the VCLEVENT_WINDOW_SHOW. Normally, we should
1611cdf0e10cSrcweir         // introduce another event which explicitly triggers the Accessibility implementations.
1612cdf0e10cSrcweir 
1613cdf0e10cSrcweir     Window* pWindow = mpWindowImpl->mpFirstOverlap;
1614cdf0e10cSrcweir     while ( pWindow )
1615cdf0e10cSrcweir     {
1616cdf0e10cSrcweir         if ( pWindow->mpWindowImpl->mbVisible )
1617cdf0e10cSrcweir             pWindow->ImplSetReallyVisible();
1618cdf0e10cSrcweir         pWindow = pWindow->mpWindowImpl->mpNext;
1619cdf0e10cSrcweir     }
1620cdf0e10cSrcweir 
1621cdf0e10cSrcweir     pWindow = mpWindowImpl->mpFirstChild;
1622cdf0e10cSrcweir     while ( pWindow )
1623cdf0e10cSrcweir     {
1624cdf0e10cSrcweir         if ( pWindow->mpWindowImpl->mbVisible )
1625cdf0e10cSrcweir             pWindow->ImplSetReallyVisible();
1626cdf0e10cSrcweir         pWindow = pWindow->mpWindowImpl->mpNext;
1627cdf0e10cSrcweir     }
1628cdf0e10cSrcweir }
1629cdf0e10cSrcweir 
1630cdf0e10cSrcweir // -----------------------------------------------------------------------
1631cdf0e10cSrcweir 
1632cdf0e10cSrcweir void Window::ImplCallInitShow()
1633cdf0e10cSrcweir {
1634cdf0e10cSrcweir     mpWindowImpl->mbReallyShown   = sal_True;
1635cdf0e10cSrcweir     mpWindowImpl->mbInInitShow    = sal_True;
1636cdf0e10cSrcweir     StateChanged( STATE_CHANGE_INITSHOW );
1637cdf0e10cSrcweir     mpWindowImpl->mbInInitShow    = sal_False;
1638cdf0e10cSrcweir 
1639cdf0e10cSrcweir     Window* pWindow = mpWindowImpl->mpFirstOverlap;
1640cdf0e10cSrcweir     while ( pWindow )
1641cdf0e10cSrcweir     {
1642cdf0e10cSrcweir         if ( pWindow->mpWindowImpl->mbVisible )
1643cdf0e10cSrcweir             pWindow->ImplCallInitShow();
1644cdf0e10cSrcweir         pWindow = pWindow->mpWindowImpl->mpNext;
1645cdf0e10cSrcweir     }
1646cdf0e10cSrcweir 
1647cdf0e10cSrcweir     pWindow = mpWindowImpl->mpFirstChild;
1648cdf0e10cSrcweir     while ( pWindow )
1649cdf0e10cSrcweir     {
1650cdf0e10cSrcweir         if ( pWindow->mpWindowImpl->mbVisible )
1651cdf0e10cSrcweir             pWindow->ImplCallInitShow();
1652cdf0e10cSrcweir         pWindow = pWindow->mpWindowImpl->mpNext;
1653cdf0e10cSrcweir     }
1654cdf0e10cSrcweir }
1655cdf0e10cSrcweir 
1656cdf0e10cSrcweir // -----------------------------------------------------------------------
1657cdf0e10cSrcweir 
1658cdf0e10cSrcweir void Window::ImplAddDel( ImplDelData* pDel ) // TODO: make "const" when incompatiblity ok
1659cdf0e10cSrcweir {
1660cdf0e10cSrcweir     DBG_ASSERT( !pDel->mpWindow, "Window::ImplAddDel(): cannot add ImplDelData twice !" );
1661cdf0e10cSrcweir     if( !pDel->mpWindow )
1662cdf0e10cSrcweir     {
1663cdf0e10cSrcweir         pDel->mpWindow = this;  // #112873# store ref to this window, so pDel can remove itself
1664cdf0e10cSrcweir         pDel->mpNext = mpWindowImpl->mpFirstDel;
1665cdf0e10cSrcweir         mpWindowImpl->mpFirstDel = pDel;
1666cdf0e10cSrcweir     }
1667cdf0e10cSrcweir }
1668cdf0e10cSrcweir 
1669cdf0e10cSrcweir // -----------------------------------------------------------------------
1670cdf0e10cSrcweir 
1671cdf0e10cSrcweir void Window::ImplRemoveDel( ImplDelData* pDel ) // TODO: make "const" when incompatiblity ok
1672cdf0e10cSrcweir {
1673cdf0e10cSrcweir     pDel->mpWindow = NULL;      // #112873# pDel is not associated with a Window anymore
1674cdf0e10cSrcweir     if ( mpWindowImpl->mpFirstDel == pDel )
1675cdf0e10cSrcweir         mpWindowImpl->mpFirstDel = pDel->mpNext;
1676cdf0e10cSrcweir     else
1677cdf0e10cSrcweir     {
1678cdf0e10cSrcweir         ImplDelData* pData = mpWindowImpl->mpFirstDel;
1679cdf0e10cSrcweir         while ( pData->mpNext != pDel )
1680cdf0e10cSrcweir             pData = pData->mpNext;
1681cdf0e10cSrcweir         pData->mpNext = pDel->mpNext;
1682cdf0e10cSrcweir     }
1683cdf0e10cSrcweir }
1684cdf0e10cSrcweir 
1685cdf0e10cSrcweir // -----------------------------------------------------------------------
1686cdf0e10cSrcweir 
1687cdf0e10cSrcweir void Window::ImplInitResolutionSettings()
1688cdf0e10cSrcweir {
1689cdf0e10cSrcweir     // AppFont-Aufloesung und DPI-Aufloesung neu berechnen
1690cdf0e10cSrcweir     if ( mpWindowImpl->mbFrame )
1691cdf0e10cSrcweir     {
1692cdf0e10cSrcweir         const StyleSettings& rStyleSettings = maSettings.GetStyleSettings();
1693cdf0e10cSrcweir         sal_uInt16 nScreenZoom = rStyleSettings.GetScreenZoom();
1694cdf0e10cSrcweir         mnDPIX = (mpWindowImpl->mpFrameData->mnDPIX*nScreenZoom)/100;
1695cdf0e10cSrcweir         mnDPIY = (mpWindowImpl->mpFrameData->mnDPIY*nScreenZoom)/100;
1696cdf0e10cSrcweir         SetPointFont( rStyleSettings.GetAppFont() );
1697cdf0e10cSrcweir     }
1698cdf0e10cSrcweir     else if ( mpWindowImpl->mpParent )
1699cdf0e10cSrcweir     {
1700cdf0e10cSrcweir         mnDPIX  = mpWindowImpl->mpParent->mnDPIX;
1701cdf0e10cSrcweir         mnDPIY  = mpWindowImpl->mpParent->mnDPIY;
1702cdf0e10cSrcweir     }
1703cdf0e10cSrcweir 
1704cdf0e10cSrcweir     // Vorberechnete Werte fuer logische Einheiten updaten und auch
1705cdf0e10cSrcweir     // die entsprechenden Tools dazu
1706cdf0e10cSrcweir     if ( IsMapMode() )
1707cdf0e10cSrcweir     {
1708cdf0e10cSrcweir         MapMode aMapMode = GetMapMode();
1709cdf0e10cSrcweir         SetMapMode();
1710cdf0e10cSrcweir         SetMapMode( aMapMode );
1711cdf0e10cSrcweir     }
1712cdf0e10cSrcweir }
1713cdf0e10cSrcweir 
1714cdf0e10cSrcweir // -----------------------------------------------------------------------
1715cdf0e10cSrcweir 
1716cdf0e10cSrcweir void Window::ImplPointToLogic( Font& rFont ) const
1717cdf0e10cSrcweir {
1718cdf0e10cSrcweir     Size    aSize = rFont.GetSize();
1719cdf0e10cSrcweir     sal_uInt16  nScreenFontZoom = maSettings.GetStyleSettings().GetScreenFontZoom();
1720cdf0e10cSrcweir 
1721cdf0e10cSrcweir     if ( aSize.Width() )
1722cdf0e10cSrcweir     {
1723cdf0e10cSrcweir         aSize.Width() *= mpWindowImpl->mpFrameData->mnDPIX;
1724cdf0e10cSrcweir         aSize.Width() += 72/2;
1725cdf0e10cSrcweir         aSize.Width() /= 72;
1726cdf0e10cSrcweir         aSize.Width() *= nScreenFontZoom;
1727cdf0e10cSrcweir         aSize.Width() /= 100;
1728cdf0e10cSrcweir     }
1729cdf0e10cSrcweir     aSize.Height() *= mpWindowImpl->mpFrameData->mnDPIY;
1730cdf0e10cSrcweir     aSize.Height() += 72/2;
1731cdf0e10cSrcweir     aSize.Height() /= 72;
1732cdf0e10cSrcweir     aSize.Height() *= nScreenFontZoom;
1733cdf0e10cSrcweir     aSize.Height() /= 100;
1734cdf0e10cSrcweir 
1735cdf0e10cSrcweir     if ( IsMapModeEnabled() )
1736cdf0e10cSrcweir         aSize = PixelToLogic( aSize );
1737cdf0e10cSrcweir 
1738cdf0e10cSrcweir     rFont.SetSize( aSize );
1739cdf0e10cSrcweir }
1740cdf0e10cSrcweir 
1741cdf0e10cSrcweir // -----------------------------------------------------------------------
1742cdf0e10cSrcweir 
1743cdf0e10cSrcweir void Window::ImplLogicToPoint( Font& rFont ) const
1744cdf0e10cSrcweir {
1745cdf0e10cSrcweir     Size    aSize = rFont.GetSize();
1746cdf0e10cSrcweir     sal_uInt16  nScreenFontZoom = maSettings.GetStyleSettings().GetScreenFontZoom();
1747cdf0e10cSrcweir 
1748cdf0e10cSrcweir     if ( IsMapModeEnabled() )
1749cdf0e10cSrcweir         aSize = LogicToPixel( aSize );
1750cdf0e10cSrcweir 
1751cdf0e10cSrcweir     if ( aSize.Width() )
1752cdf0e10cSrcweir     {
1753cdf0e10cSrcweir         aSize.Width() *= 100;
1754cdf0e10cSrcweir         aSize.Width() /= nScreenFontZoom;
1755cdf0e10cSrcweir         aSize.Width() *= 72;
1756cdf0e10cSrcweir         aSize.Width() += mpWindowImpl->mpFrameData->mnDPIX/2;
1757cdf0e10cSrcweir         aSize.Width() /= mpWindowImpl->mpFrameData->mnDPIX;
1758cdf0e10cSrcweir     }
1759cdf0e10cSrcweir     aSize.Height() *= 100;
1760cdf0e10cSrcweir     aSize.Height() /= nScreenFontZoom;
1761cdf0e10cSrcweir     aSize.Height() *= 72;
1762cdf0e10cSrcweir     aSize.Height() += mpWindowImpl->mpFrameData->mnDPIY/2;
1763cdf0e10cSrcweir     aSize.Height() /= mpWindowImpl->mpFrameData->mnDPIY;
1764cdf0e10cSrcweir 
1765cdf0e10cSrcweir     rFont.SetSize( aSize );
1766cdf0e10cSrcweir }
1767cdf0e10cSrcweir 
1768cdf0e10cSrcweir // -----------------------------------------------------------------------
1769cdf0e10cSrcweir 
1770cdf0e10cSrcweir sal_Bool Window::ImplSysObjClip( const Region* pOldRegion )
1771cdf0e10cSrcweir {
1772cdf0e10cSrcweir     sal_Bool bUpdate = sal_True;
1773cdf0e10cSrcweir 
1774cdf0e10cSrcweir     if ( mpWindowImpl->mpSysObj )
1775cdf0e10cSrcweir     {
1776cdf0e10cSrcweir         sal_Bool bVisibleState = mpWindowImpl->mbReallyVisible;
1777cdf0e10cSrcweir 
1778cdf0e10cSrcweir         if ( bVisibleState )
1779cdf0e10cSrcweir         {
1780cdf0e10cSrcweir             Region* pWinChildClipRegion = ImplGetWinChildClipRegion();
1781cdf0e10cSrcweir 
1782cdf0e10cSrcweir             if ( !pWinChildClipRegion->IsEmpty() )
1783cdf0e10cSrcweir             {
1784cdf0e10cSrcweir                 if ( pOldRegion )
1785cdf0e10cSrcweir                 {
1786cdf0e10cSrcweir                     Region aNewRegion = *pWinChildClipRegion;
1787cdf0e10cSrcweir                     pWinChildClipRegion->Intersect( *pOldRegion );
1788cdf0e10cSrcweir                     bUpdate = aNewRegion == *pWinChildClipRegion;
1789cdf0e10cSrcweir                 }
1790cdf0e10cSrcweir 
1791cdf0e10cSrcweir                 if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
1792cdf0e10cSrcweir                     ImplInvalidateAllOverlapBackgrounds();
1793cdf0e10cSrcweir 
1794cdf0e10cSrcweir                 Region      aRegion = *pWinChildClipRegion;
1795cdf0e10cSrcweir                 Rectangle   aWinRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
1796cdf0e10cSrcweir                 Region      aWinRectRegion( aWinRect );
1797cdf0e10cSrcweir                 sal_uInt16      nClipFlags = mpWindowImpl->mpSysObj->GetClipRegionType();
1798cdf0e10cSrcweir 
1799cdf0e10cSrcweir                 if ( aRegion == aWinRectRegion )
1800cdf0e10cSrcweir                     mpWindowImpl->mpSysObj->ResetClipRegion();
1801cdf0e10cSrcweir                 else
1802cdf0e10cSrcweir                 {
1803cdf0e10cSrcweir                     if ( nClipFlags & SAL_OBJECT_CLIP_EXCLUDERECTS )
1804cdf0e10cSrcweir                     {
1805cdf0e10cSrcweir                         aWinRectRegion.Exclude( aRegion );
1806cdf0e10cSrcweir                         aRegion = aWinRectRegion;
1807cdf0e10cSrcweir                     }
1808cdf0e10cSrcweir                     if ( !(nClipFlags & SAL_OBJECT_CLIP_ABSOLUTE) )
1809cdf0e10cSrcweir                         aRegion.Move( -mnOutOffX, -mnOutOffY );
1810cdf0e10cSrcweir 
1811cdf0e10cSrcweir                     // ClipRegion setzen/updaten
1812cdf0e10cSrcweir                     long                nX;
1813cdf0e10cSrcweir                     long                nY;
1814cdf0e10cSrcweir                     long                nWidth;
1815cdf0e10cSrcweir                     long                nHeight;
1816cdf0e10cSrcweir                     sal_uLong               nRectCount;
1817cdf0e10cSrcweir                     ImplRegionInfo      aInfo;
1818cdf0e10cSrcweir                     sal_Bool                bRegionRect;
1819cdf0e10cSrcweir 
1820cdf0e10cSrcweir                     nRectCount = aRegion.GetRectCount();
1821cdf0e10cSrcweir                     mpWindowImpl->mpSysObj->BeginSetClipRegion( nRectCount );
1822cdf0e10cSrcweir                     bRegionRect = aRegion.ImplGetFirstRect( aInfo, nX, nY, nWidth, nHeight );
1823cdf0e10cSrcweir                     while ( bRegionRect )
1824cdf0e10cSrcweir                     {
1825cdf0e10cSrcweir                         mpWindowImpl->mpSysObj->UnionClipRegion( nX, nY, nWidth, nHeight );
1826cdf0e10cSrcweir                         bRegionRect = aRegion.ImplGetNextRect( aInfo, nX, nY, nWidth, nHeight );
1827cdf0e10cSrcweir                     }
1828cdf0e10cSrcweir                     mpWindowImpl->mpSysObj->EndSetClipRegion();
1829cdf0e10cSrcweir                 }
1830cdf0e10cSrcweir             }
1831cdf0e10cSrcweir             else
1832cdf0e10cSrcweir                 bVisibleState = sal_False;
1833cdf0e10cSrcweir         }
1834cdf0e10cSrcweir 
1835cdf0e10cSrcweir         // Visible-Status updaten
1836cdf0e10cSrcweir         mpWindowImpl->mpSysObj->Show( bVisibleState );
1837cdf0e10cSrcweir     }
1838cdf0e10cSrcweir 
1839cdf0e10cSrcweir     return bUpdate;
1840cdf0e10cSrcweir }
1841cdf0e10cSrcweir 
1842cdf0e10cSrcweir // -----------------------------------------------------------------------
1843cdf0e10cSrcweir 
1844cdf0e10cSrcweir void Window::ImplUpdateSysObjChildsClip()
1845cdf0e10cSrcweir {
1846cdf0e10cSrcweir     if ( mpWindowImpl->mpSysObj && mpWindowImpl->mbInitWinClipRegion )
1847cdf0e10cSrcweir         ImplSysObjClip( NULL );
1848cdf0e10cSrcweir 
1849cdf0e10cSrcweir     Window* pWindow = mpWindowImpl->mpFirstChild;
1850cdf0e10cSrcweir     while ( pWindow )
1851cdf0e10cSrcweir     {
1852cdf0e10cSrcweir         pWindow->ImplUpdateSysObjChildsClip();
1853cdf0e10cSrcweir         pWindow = pWindow->mpWindowImpl->mpNext;
1854cdf0e10cSrcweir     }
1855cdf0e10cSrcweir }
1856cdf0e10cSrcweir 
1857cdf0e10cSrcweir // -----------------------------------------------------------------------
1858cdf0e10cSrcweir 
1859cdf0e10cSrcweir void Window::ImplUpdateSysObjOverlapsClip()
1860cdf0e10cSrcweir {
1861cdf0e10cSrcweir     ImplUpdateSysObjChildsClip();
1862cdf0e10cSrcweir 
1863cdf0e10cSrcweir     Window* pWindow = mpWindowImpl->mpFirstOverlap;
1864cdf0e10cSrcweir     while ( pWindow )
1865cdf0e10cSrcweir     {
1866cdf0e10cSrcweir         pWindow->ImplUpdateSysObjOverlapsClip();
1867cdf0e10cSrcweir         pWindow = pWindow->mpWindowImpl->mpNext;
1868cdf0e10cSrcweir     }
1869cdf0e10cSrcweir }
1870cdf0e10cSrcweir 
1871cdf0e10cSrcweir // -----------------------------------------------------------------------
1872cdf0e10cSrcweir 
1873cdf0e10cSrcweir void Window::ImplUpdateSysObjClip()
1874cdf0e10cSrcweir {
1875cdf0e10cSrcweir     if ( !ImplIsOverlapWindow() )
1876cdf0e10cSrcweir     {
1877cdf0e10cSrcweir         ImplUpdateSysObjChildsClip();
1878cdf0e10cSrcweir 
1879cdf0e10cSrcweir         // Schwestern muessen ihre ClipRegion auch neu berechnen
1880cdf0e10cSrcweir         if ( mpWindowImpl->mbClipSiblings )
1881cdf0e10cSrcweir         {
1882cdf0e10cSrcweir             Window* pWindow = mpWindowImpl->mpNext;
1883cdf0e10cSrcweir             while ( pWindow )
1884cdf0e10cSrcweir             {
1885cdf0e10cSrcweir                 pWindow->ImplUpdateSysObjChildsClip();
1886cdf0e10cSrcweir                 pWindow = pWindow->mpWindowImpl->mpNext;
1887cdf0e10cSrcweir             }
1888cdf0e10cSrcweir         }
1889cdf0e10cSrcweir     }
1890cdf0e10cSrcweir     else
1891cdf0e10cSrcweir         mpWindowImpl->mpFrameWindow->ImplUpdateSysObjOverlapsClip();
1892cdf0e10cSrcweir }
1893cdf0e10cSrcweir 
1894cdf0e10cSrcweir // -----------------------------------------------------------------------
1895cdf0e10cSrcweir 
1896cdf0e10cSrcweir sal_Bool Window::ImplSetClipFlagChilds( sal_Bool bSysObjOnlySmaller )
1897cdf0e10cSrcweir {
1898cdf0e10cSrcweir     sal_Bool bUpdate = sal_True;
1899cdf0e10cSrcweir     if ( mpWindowImpl->mpSysObj )
1900cdf0e10cSrcweir     {
1901cdf0e10cSrcweir         Region* pOldRegion = NULL;
1902cdf0e10cSrcweir         if ( bSysObjOnlySmaller && !mpWindowImpl->mbInitWinClipRegion )
1903cdf0e10cSrcweir             pOldRegion = new Region( mpWindowImpl->maWinClipRegion );
1904cdf0e10cSrcweir 
1905cdf0e10cSrcweir         mbInitClipRegion = sal_True;
1906cdf0e10cSrcweir         mpWindowImpl->mbInitWinClipRegion = sal_True;
1907cdf0e10cSrcweir 
1908cdf0e10cSrcweir         Window* pWindow = mpWindowImpl->mpFirstChild;
1909cdf0e10cSrcweir         while ( pWindow )
1910cdf0e10cSrcweir         {
1911cdf0e10cSrcweir             if ( !pWindow->ImplSetClipFlagChilds( bSysObjOnlySmaller ) )
1912cdf0e10cSrcweir                 bUpdate = sal_False;
1913cdf0e10cSrcweir             pWindow = pWindow->mpWindowImpl->mpNext;
1914cdf0e10cSrcweir         }
1915cdf0e10cSrcweir 
1916cdf0e10cSrcweir         if ( !ImplSysObjClip( pOldRegion ) )
1917cdf0e10cSrcweir         {
1918cdf0e10cSrcweir             mbInitClipRegion = sal_True;
1919cdf0e10cSrcweir             mpWindowImpl->mbInitWinClipRegion = sal_True;
1920cdf0e10cSrcweir             bUpdate = sal_False;
1921cdf0e10cSrcweir         }
1922cdf0e10cSrcweir 
1923cdf0e10cSrcweir         if ( pOldRegion )
1924cdf0e10cSrcweir             delete pOldRegion;
1925cdf0e10cSrcweir     }
1926cdf0e10cSrcweir     else
1927cdf0e10cSrcweir     {
1928cdf0e10cSrcweir     mbInitClipRegion = sal_True;
1929cdf0e10cSrcweir     mpWindowImpl->mbInitWinClipRegion = sal_True;
1930cdf0e10cSrcweir 
1931cdf0e10cSrcweir     Window* pWindow = mpWindowImpl->mpFirstChild;
1932cdf0e10cSrcweir     while ( pWindow )
1933cdf0e10cSrcweir     {
1934cdf0e10cSrcweir         if ( !pWindow->ImplSetClipFlagChilds( bSysObjOnlySmaller ) )
1935cdf0e10cSrcweir             bUpdate = sal_False;
1936cdf0e10cSrcweir         pWindow = pWindow->mpWindowImpl->mpNext;
1937cdf0e10cSrcweir     }
1938cdf0e10cSrcweir     }
1939cdf0e10cSrcweir     return bUpdate;
1940cdf0e10cSrcweir }
1941cdf0e10cSrcweir 
1942cdf0e10cSrcweir // -----------------------------------------------------------------------
1943cdf0e10cSrcweir 
1944cdf0e10cSrcweir sal_Bool Window::ImplSetClipFlagOverlapWindows( sal_Bool bSysObjOnlySmaller )
1945cdf0e10cSrcweir {
1946cdf0e10cSrcweir     sal_Bool bUpdate = ImplSetClipFlagChilds( bSysObjOnlySmaller );
1947cdf0e10cSrcweir 
1948cdf0e10cSrcweir     Window* pWindow = mpWindowImpl->mpFirstOverlap;
1949cdf0e10cSrcweir     while ( pWindow )
1950cdf0e10cSrcweir     {
1951cdf0e10cSrcweir         if ( !pWindow->ImplSetClipFlagOverlapWindows( bSysObjOnlySmaller ) )
1952cdf0e10cSrcweir             bUpdate = sal_False;
1953cdf0e10cSrcweir         pWindow = pWindow->mpWindowImpl->mpNext;
1954cdf0e10cSrcweir     }
1955cdf0e10cSrcweir 
1956cdf0e10cSrcweir     return bUpdate;
1957cdf0e10cSrcweir }
1958cdf0e10cSrcweir 
1959cdf0e10cSrcweir // -----------------------------------------------------------------------
1960cdf0e10cSrcweir 
1961cdf0e10cSrcweir sal_Bool Window::ImplSetClipFlag( sal_Bool bSysObjOnlySmaller )
1962cdf0e10cSrcweir {
1963cdf0e10cSrcweir     if ( !ImplIsOverlapWindow() )
1964cdf0e10cSrcweir     {
1965cdf0e10cSrcweir         sal_Bool bUpdate = ImplSetClipFlagChilds( bSysObjOnlySmaller );
1966cdf0e10cSrcweir 
1967cdf0e10cSrcweir         Window* pParent = ImplGetParent();
1968cdf0e10cSrcweir         if ( pParent &&
1969cdf0e10cSrcweir              ((pParent->GetStyle() & WB_CLIPCHILDREN) || (mpWindowImpl->mnParentClipMode & PARENTCLIPMODE_CLIP)) )
1970cdf0e10cSrcweir         {
1971cdf0e10cSrcweir             pParent->mbInitClipRegion = sal_True;
1972cdf0e10cSrcweir             pParent->mpWindowImpl->mbInitChildRegion = sal_True;
1973cdf0e10cSrcweir         }
1974cdf0e10cSrcweir 
1975cdf0e10cSrcweir         // Schwestern muessen ihre ClipRegion auch neu berechnen
1976cdf0e10cSrcweir         if ( mpWindowImpl->mbClipSiblings )
1977cdf0e10cSrcweir         {
1978cdf0e10cSrcweir             Window* pWindow = mpWindowImpl->mpNext;
1979cdf0e10cSrcweir             while ( pWindow )
1980cdf0e10cSrcweir             {
1981cdf0e10cSrcweir                 if ( !pWindow->ImplSetClipFlagChilds( bSysObjOnlySmaller ) )
1982cdf0e10cSrcweir                     bUpdate = sal_False;
1983cdf0e10cSrcweir                 pWindow = pWindow->mpWindowImpl->mpNext;
1984cdf0e10cSrcweir             }
1985cdf0e10cSrcweir         }
1986cdf0e10cSrcweir 
1987cdf0e10cSrcweir         return bUpdate;
1988cdf0e10cSrcweir     }
1989cdf0e10cSrcweir     else
1990cdf0e10cSrcweir         return mpWindowImpl->mpFrameWindow->ImplSetClipFlagOverlapWindows( bSysObjOnlySmaller );
1991cdf0e10cSrcweir }
1992cdf0e10cSrcweir 
1993cdf0e10cSrcweir // -----------------------------------------------------------------------
1994cdf0e10cSrcweir 
1995cdf0e10cSrcweir void Window::ImplIntersectWindowClipRegion( Region& rRegion )
1996cdf0e10cSrcweir {
1997cdf0e10cSrcweir     if ( mpWindowImpl->mbInitWinClipRegion )
1998cdf0e10cSrcweir         ImplInitWinClipRegion();
1999cdf0e10cSrcweir 
2000cdf0e10cSrcweir     rRegion.Intersect( mpWindowImpl->maWinClipRegion );
2001cdf0e10cSrcweir }
2002cdf0e10cSrcweir 
2003cdf0e10cSrcweir // -----------------------------------------------------------------------
2004cdf0e10cSrcweir 
2005cdf0e10cSrcweir void Window::ImplIntersectWindowRegion( Region& rRegion )
2006cdf0e10cSrcweir {
2007cdf0e10cSrcweir     rRegion.Intersect( Rectangle( Point( mnOutOffX, mnOutOffY ),
2008cdf0e10cSrcweir                                   Size( mnOutWidth, mnOutHeight ) ) );
2009cdf0e10cSrcweir     if ( mpWindowImpl->mbWinRegion )
2010cdf0e10cSrcweir         rRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
2011cdf0e10cSrcweir }
2012cdf0e10cSrcweir 
2013cdf0e10cSrcweir // -----------------------------------------------------------------------
2014cdf0e10cSrcweir 
2015cdf0e10cSrcweir void Window::ImplExcludeWindowRegion( Region& rRegion )
2016cdf0e10cSrcweir {
2017cdf0e10cSrcweir     if ( mpWindowImpl->mbWinRegion )
2018cdf0e10cSrcweir     {
2019cdf0e10cSrcweir         Point aPoint( mnOutOffX, mnOutOffY );
2020cdf0e10cSrcweir         Region aRegion( Rectangle( aPoint,
2021cdf0e10cSrcweir                                    Size( mnOutWidth, mnOutHeight ) ) );
2022cdf0e10cSrcweir         aRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
2023cdf0e10cSrcweir         rRegion.Exclude( aRegion );
2024cdf0e10cSrcweir     }
2025cdf0e10cSrcweir     else
2026cdf0e10cSrcweir     {
2027cdf0e10cSrcweir         Point aPoint( mnOutOffX, mnOutOffY );
2028cdf0e10cSrcweir         rRegion.Exclude( Rectangle( aPoint,
2029cdf0e10cSrcweir                                     Size( mnOutWidth, mnOutHeight ) ) );
2030cdf0e10cSrcweir     }
2031cdf0e10cSrcweir }
2032cdf0e10cSrcweir 
2033cdf0e10cSrcweir // -----------------------------------------------------------------------
2034cdf0e10cSrcweir 
2035cdf0e10cSrcweir void Window::ImplExcludeOverlapWindows( Region& rRegion )
2036cdf0e10cSrcweir {
2037cdf0e10cSrcweir     Window* pWindow = mpWindowImpl->mpFirstOverlap;
2038cdf0e10cSrcweir     while ( pWindow )
2039cdf0e10cSrcweir     {
2040cdf0e10cSrcweir         if ( pWindow->mpWindowImpl->mbReallyVisible )
2041cdf0e10cSrcweir         {
2042cdf0e10cSrcweir             pWindow->ImplExcludeWindowRegion( rRegion );
2043cdf0e10cSrcweir             pWindow->ImplExcludeOverlapWindows( rRegion );
2044cdf0e10cSrcweir         }
2045cdf0e10cSrcweir 
2046cdf0e10cSrcweir         pWindow = pWindow->mpWindowImpl->mpNext;
2047cdf0e10cSrcweir     }
2048cdf0e10cSrcweir }
2049cdf0e10cSrcweir 
2050cdf0e10cSrcweir // -----------------------------------------------------------------------
2051cdf0e10cSrcweir 
2052cdf0e10cSrcweir void Window::ImplExcludeOverlapWindows2( Region& rRegion )
2053cdf0e10cSrcweir {
2054cdf0e10cSrcweir     if ( mpWindowImpl->mbReallyVisible )
2055cdf0e10cSrcweir         ImplExcludeWindowRegion( rRegion );
2056cdf0e10cSrcweir 
2057cdf0e10cSrcweir     ImplExcludeOverlapWindows( rRegion );
2058cdf0e10cSrcweir }
2059cdf0e10cSrcweir 
2060cdf0e10cSrcweir // -----------------------------------------------------------------------
2061cdf0e10cSrcweir 
2062cdf0e10cSrcweir void Window::ImplClipBoundaries( Region& rRegion, sal_Bool bThis, sal_Bool bOverlaps )
2063cdf0e10cSrcweir {
2064cdf0e10cSrcweir     if ( bThis )
2065cdf0e10cSrcweir         ImplIntersectWindowClipRegion( rRegion );
2066cdf0e10cSrcweir     else if ( ImplIsOverlapWindow() )
2067cdf0e10cSrcweir     {
2068cdf0e10cSrcweir         // Evt. noch am Frame clippen
2069cdf0e10cSrcweir         if ( !mpWindowImpl->mbFrame )
2070cdf0e10cSrcweir             rRegion.Intersect( Rectangle( Point( 0, 0 ), Size( mpWindowImpl->mpFrameWindow->mnOutWidth, mpWindowImpl->mpFrameWindow->mnOutHeight ) ) );
2071cdf0e10cSrcweir 
2072cdf0e10cSrcweir         if ( bOverlaps && !rRegion.IsEmpty() )
2073cdf0e10cSrcweir         {
2074cdf0e10cSrcweir             // Clip Overlap Siblings
2075cdf0e10cSrcweir             Window* pStartOverlapWindow = this;
2076cdf0e10cSrcweir             while ( !pStartOverlapWindow->mpWindowImpl->mbFrame )
2077cdf0e10cSrcweir             {
2078cdf0e10cSrcweir                 Window* pOverlapWindow = pStartOverlapWindow->mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap;
2079cdf0e10cSrcweir                 while ( pOverlapWindow && (pOverlapWindow != pStartOverlapWindow) )
2080cdf0e10cSrcweir                 {
2081cdf0e10cSrcweir                     pOverlapWindow->ImplExcludeOverlapWindows2( rRegion );
2082cdf0e10cSrcweir                     pOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext;
2083cdf0e10cSrcweir                 }
2084cdf0e10cSrcweir                 pStartOverlapWindow = pStartOverlapWindow->mpWindowImpl->mpOverlapWindow;
2085cdf0e10cSrcweir             }
2086cdf0e10cSrcweir 
2087cdf0e10cSrcweir             // Clip Child Overlap Windows
2088cdf0e10cSrcweir             ImplExcludeOverlapWindows( rRegion );
2089cdf0e10cSrcweir         }
2090cdf0e10cSrcweir     }
2091cdf0e10cSrcweir     else
2092cdf0e10cSrcweir         ImplGetParent()->ImplIntersectWindowClipRegion( rRegion );
2093cdf0e10cSrcweir }
2094cdf0e10cSrcweir 
2095cdf0e10cSrcweir // -----------------------------------------------------------------------
2096cdf0e10cSrcweir 
2097cdf0e10cSrcweir sal_Bool Window::ImplClipChilds( Region& rRegion )
2098cdf0e10cSrcweir {
2099cdf0e10cSrcweir     sal_Bool    bOtherClip = sal_False;
2100cdf0e10cSrcweir     Window* pWindow = mpWindowImpl->mpFirstChild;
2101cdf0e10cSrcweir     while ( pWindow )
2102cdf0e10cSrcweir     {
2103cdf0e10cSrcweir         if ( pWindow->mpWindowImpl->mbReallyVisible )
2104cdf0e10cSrcweir         {
2105cdf0e10cSrcweir             // ParentClipMode-Flags auswerten
2106cdf0e10cSrcweir             sal_uInt16 nClipMode = pWindow->GetParentClipMode();
2107cdf0e10cSrcweir             if ( !(nClipMode & PARENTCLIPMODE_NOCLIP) &&
2108cdf0e10cSrcweir                  ((nClipMode & PARENTCLIPMODE_CLIP) || (GetStyle() & WB_CLIPCHILDREN)) )
2109cdf0e10cSrcweir                 pWindow->ImplExcludeWindowRegion( rRegion );
2110cdf0e10cSrcweir             else
2111cdf0e10cSrcweir                 bOtherClip = sal_True;
2112cdf0e10cSrcweir         }
2113cdf0e10cSrcweir 
2114cdf0e10cSrcweir         pWindow = pWindow->mpWindowImpl->mpNext;
2115cdf0e10cSrcweir     }
2116cdf0e10cSrcweir 
2117cdf0e10cSrcweir     return bOtherClip;
2118cdf0e10cSrcweir }
2119cdf0e10cSrcweir 
2120cdf0e10cSrcweir // -----------------------------------------------------------------------
2121cdf0e10cSrcweir 
2122cdf0e10cSrcweir void Window::ImplClipAllChilds( Region& rRegion )
2123cdf0e10cSrcweir {
2124cdf0e10cSrcweir     Window* pWindow = mpWindowImpl->mpFirstChild;
2125cdf0e10cSrcweir     while ( pWindow )
2126cdf0e10cSrcweir     {
2127cdf0e10cSrcweir         if ( pWindow->mpWindowImpl->mbReallyVisible )
2128cdf0e10cSrcweir             pWindow->ImplExcludeWindowRegion( rRegion );
2129cdf0e10cSrcweir         pWindow = pWindow->mpWindowImpl->mpNext;
2130cdf0e10cSrcweir     }
2131cdf0e10cSrcweir }
2132cdf0e10cSrcweir 
2133cdf0e10cSrcweir // -----------------------------------------------------------------------
2134cdf0e10cSrcweir 
2135cdf0e10cSrcweir void Window::ImplClipSiblings( Region& rRegion )
2136cdf0e10cSrcweir {
2137cdf0e10cSrcweir     Window* pWindow = ImplGetParent()->mpWindowImpl->mpFirstChild;
2138cdf0e10cSrcweir     while ( pWindow )
2139cdf0e10cSrcweir     {
2140cdf0e10cSrcweir         if ( pWindow == this )
2141cdf0e10cSrcweir             break;
2142cdf0e10cSrcweir 
2143cdf0e10cSrcweir         if ( pWindow->mpWindowImpl->mbReallyVisible )
2144cdf0e10cSrcweir             pWindow->ImplExcludeWindowRegion( rRegion );
2145cdf0e10cSrcweir 
2146cdf0e10cSrcweir         pWindow = pWindow->mpWindowImpl->mpNext;
2147cdf0e10cSrcweir     }
2148cdf0e10cSrcweir }
2149cdf0e10cSrcweir 
2150cdf0e10cSrcweir // -----------------------------------------------------------------------
2151cdf0e10cSrcweir 
2152cdf0e10cSrcweir void Window::ImplInitWinClipRegion()
2153cdf0e10cSrcweir {
2154cdf0e10cSrcweir     // Build Window Region
2155cdf0e10cSrcweir     mpWindowImpl->maWinClipRegion = Rectangle( Point( mnOutOffX, mnOutOffY ),
2156cdf0e10cSrcweir                                  Size( mnOutWidth, mnOutHeight ) );
2157cdf0e10cSrcweir     if ( mpWindowImpl->mbWinRegion )
2158cdf0e10cSrcweir         mpWindowImpl->maWinClipRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
2159cdf0e10cSrcweir 
2160cdf0e10cSrcweir     // ClipSiblings
2161cdf0e10cSrcweir     if ( mpWindowImpl->mbClipSiblings && !ImplIsOverlapWindow() )
2162cdf0e10cSrcweir         ImplClipSiblings( mpWindowImpl->maWinClipRegion );
2163cdf0e10cSrcweir 
2164cdf0e10cSrcweir     // Clip Parent Boundaries
2165cdf0e10cSrcweir     ImplClipBoundaries( mpWindowImpl->maWinClipRegion, sal_False, sal_True );
2166cdf0e10cSrcweir 
2167cdf0e10cSrcweir     // Clip Children
2168cdf0e10cSrcweir     if ( (GetStyle() & WB_CLIPCHILDREN) || mpWindowImpl->mbClipChildren )
2169cdf0e10cSrcweir         mpWindowImpl->mbInitChildRegion = sal_True;
2170cdf0e10cSrcweir 
2171cdf0e10cSrcweir     mpWindowImpl->mbInitWinClipRegion = sal_False;
2172cdf0e10cSrcweir }
2173cdf0e10cSrcweir 
2174cdf0e10cSrcweir // -----------------------------------------------------------------------
2175cdf0e10cSrcweir 
2176cdf0e10cSrcweir void Window::ImplInitWinChildClipRegion()
2177cdf0e10cSrcweir {
2178cdf0e10cSrcweir     if ( !mpWindowImpl->mpFirstChild )
2179cdf0e10cSrcweir     {
2180cdf0e10cSrcweir         if ( mpWindowImpl->mpChildClipRegion )
2181cdf0e10cSrcweir         {
2182cdf0e10cSrcweir             delete mpWindowImpl->mpChildClipRegion;
2183cdf0e10cSrcweir             mpWindowImpl->mpChildClipRegion = NULL;
2184cdf0e10cSrcweir         }
2185cdf0e10cSrcweir     }
2186cdf0e10cSrcweir     else
2187cdf0e10cSrcweir     {
2188cdf0e10cSrcweir         if ( !mpWindowImpl->mpChildClipRegion )
2189cdf0e10cSrcweir             mpWindowImpl->mpChildClipRegion = new Region( mpWindowImpl->maWinClipRegion );
2190cdf0e10cSrcweir         else
2191cdf0e10cSrcweir             *mpWindowImpl->mpChildClipRegion = mpWindowImpl->maWinClipRegion;
2192cdf0e10cSrcweir 
2193cdf0e10cSrcweir         ImplClipChilds( *mpWindowImpl->mpChildClipRegion );
2194cdf0e10cSrcweir     }
2195cdf0e10cSrcweir 
2196cdf0e10cSrcweir     mpWindowImpl->mbInitChildRegion = sal_False;
2197cdf0e10cSrcweir }
2198cdf0e10cSrcweir 
2199cdf0e10cSrcweir // -----------------------------------------------------------------------
2200cdf0e10cSrcweir 
2201cdf0e10cSrcweir Region* Window::ImplGetWinChildClipRegion()
2202cdf0e10cSrcweir {
2203cdf0e10cSrcweir     if ( mpWindowImpl->mbInitWinClipRegion )
2204cdf0e10cSrcweir         ImplInitWinClipRegion();
2205cdf0e10cSrcweir     if ( mpWindowImpl->mbInitChildRegion )
2206cdf0e10cSrcweir         ImplInitWinChildClipRegion();
2207cdf0e10cSrcweir     if ( mpWindowImpl->mpChildClipRegion )
2208cdf0e10cSrcweir         return mpWindowImpl->mpChildClipRegion;
2209cdf0e10cSrcweir     else
2210cdf0e10cSrcweir         return &mpWindowImpl->maWinClipRegion;
2211cdf0e10cSrcweir }
2212cdf0e10cSrcweir 
2213cdf0e10cSrcweir // -----------------------------------------------------------------------
2214cdf0e10cSrcweir 
2215cdf0e10cSrcweir void Window::ImplIntersectAndUnionOverlapWindows( const Region& rInterRegion, Region& rRegion )
2216cdf0e10cSrcweir {
2217cdf0e10cSrcweir     Window* pWindow = mpWindowImpl->mpFirstOverlap;
2218cdf0e10cSrcweir     while ( pWindow )
2219cdf0e10cSrcweir     {
2220cdf0e10cSrcweir         if ( pWindow->mpWindowImpl->mbReallyVisible )
2221cdf0e10cSrcweir         {
2222cdf0e10cSrcweir             Region aTempRegion( rInterRegion );
2223cdf0e10cSrcweir             pWindow->ImplIntersectWindowRegion( aTempRegion );
2224cdf0e10cSrcweir             rRegion.Union( aTempRegion );
2225cdf0e10cSrcweir             pWindow->ImplIntersectAndUnionOverlapWindows( rInterRegion, rRegion );
2226cdf0e10cSrcweir         }
2227cdf0e10cSrcweir 
2228cdf0e10cSrcweir         pWindow = pWindow->mpWindowImpl->mpNext;
2229cdf0e10cSrcweir     }
2230cdf0e10cSrcweir }
2231cdf0e10cSrcweir 
2232cdf0e10cSrcweir // -----------------------------------------------------------------------
2233cdf0e10cSrcweir 
2234cdf0e10cSrcweir void Window::ImplIntersectAndUnionOverlapWindows2( const Region& rInterRegion, Region& rRegion )
2235cdf0e10cSrcweir {
2236cdf0e10cSrcweir     if ( mpWindowImpl->mbReallyVisible )
2237cdf0e10cSrcweir     {
2238cdf0e10cSrcweir         Region aTempRegion( rInterRegion );
2239cdf0e10cSrcweir         ImplIntersectWindowRegion( aTempRegion );
2240cdf0e10cSrcweir         rRegion.Union( aTempRegion );
2241cdf0e10cSrcweir     }
2242cdf0e10cSrcweir 
2243cdf0e10cSrcweir     ImplIntersectAndUnionOverlapWindows( rInterRegion, rRegion );
2244cdf0e10cSrcweir }
2245cdf0e10cSrcweir 
2246cdf0e10cSrcweir // -----------------------------------------------------------------------
2247cdf0e10cSrcweir 
2248cdf0e10cSrcweir void Window::ImplCalcOverlapRegionOverlaps( const Region& rInterRegion, Region& rRegion )
2249cdf0e10cSrcweir {
2250cdf0e10cSrcweir     // Clip Overlap Siblings
2251cdf0e10cSrcweir     Window* pStartOverlapWindow;
2252cdf0e10cSrcweir     if ( !ImplIsOverlapWindow() )
2253cdf0e10cSrcweir         pStartOverlapWindow = mpWindowImpl->mpOverlapWindow;
2254cdf0e10cSrcweir     else
2255cdf0e10cSrcweir         pStartOverlapWindow = this;
2256cdf0e10cSrcweir     while ( !pStartOverlapWindow->mpWindowImpl->mbFrame )
2257cdf0e10cSrcweir     {
2258cdf0e10cSrcweir         Window* pOverlapWindow = pStartOverlapWindow->mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap;
2259cdf0e10cSrcweir         while ( pOverlapWindow && (pOverlapWindow != pStartOverlapWindow) )
2260cdf0e10cSrcweir         {
2261cdf0e10cSrcweir             pOverlapWindow->ImplIntersectAndUnionOverlapWindows2( rInterRegion, rRegion );
2262cdf0e10cSrcweir             pOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext;
2263cdf0e10cSrcweir         }
2264cdf0e10cSrcweir         pStartOverlapWindow = pStartOverlapWindow->mpWindowImpl->mpOverlapWindow;
2265cdf0e10cSrcweir     }
2266cdf0e10cSrcweir 
2267cdf0e10cSrcweir     // Clip Child Overlap Windows
2268cdf0e10cSrcweir     if ( !ImplIsOverlapWindow() )
2269cdf0e10cSrcweir         mpWindowImpl->mpOverlapWindow->ImplIntersectAndUnionOverlapWindows( rInterRegion, rRegion );
2270cdf0e10cSrcweir     else
2271cdf0e10cSrcweir         ImplIntersectAndUnionOverlapWindows( rInterRegion, rRegion );
2272cdf0e10cSrcweir }
2273cdf0e10cSrcweir 
2274cdf0e10cSrcweir // -----------------------------------------------------------------------
2275cdf0e10cSrcweir 
2276cdf0e10cSrcweir void Window::ImplCalcOverlapRegion( const Rectangle& rSourceRect, Region& rRegion,
2277cdf0e10cSrcweir                                     sal_Bool bChilds, sal_Bool bParent, sal_Bool bSiblings )
2278cdf0e10cSrcweir {
2279cdf0e10cSrcweir     Region  aRegion( rSourceRect );
2280cdf0e10cSrcweir     if ( mpWindowImpl->mbWinRegion )
2281cdf0e10cSrcweir         rRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
2282cdf0e10cSrcweir     Region  aTempRegion;
2283cdf0e10cSrcweir     Window* pWindow;
2284cdf0e10cSrcweir 
2285cdf0e10cSrcweir     ImplCalcOverlapRegionOverlaps( aRegion, rRegion );
2286cdf0e10cSrcweir 
2287cdf0e10cSrcweir     // Parent-Boundaries
2288cdf0e10cSrcweir     if ( bParent )
2289cdf0e10cSrcweir     {
2290cdf0e10cSrcweir         pWindow = this;
2291cdf0e10cSrcweir         if ( !ImplIsOverlapWindow() )
2292cdf0e10cSrcweir         {
2293cdf0e10cSrcweir             pWindow = ImplGetParent();
2294cdf0e10cSrcweir             do
2295cdf0e10cSrcweir             {
2296cdf0e10cSrcweir                 aTempRegion = aRegion;
2297cdf0e10cSrcweir                 pWindow->ImplExcludeWindowRegion( aTempRegion );
2298cdf0e10cSrcweir                 rRegion.Union( aTempRegion );
2299cdf0e10cSrcweir                 if ( pWindow->ImplIsOverlapWindow() )
2300cdf0e10cSrcweir                     break;
2301cdf0e10cSrcweir                 pWindow = pWindow->ImplGetParent();
2302cdf0e10cSrcweir             }
2303cdf0e10cSrcweir             while ( pWindow );
2304cdf0e10cSrcweir         }
2305cdf0e10cSrcweir         if ( !pWindow->mpWindowImpl->mbFrame )
2306cdf0e10cSrcweir         {
2307cdf0e10cSrcweir             aTempRegion = aRegion;
2308cdf0e10cSrcweir             aTempRegion.Exclude( Rectangle( Point( 0, 0 ), Size( mpWindowImpl->mpFrameWindow->mnOutWidth, mpWindowImpl->mpFrameWindow->mnOutHeight ) ) );
2309cdf0e10cSrcweir             rRegion.Union( aTempRegion );
2310cdf0e10cSrcweir         }
2311cdf0e10cSrcweir     }
2312cdf0e10cSrcweir 
2313cdf0e10cSrcweir     // Siblings
2314cdf0e10cSrcweir     if ( bSiblings && !ImplIsOverlapWindow() )
2315cdf0e10cSrcweir     {
2316cdf0e10cSrcweir         pWindow = mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild;
2317cdf0e10cSrcweir         do
2318cdf0e10cSrcweir         {
2319cdf0e10cSrcweir             if ( pWindow->mpWindowImpl->mbReallyVisible && (pWindow != this) )
2320cdf0e10cSrcweir             {
2321cdf0e10cSrcweir                 aTempRegion = aRegion;
2322cdf0e10cSrcweir                 pWindow->ImplIntersectWindowRegion( aTempRegion );
2323cdf0e10cSrcweir                 rRegion.Union( aTempRegion );
2324cdf0e10cSrcweir             }
2325cdf0e10cSrcweir             pWindow = pWindow->mpWindowImpl->mpNext;
2326cdf0e10cSrcweir         }
2327cdf0e10cSrcweir         while ( pWindow );
2328cdf0e10cSrcweir     }
2329cdf0e10cSrcweir 
2330cdf0e10cSrcweir     // Childs
2331cdf0e10cSrcweir     if ( bChilds )
2332cdf0e10cSrcweir     {
2333cdf0e10cSrcweir         pWindow = mpWindowImpl->mpFirstChild;
2334cdf0e10cSrcweir         while ( pWindow )
2335cdf0e10cSrcweir         {
2336cdf0e10cSrcweir             if ( pWindow->mpWindowImpl->mbReallyVisible )
2337cdf0e10cSrcweir             {
2338cdf0e10cSrcweir                 aTempRegion = aRegion;
2339cdf0e10cSrcweir                 pWindow->ImplIntersectWindowRegion( aTempRegion );
2340cdf0e10cSrcweir                 rRegion.Union( aTempRegion );
2341cdf0e10cSrcweir             }
2342cdf0e10cSrcweir             pWindow = pWindow->mpWindowImpl->mpNext;
2343cdf0e10cSrcweir         }
2344cdf0e10cSrcweir     }
2345cdf0e10cSrcweir }
2346cdf0e10cSrcweir 
2347cdf0e10cSrcweir // -----------------------------------------------------------------------
2348cdf0e10cSrcweir 
2349cdf0e10cSrcweir void Window::ImplCallPaint( const Region* pRegion, sal_uInt16 nPaintFlags )
2350cdf0e10cSrcweir {
2351cdf0e10cSrcweir     // call PrePaint. PrePaint may add to the invalidate region as well as
2352cdf0e10cSrcweir     // other parameters used below.
2353cdf0e10cSrcweir     PrePaint();
2354cdf0e10cSrcweir 
2355cdf0e10cSrcweir     mpWindowImpl->mbPaintFrame = sal_False;
2356cdf0e10cSrcweir 
2357cdf0e10cSrcweir     if ( nPaintFlags & IMPL_PAINT_PAINTALLCHILDS )
2358cdf0e10cSrcweir         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINT | IMPL_PAINT_PAINTALLCHILDS | (nPaintFlags & IMPL_PAINT_PAINTALL);
2359cdf0e10cSrcweir     if ( nPaintFlags & IMPL_PAINT_PAINTCHILDS )
2360cdf0e10cSrcweir         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINTCHILDS;
2361cdf0e10cSrcweir     if ( nPaintFlags & IMPL_PAINT_ERASE )
2362cdf0e10cSrcweir         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_ERASE;
2363cdf0e10cSrcweir     if ( nPaintFlags & IMPL_PAINT_CHECKRTL )
2364cdf0e10cSrcweir         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_CHECKRTL;
2365cdf0e10cSrcweir     if ( !mpWindowImpl->mpFirstChild )
2366cdf0e10cSrcweir         mpWindowImpl->mnPaintFlags &= ~IMPL_PAINT_PAINTALLCHILDS;
2367cdf0e10cSrcweir 
2368cdf0e10cSrcweir     if ( mpWindowImpl->mbPaintDisabled )
2369cdf0e10cSrcweir     {
2370cdf0e10cSrcweir         if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL )
2371cdf0e10cSrcweir             Invalidate( INVALIDATE_NOCHILDREN | INVALIDATE_NOERASE | INVALIDATE_NOTRANSPARENT | INVALIDATE_NOCLIPCHILDREN );
2372cdf0e10cSrcweir         else if ( pRegion )
2373cdf0e10cSrcweir             Invalidate( *pRegion, INVALIDATE_NOCHILDREN | INVALIDATE_NOERASE | INVALIDATE_NOTRANSPARENT | INVALIDATE_NOCLIPCHILDREN );
2374cdf0e10cSrcweir         return;
2375cdf0e10cSrcweir     }
2376cdf0e10cSrcweir 
2377cdf0e10cSrcweir     nPaintFlags = mpWindowImpl->mnPaintFlags & ~(IMPL_PAINT_PAINT);
2378cdf0e10cSrcweir 
2379cdf0e10cSrcweir     Region* pChildRegion = NULL;
2380cdf0e10cSrcweir     Rectangle aSelectionRect;
2381cdf0e10cSrcweir     if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINT )
2382cdf0e10cSrcweir     {
2383cdf0e10cSrcweir         Region* pWinChildClipRegion = ImplGetWinChildClipRegion();
2384cdf0e10cSrcweir         if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL )
2385cdf0e10cSrcweir             mpWindowImpl->maInvalidateRegion = *pWinChildClipRegion;
2386cdf0e10cSrcweir         else
2387cdf0e10cSrcweir         {
2388cdf0e10cSrcweir             if ( pRegion )
2389cdf0e10cSrcweir                 mpWindowImpl->maInvalidateRegion.Union( *pRegion );
2390cdf0e10cSrcweir 
2391cdf0e10cSrcweir             if( mpWindowImpl->mpWinData && mpWindowImpl->mbTrackVisible )
2392cdf0e10cSrcweir                 /* #98602# need to repaint all children within the
2393cdf0e10cSrcweir                * tracking rectangle, so the following invert
2394cdf0e10cSrcweir                * operation takes places without traces of the previous
2395cdf0e10cSrcweir                * one.
2396cdf0e10cSrcweir                */
2397cdf0e10cSrcweir                 mpWindowImpl->maInvalidateRegion.Union( *mpWindowImpl->mpWinData->mpTrackRect );
2398cdf0e10cSrcweir 
2399cdf0e10cSrcweir             if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALLCHILDS )
2400cdf0e10cSrcweir                 pChildRegion = new Region( mpWindowImpl->maInvalidateRegion );
2401cdf0e10cSrcweir             mpWindowImpl->maInvalidateRegion.Intersect( *pWinChildClipRegion );
2402cdf0e10cSrcweir         }
2403cdf0e10cSrcweir         mpWindowImpl->mnPaintFlags = 0;
2404cdf0e10cSrcweir         if ( !mpWindowImpl->maInvalidateRegion.IsEmpty() )
2405cdf0e10cSrcweir         {
2406cdf0e10cSrcweir             bool bRestoreCursor = false;
2407cdf0e10cSrcweir             if ( mpWindowImpl->mpCursor )
2408cdf0e10cSrcweir                 bRestoreCursor = mpWindowImpl->mpCursor->ImplHide( false );
2409cdf0e10cSrcweir 
2410cdf0e10cSrcweir             mbInitClipRegion = sal_True;
2411cdf0e10cSrcweir             mpWindowImpl->mbInPaint = sal_True;
2412cdf0e10cSrcweir 
2413cdf0e10cSrcweir             // Paint-Region zuruecksetzen
2414cdf0e10cSrcweir             Region      aPaintRegion( mpWindowImpl->maInvalidateRegion );
2415cdf0e10cSrcweir             Rectangle   aPaintRect = aPaintRegion.GetBoundRect();
2416cdf0e10cSrcweir 
2417cdf0e10cSrcweir             // - RTL - re-mirror paint rect and region at this window
2418cdf0e10cSrcweir 		    if( ImplIsAntiparallel() )
2419cdf0e10cSrcweir             {
2420cdf0e10cSrcweir                 ImplReMirror( aPaintRect );
2421cdf0e10cSrcweir                 ImplReMirror( aPaintRegion );
2422cdf0e10cSrcweir             }
2423cdf0e10cSrcweir             aPaintRect = ImplDevicePixelToLogic( aPaintRect);
2424cdf0e10cSrcweir             mpWindowImpl->mpPaintRegion = &aPaintRegion;
2425cdf0e10cSrcweir             mpWindowImpl->maInvalidateRegion.SetEmpty();
2426cdf0e10cSrcweir 
2427cdf0e10cSrcweir             if ( (nPaintFlags & IMPL_PAINT_ERASE) && IsBackground() )
2428cdf0e10cSrcweir             {
2429cdf0e10cSrcweir                 if ( IsClipRegion() )
2430cdf0e10cSrcweir                 {
2431cdf0e10cSrcweir                     Region aOldRegion = GetClipRegion();
2432cdf0e10cSrcweir                     SetClipRegion();
2433cdf0e10cSrcweir                     Erase();
2434cdf0e10cSrcweir                     SetClipRegion( aOldRegion );
2435cdf0e10cSrcweir                 }
2436cdf0e10cSrcweir                 else
2437cdf0e10cSrcweir                     Erase();
2438cdf0e10cSrcweir             }
2439cdf0e10cSrcweir 
2440cdf0e10cSrcweir             // #98943# trigger drawing of toolbox selection after all childern are painted
2441cdf0e10cSrcweir             if( mpWindowImpl->mbDrawSelectionBackground )
2442cdf0e10cSrcweir                 aSelectionRect = aPaintRect;
2443cdf0e10cSrcweir 
2444cdf0e10cSrcweir             Paint( aPaintRect );
2445cdf0e10cSrcweir 
2446cdf0e10cSrcweir             if ( mpWindowImpl->mpWinData )
2447cdf0e10cSrcweir             {
2448cdf0e10cSrcweir                 if ( mpWindowImpl->mbFocusVisible )
2449cdf0e10cSrcweir                     ImplInvertFocus( *(mpWindowImpl->mpWinData->mpFocusRect) );
2450cdf0e10cSrcweir             }
2451cdf0e10cSrcweir             mpWindowImpl->mbInPaint = sal_False;
2452cdf0e10cSrcweir             mbInitClipRegion = sal_True;
2453cdf0e10cSrcweir             mpWindowImpl->mpPaintRegion = NULL;
2454cdf0e10cSrcweir             if ( mpWindowImpl->mpCursor )
2455cdf0e10cSrcweir                 mpWindowImpl->mpCursor->ImplShow( false, bRestoreCursor );
2456cdf0e10cSrcweir         }
2457cdf0e10cSrcweir     }
2458cdf0e10cSrcweir     else
2459cdf0e10cSrcweir         mpWindowImpl->mnPaintFlags = 0;
2460cdf0e10cSrcweir 
2461cdf0e10cSrcweir     if ( nPaintFlags & (IMPL_PAINT_PAINTALLCHILDS | IMPL_PAINT_PAINTCHILDS) )
2462cdf0e10cSrcweir     {
2463cdf0e10cSrcweir         // die Childfenster ausgeben
2464cdf0e10cSrcweir         Window* pTempWindow = mpWindowImpl->mpFirstChild;
2465cdf0e10cSrcweir         while ( pTempWindow )
2466cdf0e10cSrcweir         {
2467cdf0e10cSrcweir             if ( pTempWindow->mpWindowImpl->mbVisible )
2468cdf0e10cSrcweir                 pTempWindow->ImplCallPaint( pChildRegion, nPaintFlags );
2469cdf0e10cSrcweir             pTempWindow = pTempWindow->mpWindowImpl->mpNext;
2470cdf0e10cSrcweir         }
2471cdf0e10cSrcweir     }
2472cdf0e10cSrcweir 
2473cdf0e10cSrcweir     if ( mpWindowImpl->mpWinData && mpWindowImpl->mbTrackVisible && (mpWindowImpl->mpWinData->mnTrackFlags & SHOWTRACK_WINDOW) )
2474cdf0e10cSrcweir         /* #98602# need to invert the tracking rect AFTER
2475cdf0e10cSrcweir         * the children have painted
2476cdf0e10cSrcweir         */
2477cdf0e10cSrcweir         InvertTracking( *(mpWindowImpl->mpWinData->mpTrackRect), mpWindowImpl->mpWinData->mnTrackFlags );
2478cdf0e10cSrcweir 
2479cdf0e10cSrcweir     // #98943# draw toolbox selection
2480cdf0e10cSrcweir     if( !aSelectionRect.IsEmpty() )
2481cdf0e10cSrcweir         DrawSelectionBackground( aSelectionRect, 3, sal_False, sal_True, sal_False );
2482cdf0e10cSrcweir 
2483cdf0e10cSrcweir     if ( pChildRegion )
2484cdf0e10cSrcweir         delete pChildRegion;
2485cdf0e10cSrcweir }
2486cdf0e10cSrcweir 
2487cdf0e10cSrcweir // -----------------------------------------------------------------------
2488cdf0e10cSrcweir 
2489cdf0e10cSrcweir void Window::ImplCallOverlapPaint()
2490cdf0e10cSrcweir {
2491cdf0e10cSrcweir     // Zuerst geben wir die ueberlappenden Fenster aus
2492cdf0e10cSrcweir     Window* pTempWindow = mpWindowImpl->mpFirstOverlap;
2493cdf0e10cSrcweir     while ( pTempWindow )
2494cdf0e10cSrcweir     {
2495cdf0e10cSrcweir         if ( pTempWindow->mpWindowImpl->mbReallyVisible )
2496cdf0e10cSrcweir             pTempWindow->ImplCallOverlapPaint();
2497cdf0e10cSrcweir         pTempWindow = pTempWindow->mpWindowImpl->mpNext;
2498cdf0e10cSrcweir     }
2499cdf0e10cSrcweir 
2500cdf0e10cSrcweir     // und dann erst uns selber
2501cdf0e10cSrcweir     if ( mpWindowImpl->mnPaintFlags & (IMPL_PAINT_PAINT | IMPL_PAINT_PAINTCHILDS) )
2502cdf0e10cSrcweir     {
2503cdf0e10cSrcweir         // - RTL - notify ImplCallPaint to check for re-mirroring (CHECKRTL)
2504cdf0e10cSrcweir         //         because we were called from the Sal layer
2505cdf0e10cSrcweir         ImplCallPaint( NULL, mpWindowImpl->mnPaintFlags /*| IMPL_PAINT_CHECKRTL */);
2506cdf0e10cSrcweir     }
2507cdf0e10cSrcweir }
2508cdf0e10cSrcweir 
2509cdf0e10cSrcweir // -----------------------------------------------------------------------
2510cdf0e10cSrcweir 
2511cdf0e10cSrcweir void Window::ImplPostPaint()
2512cdf0e10cSrcweir {
2513cdf0e10cSrcweir 	if ( !mpWindowImpl->mpFrameData->maPaintTimer.IsActive() )
2514cdf0e10cSrcweir 		mpWindowImpl->mpFrameData->maPaintTimer.Start();
2515cdf0e10cSrcweir }
2516cdf0e10cSrcweir 
2517cdf0e10cSrcweir // -----------------------------------------------------------------------
2518cdf0e10cSrcweir 
2519cdf0e10cSrcweir IMPL_LINK( Window, ImplHandlePaintHdl, void*, EMPTYARG )
2520cdf0e10cSrcweir {
2521cdf0e10cSrcweir     // save paint events until resizing is done
2522cdf0e10cSrcweir     if( mpWindowImpl->mbFrame && mpWindowImpl->mpFrameData->maResizeTimer.IsActive() )
2523cdf0e10cSrcweir         mpWindowImpl->mpFrameData->maPaintTimer.Start();
2524cdf0e10cSrcweir     else if ( mpWindowImpl->mbReallyVisible )
2525cdf0e10cSrcweir         ImplCallOverlapPaint();
2526cdf0e10cSrcweir     return 0;
2527cdf0e10cSrcweir }
2528cdf0e10cSrcweir 
2529cdf0e10cSrcweir // -----------------------------------------------------------------------
2530cdf0e10cSrcweir 
2531cdf0e10cSrcweir IMPL_LINK( Window, ImplHandleResizeTimerHdl, void*, EMPTYARG )
2532cdf0e10cSrcweir {
2533cdf0e10cSrcweir     if( mpWindowImpl->mbReallyVisible )
2534cdf0e10cSrcweir     {
2535cdf0e10cSrcweir         ImplCallResize();
2536cdf0e10cSrcweir         if( mpWindowImpl->mpFrameData->maPaintTimer.IsActive() )
2537cdf0e10cSrcweir         {
2538cdf0e10cSrcweir             mpWindowImpl->mpFrameData->maPaintTimer.Stop();
2539cdf0e10cSrcweir             mpWindowImpl->mpFrameData->maPaintTimer.GetTimeoutHdl().Call( NULL );
2540cdf0e10cSrcweir         }
2541cdf0e10cSrcweir     }
2542cdf0e10cSrcweir 
2543cdf0e10cSrcweir     return 0;
2544cdf0e10cSrcweir }
2545cdf0e10cSrcweir 
2546cdf0e10cSrcweir // -----------------------------------------------------------------------
2547cdf0e10cSrcweir 
2548cdf0e10cSrcweir void Window::ImplInvalidateFrameRegion( const Region* pRegion, sal_uInt16 nFlags )
2549cdf0e10cSrcweir {
2550cdf0e10cSrcweir     // PAINTCHILDS bei allen Parent-Fenster bis zum ersten OverlapWindow
2551cdf0e10cSrcweir     // setzen
2552cdf0e10cSrcweir     if ( !ImplIsOverlapWindow() )
2553cdf0e10cSrcweir     {
2554cdf0e10cSrcweir         Window* pTempWindow = this;
2555cdf0e10cSrcweir         sal_uInt16 nTranspPaint = IsPaintTransparent() ? IMPL_PAINT_PAINT : 0;
2556cdf0e10cSrcweir         do
2557cdf0e10cSrcweir         {
2558cdf0e10cSrcweir             pTempWindow = pTempWindow->ImplGetParent();
2559cdf0e10cSrcweir             if ( pTempWindow->mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTCHILDS )
2560cdf0e10cSrcweir                 break;
2561cdf0e10cSrcweir             pTempWindow->mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINTCHILDS | nTranspPaint;
2562cdf0e10cSrcweir             if( ! pTempWindow->IsPaintTransparent() )
2563cdf0e10cSrcweir                 nTranspPaint = 0;
2564cdf0e10cSrcweir         }
2565cdf0e10cSrcweir         while ( !pTempWindow->ImplIsOverlapWindow() );
2566cdf0e10cSrcweir     }
2567cdf0e10cSrcweir 
2568cdf0e10cSrcweir     // Paint-Flags setzen
2569cdf0e10cSrcweir     mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINT;
2570cdf0e10cSrcweir     if ( nFlags & INVALIDATE_CHILDREN )
2571cdf0e10cSrcweir         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINTALLCHILDS;
2572cdf0e10cSrcweir     if ( !(nFlags & INVALIDATE_NOERASE) )
2573cdf0e10cSrcweir         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_ERASE;
2574cdf0e10cSrcweir     if ( !pRegion )
2575cdf0e10cSrcweir         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINTALL;
2576cdf0e10cSrcweir 
2577cdf0e10cSrcweir     // Wenn nicht alles neu ausgegeben werden muss, dann die Region
2578cdf0e10cSrcweir     // dazupacken
2579cdf0e10cSrcweir     if ( !(mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL) )
2580cdf0e10cSrcweir         mpWindowImpl->maInvalidateRegion.Union( *pRegion );
2581cdf0e10cSrcweir 
2582cdf0e10cSrcweir     // Handle transparent windows correctly: invalidate must be done on the first opaque parent
2583cdf0e10cSrcweir     if( ((IsPaintTransparent() && !(nFlags & INVALIDATE_NOTRANSPARENT)) || (nFlags & INVALIDATE_TRANSPARENT) )
2584cdf0e10cSrcweir             && ImplGetParent() )
2585cdf0e10cSrcweir     {
2586cdf0e10cSrcweir         Window *pParent = ImplGetParent();
2587cdf0e10cSrcweir         while( pParent && pParent->IsPaintTransparent() )
2588cdf0e10cSrcweir             pParent = pParent->ImplGetParent();
2589cdf0e10cSrcweir         if( pParent )
2590cdf0e10cSrcweir         {
2591cdf0e10cSrcweir             Region *pChildRegion;
2592cdf0e10cSrcweir             if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL )
2593cdf0e10cSrcweir                 // invalidate the whole child window region in the parent
2594cdf0e10cSrcweir                 pChildRegion = ImplGetWinChildClipRegion();
2595cdf0e10cSrcweir             else
2596cdf0e10cSrcweir                 // invalidate the same region in the parent that has to be repainted in the child
2597cdf0e10cSrcweir                 pChildRegion = &mpWindowImpl->maInvalidateRegion;
2598cdf0e10cSrcweir 
2599cdf0e10cSrcweir             nFlags |= INVALIDATE_CHILDREN;  // paint should also be done on all children
2600cdf0e10cSrcweir             nFlags &= ~INVALIDATE_NOERASE;  // parent should paint and erase to create proper background
2601cdf0e10cSrcweir             pParent->ImplInvalidateFrameRegion( pChildRegion, nFlags );
2602cdf0e10cSrcweir         }
2603cdf0e10cSrcweir     }
2604cdf0e10cSrcweir     ImplPostPaint();
2605cdf0e10cSrcweir }
2606cdf0e10cSrcweir 
2607cdf0e10cSrcweir // -----------------------------------------------------------------------
2608cdf0e10cSrcweir 
2609cdf0e10cSrcweir void Window::ImplInvalidateOverlapFrameRegion( const Region& rRegion )
2610cdf0e10cSrcweir {
2611cdf0e10cSrcweir     Region aRegion = rRegion;
2612cdf0e10cSrcweir 
2613cdf0e10cSrcweir     ImplClipBoundaries( aRegion, sal_True, sal_True );
2614cdf0e10cSrcweir     if ( !aRegion.IsEmpty() )
2615cdf0e10cSrcweir         ImplInvalidateFrameRegion( &aRegion, INVALIDATE_CHILDREN );
2616cdf0e10cSrcweir 
2617cdf0e10cSrcweir     // Dann invalidieren wir die ueberlappenden Fenster
2618cdf0e10cSrcweir     Window* pTempWindow = mpWindowImpl->mpFirstOverlap;
2619cdf0e10cSrcweir     while ( pTempWindow )
2620cdf0e10cSrcweir     {
2621cdf0e10cSrcweir         if ( pTempWindow->IsVisible() )
2622cdf0e10cSrcweir             pTempWindow->ImplInvalidateOverlapFrameRegion( rRegion );
2623cdf0e10cSrcweir 
2624cdf0e10cSrcweir         pTempWindow = pTempWindow->mpWindowImpl->mpNext;
2625cdf0e10cSrcweir     }
2626cdf0e10cSrcweir }
2627cdf0e10cSrcweir 
2628cdf0e10cSrcweir // -----------------------------------------------------------------------
2629cdf0e10cSrcweir 
2630cdf0e10cSrcweir void Window::ImplInvalidateParentFrameRegion( Region& rRegion )
2631cdf0e10cSrcweir {
2632cdf0e10cSrcweir     if ( mpWindowImpl->mbOverlapWin )
2633cdf0e10cSrcweir         mpWindowImpl->mpFrameWindow->ImplInvalidateOverlapFrameRegion( rRegion );
2634cdf0e10cSrcweir     else
2635cdf0e10cSrcweir     {
2636cdf0e10cSrcweir         if( ImplGetParent() )
2637cdf0e10cSrcweir             ImplGetParent()->ImplInvalidateFrameRegion( &rRegion, INVALIDATE_CHILDREN );
2638cdf0e10cSrcweir     }
2639cdf0e10cSrcweir }
2640cdf0e10cSrcweir 
2641cdf0e10cSrcweir // -----------------------------------------------------------------------
2642cdf0e10cSrcweir 
2643cdf0e10cSrcweir void Window::ImplInvalidate( const Region* pRegion, sal_uInt16 nFlags )
2644cdf0e10cSrcweir {
2645cdf0e10cSrcweir 
2646cdf0e10cSrcweir     // Hintergrund-Sicherung zuruecksetzen
2647cdf0e10cSrcweir     if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
2648cdf0e10cSrcweir         ImplInvalidateAllOverlapBackgrounds();
2649cdf0e10cSrcweir 
2650cdf0e10cSrcweir     // Feststellen, was neu ausgegeben werden muss
2651cdf0e10cSrcweir     sal_Bool bInvalidateAll = !pRegion;
2652cdf0e10cSrcweir 
2653cdf0e10cSrcweir     // Transparent-Invalidate beruecksichtigen
2654cdf0e10cSrcweir     Window* pOpaqueWindow = this;
2655cdf0e10cSrcweir     if ( (mpWindowImpl->mbPaintTransparent && !(nFlags & INVALIDATE_NOTRANSPARENT)) || (nFlags & INVALIDATE_TRANSPARENT) )
2656cdf0e10cSrcweir     {
2657cdf0e10cSrcweir         Window* pTempWindow = pOpaqueWindow->ImplGetParent();
2658cdf0e10cSrcweir         while ( pTempWindow )
2659cdf0e10cSrcweir         {
2660cdf0e10cSrcweir             if ( !pTempWindow->IsPaintTransparent() )
2661cdf0e10cSrcweir             {
2662cdf0e10cSrcweir                 pOpaqueWindow = pTempWindow;
2663cdf0e10cSrcweir                 nFlags |= INVALIDATE_CHILDREN;
2664cdf0e10cSrcweir                 bInvalidateAll = sal_False;
2665cdf0e10cSrcweir                 break;
2666cdf0e10cSrcweir             }
2667cdf0e10cSrcweir 
2668cdf0e10cSrcweir             if ( pTempWindow->ImplIsOverlapWindow() )
2669cdf0e10cSrcweir                 break;
2670cdf0e10cSrcweir 
2671cdf0e10cSrcweir             pTempWindow = pTempWindow->ImplGetParent();
2672cdf0e10cSrcweir         }
2673cdf0e10cSrcweir     }
2674cdf0e10cSrcweir 
2675cdf0e10cSrcweir     // Region zusammenbauen
2676cdf0e10cSrcweir     sal_uInt16 nOrgFlags = nFlags;
2677cdf0e10cSrcweir     if ( !(nFlags & (INVALIDATE_CHILDREN | INVALIDATE_NOCHILDREN)) )
2678cdf0e10cSrcweir     {
2679cdf0e10cSrcweir         if ( GetStyle() & WB_CLIPCHILDREN )
2680cdf0e10cSrcweir             nFlags |= INVALIDATE_NOCHILDREN;
2681cdf0e10cSrcweir         else
2682cdf0e10cSrcweir             nFlags |= INVALIDATE_CHILDREN;
2683cdf0e10cSrcweir     }
2684cdf0e10cSrcweir     if ( (nFlags & INVALIDATE_NOCHILDREN) && mpWindowImpl->mpFirstChild )
2685cdf0e10cSrcweir         bInvalidateAll = sal_False;
2686cdf0e10cSrcweir     if ( bInvalidateAll )
2687cdf0e10cSrcweir         ImplInvalidateFrameRegion( NULL, nFlags );
2688cdf0e10cSrcweir     else
2689cdf0e10cSrcweir     {
2690cdf0e10cSrcweir         Rectangle   aRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
2691cdf0e10cSrcweir         Region      aRegion( aRect );
2692cdf0e10cSrcweir         if ( pRegion )
2693cdf0e10cSrcweir         {
2694cdf0e10cSrcweir             // --- RTL --- remirror region before intersecting it
2695cdf0e10cSrcweir             if ( ImplIsAntiparallel() )
2696cdf0e10cSrcweir             {
2697cdf0e10cSrcweir                 Region aRgn( *pRegion );
2698cdf0e10cSrcweir                 ImplReMirror( aRgn );
2699cdf0e10cSrcweir                 aRegion.Intersect( aRgn );
2700cdf0e10cSrcweir             }
2701cdf0e10cSrcweir             else
2702cdf0e10cSrcweir                 aRegion.Intersect( *pRegion );
2703cdf0e10cSrcweir         }
2704cdf0e10cSrcweir         ImplClipBoundaries( aRegion, sal_True, sal_True );
2705cdf0e10cSrcweir         if ( nFlags & INVALIDATE_NOCHILDREN )
2706cdf0e10cSrcweir         {
2707cdf0e10cSrcweir             nFlags &= ~INVALIDATE_CHILDREN;
2708cdf0e10cSrcweir             if ( !(nFlags & INVALIDATE_NOCLIPCHILDREN) )
2709cdf0e10cSrcweir             {
2710cdf0e10cSrcweir                 if ( nOrgFlags & INVALIDATE_NOCHILDREN )
2711cdf0e10cSrcweir                     ImplClipAllChilds( aRegion );
2712cdf0e10cSrcweir                 else
2713cdf0e10cSrcweir                 {
2714cdf0e10cSrcweir                     if ( ImplClipChilds( aRegion ) )
2715cdf0e10cSrcweir                         nFlags |= INVALIDATE_CHILDREN;
2716cdf0e10cSrcweir                 }
2717cdf0e10cSrcweir             }
2718cdf0e10cSrcweir         }
2719cdf0e10cSrcweir         if ( !aRegion.IsEmpty() )
2720cdf0e10cSrcweir             ImplInvalidateFrameRegion( &aRegion, nFlags );  // transparency is handled here, pOpaqueWindow not required
2721cdf0e10cSrcweir     }
2722cdf0e10cSrcweir 
2723cdf0e10cSrcweir     if ( nFlags & INVALIDATE_UPDATE )
2724cdf0e10cSrcweir         pOpaqueWindow->Update();        // start painting at the opaque parent
2725cdf0e10cSrcweir }
2726cdf0e10cSrcweir 
2727cdf0e10cSrcweir // -----------------------------------------------------------------------
2728cdf0e10cSrcweir 
2729cdf0e10cSrcweir void Window::ImplMoveInvalidateRegion( const Rectangle& rRect,
2730cdf0e10cSrcweir                                        long nHorzScroll, long nVertScroll,
2731cdf0e10cSrcweir                                        sal_Bool bChilds )
2732cdf0e10cSrcweir {
2733cdf0e10cSrcweir     if ( (mpWindowImpl->mnPaintFlags & (IMPL_PAINT_PAINT | IMPL_PAINT_PAINTALL)) == IMPL_PAINT_PAINT )
2734cdf0e10cSrcweir     {
2735cdf0e10cSrcweir         Region aTempRegion = mpWindowImpl->maInvalidateRegion;
2736cdf0e10cSrcweir         aTempRegion.Intersect( rRect );
2737cdf0e10cSrcweir         aTempRegion.Move( nHorzScroll, nVertScroll );
2738cdf0e10cSrcweir         mpWindowImpl->maInvalidateRegion.Union( aTempRegion );
2739cdf0e10cSrcweir     }
2740cdf0e10cSrcweir 
2741cdf0e10cSrcweir     if ( bChilds && (mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTCHILDS) )
2742cdf0e10cSrcweir     {
2743cdf0e10cSrcweir         Window* pWindow = mpWindowImpl->mpFirstChild;
2744cdf0e10cSrcweir         while ( pWindow )
2745cdf0e10cSrcweir         {
2746cdf0e10cSrcweir             pWindow->ImplMoveInvalidateRegion( rRect, nHorzScroll, nVertScroll, sal_True );
2747cdf0e10cSrcweir             pWindow = pWindow->mpWindowImpl->mpNext;
2748cdf0e10cSrcweir         }
2749cdf0e10cSrcweir     }
2750cdf0e10cSrcweir }
2751cdf0e10cSrcweir 
2752cdf0e10cSrcweir // -----------------------------------------------------------------------
2753cdf0e10cSrcweir 
2754cdf0e10cSrcweir void Window::ImplMoveAllInvalidateRegions( const Rectangle& rRect,
2755cdf0e10cSrcweir                                            long nHorzScroll, long nVertScroll,
2756cdf0e10cSrcweir                                            sal_Bool bChilds )
2757cdf0e10cSrcweir {
2758cdf0e10cSrcweir     // Paint-Region auch verschieben, wenn noch Paints anstehen
2759cdf0e10cSrcweir     ImplMoveInvalidateRegion( rRect, nHorzScroll, nVertScroll, bChilds );
2760cdf0e10cSrcweir     // Paint-Region muss bei uns verschoben gesetzt werden, die durch
2761cdf0e10cSrcweir     // die Parents gezeichnet werden
2762cdf0e10cSrcweir     if ( !ImplIsOverlapWindow() )
2763cdf0e10cSrcweir     {
2764cdf0e10cSrcweir         Region  aPaintAllRegion;
2765cdf0e10cSrcweir         Window* pPaintAllWindow = this;
2766cdf0e10cSrcweir         do
2767cdf0e10cSrcweir         {
2768cdf0e10cSrcweir             pPaintAllWindow = pPaintAllWindow->ImplGetParent();
2769cdf0e10cSrcweir             if ( pPaintAllWindow->mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALLCHILDS )
2770cdf0e10cSrcweir             {
2771cdf0e10cSrcweir                 if ( pPaintAllWindow->mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL )
2772cdf0e10cSrcweir                 {
2773cdf0e10cSrcweir                     aPaintAllRegion.SetEmpty();
2774cdf0e10cSrcweir                     break;
2775cdf0e10cSrcweir                 }
2776cdf0e10cSrcweir                 else
2777cdf0e10cSrcweir                     aPaintAllRegion.Union( pPaintAllWindow->mpWindowImpl->maInvalidateRegion );
2778cdf0e10cSrcweir             }
2779cdf0e10cSrcweir         }
2780cdf0e10cSrcweir         while ( !pPaintAllWindow->ImplIsOverlapWindow() );
2781cdf0e10cSrcweir         if ( !aPaintAllRegion.IsEmpty() )
2782cdf0e10cSrcweir         {
2783cdf0e10cSrcweir             aPaintAllRegion.Move( nHorzScroll, nVertScroll );
2784cdf0e10cSrcweir             sal_uInt16 nPaintFlags = 0;
2785cdf0e10cSrcweir             if ( bChilds )
2786cdf0e10cSrcweir                 mpWindowImpl->mnPaintFlags |= INVALIDATE_CHILDREN;
2787cdf0e10cSrcweir             ImplInvalidateFrameRegion( &aPaintAllRegion, nPaintFlags );
2788cdf0e10cSrcweir         }
2789cdf0e10cSrcweir     }
2790cdf0e10cSrcweir }
2791cdf0e10cSrcweir 
2792cdf0e10cSrcweir // -----------------------------------------------------------------------
2793cdf0e10cSrcweir 
2794cdf0e10cSrcweir void Window::ImplValidateFrameRegion( const Region* pRegion, sal_uInt16 nFlags )
2795cdf0e10cSrcweir {
2796cdf0e10cSrcweir     if ( !pRegion )
2797cdf0e10cSrcweir         mpWindowImpl->maInvalidateRegion.SetEmpty();
2798cdf0e10cSrcweir     else
2799cdf0e10cSrcweir     {
2800cdf0e10cSrcweir         // Wenn alle Childfenster neu ausgegeben werden muessen,
2801cdf0e10cSrcweir         // dann invalidieren wir diese vorher
2802cdf0e10cSrcweir         if ( (mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALLCHILDS) && mpWindowImpl->mpFirstChild )
2803cdf0e10cSrcweir         {
2804cdf0e10cSrcweir             Region aChildRegion = mpWindowImpl->maInvalidateRegion;
2805cdf0e10cSrcweir             if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL )
2806cdf0e10cSrcweir             {
2807cdf0e10cSrcweir                 Rectangle aRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
2808cdf0e10cSrcweir                 aChildRegion = aRect;
2809cdf0e10cSrcweir             }
2810cdf0e10cSrcweir             Window* pChild = mpWindowImpl->mpFirstChild;
2811cdf0e10cSrcweir             while ( pChild )
2812cdf0e10cSrcweir             {
2813cdf0e10cSrcweir                 pChild->Invalidate( aChildRegion, INVALIDATE_CHILDREN | INVALIDATE_NOTRANSPARENT );
2814cdf0e10cSrcweir                 pChild = pChild->mpWindowImpl->mpNext;
2815cdf0e10cSrcweir             }
2816cdf0e10cSrcweir         }
2817cdf0e10cSrcweir         if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL )
2818cdf0e10cSrcweir         {
2819cdf0e10cSrcweir             Rectangle aRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
2820cdf0e10cSrcweir             mpWindowImpl->maInvalidateRegion = aRect;
2821cdf0e10cSrcweir         }
2822cdf0e10cSrcweir         mpWindowImpl->maInvalidateRegion.Exclude( *pRegion );
2823cdf0e10cSrcweir     }
2824cdf0e10cSrcweir     mpWindowImpl->mnPaintFlags &= ~IMPL_PAINT_PAINTALL;
2825cdf0e10cSrcweir 
2826cdf0e10cSrcweir     if ( nFlags & VALIDATE_CHILDREN )
2827cdf0e10cSrcweir     {
2828cdf0e10cSrcweir         Window* pChild = mpWindowImpl->mpFirstChild;
2829cdf0e10cSrcweir         while ( pChild )
2830cdf0e10cSrcweir         {
2831cdf0e10cSrcweir             pChild->ImplValidateFrameRegion( pRegion, nFlags );
2832cdf0e10cSrcweir             pChild = pChild->mpWindowImpl->mpNext;
2833cdf0e10cSrcweir         }
2834cdf0e10cSrcweir     }
2835cdf0e10cSrcweir }
2836cdf0e10cSrcweir 
2837cdf0e10cSrcweir // -----------------------------------------------------------------------
2838cdf0e10cSrcweir 
2839cdf0e10cSrcweir void Window::ImplValidate( const Region* pRegion, sal_uInt16 nFlags )
2840cdf0e10cSrcweir {
2841cdf0e10cSrcweir     // Region zusammenbauen
2842cdf0e10cSrcweir     sal_Bool    bValidateAll = !pRegion;
2843cdf0e10cSrcweir     sal_uInt16  nOrgFlags = nFlags;
2844cdf0e10cSrcweir     if ( !(nFlags & (VALIDATE_CHILDREN | VALIDATE_NOCHILDREN)) )
2845cdf0e10cSrcweir     {
2846cdf0e10cSrcweir         if ( GetStyle() & WB_CLIPCHILDREN )
2847cdf0e10cSrcweir             nFlags |= VALIDATE_NOCHILDREN;
2848cdf0e10cSrcweir         else
2849cdf0e10cSrcweir             nFlags |= VALIDATE_CHILDREN;
2850cdf0e10cSrcweir     }
2851cdf0e10cSrcweir     if ( (nFlags & VALIDATE_NOCHILDREN) && mpWindowImpl->mpFirstChild )
2852cdf0e10cSrcweir         bValidateAll = sal_False;
2853cdf0e10cSrcweir     if ( bValidateAll )
2854cdf0e10cSrcweir         ImplValidateFrameRegion( NULL, nFlags );
2855cdf0e10cSrcweir     else
2856cdf0e10cSrcweir     {
2857cdf0e10cSrcweir         Rectangle   aRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
2858cdf0e10cSrcweir         Region      aRegion( aRect );
2859cdf0e10cSrcweir         if ( pRegion )
2860cdf0e10cSrcweir             aRegion.Intersect( *pRegion );
2861cdf0e10cSrcweir         ImplClipBoundaries( aRegion, sal_True, sal_True );
2862cdf0e10cSrcweir         if ( nFlags & VALIDATE_NOCHILDREN )
2863cdf0e10cSrcweir         {
2864cdf0e10cSrcweir             nFlags &= ~VALIDATE_CHILDREN;
2865cdf0e10cSrcweir             if ( nOrgFlags & VALIDATE_NOCHILDREN )
2866cdf0e10cSrcweir                 ImplClipAllChilds( aRegion );
2867cdf0e10cSrcweir             else
2868cdf0e10cSrcweir             {
2869cdf0e10cSrcweir                 if ( ImplClipChilds( aRegion ) )
2870cdf0e10cSrcweir                     nFlags |= VALIDATE_CHILDREN;
2871cdf0e10cSrcweir             }
2872cdf0e10cSrcweir         }
2873cdf0e10cSrcweir         if ( !aRegion.IsEmpty() )
2874cdf0e10cSrcweir             ImplValidateFrameRegion( &aRegion, nFlags );
2875cdf0e10cSrcweir     }
2876cdf0e10cSrcweir }
2877cdf0e10cSrcweir 
2878cdf0e10cSrcweir // -----------------------------------------------------------------------
2879cdf0e10cSrcweir 
2880cdf0e10cSrcweir void Window::ImplScroll( const Rectangle& rRect,
2881cdf0e10cSrcweir                          long nHorzScroll, long nVertScroll, sal_uInt16 nFlags )
2882cdf0e10cSrcweir {
2883cdf0e10cSrcweir     if ( !IsDeviceOutputNecessary() )
2884cdf0e10cSrcweir         return;
2885cdf0e10cSrcweir 
2886cdf0e10cSrcweir     nHorzScroll = ImplLogicWidthToDevicePixel( nHorzScroll );
2887cdf0e10cSrcweir     nVertScroll = ImplLogicHeightToDevicePixel( nVertScroll );
2888cdf0e10cSrcweir 
2889cdf0e10cSrcweir     if ( !nHorzScroll && !nVertScroll )
2890cdf0e10cSrcweir         return;
2891cdf0e10cSrcweir 
2892cdf0e10cSrcweir     // Hintergrund-Sicherung zuruecksetzen
2893cdf0e10cSrcweir     if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
2894cdf0e10cSrcweir         ImplInvalidateAllOverlapBackgrounds();
2895cdf0e10cSrcweir 
2896cdf0e10cSrcweir     if ( mpWindowImpl->mpCursor )
2897cdf0e10cSrcweir         mpWindowImpl->mpCursor->ImplHide( false );
2898cdf0e10cSrcweir 
2899cdf0e10cSrcweir     sal_uInt16 nOrgFlags = nFlags;
2900cdf0e10cSrcweir     if ( !(nFlags & (SCROLL_CHILDREN | SCROLL_NOCHILDREN)) )
2901cdf0e10cSrcweir     {
2902cdf0e10cSrcweir         if ( GetStyle() & WB_CLIPCHILDREN )
2903cdf0e10cSrcweir             nFlags |= SCROLL_NOCHILDREN;
2904cdf0e10cSrcweir         else
2905cdf0e10cSrcweir             nFlags |= SCROLL_CHILDREN;
2906cdf0e10cSrcweir     }
2907cdf0e10cSrcweir 
2908cdf0e10cSrcweir     Region  aInvalidateRegion;
2909cdf0e10cSrcweir     sal_Bool    bScrollChilds = (nFlags & SCROLL_CHILDREN) != 0;
2910cdf0e10cSrcweir     sal_Bool    bErase = (nFlags & SCROLL_NOERASE) == 0;
2911cdf0e10cSrcweir 
2912cdf0e10cSrcweir     if ( !mpWindowImpl->mpFirstChild )
2913cdf0e10cSrcweir         bScrollChilds = sal_False;
2914cdf0e10cSrcweir 
2915cdf0e10cSrcweir     // --- RTL --- check if this window requires special action
2916cdf0e10cSrcweir     sal_Bool bReMirror = ( ImplIsAntiparallel() );
2917cdf0e10cSrcweir 
2918cdf0e10cSrcweir     Rectangle aRectMirror( rRect );
2919cdf0e10cSrcweir     if( bReMirror )
2920cdf0e10cSrcweir     {
2921cdf0e10cSrcweir         // --- RTL --- make sure the invalidate region of this window is
2922cdf0e10cSrcweir         // computed in the same coordinate space as the one from the overlap windows
2923cdf0e10cSrcweir         ImplReMirror( aRectMirror );
2924cdf0e10cSrcweir     }
2925cdf0e10cSrcweir 
2926cdf0e10cSrcweir     // Paint-Bereiche anpassen
2927cdf0e10cSrcweir     ImplMoveAllInvalidateRegions( aRectMirror, nHorzScroll, nVertScroll, bScrollChilds );
2928cdf0e10cSrcweir 
2929cdf0e10cSrcweir     if ( !(nFlags & SCROLL_NOINVALIDATE) )
2930cdf0e10cSrcweir     {
2931cdf0e10cSrcweir         ImplCalcOverlapRegion( aRectMirror, aInvalidateRegion, !bScrollChilds, sal_True, sal_False );
2932cdf0e10cSrcweir 
2933cdf0e10cSrcweir         // --- RTL ---
2934cdf0e10cSrcweir         // if the scrolling on the device is performed in the opposite direction
2935cdf0e10cSrcweir         // then move the overlaps in that direction to compute the invalidate region
2936cdf0e10cSrcweir         // on the correct side, i.e., revert nHorzScroll
2937cdf0e10cSrcweir 
2938cdf0e10cSrcweir         if ( !aInvalidateRegion.IsEmpty() )
2939cdf0e10cSrcweir         {
2940cdf0e10cSrcweir             aInvalidateRegion.Move( bReMirror ? -nHorzScroll : nHorzScroll, nVertScroll );
2941cdf0e10cSrcweir             bErase = sal_True;
2942cdf0e10cSrcweir         }
2943cdf0e10cSrcweir         if ( !(nFlags & SCROLL_NOWINDOWINVALIDATE) )
2944cdf0e10cSrcweir         {
2945cdf0e10cSrcweir             Rectangle aDestRect( aRectMirror );
2946cdf0e10cSrcweir             aDestRect.Move( bReMirror ? -nHorzScroll : nHorzScroll, nVertScroll );
2947cdf0e10cSrcweir             Region aWinInvalidateRegion( aRectMirror );
2948cdf0e10cSrcweir             aWinInvalidateRegion.Exclude( aDestRect );
2949cdf0e10cSrcweir 
2950cdf0e10cSrcweir             aInvalidateRegion.Union( aWinInvalidateRegion );
2951cdf0e10cSrcweir         }
2952cdf0e10cSrcweir     }
2953cdf0e10cSrcweir 
2954cdf0e10cSrcweir     Point aPoint( mnOutOffX, mnOutOffY );
2955cdf0e10cSrcweir     Region aRegion( Rectangle( aPoint, Size( mnOutWidth, mnOutHeight ) ) );
2956cdf0e10cSrcweir     if ( nFlags & SCROLL_CLIP )
2957cdf0e10cSrcweir         aRegion.Intersect( rRect );
2958cdf0e10cSrcweir     if ( mpWindowImpl->mbWinRegion )
2959cdf0e10cSrcweir         aRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
2960cdf0e10cSrcweir 
2961cdf0e10cSrcweir     aRegion.Exclude( aInvalidateRegion );
2962cdf0e10cSrcweir 
2963cdf0e10cSrcweir     ImplClipBoundaries( aRegion, sal_False, sal_True );
2964cdf0e10cSrcweir     if ( !bScrollChilds )
2965cdf0e10cSrcweir     {
2966cdf0e10cSrcweir         if ( nOrgFlags & SCROLL_NOCHILDREN )
2967cdf0e10cSrcweir             ImplClipAllChilds( aRegion );
2968cdf0e10cSrcweir         else
2969cdf0e10cSrcweir             ImplClipChilds( aRegion );
2970cdf0e10cSrcweir     }
2971cdf0e10cSrcweir     if ( mbClipRegion && (nFlags & SCROLL_USECLIPREGION) )
2972cdf0e10cSrcweir         aRegion.Intersect( maRegion );
2973cdf0e10cSrcweir     if ( !aRegion.IsEmpty() )
2974cdf0e10cSrcweir     {
2975cdf0e10cSrcweir         if ( mpWindowImpl->mpWinData )
2976cdf0e10cSrcweir         {
2977cdf0e10cSrcweir             if ( mpWindowImpl->mbFocusVisible )
2978cdf0e10cSrcweir                 ImplInvertFocus( *(mpWindowImpl->mpWinData->mpFocusRect) );
2979cdf0e10cSrcweir             if ( mpWindowImpl->mbTrackVisible && (mpWindowImpl->mpWinData->mnTrackFlags & SHOWTRACK_WINDOW) )
2980cdf0e10cSrcweir                 InvertTracking( *(mpWindowImpl->mpWinData->mpTrackRect), mpWindowImpl->mpWinData->mnTrackFlags );
2981cdf0e10cSrcweir         }
2982cdf0e10cSrcweir 
2983cdf0e10cSrcweir         SalGraphics* pGraphics = ImplGetFrameGraphics();
2984cdf0e10cSrcweir         if ( pGraphics )
2985cdf0e10cSrcweir         {
2986cdf0e10cSrcweir             if( bReMirror )
2987cdf0e10cSrcweir             {
2988cdf0e10cSrcweir                 // --- RTL --- frame coordinates require re-mirroring
2989cdf0e10cSrcweir                 ImplReMirror( aRegion );
2990cdf0e10cSrcweir             }
2991cdf0e10cSrcweir 
2992cdf0e10cSrcweir             ImplSelectClipRegion( aRegion, pGraphics );
2993cdf0e10cSrcweir             pGraphics->CopyArea( rRect.Left()+nHorzScroll, rRect.Top()+nVertScroll,
2994cdf0e10cSrcweir                                  rRect.Left(), rRect.Top(),
2995cdf0e10cSrcweir                                  rRect.GetWidth(), rRect.GetHeight(),
2996cdf0e10cSrcweir                                  SAL_COPYAREA_WINDOWINVALIDATE, this );
2997cdf0e10cSrcweir         }
2998cdf0e10cSrcweir 
2999cdf0e10cSrcweir         if ( mpWindowImpl->mpWinData )
3000cdf0e10cSrcweir         {
3001cdf0e10cSrcweir             if ( mpWindowImpl->mbFocusVisible )
3002cdf0e10cSrcweir                 ImplInvertFocus( *(mpWindowImpl->mpWinData->mpFocusRect) );
3003cdf0e10cSrcweir             if ( mpWindowImpl->mbTrackVisible && (mpWindowImpl->mpWinData->mnTrackFlags & SHOWTRACK_WINDOW) )
3004cdf0e10cSrcweir                 InvertTracking( *(mpWindowImpl->mpWinData->mpTrackRect), mpWindowImpl->mpWinData->mnTrackFlags );
3005cdf0e10cSrcweir         }
3006cdf0e10cSrcweir     }
3007cdf0e10cSrcweir 
3008cdf0e10cSrcweir     if ( !aInvalidateRegion.IsEmpty() )
3009cdf0e10cSrcweir     {
3010cdf0e10cSrcweir         // --- RTL --- the invalidate region for this windows is already computed in frame coordinates
3011cdf0e10cSrcweir         // so it has to be re-mirrored before calling the Paint-handler
3012cdf0e10cSrcweir         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_CHECKRTL;
3013cdf0e10cSrcweir 
3014cdf0e10cSrcweir         sal_uInt16 nPaintFlags = INVALIDATE_CHILDREN;
3015cdf0e10cSrcweir         if ( !bErase )
3016cdf0e10cSrcweir             nPaintFlags |= INVALIDATE_NOERASE;
3017cdf0e10cSrcweir         if ( !bScrollChilds )
3018cdf0e10cSrcweir         {
3019cdf0e10cSrcweir             if ( nOrgFlags & SCROLL_NOCHILDREN )
3020cdf0e10cSrcweir                 ImplClipAllChilds( aInvalidateRegion );
3021cdf0e10cSrcweir             else
3022cdf0e10cSrcweir                 ImplClipChilds( aInvalidateRegion );
3023cdf0e10cSrcweir         }
3024cdf0e10cSrcweir         ImplInvalidateFrameRegion( &aInvalidateRegion, nPaintFlags );
3025cdf0e10cSrcweir     }
3026cdf0e10cSrcweir 
3027cdf0e10cSrcweir     if ( bScrollChilds )
3028cdf0e10cSrcweir     {
3029cdf0e10cSrcweir         Window* pWindow = mpWindowImpl->mpFirstChild;
3030cdf0e10cSrcweir         while ( pWindow )
3031cdf0e10cSrcweir         {
3032cdf0e10cSrcweir             Point aPos = pWindow->GetPosPixel();
3033cdf0e10cSrcweir             aPos += Point( nHorzScroll, nVertScroll );
3034cdf0e10cSrcweir             pWindow->SetPosPixel( aPos );
3035cdf0e10cSrcweir 
3036cdf0e10cSrcweir             pWindow = pWindow->mpWindowImpl->mpNext;
3037cdf0e10cSrcweir         }
3038cdf0e10cSrcweir     }
3039cdf0e10cSrcweir 
3040cdf0e10cSrcweir     if ( nFlags & SCROLL_UPDATE )
3041cdf0e10cSrcweir         Update();
3042cdf0e10cSrcweir 
3043cdf0e10cSrcweir     if ( mpWindowImpl->mpCursor )
3044cdf0e10cSrcweir         mpWindowImpl->mpCursor->ImplShow( false );
3045cdf0e10cSrcweir }
3046cdf0e10cSrcweir 
3047cdf0e10cSrcweir // -----------------------------------------------------------------------
3048cdf0e10cSrcweir 
3049cdf0e10cSrcweir void Window::ImplUpdateAll( sal_Bool bOverlapWindows )
3050cdf0e10cSrcweir {
3051cdf0e10cSrcweir     if ( !mpWindowImpl->mbReallyVisible )
3052cdf0e10cSrcweir         return;
3053cdf0e10cSrcweir 
3054cdf0e10cSrcweir     sal_Bool bFlush = sal_False;
3055cdf0e10cSrcweir     if ( mpWindowImpl->mpFrameWindow->mpWindowImpl->mbPaintFrame )
3056cdf0e10cSrcweir     {
3057cdf0e10cSrcweir         Point aPoint( 0, 0 );
3058cdf0e10cSrcweir         Region aRegion( Rectangle( aPoint, Size( mnOutWidth, mnOutHeight ) ) );
3059cdf0e10cSrcweir         ImplInvalidateOverlapFrameRegion( aRegion );
3060cdf0e10cSrcweir         if ( mpWindowImpl->mbFrame || (mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame) )
3061cdf0e10cSrcweir             bFlush = sal_True;
3062cdf0e10cSrcweir     }
3063cdf0e10cSrcweir 
3064cdf0e10cSrcweir     // Ein Update wirkt immer auf das OverlapWindow, damit bei spaeteren
3065cdf0e10cSrcweir     // Paints nicht zuviel gemalt wird, wenn dort ALLCHILDREN usw. gesetzt
3066cdf0e10cSrcweir     // ist
3067cdf0e10cSrcweir     Window* pWindow = ImplGetFirstOverlapWindow();
3068cdf0e10cSrcweir     if ( bOverlapWindows )
3069cdf0e10cSrcweir         pWindow->ImplCallOverlapPaint();
3070cdf0e10cSrcweir     else
3071cdf0e10cSrcweir     {
3072cdf0e10cSrcweir         if ( pWindow->mpWindowImpl->mnPaintFlags & (IMPL_PAINT_PAINT | IMPL_PAINT_PAINTCHILDS) )
3073cdf0e10cSrcweir             pWindow->ImplCallPaint( NULL, pWindow->mpWindowImpl->mnPaintFlags );
3074cdf0e10cSrcweir     }
3075cdf0e10cSrcweir 
3076cdf0e10cSrcweir     if ( bFlush )
3077cdf0e10cSrcweir         Flush();
3078cdf0e10cSrcweir }
3079cdf0e10cSrcweir 
3080cdf0e10cSrcweir // -----------------------------------------------------------------------
3081cdf0e10cSrcweir 
3082cdf0e10cSrcweir void Window::ImplUpdateWindowPtr( Window* pWindow )
3083cdf0e10cSrcweir {
3084cdf0e10cSrcweir     if ( mpWindowImpl->mpFrameWindow != pWindow->mpWindowImpl->mpFrameWindow )
3085cdf0e10cSrcweir     {
3086cdf0e10cSrcweir         // Graphic freigeben
3087cdf0e10cSrcweir         ImplReleaseGraphics();
3088cdf0e10cSrcweir     }
3089cdf0e10cSrcweir 
3090cdf0e10cSrcweir     mpWindowImpl->mpFrameData     = pWindow->mpWindowImpl->mpFrameData;
3091cdf0e10cSrcweir     mpWindowImpl->mpFrame         = pWindow->mpWindowImpl->mpFrame;
3092cdf0e10cSrcweir     mpWindowImpl->mpFrameWindow   = pWindow->mpWindowImpl->mpFrameWindow;
3093cdf0e10cSrcweir     if ( pWindow->ImplIsOverlapWindow() )
3094cdf0e10cSrcweir         mpWindowImpl->mpOverlapWindow = pWindow;
3095cdf0e10cSrcweir     else
3096cdf0e10cSrcweir         mpWindowImpl->mpOverlapWindow = pWindow->mpWindowImpl->mpOverlapWindow;
3097cdf0e10cSrcweir 
3098cdf0e10cSrcweir     Window* pChild = mpWindowImpl->mpFirstChild;
3099cdf0e10cSrcweir     while ( pChild )
3100cdf0e10cSrcweir     {
3101cdf0e10cSrcweir         pChild->ImplUpdateWindowPtr( pWindow );
3102cdf0e10cSrcweir         pChild = pChild->mpWindowImpl->mpNext;
3103cdf0e10cSrcweir     }
3104cdf0e10cSrcweir }
3105cdf0e10cSrcweir 
3106cdf0e10cSrcweir // -----------------------------------------------------------------------
3107cdf0e10cSrcweir 
3108cdf0e10cSrcweir void Window::ImplUpdateWindowPtr()
3109cdf0e10cSrcweir {
3110cdf0e10cSrcweir     Window* pChild = mpWindowImpl->mpFirstChild;
3111cdf0e10cSrcweir     while ( pChild )
3112cdf0e10cSrcweir     {
3113cdf0e10cSrcweir         pChild->ImplUpdateWindowPtr( this );
3114cdf0e10cSrcweir         pChild = pChild->mpWindowImpl->mpNext;
3115cdf0e10cSrcweir     }
3116cdf0e10cSrcweir }
3117cdf0e10cSrcweir 
3118cdf0e10cSrcweir // -----------------------------------------------------------------------
3119cdf0e10cSrcweir 
3120cdf0e10cSrcweir void Window::ImplUpdateOverlapWindowPtr( sal_Bool bNewFrame )
3121cdf0e10cSrcweir {
3122cdf0e10cSrcweir     sal_Bool bVisible = IsVisible();
3123cdf0e10cSrcweir     Show( sal_False );
3124cdf0e10cSrcweir     ImplRemoveWindow( bNewFrame );
3125cdf0e10cSrcweir     Window* pRealParent = mpWindowImpl->mpRealParent;
3126cdf0e10cSrcweir     ImplInsertWindow( ImplGetParent() );
3127cdf0e10cSrcweir     mpWindowImpl->mpRealParent = pRealParent;
3128cdf0e10cSrcweir     ImplUpdateWindowPtr();
3129cdf0e10cSrcweir     if ( ImplUpdatePos() )
3130cdf0e10cSrcweir         ImplUpdateSysObjPos();
3131cdf0e10cSrcweir 
3132cdf0e10cSrcweir     if ( bNewFrame )
3133cdf0e10cSrcweir     {
3134cdf0e10cSrcweir         Window* pOverlapWindow = mpWindowImpl->mpFirstOverlap;
3135cdf0e10cSrcweir         while ( pOverlapWindow )
3136cdf0e10cSrcweir         {
3137cdf0e10cSrcweir             Window* pNextOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext;
3138cdf0e10cSrcweir             pOverlapWindow->ImplUpdateOverlapWindowPtr( bNewFrame );
3139cdf0e10cSrcweir             pOverlapWindow = pNextOverlapWindow;
3140cdf0e10cSrcweir         }
3141cdf0e10cSrcweir     }
3142cdf0e10cSrcweir 
3143cdf0e10cSrcweir     if ( bVisible )
3144cdf0e10cSrcweir         Show( sal_True );
3145cdf0e10cSrcweir }
3146cdf0e10cSrcweir 
3147cdf0e10cSrcweir // -----------------------------------------------------------------------
3148cdf0e10cSrcweir 
3149cdf0e10cSrcweir sal_Bool Window::ImplUpdatePos()
3150cdf0e10cSrcweir {
3151cdf0e10cSrcweir     sal_Bool bSysChild = sal_False;
3152cdf0e10cSrcweir 
3153cdf0e10cSrcweir     if ( ImplIsOverlapWindow() )
3154cdf0e10cSrcweir     {
3155cdf0e10cSrcweir         mnOutOffX  = mpWindowImpl->mnX;
3156cdf0e10cSrcweir         mnOutOffY  = mpWindowImpl->mnY;
3157cdf0e10cSrcweir     }
3158cdf0e10cSrcweir     else
3159cdf0e10cSrcweir     {
3160cdf0e10cSrcweir         Window* pParent = ImplGetParent();
3161cdf0e10cSrcweir 
3162cdf0e10cSrcweir         mnOutOffX  = mpWindowImpl->mnX + pParent->mnOutOffX;
3163cdf0e10cSrcweir         mnOutOffY  = mpWindowImpl->mnY + pParent->mnOutOffY;
3164cdf0e10cSrcweir     }
3165cdf0e10cSrcweir 
3166cdf0e10cSrcweir     Window* pChild = mpWindowImpl->mpFirstChild;
3167cdf0e10cSrcweir     while ( pChild )
3168cdf0e10cSrcweir     {
3169cdf0e10cSrcweir         if ( pChild->ImplUpdatePos() )
3170cdf0e10cSrcweir             bSysChild = sal_True;
3171cdf0e10cSrcweir         pChild = pChild->mpWindowImpl->mpNext;
3172cdf0e10cSrcweir     }
3173cdf0e10cSrcweir 
3174cdf0e10cSrcweir     if ( mpWindowImpl->mpSysObj )
3175cdf0e10cSrcweir         bSysChild = sal_True;
3176cdf0e10cSrcweir 
3177cdf0e10cSrcweir     return bSysChild;
3178cdf0e10cSrcweir }
3179cdf0e10cSrcweir 
3180cdf0e10cSrcweir // -----------------------------------------------------------------------
3181cdf0e10cSrcweir 
3182cdf0e10cSrcweir void Window::ImplUpdateSysObjPos()
3183cdf0e10cSrcweir {
3184cdf0e10cSrcweir     if ( mpWindowImpl->mpSysObj )
3185cdf0e10cSrcweir         mpWindowImpl->mpSysObj->SetPosSize( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight );
3186cdf0e10cSrcweir 
3187cdf0e10cSrcweir     Window* pChild = mpWindowImpl->mpFirstChild;
3188cdf0e10cSrcweir     while ( pChild )
3189cdf0e10cSrcweir     {
3190cdf0e10cSrcweir         pChild->ImplUpdateSysObjPos();
3191cdf0e10cSrcweir         pChild = pChild->mpWindowImpl->mpNext;
3192cdf0e10cSrcweir     }
3193cdf0e10cSrcweir }
3194cdf0e10cSrcweir // -----------------------------------------------------------------------
3195cdf0e10cSrcweir 
3196cdf0e10cSrcweir void Window::ImplPosSizeWindow( long nX, long nY,
3197cdf0e10cSrcweir                                 long nWidth, long nHeight, sal_uInt16 nFlags )
3198cdf0e10cSrcweir {
3199cdf0e10cSrcweir     sal_Bool    bNewPos         = sal_False;
3200cdf0e10cSrcweir     sal_Bool    bNewSize        = sal_False;
3201cdf0e10cSrcweir     sal_Bool    bNewWidth       = sal_False;
3202cdf0e10cSrcweir     sal_Bool    bCopyBits       = sal_False;
3203cdf0e10cSrcweir     long    nOldOutOffX     = mnOutOffX;
3204cdf0e10cSrcweir     long    nOldOutOffY     = mnOutOffY;
3205cdf0e10cSrcweir     long    nOldOutWidth    = mnOutWidth;
3206cdf0e10cSrcweir     long    nOldOutHeight   = mnOutHeight;
3207cdf0e10cSrcweir     Region* pOverlapRegion  = NULL;
3208cdf0e10cSrcweir     Region* pOldRegion      = NULL;
3209cdf0e10cSrcweir 
3210cdf0e10cSrcweir     if ( IsReallyVisible() )
3211cdf0e10cSrcweir     {
3212cdf0e10cSrcweir         if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
3213cdf0e10cSrcweir             ImplInvalidateAllOverlapBackgrounds();
3214cdf0e10cSrcweir 
3215cdf0e10cSrcweir         Rectangle aOldWinRect( Point( nOldOutOffX, nOldOutOffY ),
3216cdf0e10cSrcweir                                Size( nOldOutWidth, nOldOutHeight ) );
3217cdf0e10cSrcweir         pOldRegion = new Region( aOldWinRect );
3218cdf0e10cSrcweir         if ( mpWindowImpl->mbWinRegion )
3219cdf0e10cSrcweir             pOldRegion->Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
3220cdf0e10cSrcweir 
3221cdf0e10cSrcweir         if ( mnOutWidth && mnOutHeight && !mpWindowImpl->mbPaintTransparent &&
3222cdf0e10cSrcweir              !mpWindowImpl->mbInitWinClipRegion && !mpWindowImpl->maWinClipRegion.IsEmpty() &&
3223cdf0e10cSrcweir              !HasPaintEvent() )
3224cdf0e10cSrcweir             bCopyBits = sal_True;
3225cdf0e10cSrcweir     }
3226cdf0e10cSrcweir 
3227cdf0e10cSrcweir     sal_Bool bnXRecycled = sal_False; // avoid duplicate mirroring in RTL case
3228cdf0e10cSrcweir     if ( nFlags & WINDOW_POSSIZE_WIDTH )
3229cdf0e10cSrcweir     {
3230cdf0e10cSrcweir         if(!( nFlags & WINDOW_POSSIZE_X ))
3231cdf0e10cSrcweir         {
3232cdf0e10cSrcweir             nX = mpWindowImpl->mnX;
3233cdf0e10cSrcweir             nFlags |= WINDOW_POSSIZE_X;
3234cdf0e10cSrcweir             bnXRecycled = sal_True; // we're using a mnX which was already mirrored in RTL case
3235cdf0e10cSrcweir         }
3236cdf0e10cSrcweir 
3237cdf0e10cSrcweir         if ( nWidth < 0 )
3238cdf0e10cSrcweir             nWidth = 0;
3239cdf0e10cSrcweir         if ( nWidth != mnOutWidth )
3240cdf0e10cSrcweir         {
3241cdf0e10cSrcweir             mnOutWidth = nWidth;
3242cdf0e10cSrcweir             bNewSize = sal_True;
3243cdf0e10cSrcweir             bCopyBits = sal_False;
3244cdf0e10cSrcweir             bNewWidth = sal_True;
3245cdf0e10cSrcweir         }
3246cdf0e10cSrcweir     }
3247cdf0e10cSrcweir     if ( nFlags & WINDOW_POSSIZE_HEIGHT )
3248cdf0e10cSrcweir     {
3249cdf0e10cSrcweir         if ( nHeight < 0 )
3250cdf0e10cSrcweir             nHeight = 0;
3251cdf0e10cSrcweir         if ( nHeight != mnOutHeight )
3252cdf0e10cSrcweir         {
3253cdf0e10cSrcweir             mnOutHeight = nHeight;
3254cdf0e10cSrcweir             bNewSize = sal_True;
3255cdf0e10cSrcweir             bCopyBits = sal_False;
3256cdf0e10cSrcweir         }
3257cdf0e10cSrcweir     }
3258cdf0e10cSrcweir 
3259cdf0e10cSrcweir     if ( nFlags & WINDOW_POSSIZE_X )
3260cdf0e10cSrcweir     {
3261cdf0e10cSrcweir         long nOrgX = nX;
3262cdf0e10cSrcweir 		// --- RTL ---  (compare the screen coordinates)
3263cdf0e10cSrcweir 		Point aPtDev( Point( nX+mnOutOffX, 0 ) );
3264cdf0e10cSrcweir 		if( ImplHasMirroredGraphics() )
3265cdf0e10cSrcweir         {
3266cdf0e10cSrcweir             mpGraphics->mirror( aPtDev.X(), this );
3267cdf0e10cSrcweir 
3268cdf0e10cSrcweir             // #106948# always mirror our pos if our parent is not mirroring, even
3269cdf0e10cSrcweir             // if we are also not mirroring
3270cdf0e10cSrcweir             // --- RTL --- check if parent is in different coordinates
3271cdf0e10cSrcweir             if( !bnXRecycled && mpWindowImpl->mpParent && !mpWindowImpl->mpParent->mpWindowImpl->mbFrame && mpWindowImpl->mpParent->ImplIsAntiparallel() )
3272cdf0e10cSrcweir             {
3273cdf0e10cSrcweir                 // --- RTL --- (re-mirror at parent window)
3274cdf0e10cSrcweir                 nX = mpWindowImpl->mpParent->mnOutWidth - mnOutWidth - nX;
3275cdf0e10cSrcweir             }
3276cdf0e10cSrcweir             /* #i99166# An LTR window in RTL UI that gets sized only would be
3277cdf0e10cSrcweir                expected to not moved its upper left point
3278cdf0e10cSrcweir             */
3279cdf0e10cSrcweir             if( bnXRecycled )
3280cdf0e10cSrcweir             {
3281cdf0e10cSrcweir                 if( ImplIsAntiparallel() )
3282cdf0e10cSrcweir                 {
3283cdf0e10cSrcweir                     aPtDev.X() = mpWindowImpl->mnAbsScreenX;
3284cdf0e10cSrcweir                     nOrgX = mpWindowImpl->maPos.X();
3285cdf0e10cSrcweir                 }
3286cdf0e10cSrcweir             }
3287cdf0e10cSrcweir         }
3288cdf0e10cSrcweir         else if( !bnXRecycled && mpWindowImpl->mpParent && !mpWindowImpl->mpParent->mpWindowImpl->mbFrame && mpWindowImpl->mpParent->ImplIsAntiparallel() )
3289cdf0e10cSrcweir         {
3290cdf0e10cSrcweir             // mirrored window in LTR UI
3291cdf0e10cSrcweir             {
3292cdf0e10cSrcweir                 // --- RTL --- (re-mirror at parent window)
3293cdf0e10cSrcweir                 nX = mpWindowImpl->mpParent->mnOutWidth - mnOutWidth - nX;
3294cdf0e10cSrcweir             }
3295cdf0e10cSrcweir         }
3296cdf0e10cSrcweir 
3297cdf0e10cSrcweir         // check maPos as well, as it could have been changed for client windows (ImplCallMove())
3298cdf0e10cSrcweir         if ( mpWindowImpl->mnAbsScreenX != aPtDev.X() || nX != mpWindowImpl->mnX || nOrgX != mpWindowImpl->maPos.X() )
3299cdf0e10cSrcweir         {
3300cdf0e10cSrcweir             if ( bCopyBits && !pOverlapRegion )
3301cdf0e10cSrcweir             {
3302cdf0e10cSrcweir                 pOverlapRegion = new Region();
3303cdf0e10cSrcweir                 ImplCalcOverlapRegion( Rectangle( Point( mnOutOffX, mnOutOffY ),
3304cdf0e10cSrcweir                                                   Size( mnOutWidth, mnOutHeight ) ),
3305cdf0e10cSrcweir                                        *pOverlapRegion, sal_False, sal_True, sal_True );
3306cdf0e10cSrcweir             }
3307cdf0e10cSrcweir             mpWindowImpl->mnX = nX;
3308cdf0e10cSrcweir             mpWindowImpl->maPos.X() = nOrgX;
3309cdf0e10cSrcweir 			mpWindowImpl->mnAbsScreenX = aPtDev.X();	// --- RTL --- (store real screen pos)
3310cdf0e10cSrcweir             bNewPos = sal_True;
3311cdf0e10cSrcweir         }
3312cdf0e10cSrcweir     }
3313cdf0e10cSrcweir     if ( nFlags & WINDOW_POSSIZE_Y )
3314cdf0e10cSrcweir     {
3315cdf0e10cSrcweir         // check maPos as well, as it could have been changed for client windows (ImplCallMove())
3316cdf0e10cSrcweir         if ( nY != mpWindowImpl->mnY || nY != mpWindowImpl->maPos.Y() )
3317cdf0e10cSrcweir         {
3318cdf0e10cSrcweir             if ( bCopyBits && !pOverlapRegion )
3319cdf0e10cSrcweir             {
3320cdf0e10cSrcweir                 pOverlapRegion = new Region();
3321cdf0e10cSrcweir                 ImplCalcOverlapRegion( Rectangle( Point( mnOutOffX, mnOutOffY ),
3322cdf0e10cSrcweir                                                   Size( mnOutWidth, mnOutHeight ) ),
3323cdf0e10cSrcweir                                        *pOverlapRegion, sal_False, sal_True, sal_True );
3324cdf0e10cSrcweir             }
3325cdf0e10cSrcweir             mpWindowImpl->mnY = nY;
3326cdf0e10cSrcweir             mpWindowImpl->maPos.Y() = nY;
3327cdf0e10cSrcweir             bNewPos = sal_True;
3328cdf0e10cSrcweir         }
3329cdf0e10cSrcweir     }
3330cdf0e10cSrcweir 
3331cdf0e10cSrcweir /*    if ( nFlags & (WINDOW_POSSIZE_X|WINDOW_POSSIZE_Y) )
3332cdf0e10cSrcweir     {
3333cdf0e10cSrcweir         POINT aPt;
3334cdf0e10cSrcweir         aPt.x = mpWindowImpl->maPos.X();
3335cdf0e10cSrcweir         aPt.y = mpWindowImpl->maPos.Y();
3336cdf0e10cSrcweir         ClientToScreen( mpWindowImpl->mpFrame->maFrameData.mhWnd , &aPt );
3337cdf0e10cSrcweir         mpWindowImpl->maPos.X() = aPt.x;
3338cdf0e10cSrcweir         mpWindowImpl->maPos.Y() = aPt.y;
3339cdf0e10cSrcweir     }
3340cdf0e10cSrcweir */
3341cdf0e10cSrcweir     if ( bNewPos || bNewSize )
3342cdf0e10cSrcweir     {
3343cdf0e10cSrcweir         sal_Bool bUpdateSysObjPos = sal_False;
3344cdf0e10cSrcweir         if ( bNewPos )
3345cdf0e10cSrcweir             bUpdateSysObjPos = ImplUpdatePos();
3346cdf0e10cSrcweir 
3347cdf0e10cSrcweir         // the borderwindow always specifies the position for its client window
3348cdf0e10cSrcweir         if ( mpWindowImpl->mpBorderWindow )
3349cdf0e10cSrcweir             mpWindowImpl->maPos = mpWindowImpl->mpBorderWindow->mpWindowImpl->maPos;
3350cdf0e10cSrcweir 
3351cdf0e10cSrcweir         if ( mpWindowImpl->mpClientWindow )
3352cdf0e10cSrcweir         {
3353cdf0e10cSrcweir             mpWindowImpl->mpClientWindow->ImplPosSizeWindow( mpWindowImpl->mpClientWindow->mpWindowImpl->mnLeftBorder,
3354cdf0e10cSrcweir                                                mpWindowImpl->mpClientWindow->mpWindowImpl->mnTopBorder,
3355cdf0e10cSrcweir                                                mnOutWidth-mpWindowImpl->mpClientWindow->mpWindowImpl->mnLeftBorder-mpWindowImpl->mpClientWindow->mpWindowImpl->mnRightBorder,
3356cdf0e10cSrcweir                                                mnOutHeight-mpWindowImpl->mpClientWindow->mpWindowImpl->mnTopBorder-mpWindowImpl->mpClientWindow->mpWindowImpl->mnBottomBorder,
3357cdf0e10cSrcweir                                                WINDOW_POSSIZE_X | WINDOW_POSSIZE_Y |
3358cdf0e10cSrcweir                                                WINDOW_POSSIZE_WIDTH | WINDOW_POSSIZE_HEIGHT );
3359cdf0e10cSrcweir             // Wenn wir ein ClientWindow haben, dann hat dieses fuer die
3360cdf0e10cSrcweir             // Applikation auch die Position des FloatingWindows
3361cdf0e10cSrcweir             mpWindowImpl->mpClientWindow->mpWindowImpl->maPos = mpWindowImpl->maPos;
3362cdf0e10cSrcweir             if ( bNewPos )
3363cdf0e10cSrcweir             {
3364cdf0e10cSrcweir                 if ( mpWindowImpl->mpClientWindow->IsVisible() )
3365cdf0e10cSrcweir                 {
3366cdf0e10cSrcweir                     mpWindowImpl->mpClientWindow->ImplCallMove();
3367cdf0e10cSrcweir                 }
3368cdf0e10cSrcweir                 else
3369cdf0e10cSrcweir                 {
3370cdf0e10cSrcweir                     mpWindowImpl->mpClientWindow->mpWindowImpl->mbCallMove = sal_True;
3371cdf0e10cSrcweir                 }
3372cdf0e10cSrcweir             }
3373cdf0e10cSrcweir         }
3374cdf0e10cSrcweir //        else
3375cdf0e10cSrcweir //        {
3376cdf0e10cSrcweir //            if ( mpWindowImpl->mpBorderWindow )
3377cdf0e10cSrcweir //                mpWindowImpl->maPos = mpWindowImpl->mpBorderWindow->mpWindowImpl->maPos;
3378cdf0e10cSrcweir //        }
3379cdf0e10cSrcweir 
3380cdf0e10cSrcweir         // Move()/Resize() werden erst bei Show() gerufen, damit min. eins vor
3381cdf0e10cSrcweir         // einem Show() kommt
3382cdf0e10cSrcweir         if ( IsVisible() )
3383cdf0e10cSrcweir         {
3384cdf0e10cSrcweir             if ( bNewPos )
3385cdf0e10cSrcweir             {
3386cdf0e10cSrcweir                 ImplCallMove();
3387cdf0e10cSrcweir             }
3388cdf0e10cSrcweir             if ( bNewSize )
3389cdf0e10cSrcweir             {
3390cdf0e10cSrcweir                 ImplCallResize();
3391cdf0e10cSrcweir             }
3392cdf0e10cSrcweir         }
3393cdf0e10cSrcweir         else
3394cdf0e10cSrcweir         {
3395cdf0e10cSrcweir             if ( bNewPos )
3396cdf0e10cSrcweir                 mpWindowImpl->mbCallMove = sal_True;
3397cdf0e10cSrcweir             if ( bNewSize )
3398cdf0e10cSrcweir                 mpWindowImpl->mbCallResize = sal_True;
3399cdf0e10cSrcweir         }
3400cdf0e10cSrcweir 
3401cdf0e10cSrcweir         sal_Bool bUpdateSysObjClip = sal_False;
3402cdf0e10cSrcweir         if ( IsReallyVisible() )
3403cdf0e10cSrcweir         {
3404cdf0e10cSrcweir             if ( bNewPos || bNewSize )
3405cdf0e10cSrcweir             {
3406cdf0e10cSrcweir                 // Hintergrund-Sicherung zuruecksetzen
3407cdf0e10cSrcweir                 if ( mpWindowImpl->mpOverlapData && mpWindowImpl->mpOverlapData->mpSaveBackDev )
3408cdf0e10cSrcweir                     ImplDeleteOverlapBackground();
3409cdf0e10cSrcweir                 if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
3410cdf0e10cSrcweir                     ImplInvalidateAllOverlapBackgrounds();
3411cdf0e10cSrcweir                 // Clip-Flag neu setzen
3412cdf0e10cSrcweir                 bUpdateSysObjClip = !ImplSetClipFlag( sal_True );
3413cdf0e10cSrcweir             }
3414cdf0e10cSrcweir 
3415cdf0e10cSrcweir             // Fensterinhalt invalidieren ?
3416cdf0e10cSrcweir             if ( bNewPos || (mnOutWidth > nOldOutWidth) || (mnOutHeight > nOldOutHeight) )
3417cdf0e10cSrcweir             {
3418cdf0e10cSrcweir                 if ( bNewPos )
3419cdf0e10cSrcweir                 {
3420cdf0e10cSrcweir                     sal_Bool bInvalidate = sal_False;
3421cdf0e10cSrcweir                     sal_Bool bParentPaint = sal_True;
3422cdf0e10cSrcweir                     if ( !ImplIsOverlapWindow() )
3423cdf0e10cSrcweir                         bParentPaint = mpWindowImpl->mpParent->IsPaintEnabled();
3424cdf0e10cSrcweir                     if ( bCopyBits && bParentPaint && !HasPaintEvent() )
3425cdf0e10cSrcweir                     {
3426cdf0e10cSrcweir                         Point aPoint( mnOutOffX, mnOutOffY );
3427cdf0e10cSrcweir                         Region aRegion( Rectangle( aPoint,
3428cdf0e10cSrcweir                                                    Size( mnOutWidth, mnOutHeight ) ) );
3429cdf0e10cSrcweir                         if ( mpWindowImpl->mbWinRegion )
3430cdf0e10cSrcweir                             aRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
3431cdf0e10cSrcweir                         ImplClipBoundaries( aRegion, sal_False, sal_True );
3432cdf0e10cSrcweir                         if ( !pOverlapRegion->IsEmpty() )
3433cdf0e10cSrcweir                         {
3434cdf0e10cSrcweir                             pOverlapRegion->Move( mnOutOffX-nOldOutOffX, mnOutOffY-nOldOutOffY );
3435cdf0e10cSrcweir                             aRegion.Exclude( *pOverlapRegion );
3436cdf0e10cSrcweir                         }
3437cdf0e10cSrcweir                         if ( !aRegion.IsEmpty() )
3438cdf0e10cSrcweir                         {
3439cdf0e10cSrcweir                             // Paint-Bereiche anpassen
3440cdf0e10cSrcweir                             ImplMoveAllInvalidateRegions( Rectangle( Point( nOldOutOffX, nOldOutOffY ),
3441cdf0e10cSrcweir                                                                      Size( nOldOutWidth, nOldOutHeight ) ),
3442cdf0e10cSrcweir                                                           mnOutOffX-nOldOutOffX, mnOutOffY-nOldOutOffY,
3443cdf0e10cSrcweir                                                           sal_True );
3444cdf0e10cSrcweir                             SalGraphics* pGraphics = ImplGetFrameGraphics();
3445cdf0e10cSrcweir                             if ( pGraphics )
3446cdf0e10cSrcweir                             {
3447cdf0e10cSrcweir                                 const bool bSelectClipRegion = ImplSelectClipRegion( aRegion, pGraphics );
3448cdf0e10cSrcweir                                 if ( bSelectClipRegion )
3449cdf0e10cSrcweir                                 {
3450cdf0e10cSrcweir                                     pGraphics->CopyArea( mnOutOffX, mnOutOffY,
3451cdf0e10cSrcweir                                                          nOldOutOffX, nOldOutOffY,
3452cdf0e10cSrcweir                                                          nOldOutWidth, nOldOutHeight,
3453cdf0e10cSrcweir                                                          SAL_COPYAREA_WINDOWINVALIDATE, this );
3454cdf0e10cSrcweir                                 }
3455cdf0e10cSrcweir                                 else
3456cdf0e10cSrcweir                                     bInvalidate = sal_True;
3457cdf0e10cSrcweir                             }
3458cdf0e10cSrcweir                             else
3459cdf0e10cSrcweir                                 bInvalidate = sal_True;
3460cdf0e10cSrcweir                             if ( !bInvalidate )
3461cdf0e10cSrcweir                             {
3462cdf0e10cSrcweir                                 if ( !pOverlapRegion->IsEmpty() )
3463cdf0e10cSrcweir                                     ImplInvalidateFrameRegion( pOverlapRegion, INVALIDATE_CHILDREN );
3464cdf0e10cSrcweir                             }
3465cdf0e10cSrcweir                         }
3466cdf0e10cSrcweir                         else
3467cdf0e10cSrcweir                             bInvalidate = sal_True;
3468cdf0e10cSrcweir                     }
3469cdf0e10cSrcweir                     else
3470cdf0e10cSrcweir                         bInvalidate = sal_True;
3471cdf0e10cSrcweir                     if ( bInvalidate )
3472cdf0e10cSrcweir                         ImplInvalidateFrameRegion( NULL, INVALIDATE_CHILDREN );
3473cdf0e10cSrcweir                 }
3474cdf0e10cSrcweir                 else
3475cdf0e10cSrcweir                 {
3476cdf0e10cSrcweir                     Point aPoint( mnOutOffX, mnOutOffY );
3477cdf0e10cSrcweir                     Region aRegion( Rectangle( aPoint,
3478cdf0e10cSrcweir                                                Size( mnOutWidth, mnOutHeight ) ) );
3479cdf0e10cSrcweir                     aRegion.Exclude( *pOldRegion );
3480cdf0e10cSrcweir                     if ( mpWindowImpl->mbWinRegion )
3481cdf0e10cSrcweir                         aRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
3482cdf0e10cSrcweir                     ImplClipBoundaries( aRegion, sal_False, sal_True );
3483cdf0e10cSrcweir                     if ( !aRegion.IsEmpty() )
3484cdf0e10cSrcweir                         ImplInvalidateFrameRegion( &aRegion, INVALIDATE_CHILDREN );
3485cdf0e10cSrcweir                 }
3486cdf0e10cSrcweir             }
3487cdf0e10cSrcweir 
3488cdf0e10cSrcweir             // Parent oder Overlaps invalidieren
3489cdf0e10cSrcweir             if ( bNewPos ||
3490cdf0e10cSrcweir                  (mnOutWidth < nOldOutWidth) || (mnOutHeight < nOldOutHeight) )
3491cdf0e10cSrcweir             {
3492cdf0e10cSrcweir                 Region aRegion( *pOldRegion );
3493cdf0e10cSrcweir                 if ( !mpWindowImpl->mbPaintTransparent )
3494cdf0e10cSrcweir                     ImplExcludeWindowRegion( aRegion );
3495cdf0e10cSrcweir                 ImplClipBoundaries( aRegion, sal_False, sal_True );
3496cdf0e10cSrcweir                 if ( !aRegion.IsEmpty() && !mpWindowImpl->mpBorderWindow )
3497cdf0e10cSrcweir                     ImplInvalidateParentFrameRegion( aRegion );
3498cdf0e10cSrcweir             }
3499cdf0e10cSrcweir         }
3500cdf0e10cSrcweir 
3501cdf0e10cSrcweir         // System-Objekte anpassen
3502cdf0e10cSrcweir         if ( bUpdateSysObjClip )
3503cdf0e10cSrcweir             ImplUpdateSysObjClip();
3504cdf0e10cSrcweir         if ( bUpdateSysObjPos )
3505cdf0e10cSrcweir             ImplUpdateSysObjPos();
3506cdf0e10cSrcweir         if ( bNewSize && mpWindowImpl->mpSysObj )
3507cdf0e10cSrcweir             mpWindowImpl->mpSysObj->SetPosSize( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight );
3508cdf0e10cSrcweir     }
3509cdf0e10cSrcweir 
3510cdf0e10cSrcweir     if ( pOverlapRegion )
3511cdf0e10cSrcweir         delete pOverlapRegion;
3512cdf0e10cSrcweir     if ( pOldRegion )
3513cdf0e10cSrcweir         delete pOldRegion;
3514cdf0e10cSrcweir }
3515cdf0e10cSrcweir 
3516cdf0e10cSrcweir // -----------------------------------------------------------------------
3517cdf0e10cSrcweir 
3518cdf0e10cSrcweir void Window::ImplToBottomChild()
3519cdf0e10cSrcweir {
3520cdf0e10cSrcweir     if ( !ImplIsOverlapWindow() && !mpWindowImpl->mbReallyVisible && (mpWindowImpl->mpParent->mpWindowImpl->mpLastChild != this) )
3521cdf0e10cSrcweir     {
3522cdf0e10cSrcweir         // Fenster an das Ende der Liste setzen
3523cdf0e10cSrcweir         if ( mpWindowImpl->mpPrev )
3524cdf0e10cSrcweir             mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext;
3525cdf0e10cSrcweir         else
3526cdf0e10cSrcweir             mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild = mpWindowImpl->mpNext;
3527cdf0e10cSrcweir         mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev;
3528cdf0e10cSrcweir         mpWindowImpl->mpPrev = mpWindowImpl->mpParent->mpWindowImpl->mpLastChild;
3529cdf0e10cSrcweir         mpWindowImpl->mpParent->mpWindowImpl->mpLastChild = this;
3530cdf0e10cSrcweir         mpWindowImpl->mpPrev->mpWindowImpl->mpNext = this;
3531cdf0e10cSrcweir         mpWindowImpl->mpNext = NULL;
3532cdf0e10cSrcweir     }
3533cdf0e10cSrcweir }
3534cdf0e10cSrcweir 
3535cdf0e10cSrcweir // -----------------------------------------------------------------------
3536cdf0e10cSrcweir 
3537cdf0e10cSrcweir void Window::ImplCalcToTop( ImplCalcToTopData* pPrevData )
3538cdf0e10cSrcweir {
3539cdf0e10cSrcweir     DBG_ASSERT( ImplIsOverlapWindow(), "Window::ImplCalcToTop(): Is not a OverlapWindow" );
3540cdf0e10cSrcweir 
3541cdf0e10cSrcweir     if ( !mpWindowImpl->mbFrame )
3542cdf0e10cSrcweir     {
3543cdf0e10cSrcweir         if ( IsReallyVisible() )
3544cdf0e10cSrcweir         {
3545cdf0e10cSrcweir             // Region berechnen, wo das Fenster mit anderen Fenstern ueberlappt
3546cdf0e10cSrcweir             Point aPoint( mnOutOffX, mnOutOffY );
3547cdf0e10cSrcweir             Region  aRegion( Rectangle( aPoint,
3548cdf0e10cSrcweir                                         Size( mnOutWidth, mnOutHeight ) ) );
3549cdf0e10cSrcweir             Region  aInvalidateRegion;
3550cdf0e10cSrcweir             ImplCalcOverlapRegionOverlaps( aRegion, aInvalidateRegion );
3551cdf0e10cSrcweir 
3552cdf0e10cSrcweir             if ( !aInvalidateRegion.IsEmpty() )
3553cdf0e10cSrcweir             {
3554cdf0e10cSrcweir                 ImplCalcToTopData* pData    = new ImplCalcToTopData;
3555cdf0e10cSrcweir                 pPrevData->mpNext           = pData;
3556cdf0e10cSrcweir                 pData->mpNext               = NULL;
3557cdf0e10cSrcweir                 pData->mpWindow             = this;
3558cdf0e10cSrcweir                 pData->mpInvalidateRegion   = new Region( aInvalidateRegion );
3559cdf0e10cSrcweir             }
3560cdf0e10cSrcweir         }
3561cdf0e10cSrcweir     }
3562cdf0e10cSrcweir }
3563cdf0e10cSrcweir 
3564cdf0e10cSrcweir // -----------------------------------------------------------------------
3565cdf0e10cSrcweir 
3566cdf0e10cSrcweir void Window::ImplCalcChildOverlapToTop( ImplCalcToTopData* pPrevData )
3567cdf0e10cSrcweir {
3568cdf0e10cSrcweir     DBG_ASSERT( ImplIsOverlapWindow(), "Window::ImplCalcChildOverlapToTop(): Is not a OverlapWindow" );
3569cdf0e10cSrcweir 
3570cdf0e10cSrcweir     ImplCalcToTop( pPrevData );
3571cdf0e10cSrcweir     if ( pPrevData->mpNext )
3572cdf0e10cSrcweir         pPrevData = pPrevData->mpNext;
3573cdf0e10cSrcweir 
3574cdf0e10cSrcweir     Window* pOverlap = mpWindowImpl->mpFirstOverlap;
3575cdf0e10cSrcweir     while ( pOverlap )
3576cdf0e10cSrcweir     {
3577cdf0e10cSrcweir         pOverlap->ImplCalcToTop( pPrevData );
3578cdf0e10cSrcweir         if ( pPrevData->mpNext )
3579cdf0e10cSrcweir             pPrevData = pPrevData->mpNext;
3580cdf0e10cSrcweir         pOverlap = pOverlap->mpWindowImpl->mpNext;
3581cdf0e10cSrcweir     }
3582cdf0e10cSrcweir }
3583cdf0e10cSrcweir 
3584cdf0e10cSrcweir // -----------------------------------------------------------------------
3585cdf0e10cSrcweir 
3586cdf0e10cSrcweir void Window::ImplToTop( sal_uInt16 nFlags )
3587cdf0e10cSrcweir {
3588cdf0e10cSrcweir     DBG_ASSERT( ImplIsOverlapWindow(), "Window::ImplToTop(): Is not a OverlapWindow" );
3589cdf0e10cSrcweir 
3590cdf0e10cSrcweir     if ( mpWindowImpl->mbFrame )
3591cdf0e10cSrcweir     {
3592cdf0e10cSrcweir         // Wenn in das externe Fenster geklickt wird, ist dieses
3593cdf0e10cSrcweir         // dafuer zustaendig dafuer zu sorgen, das unser Frame
3594cdf0e10cSrcweir         // nach vorne kommt
3595cdf0e10cSrcweir         if ( !mpWindowImpl->mpFrameData->mbHasFocus &&
3596cdf0e10cSrcweir              !mpWindowImpl->mpFrameData->mbSysObjFocus &&
3597cdf0e10cSrcweir              !mpWindowImpl->mpFrameData->mbInSysObjFocusHdl &&
3598cdf0e10cSrcweir              !mpWindowImpl->mpFrameData->mbInSysObjToTopHdl )
3599cdf0e10cSrcweir         {
3600cdf0e10cSrcweir 			// do not bring floating windows on the client to top
3601cdf0e10cSrcweir 			if( !ImplGetClientWindow() || !(ImplGetClientWindow()->GetStyle() & WB_SYSTEMFLOATWIN) )
3602cdf0e10cSrcweir 			{
3603cdf0e10cSrcweir 				sal_uInt16 nSysFlags = 0;
3604cdf0e10cSrcweir 				if ( nFlags & TOTOP_RESTOREWHENMIN )
3605cdf0e10cSrcweir 					nSysFlags |= SAL_FRAME_TOTOP_RESTOREWHENMIN;
3606cdf0e10cSrcweir 				if ( nFlags & TOTOP_FOREGROUNDTASK )
3607cdf0e10cSrcweir 					nSysFlags |= SAL_FRAME_TOTOP_FOREGROUNDTASK;
3608cdf0e10cSrcweir                 if ( nFlags & TOTOP_GRABFOCUSONLY )
3609cdf0e10cSrcweir                     nSysFlags |= SAL_FRAME_TOTOP_GRABFOCUS_ONLY;
3610cdf0e10cSrcweir 				mpWindowImpl->mpFrame->ToTop( nSysFlags );
3611cdf0e10cSrcweir 			}
3612cdf0e10cSrcweir         }
3613cdf0e10cSrcweir     }
3614cdf0e10cSrcweir     else
3615cdf0e10cSrcweir     {
3616cdf0e10cSrcweir         if ( mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap != this )
3617cdf0e10cSrcweir         {
3618cdf0e10cSrcweir             // Fenster aus der Liste entfernen
3619cdf0e10cSrcweir             mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext;
3620cdf0e10cSrcweir             if ( mpWindowImpl->mpNext )
3621cdf0e10cSrcweir                 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev;
3622cdf0e10cSrcweir             else
3623cdf0e10cSrcweir                 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap = mpWindowImpl->mpPrev;
3624cdf0e10cSrcweir 
3625cdf0e10cSrcweir             // AlwaysOnTop beruecksichtigen
3626cdf0e10cSrcweir             sal_Bool    bOnTop = IsAlwaysOnTopEnabled();
3627cdf0e10cSrcweir             Window* pNextWin = mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap;
3628cdf0e10cSrcweir             if ( !bOnTop )
3629cdf0e10cSrcweir             {
3630cdf0e10cSrcweir                 while ( pNextWin )
3631cdf0e10cSrcweir                 {
3632cdf0e10cSrcweir                     if ( !pNextWin->IsAlwaysOnTopEnabled() )
3633cdf0e10cSrcweir                         break;
3634cdf0e10cSrcweir                     pNextWin = pNextWin->mpWindowImpl->mpNext;
3635cdf0e10cSrcweir                 }
3636cdf0e10cSrcweir             }
3637cdf0e10cSrcweir 
3638cdf0e10cSrcweir             // TopLevel abpruefen
3639cdf0e10cSrcweir             sal_uInt8 nTopLevel = mpWindowImpl->mpOverlapData->mnTopLevel;
3640cdf0e10cSrcweir             while ( pNextWin )
3641cdf0e10cSrcweir             {
3642cdf0e10cSrcweir                 if ( (bOnTop != pNextWin->IsAlwaysOnTopEnabled()) ||
3643cdf0e10cSrcweir                      (nTopLevel <= pNextWin->mpWindowImpl->mpOverlapData->mnTopLevel) )
3644cdf0e10cSrcweir                     break;
3645cdf0e10cSrcweir                 pNextWin = pNextWin->mpWindowImpl->mpNext;
3646cdf0e10cSrcweir             }
3647cdf0e10cSrcweir 
3648cdf0e10cSrcweir             // Fenster in die Liste wieder eintragen
3649cdf0e10cSrcweir             mpWindowImpl->mpNext = pNextWin;
3650cdf0e10cSrcweir             if ( pNextWin )
3651cdf0e10cSrcweir             {
3652cdf0e10cSrcweir                 mpWindowImpl->mpPrev = pNextWin->mpWindowImpl->mpPrev;
3653cdf0e10cSrcweir                 pNextWin->mpWindowImpl->mpPrev = this;
3654cdf0e10cSrcweir             }
3655cdf0e10cSrcweir             else
3656cdf0e10cSrcweir             {
3657cdf0e10cSrcweir                 mpWindowImpl->mpPrev = mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap;
3658cdf0e10cSrcweir                 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap = this;
3659cdf0e10cSrcweir             }
3660cdf0e10cSrcweir             if ( mpWindowImpl->mpPrev )
3661cdf0e10cSrcweir                 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = this;
3662cdf0e10cSrcweir             else
3663cdf0e10cSrcweir                 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap = this;
3664cdf0e10cSrcweir 
3665cdf0e10cSrcweir             // ClipRegion muss von diesem Fenster und allen weiteren
3666cdf0e10cSrcweir             // ueberlappenden Fenstern neu berechnet werden.
3667cdf0e10cSrcweir             if ( IsReallyVisible() )
3668cdf0e10cSrcweir             {
3669cdf0e10cSrcweir                 // Hintergrund-Sicherung zuruecksetzen
3670cdf0e10cSrcweir                 if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
3671cdf0e10cSrcweir                     ImplInvalidateAllOverlapBackgrounds();
3672cdf0e10cSrcweir                 mpWindowImpl->mpOverlapWindow->ImplSetClipFlagOverlapWindows();
3673cdf0e10cSrcweir             }
3674cdf0e10cSrcweir         }
3675cdf0e10cSrcweir     }
3676cdf0e10cSrcweir }
3677cdf0e10cSrcweir 
3678cdf0e10cSrcweir // -----------------------------------------------------------------------
3679cdf0e10cSrcweir 
3680cdf0e10cSrcweir void Window::ImplStartToTop( sal_uInt16 nFlags )
3681cdf0e10cSrcweir {
3682cdf0e10cSrcweir     ImplCalcToTopData   aStartData;
3683cdf0e10cSrcweir     ImplCalcToTopData*  pCurData;
3684cdf0e10cSrcweir     ImplCalcToTopData*  pNextData;
3685cdf0e10cSrcweir     Window* pOverlapWindow;
3686cdf0e10cSrcweir     if ( ImplIsOverlapWindow() )
3687cdf0e10cSrcweir         pOverlapWindow = this;
3688cdf0e10cSrcweir     else
3689cdf0e10cSrcweir         pOverlapWindow = mpWindowImpl->mpOverlapWindow;
3690cdf0e10cSrcweir 
3691cdf0e10cSrcweir     // Zuerst die Paint-Bereiche berechnen
3692cdf0e10cSrcweir     Window* pTempOverlapWindow = pOverlapWindow;
3693cdf0e10cSrcweir     aStartData.mpNext = NULL;
3694cdf0e10cSrcweir     pCurData = &aStartData;
3695cdf0e10cSrcweir     do
3696cdf0e10cSrcweir     {
3697cdf0e10cSrcweir         pTempOverlapWindow->ImplCalcToTop( pCurData );
3698cdf0e10cSrcweir         if ( pCurData->mpNext )
3699cdf0e10cSrcweir             pCurData = pCurData->mpNext;
3700cdf0e10cSrcweir         pTempOverlapWindow = pTempOverlapWindow->mpWindowImpl->mpOverlapWindow;
3701cdf0e10cSrcweir     }
3702cdf0e10cSrcweir     while ( !pTempOverlapWindow->mpWindowImpl->mbFrame );
3703cdf0e10cSrcweir     // Dann die Paint-Bereiche der ChildOverlap-Windows berechnen
3704cdf0e10cSrcweir     pTempOverlapWindow = mpWindowImpl->mpFirstOverlap;
3705cdf0e10cSrcweir     while ( pTempOverlapWindow )
3706cdf0e10cSrcweir     {
3707cdf0e10cSrcweir         pTempOverlapWindow->ImplCalcToTop( pCurData );
3708cdf0e10cSrcweir         if ( pCurData->mpNext )
3709cdf0e10cSrcweir             pCurData = pCurData->mpNext;
3710cdf0e10cSrcweir         pTempOverlapWindow = pTempOverlapWindow->mpWindowImpl->mpNext;
3711cdf0e10cSrcweir     }
3712cdf0e10cSrcweir 
3713cdf0e10cSrcweir     // Dann die Fenster-Verkettung aendern
3714cdf0e10cSrcweir     pTempOverlapWindow = pOverlapWindow;
3715cdf0e10cSrcweir     do
3716cdf0e10cSrcweir     {
3717cdf0e10cSrcweir         pTempOverlapWindow->ImplToTop( nFlags );
3718cdf0e10cSrcweir         pTempOverlapWindow = pTempOverlapWindow->mpWindowImpl->mpOverlapWindow;
3719cdf0e10cSrcweir     }
3720cdf0e10cSrcweir     while ( !pTempOverlapWindow->mpWindowImpl->mbFrame );
3721cdf0e10cSrcweir     // Und zum Schluss invalidieren wir die ungueltigen Bereiche
3722cdf0e10cSrcweir     pCurData = aStartData.mpNext;
3723cdf0e10cSrcweir     while ( pCurData )
3724cdf0e10cSrcweir     {
3725cdf0e10cSrcweir         pCurData->mpWindow->ImplInvalidateFrameRegion( pCurData->mpInvalidateRegion, INVALIDATE_CHILDREN );
3726cdf0e10cSrcweir         pNextData = pCurData->mpNext;
3727cdf0e10cSrcweir         delete pCurData->mpInvalidateRegion;
3728cdf0e10cSrcweir         delete pCurData;
3729cdf0e10cSrcweir         pCurData = pNextData;
3730cdf0e10cSrcweir     }
3731cdf0e10cSrcweir }
3732cdf0e10cSrcweir 
3733cdf0e10cSrcweir // -----------------------------------------------------------------------
3734cdf0e10cSrcweir 
3735cdf0e10cSrcweir void Window::ImplFocusToTop( sal_uInt16 nFlags, sal_Bool bReallyVisible )
3736cdf0e10cSrcweir {
3737cdf0e10cSrcweir     // Soll Focus auch geholt werden?
3738cdf0e10cSrcweir     if ( !(nFlags & TOTOP_NOGRABFOCUS) )
3739cdf0e10cSrcweir     {
3740cdf0e10cSrcweir         // Erstes Fenster mit GrabFocus-Activate bekommt den Focus
3741cdf0e10cSrcweir         Window* pFocusWindow = this;
3742cdf0e10cSrcweir         while ( !pFocusWindow->ImplIsOverlapWindow() )
3743cdf0e10cSrcweir         {
3744cdf0e10cSrcweir             // Nur wenn Fenster kein Border-Fenster hat, da wir
3745cdf0e10cSrcweir             // immer das dazugehoerende BorderFenster finden wollen
3746cdf0e10cSrcweir             if ( !pFocusWindow->mpWindowImpl->mpBorderWindow )
3747cdf0e10cSrcweir             {
3748cdf0e10cSrcweir                 if ( pFocusWindow->mpWindowImpl->mnActivateMode & ACTIVATE_MODE_GRABFOCUS )
3749cdf0e10cSrcweir                     break;
3750cdf0e10cSrcweir             }
3751cdf0e10cSrcweir             pFocusWindow = pFocusWindow->ImplGetParent();
3752cdf0e10cSrcweir         }
3753cdf0e10cSrcweir         if ( (pFocusWindow->mpWindowImpl->mnActivateMode & ACTIVATE_MODE_GRABFOCUS) &&
3754cdf0e10cSrcweir              !pFocusWindow->HasChildPathFocus( sal_True ) )
3755cdf0e10cSrcweir             pFocusWindow->GrabFocus();
3756cdf0e10cSrcweir     }
3757cdf0e10cSrcweir 
3758cdf0e10cSrcweir     if ( bReallyVisible )
3759cdf0e10cSrcweir         ImplGenerateMouseMove();
3760cdf0e10cSrcweir }
3761cdf0e10cSrcweir 
3762cdf0e10cSrcweir // -----------------------------------------------------------------------
3763cdf0e10cSrcweir 
3764cdf0e10cSrcweir void Window::ImplShowAllOverlaps()
3765cdf0e10cSrcweir {
3766cdf0e10cSrcweir     Window* pOverlapWindow = mpWindowImpl->mpFirstOverlap;
3767cdf0e10cSrcweir     while ( pOverlapWindow )
3768cdf0e10cSrcweir     {
3769cdf0e10cSrcweir         if ( pOverlapWindow->mpWindowImpl->mbOverlapVisible )
3770cdf0e10cSrcweir         {
3771cdf0e10cSrcweir             pOverlapWindow->Show( sal_True, SHOW_NOACTIVATE );
3772cdf0e10cSrcweir             pOverlapWindow->mpWindowImpl->mbOverlapVisible = sal_False;
3773cdf0e10cSrcweir         }
3774cdf0e10cSrcweir 
3775cdf0e10cSrcweir         pOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext;
3776cdf0e10cSrcweir     }
3777cdf0e10cSrcweir }
3778cdf0e10cSrcweir 
3779cdf0e10cSrcweir // -----------------------------------------------------------------------
3780cdf0e10cSrcweir 
3781cdf0e10cSrcweir void Window::ImplHideAllOverlaps()
3782cdf0e10cSrcweir {
3783cdf0e10cSrcweir     Window* pOverlapWindow = mpWindowImpl->mpFirstOverlap;
3784cdf0e10cSrcweir     while ( pOverlapWindow )
3785cdf0e10cSrcweir     {
3786cdf0e10cSrcweir         if ( pOverlapWindow->IsVisible() )
3787cdf0e10cSrcweir         {
3788cdf0e10cSrcweir             pOverlapWindow->mpWindowImpl->mbOverlapVisible = sal_True;
3789cdf0e10cSrcweir             pOverlapWindow->Show( sal_False );
3790cdf0e10cSrcweir         }
3791cdf0e10cSrcweir 
3792cdf0e10cSrcweir         pOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext;
3793cdf0e10cSrcweir     }
3794cdf0e10cSrcweir }
3795cdf0e10cSrcweir 
3796cdf0e10cSrcweir // -----------------------------------------------------------------------
3797cdf0e10cSrcweir 
3798cdf0e10cSrcweir void Window::ImplCallMouseMove( sal_uInt16 nMouseCode, sal_Bool bModChanged )
3799cdf0e10cSrcweir {
3800cdf0e10cSrcweir     if ( mpWindowImpl->mpFrameData->mbMouseIn && mpWindowImpl->mpFrameWindow->mpWindowImpl->mbReallyVisible )
3801cdf0e10cSrcweir     {
3802cdf0e10cSrcweir         sal_uLong   nTime   = Time::GetSystemTicks();
3803cdf0e10cSrcweir         long    nX      = mpWindowImpl->mpFrameData->mnLastMouseX;
3804cdf0e10cSrcweir         long    nY      = mpWindowImpl->mpFrameData->mnLastMouseY;
3805cdf0e10cSrcweir         sal_uInt16  nCode   = nMouseCode;
3806cdf0e10cSrcweir         sal_uInt16  nMode   = mpWindowImpl->mpFrameData->mnMouseMode;
3807cdf0e10cSrcweir         sal_Bool    bLeave;
3808cdf0e10cSrcweir         // Auf MouseLeave testen
3809cdf0e10cSrcweir         if ( ((nX < 0) || (nY < 0) ||
3810cdf0e10cSrcweir               (nX >= mpWindowImpl->mpFrameWindow->mnOutWidth) ||
3811cdf0e10cSrcweir               (nY >= mpWindowImpl->mpFrameWindow->mnOutHeight)) &&
3812cdf0e10cSrcweir              !ImplGetSVData()->maWinData.mpCaptureWin )
3813cdf0e10cSrcweir             bLeave = sal_True;
3814cdf0e10cSrcweir         else
3815cdf0e10cSrcweir             bLeave = sal_False;
3816cdf0e10cSrcweir         nMode |= MOUSE_SYNTHETIC;
3817cdf0e10cSrcweir         if ( bModChanged )
3818cdf0e10cSrcweir             nMode |= MOUSE_MODIFIERCHANGED;
3819cdf0e10cSrcweir         ImplHandleMouseEvent( mpWindowImpl->mpFrameWindow, EVENT_MOUSEMOVE, bLeave, nX, nY, nTime, nCode, nMode );
3820cdf0e10cSrcweir     }
3821cdf0e10cSrcweir }
3822cdf0e10cSrcweir 
3823cdf0e10cSrcweir // -----------------------------------------------------------------------
3824cdf0e10cSrcweir 
3825cdf0e10cSrcweir void Window::ImplGenerateMouseMove()
3826cdf0e10cSrcweir {
3827cdf0e10cSrcweir     if ( !mpWindowImpl->mpFrameData->mnMouseMoveId )
3828cdf0e10cSrcweir         Application::PostUserEvent( mpWindowImpl->mpFrameData->mnMouseMoveId, LINK( mpWindowImpl->mpFrameWindow, Window, ImplGenerateMouseMoveHdl ) );
3829cdf0e10cSrcweir }
3830cdf0e10cSrcweir 
3831cdf0e10cSrcweir // -----------------------------------------------------------------------
3832cdf0e10cSrcweir 
3833cdf0e10cSrcweir IMPL_LINK( Window, ImplGenerateMouseMoveHdl, void*, EMPTYARG )
3834cdf0e10cSrcweir {
3835cdf0e10cSrcweir     mpWindowImpl->mpFrameData->mnMouseMoveId = 0;
3836cdf0e10cSrcweir     Window* pCaptureWin = ImplGetSVData()->maWinData.mpCaptureWin;
3837cdf0e10cSrcweir     if( ! pCaptureWin ||
3838cdf0e10cSrcweir         (pCaptureWin->mpWindowImpl && pCaptureWin->mpWindowImpl->mpFrame == mpWindowImpl->mpFrame)
3839cdf0e10cSrcweir     )
3840cdf0e10cSrcweir     {
3841cdf0e10cSrcweir         ImplCallMouseMove( mpWindowImpl->mpFrameData->mnMouseCode );
3842cdf0e10cSrcweir     }
3843cdf0e10cSrcweir     return 0;
3844cdf0e10cSrcweir }
3845cdf0e10cSrcweir 
3846cdf0e10cSrcweir // -----------------------------------------------------------------------
3847cdf0e10cSrcweir 
3848cdf0e10cSrcweir void Window::ImplInvertFocus( const Rectangle& rRect )
3849cdf0e10cSrcweir {
3850cdf0e10cSrcweir     InvertTracking( rRect, SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
3851cdf0e10cSrcweir }
3852cdf0e10cSrcweir 
3853cdf0e10cSrcweir // -----------------------------------------------------------------------
3854cdf0e10cSrcweir 
3855cdf0e10cSrcweir void Window::ImplCallFocusChangeActivate( Window* pNewOverlapWindow,
3856cdf0e10cSrcweir                                           Window* pOldOverlapWindow )
3857cdf0e10cSrcweir {
3858cdf0e10cSrcweir     ImplSVData* pSVData = ImplGetSVData();
3859cdf0e10cSrcweir     Window*     pNewRealWindow;
3860cdf0e10cSrcweir     Window*     pOldRealWindow;
3861cdf0e10cSrcweir     Window*     pLastRealWindow;
3862cdf0e10cSrcweir     sal_Bool        bCallActivate = sal_True;
3863cdf0e10cSrcweir     sal_Bool        bCallDeactivate = sal_True;
3864cdf0e10cSrcweir 
3865cdf0e10cSrcweir     pOldRealWindow = pOldOverlapWindow->ImplGetWindow();
3866cdf0e10cSrcweir     pNewRealWindow = pNewOverlapWindow->ImplGetWindow();
3867cdf0e10cSrcweir     if ( (pOldRealWindow->GetType() != WINDOW_FLOATINGWINDOW) ||
3868cdf0e10cSrcweir          pOldRealWindow->GetActivateMode() )
3869cdf0e10cSrcweir     {
3870cdf0e10cSrcweir         if ( (pNewRealWindow->GetType() == WINDOW_FLOATINGWINDOW) &&
3871cdf0e10cSrcweir              !pNewRealWindow->GetActivateMode() )
3872cdf0e10cSrcweir         {
3873cdf0e10cSrcweir             pSVData->maWinData.mpLastDeacWin = pOldOverlapWindow;
3874cdf0e10cSrcweir             bCallDeactivate = sal_False;
3875cdf0e10cSrcweir         }
3876cdf0e10cSrcweir     }
3877cdf0e10cSrcweir     else if ( (pNewRealWindow->GetType() != WINDOW_FLOATINGWINDOW) ||
3878cdf0e10cSrcweir               pNewRealWindow->GetActivateMode() )
3879cdf0e10cSrcweir     {
3880cdf0e10cSrcweir         if ( pSVData->maWinData.mpLastDeacWin )
3881cdf0e10cSrcweir         {
3882cdf0e10cSrcweir             if ( pSVData->maWinData.mpLastDeacWin == pNewOverlapWindow )
3883cdf0e10cSrcweir                 bCallActivate = sal_False;
3884cdf0e10cSrcweir             else
3885cdf0e10cSrcweir             {
3886cdf0e10cSrcweir                 pLastRealWindow = pSVData->maWinData.mpLastDeacWin->ImplGetWindow();
3887cdf0e10cSrcweir                 pSVData->maWinData.mpLastDeacWin->mpWindowImpl->mbActive = sal_False;
3888cdf0e10cSrcweir                 pSVData->maWinData.mpLastDeacWin->Deactivate();
3889cdf0e10cSrcweir                 if ( pLastRealWindow != pSVData->maWinData.mpLastDeacWin )
3890cdf0e10cSrcweir                 {
3891cdf0e10cSrcweir                     pLastRealWindow->mpWindowImpl->mbActive = sal_True;
3892cdf0e10cSrcweir                     pLastRealWindow->Activate();
3893cdf0e10cSrcweir                 }
3894cdf0e10cSrcweir             }
3895cdf0e10cSrcweir             pSVData->maWinData.mpLastDeacWin = NULL;
3896cdf0e10cSrcweir         }
3897cdf0e10cSrcweir     }
3898cdf0e10cSrcweir 
3899cdf0e10cSrcweir     if ( bCallDeactivate )
3900cdf0e10cSrcweir     {
3901cdf0e10cSrcweir         if( pOldOverlapWindow->mpWindowImpl->mbActive )
3902cdf0e10cSrcweir         {
3903cdf0e10cSrcweir             pOldOverlapWindow->mpWindowImpl->mbActive = sal_False;
3904cdf0e10cSrcweir             pOldOverlapWindow->Deactivate();
3905cdf0e10cSrcweir         }
3906cdf0e10cSrcweir         if ( pOldRealWindow != pOldOverlapWindow )
3907cdf0e10cSrcweir         {
3908cdf0e10cSrcweir             if( pOldRealWindow->mpWindowImpl->mbActive )
3909cdf0e10cSrcweir             {
3910cdf0e10cSrcweir                 pOldRealWindow->mpWindowImpl->mbActive = sal_False;
3911cdf0e10cSrcweir                 pOldRealWindow->Deactivate();
3912cdf0e10cSrcweir             }
3913cdf0e10cSrcweir         }
3914cdf0e10cSrcweir     }
3915cdf0e10cSrcweir     if ( bCallActivate && ! pNewOverlapWindow->mpWindowImpl->mbActive )
3916cdf0e10cSrcweir     {
3917cdf0e10cSrcweir         if( ! pNewOverlapWindow->mpWindowImpl->mbActive )
3918cdf0e10cSrcweir         {
3919cdf0e10cSrcweir             pNewOverlapWindow->mpWindowImpl->mbActive = sal_True;
3920cdf0e10cSrcweir             pNewOverlapWindow->Activate();
3921cdf0e10cSrcweir         }
3922cdf0e10cSrcweir         if ( pNewRealWindow != pNewOverlapWindow )
3923cdf0e10cSrcweir         {
3924cdf0e10cSrcweir             if( ! pNewRealWindow->mpWindowImpl->mbActive )
3925cdf0e10cSrcweir             {
3926cdf0e10cSrcweir                 pNewRealWindow->mpWindowImpl->mbActive = sal_True;
3927cdf0e10cSrcweir                 pNewRealWindow->Activate();
3928cdf0e10cSrcweir             }
3929cdf0e10cSrcweir         }
3930cdf0e10cSrcweir     }
3931cdf0e10cSrcweir }
3932cdf0e10cSrcweir 
3933cdf0e10cSrcweir static bool IsWindowFocused(const WindowImpl& rWinImpl)
3934cdf0e10cSrcweir {
3935cdf0e10cSrcweir     if (rWinImpl.mpSysObj)
3936cdf0e10cSrcweir         return true;
3937cdf0e10cSrcweir 
3938cdf0e10cSrcweir     if (rWinImpl.mpFrameData->mbHasFocus)
3939cdf0e10cSrcweir         return true;
3940cdf0e10cSrcweir 
3941cdf0e10cSrcweir     if (rWinImpl.mbFakeFocusSet)
3942cdf0e10cSrcweir         return true;
3943cdf0e10cSrcweir 
3944cdf0e10cSrcweir     return false;
3945cdf0e10cSrcweir }
3946cdf0e10cSrcweir 
3947cdf0e10cSrcweir // -----------------------------------------------------------------------
3948cdf0e10cSrcweir void Window::ImplGrabFocus( sal_uInt16 nFlags )
3949cdf0e10cSrcweir {
3950cdf0e10cSrcweir     // #143570# no focus for destructing windows
3951cdf0e10cSrcweir     if( mpWindowImpl->mbInDtor )
3952cdf0e10cSrcweir         return;
3953cdf0e10cSrcweir 
3954cdf0e10cSrcweir     // some event listeners do really bad stuff
3955cdf0e10cSrcweir     // => prepare for the worst
3956cdf0e10cSrcweir     ImplDelData aDogTag( this );
3957cdf0e10cSrcweir 
3958cdf0e10cSrcweir     // Currently the client window should always get the focus
3959cdf0e10cSrcweir     // Should the border window at some point be focusable
3960cdf0e10cSrcweir     // we need to change all GrabFocus() instances in VCL,
3961cdf0e10cSrcweir     // e.g. in ToTop()
3962cdf0e10cSrcweir 
3963cdf0e10cSrcweir     if ( mpWindowImpl->mpClientWindow )
3964cdf0e10cSrcweir     {
3965cdf0e10cSrcweir         // For a lack of design we need a little hack here to
3966cdf0e10cSrcweir         // ensure that dialogs on close pass the focus back to
3967cdf0e10cSrcweir         // the correct window
3968cdf0e10cSrcweir         if ( mpWindowImpl->mpLastFocusWindow && (mpWindowImpl->mpLastFocusWindow != this) &&
3969cdf0e10cSrcweir              !(mpWindowImpl->mnDlgCtrlFlags & WINDOW_DLGCTRL_WANTFOCUS) &&
3970cdf0e10cSrcweir              mpWindowImpl->mpLastFocusWindow->IsEnabled() &&
3971cdf0e10cSrcweir              mpWindowImpl->mpLastFocusWindow->IsInputEnabled() &&
3972cdf0e10cSrcweir              ! mpWindowImpl->mpLastFocusWindow->IsInModalMode()
3973cdf0e10cSrcweir              )
3974cdf0e10cSrcweir             mpWindowImpl->mpLastFocusWindow->GrabFocus();
3975cdf0e10cSrcweir         else
3976cdf0e10cSrcweir             mpWindowImpl->mpClientWindow->GrabFocus();
3977cdf0e10cSrcweir         return;
3978cdf0e10cSrcweir     }
3979cdf0e10cSrcweir     else if ( mpWindowImpl->mbFrame )
3980cdf0e10cSrcweir     {
3981cdf0e10cSrcweir         // For a lack of design we need a little hack here to
3982cdf0e10cSrcweir         // ensure that dialogs on close pass the focus back to
3983cdf0e10cSrcweir         // the correct window
3984cdf0e10cSrcweir         if ( mpWindowImpl->mpLastFocusWindow && (mpWindowImpl->mpLastFocusWindow != this) &&
3985cdf0e10cSrcweir              !(mpWindowImpl->mnDlgCtrlFlags & WINDOW_DLGCTRL_WANTFOCUS) &&
3986cdf0e10cSrcweir              mpWindowImpl->mpLastFocusWindow->IsEnabled() &&
3987cdf0e10cSrcweir              mpWindowImpl->mpLastFocusWindow->IsInputEnabled() &&
3988cdf0e10cSrcweir              ! mpWindowImpl->mpLastFocusWindow->IsInModalMode()
3989cdf0e10cSrcweir              )
3990cdf0e10cSrcweir         {
3991cdf0e10cSrcweir             mpWindowImpl->mpLastFocusWindow->GrabFocus();
3992cdf0e10cSrcweir             return;
3993cdf0e10cSrcweir         }
3994cdf0e10cSrcweir     }
3995cdf0e10cSrcweir 
3996cdf0e10cSrcweir     // If the Window is disabled, then we don't change the focus
3997cdf0e10cSrcweir     if ( !IsEnabled() || !IsInputEnabled() || IsInModalMode() )
3998cdf0e10cSrcweir         return;
3999cdf0e10cSrcweir 
4000cdf0e10cSrcweir     // we only need to set the focus if it is not already set
4001cdf0e10cSrcweir     // note: if some other frame is waiting for an asynchrounous focus event
4002cdf0e10cSrcweir     // we also have to post an asynchronous focus event for this frame
4003cdf0e10cSrcweir     // which is done using ToTop
4004cdf0e10cSrcweir     ImplSVData* pSVData = ImplGetSVData();
4005cdf0e10cSrcweir 
4006cdf0e10cSrcweir     sal_Bool bAsyncFocusWaiting = sal_False;
4007cdf0e10cSrcweir     Window *pFrame = pSVData->maWinData.mpFirstFrame;
4008cdf0e10cSrcweir     while( pFrame  )
4009cdf0e10cSrcweir     {
4010cdf0e10cSrcweir         if( pFrame != mpWindowImpl->mpFrameWindow && pFrame->mpWindowImpl->mpFrameData->mnFocusId )
4011cdf0e10cSrcweir         {
4012cdf0e10cSrcweir             bAsyncFocusWaiting = sal_True;
4013cdf0e10cSrcweir             break;
4014cdf0e10cSrcweir         }
4015cdf0e10cSrcweir         pFrame = pFrame->mpWindowImpl->mpFrameData->mpNextFrame;
4016cdf0e10cSrcweir     }
4017cdf0e10cSrcweir 
4018cdf0e10cSrcweir     bool bHasFocus = IsWindowFocused(*mpWindowImpl);
4019cdf0e10cSrcweir 
4020cdf0e10cSrcweir     sal_Bool bMustNotGrabFocus = sal_False;
4021cdf0e10cSrcweir     // #100242#, check parent hierarchy if some floater prohibits grab focus
4022cdf0e10cSrcweir 
4023cdf0e10cSrcweir     Window *pParent = this;
4024cdf0e10cSrcweir     while( pParent )
4025cdf0e10cSrcweir     {
4026cdf0e10cSrcweir         // #102158#, ignore grabfocus only if the floating parent grabs keyboard focus by itself (GrabsFocus())
4027cdf0e10cSrcweir         // otherwise we cannot set the focus in a floating toolbox
4028cdf0e10cSrcweir         if( ( (pParent->mpWindowImpl->mbFloatWin && ((FloatingWindow*)pParent)->GrabsFocus()) || ( pParent->GetStyle() & WB_SYSTEMFLOATWIN ) ) && !( pParent->GetStyle() & WB_MOVEABLE ) )
4029cdf0e10cSrcweir         {
4030cdf0e10cSrcweir             bMustNotGrabFocus = sal_True;
4031cdf0e10cSrcweir             break;
4032cdf0e10cSrcweir         }
4033cdf0e10cSrcweir         pParent = pParent->mpWindowImpl->mpParent;
4034cdf0e10cSrcweir     }
4035cdf0e10cSrcweir 
4036cdf0e10cSrcweir 
4037cdf0e10cSrcweir     if ( ( pSVData->maWinData.mpFocusWin != this && ! mpWindowImpl->mbInDtor ) || ( bAsyncFocusWaiting && !bHasFocus && !bMustNotGrabFocus ) )
4038cdf0e10cSrcweir     {
4039cdf0e10cSrcweir         // EndExtTextInput if it is not the same window
4040cdf0e10cSrcweir         if ( pSVData->maWinData.mpExtTextInputWin &&
4041cdf0e10cSrcweir              (pSVData->maWinData.mpExtTextInputWin != this) )
4042cdf0e10cSrcweir             pSVData->maWinData.mpExtTextInputWin->EndExtTextInput( EXTTEXTINPUT_END_COMPLETE );
4043cdf0e10cSrcweir 
4044cdf0e10cSrcweir         // Dieses Fenster als letztes FocusWindow merken
4045cdf0e10cSrcweir         Window* pOverlapWindow = ImplGetFirstOverlapWindow();
4046cdf0e10cSrcweir         pOverlapWindow->mpWindowImpl->mpLastFocusWindow = this;
4047cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mpFocusWin = this;
4048cdf0e10cSrcweir 
4049cdf0e10cSrcweir         if( !bHasFocus )
4050cdf0e10cSrcweir         {
4051cdf0e10cSrcweir             // menue windows never get the system focus
4052cdf0e10cSrcweir             // the application will keep the focus
4053cdf0e10cSrcweir             if( bMustNotGrabFocus )
4054cdf0e10cSrcweir                 return;
4055cdf0e10cSrcweir             else
4056cdf0e10cSrcweir             {
4057cdf0e10cSrcweir                 // Hier setzen wir schon den Focus um, da ToTop() den Focus
4058cdf0e10cSrcweir                 // nicht auf ein anderes Fenster setzen darf
4059cdf0e10cSrcweir                 //DBG_WARNING( "Window::GrabFocus() - Frame doesn't have the focus" );
4060cdf0e10cSrcweir 				mpWindowImpl->mpFrame->ToTop( SAL_FRAME_TOTOP_GRABFOCUS | SAL_FRAME_TOTOP_GRABFOCUS_ONLY );
4061cdf0e10cSrcweir                 return;
4062cdf0e10cSrcweir             }
4063cdf0e10cSrcweir         }
4064cdf0e10cSrcweir 
4065cdf0e10cSrcweir         Window* pOldFocusWindow = pSVData->maWinData.mpFocusWin;
4066cdf0e10cSrcweir         ImplDelData aOldFocusDel( pOldFocusWindow );
4067cdf0e10cSrcweir 
4068cdf0e10cSrcweir         pSVData->maWinData.mpFocusWin = this;
4069cdf0e10cSrcweir 
4070cdf0e10cSrcweir         if ( pOldFocusWindow )
4071cdf0e10cSrcweir         {
4072cdf0e10cSrcweir             // Cursor hiden
4073cdf0e10cSrcweir             if ( pOldFocusWindow->mpWindowImpl->mpCursor )
4074cdf0e10cSrcweir                 pOldFocusWindow->mpWindowImpl->mpCursor->ImplHide( true );
4075cdf0e10cSrcweir         }
4076cdf0e10cSrcweir 
4077cdf0e10cSrcweir         // !!!!! Wegen altem SV-Office Activate/Deavtivate Handling
4078cdf0e10cSrcweir         // !!!!! erstmal so wie frueher
4079cdf0e10cSrcweir         if ( pOldFocusWindow )
4080cdf0e10cSrcweir         {
4081cdf0e10cSrcweir             // Focus merken
4082cdf0e10cSrcweir             Window* pOldOverlapWindow = pOldFocusWindow->ImplGetFirstOverlapWindow();
4083cdf0e10cSrcweir             Window* pNewOverlapWindow = ImplGetFirstOverlapWindow();
4084cdf0e10cSrcweir             if ( pOldOverlapWindow != pNewOverlapWindow )
4085cdf0e10cSrcweir                 ImplCallFocusChangeActivate( pNewOverlapWindow, pOldOverlapWindow );
4086cdf0e10cSrcweir         }
4087cdf0e10cSrcweir         else
4088cdf0e10cSrcweir         {
4089cdf0e10cSrcweir             Window* pNewOverlapWindow = ImplGetFirstOverlapWindow();
4090cdf0e10cSrcweir             Window* pNewRealWindow = pNewOverlapWindow->ImplGetWindow();
4091cdf0e10cSrcweir             pNewOverlapWindow->mpWindowImpl->mbActive = sal_True;
4092cdf0e10cSrcweir             pNewOverlapWindow->Activate();
4093cdf0e10cSrcweir             if ( pNewRealWindow != pNewOverlapWindow )
4094cdf0e10cSrcweir             {
4095cdf0e10cSrcweir                 pNewRealWindow->mpWindowImpl->mbActive = sal_True;
4096cdf0e10cSrcweir                 pNewRealWindow->Activate();
4097cdf0e10cSrcweir             }
4098cdf0e10cSrcweir         }
4099cdf0e10cSrcweir /*
4100cdf0e10cSrcweir         // call Deactivate and Activate
4101cdf0e10cSrcweir         Window* pDeactivateParent;
4102cdf0e10cSrcweir         Window* pActivateParent;
4103cdf0e10cSrcweir         Window* pParent;
4104cdf0e10cSrcweir         Window* pLastParent;
4105cdf0e10cSrcweir         pDeactivateParent = pOldFocusWindow;
4106cdf0e10cSrcweir         while ( pDeactivateParent )
4107cdf0e10cSrcweir         {
4108cdf0e10cSrcweir             pParent = pDeactivateParent;
4109cdf0e10cSrcweir             if ( pParent->ImplIsChild( this ) )
4110cdf0e10cSrcweir                 break;
4111cdf0e10cSrcweir 
4112cdf0e10cSrcweir             if ( pDeactivateParent->ImplIsOverlapWindow() )
4113cdf0e10cSrcweir             {
4114cdf0e10cSrcweir                 if ( !pDeactivateParent->mpWindowImpl->mbParentActive )
4115cdf0e10cSrcweir                     break;
4116cdf0e10cSrcweir             }
4117cdf0e10cSrcweir 
4118cdf0e10cSrcweir             pDeactivateParent = pDeactivateParent->ImplGetParent();
4119cdf0e10cSrcweir         }
4120cdf0e10cSrcweir         if ( pOldFocusWindow )
4121cdf0e10cSrcweir         {
4122cdf0e10cSrcweir             pActivateParent = this;
4123cdf0e10cSrcweir             while ( pActivateParent )
4124cdf0e10cSrcweir             {
4125cdf0e10cSrcweir                 pParent = pActivateParent;
4126cdf0e10cSrcweir                 if ( pParent->ImplIsChild( pOldFocusWindow ) )
4127cdf0e10cSrcweir                     break;
4128cdf0e10cSrcweir 
4129cdf0e10cSrcweir                 if ( pActivateParent->ImplIsOverlapWindow() )
4130cdf0e10cSrcweir                 {
4131cdf0e10cSrcweir                     if ( !pActivateParent->mpWindowImpl->mbParentActive )
4132cdf0e10cSrcweir                         break;
4133cdf0e10cSrcweir                 }
4134cdf0e10cSrcweir 
4135cdf0e10cSrcweir                 pActivateParent = pActivateParent->ImplGetParent();
4136cdf0e10cSrcweir             }
4137cdf0e10cSrcweir         }
4138cdf0e10cSrcweir         else
4139cdf0e10cSrcweir         {
4140cdf0e10cSrcweir             if ( ImplIsOverlapWindow() )
4141cdf0e10cSrcweir                 pActivateParent = this;
4142cdf0e10cSrcweir             else
4143cdf0e10cSrcweir                 pActivateParent = mpWindowImpl->mpOverlapWindow;
4144cdf0e10cSrcweir             while ( pActivateParent )
4145cdf0e10cSrcweir             {
4146cdf0e10cSrcweir                 if ( pActivateParent->ImplIsOverlapWindow() )
4147cdf0e10cSrcweir                 {
4148cdf0e10cSrcweir                     if ( !pActivateParent->mpWindowImpl->mbParentActive )
4149cdf0e10cSrcweir                         break;
4150cdf0e10cSrcweir                 }
4151cdf0e10cSrcweir 
4152cdf0e10cSrcweir                 pActivateParent = pActivateParent->ImplGetParent();
4153cdf0e10cSrcweir             }
4154cdf0e10cSrcweir         }
4155cdf0e10cSrcweir         if ( pDeactivateParent )
4156cdf0e10cSrcweir         {
4157cdf0e10cSrcweir             do
4158cdf0e10cSrcweir             {
4159cdf0e10cSrcweir                 pLastParent = pOldFocusWindow;
4160cdf0e10cSrcweir                 if ( pLastParent != pDeactivateParent )
4161cdf0e10cSrcweir                 {
4162cdf0e10cSrcweir                     pParent = pLastParent->ImplGetParent();
4163cdf0e10cSrcweir                     while ( pParent )
4164cdf0e10cSrcweir                     {
4165cdf0e10cSrcweir                         if ( pParent == pDeactivateParent )
4166cdf0e10cSrcweir                             break;
4167cdf0e10cSrcweir                         pLastParent = pParent;
4168cdf0e10cSrcweir                         pParent = pParent->ImplGetParent();
4169cdf0e10cSrcweir                     }
4170cdf0e10cSrcweir                 }
4171cdf0e10cSrcweir                 else
4172cdf0e10cSrcweir                     pParent = pLastParent;
4173cdf0e10cSrcweir 
4174cdf0e10cSrcweir                 pParent->mpWindowImpl->mbActive = sal_False;
4175cdf0e10cSrcweir                 pParent->Deactivate();
4176cdf0e10cSrcweir                 pDeactivateParent = pLastParent;
4177cdf0e10cSrcweir             }
4178cdf0e10cSrcweir             while ( pDeactivateParent != pOldFocusWindow );
4179cdf0e10cSrcweir         }
4180cdf0e10cSrcweir         do
4181cdf0e10cSrcweir         {
4182cdf0e10cSrcweir             pLastParent = this;
4183cdf0e10cSrcweir             if ( pLastParent != pActivateParent )
4184cdf0e10cSrcweir             {
4185cdf0e10cSrcweir                 pParent = pLastParent->ImplGetParent();
4186cdf0e10cSrcweir                 while ( pParent )
4187cdf0e10cSrcweir                 {
4188cdf0e10cSrcweir                     if ( pParent == pActivateParent )
4189cdf0e10cSrcweir                         break;
4190cdf0e10cSrcweir                     pLastParent = pParent;
4191cdf0e10cSrcweir                     pParent = pParent->ImplGetParent();
4192cdf0e10cSrcweir                 }
4193cdf0e10cSrcweir             }
4194cdf0e10cSrcweir             else
4195cdf0e10cSrcweir                 pParent = pLastParent;
4196cdf0e10cSrcweir 
4197cdf0e10cSrcweir             pParent->mpWindowImpl->mbActive = sal_True;
4198cdf0e10cSrcweir             pParent->Activate();
4199cdf0e10cSrcweir             pActivateParent = pLastParent;
4200cdf0e10cSrcweir         }
4201cdf0e10cSrcweir         while ( pActivateParent != this );
4202cdf0e10cSrcweir */
4203cdf0e10cSrcweir         // call Get- and LoseFocus
4204cdf0e10cSrcweir         if ( pOldFocusWindow && ! aOldFocusDel.IsDelete() )
4205cdf0e10cSrcweir         {
4206cdf0e10cSrcweir             if ( pOldFocusWindow->IsTracking() &&
4207cdf0e10cSrcweir                  (pSVData->maWinData.mnTrackFlags & STARTTRACK_FOCUSCANCEL) )
4208cdf0e10cSrcweir                 pOldFocusWindow->EndTracking( ENDTRACK_CANCEL | ENDTRACK_FOCUS );
4209cdf0e10cSrcweir             NotifyEvent aNEvt( EVENT_LOSEFOCUS, pOldFocusWindow );
4210cdf0e10cSrcweir             if ( !ImplCallPreNotify( aNEvt ) )
4211cdf0e10cSrcweir                 pOldFocusWindow->LoseFocus();
4212cdf0e10cSrcweir             pOldFocusWindow->ImplCallDeactivateListeners( this );
4213cdf0e10cSrcweir         }
4214cdf0e10cSrcweir 
4215cdf0e10cSrcweir         if ( pSVData->maWinData.mpFocusWin == this )
4216cdf0e10cSrcweir         {
4217cdf0e10cSrcweir             if ( mpWindowImpl->mpSysObj )
4218cdf0e10cSrcweir             {
4219cdf0e10cSrcweir                 mpWindowImpl->mpFrameData->mpFocusWin = this;
4220cdf0e10cSrcweir                 if ( !mpWindowImpl->mpFrameData->mbInSysObjFocusHdl )
4221cdf0e10cSrcweir                     mpWindowImpl->mpSysObj->GrabFocus();
4222cdf0e10cSrcweir             }
4223cdf0e10cSrcweir 
4224cdf0e10cSrcweir             if ( pSVData->maWinData.mpFocusWin == this )
4225cdf0e10cSrcweir             {
4226cdf0e10cSrcweir                 if ( mpWindowImpl->mpCursor )
4227cdf0e10cSrcweir                     mpWindowImpl->mpCursor->ImplShow();
4228cdf0e10cSrcweir                 mpWindowImpl->mbInFocusHdl = sal_True;
4229cdf0e10cSrcweir                 mpWindowImpl->mnGetFocusFlags = nFlags;
4230cdf0e10cSrcweir                 // if we're changing focus due to closing a popup floating window
4231cdf0e10cSrcweir                 // notify the new focus window so it can restore the inner focus
4232cdf0e10cSrcweir                 // eg, toolboxes can select their recent active item
4233cdf0e10cSrcweir                 if( pOldFocusWindow &&
4234cdf0e10cSrcweir                     ! aOldFocusDel.IsDelete() &&
4235cdf0e10cSrcweir                     ( pOldFocusWindow->GetDialogControlFlags() & WINDOW_DLGCTRL_FLOATWIN_POPUPMODEEND_CANCEL ) )
4236cdf0e10cSrcweir                     mpWindowImpl->mnGetFocusFlags |= GETFOCUS_FLOATWIN_POPUPMODEEND_CANCEL;
4237cdf0e10cSrcweir                 NotifyEvent aNEvt( EVENT_GETFOCUS, this );
4238cdf0e10cSrcweir                 if ( !ImplCallPreNotify( aNEvt ) && !aDogTag.IsDelete() )
4239cdf0e10cSrcweir                     GetFocus();
4240cdf0e10cSrcweir                 if( !aDogTag.IsDelete() )
4241cdf0e10cSrcweir                     ImplCallActivateListeners( (pOldFocusWindow && ! aOldFocusDel.IsDelete()) ? pOldFocusWindow : NULL );
4242cdf0e10cSrcweir                 if( !aDogTag.IsDelete() )
4243cdf0e10cSrcweir                 {
4244cdf0e10cSrcweir                     mpWindowImpl->mnGetFocusFlags = 0;
4245cdf0e10cSrcweir                     mpWindowImpl->mbInFocusHdl = sal_False;
4246cdf0e10cSrcweir                 }
4247cdf0e10cSrcweir             }
4248cdf0e10cSrcweir         }
4249cdf0e10cSrcweir 
4250cdf0e10cSrcweir         GetpApp()->FocusChanged();
4251cdf0e10cSrcweir         ImplNewInputContext();
4252cdf0e10cSrcweir     }
4253cdf0e10cSrcweir }
4254cdf0e10cSrcweir 
4255cdf0e10cSrcweir // -----------------------------------------------------------------------
4256cdf0e10cSrcweir 
4257cdf0e10cSrcweir void Window::ImplNewInputContext()
4258cdf0e10cSrcweir {
4259cdf0e10cSrcweir     ImplSVData* pSVData = ImplGetSVData();
4260cdf0e10cSrcweir     Window*     pFocusWin = pSVData->maWinData.mpFocusWin;
4261cdf0e10cSrcweir     if ( !pFocusWin )
4262cdf0e10cSrcweir         return;
4263cdf0e10cSrcweir 
4264cdf0e10cSrcweir     // Is InputContext changed?
4265cdf0e10cSrcweir     const InputContext& rInputContext = pFocusWin->GetInputContext();
4266cdf0e10cSrcweir     if ( rInputContext == pFocusWin->mpWindowImpl->mpFrameData->maOldInputContext )
4267cdf0e10cSrcweir         return;
4268cdf0e10cSrcweir 
4269cdf0e10cSrcweir     pFocusWin->mpWindowImpl->mpFrameData->maOldInputContext = rInputContext;
4270cdf0e10cSrcweir 
4271cdf0e10cSrcweir     SalInputContext         aNewContext;
4272cdf0e10cSrcweir     const Font&             rFont = rInputContext.GetFont();
4273cdf0e10cSrcweir     const XubString&        rFontName = rFont.GetName();
4274cdf0e10cSrcweir     ImplFontEntry*          pFontEntry = NULL;
4275cdf0e10cSrcweir     aNewContext.mpFont = NULL;
4276cdf0e10cSrcweir     if ( rFontName.Len() )
4277cdf0e10cSrcweir     {
4278cdf0e10cSrcweir         Size aSize = pFocusWin->ImplLogicToDevicePixel( rFont.GetSize() );
4279cdf0e10cSrcweir         if ( !aSize.Height() )
4280cdf0e10cSrcweir         {
4281cdf0e10cSrcweir             // Nur dann Defaultgroesse setzen, wenn Fonthoehe auch in logischen
4282cdf0e10cSrcweir             // Koordinaaten 0 ist
4283cdf0e10cSrcweir             if ( rFont.GetSize().Height() )
4284cdf0e10cSrcweir                 aSize.Height() = 1;
4285cdf0e10cSrcweir             else
4286cdf0e10cSrcweir                 aSize.Height() = (12*pFocusWin->mnDPIY)/72;
4287cdf0e10cSrcweir         }
4288cdf0e10cSrcweir         // TODO: No display device uses ImplDirectFontSubstitution thingy, right? => remove it
4289cdf0e10cSrcweir         ImplDirectFontSubstitution* pFontSubst = NULL;
4290cdf0e10cSrcweir         //if( pFocusWin->mpOutDevData )
4291cdf0e10cSrcweir         //    pFontSubst = &pFocusWin->mpOutDevData->maDevFontSubst;
4292cdf0e10cSrcweir         pFontEntry = pFocusWin->mpFontCache->GetFontEntry( pFocusWin->mpFontList,
4293cdf0e10cSrcweir                          rFont, aSize, static_cast<float>(aSize.Height()), pFontSubst );
4294cdf0e10cSrcweir         if ( pFontEntry )
4295cdf0e10cSrcweir             aNewContext.mpFont = &pFontEntry->maFontSelData;
4296cdf0e10cSrcweir     }
4297cdf0e10cSrcweir     aNewContext.meLanguage  = rFont.GetLanguage();
4298cdf0e10cSrcweir     aNewContext.mnOptions   = rInputContext.GetOptions();
4299cdf0e10cSrcweir     pFocusWin->ImplGetFrame()->SetInputContext( &aNewContext );
4300cdf0e10cSrcweir 
4301cdf0e10cSrcweir     if ( pFontEntry )
4302cdf0e10cSrcweir         pFocusWin->mpFontCache->Release( pFontEntry );
4303cdf0e10cSrcweir }
4304cdf0e10cSrcweir 
4305cdf0e10cSrcweir // -----------------------------------------------------------------------
4306cdf0e10cSrcweir 
4307cdf0e10cSrcweir Window::Window( WindowType nType )
4308cdf0e10cSrcweir {
4309cdf0e10cSrcweir     DBG_CTOR( Window, ImplDbgCheckWindow );
4310cdf0e10cSrcweir 
4311cdf0e10cSrcweir     ImplInitWindowData( nType );
4312cdf0e10cSrcweir }
4313cdf0e10cSrcweir 
4314cdf0e10cSrcweir // -----------------------------------------------------------------------
4315cdf0e10cSrcweir 
4316cdf0e10cSrcweir Window::Window( Window* pParent, WinBits nStyle )
4317cdf0e10cSrcweir {
4318cdf0e10cSrcweir     DBG_CTOR( Window, ImplDbgCheckWindow );
4319cdf0e10cSrcweir 
4320cdf0e10cSrcweir     ImplInitWindowData( WINDOW_WINDOW );
4321cdf0e10cSrcweir     ImplInit( pParent, nStyle, NULL );
4322cdf0e10cSrcweir }
4323cdf0e10cSrcweir 
4324cdf0e10cSrcweir // -----------------------------------------------------------------------
4325cdf0e10cSrcweir 
4326cdf0e10cSrcweir Window::Window( Window* pParent, const ResId& rResId )
4327cdf0e10cSrcweir {
4328cdf0e10cSrcweir     DBG_CTOR( Window, ImplDbgCheckWindow );
4329cdf0e10cSrcweir 
4330cdf0e10cSrcweir     ImplInitWindowData( WINDOW_WINDOW );
4331cdf0e10cSrcweir     rResId.SetRT( RSC_WINDOW );
4332cdf0e10cSrcweir     WinBits nStyle = ImplInitRes( rResId );
4333cdf0e10cSrcweir     ImplInit( pParent, nStyle, NULL );
4334cdf0e10cSrcweir     ImplLoadRes( rResId );
4335cdf0e10cSrcweir 
4336cdf0e10cSrcweir     if ( !(nStyle & WB_HIDE) )
4337cdf0e10cSrcweir         Show();
4338cdf0e10cSrcweir }
4339cdf0e10cSrcweir 
4340cdf0e10cSrcweir // -----------------------------------------------------------------------
4341cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
4342cdf0e10cSrcweir namespace
4343cdf0e10cSrcweir {
4344cdf0e10cSrcweir     void lcl_appendWindowInfo( ByteString& io_rErrorString, const Window& i_rWindow )
4345cdf0e10cSrcweir     {
4346cdf0e10cSrcweir         // skip border windows, they don't carry information which helps diagnosing the problem
4347cdf0e10cSrcweir         const Window* pWindow( &i_rWindow );
4348cdf0e10cSrcweir         while ( pWindow && ( pWindow->GetType() == WINDOW_BORDERWINDOW ) )
4349cdf0e10cSrcweir             pWindow = pWindow->GetWindow( WINDOW_FIRSTCHILD );
4350cdf0e10cSrcweir         if ( !pWindow )
4351cdf0e10cSrcweir             pWindow = &i_rWindow;
4352cdf0e10cSrcweir 
4353cdf0e10cSrcweir         io_rErrorString += char(13);
4354cdf0e10cSrcweir         io_rErrorString += typeid( *pWindow ).name();
4355cdf0e10cSrcweir         io_rErrorString += " (window text: '";
4356cdf0e10cSrcweir         io_rErrorString += ByteString( pWindow->GetText(), RTL_TEXTENCODING_UTF8 );
4357cdf0e10cSrcweir         io_rErrorString += "')";
4358cdf0e10cSrcweir     }
4359cdf0e10cSrcweir }
4360cdf0e10cSrcweir #endif
4361cdf0e10cSrcweir // -----------------------------------------------------------------------
4362cdf0e10cSrcweir 
4363cdf0e10cSrcweir Window::~Window()
4364cdf0e10cSrcweir {
4365cdf0e10cSrcweir     ImplFreeExtWindowImpl();
4366cdf0e10cSrcweir 
4367cdf0e10cSrcweir     vcl::LazyDeletor<Window>::Undelete( this );
4368cdf0e10cSrcweir 
4369cdf0e10cSrcweir     DBG_DTOR( Window, ImplDbgCheckWindow );
4370cdf0e10cSrcweir     DBG_ASSERT( !mpWindowImpl->mbInDtor, "~Window - already in DTOR!" );
4371cdf0e10cSrcweir 
4372cdf0e10cSrcweir 
4373cdf0e10cSrcweir     // remove Key and Mouse events issued by Application::PostKey/MouseEvent
4374cdf0e10cSrcweir     Application::RemoveMouseAndKeyEvents( this );
4375cdf0e10cSrcweir 
4376cdf0e10cSrcweir     // Dispose of the canvas implementation (which, currently, has an
4377cdf0e10cSrcweir     // own wrapper window as a child to this one.
4378cdf0e10cSrcweir     uno::Reference< rendering::XCanvas > xCanvas( mpWindowImpl->mxCanvas );
4379cdf0e10cSrcweir     if( xCanvas.is() )
4380cdf0e10cSrcweir     {
4381cdf0e10cSrcweir         uno::Reference < lang::XComponent > xCanvasComponent( xCanvas,
4382cdf0e10cSrcweir                                                               uno::UNO_QUERY );
4383cdf0e10cSrcweir         if( xCanvasComponent.is() )
4384cdf0e10cSrcweir             xCanvasComponent->dispose();
4385cdf0e10cSrcweir     }
4386cdf0e10cSrcweir 
4387cdf0e10cSrcweir     mpWindowImpl->mbInDtor = sal_True;
4388cdf0e10cSrcweir 
4389cdf0e10cSrcweir     ImplCallEventListeners( VCLEVENT_OBJECT_DYING );
4390cdf0e10cSrcweir 
4391cdf0e10cSrcweir     // do not send child events for frames that were registered as native frames
4392cdf0e10cSrcweir     if( !ImplIsAccessibleNativeFrame() && mpWindowImpl->mbReallyVisible )
4393cdf0e10cSrcweir         if ( ImplIsAccessibleCandidate() && GetAccessibleParentWindow() )
4394cdf0e10cSrcweir             GetAccessibleParentWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_CHILDDESTROYED, this );
4395cdf0e10cSrcweir 
4396cdf0e10cSrcweir     // remove associated data structures from dockingmanager
4397cdf0e10cSrcweir     ImplGetDockingManager()->RemoveWindow( this );
4398cdf0e10cSrcweir 
4399cdf0e10cSrcweir 
4400cdf0e10cSrcweir     // remove ownerdraw decorated windows from list in the top-most frame window
4401cdf0e10cSrcweir     if( (GetStyle() & WB_OWNERDRAWDECORATION) && mpWindowImpl->mbFrame )
4402cdf0e10cSrcweir     {
4403cdf0e10cSrcweir         ::std::vector< Window* >& rList = ImplGetOwnerDrawList();
4404cdf0e10cSrcweir 	    ::std::vector< Window* >::iterator p;
4405cdf0e10cSrcweir         p = ::std::find( rList.begin(), rList.end(), this );
4406cdf0e10cSrcweir         if( p != rList.end() )
4407cdf0e10cSrcweir 	        rList.erase( p );
4408cdf0e10cSrcweir     }
4409cdf0e10cSrcweir 
4410cdf0e10cSrcweir     // shutdown drag and drop
4411cdf0e10cSrcweir     ::com::sun::star::uno::Reference < ::com::sun::star::lang::XComponent > xDnDComponent( mpWindowImpl->mxDNDListenerContainer, ::com::sun::star::uno::UNO_QUERY );
4412cdf0e10cSrcweir 
4413cdf0e10cSrcweir     if( xDnDComponent.is() )
4414cdf0e10cSrcweir         xDnDComponent->dispose();
4415cdf0e10cSrcweir 
4416cdf0e10cSrcweir     if( mpWindowImpl->mbFrame && mpWindowImpl->mpFrameData )
4417cdf0e10cSrcweir     {
4418cdf0e10cSrcweir         try
4419cdf0e10cSrcweir         {
4420cdf0e10cSrcweir             // deregister drop target listener
4421cdf0e10cSrcweir             if( mpWindowImpl->mpFrameData->mxDropTargetListener.is() )
4422cdf0e10cSrcweir             {
4423cdf0e10cSrcweir                 uno::Reference< XDragGestureRecognizer > xDragGestureRecognizer =
4424cdf0e10cSrcweir                     uno::Reference< XDragGestureRecognizer > (mpWindowImpl->mpFrameData->mxDragSource, UNO_QUERY);
4425cdf0e10cSrcweir                 if( xDragGestureRecognizer.is() )
4426cdf0e10cSrcweir                 {
4427cdf0e10cSrcweir                     xDragGestureRecognizer->removeDragGestureListener(
4428cdf0e10cSrcweir                         uno::Reference< XDragGestureListener > (mpWindowImpl->mpFrameData->mxDropTargetListener, UNO_QUERY));
4429cdf0e10cSrcweir                 }
4430cdf0e10cSrcweir 
4431cdf0e10cSrcweir                 mpWindowImpl->mpFrameData->mxDropTarget->removeDropTargetListener( mpWindowImpl->mpFrameData->mxDropTargetListener );
4432cdf0e10cSrcweir                 mpWindowImpl->mpFrameData->mxDropTargetListener.clear();
4433cdf0e10cSrcweir             }
4434cdf0e10cSrcweir 
4435cdf0e10cSrcweir             // shutdown drag and drop for this frame window
4436cdf0e10cSrcweir             uno::Reference< XComponent > xComponent( mpWindowImpl->mpFrameData->mxDropTarget, UNO_QUERY );
4437cdf0e10cSrcweir 
4438cdf0e10cSrcweir             // DNDEventDispatcher does not hold a reference of the DropTarget,
4439cdf0e10cSrcweir             // so it's ok if it does not support XComponent
4440cdf0e10cSrcweir             if( xComponent.is() )
4441cdf0e10cSrcweir                 xComponent->dispose();
4442cdf0e10cSrcweir         }
4443cdf0e10cSrcweir 
4444adad3ae8SHerbert Dürr         catch ( Exception&)
4445cdf0e10cSrcweir         {
4446cdf0e10cSrcweir             // can be safely ignored here.
4447cdf0e10cSrcweir         }
4448cdf0e10cSrcweir     }
4449cdf0e10cSrcweir 
4450cdf0e10cSrcweir     UnoWrapperBase* pWrapper = Application::GetUnoWrapper( sal_False );
4451cdf0e10cSrcweir     if ( pWrapper )
4452cdf0e10cSrcweir         pWrapper->WindowDestroyed( this );
4453cdf0e10cSrcweir 
4454cdf0e10cSrcweir     // MT: Must be called after WindowDestroyed!
4455cdf0e10cSrcweir     // Otherwise, if the accessible is a VCLXWindow, it will try to destroy this window again!
4456cdf0e10cSrcweir     // But accessibility implementations from applications need this dispose.
4457cdf0e10cSrcweir     if ( mpWindowImpl->mxAccessible.is() )
4458cdf0e10cSrcweir     {
4459cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent> xC( mpWindowImpl->mxAccessible, ::com::sun::star::uno::UNO_QUERY );
4460cdf0e10cSrcweir         if ( xC.is() )
4461cdf0e10cSrcweir             xC->dispose();
4462cdf0e10cSrcweir     }
4463cdf0e10cSrcweir 
4464cdf0e10cSrcweir     ImplSVData* pSVData = ImplGetSVData();
4465cdf0e10cSrcweir 
4466cdf0e10cSrcweir     if ( pSVData->maHelpData.mpHelpWin && (pSVData->maHelpData.mpHelpWin->GetParent() == this) )
4467cdf0e10cSrcweir         ImplDestroyHelpWindow( true );
4468cdf0e10cSrcweir 
4469cdf0e10cSrcweir     DBG_ASSERT( pSVData->maWinData.mpTrackWin != this,
4470cdf0e10cSrcweir                 "Window::~Window(): Window is in TrackingMode" );
4471cdf0e10cSrcweir     DBG_ASSERT( pSVData->maWinData.mpCaptureWin != this,
4472cdf0e10cSrcweir                 "Window::~Window(): Window has the mouse captured" );
4473cdf0e10cSrcweir     // #103442# DefModalDialogParent is now determined on-the-fly, so this pointer is unimportant now
4474cdf0e10cSrcweir     //DBG_ASSERT( pSVData->maWinData.mpDefDialogParent != this,
4475cdf0e10cSrcweir     //            "Window::~Window(): Window is DefModalDialogParent" );
4476cdf0e10cSrcweir 
4477cdf0e10cSrcweir     // Wegen alter kompatibilitaet
4478cdf0e10cSrcweir     if ( pSVData->maWinData.mpTrackWin == this )
4479cdf0e10cSrcweir         EndTracking();
4480cdf0e10cSrcweir     if ( pSVData->maWinData.mpCaptureWin == this )
4481cdf0e10cSrcweir         ReleaseMouse();
4482cdf0e10cSrcweir     if ( pSVData->maWinData.mpDefDialogParent == this )
4483cdf0e10cSrcweir         pSVData->maWinData.mpDefDialogParent = NULL;
4484cdf0e10cSrcweir 
4485cdf0e10cSrcweir #ifdef DBG_UTIL
4486cdf0e10cSrcweir     if ( sal_True ) // always perform these tests in non-pro versions
4487cdf0e10cSrcweir     {
4488cdf0e10cSrcweir         ByteString  aErrorStr;
4489cdf0e10cSrcweir         sal_Bool        bError = sal_False;
4490cdf0e10cSrcweir         Window*     pTempWin = mpWindowImpl->mpFrameData->mpFirstOverlap;
4491cdf0e10cSrcweir         while ( pTempWin )
4492cdf0e10cSrcweir         {
4493cdf0e10cSrcweir             if ( ImplIsRealParentPath( pTempWin ) )
4494cdf0e10cSrcweir             {
4495cdf0e10cSrcweir                 bError = sal_True;
4496cdf0e10cSrcweir                 lcl_appendWindowInfo( aErrorStr, *pTempWin );
4497cdf0e10cSrcweir             }
4498cdf0e10cSrcweir             pTempWin = pTempWin->mpWindowImpl->mpNextOverlap;
4499cdf0e10cSrcweir         }
4500cdf0e10cSrcweir         if ( bError )
4501cdf0e10cSrcweir         {
4502cdf0e10cSrcweir             ByteString aTempStr( "Window (" );
4503cdf0e10cSrcweir             aTempStr += ByteString( GetText(), RTL_TEXTENCODING_UTF8 );
4504cdf0e10cSrcweir             aTempStr += ") with living SystemWindow(s) destroyed: ";
4505cdf0e10cSrcweir             aTempStr += aErrorStr;
4506cdf0e10cSrcweir             DBG_ERROR( aTempStr.GetBuffer() );
4507cdf0e10cSrcweir 		    GetpApp()->Abort( String( aTempStr, RTL_TEXTENCODING_UTF8 ) );   // abort in non-pro version, this must be fixed!
4508cdf0e10cSrcweir         }
4509cdf0e10cSrcweir 
4510cdf0e10cSrcweir         bError = sal_False;
4511cdf0e10cSrcweir         pTempWin = pSVData->maWinData.mpFirstFrame;
4512cdf0e10cSrcweir         while ( pTempWin )
4513cdf0e10cSrcweir         {
4514cdf0e10cSrcweir             if ( ImplIsRealParentPath( pTempWin ) )
4515cdf0e10cSrcweir             {
4516cdf0e10cSrcweir                 bError = sal_True;
4517cdf0e10cSrcweir                 lcl_appendWindowInfo( aErrorStr, *pTempWin );
4518cdf0e10cSrcweir             }
4519cdf0e10cSrcweir             pTempWin = pTempWin->mpWindowImpl->mpFrameData->mpNextFrame;
4520cdf0e10cSrcweir         }
4521cdf0e10cSrcweir         if ( bError )
4522cdf0e10cSrcweir         {
4523cdf0e10cSrcweir             ByteString aTempStr( "Window (" );
4524cdf0e10cSrcweir             aTempStr += ByteString( GetText(), RTL_TEXTENCODING_UTF8 );
4525cdf0e10cSrcweir             aTempStr += ") with living SystemWindow(s) destroyed: ";
4526cdf0e10cSrcweir             aTempStr += aErrorStr;
4527cdf0e10cSrcweir             DBG_ERROR( aTempStr.GetBuffer() );
4528cdf0e10cSrcweir 		    GetpApp()->Abort( String( aTempStr, RTL_TEXTENCODING_UTF8 ) );   // abort in non-pro version, this must be fixed!
4529cdf0e10cSrcweir         }
4530cdf0e10cSrcweir 
4531cdf0e10cSrcweir         if ( mpWindowImpl->mpFirstChild )
4532cdf0e10cSrcweir         {
4533cdf0e10cSrcweir             ByteString aTempStr( "Window (" );
4534cdf0e10cSrcweir             aTempStr += ByteString( GetText(), RTL_TEXTENCODING_UTF8 );
4535cdf0e10cSrcweir             aTempStr += ") with living Child(s) destroyed: ";
4536cdf0e10cSrcweir             pTempWin = mpWindowImpl->mpFirstChild;
4537cdf0e10cSrcweir             while ( pTempWin )
4538cdf0e10cSrcweir             {
4539cdf0e10cSrcweir                 lcl_appendWindowInfo( aTempStr, *pTempWin );
4540cdf0e10cSrcweir                 pTempWin = pTempWin->mpWindowImpl->mpNext;
4541cdf0e10cSrcweir             }
4542cdf0e10cSrcweir             DBG_ERROR( aTempStr.GetBuffer() );
4543cdf0e10cSrcweir 		    GetpApp()->Abort( String( aTempStr, RTL_TEXTENCODING_UTF8 ) );   // abort in non-pro version, this must be fixed!
4544cdf0e10cSrcweir         }
4545cdf0e10cSrcweir 
4546cdf0e10cSrcweir         if ( mpWindowImpl->mpFirstOverlap )
4547cdf0e10cSrcweir         {
4548cdf0e10cSrcweir             ByteString aTempStr( "Window (" );
4549cdf0e10cSrcweir             aTempStr += ByteString( GetText(), RTL_TEXTENCODING_UTF8 );
4550cdf0e10cSrcweir             aTempStr += ") with living SystemWindow(s) destroyed: ";
4551cdf0e10cSrcweir             pTempWin = mpWindowImpl->mpFirstOverlap;
4552cdf0e10cSrcweir             while ( pTempWin )
4553cdf0e10cSrcweir             {
4554cdf0e10cSrcweir                 lcl_appendWindowInfo( aTempStr, *pTempWin );
4555cdf0e10cSrcweir                 pTempWin = pTempWin->mpWindowImpl->mpNext;
4556cdf0e10cSrcweir             }
4557cdf0e10cSrcweir             DBG_ERROR( aTempStr.GetBuffer() );
4558cdf0e10cSrcweir 		    GetpApp()->Abort( String( aTempStr, RTL_TEXTENCODING_UTF8 ) );   // abort in non-pro version, this must be fixed!
4559cdf0e10cSrcweir         }
4560cdf0e10cSrcweir 
4561cdf0e10cSrcweir         Window* pMyParent = this;
4562cdf0e10cSrcweir         SystemWindow* pMySysWin = NULL;
4563cdf0e10cSrcweir 
4564cdf0e10cSrcweir         while ( pMyParent )
4565cdf0e10cSrcweir         {
4566cdf0e10cSrcweir             if ( pMyParent->IsSystemWindow() )
4567cdf0e10cSrcweir                 pMySysWin = (SystemWindow*)pMyParent;
4568cdf0e10cSrcweir             pMyParent = pMyParent->GetParent();
4569cdf0e10cSrcweir         }
4570cdf0e10cSrcweir         if ( pMySysWin && pMySysWin->ImplIsInTaskPaneList( this ) )
4571cdf0e10cSrcweir         {
4572cdf0e10cSrcweir             ByteString aTempStr( "Window (" );
4573cdf0e10cSrcweir             aTempStr += ByteString( GetText(), RTL_TEXTENCODING_UTF8 );
4574cdf0e10cSrcweir             aTempStr += ") still in TaskPanelList!";
4575cdf0e10cSrcweir             DBG_ERROR( aTempStr.GetBuffer() );
4576cdf0e10cSrcweir 		    GetpApp()->Abort( String( aTempStr, RTL_TEXTENCODING_UTF8 ) );   // abort in non-pro version, this must be fixed!
4577cdf0e10cSrcweir         }
4578cdf0e10cSrcweir     }
4579cdf0e10cSrcweir #endif
4580cdf0e10cSrcweir 
4581cdf0e10cSrcweir     if( mpWindowImpl->mbIsInTaskPaneList )
4582cdf0e10cSrcweir     {
4583cdf0e10cSrcweir         Window* pMyParent = this;
4584cdf0e10cSrcweir         SystemWindow* pMySysWin = NULL;
4585cdf0e10cSrcweir 
4586cdf0e10cSrcweir         while ( pMyParent )
4587cdf0e10cSrcweir         {
4588cdf0e10cSrcweir             if ( pMyParent->IsSystemWindow() )
4589cdf0e10cSrcweir                 pMySysWin = (SystemWindow*)pMyParent;
4590cdf0e10cSrcweir             pMyParent = pMyParent->GetParent();
4591cdf0e10cSrcweir         }
4592cdf0e10cSrcweir         if ( pMySysWin && pMySysWin->ImplIsInTaskPaneList( this ) )
4593cdf0e10cSrcweir         {
4594cdf0e10cSrcweir             pMySysWin->GetTaskPaneList()->RemoveWindow( this );
4595cdf0e10cSrcweir         }
4596cdf0e10cSrcweir         else
4597cdf0e10cSrcweir         {
4598cdf0e10cSrcweir             ByteString aTempStr( "Window (" );
4599cdf0e10cSrcweir             aTempStr += ByteString( GetText(), RTL_TEXTENCODING_UTF8 );
4600cdf0e10cSrcweir             aTempStr += ") not found in TaskPanelList!";
4601cdf0e10cSrcweir             DBG_ERROR( aTempStr.GetBuffer() );
4602cdf0e10cSrcweir         }
4603cdf0e10cSrcweir     }
4604cdf0e10cSrcweir 
4605cdf0e10cSrcweir     // Fenster hiden, um das entsprechende Paint-Handling auszuloesen
4606cdf0e10cSrcweir     Hide();
4607cdf0e10cSrcweir 
4608cdf0e10cSrcweir     // Mitteilen, das Fenster zerstoert wird
4609cdf0e10cSrcweir     {
4610cdf0e10cSrcweir     NotifyEvent aNEvt( EVENT_DESTROY, this );
4611cdf0e10cSrcweir     Notify( aNEvt );
4612cdf0e10cSrcweir     }
4613cdf0e10cSrcweir 
4614cdf0e10cSrcweir     // EndExtTextInputMode
4615cdf0e10cSrcweir     if ( pSVData->maWinData.mpExtTextInputWin == this )
4616cdf0e10cSrcweir     {
4617cdf0e10cSrcweir         EndExtTextInput( EXTTEXTINPUT_END_COMPLETE );
4618cdf0e10cSrcweir         if ( pSVData->maWinData.mpExtTextInputWin == this )
4619cdf0e10cSrcweir             pSVData->maWinData.mpExtTextInputWin = NULL;
4620cdf0e10cSrcweir     }
4621cdf0e10cSrcweir 
4622cdf0e10cSrcweir     // check if the focus window is our child
4623cdf0e10cSrcweir     sal_Bool bHasFocussedChild = sal_False;
4624cdf0e10cSrcweir     if( pSVData->maWinData.mpFocusWin && ImplIsRealParentPath( pSVData->maWinData.mpFocusWin ) )
4625cdf0e10cSrcweir     {
4626cdf0e10cSrcweir         // #122232#, this must not happen and is an application bug ! but we try some cleanup to hopefully avoid crashes, see below
4627cdf0e10cSrcweir         bHasFocussedChild = sal_True;
4628cdf0e10cSrcweir #ifdef DBG_UTIL
4629cdf0e10cSrcweir         ByteString aTempStr( "Window (" );
4630cdf0e10cSrcweir         aTempStr += ByteString( GetText(), RTL_TEXTENCODING_UTF8 );
4631cdf0e10cSrcweir         aTempStr += ") with focussed child window destroyed ! THIS WILL LEAD TO CRASHES AND MUST BE FIXED !";
4632cdf0e10cSrcweir         DBG_ERROR( aTempStr.GetBuffer() );
4633cdf0e10cSrcweir         GetpApp()->Abort( String( aTempStr, RTL_TEXTENCODING_UTF8 ) );   // abort in non-pro version, this must be fixed!
4634cdf0e10cSrcweir #endif
4635cdf0e10cSrcweir     }
4636cdf0e10cSrcweir 
4637cdf0e10cSrcweir     // Wenn wir den Focus haben, dann den Focus auf ein anderes Fenster setzen
4638cdf0e10cSrcweir     Window* pOverlapWindow = ImplGetFirstOverlapWindow();
4639cdf0e10cSrcweir     if ( pSVData->maWinData.mpFocusWin == this
4640cdf0e10cSrcweir         || bHasFocussedChild )  // #122232#, see above, try some cleanup
4641cdf0e10cSrcweir     {
4642cdf0e10cSrcweir         if ( mpWindowImpl->mbFrame )
4643cdf0e10cSrcweir         {
4644cdf0e10cSrcweir             pSVData->maWinData.mpFocusWin = NULL;
4645cdf0e10cSrcweir             pOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL;
4646cdf0e10cSrcweir             GetpApp()->FocusChanged();
4647cdf0e10cSrcweir         }
4648cdf0e10cSrcweir         else
4649cdf0e10cSrcweir         {
4650cdf0e10cSrcweir             Window* pParent = GetParent();
4651cdf0e10cSrcweir             Window* pBorderWindow = mpWindowImpl->mpBorderWindow;
4652cdf0e10cSrcweir             // Bei ueberlappenden Fenstern wird der Focus auf den
4653cdf0e10cSrcweir             // Parent vom naechsten FrameWindow gesetzt
4654cdf0e10cSrcweir             if ( pBorderWindow )
4655cdf0e10cSrcweir             {
4656cdf0e10cSrcweir                 if ( pBorderWindow->ImplIsOverlapWindow() )
4657cdf0e10cSrcweir                     pParent = pBorderWindow->mpWindowImpl->mpOverlapWindow;
4658cdf0e10cSrcweir             }
4659cdf0e10cSrcweir             else if ( ImplIsOverlapWindow() )
4660cdf0e10cSrcweir                 pParent = mpWindowImpl->mpOverlapWindow;
4661cdf0e10cSrcweir 
4662cdf0e10cSrcweir             if ( pParent && pParent->IsEnabled() && pParent->IsInputEnabled() && ! pParent->IsInModalMode() )
4663cdf0e10cSrcweir                 pParent->GrabFocus();
4664cdf0e10cSrcweir             else
4665cdf0e10cSrcweir                 mpWindowImpl->mpFrameWindow->GrabFocus();
4666cdf0e10cSrcweir 
4667cdf0e10cSrcweir             // If the focus was set back to 'this' set it to nothing
4668cdf0e10cSrcweir             if ( pSVData->maWinData.mpFocusWin == this )
4669cdf0e10cSrcweir             {
4670cdf0e10cSrcweir                 pSVData->maWinData.mpFocusWin = NULL;
4671cdf0e10cSrcweir                 pOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL;
4672cdf0e10cSrcweir                 GetpApp()->FocusChanged();
4673cdf0e10cSrcweir             }
4674cdf0e10cSrcweir         }
4675cdf0e10cSrcweir     }
4676cdf0e10cSrcweir 
4677cdf0e10cSrcweir 
4678cdf0e10cSrcweir     if ( pOverlapWindow->mpWindowImpl->mpLastFocusWindow == this )
4679cdf0e10cSrcweir         pOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL;
4680cdf0e10cSrcweir 
4681cdf0e10cSrcweir     // reset hint for DefModalDialogParent
4682cdf0e10cSrcweir     if( pSVData->maWinData.mpActiveApplicationFrame == this )
4683cdf0e10cSrcweir         pSVData->maWinData.mpActiveApplicationFrame = NULL;
4684cdf0e10cSrcweir 
4685cdf0e10cSrcweir     // gemerkte Fenster zuruecksetzen
4686cdf0e10cSrcweir     if ( mpWindowImpl->mpFrameData->mpFocusWin == this )
4687cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mpFocusWin = NULL;
4688cdf0e10cSrcweir     if ( mpWindowImpl->mpFrameData->mpMouseMoveWin == this )
4689cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mpMouseMoveWin = NULL;
4690cdf0e10cSrcweir     if ( mpWindowImpl->mpFrameData->mpMouseDownWin == this )
4691cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mpMouseDownWin = NULL;
4692cdf0e10cSrcweir 
4693cdf0e10cSrcweir     // Deactivate-Window zuruecksetzen
4694cdf0e10cSrcweir     if ( pSVData->maWinData.mpLastDeacWin == this )
4695cdf0e10cSrcweir         pSVData->maWinData.mpLastDeacWin = NULL;
4696cdf0e10cSrcweir 
4697cdf0e10cSrcweir     if ( mpWindowImpl->mbFrame )
4698cdf0e10cSrcweir     {
4699cdf0e10cSrcweir         if ( mpWindowImpl->mpFrameData->mnFocusId )
4700cdf0e10cSrcweir             Application::RemoveUserEvent( mpWindowImpl->mpFrameData->mnFocusId );
4701cdf0e10cSrcweir         if ( mpWindowImpl->mpFrameData->mnMouseMoveId )
4702cdf0e10cSrcweir             Application::RemoveUserEvent( mpWindowImpl->mpFrameData->mnMouseMoveId );
4703cdf0e10cSrcweir     }
4704cdf0e10cSrcweir 
4705*cf06609aSHerbert Dürr     // release SalGraphics
4706cdf0e10cSrcweir     ImplReleaseGraphics();
4707cdf0e10cSrcweir 
4708*cf06609aSHerbert Dürr     // notify ImplDelData subscribers of this window about the window deletion
4709cdf0e10cSrcweir     ImplDelData* pDelData = mpWindowImpl->mpFirstDel;
4710cdf0e10cSrcweir     while ( pDelData )
4711cdf0e10cSrcweir     {
4712cdf0e10cSrcweir         pDelData->mbDel = sal_True;
4713cdf0e10cSrcweir         pDelData->mpWindow = NULL;  // #112873# pDel is not associated with a Window anymore
4714cdf0e10cSrcweir         pDelData = pDelData->mpNext;
4715cdf0e10cSrcweir     }
4716cdf0e10cSrcweir 
4717*cf06609aSHerbert Dürr     // remove window from the lists
4718cdf0e10cSrcweir     ImplRemoveWindow( sal_True );
4719cdf0e10cSrcweir 
4720cdf0e10cSrcweir     // de-register as "top window child" at our parent, if necessary
4721cdf0e10cSrcweir     if ( mpWindowImpl->mbFrame )
4722cdf0e10cSrcweir     {
4723cdf0e10cSrcweir         sal_Bool bIsTopWindow = mpWindowImpl->mpWinData && ( mpWindowImpl->mpWinData->mnIsTopWindow == 1 );
4724cdf0e10cSrcweir         if ( mpWindowImpl->mpRealParent && bIsTopWindow )
4725cdf0e10cSrcweir         {
4726cdf0e10cSrcweir             ImplWinData* pParentWinData = mpWindowImpl->mpRealParent->ImplGetWinData();
4727cdf0e10cSrcweir 
4728cdf0e10cSrcweir             ::std::list< Window* >::iterator myPos = ::std::find( pParentWinData->maTopWindowChildren.begin(),
4729cdf0e10cSrcweir                 pParentWinData->maTopWindowChildren.end(), this );
4730cdf0e10cSrcweir             DBG_ASSERT( myPos != pParentWinData->maTopWindowChildren.end(), "Window::~Window: inconsistency in top window chain!" );
4731cdf0e10cSrcweir             if ( myPos != pParentWinData->maTopWindowChildren.end() )
4732cdf0e10cSrcweir                 pParentWinData->maTopWindowChildren.erase( myPos );
4733cdf0e10cSrcweir         }
4734cdf0e10cSrcweir     }
4735cdf0e10cSrcweir 
4736*cf06609aSHerbert Dürr     // cleanup Extra Window Data, TODO: add and use ImplWinData destructor
4737cdf0e10cSrcweir     if ( mpWindowImpl->mpWinData )
4738cdf0e10cSrcweir     {
4739cdf0e10cSrcweir         if ( mpWindowImpl->mpWinData->mpExtOldText )
4740cdf0e10cSrcweir             delete mpWindowImpl->mpWinData->mpExtOldText;
4741cdf0e10cSrcweir         if ( mpWindowImpl->mpWinData->mpExtOldAttrAry )
4742cdf0e10cSrcweir             delete mpWindowImpl->mpWinData->mpExtOldAttrAry;
4743cdf0e10cSrcweir         if ( mpWindowImpl->mpWinData->mpCursorRect )
4744cdf0e10cSrcweir             delete mpWindowImpl->mpWinData->mpCursorRect;
4745cdf0e10cSrcweir         if ( mpWindowImpl->mpWinData->mpFocusRect )
4746cdf0e10cSrcweir             delete mpWindowImpl->mpWinData->mpFocusRect;
4747cdf0e10cSrcweir         if ( mpWindowImpl->mpWinData->mpTrackRect )
4748cdf0e10cSrcweir             delete mpWindowImpl->mpWinData->mpTrackRect;
4749cdf0e10cSrcweir 
4750cdf0e10cSrcweir         delete mpWindowImpl->mpWinData;
4751cdf0e10cSrcweir     }
4752cdf0e10cSrcweir 
4753*cf06609aSHerbert Dürr     // cleanup overlap related window data
4754cdf0e10cSrcweir     if ( mpWindowImpl->mpOverlapData )
4755cdf0e10cSrcweir         delete mpWindowImpl->mpOverlapData;
4756cdf0e10cSrcweir 
4757*cf06609aSHerbert Dürr     // remove BorderWindow or Frame window data
4758cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
4759cdf0e10cSrcweir         delete mpWindowImpl->mpBorderWindow;
4760cdf0e10cSrcweir     else if ( mpWindowImpl->mbFrame )
4761cdf0e10cSrcweir     {
4762cdf0e10cSrcweir         if ( pSVData->maWinData.mpFirstFrame == this )
4763cdf0e10cSrcweir             pSVData->maWinData.mpFirstFrame = mpWindowImpl->mpFrameData->mpNextFrame;
4764cdf0e10cSrcweir         else
4765cdf0e10cSrcweir         {
4766cdf0e10cSrcweir             Window* pSysWin = pSVData->maWinData.mpFirstFrame;
4767cdf0e10cSrcweir             while ( pSysWin->mpWindowImpl->mpFrameData->mpNextFrame != this )
4768cdf0e10cSrcweir                 pSysWin = pSysWin->mpWindowImpl->mpFrameData->mpNextFrame;
4769cdf0e10cSrcweir             pSysWin->mpWindowImpl->mpFrameData->mpNextFrame = mpWindowImpl->mpFrameData->mpNextFrame;
4770cdf0e10cSrcweir         }
4771cdf0e10cSrcweir         mpWindowImpl->mpFrame->SetCallback( NULL, NULL );
4772cdf0e10cSrcweir         pSVData->mpDefInst->DestroyFrame( mpWindowImpl->mpFrame );
4773cdf0e10cSrcweir         delete mpWindowImpl->mpFrameData;
4774cdf0e10cSrcweir     }
4775cdf0e10cSrcweir 
4776cdf0e10cSrcweir     // should be the last statements
4777cdf0e10cSrcweir     delete mpWindowImpl; mpWindowImpl = NULL;
4778cdf0e10cSrcweir }
4779cdf0e10cSrcweir 
4780cdf0e10cSrcweir // -----------------------------------------------------------------------
4781cdf0e10cSrcweir void Window::doLazyDelete()
4782cdf0e10cSrcweir {
4783cdf0e10cSrcweir     SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(this);
4784cdf0e10cSrcweir     DockingWindow* pDockWin = dynamic_cast<DockingWindow*>(this);
4785cdf0e10cSrcweir     if( pSysWin || ( pDockWin && pDockWin->IsFloatingMode() ) )
4786cdf0e10cSrcweir     {
4787cdf0e10cSrcweir         Show( sal_False );
4788cdf0e10cSrcweir         SetParent( ImplGetDefaultWindow() );
4789cdf0e10cSrcweir     }
4790cdf0e10cSrcweir     vcl::LazyDeletor<Window>::Delete( this );
4791cdf0e10cSrcweir }
4792cdf0e10cSrcweir 
4793cdf0e10cSrcweir // -----------------------------------------------------------------------
4794cdf0e10cSrcweir void Window::InterceptChildWindowKeyDown( sal_Bool bIntercept )
4795cdf0e10cSrcweir {
4796cdf0e10cSrcweir     if( mpWindowImpl->mpSysObj )
4797cdf0e10cSrcweir         mpWindowImpl->mpSysObj->InterceptChildWindowKeyDown( bIntercept );
4798cdf0e10cSrcweir }
4799cdf0e10cSrcweir 
4800cdf0e10cSrcweir // -----------------------------------------------------------------------
4801cdf0e10cSrcweir 
4802cdf0e10cSrcweir void Window::MouseMove( const MouseEvent& rMEvt )
4803cdf0e10cSrcweir {
4804cdf0e10cSrcweir     { // Klammerung, da in diesem Handler das Window zerstoert werden darf
4805cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
4806cdf0e10cSrcweir     }
4807cdf0e10cSrcweir 
4808cdf0e10cSrcweir     NotifyEvent aNEvt( EVENT_MOUSEMOVE, this, &rMEvt );
4809cdf0e10cSrcweir     if ( !Notify( aNEvt ) )
4810cdf0e10cSrcweir         mpWindowImpl->mbMouseMove = sal_True;
4811cdf0e10cSrcweir }
4812cdf0e10cSrcweir 
4813cdf0e10cSrcweir // -----------------------------------------------------------------------
4814cdf0e10cSrcweir 
4815cdf0e10cSrcweir void Window::MouseButtonDown( const MouseEvent& rMEvt )
4816cdf0e10cSrcweir {
4817cdf0e10cSrcweir     { // Klammerung, da in diesem Handler das Window zerstoert werden darf
4818cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
4819cdf0e10cSrcweir     }
4820cdf0e10cSrcweir 
4821cdf0e10cSrcweir     NotifyEvent aNEvt( EVENT_MOUSEBUTTONDOWN, this, &rMEvt );
4822cdf0e10cSrcweir     if ( !Notify( aNEvt ) )
4823cdf0e10cSrcweir         mpWindowImpl->mbMouseButtonDown = sal_True;
4824cdf0e10cSrcweir }
4825cdf0e10cSrcweir 
4826cdf0e10cSrcweir // -----------------------------------------------------------------------
4827cdf0e10cSrcweir 
4828cdf0e10cSrcweir void Window::MouseButtonUp( const MouseEvent& rMEvt )
4829cdf0e10cSrcweir {
4830cdf0e10cSrcweir     { // Klammerung, da in diesem Handler das Window zerstoert werden darf
4831cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
4832cdf0e10cSrcweir     }
4833cdf0e10cSrcweir 
4834cdf0e10cSrcweir     NotifyEvent aNEvt( EVENT_MOUSEBUTTONUP, this, &rMEvt );
4835cdf0e10cSrcweir     if ( !Notify( aNEvt ) )
4836cdf0e10cSrcweir         mpWindowImpl->mbMouseButtonUp = sal_True;
4837cdf0e10cSrcweir }
4838cdf0e10cSrcweir 
4839cdf0e10cSrcweir // -----------------------------------------------------------------------
4840cdf0e10cSrcweir 
4841cdf0e10cSrcweir void Window::KeyInput( const KeyEvent& rKEvt )
4842cdf0e10cSrcweir {
4843cdf0e10cSrcweir     { // Klammerung, da in diesem Handler das Window zerstoert werden darf
4844cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
4845cdf0e10cSrcweir     }
4846cdf0e10cSrcweir 
4847cdf0e10cSrcweir     NotifyEvent aNEvt( EVENT_KEYINPUT, this, &rKEvt );
4848cdf0e10cSrcweir     if ( !Notify( aNEvt ) )
4849cdf0e10cSrcweir         mpWindowImpl->mbKeyInput = sal_True;
4850cdf0e10cSrcweir }
4851cdf0e10cSrcweir 
4852cdf0e10cSrcweir // -----------------------------------------------------------------------
4853cdf0e10cSrcweir 
4854cdf0e10cSrcweir void Window::KeyUp( const KeyEvent& rKEvt )
4855cdf0e10cSrcweir {
4856cdf0e10cSrcweir     { // Klammerung, da in diesem Handler das Window zerstoert werden darf
4857cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
4858cdf0e10cSrcweir     }
4859cdf0e10cSrcweir 
4860cdf0e10cSrcweir     NotifyEvent aNEvt( EVENT_KEYUP, this, &rKEvt );
4861cdf0e10cSrcweir     if ( !Notify( aNEvt ) )
4862cdf0e10cSrcweir         mpWindowImpl->mbKeyUp = sal_True;
4863cdf0e10cSrcweir }
4864cdf0e10cSrcweir 
4865cdf0e10cSrcweir // -----------------------------------------------------------------------
4866cdf0e10cSrcweir 
4867cdf0e10cSrcweir void Window::PrePaint()
4868cdf0e10cSrcweir {
4869cdf0e10cSrcweir }
4870cdf0e10cSrcweir 
4871cdf0e10cSrcweir // -----------------------------------------------------------------------
4872cdf0e10cSrcweir 
4873cdf0e10cSrcweir void Window::Paint( const Rectangle& rRect )
4874cdf0e10cSrcweir {
4875cdf0e10cSrcweir     { // Klammerung, da in diesem Handler das Window zerstoert werden darf
4876cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
4877cdf0e10cSrcweir     }
4878cdf0e10cSrcweir 
4879cdf0e10cSrcweir     ImplCallEventListeners( VCLEVENT_WINDOW_PAINT, (void*)&rRect );
4880cdf0e10cSrcweir }
4881cdf0e10cSrcweir 
4882cdf0e10cSrcweir // -----------------------------------------------------------------------
4883cdf0e10cSrcweir 
4884cdf0e10cSrcweir void Window::PostPaint()
4885cdf0e10cSrcweir {
4886cdf0e10cSrcweir }
4887cdf0e10cSrcweir 
4888cdf0e10cSrcweir // -----------------------------------------------------------------------
4889cdf0e10cSrcweir 
4890cdf0e10cSrcweir void Window::Draw( OutputDevice*, const Point&, const Size&, sal_uLong )
4891cdf0e10cSrcweir {
4892cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
4893cdf0e10cSrcweir }
4894cdf0e10cSrcweir 
4895cdf0e10cSrcweir // -----------------------------------------------------------------------
4896cdf0e10cSrcweir 
4897cdf0e10cSrcweir void Window::Move()
4898cdf0e10cSrcweir {
4899cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
4900cdf0e10cSrcweir }
4901cdf0e10cSrcweir 
4902cdf0e10cSrcweir // -----------------------------------------------------------------------
4903cdf0e10cSrcweir 
4904cdf0e10cSrcweir void Window::Resize()
4905cdf0e10cSrcweir {
4906cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
4907cdf0e10cSrcweir }
4908cdf0e10cSrcweir 
4909cdf0e10cSrcweir // -----------------------------------------------------------------------
4910cdf0e10cSrcweir 
4911cdf0e10cSrcweir void Window::Activate()
4912cdf0e10cSrcweir {
4913cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
4914cdf0e10cSrcweir }
4915cdf0e10cSrcweir 
4916cdf0e10cSrcweir // -----------------------------------------------------------------------
4917cdf0e10cSrcweir 
4918cdf0e10cSrcweir void Window::Deactivate()
4919cdf0e10cSrcweir {
4920cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
4921cdf0e10cSrcweir }
4922cdf0e10cSrcweir 
4923cdf0e10cSrcweir // -----------------------------------------------------------------------
4924cdf0e10cSrcweir 
4925cdf0e10cSrcweir void Window::GetFocus()
4926cdf0e10cSrcweir {
4927cdf0e10cSrcweir     { // Klammerung, da in diesem Handler das Window zerstoert werden darf
4928cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
4929cdf0e10cSrcweir     }
4930cdf0e10cSrcweir 
4931cdf0e10cSrcweir     if ( HasFocus() && mpWindowImpl->mpLastFocusWindow && !(mpWindowImpl->mnDlgCtrlFlags & WINDOW_DLGCTRL_WANTFOCUS) )
4932cdf0e10cSrcweir     {
4933cdf0e10cSrcweir         ImplDelData aDogtag( this );
4934cdf0e10cSrcweir         mpWindowImpl->mpLastFocusWindow->GrabFocus();
4935cdf0e10cSrcweir         if( aDogtag.IsDelete() )
4936cdf0e10cSrcweir             return;
4937cdf0e10cSrcweir     }
4938cdf0e10cSrcweir 
4939cdf0e10cSrcweir     NotifyEvent aNEvt( EVENT_GETFOCUS, this );
4940cdf0e10cSrcweir     Notify( aNEvt );
4941cdf0e10cSrcweir }
4942cdf0e10cSrcweir 
4943cdf0e10cSrcweir // -----------------------------------------------------------------------
4944cdf0e10cSrcweir 
4945cdf0e10cSrcweir void Window::LoseFocus()
4946cdf0e10cSrcweir {
4947cdf0e10cSrcweir     { // Klammerung, da in diesem Handler das Window zerstoert werden darf
4948cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
4949cdf0e10cSrcweir     }
4950cdf0e10cSrcweir 
4951cdf0e10cSrcweir     NotifyEvent aNEvt( EVENT_LOSEFOCUS, this );
4952cdf0e10cSrcweir     Notify( aNEvt );
4953cdf0e10cSrcweir }
4954cdf0e10cSrcweir 
4955cdf0e10cSrcweir // -----------------------------------------------------------------------
4956cdf0e10cSrcweir 
4957cdf0e10cSrcweir void Window::RequestHelp( const HelpEvent& rHEvt )
4958cdf0e10cSrcweir {
4959cdf0e10cSrcweir     { // Klammerung, da in diesem Handler das Window zerstoert werden darf
4960cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
4961cdf0e10cSrcweir     }
4962cdf0e10cSrcweir 
4963cdf0e10cSrcweir     // Wenn Balloon-Help angefordert wird, dann den Balloon mit dem
4964cdf0e10cSrcweir     // gesetzten Hilfetext anzeigen
4965cdf0e10cSrcweir     if ( rHEvt.GetMode() & HELPMODE_BALLOON )
4966cdf0e10cSrcweir     {
4967cdf0e10cSrcweir         const XubString* pStr = &(GetHelpText());
4968cdf0e10cSrcweir         if ( !pStr->Len() )
4969cdf0e10cSrcweir             pStr = &(GetQuickHelpText());
4970cdf0e10cSrcweir         if ( !pStr->Len() && ImplGetParent() && !ImplIsOverlapWindow() )
4971cdf0e10cSrcweir             ImplGetParent()->RequestHelp( rHEvt );
4972cdf0e10cSrcweir         else
4973cdf0e10cSrcweir             Help::ShowBalloon( this, rHEvt.GetMousePosPixel(), *pStr );
4974cdf0e10cSrcweir     }
4975cdf0e10cSrcweir     else if ( rHEvt.GetMode() & HELPMODE_QUICK )
4976cdf0e10cSrcweir     {
4977cdf0e10cSrcweir         const XubString* pStr = &(GetQuickHelpText());
4978cdf0e10cSrcweir         if ( !pStr->Len() && ImplGetParent() && !ImplIsOverlapWindow() )
4979cdf0e10cSrcweir             ImplGetParent()->RequestHelp( rHEvt );
4980cdf0e10cSrcweir         else
4981cdf0e10cSrcweir         {
4982cdf0e10cSrcweir             Point aPos = GetPosPixel();
4983cdf0e10cSrcweir             if ( ImplGetParent() && !ImplIsOverlapWindow() )
4984cdf0e10cSrcweir                 aPos = ImplGetParent()->OutputToScreenPixel( aPos );
4985cdf0e10cSrcweir             Rectangle   aRect( aPos, GetSizePixel() );
4986cdf0e10cSrcweir             String      aHelpText;
4987cdf0e10cSrcweir             if ( pStr->Len() )
4988cdf0e10cSrcweir                 aHelpText = GetHelpText();
4989cdf0e10cSrcweir             Help::ShowQuickHelp( this, aRect, *pStr, aHelpText, QUICKHELP_CTRLTEXT );
4990cdf0e10cSrcweir         }
4991cdf0e10cSrcweir     }
4992cdf0e10cSrcweir     else
4993cdf0e10cSrcweir     {
4994cdf0e10cSrcweir 		String aStrHelpId( rtl::OStringToOUString( GetHelpId(), RTL_TEXTENCODING_UTF8 ) );
4995cdf0e10cSrcweir         if ( aStrHelpId.Len() == 0 && ImplGetParent() )
4996cdf0e10cSrcweir             ImplGetParent()->RequestHelp( rHEvt );
4997cdf0e10cSrcweir         else
4998cdf0e10cSrcweir         {
4999cdf0e10cSrcweir             Help* pHelp = Application::GetHelp();
5000cdf0e10cSrcweir             if ( pHelp )
5001cdf0e10cSrcweir 			{
5002cdf0e10cSrcweir 				if( aStrHelpId.Len() > 0 )
5003cdf0e10cSrcweir 					pHelp->Start( aStrHelpId, this );
5004cdf0e10cSrcweir 				else
5005cdf0e10cSrcweir 					pHelp->Start( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OOO_HELP_INDEX ) ), this );
5006cdf0e10cSrcweir 			}
5007cdf0e10cSrcweir         }
5008cdf0e10cSrcweir     }
5009cdf0e10cSrcweir }
5010cdf0e10cSrcweir 
5011cdf0e10cSrcweir // -----------------------------------------------------------------------
5012cdf0e10cSrcweir 
5013cdf0e10cSrcweir void Window::Command( const CommandEvent& rCEvt )
5014cdf0e10cSrcweir {
5015cdf0e10cSrcweir     { // Klammerung, da in diesem Handler das Window zerstoert werden darf
5016cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5017cdf0e10cSrcweir     }
5018cdf0e10cSrcweir 
5019cdf0e10cSrcweir     ImplCallEventListeners( VCLEVENT_WINDOW_COMMAND, (void*)&rCEvt );
5020cdf0e10cSrcweir 
5021cdf0e10cSrcweir     NotifyEvent aNEvt( EVENT_COMMAND, this, &rCEvt );
5022cdf0e10cSrcweir     if ( !Notify( aNEvt ) )
5023cdf0e10cSrcweir         mpWindowImpl->mbCommand = sal_True;
5024cdf0e10cSrcweir }
5025cdf0e10cSrcweir 
5026cdf0e10cSrcweir // -----------------------------------------------------------------------
5027cdf0e10cSrcweir 
5028cdf0e10cSrcweir void Window::Tracking( const TrackingEvent& rTEvt )
5029cdf0e10cSrcweir {
5030cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5031cdf0e10cSrcweir 
5032cdf0e10cSrcweir     ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
5033cdf0e10cSrcweir     if( pWrapper )
5034cdf0e10cSrcweir         pWrapper->Tracking( rTEvt );
5035cdf0e10cSrcweir }
5036cdf0e10cSrcweir 
5037cdf0e10cSrcweir // -----------------------------------------------------------------------
5038cdf0e10cSrcweir 
5039cdf0e10cSrcweir void Window::UserEvent( sal_uLong, void* )
5040cdf0e10cSrcweir {
5041cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5042cdf0e10cSrcweir }
5043cdf0e10cSrcweir 
5044cdf0e10cSrcweir // -----------------------------------------------------------------------
5045cdf0e10cSrcweir 
5046cdf0e10cSrcweir void Window::StateChanged( StateChangedType )
5047cdf0e10cSrcweir {
5048cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5049cdf0e10cSrcweir }
5050cdf0e10cSrcweir 
5051cdf0e10cSrcweir // -----------------------------------------------------------------------
5052cdf0e10cSrcweir 
5053cdf0e10cSrcweir void Window::DataChanged( const DataChangedEvent& )
5054cdf0e10cSrcweir {
5055cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5056cdf0e10cSrcweir }
5057cdf0e10cSrcweir 
5058cdf0e10cSrcweir // -----------------------------------------------------------------------
5059cdf0e10cSrcweir 
5060cdf0e10cSrcweir void Window::ImplNotifyKeyMouseCommandEventListeners( NotifyEvent& rNEvt )
5061cdf0e10cSrcweir {
5062cdf0e10cSrcweir     if( rNEvt.GetType() == EVENT_COMMAND )
5063cdf0e10cSrcweir     {
5064cdf0e10cSrcweir         const CommandEvent* pCEvt = rNEvt.GetCommandEvent();
5065cdf0e10cSrcweir         if ( pCEvt->GetCommand() != COMMAND_CONTEXTMENU )
5066cdf0e10cSrcweir             // non context menu events are not to be notified up the chain
5067cdf0e10cSrcweir             // so we return immediately
5068cdf0e10cSrcweir             return;
5069cdf0e10cSrcweir 
5070cdf0e10cSrcweir         if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
5071cdf0e10cSrcweir         {
5072cdf0e10cSrcweir             if ( rNEvt.GetWindow() == this )
5073cdf0e10cSrcweir                 // not interested in: The event listeners are already called in ::Command,
5074cdf0e10cSrcweir                 // and calling them here a second time doesn't make sense
5075cdf0e10cSrcweir                 ;
5076cdf0e10cSrcweir             else
5077cdf0e10cSrcweir             {
5078cdf0e10cSrcweir                 CommandEvent aCommandEvent = ImplTranslateCommandEvent( *pCEvt, rNEvt.GetWindow(), this );
5079cdf0e10cSrcweir                 ImplCallEventListeners( VCLEVENT_WINDOW_COMMAND, &aCommandEvent );
5080cdf0e10cSrcweir             }
5081cdf0e10cSrcweir         }
5082cdf0e10cSrcweir     }
5083cdf0e10cSrcweir 
5084cdf0e10cSrcweir     // #82968# notify event listeners for mouse and key events seperately and
5085cdf0e10cSrcweir     // not in PreNotify ( as for focus listeners )
5086cdf0e10cSrcweir     // this allows for procesing those events internally first and pass it to
5087cdf0e10cSrcweir     // the toolkit later
5088cdf0e10cSrcweir 
5089cdf0e10cSrcweir     ImplDelData aDelData;
5090cdf0e10cSrcweir     ImplAddDel( &aDelData );
5091cdf0e10cSrcweir 
5092cdf0e10cSrcweir     if( rNEvt.GetType() == EVENT_MOUSEMOVE )
5093cdf0e10cSrcweir     {
5094cdf0e10cSrcweir         if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
5095cdf0e10cSrcweir         {
5096cdf0e10cSrcweir             if ( rNEvt.GetWindow() == this )
5097cdf0e10cSrcweir                 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEMOVE, (void*)rNEvt.GetMouseEvent() );
5098cdf0e10cSrcweir             else
5099cdf0e10cSrcweir             {
5100cdf0e10cSrcweir                 MouseEvent aMouseEvent = ImplTranslateMouseEvent( *rNEvt.GetMouseEvent(), rNEvt.GetWindow(), this );
5101cdf0e10cSrcweir                 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEMOVE, &aMouseEvent );
5102cdf0e10cSrcweir             }
5103cdf0e10cSrcweir         }
5104cdf0e10cSrcweir     }
5105cdf0e10cSrcweir     else if( rNEvt.GetType() == EVENT_MOUSEBUTTONUP )
5106cdf0e10cSrcweir     {
5107cdf0e10cSrcweir         if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
5108cdf0e10cSrcweir         {
5109cdf0e10cSrcweir             if ( rNEvt.GetWindow() == this )
5110cdf0e10cSrcweir                 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, (void*)rNEvt.GetMouseEvent() );
5111cdf0e10cSrcweir             else
5112cdf0e10cSrcweir             {
5113cdf0e10cSrcweir                 MouseEvent aMouseEvent = ImplTranslateMouseEvent( *rNEvt.GetMouseEvent(), rNEvt.GetWindow(), this );
5114cdf0e10cSrcweir                 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, &aMouseEvent );
5115cdf0e10cSrcweir             }
5116cdf0e10cSrcweir         }
5117cdf0e10cSrcweir     }
5118cdf0e10cSrcweir     else if( rNEvt.GetType() == EVENT_MOUSEBUTTONDOWN )
5119cdf0e10cSrcweir     {
5120cdf0e10cSrcweir         if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
5121cdf0e10cSrcweir         {
5122cdf0e10cSrcweir             if ( rNEvt.GetWindow() == this )
5123cdf0e10cSrcweir                 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, (void*)rNEvt.GetMouseEvent() );
5124cdf0e10cSrcweir             else
5125cdf0e10cSrcweir             {
5126cdf0e10cSrcweir                 MouseEvent aMouseEvent = ImplTranslateMouseEvent( *rNEvt.GetMouseEvent(), rNEvt.GetWindow(), this );
5127cdf0e10cSrcweir                 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, &aMouseEvent );
5128cdf0e10cSrcweir             }
5129cdf0e10cSrcweir         }
5130cdf0e10cSrcweir     }
5131cdf0e10cSrcweir     else if( rNEvt.GetType() == EVENT_KEYINPUT )
5132cdf0e10cSrcweir     {
5133cdf0e10cSrcweir         if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
5134cdf0e10cSrcweir             ImplCallEventListeners( VCLEVENT_WINDOW_KEYINPUT, (void*)rNEvt.GetKeyEvent() );
5135cdf0e10cSrcweir     }
5136cdf0e10cSrcweir     else if( rNEvt.GetType() == EVENT_KEYUP )
5137cdf0e10cSrcweir     {
5138cdf0e10cSrcweir         if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
5139cdf0e10cSrcweir             ImplCallEventListeners( VCLEVENT_WINDOW_KEYUP, (void*)rNEvt.GetKeyEvent() );
5140cdf0e10cSrcweir     }
5141cdf0e10cSrcweir 
5142cdf0e10cSrcweir     if ( aDelData.IsDelete() )
5143cdf0e10cSrcweir         return;
5144cdf0e10cSrcweir     ImplRemoveDel( &aDelData );
5145cdf0e10cSrcweir 
5146cdf0e10cSrcweir     // #106721# check if we're part of a compound control and notify
5147cdf0e10cSrcweir     Window *pParent = ImplGetParent();
5148cdf0e10cSrcweir     while( pParent )
5149cdf0e10cSrcweir     {
5150cdf0e10cSrcweir         if( pParent->IsCompoundControl() )
5151cdf0e10cSrcweir         {
5152cdf0e10cSrcweir             pParent->ImplNotifyKeyMouseCommandEventListeners( rNEvt );
5153cdf0e10cSrcweir             break;
5154cdf0e10cSrcweir         }
5155cdf0e10cSrcweir         pParent = pParent->ImplGetParent();
5156cdf0e10cSrcweir     }
5157cdf0e10cSrcweir }
5158cdf0e10cSrcweir 
5159cdf0e10cSrcweir // -----------------------------------------------------------------------
5160cdf0e10cSrcweir 
5161cdf0e10cSrcweir long Window::PreNotify( NotifyEvent& rNEvt )
5162cdf0e10cSrcweir {
5163cdf0e10cSrcweir     { // Klammerung, da in diesem Handler das Window zerstoert werden darf
5164cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5165cdf0e10cSrcweir     }
5166cdf0e10cSrcweir 
5167cdf0e10cSrcweir     long bDone = sal_False;
5168cdf0e10cSrcweir     if ( mpWindowImpl->mpParent && !ImplIsOverlapWindow() )
5169cdf0e10cSrcweir         bDone = mpWindowImpl->mpParent->PreNotify( rNEvt );
5170cdf0e10cSrcweir 
5171cdf0e10cSrcweir     if ( !bDone )
5172cdf0e10cSrcweir     {
5173cdf0e10cSrcweir         if( rNEvt.GetType() == EVENT_GETFOCUS )
5174cdf0e10cSrcweir         {
5175cdf0e10cSrcweir             sal_Bool bCompoundFocusChanged = sal_False;
5176cdf0e10cSrcweir             if ( mpWindowImpl->mbCompoundControl && !mpWindowImpl->mbCompoundControlHasFocus && HasChildPathFocus() )
5177cdf0e10cSrcweir             {
5178cdf0e10cSrcweir                 mpWindowImpl->mbCompoundControlHasFocus = sal_True;
5179cdf0e10cSrcweir                 bCompoundFocusChanged = sal_True;
5180cdf0e10cSrcweir             }
5181cdf0e10cSrcweir 
5182cdf0e10cSrcweir             if ( bCompoundFocusChanged || ( rNEvt.GetWindow() == this ) )
5183cdf0e10cSrcweir                 ImplCallEventListeners( VCLEVENT_WINDOW_GETFOCUS );
5184cdf0e10cSrcweir         }
5185cdf0e10cSrcweir         else if( rNEvt.GetType() == EVENT_LOSEFOCUS )
5186cdf0e10cSrcweir         {
5187cdf0e10cSrcweir             sal_Bool bCompoundFocusChanged = sal_False;
5188cdf0e10cSrcweir             if ( mpWindowImpl->mbCompoundControl && mpWindowImpl->mbCompoundControlHasFocus && !HasChildPathFocus() )
5189cdf0e10cSrcweir             {
5190cdf0e10cSrcweir                 mpWindowImpl->mbCompoundControlHasFocus = sal_False ;
5191cdf0e10cSrcweir                 bCompoundFocusChanged = sal_True;
5192cdf0e10cSrcweir             }
5193cdf0e10cSrcweir 
5194cdf0e10cSrcweir             if ( bCompoundFocusChanged || ( rNEvt.GetWindow() == this ) )
5195cdf0e10cSrcweir                 ImplCallEventListeners( VCLEVENT_WINDOW_LOSEFOCUS );
5196cdf0e10cSrcweir         }
5197cdf0e10cSrcweir 
5198cdf0e10cSrcweir         // #82968# mouse and key events will be notified after processing ( in ImplNotifyKeyMouseCommandEventListeners() )!
5199cdf0e10cSrcweir         //    see also ImplHandleMouseEvent(), ImplHandleKey()
5200cdf0e10cSrcweir 
5201cdf0e10cSrcweir         /*
5202cdf0e10cSrcweir         else if( rNEvt.GetType() == EVENT_MOUSEMOVE )
5203cdf0e10cSrcweir         {
5204cdf0e10cSrcweir             if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
5205cdf0e10cSrcweir             {
5206cdf0e10cSrcweir                 if ( rNEvt.GetWindow() == this )
5207cdf0e10cSrcweir                     ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEMOVE, (void*)rNEvt.GetMouseEvent() );
5208cdf0e10cSrcweir                 else
5209cdf0e10cSrcweir                     ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEMOVE, &ImplTranslateMouseEvent( *rNEvt.GetMouseEvent(), rNEvt.GetWindow(), this ) );
5210cdf0e10cSrcweir             }
5211cdf0e10cSrcweir         }
5212cdf0e10cSrcweir         else if( rNEvt.GetType() == EVENT_MOUSEBUTTONUP )
5213cdf0e10cSrcweir         {
5214cdf0e10cSrcweir             if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
5215cdf0e10cSrcweir             {
5216cdf0e10cSrcweir                 if ( rNEvt.GetWindow() == this )
5217cdf0e10cSrcweir                     ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, (void*)rNEvt.GetMouseEvent() );
5218cdf0e10cSrcweir                 else
5219cdf0e10cSrcweir                     ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, &ImplTranslateMouseEvent( *rNEvt.GetMouseEvent(), rNEvt.GetWindow(), this ) );
5220cdf0e10cSrcweir             }
5221cdf0e10cSrcweir         }
5222cdf0e10cSrcweir         else if( rNEvt.GetType() == EVENT_MOUSEBUTTONDOWN )
5223cdf0e10cSrcweir         {
5224cdf0e10cSrcweir             if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
5225cdf0e10cSrcweir             {
5226cdf0e10cSrcweir                 if ( rNEvt.GetWindow() == this )
5227cdf0e10cSrcweir                     ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, (void*)rNEvt.GetMouseEvent() );
5228cdf0e10cSrcweir                 else
5229cdf0e10cSrcweir                     ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, &ImplTranslateMouseEvent( *rNEvt.GetMouseEvent(), rNEvt.GetWindow(), this ) );
5230cdf0e10cSrcweir             }
5231cdf0e10cSrcweir         }
5232cdf0e10cSrcweir         else if( rNEvt.GetType() == EVENT_KEYINPUT )
5233cdf0e10cSrcweir         {
5234cdf0e10cSrcweir             if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
5235cdf0e10cSrcweir                 ImplCallEventListeners( VCLEVENT_WINDOW_KEYINPUT, (void*)rNEvt.GetKeyEvent() );
5236cdf0e10cSrcweir         }
5237cdf0e10cSrcweir         else if( rNEvt.GetType() == EVENT_KEYUP )
5238cdf0e10cSrcweir         {
5239cdf0e10cSrcweir             if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
5240cdf0e10cSrcweir                 ImplCallEventListeners( VCLEVENT_WINDOW_KEYUP, (void*)rNEvt.GetKeyEvent() );
5241cdf0e10cSrcweir         }
5242cdf0e10cSrcweir         */
5243cdf0e10cSrcweir     }
5244cdf0e10cSrcweir 
5245cdf0e10cSrcweir     return bDone;
5246cdf0e10cSrcweir }
5247cdf0e10cSrcweir 
5248cdf0e10cSrcweir // -----------------------------------------------------------------------
5249cdf0e10cSrcweir 
5250cdf0e10cSrcweir long Window::Notify( NotifyEvent& rNEvt )
5251cdf0e10cSrcweir {
5252cdf0e10cSrcweir     { // Klammerung, da in diesem Handler das Window zerstoert werden darf
5253cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5254cdf0e10cSrcweir     }
5255cdf0e10cSrcweir 
5256cdf0e10cSrcweir     long nRet = sal_False;
5257cdf0e10cSrcweir 
5258cdf0e10cSrcweir     // check for docking window
5259cdf0e10cSrcweir     // but do nothing if window is docked and locked
5260cdf0e10cSrcweir     ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
5261cdf0e10cSrcweir     if( pWrapper && !( !pWrapper->IsFloatingMode() && pWrapper->IsLocked() ) )
5262cdf0e10cSrcweir     {
5263cdf0e10cSrcweir         if ( rNEvt.GetType() == EVENT_MOUSEBUTTONDOWN )
5264cdf0e10cSrcweir         {
5265cdf0e10cSrcweir             const MouseEvent* pMEvt = rNEvt.GetMouseEvent();
5266cdf0e10cSrcweir             sal_Bool bHit = pWrapper->GetDragArea().IsInside( pMEvt->GetPosPixel() );
5267cdf0e10cSrcweir             if ( pMEvt->IsLeft() )
5268cdf0e10cSrcweir             {
5269cdf0e10cSrcweir                 if ( pMEvt->IsMod1() && (pMEvt->GetClicks() == 2) )
5270cdf0e10cSrcweir                 {
5271cdf0e10cSrcweir                     // ctrl double click toggles floating mode
5272cdf0e10cSrcweir                     pWrapper->SetFloatingMode( !pWrapper->IsFloatingMode() );
5273cdf0e10cSrcweir                     return sal_True;
5274cdf0e10cSrcweir                 }
5275cdf0e10cSrcweir                 else if ( pMEvt->GetClicks() == 1 && bHit)
5276cdf0e10cSrcweir                 {
5277cdf0e10cSrcweir                     // allow start docking during mouse move
5278cdf0e10cSrcweir                     pWrapper->ImplEnableStartDocking();
5279cdf0e10cSrcweir                     return sal_True;
5280cdf0e10cSrcweir                 }
5281cdf0e10cSrcweir             }
5282cdf0e10cSrcweir         }
5283cdf0e10cSrcweir         else if ( rNEvt.GetType() == EVENT_MOUSEMOVE )
5284cdf0e10cSrcweir         {
5285cdf0e10cSrcweir             const MouseEvent* pMEvt = rNEvt.GetMouseEvent();
5286cdf0e10cSrcweir             sal_Bool bHit = pWrapper->GetDragArea().IsInside( pMEvt->GetPosPixel() );
5287cdf0e10cSrcweir             if ( pMEvt->IsLeft() )
5288cdf0e10cSrcweir             {
5289cdf0e10cSrcweir                 // check if a single click initiated this sequence ( ImplStartDockingEnabled() )
5290cdf0e10cSrcweir                 // check if window is docked and
5291cdf0e10cSrcweir                 if( pWrapper->ImplStartDockingEnabled() && !pWrapper->IsFloatingMode() &&
5292cdf0e10cSrcweir                     !pWrapper->IsDocking() && bHit )
5293cdf0e10cSrcweir                 {
5294cdf0e10cSrcweir                     Point   aPos = pMEvt->GetPosPixel();
5295cdf0e10cSrcweir                     Window* pWindow = rNEvt.GetWindow();
5296cdf0e10cSrcweir                     if ( pWindow != this )
5297cdf0e10cSrcweir                     {
5298cdf0e10cSrcweir                         aPos = pWindow->OutputToScreenPixel( aPos );
5299cdf0e10cSrcweir                         aPos = ScreenToOutputPixel( aPos );
5300cdf0e10cSrcweir                     }
5301cdf0e10cSrcweir                     pWrapper->ImplStartDocking( aPos );
5302cdf0e10cSrcweir                 }
5303cdf0e10cSrcweir                 return sal_True;
5304cdf0e10cSrcweir             }
5305cdf0e10cSrcweir         }
5306cdf0e10cSrcweir         else if( rNEvt.GetType() == EVENT_KEYINPUT )
5307cdf0e10cSrcweir         {
5308cdf0e10cSrcweir             const KeyCode& rKey = rNEvt.GetKeyEvent()->GetKeyCode();
5309cdf0e10cSrcweir             if( rKey.GetCode() == KEY_F10 && rKey.GetModifier() &&
5310cdf0e10cSrcweir                 rKey.IsShift() && rKey.IsMod1() )
5311cdf0e10cSrcweir             {
5312cdf0e10cSrcweir                 pWrapper->SetFloatingMode( !pWrapper->IsFloatingMode() );
5313cdf0e10cSrcweir                 /* At this point the floating toolbar frame does not have the
5314cdf0e10cSrcweir                  * input focus since these frames don't get the focus per default
5315cdf0e10cSrcweir                  * To enable keyboard handling of this toolbar set the input focus
5316cdf0e10cSrcweir                  * to the frame. This needs to be done with ToTop since GrabFocus
5317cdf0e10cSrcweir                  * would not notice any change since "this" already has the focus.
5318cdf0e10cSrcweir                  */
5319cdf0e10cSrcweir                 if( pWrapper->IsFloatingMode() )
5320cdf0e10cSrcweir                     ToTop( TOTOP_GRABFOCUSONLY );
5321cdf0e10cSrcweir                 return sal_True;
5322cdf0e10cSrcweir             }
5323cdf0e10cSrcweir         }
5324cdf0e10cSrcweir     }
5325cdf0e10cSrcweir 
5326cdf0e10cSrcweir     // Dialog-Steuerung
5327cdf0e10cSrcweir     if ( (GetStyle() & (WB_DIALOGCONTROL | WB_NODIALOGCONTROL)) == WB_DIALOGCONTROL )
5328cdf0e10cSrcweir     {
5329cdf0e10cSrcweir         // Wenn Parent auch DialogSteuerung aktiviert hat, uebernimmt dieser die Steuerung
5330cdf0e10cSrcweir         if ( (rNEvt.GetType() == EVENT_KEYINPUT) || (rNEvt.GetType() == EVENT_KEYUP) )
5331cdf0e10cSrcweir         {
5332cdf0e10cSrcweir             if ( ImplIsOverlapWindow() ||
5333cdf0e10cSrcweir                  ((ImplGetParent()->GetStyle() & (WB_DIALOGCONTROL | WB_NODIALOGCONTROL)) != WB_DIALOGCONTROL) )
5334cdf0e10cSrcweir             {
5335cdf0e10cSrcweir                 nRet = ImplDlgCtrl( *rNEvt.GetKeyEvent(), rNEvt.GetType() == EVENT_KEYINPUT );
5336cdf0e10cSrcweir             }
5337cdf0e10cSrcweir         }
5338cdf0e10cSrcweir         else if ( (rNEvt.GetType() == EVENT_GETFOCUS) || (rNEvt.GetType() == EVENT_LOSEFOCUS) )
5339cdf0e10cSrcweir         {
5340cdf0e10cSrcweir             ImplDlgCtrlFocusChanged( rNEvt.GetWindow(), rNEvt.GetType() == EVENT_GETFOCUS );
5341cdf0e10cSrcweir             if ( (rNEvt.GetWindow() == this) && (rNEvt.GetType() == EVENT_GETFOCUS) &&
5342cdf0e10cSrcweir                  !(GetStyle() & WB_TABSTOP) && !(mpWindowImpl->mnDlgCtrlFlags & WINDOW_DLGCTRL_WANTFOCUS) )
5343cdf0e10cSrcweir             {
5344cdf0e10cSrcweir                 sal_uInt16 n = 0;
5345cdf0e10cSrcweir                 Window* pFirstChild = ImplGetDlgWindow( n, DLGWINDOW_FIRST );
5346cdf0e10cSrcweir                 if ( pFirstChild )
5347cdf0e10cSrcweir                     pFirstChild->ImplControlFocus();
5348cdf0e10cSrcweir             }
5349cdf0e10cSrcweir         }
5350cdf0e10cSrcweir     }
5351cdf0e10cSrcweir 
5352cdf0e10cSrcweir     if ( !nRet )
5353cdf0e10cSrcweir     {
5354cdf0e10cSrcweir         if ( mpWindowImpl->mpParent && !ImplIsOverlapWindow() )
5355cdf0e10cSrcweir             nRet = mpWindowImpl->mpParent->Notify( rNEvt );
5356cdf0e10cSrcweir     }
5357cdf0e10cSrcweir 
5358cdf0e10cSrcweir     return nRet;
5359cdf0e10cSrcweir }
5360cdf0e10cSrcweir 
5361cdf0e10cSrcweir // -----------------------------------------------------------------------
5362cdf0e10cSrcweir 
5363cdf0e10cSrcweir void Window::ImplCallEventListeners( sal_uLong nEvent, void* pData )
5364cdf0e10cSrcweir {
5365cdf0e10cSrcweir 	// The implementation was moved to CallEventListeners(),
5366cdf0e10cSrcweir 	// because derived classes in svtools must be able to
5367cdf0e10cSrcweir 	// call the event listeners and ImplCallEventListeners()
5368cdf0e10cSrcweir 	// is not exported.
5369cdf0e10cSrcweir 	// TODO: replace ImplCallEventListeners() by CallEventListeners() in vcl
5370cdf0e10cSrcweir 
5371cdf0e10cSrcweir 	CallEventListeners( nEvent, pData );
5372cdf0e10cSrcweir }
5373cdf0e10cSrcweir 
5374cdf0e10cSrcweir // -----------------------------------------------------------------------
5375cdf0e10cSrcweir 
5376cdf0e10cSrcweir void Window::CallEventListeners( sal_uLong nEvent, void* pData )
5377cdf0e10cSrcweir {
5378cdf0e10cSrcweir     VclWindowEvent aEvent( this, nEvent, pData );
5379cdf0e10cSrcweir 
5380cdf0e10cSrcweir     ImplDelData aDelData;
5381cdf0e10cSrcweir     ImplAddDel( &aDelData );
5382cdf0e10cSrcweir 
5383cdf0e10cSrcweir     ImplGetSVData()->mpApp->ImplCallEventListeners( &aEvent );
5384cdf0e10cSrcweir 
5385cdf0e10cSrcweir     if ( aDelData.IsDelete() )
5386cdf0e10cSrcweir         return;
5387cdf0e10cSrcweir 
5388cdf0e10cSrcweir     if ( !mpWindowImpl->maEventListeners.empty() )
5389cdf0e10cSrcweir         mpWindowImpl->maEventListeners.Call( &aEvent );
5390cdf0e10cSrcweir 
5391cdf0e10cSrcweir     if ( aDelData.IsDelete() )
5392cdf0e10cSrcweir         return;
5393cdf0e10cSrcweir 
5394cdf0e10cSrcweir     ImplRemoveDel( &aDelData );
5395cdf0e10cSrcweir 
5396cdf0e10cSrcweir     Window* pWindow = this;
5397cdf0e10cSrcweir     while ( pWindow )
5398cdf0e10cSrcweir     {
5399cdf0e10cSrcweir         pWindow->ImplAddDel( &aDelData );
5400cdf0e10cSrcweir 
5401cdf0e10cSrcweir         if ( !pWindow->mpWindowImpl->maChildEventListeners.empty() )
5402cdf0e10cSrcweir             pWindow->mpWindowImpl->maChildEventListeners.Call( &aEvent );
5403cdf0e10cSrcweir 
5404cdf0e10cSrcweir         if ( aDelData.IsDelete() )
5405cdf0e10cSrcweir             return;
5406cdf0e10cSrcweir 
5407cdf0e10cSrcweir         pWindow->ImplRemoveDel( &aDelData );
5408cdf0e10cSrcweir 
5409cdf0e10cSrcweir         pWindow = pWindow->GetParent();
5410cdf0e10cSrcweir     }
5411cdf0e10cSrcweir }
5412cdf0e10cSrcweir 
5413cdf0e10cSrcweir void Window::FireVclEvent( VclSimpleEvent* pEvent )
5414cdf0e10cSrcweir {
5415cdf0e10cSrcweir     ImplGetSVData()->mpApp->ImplCallEventListeners(pEvent);
5416cdf0e10cSrcweir }
5417cdf0e10cSrcweir 
5418cdf0e10cSrcweir // -----------------------------------------------------------------------
5419cdf0e10cSrcweir 
5420cdf0e10cSrcweir void Window::AddEventListener( const Link& rEventListener )
5421cdf0e10cSrcweir {
5422cdf0e10cSrcweir     mpWindowImpl->maEventListeners.push_back( rEventListener );
5423cdf0e10cSrcweir }
5424cdf0e10cSrcweir 
5425cdf0e10cSrcweir // -----------------------------------------------------------------------
5426cdf0e10cSrcweir 
5427cdf0e10cSrcweir void Window::RemoveEventListener( const Link& rEventListener )
5428cdf0e10cSrcweir {
5429cdf0e10cSrcweir     mpWindowImpl->maEventListeners.remove( rEventListener );
5430cdf0e10cSrcweir }
5431cdf0e10cSrcweir 
5432cdf0e10cSrcweir // -----------------------------------------------------------------------
5433cdf0e10cSrcweir 
5434cdf0e10cSrcweir void Window::AddChildEventListener( const Link& rEventListener )
5435cdf0e10cSrcweir {
5436cdf0e10cSrcweir     mpWindowImpl->maChildEventListeners.push_back( rEventListener );
5437cdf0e10cSrcweir }
5438cdf0e10cSrcweir 
5439cdf0e10cSrcweir // -----------------------------------------------------------------------
5440cdf0e10cSrcweir 
5441cdf0e10cSrcweir void Window::RemoveChildEventListener( const Link& rEventListener )
5442cdf0e10cSrcweir {
5443cdf0e10cSrcweir     mpWindowImpl->maChildEventListeners.remove( rEventListener );
5444cdf0e10cSrcweir }
5445cdf0e10cSrcweir 
5446cdf0e10cSrcweir // -----------------------------------------------------------------------
5447cdf0e10cSrcweir 
5448cdf0e10cSrcweir sal_uLong Window::PostUserEvent( sal_uLong nEvent, void* pEventData )
5449cdf0e10cSrcweir {
5450cdf0e10cSrcweir     sal_uLong nEventId;
5451cdf0e10cSrcweir     PostUserEvent( nEventId, nEvent, pEventData );
5452cdf0e10cSrcweir     return nEventId;
5453cdf0e10cSrcweir }
5454cdf0e10cSrcweir 
5455cdf0e10cSrcweir // -----------------------------------------------------------------------
5456cdf0e10cSrcweir 
5457cdf0e10cSrcweir sal_uLong Window::PostUserEvent( const Link& rLink, void* pCaller )
5458cdf0e10cSrcweir {
5459cdf0e10cSrcweir     sal_uLong nEventId;
5460cdf0e10cSrcweir     PostUserEvent( nEventId, rLink, pCaller );
5461cdf0e10cSrcweir     return nEventId;
5462cdf0e10cSrcweir }
5463cdf0e10cSrcweir 
5464cdf0e10cSrcweir // -----------------------------------------------------------------------
5465cdf0e10cSrcweir 
5466cdf0e10cSrcweir sal_Bool Window::PostUserEvent( sal_uLong& rEventId, sal_uLong nEvent, void* pEventData )
5467cdf0e10cSrcweir {
5468cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5469cdf0e10cSrcweir 
5470cdf0e10cSrcweir     ImplSVEvent* pSVEvent = new ImplSVEvent;
5471cdf0e10cSrcweir     pSVEvent->mnEvent   = nEvent;
5472cdf0e10cSrcweir     pSVEvent->mpData    = pEventData;
5473cdf0e10cSrcweir     pSVEvent->mpLink    = NULL;
5474cdf0e10cSrcweir     pSVEvent->mpWindow  = this;
5475cdf0e10cSrcweir     pSVEvent->mbCall    = sal_True;
5476cdf0e10cSrcweir     ImplAddDel( &(pSVEvent->maDelData) );
5477cdf0e10cSrcweir     rEventId = (sal_uLong)pSVEvent;
5478cdf0e10cSrcweir     if ( mpWindowImpl->mpFrame->PostEvent( pSVEvent ) )
5479cdf0e10cSrcweir         return sal_True;
5480cdf0e10cSrcweir     else
5481cdf0e10cSrcweir     {
5482cdf0e10cSrcweir         rEventId = 0;
5483cdf0e10cSrcweir         ImplRemoveDel( &(pSVEvent->maDelData) );
5484cdf0e10cSrcweir         delete pSVEvent;
5485cdf0e10cSrcweir         return sal_False;
5486cdf0e10cSrcweir     }
5487cdf0e10cSrcweir }
5488cdf0e10cSrcweir 
5489cdf0e10cSrcweir // -----------------------------------------------------------------------
5490cdf0e10cSrcweir 
5491cdf0e10cSrcweir sal_Bool Window::PostUserEvent( sal_uLong& rEventId, const Link& rLink, void* pCaller )
5492cdf0e10cSrcweir {
5493cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5494cdf0e10cSrcweir 
5495cdf0e10cSrcweir     ImplSVEvent* pSVEvent = new ImplSVEvent;
5496cdf0e10cSrcweir     pSVEvent->mnEvent   = 0;
5497cdf0e10cSrcweir     pSVEvent->mpData    = pCaller;
5498cdf0e10cSrcweir     pSVEvent->mpLink    = new Link( rLink );
5499cdf0e10cSrcweir     pSVEvent->mpWindow  = this;
5500cdf0e10cSrcweir     pSVEvent->mbCall    = sal_True;
5501cdf0e10cSrcweir     ImplAddDel( &(pSVEvent->maDelData) );
5502cdf0e10cSrcweir     rEventId = (sal_uLong)pSVEvent;
5503cdf0e10cSrcweir     if ( mpWindowImpl->mpFrame->PostEvent( pSVEvent ) )
5504cdf0e10cSrcweir         return sal_True;
5505cdf0e10cSrcweir     else
5506cdf0e10cSrcweir     {
5507cdf0e10cSrcweir         rEventId = 0;
5508cdf0e10cSrcweir         ImplRemoveDel( &(pSVEvent->maDelData) );
5509cdf0e10cSrcweir         delete pSVEvent;
5510cdf0e10cSrcweir         return sal_False;
5511cdf0e10cSrcweir     }
5512cdf0e10cSrcweir }
5513cdf0e10cSrcweir 
5514cdf0e10cSrcweir // -----------------------------------------------------------------------
5515cdf0e10cSrcweir 
5516cdf0e10cSrcweir void Window::RemoveUserEvent( sal_uLong nUserEvent )
5517cdf0e10cSrcweir {
5518cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5519cdf0e10cSrcweir 
5520cdf0e10cSrcweir     ImplSVEvent* pSVEvent = (ImplSVEvent*)nUserEvent;
5521cdf0e10cSrcweir 
5522cdf0e10cSrcweir     DBG_ASSERT( pSVEvent->mpWindow == this,
5523cdf0e10cSrcweir                 "Window::RemoveUserEvent(): Event doesn't send to this window or is already removed" );
5524cdf0e10cSrcweir     DBG_ASSERT( pSVEvent->mbCall,
5525cdf0e10cSrcweir                 "Window::RemoveUserEvent(): Event is already removed" );
5526cdf0e10cSrcweir 
5527cdf0e10cSrcweir     if ( pSVEvent->mpWindow )
5528cdf0e10cSrcweir     {
5529cdf0e10cSrcweir         pSVEvent->mpWindow->ImplRemoveDel( &(pSVEvent->maDelData) );
5530cdf0e10cSrcweir         pSVEvent->mpWindow = NULL;
5531cdf0e10cSrcweir     }
5532cdf0e10cSrcweir 
5533cdf0e10cSrcweir     pSVEvent->mbCall = sal_False;
5534cdf0e10cSrcweir }
5535cdf0e10cSrcweir 
5536cdf0e10cSrcweir // -----------------------------------------------------------------------
5537cdf0e10cSrcweir 
5538cdf0e10cSrcweir IMPL_LINK( Window, ImplAsyncStateChangedHdl, void*, pState )
5539cdf0e10cSrcweir {
5540cdf0e10cSrcweir     StateChanged( (StateChangedType)(sal_uLong)pState );
5541cdf0e10cSrcweir     return 0;
5542cdf0e10cSrcweir }
5543cdf0e10cSrcweir 
5544cdf0e10cSrcweir // -----------------------------------------------------------------------
5545cdf0e10cSrcweir 
5546cdf0e10cSrcweir void Window::PostStateChanged( StateChangedType nState )
5547cdf0e10cSrcweir {
5548cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5549cdf0e10cSrcweir 
5550cdf0e10cSrcweir     PostUserEvent( LINK( this, Window, ImplAsyncStateChangedHdl ), (void*)(sal_uLong)nState );
5551cdf0e10cSrcweir }
5552cdf0e10cSrcweir 
5553cdf0e10cSrcweir // -----------------------------------------------------------------------
5554cdf0e10cSrcweir 
5555cdf0e10cSrcweir sal_Bool Window::IsLocked( sal_Bool bChilds ) const
5556cdf0e10cSrcweir {
5557cdf0e10cSrcweir     if ( mpWindowImpl->mnLockCount != 0 )
5558cdf0e10cSrcweir         return sal_True;
5559cdf0e10cSrcweir 
5560cdf0e10cSrcweir     if ( bChilds || mpWindowImpl->mbChildNotify )
5561cdf0e10cSrcweir     {
5562cdf0e10cSrcweir         Window* pChild = mpWindowImpl->mpFirstChild;
5563cdf0e10cSrcweir         while ( pChild )
5564cdf0e10cSrcweir         {
5565cdf0e10cSrcweir             if ( pChild->IsLocked( sal_True ) )
5566cdf0e10cSrcweir                 return sal_True;
5567cdf0e10cSrcweir             pChild = pChild->mpWindowImpl->mpNext;
5568cdf0e10cSrcweir         }
5569cdf0e10cSrcweir     }
5570cdf0e10cSrcweir 
5571cdf0e10cSrcweir     return sal_False;
5572cdf0e10cSrcweir }
5573cdf0e10cSrcweir 
5574cdf0e10cSrcweir // -----------------------------------------------------------------------
5575cdf0e10cSrcweir 
5576cdf0e10cSrcweir void Window::SetStyle( WinBits nStyle )
5577cdf0e10cSrcweir {
5578cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5579cdf0e10cSrcweir 
5580cdf0e10cSrcweir     if ( mpWindowImpl->mnStyle != nStyle )
5581cdf0e10cSrcweir     {
5582cdf0e10cSrcweir         mpWindowImpl->mnPrevStyle = mpWindowImpl->mnStyle;
5583cdf0e10cSrcweir         mpWindowImpl->mnStyle = nStyle;
5584cdf0e10cSrcweir         StateChanged( STATE_CHANGE_STYLE );
5585cdf0e10cSrcweir     }
5586cdf0e10cSrcweir }
5587cdf0e10cSrcweir 
5588cdf0e10cSrcweir // -----------------------------------------------------------------------
5589cdf0e10cSrcweir 
5590cdf0e10cSrcweir void Window::SetExtendedStyle( WinBits nExtendedStyle )
5591cdf0e10cSrcweir {
5592cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5593cdf0e10cSrcweir 
5594cdf0e10cSrcweir     if ( mpWindowImpl->mnExtendedStyle != nExtendedStyle )
5595cdf0e10cSrcweir     {
5596cdf0e10cSrcweir         Window* pWindow = ImplGetBorderWindow();
5597cdf0e10cSrcweir         if( ! pWindow )
5598cdf0e10cSrcweir             pWindow = this;
5599cdf0e10cSrcweir         if( pWindow->mpWindowImpl->mbFrame )
5600cdf0e10cSrcweir         {
5601cdf0e10cSrcweir             SalExtStyle nExt = 0;
5602cdf0e10cSrcweir             if( (nExtendedStyle & WB_EXT_DOCUMENT) )
5603cdf0e10cSrcweir                 nExt |= SAL_FRAME_EXT_STYLE_DOCUMENT;
5604cdf0e10cSrcweir             if( (nExtendedStyle & WB_EXT_DOCMODIFIED) )
5605cdf0e10cSrcweir                 nExt |= SAL_FRAME_EXT_STYLE_DOCMODIFIED;
5606cdf0e10cSrcweir 
5607cdf0e10cSrcweir             pWindow->ImplGetFrame()->SetExtendedFrameStyle( nExt );
5608cdf0e10cSrcweir         }
5609cdf0e10cSrcweir         mpWindowImpl->mnPrevExtendedStyle = mpWindowImpl->mnExtendedStyle;
5610cdf0e10cSrcweir         mpWindowImpl->mnExtendedStyle = nExtendedStyle;
5611cdf0e10cSrcweir         StateChanged( STATE_CHANGE_EXTENDEDSTYLE );
5612cdf0e10cSrcweir     }
5613cdf0e10cSrcweir }
5614cdf0e10cSrcweir 
5615cdf0e10cSrcweir // -----------------------------------------------------------------------
5616cdf0e10cSrcweir 
5617cdf0e10cSrcweir SystemWindow* Window::GetSystemWindow() const
5618cdf0e10cSrcweir {
5619cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5620cdf0e10cSrcweir 
5621cdf0e10cSrcweir     const Window* pWin = this;
5622cdf0e10cSrcweir     while ( pWin && !pWin->IsSystemWindow() )
5623cdf0e10cSrcweir         pWin  = pWin->GetParent();
5624cdf0e10cSrcweir     return (SystemWindow*)pWin;
5625cdf0e10cSrcweir }
5626cdf0e10cSrcweir 
5627cdf0e10cSrcweir // -----------------------------------------------------------------------
5628cdf0e10cSrcweir 
5629cdf0e10cSrcweir void Window::SetBorderStyle( sal_uInt16 nBorderStyle )
5630cdf0e10cSrcweir {
5631cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5632cdf0e10cSrcweir 
5633cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
5634cdf0e10cSrcweir     {
5635cdf0e10cSrcweir         if( nBorderStyle == WINDOW_BORDER_REMOVEBORDER &&
5636cdf0e10cSrcweir             ! mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame &&
5637cdf0e10cSrcweir             mpWindowImpl->mpBorderWindow->mpWindowImpl->mpParent
5638cdf0e10cSrcweir             )
5639cdf0e10cSrcweir         {
5640cdf0e10cSrcweir             // this is a little awkward: some controls (e.g. svtools ProgressBar)
5641cdf0e10cSrcweir             // cannot avoid getting constructed with WB_BORDER but want to disable
5642cdf0e10cSrcweir             // borders in case of NWF drawing. So they need a method to remove their border window
5643cdf0e10cSrcweir             Window* pBorderWin = mpWindowImpl->mpBorderWindow;
5644cdf0e10cSrcweir             // remove us as border window's client
5645cdf0e10cSrcweir             pBorderWin->mpWindowImpl->mpClientWindow = NULL;
5646cdf0e10cSrcweir             mpWindowImpl->mpBorderWindow = NULL;
5647cdf0e10cSrcweir             mpWindowImpl->mpRealParent = pBorderWin->mpWindowImpl->mpParent;
5648cdf0e10cSrcweir             // reparent us above the border window
5649cdf0e10cSrcweir             SetParent( pBorderWin->mpWindowImpl->mpParent );
5650cdf0e10cSrcweir             // set us to the position and size of our previous border
5651cdf0e10cSrcweir             Point aBorderPos( pBorderWin->GetPosPixel() );
5652cdf0e10cSrcweir             Size aBorderSize( pBorderWin->GetSizePixel() );
5653cdf0e10cSrcweir             SetPosSizePixel( aBorderPos.X(), aBorderPos.Y(), aBorderSize.Width(), aBorderSize.Height() );
5654cdf0e10cSrcweir             // release border window
5655cdf0e10cSrcweir             delete pBorderWin;
5656cdf0e10cSrcweir 
5657cdf0e10cSrcweir             // set new style bits
5658cdf0e10cSrcweir             SetStyle( GetStyle() & (~WB_BORDER) );
5659cdf0e10cSrcweir         }
5660cdf0e10cSrcweir         else
5661cdf0e10cSrcweir         {
5662cdf0e10cSrcweir             if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW )
5663cdf0e10cSrcweir                  ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->SetBorderStyle( nBorderStyle );
5664cdf0e10cSrcweir             else
5665cdf0e10cSrcweir                 mpWindowImpl->mpBorderWindow->SetBorderStyle( nBorderStyle );
5666cdf0e10cSrcweir         }
5667cdf0e10cSrcweir     }
5668cdf0e10cSrcweir }
5669cdf0e10cSrcweir 
5670cdf0e10cSrcweir // -----------------------------------------------------------------------
5671cdf0e10cSrcweir 
5672cdf0e10cSrcweir sal_uInt16 Window::GetBorderStyle() const
5673cdf0e10cSrcweir {
5674cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5675cdf0e10cSrcweir 
5676cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
5677cdf0e10cSrcweir     {
5678cdf0e10cSrcweir         if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW )
5679cdf0e10cSrcweir             return ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->GetBorderStyle();
5680cdf0e10cSrcweir         else
5681cdf0e10cSrcweir             return mpWindowImpl->mpBorderWindow->GetBorderStyle();
5682cdf0e10cSrcweir     }
5683cdf0e10cSrcweir 
5684cdf0e10cSrcweir     return 0;
5685cdf0e10cSrcweir }
5686cdf0e10cSrcweir 
5687cdf0e10cSrcweir // -----------------------------------------------------------------------
5688cdf0e10cSrcweir 
5689cdf0e10cSrcweir long Window::CalcTitleWidth() const
5690cdf0e10cSrcweir {
5691cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5692cdf0e10cSrcweir 
5693cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
5694cdf0e10cSrcweir     {
5695cdf0e10cSrcweir         if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW )
5696cdf0e10cSrcweir             return ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->CalcTitleWidth();
5697cdf0e10cSrcweir         else
5698cdf0e10cSrcweir             return mpWindowImpl->mpBorderWindow->CalcTitleWidth();
5699cdf0e10cSrcweir     }
5700cdf0e10cSrcweir     else if ( mpWindowImpl->mbFrame && (mpWindowImpl->mnStyle & WB_MOVEABLE) )
5701cdf0e10cSrcweir     {
5702cdf0e10cSrcweir         // Fuer Frame-Fenster raten wir die Breite, da wir den Border fuer
5703cdf0e10cSrcweir         // externe Dialoge nicht kennen
5704cdf0e10cSrcweir         const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
5705cdf0e10cSrcweir         Font aFont = GetFont();
5706cdf0e10cSrcweir         ((Window*)this)->SetPointFont( rStyleSettings.GetTitleFont() );
5707cdf0e10cSrcweir         long nTitleWidth = GetTextWidth( GetText() );
5708cdf0e10cSrcweir         ((Window*)this)->SetFont( aFont );
5709cdf0e10cSrcweir         nTitleWidth += rStyleSettings.GetTitleHeight() * 3;
5710cdf0e10cSrcweir         nTitleWidth += rStyleSettings.GetBorderSize() * 2;
5711cdf0e10cSrcweir         nTitleWidth += 10;
5712cdf0e10cSrcweir         return nTitleWidth;
5713cdf0e10cSrcweir     }
5714cdf0e10cSrcweir 
5715cdf0e10cSrcweir     return 0;
5716cdf0e10cSrcweir }
5717cdf0e10cSrcweir 
5718cdf0e10cSrcweir // -----------------------------------------------------------------------
5719cdf0e10cSrcweir 
5720cdf0e10cSrcweir void Window::EnableClipSiblings( sal_Bool bClipSiblings )
5721cdf0e10cSrcweir {
5722cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5723cdf0e10cSrcweir 
5724cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
5725cdf0e10cSrcweir         mpWindowImpl->mpBorderWindow->EnableClipSiblings( bClipSiblings );
5726cdf0e10cSrcweir 
5727cdf0e10cSrcweir     mpWindowImpl->mbClipSiblings = bClipSiblings;
5728cdf0e10cSrcweir }
5729cdf0e10cSrcweir 
5730cdf0e10cSrcweir // -----------------------------------------------------------------------
5731cdf0e10cSrcweir 
5732cdf0e10cSrcweir void Window::SetMouseTransparent( sal_Bool bTransparent )
5733cdf0e10cSrcweir {
5734cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5735cdf0e10cSrcweir 
5736cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
5737cdf0e10cSrcweir         mpWindowImpl->mpBorderWindow->SetMouseTransparent( bTransparent );
5738cdf0e10cSrcweir 
5739cdf0e10cSrcweir     if( mpWindowImpl->mpSysObj )
5740cdf0e10cSrcweir         mpWindowImpl->mpSysObj->SetMouseTransparent( bTransparent );
5741cdf0e10cSrcweir 
5742cdf0e10cSrcweir     mpWindowImpl->mbMouseTransparent = bTransparent;
5743cdf0e10cSrcweir }
5744cdf0e10cSrcweir 
5745cdf0e10cSrcweir // -----------------------------------------------------------------------
5746cdf0e10cSrcweir 
5747cdf0e10cSrcweir void Window::SetPaintTransparent( sal_Bool bTransparent )
5748cdf0e10cSrcweir {
5749cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5750cdf0e10cSrcweir 
5751cdf0e10cSrcweir     // transparency is not useful for frames as the background would have to be provided by a different frame
5752cdf0e10cSrcweir     if( bTransparent && mpWindowImpl->mbFrame )
5753cdf0e10cSrcweir         return;
5754cdf0e10cSrcweir 
5755cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
5756cdf0e10cSrcweir         mpWindowImpl->mpBorderWindow->SetPaintTransparent( bTransparent );
5757cdf0e10cSrcweir 
5758cdf0e10cSrcweir     mpWindowImpl->mbPaintTransparent = bTransparent;
5759cdf0e10cSrcweir }
5760cdf0e10cSrcweir 
5761cdf0e10cSrcweir // -----------------------------------------------------------------------
5762cdf0e10cSrcweir 
5763cdf0e10cSrcweir void Window::SetInputContext( const InputContext& rInputContext )
5764cdf0e10cSrcweir {
5765cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5766cdf0e10cSrcweir 
5767cdf0e10cSrcweir     mpWindowImpl->maInputContext = rInputContext;
5768cdf0e10cSrcweir     if ( !mpWindowImpl->mbInFocusHdl && HasFocus() )
5769cdf0e10cSrcweir         ImplNewInputContext();
5770cdf0e10cSrcweir }
5771cdf0e10cSrcweir 
5772cdf0e10cSrcweir // -----------------------------------------------------------------------
5773cdf0e10cSrcweir 
5774cdf0e10cSrcweir void Window::EndExtTextInput( sal_uInt16 nFlags )
5775cdf0e10cSrcweir {
5776cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5777cdf0e10cSrcweir 
5778cdf0e10cSrcweir     if ( mpWindowImpl->mbExtTextInput )
5779cdf0e10cSrcweir         ImplGetFrame()->EndExtTextInput( nFlags );
5780cdf0e10cSrcweir }
5781cdf0e10cSrcweir 
5782cdf0e10cSrcweir // -----------------------------------------------------------------------
5783cdf0e10cSrcweir 
5784cdf0e10cSrcweir void Window::SetCursorRect( const Rectangle* pRect, long nExtTextInputWidth )
5785cdf0e10cSrcweir {
5786cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5787cdf0e10cSrcweir 
5788cdf0e10cSrcweir     ImplWinData* pWinData = ImplGetWinData();
5789cdf0e10cSrcweir     if ( pWinData->mpCursorRect )
5790cdf0e10cSrcweir     {
5791cdf0e10cSrcweir         if ( pRect )
5792cdf0e10cSrcweir             *pWinData->mpCursorRect = *pRect;
5793cdf0e10cSrcweir         else
5794cdf0e10cSrcweir         {
5795cdf0e10cSrcweir             delete pWinData->mpCursorRect;
5796cdf0e10cSrcweir             pWinData->mpCursorRect = NULL;
5797cdf0e10cSrcweir         }
5798cdf0e10cSrcweir     }
5799cdf0e10cSrcweir     else
5800cdf0e10cSrcweir     {
5801cdf0e10cSrcweir         if ( pRect )
5802cdf0e10cSrcweir             pWinData->mpCursorRect = new Rectangle( *pRect );
5803cdf0e10cSrcweir     }
5804cdf0e10cSrcweir 
5805cdf0e10cSrcweir     pWinData->mnCursorExtWidth = nExtTextInputWidth;
5806cdf0e10cSrcweir 
5807cdf0e10cSrcweir }
5808cdf0e10cSrcweir 
5809cdf0e10cSrcweir // -----------------------------------------------------------------------
5810cdf0e10cSrcweir 
5811cdf0e10cSrcweir const Rectangle* Window::GetCursorRect() const
5812cdf0e10cSrcweir {
5813cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5814cdf0e10cSrcweir 
5815cdf0e10cSrcweir     ImplWinData* pWinData = ImplGetWinData();
5816cdf0e10cSrcweir     return pWinData->mpCursorRect;
5817cdf0e10cSrcweir }
5818cdf0e10cSrcweir 
5819cdf0e10cSrcweir // -----------------------------------------------------------------------
5820cdf0e10cSrcweir 
5821cdf0e10cSrcweir long Window::GetCursorExtTextInputWidth() const
5822cdf0e10cSrcweir {
5823cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5824cdf0e10cSrcweir 
5825cdf0e10cSrcweir     ImplWinData* pWinData = ImplGetWinData();
5826cdf0e10cSrcweir     return pWinData->mnCursorExtWidth;
5827cdf0e10cSrcweir }
5828cdf0e10cSrcweir 
5829cdf0e10cSrcweir // -----------------------------------------------------------------------
5830cdf0e10cSrcweir void Window::SetSettings( const AllSettings& rSettings )
5831cdf0e10cSrcweir {
5832cdf0e10cSrcweir     SetSettings( rSettings, sal_False );
5833cdf0e10cSrcweir }
5834cdf0e10cSrcweir 
5835cdf0e10cSrcweir void Window::SetSettings( const AllSettings& rSettings, sal_Bool bChild )
5836cdf0e10cSrcweir {
5837cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5838cdf0e10cSrcweir 
5839cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
5840cdf0e10cSrcweir     {
5841cdf0e10cSrcweir         mpWindowImpl->mpBorderWindow->SetSettings( rSettings, sal_False );
5842cdf0e10cSrcweir         if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
5843cdf0e10cSrcweir              ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
5844cdf0e10cSrcweir             ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->SetSettings( rSettings, sal_True );
5845cdf0e10cSrcweir     }
5846cdf0e10cSrcweir 
5847cdf0e10cSrcweir     AllSettings aOldSettings = maSettings;
5848cdf0e10cSrcweir     OutputDevice::SetSettings( rSettings );
5849cdf0e10cSrcweir     sal_uLong nChangeFlags = aOldSettings.GetChangeFlags( rSettings );
5850cdf0e10cSrcweir 
5851cdf0e10cSrcweir     // AppFont-Aufloesung und DPI-Aufloesung neu berechnen
5852cdf0e10cSrcweir     ImplInitResolutionSettings();
5853cdf0e10cSrcweir 
5854cdf0e10cSrcweir     if ( nChangeFlags )
5855cdf0e10cSrcweir     {
5856cdf0e10cSrcweir         DataChangedEvent aDCEvt( DATACHANGED_SETTINGS, &aOldSettings, nChangeFlags );
5857cdf0e10cSrcweir         DataChanged( aDCEvt );
5858cdf0e10cSrcweir     }
5859cdf0e10cSrcweir 
5860cdf0e10cSrcweir     if ( bChild || mpWindowImpl->mbChildNotify )
5861cdf0e10cSrcweir     {
5862cdf0e10cSrcweir         Window* pChild = mpWindowImpl->mpFirstChild;
5863cdf0e10cSrcweir         while ( pChild )
5864cdf0e10cSrcweir         {
5865cdf0e10cSrcweir             pChild->SetSettings( rSettings, bChild );
5866cdf0e10cSrcweir             pChild = pChild->mpWindowImpl->mpNext;
5867cdf0e10cSrcweir         }
5868cdf0e10cSrcweir     }
5869cdf0e10cSrcweir }
5870cdf0e10cSrcweir 
5871cdf0e10cSrcweir // -----------------------------------------------------------------------
5872cdf0e10cSrcweir 
5873cdf0e10cSrcweir void Window::UpdateSettings( const AllSettings& rSettings, sal_Bool bChild )
5874cdf0e10cSrcweir {
5875cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5876cdf0e10cSrcweir 
5877cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
5878cdf0e10cSrcweir     {
5879cdf0e10cSrcweir         mpWindowImpl->mpBorderWindow->UpdateSettings( rSettings, sal_False );
5880cdf0e10cSrcweir         if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
5881cdf0e10cSrcweir              ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
5882cdf0e10cSrcweir             ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->UpdateSettings( rSettings, sal_True );
5883cdf0e10cSrcweir     }
5884cdf0e10cSrcweir 
5885cdf0e10cSrcweir     AllSettings aOldSettings = maSettings;
5886cdf0e10cSrcweir     sal_uLong nChangeFlags = maSettings.Update( maSettings.GetWindowUpdate(), rSettings );
5887cdf0e10cSrcweir 	nChangeFlags |= SETTINGS_IN_UPDATE_SETTINGS; // Set this flag so the receiver of the data changed
5888cdf0e10cSrcweir                                                  // event can distinguish between the changing of global
5889cdf0e10cSrcweir                                                  // setting and a local change ( with SetSettings )
5890cdf0e10cSrcweir 
5891cdf0e10cSrcweir     // AppFont-Aufloesung und DPI-Aufloesung neu berechnen
5892cdf0e10cSrcweir     ImplInitResolutionSettings();
5893cdf0e10cSrcweir 
5894cdf0e10cSrcweir     /* #i73785#
5895cdf0e10cSrcweir     *  do not overwrite a WheelBehavior with false
5896cdf0e10cSrcweir     *  this looks kind of a hack, but WheelBehavior
5897cdf0e10cSrcweir     *  is always a local change, not a system property,
5898cdf0e10cSrcweir     *  so we can spare all our users the hassle of reacting on
5899cdf0e10cSrcweir     *  this in their respective DataChanged.
5900cdf0e10cSrcweir     */
5901cdf0e10cSrcweir     MouseSettings aSet( maSettings.GetMouseSettings() );
5902cdf0e10cSrcweir     aSet.SetWheelBehavior( aOldSettings.GetMouseSettings().GetWheelBehavior() );
5903cdf0e10cSrcweir     maSettings.SetMouseSettings( aSet );
5904cdf0e10cSrcweir 
5905cdf0e10cSrcweir     if( (nChangeFlags & SETTINGS_STYLE) && IsBackground() )
5906cdf0e10cSrcweir     {
5907cdf0e10cSrcweir         Wallpaper aWallpaper = GetBackground();
5908cdf0e10cSrcweir         if( !aWallpaper.IsBitmap() && !aWallpaper.IsGradient() )
5909cdf0e10cSrcweir         {
5910cdf0e10cSrcweir             if ( mpWindowImpl->mnStyle & WB_3DLOOK )
5911cdf0e10cSrcweir                 SetBackground( Wallpaper( rSettings.GetStyleSettings().GetFaceColor() ) );
5912cdf0e10cSrcweir             else
5913cdf0e10cSrcweir                 SetBackground( Wallpaper( rSettings.GetStyleSettings().GetWindowColor() ) );
5914cdf0e10cSrcweir         }
5915cdf0e10cSrcweir     }
5916cdf0e10cSrcweir 
5917cdf0e10cSrcweir     if ( nChangeFlags )
5918cdf0e10cSrcweir     {
5919cdf0e10cSrcweir         DataChangedEvent aDCEvt( DATACHANGED_SETTINGS, &aOldSettings, nChangeFlags );
5920cdf0e10cSrcweir         DataChanged( aDCEvt );
5921cdf0e10cSrcweir         // notify data change handler
5922cdf0e10cSrcweir         ImplCallEventListeners( VCLEVENT_WINDOW_DATACHANGED, &aDCEvt);
5923cdf0e10cSrcweir     }
5924cdf0e10cSrcweir 
5925cdf0e10cSrcweir     if ( bChild || mpWindowImpl->mbChildNotify )
5926cdf0e10cSrcweir     {
5927cdf0e10cSrcweir         Window* pChild = mpWindowImpl->mpFirstChild;
5928cdf0e10cSrcweir         while ( pChild )
5929cdf0e10cSrcweir         {
5930cdf0e10cSrcweir             pChild->UpdateSettings( rSettings, bChild );
5931cdf0e10cSrcweir             pChild = pChild->mpWindowImpl->mpNext;
5932cdf0e10cSrcweir         }
5933cdf0e10cSrcweir     }
5934cdf0e10cSrcweir }
5935cdf0e10cSrcweir 
5936cdf0e10cSrcweir // -----------------------------------------------------------------------
5937cdf0e10cSrcweir 
5938cdf0e10cSrcweir void Window::NotifyAllChilds( DataChangedEvent& rDCEvt )
5939cdf0e10cSrcweir {
5940cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5941cdf0e10cSrcweir 
5942cdf0e10cSrcweir     DataChanged( rDCEvt );
5943cdf0e10cSrcweir 
5944cdf0e10cSrcweir     Window* pChild = mpWindowImpl->mpFirstChild;
5945cdf0e10cSrcweir     while ( pChild )
5946cdf0e10cSrcweir     {
5947cdf0e10cSrcweir         pChild->NotifyAllChilds( rDCEvt );
5948cdf0e10cSrcweir         pChild = pChild->mpWindowImpl->mpNext;
5949cdf0e10cSrcweir     }
5950cdf0e10cSrcweir }
5951cdf0e10cSrcweir 
5952cdf0e10cSrcweir // -----------------------------------------------------------------------
5953cdf0e10cSrcweir 
5954cdf0e10cSrcweir void Window::SetPointFont( const Font& rFont )
5955cdf0e10cSrcweir {
5956cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5957cdf0e10cSrcweir 
5958cdf0e10cSrcweir     Font aFont = rFont;
5959cdf0e10cSrcweir     ImplPointToLogic( aFont );
5960cdf0e10cSrcweir     SetFont( aFont );
5961cdf0e10cSrcweir }
5962cdf0e10cSrcweir 
5963cdf0e10cSrcweir // -----------------------------------------------------------------------
5964cdf0e10cSrcweir 
5965cdf0e10cSrcweir Font Window::GetPointFont() const
5966cdf0e10cSrcweir {
5967cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5968cdf0e10cSrcweir 
5969cdf0e10cSrcweir     Font aFont = GetFont();
5970cdf0e10cSrcweir     ImplLogicToPoint( aFont );
5971cdf0e10cSrcweir     return aFont;
5972cdf0e10cSrcweir }
5973cdf0e10cSrcweir 
5974cdf0e10cSrcweir // -----------------------------------------------------------------------
5975cdf0e10cSrcweir 
5976cdf0e10cSrcweir // TODO: remove in next incompatible build
5977cdf0e10cSrcweir void Window::GetFontResolution( sal_Int32& nDPIX, sal_Int32& nDPIY ) const
5978cdf0e10cSrcweir {
5979cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5980cdf0e10cSrcweir 
5981cdf0e10cSrcweir     nDPIX = mpWindowImpl->mpFrameData->mnDPIX;
5982cdf0e10cSrcweir     nDPIY = mpWindowImpl->mpFrameData->mnDPIY;
5983cdf0e10cSrcweir }
5984cdf0e10cSrcweir 
5985cdf0e10cSrcweir // -----------------------------------------------------------------------
5986cdf0e10cSrcweir 
5987cdf0e10cSrcweir void Window::SetParentClipMode( sal_uInt16 nMode )
5988cdf0e10cSrcweir {
5989cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
5990cdf0e10cSrcweir 
5991cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
5992cdf0e10cSrcweir         mpWindowImpl->mpBorderWindow->SetParentClipMode( nMode );
5993cdf0e10cSrcweir     else
5994cdf0e10cSrcweir     {
5995cdf0e10cSrcweir         if ( !ImplIsOverlapWindow() )
5996cdf0e10cSrcweir         {
5997cdf0e10cSrcweir             mpWindowImpl->mnParentClipMode = nMode;
5998cdf0e10cSrcweir             if ( nMode & PARENTCLIPMODE_CLIP )
5999cdf0e10cSrcweir                 mpWindowImpl->mpParent->mpWindowImpl->mbClipChildren = sal_True;
6000cdf0e10cSrcweir         }
6001cdf0e10cSrcweir     }
6002cdf0e10cSrcweir }
6003cdf0e10cSrcweir 
6004cdf0e10cSrcweir // -----------------------------------------------------------------------
6005cdf0e10cSrcweir 
6006cdf0e10cSrcweir sal_uInt16 Window::GetParentClipMode() const
6007cdf0e10cSrcweir {
6008cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
6009cdf0e10cSrcweir 
6010cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
6011cdf0e10cSrcweir         return mpWindowImpl->mpBorderWindow->GetParentClipMode();
6012cdf0e10cSrcweir     else
6013cdf0e10cSrcweir         return mpWindowImpl->mnParentClipMode;
6014cdf0e10cSrcweir }
6015cdf0e10cSrcweir 
6016cdf0e10cSrcweir // -----------------------------------------------------------------------
6017cdf0e10cSrcweir 
6018cdf0e10cSrcweir void Window::SetWindowRegionPixel()
6019cdf0e10cSrcweir {
6020cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
6021cdf0e10cSrcweir 
6022cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
6023cdf0e10cSrcweir         mpWindowImpl->mpBorderWindow->SetWindowRegionPixel();
6024cdf0e10cSrcweir     else if( mpWindowImpl->mbFrame )
6025cdf0e10cSrcweir     {
6026cdf0e10cSrcweir         mpWindowImpl->maWinRegion = Region( REGION_NULL);
6027cdf0e10cSrcweir         mpWindowImpl->mbWinRegion = sal_False;
6028cdf0e10cSrcweir         mpWindowImpl->mpFrame->ResetClipRegion();
6029cdf0e10cSrcweir     }
6030cdf0e10cSrcweir     else
6031cdf0e10cSrcweir     {
6032cdf0e10cSrcweir         if ( mpWindowImpl->mbWinRegion )
6033cdf0e10cSrcweir         {
6034cdf0e10cSrcweir             mpWindowImpl->maWinRegion = Region( REGION_NULL );
6035cdf0e10cSrcweir             mpWindowImpl->mbWinRegion = sal_False;
6036cdf0e10cSrcweir             ImplSetClipFlag();
6037cdf0e10cSrcweir 
6038cdf0e10cSrcweir             if ( IsReallyVisible() )
6039cdf0e10cSrcweir             {
6040cdf0e10cSrcweir                 // Hintergrund-Sicherung zuruecksetzen
6041cdf0e10cSrcweir                 if ( mpWindowImpl->mpOverlapData && mpWindowImpl->mpOverlapData->mpSaveBackDev )
6042cdf0e10cSrcweir                     ImplDeleteOverlapBackground();
6043cdf0e10cSrcweir                 if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
6044cdf0e10cSrcweir                     ImplInvalidateAllOverlapBackgrounds();
6045cdf0e10cSrcweir                 Rectangle   aRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
6046cdf0e10cSrcweir                 Region      aRegion( aRect );
6047cdf0e10cSrcweir                 ImplInvalidateParentFrameRegion( aRegion );
6048cdf0e10cSrcweir             }
6049cdf0e10cSrcweir         }
6050cdf0e10cSrcweir     }
6051cdf0e10cSrcweir }
6052cdf0e10cSrcweir 
6053cdf0e10cSrcweir // -----------------------------------------------------------------------
6054cdf0e10cSrcweir 
6055cdf0e10cSrcweir void Window::SetWindowRegionPixel( const Region& rRegion )
6056cdf0e10cSrcweir {
6057cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
6058cdf0e10cSrcweir 
6059cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
6060cdf0e10cSrcweir         mpWindowImpl->mpBorderWindow->SetWindowRegionPixel( rRegion );
6061cdf0e10cSrcweir     else if( mpWindowImpl->mbFrame )
6062cdf0e10cSrcweir     {
6063cdf0e10cSrcweir         if( rRegion.GetType() != REGION_NULL )
6064cdf0e10cSrcweir         {
6065cdf0e10cSrcweir             mpWindowImpl->maWinRegion = rRegion;
6066cdf0e10cSrcweir             mpWindowImpl->mbWinRegion = ! rRegion.IsEmpty();
6067cdf0e10cSrcweir             if( mpWindowImpl->mbWinRegion )
6068cdf0e10cSrcweir             {
6069cdf0e10cSrcweir                 // ClipRegion setzen/updaten
6070cdf0e10cSrcweir                 long                nX;
6071cdf0e10cSrcweir                 long                nY;
6072cdf0e10cSrcweir                 long                nWidth;
6073cdf0e10cSrcweir                 long                nHeight;
6074cdf0e10cSrcweir                 sal_uLong               nRectCount;
6075cdf0e10cSrcweir                 ImplRegionInfo      aInfo;
6076cdf0e10cSrcweir                 sal_Bool                bRegionRect;
6077cdf0e10cSrcweir 
6078cdf0e10cSrcweir                 nRectCount = mpWindowImpl->maWinRegion.GetRectCount();
6079cdf0e10cSrcweir                 mpWindowImpl->mpFrame->BeginSetClipRegion( nRectCount );
6080cdf0e10cSrcweir                 bRegionRect = mpWindowImpl->maWinRegion.ImplGetFirstRect( aInfo, nX, nY, nWidth, nHeight );
6081cdf0e10cSrcweir                 while ( bRegionRect )
6082cdf0e10cSrcweir                 {
6083cdf0e10cSrcweir                     mpWindowImpl->mpFrame->UnionClipRegion( nX, nY, nWidth, nHeight );
6084cdf0e10cSrcweir                     bRegionRect = mpWindowImpl->maWinRegion.ImplGetNextRect( aInfo, nX, nY, nWidth, nHeight );
6085cdf0e10cSrcweir                 }
6086cdf0e10cSrcweir                 mpWindowImpl->mpFrame->EndSetClipRegion();
6087cdf0e10cSrcweir             }
6088cdf0e10cSrcweir             else
6089cdf0e10cSrcweir                 SetWindowRegionPixel();
6090cdf0e10cSrcweir         }
6091cdf0e10cSrcweir         else
6092cdf0e10cSrcweir             SetWindowRegionPixel();
6093cdf0e10cSrcweir     }
6094cdf0e10cSrcweir     else
6095cdf0e10cSrcweir     {
6096cdf0e10cSrcweir         sal_Bool bInvalidate = sal_False;
6097cdf0e10cSrcweir 
6098cdf0e10cSrcweir         if ( rRegion.GetType() == REGION_NULL )
6099cdf0e10cSrcweir         {
6100cdf0e10cSrcweir             if ( mpWindowImpl->mbWinRegion )
6101cdf0e10cSrcweir             {
6102cdf0e10cSrcweir                 mpWindowImpl->maWinRegion = Region( REGION_NULL );
6103cdf0e10cSrcweir                 mpWindowImpl->mbWinRegion = sal_False;
6104cdf0e10cSrcweir                 ImplSetClipFlag();
6105cdf0e10cSrcweir                 bInvalidate = sal_True;
6106cdf0e10cSrcweir             }
6107cdf0e10cSrcweir         }
6108cdf0e10cSrcweir         else
6109cdf0e10cSrcweir         {
6110cdf0e10cSrcweir             mpWindowImpl->maWinRegion = rRegion;
6111cdf0e10cSrcweir             mpWindowImpl->mbWinRegion = sal_True;
6112cdf0e10cSrcweir             ImplSetClipFlag();
6113cdf0e10cSrcweir             bInvalidate = sal_True;
6114cdf0e10cSrcweir         }
6115cdf0e10cSrcweir 
6116cdf0e10cSrcweir         if ( IsReallyVisible() )
6117cdf0e10cSrcweir         {
6118cdf0e10cSrcweir             // Hintergrund-Sicherung zuruecksetzen
6119cdf0e10cSrcweir             if ( mpWindowImpl->mpOverlapData && mpWindowImpl->mpOverlapData->mpSaveBackDev )
6120cdf0e10cSrcweir                 ImplDeleteOverlapBackground();
6121cdf0e10cSrcweir             if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
6122cdf0e10cSrcweir                 ImplInvalidateAllOverlapBackgrounds();
6123cdf0e10cSrcweir             Rectangle   aRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
6124cdf0e10cSrcweir             Region      aRegion( aRect );
6125cdf0e10cSrcweir             ImplInvalidateParentFrameRegion( aRegion );
6126cdf0e10cSrcweir         }
6127cdf0e10cSrcweir     }
6128cdf0e10cSrcweir }
6129cdf0e10cSrcweir 
6130cdf0e10cSrcweir // -----------------------------------------------------------------------
6131cdf0e10cSrcweir 
6132cdf0e10cSrcweir const Region& Window::GetWindowRegionPixel() const
6133cdf0e10cSrcweir {
6134cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
6135cdf0e10cSrcweir 
6136cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
6137cdf0e10cSrcweir         return mpWindowImpl->mpBorderWindow->GetWindowRegionPixel();
6138cdf0e10cSrcweir     else
6139cdf0e10cSrcweir         return mpWindowImpl->maWinRegion;
6140cdf0e10cSrcweir }
6141cdf0e10cSrcweir 
6142cdf0e10cSrcweir // -----------------------------------------------------------------------
6143cdf0e10cSrcweir 
6144cdf0e10cSrcweir sal_Bool Window::IsWindowRegionPixel() const
6145cdf0e10cSrcweir {
6146cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
6147cdf0e10cSrcweir 
6148cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
6149cdf0e10cSrcweir         return mpWindowImpl->mpBorderWindow->IsWindowRegionPixel();
6150cdf0e10cSrcweir     else
6151cdf0e10cSrcweir         return mpWindowImpl->mbWinRegion;
6152cdf0e10cSrcweir }
6153cdf0e10cSrcweir 
6154cdf0e10cSrcweir // -----------------------------------------------------------------------
6155cdf0e10cSrcweir 
6156cdf0e10cSrcweir Region Window::GetWindowClipRegionPixel( sal_uInt16 nFlags ) const
6157cdf0e10cSrcweir {
6158cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
6159cdf0e10cSrcweir 
6160cdf0e10cSrcweir     Region aWinClipRegion;
6161cdf0e10cSrcweir 
6162cdf0e10cSrcweir     if ( nFlags & WINDOW_GETCLIPREGION_NOCHILDREN )
6163cdf0e10cSrcweir     {
6164cdf0e10cSrcweir         if ( mpWindowImpl->mbInitWinClipRegion )
6165cdf0e10cSrcweir             ((Window*)this)->ImplInitWinClipRegion();
6166cdf0e10cSrcweir         aWinClipRegion = mpWindowImpl->maWinClipRegion;
6167cdf0e10cSrcweir     }
6168cdf0e10cSrcweir     else
6169cdf0e10cSrcweir     {
6170cdf0e10cSrcweir         Region* pWinChildClipRegion = ((Window*)this)->ImplGetWinChildClipRegion();
6171cdf0e10cSrcweir         aWinClipRegion = *pWinChildClipRegion;
6172cdf0e10cSrcweir         // --- RTL --- remirror clip region before passing it to somebody
6173cdf0e10cSrcweir         if( ImplIsAntiparallel() )
6174cdf0e10cSrcweir             ImplReMirror( aWinClipRegion );
6175cdf0e10cSrcweir     }
6176cdf0e10cSrcweir 
6177cdf0e10cSrcweir     if ( nFlags & WINDOW_GETCLIPREGION_NULL )
6178cdf0e10cSrcweir     {
6179cdf0e10cSrcweir         Rectangle   aWinRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
6180cdf0e10cSrcweir         Region      aWinRegion( aWinRect );
6181cdf0e10cSrcweir 
6182cdf0e10cSrcweir         if ( aWinRegion == aWinClipRegion )
6183cdf0e10cSrcweir             aWinClipRegion.SetNull();
6184cdf0e10cSrcweir     }
6185cdf0e10cSrcweir 
6186cdf0e10cSrcweir     aWinClipRegion.Move( -mnOutOffX, -mnOutOffY );
6187cdf0e10cSrcweir 
6188cdf0e10cSrcweir     return aWinClipRegion;
6189cdf0e10cSrcweir }
6190cdf0e10cSrcweir 
6191cdf0e10cSrcweir // -----------------------------------------------------------------------
6192cdf0e10cSrcweir 
6193cdf0e10cSrcweir Region Window::GetPaintRegion() const
6194cdf0e10cSrcweir {
6195cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
6196cdf0e10cSrcweir 
6197cdf0e10cSrcweir     if ( mpWindowImpl->mpPaintRegion )
6198cdf0e10cSrcweir     {
6199cdf0e10cSrcweir         Region aRegion = *mpWindowImpl->mpPaintRegion;
6200cdf0e10cSrcweir         aRegion.Move( -mnOutOffX, -mnOutOffY );
6201cdf0e10cSrcweir         return PixelToLogic( aRegion );
6202cdf0e10cSrcweir     }
6203cdf0e10cSrcweir     else
6204cdf0e10cSrcweir     {
6205cdf0e10cSrcweir         Region aPaintRegion( REGION_NULL );
6206cdf0e10cSrcweir         return aPaintRegion;
6207cdf0e10cSrcweir     }
6208cdf0e10cSrcweir }
6209cdf0e10cSrcweir 
6210cdf0e10cSrcweir // -----------------------------------------------------------------------
6211cdf0e10cSrcweir 
6212cdf0e10cSrcweir void Window::ExpandPaintClipRegion( const Region& rRegion )
6213cdf0e10cSrcweir {
6214cdf0e10cSrcweir     if( mpWindowImpl->mpPaintRegion )
6215cdf0e10cSrcweir     {
6216cdf0e10cSrcweir         Region aPixRegion = LogicToPixel( rRegion );
6217cdf0e10cSrcweir         Region aDevPixRegion = ImplPixelToDevicePixel( aPixRegion );
6218cdf0e10cSrcweir 
6219cdf0e10cSrcweir         Region aWinChildRegion = *ImplGetWinChildClipRegion();
6220cdf0e10cSrcweir         // --- RTL -- only this region is in frame coordinates, so re-mirror it
6221cdf0e10cSrcweir         if( ImplIsAntiparallel() )
6222cdf0e10cSrcweir             ImplReMirror( aWinChildRegion );
6223cdf0e10cSrcweir         aDevPixRegion.Intersect( aWinChildRegion );
6224cdf0e10cSrcweir         if( ! aDevPixRegion.IsEmpty() )
6225cdf0e10cSrcweir         {
6226cdf0e10cSrcweir             mpWindowImpl->mpPaintRegion->Union( aDevPixRegion );
6227cdf0e10cSrcweir             mbInitClipRegion = sal_True;
6228cdf0e10cSrcweir         }
6229cdf0e10cSrcweir     }
6230cdf0e10cSrcweir }
6231cdf0e10cSrcweir 
6232cdf0e10cSrcweir // -----------------------------------------------------------------------
6233cdf0e10cSrcweir 
6234cdf0e10cSrcweir static SystemWindow *ImplGetLastSystemWindow( Window *pWin )
6235cdf0e10cSrcweir {
6236cdf0e10cSrcweir     // get the most top-level system window, the one that contains the taskpanelist
6237cdf0e10cSrcweir     SystemWindow *pSysWin = NULL;
6238cdf0e10cSrcweir     if( !pWin )
6239cdf0e10cSrcweir         return pSysWin;
6240cdf0e10cSrcweir     Window *pMyParent = pWin;
6241cdf0e10cSrcweir     while ( pMyParent )
6242cdf0e10cSrcweir     {
6243cdf0e10cSrcweir         if ( pMyParent->IsSystemWindow() )
6244cdf0e10cSrcweir             pSysWin = (SystemWindow*)pMyParent;
6245cdf0e10cSrcweir         pMyParent = pMyParent->GetParent();
6246cdf0e10cSrcweir     }
6247cdf0e10cSrcweir     return pSysWin;
6248cdf0e10cSrcweir }
6249cdf0e10cSrcweir 
6250cdf0e10cSrcweir void Window::SetParent( Window* pNewParent )
6251cdf0e10cSrcweir {
6252cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
6253cdf0e10cSrcweir     DBG_ASSERT( pNewParent, "Window::SetParent(): pParent == NULL" );
6254cdf0e10cSrcweir     DBG_ASSERT( pNewParent != this, "someone tried to reparent a window to itself" );
6255cdf0e10cSrcweir 
6256cdf0e10cSrcweir     if( pNewParent == this )
6257cdf0e10cSrcweir         return;
6258cdf0e10cSrcweir 
6259cdf0e10cSrcweir     // check if the taskpanelist would change and move the window pointer accordingly
6260cdf0e10cSrcweir     SystemWindow *pSysWin = ImplGetLastSystemWindow(this);
6261cdf0e10cSrcweir     SystemWindow *pNewSysWin = NULL;
6262cdf0e10cSrcweir     sal_Bool bChangeTaskPaneList = sal_False;
6263cdf0e10cSrcweir     if( pSysWin && pSysWin->ImplIsInTaskPaneList( this ) )
6264cdf0e10cSrcweir     {
6265cdf0e10cSrcweir         pNewSysWin = ImplGetLastSystemWindow( pNewParent );
6266cdf0e10cSrcweir         if( pNewSysWin && pNewSysWin != pSysWin )
6267cdf0e10cSrcweir         {
6268cdf0e10cSrcweir             bChangeTaskPaneList = sal_True;
6269cdf0e10cSrcweir             pSysWin->GetTaskPaneList()->RemoveWindow( this );
6270cdf0e10cSrcweir         }
6271cdf0e10cSrcweir     }
6272cdf0e10cSrcweir     // remove ownerdraw decorated windows from list in the top-most frame window
6273cdf0e10cSrcweir     if( (GetStyle() & WB_OWNERDRAWDECORATION) && mpWindowImpl->mbFrame )
6274cdf0e10cSrcweir     {
6275cdf0e10cSrcweir         ::std::vector< Window* >& rList = ImplGetOwnerDrawList();
6276cdf0e10cSrcweir 	    ::std::vector< Window* >::iterator p;
6277cdf0e10cSrcweir         p = ::std::find( rList.begin(), rList.end(), this );
6278cdf0e10cSrcweir         if( p != rList.end() )
6279cdf0e10cSrcweir 	        rList.erase( p );
6280cdf0e10cSrcweir     }
6281cdf0e10cSrcweir 
6282cdf0e10cSrcweir     ImplSetFrameParent( pNewParent );
6283cdf0e10cSrcweir 
6284cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
6285cdf0e10cSrcweir     {
6286cdf0e10cSrcweir         mpWindowImpl->mpRealParent = pNewParent;
6287cdf0e10cSrcweir         mpWindowImpl->mpBorderWindow->SetParent( pNewParent );
6288cdf0e10cSrcweir         return;
6289cdf0e10cSrcweir     }
6290cdf0e10cSrcweir 
6291cdf0e10cSrcweir     if ( mpWindowImpl->mpParent == pNewParent )
6292cdf0e10cSrcweir         return;
6293cdf0e10cSrcweir 
6294cdf0e10cSrcweir     if ( mpWindowImpl->mbFrame )
6295cdf0e10cSrcweir         mpWindowImpl->mpFrame->SetParent( pNewParent->mpWindowImpl->mpFrame );
6296cdf0e10cSrcweir 
6297cdf0e10cSrcweir     sal_Bool bVisible = IsVisible();
6298cdf0e10cSrcweir     Show( sal_False, SHOW_NOFOCUSCHANGE );
6299cdf0e10cSrcweir 
6300cdf0e10cSrcweir     // Testen, ob sich das Overlap-Window aendert
6301cdf0e10cSrcweir     Window* pOldOverlapWindow;
6302cdf0e10cSrcweir     Window* pNewOverlapWindow = NULL;
6303cdf0e10cSrcweir     if ( ImplIsOverlapWindow() )
6304cdf0e10cSrcweir         pOldOverlapWindow = NULL;
6305cdf0e10cSrcweir     else
6306cdf0e10cSrcweir     {
6307cdf0e10cSrcweir         pNewOverlapWindow = pNewParent->ImplGetFirstOverlapWindow();
6308cdf0e10cSrcweir         if ( mpWindowImpl->mpOverlapWindow != pNewOverlapWindow )
6309cdf0e10cSrcweir             pOldOverlapWindow = mpWindowImpl->mpOverlapWindow;
6310cdf0e10cSrcweir         else
6311cdf0e10cSrcweir             pOldOverlapWindow = NULL;
6312cdf0e10cSrcweir     }
6313cdf0e10cSrcweir 
6314cdf0e10cSrcweir     // Fenster in der Hirachie umsetzen
6315cdf0e10cSrcweir     sal_Bool bFocusOverlapWin = HasChildPathFocus( sal_True );
6316cdf0e10cSrcweir     sal_Bool bFocusWin = HasChildPathFocus();
6317cdf0e10cSrcweir     sal_Bool bNewFrame = pNewParent->mpWindowImpl->mpFrameWindow != mpWindowImpl->mpFrameWindow;
6318cdf0e10cSrcweir     if ( bNewFrame )
6319cdf0e10cSrcweir     {
6320cdf0e10cSrcweir         if ( mpWindowImpl->mpFrameData->mpFocusWin )
6321cdf0e10cSrcweir         {
6322cdf0e10cSrcweir             if ( IsWindowOrChild( mpWindowImpl->mpFrameData->mpFocusWin ) )
6323cdf0e10cSrcweir                 mpWindowImpl->mpFrameData->mpFocusWin = NULL;
6324cdf0e10cSrcweir         }
6325cdf0e10cSrcweir         if ( mpWindowImpl->mpFrameData->mpMouseMoveWin )
6326cdf0e10cSrcweir         {
6327cdf0e10cSrcweir             if ( IsWindowOrChild( mpWindowImpl->mpFrameData->mpMouseMoveWin ) )
6328cdf0e10cSrcweir                 mpWindowImpl->mpFrameData->mpMouseMoveWin = NULL;
6329cdf0e10cSrcweir         }
6330cdf0e10cSrcweir         if ( mpWindowImpl->mpFrameData->mpMouseDownWin )
6331cdf0e10cSrcweir         {
6332cdf0e10cSrcweir             if ( IsWindowOrChild( mpWindowImpl->mpFrameData->mpMouseDownWin ) )
6333cdf0e10cSrcweir                 mpWindowImpl->mpFrameData->mpMouseDownWin = NULL;
6334cdf0e10cSrcweir         }
6335cdf0e10cSrcweir     }
6336cdf0e10cSrcweir     ImplRemoveWindow( bNewFrame );
6337cdf0e10cSrcweir     ImplInsertWindow( pNewParent );
6338cdf0e10cSrcweir     if ( mpWindowImpl->mnParentClipMode & PARENTCLIPMODE_CLIP )
6339cdf0e10cSrcweir         pNewParent->mpWindowImpl->mbClipChildren = sal_True;
6340cdf0e10cSrcweir     ImplUpdateWindowPtr();
6341cdf0e10cSrcweir     if ( ImplUpdatePos() )
6342cdf0e10cSrcweir         ImplUpdateSysObjPos();
6343cdf0e10cSrcweir 
6344cdf0e10cSrcweir     // Wenn sich das Overlap-Window geaendert hat, dann muss getestet werden,
6345cdf0e10cSrcweir     // ob auch OverlapWindow die das Child-Fenster als Parent gehabt haben
6346cdf0e10cSrcweir     // in der Window-Hirachie umgesetzt werden muessen
6347cdf0e10cSrcweir     if ( ImplIsOverlapWindow() )
6348cdf0e10cSrcweir     {
6349cdf0e10cSrcweir         if ( bNewFrame )
6350cdf0e10cSrcweir         {
6351cdf0e10cSrcweir             Window* pOverlapWindow = mpWindowImpl->mpFirstOverlap;
6352cdf0e10cSrcweir             while ( pOverlapWindow )
6353cdf0e10cSrcweir             {
6354cdf0e10cSrcweir                 Window* pNextOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext;
6355cdf0e10cSrcweir                 pOverlapWindow->ImplUpdateOverlapWindowPtr( bNewFrame );
6356cdf0e10cSrcweir                 pOverlapWindow = pNextOverlapWindow;
6357cdf0e10cSrcweir             }
6358cdf0e10cSrcweir         }
6359cdf0e10cSrcweir     }
6360cdf0e10cSrcweir     else if ( pOldOverlapWindow )
6361cdf0e10cSrcweir     {
6362cdf0e10cSrcweir         // Focus-Save zuruecksetzen
6363cdf0e10cSrcweir         if ( bFocusWin ||
6364cdf0e10cSrcweir              (pOldOverlapWindow->mpWindowImpl->mpLastFocusWindow &&
6365cdf0e10cSrcweir               IsWindowOrChild( pOldOverlapWindow->mpWindowImpl->mpLastFocusWindow )) )
6366cdf0e10cSrcweir             pOldOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL;
6367cdf0e10cSrcweir 
6368cdf0e10cSrcweir         Window* pOverlapWindow = pOldOverlapWindow->mpWindowImpl->mpFirstOverlap;
6369cdf0e10cSrcweir         while ( pOverlapWindow )
6370cdf0e10cSrcweir         {
6371cdf0e10cSrcweir             Window* pNextOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext;
6372cdf0e10cSrcweir             if ( ImplIsRealParentPath( pOverlapWindow->ImplGetWindow() ) )
6373cdf0e10cSrcweir                 pOverlapWindow->ImplUpdateOverlapWindowPtr( bNewFrame );
6374cdf0e10cSrcweir             pOverlapWindow = pNextOverlapWindow;
6375cdf0e10cSrcweir         }
6376cdf0e10cSrcweir 
6377cdf0e10cSrcweir         // Activate-Status beim naechsten Overlap-Window updaten
6378cdf0e10cSrcweir         if ( HasChildPathFocus( sal_True ) )
6379cdf0e10cSrcweir             ImplCallFocusChangeActivate( pNewOverlapWindow, pOldOverlapWindow );
6380cdf0e10cSrcweir     }
6381cdf0e10cSrcweir 
6382cdf0e10cSrcweir     // Activate-Status mit umsetzen
6383cdf0e10cSrcweir     if ( bNewFrame )
6384cdf0e10cSrcweir     {
6385cdf0e10cSrcweir         if ( (GetType() == WINDOW_BORDERWINDOW) &&
6386cdf0e10cSrcweir              (ImplGetWindow()->GetType() == WINDOW_FLOATINGWINDOW) )
6387cdf0e10cSrcweir             ((ImplBorderWindow*)this)->SetDisplayActive( mpWindowImpl->mpFrameData->mbHasFocus );
6388cdf0e10cSrcweir     }
6389cdf0e10cSrcweir 
6390cdf0e10cSrcweir     // Focus evtl. auf den neuen Frame umsetzen, wenn FocusWindow mit
6391cdf0e10cSrcweir     // SetParent() umgesetzt wird
6392cdf0e10cSrcweir     if ( bFocusOverlapWin )
6393cdf0e10cSrcweir     {
6394cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mpFocusWin = Application::GetFocusWindow();
6395cdf0e10cSrcweir         if ( !mpWindowImpl->mpFrameData->mbHasFocus )
6396cdf0e10cSrcweir         {
6397cdf0e10cSrcweir             mpWindowImpl->mpFrame->ToTop( 0 );
6398cdf0e10cSrcweir         }
6399cdf0e10cSrcweir     }
6400cdf0e10cSrcweir 
6401cdf0e10cSrcweir     // Assure DragSource and DropTarget members are created
6402cdf0e10cSrcweir     if ( bNewFrame )
6403cdf0e10cSrcweir     {
6404cdf0e10cSrcweir             GetDropTarget();
6405cdf0e10cSrcweir     }
6406cdf0e10cSrcweir 
6407cdf0e10cSrcweir     if( bChangeTaskPaneList )
6408cdf0e10cSrcweir         pNewSysWin->GetTaskPaneList()->AddWindow( this );
6409cdf0e10cSrcweir 
6410cdf0e10cSrcweir 	if( (GetStyle() & WB_OWNERDRAWDECORATION) && mpWindowImpl->mbFrame )
6411cdf0e10cSrcweir         ImplGetOwnerDrawList().push_back( this );
6412cdf0e10cSrcweir 
6413cdf0e10cSrcweir     if ( bVisible )
6414cdf0e10cSrcweir         Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
6415cdf0e10cSrcweir }
6416cdf0e10cSrcweir 
6417cdf0e10cSrcweir // -----------------------------------------------------------------------
6418cdf0e10cSrcweir 
6419cdf0e10cSrcweir void Window::Show( sal_Bool bVisible, sal_uInt16 nFlags )
6420cdf0e10cSrcweir {
6421cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
6422cdf0e10cSrcweir 
6423cdf0e10cSrcweir     if ( mpWindowImpl->mbVisible == bVisible )
6424cdf0e10cSrcweir         return;
6425cdf0e10cSrcweir 
6426cdf0e10cSrcweir     ImplDelData aDogTag( this );
6427cdf0e10cSrcweir 
6428cdf0e10cSrcweir     sal_Bool bRealVisibilityChanged = sal_False;
6429cdf0e10cSrcweir     mpWindowImpl->mbVisible = (bVisible != 0);
6430cdf0e10cSrcweir 
6431cdf0e10cSrcweir     if ( !bVisible )
6432cdf0e10cSrcweir     {
6433cdf0e10cSrcweir         ImplHideAllOverlaps();
6434cdf0e10cSrcweir         if( aDogTag.IsDelete() )
6435cdf0e10cSrcweir             return;
6436cdf0e10cSrcweir 
6437cdf0e10cSrcweir         if ( mpWindowImpl->mpBorderWindow )
6438cdf0e10cSrcweir         {
6439cdf0e10cSrcweir             sal_Bool bOldUpdate = mpWindowImpl->mpBorderWindow->mpWindowImpl->mbNoParentUpdate;
6440cdf0e10cSrcweir             if ( mpWindowImpl->mbNoParentUpdate )
6441cdf0e10cSrcweir                 mpWindowImpl->mpBorderWindow->mpWindowImpl->mbNoParentUpdate = sal_True;
6442cdf0e10cSrcweir             mpWindowImpl->mpBorderWindow->Show( sal_False, nFlags );
6443cdf0e10cSrcweir             mpWindowImpl->mpBorderWindow->mpWindowImpl->mbNoParentUpdate = bOldUpdate;
6444cdf0e10cSrcweir         }
6445cdf0e10cSrcweir         else if ( mpWindowImpl->mbFrame )
6446cdf0e10cSrcweir         {
6447cdf0e10cSrcweir             mpWindowImpl->mbSuppressAccessibilityEvents = sal_True;
6448cdf0e10cSrcweir             mpWindowImpl->mpFrame->Show( sal_False, sal_False );
6449cdf0e10cSrcweir         }
6450cdf0e10cSrcweir 
6451cdf0e10cSrcweir         StateChanged( STATE_CHANGE_VISIBLE );
6452cdf0e10cSrcweir 
6453cdf0e10cSrcweir         if ( mpWindowImpl->mbReallyVisible )
6454cdf0e10cSrcweir         {
6455cdf0e10cSrcweir             Region  aInvRegion( REGION_EMPTY );
6456cdf0e10cSrcweir             sal_Bool    bSaveBack = sal_False;
6457cdf0e10cSrcweir 
6458cdf0e10cSrcweir             if ( ImplIsOverlapWindow() && !mpWindowImpl->mbFrame )
6459cdf0e10cSrcweir             {
6460cdf0e10cSrcweir                 if ( ImplRestoreOverlapBackground( aInvRegion ) )
6461cdf0e10cSrcweir                     bSaveBack = sal_True;
6462cdf0e10cSrcweir             }
6463cdf0e10cSrcweir 
6464cdf0e10cSrcweir             if ( !bSaveBack )
6465cdf0e10cSrcweir             {
6466cdf0e10cSrcweir                 if ( mpWindowImpl->mbInitWinClipRegion )
6467cdf0e10cSrcweir                     ImplInitWinClipRegion();
6468cdf0e10cSrcweir                 aInvRegion = mpWindowImpl->maWinClipRegion;
6469cdf0e10cSrcweir             }
6470cdf0e10cSrcweir 
6471cdf0e10cSrcweir             if( aDogTag.IsDelete() )
6472cdf0e10cSrcweir                 return;
6473cdf0e10cSrcweir 
6474cdf0e10cSrcweir             bRealVisibilityChanged = mpWindowImpl->mbReallyVisible;
6475cdf0e10cSrcweir             ImplResetReallyVisible();
6476cdf0e10cSrcweir             ImplSetClipFlag();
6477cdf0e10cSrcweir 
6478cdf0e10cSrcweir             if ( ImplIsOverlapWindow() && !mpWindowImpl->mbFrame )
6479cdf0e10cSrcweir             {
6480cdf0e10cSrcweir                 // Focus umsetzen
6481cdf0e10cSrcweir                 if ( !(nFlags & SHOW_NOFOCUSCHANGE) && HasChildPathFocus() )
6482cdf0e10cSrcweir                 {
6483cdf0e10cSrcweir                     if ( mpWindowImpl->mpOverlapWindow->IsEnabled() &&
6484cdf0e10cSrcweir                          mpWindowImpl->mpOverlapWindow->IsInputEnabled() &&
6485cdf0e10cSrcweir                          ! mpWindowImpl->mpOverlapWindow->IsInModalMode()
6486cdf0e10cSrcweir                          )
6487cdf0e10cSrcweir                         mpWindowImpl->mpOverlapWindow->GrabFocus();
6488cdf0e10cSrcweir                 }
6489cdf0e10cSrcweir             }
6490cdf0e10cSrcweir 
6491cdf0e10cSrcweir             if ( !mpWindowImpl->mbFrame )
6492cdf0e10cSrcweir             {
6493cdf0e10cSrcweir                 if( mpWindowImpl->mpWinData && mpWindowImpl->mpWinData->mbEnableNativeWidget )
6494cdf0e10cSrcweir                 {
6495cdf0e10cSrcweir                     /*
6496cdf0e10cSrcweir                     * #i48371# native theming: some themes draw outside the control
6497cdf0e10cSrcweir                     * area we tell them to (bad thing, but we cannot do much about it ).
6498cdf0e10cSrcweir                     * On hiding these controls they get invalidated with their window rectangle
6499cdf0e10cSrcweir                     * which leads to the parts outside the control area being left and not
6500cdf0e10cSrcweir                     * invalidated. Workaround: invalidate an area on the parent, too
6501cdf0e10cSrcweir                     */
6502cdf0e10cSrcweir                     const int workaround_border = 5;
6503cdf0e10cSrcweir                     Rectangle aBounds( aInvRegion.GetBoundRect() );
6504cdf0e10cSrcweir                     aBounds.Left()      -= workaround_border;
6505cdf0e10cSrcweir                     aBounds.Top()       -= workaround_border;
6506cdf0e10cSrcweir                     aBounds.Right()     += workaround_border;
6507cdf0e10cSrcweir                     aBounds.Bottom()    += workaround_border;
6508cdf0e10cSrcweir                     aInvRegion = aBounds;
6509cdf0e10cSrcweir                 }
6510cdf0e10cSrcweir                 if ( !mpWindowImpl->mbNoParentUpdate && !(nFlags & SHOW_NOPARENTUPDATE) )
6511cdf0e10cSrcweir                 {
6512cdf0e10cSrcweir                     if ( !aInvRegion.IsEmpty() )
6513cdf0e10cSrcweir                         ImplInvalidateParentFrameRegion( aInvRegion );
6514cdf0e10cSrcweir                 }
6515cdf0e10cSrcweir                 ImplGenerateMouseMove();
6516cdf0e10cSrcweir             }
6517cdf0e10cSrcweir         }
6518cdf0e10cSrcweir     }
6519cdf0e10cSrcweir     else
6520cdf0e10cSrcweir     {
6521cdf0e10cSrcweir         // inherit native widget flag for form controls
6522cdf0e10cSrcweir         // required here, because frames never show up in the child hierarchy - which should be fixed....
6523cdf0e10cSrcweir         // eg, the drop down of a combobox which is a system floating window
6524cdf0e10cSrcweir         if( mpWindowImpl->mbFrame && GetParent() && GetParent()->IsCompoundControl() &&
6525cdf0e10cSrcweir             GetParent()->IsNativeWidgetEnabled() != IsNativeWidgetEnabled() )
6526cdf0e10cSrcweir             EnableNativeWidget( GetParent()->IsNativeWidgetEnabled() );
6527cdf0e10cSrcweir 
6528cdf0e10cSrcweir         if ( mpWindowImpl->mbCallMove )
6529cdf0e10cSrcweir         {
6530cdf0e10cSrcweir             ImplCallMove();
6531cdf0e10cSrcweir         }
6532cdf0e10cSrcweir         if ( mpWindowImpl->mbCallResize )
6533cdf0e10cSrcweir         {
6534cdf0e10cSrcweir             ImplCallResize();
6535cdf0e10cSrcweir         }
6536cdf0e10cSrcweir 
6537cdf0e10cSrcweir         StateChanged( STATE_CHANGE_VISIBLE );
6538cdf0e10cSrcweir 
6539cdf0e10cSrcweir         Window* pTestParent;
6540cdf0e10cSrcweir         if ( ImplIsOverlapWindow() )
6541cdf0e10cSrcweir             pTestParent = mpWindowImpl->mpOverlapWindow;
6542cdf0e10cSrcweir         else
6543cdf0e10cSrcweir             pTestParent = ImplGetParent();
6544cdf0e10cSrcweir         if ( mpWindowImpl->mbFrame || pTestParent->mpWindowImpl->mbReallyVisible )
6545cdf0e10cSrcweir         {
6546cdf0e10cSrcweir             // Wenn ein Window gerade sichtbar wird, schicken wir allen
6547cdf0e10cSrcweir             // Child-Fenstern ein StateChanged, damit diese sich
6548cdf0e10cSrcweir             // initialisieren koennen
6549cdf0e10cSrcweir             ImplCallInitShow();
6550cdf0e10cSrcweir 
6551cdf0e10cSrcweir             // Wenn es ein SystemWindow ist, dann kommt es auch automatisch
6552cdf0e10cSrcweir             // nach vorne, wenn es gewuenscht ist
6553cdf0e10cSrcweir             if ( ImplIsOverlapWindow() && !(nFlags & SHOW_NOACTIVATE) )
6554cdf0e10cSrcweir             {
6555cdf0e10cSrcweir                 ImplStartToTop(( nFlags & SHOW_FOREGROUNDTASK ) ? TOTOP_FOREGROUNDTASK : 0 );
6556cdf0e10cSrcweir                 ImplFocusToTop( 0, sal_False );
6557cdf0e10cSrcweir             }
6558cdf0e10cSrcweir 
6559cdf0e10cSrcweir             // Hintergrund sichern
6560cdf0e10cSrcweir             if ( mpWindowImpl->mpOverlapData && mpWindowImpl->mpOverlapData->mbSaveBack )
6561cdf0e10cSrcweir                 ImplSaveOverlapBackground();
6562cdf0e10cSrcweir             // adjust mpWindowImpl->mbReallyVisible
6563cdf0e10cSrcweir             bRealVisibilityChanged = !mpWindowImpl->mbReallyVisible;
6564cdf0e10cSrcweir             ImplSetReallyVisible();
6565cdf0e10cSrcweir 
6566cdf0e10cSrcweir             // Dafuer sorgen, das Clip-Rechtecke neu berechnet werden
6567cdf0e10cSrcweir             ImplSetClipFlag();
6568cdf0e10cSrcweir 
6569cdf0e10cSrcweir             if ( !mpWindowImpl->mbFrame )
6570cdf0e10cSrcweir             {
6571cdf0e10cSrcweir                 sal_uInt16 nInvalidateFlags = INVALIDATE_CHILDREN;
6572cdf0e10cSrcweir                 if( ! IsPaintTransparent() )
6573cdf0e10cSrcweir                     nInvalidateFlags |= INVALIDATE_NOTRANSPARENT;
6574cdf0e10cSrcweir                 ImplInvalidate( NULL, nInvalidateFlags );
6575cdf0e10cSrcweir                 ImplGenerateMouseMove();
6576cdf0e10cSrcweir             }
6577cdf0e10cSrcweir         }
6578cdf0e10cSrcweir 
6579cdf0e10cSrcweir         if ( mpWindowImpl->mpBorderWindow )
6580cdf0e10cSrcweir             mpWindowImpl->mpBorderWindow->Show( sal_True, nFlags );
6581cdf0e10cSrcweir         else if ( mpWindowImpl->mbFrame )
6582cdf0e10cSrcweir         {
6583cdf0e10cSrcweir             ImplSVData* pSVData = ImplGetSVData();
6584cdf0e10cSrcweir             // #106431#, hide SplashScreen
6585cdf0e10cSrcweir             if( pSVData->mpIntroWindow && !ImplIsWindowOrChild( pSVData->mpIntroWindow ) )
6586cdf0e10cSrcweir                 pSVData->mpIntroWindow->Hide();
6587cdf0e10cSrcweir 
6588cdf0e10cSrcweir             //DBG_ASSERT( !mpWindowImpl->mbSuppressAccessibilityEvents, "Window::Show() - Frame reactivated");
6589cdf0e10cSrcweir             mpWindowImpl->mbSuppressAccessibilityEvents = sal_False;
6590cdf0e10cSrcweir 
6591cdf0e10cSrcweir             mpWindowImpl->mbPaintFrame = sal_True;
6592cdf0e10cSrcweir             sal_Bool bNoActivate = (nFlags & (SHOW_NOACTIVATE|SHOW_NOFOCUSCHANGE)) ? sal_True : sal_False;
6593cdf0e10cSrcweir             mpWindowImpl->mpFrame->Show( sal_True, bNoActivate );
6594cdf0e10cSrcweir             if( aDogTag.IsDelete() )
6595cdf0e10cSrcweir                 return;
6596cdf0e10cSrcweir 
6597cdf0e10cSrcweir             // Query the correct size of the window, if we are waiting for
6598cdf0e10cSrcweir             // a system resize
6599cdf0e10cSrcweir             if ( mpWindowImpl->mbWaitSystemResize )
6600cdf0e10cSrcweir             {
6601cdf0e10cSrcweir                 long nOutWidth;
6602cdf0e10cSrcweir                 long nOutHeight;
6603cdf0e10cSrcweir                 mpWindowImpl->mpFrame->GetClientSize( nOutWidth, nOutHeight );
6604cdf0e10cSrcweir                 ImplHandleResize( this, nOutWidth, nOutHeight );
6605cdf0e10cSrcweir             }
6606cdf0e10cSrcweir         }
6607cdf0e10cSrcweir 
6608cdf0e10cSrcweir         if( aDogTag.IsDelete() )
6609cdf0e10cSrcweir             return;
6610cdf0e10cSrcweir 
6611cdf0e10cSrcweir #ifdef DBG_UTIL
6612cdf0e10cSrcweir         if ( IsDialog() || (GetType() == WINDOW_TABPAGE) || (GetType() == WINDOW_DOCKINGWINDOW) )
6613cdf0e10cSrcweir         {
6614cdf0e10cSrcweir             DBG_DIALOGTEST( this );
6615cdf0e10cSrcweir         }
6616cdf0e10cSrcweir #endif
6617cdf0e10cSrcweir 
6618cdf0e10cSrcweir         ImplShowAllOverlaps();
6619cdf0e10cSrcweir     }
6620cdf0e10cSrcweir 
6621cdf0e10cSrcweir     if( aDogTag.IsDelete() )
6622cdf0e10cSrcweir         return;
6623cdf0e10cSrcweir     // invalidate all saved backgrounds
6624cdf0e10cSrcweir     if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
6625cdf0e10cSrcweir         ImplInvalidateAllOverlapBackgrounds();
6626cdf0e10cSrcweir 
6627cdf0e10cSrcweir     // the SHOW/HIDE events also serve as indicators to send child creation/destroy events to the access bridge
6628cdf0e10cSrcweir     // However, the access bridge only uses this event if the data member is not NULL (it's kind of a hack that
6629cdf0e10cSrcweir     // we re-use the SHOW/HIDE events this way, with this particular semantics).
6630cdf0e10cSrcweir     // Since #104887#, the notifications for the access bridge are done in Impl(Set|Reset)ReallyVisible. Here, we
6631cdf0e10cSrcweir     // now only notify with a NULL data pointer, for all other clients except the access bridge.
6632cdf0e10cSrcweir     if ( !bRealVisibilityChanged )
6633cdf0e10cSrcweir         ImplCallEventListeners( mpWindowImpl->mbVisible ? VCLEVENT_WINDOW_SHOW : VCLEVENT_WINDOW_HIDE, NULL );
6634cdf0e10cSrcweir     if( aDogTag.IsDelete() )
6635cdf0e10cSrcweir         return;
6636cdf0e10cSrcweir 
6637cdf0e10cSrcweir     // #107575#, if a floating windows is shown that grabs the focus, we have to notify the toolkit about it
6638cdf0e10cSrcweir     // ImplGrabFocus() is not called in this case
6639cdf0e10cSrcweir     // Because this might lead to problems the task will be shifted to 6.y
6640cdf0e10cSrcweir     // Note: top-level context menues are registered at the access bridge after being shown,
6641cdf0e10cSrcweir     // so this will probably not help here....
6642cdf0e10cSrcweir     /*
6643cdf0e10cSrcweir     if( mpWindowImpl->mbFloatWin && ((FloatingWindow*) this )->GrabsFocus() )
6644cdf0e10cSrcweir     {
6645cdf0e10cSrcweir         ImplSVData* pSVData = ImplGetSVData();
6646cdf0e10cSrcweir         if( !mpWindowImpl->mbVisible )
6647cdf0e10cSrcweir         {
6648cdf0e10cSrcweir             ImplCallEventListeners( VCLEVENT_WINDOW_LOSEFOCUS );
6649cdf0e10cSrcweir             if( pSVData->maWinData.mpFocusWin )
6650cdf0e10cSrcweir                 pSVData->maWinData.mpFocusWin->ImplCallEventListeners( VCLEVENT_WINDOW_GETFOCUS );
6651cdf0e10cSrcweir         }
6652cdf0e10cSrcweir         else
6653cdf0e10cSrcweir         {
6654cdf0e10cSrcweir             if( pSVData->maWinData.mpFocusWin )
6655cdf0e10cSrcweir                 pSVData->maWinData.mpFocusWin->ImplCallEventListeners( VCLEVENT_WINDOW_LOSEFOCUS );
6656cdf0e10cSrcweir             ImplCallEventListeners( VCLEVENT_WINDOW_GETFOCUS );
6657cdf0e10cSrcweir         }
6658cdf0e10cSrcweir     }
6659cdf0e10cSrcweir     */
6660cdf0e10cSrcweir }
6661cdf0e10cSrcweir 
6662cdf0e10cSrcweir // -----------------------------------------------------------------------
6663cdf0e10cSrcweir 
6664cdf0e10cSrcweir Size Window::GetSizePixel() const
6665cdf0e10cSrcweir {
6666cdf0e10cSrcweir     // #i43257# trigger pending resize handler to assure correct window sizes
6667cdf0e10cSrcweir     if( mpWindowImpl->mpFrameData->maResizeTimer.IsActive() )
6668cdf0e10cSrcweir     {
6669cdf0e10cSrcweir         ImplDelData aDogtag( this );
6670cdf0e10cSrcweir         mpWindowImpl->mpFrameData->maResizeTimer.Stop();
6671cdf0e10cSrcweir         mpWindowImpl->mpFrameData->maResizeTimer.GetTimeoutHdl().Call( NULL );
6672cdf0e10cSrcweir         if( aDogtag.IsDelete() )
6673cdf0e10cSrcweir             return Size(0,0);
6674cdf0e10cSrcweir     }
6675cdf0e10cSrcweir 
6676cdf0e10cSrcweir     return Size( mnOutWidth+mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder,
6677cdf0e10cSrcweir                  mnOutHeight+mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder );
6678cdf0e10cSrcweir }
6679cdf0e10cSrcweir 
6680cdf0e10cSrcweir void Window::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
6681cdf0e10cSrcweir                                sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
6682cdf0e10cSrcweir {
6683cdf0e10cSrcweir     rLeftBorder     = mpWindowImpl->mnLeftBorder;
6684cdf0e10cSrcweir     rTopBorder      = mpWindowImpl->mnTopBorder;
6685cdf0e10cSrcweir     rRightBorder    = mpWindowImpl->mnRightBorder;
6686cdf0e10cSrcweir     rBottomBorder   = mpWindowImpl->mnBottomBorder;
6687cdf0e10cSrcweir }
6688cdf0e10cSrcweir 
6689cdf0e10cSrcweir 
6690cdf0e10cSrcweir // -----------------------------------------------------------------------
6691cdf0e10cSrcweir 
6692cdf0e10cSrcweir void Window::Enable( bool bEnable, bool bChild )
6693cdf0e10cSrcweir {
6694cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
6695cdf0e10cSrcweir 
6696cdf0e10cSrcweir     if ( !bEnable )
6697cdf0e10cSrcweir     {
6698cdf0e10cSrcweir         // Wenn ein Fenster disablte wird, wird automatisch der Tracking-Modus
6699cdf0e10cSrcweir         // beendet oder der Capture geklaut
6700cdf0e10cSrcweir         if ( IsTracking() )
6701cdf0e10cSrcweir             EndTracking( ENDTRACK_CANCEL );
6702cdf0e10cSrcweir         if ( IsMouseCaptured() )
6703cdf0e10cSrcweir             ReleaseMouse();
6704cdf0e10cSrcweir         // Wenn Fenster den Focus hat und in der Dialog-Steuerung enthalten,
6705cdf0e10cSrcweir         // wird versucht, den Focus auf das naechste Control weiterzuschalten
6706cdf0e10cSrcweir         // mpWindowImpl->mbDisabled darf erst nach Aufruf von ImplDlgCtrlNextWindow() gesetzt
6707cdf0e10cSrcweir         // werden. Ansonsten muss ImplDlgCtrlNextWindow() umgestellt werden
6708cdf0e10cSrcweir         if ( HasFocus() )
6709cdf0e10cSrcweir             ImplDlgCtrlNextWindow();
6710cdf0e10cSrcweir     }
6711cdf0e10cSrcweir 
6712cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
6713cdf0e10cSrcweir     {
6714cdf0e10cSrcweir         mpWindowImpl->mpBorderWindow->Enable( bEnable, sal_False );
6715cdf0e10cSrcweir         if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
6716cdf0e10cSrcweir              ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
6717cdf0e10cSrcweir             ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->Enable( bEnable, sal_True );
6718cdf0e10cSrcweir     }
6719cdf0e10cSrcweir 
6720cdf0e10cSrcweir     // #i56102# restore app focus win in case the
6721cdf0e10cSrcweir     // window was disabled when the frame focus changed
6722cdf0e10cSrcweir     ImplSVData* pSVData = ImplGetSVData();
6723cdf0e10cSrcweir     if( bEnable &&
6724cdf0e10cSrcweir         pSVData->maWinData.mpFocusWin == NULL &&
6725cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mbHasFocus &&
6726cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mpFocusWin == this )
6727cdf0e10cSrcweir         pSVData->maWinData.mpFocusWin = this;
6728cdf0e10cSrcweir 
6729cdf0e10cSrcweir     if ( mpWindowImpl->mbDisabled != !bEnable )
6730cdf0e10cSrcweir     {
6731cdf0e10cSrcweir         mpWindowImpl->mbDisabled = !bEnable;
6732cdf0e10cSrcweir         if ( mpWindowImpl->mpSysObj )
6733cdf0e10cSrcweir             mpWindowImpl->mpSysObj->Enable( bEnable && !mpWindowImpl->mbInputDisabled );
6734cdf0e10cSrcweir //      if ( mpWindowImpl->mbFrame )
6735cdf0e10cSrcweir //          mpWindowImpl->mpFrame->Enable( bEnable && !mpWindowImpl->mbInputDisabled );
6736cdf0e10cSrcweir         StateChanged( STATE_CHANGE_ENABLE );
6737cdf0e10cSrcweir 
6738cdf0e10cSrcweir         ImplCallEventListeners( bEnable ? VCLEVENT_WINDOW_ENABLED : VCLEVENT_WINDOW_DISABLED );
6739cdf0e10cSrcweir     }
6740cdf0e10cSrcweir 
6741cdf0e10cSrcweir     if ( bChild || mpWindowImpl->mbChildNotify )
6742cdf0e10cSrcweir     {
6743cdf0e10cSrcweir         Window* pChild = mpWindowImpl->mpFirstChild;
6744cdf0e10cSrcweir         while ( pChild )
6745cdf0e10cSrcweir         {
6746cdf0e10cSrcweir             pChild->Enable( bEnable, bChild );
6747cdf0e10cSrcweir             pChild = pChild->mpWindowImpl->mpNext;
6748cdf0e10cSrcweir         }
6749cdf0e10cSrcweir     }
6750cdf0e10cSrcweir 
6751cdf0e10cSrcweir     if ( IsReallyVisible() )
6752cdf0e10cSrcweir         ImplGenerateMouseMove();
6753cdf0e10cSrcweir }
6754cdf0e10cSrcweir 
6755cdf0e10cSrcweir // -----------------------------------------------------------------------
6756cdf0e10cSrcweir 
6757cdf0e10cSrcweir void Window::SetCallHandlersOnInputDisabled( bool bCall )
6758cdf0e10cSrcweir {
6759cdf0e10cSrcweir     mpWindowImpl->mbCallHandlersDuringInputDisabled = bCall ? sal_True : sal_False;
6760cdf0e10cSrcweir 
6761cdf0e10cSrcweir     Window* pChild = mpWindowImpl->mpFirstChild;
6762cdf0e10cSrcweir     while ( pChild )
6763cdf0e10cSrcweir     {
6764cdf0e10cSrcweir         pChild->SetCallHandlersOnInputDisabled( bCall );
6765cdf0e10cSrcweir         pChild = pChild->mpWindowImpl->mpNext;
6766cdf0e10cSrcweir     }
6767cdf0e10cSrcweir }
6768cdf0e10cSrcweir 
6769cdf0e10cSrcweir // -----------------------------------------------------------------------
6770cdf0e10cSrcweir 
6771cdf0e10cSrcweir bool Window::IsCallHandlersOnInputDisabled() const
6772cdf0e10cSrcweir {
6773cdf0e10cSrcweir     return mpWindowImpl->mbCallHandlersDuringInputDisabled ? true : false;
6774cdf0e10cSrcweir }
6775cdf0e10cSrcweir 
6776cdf0e10cSrcweir // -----------------------------------------------------------------------
6777cdf0e10cSrcweir 
6778cdf0e10cSrcweir void Window::EnableInput( sal_Bool bEnable, sal_Bool bChild )
6779cdf0e10cSrcweir {
6780cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
6781cdf0e10cSrcweir 
6782cdf0e10cSrcweir     sal_Bool bNotify = (bEnable != mpWindowImpl->mbInputDisabled);
6783cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
6784cdf0e10cSrcweir     {
6785cdf0e10cSrcweir         mpWindowImpl->mpBorderWindow->EnableInput( bEnable, sal_False );
6786cdf0e10cSrcweir         if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
6787cdf0e10cSrcweir              ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
6788cdf0e10cSrcweir             ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->EnableInput( bEnable, sal_True );
6789cdf0e10cSrcweir     }
6790cdf0e10cSrcweir 
6791cdf0e10cSrcweir     if ( (! bEnable && mpWindowImpl->meAlwaysInputMode != AlwaysInputEnabled) ||
6792cdf0e10cSrcweir          (  bEnable && mpWindowImpl->meAlwaysInputMode != AlwaysInputDisabled) )
6793cdf0e10cSrcweir     {
6794cdf0e10cSrcweir         // Wenn ein Fenster disablte wird, wird automatisch der
6795cdf0e10cSrcweir         // Tracking-Modus beendet oder der Capture geklaut
6796cdf0e10cSrcweir         if ( !bEnable )
6797cdf0e10cSrcweir         {
6798cdf0e10cSrcweir             if ( IsTracking() )
6799cdf0e10cSrcweir                 EndTracking( ENDTRACK_CANCEL );
6800cdf0e10cSrcweir             if ( IsMouseCaptured() )
6801cdf0e10cSrcweir                 ReleaseMouse();
6802cdf0e10cSrcweir         }
6803cdf0e10cSrcweir 
6804cdf0e10cSrcweir         if ( mpWindowImpl->mbInputDisabled != !bEnable )
6805cdf0e10cSrcweir         {
6806cdf0e10cSrcweir             mpWindowImpl->mbInputDisabled = !bEnable;
6807cdf0e10cSrcweir             if ( mpWindowImpl->mpSysObj )
6808cdf0e10cSrcweir                 mpWindowImpl->mpSysObj->Enable( !mpWindowImpl->mbDisabled && bEnable );
6809cdf0e10cSrcweir //          if ( mpWindowImpl->mbFrame )
6810cdf0e10cSrcweir //              mpWindowImpl->mpFrame->Enable( !mpWindowImpl->mbDisabled && bEnable );
6811cdf0e10cSrcweir         }
6812cdf0e10cSrcweir     }
6813cdf0e10cSrcweir 
6814cdf0e10cSrcweir     // #i56102# restore app focus win in case the
6815cdf0e10cSrcweir     // window was disabled when the frame focus changed
6816cdf0e10cSrcweir     ImplSVData* pSVData = ImplGetSVData();
6817cdf0e10cSrcweir     if( bEnable &&
6818cdf0e10cSrcweir         pSVData->maWinData.mpFocusWin == NULL &&
6819cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mbHasFocus &&
6820cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mpFocusWin == this )
6821cdf0e10cSrcweir         pSVData->maWinData.mpFocusWin = this;
6822cdf0e10cSrcweir 
6823cdf0e10cSrcweir     if ( bChild || mpWindowImpl->mbChildNotify )
6824cdf0e10cSrcweir     {
6825cdf0e10cSrcweir         Window* pChild = mpWindowImpl->mpFirstChild;
6826cdf0e10cSrcweir         while ( pChild )
6827cdf0e10cSrcweir         {
6828cdf0e10cSrcweir             pChild->EnableInput( bEnable, bChild );
6829cdf0e10cSrcweir             pChild = pChild->mpWindowImpl->mpNext;
6830cdf0e10cSrcweir         }
6831cdf0e10cSrcweir     }
6832cdf0e10cSrcweir 
6833cdf0e10cSrcweir     if ( IsReallyVisible() )
6834cdf0e10cSrcweir         ImplGenerateMouseMove();
6835cdf0e10cSrcweir 
6836cdf0e10cSrcweir     // #104827# notify parent
6837cdf0e10cSrcweir     if ( bNotify )
6838cdf0e10cSrcweir     {
6839cdf0e10cSrcweir         NotifyEvent aNEvt( bEnable ? EVENT_INPUTENABLE : EVENT_INPUTDISABLE, this );
6840cdf0e10cSrcweir         Notify( aNEvt );
6841cdf0e10cSrcweir     }
6842cdf0e10cSrcweir }
6843cdf0e10cSrcweir 
6844cdf0e10cSrcweir // -----------------------------------------------------------------------
6845cdf0e10cSrcweir 
6846cdf0e10cSrcweir void Window::EnableInput( sal_Bool bEnable, sal_Bool bChild, sal_Bool bSysWin,
6847cdf0e10cSrcweir                           const Window* pExcludeWindow )
6848cdf0e10cSrcweir {
6849cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
6850cdf0e10cSrcweir 
6851cdf0e10cSrcweir     EnableInput( bEnable, bChild );
6852cdf0e10cSrcweir     if ( bSysWin )
6853cdf0e10cSrcweir     {
6854cdf0e10cSrcweir         // pExculeWindow is the first Overlap-Frame --> if this
6855cdf0e10cSrcweir         // shouldn't be the case, than this must be changed in dialog.cxx
6856cdf0e10cSrcweir         if( pExcludeWindow )
6857cdf0e10cSrcweir             pExcludeWindow = pExcludeWindow->ImplGetFirstOverlapWindow();
6858cdf0e10cSrcweir         Window* pSysWin = mpWindowImpl->mpFrameWindow->mpWindowImpl->mpFrameData->mpFirstOverlap;
6859cdf0e10cSrcweir         while ( pSysWin )
6860cdf0e10cSrcweir         {
6861cdf0e10cSrcweir             // Is Window in the path from this window
6862cdf0e10cSrcweir             if ( ImplGetFirstOverlapWindow()->ImplIsWindowOrChild( pSysWin, sal_True ) )
6863cdf0e10cSrcweir             {
6864cdf0e10cSrcweir                 // Is Window not in the exclude window path or not the
6865cdf0e10cSrcweir                 // exclude window, than change the status
6866cdf0e10cSrcweir                 if ( !pExcludeWindow || !pExcludeWindow->ImplIsWindowOrChild( pSysWin, sal_True ) )
6867cdf0e10cSrcweir                     pSysWin->EnableInput( bEnable, bChild );
6868cdf0e10cSrcweir             }
6869cdf0e10cSrcweir             pSysWin = pSysWin->mpWindowImpl->mpNextOverlap;
6870cdf0e10cSrcweir         }
6871cdf0e10cSrcweir 
6872cdf0e10cSrcweir         // enable/disable floating system windows as well
6873cdf0e10cSrcweir         Window* pFrameWin = ImplGetSVData()->maWinData.mpFirstFrame;
6874cdf0e10cSrcweir         while ( pFrameWin )
6875cdf0e10cSrcweir         {
6876cdf0e10cSrcweir             if( pFrameWin->ImplIsFloatingWindow() )
6877cdf0e10cSrcweir             {
6878cdf0e10cSrcweir                 // Is Window in the path from this window
6879cdf0e10cSrcweir                 if ( ImplGetFirstOverlapWindow()->ImplIsWindowOrChild( pFrameWin, sal_True ) )
6880cdf0e10cSrcweir                 {
6881cdf0e10cSrcweir                     // Is Window not in the exclude window path or not the
6882cdf0e10cSrcweir                     // exclude window, than change the status
6883cdf0e10cSrcweir                     if ( !pExcludeWindow || !pExcludeWindow->ImplIsWindowOrChild( pFrameWin, sal_True ) )
6884cdf0e10cSrcweir                         pFrameWin->EnableInput( bEnable, bChild );
6885cdf0e10cSrcweir                 }
6886cdf0e10cSrcweir             }
6887cdf0e10cSrcweir             pFrameWin = pFrameWin->mpWindowImpl->mpFrameData->mpNextFrame;
6888cdf0e10cSrcweir         }
6889cdf0e10cSrcweir 
6890cdf0e10cSrcweir         // the same for ownerdraw floating windows
6891cdf0e10cSrcweir         if( mpWindowImpl->mbFrame )
6892cdf0e10cSrcweir         {
6893cdf0e10cSrcweir             ::std::vector< Window* >& rList = mpWindowImpl->mpFrameData->maOwnerDrawList;
6894cdf0e10cSrcweir             ::std::vector< Window* >::iterator p = rList.begin();
6895cdf0e10cSrcweir             while( p != rList.end() )
6896cdf0e10cSrcweir             {
6897cdf0e10cSrcweir                 // Is Window in the path from this window
6898cdf0e10cSrcweir                 if ( ImplGetFirstOverlapWindow()->ImplIsWindowOrChild( (*p), sal_True ) )
6899cdf0e10cSrcweir                 {
6900cdf0e10cSrcweir                     // Is Window not in the exclude window path or not the
6901cdf0e10cSrcweir                     // exclude window, than change the status
6902cdf0e10cSrcweir                     if ( !pExcludeWindow || !pExcludeWindow->ImplIsWindowOrChild( (*p), sal_True ) )
6903cdf0e10cSrcweir                         (*p)->EnableInput( bEnable, bChild );
6904cdf0e10cSrcweir                 }
6905cdf0e10cSrcweir                 p++;
6906cdf0e10cSrcweir             }
6907cdf0e10cSrcweir         }
6908cdf0e10cSrcweir     }
6909cdf0e10cSrcweir }
6910cdf0e10cSrcweir 
6911cdf0e10cSrcweir // -----------------------------------------------------------------------
6912cdf0e10cSrcweir 
6913cdf0e10cSrcweir void Window::AlwaysEnableInput( sal_Bool bAlways, sal_Bool bChild )
6914cdf0e10cSrcweir {
6915cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
6916cdf0e10cSrcweir 
6917cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
6918cdf0e10cSrcweir         mpWindowImpl->mpBorderWindow->AlwaysEnableInput( bAlways, sal_False );
6919cdf0e10cSrcweir 
6920cdf0e10cSrcweir     if( bAlways && mpWindowImpl->meAlwaysInputMode != AlwaysInputEnabled )
6921cdf0e10cSrcweir     {
6922cdf0e10cSrcweir         mpWindowImpl->meAlwaysInputMode = AlwaysInputEnabled;
6923cdf0e10cSrcweir 
6924cdf0e10cSrcweir         if ( bAlways )
6925cdf0e10cSrcweir             EnableInput( sal_True, sal_False );
6926cdf0e10cSrcweir     }
6927cdf0e10cSrcweir     else if( ! bAlways && mpWindowImpl->meAlwaysInputMode == AlwaysInputEnabled )
6928cdf0e10cSrcweir     {
6929cdf0e10cSrcweir         mpWindowImpl->meAlwaysInputMode = AlwaysInputNone;
6930cdf0e10cSrcweir     }
6931cdf0e10cSrcweir 
6932cdf0e10cSrcweir     if ( bChild || mpWindowImpl->mbChildNotify )
6933cdf0e10cSrcweir     {
6934cdf0e10cSrcweir         Window* pChild = mpWindowImpl->mpFirstChild;
6935cdf0e10cSrcweir         while ( pChild )
6936cdf0e10cSrcweir         {
6937cdf0e10cSrcweir             pChild->AlwaysEnableInput( bAlways, bChild );
6938cdf0e10cSrcweir             pChild = pChild->mpWindowImpl->mpNext;
6939cdf0e10cSrcweir         }
6940cdf0e10cSrcweir     }
6941cdf0e10cSrcweir }
6942cdf0e10cSrcweir 
6943cdf0e10cSrcweir // -----------------------------------------------------------------------
6944cdf0e10cSrcweir 
6945cdf0e10cSrcweir void Window::AlwaysDisableInput( sal_Bool bAlways, sal_Bool bChild )
6946cdf0e10cSrcweir {
6947cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
6948cdf0e10cSrcweir 
6949cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
6950cdf0e10cSrcweir         mpWindowImpl->mpBorderWindow->AlwaysDisableInput( bAlways, sal_False );
6951cdf0e10cSrcweir 
6952cdf0e10cSrcweir     if( bAlways && mpWindowImpl->meAlwaysInputMode != AlwaysInputDisabled )
6953cdf0e10cSrcweir     {
6954cdf0e10cSrcweir         mpWindowImpl->meAlwaysInputMode = AlwaysInputDisabled;
6955cdf0e10cSrcweir 
6956cdf0e10cSrcweir         if ( bAlways )
6957cdf0e10cSrcweir             EnableInput( sal_False, sal_False );
6958cdf0e10cSrcweir     }
6959cdf0e10cSrcweir     else if( ! bAlways && mpWindowImpl->meAlwaysInputMode == AlwaysInputDisabled )
6960cdf0e10cSrcweir     {
6961cdf0e10cSrcweir         mpWindowImpl->meAlwaysInputMode = AlwaysInputNone;
6962cdf0e10cSrcweir     }
6963cdf0e10cSrcweir 
6964cdf0e10cSrcweir     if ( bChild || mpWindowImpl->mbChildNotify )
6965cdf0e10cSrcweir     {
6966cdf0e10cSrcweir         Window* pChild = mpWindowImpl->mpFirstChild;
6967cdf0e10cSrcweir         while ( pChild )
6968cdf0e10cSrcweir         {
6969cdf0e10cSrcweir             pChild->AlwaysDisableInput( bAlways, bChild );
6970cdf0e10cSrcweir             pChild = pChild->mpWindowImpl->mpNext;
6971cdf0e10cSrcweir         }
6972cdf0e10cSrcweir     }
6973cdf0e10cSrcweir }
6974cdf0e10cSrcweir 
6975cdf0e10cSrcweir // -----------------------------------------------------------------------
6976cdf0e10cSrcweir 
6977cdf0e10cSrcweir void Window::SetActivateMode( sal_uInt16 nMode )
6978cdf0e10cSrcweir {
6979cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
6980cdf0e10cSrcweir 
6981cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
6982cdf0e10cSrcweir         mpWindowImpl->mpBorderWindow->SetActivateMode( nMode );
6983cdf0e10cSrcweir 
6984cdf0e10cSrcweir     if ( mpWindowImpl->mnActivateMode != nMode )
6985cdf0e10cSrcweir     {
6986cdf0e10cSrcweir         mpWindowImpl->mnActivateMode = nMode;
6987cdf0e10cSrcweir 
6988cdf0e10cSrcweir         // Evtl. ein Decativate/Activate ausloesen
6989cdf0e10cSrcweir         if ( mpWindowImpl->mnActivateMode )
6990cdf0e10cSrcweir         {
6991cdf0e10cSrcweir             if ( (mpWindowImpl->mbActive || (GetType() == WINDOW_BORDERWINDOW)) &&
6992cdf0e10cSrcweir                  !HasChildPathFocus( sal_True ) )
6993cdf0e10cSrcweir             {
6994cdf0e10cSrcweir                 mpWindowImpl->mbActive = sal_False;
6995cdf0e10cSrcweir                 Deactivate();
6996cdf0e10cSrcweir             }
6997cdf0e10cSrcweir         }
6998cdf0e10cSrcweir         else
6999cdf0e10cSrcweir         {
7000cdf0e10cSrcweir             if ( !mpWindowImpl->mbActive || (GetType() == WINDOW_BORDERWINDOW) )
7001cdf0e10cSrcweir             {
7002cdf0e10cSrcweir                 mpWindowImpl->mbActive = sal_True;
7003cdf0e10cSrcweir                 Activate();
7004cdf0e10cSrcweir             }
7005cdf0e10cSrcweir         }
7006cdf0e10cSrcweir     }
7007cdf0e10cSrcweir }
7008cdf0e10cSrcweir 
7009cdf0e10cSrcweir // -----------------------------------------------------------------------
7010cdf0e10cSrcweir 
7011cdf0e10cSrcweir void Window::ToTop( sal_uInt16 nFlags )
7012cdf0e10cSrcweir {
7013cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7014cdf0e10cSrcweir 
7015cdf0e10cSrcweir     ImplStartToTop( nFlags );
7016cdf0e10cSrcweir     ImplFocusToTop( nFlags, IsReallyVisible() );
7017cdf0e10cSrcweir }
7018cdf0e10cSrcweir 
7019cdf0e10cSrcweir // -----------------------------------------------------------------------
7020cdf0e10cSrcweir 
7021cdf0e10cSrcweir void Window::SetZOrder( Window* pRefWindow, sal_uInt16 nFlags )
7022cdf0e10cSrcweir {
7023cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7024cdf0e10cSrcweir 
7025cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
7026cdf0e10cSrcweir     {
7027cdf0e10cSrcweir         mpWindowImpl->mpBorderWindow->SetZOrder( pRefWindow, nFlags );
7028cdf0e10cSrcweir         return;
7029cdf0e10cSrcweir     }
7030cdf0e10cSrcweir 
7031cdf0e10cSrcweir     if ( nFlags & WINDOW_ZORDER_FIRST )
7032cdf0e10cSrcweir     {
7033cdf0e10cSrcweir         if ( ImplIsOverlapWindow() )
7034cdf0e10cSrcweir             pRefWindow = mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap;
7035cdf0e10cSrcweir         else
7036cdf0e10cSrcweir             pRefWindow = mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild;
7037cdf0e10cSrcweir         nFlags |= WINDOW_ZORDER_BEFOR;
7038cdf0e10cSrcweir     }
7039cdf0e10cSrcweir     else if ( nFlags & WINDOW_ZORDER_LAST )
7040cdf0e10cSrcweir     {
7041cdf0e10cSrcweir         if ( ImplIsOverlapWindow() )
7042cdf0e10cSrcweir             pRefWindow = mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap;
7043cdf0e10cSrcweir         else
7044cdf0e10cSrcweir             pRefWindow = mpWindowImpl->mpParent->mpWindowImpl->mpLastChild;
7045cdf0e10cSrcweir         nFlags |= WINDOW_ZORDER_BEHIND;
7046cdf0e10cSrcweir     }
7047cdf0e10cSrcweir 
7048cdf0e10cSrcweir     while ( pRefWindow->mpWindowImpl->mpBorderWindow )
7049cdf0e10cSrcweir         pRefWindow = pRefWindow->mpWindowImpl->mpBorderWindow;
7050cdf0e10cSrcweir     if ( (pRefWindow == this) || mpWindowImpl->mbFrame )
7051cdf0e10cSrcweir         return;
7052cdf0e10cSrcweir 
7053cdf0e10cSrcweir     DBG_ASSERT( pRefWindow->mpWindowImpl->mpParent == mpWindowImpl->mpParent, "Window::SetZOrder() - pRefWindow has other parent" );
7054cdf0e10cSrcweir     if ( nFlags & WINDOW_ZORDER_BEFOR )
7055cdf0e10cSrcweir     {
7056cdf0e10cSrcweir         if ( pRefWindow->mpWindowImpl->mpPrev == this )
7057cdf0e10cSrcweir             return;
7058cdf0e10cSrcweir 
7059cdf0e10cSrcweir         if ( ImplIsOverlapWindow() )
7060cdf0e10cSrcweir         {
7061cdf0e10cSrcweir             if ( mpWindowImpl->mpPrev )
7062cdf0e10cSrcweir                 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext;
7063cdf0e10cSrcweir             else
7064cdf0e10cSrcweir                 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap = mpWindowImpl->mpNext;
7065cdf0e10cSrcweir             if ( mpWindowImpl->mpNext )
7066cdf0e10cSrcweir                 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev;
7067cdf0e10cSrcweir             else
7068cdf0e10cSrcweir                 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap = mpWindowImpl->mpPrev;
7069cdf0e10cSrcweir             if ( !pRefWindow->mpWindowImpl->mpPrev )
7070cdf0e10cSrcweir                 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap = this;
7071cdf0e10cSrcweir         }
7072cdf0e10cSrcweir         else
7073cdf0e10cSrcweir         {
7074cdf0e10cSrcweir             if ( mpWindowImpl->mpPrev )
7075cdf0e10cSrcweir                 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext;
7076cdf0e10cSrcweir             else
7077cdf0e10cSrcweir                 mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild = mpWindowImpl->mpNext;
7078cdf0e10cSrcweir             if ( mpWindowImpl->mpNext )
7079cdf0e10cSrcweir                 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev;
7080cdf0e10cSrcweir             else
7081cdf0e10cSrcweir                 mpWindowImpl->mpParent->mpWindowImpl->mpLastChild = mpWindowImpl->mpPrev;
7082cdf0e10cSrcweir             if ( !pRefWindow->mpWindowImpl->mpPrev )
7083cdf0e10cSrcweir                 mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild = this;
7084cdf0e10cSrcweir         }
7085cdf0e10cSrcweir 
7086cdf0e10cSrcweir         mpWindowImpl->mpPrev = pRefWindow->mpWindowImpl->mpPrev;
7087cdf0e10cSrcweir         mpWindowImpl->mpNext = pRefWindow;
7088cdf0e10cSrcweir         if ( mpWindowImpl->mpPrev )
7089cdf0e10cSrcweir             mpWindowImpl->mpPrev->mpWindowImpl->mpNext = this;
7090cdf0e10cSrcweir         mpWindowImpl->mpNext->mpWindowImpl->mpPrev = this;
7091cdf0e10cSrcweir     }
7092cdf0e10cSrcweir     else if ( nFlags & WINDOW_ZORDER_BEHIND )
7093cdf0e10cSrcweir     {
7094cdf0e10cSrcweir         if ( pRefWindow->mpWindowImpl->mpNext == this )
7095cdf0e10cSrcweir             return;
7096cdf0e10cSrcweir 
7097cdf0e10cSrcweir         if ( ImplIsOverlapWindow() )
7098cdf0e10cSrcweir         {
7099cdf0e10cSrcweir             if ( mpWindowImpl->mpPrev )
7100cdf0e10cSrcweir                 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext;
7101cdf0e10cSrcweir             else
7102cdf0e10cSrcweir                 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap = mpWindowImpl->mpNext;
7103cdf0e10cSrcweir             if ( mpWindowImpl->mpNext )
7104cdf0e10cSrcweir                 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev;
7105cdf0e10cSrcweir             else
7106cdf0e10cSrcweir                 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap = mpWindowImpl->mpPrev;
7107cdf0e10cSrcweir             if ( !pRefWindow->mpWindowImpl->mpNext )
7108cdf0e10cSrcweir                 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap = this;
7109cdf0e10cSrcweir         }
7110cdf0e10cSrcweir         else
7111cdf0e10cSrcweir         {
7112cdf0e10cSrcweir             if ( mpWindowImpl->mpPrev )
7113cdf0e10cSrcweir                 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext;
7114cdf0e10cSrcweir             else
7115cdf0e10cSrcweir                 mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild = mpWindowImpl->mpNext;
7116cdf0e10cSrcweir             if ( mpWindowImpl->mpNext )
7117cdf0e10cSrcweir                 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev;
7118cdf0e10cSrcweir             else
7119cdf0e10cSrcweir                 mpWindowImpl->mpParent->mpWindowImpl->mpLastChild = mpWindowImpl->mpPrev;
7120cdf0e10cSrcweir             if ( !pRefWindow->mpWindowImpl->mpNext )
7121cdf0e10cSrcweir                 mpWindowImpl->mpParent->mpWindowImpl->mpLastChild = this;
7122cdf0e10cSrcweir         }
7123cdf0e10cSrcweir 
7124cdf0e10cSrcweir         mpWindowImpl->mpPrev = pRefWindow;
7125cdf0e10cSrcweir         mpWindowImpl->mpNext = pRefWindow->mpWindowImpl->mpNext;
7126cdf0e10cSrcweir         if ( mpWindowImpl->mpNext )
7127cdf0e10cSrcweir             mpWindowImpl->mpNext->mpWindowImpl->mpPrev = this;
7128cdf0e10cSrcweir         mpWindowImpl->mpPrev->mpWindowImpl->mpNext = this;
7129cdf0e10cSrcweir     }
7130cdf0e10cSrcweir 
7131cdf0e10cSrcweir     if ( IsReallyVisible() )
7132cdf0e10cSrcweir     {
7133cdf0e10cSrcweir         // Hintergrund-Sicherung zuruecksetzen
7134cdf0e10cSrcweir         if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
7135cdf0e10cSrcweir             ImplInvalidateAllOverlapBackgrounds();
7136cdf0e10cSrcweir 
7137cdf0e10cSrcweir         if ( mpWindowImpl->mbInitWinClipRegion || !mpWindowImpl->maWinClipRegion.IsEmpty() )
7138cdf0e10cSrcweir         {
7139cdf0e10cSrcweir             sal_Bool bInitWinClipRegion = mpWindowImpl->mbInitWinClipRegion;
7140cdf0e10cSrcweir             ImplSetClipFlag();
7141cdf0e10cSrcweir 
7142cdf0e10cSrcweir             // Wenn ClipRegion noch nicht initalisiert wurde, dann
7143cdf0e10cSrcweir             // gehen wir davon aus, das das Fenster noch nicht
7144cdf0e10cSrcweir             // ausgegeben wurde und loesen somit auch keine
7145cdf0e10cSrcweir             // Invalidates aus. Dies ist eine Optimierung fuer
7146cdf0e10cSrcweir             // HTML-Dokumenten mit vielen Controls. Wenn es mal
7147cdf0e10cSrcweir             // Probleme mit dieser Abfrage gibt, sollte man ein
7148cdf0e10cSrcweir             // Flag einfuehren, ob das Fenster nach Show schon
7149cdf0e10cSrcweir             // einmal ausgegeben wurde.
7150cdf0e10cSrcweir             if ( !bInitWinClipRegion )
7151cdf0e10cSrcweir             {
7152cdf0e10cSrcweir                 // Alle nebeneinanderliegen Fenster invalidieren
7153cdf0e10cSrcweir                 // Noch nicht komplett implementiert !!!
7154cdf0e10cSrcweir                 Rectangle   aWinRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
7155cdf0e10cSrcweir                 Window*     pWindow = NULL;
7156cdf0e10cSrcweir                 if ( ImplIsOverlapWindow() )
7157cdf0e10cSrcweir                 {
7158cdf0e10cSrcweir                     if ( mpWindowImpl->mpOverlapWindow )
7159cdf0e10cSrcweir                         pWindow = mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap;
7160cdf0e10cSrcweir                 }
7161cdf0e10cSrcweir                 else
7162cdf0e10cSrcweir                     pWindow = ImplGetParent()->mpWindowImpl->mpFirstChild;
7163cdf0e10cSrcweir                 // Alle Fenster, die vor uns liegen und von uns verdeckt wurden,
7164cdf0e10cSrcweir                 // invalidieren
7165cdf0e10cSrcweir                 while ( pWindow )
7166cdf0e10cSrcweir                 {
7167cdf0e10cSrcweir                     if ( pWindow == this )
7168cdf0e10cSrcweir                         break;
7169cdf0e10cSrcweir                     Rectangle aCompRect( Point( pWindow->mnOutOffX, pWindow->mnOutOffY ),
7170cdf0e10cSrcweir                                          Size( pWindow->mnOutWidth, pWindow->mnOutHeight ) );
7171cdf0e10cSrcweir                     if ( aWinRect.IsOver( aCompRect ) )
7172cdf0e10cSrcweir                         pWindow->Invalidate( INVALIDATE_CHILDREN | INVALIDATE_NOTRANSPARENT );
7173cdf0e10cSrcweir                     pWindow = pWindow->mpWindowImpl->mpNext;
7174cdf0e10cSrcweir                 }
7175cdf0e10cSrcweir                 // Wenn uns ein Fenster welches im Hinterund liegt verdeckt hat,
7176cdf0e10cSrcweir                 // dann muessen wir uns neu ausgeben
7177cdf0e10cSrcweir                 while ( pWindow )
7178cdf0e10cSrcweir                 {
7179cdf0e10cSrcweir                     if ( pWindow != this )
7180cdf0e10cSrcweir                     {
7181cdf0e10cSrcweir                         Rectangle aCompRect( Point( pWindow->mnOutOffX, pWindow->mnOutOffY ),
7182cdf0e10cSrcweir                                              Size( pWindow->mnOutWidth, pWindow->mnOutHeight ) );
7183cdf0e10cSrcweir                         if ( aWinRect.IsOver( aCompRect ) )
7184cdf0e10cSrcweir                         {
7185cdf0e10cSrcweir                             Invalidate( INVALIDATE_CHILDREN | INVALIDATE_NOTRANSPARENT );
7186cdf0e10cSrcweir                             break;
7187cdf0e10cSrcweir                         }
7188cdf0e10cSrcweir                     }
7189cdf0e10cSrcweir                     pWindow = pWindow->mpWindowImpl->mpNext;
7190cdf0e10cSrcweir                 }
7191cdf0e10cSrcweir             }
7192cdf0e10cSrcweir         }
7193cdf0e10cSrcweir     }
7194cdf0e10cSrcweir }
7195cdf0e10cSrcweir 
7196cdf0e10cSrcweir // -----------------------------------------------------------------------
7197cdf0e10cSrcweir 
7198cdf0e10cSrcweir void Window::EnableAlwaysOnTop( sal_Bool bEnable )
7199cdf0e10cSrcweir {
7200cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7201cdf0e10cSrcweir 
7202cdf0e10cSrcweir     mpWindowImpl->mbAlwaysOnTop = bEnable;
7203cdf0e10cSrcweir 
7204cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
7205cdf0e10cSrcweir         mpWindowImpl->mpBorderWindow->EnableAlwaysOnTop( bEnable );
7206cdf0e10cSrcweir     else if ( bEnable && IsReallyVisible() )
7207cdf0e10cSrcweir         ToTop();
7208cdf0e10cSrcweir 
7209cdf0e10cSrcweir     if ( mpWindowImpl->mbFrame )
7210cdf0e10cSrcweir         mpWindowImpl->mpFrame->SetAlwaysOnTop( bEnable );
7211cdf0e10cSrcweir }
7212cdf0e10cSrcweir 
7213cdf0e10cSrcweir // -----------------------------------------------------------------------
7214cdf0e10cSrcweir 
7215cdf0e10cSrcweir void Window::SetPosSizePixel( long nX, long nY,
7216cdf0e10cSrcweir                               long nWidth, long nHeight, sal_uInt16 nFlags )
7217cdf0e10cSrcweir {
7218cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7219cdf0e10cSrcweir 
7220cdf0e10cSrcweir     sal_Bool bHasValidSize = !mpWindowImpl->mbDefSize;
7221cdf0e10cSrcweir 
7222cdf0e10cSrcweir     if ( nFlags & WINDOW_POSSIZE_POS )
7223cdf0e10cSrcweir         mpWindowImpl->mbDefPos = sal_False;
7224cdf0e10cSrcweir     if ( nFlags & WINDOW_POSSIZE_SIZE )
7225cdf0e10cSrcweir         mpWindowImpl->mbDefSize = sal_False;
7226cdf0e10cSrcweir 
7227cdf0e10cSrcweir     // Oberstes BorderWindow ist das Window, welches positioniert werden soll
7228cdf0e10cSrcweir     Window* pWindow = this;
7229cdf0e10cSrcweir     while ( pWindow->mpWindowImpl->mpBorderWindow )
7230cdf0e10cSrcweir         pWindow = pWindow->mpWindowImpl->mpBorderWindow;
7231cdf0e10cSrcweir 
7232cdf0e10cSrcweir     if ( pWindow->mpWindowImpl->mbFrame )
7233cdf0e10cSrcweir     {
7234cdf0e10cSrcweir         // Note: if we're positioning a frame, the coordinates are interpreted
7235cdf0e10cSrcweir         // as being the top-left corner of the window's client area and NOT
7236cdf0e10cSrcweir         // as the position of the border ! (due to limitations of several UNIX window managers)
7237cdf0e10cSrcweir         long nOldWidth  = pWindow->mnOutWidth;
7238cdf0e10cSrcweir 
7239cdf0e10cSrcweir         if ( !(nFlags & WINDOW_POSSIZE_WIDTH) )
7240cdf0e10cSrcweir             nWidth = pWindow->mnOutWidth;
7241cdf0e10cSrcweir         if ( !(nFlags & WINDOW_POSSIZE_HEIGHT) )
7242cdf0e10cSrcweir             nHeight = pWindow->mnOutHeight;
7243cdf0e10cSrcweir 
7244cdf0e10cSrcweir 
7245cdf0e10cSrcweir         sal_uInt16 nSysFlags=0;
7246cdf0e10cSrcweir         if( nFlags & WINDOW_POSSIZE_WIDTH )
7247cdf0e10cSrcweir             nSysFlags |= SAL_FRAME_POSSIZE_WIDTH;
7248cdf0e10cSrcweir         if( nFlags & WINDOW_POSSIZE_HEIGHT )
7249cdf0e10cSrcweir             nSysFlags |= SAL_FRAME_POSSIZE_HEIGHT;
7250cdf0e10cSrcweir         if( nFlags & WINDOW_POSSIZE_X )
7251cdf0e10cSrcweir         {
7252cdf0e10cSrcweir             nSysFlags |= SAL_FRAME_POSSIZE_X;
7253cdf0e10cSrcweir             if( pWindow->GetParent() && (pWindow->GetStyle() & WB_SYSTEMCHILDWINDOW) )
7254cdf0e10cSrcweir 			{
7255cdf0e10cSrcweir                 Window* pParent = pWindow->GetParent();
7256cdf0e10cSrcweir                 nX += pParent->mnOutOffX;
7257cdf0e10cSrcweir 			}
7258cdf0e10cSrcweir             if( GetParent() && GetParent()->ImplIsAntiparallel() )
7259cdf0e10cSrcweir             {
7260cdf0e10cSrcweir                 // --- RTL --- (re-mirror at parent window)
7261cdf0e10cSrcweir                 Rectangle aRect( Point ( nX, nY ), Size( nWidth, nHeight ) );
7262cdf0e10cSrcweir                 GetParent()->ImplReMirror( aRect );
7263cdf0e10cSrcweir                 nX = aRect.nLeft;
7264cdf0e10cSrcweir             }
7265cdf0e10cSrcweir         }
7266cdf0e10cSrcweir         if( !(nFlags & WINDOW_POSSIZE_X) && bHasValidSize && pWindow->mpWindowImpl->mpFrame->maGeometry.nWidth )
7267cdf0e10cSrcweir         {
7268cdf0e10cSrcweir             // --- RTL ---  make sure the old right aligned position is not changed
7269cdf0e10cSrcweir             //              system windows will always grow to the right
7270cdf0e10cSrcweir             if( pWindow->GetParent() && pWindow->GetParent()->ImplHasMirroredGraphics() )
7271cdf0e10cSrcweir             {
7272cdf0e10cSrcweir                 long myWidth = nOldWidth;
7273cdf0e10cSrcweir                 if( !myWidth )
7274cdf0e10cSrcweir                     myWidth = mpWindowImpl->mpFrame->GetUnmirroredGeometry().nWidth;
7275cdf0e10cSrcweir                 if( !myWidth )
7276cdf0e10cSrcweir                     myWidth = nWidth;
7277cdf0e10cSrcweir                 nFlags |= WINDOW_POSSIZE_X;
7278cdf0e10cSrcweir                 nSysFlags |= SAL_FRAME_POSSIZE_X;
7279cdf0e10cSrcweir                 nX = mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX - pWindow->GetParent()->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX -
7280cdf0e10cSrcweir                     mpWindowImpl->mpFrame->GetUnmirroredGeometry().nLeftDecoration;
7281cdf0e10cSrcweir                 nX = pWindow->GetParent()->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX - mpWindowImpl->mpFrame->GetUnmirroredGeometry().nLeftDecoration +
7282cdf0e10cSrcweir                     pWindow->GetParent()->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nWidth - myWidth - 1 - mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX;
7283cdf0e10cSrcweir                 if(!(nFlags & WINDOW_POSSIZE_Y))
7284cdf0e10cSrcweir                 {
7285cdf0e10cSrcweir                     nFlags |= WINDOW_POSSIZE_Y;
7286cdf0e10cSrcweir                     nSysFlags |= SAL_FRAME_POSSIZE_Y;
7287cdf0e10cSrcweir                     nY = mpWindowImpl->mpFrame->GetUnmirroredGeometry().nY - pWindow->GetParent()->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nY -
7288cdf0e10cSrcweir                         mpWindowImpl->mpFrame->GetUnmirroredGeometry().nTopDecoration;
7289cdf0e10cSrcweir                 }
7290cdf0e10cSrcweir             }
7291cdf0e10cSrcweir         }
7292cdf0e10cSrcweir         if( nFlags & WINDOW_POSSIZE_Y )
7293cdf0e10cSrcweir 		{
7294cdf0e10cSrcweir             nSysFlags |= SAL_FRAME_POSSIZE_Y;
7295cdf0e10cSrcweir             if( pWindow->GetParent() && (pWindow->GetStyle() & WB_SYSTEMCHILDWINDOW) )
7296cdf0e10cSrcweir 			{
7297cdf0e10cSrcweir                 Window* pParent = pWindow->GetParent();
7298cdf0e10cSrcweir                 nY += pParent->mnOutOffY;
7299cdf0e10cSrcweir 			}
7300cdf0e10cSrcweir 		}
7301cdf0e10cSrcweir 
7302cdf0e10cSrcweir         if( nSysFlags & (SAL_FRAME_POSSIZE_WIDTH|SAL_FRAME_POSSIZE_HEIGHT) )
7303cdf0e10cSrcweir         {
7304cdf0e10cSrcweir             // check for min/max client size and adjust size accordingly
7305cdf0e10cSrcweir             // otherwise it may happen that the resize event is ignored, i.e. the old size remains
7306cdf0e10cSrcweir             // unchanged but ImplHandleResize() is called with the wrong size
7307cdf0e10cSrcweir             SystemWindow *pSystemWindow = dynamic_cast< SystemWindow* >( pWindow );
7308cdf0e10cSrcweir             if( pSystemWindow )
7309cdf0e10cSrcweir             {
7310cdf0e10cSrcweir                 Size aMinSize = pSystemWindow->GetMinOutputSizePixel();
7311cdf0e10cSrcweir                 Size aMaxSize = pSystemWindow->GetMaxOutputSizePixel();
7312cdf0e10cSrcweir                 if( nWidth < aMinSize.Width() )
7313cdf0e10cSrcweir                     nWidth = aMinSize.Width();
7314cdf0e10cSrcweir                 if( nHeight < aMinSize.Height() )
7315cdf0e10cSrcweir                     nHeight = aMinSize.Height();
7316cdf0e10cSrcweir 
7317cdf0e10cSrcweir                 if( nWidth > aMaxSize.Width() )
7318cdf0e10cSrcweir                     nWidth = aMaxSize.Width();
7319cdf0e10cSrcweir                 if( nHeight > aMaxSize.Height() )
7320cdf0e10cSrcweir                     nHeight = aMaxSize.Height();
7321cdf0e10cSrcweir             }
7322cdf0e10cSrcweir         }
7323cdf0e10cSrcweir 
7324cdf0e10cSrcweir         pWindow->mpWindowImpl->mpFrame->SetPosSize( nX, nY, nWidth, nHeight, nSysFlags );
7325cdf0e10cSrcweir 
7326cdf0e10cSrcweir         // Resize should be called directly. If we havn't
7327cdf0e10cSrcweir         // set the correct size, we get a second resize from
7328cdf0e10cSrcweir         // the system with the correct size. This can be happend
7329cdf0e10cSrcweir         // if the size is to small or to large.
7330cdf0e10cSrcweir         ImplHandleResize( pWindow, nWidth, nHeight );
7331cdf0e10cSrcweir     }
7332cdf0e10cSrcweir     else
7333cdf0e10cSrcweir     {
7334cdf0e10cSrcweir         pWindow->ImplPosSizeWindow( nX, nY, nWidth, nHeight, nFlags );
7335cdf0e10cSrcweir         if ( IsReallyVisible() )
7336cdf0e10cSrcweir             ImplGenerateMouseMove();
7337cdf0e10cSrcweir     }
7338cdf0e10cSrcweir }
7339cdf0e10cSrcweir 
7340cdf0e10cSrcweir // -----------------------------------------------------------------------
7341cdf0e10cSrcweir 
7342cdf0e10cSrcweir Point Window::GetPosPixel() const
7343cdf0e10cSrcweir {
7344cdf0e10cSrcweir 	return mpWindowImpl->maPos;
7345cdf0e10cSrcweir }
7346cdf0e10cSrcweir 
7347cdf0e10cSrcweir // -----------------------------------------------------------------------
7348cdf0e10cSrcweir 
7349cdf0e10cSrcweir Rectangle Window::GetDesktopRectPixel() const
7350cdf0e10cSrcweir {
7351cdf0e10cSrcweir     Rectangle rRect;
7352cdf0e10cSrcweir     mpWindowImpl->mpFrameWindow->mpWindowImpl->mpFrame->GetWorkArea( rRect );
7353cdf0e10cSrcweir     return rRect;
7354cdf0e10cSrcweir }
7355cdf0e10cSrcweir 
7356cdf0e10cSrcweir // -----------------------------------------------------------------------
7357cdf0e10cSrcweir 
7358cdf0e10cSrcweir Point Window::OutputToScreenPixel( const Point& rPos ) const
7359cdf0e10cSrcweir {
7360cdf0e10cSrcweir     // relative to top level parent
7361cdf0e10cSrcweir     return Point( rPos.X()+mnOutOffX, rPos.Y()+mnOutOffY );
7362cdf0e10cSrcweir }
7363cdf0e10cSrcweir 
7364cdf0e10cSrcweir // -----------------------------------------------------------------------
7365cdf0e10cSrcweir 
7366cdf0e10cSrcweir Point Window::ScreenToOutputPixel( const Point& rPos ) const
7367cdf0e10cSrcweir {
7368cdf0e10cSrcweir     // relative to top level parent
7369cdf0e10cSrcweir     return Point( rPos.X()-mnOutOffX, rPos.Y()-mnOutOffY );
7370cdf0e10cSrcweir }
7371cdf0e10cSrcweir 
7372cdf0e10cSrcweir // -----------------------------------------------------------------------
7373cdf0e10cSrcweir 
7374cdf0e10cSrcweir long Window::ImplGetUnmirroredOutOffX()
7375cdf0e10cSrcweir {
7376cdf0e10cSrcweir     // revert mnOutOffX changes that were potentially made in ImplPosSizeWindow
7377cdf0e10cSrcweir     long offx = mnOutOffX;
7378cdf0e10cSrcweir     if( ImplHasMirroredGraphics() )
7379cdf0e10cSrcweir     {
7380cdf0e10cSrcweir         if( mpWindowImpl->mpParent && !mpWindowImpl->mpParent->mpWindowImpl->mbFrame && mpWindowImpl->mpParent->ImplIsAntiparallel() )
7381cdf0e10cSrcweir         {
7382cdf0e10cSrcweir             if ( !ImplIsOverlapWindow() )
7383cdf0e10cSrcweir                 offx -= mpWindowImpl->mpParent->mnOutOffX;
7384cdf0e10cSrcweir 
7385cdf0e10cSrcweir             offx = mpWindowImpl->mpParent->mnOutWidth - mnOutWidth - offx;
7386cdf0e10cSrcweir 
7387cdf0e10cSrcweir             if ( !ImplIsOverlapWindow() )
7388cdf0e10cSrcweir                 offx += mpWindowImpl->mpParent->mnOutOffX;
7389cdf0e10cSrcweir 
7390cdf0e10cSrcweir         }
7391cdf0e10cSrcweir     }
7392cdf0e10cSrcweir     return offx;
7393cdf0e10cSrcweir }
7394cdf0e10cSrcweir 
7395cdf0e10cSrcweir // normalized screen pixel are independent of mirroring
7396cdf0e10cSrcweir Point Window::OutputToNormalizedScreenPixel( const Point& rPos ) const
7397cdf0e10cSrcweir {
7398cdf0e10cSrcweir     // relative to top level parent
7399cdf0e10cSrcweir     long offx = ((Window*) this)->ImplGetUnmirroredOutOffX();
7400cdf0e10cSrcweir     return Point( rPos.X()+offx, rPos.Y()+mnOutOffY );
7401cdf0e10cSrcweir }
7402cdf0e10cSrcweir 
7403cdf0e10cSrcweir Point Window::NormalizedScreenToOutputPixel( const Point& rPos ) const
7404cdf0e10cSrcweir {
7405cdf0e10cSrcweir     // relative to top level parent
7406cdf0e10cSrcweir     long offx = ((Window*) this)->ImplGetUnmirroredOutOffX();
7407cdf0e10cSrcweir     return Point( rPos.X()-offx, rPos.Y()-mnOutOffY );
7408cdf0e10cSrcweir }
7409cdf0e10cSrcweir 
7410cdf0e10cSrcweir // -----------------------------------------------------------------------
7411cdf0e10cSrcweir 
7412cdf0e10cSrcweir Point Window::OutputToAbsoluteScreenPixel( const Point& rPos ) const
7413cdf0e10cSrcweir {
7414cdf0e10cSrcweir     // relative to the screen
7415cdf0e10cSrcweir     Point p = OutputToScreenPixel( rPos );
7416cdf0e10cSrcweir     SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry();
7417cdf0e10cSrcweir     p.X() += g.nX;
7418cdf0e10cSrcweir     p.Y() += g.nY;
7419cdf0e10cSrcweir     return p;
7420cdf0e10cSrcweir }
7421cdf0e10cSrcweir 
7422cdf0e10cSrcweir // -----------------------------------------------------------------------
7423cdf0e10cSrcweir 
7424cdf0e10cSrcweir Point Window::AbsoluteScreenToOutputPixel( const Point& rPos ) const
7425cdf0e10cSrcweir {
7426cdf0e10cSrcweir     // relative to the screen
7427cdf0e10cSrcweir     Point p = ScreenToOutputPixel( rPos );
7428cdf0e10cSrcweir     SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry();
7429cdf0e10cSrcweir     p.X() -= g.nX;
7430cdf0e10cSrcweir     p.Y() -= g.nY;
7431cdf0e10cSrcweir     return p;
7432cdf0e10cSrcweir }
7433cdf0e10cSrcweir 
7434cdf0e10cSrcweir // -----------------------------------------------------------------------
7435cdf0e10cSrcweir 
7436cdf0e10cSrcweir Rectangle Window::ImplOutputToUnmirroredAbsoluteScreenPixel( const Rectangle &rRect ) const
7437cdf0e10cSrcweir {
7438cdf0e10cSrcweir     // this method creates unmirrored screen coordinates to be compared with the desktop
7439cdf0e10cSrcweir     // and is used for positioning of RTL popup windows correctly on the screen
7440cdf0e10cSrcweir     SalFrameGeometry g = mpWindowImpl->mpFrame->GetUnmirroredGeometry();
7441cdf0e10cSrcweir 
7442cdf0e10cSrcweir     Point p1 = OutputToScreenPixel( rRect.TopRight() );
7443cdf0e10cSrcweir     p1.X() = g.nX+g.nWidth-p1.X();
7444cdf0e10cSrcweir     p1.Y() += g.nY;
7445cdf0e10cSrcweir 
7446cdf0e10cSrcweir     Point p2 = OutputToScreenPixel( rRect.BottomLeft() );
7447cdf0e10cSrcweir     p2.X() = g.nX+g.nWidth-p2.X();
7448cdf0e10cSrcweir     p2.Y() += g.nY;
7449cdf0e10cSrcweir 
7450cdf0e10cSrcweir     return Rectangle( p1, p2 );
7451cdf0e10cSrcweir }
7452cdf0e10cSrcweir 
7453cdf0e10cSrcweir 
7454cdf0e10cSrcweir // -----------------------------------------------------------------------
7455cdf0e10cSrcweir 
7456cdf0e10cSrcweir Rectangle Window::GetWindowExtentsRelative( Window *pRelativeWindow ) const
7457cdf0e10cSrcweir {
7458cdf0e10cSrcweir     // with decoration
7459cdf0e10cSrcweir     return ImplGetWindowExtentsRelative( pRelativeWindow, sal_False );
7460cdf0e10cSrcweir }
7461cdf0e10cSrcweir 
7462cdf0e10cSrcweir Rectangle Window::GetClientWindowExtentsRelative( Window *pRelativeWindow ) const
7463cdf0e10cSrcweir {
7464cdf0e10cSrcweir     // without decoration
7465cdf0e10cSrcweir     return ImplGetWindowExtentsRelative( pRelativeWindow, sal_True );
7466cdf0e10cSrcweir }
7467cdf0e10cSrcweir 
7468cdf0e10cSrcweir // -----------------------------------------------------------------------
7469cdf0e10cSrcweir 
7470cdf0e10cSrcweir Rectangle Window::ImplGetWindowExtentsRelative( Window *pRelativeWindow, sal_Bool bClientOnly ) const
7471cdf0e10cSrcweir {
7472cdf0e10cSrcweir     SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry();
7473cdf0e10cSrcweir     // make sure we use the extent of our border window,
7474cdf0e10cSrcweir     // otherwise we miss a few pixels
7475cdf0e10cSrcweir     const Window *pWin = (!bClientOnly && mpWindowImpl->mpBorderWindow) ? mpWindowImpl->mpBorderWindow : this;
7476cdf0e10cSrcweir 
7477cdf0e10cSrcweir     Point aPos( pWin->OutputToScreenPixel( Point(0,0) ) );
7478cdf0e10cSrcweir     aPos.X() += g.nX;
7479cdf0e10cSrcweir     aPos.Y() += g.nY;
7480cdf0e10cSrcweir     Size aSize ( pWin->GetSizePixel() );
7481cdf0e10cSrcweir     // #104088# do not add decoration to the workwindow to be compatible to java accessibility api
7482cdf0e10cSrcweir 	if( !bClientOnly && (mpWindowImpl->mbFrame || (mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame && GetType() != WINDOW_WORKWINDOW)) )
7483cdf0e10cSrcweir 	{
7484cdf0e10cSrcweir 		aPos.X() -= g.nLeftDecoration;
7485cdf0e10cSrcweir 		aPos.Y() -= g.nTopDecoration;
7486cdf0e10cSrcweir 		aSize.Width() += g.nLeftDecoration + g.nRightDecoration;
7487cdf0e10cSrcweir 		aSize.Height() += g.nTopDecoration + g.nBottomDecoration;
7488cdf0e10cSrcweir 	}
7489cdf0e10cSrcweir     if( pRelativeWindow )
7490cdf0e10cSrcweir     {
7491cdf0e10cSrcweir         // #106399# express coordinates relative to borderwindow
7492cdf0e10cSrcweir         Window *pRelWin = (!bClientOnly && pRelativeWindow->mpWindowImpl->mpBorderWindow) ? pRelativeWindow->mpWindowImpl->mpBorderWindow : pRelativeWindow;
7493cdf0e10cSrcweir         aPos = pRelWin->AbsoluteScreenToOutputPixel( aPos );
7494cdf0e10cSrcweir     }
7495cdf0e10cSrcweir     return Rectangle( aPos, aSize );
7496cdf0e10cSrcweir }
7497cdf0e10cSrcweir 
7498cdf0e10cSrcweir // -----------------------------------------------------------------------
7499cdf0e10cSrcweir 
7500cdf0e10cSrcweir void Window::Scroll( long nHorzScroll, long nVertScroll, sal_uInt16 nFlags )
7501cdf0e10cSrcweir {
7502cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7503cdf0e10cSrcweir 
7504cdf0e10cSrcweir     ImplScroll( Rectangle( Point( mnOutOffX, mnOutOffY ),
7505cdf0e10cSrcweir                            Size( mnOutWidth, mnOutHeight ) ),
7506cdf0e10cSrcweir                 nHorzScroll, nVertScroll, nFlags & ~SCROLL_CLIP );
7507cdf0e10cSrcweir }
7508cdf0e10cSrcweir 
7509cdf0e10cSrcweir // -----------------------------------------------------------------------
7510cdf0e10cSrcweir 
7511cdf0e10cSrcweir void Window::Scroll( long nHorzScroll, long nVertScroll,
7512cdf0e10cSrcweir                      const Rectangle& rRect, sal_uInt16 nFlags )
7513cdf0e10cSrcweir {
7514cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7515cdf0e10cSrcweir 
7516cdf0e10cSrcweir     Rectangle aRect = ImplLogicToDevicePixel( rRect );
7517cdf0e10cSrcweir     aRect.Intersection( Rectangle( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) ) );
7518cdf0e10cSrcweir     if ( !aRect.IsEmpty() )
7519cdf0e10cSrcweir         ImplScroll( aRect, nHorzScroll, nVertScroll, nFlags );
7520cdf0e10cSrcweir }
7521cdf0e10cSrcweir 
7522cdf0e10cSrcweir // -----------------------------------------------------------------------
7523cdf0e10cSrcweir 
7524cdf0e10cSrcweir void Window::Invalidate( sal_uInt16 nFlags )
7525cdf0e10cSrcweir {
7526cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7527cdf0e10cSrcweir 
7528cdf0e10cSrcweir     if ( !IsDeviceOutputNecessary() || !mnOutWidth || !mnOutHeight )
7529cdf0e10cSrcweir         return;
7530cdf0e10cSrcweir 
7531cdf0e10cSrcweir     ImplInvalidate( NULL, nFlags );
7532cdf0e10cSrcweir }
7533cdf0e10cSrcweir 
7534cdf0e10cSrcweir // -----------------------------------------------------------------------
7535cdf0e10cSrcweir 
7536cdf0e10cSrcweir void Window::Invalidate( const Rectangle& rRect, sal_uInt16 nFlags )
7537cdf0e10cSrcweir {
7538cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7539cdf0e10cSrcweir 
7540cdf0e10cSrcweir     if ( !IsDeviceOutputNecessary() || !mnOutWidth || !mnOutHeight )
7541cdf0e10cSrcweir         return;
7542cdf0e10cSrcweir 
7543cdf0e10cSrcweir     Rectangle aRect = ImplLogicToDevicePixel( rRect );
7544cdf0e10cSrcweir     if ( !aRect.IsEmpty() )
7545cdf0e10cSrcweir     {
7546cdf0e10cSrcweir         Region aRegion( aRect );
7547cdf0e10cSrcweir         ImplInvalidate( &aRegion, nFlags );
7548cdf0e10cSrcweir     }
7549cdf0e10cSrcweir }
7550cdf0e10cSrcweir 
7551cdf0e10cSrcweir // -----------------------------------------------------------------------
7552cdf0e10cSrcweir 
7553cdf0e10cSrcweir void Window::Invalidate( const Region& rRegion, sal_uInt16 nFlags )
7554cdf0e10cSrcweir {
7555cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7556cdf0e10cSrcweir 
7557cdf0e10cSrcweir     if ( !IsDeviceOutputNecessary() || !mnOutWidth || !mnOutHeight )
7558cdf0e10cSrcweir         return;
7559cdf0e10cSrcweir 
7560cdf0e10cSrcweir     if ( rRegion.IsNull() )
7561cdf0e10cSrcweir         ImplInvalidate( NULL, nFlags );
7562cdf0e10cSrcweir     else
7563cdf0e10cSrcweir     {
7564cdf0e10cSrcweir         Region aRegion = ImplPixelToDevicePixel( LogicToPixel( rRegion ) );
7565cdf0e10cSrcweir         if ( !aRegion.IsEmpty() )
7566cdf0e10cSrcweir             ImplInvalidate( &aRegion, nFlags );
7567cdf0e10cSrcweir     }
7568cdf0e10cSrcweir }
7569cdf0e10cSrcweir 
7570cdf0e10cSrcweir // -----------------------------------------------------------------------
7571cdf0e10cSrcweir 
7572cdf0e10cSrcweir void Window::Validate( sal_uInt16 nFlags )
7573cdf0e10cSrcweir {
7574cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7575cdf0e10cSrcweir 
7576cdf0e10cSrcweir     if ( !IsDeviceOutputNecessary() || !mnOutWidth || !mnOutHeight )
7577cdf0e10cSrcweir         return;
7578cdf0e10cSrcweir 
7579cdf0e10cSrcweir     ImplValidate( NULL, nFlags );
7580cdf0e10cSrcweir }
7581cdf0e10cSrcweir 
7582cdf0e10cSrcweir // -----------------------------------------------------------------------
7583cdf0e10cSrcweir 
7584cdf0e10cSrcweir void Window::Validate( const Rectangle& rRect, sal_uInt16 nFlags )
7585cdf0e10cSrcweir {
7586cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7587cdf0e10cSrcweir 
7588cdf0e10cSrcweir     if ( !IsDeviceOutputNecessary() || !mnOutWidth || !mnOutHeight )
7589cdf0e10cSrcweir         return;
7590cdf0e10cSrcweir 
7591cdf0e10cSrcweir     Rectangle aRect = ImplLogicToDevicePixel( rRect );
7592cdf0e10cSrcweir     if ( !aRect.IsEmpty() )
7593cdf0e10cSrcweir     {
7594cdf0e10cSrcweir         Region aRegion( aRect );
7595cdf0e10cSrcweir         ImplValidate( &aRegion, nFlags );
7596cdf0e10cSrcweir     }
7597cdf0e10cSrcweir }
7598cdf0e10cSrcweir 
7599cdf0e10cSrcweir // -----------------------------------------------------------------------
7600cdf0e10cSrcweir 
7601cdf0e10cSrcweir void Window::Validate( const Region& rRegion, sal_uInt16 nFlags )
7602cdf0e10cSrcweir {
7603cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7604cdf0e10cSrcweir 
7605cdf0e10cSrcweir     if ( !IsDeviceOutputNecessary() || !mnOutWidth || !mnOutHeight )
7606cdf0e10cSrcweir         return;
7607cdf0e10cSrcweir 
7608cdf0e10cSrcweir     if ( rRegion.IsNull() )
7609cdf0e10cSrcweir         ImplValidate( NULL, nFlags );
7610cdf0e10cSrcweir     else
7611cdf0e10cSrcweir     {
7612cdf0e10cSrcweir         Region aRegion = ImplPixelToDevicePixel( LogicToPixel( rRegion ) );
7613cdf0e10cSrcweir         if ( !aRegion.IsEmpty() )
7614cdf0e10cSrcweir             ImplValidate( &aRegion, nFlags );
7615cdf0e10cSrcweir     }
7616cdf0e10cSrcweir }
7617cdf0e10cSrcweir 
7618cdf0e10cSrcweir // -----------------------------------------------------------------------
7619cdf0e10cSrcweir 
7620cdf0e10cSrcweir sal_Bool Window::HasPaintEvent() const
7621cdf0e10cSrcweir {
7622cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7623cdf0e10cSrcweir 
7624cdf0e10cSrcweir     if ( !mpWindowImpl->mbReallyVisible )
7625cdf0e10cSrcweir         return sal_False;
7626cdf0e10cSrcweir 
7627cdf0e10cSrcweir     if ( mpWindowImpl->mpFrameWindow->mpWindowImpl->mbPaintFrame )
7628cdf0e10cSrcweir         return sal_True;
7629cdf0e10cSrcweir 
7630cdf0e10cSrcweir     if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINT )
7631cdf0e10cSrcweir         return sal_True;
7632cdf0e10cSrcweir 
7633cdf0e10cSrcweir     if ( !ImplIsOverlapWindow() )
7634cdf0e10cSrcweir     {
7635cdf0e10cSrcweir         const Window* pTempWindow = this;
7636cdf0e10cSrcweir         do
7637cdf0e10cSrcweir         {
7638cdf0e10cSrcweir             pTempWindow = pTempWindow->ImplGetParent();
7639cdf0e10cSrcweir             if ( pTempWindow->mpWindowImpl->mnPaintFlags & (IMPL_PAINT_PAINTCHILDS | IMPL_PAINT_PAINTALLCHILDS) )
7640cdf0e10cSrcweir                 return sal_True;
7641cdf0e10cSrcweir         }
7642cdf0e10cSrcweir         while ( !pTempWindow->ImplIsOverlapWindow() );
7643cdf0e10cSrcweir     }
7644cdf0e10cSrcweir 
7645cdf0e10cSrcweir     return sal_False;
7646cdf0e10cSrcweir }
7647cdf0e10cSrcweir 
7648cdf0e10cSrcweir // -----------------------------------------------------------------------
7649cdf0e10cSrcweir 
7650cdf0e10cSrcweir void Window::Update()
7651cdf0e10cSrcweir {
7652cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7653cdf0e10cSrcweir 
7654cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
7655cdf0e10cSrcweir     {
7656cdf0e10cSrcweir         mpWindowImpl->mpBorderWindow->Update();
7657cdf0e10cSrcweir         return;
7658cdf0e10cSrcweir     }
7659cdf0e10cSrcweir 
7660cdf0e10cSrcweir     if ( !mpWindowImpl->mbReallyVisible )
7661cdf0e10cSrcweir         return;
7662cdf0e10cSrcweir 
7663cdf0e10cSrcweir     sal_Bool bFlush = sal_False;
7664cdf0e10cSrcweir     if ( mpWindowImpl->mpFrameWindow->mpWindowImpl->mbPaintFrame )
7665cdf0e10cSrcweir     {
7666cdf0e10cSrcweir         Point aPoint( 0, 0 );
7667cdf0e10cSrcweir         Region aRegion( Rectangle( aPoint, Size( mnOutWidth, mnOutHeight ) ) );
7668cdf0e10cSrcweir         ImplInvalidateOverlapFrameRegion( aRegion );
7669cdf0e10cSrcweir         if ( mpWindowImpl->mbFrame || (mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame) )
7670cdf0e10cSrcweir             bFlush = sal_True;
7671cdf0e10cSrcweir     }
7672cdf0e10cSrcweir 
7673cdf0e10cSrcweir     // Zuerst muessen wir alle Fenster ueberspringen, die Paint-Transparent
7674cdf0e10cSrcweir     // sind
7675cdf0e10cSrcweir     Window* pUpdateWindow = this;
7676cdf0e10cSrcweir     Window* pWindow = pUpdateWindow;
7677cdf0e10cSrcweir     while ( !pWindow->ImplIsOverlapWindow() )
7678cdf0e10cSrcweir     {
7679cdf0e10cSrcweir         if ( !pWindow->mpWindowImpl->mbPaintTransparent )
7680cdf0e10cSrcweir         {
7681cdf0e10cSrcweir             pUpdateWindow = pWindow;
7682cdf0e10cSrcweir             break;
7683cdf0e10cSrcweir         }
7684cdf0e10cSrcweir         pWindow = pWindow->ImplGetParent();
7685cdf0e10cSrcweir     }
7686cdf0e10cSrcweir     // Ein Update wirkt immer auf das Window, wo PAINTALLCHILDS gesetzt
7687cdf0e10cSrcweir     // ist, damit nicht zuviel gemalt wird
7688cdf0e10cSrcweir     pWindow = pUpdateWindow;
7689cdf0e10cSrcweir     do
7690cdf0e10cSrcweir     {
7691cdf0e10cSrcweir         if ( pWindow->mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALLCHILDS )
7692cdf0e10cSrcweir             pUpdateWindow = pWindow;
7693cdf0e10cSrcweir         if ( pWindow->ImplIsOverlapWindow() )
7694cdf0e10cSrcweir             break;
7695cdf0e10cSrcweir         pWindow = pWindow->ImplGetParent();
7696cdf0e10cSrcweir     }
7697cdf0e10cSrcweir     while ( pWindow );
7698cdf0e10cSrcweir 
7699cdf0e10cSrcweir     // Wenn es etwas zu malen gibt, dann ein Paint ausloesen
7700cdf0e10cSrcweir     if ( pUpdateWindow->mpWindowImpl->mnPaintFlags & (IMPL_PAINT_PAINT | IMPL_PAINT_PAINTCHILDS) )
7701cdf0e10cSrcweir     {
7702cdf0e10cSrcweir          // und fuer alle ueber uns stehende System-Fenster auch ein Update
7703cdf0e10cSrcweir          // ausloesen, damit nicht die ganze Zeit luecken stehen bleiben
7704cdf0e10cSrcweir          Window* pUpdateOverlapWindow = ImplGetFirstOverlapWindow()->mpWindowImpl->mpFirstOverlap;
7705cdf0e10cSrcweir          while ( pUpdateOverlapWindow )
7706cdf0e10cSrcweir          {
7707cdf0e10cSrcweir              pUpdateOverlapWindow->Update();
7708cdf0e10cSrcweir              pUpdateOverlapWindow = pUpdateOverlapWindow->mpWindowImpl->mpNext;
7709cdf0e10cSrcweir          }
7710cdf0e10cSrcweir 
7711cdf0e10cSrcweir         pUpdateWindow->ImplCallPaint( NULL, pUpdateWindow->mpWindowImpl->mnPaintFlags );
7712cdf0e10cSrcweir     }
7713cdf0e10cSrcweir 
7714cdf0e10cSrcweir     if ( bFlush )
7715cdf0e10cSrcweir         Flush();
7716cdf0e10cSrcweir }
7717cdf0e10cSrcweir 
7718cdf0e10cSrcweir // -----------------------------------------------------------------------
7719cdf0e10cSrcweir 
7720cdf0e10cSrcweir void Window::Flush()
7721cdf0e10cSrcweir {
7722cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7723cdf0e10cSrcweir 
7724cdf0e10cSrcweir     const Rectangle aWinRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
7725cdf0e10cSrcweir     mpWindowImpl->mpFrame->Flush( aWinRect );
7726cdf0e10cSrcweir }
7727cdf0e10cSrcweir 
7728cdf0e10cSrcweir // -----------------------------------------------------------------------
7729cdf0e10cSrcweir 
7730cdf0e10cSrcweir void Window::Sync()
7731cdf0e10cSrcweir {
7732cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7733cdf0e10cSrcweir 
7734cdf0e10cSrcweir     mpWindowImpl->mpFrame->Sync();
7735cdf0e10cSrcweir }
7736cdf0e10cSrcweir 
7737cdf0e10cSrcweir // -----------------------------------------------------------------------
7738cdf0e10cSrcweir 
7739cdf0e10cSrcweir void Window::SetUpdateMode( sal_Bool bUpdate )
7740cdf0e10cSrcweir {
7741cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7742cdf0e10cSrcweir 
7743cdf0e10cSrcweir     mpWindowImpl->mbNoUpdate = !bUpdate;
7744cdf0e10cSrcweir     StateChanged( STATE_CHANGE_UPDATEMODE );
7745cdf0e10cSrcweir }
7746cdf0e10cSrcweir 
7747cdf0e10cSrcweir // -----------------------------------------------------------------------
7748cdf0e10cSrcweir 
7749cdf0e10cSrcweir void Window::GrabFocus()
7750cdf0e10cSrcweir {
7751cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7752cdf0e10cSrcweir 
7753cdf0e10cSrcweir     ImplGrabFocus( 0 );
7754cdf0e10cSrcweir }
7755cdf0e10cSrcweir 
7756cdf0e10cSrcweir // -----------------------------------------------------------------------
7757cdf0e10cSrcweir 
7758cdf0e10cSrcweir sal_Bool Window::HasFocus() const
7759cdf0e10cSrcweir {
7760cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7761cdf0e10cSrcweir 
7762cdf0e10cSrcweir     // #107575# the first floating window always has the keyboard focus, see also winproc.cxx: ImplGetKeyInputWindow()
7763cdf0e10cSrcweir     //  task was shifted to 6.y, so its commented out
7764cdf0e10cSrcweir     /*
7765cdf0e10cSrcweir     Window* pFocusWin = ImplGetSVData()->maWinData.mpFirstFloat;
7766cdf0e10cSrcweir     if( pFocusWin && pFocusWin->mpWindowImpl->mbFloatWin && ((FloatingWindow *)pFocusWin)->GrabsFocus() )
7767cdf0e10cSrcweir         pFocusWin = pFocusWin->GetPreferredKeyInputWindow();
7768cdf0e10cSrcweir     else
7769cdf0e10cSrcweir         pFocusWin = ImplGetSVData()->maWinData.mpFocusWin;
7770cdf0e10cSrcweir 
7771cdf0e10cSrcweir     return (this == pFocusWin);
7772cdf0e10cSrcweir     */
7773cdf0e10cSrcweir 
7774cdf0e10cSrcweir     return (this == ImplGetSVData()->maWinData.mpFocusWin);
7775cdf0e10cSrcweir }
7776cdf0e10cSrcweir 
7777cdf0e10cSrcweir // -----------------------------------------------------------------------
7778cdf0e10cSrcweir 
7779cdf0e10cSrcweir void Window::GrabFocusToDocument()
7780cdf0e10cSrcweir {
7781cdf0e10cSrcweir 	Window *pWin = this;
7782cdf0e10cSrcweir 	while( pWin )
7783cdf0e10cSrcweir 	{
7784cdf0e10cSrcweir 		if( !pWin->GetParent() )
7785cdf0e10cSrcweir 		{
7786cdf0e10cSrcweir 			pWin->ImplGetFrameWindow()->GetWindow( WINDOW_CLIENT )->GrabFocus();
7787cdf0e10cSrcweir 			return;
7788cdf0e10cSrcweir 		}
7789cdf0e10cSrcweir 		pWin = pWin->GetParent();
7790cdf0e10cSrcweir 	}
7791cdf0e10cSrcweir }
7792cdf0e10cSrcweir 
7793cdf0e10cSrcweir void Window::SetFakeFocus( bool bFocus )
7794cdf0e10cSrcweir {
7795cdf0e10cSrcweir     ImplGetWindowImpl()->mbFakeFocusSet = bFocus;
7796cdf0e10cSrcweir }
7797cdf0e10cSrcweir 
7798cdf0e10cSrcweir // -----------------------------------------------------------------------
7799cdf0e10cSrcweir 
7800cdf0e10cSrcweir sal_Bool Window::HasChildPathFocus( sal_Bool bSystemWindow ) const
7801cdf0e10cSrcweir {
7802cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7803cdf0e10cSrcweir 
7804cdf0e10cSrcweir     // #107575#, the first floating window always has the keyboard focus, see also winproc.cxx: ImplGetKeyInputWindow()
7805cdf0e10cSrcweir     //  task was shifted to 6.y, so its commented out
7806cdf0e10cSrcweir     /*
7807cdf0e10cSrcweir     Window* pFocusWin = ImplGetSVData()->maWinData.mpFirstFloat;
7808cdf0e10cSrcweir     if( pFocusWin && pFocusWin->mpWindowImpl->mbFloatWin && ((FloatingWindow *)pFocusWin)->GrabsFocus() )
7809cdf0e10cSrcweir         pFocusWin = pFocusWin->GetPreferredKeyInputWindow();
7810cdf0e10cSrcweir     else
7811cdf0e10cSrcweir         pFocusWin = ImplGetSVData()->maWinData.mpFocusWin;
7812cdf0e10cSrcweir     */
7813cdf0e10cSrcweir     Window* pFocusWin = ImplGetSVData()->maWinData.mpFocusWin;
7814cdf0e10cSrcweir     if ( pFocusWin )
7815cdf0e10cSrcweir         return ImplIsWindowOrChild( pFocusWin, bSystemWindow );
7816cdf0e10cSrcweir     return sal_False;
7817cdf0e10cSrcweir }
7818cdf0e10cSrcweir 
7819cdf0e10cSrcweir // -----------------------------------------------------------------------
7820cdf0e10cSrcweir 
7821cdf0e10cSrcweir void Window::CaptureMouse()
7822cdf0e10cSrcweir {
7823cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7824cdf0e10cSrcweir 
7825cdf0e10cSrcweir     ImplSVData* pSVData = ImplGetSVData();
7826cdf0e10cSrcweir 
7827cdf0e10cSrcweir     // Tracking evt. beenden
7828cdf0e10cSrcweir     if ( pSVData->maWinData.mpTrackWin != this )
7829cdf0e10cSrcweir     {
7830cdf0e10cSrcweir         if ( pSVData->maWinData.mpTrackWin )
7831cdf0e10cSrcweir             pSVData->maWinData.mpTrackWin->EndTracking( ENDTRACK_CANCEL );
7832cdf0e10cSrcweir     }
7833cdf0e10cSrcweir 
7834cdf0e10cSrcweir     if ( pSVData->maWinData.mpCaptureWin != this )
7835cdf0e10cSrcweir     {
7836cdf0e10cSrcweir         pSVData->maWinData.mpCaptureWin = this;
7837cdf0e10cSrcweir         mpWindowImpl->mpFrame->CaptureMouse( sal_True );
7838cdf0e10cSrcweir     }
7839cdf0e10cSrcweir }
7840cdf0e10cSrcweir 
7841cdf0e10cSrcweir // -----------------------------------------------------------------------
7842cdf0e10cSrcweir 
7843cdf0e10cSrcweir void Window::ReleaseMouse()
7844cdf0e10cSrcweir {
7845cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7846cdf0e10cSrcweir 
7847cdf0e10cSrcweir     ImplSVData* pSVData = ImplGetSVData();
7848cdf0e10cSrcweir 
7849cdf0e10cSrcweir     DBG_ASSERTWARNING( pSVData->maWinData.mpCaptureWin == this,
7850cdf0e10cSrcweir                        "Window::ReleaseMouse(): window doesn't have the mouse capture" );
7851cdf0e10cSrcweir 
7852cdf0e10cSrcweir     if ( pSVData->maWinData.mpCaptureWin == this )
7853cdf0e10cSrcweir     {
7854cdf0e10cSrcweir         pSVData->maWinData.mpCaptureWin = NULL;
7855cdf0e10cSrcweir         mpWindowImpl->mpFrame->CaptureMouse( sal_False );
7856cdf0e10cSrcweir         ImplGenerateMouseMove();
7857cdf0e10cSrcweir     }
7858cdf0e10cSrcweir }
7859cdf0e10cSrcweir 
7860cdf0e10cSrcweir // -----------------------------------------------------------------------
7861cdf0e10cSrcweir 
7862cdf0e10cSrcweir sal_Bool Window::IsMouseCaptured() const
7863cdf0e10cSrcweir {
7864cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7865cdf0e10cSrcweir 
7866cdf0e10cSrcweir     return (this == ImplGetSVData()->maWinData.mpCaptureWin);
7867cdf0e10cSrcweir }
7868cdf0e10cSrcweir 
7869cdf0e10cSrcweir // -----------------------------------------------------------------------
7870cdf0e10cSrcweir 
7871cdf0e10cSrcweir void Window::SetPointer( const Pointer& rPointer )
7872cdf0e10cSrcweir {
7873cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7874cdf0e10cSrcweir 
7875cdf0e10cSrcweir     if ( mpWindowImpl->maPointer == rPointer )
7876cdf0e10cSrcweir         return;
7877cdf0e10cSrcweir 
7878cdf0e10cSrcweir     mpWindowImpl->maPointer   = rPointer;
7879cdf0e10cSrcweir 
7880cdf0e10cSrcweir     // Pointer evt. direkt umsetzen
7881cdf0e10cSrcweir     if ( !mpWindowImpl->mpFrameData->mbInMouseMove && ImplTestMousePointerSet() )
7882cdf0e10cSrcweir         mpWindowImpl->mpFrame->SetPointer( ImplGetMousePointer() );
7883cdf0e10cSrcweir }
7884cdf0e10cSrcweir 
7885cdf0e10cSrcweir // -----------------------------------------------------------------------
7886cdf0e10cSrcweir 
7887cdf0e10cSrcweir void Window::EnableChildPointerOverwrite( sal_Bool bOverwrite )
7888cdf0e10cSrcweir {
7889cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7890cdf0e10cSrcweir 
7891cdf0e10cSrcweir     if ( mpWindowImpl->mbChildPtrOverwrite == bOverwrite )
7892cdf0e10cSrcweir         return;
7893cdf0e10cSrcweir 
7894cdf0e10cSrcweir     mpWindowImpl->mbChildPtrOverwrite  = bOverwrite;
7895cdf0e10cSrcweir 
7896cdf0e10cSrcweir     // Pointer evt. direkt umsetzen
7897cdf0e10cSrcweir     if ( !mpWindowImpl->mpFrameData->mbInMouseMove && ImplTestMousePointerSet() )
7898cdf0e10cSrcweir         mpWindowImpl->mpFrame->SetPointer( ImplGetMousePointer() );
7899cdf0e10cSrcweir }
7900cdf0e10cSrcweir 
7901cdf0e10cSrcweir // -----------------------------------------------------------------------
7902cdf0e10cSrcweir 
7903cdf0e10cSrcweir void Window::SetPointerPosPixel( const Point& rPos )
7904cdf0e10cSrcweir {
7905cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7906cdf0e10cSrcweir 
7907cdf0e10cSrcweir     Point aPos = ImplOutputToFrame( rPos );
7908cdf0e10cSrcweir     if( ImplHasMirroredGraphics() )
7909cdf0e10cSrcweir     {
7910cdf0e10cSrcweir         if( !IsRTLEnabled() )
7911cdf0e10cSrcweir         {
7912cdf0e10cSrcweir             // --- RTL --- (re-mirror mouse pos at this window)
7913cdf0e10cSrcweir             ImplReMirror( aPos );
7914cdf0e10cSrcweir         }
7915cdf0e10cSrcweir         // mirroring is required here, SetPointerPos bypasses SalGraphics
7916cdf0e10cSrcweir         mpGraphics->mirror( aPos.X(), this );
7917cdf0e10cSrcweir     }
7918cdf0e10cSrcweir     else if( ImplIsAntiparallel() )
7919cdf0e10cSrcweir     {
7920cdf0e10cSrcweir         ImplReMirror( aPos );
7921cdf0e10cSrcweir     }
7922cdf0e10cSrcweir     mpWindowImpl->mpFrame->SetPointerPos( aPos.X(), aPos.Y() );
7923cdf0e10cSrcweir }
7924cdf0e10cSrcweir 
7925cdf0e10cSrcweir // -----------------------------------------------------------------------
7926cdf0e10cSrcweir 
7927cdf0e10cSrcweir Point Window::GetPointerPosPixel()
7928cdf0e10cSrcweir {
7929cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7930cdf0e10cSrcweir 
7931cdf0e10cSrcweir     Point aPos( mpWindowImpl->mpFrameData->mnLastMouseX, mpWindowImpl->mpFrameData->mnLastMouseY );
7932cdf0e10cSrcweir     if( ImplIsAntiparallel() )
7933cdf0e10cSrcweir     {
7934cdf0e10cSrcweir         // --- RTL --- (re-mirror mouse pos at this window)
7935cdf0e10cSrcweir         ImplReMirror( aPos );
7936cdf0e10cSrcweir     }
7937cdf0e10cSrcweir     return ImplFrameToOutput( aPos );
7938cdf0e10cSrcweir }
7939cdf0e10cSrcweir 
7940cdf0e10cSrcweir // -----------------------------------------------------------------------
7941cdf0e10cSrcweir 
7942cdf0e10cSrcweir Point Window::GetLastPointerPosPixel()
7943cdf0e10cSrcweir {
7944cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7945cdf0e10cSrcweir 
7946cdf0e10cSrcweir     Point aPos( mpWindowImpl->mpFrameData->mnBeforeLastMouseX, mpWindowImpl->mpFrameData->mnBeforeLastMouseY );
7947cdf0e10cSrcweir     if( ImplIsAntiparallel() )
7948cdf0e10cSrcweir     {
7949cdf0e10cSrcweir         // --- RTL --- (re-mirror mouse pos at this window)
7950cdf0e10cSrcweir         ImplReMirror( aPos );
7951cdf0e10cSrcweir     }
7952cdf0e10cSrcweir     return ImplFrameToOutput( aPos );
7953cdf0e10cSrcweir }
7954cdf0e10cSrcweir 
7955cdf0e10cSrcweir // -----------------------------------------------------------------------
7956cdf0e10cSrcweir 
7957cdf0e10cSrcweir void Window::ShowPointer( sal_Bool bVisible )
7958cdf0e10cSrcweir {
7959cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
7960cdf0e10cSrcweir 
7961cdf0e10cSrcweir     if ( mpWindowImpl->mbNoPtrVisible != !bVisible )
7962cdf0e10cSrcweir     {
7963cdf0e10cSrcweir         mpWindowImpl->mbNoPtrVisible = !bVisible;
7964cdf0e10cSrcweir 
7965cdf0e10cSrcweir         // Pointer evt. direkt umsetzen
7966cdf0e10cSrcweir         if ( !mpWindowImpl->mpFrameData->mbInMouseMove && ImplTestMousePointerSet() )
7967cdf0e10cSrcweir             mpWindowImpl->mpFrame->SetPointer( ImplGetMousePointer() );
7968cdf0e10cSrcweir     }
7969cdf0e10cSrcweir }
7970cdf0e10cSrcweir 
7971cdf0e10cSrcweir // -----------------------------------------------------------------------
7972cdf0e10cSrcweir 
7973cdf0e10cSrcweir Window::PointerState Window::GetPointerState()
7974cdf0e10cSrcweir {
7975cdf0e10cSrcweir     PointerState aState;
7976cdf0e10cSrcweir     aState.mnState = 0;
7977cdf0e10cSrcweir 
7978cdf0e10cSrcweir     if (mpWindowImpl->mpFrame)
7979cdf0e10cSrcweir     {
7980cdf0e10cSrcweir         SalFrame::SalPointerState aSalPointerState;
7981cdf0e10cSrcweir 
7982cdf0e10cSrcweir         aSalPointerState = mpWindowImpl->mpFrame->GetPointerState();
7983cdf0e10cSrcweir         if( ImplIsAntiparallel() )
7984cdf0e10cSrcweir         {
7985cdf0e10cSrcweir             // --- RTL --- (re-mirror mouse pos at this window)
7986cdf0e10cSrcweir             ImplReMirror( aSalPointerState.maPos );
7987cdf0e10cSrcweir         }
7988cdf0e10cSrcweir         aState.maPos = ImplFrameToOutput( aSalPointerState.maPos );
7989cdf0e10cSrcweir         aState.mnState = aSalPointerState.mnState;
7990cdf0e10cSrcweir     }
7991cdf0e10cSrcweir     return aState;
7992cdf0e10cSrcweir }
7993cdf0e10cSrcweir 
7994cdf0e10cSrcweir // -----------------------------------------------------------------------
7995cdf0e10cSrcweir 
7996cdf0e10cSrcweir sal_Bool Window::IsMouseOver()
7997cdf0e10cSrcweir {
7998cdf0e10cSrcweir     return ImplGetWinData()->mbMouseOver;
7999cdf0e10cSrcweir }
8000cdf0e10cSrcweir 
8001cdf0e10cSrcweir // -----------------------------------------------------------------------
8002cdf0e10cSrcweir 
8003cdf0e10cSrcweir void Window::EnterWait()
8004cdf0e10cSrcweir {
8005cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
8006cdf0e10cSrcweir 
8007cdf0e10cSrcweir     mpWindowImpl->mnWaitCount++;
8008cdf0e10cSrcweir 
8009cdf0e10cSrcweir     if ( mpWindowImpl->mnWaitCount == 1 )
8010cdf0e10cSrcweir     {
8011cdf0e10cSrcweir         // Pointer evt. direkt umsetzen
8012cdf0e10cSrcweir         if ( !mpWindowImpl->mpFrameData->mbInMouseMove && ImplTestMousePointerSet() )
8013cdf0e10cSrcweir             mpWindowImpl->mpFrame->SetPointer( ImplGetMousePointer() );
8014cdf0e10cSrcweir     }
8015cdf0e10cSrcweir }
8016cdf0e10cSrcweir 
8017cdf0e10cSrcweir // -----------------------------------------------------------------------
8018cdf0e10cSrcweir 
8019cdf0e10cSrcweir void Window::LeaveWait()
8020cdf0e10cSrcweir {
8021cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
8022cdf0e10cSrcweir 
8023cdf0e10cSrcweir     if ( mpWindowImpl->mnWaitCount )
8024cdf0e10cSrcweir     {
8025cdf0e10cSrcweir         mpWindowImpl->mnWaitCount--;
8026cdf0e10cSrcweir 
8027cdf0e10cSrcweir         if ( !mpWindowImpl->mnWaitCount )
8028cdf0e10cSrcweir         {
8029cdf0e10cSrcweir             // Pointer evt. direkt umsetzen
8030cdf0e10cSrcweir             if ( !mpWindowImpl->mpFrameData->mbInMouseMove && ImplTestMousePointerSet() )
8031cdf0e10cSrcweir                 mpWindowImpl->mpFrame->SetPointer( ImplGetMousePointer() );
8032cdf0e10cSrcweir         }
8033cdf0e10cSrcweir     }
8034cdf0e10cSrcweir }
8035cdf0e10cSrcweir 
8036cdf0e10cSrcweir // -----------------------------------------------------------------------
8037cdf0e10cSrcweir 
8038cdf0e10cSrcweir void Window::SetCursor( Cursor* pCursor )
8039cdf0e10cSrcweir {
8040cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
8041cdf0e10cSrcweir 
8042cdf0e10cSrcweir     if ( mpWindowImpl->mpCursor != pCursor )
8043cdf0e10cSrcweir     {
8044cdf0e10cSrcweir         if ( mpWindowImpl->mpCursor )
8045cdf0e10cSrcweir             mpWindowImpl->mpCursor->ImplHide( true );
8046cdf0e10cSrcweir         mpWindowImpl->mpCursor = pCursor;
8047cdf0e10cSrcweir         if ( pCursor )
8048cdf0e10cSrcweir             pCursor->ImplShow();
8049cdf0e10cSrcweir     }
8050cdf0e10cSrcweir }
8051cdf0e10cSrcweir 
8052cdf0e10cSrcweir // -----------------------------------------------------------------------
8053cdf0e10cSrcweir 
8054cdf0e10cSrcweir void Window::SetText( const XubString& rStr )
8055cdf0e10cSrcweir {
8056cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
8057cdf0e10cSrcweir 
8058cdf0e10cSrcweir     String oldTitle( mpWindowImpl->maText );
8059cdf0e10cSrcweir     mpWindowImpl->maText = rStr;
8060cdf0e10cSrcweir 
8061cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
8062cdf0e10cSrcweir         mpWindowImpl->mpBorderWindow->SetText( rStr );
8063cdf0e10cSrcweir     else if ( mpWindowImpl->mbFrame )
8064cdf0e10cSrcweir         mpWindowImpl->mpFrame->SetTitle( rStr );
8065cdf0e10cSrcweir 
8066cdf0e10cSrcweir     ImplCallEventListeners( VCLEVENT_WINDOW_FRAMETITLECHANGED, &oldTitle );
8067cdf0e10cSrcweir 
8068cdf0e10cSrcweir 	// #107247# needed for accessibility
8069cdf0e10cSrcweir 	// The VCLEVENT_WINDOW_FRAMETITLECHANGED is (mis)used to notify accessible name changes.
8070cdf0e10cSrcweir 	// Therefore a window, which is labeled by this window, must also notify an accessible
8071cdf0e10cSrcweir 	// name change.
8072cdf0e10cSrcweir 	if ( IsReallyVisible() )
8073cdf0e10cSrcweir 	{
8074cdf0e10cSrcweir 		Window* pWindow = GetAccessibleRelationLabelFor();
8075cdf0e10cSrcweir 		if ( pWindow && pWindow != this )
8076cdf0e10cSrcweir 			pWindow->ImplCallEventListeners( VCLEVENT_WINDOW_FRAMETITLECHANGED, &oldTitle );
8077cdf0e10cSrcweir 	}
8078cdf0e10cSrcweir 
8079cdf0e10cSrcweir     StateChanged( STATE_CHANGE_TEXT );
8080cdf0e10cSrcweir }
8081cdf0e10cSrcweir 
8082cdf0e10cSrcweir // -----------------------------------------------------------------------
8083cdf0e10cSrcweir 
8084cdf0e10cSrcweir String Window::GetText() const
8085cdf0e10cSrcweir {
8086cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
8087cdf0e10cSrcweir 
8088cdf0e10cSrcweir     return mpWindowImpl->maText;
8089cdf0e10cSrcweir }
8090cdf0e10cSrcweir 
8091cdf0e10cSrcweir // -----------------------------------------------------------------------
8092cdf0e10cSrcweir 
8093cdf0e10cSrcweir String Window::GetDisplayText() const
8094cdf0e10cSrcweir {
8095cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
8096cdf0e10cSrcweir 
8097cdf0e10cSrcweir     return GetText();
8098cdf0e10cSrcweir }
8099cdf0e10cSrcweir 
8100cdf0e10cSrcweir // -----------------------------------------------------------------------
8101cdf0e10cSrcweir 
8102cdf0e10cSrcweir const Wallpaper& Window::GetDisplayBackground() const
8103cdf0e10cSrcweir {
8104cdf0e10cSrcweir     // FIXME: fix issue 52349, need to fix this really in
8105cdf0e10cSrcweir     // all NWF enabled controls
8106cdf0e10cSrcweir     const ToolBox* pTB = dynamic_cast<const ToolBox*>(this);
8107cdf0e10cSrcweir     if( pTB )
8108cdf0e10cSrcweir     {
8109cdf0e10cSrcweir         if( IsNativeWidgetEnabled() )
8110cdf0e10cSrcweir             return pTB->ImplGetToolBoxPrivateData()->maDisplayBackground;
8111cdf0e10cSrcweir     }
8112cdf0e10cSrcweir 
8113cdf0e10cSrcweir     if( !IsBackground() )
8114cdf0e10cSrcweir     {
8115cdf0e10cSrcweir         if( mpWindowImpl->mpParent )
8116cdf0e10cSrcweir             return mpWindowImpl->mpParent->GetDisplayBackground();
8117cdf0e10cSrcweir     }
8118cdf0e10cSrcweir 
8119cdf0e10cSrcweir     const Wallpaper& rBack = GetBackground();
8120cdf0e10cSrcweir     if( ! rBack.IsBitmap() &&
8121cdf0e10cSrcweir         ! rBack.IsGradient() &&
8122cdf0e10cSrcweir         rBack.GetColor().GetColor() == COL_TRANSPARENT &&
8123cdf0e10cSrcweir         mpWindowImpl->mpParent )
8124cdf0e10cSrcweir             return mpWindowImpl->mpParent->GetDisplayBackground();
8125cdf0e10cSrcweir     return rBack;
8126cdf0e10cSrcweir }
8127cdf0e10cSrcweir 
8128cdf0e10cSrcweir // -----------------------------------------------------------------------
8129cdf0e10cSrcweir 
8130cdf0e10cSrcweir const XubString& Window::GetHelpText() const
8131cdf0e10cSrcweir {
8132cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
8133cdf0e10cSrcweir 
8134cdf0e10cSrcweir 	String aStrHelpId( rtl::OStringToOUString( GetHelpId(), RTL_TEXTENCODING_UTF8 ) );
8135cdf0e10cSrcweir 	bool bStrHelpId = (aStrHelpId.Len() > 0);
8136cdf0e10cSrcweir 
8137cdf0e10cSrcweir     if ( !mpWindowImpl->maHelpText.Len() && bStrHelpId )
8138cdf0e10cSrcweir     {
8139cdf0e10cSrcweir         if ( !IsDialog() && (mpWindowImpl->mnType != WINDOW_TABPAGE) && (mpWindowImpl->mnType != WINDOW_FLOATINGWINDOW) )
8140cdf0e10cSrcweir         {
8141cdf0e10cSrcweir             Help* pHelp = Application::GetHelp();
8142cdf0e10cSrcweir             if ( pHelp )
8143cdf0e10cSrcweir 			{
8144cdf0e10cSrcweir 			    ((Window*)this)->mpWindowImpl->maHelpText = pHelp->GetHelpText( aStrHelpId, this );
8145cdf0e10cSrcweir                 mpWindowImpl->mbHelpTextDynamic = sal_False;
8146cdf0e10cSrcweir 			}
8147cdf0e10cSrcweir         }
8148cdf0e10cSrcweir     }
8149cdf0e10cSrcweir     else if( mpWindowImpl->mbHelpTextDynamic && bStrHelpId )
8150cdf0e10cSrcweir     {
8151cdf0e10cSrcweir         static const char* pEnv = getenv( "HELP_DEBUG" );
8152cdf0e10cSrcweir         if( pEnv && *pEnv )
8153cdf0e10cSrcweir         {
8154cdf0e10cSrcweir             rtl::OUStringBuffer aTxt( 64+mpWindowImpl->maHelpText.Len() );
8155cdf0e10cSrcweir             aTxt.append( mpWindowImpl->maHelpText );
8156cdf0e10cSrcweir             aTxt.appendAscii( "\n------------------\n" );
8157cdf0e10cSrcweir             aTxt.append( rtl::OUString( aStrHelpId ) );
8158cdf0e10cSrcweir             mpWindowImpl->maHelpText = aTxt.makeStringAndClear();
8159cdf0e10cSrcweir         }
8160cdf0e10cSrcweir         mpWindowImpl->mbHelpTextDynamic = sal_False;
8161cdf0e10cSrcweir     }
8162cdf0e10cSrcweir 
8163cdf0e10cSrcweir     return mpWindowImpl->maHelpText;
8164cdf0e10cSrcweir }
8165cdf0e10cSrcweir 
8166cdf0e10cSrcweir // -----------------------------------------------------------------------
8167cdf0e10cSrcweir 
8168cdf0e10cSrcweir Window* Window::FindWindow( const Point& rPos ) const
8169cdf0e10cSrcweir {
8170cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
8171cdf0e10cSrcweir 
8172cdf0e10cSrcweir     Point aPos = OutputToScreenPixel( rPos );
8173cdf0e10cSrcweir     return ((Window*)this)->ImplFindWindow( aPos );
8174cdf0e10cSrcweir }
8175cdf0e10cSrcweir 
8176cdf0e10cSrcweir // -----------------------------------------------------------------------
8177cdf0e10cSrcweir 
8178cdf0e10cSrcweir sal_uInt16 Window::GetChildCount() const
8179cdf0e10cSrcweir {
8180cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
8181cdf0e10cSrcweir 
8182cdf0e10cSrcweir     sal_uInt16  nChildCount = 0;
8183cdf0e10cSrcweir     Window* pChild = mpWindowImpl->mpFirstChild;
8184cdf0e10cSrcweir     while ( pChild )
8185cdf0e10cSrcweir     {
8186cdf0e10cSrcweir         nChildCount++;
8187cdf0e10cSrcweir         pChild = pChild->mpWindowImpl->mpNext;
8188cdf0e10cSrcweir     }
8189cdf0e10cSrcweir 
8190cdf0e10cSrcweir     return nChildCount;
8191cdf0e10cSrcweir }
8192cdf0e10cSrcweir 
8193cdf0e10cSrcweir // -----------------------------------------------------------------------
8194cdf0e10cSrcweir 
8195cdf0e10cSrcweir Window* Window::GetChild( sal_uInt16 nChild ) const
8196cdf0e10cSrcweir {
8197cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
8198cdf0e10cSrcweir 
8199cdf0e10cSrcweir     sal_uInt16  nChildCount = 0;
8200cdf0e10cSrcweir     Window* pChild = mpWindowImpl->mpFirstChild;
8201cdf0e10cSrcweir     while ( pChild )
8202cdf0e10cSrcweir     {
8203cdf0e10cSrcweir         if ( nChild == nChildCount )
8204cdf0e10cSrcweir             return pChild;
8205cdf0e10cSrcweir         pChild = pChild->mpWindowImpl->mpNext;
8206cdf0e10cSrcweir         nChildCount++;
8207cdf0e10cSrcweir     }
8208cdf0e10cSrcweir 
8209cdf0e10cSrcweir     return NULL;
8210cdf0e10cSrcweir }
8211cdf0e10cSrcweir 
8212cdf0e10cSrcweir // -----------------------------------------------------------------------
8213cdf0e10cSrcweir 
8214cdf0e10cSrcweir Window* Window::GetWindow( sal_uInt16 nType ) const
8215cdf0e10cSrcweir {
8216cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
8217cdf0e10cSrcweir 
8218cdf0e10cSrcweir     switch ( nType )
8219cdf0e10cSrcweir     {
8220cdf0e10cSrcweir         case WINDOW_PARENT:
8221cdf0e10cSrcweir             return mpWindowImpl->mpRealParent;
8222cdf0e10cSrcweir 
8223cdf0e10cSrcweir         case WINDOW_FIRSTCHILD:
8224cdf0e10cSrcweir             return mpWindowImpl->mpFirstChild;
8225cdf0e10cSrcweir 
8226cdf0e10cSrcweir         case WINDOW_LASTCHILD:
8227cdf0e10cSrcweir             return mpWindowImpl->mpLastChild;
8228cdf0e10cSrcweir 
8229cdf0e10cSrcweir         case WINDOW_PREV:
8230cdf0e10cSrcweir             return mpWindowImpl->mpPrev;
8231cdf0e10cSrcweir 
8232cdf0e10cSrcweir         case WINDOW_NEXT:
8233cdf0e10cSrcweir             return mpWindowImpl->mpNext;
8234cdf0e10cSrcweir 
8235cdf0e10cSrcweir         case WINDOW_FIRSTOVERLAP:
8236cdf0e10cSrcweir             return mpWindowImpl->mpFirstOverlap;
8237cdf0e10cSrcweir 
8238cdf0e10cSrcweir         case WINDOW_LASTOVERLAP:
8239cdf0e10cSrcweir             return mpWindowImpl->mpLastOverlap;
8240cdf0e10cSrcweir 
8241cdf0e10cSrcweir         case WINDOW_OVERLAP:
8242cdf0e10cSrcweir             if ( ImplIsOverlapWindow() )
8243cdf0e10cSrcweir                 return (Window*)this;
8244cdf0e10cSrcweir             else
8245cdf0e10cSrcweir                 return mpWindowImpl->mpOverlapWindow;
8246cdf0e10cSrcweir 
8247cdf0e10cSrcweir         case WINDOW_PARENTOVERLAP:
8248cdf0e10cSrcweir             if ( ImplIsOverlapWindow() )
8249cdf0e10cSrcweir                 return mpWindowImpl->mpOverlapWindow;
8250cdf0e10cSrcweir             else
8251cdf0e10cSrcweir                 return mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpOverlapWindow;
8252cdf0e10cSrcweir 
8253cdf0e10cSrcweir         case WINDOW_CLIENT:
8254cdf0e10cSrcweir             return ((Window*)this)->ImplGetWindow();
8255cdf0e10cSrcweir 
8256cdf0e10cSrcweir         case WINDOW_REALPARENT:
8257cdf0e10cSrcweir             return ImplGetParent();
8258cdf0e10cSrcweir 
8259cdf0e10cSrcweir         case WINDOW_FRAME:
8260cdf0e10cSrcweir             return mpWindowImpl->mpFrameWindow;
8261cdf0e10cSrcweir 
8262cdf0e10cSrcweir         case WINDOW_BORDER:
8263cdf0e10cSrcweir             if ( mpWindowImpl->mpBorderWindow )
8264cdf0e10cSrcweir                 return mpWindowImpl->mpBorderWindow->GetWindow( WINDOW_BORDER );
8265cdf0e10cSrcweir             return (Window*)this;
8266cdf0e10cSrcweir 
8267cdf0e10cSrcweir         case WINDOW_FIRSTTOPWINDOWCHILD:
8268cdf0e10cSrcweir             return ImplGetWinData()->maTopWindowChildren.empty() ? NULL : *ImplGetWinData()->maTopWindowChildren.begin();
8269cdf0e10cSrcweir 
8270cdf0e10cSrcweir         case WINDOW_LASTTOPWINDOWCHILD:
8271cdf0e10cSrcweir             return ImplGetWinData()->maTopWindowChildren.empty() ? NULL : *ImplGetWinData()->maTopWindowChildren.rbegin();
8272cdf0e10cSrcweir 
8273cdf0e10cSrcweir         case WINDOW_PREVTOPWINDOWSIBLING:
8274cdf0e10cSrcweir         {
8275cdf0e10cSrcweir             if ( !mpWindowImpl->mpRealParent )
8276cdf0e10cSrcweir                 return NULL;
8277cdf0e10cSrcweir             const ::std::list< Window* >& rTopWindows( mpWindowImpl->mpRealParent->ImplGetWinData()->maTopWindowChildren );
8278cdf0e10cSrcweir             ::std::list< Window* >::const_iterator myPos =
8279cdf0e10cSrcweir                 ::std::find( rTopWindows.begin(), rTopWindows.end(), this );
8280cdf0e10cSrcweir             if ( myPos == rTopWindows.end() )
8281cdf0e10cSrcweir                 return NULL;
8282cdf0e10cSrcweir             if ( myPos == rTopWindows.begin() )
8283cdf0e10cSrcweir                 return NULL;
8284cdf0e10cSrcweir             return *--myPos;
8285cdf0e10cSrcweir         }
8286cdf0e10cSrcweir 
8287cdf0e10cSrcweir         case WINDOW_NEXTTOPWINDOWSIBLING:
8288cdf0e10cSrcweir         {
8289cdf0e10cSrcweir             if ( !mpWindowImpl->mpRealParent )
8290cdf0e10cSrcweir                 return NULL;
8291cdf0e10cSrcweir             const ::std::list< Window* >& rTopWindows( mpWindowImpl->mpRealParent->ImplGetWinData()->maTopWindowChildren );
8292cdf0e10cSrcweir             ::std::list< Window* >::const_iterator myPos =
8293cdf0e10cSrcweir                 ::std::find( rTopWindows.begin(), rTopWindows.end(), this );
8294cdf0e10cSrcweir             if ( ( myPos == rTopWindows.end() ) || ( ++myPos == rTopWindows.end() ) )
8295cdf0e10cSrcweir                 return NULL;
8296cdf0e10cSrcweir             return *myPos;
8297cdf0e10cSrcweir         }
8298cdf0e10cSrcweir 
8299cdf0e10cSrcweir     }
8300cdf0e10cSrcweir 
8301cdf0e10cSrcweir     return NULL;
8302cdf0e10cSrcweir }
8303cdf0e10cSrcweir 
8304cdf0e10cSrcweir // -----------------------------------------------------------------------
8305cdf0e10cSrcweir 
8306cdf0e10cSrcweir sal_Bool Window::IsChild( const Window* pWindow, sal_Bool bSystemWindow ) const
8307cdf0e10cSrcweir {
8308cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
8309cdf0e10cSrcweir     DBG_CHKOBJ( pWindow, Window, ImplDbgCheckWindow );
8310cdf0e10cSrcweir 
8311cdf0e10cSrcweir     do
8312cdf0e10cSrcweir     {
8313cdf0e10cSrcweir         if ( !bSystemWindow && pWindow->ImplIsOverlapWindow() )
8314cdf0e10cSrcweir             break;
8315cdf0e10cSrcweir 
8316cdf0e10cSrcweir         pWindow = pWindow->ImplGetParent();
8317cdf0e10cSrcweir 
8318cdf0e10cSrcweir         if ( pWindow == this )
8319cdf0e10cSrcweir             return sal_True;
8320cdf0e10cSrcweir     }
8321cdf0e10cSrcweir     while ( pWindow );
8322cdf0e10cSrcweir 
8323cdf0e10cSrcweir     return sal_False;
8324cdf0e10cSrcweir }
8325cdf0e10cSrcweir 
8326cdf0e10cSrcweir // -----------------------------------------------------------------------
8327cdf0e10cSrcweir 
8328cdf0e10cSrcweir sal_Bool Window::IsWindowOrChild( const Window* pWindow, sal_Bool bSystemWindow ) const
8329cdf0e10cSrcweir {
8330cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
8331cdf0e10cSrcweir     DBG_CHKOBJ( pWindow, Window, ImplDbgCheckWindow );
8332cdf0e10cSrcweir 
8333cdf0e10cSrcweir     if ( this == pWindow )
8334cdf0e10cSrcweir         return sal_True;
8335cdf0e10cSrcweir     return ImplIsChild( pWindow, bSystemWindow );
8336cdf0e10cSrcweir }
8337cdf0e10cSrcweir 
8338cdf0e10cSrcweir // -----------------------------------------------------------------------
8339cdf0e10cSrcweir 
8340cdf0e10cSrcweir const SystemEnvData* Window::GetSystemData() const
8341cdf0e10cSrcweir {
8342cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
8343cdf0e10cSrcweir 
8344cdf0e10cSrcweir     return mpWindowImpl->mpFrame ? mpWindowImpl->mpFrame->GetSystemData() : NULL;
8345cdf0e10cSrcweir }
8346cdf0e10cSrcweir 
8347cdf0e10cSrcweir ::com::sun::star::uno::Any Window::GetSystemDataAny() const
8348cdf0e10cSrcweir {
8349cdf0e10cSrcweir     ::com::sun::star::uno::Any aRet;
8350cdf0e10cSrcweir     const SystemEnvData* pSysData = GetSystemData();
8351cdf0e10cSrcweir     if( pSysData )
8352cdf0e10cSrcweir     {
8353cdf0e10cSrcweir         ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( (sal_Int8*)pSysData, pSysData->nSize );
8354cdf0e10cSrcweir         aRet <<= aSeq;
8355cdf0e10cSrcweir     }
8356cdf0e10cSrcweir     return aRet;
8357cdf0e10cSrcweir }
8358cdf0e10cSrcweir 
8359cdf0e10cSrcweir // -----------------------------------------------------------------------
8360cdf0e10cSrcweir 
8361cdf0e10cSrcweir void Window::SetWindowPeer( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xPeer, VCLXWindow* pVCLXWindow  )
8362cdf0e10cSrcweir {
8363cdf0e10cSrcweir     // be safe against re-entrance: first clear the old ref, then assign the new one
8364cdf0e10cSrcweir     // #133706# / 2006-03-30 / frank.schoenheit@sun.com
8365cdf0e10cSrcweir     mpWindowImpl->mxWindowPeer.clear();
8366cdf0e10cSrcweir     mpWindowImpl->mxWindowPeer = xPeer;
8367cdf0e10cSrcweir 
8368cdf0e10cSrcweir     mpWindowImpl->mpVCLXWindow = pVCLXWindow;
8369cdf0e10cSrcweir }
8370cdf0e10cSrcweir 
8371cdf0e10cSrcweir // -----------------------------------------------------------------------
8372cdf0e10cSrcweir 
8373cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > Window::GetComponentInterface( sal_Bool bCreate )
8374cdf0e10cSrcweir {
8375cdf0e10cSrcweir     if ( !mpWindowImpl->mxWindowPeer.is() && bCreate )
8376cdf0e10cSrcweir     {
8377cdf0e10cSrcweir         UnoWrapperBase* pWrapper = Application::GetUnoWrapper();
8378cdf0e10cSrcweir         if ( pWrapper )
8379cdf0e10cSrcweir             mpWindowImpl->mxWindowPeer = pWrapper->GetWindowInterface( this, sal_True );
8380cdf0e10cSrcweir     }
8381cdf0e10cSrcweir     return mpWindowImpl->mxWindowPeer;
8382cdf0e10cSrcweir }
8383cdf0e10cSrcweir 
8384cdf0e10cSrcweir // -----------------------------------------------------------------------
8385cdf0e10cSrcweir 
8386cdf0e10cSrcweir void Window::SetComponentInterface( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xIFace )
8387cdf0e10cSrcweir {
8388cdf0e10cSrcweir     UnoWrapperBase* pWrapper = Application::GetUnoWrapper();
8389cdf0e10cSrcweir     DBG_ASSERT( pWrapper, "SetComponentInterface: No Wrapper!" );
8390cdf0e10cSrcweir     if ( pWrapper )
8391cdf0e10cSrcweir         pWrapper->SetWindowInterface( this, xIFace );
8392cdf0e10cSrcweir }
8393cdf0e10cSrcweir 
8394cdf0e10cSrcweir // -----------------------------------------------------------------------
8395cdf0e10cSrcweir 
8396cdf0e10cSrcweir void Window::ImplCallDeactivateListeners( Window *pNew )
8397cdf0e10cSrcweir {
8398cdf0e10cSrcweir     // no deactivation if the the newly activated window is my child
8399cdf0e10cSrcweir     if ( !pNew || !ImplIsChild( pNew ) )
8400cdf0e10cSrcweir     {
8401cdf0e10cSrcweir         ImplDelData aDogtag( this );
8402cdf0e10cSrcweir         ImplCallEventListeners( VCLEVENT_WINDOW_DEACTIVATE );
8403cdf0e10cSrcweir         if( aDogtag.IsDelete() )
8404cdf0e10cSrcweir             return;
8405cdf0e10cSrcweir 
8406cdf0e10cSrcweir         // #100759#, avoid walking the wrong frame's hierarchy
8407cdf0e10cSrcweir         //           eg, undocked docking windows (ImplDockFloatWin)
8408cdf0e10cSrcweir         if ( ImplGetParent() && mpWindowImpl->mpFrameWindow == ImplGetParent()->mpWindowImpl->mpFrameWindow )
8409cdf0e10cSrcweir             ImplGetParent()->ImplCallDeactivateListeners( pNew );
8410cdf0e10cSrcweir     }
8411cdf0e10cSrcweir }
8412cdf0e10cSrcweir 
8413cdf0e10cSrcweir // -----------------------------------------------------------------------
8414cdf0e10cSrcweir 
8415cdf0e10cSrcweir void Window::ImplCallActivateListeners( Window *pOld )
8416cdf0e10cSrcweir {
8417cdf0e10cSrcweir     // no activation if the the old active window is my child
8418cdf0e10cSrcweir     if ( !pOld || !ImplIsChild( pOld ) )
8419cdf0e10cSrcweir     {
8420cdf0e10cSrcweir         ImplDelData aDogtag( this );
8421cdf0e10cSrcweir         ImplCallEventListeners( VCLEVENT_WINDOW_ACTIVATE, pOld );
8422cdf0e10cSrcweir         if( aDogtag.IsDelete() )
8423cdf0e10cSrcweir             return;
8424cdf0e10cSrcweir 
8425cdf0e10cSrcweir 		// #106298# revoke the change for 105369, because this change
8426cdf0e10cSrcweir 		//          disabled the activate event for the parent,
8427cdf0e10cSrcweir 		//          if the parent is a compound control
8428cdf0e10cSrcweir 		//if( !GetParent() || !GetParent()->IsCompoundControl() )
8429cdf0e10cSrcweir 		//{
8430cdf0e10cSrcweir 			// #100759#, avoid walking the wrong frame's hierarchy
8431cdf0e10cSrcweir 			//           eg, undocked docking windows (ImplDockFloatWin)
8432cdf0e10cSrcweir             // #104714#, revert the changes for 100759 because it has a side effect when pOld is a dialog
8433cdf0e10cSrcweir             //           additionally the gallery is not dockable anymore, so 100759 canot occur
8434cdf0e10cSrcweir 			if ( ImplGetParent() ) /* && mpWindowImpl->mpFrameWindow == ImplGetParent()->mpWindowImpl->mpFrameWindow ) */
8435cdf0e10cSrcweir 				ImplGetParent()->ImplCallActivateListeners( pOld );
8436cdf0e10cSrcweir             else if( (mpWindowImpl->mnStyle & WB_INTROWIN) == 0 )
8437cdf0e10cSrcweir             {
8438cdf0e10cSrcweir                 // top level frame reached: store hint for DefModalDialogParent
8439cdf0e10cSrcweir                 ImplGetSVData()->maWinData.mpActiveApplicationFrame = mpWindowImpl->mpFrameWindow;
8440cdf0e10cSrcweir             }
8441cdf0e10cSrcweir         //}
8442cdf0e10cSrcweir     }
8443cdf0e10cSrcweir }
8444cdf0e10cSrcweir 
8445cdf0e10cSrcweir // -----------------------------------------------------------------------
8446cdf0e10cSrcweir 
8447cdf0e10cSrcweir bool Window::ImplStopDnd()
8448cdf0e10cSrcweir {
8449cdf0e10cSrcweir     bool bRet = false;
8450cdf0e10cSrcweir     if( mpWindowImpl->mpFrameData && mpWindowImpl->mpFrameData->mxDropTargetListener.is() )
8451cdf0e10cSrcweir     {
8452cdf0e10cSrcweir         bRet = true;
8453cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mxDropTarget.clear();
8454cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mxDragSource.clear();
8455cdf0e10cSrcweir         mpWindowImpl->mpFrameData->mxDropTargetListener.clear();
8456cdf0e10cSrcweir     }
8457cdf0e10cSrcweir 
8458cdf0e10cSrcweir     return bRet;
8459cdf0e10cSrcweir }
8460cdf0e10cSrcweir 
8461cdf0e10cSrcweir // -----------------------------------------------------------------------
8462cdf0e10cSrcweir 
8463cdf0e10cSrcweir void Window::ImplStartDnd()
8464cdf0e10cSrcweir {
8465cdf0e10cSrcweir     GetDropTarget();
8466cdf0e10cSrcweir }
8467cdf0e10cSrcweir 
8468cdf0e10cSrcweir // -----------------------------------------------------------------------
8469cdf0e10cSrcweir 
8470cdf0e10cSrcweir uno::Reference< XDropTarget > Window::GetDropTarget()
8471cdf0e10cSrcweir {
8472cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
8473cdf0e10cSrcweir 
8474cdf0e10cSrcweir     if( ! mpWindowImpl->mxDNDListenerContainer.is() )
8475cdf0e10cSrcweir     {
8476cdf0e10cSrcweir         sal_Int8 nDefaultActions = 0;
8477cdf0e10cSrcweir 
8478cdf0e10cSrcweir         if( mpWindowImpl->mpFrameData )
8479cdf0e10cSrcweir         {
8480cdf0e10cSrcweir             if( ! mpWindowImpl->mpFrameData->mxDropTarget.is() )
8481cdf0e10cSrcweir             {
8482cdf0e10cSrcweir                 // initialization is done in GetDragSource
8483cdf0e10cSrcweir                 uno::Reference< XDragSource > xDragSource = GetDragSource();
8484cdf0e10cSrcweir             }
8485cdf0e10cSrcweir 
8486cdf0e10cSrcweir             if( mpWindowImpl->mpFrameData->mxDropTarget.is() )
8487cdf0e10cSrcweir             {
8488cdf0e10cSrcweir                 nDefaultActions = mpWindowImpl->mpFrameData->mxDropTarget->getDefaultActions();
8489cdf0e10cSrcweir 
8490cdf0e10cSrcweir                 if( ! mpWindowImpl->mpFrameData->mxDropTargetListener.is() )
8491cdf0e10cSrcweir                 {
8492cdf0e10cSrcweir                     mpWindowImpl->mpFrameData->mxDropTargetListener = new DNDEventDispatcher( mpWindowImpl->mpFrameWindow );
8493cdf0e10cSrcweir 
8494cdf0e10cSrcweir                     try
8495cdf0e10cSrcweir                     {
8496cdf0e10cSrcweir                         mpWindowImpl->mpFrameData->mxDropTarget->addDropTargetListener( mpWindowImpl->mpFrameData->mxDropTargetListener );
8497cdf0e10cSrcweir 
8498cdf0e10cSrcweir                         // register also as drag gesture listener if directly supported by drag source
8499cdf0e10cSrcweir                         uno::Reference< XDragGestureRecognizer > xDragGestureRecognizer =
8500cdf0e10cSrcweir                             uno::Reference< XDragGestureRecognizer > (mpWindowImpl->mpFrameData->mxDragSource, UNO_QUERY);
8501cdf0e10cSrcweir 
8502cdf0e10cSrcweir                         if( xDragGestureRecognizer.is() )
8503cdf0e10cSrcweir                         {
8504cdf0e10cSrcweir                             xDragGestureRecognizer->addDragGestureListener(
8505cdf0e10cSrcweir                                 uno::Reference< XDragGestureListener > (mpWindowImpl->mpFrameData->mxDropTargetListener, UNO_QUERY));
8506cdf0e10cSrcweir                         }
8507cdf0e10cSrcweir                         else
8508cdf0e10cSrcweir                             mpWindowImpl->mpFrameData->mbInternalDragGestureRecognizer = sal_True;
8509cdf0e10cSrcweir 
8510cdf0e10cSrcweir                     }
8511cdf0e10cSrcweir 
8512adad3ae8SHerbert Dürr                     catch( RuntimeException&)
8513cdf0e10cSrcweir                     {
8514cdf0e10cSrcweir                         // release all instances
8515cdf0e10cSrcweir                         mpWindowImpl->mpFrameData->mxDropTarget.clear();
8516cdf0e10cSrcweir                         mpWindowImpl->mpFrameData->mxDragSource.clear();
8517cdf0e10cSrcweir                     }
8518cdf0e10cSrcweir                 }
8519cdf0e10cSrcweir             }
8520cdf0e10cSrcweir 
8521cdf0e10cSrcweir         }
8522cdf0e10cSrcweir 
8523cdf0e10cSrcweir         mpWindowImpl->mxDNDListenerContainer = static_cast < XDropTarget * > ( new DNDListenerContainer( nDefaultActions ) );
8524cdf0e10cSrcweir     }
8525cdf0e10cSrcweir 
8526cdf0e10cSrcweir     // this object is located in the same process, so there will be no runtime exception
8527cdf0e10cSrcweir     return uno::Reference< XDropTarget > ( mpWindowImpl->mxDNDListenerContainer, UNO_QUERY );
8528cdf0e10cSrcweir }
8529cdf0e10cSrcweir 
8530cdf0e10cSrcweir // -----------------------------------------------------------------------
8531cdf0e10cSrcweir 
8532cdf0e10cSrcweir uno::Reference< XDragSource > Window::GetDragSource()
8533cdf0e10cSrcweir {
8534cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
8535cdf0e10cSrcweir 
8536cdf0e10cSrcweir     if( mpWindowImpl->mpFrameData )
8537cdf0e10cSrcweir     {
8538cdf0e10cSrcweir         if( ! mpWindowImpl->mpFrameData->mxDragSource.is() )
8539cdf0e10cSrcweir         {
8540cdf0e10cSrcweir             try
8541cdf0e10cSrcweir             {
8542cdf0e10cSrcweir                 uno::Reference< XMultiServiceFactory > xFactory = vcl::unohelper::GetMultiServiceFactory();
8543cdf0e10cSrcweir                 if ( xFactory.is() )
8544cdf0e10cSrcweir                 {
8545cdf0e10cSrcweir                     const SystemEnvData * pEnvData = GetSystemData();
8546cdf0e10cSrcweir 
8547cdf0e10cSrcweir                     if( pEnvData )
8548cdf0e10cSrcweir                     {
8549cdf0e10cSrcweir                         Sequence< Any > aDragSourceAL( 2 ), aDropTargetAL( 2 );
8550cdf0e10cSrcweir                         OUString aDragSourceSN, aDropTargetSN;
8551cdf0e10cSrcweir #if defined WNT
8552cdf0e10cSrcweir                         aDragSourceSN = OUString::createFromAscii( "com.sun.star.datatransfer.dnd.OleDragSource" );
8553cdf0e10cSrcweir                         aDropTargetSN = OUString::createFromAscii( "com.sun.star.datatransfer.dnd.OleDropTarget" );
8554cdf0e10cSrcweir                         aDragSourceAL[ 1 ] = makeAny( (sal_uInt32) pEnvData->hWnd );
8555cdf0e10cSrcweir                         aDropTargetAL[ 0 ] = makeAny( (sal_uInt32) pEnvData->hWnd );
8556cdf0e10cSrcweir #elif defined QUARTZ
8557cdf0e10cSrcweir 			/* FIXME: Mac OS X specific dnd interface does not exist! *
8558cdf0e10cSrcweir 			 * Using Windows based dnd as a temporary solution        */
8559cdf0e10cSrcweir                         aDragSourceSN = OUString::createFromAscii( "com.sun.star.datatransfer.dnd.OleDragSource" );
8560cdf0e10cSrcweir                         aDropTargetSN = OUString::createFromAscii( "com.sun.star.datatransfer.dnd.OleDropTarget" );
8561cdf0e10cSrcweir                         aDragSourceAL[ 1 ] = makeAny( static_cast<sal_uInt64>( reinterpret_cast<sal_IntPtr>(pEnvData->pView) ) );
8562cdf0e10cSrcweir                         aDropTargetAL[ 0 ] = makeAny( static_cast<sal_uInt64>( reinterpret_cast<sal_IntPtr>(pEnvData->pView) ) );
8563cdf0e10cSrcweir #elif defined UNX
8564cdf0e10cSrcweir                         aDropTargetAL.realloc( 3 );
8565cdf0e10cSrcweir                         aDragSourceAL.realloc( 3 );
8566cdf0e10cSrcweir                         aDragSourceSN = OUString::createFromAscii( "com.sun.star.datatransfer.dnd.X11DragSource" );
8567cdf0e10cSrcweir                         aDropTargetSN = OUString::createFromAscii( "com.sun.star.datatransfer.dnd.X11DropTarget" );
8568cdf0e10cSrcweir 
8569cdf0e10cSrcweir                         aDragSourceAL[ 0 ] = makeAny( Application::GetDisplayConnection() );
8570cdf0e10cSrcweir                         aDragSourceAL[ 2 ] = makeAny( vcl::createBmpConverter() );
8571cdf0e10cSrcweir                         aDropTargetAL[ 0 ] = makeAny( Application::GetDisplayConnection() );
8572cdf0e10cSrcweir                         aDropTargetAL[ 1 ] = makeAny( (sal_Size)(pEnvData->aShellWindow) );
8573cdf0e10cSrcweir                         aDropTargetAL[ 2 ] = makeAny( vcl::createBmpConverter() );
8574cdf0e10cSrcweir #endif
8575cdf0e10cSrcweir                         if( aDragSourceSN.getLength() )
8576cdf0e10cSrcweir                             mpWindowImpl->mpFrameData->mxDragSource = uno::Reference< XDragSource > ( xFactory->createInstanceWithArguments( aDragSourceSN, aDragSourceAL ), UNO_QUERY );
8577cdf0e10cSrcweir 
8578cdf0e10cSrcweir                         if( aDropTargetSN.getLength() )
8579cdf0e10cSrcweir                             mpWindowImpl->mpFrameData->mxDropTarget = uno::Reference< XDropTarget > ( xFactory->createInstanceWithArguments( aDropTargetSN, aDropTargetAL ), UNO_QUERY );
8580cdf0e10cSrcweir                     }
8581cdf0e10cSrcweir                 }
8582cdf0e10cSrcweir             }
8583cdf0e10cSrcweir 
8584cdf0e10cSrcweir             // createInstance can throw any exception
8585adad3ae8SHerbert Dürr             catch( Exception&)
8586cdf0e10cSrcweir             {
8587cdf0e10cSrcweir                 // release all instances
8588cdf0e10cSrcweir                 mpWindowImpl->mpFrameData->mxDropTarget.clear();
8589cdf0e10cSrcweir                 mpWindowImpl->mpFrameData->mxDragSource.clear();
8590cdf0e10cSrcweir             }
8591cdf0e10cSrcweir         }
8592cdf0e10cSrcweir 
8593cdf0e10cSrcweir         return mpWindowImpl->mpFrameData->mxDragSource;
8594cdf0e10cSrcweir     }
8595cdf0e10cSrcweir 
8596cdf0e10cSrcweir     return uno::Reference< XDragSource > ();
8597cdf0e10cSrcweir }
8598cdf0e10cSrcweir 
8599cdf0e10cSrcweir // -----------------------------------------------------------------------
8600cdf0e10cSrcweir 
8601cdf0e10cSrcweir void Window::GetDragSourceDropTarget(uno::Reference< XDragSource >& xDragSource, uno::Reference< XDropTarget > &xDropTarget )
8602cdf0e10cSrcweir // only for RVP transmission
8603cdf0e10cSrcweir {
8604cdf0e10cSrcweir     if( mpWindowImpl->mpFrameData )
8605cdf0e10cSrcweir     {
8606cdf0e10cSrcweir         // initialization is done in GetDragSource
8607cdf0e10cSrcweir         xDragSource = GetDragSource();
8608cdf0e10cSrcweir         xDropTarget = mpWindowImpl->mpFrameData->mxDropTarget;
8609cdf0e10cSrcweir     }
8610cdf0e10cSrcweir     else
8611cdf0e10cSrcweir     {
8612cdf0e10cSrcweir         xDragSource.clear();
8613cdf0e10cSrcweir         xDropTarget.clear();
8614cdf0e10cSrcweir     }
8615cdf0e10cSrcweir }
8616cdf0e10cSrcweir 
8617cdf0e10cSrcweir // -----------------------------------------------------------------------
8618cdf0e10cSrcweir 
8619cdf0e10cSrcweir uno::Reference< XDragGestureRecognizer > Window::GetDragGestureRecognizer()
8620cdf0e10cSrcweir {
8621cdf0e10cSrcweir     return uno::Reference< XDragGestureRecognizer > ( GetDropTarget(), UNO_QUERY );
8622cdf0e10cSrcweir }
8623cdf0e10cSrcweir 
8624cdf0e10cSrcweir // -----------------------------------------------------------------------
8625cdf0e10cSrcweir 
8626cdf0e10cSrcweir uno::Reference< XClipboard > Window::GetClipboard()
8627cdf0e10cSrcweir {
8628cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
8629cdf0e10cSrcweir 
8630cdf0e10cSrcweir     if( mpWindowImpl->mpFrameData )
8631cdf0e10cSrcweir     {
8632cdf0e10cSrcweir         if( ! mpWindowImpl->mpFrameData->mxClipboard.is() )
8633cdf0e10cSrcweir         {
8634cdf0e10cSrcweir             try
8635cdf0e10cSrcweir             {
8636cdf0e10cSrcweir                 uno::Reference< XMultiServiceFactory > xFactory( vcl::unohelper::GetMultiServiceFactory() );
8637cdf0e10cSrcweir 
8638cdf0e10cSrcweir                 if( xFactory.is() )
8639cdf0e10cSrcweir                 {
8640cdf0e10cSrcweir                     mpWindowImpl->mpFrameData->mxClipboard = uno::Reference< XClipboard >( xFactory->createInstance( OUString::createFromAscii( "com.sun.star.datatransfer.clipboard.SystemClipboardExt" ) ), UNO_QUERY );
8641cdf0e10cSrcweir 
8642cdf0e10cSrcweir                     if( !mpWindowImpl->mpFrameData->mxClipboard.is() )
8643cdf0e10cSrcweir                         mpWindowImpl->mpFrameData->mxClipboard = uno::Reference< XClipboard >( xFactory->createInstance( OUString::createFromAscii( "com.sun.star.datatransfer.clipboard.SystemClipboard" ) ), UNO_QUERY );
8644cdf0e10cSrcweir 
8645cdf0e10cSrcweir #if defined(UNX) && !defined(QUARTZ)          // unix clipboard needs to be initialized
8646cdf0e10cSrcweir                     if( mpWindowImpl->mpFrameData->mxClipboard.is() )
8647cdf0e10cSrcweir                     {
8648cdf0e10cSrcweir                         uno::Reference< XInitialization > xInit = uno::Reference< XInitialization >( mpWindowImpl->mpFrameData->mxClipboard, UNO_QUERY );
8649cdf0e10cSrcweir 
8650cdf0e10cSrcweir                         if( xInit.is() )
8651cdf0e10cSrcweir                         {
8652cdf0e10cSrcweir                             Sequence< Any > aArgumentList( 3 );
8653cdf0e10cSrcweir                             aArgumentList[ 0 ] = makeAny( Application::GetDisplayConnection() );
8654cdf0e10cSrcweir                             aArgumentList[ 1 ] = makeAny( OUString::createFromAscii( "CLIPBOARD" ) );
8655cdf0e10cSrcweir                             aArgumentList[ 2 ] = makeAny( vcl::createBmpConverter() );
8656cdf0e10cSrcweir 
8657cdf0e10cSrcweir                             xInit->initialize( aArgumentList );
8658cdf0e10cSrcweir                         }
8659cdf0e10cSrcweir                     }
8660cdf0e10cSrcweir #endif
8661cdf0e10cSrcweir                 }
8662cdf0e10cSrcweir             }
8663cdf0e10cSrcweir 
8664cdf0e10cSrcweir             // createInstance can throw any exception
8665adad3ae8SHerbert Dürr             catch( Exception&)
8666cdf0e10cSrcweir             {
8667cdf0e10cSrcweir                 // release all instances
8668cdf0e10cSrcweir                 mpWindowImpl->mpFrameData->mxClipboard.clear();
8669cdf0e10cSrcweir             }
8670cdf0e10cSrcweir         }
8671cdf0e10cSrcweir 
8672cdf0e10cSrcweir         return mpWindowImpl->mpFrameData->mxClipboard;
8673cdf0e10cSrcweir     }
8674cdf0e10cSrcweir 
8675cdf0e10cSrcweir     return static_cast < XClipboard * > (0);
8676cdf0e10cSrcweir }
8677cdf0e10cSrcweir 
8678cdf0e10cSrcweir // -----------------------------------------------------------------------
8679cdf0e10cSrcweir 
8680cdf0e10cSrcweir uno::Reference< XClipboard > Window::GetPrimarySelection()
8681cdf0e10cSrcweir {
8682cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
8683cdf0e10cSrcweir 
8684cdf0e10cSrcweir     if( mpWindowImpl->mpFrameData )
8685cdf0e10cSrcweir     {
8686cdf0e10cSrcweir         if( ! mpWindowImpl->mpFrameData->mxSelection.is() )
8687cdf0e10cSrcweir         {
8688cdf0e10cSrcweir             try
8689cdf0e10cSrcweir             {
8690cdf0e10cSrcweir                 uno::Reference< XMultiServiceFactory > xFactory( vcl::unohelper::GetMultiServiceFactory() );
8691cdf0e10cSrcweir 
8692cdf0e10cSrcweir                 if( xFactory.is() )
8693cdf0e10cSrcweir                 {
8694cdf0e10cSrcweir #if defined(UNX) && !defined(QUARTZ)
8695cdf0e10cSrcweir                     Sequence< Any > aArgumentList( 3 );
8696cdf0e10cSrcweir                   	aArgumentList[ 0 ] = makeAny( Application::GetDisplayConnection() );
8697cdf0e10cSrcweir                     aArgumentList[ 1 ] = makeAny( OUString::createFromAscii( "PRIMARY" ) );
8698cdf0e10cSrcweir                     aArgumentList[ 2 ] = makeAny( vcl::createBmpConverter() );
8699cdf0e10cSrcweir 
8700cdf0e10cSrcweir                     mpWindowImpl->mpFrameData->mxSelection = uno::Reference< XClipboard >( xFactory->createInstanceWithArguments(
8701cdf0e10cSrcweir 					OUString::createFromAscii( "com.sun.star.datatransfer.clipboard.SystemClipboard" ), aArgumentList ), UNO_QUERY );
8702cdf0e10cSrcweir #	else
8703cdf0e10cSrcweir 					static uno::Reference< XClipboard >	s_xSelection;
8704cdf0e10cSrcweir 
8705cdf0e10cSrcweir 					if ( !s_xSelection.is() )
8706cdf0e10cSrcweir  						s_xSelection = uno::Reference< XClipboard >( xFactory->createInstance( OUString::createFromAscii( "com.sun.star.datatransfer.clipboard.GenericClipboardExt" ) ), UNO_QUERY );
8707cdf0e10cSrcweir 
8708cdf0e10cSrcweir 					if ( !s_xSelection.is() )
8709cdf0e10cSrcweir  						s_xSelection = uno::Reference< XClipboard >( xFactory->createInstance( OUString::createFromAscii( "com.sun.star.datatransfer.clipboard.GenericClipboard" ) ), UNO_QUERY );
8710cdf0e10cSrcweir 
8711cdf0e10cSrcweir                     mpWindowImpl->mpFrameData->mxSelection = s_xSelection;
8712cdf0e10cSrcweir #	endif
8713cdf0e10cSrcweir                 }
8714cdf0e10cSrcweir             }
8715cdf0e10cSrcweir 
8716cdf0e10cSrcweir             // createInstance can throw any exception
8717adad3ae8SHerbert Dürr             catch( Exception&)
8718cdf0e10cSrcweir             {
8719cdf0e10cSrcweir                 // release all instances
8720cdf0e10cSrcweir                 mpWindowImpl->mpFrameData->mxSelection.clear();
8721cdf0e10cSrcweir             }
8722cdf0e10cSrcweir         }
8723cdf0e10cSrcweir 
8724cdf0e10cSrcweir         return mpWindowImpl->mpFrameData->mxSelection;
8725cdf0e10cSrcweir     }
8726cdf0e10cSrcweir 
8727cdf0e10cSrcweir     return static_cast < XClipboard * > (0);
8728cdf0e10cSrcweir }
8729cdf0e10cSrcweir 
8730cdf0e10cSrcweir // -----------------------------------------------------------------------
8731cdf0e10cSrcweir // Accessibility
8732cdf0e10cSrcweir // -----------------------------------------------------------------------
8733cdf0e10cSrcweir 
8734cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > Window::GetAccessible( sal_Bool bCreate )
8735cdf0e10cSrcweir {
8736cdf0e10cSrcweir     // do not optimize hierarchy for the top level border win (ie, when there is no parent)
8737cdf0e10cSrcweir     /* // do not optimize accessible hierarchy at all to better reflect real VCL hierarchy
8738cdf0e10cSrcweir 	if ( GetParent() && ( GetType() == WINDOW_BORDERWINDOW ) && ( GetChildCount() == 1 ) )
8739cdf0e10cSrcweir     //if( !ImplIsAccessibleCandidate() )
8740cdf0e10cSrcweir 	{
8741cdf0e10cSrcweir 		Window* pChild = GetAccessibleChildWindow( 0 );
8742cdf0e10cSrcweir 		if ( pChild )
8743cdf0e10cSrcweir 			return pChild->GetAccessible();
8744cdf0e10cSrcweir 	}
8745cdf0e10cSrcweir     */
8746cdf0e10cSrcweir     if ( !mpWindowImpl->mxAccessible.is() && bCreate )
8747cdf0e10cSrcweir         mpWindowImpl->mxAccessible = CreateAccessible();
8748cdf0e10cSrcweir 
8749cdf0e10cSrcweir 	return mpWindowImpl->mxAccessible;
8750cdf0e10cSrcweir }
8751cdf0e10cSrcweir 
8752cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > Window::CreateAccessible()
8753cdf0e10cSrcweir {
8754cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAcc( GetComponentInterface( sal_True ), ::com::sun::star::uno::UNO_QUERY );
8755cdf0e10cSrcweir     return xAcc;
8756cdf0e10cSrcweir }
8757cdf0e10cSrcweir 
8758cdf0e10cSrcweir void Window::SetAccessible( ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > x )
8759cdf0e10cSrcweir {
8760cdf0e10cSrcweir     mpWindowImpl->mxAccessible = x;
8761cdf0e10cSrcweir }
8762cdf0e10cSrcweir 
8763cdf0e10cSrcweir // skip all border windows that are no top level frames
8764cdf0e10cSrcweir sal_Bool Window::ImplIsAccessibleCandidate() const
8765cdf0e10cSrcweir {
8766cdf0e10cSrcweir     if( !mpWindowImpl->mbBorderWin )
8767cdf0e10cSrcweir         return sal_True;
8768cdf0e10cSrcweir     else
8769cdf0e10cSrcweir         // #101741 do not check for WB_CLOSEABLE because undecorated floaters (like menues!) are closeable
8770cdf0e10cSrcweir         if( mpWindowImpl->mbFrame && mpWindowImpl->mnStyle & (WB_MOVEABLE | WB_SIZEABLE) )
8771cdf0e10cSrcweir             return sal_True;
8772cdf0e10cSrcweir         else
8773cdf0e10cSrcweir             return sal_False;
8774cdf0e10cSrcweir }
8775cdf0e10cSrcweir 
8776cdf0e10cSrcweir sal_Bool Window::ImplIsAccessibleNativeFrame() const
8777cdf0e10cSrcweir {
8778cdf0e10cSrcweir     if( mpWindowImpl->mbFrame )
8779cdf0e10cSrcweir         // #101741 do not check for WB_CLOSEABLE because undecorated floaters (like menues!) are closeable
8780cdf0e10cSrcweir         if( (mpWindowImpl->mnStyle & (WB_MOVEABLE | WB_SIZEABLE)) )
8781cdf0e10cSrcweir             return sal_True;
8782cdf0e10cSrcweir         else
8783cdf0e10cSrcweir             return sal_False;
8784cdf0e10cSrcweir     else
8785cdf0e10cSrcweir         return sal_False;
8786cdf0e10cSrcweir }
8787cdf0e10cSrcweir 
8788cdf0e10cSrcweir sal_uInt16 Window::ImplGetAccessibleCandidateChildWindowCount( sal_uInt16 nFirstWindowType ) const
8789cdf0e10cSrcweir {
8790cdf0e10cSrcweir     sal_uInt16  nChildren = 0;
8791cdf0e10cSrcweir     Window* pChild = GetWindow( nFirstWindowType );
8792cdf0e10cSrcweir     while ( pChild )
8793cdf0e10cSrcweir     {
8794cdf0e10cSrcweir         if( pChild->ImplIsAccessibleCandidate() )
8795cdf0e10cSrcweir             nChildren++;
8796cdf0e10cSrcweir         else
8797cdf0e10cSrcweir             nChildren = sal::static_int_cast<sal_uInt16>(nChildren + pChild->ImplGetAccessibleCandidateChildWindowCount( WINDOW_FIRSTCHILD ));
8798cdf0e10cSrcweir         pChild = pChild->mpWindowImpl->mpNext;
8799cdf0e10cSrcweir     }
8800cdf0e10cSrcweir     return nChildren;
8801cdf0e10cSrcweir }
8802cdf0e10cSrcweir 
8803cdf0e10cSrcweir Window* Window::ImplGetAccessibleCandidateChild( sal_uInt16 nChild, sal_uInt16& rChildCount, sal_uInt16 nFirstWindowType, sal_Bool bTopLevel ) const
8804cdf0e10cSrcweir {
8805cdf0e10cSrcweir     DBG_CHKTHIS( Window, ImplDbgCheckWindow );
8806cdf0e10cSrcweir 
8807cdf0e10cSrcweir     if( bTopLevel )
8808cdf0e10cSrcweir         rChildCount = 0;
8809cdf0e10cSrcweir 
8810cdf0e10cSrcweir     Window* pChild = GetWindow( nFirstWindowType );
8811cdf0e10cSrcweir     while ( pChild )
8812cdf0e10cSrcweir     {
8813cdf0e10cSrcweir         Window *pTmpChild = pChild;
8814cdf0e10cSrcweir 
8815cdf0e10cSrcweir         if( !pChild->ImplIsAccessibleCandidate() )
8816cdf0e10cSrcweir             pTmpChild = pChild->ImplGetAccessibleCandidateChild( nChild, rChildCount, WINDOW_FIRSTCHILD, sal_False );
8817cdf0e10cSrcweir 
8818cdf0e10cSrcweir         if ( nChild == rChildCount )
8819cdf0e10cSrcweir             return pTmpChild;
8820cdf0e10cSrcweir         pChild = pChild->mpWindowImpl->mpNext;
8821cdf0e10cSrcweir         rChildCount++;
8822cdf0e10cSrcweir     }
8823cdf0e10cSrcweir 
8824cdf0e10cSrcweir     return NULL;
8825cdf0e10cSrcweir }
8826cdf0e10cSrcweir 
8827cdf0e10cSrcweir /*
8828cdf0e10cSrcweir Window* Window::GetAccessibleParentWindow() const
8829cdf0e10cSrcweir {
8830cdf0e10cSrcweir     Window* pParent = GetParent();
8831cdf0e10cSrcweir     while ( pParent )
8832cdf0e10cSrcweir         if( pParent->ImplIsAccessibleCandidate() )
8833cdf0e10cSrcweir             break;
8834cdf0e10cSrcweir         else
8835cdf0e10cSrcweir             pParent = pParent->GetParent();
8836cdf0e10cSrcweir     return pParent;
8837cdf0e10cSrcweir }
8838cdf0e10cSrcweir */
8839cdf0e10cSrcweir 
8840cdf0e10cSrcweir Window* Window::GetAccessibleParentWindow() const
8841cdf0e10cSrcweir {
8842cdf0e10cSrcweir 	if ( ImplIsAccessibleNativeFrame() )
8843cdf0e10cSrcweir 		return NULL;
8844cdf0e10cSrcweir 
8845cdf0e10cSrcweir     Window* pParent = mpWindowImpl->mpParent;
8846cdf0e10cSrcweir     if( GetType() == WINDOW_MENUBARWINDOW )
8847cdf0e10cSrcweir     {
8848cdf0e10cSrcweir         // report the menubar as a child of THE workwindow
8849cdf0e10cSrcweir         Window *pWorkWin = GetParent()->mpWindowImpl->mpFirstChild;
8850cdf0e10cSrcweir         while( pWorkWin && (pWorkWin == this) )
8851cdf0e10cSrcweir             pWorkWin = pWorkWin->mpWindowImpl->mpNext;
8852cdf0e10cSrcweir         pParent = pWorkWin;
8853cdf0e10cSrcweir     }
8854cdf0e10cSrcweir     // If this a floating window which has a native boarder window, this one should be reported as
8855cdf0e10cSrcweir     // accessible parent
8856cdf0e10cSrcweir     else if( GetType() == WINDOW_FLOATINGWINDOW &&
8857cdf0e10cSrcweir 		mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame)
8858cdf0e10cSrcweir     {
8859cdf0e10cSrcweir         pParent = mpWindowImpl->mpBorderWindow;
8860cdf0e10cSrcweir     }
8861cdf0e10cSrcweir     else if( pParent && !pParent->ImplIsAccessibleCandidate() )
8862cdf0e10cSrcweir     {
8863cdf0e10cSrcweir         pParent = pParent->mpWindowImpl->mpParent;
8864cdf0e10cSrcweir     }
8865cdf0e10cSrcweir     return pParent;
8866cdf0e10cSrcweir }
8867cdf0e10cSrcweir 
8868cdf0e10cSrcweir /*
8869cdf0e10cSrcweir sal_uInt16 Window::GetAccessibleChildWindowCount()
8870cdf0e10cSrcweir {
8871cdf0e10cSrcweir     sal_uInt16 nChildren = ImplGetAccessibleCandidateChildWindowCount( WINDOW_FIRSTCHILD );
8872cdf0e10cSrcweir 
8873cdf0e10cSrcweir     // Search also for SystemWindows.
8874cdf0e10cSrcweir 	Window* pOverlap = GetWindow( WINDOW_OVERLAP );
8875cdf0e10cSrcweir     nChildren += pOverlap->ImplGetAccessibleCandidateChildWindowCount( WINDOW_FIRSTOVERLAP );
8876cdf0e10cSrcweir 
8877cdf0e10cSrcweir     return nChildren;
8878cdf0e10cSrcweir }
8879cdf0e10cSrcweir */
8880cdf0e10cSrcweir 
8881cdf0e10cSrcweir sal_uInt16 Window::GetAccessibleChildWindowCount()
8882cdf0e10cSrcweir {
8883cdf0e10cSrcweir     sal_uInt16 nChildren = 0;
8884cdf0e10cSrcweir     Window* pChild = mpWindowImpl->mpFirstChild;
8885cdf0e10cSrcweir     while( pChild )
8886cdf0e10cSrcweir     {
8887cdf0e10cSrcweir         if( pChild->IsVisible() )
8888cdf0e10cSrcweir             nChildren++;
8889cdf0e10cSrcweir         pChild = pChild->mpWindowImpl->mpNext;
8890cdf0e10cSrcweir     }
8891cdf0e10cSrcweir 
8892cdf0e10cSrcweir     // #107176# ignore overlapwindows
8893cdf0e10cSrcweir     // this only affects non-system floating windows
8894cdf0e10cSrcweir     // which are either not accessible (like the HelpAgent) or should be changed to system windows anyway
8895cdf0e10cSrcweir     /*
8896cdf0e10cSrcweir     if( ImplIsOverlapWindow() )
8897cdf0e10cSrcweir     {
8898cdf0e10cSrcweir 	    Window* pOverlap = GetWindow( WINDOW_FIRSTOVERLAP );
8899cdf0e10cSrcweir 	    while ( pOverlap )
8900cdf0e10cSrcweir 	    {
8901cdf0e10cSrcweir             if( pOverlap->IsVisible() )
8902cdf0e10cSrcweir                 nChildren++;
8903cdf0e10cSrcweir 		    pOverlap = pOverlap->GetWindow( WINDOW_NEXT );
8904cdf0e10cSrcweir 	    }
8905cdf0e10cSrcweir     }
8906cdf0e10cSrcweir     */
8907cdf0e10cSrcweir 
8908cdf0e10cSrcweir     // report the menubarwindow as a child of THE workwindow
8909cdf0e10cSrcweir     if( GetType() == WINDOW_BORDERWINDOW )
8910cdf0e10cSrcweir     {
8911cdf0e10cSrcweir         if( ((ImplBorderWindow *) this)->mpMenuBarWindow &&
8912cdf0e10cSrcweir             ((ImplBorderWindow *) this)->mpMenuBarWindow->IsVisible()
8913cdf0e10cSrcweir             )
8914cdf0e10cSrcweir             --nChildren;
8915cdf0e10cSrcweir     }
8916cdf0e10cSrcweir     else if( GetType() == WINDOW_WORKWINDOW )
8917cdf0e10cSrcweir     {
8918cdf0e10cSrcweir         if( ((WorkWindow *) this)->GetMenuBar() &&
8919cdf0e10cSrcweir             ((WorkWindow *) this)->GetMenuBar()->GetWindow() &&
8920cdf0e10cSrcweir             ((WorkWindow *) this)->GetMenuBar()->GetWindow()->IsVisible()
8921cdf0e10cSrcweir             )
8922cdf0e10cSrcweir             ++nChildren;
8923cdf0e10cSrcweir     }
8924cdf0e10cSrcweir 
8925cdf0e10cSrcweir     return nChildren;
8926cdf0e10cSrcweir }
8927cdf0e10cSrcweir 
8928cdf0e10cSrcweir /*
8929cdf0e10cSrcweir Window* Window::GetAccessibleChildWindow( sal_uInt16 n )
8930cdf0e10cSrcweir {
8931cdf0e10cSrcweir     sal_uInt16 nChildCount; // will be set in ImplGetAccessibleCandidateChild(...)
8932cdf0e10cSrcweir 	Window* pChild = ImplGetAccessibleCandidateChild( n, nChildCount, WINDOW_FIRSTCHILD, sal_True );
8933cdf0e10cSrcweir     if ( !pChild && ( n >= nChildCount ) )
8934cdf0e10cSrcweir     {
8935cdf0e10cSrcweir 	    Window* pOverlap = GetWindow( WINDOW_OVERLAP );
8936cdf0e10cSrcweir         pChild = pOverlap->ImplGetAccessibleCandidateChild( n, nChildCount, WINDOW_FIRSTOVERLAP, sal_False );
8937cdf0e10cSrcweir     }
8938cdf0e10cSrcweir 
8939cdf0e10cSrcweir     return pChild;
8940cdf0e10cSrcweir }
8941cdf0e10cSrcweir */
8942cdf0e10cSrcweir 
8943cdf0e10cSrcweir Window* Window::GetAccessibleChildWindow( sal_uInt16 n )
8944cdf0e10cSrcweir {
8945cdf0e10cSrcweir     // report the menubarwindow as a the first child of THE workwindow
8946cdf0e10cSrcweir     if( GetType() == WINDOW_WORKWINDOW && ((WorkWindow *) this)->GetMenuBar() )
8947cdf0e10cSrcweir     {
8948cdf0e10cSrcweir         if( n == 0 )
8949cdf0e10cSrcweir         {
8950cdf0e10cSrcweir             MenuBar *pMenuBar = ((WorkWindow *) this)->GetMenuBar();
8951cdf0e10cSrcweir             if( pMenuBar->GetWindow() && pMenuBar->GetWindow()->IsVisible() )
8952cdf0e10cSrcweir                 return pMenuBar->GetWindow();
8953cdf0e10cSrcweir         }
8954cdf0e10cSrcweir         else
8955cdf0e10cSrcweir             --n;
8956cdf0e10cSrcweir     }
8957cdf0e10cSrcweir 
8958cdf0e10cSrcweir     // transform n to child number including invisible children
8959cdf0e10cSrcweir     sal_uInt16 nChildren = n;
8960cdf0e10cSrcweir     Window* pChild = mpWindowImpl->mpFirstChild;
8961cdf0e10cSrcweir     while( pChild )
8962cdf0e10cSrcweir     {
8963cdf0e10cSrcweir         if( pChild->IsVisible() )
8964cdf0e10cSrcweir         {
8965cdf0e10cSrcweir             if( ! nChildren )
8966cdf0e10cSrcweir                 break;
8967cdf0e10cSrcweir             nChildren--;
8968cdf0e10cSrcweir         }
8969cdf0e10cSrcweir         pChild = pChild->mpWindowImpl->mpNext;
8970cdf0e10cSrcweir     }
8971cdf0e10cSrcweir 
8972cdf0e10cSrcweir     if( GetType() == WINDOW_BORDERWINDOW && pChild && pChild->GetType() == WINDOW_MENUBARWINDOW )
8973cdf0e10cSrcweir     {
8974cdf0e10cSrcweir         do pChild = pChild->mpWindowImpl->mpNext; while( pChild && ! pChild->IsVisible() );
8975cdf0e10cSrcweir         DBG_ASSERT( pChild, "GetAccessibleChildWindow(): wrong index in border window");
8976cdf0e10cSrcweir     }
8977cdf0e10cSrcweir     if ( !pChild )
8978cdf0e10cSrcweir     {
8979cdf0e10cSrcweir         // #107176# ignore overlapwindows
8980cdf0e10cSrcweir         /*
8981cdf0e10cSrcweir         if( ImplIsOverlapWindow() )
8982cdf0e10cSrcweir         {
8983cdf0e10cSrcweir 	        Window* pOverlap = GetWindow( WINDOW_FIRSTOVERLAP );
8984cdf0e10cSrcweir 	        while ( !pChild && pOverlap )
8985cdf0e10cSrcweir 	        {
8986cdf0e10cSrcweir                 if ( !nChildren && pOverlap->IsVisible() )
8987cdf0e10cSrcweir                 {
8988cdf0e10cSrcweir                     pChild = pOverlap;
8989cdf0e10cSrcweir                     break;
8990cdf0e10cSrcweir                 }
8991cdf0e10cSrcweir                 pOverlap = pOverlap->GetWindow( WINDOW_NEXT );
8992cdf0e10cSrcweir                 if( pOverlap && pOverlap->IsVisible() )
8993cdf0e10cSrcweir                     nChildren--;
8994cdf0e10cSrcweir 	        }
8995cdf0e10cSrcweir         }
8996cdf0e10cSrcweir         */
8997cdf0e10cSrcweir 
8998cdf0e10cSrcweir     }
8999cdf0e10cSrcweir 	if ( pChild && ( pChild->GetType() == WINDOW_BORDERWINDOW ) && ( pChild->GetChildCount() == 1 ) )
9000cdf0e10cSrcweir     {
9001cdf0e10cSrcweir         pChild = pChild->GetChild( 0 );
9002cdf0e10cSrcweir     }
9003cdf0e10cSrcweir     return pChild;
9004cdf0e10cSrcweir }
9005cdf0e10cSrcweir 
9006cdf0e10cSrcweir 
9007cdf0e10cSrcweir void Window::SetAccessibleRole( sal_uInt16 nRole )
9008cdf0e10cSrcweir {
9009cdf0e10cSrcweir     if ( !mpWindowImpl->mpAccessibleInfos )
9010cdf0e10cSrcweir         mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos;
9011cdf0e10cSrcweir 
9012cdf0e10cSrcweir     DBG_ASSERT( mpWindowImpl->mpAccessibleInfos->nAccessibleRole == 0xFFFF, "AccessibleRole already set!" );
9013cdf0e10cSrcweir     mpWindowImpl->mpAccessibleInfos->nAccessibleRole = nRole;
9014cdf0e10cSrcweir }
9015cdf0e10cSrcweir 
9016cdf0e10cSrcweir sal_uInt16 Window::GetAccessibleRole() const
9017cdf0e10cSrcweir {
9018cdf0e10cSrcweir     using namespace ::com::sun::star;
9019cdf0e10cSrcweir 
9020cdf0e10cSrcweir     sal_uInt16 nRole = mpWindowImpl->mpAccessibleInfos ? mpWindowImpl->mpAccessibleInfos->nAccessibleRole : 0xFFFF;
9021cdf0e10cSrcweir     if ( nRole == 0xFFFF )
9022cdf0e10cSrcweir     {
9023cdf0e10cSrcweir         switch ( GetType() )
9024cdf0e10cSrcweir         {
9025cdf0e10cSrcweir             case WINDOW_MESSBOX:    // MT: Would be nice to have special roles!
9026cdf0e10cSrcweir             case WINDOW_INFOBOX:
9027cdf0e10cSrcweir             case WINDOW_WARNINGBOX:
9028cdf0e10cSrcweir             case WINDOW_ERRORBOX:
9029cdf0e10cSrcweir             case WINDOW_QUERYBOX: nRole = accessibility::AccessibleRole::ALERT; break;
9030cdf0e10cSrcweir 
9031cdf0e10cSrcweir             case WINDOW_MODELESSDIALOG:
9032cdf0e10cSrcweir             case WINDOW_MODALDIALOG:
9033cdf0e10cSrcweir             case WINDOW_SYSTEMDIALOG:
9034cdf0e10cSrcweir             case WINDOW_PRINTERSETUPDIALOG:
9035cdf0e10cSrcweir             case WINDOW_PRINTDIALOG:
9036cdf0e10cSrcweir             case WINDOW_TABDIALOG:
9037cdf0e10cSrcweir             case WINDOW_BUTTONDIALOG:
9038cdf0e10cSrcweir             case WINDOW_DIALOG: nRole = accessibility::AccessibleRole::DIALOG; break;
9039cdf0e10cSrcweir 
9040cdf0e10cSrcweir             case WINDOW_PUSHBUTTON:
9041cdf0e10cSrcweir             case WINDOW_OKBUTTON:
9042cdf0e10cSrcweir             case WINDOW_CANCELBUTTON:
9043cdf0e10cSrcweir             case WINDOW_HELPBUTTON:
9044cdf0e10cSrcweir             case WINDOW_IMAGEBUTTON:
9045cdf0e10cSrcweir             case WINDOW_MENUBUTTON:
9046cdf0e10cSrcweir             case WINDOW_MOREBUTTON:
9047cdf0e10cSrcweir             case WINDOW_SPINBUTTON:
9048cdf0e10cSrcweir             case WINDOW_BUTTON: nRole = accessibility::AccessibleRole::PUSH_BUTTON; break;
9049cdf0e10cSrcweir 
9050cdf0e10cSrcweir             case WINDOW_PATHDIALOG: nRole = accessibility::AccessibleRole::DIRECTORY_PANE; break;
9051cdf0e10cSrcweir             case WINDOW_FILEDIALOG: nRole = accessibility::AccessibleRole::FILE_CHOOSER; break;
9052cdf0e10cSrcweir             case WINDOW_COLORDIALOG: nRole = accessibility::AccessibleRole::COLOR_CHOOSER; break;
9053cdf0e10cSrcweir             case WINDOW_FONTDIALOG: nRole = accessibility::AccessibleRole::FONT_CHOOSER; break;
9054cdf0e10cSrcweir 
9055cdf0e10cSrcweir             case WINDOW_IMAGERADIOBUTTON:
9056cdf0e10cSrcweir             case WINDOW_RADIOBUTTON: nRole = accessibility::AccessibleRole::RADIO_BUTTON; break;
9057cdf0e10cSrcweir             case WINDOW_TRISTATEBOX:
9058cdf0e10cSrcweir             case WINDOW_CHECKBOX: nRole = accessibility::AccessibleRole::CHECK_BOX; break;
9059cdf0e10cSrcweir 
9060cdf0e10cSrcweir             case WINDOW_MULTILINEEDIT: nRole = accessibility::AccessibleRole::SCROLL_PANE; break;
9061cdf0e10cSrcweir 
9062cdf0e10cSrcweir             case WINDOW_PATTERNFIELD:
9063cdf0e10cSrcweir             case WINDOW_NUMERICFIELD:
9064cdf0e10cSrcweir             case WINDOW_METRICFIELD:
9065cdf0e10cSrcweir             case WINDOW_CURRENCYFIELD:
9066cdf0e10cSrcweir             case WINDOW_LONGCURRENCYFIELD:
9067cdf0e10cSrcweir             case WINDOW_EDIT: nRole = ( GetStyle() & WB_PASSWORD ) ? (accessibility::AccessibleRole::PASSWORD_TEXT) : (accessibility::AccessibleRole::TEXT); break;
9068cdf0e10cSrcweir 
9069cdf0e10cSrcweir             case WINDOW_PATTERNBOX:
9070cdf0e10cSrcweir             case WINDOW_NUMERICBOX:
9071cdf0e10cSrcweir             case WINDOW_METRICBOX:
9072cdf0e10cSrcweir             case WINDOW_CURRENCYBOX:
9073cdf0e10cSrcweir             case WINDOW_LONGCURRENCYBOX:
9074cdf0e10cSrcweir             case WINDOW_COMBOBOX: nRole = accessibility::AccessibleRole::COMBO_BOX; break;
9075cdf0e10cSrcweir 
9076cdf0e10cSrcweir             case WINDOW_LISTBOX:
9077cdf0e10cSrcweir             case WINDOW_MULTILISTBOX: nRole = accessibility::AccessibleRole::LIST; break;
9078cdf0e10cSrcweir 
9079cdf0e10cSrcweir 			case WINDOW_TREELISTBOX: nRole = accessibility::AccessibleRole::TREE; break;
9080cdf0e10cSrcweir 
9081cdf0e10cSrcweir             case WINDOW_FIXEDTEXT: nRole = accessibility::AccessibleRole::LABEL; break;
9082cdf0e10cSrcweir             case WINDOW_FIXEDBORDER:
9083cdf0e10cSrcweir             case WINDOW_FIXEDLINE: nRole = accessibility::AccessibleRole::SEPARATOR; break;
9084cdf0e10cSrcweir             case WINDOW_FIXEDBITMAP:
9085cdf0e10cSrcweir             case WINDOW_FIXEDIMAGE: nRole = accessibility::AccessibleRole::ICON; break;
9086cdf0e10cSrcweir             case WINDOW_GROUPBOX: nRole = accessibility::AccessibleRole::GROUP_BOX; break;
9087cdf0e10cSrcweir             case WINDOW_SCROLLBAR: nRole = accessibility::AccessibleRole::SCROLL_BAR; break;
9088cdf0e10cSrcweir 
9089cdf0e10cSrcweir             case WINDOW_SLIDER:
9090cdf0e10cSrcweir             case WINDOW_SPLITTER:
9091cdf0e10cSrcweir             case WINDOW_SPLITWINDOW: nRole = accessibility::AccessibleRole::SPLIT_PANE; break;
9092cdf0e10cSrcweir 
9093cdf0e10cSrcweir             case WINDOW_DATEBOX:
9094cdf0e10cSrcweir             case WINDOW_TIMEBOX:
9095cdf0e10cSrcweir             case WINDOW_DATEFIELD:
9096cdf0e10cSrcweir             case WINDOW_TIMEFIELD: nRole = accessibility::AccessibleRole::DATE_EDITOR; break;
9097cdf0e10cSrcweir 
9098cdf0e10cSrcweir             case WINDOW_SPINFIELD: nRole = accessibility::AccessibleRole::SPIN_BOX; break;
9099cdf0e10cSrcweir 
9100cdf0e10cSrcweir             case WINDOW_TOOLBOX: nRole = accessibility::AccessibleRole::TOOL_BAR; break;
9101cdf0e10cSrcweir             case WINDOW_STATUSBAR: nRole = accessibility::AccessibleRole::STATUS_BAR; break;
9102cdf0e10cSrcweir 
9103cdf0e10cSrcweir             case WINDOW_TABPAGE: nRole = accessibility::AccessibleRole::PANEL; break;
9104cdf0e10cSrcweir             case WINDOW_TABCONTROL: nRole = accessibility::AccessibleRole::PAGE_TAB_LIST; break;
9105cdf0e10cSrcweir 
9106cdf0e10cSrcweir             case WINDOW_DOCKINGWINDOW:
9107cdf0e10cSrcweir             case WINDOW_SYSWINDOW:      nRole = (mpWindowImpl->mbFrame) ? accessibility::AccessibleRole::FRAME :
9108cdf0e10cSrcweir                                                                           accessibility::AccessibleRole::PANEL; break;
9109cdf0e10cSrcweir 
9110cdf0e10cSrcweir             case WINDOW_FLOATINGWINDOW: nRole = ( mpWindowImpl->mbFrame ||
9111cdf0e10cSrcweir                                                  (mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame) ||
9112cdf0e10cSrcweir                                                  (GetStyle() & WB_OWNERDRAWDECORATION) ) ? accessibility::AccessibleRole::FRAME :
9113cdf0e10cSrcweir                                                                                            accessibility::AccessibleRole::WINDOW; break;
9114cdf0e10cSrcweir 
9115cdf0e10cSrcweir             case WINDOW_WORKWINDOW: nRole = accessibility::AccessibleRole::ROOT_PANE; break;
9116cdf0e10cSrcweir 
9117cdf0e10cSrcweir 
9118cdf0e10cSrcweir             case WINDOW_SCROLLBARBOX: nRole = accessibility::AccessibleRole::FILLER; break;
9119cdf0e10cSrcweir 
9120cdf0e10cSrcweir             case WINDOW_HELPTEXTWINDOW: nRole = accessibility::AccessibleRole::TOOL_TIP; break;
9121cdf0e10cSrcweir 
9122cdf0e10cSrcweir 			case WINDOW_RULER:			nRole = accessibility::AccessibleRole::RULER; break;
9123cdf0e10cSrcweir             case WINDOW_WINDOW:
9124cdf0e10cSrcweir             case WINDOW_CONTROL:
9125cdf0e10cSrcweir             case WINDOW_BORDERWINDOW:
9126cdf0e10cSrcweir             case WINDOW_SYSTEMCHILDWINDOW:
9127cdf0e10cSrcweir             default:
9128cdf0e10cSrcweir                 if (ImplIsAccessibleNativeFrame() )
9129cdf0e10cSrcweir                     nRole = accessibility::AccessibleRole::FRAME;
9130cdf0e10cSrcweir                 else if( IsScrollable() )
9131cdf0e10cSrcweir                     nRole = accessibility::AccessibleRole::SCROLL_PANE;
9132cdf0e10cSrcweir                 else if( ((Window*)this)->ImplGetWindow()->IsMenuFloatingWindow() )
9133cdf0e10cSrcweir                     nRole = accessibility::AccessibleRole::WINDOW;      // #106002#, contextmenues are windows (i.e. toplevel)
9134cdf0e10cSrcweir                 else
9135cdf0e10cSrcweir                     // #104051# WINDOW seems to be a bad default role, use LAYEREDPANE instead
9136cdf0e10cSrcweir                     // a WINDOW is interpreted as a top-level window, which is typically not the case
9137cdf0e10cSrcweir                     //nRole = accessibility::AccessibleRole::WINDOW;
9138cdf0e10cSrcweir                     nRole = accessibility::AccessibleRole::PANEL;
9139cdf0e10cSrcweir         }
9140cdf0e10cSrcweir     }
9141cdf0e10cSrcweir     return nRole;
9142cdf0e10cSrcweir }
9143cdf0e10cSrcweir 
9144cdf0e10cSrcweir void Window::SetAccessibleName( const String& rName )
9145cdf0e10cSrcweir {
9146cdf0e10cSrcweir    if ( !mpWindowImpl->mpAccessibleInfos )
9147cdf0e10cSrcweir         mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos;
9148cdf0e10cSrcweir 
9149cdf0e10cSrcweir     delete mpWindowImpl->mpAccessibleInfos->pAccessibleName;
9150cdf0e10cSrcweir     mpWindowImpl->mpAccessibleInfos->pAccessibleName = new String( rName );
9151cdf0e10cSrcweir }
9152cdf0e10cSrcweir 
9153cdf0e10cSrcweir String Window::GetAccessibleName() const
9154cdf0e10cSrcweir {
9155cdf0e10cSrcweir 	String aAccessibleName;
9156cdf0e10cSrcweir 	if ( mpWindowImpl->mpAccessibleInfos && mpWindowImpl->mpAccessibleInfos->pAccessibleName )
9157cdf0e10cSrcweir 	{
9158cdf0e10cSrcweir 		aAccessibleName = *mpWindowImpl->mpAccessibleInfos->pAccessibleName;
9159cdf0e10cSrcweir 	}
9160cdf0e10cSrcweir 	else
9161cdf0e10cSrcweir 	{
9162cdf0e10cSrcweir         switch ( GetType() )
9163cdf0e10cSrcweir         {
9164cdf0e10cSrcweir //            case WINDOW_IMAGERADIOBUTTON:
9165cdf0e10cSrcweir //            case WINDOW_RADIOBUTTON:
9166cdf0e10cSrcweir //            case WINDOW_TRISTATEBOX:
9167cdf0e10cSrcweir //            case WINDOW_CHECKBOX:
9168cdf0e10cSrcweir 
9169cdf0e10cSrcweir             case WINDOW_MULTILINEEDIT:
9170cdf0e10cSrcweir             case WINDOW_PATTERNFIELD:
9171cdf0e10cSrcweir             case WINDOW_NUMERICFIELD:
9172cdf0e10cSrcweir             case WINDOW_METRICFIELD:
9173cdf0e10cSrcweir             case WINDOW_CURRENCYFIELD:
9174cdf0e10cSrcweir             case WINDOW_LONGCURRENCYFIELD:
9175cdf0e10cSrcweir             case WINDOW_EDIT:
9176cdf0e10cSrcweir 
9177cdf0e10cSrcweir             case WINDOW_DATEBOX:
9178cdf0e10cSrcweir             case WINDOW_TIMEBOX:
9179cdf0e10cSrcweir             case WINDOW_CURRENCYBOX:
9180cdf0e10cSrcweir             case WINDOW_LONGCURRENCYBOX:
9181cdf0e10cSrcweir             case WINDOW_DATEFIELD:
9182cdf0e10cSrcweir             case WINDOW_TIMEFIELD:
9183cdf0e10cSrcweir             case WINDOW_SPINFIELD:
9184cdf0e10cSrcweir 
9185cdf0e10cSrcweir             case WINDOW_COMBOBOX:
9186cdf0e10cSrcweir             case WINDOW_LISTBOX:
9187cdf0e10cSrcweir             case WINDOW_MULTILISTBOX:
9188cdf0e10cSrcweir 			case WINDOW_TREELISTBOX:
9189cdf0e10cSrcweir 			case WINDOW_METRICBOX:
9190cdf0e10cSrcweir             {
9191cdf0e10cSrcweir                 Window *pLabel = GetAccessibleRelationLabeledBy();
9192cdf0e10cSrcweir                 if ( pLabel && pLabel != this )
9193cdf0e10cSrcweir                     aAccessibleName = pLabel->GetText();
9194cdf0e10cSrcweir             }
9195cdf0e10cSrcweir             break;
9196cdf0e10cSrcweir 
9197cdf0e10cSrcweir             case WINDOW_IMAGEBUTTON:
9198cdf0e10cSrcweir             case WINDOW_PUSHBUTTON:
9199cdf0e10cSrcweir                 aAccessibleName = GetText();
9200cdf0e10cSrcweir                 if ( !aAccessibleName.Len() )
9201cdf0e10cSrcweir                 {
9202cdf0e10cSrcweir                     aAccessibleName = GetQuickHelpText();
9203cdf0e10cSrcweir                     if ( !aAccessibleName.Len() )
9204cdf0e10cSrcweir                         aAccessibleName = GetHelpText();
9205cdf0e10cSrcweir                 }
9206cdf0e10cSrcweir             break;
9207cdf0e10cSrcweir 
9208cdf0e10cSrcweir             default:
9209cdf0e10cSrcweir                 aAccessibleName = GetText();
9210cdf0e10cSrcweir                 break;
9211cdf0e10cSrcweir         }
9212cdf0e10cSrcweir 
9213cdf0e10cSrcweir 		aAccessibleName = GetNonMnemonicString( aAccessibleName );
9214cdf0e10cSrcweir 	}
9215cdf0e10cSrcweir 
9216cdf0e10cSrcweir 	return aAccessibleName;
9217cdf0e10cSrcweir }
9218cdf0e10cSrcweir 
9219cdf0e10cSrcweir void Window::SetAccessibleDescription( const String& rDescription )
9220cdf0e10cSrcweir {
9221cdf0e10cSrcweir    if ( ! mpWindowImpl->mpAccessibleInfos )
9222cdf0e10cSrcweir         mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos;
9223cdf0e10cSrcweir 
9224cdf0e10cSrcweir     DBG_ASSERT( !mpWindowImpl->mpAccessibleInfos->pAccessibleDescription, "AccessibleDescription already set!" );
9225cdf0e10cSrcweir     delete mpWindowImpl->mpAccessibleInfos->pAccessibleDescription;
9226cdf0e10cSrcweir     mpWindowImpl->mpAccessibleInfos->pAccessibleDescription = new String( rDescription );
9227cdf0e10cSrcweir }
9228cdf0e10cSrcweir 
9229cdf0e10cSrcweir String Window::GetAccessibleDescription() const
9230cdf0e10cSrcweir {
9231cdf0e10cSrcweir 	String aAccessibleDescription;
9232cdf0e10cSrcweir 	if ( mpWindowImpl->mpAccessibleInfos && mpWindowImpl->mpAccessibleInfos->pAccessibleDescription )
9233cdf0e10cSrcweir 	{
9234cdf0e10cSrcweir 		aAccessibleDescription = *mpWindowImpl->mpAccessibleInfos->pAccessibleDescription;
9235cdf0e10cSrcweir 	}
9236cdf0e10cSrcweir 	else
9237cdf0e10cSrcweir 	{
9238cdf0e10cSrcweir 		// Special code for help text windows. ZT asks the border window for the
9239cdf0e10cSrcweir 		// description so we have to forward this request to our inner window.
9240cdf0e10cSrcweir 		const Window* pWin = ((Window *)this)->ImplGetWindow();
9241cdf0e10cSrcweir 		if ( pWin->GetType() == WINDOW_HELPTEXTWINDOW )
9242cdf0e10cSrcweir 			aAccessibleDescription = pWin->GetHelpText();
9243cdf0e10cSrcweir 		else
9244cdf0e10cSrcweir 			aAccessibleDescription = GetHelpText();
9245cdf0e10cSrcweir 	}
9246cdf0e10cSrcweir 
9247cdf0e10cSrcweir 	return aAccessibleDescription;
9248cdf0e10cSrcweir }
9249cdf0e10cSrcweir 
9250cdf0e10cSrcweir void Window::SetAccessibleRelationLabeledBy( Window* pLabeledBy )
9251cdf0e10cSrcweir {
9252cdf0e10cSrcweir 	if ( !mpWindowImpl->mpAccessibleInfos )
9253cdf0e10cSrcweir 		mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos;
9254cdf0e10cSrcweir 	mpWindowImpl->mpAccessibleInfos->pLabeledByWindow = pLabeledBy;
9255cdf0e10cSrcweir }
9256cdf0e10cSrcweir 
9257cdf0e10cSrcweir void Window::SetAccessibleRelationLabelFor( Window* pLabelFor )
9258cdf0e10cSrcweir {
9259cdf0e10cSrcweir 	if ( !mpWindowImpl->mpAccessibleInfos )
9260cdf0e10cSrcweir 		mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos;
9261cdf0e10cSrcweir 	mpWindowImpl->mpAccessibleInfos->pLabelForWindow = pLabelFor;
9262cdf0e10cSrcweir }
9263cdf0e10cSrcweir 
9264cdf0e10cSrcweir void Window::SetAccessibleRelationMemberOf( Window* pMemberOfWin )
9265cdf0e10cSrcweir {
9266cdf0e10cSrcweir 	if ( !mpWindowImpl->mpAccessibleInfos )
9267cdf0e10cSrcweir 		mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos;
9268cdf0e10cSrcweir 	mpWindowImpl->mpAccessibleInfos->pMemberOfWindow = pMemberOfWin;
9269cdf0e10cSrcweir }
9270cdf0e10cSrcweir 
9271cdf0e10cSrcweir sal_Bool Window::IsAccessibilityEventsSuppressed( sal_Bool bTraverseParentPath )
9272cdf0e10cSrcweir {
9273cdf0e10cSrcweir     if( !bTraverseParentPath )
9274cdf0e10cSrcweir         return mpWindowImpl->mbSuppressAccessibilityEvents;
9275cdf0e10cSrcweir     else
9276cdf0e10cSrcweir     {
9277cdf0e10cSrcweir         Window *pParent = this;
9278cdf0e10cSrcweir         while ( pParent && pParent->mpWindowImpl)
9279cdf0e10cSrcweir         {
9280cdf0e10cSrcweir             if( pParent->mpWindowImpl->mbSuppressAccessibilityEvents )
9281cdf0e10cSrcweir                 return sal_True;
9282cdf0e10cSrcweir             else
9283cdf0e10cSrcweir                 pParent = pParent->mpWindowImpl->mpParent; // do not use GetParent() to find borderwindows that are frames
9284cdf0e10cSrcweir         }
9285cdf0e10cSrcweir         return sal_False;
9286cdf0e10cSrcweir     }
9287cdf0e10cSrcweir }
9288cdf0e10cSrcweir 
9289cdf0e10cSrcweir void Window::SetAccessibilityEventsSuppressed(sal_Bool bSuppressed)
9290cdf0e10cSrcweir {
9291cdf0e10cSrcweir 	mpWindowImpl->mbSuppressAccessibilityEvents = bSuppressed;
9292cdf0e10cSrcweir }
9293cdf0e10cSrcweir 
9294cdf0e10cSrcweir void Window::RecordLayoutData( vcl::ControlLayoutData* pLayout, const Rectangle& rRect )
9295cdf0e10cSrcweir {
9296cdf0e10cSrcweir     if( ! mpOutDevData )
9297cdf0e10cSrcweir         ImplInitOutDevData();
9298cdf0e10cSrcweir 	mpOutDevData->mpRecordLayout = pLayout;
9299cdf0e10cSrcweir 	mpOutDevData->maRecordRect = rRect;
9300cdf0e10cSrcweir     Paint( rRect );
9301cdf0e10cSrcweir     mpOutDevData->mpRecordLayout = NULL;
9302cdf0e10cSrcweir }
9303cdf0e10cSrcweir 
9304cdf0e10cSrcweir // -----------------------------------------------------------------------
9305cdf0e10cSrcweir // -----------------------------------------------------------------------
9306cdf0e10cSrcweir 
9307cdf0e10cSrcweir 
9308cdf0e10cSrcweir // returns background color used in this control
9309cdf0e10cSrcweir // false: could not determine color
9310cdf0e10cSrcweir sal_Bool Window::ImplGetCurrentBackgroundColor( Color& rCol )
9311cdf0e10cSrcweir {
9312cdf0e10cSrcweir 	sal_Bool bRet = sal_True;
9313cdf0e10cSrcweir 
9314cdf0e10cSrcweir     switch ( GetType() )
9315cdf0e10cSrcweir     {
9316cdf0e10cSrcweir 		// peform special handling here
9317cdf0e10cSrcweir         case WINDOW_PUSHBUTTON:
9318cdf0e10cSrcweir         case WINDOW_OKBUTTON:
9319cdf0e10cSrcweir         case WINDOW_CANCELBUTTON:
9320cdf0e10cSrcweir 		// etc.
9321cdf0e10cSrcweir         default:
9322cdf0e10cSrcweir 			if( IsControlBackground() )
9323cdf0e10cSrcweir 				rCol = GetControlBackground();
9324cdf0e10cSrcweir 			else if( IsBackground() )
9325cdf0e10cSrcweir 				{
9326cdf0e10cSrcweir 					Wallpaper aWall = GetBackground();
9327cdf0e10cSrcweir 					if( !aWall.IsGradient() && !aWall.IsBitmap() )
9328cdf0e10cSrcweir 						rCol = aWall.GetColor();
9329cdf0e10cSrcweir 					else
9330cdf0e10cSrcweir 						bRet = sal_False;
9331cdf0e10cSrcweir 				}
9332cdf0e10cSrcweir 			else
9333cdf0e10cSrcweir 				rCol = GetSettings().GetStyleSettings().GetFaceColor();
9334cdf0e10cSrcweir 			break;
9335cdf0e10cSrcweir     }
9336cdf0e10cSrcweir 	return bRet;
9337cdf0e10cSrcweir }
9338cdf0e10cSrcweir 
9339cdf0e10cSrcweir void Window::DrawSelectionBackground( const Rectangle& rRect, sal_uInt16 highlight, sal_Bool bChecked, sal_Bool bDrawBorder, sal_Bool bDrawExtBorderOnly )
9340cdf0e10cSrcweir {
9341cdf0e10cSrcweir     DrawSelectionBackground( rRect, highlight, bChecked, bDrawBorder, bDrawExtBorderOnly, 0, NULL, NULL );
9342cdf0e10cSrcweir }
9343cdf0e10cSrcweir 
9344cdf0e10cSrcweir void Window::DrawSelectionBackground( const Rectangle& rRect, sal_uInt16 highlight, sal_Bool bChecked, sal_Bool bDrawBorder, sal_Bool bDrawExtBorderOnly, Color* pSelectionTextColor )
9345cdf0e10cSrcweir {
9346cdf0e10cSrcweir     DrawSelectionBackground( rRect, highlight, bChecked, bDrawBorder, bDrawExtBorderOnly, 0, pSelectionTextColor, NULL );
9347cdf0e10cSrcweir }
9348cdf0e10cSrcweir 
9349cdf0e10cSrcweir void Window::DrawSelectionBackground( const Rectangle& rRect,
9350cdf0e10cSrcweir                                       sal_uInt16 highlight,
9351cdf0e10cSrcweir                                       sal_Bool bChecked,
9352cdf0e10cSrcweir                                       sal_Bool bDrawBorder,
9353cdf0e10cSrcweir                                       sal_Bool bDrawExtBorderOnly,
9354cdf0e10cSrcweir                                       long nCornerRadius,
9355cdf0e10cSrcweir                                       Color* pSelectionTextColor,
9356cdf0e10cSrcweir                                       Color* pPaintColor
9357cdf0e10cSrcweir                                       )
9358cdf0e10cSrcweir {
9359cdf0e10cSrcweir     if( rRect.IsEmpty() )
9360cdf0e10cSrcweir         return;
9361cdf0e10cSrcweir 
9362cdf0e10cSrcweir     bool bRoundEdges = nCornerRadius > 0;
9363cdf0e10cSrcweir 
9364cdf0e10cSrcweir     const StyleSettings& rStyles = GetSettings().GetStyleSettings();
9365cdf0e10cSrcweir 
9366cdf0e10cSrcweir 
9367cdf0e10cSrcweir     // colors used for item highlighting
9368cdf0e10cSrcweir     Color aSelectionBorderCol( pPaintColor ? *pPaintColor : rStyles.GetHighlightColor() );
9369cdf0e10cSrcweir     Color aSelectionFillCol( aSelectionBorderCol );
9370cdf0e10cSrcweir 
9371cdf0e10cSrcweir 	sal_Bool bDark = rStyles.GetFaceColor().IsDark();
9372cdf0e10cSrcweir 	sal_Bool bBright = ( rStyles.GetFaceColor() == Color( COL_WHITE ) );
9373cdf0e10cSrcweir 
9374cdf0e10cSrcweir     int c1 = aSelectionBorderCol.GetLuminance();
9375cdf0e10cSrcweir     int c2 = GetDisplayBackground().GetColor().GetLuminance();
9376cdf0e10cSrcweir 
9377cdf0e10cSrcweir     if( !bDark && !bBright && abs( c2-c1 ) < (pPaintColor ? 40 : 75) )
9378cdf0e10cSrcweir     {
9379cdf0e10cSrcweir         // constrast too low
9380cdf0e10cSrcweir         sal_uInt16 h,s,b;
9381cdf0e10cSrcweir         aSelectionFillCol.RGBtoHSB( h, s, b );
9382cdf0e10cSrcweir         if( b > 50 )    b -= 40;
9383cdf0e10cSrcweir         else            b += 40;
9384cdf0e10cSrcweir         aSelectionFillCol.SetColor( Color::HSBtoRGB( h, s, b ) );
9385cdf0e10cSrcweir         aSelectionBorderCol = aSelectionFillCol;
9386cdf0e10cSrcweir     }
9387cdf0e10cSrcweir 
9388cdf0e10cSrcweir     if( bRoundEdges )
9389cdf0e10cSrcweir     {
9390cdf0e10cSrcweir         if( aSelectionBorderCol.IsDark() )
9391cdf0e10cSrcweir             aSelectionBorderCol.IncreaseLuminance( 128 );
9392cdf0e10cSrcweir         else
9393cdf0e10cSrcweir             aSelectionBorderCol.DecreaseLuminance( 128 );
9394cdf0e10cSrcweir     }
9395cdf0e10cSrcweir 
9396cdf0e10cSrcweir     Rectangle aRect( rRect );
9397cdf0e10cSrcweir     if( bDrawExtBorderOnly )
9398cdf0e10cSrcweir     {
9399cdf0e10cSrcweir         aRect.nLeft     -= 1;
9400cdf0e10cSrcweir         aRect.nTop      -= 1;
9401cdf0e10cSrcweir         aRect.nRight    += 1;
9402cdf0e10cSrcweir         aRect.nBottom   += 1;
9403cdf0e10cSrcweir     }
9404cdf0e10cSrcweir     Color oldFillCol = GetFillColor();
9405cdf0e10cSrcweir     Color oldLineCol = GetLineColor();
9406cdf0e10cSrcweir 
9407cdf0e10cSrcweir     if( bDrawBorder )
9408cdf0e10cSrcweir         SetLineColor( bDark ? Color(COL_WHITE) : ( bBright ? Color(COL_BLACK) : aSelectionBorderCol ) );
9409cdf0e10cSrcweir     else
9410cdf0e10cSrcweir         SetLineColor();
9411cdf0e10cSrcweir 
9412cdf0e10cSrcweir     sal_uInt16 nPercent = 0;
9413cdf0e10cSrcweir     if( !highlight )
9414cdf0e10cSrcweir 	{
9415cdf0e10cSrcweir 		if( bDark )
9416cdf0e10cSrcweir 			aSelectionFillCol = COL_BLACK;
9417cdf0e10cSrcweir 		else
9418cdf0e10cSrcweir 			nPercent = 80;  // just checked (light)
9419cdf0e10cSrcweir 	}
9420cdf0e10cSrcweir     else
9421cdf0e10cSrcweir     {
9422cdf0e10cSrcweir         if( bChecked && highlight == 2 )
9423cdf0e10cSrcweir 		{
9424cdf0e10cSrcweir 			if( bDark )
9425cdf0e10cSrcweir 			    aSelectionFillCol = COL_LIGHTGRAY;
9426cdf0e10cSrcweir             else if ( bBright )
9427cdf0e10cSrcweir             {
9428cdf0e10cSrcweir 			    aSelectionFillCol = COL_BLACK;
9429cdf0e10cSrcweir                 SetLineColor( COL_BLACK );
9430cdf0e10cSrcweir                 nPercent = 0;
9431cdf0e10cSrcweir             }
9432cdf0e10cSrcweir             else
9433cdf0e10cSrcweir                 nPercent = bRoundEdges ? 40 : 20;          // selected, pressed or checked ( very dark )
9434cdf0e10cSrcweir 		}
9435cdf0e10cSrcweir         else if( bChecked || highlight == 1 )
9436cdf0e10cSrcweir 		{
9437cdf0e10cSrcweir 			if( bDark )
9438cdf0e10cSrcweir 			    aSelectionFillCol = COL_GRAY;
9439cdf0e10cSrcweir             else if ( bBright )
9440cdf0e10cSrcweir             {
9441cdf0e10cSrcweir 			    aSelectionFillCol = COL_BLACK;
9442cdf0e10cSrcweir                 SetLineColor( COL_BLACK );
9443cdf0e10cSrcweir                 nPercent = 0;
9444cdf0e10cSrcweir             }
9445cdf0e10cSrcweir             else
9446cdf0e10cSrcweir                 nPercent = bRoundEdges ? 60 : 35;          // selected, pressed or checked ( very dark )
9447cdf0e10cSrcweir 		}
9448cdf0e10cSrcweir         else
9449cdf0e10cSrcweir 		{
9450cdf0e10cSrcweir 			if( bDark )
9451cdf0e10cSrcweir 			    aSelectionFillCol = COL_LIGHTGRAY;
9452cdf0e10cSrcweir             else if ( bBright )
9453cdf0e10cSrcweir             {
9454cdf0e10cSrcweir 			    aSelectionFillCol = COL_BLACK;
9455cdf0e10cSrcweir                 SetLineColor( COL_BLACK );
9456cdf0e10cSrcweir                 if( highlight == 3 )
9457cdf0e10cSrcweir                     nPercent = 80;
9458cdf0e10cSrcweir                 else
9459cdf0e10cSrcweir                     nPercent = 0;
9460cdf0e10cSrcweir             }
9461cdf0e10cSrcweir             else
9462cdf0e10cSrcweir                 nPercent = 70;          // selected ( dark )
9463cdf0e10cSrcweir 		}
9464cdf0e10cSrcweir     }
9465cdf0e10cSrcweir 
9466cdf0e10cSrcweir     if( bDark && bDrawExtBorderOnly )
9467cdf0e10cSrcweir     {
9468cdf0e10cSrcweir         SetFillColor();
9469cdf0e10cSrcweir         if( pSelectionTextColor )
9470cdf0e10cSrcweir             *pSelectionTextColor = rStyles.GetHighlightTextColor();
9471cdf0e10cSrcweir     }
9472cdf0e10cSrcweir     else
9473cdf0e10cSrcweir     {
9474cdf0e10cSrcweir         SetFillColor( aSelectionFillCol );
9475cdf0e10cSrcweir         if( pSelectionTextColor )
9476cdf0e10cSrcweir         {
9477cdf0e10cSrcweir             Color aTextColor = IsControlBackground() ? GetControlForeground() : rStyles.GetButtonTextColor();
9478cdf0e10cSrcweir             Color aHLTextColor = rStyles.GetHighlightTextColor();
9479cdf0e10cSrcweir             int nTextDiff = abs(aSelectionFillCol.GetLuminance() - aTextColor.GetLuminance());
9480cdf0e10cSrcweir             int nHLDiff = abs(aSelectionFillCol.GetLuminance() - aHLTextColor.GetLuminance());
9481cdf0e10cSrcweir             *pSelectionTextColor = (nHLDiff >= nTextDiff) ? aHLTextColor : aTextColor;
9482cdf0e10cSrcweir         }
9483cdf0e10cSrcweir     }
9484cdf0e10cSrcweir 
9485cdf0e10cSrcweir 
9486cdf0e10cSrcweir 	if( bDark )
9487cdf0e10cSrcweir 	{
9488cdf0e10cSrcweir 		DrawRect( aRect );
9489cdf0e10cSrcweir 	}
9490cdf0e10cSrcweir 	else
9491cdf0e10cSrcweir 	{
9492cdf0e10cSrcweir         if( bRoundEdges )
9493cdf0e10cSrcweir         {
9494cdf0e10cSrcweir             Polygon aPoly( aRect, nCornerRadius, nCornerRadius );
9495cdf0e10cSrcweir             PolyPolygon aPolyPoly( aPoly );
9496cdf0e10cSrcweir             DrawTransparent( aPolyPoly, nPercent );
9497cdf0e10cSrcweir         }
9498cdf0e10cSrcweir         else
9499cdf0e10cSrcweir         {
9500cdf0e10cSrcweir             Polygon aPoly( aRect );
9501cdf0e10cSrcweir             PolyPolygon aPolyPoly( aPoly );
9502cdf0e10cSrcweir             DrawTransparent( aPolyPoly, nPercent );
9503cdf0e10cSrcweir         }
9504cdf0e10cSrcweir 	}
9505cdf0e10cSrcweir 
9506cdf0e10cSrcweir     SetFillColor( oldFillCol );
9507cdf0e10cSrcweir     SetLineColor( oldLineCol );
9508cdf0e10cSrcweir }
9509cdf0e10cSrcweir 
9510cdf0e10cSrcweir /*
9511cdf0e10cSrcweir void Window::DbgAssertNoEventListeners()
9512cdf0e10cSrcweir {
9513cdf0e10cSrcweir     VclWindowEvent aEvent( this, 0, NULL );
9514cdf0e10cSrcweir     DBG_ASSERT( mpWindowImpl->maEventListeners.empty(), "Eventlistener: Who is still listening???" )
9515cdf0e10cSrcweir     if ( !mpWindowImpl->maEventListeners.empty() )
9516cdf0e10cSrcweir         mpWindowImpl->maEventListeners.Call( &aEvent );
9517cdf0e10cSrcweir 
9518cdf0e10cSrcweir     DBG_ASSERT( mpWindowImpl->maChildEventListeners.empty(), "ChildEventlistener: Who is still listening???" )
9519cdf0e10cSrcweir     if ( !mpWindowImpl->maChildEventListeners.empty() )
9520cdf0e10cSrcweir         mpWindowImpl->maChildEventListeners.Call( &aEvent );
9521cdf0e10cSrcweir }
9522cdf0e10cSrcweir */
9523cdf0e10cSrcweir 
9524cdf0e10cSrcweir // controls should return the window that gets the
9525cdf0e10cSrcweir // focus by default, so keyevents can be sent to that window directly
9526cdf0e10cSrcweir Window* Window::GetPreferredKeyInputWindow()
9527cdf0e10cSrcweir {
9528cdf0e10cSrcweir     return this;
9529cdf0e10cSrcweir }
9530cdf0e10cSrcweir 
9531cdf0e10cSrcweir 
9532cdf0e10cSrcweir sal_Bool Window::IsScrollable() const
9533cdf0e10cSrcweir {
9534cdf0e10cSrcweir     // check for scrollbars
9535cdf0e10cSrcweir     Window *pChild = mpWindowImpl->mpFirstChild;
9536cdf0e10cSrcweir     while( pChild )
9537cdf0e10cSrcweir     {
9538cdf0e10cSrcweir         if( pChild->GetType() == WINDOW_SCROLLBAR )
9539cdf0e10cSrcweir             return true;
9540cdf0e10cSrcweir         else
9541cdf0e10cSrcweir             pChild = pChild->mpWindowImpl->mpNext;
9542cdf0e10cSrcweir     }
9543cdf0e10cSrcweir     return false;
9544cdf0e10cSrcweir }
9545cdf0e10cSrcweir 
9546cdf0e10cSrcweir sal_Bool Window::IsTopWindow() const
9547cdf0e10cSrcweir {
9548cdf0e10cSrcweir     if ( mpWindowImpl->mbInDtor )
9549cdf0e10cSrcweir         return sal_False;
9550cdf0e10cSrcweir 
9551cdf0e10cSrcweir     // topwindows must be frames or they must have a borderwindow which is a frame
9552cdf0e10cSrcweir     if( !mpWindowImpl->mbFrame && (!mpWindowImpl->mpBorderWindow || (mpWindowImpl->mpBorderWindow && !mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame) ) )
9553cdf0e10cSrcweir         return sal_False;
9554cdf0e10cSrcweir 
9555cdf0e10cSrcweir     ImplGetWinData();
9556cdf0e10cSrcweir     if( mpWindowImpl->mpWinData->mnIsTopWindow == (sal_uInt16)~0)    // still uninitialized
9557cdf0e10cSrcweir     {
9558cdf0e10cSrcweir         // #113722#, cache result of expensive queryInterface call
9559cdf0e10cSrcweir         Window *pThisWin = (Window*)this;
9560cdf0e10cSrcweir         uno::Reference< XTopWindow > xTopWindow( pThisWin->GetComponentInterface(), UNO_QUERY );
9561cdf0e10cSrcweir         pThisWin->mpWindowImpl->mpWinData->mnIsTopWindow = xTopWindow.is() ? 1 : 0;
9562cdf0e10cSrcweir     }
9563cdf0e10cSrcweir     return mpWindowImpl->mpWinData->mnIsTopWindow == 1 ? sal_True : sal_False;
9564cdf0e10cSrcweir }
9565cdf0e10cSrcweir 
9566cdf0e10cSrcweir void Window::ImplMirrorFramePos( Point &pt ) const
9567cdf0e10cSrcweir {
9568cdf0e10cSrcweir     pt.X() = mpWindowImpl->mpFrame->maGeometry.nWidth-1-pt.X();
9569cdf0e10cSrcweir }
9570cdf0e10cSrcweir 
9571cdf0e10cSrcweir // frame based modal counter (dialogs are not modal to the whole application anymore)
9572cdf0e10cSrcweir sal_Bool Window::IsInModalMode() const
9573cdf0e10cSrcweir {
9574cdf0e10cSrcweir     return (mpWindowImpl->mpFrameWindow->mpWindowImpl->mpFrameData->mnModalMode != 0);
9575cdf0e10cSrcweir }
9576cdf0e10cSrcweir void Window::ImplIncModalCount()
9577cdf0e10cSrcweir {
9578cdf0e10cSrcweir     Window* pFrameWindow = mpWindowImpl->mpFrameWindow;
9579cdf0e10cSrcweir     Window* pParent = pFrameWindow;
9580cdf0e10cSrcweir     while( pFrameWindow )
9581cdf0e10cSrcweir     {
9582cdf0e10cSrcweir         pFrameWindow->mpWindowImpl->mpFrameData->mnModalMode++;
9583cdf0e10cSrcweir         while( pParent && pParent->mpWindowImpl->mpFrameWindow == pFrameWindow )
9584cdf0e10cSrcweir         {
9585cdf0e10cSrcweir             pParent = pParent->GetParent();
9586cdf0e10cSrcweir         }
9587cdf0e10cSrcweir         pFrameWindow = pParent ? pParent->mpWindowImpl->mpFrameWindow : NULL;
9588cdf0e10cSrcweir     }
9589cdf0e10cSrcweir }
9590cdf0e10cSrcweir void Window::ImplDecModalCount()
9591cdf0e10cSrcweir {
9592cdf0e10cSrcweir     Window* pFrameWindow = mpWindowImpl->mpFrameWindow;
9593cdf0e10cSrcweir     Window* pParent = pFrameWindow;
9594cdf0e10cSrcweir     while( pFrameWindow )
9595cdf0e10cSrcweir     {
9596cdf0e10cSrcweir         pFrameWindow->mpWindowImpl->mpFrameData->mnModalMode--;
9597cdf0e10cSrcweir         while( pParent && pParent->mpWindowImpl->mpFrameWindow == pFrameWindow )
9598cdf0e10cSrcweir         {
9599cdf0e10cSrcweir             pParent = pParent->GetParent();
9600cdf0e10cSrcweir         }
9601cdf0e10cSrcweir         pFrameWindow = pParent ? pParent->mpWindowImpl->mpFrameWindow : NULL;
9602cdf0e10cSrcweir     }
9603cdf0e10cSrcweir }
9604cdf0e10cSrcweir sal_Bool Window::ImplIsInTaskPaneList()
9605cdf0e10cSrcweir {
9606cdf0e10cSrcweir     return mpWindowImpl->mbIsInTaskPaneList;
9607cdf0e10cSrcweir }
9608cdf0e10cSrcweir void Window::ImplIsInTaskPaneList( sal_Bool mbIsInTaskList )
9609cdf0e10cSrcweir {
9610cdf0e10cSrcweir     mpWindowImpl->mbIsInTaskPaneList = mbIsInTaskList;
9611cdf0e10cSrcweir }
9612cdf0e10cSrcweir 
9613cdf0e10cSrcweir void Window::ImplNotifyIconifiedState( sal_Bool bIconified )
9614cdf0e10cSrcweir {
9615cdf0e10cSrcweir     mpWindowImpl->mpFrameWindow->ImplCallEventListeners( bIconified ? VCLEVENT_WINDOW_MINIMIZE : VCLEVENT_WINDOW_NORMALIZE );
9616cdf0e10cSrcweir     // #109206# notify client window as well to have toolkit topwindow listeners notified
9617cdf0e10cSrcweir     if( mpWindowImpl->mpFrameWindow->mpWindowImpl->mpClientWindow && mpWindowImpl->mpFrameWindow != mpWindowImpl->mpFrameWindow->mpWindowImpl->mpClientWindow )
9618cdf0e10cSrcweir         mpWindowImpl->mpFrameWindow->mpWindowImpl->mpClientWindow->ImplCallEventListeners( bIconified ? VCLEVENT_WINDOW_MINIMIZE : VCLEVENT_WINDOW_NORMALIZE );
9619cdf0e10cSrcweir }
9620cdf0e10cSrcweir 
9621cdf0e10cSrcweir sal_Bool Window::HasActiveChildFrame()
9622cdf0e10cSrcweir {
9623cdf0e10cSrcweir     sal_Bool bRet = sal_False;
9624cdf0e10cSrcweir     Window *pFrameWin = ImplGetSVData()->maWinData.mpFirstFrame;
9625cdf0e10cSrcweir     while( pFrameWin )
9626cdf0e10cSrcweir     {
9627cdf0e10cSrcweir         if( pFrameWin != mpWindowImpl->mpFrameWindow )
9628cdf0e10cSrcweir         {
9629cdf0e10cSrcweir             sal_Bool bDecorated = sal_False;
9630cdf0e10cSrcweir             Window *pChildFrame = pFrameWin->ImplGetWindow();
9631cdf0e10cSrcweir             // #i15285# unfortunately WB_MOVEABLE is the same as WB_TABSTOP which can
9632cdf0e10cSrcweir             // be removed for ToolBoxes to influence the keyboard accessibility
9633cdf0e10cSrcweir             // thus WB_MOVEABLE is no indicator for decoration anymore
9634cdf0e10cSrcweir             // but FloatingWindows carry this information in their TitleType...
9635cdf0e10cSrcweir             // TODO: avoid duplicate WinBits !!!
9636cdf0e10cSrcweir             if( pChildFrame && pChildFrame->ImplIsFloatingWindow() )
9637cdf0e10cSrcweir                 bDecorated = ((FloatingWindow*) pChildFrame)->GetTitleType() != FLOATWIN_TITLE_NONE;
9638cdf0e10cSrcweir             if( bDecorated || (pFrameWin->mpWindowImpl->mnStyle & (WB_MOVEABLE | WB_SIZEABLE) ) )
9639cdf0e10cSrcweir                 if( pChildFrame && pChildFrame->IsVisible() && pChildFrame->IsActive() )
9640cdf0e10cSrcweir                 {
9641cdf0e10cSrcweir                     if( ImplIsChild( pChildFrame, sal_True ) )
9642cdf0e10cSrcweir                     {
9643cdf0e10cSrcweir                         bRet = sal_True;
9644cdf0e10cSrcweir                         break;
9645cdf0e10cSrcweir                     }
9646cdf0e10cSrcweir                 }
9647cdf0e10cSrcweir         }
9648cdf0e10cSrcweir         pFrameWin = pFrameWin->mpWindowImpl->mpFrameData->mpNextFrame;
9649cdf0e10cSrcweir     }
9650cdf0e10cSrcweir     return bRet;
9651cdf0e10cSrcweir }
9652cdf0e10cSrcweir 
9653cdf0e10cSrcweir LanguageType Window::GetInputLanguage() const
9654cdf0e10cSrcweir {
9655cdf0e10cSrcweir     return mpWindowImpl->mpFrame->GetInputLanguage();
9656cdf0e10cSrcweir }
9657cdf0e10cSrcweir 
9658cdf0e10cSrcweir void Window::EnableNativeWidget( sal_Bool bEnable )
9659cdf0e10cSrcweir {
9660cdf0e10cSrcweir     static const char* pNoNWF = getenv( "SAL_NO_NWF" );
9661cdf0e10cSrcweir     if( pNoNWF && *pNoNWF )
9662cdf0e10cSrcweir         bEnable = sal_False;
9663cdf0e10cSrcweir 
9664cdf0e10cSrcweir     if( bEnable != ImplGetWinData()->mbEnableNativeWidget )
9665cdf0e10cSrcweir     {
9666cdf0e10cSrcweir         ImplGetWinData()->mbEnableNativeWidget = bEnable;
9667cdf0e10cSrcweir 
9668cdf0e10cSrcweir         // send datachanged event to allow for internal changes required for NWF
9669cdf0e10cSrcweir         // like clipmode, transparency, etc.
9670cdf0e10cSrcweir         DataChangedEvent aDCEvt( DATACHANGED_SETTINGS, &maSettings, SETTINGS_STYLE );
9671cdf0e10cSrcweir         DataChanged( aDCEvt );
9672cdf0e10cSrcweir 
9673cdf0e10cSrcweir         // sometimes the borderwindow is queried, so keep it in sync
9674cdf0e10cSrcweir         if( mpWindowImpl->mpBorderWindow )
9675cdf0e10cSrcweir             mpWindowImpl->mpBorderWindow->ImplGetWinData()->mbEnableNativeWidget = bEnable;
9676cdf0e10cSrcweir     }
9677cdf0e10cSrcweir 
9678cdf0e10cSrcweir     // push down, useful for compound controls
9679cdf0e10cSrcweir     Window *pChild = mpWindowImpl->mpFirstChild;
9680cdf0e10cSrcweir     while( pChild )
9681cdf0e10cSrcweir     {
9682cdf0e10cSrcweir         pChild->EnableNativeWidget( bEnable );
9683cdf0e10cSrcweir         pChild = pChild->mpWindowImpl->mpNext;
9684cdf0e10cSrcweir     }
9685cdf0e10cSrcweir }
9686cdf0e10cSrcweir 
9687cdf0e10cSrcweir sal_Bool Window::IsNativeWidgetEnabled() const
9688cdf0e10cSrcweir {
9689cdf0e10cSrcweir     return ImplGetWinData()->mbEnableNativeWidget;
9690cdf0e10cSrcweir }
9691cdf0e10cSrcweir 
9692cdf0e10cSrcweir #ifdef WNT // see #140456#
9693cdf0e10cSrcweir #include <win/salframe.h>
9694cdf0e10cSrcweir #endif
9695cdf0e10cSrcweir 
9696cdf0e10cSrcweir uno::Reference< rendering::XCanvas > Window::ImplGetCanvas( const Size& rFullscreenSize,
9697cdf0e10cSrcweir                                                        bool        bFullscreen,
9698cdf0e10cSrcweir                                                        bool        bSpriteCanvas ) const
9699cdf0e10cSrcweir {
9700cdf0e10cSrcweir     // try to retrieve hard reference from weak member
9701cdf0e10cSrcweir     uno::Reference< rendering::XCanvas > xCanvas( mpWindowImpl->mxCanvas );
9702cdf0e10cSrcweir 
9703cdf0e10cSrcweir     // canvas still valid? Then we're done.
9704cdf0e10cSrcweir     if( xCanvas.is() )
9705cdf0e10cSrcweir         return xCanvas;
9706cdf0e10cSrcweir 
9707cdf0e10cSrcweir     Sequence< Any > aArg(6);
9708cdf0e10cSrcweir 
9709cdf0e10cSrcweir     // Feed any with operating system's window handle
9710cdf0e10cSrcweir     // ==============================================
9711cdf0e10cSrcweir 
9712cdf0e10cSrcweir     // common: first any is VCL pointer to window (for VCL canvas)
9713cdf0e10cSrcweir     aArg[ 0 ] = makeAny( reinterpret_cast<sal_Int64>(this) );
9714cdf0e10cSrcweir 
9715cdf0e10cSrcweir     // TODO(Q1): Make GetSystemData method virtual
9716cdf0e10cSrcweir 
9717cdf0e10cSrcweir     // check whether we're a SysChild: have to fetch system data
9718cdf0e10cSrcweir     // directly from SystemChildWindow, because the GetSystemData
9719cdf0e10cSrcweir     // method is unfortunately not virtual
9720cdf0e10cSrcweir     const SystemChildWindow* pSysChild = dynamic_cast< const SystemChildWindow* >( this );
9721cdf0e10cSrcweir     if( pSysChild )
9722cdf0e10cSrcweir     {
9723cdf0e10cSrcweir         aArg[ 1 ] = pSysChild->GetSystemDataAny();
9724cdf0e10cSrcweir         aArg[ 5 ] = pSysChild->GetSystemGfxDataAny();
9725cdf0e10cSrcweir     }
9726cdf0e10cSrcweir     else
9727cdf0e10cSrcweir     {
9728cdf0e10cSrcweir         aArg[ 1 ] = GetSystemDataAny();
9729cdf0e10cSrcweir         aArg[ 5 ] = GetSystemGfxDataAny();
9730cdf0e10cSrcweir     }
9731cdf0e10cSrcweir 
9732cdf0e10cSrcweir     if( bFullscreen )
9733cdf0e10cSrcweir         aArg[ 2 ] = makeAny( ::com::sun::star::awt::Rectangle( 0, 0,
9734cdf0e10cSrcweir                                                                rFullscreenSize.Width(),
9735cdf0e10cSrcweir                                                                rFullscreenSize.Height() ) );
9736cdf0e10cSrcweir     else
9737cdf0e10cSrcweir         aArg[ 2 ] = makeAny( ::com::sun::star::awt::Rectangle( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight ) );
9738cdf0e10cSrcweir 
9739cdf0e10cSrcweir     aArg[ 3 ] = makeAny( mpWindowImpl->mbAlwaysOnTop ? sal_True : sal_False );
9740cdf0e10cSrcweir     aArg[ 4 ] = makeAny( uno::Reference< awt::XWindow >(
9741cdf0e10cSrcweir                              const_cast<Window*>(this)->GetComponentInterface(),
9742cdf0e10cSrcweir                              uno::UNO_QUERY ));
9743cdf0e10cSrcweir 
9744cdf0e10cSrcweir     uno::Reference< XMultiServiceFactory > xFactory = vcl::unohelper::GetMultiServiceFactory();
9745cdf0e10cSrcweir 
9746cdf0e10cSrcweir     // Create canvas instance with window handle
9747cdf0e10cSrcweir     // =========================================
9748cdf0e10cSrcweir     if ( xFactory.is() )
9749cdf0e10cSrcweir     {
9750cdf0e10cSrcweir         static ::vcl::DeleteUnoReferenceOnDeinit<lang::XMultiServiceFactory> xStaticCanvasFactory(
9751cdf0e10cSrcweir             uno::Reference<lang::XMultiServiceFactory>(
9752cdf0e10cSrcweir                 xFactory->createInstance(
9753cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(
9754cdf0e10cSrcweir                             "com.sun.star.rendering.CanvasFactory") ) ),
9755cdf0e10cSrcweir                 UNO_QUERY ));
9756cdf0e10cSrcweir         uno::Reference<lang::XMultiServiceFactory> xCanvasFactory(xStaticCanvasFactory.get());
9757cdf0e10cSrcweir 
9758cdf0e10cSrcweir         if(xCanvasFactory.is())
9759cdf0e10cSrcweir         {
9760cdf0e10cSrcweir #ifdef WNT
9761cdf0e10cSrcweir             // see #140456# - if we're running on a multiscreen setup,
9762cdf0e10cSrcweir             // request special, multi-screen safe sprite canvas
9763cdf0e10cSrcweir             // implementation (not DX5 canvas, as it cannot cope with
9764cdf0e10cSrcweir             // surfaces spanning multiple displays). Note: canvas
9765cdf0e10cSrcweir             // (without sprite) stays the same)
9766cdf0e10cSrcweir 			const sal_uInt32 nDisplay = static_cast< WinSalFrame* >( mpWindowImpl->mpFrame )->mnDisplay;
9767cdf0e10cSrcweir 			if( (nDisplay >= Application::GetScreenCount()) )
9768cdf0e10cSrcweir             {
9769cdf0e10cSrcweir                 xCanvas.set( xCanvasFactory->createInstanceWithArguments(
9770cdf0e10cSrcweir                                  bSpriteCanvas ?
9771cdf0e10cSrcweir                                  OUString( RTL_CONSTASCII_USTRINGPARAM(
9772cdf0e10cSrcweir                                                "com.sun.star.rendering.SpriteCanvas.MultiScreen" )) :
9773cdf0e10cSrcweir                                  OUString( RTL_CONSTASCII_USTRINGPARAM(
9774cdf0e10cSrcweir                                                "com.sun.star.rendering.Canvas.MultiScreen" )),
9775cdf0e10cSrcweir                                  aArg ),
9776cdf0e10cSrcweir                              UNO_QUERY );
9777cdf0e10cSrcweir 
9778cdf0e10cSrcweir             }
9779cdf0e10cSrcweir             else
9780cdf0e10cSrcweir             {
9781cdf0e10cSrcweir #endif
9782cdf0e10cSrcweir                 xCanvas.set( xCanvasFactory->createInstanceWithArguments(
9783cdf0e10cSrcweir                                  bSpriteCanvas ?
9784cdf0e10cSrcweir                                  OUString( RTL_CONSTASCII_USTRINGPARAM(
9785cdf0e10cSrcweir                                                "com.sun.star.rendering.SpriteCanvas" )) :
9786cdf0e10cSrcweir                                  OUString( RTL_CONSTASCII_USTRINGPARAM(
9787cdf0e10cSrcweir                                                "com.sun.star.rendering.Canvas" )),
9788cdf0e10cSrcweir                                  aArg ),
9789cdf0e10cSrcweir                              UNO_QUERY );
9790cdf0e10cSrcweir 
9791cdf0e10cSrcweir #ifdef WNT
9792cdf0e10cSrcweir             }
9793cdf0e10cSrcweir #endif
9794cdf0e10cSrcweir 
9795cdf0e10cSrcweir             mpWindowImpl->mxCanvas = xCanvas;
9796cdf0e10cSrcweir         }
9797cdf0e10cSrcweir     }
9798cdf0e10cSrcweir 
9799cdf0e10cSrcweir     // no factory??? Empty reference, then.
9800cdf0e10cSrcweir     return xCanvas;
9801cdf0e10cSrcweir }
9802cdf0e10cSrcweir 
9803cdf0e10cSrcweir uno::Reference< rendering::XCanvas > Window::GetCanvas() const
9804cdf0e10cSrcweir {
9805cdf0e10cSrcweir     return ImplGetCanvas( Size(), false, false );
9806cdf0e10cSrcweir }
9807cdf0e10cSrcweir 
9808cdf0e10cSrcweir uno::Reference< rendering::XSpriteCanvas > Window::GetSpriteCanvas() const
9809cdf0e10cSrcweir {
9810cdf0e10cSrcweir     uno::Reference< rendering::XSpriteCanvas > xSpriteCanvas(
9811cdf0e10cSrcweir         ImplGetCanvas( Size(), false, true ), uno::UNO_QUERY );
9812cdf0e10cSrcweir     return xSpriteCanvas;
9813cdf0e10cSrcweir }
9814cdf0e10cSrcweir 
9815cdf0e10cSrcweir uno::Reference< ::com::sun::star::rendering::XSpriteCanvas > Window::GetFullscreenSpriteCanvas( const Size& rFullscreenSize ) const
9816cdf0e10cSrcweir {
9817cdf0e10cSrcweir     uno::Reference< rendering::XSpriteCanvas > xSpriteCanvas(
9818cdf0e10cSrcweir         ImplGetCanvas( rFullscreenSize, true, true ), uno::UNO_QUERY );
9819cdf0e10cSrcweir     return xSpriteCanvas;
9820cdf0e10cSrcweir }
9821cdf0e10cSrcweir 
9822cdf0e10cSrcweir void Window::ImplPaintToDevice( OutputDevice* i_pTargetOutDev, const Point& i_rPos )
9823cdf0e10cSrcweir {
9824cdf0e10cSrcweir     sal_Bool bRVisible = mpWindowImpl->mbReallyVisible;
9825cdf0e10cSrcweir     mpWindowImpl->mbReallyVisible = mpWindowImpl->mbVisible;
9826cdf0e10cSrcweir     sal_Bool bDevOutput = mbDevOutput;
9827cdf0e10cSrcweir     mbDevOutput = sal_True;
9828cdf0e10cSrcweir 
9829cdf0e10cSrcweir     long nOldDPIX = ImplGetDPIX();
9830cdf0e10cSrcweir     long nOldDPIY = ImplGetDPIY();
9831cdf0e10cSrcweir     mnDPIX = i_pTargetOutDev->ImplGetDPIX();
9832cdf0e10cSrcweir     mnDPIY = i_pTargetOutDev->ImplGetDPIY();
9833cdf0e10cSrcweir     sal_Bool bOutput = IsOutputEnabled();
9834cdf0e10cSrcweir     EnableOutput();
9835cdf0e10cSrcweir 
9836cdf0e10cSrcweir     DBG_ASSERT( GetMapMode().GetMapUnit() == MAP_PIXEL, "MapMode must be PIXEL based" );
9837cdf0e10cSrcweir     if ( GetMapMode().GetMapUnit() != MAP_PIXEL )
9838cdf0e10cSrcweir         return;
9839cdf0e10cSrcweir 
9840cdf0e10cSrcweir     // preserve graphicsstate
9841cdf0e10cSrcweir     Push();
9842cdf0e10cSrcweir     Region aClipRegion( GetClipRegion() );
9843cdf0e10cSrcweir     SetClipRegion();
9844cdf0e10cSrcweir 
9845cdf0e10cSrcweir     GDIMetaFile* pOldMtf = GetConnectMetaFile();
9846cdf0e10cSrcweir     GDIMetaFile aMtf;
9847cdf0e10cSrcweir     SetConnectMetaFile( &aMtf );
9848cdf0e10cSrcweir 
9849cdf0e10cSrcweir     // put a push action to metafile
9850cdf0e10cSrcweir     Push();
9851cdf0e10cSrcweir     // copy graphics state to metafile
9852cdf0e10cSrcweir     Font aCopyFont = GetFont();
9853cdf0e10cSrcweir     if( nOldDPIX != mnDPIX || nOldDPIY != mnDPIY )
9854cdf0e10cSrcweir     {
9855cdf0e10cSrcweir         aCopyFont.SetHeight( aCopyFont.GetHeight() * mnDPIY / nOldDPIY );
9856cdf0e10cSrcweir         aCopyFont.SetWidth( aCopyFont.GetWidth() * mnDPIX / nOldDPIX );
9857cdf0e10cSrcweir     }
9858cdf0e10cSrcweir     SetFont( aCopyFont );
9859cdf0e10cSrcweir     SetTextColor( GetTextColor() );
9860cdf0e10cSrcweir     if( IsLineColor() )
9861cdf0e10cSrcweir         SetLineColor( GetLineColor() );
9862cdf0e10cSrcweir     else
9863cdf0e10cSrcweir         SetLineColor();
9864cdf0e10cSrcweir     if( IsFillColor() )
9865cdf0e10cSrcweir         SetFillColor( GetFillColor() );
9866cdf0e10cSrcweir     else
9867cdf0e10cSrcweir         SetFillColor();
9868cdf0e10cSrcweir     if( IsTextLineColor() )
9869cdf0e10cSrcweir         SetTextLineColor( GetTextLineColor() );
9870cdf0e10cSrcweir     else
9871cdf0e10cSrcweir         SetTextLineColor();
9872cdf0e10cSrcweir     if( IsOverlineColor() )
9873cdf0e10cSrcweir         SetOverlineColor( GetOverlineColor() );
9874cdf0e10cSrcweir     else
9875cdf0e10cSrcweir         SetOverlineColor();
9876cdf0e10cSrcweir     if( IsTextFillColor() )
9877cdf0e10cSrcweir         SetTextFillColor( GetTextFillColor() );
9878cdf0e10cSrcweir     else
9879cdf0e10cSrcweir         SetTextFillColor();
9880cdf0e10cSrcweir     SetTextAlign( GetTextAlign() );
9881cdf0e10cSrcweir     SetRasterOp( GetRasterOp() );
9882cdf0e10cSrcweir     if( IsRefPoint() )
9883cdf0e10cSrcweir         SetRefPoint( GetRefPoint() );
9884cdf0e10cSrcweir     else
9885cdf0e10cSrcweir         SetRefPoint();
9886cdf0e10cSrcweir     SetLayoutMode( GetLayoutMode() );
9887cdf0e10cSrcweir     SetDigitLanguage( GetDigitLanguage() );
9888cdf0e10cSrcweir     Rectangle aPaintRect( Point( 0, 0 ), GetOutputSizePixel() );
9889cdf0e10cSrcweir     aClipRegion.Intersect( aPaintRect );
9890cdf0e10cSrcweir     SetClipRegion( aClipRegion );
9891cdf0e10cSrcweir 
9892cdf0e10cSrcweir     // do the actual paint
9893cdf0e10cSrcweir 
9894cdf0e10cSrcweir     // background
9895cdf0e10cSrcweir     if( ! IsPaintTransparent() && IsBackground() && ! (GetParentClipMode() & PARENTCLIPMODE_NOCLIP ) )
9896cdf0e10cSrcweir         Erase();
9897cdf0e10cSrcweir     // foreground
9898cdf0e10cSrcweir     Paint( aPaintRect );
9899cdf0e10cSrcweir     // put a pop action to metafile
9900cdf0e10cSrcweir     Pop();
9901cdf0e10cSrcweir 
9902cdf0e10cSrcweir     SetConnectMetaFile( pOldMtf );
9903cdf0e10cSrcweir     EnableOutput( bOutput );
9904cdf0e10cSrcweir     mpWindowImpl->mbReallyVisible = bRVisible;
9905cdf0e10cSrcweir 
9906cdf0e10cSrcweir     // paint metafile to VDev
9907cdf0e10cSrcweir     VirtualDevice* pMaskedDevice = new VirtualDevice( *i_pTargetOutDev, 0, 0 );
9908cdf0e10cSrcweir     pMaskedDevice->SetOutputSizePixel( GetOutputSizePixel() );
9909cdf0e10cSrcweir     pMaskedDevice->EnableRTL( IsRTLEnabled() );
9910cdf0e10cSrcweir     aMtf.WindStart();
9911cdf0e10cSrcweir     aMtf.Play( pMaskedDevice );
9912cdf0e10cSrcweir     BitmapEx aBmpEx( pMaskedDevice->GetBitmapEx( Point( 0, 0 ), pMaskedDevice->GetOutputSizePixel() ) );
9913cdf0e10cSrcweir     i_pTargetOutDev->DrawBitmapEx( i_rPos, aBmpEx );
9914cdf0e10cSrcweir     // get rid of virtual device now so they don't pile up during recursive calls
9915cdf0e10cSrcweir     delete pMaskedDevice, pMaskedDevice = NULL;
9916cdf0e10cSrcweir 
9917cdf0e10cSrcweir 
9918cdf0e10cSrcweir     for( Window* pChild = mpWindowImpl->mpFirstChild; pChild; pChild = pChild->mpWindowImpl->mpNext )
9919cdf0e10cSrcweir     {
9920cdf0e10cSrcweir         if( pChild->mpWindowImpl->mpFrame == mpWindowImpl->mpFrame && pChild->IsVisible() )
9921cdf0e10cSrcweir         {
9922cdf0e10cSrcweir             long nDeltaX = pChild->mnOutOffX - mnOutOffX;
9923cdf0e10cSrcweir             if( ImplHasMirroredGraphics() )
9924cdf0e10cSrcweir                 nDeltaX = mnOutWidth - nDeltaX - pChild->mnOutWidth;
9925cdf0e10cSrcweir             long nDeltaY = pChild->GetOutOffYPixel() - GetOutOffYPixel();
9926cdf0e10cSrcweir             Point aPos( i_rPos );
9927cdf0e10cSrcweir             Point aDelta( nDeltaX, nDeltaY );
9928cdf0e10cSrcweir             aPos += aDelta;
9929cdf0e10cSrcweir             pChild->ImplPaintToDevice( i_pTargetOutDev, aPos );
9930cdf0e10cSrcweir         }
9931cdf0e10cSrcweir     }
9932cdf0e10cSrcweir 
9933cdf0e10cSrcweir     // restore graphics state
9934cdf0e10cSrcweir     Pop();
9935cdf0e10cSrcweir 
9936cdf0e10cSrcweir     EnableOutput( bOutput );
9937cdf0e10cSrcweir     mpWindowImpl->mbReallyVisible = bRVisible;
9938cdf0e10cSrcweir     mbDevOutput = bDevOutput;
9939cdf0e10cSrcweir     mnDPIX = nOldDPIX;
9940cdf0e10cSrcweir     mnDPIY = nOldDPIY;
9941cdf0e10cSrcweir }
9942cdf0e10cSrcweir 
9943cdf0e10cSrcweir void Window::PaintToDevice( OutputDevice* pDev, const Point& rPos, const Size& /*rSize*/ )
9944cdf0e10cSrcweir {
9945cdf0e10cSrcweir     // FIXME: scaling: currently this is for pixel copying only
9946cdf0e10cSrcweir 
9947cdf0e10cSrcweir     DBG_ASSERT( ! pDev->ImplHasMirroredGraphics(), "PaintToDevice to mirroring graphics" );
9948cdf0e10cSrcweir     DBG_ASSERT( ! pDev->IsRTLEnabled(), "PaintToDevice to mirroring device" );
9949cdf0e10cSrcweir 
9950cdf0e10cSrcweir 
9951cdf0e10cSrcweir     Point       aPos  = pDev->LogicToPixel( rPos );
9952cdf0e10cSrcweir 
9953cdf0e10cSrcweir     Window* pRealParent = NULL;
9954cdf0e10cSrcweir     if( ! mpWindowImpl->mbVisible )
9955cdf0e10cSrcweir     {
9956cdf0e10cSrcweir         Window* pTempParent = ImplGetDefaultWindow();
9957cdf0e10cSrcweir         if( pTempParent )
9958cdf0e10cSrcweir             pTempParent->EnableChildTransparentMode();
9959cdf0e10cSrcweir         pRealParent = GetParent();
9960cdf0e10cSrcweir         SetParent( pTempParent );
9961cdf0e10cSrcweir         // trigger correct visibility flags for children
9962cdf0e10cSrcweir         Show();
9963cdf0e10cSrcweir         Hide();
9964cdf0e10cSrcweir     }
9965cdf0e10cSrcweir 
9966cdf0e10cSrcweir     sal_Bool bVisible = mpWindowImpl->mbVisible;
9967cdf0e10cSrcweir     mpWindowImpl->mbVisible = sal_True;
9968cdf0e10cSrcweir 
9969cdf0e10cSrcweir     if( mpWindowImpl->mpBorderWindow )
9970cdf0e10cSrcweir         mpWindowImpl->mpBorderWindow->ImplPaintToDevice( pDev, rPos );
9971cdf0e10cSrcweir     else
9972cdf0e10cSrcweir         ImplPaintToDevice( pDev, rPos );
9973cdf0e10cSrcweir 
9974cdf0e10cSrcweir     mpWindowImpl->mbVisible = bVisible;
9975cdf0e10cSrcweir 
9976cdf0e10cSrcweir     if( pRealParent )
9977cdf0e10cSrcweir         SetParent( pRealParent );
9978cdf0e10cSrcweir }
9979cdf0e10cSrcweir 
9980cdf0e10cSrcweir XubString Window::GetSurroundingText() const
9981cdf0e10cSrcweir {
9982cdf0e10cSrcweir   return XubString::EmptyString();
9983cdf0e10cSrcweir }
9984cdf0e10cSrcweir 
9985cdf0e10cSrcweir Selection Window::GetSurroundingTextSelection() const
9986cdf0e10cSrcweir {
9987cdf0e10cSrcweir   return Selection( 0, 0 );
9988cdf0e10cSrcweir }
9989cdf0e10cSrcweir 
9990