1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #include <tools/debug.hxx>
23 #include <vcl/svapp.hxx>
24 #include <vcl/wrkwin.hxx>
25 // declare system types in sysdata.hxx
26 #include <vcl/sysdata.hxx>
27 #include <com/sun/star/lang/XComponent.hpp>
28 #include <com/sun/star/rendering/XCanvas.hpp>
31 #include <salframe.hxx>
35 void WorkWindow::ImplInitWorkWindowData()
37 mnIcon
= 0; // Should be removed in the next top level update - now in SystemWindow
39 mnPresentationFlags
= PresentationFlags::NONE
;
40 mbPresentationMode
= false;
41 mbPresentationVisible
= false;
42 mbPresentationFull
= false;
43 mbFullScreenMode
= false;
45 maLayoutIdle
.SetDebugName( "vcl::WorkWindow maLayoutIdle" );
48 void WorkWindow::ImplInit( vcl::Window
* pParent
, WinBits nStyle
, SystemParentData
* pSystemParentData
)
50 BorderWindowStyle nFrameStyle
= BorderWindowStyle::Frame
;
51 if ( nStyle
& WB_APP
)
52 nFrameStyle
|= BorderWindowStyle::App
;
54 VclPtrInstance
<ImplBorderWindow
> pBorderWin( pParent
, pSystemParentData
, nStyle
, nFrameStyle
);
55 Window::ImplInit( pBorderWin
, nStyle
& (WB_3DLOOK
| WB_CLIPCHILDREN
| WB_DIALOGCONTROL
| WB_SYSTEMFLOATWIN
), nullptr );
56 pBorderWin
->mpWindowImpl
->mpClientWindow
= this;
57 pBorderWin
->GetBorder( mpWindowImpl
->mnLeftBorder
, mpWindowImpl
->mnTopBorder
, mpWindowImpl
->mnRightBorder
, mpWindowImpl
->mnBottomBorder
);
58 mpWindowImpl
->mpBorderWindow
= pBorderWin
;
60 // mpWindowImpl->mpRealParent = pParent; // should actually be set, but is not set due to errors with the menubar!!
62 if ( nStyle
& WB_APP
)
64 ImplSVData
* pSVData
= ImplGetSVData();
65 SAL_WARN_IF( pSVData
->maWinData
.mpAppWin
, "vcl", "WorkWindow::WorkWindow(): More than one window with style WB_APP" );
66 pSVData
->maWinData
.mpAppWin
= this;
69 SetActivateMode( ActivateModeFlags::GrabFocus
);
72 void WorkWindow::ImplInit( vcl::Window
* pParent
, WinBits nStyle
, const css::uno::Any
& aSystemWorkWindowToken
)
74 if( aSystemWorkWindowToken
.hasValue() )
76 css::uno::Sequence
< sal_Int8
> aSeq
;
77 aSystemWorkWindowToken
>>= aSeq
;
78 SystemParentData
* pData
= reinterpret_cast<SystemParentData
*>(aSeq
.getArray());
79 SAL_WARN_IF( aSeq
.getLength() != sizeof( SystemParentData
) || pData
->nSize
!= sizeof( SystemParentData
), "vcl", "WorkWindow::WorkWindow( vcl::Window*, const Any&, WinBits ) called with invalid Any" );
80 // init with style 0 as does WorkWindow::WorkWindow( SystemParentData* );
81 ImplInit( pParent
, 0, pData
);
84 ImplInit( pParent
, nStyle
);
87 WorkWindow::WorkWindow( WindowType nType
) :
90 ImplInitWorkWindowData();
93 WorkWindow::WorkWindow( vcl::Window
* pParent
, WinBits nStyle
) :
94 SystemWindow( WINDOW_WORKWINDOW
)
96 ImplInitWorkWindowData();
97 ImplInit( pParent
, nStyle
);
100 WorkWindow::WorkWindow( vcl::Window
* pParent
, const css::uno::Any
& aSystemWorkWindowToken
, WinBits nStyle
) :
101 SystemWindow( WINDOW_WORKWINDOW
)
103 ImplInitWorkWindowData();
105 ImplInit( pParent
, nStyle
, aSystemWorkWindowToken
);
108 WorkWindow::WorkWindow( SystemParentData
* pParent
) :
109 SystemWindow( WINDOW_WORKWINDOW
)
111 ImplInitWorkWindowData();
113 ImplInit( nullptr, 0, pParent
);
116 WorkWindow::~WorkWindow()
121 void WorkWindow::dispose()
123 ImplSVData
* pSVData
= ImplGetSVData();
124 if ( pSVData
->maWinData
.mpAppWin
== this )
126 pSVData
->maWinData
.mpAppWin
= nullptr;
129 SystemWindow::dispose();
132 void WorkWindow::ShowFullScreenMode( bool bFullScreenMode
)
134 return ShowFullScreenMode( bFullScreenMode
, GetScreenNumber());
137 void WorkWindow::ShowFullScreenMode( bool bFullScreenMode
, sal_Int32 nDisplayScreen
)
139 if ( !mbFullScreenMode
== !bFullScreenMode
)
142 mbFullScreenMode
= bFullScreenMode
;
145 // Dispose of the canvas implementation, which might rely on
146 // screen-specific system data.
147 css::uno::Reference
< css::rendering::XCanvas
> xCanvas( mpWindowImpl
->mxCanvas
);
150 css::uno::Reference
< css::lang::XComponent
> xCanvasComponent( xCanvas
, css::uno::UNO_QUERY
);
151 if( xCanvasComponent
.is() )
152 xCanvasComponent
->dispose();
155 mpWindowImpl
->mpFrameWindow
->mpWindowImpl
->mbWaitSystemResize
= true;
156 ImplGetFrame()->ShowFullScreen( bFullScreenMode
, nDisplayScreen
);
160 void WorkWindow::StartPresentationMode( PresentationFlags nFlags
)
162 return StartPresentationMode( false/*bPresentation*/, nFlags
, GetScreenNumber());
165 void WorkWindow::StartPresentationMode( bool bPresentation
, PresentationFlags nFlags
, sal_uInt32 nDisplayScreen
)
167 if ( !bPresentation
== !mbPresentationMode
)
172 mbPresentationMode
= true;
173 mbPresentationVisible
= IsVisible();
174 mbPresentationFull
= mbFullScreenMode
;
175 mnPresentationFlags
= nFlags
;
177 if ( !(mnPresentationFlags
& PresentationFlags::NoFullScreen
) )
178 ShowFullScreenMode( true, nDisplayScreen
);
181 if ( mnPresentationFlags
& PresentationFlags::HideAllApps
)
182 mpWindowImpl
->mpFrame
->SetAlwaysOnTop( true );
183 if ( !(mnPresentationFlags
& PresentationFlags::NoAutoShow
) )
185 mpWindowImpl
->mpFrame
->StartPresentation( true );
188 if ( !(mnPresentationFlags
& PresentationFlags::NoAutoShow
) )
193 Show( mbPresentationVisible
);
196 mpWindowImpl
->mpFrame
->StartPresentation( false );
197 if ( mnPresentationFlags
& PresentationFlags::HideAllApps
)
198 mpWindowImpl
->mpFrame
->SetAlwaysOnTop( false );
200 ShowFullScreenMode( mbPresentationFull
, nDisplayScreen
);
202 mbPresentationMode
= false;
203 mbPresentationVisible
= false;
204 mbPresentationFull
= false;
205 mnPresentationFlags
= PresentationFlags::NONE
;
209 bool WorkWindow::IsMinimized() const
211 //return mpWindowImpl->mpFrameData->mbMinimized;
212 SalFrameState aState
;
213 if (mpWindowImpl
->mpFrame
->GetWindowState(&aState
))
214 return bool(aState
.mnState
& WindowStateState::Minimized
);
219 bool WorkWindow::SetPluginParent( SystemParentData
* pParent
)
221 SAL_WARN_IF( mbPresentationMode
|| mbFullScreenMode
, "vcl", "SetPluginParent in fullscreen or presentation mode !" );
223 bool bWasDnd
= Window::ImplStopDnd();
225 bool bShown
= IsVisible();
227 bool bRet
= mpWindowImpl
->mpFrame
->SetPluginParent( pParent
);
231 Window::ImplStartDnd();
236 void WorkWindow::ImplSetFrameState( WindowStateState aFrameState
)
238 SalFrameState aState
;
239 aState
.mnMask
= WindowStateMask::State
;
240 aState
.mnState
= aFrameState
;
241 mpWindowImpl
->mpFrame
->SetWindowState( &aState
);
244 void WorkWindow::Minimize()
246 ImplSetFrameState( WindowStateState::Minimized
);
249 void WorkWindow::Restore()
251 ImplSetFrameState( WindowStateState::Normal
);
254 bool WorkWindow::Close()
256 bool bCanClose
= SystemWindow::Close();
258 // Ist es das Applikationsfenster, dann beende die Applikation
259 if ( bCanClose
&& ( ImplGetSVData()->maWinData
.mpAppWin
== this ) )
265 void WorkWindow::Maximize( bool bMaximize
)
267 ImplSetFrameState( bMaximize
? WindowStateState::Maximized
: WindowStateState::Normal
);
270 bool WorkWindow::IsMaximized() const
274 SalFrameState aState
;
275 if( mpWindowImpl
->mpFrame
->GetWindowState( &aState
) )
277 if( aState
.mnState
& (WindowStateState::Maximized
|
278 WindowStateState::MaximizedHorz
|
279 WindowStateState::MaximizedVert
) )
285 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */