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 1305 : void WorkWindow::ImplInitWorkWindowData()
40 : {
41 1305 : mnIcon = 0; // Should be removed in the next top level update - now in SystemWindow
42 :
43 1305 : mnPresentationFlags = 0;
44 1305 : mbPresentationMode = sal_False;
45 1305 : mbPresentationVisible = sal_False;
46 1305 : mbPresentationFull = sal_False;
47 1305 : mbFullScreenMode = sal_False;
48 1305 : }
49 :
50 : // -----------------------------------------------------------------------
51 :
52 1305 : void WorkWindow::ImplInit( Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData )
53 : {
54 1305 : sal_uInt16 nFrameStyle = BORDERWINDOW_STYLE_FRAME;
55 1305 : if ( nStyle & WB_APP )
56 0 : nFrameStyle |= BORDERWINDOW_STYLE_APP;
57 :
58 1305 : ImplBorderWindow* pBorderWin = new ImplBorderWindow( pParent, pSystemParentData, nStyle, nFrameStyle );
59 1305 : Window::ImplInit( pBorderWin, nStyle & (WB_3DLOOK | WB_CLIPCHILDREN | WB_DIALOGCONTROL | WB_SYSTEMFLOATWIN), NULL );
60 1305 : pBorderWin->mpWindowImpl->mpClientWindow = this;
61 1305 : pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
62 1305 : mpWindowImpl->mpBorderWindow = pBorderWin;
63 :
64 : // mpWindowImpl->mpRealParent = pParent; // should actually be set, but is not set due to errors with the menubar!!
65 :
66 1305 : 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 1305 : SetActivateMode( ACTIVATE_MODE_GRABFOCUS );
74 1305 : }
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 : // -----------------------------------------------------------------------
102 :
103 1305 : WorkWindow::WorkWindow( Window* pParent, WinBits nStyle ) :
104 1305 : SystemWindow( WINDOW_WORKWINDOW )
105 : {
106 1305 : ImplInitWorkWindowData();
107 1305 : ImplInit( pParent, nStyle, NULL );
108 1305 : }
109 :
110 : // -----------------------------------------------------------------------
111 :
112 0 : WorkWindow::WorkWindow( Window* pParent, const ::com::sun::star::uno::Any& aSystemWorkWindowToken, WinBits nStyle ) :
113 0 : SystemWindow( WINDOW_WORKWINDOW )
114 : {
115 0 : ImplInitWorkWindowData();
116 0 : mbSysChild = sal_True;
117 0 : ImplInit( pParent, nStyle, aSystemWorkWindowToken );
118 0 : }
119 :
120 : // -----------------------------------------------------------------------
121 :
122 0 : WorkWindow::WorkWindow( SystemParentData* pParent ) :
123 0 : SystemWindow( WINDOW_WORKWINDOW )
124 : {
125 0 : ImplInitWorkWindowData();
126 0 : mbSysChild = sal_True;
127 0 : ImplInit( NULL, 0, pParent );
128 0 : }
129 :
130 : // -----------------------------------------------------------------------
131 :
132 3752 : WorkWindow::~WorkWindow()
133 : {
134 1251 : ImplSVData* pSVData = ImplGetSVData();
135 1251 : if ( pSVData->maWinData.mpAppWin == this )
136 : {
137 0 : pSVData->maWinData.mpAppWin = NULL;
138 0 : Application::Quit();
139 : }
140 2501 : }
141 :
142 : // -----------------------------------------------------------------------
143 :
144 0 : void WorkWindow::ShowFullScreenMode( sal_Bool bFullScreenMode )
145 : {
146 0 : return ShowFullScreenMode( bFullScreenMode, GetScreenNumber());
147 : }
148 :
149 0 : void WorkWindow::ShowFullScreenMode( sal_Bool bFullScreenMode, sal_Int32 nDisplayScreen )
150 : {
151 0 : if ( !mbFullScreenMode == !bFullScreenMode )
152 0 : return;
153 :
154 0 : mbFullScreenMode = bFullScreenMode != 0;
155 0 : if ( !mbSysChild )
156 : {
157 : // Dispose of the canvas implementation, which might rely on
158 : // screen-specific system data.
159 0 : com::sun::star::uno::Reference< com::sun::star::rendering::XCanvas > xCanvas( mpWindowImpl->mxCanvas );
160 0 : if( xCanvas.is() )
161 : {
162 : com::sun::star::uno::Reference< com::sun::star::lang::XComponent >
163 : xCanvasComponent( xCanvas,
164 0 : com::sun::star::uno::UNO_QUERY );
165 0 : if( xCanvasComponent.is() )
166 0 : xCanvasComponent->dispose();
167 : }
168 :
169 0 : mpWindowImpl->mpFrameWindow->mpWindowImpl->mbWaitSystemResize = sal_True;
170 0 : ImplGetFrame()->ShowFullScreen( bFullScreenMode, nDisplayScreen );
171 : }
172 : }
173 :
174 : // -----------------------------------------------------------------------
175 :
176 0 : void WorkWindow::StartPresentationMode( sal_Bool bPresentation, sal_uInt16 nFlags )
177 : {
178 0 : return StartPresentationMode( bPresentation, nFlags, GetScreenNumber());
179 : }
180 :
181 0 : void WorkWindow::StartPresentationMode( sal_Bool bPresentation, sal_uInt16 nFlags, sal_Int32 nDisplayScreen )
182 : {
183 0 : if ( !bPresentation == !mbPresentationMode )
184 0 : return;
185 :
186 0 : if ( bPresentation )
187 : {
188 0 : mbPresentationMode = sal_True;
189 0 : mbPresentationVisible = IsVisible();
190 0 : mbPresentationFull = mbFullScreenMode;
191 0 : mnPresentationFlags = nFlags;
192 :
193 0 : if ( !(mnPresentationFlags & PRESENTATION_NOFULLSCREEN) )
194 0 : ShowFullScreenMode( sal_True, nDisplayScreen );
195 0 : if ( !mbSysChild )
196 : {
197 0 : if ( mnPresentationFlags & PRESENTATION_HIDEALLAPPS )
198 0 : mpWindowImpl->mpFrame->SetAlwaysOnTop( sal_True );
199 0 : if ( !(mnPresentationFlags & PRESENTATION_NOAUTOSHOW) )
200 0 : ToTop();
201 0 : mpWindowImpl->mpFrame->StartPresentation( sal_True );
202 : }
203 :
204 0 : if ( !(mnPresentationFlags & PRESENTATION_NOAUTOSHOW) )
205 0 : Show();
206 : }
207 : else
208 : {
209 0 : Show( mbPresentationVisible );
210 0 : if ( !mbSysChild )
211 : {
212 0 : mpWindowImpl->mpFrame->StartPresentation( sal_False );
213 0 : if ( mnPresentationFlags & PRESENTATION_HIDEALLAPPS )
214 0 : mpWindowImpl->mpFrame->SetAlwaysOnTop( sal_False );
215 : }
216 0 : ShowFullScreenMode( mbPresentationFull, nDisplayScreen );
217 :
218 0 : mbPresentationMode = sal_False;
219 0 : mbPresentationVisible = sal_False;
220 0 : mbPresentationFull = sal_False;
221 0 : mnPresentationFlags = 0;
222 : }
223 : }
224 :
225 : // -----------------------------------------------------------------------
226 :
227 2151 : sal_Bool WorkWindow::IsMinimized() const
228 : {
229 : //return mpWindowImpl->mpFrameData->mbMinimized;
230 : SalFrameState aState;
231 2151 : mpWindowImpl->mpFrame->GetWindowState(&aState);
232 2151 : return (( aState.mnState & WINDOWSTATE_STATE_MINIMIZED ) != 0);
233 : }
234 :
235 : // -----------------------------------------------------------------------
236 :
237 0 : sal_Bool WorkWindow::SetPluginParent( SystemParentData* pParent )
238 : {
239 : DBG_ASSERT( ! mbPresentationMode && ! mbFullScreenMode, "SetPluginParent in fullscreen or presentation mode !" );
240 :
241 0 : bool bWasDnd = Window::ImplStopDnd();
242 :
243 0 : sal_Bool bShown = IsVisible();
244 0 : Show( sal_False );
245 0 : sal_Bool bRet = mpWindowImpl->mpFrame->SetPluginParent( pParent );
246 0 : Show( bShown );
247 :
248 0 : if( bWasDnd )
249 0 : Window::ImplStartDnd();
250 :
251 0 : return bRet;
252 : }
253 :
254 0 : void WorkWindow::ImplSetFrameState( sal_uLong aFrameState )
255 : {
256 : SalFrameState aState;
257 0 : aState.mnMask = WINDOWSTATE_MASK_STATE;
258 0 : aState.mnState = aFrameState;
259 0 : mpWindowImpl->mpFrame->SetWindowState( &aState );
260 0 : }
261 :
262 :
263 0 : void WorkWindow::Minimize()
264 : {
265 0 : ImplSetFrameState( WINDOWSTATE_STATE_MINIMIZED );
266 0 : }
267 :
268 0 : void WorkWindow::Restore()
269 : {
270 0 : ImplSetFrameState( WINDOWSTATE_STATE_NORMAL );
271 0 : }
272 :
273 0 : sal_Bool WorkWindow::Close()
274 : {
275 0 : sal_Bool bCanClose = SystemWindow::Close();
276 :
277 : // Ist es das Applikationsfenster, dann beende die Applikation
278 0 : if ( bCanClose && ( ImplGetSVData()->maWinData.mpAppWin == this ) )
279 0 : GetpApp()->Quit();
280 :
281 0 : return bCanClose;
282 : }
283 :
284 0 : void WorkWindow::Maximize( sal_Bool bMaximize )
285 : {
286 0 : ImplSetFrameState( bMaximize ? WINDOWSTATE_STATE_MAXIMIZED : WINDOWSTATE_STATE_NORMAL );
287 0 : }
288 :
289 0 : sal_Bool WorkWindow::IsMaximized() const
290 : {
291 0 : sal_Bool bRet = sal_False;
292 :
293 : SalFrameState aState;
294 0 : if( mpWindowImpl->mpFrame->GetWindowState( &aState ) )
295 : {
296 0 : if( aState.mnState & (WINDOWSTATE_STATE_MAXIMIZED |
297 : WINDOWSTATE_STATE_MAXIMIZED_HORZ |
298 : WINDOWSTATE_STATE_MAXIMIZED_VERT ) )
299 0 : bRet = sal_True;
300 : }
301 0 : return bRet;
302 465 : }
303 :
304 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|