Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include <tools/debug.hxx>
22 : #include <tools/rc.h>
23 :
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>
31 :
32 : #include <svdata.hxx>
33 : #include <salframe.hxx>
34 : #include <brdwin.hxx>
35 : #include <window.h>
36 :
37 : // =======================================================================
38 :
39 263 : void WorkWindow::ImplInitWorkWindowData()
40 : {
41 263 : mnIcon = 0; // Should be removed in the next top level update - now in SystemWindow
42 :
43 263 : mnPresentationFlags = 0;
44 263 : mbPresentationMode = sal_False;
45 263 : mbPresentationVisible = sal_False;
46 263 : mbPresentationFull = sal_False;
47 263 : mbFullScreenMode = sal_False;
48 263 : }
49 :
50 : // -----------------------------------------------------------------------
51 :
52 263 : void WorkWindow::ImplInit( Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData )
53 : {
54 263 : sal_uInt16 nFrameStyle = BORDERWINDOW_STYLE_FRAME;
55 263 : if ( nStyle & WB_APP )
56 0 : nFrameStyle |= BORDERWINDOW_STYLE_APP;
57 :
58 263 : ImplBorderWindow* pBorderWin = new ImplBorderWindow( pParent, pSystemParentData, nStyle, nFrameStyle );
59 263 : Window::ImplInit( pBorderWin, nStyle & (WB_3DLOOK | WB_CLIPCHILDREN | WB_DIALOGCONTROL | WB_SYSTEMFLOATWIN), NULL );
60 263 : pBorderWin->mpWindowImpl->mpClientWindow = this;
61 263 : pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
62 263 : mpWindowImpl->mpBorderWindow = pBorderWin;
63 :
64 : // mpWindowImpl->mpRealParent = pParent; // should actually be set, but is not set due to errors with the menubar!!
65 :
66 263 : if ( nStyle & WB_APP )
67 : {
68 0 : ImplSVData* pSVData = ImplGetSVData();
69 : DBG_ASSERT( !pSVData->maWinData.mpAppWin, "WorkWindow::WorkWindow(): More than one window with style WB_APP" );
70 0 : pSVData->maWinData.mpAppWin = this;
71 : }
72 :
73 263 : SetActivateMode( ACTIVATE_MODE_GRABFOCUS );
74 263 : }
75 :
76 : // -----------------------------------------------------------------------
77 :
78 0 : void WorkWindow::ImplInit( Window* pParent, WinBits nStyle, const ::com::sun::star::uno::Any& aSystemWorkWindowToken )
79 : {
80 0 : if( aSystemWorkWindowToken.hasValue() )
81 : {
82 0 : ::com::sun::star::uno::Sequence< sal_Int8 > aSeq;
83 0 : aSystemWorkWindowToken >>= aSeq;
84 0 : 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 0 : ImplInit( pParent, 0, pData );
88 : }
89 : else
90 0 : ImplInit( pParent, nStyle, NULL );
91 0 : }
92 :
93 : // -----------------------------------------------------------------------
94 :
95 0 : WorkWindow::WorkWindow( WindowType nType ) :
96 0 : SystemWindow( nType )
97 : {
98 0 : ImplInitWorkWindowData();
99 0 : }
100 :
101 : #ifdef ANDROID
102 :
103 : extern "C" void *
104 : createWindowFoo(void)
105 : {
106 : return (void*) new WorkWindow((Window *)NULL);
107 : }
108 :
109 : #endif
110 :
111 : // -----------------------------------------------------------------------
112 :
113 263 : WorkWindow::WorkWindow( Window* pParent, WinBits nStyle ) :
114 263 : SystemWindow( WINDOW_WORKWINDOW )
115 : {
116 263 : ImplInitWorkWindowData();
117 263 : ImplInit( pParent, nStyle, NULL );
118 263 : }
119 :
120 : // -----------------------------------------------------------------------
121 :
122 0 : WorkWindow::WorkWindow( Window* pParent, const ::com::sun::star::uno::Any& aSystemWorkWindowToken, WinBits nStyle ) :
123 0 : SystemWindow( WINDOW_WORKWINDOW )
124 : {
125 0 : ImplInitWorkWindowData();
126 0 : mbSysChild = sal_True;
127 0 : ImplInit( pParent, nStyle, aSystemWorkWindowToken );
128 0 : }
129 :
130 : // -----------------------------------------------------------------------
131 :
132 0 : WorkWindow::WorkWindow( SystemParentData* pParent ) :
133 0 : SystemWindow( WINDOW_WORKWINDOW )
134 : {
135 0 : ImplInitWorkWindowData();
136 0 : mbSysChild = sal_True;
137 0 : ImplInit( NULL, 0, pParent );
138 0 : }
139 :
140 : // -----------------------------------------------------------------------
141 :
142 189 : WorkWindow::~WorkWindow()
143 : {
144 63 : ImplSVData* pSVData = ImplGetSVData();
145 63 : if ( pSVData->maWinData.mpAppWin == this )
146 : {
147 0 : pSVData->maWinData.mpAppWin = NULL;
148 0 : Application::Quit();
149 : }
150 126 : }
151 :
152 : // -----------------------------------------------------------------------
153 :
154 0 : void WorkWindow::ShowFullScreenMode( sal_Bool bFullScreenMode )
155 : {
156 0 : return ShowFullScreenMode( bFullScreenMode, GetScreenNumber());
157 : }
158 :
159 0 : void WorkWindow::ShowFullScreenMode( sal_Bool bFullScreenMode, sal_Int32 nDisplayScreen )
160 : {
161 0 : if ( !mbFullScreenMode == !bFullScreenMode )
162 0 : return;
163 :
164 0 : mbFullScreenMode = bFullScreenMode != 0;
165 0 : if ( !mbSysChild )
166 : {
167 : // Dispose of the canvas implementation, which might rely on
168 : // screen-specific system data.
169 0 : com::sun::star::uno::Reference< com::sun::star::rendering::XCanvas > xCanvas( mpWindowImpl->mxCanvas );
170 0 : if( xCanvas.is() )
171 : {
172 : com::sun::star::uno::Reference< com::sun::star::lang::XComponent >
173 : xCanvasComponent( xCanvas,
174 0 : com::sun::star::uno::UNO_QUERY );
175 0 : if( xCanvasComponent.is() )
176 0 : xCanvasComponent->dispose();
177 : }
178 :
179 0 : mpWindowImpl->mpFrameWindow->mpWindowImpl->mbWaitSystemResize = sal_True;
180 0 : ImplGetFrame()->ShowFullScreen( bFullScreenMode, nDisplayScreen );
181 : }
182 : }
183 :
184 : // -----------------------------------------------------------------------
185 :
186 0 : void WorkWindow::StartPresentationMode( sal_Bool bPresentation, sal_uInt16 nFlags )
187 : {
188 0 : return StartPresentationMode( bPresentation, nFlags, GetScreenNumber());
189 : }
190 :
191 0 : void WorkWindow::StartPresentationMode( sal_Bool bPresentation, sal_uInt16 nFlags, sal_Int32 nDisplayScreen )
192 : {
193 0 : if ( !bPresentation == !mbPresentationMode )
194 0 : return;
195 :
196 0 : if ( bPresentation )
197 : {
198 0 : mbPresentationMode = sal_True;
199 0 : mbPresentationVisible = IsVisible();
200 0 : mbPresentationFull = mbFullScreenMode;
201 0 : mnPresentationFlags = nFlags;
202 :
203 0 : if ( !(mnPresentationFlags & PRESENTATION_NOFULLSCREEN) )
204 0 : ShowFullScreenMode( sal_True, nDisplayScreen );
205 0 : if ( !mbSysChild )
206 : {
207 0 : if ( mnPresentationFlags & PRESENTATION_HIDEALLAPPS )
208 0 : mpWindowImpl->mpFrame->SetAlwaysOnTop( sal_True );
209 0 : if ( !(mnPresentationFlags & PRESENTATION_NOAUTOSHOW) )
210 0 : ToTop();
211 0 : mpWindowImpl->mpFrame->StartPresentation( sal_True );
212 : }
213 :
214 0 : if ( !(mnPresentationFlags & PRESENTATION_NOAUTOSHOW) )
215 0 : Show();
216 : }
217 : else
218 : {
219 0 : Show( mbPresentationVisible );
220 0 : if ( !mbSysChild )
221 : {
222 0 : mpWindowImpl->mpFrame->StartPresentation( sal_False );
223 0 : if ( mnPresentationFlags & PRESENTATION_HIDEALLAPPS )
224 0 : mpWindowImpl->mpFrame->SetAlwaysOnTop( sal_False );
225 : }
226 0 : ShowFullScreenMode( mbPresentationFull, nDisplayScreen );
227 :
228 0 : mbPresentationMode = sal_False;
229 0 : mbPresentationVisible = sal_False;
230 0 : mbPresentationFull = sal_False;
231 0 : mnPresentationFlags = 0;
232 : }
233 : }
234 :
235 : // -----------------------------------------------------------------------
236 :
237 347 : sal_Bool WorkWindow::IsMinimized() const
238 : {
239 : //return mpWindowImpl->mpFrameData->mbMinimized;
240 : SalFrameState aState;
241 347 : mpWindowImpl->mpFrame->GetWindowState(&aState);
242 347 : return (( aState.mnState & SAL_FRAMESTATE_MINIMIZED ) != 0);
243 : }
244 :
245 : // -----------------------------------------------------------------------
246 :
247 0 : sal_Bool WorkWindow::SetPluginParent( SystemParentData* pParent )
248 : {
249 : DBG_ASSERT( ! mbPresentationMode && ! mbFullScreenMode, "SetPluginParent in fullscreen or presentation mode !" );
250 :
251 0 : bool bWasDnd = Window::ImplStopDnd();
252 :
253 0 : sal_Bool bShown = IsVisible();
254 0 : Show( sal_False );
255 0 : sal_Bool bRet = mpWindowImpl->mpFrame->SetPluginParent( pParent );
256 0 : Show( bShown );
257 :
258 0 : if( bWasDnd )
259 0 : Window::ImplStartDnd();
260 :
261 0 : return bRet;
262 : }
263 :
264 0 : void WorkWindow::ImplSetFrameState( sal_uLong aFrameState )
265 : {
266 : SalFrameState aState;
267 0 : aState.mnMask = SAL_FRAMESTATE_MASK_STATE;
268 0 : aState.mnState = aFrameState;
269 0 : mpWindowImpl->mpFrame->SetWindowState( &aState );
270 0 : }
271 :
272 :
273 0 : void WorkWindow::Minimize()
274 : {
275 0 : ImplSetFrameState( SAL_FRAMESTATE_MINIMIZED );
276 0 : }
277 :
278 0 : void WorkWindow::Restore()
279 : {
280 0 : ImplSetFrameState( SAL_FRAMESTATE_NORMAL );
281 0 : }
282 :
283 0 : sal_Bool WorkWindow::Close()
284 : {
285 0 : sal_Bool bCanClose = SystemWindow::Close();
286 :
287 : // Ist es das Applikationsfenster, dann beende die Applikation
288 0 : if ( bCanClose && ( ImplGetSVData()->maWinData.mpAppWin == this ) )
289 0 : GetpApp()->Quit();
290 :
291 0 : return bCanClose;
292 : }
293 :
294 0 : void WorkWindow::Maximize( sal_Bool bMaximize )
295 : {
296 0 : ImplSetFrameState( bMaximize ? SAL_FRAMESTATE_MAXIMIZED : SAL_FRAMESTATE_NORMAL );
297 0 : }
298 :
299 0 : sal_Bool WorkWindow::IsMaximized() const
300 : {
301 0 : sal_Bool bRet = sal_False;
302 :
303 : SalFrameState aState;
304 0 : if( mpWindowImpl->mpFrame->GetWindowState( &aState ) )
305 : {
306 0 : if( aState.mnState & (SAL_FRAMESTATE_MAXIMIZED |
307 : SAL_FRAMESTATE_MAXIMIZED_HORZ |
308 : SAL_FRAMESTATE_MAXIMIZED_VERT ) )
309 0 : bRet = sal_True;
310 : }
311 0 : return bRet;
312 : }
313 :
314 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|