1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include <tools/debug.hxx>
33 #include <vcl/svapp.hxx>
34 #include <vcl/wrkwin.hxx>
35 // declare system types in sysdata.hxx
37 #include <vcl/sysdata.hxx>
38 #include <com/sun/star/lang/XComponent.hpp>
39 #include <com/sun/star/rendering/XCanvas.hpp>
42 #include <salframe.hxx>
46 // =======================================================================
48 void WorkWindow::ImplInitWorkWindowData()
50 mnIcon
= 0; // Should be removed in the next top level update - now in SystemWindow
52 mnPresentationFlags
= 0;
53 mbPresentationMode
= sal_False
;
54 mbPresentationVisible
= sal_False
;
55 mbPresentationFull
= sal_False
;
56 mbFullScreenMode
= sal_False
;
59 // -----------------------------------------------------------------------
61 void WorkWindow::ImplInit( Window
* pParent
, WinBits nStyle
, SystemParentData
* pSystemParentData
)
63 sal_uInt16 nFrameStyle
= BORDERWINDOW_STYLE_FRAME
;
64 if ( nStyle
& WB_APP
)
65 nFrameStyle
|= BORDERWINDOW_STYLE_APP
;
67 ImplBorderWindow
* pBorderWin
= new ImplBorderWindow( pParent
, pSystemParentData
, nStyle
, nFrameStyle
);
68 Window::ImplInit( pBorderWin
, nStyle
& (WB_3DLOOK
| WB_CLIPCHILDREN
| WB_DIALOGCONTROL
| WB_SYSTEMFLOATWIN
), NULL
);
69 pBorderWin
->mpWindowImpl
->mpClientWindow
= this;
70 pBorderWin
->GetBorder( mpWindowImpl
->mnLeftBorder
, mpWindowImpl
->mnTopBorder
, mpWindowImpl
->mnRightBorder
, mpWindowImpl
->mnBottomBorder
);
71 mpWindowImpl
->mpBorderWindow
= pBorderWin
;
73 // mpWindowImpl->mpRealParent = pParent; // should actually be set, but is not set due to errors with the menubar!!
75 if ( nStyle
& WB_APP
)
77 ImplSVData
* pSVData
= ImplGetSVData();
78 DBG_ASSERT( !pSVData
->maWinData
.mpAppWin
, "WorkWindow::WorkWindow(): More than one window with style WB_APP" );
79 pSVData
->maWinData
.mpAppWin
= this;
82 SetActivateMode( ACTIVATE_MODE_GRABFOCUS
);
85 // -----------------------------------------------------------------------
87 void WorkWindow::ImplInit( Window
* pParent
, WinBits nStyle
, const ::com::sun::star::uno::Any
& aSystemWorkWindowToken
)
89 if( aSystemWorkWindowToken
.hasValue() )
91 ::com::sun::star::uno::Sequence
< sal_Int8
> aSeq
;
92 aSystemWorkWindowToken
>>= aSeq
;
93 SystemParentData
* pData
= (SystemParentData
*)aSeq
.getArray();
94 DBG_ASSERT( aSeq
.getLength() == sizeof( SystemParentData
) && pData
->nSize
== sizeof( SystemParentData
), "WorkWindow::WorkWindow( Window*, const Any&, WinBits ) called with invalid Any" );
95 // init with style 0 as does WorkWindow::WorkWindow( SystemParentData* );
96 ImplInit( pParent
, 0, pData
);
99 ImplInit( pParent
, nStyle
, NULL
);
102 // -----------------------------------------------------------------------
104 WorkWindow::WorkWindow( WindowType nType
) :
105 SystemWindow( nType
)
107 ImplInitWorkWindowData();
113 createWindowFoo(void)
115 return (void*) new WorkWindow((Window
*)NULL
);
120 // -----------------------------------------------------------------------
122 WorkWindow::WorkWindow( Window
* pParent
, WinBits nStyle
) :
123 SystemWindow( WINDOW_WORKWINDOW
)
125 ImplInitWorkWindowData();
126 ImplInit( pParent
, nStyle
, NULL
);
129 // -----------------------------------------------------------------------
131 WorkWindow::WorkWindow( Window
* pParent
, const ResId
& rResId
) :
132 SystemWindow( WINDOW_WORKWINDOW
)
134 ImplInitWorkWindowData();
135 rResId
.SetRT( RSC_WORKWIN
);
136 WinBits nStyle
= ImplInitRes( rResId
);
137 ImplInit( pParent
, nStyle
);
138 ImplLoadRes( rResId
);
141 // -----------------------------------------------------------------------
143 WorkWindow::WorkWindow( Window
* pParent
, const ::com::sun::star::uno::Any
& aSystemWorkWindowToken
, WinBits nStyle
) :
144 SystemWindow( WINDOW_WORKWINDOW
)
146 ImplInitWorkWindowData();
147 mbSysChild
= sal_True
;
148 ImplInit( pParent
, nStyle
, aSystemWorkWindowToken
);
151 // -----------------------------------------------------------------------
153 WorkWindow::WorkWindow( SystemParentData
* pParent
) :
154 SystemWindow( WINDOW_WORKWINDOW
)
156 ImplInitWorkWindowData();
157 mbSysChild
= sal_True
;
158 ImplInit( NULL
, 0, pParent
);
161 // -----------------------------------------------------------------------
163 void WorkWindow::ImplLoadRes( const ResId
& rResId
)
165 SystemWindow::ImplLoadRes( rResId
);
168 if ( !(rResId
.GetWinBits() & WB_HIDE
) && (RSC_WORKWIN
== rResId
.GetRT()) )
172 // -----------------------------------------------------------------------
174 WorkWindow::~WorkWindow()
176 ImplSVData
* pSVData
= ImplGetSVData();
177 if ( pSVData
->maWinData
.mpAppWin
== this )
179 pSVData
->maWinData
.mpAppWin
= NULL
;
184 // -----------------------------------------------------------------------
186 void WorkWindow::ShowFullScreenMode( sal_Bool bFullScreenMode
, sal_Int32 nDisplayScreen
)
188 if ( !mbFullScreenMode
== !bFullScreenMode
)
191 if( (nDisplayScreen
< 0)
192 || (nDisplayScreen
>= static_cast<sal_Int32
>(Application::GetScreenCount()) ) )
194 nDisplayScreen
= GetScreenNumber();
197 mbFullScreenMode
= bFullScreenMode
!= 0;
200 // Dispose of the canvas implementation, which might rely on
201 // screen-specific system data.
202 com::sun::star::uno::Reference
< com::sun::star::rendering::XCanvas
> xCanvas( mpWindowImpl
->mxCanvas
);
205 com::sun::star::uno::Reference
< com::sun::star::lang::XComponent
>
206 xCanvasComponent( xCanvas
,
207 com::sun::star::uno::UNO_QUERY
);
208 if( xCanvasComponent
.is() )
209 xCanvasComponent
->dispose();
212 mpWindowImpl
->mpFrameWindow
->mpWindowImpl
->mbWaitSystemResize
= sal_True
;
213 ImplGetFrame()->ShowFullScreen( bFullScreenMode
, nDisplayScreen
);
217 // -----------------------------------------------------------------------
219 void WorkWindow::StartPresentationMode( sal_Bool bPresentation
, sal_uInt16 nFlags
, sal_Int32 nDisplayScreen
)
221 if ( !bPresentation
== !mbPresentationMode
)
226 mbPresentationMode
= sal_True
;
227 mbPresentationVisible
= IsVisible();
228 mbPresentationFull
= mbFullScreenMode
;
229 mnPresentationFlags
= nFlags
;
231 if ( !(mnPresentationFlags
& PRESENTATION_NOFULLSCREEN
) )
232 ShowFullScreenMode( sal_True
, nDisplayScreen
);
235 if ( mnPresentationFlags
& PRESENTATION_HIDEALLAPPS
)
236 mpWindowImpl
->mpFrame
->SetAlwaysOnTop( sal_True
);
237 if ( !(mnPresentationFlags
& PRESENTATION_NOAUTOSHOW
) )
239 mpWindowImpl
->mpFrame
->StartPresentation( sal_True
);
242 if ( !(mnPresentationFlags
& PRESENTATION_NOAUTOSHOW
) )
247 Show( mbPresentationVisible
);
250 mpWindowImpl
->mpFrame
->StartPresentation( sal_False
);
251 if ( mnPresentationFlags
& PRESENTATION_HIDEALLAPPS
)
252 mpWindowImpl
->mpFrame
->SetAlwaysOnTop( sal_False
);
254 ShowFullScreenMode( mbPresentationFull
, nDisplayScreen
);
256 mbPresentationMode
= sal_False
;
257 mbPresentationVisible
= sal_False
;
258 mbPresentationFull
= sal_False
;
259 mnPresentationFlags
= 0;
263 // -----------------------------------------------------------------------
265 sal_Bool
WorkWindow::IsMinimized() const
267 //return mpWindowImpl->mpFrameData->mbMinimized;
268 SalFrameState aState
;
269 mpWindowImpl
->mpFrame
->GetWindowState(&aState
);
270 return (( aState
.mnState
& SAL_FRAMESTATE_MINIMIZED
) != 0);
273 // -----------------------------------------------------------------------
275 sal_Bool
WorkWindow::SetPluginParent( SystemParentData
* pParent
)
277 DBG_ASSERT( ! mbPresentationMode
&& ! mbFullScreenMode
, "SetPluginParent in fullscreen or presentation mode !" );
279 bool bWasDnd
= Window::ImplStopDnd();
281 sal_Bool bShown
= IsVisible();
283 sal_Bool bRet
= mpWindowImpl
->mpFrame
->SetPluginParent( pParent
);
287 Window::ImplStartDnd();
292 void WorkWindow::ImplSetFrameState( sal_uLong aFrameState
)
294 SalFrameState aState
;
295 aState
.mnMask
= SAL_FRAMESTATE_MASK_STATE
;
296 aState
.mnState
= aFrameState
;
297 mpWindowImpl
->mpFrame
->SetWindowState( &aState
);
301 void WorkWindow::Minimize()
303 ImplSetFrameState( SAL_FRAMESTATE_MINIMIZED
);
306 void WorkWindow::Restore()
308 ImplSetFrameState( SAL_FRAMESTATE_NORMAL
);
311 sal_Bool
WorkWindow::Close()
313 sal_Bool bCanClose
= SystemWindow::Close();
315 // Ist es das Applikationsfenster, dann beende die Applikation
316 if ( bCanClose
&& ( ImplGetSVData()->maWinData
.mpAppWin
== this ) )
322 void WorkWindow::Maximize( sal_Bool bMaximize
)
324 ImplSetFrameState( bMaximize
? SAL_FRAMESTATE_MAXIMIZED
: SAL_FRAMESTATE_NORMAL
);
327 sal_Bool
WorkWindow::IsMaximized() const
329 sal_Bool bRet
= sal_False
;
331 SalFrameState aState
;
332 if( mpWindowImpl
->mpFrame
->GetWindowState( &aState
) )
334 if( aState
.mnState
& (SAL_FRAMESTATE_MAXIMIZED
|
335 SAL_FRAMESTATE_MAXIMIZED_HORZ
|
336 SAL_FRAMESTATE_MAXIMIZED_VERT
) )
342 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */