Version 4.2.0.1, tag libreoffice-4.2.0.1
[LibreOffice.git] / vcl / source / window / wrkwin.cxx
blob3746f295846501748f98eabcf8a014266977e02b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <tools/debug.hxx>
22 #include <tools/rc.h>
24 #include <vcl/svapp.hxx>
25 #include <vcl/wrkwin.hxx>
26 // declare system types in sysdata.hxx
27 #include <svsys.h>
28 #include <vcl/sysdata.hxx>
29 #include <com/sun/star/lang/XComponent.hpp>
30 #include <com/sun/star/rendering/XCanvas.hpp>
32 #include <svdata.hxx>
33 #include <salframe.hxx>
34 #include <brdwin.hxx>
35 #include <window.h>
37 // =======================================================================
39 void WorkWindow::ImplInitWorkWindowData()
41 mnIcon = 0; // Should be removed in the next top level update - now in SystemWindow
43 mnPresentationFlags = 0;
44 mbPresentationMode = sal_False;
45 mbPresentationVisible = sal_False;
46 mbPresentationFull = sal_False;
47 mbFullScreenMode = sal_False;
50 // -----------------------------------------------------------------------
52 void WorkWindow::ImplInit( Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData )
54 sal_uInt16 nFrameStyle = BORDERWINDOW_STYLE_FRAME;
55 if ( nStyle & WB_APP )
56 nFrameStyle |= BORDERWINDOW_STYLE_APP;
58 ImplBorderWindow* pBorderWin = new ImplBorderWindow( pParent, pSystemParentData, nStyle, nFrameStyle );
59 Window::ImplInit( pBorderWin, nStyle & (WB_3DLOOK | WB_CLIPCHILDREN | WB_DIALOGCONTROL | WB_SYSTEMFLOATWIN), NULL );
60 pBorderWin->mpWindowImpl->mpClientWindow = this;
61 pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
62 mpWindowImpl->mpBorderWindow = pBorderWin;
64 // mpWindowImpl->mpRealParent = pParent; // should actually be set, but is not set due to errors with the menubar!!
66 if ( nStyle & WB_APP )
68 ImplSVData* pSVData = ImplGetSVData();
69 DBG_ASSERT( !pSVData->maWinData.mpAppWin, "WorkWindow::WorkWindow(): More than one window with style WB_APP" );
70 pSVData->maWinData.mpAppWin = this;
73 SetActivateMode( ACTIVATE_MODE_GRABFOCUS );
76 // -----------------------------------------------------------------------
78 void WorkWindow::ImplInit( Window* pParent, WinBits nStyle, const ::com::sun::star::uno::Any& aSystemWorkWindowToken )
80 if( aSystemWorkWindowToken.hasValue() )
82 ::com::sun::star::uno::Sequence< sal_Int8 > aSeq;
83 aSystemWorkWindowToken >>= aSeq;
84 SystemParentData* pData = (SystemParentData*)aSeq.getArray();
85 DBG_ASSERT( aSeq.getLength() == sizeof( SystemParentData ) && pData->nSize == sizeof( SystemParentData ), "WorkWindow::WorkWindow( Window*, const Any&, WinBits ) called with invalid Any" );
86 // init with style 0 as does WorkWindow::WorkWindow( SystemParentData* );
87 ImplInit( pParent, 0, pData );
89 else
90 ImplInit( pParent, nStyle, NULL );
93 // -----------------------------------------------------------------------
95 WorkWindow::WorkWindow( WindowType nType ) :
96 SystemWindow( nType )
98 ImplInitWorkWindowData();
101 // -----------------------------------------------------------------------
103 WorkWindow::WorkWindow( Window* pParent, WinBits nStyle ) :
104 SystemWindow( WINDOW_WORKWINDOW )
106 ImplInitWorkWindowData();
107 ImplInit( pParent, nStyle, NULL );
110 // -----------------------------------------------------------------------
112 WorkWindow::WorkWindow( Window* pParent, const ::com::sun::star::uno::Any& aSystemWorkWindowToken, WinBits nStyle ) :
113 SystemWindow( WINDOW_WORKWINDOW )
115 ImplInitWorkWindowData();
116 mbSysChild = sal_True;
117 ImplInit( pParent, nStyle, aSystemWorkWindowToken );
120 // -----------------------------------------------------------------------
122 WorkWindow::WorkWindow( SystemParentData* pParent ) :
123 SystemWindow( WINDOW_WORKWINDOW )
125 ImplInitWorkWindowData();
126 mbSysChild = sal_True;
127 ImplInit( NULL, 0, pParent );
130 // -----------------------------------------------------------------------
132 WorkWindow::~WorkWindow()
134 ImplSVData* pSVData = ImplGetSVData();
135 if ( pSVData->maWinData.mpAppWin == this )
137 pSVData->maWinData.mpAppWin = NULL;
138 Application::Quit();
142 // -----------------------------------------------------------------------
144 void WorkWindow::ShowFullScreenMode( sal_Bool bFullScreenMode )
146 return ShowFullScreenMode( bFullScreenMode, GetScreenNumber());
149 void WorkWindow::ShowFullScreenMode( sal_Bool bFullScreenMode, sal_Int32 nDisplayScreen )
151 if ( !mbFullScreenMode == !bFullScreenMode )
152 return;
154 mbFullScreenMode = bFullScreenMode != 0;
155 if ( !mbSysChild )
157 // Dispose of the canvas implementation, which might rely on
158 // screen-specific system data.
159 com::sun::star::uno::Reference< com::sun::star::rendering::XCanvas > xCanvas( mpWindowImpl->mxCanvas );
160 if( xCanvas.is() )
162 com::sun::star::uno::Reference< com::sun::star::lang::XComponent >
163 xCanvasComponent( xCanvas,
164 com::sun::star::uno::UNO_QUERY );
165 if( xCanvasComponent.is() )
166 xCanvasComponent->dispose();
169 mpWindowImpl->mpFrameWindow->mpWindowImpl->mbWaitSystemResize = sal_True;
170 ImplGetFrame()->ShowFullScreen( bFullScreenMode, nDisplayScreen );
174 // -----------------------------------------------------------------------
176 void WorkWindow::StartPresentationMode( sal_Bool bPresentation, sal_uInt16 nFlags )
178 return StartPresentationMode( bPresentation, nFlags, GetScreenNumber());
181 void WorkWindow::StartPresentationMode( sal_Bool bPresentation, sal_uInt16 nFlags, sal_Int32 nDisplayScreen )
183 if ( !bPresentation == !mbPresentationMode )
184 return;
186 if ( bPresentation )
188 mbPresentationMode = sal_True;
189 mbPresentationVisible = IsVisible();
190 mbPresentationFull = mbFullScreenMode;
191 mnPresentationFlags = nFlags;
193 if ( !(mnPresentationFlags & PRESENTATION_NOFULLSCREEN) )
194 ShowFullScreenMode( sal_True, nDisplayScreen );
195 if ( !mbSysChild )
197 if ( mnPresentationFlags & PRESENTATION_HIDEALLAPPS )
198 mpWindowImpl->mpFrame->SetAlwaysOnTop( sal_True );
199 if ( !(mnPresentationFlags & PRESENTATION_NOAUTOSHOW) )
200 ToTop();
201 mpWindowImpl->mpFrame->StartPresentation( sal_True );
204 if ( !(mnPresentationFlags & PRESENTATION_NOAUTOSHOW) )
205 Show();
207 else
209 Show( mbPresentationVisible );
210 if ( !mbSysChild )
212 mpWindowImpl->mpFrame->StartPresentation( sal_False );
213 if ( mnPresentationFlags & PRESENTATION_HIDEALLAPPS )
214 mpWindowImpl->mpFrame->SetAlwaysOnTop( sal_False );
216 ShowFullScreenMode( mbPresentationFull, nDisplayScreen );
218 mbPresentationMode = sal_False;
219 mbPresentationVisible = sal_False;
220 mbPresentationFull = sal_False;
221 mnPresentationFlags = 0;
225 // -----------------------------------------------------------------------
227 sal_Bool WorkWindow::IsMinimized() const
229 //return mpWindowImpl->mpFrameData->mbMinimized;
230 SalFrameState aState;
231 mpWindowImpl->mpFrame->GetWindowState(&aState);
232 return (( aState.mnState & WINDOWSTATE_STATE_MINIMIZED ) != 0);
235 // -----------------------------------------------------------------------
237 sal_Bool WorkWindow::SetPluginParent( SystemParentData* pParent )
239 DBG_ASSERT( ! mbPresentationMode && ! mbFullScreenMode, "SetPluginParent in fullscreen or presentation mode !" );
241 bool bWasDnd = Window::ImplStopDnd();
243 sal_Bool bShown = IsVisible();
244 Show( sal_False );
245 sal_Bool bRet = mpWindowImpl->mpFrame->SetPluginParent( pParent );
246 Show( bShown );
248 if( bWasDnd )
249 Window::ImplStartDnd();
251 return bRet;
254 void WorkWindow::ImplSetFrameState( sal_uLong aFrameState )
256 SalFrameState aState;
257 aState.mnMask = WINDOWSTATE_MASK_STATE;
258 aState.mnState = aFrameState;
259 mpWindowImpl->mpFrame->SetWindowState( &aState );
263 void WorkWindow::Minimize()
265 ImplSetFrameState( WINDOWSTATE_STATE_MINIMIZED );
268 void WorkWindow::Restore()
270 ImplSetFrameState( WINDOWSTATE_STATE_NORMAL );
273 sal_Bool WorkWindow::Close()
275 sal_Bool bCanClose = SystemWindow::Close();
277 // Ist es das Applikationsfenster, dann beende die Applikation
278 if ( bCanClose && ( ImplGetSVData()->maWinData.mpAppWin == this ) )
279 GetpApp()->Quit();
281 return bCanClose;
284 void WorkWindow::Maximize( sal_Bool bMaximize )
286 ImplSetFrameState( bMaximize ? WINDOWSTATE_STATE_MAXIMIZED : WINDOWSTATE_STATE_NORMAL );
289 sal_Bool WorkWindow::IsMaximized() const
291 sal_Bool bRet = sal_False;
293 SalFrameState aState;
294 if( mpWindowImpl->mpFrame->GetWindowState( &aState ) )
296 if( aState.mnState & (WINDOWSTATE_STATE_MAXIMIZED |
297 WINDOWSTATE_STATE_MAXIMIZED_HORZ |
298 WINDOWSTATE_STATE_MAXIMIZED_VERT ) )
299 bRet = sal_True;
301 return bRet;
304 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */