1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: syswin.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
33 #include <tools/debug.hxx>
38 #include <vcl/salframe.hxx>
39 #include <vcl/svdata.hxx>
40 #include <vcl/svapp.hxx>
41 #include <vcl/brdwin.hxx>
42 #include <vcl/menu.hxx>
43 #include <vcl/window.h>
44 #include <vcl/brdwin.hxx>
45 #include <vcl/sound.hxx>
46 #include <vcl/svapp.hxx>
47 #include <vcl/event.hxx>
48 #include <vcl/syswin.hxx>
49 #include <vcl/taskpanelist.hxx>
50 #include <vcl/unowrap.hxx>
53 using namespace ::com::sun::star::uno
;
54 using namespace ::com::sun::star::lang
;
56 // =======================================================================
57 class SystemWindow::ImplData
63 TaskPaneList
* mpTaskPaneList
;
67 SystemWindow::ImplData::ImplData()
69 mpTaskPaneList
= NULL
;
70 maMaxOutSize
= Size( SHRT_MAX
, SHRT_MAX
);
73 SystemWindow::ImplData::~ImplData()
76 delete mpTaskPaneList
;
79 // =======================================================================
81 SystemWindow::SystemWindow( WindowType nType
) :
84 mpImplData
= new ImplData
;
85 mpWindowImpl
->mbSysWin
= TRUE
;
86 mpWindowImpl
->mnActivateMode
= ACTIVATE_MODE_GRABFOCUS
;
95 mnMenuBarMode
= MENUBAR_MODE_NORMAL
;
99 SystemWindow::~SystemWindow()
105 // -----------------------------------------------------------------------
107 long SystemWindow::Notify( NotifyEvent
& rNEvt
)
109 // capture KeyEvents for menu handling
110 if ( rNEvt
.GetType() == EVENT_KEYINPUT
)
112 MenuBar
* pMBar
= mpMenuBar
;
113 if ( !pMBar
&& ( GetType() == WINDOW_FLOATINGWINDOW
) )
115 Window
* pWin
= ImplGetFrameWindow()->ImplGetWindow();
116 if( pWin
&& pWin
->IsSystemWindow() )
117 pMBar
= ((SystemWindow
*)pWin
)->GetMenuBar();
119 if ( pMBar
&& pMBar
->ImplHandleKeyEvent( *rNEvt
.GetKeyEvent(), FALSE
) )
123 return Window::Notify( rNEvt
);
126 // -----------------------------------------------------------------------
128 long SystemWindow::PreNotify( NotifyEvent
& rNEvt
)
130 // capture KeyEvents for taskpane cycling
131 if ( rNEvt
.GetType() == EVENT_KEYINPUT
)
133 if( rNEvt
.GetKeyEvent()->GetKeyCode().GetCode() == KEY_F6
&&
134 rNEvt
.GetKeyEvent()->GetKeyCode().IsMod1() &&
135 !rNEvt
.GetKeyEvent()->GetKeyCode().IsShift() )
137 // Ctrl-F6 goes directly to the document
138 GrabFocusToDocument();
143 TaskPaneList
*pTList
= mpImplData
->mpTaskPaneList
;
144 if( !pTList
&& ( GetType() == WINDOW_FLOATINGWINDOW
) )
146 Window
* pWin
= ImplGetFrameWindow()->ImplGetWindow();
147 if( pWin
&& pWin
->IsSystemWindow() )
148 pTList
= ((SystemWindow
*)pWin
)->mpImplData
->mpTaskPaneList
;
152 // search topmost system window which is the one to handle dialog/toolbar cycling
153 SystemWindow
*pSysWin
= this;
157 pWin
= pWin
->GetParent();
158 if( pWin
&& pWin
->IsSystemWindow() )
159 pSysWin
= (SystemWindow
*) pWin
;
161 pTList
= pSysWin
->mpImplData
->mpTaskPaneList
;
163 if( pTList
&& pTList
->HandleKeyEvent( *rNEvt
.GetKeyEvent() ) )
167 return Window::PreNotify( rNEvt
);
170 // -----------------------------------------------------------------------
172 TaskPaneList
* SystemWindow::GetTaskPaneList()
174 if( mpImplData
->mpTaskPaneList
)
175 return mpImplData
->mpTaskPaneList
;
178 mpImplData
->mpTaskPaneList
= new TaskPaneList();
179 MenuBar
* pMBar
= mpMenuBar
;
180 if ( !pMBar
&& ( GetType() == WINDOW_FLOATINGWINDOW
) )
182 Window
* pWin
= ImplGetFrameWindow()->ImplGetWindow();
183 if ( pWin
&& pWin
->IsSystemWindow() )
184 pMBar
= ((SystemWindow
*)pWin
)->GetMenuBar();
187 mpImplData
->mpTaskPaneList
->AddWindow( pMBar
->ImplGetWindow() );
188 return mpImplData
->mpTaskPaneList
;
192 // -----------------------------------------------------------------------
194 BOOL
SystemWindow::Close()
196 ImplDelData aDelData
;
197 ImplAddDel( &aDelData
);
198 ImplCallEventListeners( VCLEVENT_WINDOW_CLOSE
);
199 if ( aDelData
.IsDelete() )
201 ImplRemoveDel( &aDelData
);
203 if ( mpWindowImpl
->mxWindowPeer
.is() && IsCreatedWithToolkit() )
206 // Is Window not closeable, ignore close
207 Window
* pBorderWin
= ImplGetBorderWindow();
210 nStyle
= pBorderWin
->GetStyle();
213 if ( !(nStyle
& WB_CLOSEABLE
) )
215 Sound::Beep( SOUND_DISABLE
, this );
224 // -----------------------------------------------------------------------
226 void SystemWindow::TitleButtonClick( USHORT
)
230 // -----------------------------------------------------------------------
232 void SystemWindow::Pin()
236 // -----------------------------------------------------------------------
238 void SystemWindow::Roll()
242 // -----------------------------------------------------------------------
244 void SystemWindow::Resizing( Size
& )
248 // -----------------------------------------------------------------------
250 void SystemWindow::SetZLevel( BYTE nLevel
)
252 Window
* pWindow
= this;
253 while ( pWindow
->mpWindowImpl
->mpBorderWindow
)
254 pWindow
= pWindow
->mpWindowImpl
->mpBorderWindow
;
255 if ( pWindow
->mpWindowImpl
->mbOverlapWin
&& !pWindow
->mpWindowImpl
->mbFrame
)
257 BYTE nOldLevel
= pWindow
->mpWindowImpl
->mpOverlapData
->mnTopLevel
;
258 pWindow
->mpWindowImpl
->mpOverlapData
->mnTopLevel
= nLevel
;
259 // Wenn der neue Level groesser als der alte ist, schieben
260 // wir das Fenster nach hinten
261 if ( !IsReallyVisible() && (nLevel
> nOldLevel
) && pWindow
->mpWindowImpl
->mpNext
)
263 // Fenster aus der Liste entfernen
264 if ( pWindow
->mpWindowImpl
->mpPrev
)
265 pWindow
->mpWindowImpl
->mpPrev
->mpWindowImpl
->mpNext
= pWindow
->mpWindowImpl
->mpNext
;
267 pWindow
->mpWindowImpl
->mpOverlapWindow
->mpWindowImpl
->mpFirstOverlap
= pWindow
->mpWindowImpl
->mpNext
;
268 pWindow
->mpWindowImpl
->mpNext
->mpWindowImpl
->mpPrev
= pWindow
->mpWindowImpl
->mpPrev
;
269 pWindow
->mpWindowImpl
->mpNext
= NULL
;
270 // und Fenster wieder in die Liste am Ende eintragen
271 pWindow
->mpWindowImpl
->mpPrev
= pWindow
->mpWindowImpl
->mpOverlapWindow
->mpWindowImpl
->mpLastOverlap
;
272 pWindow
->mpWindowImpl
->mpOverlapWindow
->mpWindowImpl
->mpLastOverlap
= pWindow
;
273 pWindow
->mpWindowImpl
->mpPrev
->mpWindowImpl
->mpNext
= pWindow
;
278 // -----------------------------------------------------------------------
280 void SystemWindow::SetIcon( USHORT nIcon
)
282 if ( mnIcon
== nIcon
)
289 const Window
* pWindow
= this;
290 while ( pWindow
->mpWindowImpl
->mpBorderWindow
)
291 pWindow
= pWindow
->mpWindowImpl
->mpBorderWindow
;
293 if ( pWindow
->mpWindowImpl
->mbFrame
)
294 pWindow
->mpWindowImpl
->mpFrame
->SetIcon( nIcon
);
298 // -----------------------------------------------------------------------
300 BYTE
SystemWindow::GetZLevel() const
302 const Window
* pWindow
= this;
303 while ( pWindow
->mpWindowImpl
->mpBorderWindow
)
304 pWindow
= pWindow
->mpWindowImpl
->mpBorderWindow
;
305 if ( pWindow
->mpWindowImpl
->mpOverlapData
)
306 return pWindow
->mpWindowImpl
->mpOverlapData
->mnTopLevel
;
311 // -----------------------------------------------------------------------
313 void SystemWindow::EnableSaveBackground( BOOL bSave
)
315 if( ImplGetSVData()->maWinData
.mbNoSaveBackground
)
318 Window
* pWindow
= this;
319 while ( pWindow
->mpWindowImpl
->mpBorderWindow
)
320 pWindow
= pWindow
->mpWindowImpl
->mpBorderWindow
;
321 if ( pWindow
->mpWindowImpl
->mbOverlapWin
&& !pWindow
->mpWindowImpl
->mbFrame
)
323 pWindow
->mpWindowImpl
->mpOverlapData
->mbSaveBack
= bSave
;
325 pWindow
->ImplDeleteOverlapBackground();
329 // -----------------------------------------------------------------------
331 BOOL
SystemWindow::IsSaveBackgroundEnabled() const
333 const Window
* pWindow
= this;
334 while ( pWindow
->mpWindowImpl
->mpBorderWindow
)
335 pWindow
= pWindow
->mpWindowImpl
->mpBorderWindow
;
336 if ( pWindow
->mpWindowImpl
->mpOverlapData
)
337 return pWindow
->mpWindowImpl
->mpOverlapData
->mbSaveBack
;
342 // -----------------------------------------------------------------------
344 void SystemWindow::ShowTitleButton( USHORT nButton
, BOOL bVisible
)
346 if ( nButton
== TITLE_BUTTON_DOCKING
)
348 if ( mbDockBtn
!= bVisible
)
350 mbDockBtn
= bVisible
;
351 if ( mpWindowImpl
->mpBorderWindow
)
352 ((ImplBorderWindow
*)mpWindowImpl
->mpBorderWindow
)->SetDockButton( bVisible
);
355 else if ( nButton
== TITLE_BUTTON_HIDE
)
357 if ( mbHideBtn
!= bVisible
)
359 mbHideBtn
= bVisible
;
360 if ( mpWindowImpl
->mpBorderWindow
)
361 ((ImplBorderWindow
*)mpWindowImpl
->mpBorderWindow
)->SetHideButton( bVisible
);
364 else if ( nButton
== TITLE_BUTTON_MENU
)
366 if ( mpWindowImpl
->mpBorderWindow
)
367 ((ImplBorderWindow
*)mpWindowImpl
->mpBorderWindow
)->SetMenuButton( bVisible
);
373 // -----------------------------------------------------------------------
375 BOOL
SystemWindow::IsTitleButtonVisible( USHORT nButton
) const
377 if ( nButton
== TITLE_BUTTON_DOCKING
)
379 else /* if ( nButton == TITLE_BUTTON_HIDE ) */
383 // -----------------------------------------------------------------------
385 void SystemWindow::SetPin( BOOL bPin
)
387 if ( bPin
!= mbPined
)
390 if ( mpWindowImpl
->mpBorderWindow
)
391 ((ImplBorderWindow
*)mpWindowImpl
->mpBorderWindow
)->SetPin( bPin
);
395 // -----------------------------------------------------------------------
397 void SystemWindow::RollUp()
401 maOrgSize
= GetOutputSizePixel();
403 Size aSize
= maRollUpOutSize
;
404 if ( !aSize
.Width() )
405 aSize
.Width() = GetOutputSizePixel().Width();
407 if ( mpWindowImpl
->mpBorderWindow
)
408 ((ImplBorderWindow
*)mpWindowImpl
->mpBorderWindow
)->SetRollUp( TRUE
, aSize
);
410 SetOutputSizePixel( aSize
);
415 // -----------------------------------------------------------------------
417 void SystemWindow::RollDown()
422 if ( mpWindowImpl
->mpBorderWindow
)
423 ((ImplBorderWindow
*)mpWindowImpl
->mpBorderWindow
)->SetRollUp( FALSE
, maOrgSize
);
425 SetOutputSizePixel( maOrgSize
);
429 // -----------------------------------------------------------------------
431 void SystemWindow::SetMinOutputSizePixel( const Size
& rSize
)
433 maMinOutSize
= rSize
;
434 if ( mpWindowImpl
->mpBorderWindow
)
436 ((ImplBorderWindow
*)mpWindowImpl
->mpBorderWindow
)->SetMinOutputSize( rSize
.Width(), rSize
.Height() );
437 if ( mpWindowImpl
->mpBorderWindow
->mpWindowImpl
->mbFrame
)
438 mpWindowImpl
->mpBorderWindow
->mpWindowImpl
->mpFrame
->SetMinClientSize( rSize
.Width(), rSize
.Height() );
440 else if ( mpWindowImpl
->mbFrame
)
441 mpWindowImpl
->mpFrame
->SetMinClientSize( rSize
.Width(), rSize
.Height() );
444 // -----------------------------------------------------------------------
446 void SystemWindow::SetMaxOutputSizePixel( const Size
& rSize
)
449 if( aSize
.Width() > SHRT_MAX
|| aSize
.Width() <= 0 )
450 aSize
.Width() = SHRT_MAX
;
451 if( aSize
.Height() > SHRT_MAX
|| aSize
.Height() <= 0 )
452 aSize
.Height() = SHRT_MAX
;
454 mpImplData
->maMaxOutSize
= aSize
;
455 if ( mpWindowImpl
->mpBorderWindow
)
457 ((ImplBorderWindow
*)mpWindowImpl
->mpBorderWindow
)->SetMaxOutputSize( aSize
.Width(), aSize
.Height() );
458 if ( mpWindowImpl
->mpBorderWindow
->mpWindowImpl
->mbFrame
)
459 mpWindowImpl
->mpBorderWindow
->mpWindowImpl
->mpFrame
->SetMaxClientSize( aSize
.Width(), aSize
.Height() );
461 else if ( mpWindowImpl
->mbFrame
)
462 mpWindowImpl
->mpFrame
->SetMaxClientSize( aSize
.Width(), aSize
.Height() );
465 const Size
& SystemWindow::GetMaxOutputSizePixel() const
467 return mpImplData
->maMaxOutSize
;
469 // -----------------------------------------------------------------------
471 Size
SystemWindow::GetResizeOutputSizePixel() const
473 Size aSize
= GetOutputSizePixel();
474 if ( aSize
.Width() < maMinOutSize
.Width() )
475 aSize
.Width() = maMinOutSize
.Width();
476 if ( aSize
.Height() < maMinOutSize
.Height() )
477 aSize
.Height() = maMinOutSize
.Height();
481 // -----------------------------------------------------------------------
483 static void ImplWindowStateFromStr( WindowStateData
& rData
, const ByteString
& rStr
)
485 ULONG nValidMask
= 0;
486 xub_StrLen nIndex
= 0;
487 ByteString aTokenStr
;
489 aTokenStr
= rStr
.GetToken( 0, ',', nIndex
);
490 if ( aTokenStr
.Len() )
492 rData
.SetX( aTokenStr
.ToInt32() );
493 if( rData
.GetX() > -16384 && rData
.GetX() < 16384 )
494 nValidMask
|= WINDOWSTATE_MASK_X
;
500 aTokenStr
= rStr
.GetToken( 0, ',', nIndex
);
501 if ( aTokenStr
.Len() )
503 rData
.SetY( aTokenStr
.ToInt32() );
504 if( rData
.GetY() > -16384 && rData
.GetY() < 16384 )
505 nValidMask
|= WINDOWSTATE_MASK_Y
;
511 aTokenStr
= rStr
.GetToken( 0, ',', nIndex
);
512 if ( aTokenStr
.Len() )
514 rData
.SetWidth( aTokenStr
.ToInt32() );
515 if( rData
.GetWidth() > 0 && rData
.GetWidth() < 16384 )
516 nValidMask
|= WINDOWSTATE_MASK_WIDTH
;
522 aTokenStr
= rStr
.GetToken( 0, ';', nIndex
);
523 if ( aTokenStr
.Len() )
525 rData
.SetHeight( aTokenStr
.ToInt32() );
526 if( rData
.GetHeight() > 0 && rData
.GetHeight() < 16384 )
527 nValidMask
|= WINDOWSTATE_MASK_HEIGHT
;
529 rData
.SetHeight( 0 );
532 rData
.SetHeight( 0 );
533 aTokenStr
= rStr
.GetToken( 0, ';', nIndex
);
534 if ( aTokenStr
.Len() )
536 // #94144# allow Minimize again, should be masked out when read from configuration
537 // 91625 - ignore Minimize
538 ULONG nState
= (ULONG
)aTokenStr
.ToInt32();
539 //nState &= ~(WINDOWSTATE_STATE_MINIMIZED);
540 rData
.SetState( nState
);
541 nValidMask
|= WINDOWSTATE_MASK_STATE
;
546 // read maximized pos/size
547 aTokenStr
= rStr
.GetToken( 0, ',', nIndex
);
548 if ( aTokenStr
.Len() )
550 rData
.SetMaximizedX( aTokenStr
.ToInt32() );
551 if( rData
.GetMaximizedX() > -16384 && rData
.GetMaximizedX() < 16384 )
552 nValidMask
|= WINDOWSTATE_MASK_MAXIMIZED_X
;
554 rData
.SetMaximizedX( 0 );
557 rData
.SetMaximizedX( 0 );
558 aTokenStr
= rStr
.GetToken( 0, ',', nIndex
);
559 if ( aTokenStr
.Len() )
561 rData
.SetMaximizedY( aTokenStr
.ToInt32() );
562 if( rData
.GetMaximizedY() > -16384 && rData
.GetMaximizedY() < 16384 )
563 nValidMask
|= WINDOWSTATE_MASK_MAXIMIZED_Y
;
565 rData
.SetMaximizedY( 0 );
568 rData
.SetMaximizedY( 0 );
569 aTokenStr
= rStr
.GetToken( 0, ',', nIndex
);
570 if ( aTokenStr
.Len() )
572 rData
.SetMaximizedWidth( aTokenStr
.ToInt32() );
573 if( rData
.GetMaximizedWidth() > 0 && rData
.GetMaximizedWidth() < 16384 )
574 nValidMask
|= WINDOWSTATE_MASK_MAXIMIZED_WIDTH
;
576 rData
.SetMaximizedWidth( 0 );
579 rData
.SetMaximizedWidth( 0 );
580 aTokenStr
= rStr
.GetToken( 0, ';', nIndex
);
581 if ( aTokenStr
.Len() )
583 rData
.SetMaximizedHeight( aTokenStr
.ToInt32() );
584 if( rData
.GetMaximizedHeight() > 0 && rData
.GetMaximizedHeight() < 16384 )
585 nValidMask
|= WINDOWSTATE_MASK_MAXIMIZED_HEIGHT
;
587 rData
.SetMaximizedHeight( 0 );
590 rData
.SetMaximizedHeight( 0 );
593 rData
.SetMask( nValidMask
);
596 // -----------------------------------------------------------------------
598 static void ImplWindowStateToStr( const WindowStateData
& rData
, ByteString
& rStr
)
600 ULONG nValidMask
= rData
.GetMask();
604 if ( nValidMask
& WINDOWSTATE_MASK_X
)
605 rStr
.Append( ByteString::CreateFromInt32( rData
.GetX() ) );
607 if ( nValidMask
& WINDOWSTATE_MASK_Y
)
608 rStr
.Append( ByteString::CreateFromInt32( rData
.GetY() ) );
610 if ( nValidMask
& WINDOWSTATE_MASK_WIDTH
)
611 rStr
.Append( ByteString::CreateFromInt32( rData
.GetWidth() ) );
613 if ( nValidMask
& WINDOWSTATE_MASK_HEIGHT
)
614 rStr
.Append( ByteString::CreateFromInt32( rData
.GetHeight() ) );
616 if ( nValidMask
& WINDOWSTATE_MASK_STATE
)
618 // #94144# allow Minimize again, should be masked out when read from configuration
619 // 91625 - ignore Minimize
620 ULONG nState
= rData
.GetState();
621 //nState &= ~(WINDOWSTATE_STATE_MINIMIZED);
622 rStr
.Append( ByteString::CreateFromInt32( (long)nState
) );
625 if ( nValidMask
& WINDOWSTATE_MASK_MAXIMIZED_X
)
626 rStr
.Append( ByteString::CreateFromInt32( rData
.GetMaximizedX() ) );
628 if ( nValidMask
& WINDOWSTATE_MASK_MAXIMIZED_Y
)
629 rStr
.Append( ByteString::CreateFromInt32( rData
.GetMaximizedY() ) );
631 if ( nValidMask
& WINDOWSTATE_MASK_MAXIMIZED_WIDTH
)
632 rStr
.Append( ByteString::CreateFromInt32( rData
.GetMaximizedWidth() ) );
634 if ( nValidMask
& WINDOWSTATE_MASK_MAXIMIZED_HEIGHT
)
635 rStr
.Append( ByteString::CreateFromInt32( rData
.GetMaximizedHeight() ) );
639 // -----------------------------------------------------------------------
641 void SystemWindow::SetWindowStateData( const WindowStateData
& rData
)
643 ULONG nValidMask
= rData
.GetMask();
650 Window
* pWindow
= this;
651 while ( pWindow
->mpWindowImpl
->mpBorderWindow
)
652 pWindow
= pWindow
->mpWindowImpl
->mpBorderWindow
;
654 if ( pWindow
->mpWindowImpl
->mbFrame
)
656 ULONG nState
= rData
.GetState();
657 SalFrameState aState
;
658 aState
.mnMask
= rData
.GetMask();
659 aState
.mnX
= rData
.GetX();
660 aState
.mnY
= rData
.GetY();
661 aState
.mnWidth
= rData
.GetWidth();
662 aState
.mnHeight
= rData
.GetHeight();
664 if( rData
.GetMask() & (WINDOWSTATE_MASK_WIDTH
|WINDOWSTATE_MASK_HEIGHT
) )
666 // #i43799# adjust window state sizes if a minimial output size was set
667 // otherwise the frame and the client might get different sizes
668 if( maMinOutSize
.Width() > aState
.mnWidth
)
669 aState
.mnWidth
= maMinOutSize
.Width();
670 if( maMinOutSize
.Height() > aState
.mnHeight
)
671 aState
.mnHeight
= maMinOutSize
.Height();
674 aState
.mnMaximizedX
= rData
.GetMaximizedX();
675 aState
.mnMaximizedY
= rData
.GetMaximizedY();
676 aState
.mnMaximizedWidth
= rData
.GetMaximizedWidth();
677 aState
.mnMaximizedHeight
= rData
.GetMaximizedHeight();
678 // #94144# allow Minimize again, should be masked out when read from configuration
679 // 91625 - ignore Minimize
680 //nState &= ~(WINDOWSTATE_STATE_MINIMIZED);
681 aState
.mnState
= nState
& SAL_FRAMESTATE_SYSTEMMASK
;
683 // #96568# avoid having multiple frames at the same screen location
684 // do the check only if not maximized
685 if( !((rData
.GetMask() & WINDOWSTATE_MASK_STATE
) && (nState
& WINDOWSTATE_STATE_MAXIMIZED
)) )
686 if( rData
.GetMask() & (WINDOWSTATE_MASK_POS
|WINDOWSTATE_MASK_WIDTH
|WINDOWSTATE_MASK_HEIGHT
) )
688 Rectangle aDesktop
= GetDesktopRectPixel();
689 ImplSVData
*pSVData
= ImplGetSVData();
690 Window
*pWin
= pSVData
->maWinData
.mpFirstFrame
;
691 BOOL bWrapped
= FALSE
;
694 if( !pWin
->ImplIsRealParentPath( this ) &&
695 pWin
->ImplGetWindow()->IsTopWindow() && pWin
->mpWindowImpl
->mbReallyVisible
)
697 SalFrameGeometry g
= pWin
->mpWindowImpl
->mpFrame
->GetGeometry();
698 if( abs(g
.nX
-aState
.mnX
) < 2 && abs(g
.nY
-aState
.mnY
) < 5 )
700 long displacement
= g
.nTopDecoration
? g
.nTopDecoration
: 20;
701 if( (unsigned long) (aState
.mnX
+ displacement
+ aState
.mnWidth
+ g
.nRightDecoration
) > (unsigned long) aDesktop
.nRight
||
702 (unsigned long) (aState
.mnY
+ displacement
+ aState
.mnHeight
+ g
.nBottomDecoration
) > (unsigned long) aDesktop
.nBottom
)
704 // displacing would leave screen
705 aState
.mnX
= g
.nLeftDecoration
? g
.nLeftDecoration
: 10; // should result in (0,0)
706 aState
.mnY
= displacement
;
708 (unsigned long) (aState
.mnX
+ displacement
+ aState
.mnWidth
+ g
.nRightDecoration
) > (unsigned long) aDesktop
.nRight
||
709 (unsigned long) (aState
.mnY
+ displacement
+ aState
.mnHeight
+ g
.nBottomDecoration
) > (unsigned long) aDesktop
.nBottom
)
710 break; // further displacement not possible -> break
711 // avoid endless testing
717 aState
.mnX
+= displacement
;
718 aState
.mnY
+= displacement
;
720 pWin
= pSVData
->maWinData
.mpFirstFrame
; // check new pos again
723 pWin
= pWin
->mpWindowImpl
->mpFrameData
->mpNextFrame
;
727 mpWindowImpl
->mpFrame
->SetWindowState( &aState
);
729 // do a synchronous resize for layout reasons
730 // but use rData only when the window is not to be maximized (#i38089#)
731 // otherwise we have no useful size information
732 if( (rData
.GetMask() & WINDOWSTATE_MASK_STATE
) && (nState
& WINDOWSTATE_STATE_MAXIMIZED
) )
734 // query maximized size from frame
735 SalFrameGeometry aGeometry
= mpWindowImpl
->mpFrame
->GetGeometry();
737 // but use it only if it is different from the restore size (rData)
738 // as currently only on windows the exact size of a maximized window
739 // can be computed without actually showing the window
740 if( aGeometry
.nWidth
!= rData
.GetWidth() || aGeometry
.nHeight
!= rData
.GetHeight() )
741 ImplHandleResize( pWindow
, aGeometry
.nWidth
, aGeometry
.nHeight
);
744 if( rData
.GetMask() & (WINDOWSTATE_MASK_WIDTH
|WINDOWSTATE_MASK_HEIGHT
) )
745 ImplHandleResize( pWindow
, aState
.mnWidth
, aState
.mnHeight
); // #i43799# use aState and not rData, see above
750 if ( nValidMask
& WINDOWSTATE_MASK_X
)
751 nPosSize
|= WINDOW_POSSIZE_X
;
752 if ( nValidMask
& WINDOWSTATE_MASK_Y
)
753 nPosSize
|= WINDOW_POSSIZE_Y
;
754 if ( nValidMask
& WINDOWSTATE_MASK_WIDTH
)
755 nPosSize
|= WINDOW_POSSIZE_WIDTH
;
756 if ( nValidMask
& WINDOWSTATE_MASK_HEIGHT
)
757 nPosSize
|= WINDOW_POSSIZE_HEIGHT
;
762 long nX
= rData
.GetX();
763 long nY
= rData
.GetY();
764 long nWidth
= rData
.GetWidth();
765 long nHeight
= rData
.GetHeight();
766 const SalFrameGeometry
& rGeom
= pWindow
->mpWindowImpl
->mpFrame
->GetGeometry();
769 if( nX
+ nWidth
> (long) rGeom
.nWidth
)
770 nX
= rGeom
.nWidth
- nWidth
;
773 if( nY
+ nHeight
> (long) rGeom
.nHeight
)
774 nY
= rGeom
.nHeight
- nHeight
;
775 SetPosSizePixel( nX
, nY
, nWidth
, nHeight
, nPosSize
);
776 maOrgSize
= Size( nWidth
, nHeight
);
778 // 91625 - ignore Minimize
779 if ( nValidMask
& WINDOWSTATE_MASK_STATE
)
781 ULONG nState
= rData
.GetState();
782 if ( nState
& WINDOWSTATE_STATE_ROLLUP
)
790 // -----------------------------------------------------------------------
792 void SystemWindow::GetWindowStateData( WindowStateData
& rData
) const
794 ULONG nValidMask
= rData
.GetMask();
801 const Window
* pWindow
= this;
802 while ( pWindow
->mpWindowImpl
->mpBorderWindow
)
803 pWindow
= pWindow
->mpWindowImpl
->mpBorderWindow
;
805 if ( pWindow
->mpWindowImpl
->mbFrame
)
807 SalFrameState aState
;
808 aState
.mnMask
= 0xFFFFFFFF;
809 if ( mpWindowImpl
->mpFrame
->GetWindowState( &aState
) )
811 if ( nValidMask
& WINDOWSTATE_MASK_X
)
812 rData
.SetX( aState
.mnX
);
813 if ( nValidMask
& WINDOWSTATE_MASK_Y
)
814 rData
.SetY( aState
.mnY
);
815 if ( nValidMask
& WINDOWSTATE_MASK_WIDTH
)
816 rData
.SetWidth( aState
.mnWidth
);
817 if ( nValidMask
& WINDOWSTATE_MASK_HEIGHT
)
818 rData
.SetHeight( aState
.mnHeight
);
819 if ( aState
.mnMask
& SAL_FRAMESTATE_MASK_MAXIMIZED_X
)
821 rData
.SetMaximizedX( aState
.mnMaximizedX
);
822 nValidMask
|= WINDOWSTATE_MASK_MAXIMIZED_X
;
824 if ( aState
.mnMask
& SAL_FRAMESTATE_MASK_MAXIMIZED_Y
)
826 rData
.SetMaximizedY( aState
.mnMaximizedY
);
827 nValidMask
|= WINDOWSTATE_MASK_MAXIMIZED_Y
;
829 if ( aState
.mnMask
& SAL_FRAMESTATE_MASK_MAXIMIZED_WIDTH
)
831 rData
.SetMaximizedWidth( aState
.mnMaximizedWidth
);
832 nValidMask
|= WINDOWSTATE_MASK_MAXIMIZED_WIDTH
;
834 if ( aState
.mnMask
& SAL_FRAMESTATE_MASK_MAXIMIZED_HEIGHT
)
836 rData
.SetMaximizedHeight( aState
.mnMaximizedHeight
);
837 nValidMask
|= WINDOWSTATE_MASK_MAXIMIZED_HEIGHT
;
839 if ( nValidMask
& WINDOWSTATE_MASK_STATE
)
841 // #94144# allow Minimize again, should be masked out when read from configuration
842 // 91625 - ignore Minimize
843 if ( !(nValidMask
&WINDOWSTATE_MASK_MINIMIZED
) )
844 aState
.mnState
&= ~(WINDOWSTATE_STATE_MINIMIZED
);
845 rData
.SetState( aState
.mnState
);
847 rData
.SetMask( nValidMask
);
854 Point aPos
= GetPosPixel();
855 Size aSize
= GetSizePixel();
860 aSize
.Height() += maOrgSize
.Height();
861 nState
|= WINDOWSTATE_STATE_ROLLUP
;
864 if ( nValidMask
& WINDOWSTATE_MASK_X
)
865 rData
.SetX( aPos
.X() );
866 if ( nValidMask
& WINDOWSTATE_MASK_Y
)
867 rData
.SetY( aPos
.Y() );
868 if ( nValidMask
& WINDOWSTATE_MASK_WIDTH
)
869 rData
.SetWidth( aSize
.Width() );
870 if ( nValidMask
& WINDOWSTATE_MASK_HEIGHT
)
871 rData
.SetHeight( aSize
.Height() );
872 if ( nValidMask
& WINDOWSTATE_MASK_STATE
)
873 rData
.SetState( nState
);
877 // -----------------------------------------------------------------------
879 void SystemWindow::SetWindowState( const ByteString
& rStr
)
884 WindowStateData aData
;
885 ImplWindowStateFromStr( aData
, rStr
);
886 SetWindowStateData( aData
);
889 // -----------------------------------------------------------------------
891 ByteString
SystemWindow::GetWindowState( ULONG nMask
) const
893 WindowStateData aData
;
894 aData
.SetMask( nMask
);
895 GetWindowStateData( aData
);
898 ImplWindowStateToStr( aData
, aStr
);
902 // -----------------------------------------------------------------------
904 void SystemWindow::SetMenuBar( MenuBar
* pMenuBar
)
906 if ( mpMenuBar
!= pMenuBar
)
908 MenuBar
* pOldMenuBar
= mpMenuBar
;
909 Window
* pOldWindow
= NULL
;
910 Window
* pNewWindow
=NULL
;
911 mpMenuBar
= pMenuBar
;
913 if ( mpWindowImpl
->mpBorderWindow
&& (mpWindowImpl
->mpBorderWindow
->GetType() == WINDOW_BORDERWINDOW
) )
916 pOldWindow
= pOldMenuBar
->ImplGetWindow();
921 ImplCallEventListeners( VCLEVENT_WINDOW_MENUBARREMOVED
, (void*) pOldMenuBar
);
922 pOldWindow
->SetAccessible( ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>() );
926 DBG_ASSERT( !pMenuBar
->pWindow
, "SystemWindow::SetMenuBar() - MenuBars can only set in one SystemWindow at time" );
927 ((ImplBorderWindow
*)mpWindowImpl
->mpBorderWindow
)->SetMenuBarWindow( pNewWindow
= MenuBar::ImplCreate( mpWindowImpl
->mpBorderWindow
, pOldWindow
, pMenuBar
) );
928 ImplCallEventListeners( VCLEVENT_WINDOW_MENUBARADDED
, (void*) pMenuBar
);
931 ((ImplBorderWindow
*)mpWindowImpl
->mpBorderWindow
)->SetMenuBarWindow( NULL
);
935 BOOL bDelete
= (pMenuBar
== 0) ? TRUE
: FALSE
;
936 if( bDelete
&& pOldWindow
)
938 if( mpImplData
->mpTaskPaneList
)
939 mpImplData
->mpTaskPaneList
->RemoveWindow( pOldWindow
);
941 MenuBar::ImplDestroy( pOldMenuBar
, bDelete
);
943 pOldWindow
= NULL
; // will be deleted in MenuBar::ImplDestroy,
950 pNewWindow
= pMenuBar
->ImplGetWindow();
952 pOldWindow
= pOldMenuBar
->ImplGetWindow();
955 // update taskpane list to make menubar accessible
956 if( mpImplData
->mpTaskPaneList
)
959 mpImplData
->mpTaskPaneList
->RemoveWindow( pOldWindow
);
961 mpImplData
->mpTaskPaneList
->AddWindow( pNewWindow
);
966 // -----------------------------------------------------------------------
968 void SystemWindow::SetMenuBarMode( USHORT nMode
)
970 if ( mnMenuBarMode
!= nMode
)
972 mnMenuBarMode
= nMode
;
973 if ( mpWindowImpl
->mpBorderWindow
&& (mpWindowImpl
->mpBorderWindow
->GetType() == WINDOW_BORDERWINDOW
) )
975 if ( nMode
== MENUBAR_MODE_HIDE
)
976 ((ImplBorderWindow
*)mpWindowImpl
->mpBorderWindow
)->SetMenuBarMode( TRUE
);
978 ((ImplBorderWindow
*)mpWindowImpl
->mpBorderWindow
)->SetMenuBarMode( FALSE
);
983 // -----------------------------------------------------------------------
985 BOOL
SystemWindow::ImplIsInTaskPaneList( Window
* pWin
)
987 if( mpImplData
&& mpImplData
->mpTaskPaneList
)
988 return mpImplData
->mpTaskPaneList
->IsInList( pWin
);
992 // -----------------------------------------------------------------------
994 unsigned int SystemWindow::GetScreenNumber() const
996 return mpWindowImpl
->mpFrame
->maGeometry
.nScreenNumber
;
999 // -----------------------------------------------------------------------
1001 void SystemWindow::SetScreenNumber( unsigned int nScreen
)
1003 mpWindowImpl
->mpFrame
->SetScreenNumber( nScreen
);