2010-10-14 08:27:31 +02:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2000-09-18 16:07:07 +00:00
/*************************************************************************
*
2008-04-11 08:17:03 +00:00
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER .
2000-09-18 16:07:07 +00:00
*
2010-02-12 15:01:35 +01:00
* Copyright 2000 , 2010 Oracle and / or its affiliates .
2000-09-18 16:07:07 +00:00
*
2008-04-11 08:17:03 +00:00
* OpenOffice . org - a multi - platform office productivity suite
2000-09-18 16:07:07 +00:00
*
2008-04-11 08:17:03 +00:00
* This file is part of OpenOffice . org .
2000-09-18 16:07:07 +00:00
*
2008-04-11 08:17:03 +00:00
* OpenOffice . org is free software : you can redistribute it and / or modify
* it under the terms of the GNU Lesser General Public License version 3
* only , as published by the Free Software Foundation .
2000-09-18 16:07:07 +00:00
*
2008-04-11 08:17:03 +00:00
* OpenOffice . org is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU Lesser General Public License version 3 for more details
* ( a copy is included in the LICENSE file that accompanied this code ) .
2000-09-18 16:07:07 +00:00
*
2008-04-11 08:17:03 +00:00
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice . org . If not , see
* < http : //www.openoffice.org/license.html>
* for a copy of the LGPLv3 License .
2000-09-18 16:07:07 +00:00
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2006-09-17 11:24:39 +00:00
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
# include <svsys.h>
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>
2000-09-18 16:07:07 +00:00
// =======================================================================
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
2000-09-18 16:07:07 +00:00
mnPresentationFlags = 0 ;
2010-09-29 15:46:40 +08:00
mbPresentationMode = sal_False ;
mbPresentationVisible = sal_False ;
mbPresentationFull = sal_False ;
mbFullScreenMode = sal_False ;
2000-09-18 16:07:07 +00:00
}
// -----------------------------------------------------------------------
void WorkWindow : : ImplInit ( Window * pParent , WinBits nStyle , SystemParentData * pSystemParentData )
{
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
2000-09-18 16:07:07 +00:00
ImplBorderWindow * pBorderWin = new ImplBorderWindow ( 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 ;
}
SetActivateMode ( ACTIVATE_MODE_GRABFOCUS ) ;
}
// -----------------------------------------------------------------------
void WorkWindow : : ImplInit ( Window * pParent , WinBits nStyle , const : : com : : sun : : star : : uno : : Any & aSystemWorkWindowToken )
{
if ( aSystemWorkWindowToken . hasValue ( ) )
{
: : com : : sun : : star : : uno : : Sequence < sal_Int8 > aSeq ;
aSystemWorkWindowToken > > = aSeq ;
SystemParentData * pData = ( SystemParentData * ) aSeq . getArray ( ) ;
DBG_ASSERT ( aSeq . getLength ( ) = = sizeof ( SystemParentData ) & & pData - > nSize = = sizeof ( SystemParentData ) , " WorkWindow::WorkWindow( Window*, const Any&, WinBits ) called with invalid Any " ) ;
// 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
}
2012-05-29 23:57:58 +03:00
# ifdef ANDROID
extern " C " void *
createWindowFoo ( void )
{
return ( void * ) new WorkWindow ( ( Window * ) NULL ) ;
}
# endif
2000-09-18 16:07:07 +00:00
// -----------------------------------------------------------------------
WorkWindow : : WorkWindow ( Window * pParent , WinBits nStyle ) :
SystemWindow ( WINDOW_WORKWINDOW )
{
2006-06-19 18:43:32 +00:00
ImplInitWorkWindowData ( ) ;
2000-09-18 16:07:07 +00:00
ImplInit ( pParent , nStyle , NULL ) ;
}
// -----------------------------------------------------------------------
WorkWindow : : WorkWindow ( Window * pParent , const ResId & rResId ) :
SystemWindow ( WINDOW_WORKWINDOW )
{
2006-06-19 18:43:32 +00:00
ImplInitWorkWindowData ( ) ;
2000-09-18 16:07:07 +00:00
rResId . SetRT ( RSC_WORKWIN ) ;
2007-04-26 08:32:22 +00:00
WinBits nStyle = ImplInitRes ( rResId ) ;
ImplInit ( pParent , nStyle ) ;
2000-09-18 16:07:07 +00:00
ImplLoadRes ( rResId ) ;
}
// -----------------------------------------------------------------------
WorkWindow : : WorkWindow ( Window * pParent , const : : com : : sun : : star : : uno : : Any & aSystemWorkWindowToken , WinBits nStyle ) :
SystemWindow ( WINDOW_WORKWINDOW )
{
2006-06-19 18:43:32 +00:00
ImplInitWorkWindowData ( ) ;
2010-09-29 15:46:40 +08:00
mbSysChild = sal_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 ( ) ;
2010-09-29 15:46:40 +08:00
mbSysChild = sal_True ;
2000-09-18 16:07:07 +00:00
ImplInit ( NULL , 0 , pParent ) ;
}
// -----------------------------------------------------------------------
void WorkWindow : : ImplLoadRes ( const ResId & rResId )
{
SystemWindow : : ImplLoadRes ( rResId ) ;
2005-01-03 16:43:37 +00:00
ReadLongRes ( ) ;
2007-04-26 08:32:22 +00:00
if ( ! ( rResId . GetWinBits ( ) & WB_HIDE ) & & ( RSC_WORKWIN = = rResId . GetRT ( ) ) )
2000-09-18 16:07:07 +00:00
Show ( ) ;
}
// -----------------------------------------------------------------------
WorkWindow : : ~ WorkWindow ( )
{
ImplSVData * pSVData = ImplGetSVData ( ) ;
if ( pSVData - > maWinData . mpAppWin = = this )
{
pSVData - > maWinData . mpAppWin = NULL ;
Application : : Quit ( ) ;
}
}
// -----------------------------------------------------------------------
2012-01-15 01:24:38 +00:00
void WorkWindow : : ShowFullScreenMode ( sal_Bool bFullScreenMode , sal_Int32 nDisplayScreen )
2000-09-18 16:07:07 +00:00
{
if ( ! mbFullScreenMode = = ! bFullScreenMode )
return ;
2012-01-15 01:24:38 +00:00
if ( ( nDisplayScreen < 0 )
| | ( nDisplayScreen > = static_cast < sal_Int32 > ( Application : : GetScreenCount ( ) ) ) )
2008-10-01 13:46:45 +00:00
{
2012-01-15 01:24:38 +00:00
nDisplayScreen = GetScreenNumber ( ) ;
2008-10-01 13:46:45 +00:00
}
2000-09-18 16:07:07 +00:00
mbFullScreenMode = bFullScreenMode ! = 0 ;
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 ( ) ;
}
2010-09-29 15:46:40 +08:00
mpWindowImpl - > mpFrameWindow - > mpWindowImpl - > mbWaitSystemResize = sal_True ;
2012-01-15 01:24:38 +00:00
ImplGetFrame ( ) - > ShowFullScreen ( bFullScreenMode , nDisplayScreen ) ;
2000-09-18 16:07:07 +00:00
}
}
// -----------------------------------------------------------------------
2012-01-15 01:24:38 +00:00
void WorkWindow : : StartPresentationMode ( sal_Bool bPresentation , sal_uInt16 nFlags , sal_Int32 nDisplayScreen )
2000-09-18 16:07:07 +00:00
{
if ( ! bPresentation = = ! mbPresentationMode )
return ;
if ( bPresentation )
{
2010-09-29 15:46:40 +08:00
mbPresentationMode = sal_True ;
2000-09-18 16:07:07 +00:00
mbPresentationVisible = IsVisible ( ) ;
mbPresentationFull = mbFullScreenMode ;
mnPresentationFlags = nFlags ;
if ( ! ( mnPresentationFlags & PRESENTATION_NOFULLSCREEN ) )
2012-01-15 01:24:38 +00:00
ShowFullScreenMode ( sal_True , nDisplayScreen ) ;
2000-09-18 16:07:07 +00:00
if ( ! mbSysChild )
{
if ( mnPresentationFlags & PRESENTATION_HIDEALLAPPS )
2010-09-29 15:46:40 +08:00
mpWindowImpl - > mpFrame - > SetAlwaysOnTop ( sal_True ) ;
2000-09-18 16:07:07 +00:00
if ( ! ( mnPresentationFlags & PRESENTATION_NOAUTOSHOW ) )
ToTop ( ) ;
2010-09-29 15:46:40 +08:00
mpWindowImpl - > mpFrame - > StartPresentation ( sal_True ) ;
2000-09-18 16:07:07 +00:00
}
if ( ! ( mnPresentationFlags & PRESENTATION_NOAUTOSHOW ) )
Show ( ) ;
}
else
{
Show ( mbPresentationVisible ) ;
if ( ! mbSysChild )
{
2010-09-29 15:46:40 +08:00
mpWindowImpl - > mpFrame - > StartPresentation ( sal_False ) ;
2000-09-18 16:07:07 +00:00
if ( mnPresentationFlags & PRESENTATION_HIDEALLAPPS )
2010-09-29 15:46:40 +08:00
mpWindowImpl - > mpFrame - > SetAlwaysOnTop ( sal_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
2010-09-29 15:46:40 +08:00
mbPresentationMode = sal_False ;
mbPresentationVisible = sal_False ;
mbPresentationFull = sal_False ;
2000-09-18 16:07:07 +00:00
mnPresentationFlags = 0 ;
}
}
// -----------------------------------------------------------------------
2010-09-29 15:46:40 +08:00
sal_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 ) ;
2002-10-11 17:08:29 +00:00
return ( ( aState . mnState & SAL_FRAMESTATE_MINIMIZED ) ! = 0 ) ;
2000-09-18 16:07:07 +00:00
}
2003-04-11 16:31:17 +00:00
// -----------------------------------------------------------------------
2010-09-29 15:46:40 +08:00
sal_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 ( ) ;
2010-09-29 15:46:40 +08:00
sal_Bool bShown = IsVisible ( ) ;
Show ( sal_False ) ;
sal_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 ;
aState . mnMask = SAL_FRAMESTATE_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 ( )
{
ImplSetFrameState ( SAL_FRAMESTATE_MINIMIZED ) ;
}
void WorkWindow : : Restore ( )
{
ImplSetFrameState ( SAL_FRAMESTATE_NORMAL ) ;
}
2010-09-29 15:46:40 +08:00
sal_Bool WorkWindow : : Close ( )
2004-01-06 13:22:26 +00:00
{
2010-09-29 15:46:40 +08:00
sal_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 ) )
GetpApp ( ) - > Quit ( ) ;
return bCanClose ;
}
2010-09-29 15:46:40 +08:00
void WorkWindow : : Maximize ( sal_Bool bMaximize )
2004-06-17 10:44:01 +00:00
{
ImplSetFrameState ( bMaximize ? SAL_FRAMESTATE_MAXIMIZED : SAL_FRAMESTATE_NORMAL ) ;
}
2010-09-29 15:46:40 +08:00
sal_Bool WorkWindow : : IsMaximized ( ) const
2004-06-17 10:44:01 +00:00
{
2010-09-29 15:46:40 +08:00
sal_Bool bRet = sal_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
{
if ( aState . mnState & ( SAL_FRAMESTATE_MAXIMIZED |
SAL_FRAMESTATE_MAXIMIZED_HORZ |
SAL_FRAMESTATE_MAXIMIZED_VERT ) )
2010-09-29 15:46:40 +08:00
bRet = sal_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: */