xref: /AOO41X/main/vcl/source/window/syswin.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_vcl.hxx"
30*cdf0e10cSrcweir #include <tools/debug.hxx>
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include <vcl/svapp.hxx>
33*cdf0e10cSrcweir #include <vcl/menu.hxx>
34*cdf0e10cSrcweir #include <vcl/sound.hxx>
35*cdf0e10cSrcweir #include <vcl/svapp.hxx>
36*cdf0e10cSrcweir #include <vcl/event.hxx>
37*cdf0e10cSrcweir #include <vcl/syswin.hxx>
38*cdf0e10cSrcweir #include <vcl/taskpanelist.hxx>
39*cdf0e10cSrcweir #include <vcl/unowrap.hxx>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #include <salframe.hxx>
42*cdf0e10cSrcweir #include <svdata.hxx>
43*cdf0e10cSrcweir #include <brdwin.hxx>
44*cdf0e10cSrcweir #include <window.h>
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
47*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir // =======================================================================
50*cdf0e10cSrcweir class SystemWindow::ImplData
51*cdf0e10cSrcweir {
52*cdf0e10cSrcweir public:
53*cdf0e10cSrcweir     ImplData();
54*cdf0e10cSrcweir     ~ImplData();
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir     TaskPaneList*   mpTaskPaneList;
57*cdf0e10cSrcweir     Size            maMaxOutSize;
58*cdf0e10cSrcweir     rtl::OUString   maRepresentedURL;
59*cdf0e10cSrcweir };
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir SystemWindow::ImplData::ImplData()
62*cdf0e10cSrcweir {
63*cdf0e10cSrcweir     mpTaskPaneList = NULL;
64*cdf0e10cSrcweir     maMaxOutSize = Size( SHRT_MAX, SHRT_MAX );
65*cdf0e10cSrcweir }
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir SystemWindow::ImplData::~ImplData()
68*cdf0e10cSrcweir {
69*cdf0e10cSrcweir     if( mpTaskPaneList )
70*cdf0e10cSrcweir         delete mpTaskPaneList;
71*cdf0e10cSrcweir }
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir // =======================================================================
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir SystemWindow::SystemWindow( WindowType nType ) :
76*cdf0e10cSrcweir     Window( nType )
77*cdf0e10cSrcweir {
78*cdf0e10cSrcweir     mpImplData          = new ImplData;
79*cdf0e10cSrcweir     mpWindowImpl->mbSysWin            = sal_True;
80*cdf0e10cSrcweir     mpWindowImpl->mnActivateMode      = ACTIVATE_MODE_GRABFOCUS;
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir     mpMenuBar           = NULL;
83*cdf0e10cSrcweir     mbPined             = sal_False;
84*cdf0e10cSrcweir     mbRollUp            = sal_False;
85*cdf0e10cSrcweir     mbRollFunc          = sal_False;
86*cdf0e10cSrcweir     mbDockBtn           = sal_False;
87*cdf0e10cSrcweir     mbHideBtn           = sal_False;
88*cdf0e10cSrcweir     mbSysChild          = sal_False;
89*cdf0e10cSrcweir     mnMenuBarMode       = MENUBAR_MODE_NORMAL;
90*cdf0e10cSrcweir     mnIcon              = 0;
91*cdf0e10cSrcweir }
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir SystemWindow::~SystemWindow()
94*cdf0e10cSrcweir {
95*cdf0e10cSrcweir     delete mpImplData;
96*cdf0e10cSrcweir     mpImplData = NULL;
97*cdf0e10cSrcweir }
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir // -----------------------------------------------------------------------
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir long SystemWindow::Notify( NotifyEvent& rNEvt )
102*cdf0e10cSrcweir {
103*cdf0e10cSrcweir     // capture KeyEvents for menu handling
104*cdf0e10cSrcweir     if ( rNEvt.GetType() == EVENT_KEYINPUT )
105*cdf0e10cSrcweir     {
106*cdf0e10cSrcweir         MenuBar* pMBar = mpMenuBar;
107*cdf0e10cSrcweir         if ( !pMBar && ( GetType() == WINDOW_FLOATINGWINDOW ) )
108*cdf0e10cSrcweir         {
109*cdf0e10cSrcweir             Window* pWin = ImplGetFrameWindow()->ImplGetWindow();
110*cdf0e10cSrcweir             if( pWin && pWin->IsSystemWindow() )
111*cdf0e10cSrcweir                 pMBar = ((SystemWindow*)pWin)->GetMenuBar();
112*cdf0e10cSrcweir         }
113*cdf0e10cSrcweir         if ( pMBar && pMBar->ImplHandleKeyEvent( *rNEvt.GetKeyEvent(), sal_False ) )
114*cdf0e10cSrcweir             return sal_True;
115*cdf0e10cSrcweir     }
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir     return Window::Notify( rNEvt );
118*cdf0e10cSrcweir }
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir // -----------------------------------------------------------------------
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir long SystemWindow::PreNotify( NotifyEvent& rNEvt )
123*cdf0e10cSrcweir {
124*cdf0e10cSrcweir     // capture KeyEvents for taskpane cycling
125*cdf0e10cSrcweir     if ( rNEvt.GetType() == EVENT_KEYINPUT )
126*cdf0e10cSrcweir     {
127*cdf0e10cSrcweir         if( rNEvt.GetKeyEvent()->GetKeyCode().GetCode() == KEY_F6 &&
128*cdf0e10cSrcweir             rNEvt.GetKeyEvent()->GetKeyCode().IsMod1() &&
129*cdf0e10cSrcweir            !rNEvt.GetKeyEvent()->GetKeyCode().IsShift() )
130*cdf0e10cSrcweir         {
131*cdf0e10cSrcweir             // Ctrl-F6 goes directly to the document
132*cdf0e10cSrcweir 			GrabFocusToDocument();
133*cdf0e10cSrcweir 			return sal_True;
134*cdf0e10cSrcweir         }
135*cdf0e10cSrcweir         else
136*cdf0e10cSrcweir         {
137*cdf0e10cSrcweir             TaskPaneList *pTList = mpImplData->mpTaskPaneList;
138*cdf0e10cSrcweir             if( !pTList && ( GetType() == WINDOW_FLOATINGWINDOW ) )
139*cdf0e10cSrcweir             {
140*cdf0e10cSrcweir                 Window* pWin = ImplGetFrameWindow()->ImplGetWindow();
141*cdf0e10cSrcweir                 if( pWin && pWin->IsSystemWindow() )
142*cdf0e10cSrcweir                     pTList = ((SystemWindow*)pWin)->mpImplData->mpTaskPaneList;
143*cdf0e10cSrcweir             }
144*cdf0e10cSrcweir             if( !pTList )
145*cdf0e10cSrcweir             {
146*cdf0e10cSrcweir                 // search topmost system window which is the one to handle dialog/toolbar cycling
147*cdf0e10cSrcweir                 SystemWindow *pSysWin = this;
148*cdf0e10cSrcweir                 Window *pWin = this;
149*cdf0e10cSrcweir                 while( pWin )
150*cdf0e10cSrcweir                 {
151*cdf0e10cSrcweir                     pWin = pWin->GetParent();
152*cdf0e10cSrcweir                     if( pWin && pWin->IsSystemWindow() )
153*cdf0e10cSrcweir                         pSysWin = (SystemWindow*) pWin;
154*cdf0e10cSrcweir                 }
155*cdf0e10cSrcweir                 pTList = pSysWin->mpImplData->mpTaskPaneList;
156*cdf0e10cSrcweir             }
157*cdf0e10cSrcweir 		    if( pTList && pTList->HandleKeyEvent( *rNEvt.GetKeyEvent() ) )
158*cdf0e10cSrcweir 			    return sal_True;
159*cdf0e10cSrcweir         }
160*cdf0e10cSrcweir 	}
161*cdf0e10cSrcweir     return Window::PreNotify( rNEvt );
162*cdf0e10cSrcweir }
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir // -----------------------------------------------------------------------
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir TaskPaneList* SystemWindow::GetTaskPaneList()
167*cdf0e10cSrcweir {
168*cdf0e10cSrcweir 	if( mpImplData->mpTaskPaneList )
169*cdf0e10cSrcweir 		return mpImplData->mpTaskPaneList ;
170*cdf0e10cSrcweir 	else
171*cdf0e10cSrcweir 	{
172*cdf0e10cSrcweir 		mpImplData->mpTaskPaneList = new TaskPaneList();
173*cdf0e10cSrcweir         MenuBar* pMBar = mpMenuBar;
174*cdf0e10cSrcweir         if ( !pMBar && ( GetType() == WINDOW_FLOATINGWINDOW ) )
175*cdf0e10cSrcweir         {
176*cdf0e10cSrcweir             Window* pWin = ImplGetFrameWindow()->ImplGetWindow();
177*cdf0e10cSrcweir             if ( pWin && pWin->IsSystemWindow() )
178*cdf0e10cSrcweir                 pMBar = ((SystemWindow*)pWin)->GetMenuBar();
179*cdf0e10cSrcweir         }
180*cdf0e10cSrcweir 		if( pMBar )
181*cdf0e10cSrcweir 			mpImplData->mpTaskPaneList->AddWindow( pMBar->ImplGetWindow() );
182*cdf0e10cSrcweir 		return mpImplData->mpTaskPaneList;
183*cdf0e10cSrcweir 	}
184*cdf0e10cSrcweir }
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir // -----------------------------------------------------------------------
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir sal_Bool SystemWindow::Close()
189*cdf0e10cSrcweir {
190*cdf0e10cSrcweir     ImplDelData aDelData;
191*cdf0e10cSrcweir     ImplAddDel( &aDelData );
192*cdf0e10cSrcweir     ImplCallEventListeners( VCLEVENT_WINDOW_CLOSE );
193*cdf0e10cSrcweir     if ( aDelData.IsDelete() )
194*cdf0e10cSrcweir         return sal_False;
195*cdf0e10cSrcweir     ImplRemoveDel( &aDelData );
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir     if ( mpWindowImpl->mxWindowPeer.is() && IsCreatedWithToolkit() )
198*cdf0e10cSrcweir         return sal_False;
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir     // Is Window not closeable, ignore close
201*cdf0e10cSrcweir     Window*     pBorderWin = ImplGetBorderWindow();
202*cdf0e10cSrcweir     WinBits     nStyle;
203*cdf0e10cSrcweir     if ( pBorderWin )
204*cdf0e10cSrcweir         nStyle = pBorderWin->GetStyle();
205*cdf0e10cSrcweir     else
206*cdf0e10cSrcweir         nStyle = GetStyle();
207*cdf0e10cSrcweir     if ( !(nStyle & WB_CLOSEABLE) )
208*cdf0e10cSrcweir     {
209*cdf0e10cSrcweir         Sound::Beep( SOUND_DISABLE, this );
210*cdf0e10cSrcweir         return sal_False;
211*cdf0e10cSrcweir     }
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir     Hide();
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir     return sal_True;
216*cdf0e10cSrcweir }
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir // -----------------------------------------------------------------------
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir void SystemWindow::TitleButtonClick( sal_uInt16 )
221*cdf0e10cSrcweir {
222*cdf0e10cSrcweir }
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir // -----------------------------------------------------------------------
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir void SystemWindow::Pin()
227*cdf0e10cSrcweir {
228*cdf0e10cSrcweir }
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir // -----------------------------------------------------------------------
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir void SystemWindow::Roll()
233*cdf0e10cSrcweir {
234*cdf0e10cSrcweir }
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir // -----------------------------------------------------------------------
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir void SystemWindow::Resizing( Size& )
239*cdf0e10cSrcweir {
240*cdf0e10cSrcweir }
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir // -----------------------------------------------------------------------
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir void SystemWindow::SetZLevel( sal_uInt8 nLevel )
245*cdf0e10cSrcweir {
246*cdf0e10cSrcweir     Window* pWindow = this;
247*cdf0e10cSrcweir     while ( pWindow->mpWindowImpl->mpBorderWindow )
248*cdf0e10cSrcweir         pWindow = pWindow->mpWindowImpl->mpBorderWindow;
249*cdf0e10cSrcweir     if ( pWindow->mpWindowImpl->mbOverlapWin && !pWindow->mpWindowImpl->mbFrame )
250*cdf0e10cSrcweir     {
251*cdf0e10cSrcweir         sal_uInt8 nOldLevel = pWindow->mpWindowImpl->mpOverlapData->mnTopLevel;
252*cdf0e10cSrcweir         pWindow->mpWindowImpl->mpOverlapData->mnTopLevel = nLevel;
253*cdf0e10cSrcweir         // Wenn der neue Level groesser als der alte ist, schieben
254*cdf0e10cSrcweir         // wir das Fenster nach hinten
255*cdf0e10cSrcweir         if ( !IsReallyVisible() && (nLevel > nOldLevel) && pWindow->mpWindowImpl->mpNext )
256*cdf0e10cSrcweir         {
257*cdf0e10cSrcweir             // Fenster aus der Liste entfernen
258*cdf0e10cSrcweir             if ( pWindow->mpWindowImpl->mpPrev )
259*cdf0e10cSrcweir                 pWindow->mpWindowImpl->mpPrev->mpWindowImpl->mpNext = pWindow->mpWindowImpl->mpNext;
260*cdf0e10cSrcweir             else
261*cdf0e10cSrcweir                 pWindow->mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap = pWindow->mpWindowImpl->mpNext;
262*cdf0e10cSrcweir             pWindow->mpWindowImpl->mpNext->mpWindowImpl->mpPrev = pWindow->mpWindowImpl->mpPrev;
263*cdf0e10cSrcweir             pWindow->mpWindowImpl->mpNext = NULL;
264*cdf0e10cSrcweir             // und Fenster wieder in die Liste am Ende eintragen
265*cdf0e10cSrcweir             pWindow->mpWindowImpl->mpPrev = pWindow->mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap;
266*cdf0e10cSrcweir             pWindow->mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap = pWindow;
267*cdf0e10cSrcweir             pWindow->mpWindowImpl->mpPrev->mpWindowImpl->mpNext = pWindow;
268*cdf0e10cSrcweir         }
269*cdf0e10cSrcweir     }
270*cdf0e10cSrcweir }
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir // -----------------------------------------------------------------------
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir void SystemWindow::SetRepresentedURL( const rtl::OUString& i_rURL )
275*cdf0e10cSrcweir {
276*cdf0e10cSrcweir     bool bChanged = (i_rURL != mpImplData->maRepresentedURL);
277*cdf0e10cSrcweir     mpImplData->maRepresentedURL = i_rURL;
278*cdf0e10cSrcweir     if ( !mbSysChild && bChanged )
279*cdf0e10cSrcweir     {
280*cdf0e10cSrcweir         const Window* pWindow = this;
281*cdf0e10cSrcweir         while ( pWindow->mpWindowImpl->mpBorderWindow )
282*cdf0e10cSrcweir             pWindow = pWindow->mpWindowImpl->mpBorderWindow;
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir         if ( pWindow->mpWindowImpl->mbFrame )
285*cdf0e10cSrcweir             pWindow->mpWindowImpl->mpFrame->SetRepresentedURL( i_rURL );
286*cdf0e10cSrcweir     }
287*cdf0e10cSrcweir }
288*cdf0e10cSrcweir // -----------------------------------------------------------------------
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir const rtl::OUString& SystemWindow::GetRepresentedURL() const
291*cdf0e10cSrcweir {
292*cdf0e10cSrcweir     return mpImplData->maRepresentedURL;
293*cdf0e10cSrcweir }
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir // -----------------------------------------------------------------------
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir void SystemWindow::SetIcon( sal_uInt16 nIcon )
298*cdf0e10cSrcweir {
299*cdf0e10cSrcweir     if ( mnIcon == nIcon )
300*cdf0e10cSrcweir         return;
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir     mnIcon = nIcon;
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir     if ( !mbSysChild )
305*cdf0e10cSrcweir     {
306*cdf0e10cSrcweir         const Window* pWindow = this;
307*cdf0e10cSrcweir         while ( pWindow->mpWindowImpl->mpBorderWindow )
308*cdf0e10cSrcweir             pWindow = pWindow->mpWindowImpl->mpBorderWindow;
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir         if ( pWindow->mpWindowImpl->mbFrame )
311*cdf0e10cSrcweir             pWindow->mpWindowImpl->mpFrame->SetIcon( nIcon );
312*cdf0e10cSrcweir     }
313*cdf0e10cSrcweir }
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir // -----------------------------------------------------------------------
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir sal_uInt8 SystemWindow::GetZLevel() const
318*cdf0e10cSrcweir {
319*cdf0e10cSrcweir     const Window* pWindow = this;
320*cdf0e10cSrcweir     while ( pWindow->mpWindowImpl->mpBorderWindow )
321*cdf0e10cSrcweir         pWindow = pWindow->mpWindowImpl->mpBorderWindow;
322*cdf0e10cSrcweir     if ( pWindow->mpWindowImpl->mpOverlapData )
323*cdf0e10cSrcweir         return pWindow->mpWindowImpl->mpOverlapData->mnTopLevel;
324*cdf0e10cSrcweir     else
325*cdf0e10cSrcweir         return sal_False;
326*cdf0e10cSrcweir }
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir // -----------------------------------------------------------------------
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir void SystemWindow::EnableSaveBackground( sal_Bool bSave )
331*cdf0e10cSrcweir {
332*cdf0e10cSrcweir     if( ImplGetSVData()->maWinData.mbNoSaveBackground )
333*cdf0e10cSrcweir         bSave = false;
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir     Window* pWindow = this;
336*cdf0e10cSrcweir     while ( pWindow->mpWindowImpl->mpBorderWindow )
337*cdf0e10cSrcweir         pWindow = pWindow->mpWindowImpl->mpBorderWindow;
338*cdf0e10cSrcweir     if ( pWindow->mpWindowImpl->mbOverlapWin && !pWindow->mpWindowImpl->mbFrame )
339*cdf0e10cSrcweir     {
340*cdf0e10cSrcweir         pWindow->mpWindowImpl->mpOverlapData->mbSaveBack = bSave;
341*cdf0e10cSrcweir         if ( !bSave )
342*cdf0e10cSrcweir             pWindow->ImplDeleteOverlapBackground();
343*cdf0e10cSrcweir     }
344*cdf0e10cSrcweir }
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir // -----------------------------------------------------------------------
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir sal_Bool SystemWindow::IsSaveBackgroundEnabled() const
349*cdf0e10cSrcweir {
350*cdf0e10cSrcweir     const Window* pWindow = this;
351*cdf0e10cSrcweir     while ( pWindow->mpWindowImpl->mpBorderWindow )
352*cdf0e10cSrcweir         pWindow = pWindow->mpWindowImpl->mpBorderWindow;
353*cdf0e10cSrcweir     if ( pWindow->mpWindowImpl->mpOverlapData )
354*cdf0e10cSrcweir         return pWindow->mpWindowImpl->mpOverlapData->mbSaveBack;
355*cdf0e10cSrcweir     else
356*cdf0e10cSrcweir         return sal_False;
357*cdf0e10cSrcweir }
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir // -----------------------------------------------------------------------
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir void SystemWindow::ShowTitleButton( sal_uInt16 nButton, sal_Bool bVisible )
362*cdf0e10cSrcweir {
363*cdf0e10cSrcweir     if ( nButton == TITLE_BUTTON_DOCKING )
364*cdf0e10cSrcweir     {
365*cdf0e10cSrcweir         if ( mbDockBtn != bVisible )
366*cdf0e10cSrcweir         {
367*cdf0e10cSrcweir             mbDockBtn = bVisible;
368*cdf0e10cSrcweir             if ( mpWindowImpl->mpBorderWindow )
369*cdf0e10cSrcweir                 ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->SetDockButton( bVisible );
370*cdf0e10cSrcweir         }
371*cdf0e10cSrcweir     }
372*cdf0e10cSrcweir     else if ( nButton == TITLE_BUTTON_HIDE )
373*cdf0e10cSrcweir     {
374*cdf0e10cSrcweir         if ( mbHideBtn != bVisible )
375*cdf0e10cSrcweir         {
376*cdf0e10cSrcweir             mbHideBtn = bVisible;
377*cdf0e10cSrcweir             if ( mpWindowImpl->mpBorderWindow )
378*cdf0e10cSrcweir                 ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->SetHideButton( bVisible );
379*cdf0e10cSrcweir         }
380*cdf0e10cSrcweir     }
381*cdf0e10cSrcweir     else if ( nButton == TITLE_BUTTON_MENU )
382*cdf0e10cSrcweir     {
383*cdf0e10cSrcweir         if ( mpWindowImpl->mpBorderWindow )
384*cdf0e10cSrcweir             ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->SetMenuButton( bVisible );
385*cdf0e10cSrcweir     }
386*cdf0e10cSrcweir     else
387*cdf0e10cSrcweir         return;
388*cdf0e10cSrcweir }
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir // -----------------------------------------------------------------------
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir sal_Bool SystemWindow::IsTitleButtonVisible( sal_uInt16 nButton ) const
393*cdf0e10cSrcweir {
394*cdf0e10cSrcweir     if ( nButton == TITLE_BUTTON_DOCKING )
395*cdf0e10cSrcweir         return mbDockBtn;
396*cdf0e10cSrcweir     else /* if ( nButton == TITLE_BUTTON_HIDE ) */
397*cdf0e10cSrcweir         return mbHideBtn;
398*cdf0e10cSrcweir }
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir // -----------------------------------------------------------------------
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir void SystemWindow::SetPin( sal_Bool bPin )
403*cdf0e10cSrcweir {
404*cdf0e10cSrcweir     if ( bPin != mbPined )
405*cdf0e10cSrcweir     {
406*cdf0e10cSrcweir         mbPined = bPin;
407*cdf0e10cSrcweir         if ( mpWindowImpl->mpBorderWindow )
408*cdf0e10cSrcweir             ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->SetPin( bPin );
409*cdf0e10cSrcweir     }
410*cdf0e10cSrcweir }
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir // -----------------------------------------------------------------------
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir void SystemWindow::RollUp()
415*cdf0e10cSrcweir {
416*cdf0e10cSrcweir     if ( !mbRollUp )
417*cdf0e10cSrcweir     {
418*cdf0e10cSrcweir         maOrgSize = GetOutputSizePixel();
419*cdf0e10cSrcweir         mbRollFunc = sal_True;
420*cdf0e10cSrcweir         Size aSize = maRollUpOutSize;
421*cdf0e10cSrcweir         if ( !aSize.Width() )
422*cdf0e10cSrcweir             aSize.Width() = GetOutputSizePixel().Width();
423*cdf0e10cSrcweir         mbRollUp = sal_True;
424*cdf0e10cSrcweir         if ( mpWindowImpl->mpBorderWindow )
425*cdf0e10cSrcweir             ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->SetRollUp( sal_True, aSize );
426*cdf0e10cSrcweir         else
427*cdf0e10cSrcweir             SetOutputSizePixel( aSize );
428*cdf0e10cSrcweir         mbRollFunc = sal_False;
429*cdf0e10cSrcweir     }
430*cdf0e10cSrcweir }
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir // -----------------------------------------------------------------------
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir void SystemWindow::RollDown()
435*cdf0e10cSrcweir {
436*cdf0e10cSrcweir     if ( mbRollUp )
437*cdf0e10cSrcweir     {
438*cdf0e10cSrcweir         mbRollUp = sal_False;
439*cdf0e10cSrcweir         if ( mpWindowImpl->mpBorderWindow )
440*cdf0e10cSrcweir             ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->SetRollUp( sal_False, maOrgSize );
441*cdf0e10cSrcweir         else
442*cdf0e10cSrcweir             SetOutputSizePixel( maOrgSize );
443*cdf0e10cSrcweir     }
444*cdf0e10cSrcweir }
445*cdf0e10cSrcweir 
446*cdf0e10cSrcweir // -----------------------------------------------------------------------
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir void SystemWindow::SetMinOutputSizePixel( const Size& rSize )
449*cdf0e10cSrcweir {
450*cdf0e10cSrcweir     maMinOutSize = rSize;
451*cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
452*cdf0e10cSrcweir     {
453*cdf0e10cSrcweir         ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->SetMinOutputSize( rSize.Width(), rSize.Height() );
454*cdf0e10cSrcweir         if ( mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame )
455*cdf0e10cSrcweir             mpWindowImpl->mpBorderWindow->mpWindowImpl->mpFrame->SetMinClientSize( rSize.Width(), rSize.Height() );
456*cdf0e10cSrcweir     }
457*cdf0e10cSrcweir     else if ( mpWindowImpl->mbFrame )
458*cdf0e10cSrcweir         mpWindowImpl->mpFrame->SetMinClientSize( rSize.Width(), rSize.Height() );
459*cdf0e10cSrcweir }
460*cdf0e10cSrcweir 
461*cdf0e10cSrcweir // -----------------------------------------------------------------------
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir void SystemWindow::SetMaxOutputSizePixel( const Size& rSize )
464*cdf0e10cSrcweir {
465*cdf0e10cSrcweir     Size aSize( rSize );
466*cdf0e10cSrcweir     if( aSize.Width() > SHRT_MAX || aSize.Width() <= 0 )
467*cdf0e10cSrcweir         aSize.Width() = SHRT_MAX;
468*cdf0e10cSrcweir     if( aSize.Height() > SHRT_MAX || aSize.Height() <= 0 )
469*cdf0e10cSrcweir         aSize.Height() = SHRT_MAX;
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir     mpImplData->maMaxOutSize = aSize;
472*cdf0e10cSrcweir     if ( mpWindowImpl->mpBorderWindow )
473*cdf0e10cSrcweir     {
474*cdf0e10cSrcweir         ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->SetMaxOutputSize( aSize.Width(), aSize.Height() );
475*cdf0e10cSrcweir         if ( mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame )
476*cdf0e10cSrcweir             mpWindowImpl->mpBorderWindow->mpWindowImpl->mpFrame->SetMaxClientSize( aSize.Width(), aSize.Height() );
477*cdf0e10cSrcweir     }
478*cdf0e10cSrcweir     else if ( mpWindowImpl->mbFrame )
479*cdf0e10cSrcweir         mpWindowImpl->mpFrame->SetMaxClientSize( aSize.Width(), aSize.Height() );
480*cdf0e10cSrcweir }
481*cdf0e10cSrcweir 
482*cdf0e10cSrcweir const Size& SystemWindow::GetMaxOutputSizePixel() const
483*cdf0e10cSrcweir {
484*cdf0e10cSrcweir     return mpImplData->maMaxOutSize;
485*cdf0e10cSrcweir }
486*cdf0e10cSrcweir // -----------------------------------------------------------------------
487*cdf0e10cSrcweir 
488*cdf0e10cSrcweir Size SystemWindow::GetResizeOutputSizePixel() const
489*cdf0e10cSrcweir {
490*cdf0e10cSrcweir     Size aSize = GetOutputSizePixel();
491*cdf0e10cSrcweir     if ( aSize.Width() < maMinOutSize.Width() )
492*cdf0e10cSrcweir         aSize.Width() = maMinOutSize.Width();
493*cdf0e10cSrcweir     if ( aSize.Height() < maMinOutSize.Height() )
494*cdf0e10cSrcweir         aSize.Height() = maMinOutSize.Height();
495*cdf0e10cSrcweir     return aSize;
496*cdf0e10cSrcweir }
497*cdf0e10cSrcweir 
498*cdf0e10cSrcweir // -----------------------------------------------------------------------
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir static void ImplWindowStateFromStr( WindowStateData& rData, const ByteString& rStr )
501*cdf0e10cSrcweir {
502*cdf0e10cSrcweir     sal_uLong       nValidMask  = 0;
503*cdf0e10cSrcweir     xub_StrLen  nIndex      = 0;
504*cdf0e10cSrcweir     ByteString  aTokenStr;
505*cdf0e10cSrcweir 
506*cdf0e10cSrcweir     aTokenStr = rStr.GetToken( 0, ',', nIndex );
507*cdf0e10cSrcweir     if ( aTokenStr.Len() )
508*cdf0e10cSrcweir     {
509*cdf0e10cSrcweir         rData.SetX( aTokenStr.ToInt32() );
510*cdf0e10cSrcweir         if( rData.GetX() > -16384 && rData.GetX() < 16384 )
511*cdf0e10cSrcweir             nValidMask |= WINDOWSTATE_MASK_X;
512*cdf0e10cSrcweir         else
513*cdf0e10cSrcweir             rData.SetX( 0 );
514*cdf0e10cSrcweir     }
515*cdf0e10cSrcweir     else
516*cdf0e10cSrcweir         rData.SetX( 0 );
517*cdf0e10cSrcweir     aTokenStr = rStr.GetToken( 0, ',', nIndex );
518*cdf0e10cSrcweir     if ( aTokenStr.Len() )
519*cdf0e10cSrcweir     {
520*cdf0e10cSrcweir         rData.SetY( aTokenStr.ToInt32() );
521*cdf0e10cSrcweir         if( rData.GetY() > -16384 && rData.GetY() < 16384 )
522*cdf0e10cSrcweir             nValidMask |= WINDOWSTATE_MASK_Y;
523*cdf0e10cSrcweir         else
524*cdf0e10cSrcweir             rData.SetY( 0 );
525*cdf0e10cSrcweir     }
526*cdf0e10cSrcweir     else
527*cdf0e10cSrcweir         rData.SetY( 0 );
528*cdf0e10cSrcweir     aTokenStr = rStr.GetToken( 0, ',', nIndex );
529*cdf0e10cSrcweir     if ( aTokenStr.Len() )
530*cdf0e10cSrcweir     {
531*cdf0e10cSrcweir         rData.SetWidth( aTokenStr.ToInt32() );
532*cdf0e10cSrcweir         if( rData.GetWidth() > 0 && rData.GetWidth() < 16384 )
533*cdf0e10cSrcweir             nValidMask |= WINDOWSTATE_MASK_WIDTH;
534*cdf0e10cSrcweir         else
535*cdf0e10cSrcweir             rData.SetWidth( 0 );
536*cdf0e10cSrcweir     }
537*cdf0e10cSrcweir     else
538*cdf0e10cSrcweir         rData.SetWidth( 0 );
539*cdf0e10cSrcweir     aTokenStr = rStr.GetToken( 0, ';', nIndex );
540*cdf0e10cSrcweir     if ( aTokenStr.Len() )
541*cdf0e10cSrcweir     {
542*cdf0e10cSrcweir         rData.SetHeight( aTokenStr.ToInt32() );
543*cdf0e10cSrcweir         if( rData.GetHeight() > 0 && rData.GetHeight() < 16384 )
544*cdf0e10cSrcweir             nValidMask |= WINDOWSTATE_MASK_HEIGHT;
545*cdf0e10cSrcweir         else
546*cdf0e10cSrcweir             rData.SetHeight( 0 );
547*cdf0e10cSrcweir     }
548*cdf0e10cSrcweir     else
549*cdf0e10cSrcweir         rData.SetHeight( 0 );
550*cdf0e10cSrcweir     aTokenStr = rStr.GetToken( 0, ';', nIndex );
551*cdf0e10cSrcweir     if ( aTokenStr.Len() )
552*cdf0e10cSrcweir     {
553*cdf0e10cSrcweir         // #94144# allow Minimize again, should be masked out when read from configuration
554*cdf0e10cSrcweir         // 91625 - ignore Minimize
555*cdf0e10cSrcweir         sal_uLong nState = (sal_uLong)aTokenStr.ToInt32();
556*cdf0e10cSrcweir         //nState &= ~(WINDOWSTATE_STATE_MINIMIZED);
557*cdf0e10cSrcweir         rData.SetState( nState );
558*cdf0e10cSrcweir         nValidMask |= WINDOWSTATE_MASK_STATE;
559*cdf0e10cSrcweir     }
560*cdf0e10cSrcweir     else
561*cdf0e10cSrcweir         rData.SetState( 0 );
562*cdf0e10cSrcweir 
563*cdf0e10cSrcweir     // read maximized pos/size
564*cdf0e10cSrcweir     aTokenStr = rStr.GetToken( 0, ',', nIndex );
565*cdf0e10cSrcweir     if ( aTokenStr.Len() )
566*cdf0e10cSrcweir     {
567*cdf0e10cSrcweir         rData.SetMaximizedX( aTokenStr.ToInt32() );
568*cdf0e10cSrcweir         if( rData.GetMaximizedX() > -16384 && rData.GetMaximizedX() < 16384 )
569*cdf0e10cSrcweir             nValidMask |= WINDOWSTATE_MASK_MAXIMIZED_X;
570*cdf0e10cSrcweir         else
571*cdf0e10cSrcweir             rData.SetMaximizedX( 0 );
572*cdf0e10cSrcweir     }
573*cdf0e10cSrcweir     else
574*cdf0e10cSrcweir         rData.SetMaximizedX( 0 );
575*cdf0e10cSrcweir     aTokenStr = rStr.GetToken( 0, ',', nIndex );
576*cdf0e10cSrcweir     if ( aTokenStr.Len() )
577*cdf0e10cSrcweir     {
578*cdf0e10cSrcweir         rData.SetMaximizedY( aTokenStr.ToInt32() );
579*cdf0e10cSrcweir         if( rData.GetMaximizedY() > -16384 && rData.GetMaximizedY() < 16384 )
580*cdf0e10cSrcweir             nValidMask |= WINDOWSTATE_MASK_MAXIMIZED_Y;
581*cdf0e10cSrcweir         else
582*cdf0e10cSrcweir             rData.SetMaximizedY( 0 );
583*cdf0e10cSrcweir     }
584*cdf0e10cSrcweir     else
585*cdf0e10cSrcweir         rData.SetMaximizedY( 0 );
586*cdf0e10cSrcweir     aTokenStr = rStr.GetToken( 0, ',', nIndex );
587*cdf0e10cSrcweir     if ( aTokenStr.Len() )
588*cdf0e10cSrcweir     {
589*cdf0e10cSrcweir         rData.SetMaximizedWidth( aTokenStr.ToInt32() );
590*cdf0e10cSrcweir         if( rData.GetMaximizedWidth() > 0 && rData.GetMaximizedWidth() < 16384 )
591*cdf0e10cSrcweir             nValidMask |= WINDOWSTATE_MASK_MAXIMIZED_WIDTH;
592*cdf0e10cSrcweir         else
593*cdf0e10cSrcweir             rData.SetMaximizedWidth( 0 );
594*cdf0e10cSrcweir     }
595*cdf0e10cSrcweir     else
596*cdf0e10cSrcweir         rData.SetMaximizedWidth( 0 );
597*cdf0e10cSrcweir     aTokenStr = rStr.GetToken( 0, ';', nIndex );
598*cdf0e10cSrcweir     if ( aTokenStr.Len() )
599*cdf0e10cSrcweir     {
600*cdf0e10cSrcweir         rData.SetMaximizedHeight( aTokenStr.ToInt32() );
601*cdf0e10cSrcweir         if( rData.GetMaximizedHeight() > 0 && rData.GetMaximizedHeight() < 16384 )
602*cdf0e10cSrcweir             nValidMask |= WINDOWSTATE_MASK_MAXIMIZED_HEIGHT;
603*cdf0e10cSrcweir         else
604*cdf0e10cSrcweir             rData.SetMaximizedHeight( 0 );
605*cdf0e10cSrcweir     }
606*cdf0e10cSrcweir     else
607*cdf0e10cSrcweir         rData.SetMaximizedHeight( 0 );
608*cdf0e10cSrcweir 
609*cdf0e10cSrcweir     // mark valid fields
610*cdf0e10cSrcweir     rData.SetMask( nValidMask );
611*cdf0e10cSrcweir }
612*cdf0e10cSrcweir 
613*cdf0e10cSrcweir // -----------------------------------------------------------------------
614*cdf0e10cSrcweir 
615*cdf0e10cSrcweir static void ImplWindowStateToStr( const WindowStateData& rData, ByteString& rStr )
616*cdf0e10cSrcweir {
617*cdf0e10cSrcweir     sal_uLong nValidMask = rData.GetMask();
618*cdf0e10cSrcweir     if ( !nValidMask )
619*cdf0e10cSrcweir         return;
620*cdf0e10cSrcweir 
621*cdf0e10cSrcweir     if ( nValidMask & WINDOWSTATE_MASK_X )
622*cdf0e10cSrcweir         rStr.Append( ByteString::CreateFromInt32( rData.GetX() ) );
623*cdf0e10cSrcweir     rStr.Append( ',' );
624*cdf0e10cSrcweir     if ( nValidMask & WINDOWSTATE_MASK_Y )
625*cdf0e10cSrcweir         rStr.Append( ByteString::CreateFromInt32( rData.GetY() ) );
626*cdf0e10cSrcweir     rStr.Append( ',' );
627*cdf0e10cSrcweir     if ( nValidMask & WINDOWSTATE_MASK_WIDTH )
628*cdf0e10cSrcweir         rStr.Append( ByteString::CreateFromInt32( rData.GetWidth() ) );
629*cdf0e10cSrcweir     rStr.Append( ',' );
630*cdf0e10cSrcweir     if ( nValidMask & WINDOWSTATE_MASK_HEIGHT )
631*cdf0e10cSrcweir         rStr.Append( ByteString::CreateFromInt32( rData.GetHeight() ) );
632*cdf0e10cSrcweir     rStr.Append( ';' );
633*cdf0e10cSrcweir     if ( nValidMask & WINDOWSTATE_MASK_STATE )
634*cdf0e10cSrcweir     {
635*cdf0e10cSrcweir         // #94144# allow Minimize again, should be masked out when read from configuration
636*cdf0e10cSrcweir         // 91625 - ignore Minimize
637*cdf0e10cSrcweir         sal_uLong nState = rData.GetState();
638*cdf0e10cSrcweir         //nState &= ~(WINDOWSTATE_STATE_MINIMIZED);
639*cdf0e10cSrcweir         rStr.Append( ByteString::CreateFromInt32( (long)nState ) );
640*cdf0e10cSrcweir     }
641*cdf0e10cSrcweir     rStr.Append( ';' );
642*cdf0e10cSrcweir     if ( nValidMask & WINDOWSTATE_MASK_MAXIMIZED_X )
643*cdf0e10cSrcweir         rStr.Append( ByteString::CreateFromInt32( rData.GetMaximizedX() ) );
644*cdf0e10cSrcweir     rStr.Append( ',' );
645*cdf0e10cSrcweir     if ( nValidMask & WINDOWSTATE_MASK_MAXIMIZED_Y )
646*cdf0e10cSrcweir         rStr.Append( ByteString::CreateFromInt32( rData.GetMaximizedY() ) );
647*cdf0e10cSrcweir     rStr.Append( ',' );
648*cdf0e10cSrcweir     if ( nValidMask & WINDOWSTATE_MASK_MAXIMIZED_WIDTH )
649*cdf0e10cSrcweir         rStr.Append( ByteString::CreateFromInt32( rData.GetMaximizedWidth() ) );
650*cdf0e10cSrcweir     rStr.Append( ',' );
651*cdf0e10cSrcweir     if ( nValidMask & WINDOWSTATE_MASK_MAXIMIZED_HEIGHT )
652*cdf0e10cSrcweir         rStr.Append( ByteString::CreateFromInt32( rData.GetMaximizedHeight() ) );
653*cdf0e10cSrcweir     rStr.Append( ';' );
654*cdf0e10cSrcweir }
655*cdf0e10cSrcweir 
656*cdf0e10cSrcweir // -----------------------------------------------------------------------
657*cdf0e10cSrcweir 
658*cdf0e10cSrcweir void SystemWindow::ImplMoveToScreen( long& io_rX, long& io_rY, long i_nWidth, long i_nHeight, Window* i_pConfigureWin )
659*cdf0e10cSrcweir {
660*cdf0e10cSrcweir     Rectangle aScreenRect;
661*cdf0e10cSrcweir     if( Application::IsMultiDisplay() )
662*cdf0e10cSrcweir     {
663*cdf0e10cSrcweir         aScreenRect = Application::GetScreenPosSizePixel( GetScreenNumber() );
664*cdf0e10cSrcweir     }
665*cdf0e10cSrcweir     else
666*cdf0e10cSrcweir     {
667*cdf0e10cSrcweir         aScreenRect = Application::GetScreenPosSizePixel( 0 );
668*cdf0e10cSrcweir         for( unsigned int i = 1; i < Application::GetScreenCount(); i++ )
669*cdf0e10cSrcweir             aScreenRect.Union( Application::GetScreenPosSizePixel( i ) );
670*cdf0e10cSrcweir     }
671*cdf0e10cSrcweir     // unfortunately most of the time width and height are not really known
672*cdf0e10cSrcweir     if( i_nWidth < 1 )
673*cdf0e10cSrcweir         i_nWidth = 50;
674*cdf0e10cSrcweir     if( i_nHeight < 1 )
675*cdf0e10cSrcweir         i_nHeight = 50;
676*cdf0e10cSrcweir 
677*cdf0e10cSrcweir     // check left border
678*cdf0e10cSrcweir     bool bMove = false;
679*cdf0e10cSrcweir     if( io_rX + i_nWidth < aScreenRect.Left() )
680*cdf0e10cSrcweir     {
681*cdf0e10cSrcweir         bMove = true;
682*cdf0e10cSrcweir         io_rX = aScreenRect.Left();
683*cdf0e10cSrcweir     }
684*cdf0e10cSrcweir     // check right border
685*cdf0e10cSrcweir     if( io_rX > aScreenRect.Right() - i_nWidth )
686*cdf0e10cSrcweir     {
687*cdf0e10cSrcweir         bMove = true;
688*cdf0e10cSrcweir         io_rX = aScreenRect.Right() - i_nWidth;
689*cdf0e10cSrcweir     }
690*cdf0e10cSrcweir     // check top border
691*cdf0e10cSrcweir     if( io_rY + i_nHeight < aScreenRect.Top() )
692*cdf0e10cSrcweir     {
693*cdf0e10cSrcweir         bMove = true;
694*cdf0e10cSrcweir         io_rY = aScreenRect.Top();
695*cdf0e10cSrcweir     }
696*cdf0e10cSrcweir     // check bottom border
697*cdf0e10cSrcweir     if( io_rY > aScreenRect.Bottom() - i_nHeight )
698*cdf0e10cSrcweir     {
699*cdf0e10cSrcweir         bMove = true;
700*cdf0e10cSrcweir         io_rY = aScreenRect.Bottom() - i_nHeight;
701*cdf0e10cSrcweir     }
702*cdf0e10cSrcweir     Window* pParent = i_pConfigureWin->GetParent();
703*cdf0e10cSrcweir     if( bMove && pParent )
704*cdf0e10cSrcweir     {
705*cdf0e10cSrcweir         // calculate absolute screen pos here, since that is what is contained in WindowState
706*cdf0e10cSrcweir         Point aParentAbsPos( pParent->OutputToAbsoluteScreenPixel( Point(0,0) ) );
707*cdf0e10cSrcweir         Size aParentSizePixel( pParent->GetOutputSizePixel() );
708*cdf0e10cSrcweir         Point aPos( (aParentSizePixel.Width() - i_nWidth) / 2,
709*cdf0e10cSrcweir                     (aParentSizePixel.Height() - i_nHeight) / 2 );
710*cdf0e10cSrcweir         io_rX = aParentAbsPos.X() + aPos.X();
711*cdf0e10cSrcweir         io_rY = aParentAbsPos.Y() + aPos.Y();
712*cdf0e10cSrcweir     }
713*cdf0e10cSrcweir }
714*cdf0e10cSrcweir 
715*cdf0e10cSrcweir void SystemWindow::SetWindowStateData( const WindowStateData& rData )
716*cdf0e10cSrcweir {
717*cdf0e10cSrcweir     sal_uLong nValidMask = rData.GetMask();
718*cdf0e10cSrcweir     if ( !nValidMask )
719*cdf0e10cSrcweir         return;
720*cdf0e10cSrcweir 
721*cdf0e10cSrcweir     if ( mbSysChild )
722*cdf0e10cSrcweir         return;
723*cdf0e10cSrcweir 
724*cdf0e10cSrcweir     Window* pWindow = this;
725*cdf0e10cSrcweir     while ( pWindow->mpWindowImpl->mpBorderWindow )
726*cdf0e10cSrcweir         pWindow = pWindow->mpWindowImpl->mpBorderWindow;
727*cdf0e10cSrcweir 
728*cdf0e10cSrcweir     if ( pWindow->mpWindowImpl->mbFrame )
729*cdf0e10cSrcweir     {
730*cdf0e10cSrcweir         sal_uLong           nState      = rData.GetState();
731*cdf0e10cSrcweir         SalFrameState   aState;
732*cdf0e10cSrcweir         aState.mnMask               = rData.GetMask();
733*cdf0e10cSrcweir         aState.mnX                  = rData.GetX();
734*cdf0e10cSrcweir         aState.mnY                  = rData.GetY();
735*cdf0e10cSrcweir         aState.mnWidth              = rData.GetWidth();
736*cdf0e10cSrcweir         aState.mnHeight             = rData.GetHeight();
737*cdf0e10cSrcweir 
738*cdf0e10cSrcweir         if( rData.GetMask() & (WINDOWSTATE_MASK_WIDTH|WINDOWSTATE_MASK_HEIGHT) )
739*cdf0e10cSrcweir         {
740*cdf0e10cSrcweir             // #i43799# adjust window state sizes if a minimial output size was set
741*cdf0e10cSrcweir             // otherwise the frame and the client might get different sizes
742*cdf0e10cSrcweir             if( maMinOutSize.Width() > aState.mnWidth )
743*cdf0e10cSrcweir                 aState.mnWidth = maMinOutSize.Width();
744*cdf0e10cSrcweir             if( maMinOutSize.Height() > aState.mnHeight )
745*cdf0e10cSrcweir                 aState.mnHeight = maMinOutSize.Height();
746*cdf0e10cSrcweir         }
747*cdf0e10cSrcweir 
748*cdf0e10cSrcweir         aState.mnMaximizedX         = rData.GetMaximizedX();
749*cdf0e10cSrcweir         aState.mnMaximizedY         = rData.GetMaximizedY();
750*cdf0e10cSrcweir         aState.mnMaximizedWidth     = rData.GetMaximizedWidth();
751*cdf0e10cSrcweir         aState.mnMaximizedHeight    = rData.GetMaximizedHeight();
752*cdf0e10cSrcweir         // #94144# allow Minimize again, should be masked out when read from configuration
753*cdf0e10cSrcweir         // 91625 - ignore Minimize
754*cdf0e10cSrcweir         //nState &= ~(WINDOWSTATE_STATE_MINIMIZED);
755*cdf0e10cSrcweir         aState.mnState  = nState & SAL_FRAMESTATE_SYSTEMMASK;
756*cdf0e10cSrcweir 
757*cdf0e10cSrcweir         // normalize window positions onto screen
758*cdf0e10cSrcweir         ImplMoveToScreen( aState.mnX, aState.mnY, aState.mnWidth, aState.mnHeight, pWindow );
759*cdf0e10cSrcweir         ImplMoveToScreen( aState.mnMaximizedX, aState.mnMaximizedY, aState.mnMaximizedWidth, aState.mnMaximizedHeight, pWindow );
760*cdf0e10cSrcweir 
761*cdf0e10cSrcweir         // #96568# avoid having multiple frames at the same screen location
762*cdf0e10cSrcweir         //  do the check only if not maximized
763*cdf0e10cSrcweir         if( !((rData.GetMask() & WINDOWSTATE_MASK_STATE) && (nState & WINDOWSTATE_STATE_MAXIMIZED)) )
764*cdf0e10cSrcweir             if( rData.GetMask() & (WINDOWSTATE_MASK_POS|WINDOWSTATE_MASK_WIDTH|WINDOWSTATE_MASK_HEIGHT) )
765*cdf0e10cSrcweir             {
766*cdf0e10cSrcweir                 Rectangle aDesktop = GetDesktopRectPixel();
767*cdf0e10cSrcweir                 ImplSVData *pSVData = ImplGetSVData();
768*cdf0e10cSrcweir                 Window *pWin = pSVData->maWinData.mpFirstFrame;
769*cdf0e10cSrcweir                 sal_Bool bWrapped = sal_False;
770*cdf0e10cSrcweir                 while( pWin )
771*cdf0e10cSrcweir                 {
772*cdf0e10cSrcweir                     if( !pWin->ImplIsRealParentPath( this ) && ( pWin != this ) &&
773*cdf0e10cSrcweir                         pWin->ImplGetWindow()->IsTopWindow() && pWin->mpWindowImpl->mbReallyVisible )
774*cdf0e10cSrcweir                     {
775*cdf0e10cSrcweir                         SalFrameGeometry g = pWin->mpWindowImpl->mpFrame->GetGeometry();
776*cdf0e10cSrcweir                         if( abs(g.nX-aState.mnX) < 2 && abs(g.nY-aState.mnY) < 5 )
777*cdf0e10cSrcweir                         {
778*cdf0e10cSrcweir                             long displacement = g.nTopDecoration ? g.nTopDecoration : 20;
779*cdf0e10cSrcweir                             if( (unsigned long) (aState.mnX + displacement + aState.mnWidth + g.nRightDecoration) > (unsigned long) aDesktop.nRight ||
780*cdf0e10cSrcweir                                 (unsigned long) (aState.mnY + displacement + aState.mnHeight + g.nBottomDecoration) > (unsigned long) aDesktop.nBottom )
781*cdf0e10cSrcweir                             {
782*cdf0e10cSrcweir                                 // displacing would leave screen
783*cdf0e10cSrcweir                                 aState.mnX = g.nLeftDecoration ? g.nLeftDecoration : 10; // should result in (0,0)
784*cdf0e10cSrcweir                                 aState.mnY = displacement;
785*cdf0e10cSrcweir                                 if( bWrapped ||
786*cdf0e10cSrcweir                                     (unsigned long) (aState.mnX + displacement + aState.mnWidth + g.nRightDecoration) > (unsigned long) aDesktop.nRight ||
787*cdf0e10cSrcweir                                     (unsigned long) (aState.mnY + displacement + aState.mnHeight + g.nBottomDecoration) > (unsigned long) aDesktop.nBottom )
788*cdf0e10cSrcweir                                     break;  // further displacement not possible -> break
789*cdf0e10cSrcweir                                 // avoid endless testing
790*cdf0e10cSrcweir                                 bWrapped = sal_True;
791*cdf0e10cSrcweir                             }
792*cdf0e10cSrcweir                             else
793*cdf0e10cSrcweir                             {
794*cdf0e10cSrcweir                                 // displace
795*cdf0e10cSrcweir                                 aState.mnX += displacement;
796*cdf0e10cSrcweir                                 aState.mnY += displacement;
797*cdf0e10cSrcweir                             }
798*cdf0e10cSrcweir                         pWin = pSVData->maWinData.mpFirstFrame; // check new pos again
799*cdf0e10cSrcweir                         }
800*cdf0e10cSrcweir                     }
801*cdf0e10cSrcweir                     pWin = pWin->mpWindowImpl->mpFrameData->mpNextFrame;
802*cdf0e10cSrcweir                 }
803*cdf0e10cSrcweir             }
804*cdf0e10cSrcweir 
805*cdf0e10cSrcweir         mpWindowImpl->mpFrame->SetWindowState( &aState );
806*cdf0e10cSrcweir 
807*cdf0e10cSrcweir         // do a synchronous resize for layout reasons
808*cdf0e10cSrcweir         //  but use rData only when the window is not to be maximized (#i38089#)
809*cdf0e10cSrcweir         //  otherwise we have no useful size information
810*cdf0e10cSrcweir         if( (rData.GetMask() & WINDOWSTATE_MASK_STATE) && (nState & WINDOWSTATE_STATE_MAXIMIZED) )
811*cdf0e10cSrcweir         {
812*cdf0e10cSrcweir             // query maximized size from frame
813*cdf0e10cSrcweir             SalFrameGeometry aGeometry = mpWindowImpl->mpFrame->GetGeometry();
814*cdf0e10cSrcweir 
815*cdf0e10cSrcweir             // but use it only if it is different from the restore size (rData)
816*cdf0e10cSrcweir             // as currently only on windows the exact size of a maximized window
817*cdf0e10cSrcweir             //  can be computed without actually showing the window
818*cdf0e10cSrcweir             if( aGeometry.nWidth != rData.GetWidth() || aGeometry.nHeight != rData.GetHeight() )
819*cdf0e10cSrcweir                 ImplHandleResize( pWindow, aGeometry.nWidth, aGeometry.nHeight );
820*cdf0e10cSrcweir         }
821*cdf0e10cSrcweir         else
822*cdf0e10cSrcweir             if( rData.GetMask() & (WINDOWSTATE_MASK_WIDTH|WINDOWSTATE_MASK_HEIGHT) )
823*cdf0e10cSrcweir                 ImplHandleResize( pWindow, aState.mnWidth, aState.mnHeight );   // #i43799# use aState and not rData, see above
824*cdf0e10cSrcweir     }
825*cdf0e10cSrcweir     else
826*cdf0e10cSrcweir     {
827*cdf0e10cSrcweir         sal_uInt16 nPosSize = 0;
828*cdf0e10cSrcweir         if ( nValidMask & WINDOWSTATE_MASK_X )
829*cdf0e10cSrcweir             nPosSize |= WINDOW_POSSIZE_X;
830*cdf0e10cSrcweir         if ( nValidMask & WINDOWSTATE_MASK_Y )
831*cdf0e10cSrcweir             nPosSize |= WINDOW_POSSIZE_Y;
832*cdf0e10cSrcweir         if ( nValidMask & WINDOWSTATE_MASK_WIDTH )
833*cdf0e10cSrcweir             nPosSize |= WINDOW_POSSIZE_WIDTH;
834*cdf0e10cSrcweir         if ( nValidMask & WINDOWSTATE_MASK_HEIGHT )
835*cdf0e10cSrcweir             nPosSize |= WINDOW_POSSIZE_HEIGHT;
836*cdf0e10cSrcweir 
837*cdf0e10cSrcweir         if( IsRollUp() )
838*cdf0e10cSrcweir             RollDown();
839*cdf0e10cSrcweir 
840*cdf0e10cSrcweir         long nX			= rData.GetX();
841*cdf0e10cSrcweir         long nY			= rData.GetY();
842*cdf0e10cSrcweir         long nWidth		= rData.GetWidth();
843*cdf0e10cSrcweir         long nHeight	= rData.GetHeight();
844*cdf0e10cSrcweir         const SalFrameGeometry& rGeom = pWindow->mpWindowImpl->mpFrame->GetGeometry();
845*cdf0e10cSrcweir         if( nX < 0 )
846*cdf0e10cSrcweir             nX = 0;
847*cdf0e10cSrcweir         if( nX + nWidth > (long) rGeom.nWidth )
848*cdf0e10cSrcweir             nX = rGeom.nWidth - nWidth;
849*cdf0e10cSrcweir         if( nY < 0 )
850*cdf0e10cSrcweir             nY = 0;
851*cdf0e10cSrcweir         if( nY + nHeight > (long) rGeom.nHeight )
852*cdf0e10cSrcweir             nY = rGeom.nHeight - nHeight;
853*cdf0e10cSrcweir         SetPosSizePixel( nX, nY, nWidth, nHeight, nPosSize );
854*cdf0e10cSrcweir         maOrgSize = Size( nWidth, nHeight );
855*cdf0e10cSrcweir 
856*cdf0e10cSrcweir         // 91625 - ignore Minimize
857*cdf0e10cSrcweir         if ( nValidMask & WINDOWSTATE_MASK_STATE )
858*cdf0e10cSrcweir         {
859*cdf0e10cSrcweir             sal_uLong nState = rData.GetState();
860*cdf0e10cSrcweir             if ( nState & WINDOWSTATE_STATE_ROLLUP )
861*cdf0e10cSrcweir                 RollUp();
862*cdf0e10cSrcweir             else
863*cdf0e10cSrcweir                 RollDown();
864*cdf0e10cSrcweir         }
865*cdf0e10cSrcweir     }
866*cdf0e10cSrcweir }
867*cdf0e10cSrcweir 
868*cdf0e10cSrcweir // -----------------------------------------------------------------------
869*cdf0e10cSrcweir 
870*cdf0e10cSrcweir void SystemWindow::GetWindowStateData( WindowStateData& rData ) const
871*cdf0e10cSrcweir {
872*cdf0e10cSrcweir     sal_uLong nValidMask = rData.GetMask();
873*cdf0e10cSrcweir     if ( !nValidMask )
874*cdf0e10cSrcweir         return;
875*cdf0e10cSrcweir 
876*cdf0e10cSrcweir     if ( mbSysChild )
877*cdf0e10cSrcweir         return;
878*cdf0e10cSrcweir 
879*cdf0e10cSrcweir     const Window* pWindow = this;
880*cdf0e10cSrcweir     while ( pWindow->mpWindowImpl->mpBorderWindow )
881*cdf0e10cSrcweir         pWindow = pWindow->mpWindowImpl->mpBorderWindow;
882*cdf0e10cSrcweir 
883*cdf0e10cSrcweir     if ( pWindow->mpWindowImpl->mbFrame )
884*cdf0e10cSrcweir     {
885*cdf0e10cSrcweir         SalFrameState aState;
886*cdf0e10cSrcweir         aState.mnMask = 0xFFFFFFFF;
887*cdf0e10cSrcweir         if ( mpWindowImpl->mpFrame->GetWindowState( &aState ) )
888*cdf0e10cSrcweir         {
889*cdf0e10cSrcweir             if ( nValidMask & WINDOWSTATE_MASK_X )
890*cdf0e10cSrcweir                 rData.SetX( aState.mnX );
891*cdf0e10cSrcweir             if ( nValidMask & WINDOWSTATE_MASK_Y )
892*cdf0e10cSrcweir                 rData.SetY( aState.mnY );
893*cdf0e10cSrcweir             if ( nValidMask & WINDOWSTATE_MASK_WIDTH )
894*cdf0e10cSrcweir                 rData.SetWidth( aState.mnWidth );
895*cdf0e10cSrcweir             if ( nValidMask & WINDOWSTATE_MASK_HEIGHT )
896*cdf0e10cSrcweir                 rData.SetHeight( aState.mnHeight );
897*cdf0e10cSrcweir             if ( aState.mnMask & SAL_FRAMESTATE_MASK_MAXIMIZED_X )
898*cdf0e10cSrcweir             {
899*cdf0e10cSrcweir                 rData.SetMaximizedX( aState.mnMaximizedX );
900*cdf0e10cSrcweir                 nValidMask |= WINDOWSTATE_MASK_MAXIMIZED_X;
901*cdf0e10cSrcweir             }
902*cdf0e10cSrcweir             if ( aState.mnMask & SAL_FRAMESTATE_MASK_MAXIMIZED_Y )
903*cdf0e10cSrcweir             {
904*cdf0e10cSrcweir                 rData.SetMaximizedY( aState.mnMaximizedY );
905*cdf0e10cSrcweir                 nValidMask |= WINDOWSTATE_MASK_MAXIMIZED_Y;
906*cdf0e10cSrcweir             }
907*cdf0e10cSrcweir             if ( aState.mnMask & SAL_FRAMESTATE_MASK_MAXIMIZED_WIDTH )
908*cdf0e10cSrcweir             {
909*cdf0e10cSrcweir                 rData.SetMaximizedWidth( aState.mnMaximizedWidth );
910*cdf0e10cSrcweir                 nValidMask |= WINDOWSTATE_MASK_MAXIMIZED_WIDTH;
911*cdf0e10cSrcweir             }
912*cdf0e10cSrcweir             if ( aState.mnMask & SAL_FRAMESTATE_MASK_MAXIMIZED_HEIGHT )
913*cdf0e10cSrcweir             {
914*cdf0e10cSrcweir                 rData.SetMaximizedHeight( aState.mnMaximizedHeight );
915*cdf0e10cSrcweir                 nValidMask |= WINDOWSTATE_MASK_MAXIMIZED_HEIGHT;
916*cdf0e10cSrcweir             }
917*cdf0e10cSrcweir             if ( nValidMask & WINDOWSTATE_MASK_STATE )
918*cdf0e10cSrcweir             {
919*cdf0e10cSrcweir                 // #94144# allow Minimize again, should be masked out when read from configuration
920*cdf0e10cSrcweir                 // 91625 - ignore Minimize
921*cdf0e10cSrcweir 				if ( !(nValidMask&WINDOWSTATE_MASK_MINIMIZED) )
922*cdf0e10cSrcweir                 	aState.mnState &= ~(WINDOWSTATE_STATE_MINIMIZED);
923*cdf0e10cSrcweir                 rData.SetState( aState.mnState );
924*cdf0e10cSrcweir             }
925*cdf0e10cSrcweir             rData.SetMask( nValidMask );
926*cdf0e10cSrcweir         }
927*cdf0e10cSrcweir         else
928*cdf0e10cSrcweir             rData.SetMask( 0 );
929*cdf0e10cSrcweir     }
930*cdf0e10cSrcweir     else
931*cdf0e10cSrcweir     {
932*cdf0e10cSrcweir         Point   aPos = GetPosPixel();
933*cdf0e10cSrcweir         Size    aSize = GetSizePixel();
934*cdf0e10cSrcweir         sal_uLong   nState = 0;
935*cdf0e10cSrcweir 
936*cdf0e10cSrcweir         if ( IsRollUp() )
937*cdf0e10cSrcweir         {
938*cdf0e10cSrcweir             aSize.Height() += maOrgSize.Height();
939*cdf0e10cSrcweir             nState |= WINDOWSTATE_STATE_ROLLUP;
940*cdf0e10cSrcweir         }
941*cdf0e10cSrcweir 
942*cdf0e10cSrcweir         if ( nValidMask & WINDOWSTATE_MASK_X )
943*cdf0e10cSrcweir             rData.SetX( aPos.X() );
944*cdf0e10cSrcweir         if ( nValidMask & WINDOWSTATE_MASK_Y )
945*cdf0e10cSrcweir             rData.SetY( aPos.Y() );
946*cdf0e10cSrcweir         if ( nValidMask & WINDOWSTATE_MASK_WIDTH )
947*cdf0e10cSrcweir             rData.SetWidth( aSize.Width() );
948*cdf0e10cSrcweir         if ( nValidMask & WINDOWSTATE_MASK_HEIGHT )
949*cdf0e10cSrcweir             rData.SetHeight( aSize.Height() );
950*cdf0e10cSrcweir         if ( nValidMask & WINDOWSTATE_MASK_STATE )
951*cdf0e10cSrcweir             rData.SetState( nState );
952*cdf0e10cSrcweir     }
953*cdf0e10cSrcweir }
954*cdf0e10cSrcweir 
955*cdf0e10cSrcweir // -----------------------------------------------------------------------
956*cdf0e10cSrcweir 
957*cdf0e10cSrcweir void SystemWindow::SetWindowState( const ByteString& rStr )
958*cdf0e10cSrcweir {
959*cdf0e10cSrcweir     if ( !rStr.Len() )
960*cdf0e10cSrcweir         return;
961*cdf0e10cSrcweir 
962*cdf0e10cSrcweir     WindowStateData aData;
963*cdf0e10cSrcweir     ImplWindowStateFromStr( aData, rStr );
964*cdf0e10cSrcweir     SetWindowStateData( aData );
965*cdf0e10cSrcweir }
966*cdf0e10cSrcweir 
967*cdf0e10cSrcweir // -----------------------------------------------------------------------
968*cdf0e10cSrcweir 
969*cdf0e10cSrcweir ByteString SystemWindow::GetWindowState( sal_uLong nMask ) const
970*cdf0e10cSrcweir {
971*cdf0e10cSrcweir     WindowStateData aData;
972*cdf0e10cSrcweir     aData.SetMask( nMask );
973*cdf0e10cSrcweir     GetWindowStateData( aData );
974*cdf0e10cSrcweir 
975*cdf0e10cSrcweir     ByteString aStr;
976*cdf0e10cSrcweir     ImplWindowStateToStr( aData, aStr );
977*cdf0e10cSrcweir     return aStr;
978*cdf0e10cSrcweir }
979*cdf0e10cSrcweir 
980*cdf0e10cSrcweir // -----------------------------------------------------------------------
981*cdf0e10cSrcweir 
982*cdf0e10cSrcweir void SystemWindow::SetMenuBar( MenuBar* pMenuBar )
983*cdf0e10cSrcweir {
984*cdf0e10cSrcweir     if ( mpMenuBar != pMenuBar )
985*cdf0e10cSrcweir     {
986*cdf0e10cSrcweir         MenuBar* pOldMenuBar = mpMenuBar;
987*cdf0e10cSrcweir         Window*  pOldWindow = NULL;
988*cdf0e10cSrcweir         Window*  pNewWindow=NULL;
989*cdf0e10cSrcweir         mpMenuBar = pMenuBar;
990*cdf0e10cSrcweir 
991*cdf0e10cSrcweir         if ( mpWindowImpl->mpBorderWindow && (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) )
992*cdf0e10cSrcweir         {
993*cdf0e10cSrcweir             if ( pOldMenuBar )
994*cdf0e10cSrcweir                 pOldWindow = pOldMenuBar->ImplGetWindow();
995*cdf0e10cSrcweir             else
996*cdf0e10cSrcweir                 pOldWindow = NULL;
997*cdf0e10cSrcweir 			if ( pOldWindow )
998*cdf0e10cSrcweir 			{
999*cdf0e10cSrcweir 				ImplCallEventListeners( VCLEVENT_WINDOW_MENUBARREMOVED, (void*) pOldMenuBar );
1000*cdf0e10cSrcweir 				pOldWindow->SetAccessible( ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >() );
1001*cdf0e10cSrcweir 			}
1002*cdf0e10cSrcweir             if ( pMenuBar )
1003*cdf0e10cSrcweir             {
1004*cdf0e10cSrcweir                 DBG_ASSERT( !pMenuBar->pWindow, "SystemWindow::SetMenuBar() - MenuBars can only set in one SystemWindow at time" );
1005*cdf0e10cSrcweir                 ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->SetMenuBarWindow( pNewWindow = MenuBar::ImplCreate( mpWindowImpl->mpBorderWindow, pOldWindow, pMenuBar ) );
1006*cdf0e10cSrcweir 				ImplCallEventListeners( VCLEVENT_WINDOW_MENUBARADDED, (void*) pMenuBar );
1007*cdf0e10cSrcweir 			}
1008*cdf0e10cSrcweir             else
1009*cdf0e10cSrcweir                 ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->SetMenuBarWindow( NULL );
1010*cdf0e10cSrcweir             ImplToBottomChild();
1011*cdf0e10cSrcweir             if ( pOldMenuBar )
1012*cdf0e10cSrcweir             {
1013*cdf0e10cSrcweir                 sal_Bool bDelete = (pMenuBar == 0) ? sal_True : sal_False;
1014*cdf0e10cSrcweir                 if( bDelete && pOldWindow )
1015*cdf0e10cSrcweir                 {
1016*cdf0e10cSrcweir                     if( mpImplData->mpTaskPaneList )
1017*cdf0e10cSrcweir                         mpImplData->mpTaskPaneList->RemoveWindow( pOldWindow );
1018*cdf0e10cSrcweir                 }
1019*cdf0e10cSrcweir                 MenuBar::ImplDestroy( pOldMenuBar, bDelete );
1020*cdf0e10cSrcweir                 if( bDelete )
1021*cdf0e10cSrcweir                     pOldWindow = NULL;  // will be deleted in MenuBar::ImplDestroy,
1022*cdf0e10cSrcweir             }
1023*cdf0e10cSrcweir 
1024*cdf0e10cSrcweir         }
1025*cdf0e10cSrcweir         else
1026*cdf0e10cSrcweir         {
1027*cdf0e10cSrcweir             if( pMenuBar )
1028*cdf0e10cSrcweir                 pNewWindow = pMenuBar->ImplGetWindow();
1029*cdf0e10cSrcweir             if( pOldMenuBar )
1030*cdf0e10cSrcweir                 pOldWindow = pOldMenuBar->ImplGetWindow();
1031*cdf0e10cSrcweir         }
1032*cdf0e10cSrcweir 
1033*cdf0e10cSrcweir         // update taskpane list to make menubar accessible
1034*cdf0e10cSrcweir         if( mpImplData->mpTaskPaneList )
1035*cdf0e10cSrcweir         {
1036*cdf0e10cSrcweir             if( pOldWindow )
1037*cdf0e10cSrcweir                 mpImplData->mpTaskPaneList->RemoveWindow( pOldWindow );
1038*cdf0e10cSrcweir             if( pNewWindow )
1039*cdf0e10cSrcweir                 mpImplData->mpTaskPaneList->AddWindow( pNewWindow );
1040*cdf0e10cSrcweir         }
1041*cdf0e10cSrcweir     }
1042*cdf0e10cSrcweir }
1043*cdf0e10cSrcweir 
1044*cdf0e10cSrcweir // -----------------------------------------------------------------------
1045*cdf0e10cSrcweir 
1046*cdf0e10cSrcweir void SystemWindow::SetMenuBarMode( sal_uInt16 nMode )
1047*cdf0e10cSrcweir {
1048*cdf0e10cSrcweir     if ( mnMenuBarMode != nMode )
1049*cdf0e10cSrcweir     {
1050*cdf0e10cSrcweir         mnMenuBarMode = nMode;
1051*cdf0e10cSrcweir         if ( mpWindowImpl->mpBorderWindow && (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) )
1052*cdf0e10cSrcweir         {
1053*cdf0e10cSrcweir             if ( nMode == MENUBAR_MODE_HIDE )
1054*cdf0e10cSrcweir                 ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->SetMenuBarMode( sal_True );
1055*cdf0e10cSrcweir             else
1056*cdf0e10cSrcweir                 ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->SetMenuBarMode( sal_False );
1057*cdf0e10cSrcweir         }
1058*cdf0e10cSrcweir     }
1059*cdf0e10cSrcweir }
1060*cdf0e10cSrcweir 
1061*cdf0e10cSrcweir // -----------------------------------------------------------------------
1062*cdf0e10cSrcweir 
1063*cdf0e10cSrcweir sal_Bool SystemWindow::ImplIsInTaskPaneList( Window* pWin )
1064*cdf0e10cSrcweir {
1065*cdf0e10cSrcweir     if( mpImplData && mpImplData->mpTaskPaneList )
1066*cdf0e10cSrcweir         return mpImplData->mpTaskPaneList->IsInList( pWin );
1067*cdf0e10cSrcweir     return sal_False;
1068*cdf0e10cSrcweir }
1069*cdf0e10cSrcweir 
1070*cdf0e10cSrcweir // -----------------------------------------------------------------------
1071*cdf0e10cSrcweir 
1072*cdf0e10cSrcweir unsigned int SystemWindow::GetScreenNumber() const
1073*cdf0e10cSrcweir {
1074*cdf0e10cSrcweir     return mpWindowImpl->mpFrame->maGeometry.nScreenNumber;
1075*cdf0e10cSrcweir }
1076*cdf0e10cSrcweir 
1077*cdf0e10cSrcweir // -----------------------------------------------------------------------
1078*cdf0e10cSrcweir 
1079*cdf0e10cSrcweir void SystemWindow::SetScreenNumber( unsigned int nScreen)
1080*cdf0e10cSrcweir {
1081*cdf0e10cSrcweir     mpWindowImpl->mpFrame->SetScreenNumber( nScreen );
1082*cdf0e10cSrcweir }
1083