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