19f62ea84SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 39f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 49f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file 59f62ea84SAndrew Rist * distributed with this work for additional information 69f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file 79f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the 89f62ea84SAndrew Rist * "License"); you may not use this file except in compliance 99f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at 109f62ea84SAndrew Rist * 119f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 129f62ea84SAndrew Rist * 139f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing, 149f62ea84SAndrew Rist * software distributed under the License is distributed on an 159f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 169f62ea84SAndrew Rist * KIND, either express or implied. See the License for the 179f62ea84SAndrew Rist * specific language governing permissions and limitations 189f62ea84SAndrew Rist * under the License. 199f62ea84SAndrew Rist * 209f62ea84SAndrew Rist *************************************************************/ 219f62ea84SAndrew Rist 229f62ea84SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_vcl.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <tools/debug.hxx> 28cdf0e10cSrcweir #include <tools/rc.h> 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <vcl/svapp.hxx> 31cdf0e10cSrcweir #include <vcl/wrkwin.hxx> 32cdf0e10cSrcweir // declare system types in sysdata.hxx 33cdf0e10cSrcweir #include <svsys.h> 34cdf0e10cSrcweir #include <vcl/sysdata.hxx> 35*8a74df9aSPedro Giffuni 36cdf0e10cSrcweir #include <svdata.hxx> 37cdf0e10cSrcweir #include <salframe.hxx> 38cdf0e10cSrcweir #include <brdwin.hxx> 39cdf0e10cSrcweir #include <window.h> 40cdf0e10cSrcweir 41cdf0e10cSrcweir // ======================================================================= 42cdf0e10cSrcweir 43cdf0e10cSrcweir #define WORKWIN_WINDOWSTATE_FULLSCREEN ((sal_uLong)0x00010000) 44cdf0e10cSrcweir #define WORKWIN_WINDOWSTATE_ALL ((sal_uLong)0x00FF0000) 45cdf0e10cSrcweir 46cdf0e10cSrcweir // ======================================================================= 47cdf0e10cSrcweir 48cdf0e10cSrcweir void WorkWindow::ImplInitWorkWindowData() 49cdf0e10cSrcweir { 50cdf0e10cSrcweir mnIcon = 0; // Should be removed in the next top level update - now in SystemWindow 51cdf0e10cSrcweir 52cdf0e10cSrcweir mnPresentationFlags = 0; 53cdf0e10cSrcweir mbPresentationMode = sal_False; 54cdf0e10cSrcweir mbPresentationVisible = sal_False; 55cdf0e10cSrcweir mbPresentationFull = sal_False; 56cdf0e10cSrcweir mbFullScreenMode = sal_False; 57cdf0e10cSrcweir } 58cdf0e10cSrcweir 59cdf0e10cSrcweir // ----------------------------------------------------------------------- 60cdf0e10cSrcweir 61cdf0e10cSrcweir void WorkWindow::ImplInit( Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData ) 62cdf0e10cSrcweir { 63cdf0e10cSrcweir sal_uInt16 nFrameStyle = BORDERWINDOW_STYLE_FRAME; 64cdf0e10cSrcweir if ( nStyle & WB_APP ) 65cdf0e10cSrcweir nFrameStyle |= BORDERWINDOW_STYLE_APP; 66cdf0e10cSrcweir 67cdf0e10cSrcweir ImplBorderWindow* pBorderWin = new ImplBorderWindow( pParent, pSystemParentData, nStyle, nFrameStyle ); 68cdf0e10cSrcweir Window::ImplInit( pBorderWin, nStyle & (WB_3DLOOK | WB_CLIPCHILDREN | WB_DIALOGCONTROL | WB_SYSTEMFLOATWIN), NULL ); 69cdf0e10cSrcweir pBorderWin->mpWindowImpl->mpClientWindow = this; 70cdf0e10cSrcweir pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder ); 71cdf0e10cSrcweir mpWindowImpl->mpBorderWindow = pBorderWin; 72cdf0e10cSrcweir // mpWindowImpl->mpRealParent = pParent; // !!! Muesste eigentlich gesetzt werden, aber wegen Fehlern mit dem MenuBar erstmal nicht gesetzt !!! 73cdf0e10cSrcweir 74cdf0e10cSrcweir if ( nStyle & WB_APP ) 75cdf0e10cSrcweir { 76cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 77cdf0e10cSrcweir DBG_ASSERT( !pSVData->maWinData.mpAppWin, "WorkWindow::WorkWindow(): More than one window with style WB_APP" ); 78cdf0e10cSrcweir pSVData->maWinData.mpAppWin = this; 79cdf0e10cSrcweir } 80cdf0e10cSrcweir 81cdf0e10cSrcweir SetActivateMode( ACTIVATE_MODE_GRABFOCUS ); 82cdf0e10cSrcweir } 83cdf0e10cSrcweir 84cdf0e10cSrcweir // ----------------------------------------------------------------------- 85cdf0e10cSrcweir 86cdf0e10cSrcweir void WorkWindow::ImplInit( Window* pParent, WinBits nStyle, const ::com::sun::star::uno::Any& aSystemWorkWindowToken ) 87cdf0e10cSrcweir { 88cdf0e10cSrcweir if( aSystemWorkWindowToken.hasValue() ) 89cdf0e10cSrcweir { 90cdf0e10cSrcweir ::com::sun::star::uno::Sequence< sal_Int8 > aSeq; 91cdf0e10cSrcweir aSystemWorkWindowToken >>= aSeq; 92cdf0e10cSrcweir SystemParentData* pData = (SystemParentData*)aSeq.getArray(); 93cdf0e10cSrcweir DBG_ASSERT( aSeq.getLength() == sizeof( SystemParentData ) && pData->nSize == sizeof( SystemParentData ), "WorkWindow::WorkWindow( Window*, const Any&, WinBits ) called with invalid Any" ); 94cdf0e10cSrcweir // init with style 0 as does WorkWindow::WorkWindow( SystemParentData* ); 95cdf0e10cSrcweir ImplInit( pParent, 0, pData ); 96cdf0e10cSrcweir } 97cdf0e10cSrcweir else 98cdf0e10cSrcweir ImplInit( pParent, nStyle, NULL ); 99cdf0e10cSrcweir } 100cdf0e10cSrcweir 101cdf0e10cSrcweir // ----------------------------------------------------------------------- 102cdf0e10cSrcweir 103cdf0e10cSrcweir WorkWindow::WorkWindow( WindowType nType ) : 104cdf0e10cSrcweir SystemWindow( nType ) 105cdf0e10cSrcweir { 106cdf0e10cSrcweir ImplInitWorkWindowData(); 107cdf0e10cSrcweir } 108cdf0e10cSrcweir 109cdf0e10cSrcweir // ----------------------------------------------------------------------- 110cdf0e10cSrcweir 111cdf0e10cSrcweir WorkWindow::WorkWindow( Window* pParent, WinBits nStyle ) : 112cdf0e10cSrcweir SystemWindow( WINDOW_WORKWINDOW ) 113cdf0e10cSrcweir { 114cdf0e10cSrcweir ImplInitWorkWindowData(); 115cdf0e10cSrcweir ImplInit( pParent, nStyle, NULL ); 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118cdf0e10cSrcweir // ----------------------------------------------------------------------- 119cdf0e10cSrcweir 120cdf0e10cSrcweir WorkWindow::WorkWindow( Window* pParent, const ResId& rResId ) : 121cdf0e10cSrcweir SystemWindow( WINDOW_WORKWINDOW ) 122cdf0e10cSrcweir { 123cdf0e10cSrcweir ImplInitWorkWindowData(); 124cdf0e10cSrcweir rResId.SetRT( RSC_WORKWIN ); 125cdf0e10cSrcweir WinBits nStyle = ImplInitRes( rResId ); 126cdf0e10cSrcweir ImplInit( pParent, nStyle ); 127cdf0e10cSrcweir ImplLoadRes( rResId ); 128cdf0e10cSrcweir } 129cdf0e10cSrcweir 130cdf0e10cSrcweir // ----------------------------------------------------------------------- 131cdf0e10cSrcweir 132cdf0e10cSrcweir WorkWindow::WorkWindow( Window* pParent, const ::com::sun::star::uno::Any& aSystemWorkWindowToken, WinBits nStyle ) : 133cdf0e10cSrcweir SystemWindow( WINDOW_WORKWINDOW ) 134cdf0e10cSrcweir { 135cdf0e10cSrcweir ImplInitWorkWindowData(); 136cdf0e10cSrcweir mbSysChild = sal_True; 137cdf0e10cSrcweir ImplInit( pParent, nStyle, aSystemWorkWindowToken ); 138cdf0e10cSrcweir } 139cdf0e10cSrcweir 140cdf0e10cSrcweir // ----------------------------------------------------------------------- 141cdf0e10cSrcweir 142cdf0e10cSrcweir WorkWindow::WorkWindow( SystemParentData* pParent ) : 143cdf0e10cSrcweir SystemWindow( WINDOW_WORKWINDOW ) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir ImplInitWorkWindowData(); 146cdf0e10cSrcweir mbSysChild = sal_True; 147cdf0e10cSrcweir ImplInit( NULL, 0, pParent ); 148cdf0e10cSrcweir } 149cdf0e10cSrcweir 150cdf0e10cSrcweir // ----------------------------------------------------------------------- 151cdf0e10cSrcweir 152cdf0e10cSrcweir void WorkWindow::ImplLoadRes( const ResId& rResId ) 153cdf0e10cSrcweir { 154cdf0e10cSrcweir SystemWindow::ImplLoadRes( rResId ); 155cdf0e10cSrcweir 156cdf0e10cSrcweir ReadLongRes(); 157cdf0e10cSrcweir if ( !(rResId.GetWinBits() & WB_HIDE) && (RSC_WORKWIN == rResId.GetRT()) ) 158cdf0e10cSrcweir Show(); 159cdf0e10cSrcweir } 160cdf0e10cSrcweir 161cdf0e10cSrcweir // ----------------------------------------------------------------------- 162cdf0e10cSrcweir 163cdf0e10cSrcweir WorkWindow::~WorkWindow() 164cdf0e10cSrcweir { 165cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 166cdf0e10cSrcweir if ( pSVData->maWinData.mpAppWin == this ) 167cdf0e10cSrcweir { 168cdf0e10cSrcweir pSVData->maWinData.mpAppWin = NULL; 169cdf0e10cSrcweir Application::Quit(); 170cdf0e10cSrcweir } 171cdf0e10cSrcweir } 172cdf0e10cSrcweir 173cdf0e10cSrcweir // ----------------------------------------------------------------------- 174cdf0e10cSrcweir 175cdf0e10cSrcweir void WorkWindow::ShowFullScreenMode( sal_Bool bFullScreenMode, sal_Int32 nDisplay ) 176cdf0e10cSrcweir { 177cdf0e10cSrcweir if ( !mbFullScreenMode == !bFullScreenMode ) 178cdf0e10cSrcweir return; 179cdf0e10cSrcweir 180cdf0e10cSrcweir if( (nDisplay < -1) 181cdf0e10cSrcweir || (nDisplay >= static_cast<sal_Int32>(Application::GetScreenCount()) ) ) 182cdf0e10cSrcweir { 183cdf0e10cSrcweir nDisplay = GetScreenNumber(); 184cdf0e10cSrcweir } 185cdf0e10cSrcweir 186cdf0e10cSrcweir mbFullScreenMode = bFullScreenMode != 0; 187cdf0e10cSrcweir if ( !mbSysChild ) 188cdf0e10cSrcweir { 189cdf0e10cSrcweir mpWindowImpl->mpFrameWindow->mpWindowImpl->mbWaitSystemResize = sal_True; 190cdf0e10cSrcweir ImplGetFrame()->ShowFullScreen( bFullScreenMode, nDisplay ); 191cdf0e10cSrcweir } 192cdf0e10cSrcweir } 193cdf0e10cSrcweir 194cdf0e10cSrcweir // ----------------------------------------------------------------------- 195cdf0e10cSrcweir 196cdf0e10cSrcweir void WorkWindow::StartPresentationMode( sal_Bool bPresentation, sal_uInt16 nFlags, sal_Int32 nDisplay ) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir if ( !bPresentation == !mbPresentationMode ) 199cdf0e10cSrcweir return; 200cdf0e10cSrcweir 201cdf0e10cSrcweir if ( bPresentation ) 202cdf0e10cSrcweir { 203cdf0e10cSrcweir mbPresentationMode = sal_True; 204cdf0e10cSrcweir mbPresentationVisible = IsVisible(); 205cdf0e10cSrcweir mbPresentationFull = mbFullScreenMode; 206cdf0e10cSrcweir mnPresentationFlags = nFlags; 207cdf0e10cSrcweir 208cdf0e10cSrcweir if ( !(mnPresentationFlags & PRESENTATION_NOFULLSCREEN) ) 209cdf0e10cSrcweir ShowFullScreenMode( sal_True, nDisplay ); 210cdf0e10cSrcweir if ( !mbSysChild ) 211cdf0e10cSrcweir { 212cdf0e10cSrcweir if ( mnPresentationFlags & PRESENTATION_HIDEALLAPPS ) 213cdf0e10cSrcweir mpWindowImpl->mpFrame->SetAlwaysOnTop( sal_True ); 214cdf0e10cSrcweir if ( !(mnPresentationFlags & PRESENTATION_NOAUTOSHOW) ) 215cdf0e10cSrcweir ToTop(); 216cdf0e10cSrcweir mpWindowImpl->mpFrame->StartPresentation( sal_True ); 217cdf0e10cSrcweir } 218cdf0e10cSrcweir 219cdf0e10cSrcweir if ( !(mnPresentationFlags & PRESENTATION_NOAUTOSHOW) ) 220cdf0e10cSrcweir Show(); 221cdf0e10cSrcweir } 222cdf0e10cSrcweir else 223cdf0e10cSrcweir { 224cdf0e10cSrcweir Show( mbPresentationVisible ); 225cdf0e10cSrcweir if ( !mbSysChild ) 226cdf0e10cSrcweir { 227cdf0e10cSrcweir mpWindowImpl->mpFrame->StartPresentation( sal_False ); 228cdf0e10cSrcweir if ( mnPresentationFlags & PRESENTATION_HIDEALLAPPS ) 229cdf0e10cSrcweir mpWindowImpl->mpFrame->SetAlwaysOnTop( sal_False ); 230cdf0e10cSrcweir } 231cdf0e10cSrcweir ShowFullScreenMode( mbPresentationFull, nDisplay ); 232cdf0e10cSrcweir 233cdf0e10cSrcweir mbPresentationMode = sal_False; 234cdf0e10cSrcweir mbPresentationVisible = sal_False; 235cdf0e10cSrcweir mbPresentationFull = sal_False; 236cdf0e10cSrcweir mnPresentationFlags = 0; 237cdf0e10cSrcweir } 238cdf0e10cSrcweir } 239cdf0e10cSrcweir 240cdf0e10cSrcweir // ----------------------------------------------------------------------- 241cdf0e10cSrcweir 242cdf0e10cSrcweir sal_Bool WorkWindow::IsMinimized() const 243cdf0e10cSrcweir { 244cdf0e10cSrcweir //return mpWindowImpl->mpFrameData->mbMinimized; 245cdf0e10cSrcweir SalFrameState aState; 246cdf0e10cSrcweir mpWindowImpl->mpFrame->GetWindowState(&aState); 247cdf0e10cSrcweir return (( aState.mnState & SAL_FRAMESTATE_MINIMIZED ) != 0); 248cdf0e10cSrcweir } 249cdf0e10cSrcweir 250cdf0e10cSrcweir // ----------------------------------------------------------------------- 251cdf0e10cSrcweir 252cdf0e10cSrcweir sal_Bool WorkWindow::SetPluginParent( SystemParentData* pParent ) 253cdf0e10cSrcweir { 254cdf0e10cSrcweir DBG_ASSERT( ! mbPresentationMode && ! mbFullScreenMode, "SetPluginParent in fullscreen or presentation mode !" ); 255cdf0e10cSrcweir 256cdf0e10cSrcweir bool bWasDnd = Window::ImplStopDnd(); 257cdf0e10cSrcweir 258cdf0e10cSrcweir sal_Bool bShown = IsVisible(); 259cdf0e10cSrcweir Show( sal_False ); 260cdf0e10cSrcweir sal_Bool bRet = mpWindowImpl->mpFrame->SetPluginParent( pParent ); 261cdf0e10cSrcweir Show( bShown ); 262cdf0e10cSrcweir 263cdf0e10cSrcweir if( bWasDnd ) 264cdf0e10cSrcweir Window::ImplStartDnd(); 265cdf0e10cSrcweir 266cdf0e10cSrcweir return bRet; 267cdf0e10cSrcweir } 268cdf0e10cSrcweir 269cdf0e10cSrcweir void WorkWindow::ImplSetFrameState( sal_uLong aFrameState ) 270cdf0e10cSrcweir { 271cdf0e10cSrcweir SalFrameState aState; 272cdf0e10cSrcweir aState.mnMask = SAL_FRAMESTATE_MASK_STATE; 273cdf0e10cSrcweir aState.mnState = aFrameState; 274cdf0e10cSrcweir mpWindowImpl->mpFrame->SetWindowState( &aState ); 275cdf0e10cSrcweir } 276cdf0e10cSrcweir 277cdf0e10cSrcweir 278cdf0e10cSrcweir void WorkWindow::Minimize() 279cdf0e10cSrcweir { 280cdf0e10cSrcweir ImplSetFrameState( SAL_FRAMESTATE_MINIMIZED ); 281cdf0e10cSrcweir } 282cdf0e10cSrcweir 283cdf0e10cSrcweir void WorkWindow::Restore() 284cdf0e10cSrcweir { 285cdf0e10cSrcweir ImplSetFrameState( SAL_FRAMESTATE_NORMAL ); 286cdf0e10cSrcweir } 287cdf0e10cSrcweir 288cdf0e10cSrcweir sal_Bool WorkWindow::Close() 289cdf0e10cSrcweir { 290cdf0e10cSrcweir sal_Bool bCanClose = SystemWindow::Close(); 291cdf0e10cSrcweir 292cdf0e10cSrcweir // Ist es das Applikationsfenster, dann beende die Applikation 293cdf0e10cSrcweir if ( bCanClose && ( ImplGetSVData()->maWinData.mpAppWin == this ) ) 294cdf0e10cSrcweir GetpApp()->Quit(); 295cdf0e10cSrcweir 296cdf0e10cSrcweir return bCanClose; 297cdf0e10cSrcweir } 298cdf0e10cSrcweir 299cdf0e10cSrcweir void WorkWindow::Maximize( sal_Bool bMaximize ) 300cdf0e10cSrcweir { 301cdf0e10cSrcweir ImplSetFrameState( bMaximize ? SAL_FRAMESTATE_MAXIMIZED : SAL_FRAMESTATE_NORMAL ); 302cdf0e10cSrcweir } 303cdf0e10cSrcweir 304cdf0e10cSrcweir sal_Bool WorkWindow::IsMaximized() const 305cdf0e10cSrcweir { 306cdf0e10cSrcweir sal_Bool bRet = sal_False; 307cdf0e10cSrcweir 308cdf0e10cSrcweir SalFrameState aState; 309cdf0e10cSrcweir if( mpWindowImpl->mpFrame->GetWindowState( &aState ) ) 310cdf0e10cSrcweir { 311cdf0e10cSrcweir if( aState.mnState & (SAL_FRAMESTATE_MAXIMIZED | 312cdf0e10cSrcweir SAL_FRAMESTATE_MAXIMIZED_HORZ | 313cdf0e10cSrcweir SAL_FRAMESTATE_MAXIMIZED_VERT ) ) 314cdf0e10cSrcweir bRet = sal_True; 315cdf0e10cSrcweir } 316cdf0e10cSrcweir return bRet; 317cdf0e10cSrcweir } 318