2010-10-14 08:27:31 +02:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2012-11-06 12:12:33 +00:00
/*
* This file is part of the LibreOffice project .
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License , v . 2.0 . If a copy of the MPL was not distributed with this
* file , You can obtain one at http : //mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice :
*
* Licensed to the Apache Software Foundation ( ASF ) under one or more
* contributor license agreements . See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership . The ASF licenses this file to you under the Apache
* License , Version 2.0 ( the " License " ) ; you may not use this file
* except in compliance with the License . You may obtain a copy of
* the License at http : //www.apache.org/licenses/LICENSE-2.0 .
*/
2000-09-18 16:07:07 +00:00
# include <tools/debug.hxx>
2004-01-06 13:22:26 +00:00
# include <tools/rc.h>
2011-01-24 16:34:14 +01:00
2007-06-27 19:36:45 +00:00
# include <vcl/svapp.hxx>
# include <vcl/wrkwin.hxx>
2011-01-24 20:21:12 +01:00
// declare system types in sysdata.hxx
2007-07-24 09:23:59 +00:00
# include <vcl/sysdata.hxx>
2010-10-06 15:11:57 +01:00
# include <com/sun/star/lang/XComponent.hpp>
# include <com/sun/star/rendering/XCanvas.hpp>
2000-09-18 16:07:07 +00:00
2011-01-24 16:34:14 +01:00
# include <svdata.hxx>
# include <salframe.hxx>
# include <brdwin.hxx>
# include <window.h>
2006-06-19 18:43:32 +00:00
void WorkWindow : : ImplInitWorkWindowData ( )
2000-09-18 16:07:07 +00:00
{
2001-08-23 12:40:56 +00:00
mnIcon = 0 ; // Should be removed in the next top level update - now in SystemWindow
2015-05-28 13:49:48 +02:00
mnPresentationFlags = PresentationFlags : : NONE ;
2014-02-21 12:53:51 +01:00
mbPresentationMode = false ;
mbPresentationVisible = false ;
mbPresentationFull = false ;
mbFullScreenMode = false ;
2000-09-18 16:07:07 +00:00
}
2014-09-23 11:20:40 +02:00
void WorkWindow : : ImplInit ( vcl : : Window * pParent , WinBits nStyle , SystemParentData * pSystemParentData )
2000-09-18 16:07:07 +00:00
{
2010-09-29 15:46:40 +08:00
sal_uInt16 nFrameStyle = BORDERWINDOW_STYLE_FRAME ;
2000-09-18 16:07:07 +00:00
if ( nStyle & WB_APP )
nFrameStyle | = BORDERWINDOW_STYLE_APP ;
2002-03-15 16:10:25 +00:00
2015-04-20 15:35:54 +01:00
VclPtrInstance < ImplBorderWindow > pBorderWin ( pParent , pSystemParentData , nStyle , nFrameStyle ) ;
2001-11-23 11:39:27 +00:00
Window : : ImplInit ( pBorderWin , nStyle & ( WB_3DLOOK | WB_CLIPCHILDREN | WB_DIALOGCONTROL | WB_SYSTEMFLOATWIN ) , NULL ) ;
2005-01-13 17:07:37 +00:00
pBorderWin - > mpWindowImpl - > mpClientWindow = this ;
pBorderWin - > GetBorder ( mpWindowImpl - > mnLeftBorder , mpWindowImpl - > mnTopBorder , mpWindowImpl - > mnRightBorder , mpWindowImpl - > mnBottomBorder ) ;
mpWindowImpl - > mpBorderWindow = pBorderWin ;
2011-12-18 12:21:45 +01:00
// mpWindowImpl->mpRealParent = pParent; // should actually be set, but is not set due to errors with the menubar!!
2000-09-18 16:07:07 +00:00
if ( nStyle & WB_APP )
{
ImplSVData * pSVData = ImplGetSVData ( ) ;
DBG_ASSERT ( ! pSVData - > maWinData . mpAppWin , " WorkWindow::WorkWindow(): More than one window with style WB_APP " ) ;
pSVData - > maWinData . mpAppWin = this ;
}
2015-05-22 15:25:59 +02:00
SetActivateMode ( ActivateModeFlags : : GrabFocus ) ;
2000-09-18 16:07:07 +00:00
}
2014-09-23 11:20:40 +02:00
void WorkWindow : : ImplInit ( vcl : : Window * pParent , WinBits nStyle , const : : com : : sun : : star : : uno : : Any & aSystemWorkWindowToken )
2000-09-18 16:07:07 +00:00
{
if ( aSystemWorkWindowToken . hasValue ( ) )
{
: : com : : sun : : star : : uno : : Sequence < sal_Int8 > aSeq ;
aSystemWorkWindowToken > > = aSeq ;
2015-01-19 15:10:10 +01:00
SystemParentData * pData = reinterpret_cast < SystemParentData * > ( aSeq . getArray ( ) ) ;
2014-09-23 11:20:40 +02:00
DBG_ASSERT ( aSeq . getLength ( ) = = sizeof ( SystemParentData ) & & pData - > nSize = = sizeof ( SystemParentData ) , " WorkWindow::WorkWindow( vcl::Window*, const Any&, WinBits ) called with invalid Any " ) ;
2000-09-18 16:07:07 +00:00
// init with style 0 as does WorkWindow::WorkWindow( SystemParentData* );
ImplInit ( pParent , 0 , pData ) ;
}
else
ImplInit ( pParent , nStyle , NULL ) ;
}
WorkWindow : : WorkWindow ( WindowType nType ) :
SystemWindow ( nType )
{
2006-06-19 18:43:32 +00:00
ImplInitWorkWindowData ( ) ;
2000-09-18 16:07:07 +00:00
}
2014-09-23 11:20:40 +02:00
WorkWindow : : WorkWindow ( vcl : : Window * pParent , WinBits nStyle ) :
2000-09-18 16:07:07 +00:00
SystemWindow ( WINDOW_WORKWINDOW )
{
2006-06-19 18:43:32 +00:00
ImplInitWorkWindowData ( ) ;
2000-09-18 16:07:07 +00:00
ImplInit ( pParent , nStyle , NULL ) ;
}
2014-09-23 11:20:40 +02:00
WorkWindow : : WorkWindow ( vcl : : Window * pParent , const : : com : : sun : : star : : uno : : Any & aSystemWorkWindowToken , WinBits nStyle ) :
2000-09-18 16:07:07 +00:00
SystemWindow ( WINDOW_WORKWINDOW )
{
2006-06-19 18:43:32 +00:00
ImplInitWorkWindowData ( ) ;
2014-02-21 12:53:51 +01:00
mbSysChild = true ;
2000-09-18 16:07:07 +00:00
ImplInit ( pParent , nStyle , aSystemWorkWindowToken ) ;
}
WorkWindow : : WorkWindow ( SystemParentData * pParent ) :
SystemWindow ( WINDOW_WORKWINDOW )
{
2006-06-19 18:43:32 +00:00
ImplInitWorkWindowData ( ) ;
2014-02-21 12:53:51 +01:00
mbSysChild = true ;
2000-09-18 16:07:07 +00:00
ImplInit ( NULL , 0 , pParent ) ;
}
WorkWindow : : ~ WorkWindow ( )
2015-01-15 15:48:23 +02:00
{
2015-03-10 09:07:06 +02:00
disposeOnce ( ) ;
2015-01-15 15:48:23 +02:00
}
void WorkWindow : : dispose ( )
2000-09-18 16:07:07 +00:00
{
ImplSVData * pSVData = ImplGetSVData ( ) ;
if ( pSVData - > maWinData . mpAppWin = = this )
{
pSVData - > maWinData . mpAppWin = NULL ;
Application : : Quit ( ) ;
}
2015-01-09 15:26:08 +00:00
SystemWindow : : dispose ( ) ;
2000-09-18 16:07:07 +00:00
}
2014-02-21 12:53:51 +01:00
void WorkWindow : : ShowFullScreenMode ( bool bFullScreenMode )
2012-11-26 14:54:34 +01:00
{
return ShowFullScreenMode ( bFullScreenMode , GetScreenNumber ( ) ) ;
}
2014-02-21 12:53:51 +01:00
void WorkWindow : : ShowFullScreenMode ( bool bFullScreenMode , sal_Int32 nDisplayScreen )
2000-09-18 16:07:07 +00:00
{
if ( ! mbFullScreenMode = = ! bFullScreenMode )
return ;
2014-02-21 12:53:51 +01:00
mbFullScreenMode = bFullScreenMode ;
2000-09-18 16:07:07 +00:00
if ( ! mbSysChild )
{
2010-10-06 15:11:57 +01:00
// Dispose of the canvas implementation, which might rely on
// screen-specific system data.
com : : sun : : star : : uno : : Reference < com : : sun : : star : : rendering : : XCanvas > xCanvas ( mpWindowImpl - > mxCanvas ) ;
if ( xCanvas . is ( ) )
{
com : : sun : : star : : uno : : Reference < com : : sun : : star : : lang : : XComponent >
xCanvasComponent ( xCanvas ,
com : : sun : : star : : uno : : UNO_QUERY ) ;
if ( xCanvasComponent . is ( ) )
xCanvasComponent - > dispose ( ) ;
}
2014-01-28 19:59:13 +01:00
mpWindowImpl - > mpFrameWindow - > mpWindowImpl - > mbWaitSystemResize = true ;
2012-01-15 01:24:38 +00:00
ImplGetFrame ( ) - > ShowFullScreen ( bFullScreenMode , nDisplayScreen ) ;
2000-09-18 16:07:07 +00:00
}
}
2015-05-28 13:49:48 +02:00
void WorkWindow : : StartPresentationMode ( bool bPresentation , PresentationFlags nFlags )
2012-11-26 14:54:34 +01:00
{
return StartPresentationMode ( bPresentation , nFlags , GetScreenNumber ( ) ) ;
}
2015-05-28 13:49:48 +02:00
void WorkWindow : : StartPresentationMode ( bool bPresentation , PresentationFlags nFlags , sal_Int32 nDisplayScreen )
2000-09-18 16:07:07 +00:00
{
if ( ! bPresentation = = ! mbPresentationMode )
return ;
if ( bPresentation )
{
2014-02-21 12:53:51 +01:00
mbPresentationMode = true ;
2000-09-18 16:07:07 +00:00
mbPresentationVisible = IsVisible ( ) ;
mbPresentationFull = mbFullScreenMode ;
mnPresentationFlags = nFlags ;
2015-05-28 13:49:48 +02:00
if ( ! ( mnPresentationFlags & PresentationFlags : : NoFullScreen ) )
2014-02-21 12:53:51 +01:00
ShowFullScreenMode ( true , nDisplayScreen ) ;
2000-09-18 16:07:07 +00:00
if ( ! mbSysChild )
{
2015-05-28 13:49:48 +02:00
if ( mnPresentationFlags & PresentationFlags : : HideAllApps )
2014-02-24 01:53:13 +11:00
mpWindowImpl - > mpFrame - > SetAlwaysOnTop ( true ) ;
2015-05-28 13:49:48 +02:00
if ( ! ( mnPresentationFlags & PresentationFlags : : NoAutoShow ) )
2000-09-18 16:07:07 +00:00
ToTop ( ) ;
2014-02-24 01:53:13 +11:00
mpWindowImpl - > mpFrame - > StartPresentation ( true ) ;
2000-09-18 16:07:07 +00:00
}
2015-05-28 13:49:48 +02:00
if ( ! ( mnPresentationFlags & PresentationFlags : : NoAutoShow ) )
2000-09-18 16:07:07 +00:00
Show ( ) ;
}
else
{
Show ( mbPresentationVisible ) ;
if ( ! mbSysChild )
{
2014-02-24 01:53:13 +11:00
mpWindowImpl - > mpFrame - > StartPresentation ( false ) ;
2015-05-28 13:49:48 +02:00
if ( mnPresentationFlags & PresentationFlags : : HideAllApps )
2014-02-24 01:53:13 +11:00
mpWindowImpl - > mpFrame - > SetAlwaysOnTop ( false ) ;
2000-09-18 16:07:07 +00:00
}
2012-01-15 01:24:38 +00:00
ShowFullScreenMode ( mbPresentationFull , nDisplayScreen ) ;
2000-09-18 16:07:07 +00:00
2014-02-21 12:53:51 +01:00
mbPresentationMode = false ;
mbPresentationVisible = false ;
mbPresentationFull = false ;
2015-05-28 13:49:48 +02:00
mnPresentationFlags = PresentationFlags : : NONE ;
2000-09-18 16:07:07 +00:00
}
}
2014-02-21 12:53:51 +01:00
bool WorkWindow : : IsMinimized ( ) const
2000-09-18 16:07:07 +00:00
{
2005-01-13 17:07:37 +00:00
//return mpWindowImpl->mpFrameData->mbMinimized;
2002-10-11 17:08:29 +00:00
SalFrameState aState ;
2005-01-13 17:07:37 +00:00
mpWindowImpl - > mpFrame - > GetWindowState ( & aState ) ;
2013-03-27 01:20:01 +02:00
return ( ( aState . mnState & WINDOWSTATE_STATE_MINIMIZED ) ! = 0 ) ;
2000-09-18 16:07:07 +00:00
}
2003-04-11 16:31:17 +00:00
2014-02-21 12:53:51 +01:00
bool WorkWindow : : SetPluginParent ( SystemParentData * pParent )
2003-04-11 16:31:17 +00:00
{
DBG_ASSERT ( ! mbPresentationMode & & ! mbFullScreenMode , " SetPluginParent in fullscreen or presentation mode ! " ) ;
bool bWasDnd = Window : : ImplStopDnd ( ) ;
2014-02-21 12:53:51 +01:00
bool bShown = IsVisible ( ) ;
2014-01-28 19:59:13 +01:00
Show ( false ) ;
2014-02-21 12:53:51 +01:00
bool bRet = mpWindowImpl - > mpFrame - > SetPluginParent ( pParent ) ;
2003-04-11 16:31:17 +00:00
Show ( bShown ) ;
if ( bWasDnd )
Window : : ImplStartDnd ( ) ;
return bRet ;
}
2004-01-06 13:22:26 +00:00
2011-01-12 15:07:10 +01:00
void WorkWindow : : ImplSetFrameState ( sal_uLong aFrameState )
2004-01-06 13:22:26 +00:00
{
SalFrameState aState ;
2013-03-27 01:20:01 +02:00
aState . mnMask = WINDOWSTATE_MASK_STATE ;
2006-06-19 18:43:32 +00:00
aState . mnState = aFrameState ;
2005-01-13 17:07:37 +00:00
mpWindowImpl - > mpFrame - > SetWindowState ( & aState ) ;
2004-01-06 13:22:26 +00:00
}
void WorkWindow : : Minimize ( )
{
2013-03-27 01:20:01 +02:00
ImplSetFrameState ( WINDOWSTATE_STATE_MINIMIZED ) ;
2004-01-06 13:22:26 +00:00
}
void WorkWindow : : Restore ( )
{
2013-03-27 01:20:01 +02:00
ImplSetFrameState ( WINDOWSTATE_STATE_NORMAL ) ;
2004-01-06 13:22:26 +00:00
}
2014-02-21 12:53:51 +01:00
bool WorkWindow : : Close ( )
2004-01-06 13:22:26 +00:00
{
2014-02-21 12:53:51 +01:00
bool bCanClose = SystemWindow : : Close ( ) ;
2004-01-06 13:22:26 +00:00
// Ist es das Applikationsfenster, dann beende die Applikation
if ( bCanClose & & ( ImplGetSVData ( ) - > maWinData . mpAppWin = = this ) )
2014-06-13 17:53:02 +02:00
Application : : Quit ( ) ;
2004-01-06 13:22:26 +00:00
return bCanClose ;
}
2014-02-21 12:53:51 +01:00
void WorkWindow : : Maximize ( bool bMaximize )
2004-06-17 10:44:01 +00:00
{
2013-03-27 01:20:01 +02:00
ImplSetFrameState ( bMaximize ? WINDOWSTATE_STATE_MAXIMIZED : WINDOWSTATE_STATE_NORMAL ) ;
2004-06-17 10:44:01 +00:00
}
2014-02-21 12:53:51 +01:00
bool WorkWindow : : IsMaximized ( ) const
2004-06-17 10:44:01 +00:00
{
2014-02-21 12:53:51 +01:00
bool bRet = false ;
2004-06-17 10:44:01 +00:00
SalFrameState aState ;
2005-01-13 17:07:37 +00:00
if ( mpWindowImpl - > mpFrame - > GetWindowState ( & aState ) )
2004-06-17 10:44:01 +00:00
{
2013-03-27 01:20:01 +02:00
if ( aState . mnState & ( WINDOWSTATE_STATE_MAXIMIZED |
WINDOWSTATE_STATE_MAXIMIZED_HORZ |
WINDOWSTATE_STATE_MAXIMIZED_VERT ) )
2014-02-21 12:53:51 +01:00
bRet = true ;
2004-06-17 10:44:01 +00:00
}
return bRet ;
}
2010-10-14 08:27:31 +02:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */