merge the formfield patch from ooo-build
[ooovba.git] / vcl / source / window / syschild.cxx
blob5a5c74f3c7f1e97f6002447eb62cf668ef12e0ef
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: syschild.cxx,v $
10 * $Revision: 1.13 $
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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
34 #ifndef _SV_SVSYS_HXX
35 #include <svsys.h>
36 #endif
37 #include <vcl/salinst.hxx>
38 #include <vcl/salframe.hxx>
39 #include <vcl/window.hxx>
40 #include <vcl/salobj.hxx>
42 #ifndef _SV_RC_H
43 #include <tools/rc.h>
44 #endif
45 #include <vcl/svdata.hxx>
46 #ifndef _SV_WIDNOW_H
47 #include <vcl/window.h>
48 #endif
49 #include <vcl/svapp.hxx>
50 #include <vcl/syschild.hxx>
54 // =======================================================================
56 long ImplSysChildProc( void* pInst, SalObject* /* pObject */,
57 USHORT nEvent, const void* /* pEvent */ )
59 SystemChildWindow* pWindow = (SystemChildWindow*)pInst;
60 long nRet = 0;
62 ImplDelData aDogTag( pWindow );
63 switch ( nEvent )
65 case SALOBJ_EVENT_GETFOCUS:
66 // Focus holen und zwar so, das alle Handler gerufen
67 // werden, als ob dieses Fenster den Focus bekommt,
68 // ohne das der Frame den Focus wieder klaut
69 pWindow->ImplGetFrameData()->mbSysObjFocus = TRUE;
70 pWindow->ImplGetFrameData()->mbInSysObjToTopHdl = TRUE;
71 pWindow->ToTop( TOTOP_NOGRABFOCUS );
72 if( aDogTag.IsDead() )
73 break;
74 pWindow->ImplGetFrameData()->mbInSysObjToTopHdl = FALSE;
75 pWindow->ImplGetFrameData()->mbInSysObjFocusHdl = TRUE;
76 pWindow->GrabFocus();
77 if( aDogTag.IsDead() )
78 break;
79 pWindow->ImplGetFrameData()->mbInSysObjFocusHdl = FALSE;
80 break;
82 case SALOBJ_EVENT_LOSEFOCUS:
83 // Hintenrum einen LoseFocus ausloesen, das der Status
84 // der Fenster dem entsprechenden Activate-Status
85 // entspricht
86 pWindow->ImplGetFrameData()->mbSysObjFocus = FALSE;
87 if ( !pWindow->ImplGetFrameData()->mnFocusId )
89 pWindow->ImplGetFrameData()->mbStartFocusState = TRUE;
90 Application::PostUserEvent( pWindow->ImplGetFrameData()->mnFocusId, LINK( pWindow->ImplGetFrameWindow(), Window, ImplAsyncFocusHdl ) );
92 break;
94 case SALOBJ_EVENT_TOTOP:
95 pWindow->ImplGetFrameData()->mbInSysObjToTopHdl = TRUE;
96 if ( !Application::GetFocusWindow() || pWindow->HasChildPathFocus() )
97 pWindow->ToTop( TOTOP_NOGRABFOCUS );
98 else
99 pWindow->ToTop();
100 if( aDogTag.IsDead() )
101 break;
102 pWindow->GrabFocus();
103 if( aDogTag.IsDead() )
104 break;
105 pWindow->ImplGetFrameData()->mbInSysObjToTopHdl = FALSE;
106 break;
109 return nRet;
112 // =======================================================================
114 void SystemChildWindow::ImplInitSysChild( Window* pParent, WinBits nStyle, SystemWindowData *pData, BOOL bShow )
116 mpWindowImpl->mpSysObj = ImplGetSVData()->mpDefInst->CreateObject( pParent->ImplGetFrame(), pData, bShow );
118 Window::ImplInit( pParent, nStyle, NULL );
120 // Wenn es ein richtiges SysChild ist, dann painten wir auch nicht
121 if ( GetSystemData() )
123 mpWindowImpl->mpSysObj->SetCallback( this, ImplSysChildProc );
124 SetParentClipMode( PARENTCLIPMODE_CLIP );
125 SetBackground();
129 // -----------------------------------------------------------------------
131 SystemChildWindow::SystemChildWindow( Window* pParent, WinBits nStyle ) :
132 Window( WINDOW_SYSTEMCHILDWINDOW )
134 ImplInitSysChild( pParent, nStyle, NULL );
137 // -----------------------------------------------------------------------
139 SystemChildWindow::SystemChildWindow( Window* pParent, WinBits nStyle, SystemWindowData *pData, BOOL bShow ) :
140 Window( WINDOW_SYSTEMCHILDWINDOW )
142 ImplInitSysChild( pParent, nStyle, pData, bShow );
145 // -----------------------------------------------------------------------
147 SystemChildWindow::SystemChildWindow( Window* pParent, const ResId& rResId ) :
148 Window( WINDOW_SYSTEMCHILDWINDOW )
150 rResId.SetRT( RSC_WINDOW );
151 WinBits nStyle = ImplInitRes( rResId );
152 ImplInitSysChild( pParent, nStyle, NULL );
153 ImplLoadRes( rResId );
155 if ( !(nStyle & WB_HIDE) )
156 Show();
159 // -----------------------------------------------------------------------
161 SystemChildWindow::~SystemChildWindow()
163 Hide();
164 if ( mpWindowImpl->mpSysObj )
166 ImplGetSVData()->mpDefInst->DestroyObject( mpWindowImpl->mpSysObj );
167 mpWindowImpl->mpSysObj = NULL;
171 // -----------------------------------------------------------------------
173 const SystemEnvData* SystemChildWindow::GetSystemData() const
175 if ( mpWindowImpl->mpSysObj )
176 return mpWindowImpl->mpSysObj->GetSystemData();
177 else
178 return NULL;
181 // -----------------------------------------------------------------------
183 void SystemChildWindow::EnableEraseBackground( BOOL bEnable )
185 if ( mpWindowImpl->mpSysObj )
186 mpWindowImpl->mpSysObj->EnableEraseBackground( bEnable );
189 BOOL SystemChildWindow::IsEraseBackgroundEnabled()
191 if ( mpWindowImpl->mpSysObj )
192 return mpWindowImpl->mpSysObj->IsEraseBackgroundEnabled();
193 else
194 return FALSE;
197 void SystemChildWindow::SetForwardKey( BOOL bEnable )
199 if ( mpWindowImpl->mpSysObj )
200 mpWindowImpl->mpSysObj->SetForwardKey( bEnable );