1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svpframe.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "svpframe.hxx"
32 #include "svpinst.hxx"
35 #include <basebmp/scanlineformats.hxx>
36 #include <basegfx/vector/b2ivector.hxx>
38 using namespace basebmp
;
39 using namespace basegfx
;
41 SvpSalFrame
* SvpSalFrame::s_pFocusFrame
= NULL
;
43 SvpSalFrame::SvpSalFrame( SvpSalInstance
* pInstance
,
47 m_pInstance( pInstance
),
48 m_pParent( static_cast<SvpSalFrame
*>(pParent
) ),
49 m_nStyle( nSalFrameStyle
),
56 m_aSystemChildData
.nSize
= sizeof( SystemChildData
);
57 m_aSystemChildData
.pDisplay
= NULL
;
58 m_aSystemChildData
.aWindow
= 0;
59 m_aSystemChildData
.pSalFrame
= this;
60 m_aSystemChildData
.pWidget
= NULL
;
61 m_aSystemChildData
.pVisual
= NULL
;
62 m_aSystemChildData
.nDepth
= 24;
63 m_aSystemChildData
.aColormap
= 0;
64 m_aSystemChildData
.pAppContext
= NULL
;
65 m_aSystemChildData
.aShellWindow
= 0;
66 m_aSystemChildData
.pShellWidget
= NULL
;
69 m_pParent
->m_aChildren
.push_back( this );
72 m_pInstance
->registerFrame( this );
74 SetPosSize( 0, 0, 800, 600, SAL_FRAME_POSSIZE_WIDTH
| SAL_FRAME_POSSIZE_HEIGHT
);
77 SvpSalFrame::~SvpSalFrame()
80 m_pInstance
->deregisterFrame( this );
82 std::list
<SvpSalFrame
*> Children
= m_aChildren
;
83 for( std::list
<SvpSalFrame
*>::iterator it
= Children
.begin();
84 it
!= Children
.end(); ++it
)
85 (*it
)->SetParent( m_pParent
);
87 m_pParent
->m_aChildren
.remove( this );
90 void SvpSalFrame::GetFocus()
92 if( (m_nStyle
& (SAL_FRAME_STYLE_OWNERDRAWDECORATION
| SAL_FRAME_STYLE_FLOAT
)) == 0 )
95 s_pFocusFrame
->LoseFocus();
97 m_pInstance
->PostEvent( this, NULL
, SALEVENT_GETFOCUS
);
101 void SvpSalFrame::LoseFocus()
103 if( s_pFocusFrame
== this )
105 m_pInstance
->PostEvent( this, NULL
, SALEVENT_LOSEFOCUS
);
106 s_pFocusFrame
= NULL
;
110 SalGraphics
* SvpSalFrame::GetGraphics()
112 SvpSalGraphics
* pGraphics
= new SvpSalGraphics();
113 pGraphics
->setDevice( m_aFrame
);
114 m_aGraphics
.push_back( pGraphics
);
118 void SvpSalFrame::ReleaseGraphics( SalGraphics
* pGraphics
)
120 SvpSalGraphics
* pSvpGraphics
= dynamic_cast<SvpSalGraphics
*>(pGraphics
);
121 m_aGraphics
.remove( pSvpGraphics
);
125 BOOL
SvpSalFrame::PostEvent( void* pData
)
127 m_pInstance
->PostEvent( this, pData
, SALEVENT_USEREVENT
);
131 void SvpSalFrame::PostPaint() const
135 SalPaintEvent
aPEvt(0, 0, maGeometry
.nWidth
, maGeometry
.nHeight
);
136 CallCallback( SALEVENT_PAINT
, &aPEvt
);
140 void SvpSalFrame::SetTitle( const XubString
& )
144 void SvpSalFrame::SetIcon( USHORT
)
148 void SvpSalFrame::SetMenu( SalMenu
* )
152 void SvpSalFrame::DrawMenuBar()
156 void SvpSalFrame::SetExtendedFrameStyle( SalExtStyle
)
160 void SvpSalFrame::Show( BOOL bVisible
, BOOL bNoActivate
)
162 if( bVisible
&& ! m_bVisible
)
165 m_pInstance
->PostEvent( this, NULL
, SALEVENT_RESIZE
);
169 else if( ! bVisible
&& m_bVisible
)
172 m_pInstance
->PostEvent( this, NULL
, SALEVENT_RESIZE
);
177 void SvpSalFrame::Enable( BOOL
)
181 void SvpSalFrame::SetMinClientSize( long nWidth
, long nHeight
)
183 m_nMinWidth
= nWidth
;
184 m_nMinHeight
= nHeight
;
187 void SvpSalFrame::SetMaxClientSize( long nWidth
, long nHeight
)
189 m_nMaxWidth
= nWidth
;
190 m_nMaxHeight
= nHeight
;
193 void SvpSalFrame::SetPosSize( long nX
, long nY
, long nWidth
, long nHeight
, USHORT nFlags
)
195 if( (nFlags
& SAL_FRAME_POSSIZE_X
) != 0 )
197 if( (nFlags
& SAL_FRAME_POSSIZE_Y
) != 0 )
199 if( (nFlags
& SAL_FRAME_POSSIZE_WIDTH
) != 0 )
201 maGeometry
.nWidth
= nWidth
;
202 if( m_nMaxWidth
> 0 && maGeometry
.nWidth
> (unsigned int)m_nMaxWidth
)
203 maGeometry
.nWidth
= m_nMaxWidth
;
204 if( m_nMinWidth
> 0 && maGeometry
.nWidth
< (unsigned int)m_nMinWidth
)
205 maGeometry
.nWidth
= m_nMinWidth
;
207 if( (nFlags
& SAL_FRAME_POSSIZE_HEIGHT
) != 0 )
209 maGeometry
.nHeight
= nHeight
;
210 if( m_nMaxHeight
> 0 && maGeometry
.nHeight
> (unsigned int)m_nMaxHeight
)
211 maGeometry
.nHeight
= m_nMaxHeight
;
212 if( m_nMinHeight
> 0 && maGeometry
.nHeight
< (unsigned int)m_nMinHeight
)
213 maGeometry
.nHeight
= m_nMinHeight
;
215 B2IVector
aFrameSize( maGeometry
.nWidth
, maGeometry
.nHeight
);
216 if( ! m_aFrame
.get() || m_aFrame
->getSize() != aFrameSize
)
218 if( aFrameSize
.getX() == 0 )
219 aFrameSize
.setX( 1 );
220 if( aFrameSize
.getY() == 0 )
221 aFrameSize
.setY( 1 );
222 m_aFrame
= createBitmapDevice( aFrameSize
, false, SVP_DEFAULT_BITMAP_FORMAT
);
223 // update device in existing graphics
224 for( std::list
< SvpSalGraphics
* >::iterator it
= m_aGraphics
.begin();
225 it
!= m_aGraphics
.end(); ++it
)
226 (*it
)->setDevice( m_aFrame
);
229 m_pInstance
->PostEvent( this, NULL
, SALEVENT_RESIZE
);
232 void SvpSalFrame::GetClientSize( long& rWidth
, long& rHeight
)
236 rWidth
= maGeometry
.nWidth
;
237 rHeight
= maGeometry
.nHeight
;
240 rWidth
= rHeight
= 0;
243 void SvpSalFrame::GetWorkArea( Rectangle
& rRect
)
245 rRect
= Rectangle( Point( 0, 0 ),
246 Size( VIRTUAL_DESKTOP_WIDTH
, VIRTUAL_DESKTOP_HEIGHT
) );
249 SalFrame
* SvpSalFrame::GetParent() const
254 #define _FRAMESTATE_MASK_GEOMETRY \
255 (SAL_FRAMESTATE_MASK_X | SAL_FRAMESTATE_MASK_Y | \
256 SAL_FRAMESTATE_MASK_WIDTH | SAL_FRAMESTATE_MASK_HEIGHT)
257 #define _FRAMESTATE_MASK_MAXIMIZED_GEOMETRY \
258 (SAL_FRAMESTATE_MASK_MAXIMIZED_X | SAL_FRAMESTATE_MASK_MAXIMIZED_Y | \
259 SAL_FRAMESTATE_MASK_MAXIMIZED_WIDTH | SAL_FRAMESTATE_MASK_MAXIMIZED_HEIGHT)
261 void SvpSalFrame::SetWindowState( const SalFrameState
*pState
)
266 // Request for position or size change
267 if (pState
->mnMask
& _FRAMESTATE_MASK_GEOMETRY
)
269 long nX
= maGeometry
.nX
;
270 long nY
= maGeometry
.nY
;
271 long nWidth
= maGeometry
.nWidth
;
272 long nHeight
= maGeometry
.nHeight
;
274 // change requested properties
275 if (pState
->mnMask
& SAL_FRAMESTATE_MASK_X
)
277 if (pState
->mnMask
& SAL_FRAMESTATE_MASK_Y
)
279 if (pState
->mnMask
& SAL_FRAMESTATE_MASK_WIDTH
)
280 nWidth
= pState
->mnWidth
;
281 if (pState
->mnMask
& SAL_FRAMESTATE_MASK_HEIGHT
)
282 nHeight
= pState
->mnHeight
;
284 SetPosSize( nX
, nY
, nWidth
, nHeight
,
285 SAL_FRAME_POSSIZE_X
| SAL_FRAME_POSSIZE_Y
|
286 SAL_FRAME_POSSIZE_WIDTH
| SAL_FRAME_POSSIZE_HEIGHT
);
290 BOOL
SvpSalFrame::GetWindowState( SalFrameState
* pState
)
292 pState
->mnState
= SAL_FRAMESTATE_NORMAL
;
293 pState
->mnX
= maGeometry
.nX
;
294 pState
->mnY
= maGeometry
.nY
;
295 pState
->mnWidth
= maGeometry
.nWidth
;
296 pState
->mnHeight
= maGeometry
.nHeight
;
297 pState
->mnMask
= _FRAMESTATE_MASK_GEOMETRY
| SAL_FRAMESTATE_MASK_STATE
;
302 void SvpSalFrame::ShowFullScreen( BOOL
, sal_Int32
)
304 SetPosSize( 0, 0, VIRTUAL_DESKTOP_WIDTH
, VIRTUAL_DESKTOP_HEIGHT
,
305 SAL_FRAME_POSSIZE_WIDTH
| SAL_FRAME_POSSIZE_HEIGHT
);
308 void SvpSalFrame::StartPresentation( BOOL
)
312 void SvpSalFrame::SetAlwaysOnTop( BOOL
)
316 void SvpSalFrame::ToTop( USHORT
)
321 void SvpSalFrame::SetPointer( PointerStyle
)
325 void SvpSalFrame::CaptureMouse( BOOL
)
329 void SvpSalFrame::SetPointerPos( long, long )
333 void SvpSalFrame::Flush()
337 void SvpSalFrame::Sync()
341 void SvpSalFrame::SetInputContext( SalInputContext
* )
345 void SvpSalFrame::EndExtTextInput( USHORT
)
349 String
SvpSalFrame::GetKeyName( USHORT
)
354 String
SvpSalFrame::GetSymbolKeyName( const XubString
&, USHORT
)
359 BOOL
SvpSalFrame::MapUnicodeToKeyCode( sal_Unicode
, LanguageType
, KeyCode
& )
364 LanguageType
SvpSalFrame::GetInputLanguage()
366 return LANGUAGE_DONTKNOW
;
369 SalBitmap
* SvpSalFrame::SnapShot()
374 void SvpSalFrame::UpdateSettings( AllSettings
& )
378 void SvpSalFrame::Beep( SoundType
)
382 const SystemEnvData
* SvpSalFrame::GetSystemData() const
384 return &m_aSystemChildData
;
387 SalFrame::SalPointerState
SvpSalFrame::GetPointerState()
389 SalPointerState aState
;
394 SalFrame::SalIndicatorState
SvpSalFrame::GetIndicatorState()
396 SalIndicatorState aState
;
401 void SvpSalFrame::SimulateKeyPress( USHORT
/*nKeyCode*/ )
405 void SvpSalFrame::SetParent( SalFrame
* pNewParent
)
408 m_pParent
->m_aChildren
.remove( this );
409 m_pParent
= static_cast<SvpSalFrame
*>(pNewParent
);
412 bool SvpSalFrame::SetPluginParent( SystemParentData
* )
417 void SvpSalFrame::SetBackgroundBitmap( SalBitmap
* )
421 void SvpSalFrame::ResetClipRegion()
425 void SvpSalFrame::BeginSetClipRegion( ULONG
)
429 void SvpSalFrame::UnionClipRegion( long, long, long, long )
433 void SvpSalFrame::EndSetClipRegion()