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: syschild.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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
37 #include <vcl/salinst.hxx>
38 #include <vcl/salframe.hxx>
39 #include <vcl/window.hxx>
40 #include <vcl/salobj.hxx>
45 #include <vcl/svdata.hxx>
47 #include <vcl/window.h>
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
;
62 ImplDelData
aDogTag( pWindow
);
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() )
74 pWindow
->ImplGetFrameData()->mbInSysObjToTopHdl
= FALSE
;
75 pWindow
->ImplGetFrameData()->mbInSysObjFocusHdl
= TRUE
;
77 if( aDogTag
.IsDead() )
79 pWindow
->ImplGetFrameData()->mbInSysObjFocusHdl
= FALSE
;
82 case SALOBJ_EVENT_LOSEFOCUS
:
83 // Hintenrum einen LoseFocus ausloesen, das der Status
84 // der Fenster dem entsprechenden Activate-Status
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
) );
94 case SALOBJ_EVENT_TOTOP
:
95 pWindow
->ImplGetFrameData()->mbInSysObjToTopHdl
= TRUE
;
96 if ( !Application::GetFocusWindow() || pWindow
->HasChildPathFocus() )
97 pWindow
->ToTop( TOTOP_NOGRABFOCUS
);
100 if( aDogTag
.IsDead() )
102 pWindow
->GrabFocus();
103 if( aDogTag
.IsDead() )
105 pWindow
->ImplGetFrameData()->mbInSysObjToTopHdl
= FALSE
;
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
);
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
) )
159 // -----------------------------------------------------------------------
161 SystemChildWindow::~SystemChildWindow()
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();
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();
197 void SystemChildWindow::SetForwardKey( BOOL bEnable
)
199 if ( mpWindowImpl
->mpSysObj
)
200 mpWindowImpl
->mpSysObj
->SetForwardKey( bEnable
);