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