xref: /AOO41X/main/vcl/source/app/help.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_vcl.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "tools/debug.hxx"
32*cdf0e10cSrcweir #include "tools/diagnose_ex.h"
33*cdf0e10cSrcweir #include "tools/time.hxx"
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include "vcl/window.hxx"
36*cdf0e10cSrcweir #include "vcl/event.hxx"
37*cdf0e10cSrcweir #include "vcl/svapp.hxx"
38*cdf0e10cSrcweir #include "vcl/wrkwin.hxx"
39*cdf0e10cSrcweir #include "vcl/help.hxx"
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #include "helpwin.hxx"
42*cdf0e10cSrcweir #include "svdata.hxx"
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir // =======================================================================
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #define HELPWINSTYLE_QUICK		0
47*cdf0e10cSrcweir #define HELPWINSTYLE_BALLOON	1
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir #define HELPTEXTMARGIN_QUICK	3
50*cdf0e10cSrcweir #define HELPTEXTMARGIN_BALLOON	6
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir #define HELPDELAY_NORMAL		1
53*cdf0e10cSrcweir #define HELPDELAY_SHORT 		2
54*cdf0e10cSrcweir #define HELPDELAY_NONE			3
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir // =======================================================================
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir Help::Help()
59*cdf0e10cSrcweir {
60*cdf0e10cSrcweir }
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir Help::~Help()
63*cdf0e10cSrcweir {
64*cdf0e10cSrcweir }
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir // -----------------------------------------------------------------------
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir void Help::OpenHelpAgent( const rtl::OString& )
69*cdf0e10cSrcweir {
70*cdf0e10cSrcweir }
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir // -----------------------------------------------------------------------
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir sal_Bool Help::Start( const XubString&, const Window* )
75*cdf0e10cSrcweir {
76*cdf0e10cSrcweir 	return sal_False;
77*cdf0e10cSrcweir }
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir sal_Bool Help::SearchKeyword( const XubString& )
80*cdf0e10cSrcweir {
81*cdf0e10cSrcweir 	return sal_False;
82*cdf0e10cSrcweir }
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir // -----------------------------------------------------------------------
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir XubString Help::GetHelpText( const String&, const Window* )
87*cdf0e10cSrcweir {
88*cdf0e10cSrcweir 	return ImplGetSVEmptyStr();
89*cdf0e10cSrcweir }
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir // -----------------------------------------------------------------------
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir void Help::EnableContextHelp()
94*cdf0e10cSrcweir {
95*cdf0e10cSrcweir 	ImplGetSVData()->maHelpData.mbContextHelp = sal_True;
96*cdf0e10cSrcweir }
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir // -----------------------------------------------------------------------
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir void Help::DisableContextHelp()
101*cdf0e10cSrcweir {
102*cdf0e10cSrcweir 	ImplGetSVData()->maHelpData.mbContextHelp = sal_False;
103*cdf0e10cSrcweir }
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir // -----------------------------------------------------------------------
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir sal_Bool Help::IsContextHelpEnabled()
108*cdf0e10cSrcweir {
109*cdf0e10cSrcweir 	return ImplGetSVData()->maHelpData.mbContextHelp;
110*cdf0e10cSrcweir }
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir // -----------------------------------------------------------------------
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir sal_Bool Help::StartContextHelp()
115*cdf0e10cSrcweir {
116*cdf0e10cSrcweir 	ImplSVData* pSVData = ImplGetSVData();
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir 	if ( pSVData->maHelpData.mbContextHelp )
119*cdf0e10cSrcweir 	{
120*cdf0e10cSrcweir 		Window* pWindow = pSVData->maWinData.mpFocusWin;
121*cdf0e10cSrcweir 		if ( pWindow )
122*cdf0e10cSrcweir 		{
123*cdf0e10cSrcweir 			Point		aMousePos = pWindow->OutputToScreenPixel( pWindow->GetPointerPosPixel() );
124*cdf0e10cSrcweir 			HelpEvent	aHelpEvent( aMousePos, HELPMODE_CONTEXT );
125*cdf0e10cSrcweir 			pWindow->RequestHelp( aHelpEvent );
126*cdf0e10cSrcweir 			return sal_True;
127*cdf0e10cSrcweir 		}
128*cdf0e10cSrcweir 	}
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 	return sal_False;
131*cdf0e10cSrcweir }
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir // -----------------------------------------------------------------------
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir void Help::EnableExtHelp()
136*cdf0e10cSrcweir {
137*cdf0e10cSrcweir 	ImplGetSVData()->maHelpData.mbExtHelp = sal_True;
138*cdf0e10cSrcweir }
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir // -----------------------------------------------------------------------
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir void Help::DisableExtHelp()
143*cdf0e10cSrcweir {
144*cdf0e10cSrcweir 	ImplGetSVData()->maHelpData.mbExtHelp = sal_False;
145*cdf0e10cSrcweir }
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir // -----------------------------------------------------------------------
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir sal_Bool Help::IsExtHelpEnabled()
150*cdf0e10cSrcweir {
151*cdf0e10cSrcweir 	return ImplGetSVData()->maHelpData.mbExtHelp;
152*cdf0e10cSrcweir }
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir // -----------------------------------------------------------------------
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir sal_Bool Help::StartExtHelp()
157*cdf0e10cSrcweir {
158*cdf0e10cSrcweir 	ImplSVData* pSVData = ImplGetSVData();
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir 	if ( pSVData->maHelpData.mbExtHelp && !pSVData->maHelpData.mbExtHelpMode )
161*cdf0e10cSrcweir 	{
162*cdf0e10cSrcweir 		pSVData->maHelpData.mbExtHelpMode = sal_True;
163*cdf0e10cSrcweir 		pSVData->maHelpData.mbOldBalloonMode = pSVData->maHelpData.mbBalloonHelp;
164*cdf0e10cSrcweir 		pSVData->maHelpData.mbBalloonHelp = sal_True;
165*cdf0e10cSrcweir 		if ( pSVData->maWinData.mpAppWin )
166*cdf0e10cSrcweir 			pSVData->maWinData.mpAppWin->ImplGenerateMouseMove();
167*cdf0e10cSrcweir 		return sal_True;
168*cdf0e10cSrcweir 	}
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir 	return sal_False;
171*cdf0e10cSrcweir }
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir // -----------------------------------------------------------------------
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir sal_Bool Help::EndExtHelp()
176*cdf0e10cSrcweir {
177*cdf0e10cSrcweir 	ImplSVData* pSVData = ImplGetSVData();
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir 	if ( pSVData->maHelpData.mbExtHelp && pSVData->maHelpData.mbExtHelpMode )
180*cdf0e10cSrcweir 	{
181*cdf0e10cSrcweir 		pSVData->maHelpData.mbExtHelpMode = sal_False;
182*cdf0e10cSrcweir 		pSVData->maHelpData.mbBalloonHelp = pSVData->maHelpData.mbOldBalloonMode;
183*cdf0e10cSrcweir 		if ( pSVData->maWinData.mpAppWin )
184*cdf0e10cSrcweir 			pSVData->maWinData.mpAppWin->ImplGenerateMouseMove();
185*cdf0e10cSrcweir 		return sal_True;
186*cdf0e10cSrcweir 	}
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir 	return sal_False;
189*cdf0e10cSrcweir }
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir // -----------------------------------------------------------------------
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir sal_Bool Help::IsExtHelpActive()
194*cdf0e10cSrcweir {
195*cdf0e10cSrcweir 	return ImplGetSVData()->maHelpData.mbExtHelpMode;
196*cdf0e10cSrcweir }
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir // -----------------------------------------------------------------------
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir void Help::EnableBalloonHelp()
201*cdf0e10cSrcweir {
202*cdf0e10cSrcweir 	ImplGetSVData()->maHelpData.mbBalloonHelp = sal_True;
203*cdf0e10cSrcweir }
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir // -----------------------------------------------------------------------
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir void Help::DisableBalloonHelp()
208*cdf0e10cSrcweir {
209*cdf0e10cSrcweir 	ImplGetSVData()->maHelpData.mbBalloonHelp = sal_False;
210*cdf0e10cSrcweir }
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir // -----------------------------------------------------------------------
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir sal_Bool Help::IsBalloonHelpEnabled()
215*cdf0e10cSrcweir {
216*cdf0e10cSrcweir 	return ImplGetSVData()->maHelpData.mbBalloonHelp;
217*cdf0e10cSrcweir }
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir // -----------------------------------------------------------------------
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir sal_Bool Help::ShowBalloon( Window* pParent,
222*cdf0e10cSrcweir 						const Point& rScreenPos,
223*cdf0e10cSrcweir 						const XubString& rHelpText )
224*cdf0e10cSrcweir {
225*cdf0e10cSrcweir 	ImplShowHelpWindow( pParent, HELPWINSTYLE_BALLOON, 0,
226*cdf0e10cSrcweir 						rHelpText, ImplGetSVEmptyStr(), rScreenPos );
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 	return sal_True;
229*cdf0e10cSrcweir }
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir // -----------------------------------------------------------------------
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir sal_Bool Help::ShowBalloon( Window* pParent,
234*cdf0e10cSrcweir 						const Point& rScreenPos, const Rectangle& rRect,
235*cdf0e10cSrcweir 						const XubString& rHelpText )
236*cdf0e10cSrcweir {
237*cdf0e10cSrcweir 	ImplShowHelpWindow( pParent, HELPWINSTYLE_BALLOON, 0,
238*cdf0e10cSrcweir 						rHelpText, ImplGetSVEmptyStr(), rScreenPos, &rRect );
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir 	return sal_True;
241*cdf0e10cSrcweir }
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir // -----------------------------------------------------------------------
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir void Help::EnableQuickHelp()
246*cdf0e10cSrcweir {
247*cdf0e10cSrcweir 	ImplGetSVData()->maHelpData.mbQuickHelp = sal_True;
248*cdf0e10cSrcweir }
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir // -----------------------------------------------------------------------
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir void Help::DisableQuickHelp()
253*cdf0e10cSrcweir {
254*cdf0e10cSrcweir 	ImplGetSVData()->maHelpData.mbQuickHelp = sal_False;
255*cdf0e10cSrcweir }
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir // -----------------------------------------------------------------------
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir sal_Bool Help::IsQuickHelpEnabled()
260*cdf0e10cSrcweir {
261*cdf0e10cSrcweir 	return ImplGetSVData()->maHelpData.mbQuickHelp;
262*cdf0e10cSrcweir }
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir // -----------------------------------------------------------------------
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir sal_Bool Help::ShowQuickHelp( Window* pParent,
267*cdf0e10cSrcweir 						  const Rectangle& rScreenRect,
268*cdf0e10cSrcweir 						  const XubString& rHelpText,
269*cdf0e10cSrcweir 						  const XubString& rLongHelpText,
270*cdf0e10cSrcweir 						  sal_uInt16 nStyle )
271*cdf0e10cSrcweir {
272*cdf0e10cSrcweir 	ImplShowHelpWindow( pParent, HELPWINSTYLE_QUICK, nStyle,
273*cdf0e10cSrcweir 						rHelpText, rLongHelpText,
274*cdf0e10cSrcweir 						pParent->OutputToScreenPixel( pParent->GetPointerPosPixel() ), &rScreenRect );
275*cdf0e10cSrcweir 	return sal_True;
276*cdf0e10cSrcweir }
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir // -----------------------------------------------------------------------
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir void Help::HideBalloonAndQuickHelp()
281*cdf0e10cSrcweir {
282*cdf0e10cSrcweir 	HelpTextWindow const * pHelpWin = ImplGetSVData()->maHelpData.mpHelpWin;
283*cdf0e10cSrcweir     bool const bIsVisible = ( pHelpWin != NULL ) && pHelpWin->IsVisible();
284*cdf0e10cSrcweir     ImplDestroyHelpWindow( bIsVisible );
285*cdf0e10cSrcweir }
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir // -----------------------------------------------------------------------
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir sal_uIntPtr Help::ShowTip( Window* pParent, const Rectangle& rScreenRect,
290*cdf0e10cSrcweir 					 const XubString& rText, sal_uInt16 nStyle )
291*cdf0e10cSrcweir {
292*cdf0e10cSrcweir     sal_uInt16 nHelpWinStyle = ( ( nStyle & QUICKHELP_TIP_STYLE_BALLOON ) != 0 ) ? HELPWINSTYLE_BALLOON : HELPWINSTYLE_QUICK;
293*cdf0e10cSrcweir 	HelpTextWindow* pHelpWin = new HelpTextWindow( pParent, rText, nHelpWinStyle, nStyle );
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir     sal_uIntPtr nId = reinterpret_cast< sal_uIntPtr >( pHelpWin );
296*cdf0e10cSrcweir     UpdateTip( nId, pParent, rScreenRect, rText );
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir 	pHelpWin->ShowHelp( HELPDELAY_NONE );
299*cdf0e10cSrcweir 	return nId;
300*cdf0e10cSrcweir }
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir // -----------------------------------------------------------------------
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir void Help::UpdateTip( sal_uIntPtr nId, Window* pParent, const Rectangle& rScreenRect, const XubString& rText )
305*cdf0e10cSrcweir {
306*cdf0e10cSrcweir     HelpTextWindow* pHelpWin = reinterpret_cast< HelpTextWindow* >( nId );
307*cdf0e10cSrcweir     ENSURE_OR_RETURN_VOID( pHelpWin != NULL, "Help::UpdateTip: invalid ID!" );
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir 	Size aSz = pHelpWin->CalcOutSize();
310*cdf0e10cSrcweir 	pHelpWin->SetOutputSizePixel( aSz );
311*cdf0e10cSrcweir 	ImplSetHelpWindowPos( pHelpWin, pHelpWin->GetWinStyle(), pHelpWin->GetStyle(),
312*cdf0e10cSrcweir 		pParent->OutputToScreenPixel( pParent->GetPointerPosPixel() ), &rScreenRect );
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir     pHelpWin->SetHelpText( rText );
315*cdf0e10cSrcweir     pHelpWin->Invalidate();
316*cdf0e10cSrcweir }
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir // -----------------------------------------------------------------------
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir void Help::HideTip( sal_uLong nId )
321*cdf0e10cSrcweir {
322*cdf0e10cSrcweir 	HelpTextWindow* pHelpWin = (HelpTextWindow*)nId;
323*cdf0e10cSrcweir 	Window* pFrameWindow = pHelpWin->ImplGetFrameWindow();
324*cdf0e10cSrcweir 	pHelpWin->Hide();
325*cdf0e10cSrcweir 	// Update ausloesen, damit ein Paint sofort ausgeloest wird, da
326*cdf0e10cSrcweir 	// wir den Hintergrund nicht sichern
327*cdf0e10cSrcweir 	pFrameWindow->ImplUpdateAll();
328*cdf0e10cSrcweir 	delete pHelpWin;
329*cdf0e10cSrcweir     ImplGetSVData()->maHelpData.mnLastHelpHideTime = Time::GetSystemTicks();
330*cdf0e10cSrcweir }
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir // =======================================================================
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir HelpTextWindow::HelpTextWindow( Window* pParent, const XubString& rText, sal_uInt16 nHelpWinStyle, sal_uInt16 nStyle ) :
335*cdf0e10cSrcweir 	//FloatingWindow( pParent->ImplGetFrameWindow(), WB_SYSTEMWINDOW ),
336*cdf0e10cSrcweir 	FloatingWindow( pParent, WB_SYSTEMWINDOW|WB_TOOLTIPWIN ), // #105827# if we change the parent, mirroring will not work correctly when positioning this window
337*cdf0e10cSrcweir 	maHelpText( rText )
338*cdf0e10cSrcweir {
339*cdf0e10cSrcweir 	SetType( WINDOW_HELPTEXTWINDOW );
340*cdf0e10cSrcweir 	ImplSetMouseTransparent( sal_True );
341*cdf0e10cSrcweir 	mnHelpWinStyle = nHelpWinStyle;
342*cdf0e10cSrcweir 	mnStyle = nStyle;
343*cdf0e10cSrcweir //  on windows this will raise the application window, because help windows are system windows now
344*cdf0e10cSrcweir //	EnableAlwaysOnTop();
345*cdf0e10cSrcweir 	EnableSaveBackground();
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir 	const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
348*cdf0e10cSrcweir 	SetPointFont( rStyleSettings.GetHelpFont() );
349*cdf0e10cSrcweir 	SetTextColor( rStyleSettings.GetHelpTextColor() );
350*cdf0e10cSrcweir 	SetTextAlign( ALIGN_TOP );
351*cdf0e10cSrcweir     if ( IsNativeControlSupported( CTRL_TOOLTIP, PART_ENTIRE_CONTROL ) )
352*cdf0e10cSrcweir     {
353*cdf0e10cSrcweir         EnableChildTransparentMode( sal_True );
354*cdf0e10cSrcweir         SetParentClipMode( PARENTCLIPMODE_NOCLIP );
355*cdf0e10cSrcweir         SetPaintTransparent( sal_True );
356*cdf0e10cSrcweir         SetBackground();
357*cdf0e10cSrcweir     }
358*cdf0e10cSrcweir     else
359*cdf0e10cSrcweir         SetBackground( Wallpaper( rStyleSettings.GetHelpColor() ) );
360*cdf0e10cSrcweir     if( rStyleSettings.GetHelpColor().IsDark() )
361*cdf0e10cSrcweir 	    SetLineColor( COL_WHITE );
362*cdf0e10cSrcweir     else
363*cdf0e10cSrcweir 	    SetLineColor( COL_BLACK );
364*cdf0e10cSrcweir 	SetFillColor();
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir     if( mnStyle & QUICKHELP_BIDI_RTL )
367*cdf0e10cSrcweir     {
368*cdf0e10cSrcweir         sal_uLong nLayoutMode = GetLayoutMode();
369*cdf0e10cSrcweir         nLayoutMode |= TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_TEXTORIGIN_LEFT;
370*cdf0e10cSrcweir         SetLayoutMode( nLayoutMode );
371*cdf0e10cSrcweir     }
372*cdf0e10cSrcweir     SetHelpText( rText );
373*cdf0e10cSrcweir     Window::SetHelpText( rText );
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir     ImplSVData* pSVData = ImplGetSVData();
376*cdf0e10cSrcweir     if ( pSVData->maHelpData.mbSetKeyboardHelp )
377*cdf0e10cSrcweir         pSVData->maHelpData.mbKeyboardHelp = sal_True;
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir     const HelpSettings& rHelpSettings = pParent->GetSettings().GetHelpSettings();
380*cdf0e10cSrcweir 	maShowTimer.SetTimeoutHdl( LINK( this, HelpTextWindow, TimerHdl ) );
381*cdf0e10cSrcweir 	maHideTimer.SetTimeoutHdl( LINK( this, HelpTextWindow, TimerHdl ) );
382*cdf0e10cSrcweir 	maHideTimer.SetTimeout( rHelpSettings.GetTipTimeout() );
383*cdf0e10cSrcweir }
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir // -----------------------------------------------------------------------
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir HelpTextWindow::~HelpTextWindow()
388*cdf0e10cSrcweir {
389*cdf0e10cSrcweir 	maShowTimer.Stop();
390*cdf0e10cSrcweir 	maHideTimer.Stop();
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir     if( this == ImplGetSVData()->maHelpData.mpHelpWin )
393*cdf0e10cSrcweir         ImplGetSVData()->maHelpData.mpHelpWin = NULL;
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir 	if ( maStatusText.Len() )
396*cdf0e10cSrcweir 	{
397*cdf0e10cSrcweir 		ImplSVData* pSVData = ImplGetSVData();
398*cdf0e10cSrcweir 		pSVData->mpApp->HideHelpStatusText();
399*cdf0e10cSrcweir 	}
400*cdf0e10cSrcweir }
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir // -----------------------------------------------------------------------
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir void HelpTextWindow::SetHelpText( const String& rHelpText )
405*cdf0e10cSrcweir {
406*cdf0e10cSrcweir     maHelpText = rHelpText;
407*cdf0e10cSrcweir 	if ( mnHelpWinStyle == HELPWINSTYLE_QUICK )
408*cdf0e10cSrcweir 	{
409*cdf0e10cSrcweir 		Size aSize;
410*cdf0e10cSrcweir 		aSize.Height() = GetTextHeight();
411*cdf0e10cSrcweir 		if ( mnStyle & QUICKHELP_CTRLTEXT )
412*cdf0e10cSrcweir 			aSize.Width() = GetCtrlTextWidth( maHelpText );
413*cdf0e10cSrcweir 		else
414*cdf0e10cSrcweir 			aSize.Width() = GetTextWidth( maHelpText );
415*cdf0e10cSrcweir 		maTextRect = Rectangle( Point( HELPTEXTMARGIN_QUICK, HELPTEXTMARGIN_QUICK ), aSize );
416*cdf0e10cSrcweir 	}
417*cdf0e10cSrcweir 	else // HELPWINSTYLE_BALLOON
418*cdf0e10cSrcweir 	{
419*cdf0e10cSrcweir 		Point		aTmpPoint;
420*cdf0e10cSrcweir 		sal_uInt16		nCharsInLine = 35 + ((maHelpText.Len()/100)*5);
421*cdf0e10cSrcweir 		XubString	aXXX;
422*cdf0e10cSrcweir 		aXXX.Fill( nCharsInLine, 'x' );   // Durchschnittliche Breite, damit nicht jedes Fenster anders.
423*cdf0e10cSrcweir 		long nWidth = GetTextWidth( aXXX );
424*cdf0e10cSrcweir 		Size aTmpSize( nWidth, 0x7FFFFFFF );
425*cdf0e10cSrcweir 		Rectangle aTry1( aTmpPoint, aTmpSize );
426*cdf0e10cSrcweir 		sal_uInt16 nDrawFlags = TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK |
427*cdf0e10cSrcweir 							TEXT_DRAW_LEFT | TEXT_DRAW_TOP;
428*cdf0e10cSrcweir 		if ( mnStyle & QUICKHELP_CTRLTEXT )
429*cdf0e10cSrcweir 			nDrawFlags |= TEXT_DRAW_MNEMONIC;
430*cdf0e10cSrcweir 		Rectangle aTextRect = GetTextRect( aTry1, maHelpText, nDrawFlags );
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir 		// Spaeter mal eine geeignete Breite ermitteln...
433*cdf0e10cSrcweir 		maTextRect = aTextRect;
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir 		// Sicherheitsabstand...
436*cdf0e10cSrcweir 		maTextRect.SetPos( Point( HELPTEXTMARGIN_BALLOON, HELPTEXTMARGIN_BALLOON ) );
437*cdf0e10cSrcweir 	}
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir     Size aSize( CalcOutSize() );
440*cdf0e10cSrcweir     SetOutputSizePixel( aSize );
441*cdf0e10cSrcweir }
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir // -----------------------------------------------------------------------
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir void HelpTextWindow::ImplShow()
446*cdf0e10cSrcweir {
447*cdf0e10cSrcweir 	ImplDelData aDogTag( this );
448*cdf0e10cSrcweir 	if ( maStatusText.Len() )
449*cdf0e10cSrcweir 	{
450*cdf0e10cSrcweir 		ImplSVData* pSVData = ImplGetSVData();
451*cdf0e10cSrcweir 		pSVData->mpApp->ShowHelpStatusText( maStatusText );
452*cdf0e10cSrcweir 	}
453*cdf0e10cSrcweir 	Show( sal_True, SHOW_NOACTIVATE );
454*cdf0e10cSrcweir 	if( !aDogTag.IsDelete() )
455*cdf0e10cSrcweir 	Update();
456*cdf0e10cSrcweir }
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir // -----------------------------------------------------------------------
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir void HelpTextWindow::Paint( const Rectangle& )
461*cdf0e10cSrcweir {
462*cdf0e10cSrcweir     // paint native background
463*cdf0e10cSrcweir     bool bNativeOK = false;
464*cdf0e10cSrcweir     if ( IsNativeControlSupported( CTRL_TOOLTIP, PART_ENTIRE_CONTROL ) )
465*cdf0e10cSrcweir     {
466*cdf0e10cSrcweir         // #i46472# workaround gcc3.3 temporary problem
467*cdf0e10cSrcweir         Rectangle aCtrlRegion( Point( 0, 0 ), GetOutputSizePixel() );
468*cdf0e10cSrcweir         ImplControlValue    aControlValue;
469*cdf0e10cSrcweir         bNativeOK = DrawNativeControl( CTRL_TOOLTIP, PART_ENTIRE_CONTROL, aCtrlRegion,
470*cdf0e10cSrcweir                                        0, aControlValue, rtl::OUString() );
471*cdf0e10cSrcweir     }
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir 	// paint text
474*cdf0e10cSrcweir 	if ( mnHelpWinStyle == HELPWINSTYLE_QUICK )
475*cdf0e10cSrcweir 	{
476*cdf0e10cSrcweir 		if ( mnStyle & QUICKHELP_CTRLTEXT )
477*cdf0e10cSrcweir 			DrawCtrlText( maTextRect.TopLeft(), maHelpText );
478*cdf0e10cSrcweir 		else
479*cdf0e10cSrcweir 			DrawText( maTextRect.TopLeft(), maHelpText );
480*cdf0e10cSrcweir 	}
481*cdf0e10cSrcweir 	else // HELPWINSTYLE_BALLOON
482*cdf0e10cSrcweir 	{
483*cdf0e10cSrcweir 		sal_uInt16 nDrawFlags = TEXT_DRAW_MULTILINE|TEXT_DRAW_WORDBREAK|
484*cdf0e10cSrcweir 								TEXT_DRAW_LEFT|TEXT_DRAW_TOP;
485*cdf0e10cSrcweir 		if ( mnStyle & QUICKHELP_CTRLTEXT )
486*cdf0e10cSrcweir 			nDrawFlags |= TEXT_DRAW_MNEMONIC;
487*cdf0e10cSrcweir 		DrawText( maTextRect, maHelpText, nDrawFlags );
488*cdf0e10cSrcweir 	}
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir 	// border
491*cdf0e10cSrcweir     if( ! bNativeOK )
492*cdf0e10cSrcweir     {
493*cdf0e10cSrcweir         Size aSz = GetOutputSizePixel();
494*cdf0e10cSrcweir         DrawRect( Rectangle( Point(), aSz ) );
495*cdf0e10cSrcweir         if ( mnHelpWinStyle == HELPWINSTYLE_BALLOON )
496*cdf0e10cSrcweir         {
497*cdf0e10cSrcweir             aSz.Width() -= 2;
498*cdf0e10cSrcweir             aSz.Height() -= 2;
499*cdf0e10cSrcweir             Color aColor( GetLineColor() );
500*cdf0e10cSrcweir             SetLineColor( ( COL_GRAY ) );
501*cdf0e10cSrcweir             DrawRect( Rectangle( Point( 1, 1 ), aSz ) );
502*cdf0e10cSrcweir             SetLineColor( aColor );
503*cdf0e10cSrcweir         }
504*cdf0e10cSrcweir     }
505*cdf0e10cSrcweir }
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir // -----------------------------------------------------------------------
508*cdf0e10cSrcweir 
509*cdf0e10cSrcweir void HelpTextWindow::ShowHelp( sal_uInt16 nDelayMode )
510*cdf0e10cSrcweir {
511*cdf0e10cSrcweir 	sal_uLong nTimeout = 0;
512*cdf0e10cSrcweir 	if ( nDelayMode != HELPDELAY_NONE )
513*cdf0e10cSrcweir 	{
514*cdf0e10cSrcweir 		// Im ExtendedHelp-Fall die Hilfe schneller anzeigen
515*cdf0e10cSrcweir 		if ( ImplGetSVData()->maHelpData.mbExtHelpMode )
516*cdf0e10cSrcweir 			nTimeout = 15;
517*cdf0e10cSrcweir 		else
518*cdf0e10cSrcweir 		{
519*cdf0e10cSrcweir 			const HelpSettings& rHelpSettings = GetSettings().GetHelpSettings();
520*cdf0e10cSrcweir 			if ( mnHelpWinStyle == HELPWINSTYLE_QUICK )
521*cdf0e10cSrcweir 				nTimeout = rHelpSettings.GetTipDelay();
522*cdf0e10cSrcweir 			else
523*cdf0e10cSrcweir 				nTimeout = rHelpSettings.GetBalloonDelay();
524*cdf0e10cSrcweir 		}
525*cdf0e10cSrcweir 
526*cdf0e10cSrcweir 		if ( nDelayMode == HELPDELAY_SHORT )
527*cdf0e10cSrcweir 			nTimeout /= 3;
528*cdf0e10cSrcweir 	}
529*cdf0e10cSrcweir 
530*cdf0e10cSrcweir 	maShowTimer.SetTimeout( nTimeout );
531*cdf0e10cSrcweir 	maShowTimer.Start();
532*cdf0e10cSrcweir }
533*cdf0e10cSrcweir 
534*cdf0e10cSrcweir // -----------------------------------------------------------------------
535*cdf0e10cSrcweir 
536*cdf0e10cSrcweir IMPL_LINK( HelpTextWindow, TimerHdl, Timer*, pTimer)
537*cdf0e10cSrcweir {
538*cdf0e10cSrcweir 	if ( pTimer == &maShowTimer )
539*cdf0e10cSrcweir 	{
540*cdf0e10cSrcweir 		if ( mnHelpWinStyle == HELPWINSTYLE_QUICK )
541*cdf0e10cSrcweir 		{
542*cdf0e10cSrcweir 			// start auto-hide-timer for non-ShowTip windows
543*cdf0e10cSrcweir 			ImplSVData* pSVData = ImplGetSVData();
544*cdf0e10cSrcweir 			if ( this == pSVData->maHelpData.mpHelpWin )
545*cdf0e10cSrcweir 				maHideTimer.Start();
546*cdf0e10cSrcweir 		}
547*cdf0e10cSrcweir 		ImplShow();
548*cdf0e10cSrcweir 	}
549*cdf0e10cSrcweir 	else
550*cdf0e10cSrcweir 	{
551*cdf0e10cSrcweir         DBG_ASSERT( pTimer == &maHideTimer, "HelpTextWindow::TimerHdl with bad Timer" );
552*cdf0e10cSrcweir   		ImplDestroyHelpWindow( true );
553*cdf0e10cSrcweir 	}
554*cdf0e10cSrcweir 
555*cdf0e10cSrcweir 	return 1;
556*cdf0e10cSrcweir }
557*cdf0e10cSrcweir 
558*cdf0e10cSrcweir // -----------------------------------------------------------------------
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir Size HelpTextWindow::CalcOutSize() const
561*cdf0e10cSrcweir {
562*cdf0e10cSrcweir 	Size aSz = maTextRect.GetSize();
563*cdf0e10cSrcweir 	aSz.Width() += 2*maTextRect.Left();
564*cdf0e10cSrcweir 	aSz.Height() += 2*maTextRect.Top();
565*cdf0e10cSrcweir 	return aSz;
566*cdf0e10cSrcweir }
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir // -----------------------------------------------------------------------
569*cdf0e10cSrcweir 
570*cdf0e10cSrcweir void HelpTextWindow::RequestHelp( const HelpEvent& /*rHEvt*/ )
571*cdf0e10cSrcweir {
572*cdf0e10cSrcweir 	// Nur damit nicht von Window::RequestHelp() ein
573*cdf0e10cSrcweir 	// ShowQuickHelp/ShowBalloonHelp am HelpTextWindow aufgerufen wird.
574*cdf0e10cSrcweir }
575*cdf0e10cSrcweir 
576*cdf0e10cSrcweir // -----------------------------------------------------------------------
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir String HelpTextWindow::GetText() const
579*cdf0e10cSrcweir {
580*cdf0e10cSrcweir 	return maHelpText;
581*cdf0e10cSrcweir }
582*cdf0e10cSrcweir 
583*cdf0e10cSrcweir // -----------------------------------------------------------------------
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > HelpTextWindow::CreateAccessible()
586*cdf0e10cSrcweir {
587*cdf0e10cSrcweir     return FloatingWindow::CreateAccessible();
588*cdf0e10cSrcweir }
589*cdf0e10cSrcweir 
590*cdf0e10cSrcweir // -----------------------------------------------------------------------
591*cdf0e10cSrcweir 
592*cdf0e10cSrcweir sal_Bool HelpTextWindow::RegisterAccessibleParent()
593*cdf0e10cSrcweir {
594*cdf0e10cSrcweir         return sal_False;
595*cdf0e10cSrcweir }
596*cdf0e10cSrcweir 
597*cdf0e10cSrcweir // -----------------------------------------------------------------------
598*cdf0e10cSrcweir 
599*cdf0e10cSrcweir void HelpTextWindow::RevokeAccessibleParent()
600*cdf0e10cSrcweir {
601*cdf0e10cSrcweir }
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir // =======================================================================
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir void ImplShowHelpWindow( Window* pParent, sal_uInt16 nHelpWinStyle, sal_uInt16 nStyle,
606*cdf0e10cSrcweir 						 const XubString& rHelpText, const XubString& rStatusText,
607*cdf0e10cSrcweir 						 const Point& rScreenPos, const Rectangle* pHelpArea )
608*cdf0e10cSrcweir {
609*cdf0e10cSrcweir 	ImplSVData* pSVData = ImplGetSVData();
610*cdf0e10cSrcweir 
611*cdf0e10cSrcweir 	if( !rHelpText.Len() && !pSVData->maHelpData.mbRequestingHelp )
612*cdf0e10cSrcweir 		return;
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir 	HelpTextWindow* pHelpWin = pSVData->maHelpData.mpHelpWin;
615*cdf0e10cSrcweir 	sal_uInt16 nDelayMode = HELPDELAY_NORMAL;
616*cdf0e10cSrcweir 	if ( pHelpWin )
617*cdf0e10cSrcweir 	{
618*cdf0e10cSrcweir 		DBG_ASSERT( pHelpWin != pParent, "HelpInHelp ?!" );
619*cdf0e10cSrcweir 
620*cdf0e10cSrcweir         if  (   (   ( pHelpWin->GetHelpText() != rHelpText )
621*cdf0e10cSrcweir                 ||  ( pHelpWin->GetWinStyle() != nHelpWinStyle )
622*cdf0e10cSrcweir                 ||  (   pHelpArea
623*cdf0e10cSrcweir                     &&  ( pHelpWin->GetHelpArea() != *pHelpArea )
624*cdf0e10cSrcweir                     )
625*cdf0e10cSrcweir                 )
626*cdf0e10cSrcweir             &&  pSVData->maHelpData.mbRequestingHelp
627*cdf0e10cSrcweir             )
628*cdf0e10cSrcweir 		{
629*cdf0e10cSrcweir 			// remove help window if no HelpText or other HelpText or
630*cdf0e10cSrcweir 			// other help mode. but keep it if we are scrolling, ie not requesting help
631*cdf0e10cSrcweir             bool bWasVisible = pHelpWin->IsVisible();
632*cdf0e10cSrcweir 			if ( bWasVisible )
633*cdf0e10cSrcweir 				nDelayMode = HELPDELAY_NONE; // display it quickly if we were already in quick help mode
634*cdf0e10cSrcweir 			pHelpWin = NULL;
635*cdf0e10cSrcweir 			ImplDestroyHelpWindow( bWasVisible );
636*cdf0e10cSrcweir 		}
637*cdf0e10cSrcweir 		else
638*cdf0e10cSrcweir 		{
639*cdf0e10cSrcweir             bool const bTextChanged = rHelpText != pHelpWin->GetHelpText();
640*cdf0e10cSrcweir             if ( bTextChanged || ( ( nStyle & QUICKHELP_FORCE_REPOSITION ) != 0 ) )
641*cdf0e10cSrcweir             {
642*cdf0e10cSrcweir                 Window * pWindow = pHelpWin->GetParent()->ImplGetFrameWindow();
643*cdf0e10cSrcweir                 Rectangle aInvRect( pHelpWin->GetWindowExtentsRelative( pWindow ) );
644*cdf0e10cSrcweir                 if( pHelpWin->IsVisible() )
645*cdf0e10cSrcweir 					pWindow->Invalidate( aInvRect );
646*cdf0e10cSrcweir 
647*cdf0e10cSrcweir                 pHelpWin->SetHelpText( rHelpText );
648*cdf0e10cSrcweir 			    // approach mouse position
649*cdf0e10cSrcweir 			    ImplSetHelpWindowPos( pHelpWin, nHelpWinStyle, nStyle, rScreenPos, pHelpArea );
650*cdf0e10cSrcweir                 if( pHelpWin->IsVisible() )
651*cdf0e10cSrcweir                     pHelpWin->Invalidate();
652*cdf0e10cSrcweir             }
653*cdf0e10cSrcweir 		}
654*cdf0e10cSrcweir 	}
655*cdf0e10cSrcweir 
656*cdf0e10cSrcweir 	if ( !pHelpWin && rHelpText.Len() )
657*cdf0e10cSrcweir 	{
658*cdf0e10cSrcweir         sal_uLong nCurTime = Time::GetSystemTicks();
659*cdf0e10cSrcweir         if  (   ( ( nCurTime - pSVData->maHelpData.mnLastHelpHideTime ) < pParent->GetSettings().GetHelpSettings().GetTipDelay() )
660*cdf0e10cSrcweir             ||  ( ( nStyle & QUICKHELP_NO_DELAY ) != 0 )
661*cdf0e10cSrcweir             )
662*cdf0e10cSrcweir             nDelayMode = HELPDELAY_NONE;
663*cdf0e10cSrcweir 
664*cdf0e10cSrcweir 		DBG_ASSERT( !pHelpWin, "Noch ein HelpWin ?!" );
665*cdf0e10cSrcweir 		pHelpWin = new HelpTextWindow( pParent, rHelpText, nHelpWinStyle, nStyle );
666*cdf0e10cSrcweir 		pSVData->maHelpData.mpHelpWin = pHelpWin;
667*cdf0e10cSrcweir 		pHelpWin->SetStatusText( rStatusText );
668*cdf0e10cSrcweir 		if ( pHelpArea )
669*cdf0e10cSrcweir 			pHelpWin->SetHelpArea( *pHelpArea );
670*cdf0e10cSrcweir 
671*cdf0e10cSrcweir 		//	positioning
672*cdf0e10cSrcweir 		Size aSz = pHelpWin->CalcOutSize();
673*cdf0e10cSrcweir 		pHelpWin->SetOutputSizePixel( aSz );
674*cdf0e10cSrcweir 		ImplSetHelpWindowPos( pHelpWin, nHelpWinStyle, nStyle, rScreenPos, pHelpArea );
675*cdf0e10cSrcweir 		// if not called from Window::RequestHelp, then without delay...
676*cdf0e10cSrcweir 		if ( !pSVData->maHelpData.mbRequestingHelp )
677*cdf0e10cSrcweir 			nDelayMode = HELPDELAY_NONE;
678*cdf0e10cSrcweir 		pHelpWin->ShowHelp( nDelayMode );
679*cdf0e10cSrcweir 	}
680*cdf0e10cSrcweir }
681*cdf0e10cSrcweir 
682*cdf0e10cSrcweir // -----------------------------------------------------------------------
683*cdf0e10cSrcweir 
684*cdf0e10cSrcweir void ImplDestroyHelpWindow( bool bUpdateHideTime )
685*cdf0e10cSrcweir {
686*cdf0e10cSrcweir 	ImplSVData* pSVData = ImplGetSVData();
687*cdf0e10cSrcweir 	HelpTextWindow* pHelpWin = pSVData->maHelpData.mpHelpWin;
688*cdf0e10cSrcweir 	if ( pHelpWin )
689*cdf0e10cSrcweir 	{
690*cdf0e10cSrcweir         Window * pWindow = pHelpWin->GetParent()->ImplGetFrameWindow();
691*cdf0e10cSrcweir 		// find out screen area covered by system help window
692*cdf0e10cSrcweir         Rectangle aInvRect( pHelpWin->GetWindowExtentsRelative( pWindow ) );
693*cdf0e10cSrcweir 		if( pHelpWin->IsVisible() )
694*cdf0e10cSrcweir 			pWindow->Invalidate( aInvRect );
695*cdf0e10cSrcweir 		pSVData->maHelpData.mpHelpWin = NULL;
696*cdf0e10cSrcweir 		pSVData->maHelpData.mbKeyboardHelp = sal_False;
697*cdf0e10cSrcweir 		pHelpWin->Hide();
698*cdf0e10cSrcweir 		delete pHelpWin;
699*cdf0e10cSrcweir         if( bUpdateHideTime )
700*cdf0e10cSrcweir             pSVData->maHelpData.mnLastHelpHideTime = Time::GetSystemTicks();
701*cdf0e10cSrcweir 	}
702*cdf0e10cSrcweir }
703*cdf0e10cSrcweir 
704*cdf0e10cSrcweir // -----------------------------------------------------------------------
705*cdf0e10cSrcweir 
706*cdf0e10cSrcweir void ImplSetHelpWindowPos( Window* pHelpWin, sal_uInt16 nHelpWinStyle, sal_uInt16 nStyle,
707*cdf0e10cSrcweir 						   const Point& rPos, const Rectangle* pHelpArea )
708*cdf0e10cSrcweir {
709*cdf0e10cSrcweir 	Point		aPos = rPos;
710*cdf0e10cSrcweir 	Size		aSz = pHelpWin->GetSizePixel();
711*cdf0e10cSrcweir 	Rectangle	aScreenRect = pHelpWin->ImplGetFrameWindow()->GetDesktopRectPixel();
712*cdf0e10cSrcweir     aPos = pHelpWin->GetParent()->ImplGetFrameWindow()->OutputToAbsoluteScreenPixel( aPos );
713*cdf0e10cSrcweir     // get mouse screen coords
714*cdf0e10cSrcweir     Point mPos( pHelpWin->GetParent()->ImplGetFrameWindow()->GetPointerPosPixel() );
715*cdf0e10cSrcweir     mPos = pHelpWin->GetParent()->ImplGetFrameWindow()->OutputToAbsoluteScreenPixel( mPos );
716*cdf0e10cSrcweir 
717*cdf0e10cSrcweir 	if ( nHelpWinStyle == HELPWINSTYLE_QUICK )
718*cdf0e10cSrcweir 	{
719*cdf0e10cSrcweir 		if ( !(nStyle & QUICKHELP_NOAUTOPOS) )
720*cdf0e10cSrcweir 		{
721*cdf0e10cSrcweir 			long nScreenHeight = aScreenRect.GetHeight();
722*cdf0e10cSrcweir 			aPos.X() -= 4;
723*cdf0e10cSrcweir 			if ( aPos.Y() > aScreenRect.Top()+nScreenHeight-(nScreenHeight/4) )
724*cdf0e10cSrcweir 				aPos.Y() -= aSz.Height()+4;
725*cdf0e10cSrcweir 			else
726*cdf0e10cSrcweir 				aPos.Y() += 21;
727*cdf0e10cSrcweir 		}
728*cdf0e10cSrcweir 	}
729*cdf0e10cSrcweir 	else
730*cdf0e10cSrcweir 	{
731*cdf0e10cSrcweir 		// If it's the mouse position, move the window slightly
732*cdf0e10cSrcweir 		// so the mouse pointer does not cover it
733*cdf0e10cSrcweir 		if ( aPos == mPos )
734*cdf0e10cSrcweir 		{
735*cdf0e10cSrcweir 			aPos.X() += 12;
736*cdf0e10cSrcweir 			aPos.Y() += 16;
737*cdf0e10cSrcweir 		}
738*cdf0e10cSrcweir 	}
739*cdf0e10cSrcweir 
740*cdf0e10cSrcweir 	if ( nStyle & QUICKHELP_NOAUTOPOS )
741*cdf0e10cSrcweir 	{
742*cdf0e10cSrcweir 		if ( pHelpArea )
743*cdf0e10cSrcweir 		{
744*cdf0e10cSrcweir             // convert help area to screen coords
745*cdf0e10cSrcweir             Rectangle devHelpArea(
746*cdf0e10cSrcweir                 pHelpWin->GetParent()->ImplGetFrameWindow()->OutputToAbsoluteScreenPixel( pHelpArea->TopLeft() ),
747*cdf0e10cSrcweir                 pHelpWin->GetParent()->ImplGetFrameWindow()->OutputToAbsoluteScreenPixel( pHelpArea->BottomRight() ) );
748*cdf0e10cSrcweir 
749*cdf0e10cSrcweir 			// Welche Position vom Rechteck?
750*cdf0e10cSrcweir 			aPos = devHelpArea.Center();
751*cdf0e10cSrcweir 
752*cdf0e10cSrcweir 			if ( nStyle & QUICKHELP_LEFT )
753*cdf0e10cSrcweir 				aPos.X() = devHelpArea.Left();
754*cdf0e10cSrcweir 			else if ( nStyle & QUICKHELP_RIGHT )
755*cdf0e10cSrcweir 				aPos.X() = devHelpArea.Right();
756*cdf0e10cSrcweir 
757*cdf0e10cSrcweir 			if ( nStyle & QUICKHELP_TOP )
758*cdf0e10cSrcweir 				aPos.Y() = devHelpArea.Top();
759*cdf0e10cSrcweir 			else if ( nStyle & QUICKHELP_BOTTOM )
760*cdf0e10cSrcweir 				aPos.Y() = devHelpArea.Bottom();
761*cdf0e10cSrcweir 		}
762*cdf0e10cSrcweir 
763*cdf0e10cSrcweir 		// Welche Richtung?
764*cdf0e10cSrcweir 		if ( nStyle & QUICKHELP_LEFT )
765*cdf0e10cSrcweir 			;
766*cdf0e10cSrcweir 		else if ( nStyle & QUICKHELP_RIGHT )
767*cdf0e10cSrcweir 			aPos.X() -= aSz.Width();
768*cdf0e10cSrcweir 		else
769*cdf0e10cSrcweir 			aPos.X() -= aSz.Width()/2;
770*cdf0e10cSrcweir 
771*cdf0e10cSrcweir 		if ( nStyle & QUICKHELP_TOP )
772*cdf0e10cSrcweir 			;
773*cdf0e10cSrcweir 		else if ( nStyle & QUICKHELP_BOTTOM )
774*cdf0e10cSrcweir 			aPos.Y() -= aSz.Height();
775*cdf0e10cSrcweir 		else
776*cdf0e10cSrcweir 			aPos.Y() -= aSz.Height()/2;
777*cdf0e10cSrcweir 	}
778*cdf0e10cSrcweir 
779*cdf0e10cSrcweir 	if ( aPos.X() < aScreenRect.Left() )
780*cdf0e10cSrcweir 		aPos.X() = aScreenRect.Left();
781*cdf0e10cSrcweir 	else if ( ( aPos.X() + aSz.Width() ) > aScreenRect.Right() )
782*cdf0e10cSrcweir 		aPos.X() = aScreenRect.Right() - aSz.Width();
783*cdf0e10cSrcweir 	if ( aPos.Y() < aScreenRect.Top() )
784*cdf0e10cSrcweir 		aPos.Y() = aScreenRect.Top();
785*cdf0e10cSrcweir 	else if ( ( aPos.Y() + aSz.Height() ) > aScreenRect.Bottom() )
786*cdf0e10cSrcweir 		aPos.Y() = aScreenRect.Bottom() - aSz.Height();
787*cdf0e10cSrcweir 
788*cdf0e10cSrcweir 	if( ! (nStyle & QUICKHELP_NOEVADEPOINTER) )
789*cdf0e10cSrcweir 	{
790*cdf0e10cSrcweir 	    /* the remark below should be obsolete by now as the helpwindow should
791*cdf0e10cSrcweir 	    not be focusable, leaving it as a hint. However it is sensible in most
792*cdf0e10cSrcweir 	    conditions to evade the mouse pointer so the content window is fully visible.
793*cdf0e10cSrcweir 
794*cdf0e10cSrcweir         // the popup must not appear under the mouse
795*cdf0e10cSrcweir         // otherwise it would directly be closed due to a focus change...
796*cdf0e10cSrcweir         */
797*cdf0e10cSrcweir         Rectangle aHelpRect( aPos, aSz );
798*cdf0e10cSrcweir         if( aHelpRect.IsInside( mPos ) )
799*cdf0e10cSrcweir         {
800*cdf0e10cSrcweir             Point delta(2,2);
801*cdf0e10cSrcweir             Point pSize( aSz.Width(), aSz.Height() );
802*cdf0e10cSrcweir             Point pTest( mPos - pSize - delta );
803*cdf0e10cSrcweir             if( pTest.X() > aScreenRect.Left() &&  pTest.Y() > aScreenRect.Top() )
804*cdf0e10cSrcweir                 aPos = pTest;
805*cdf0e10cSrcweir             else
806*cdf0e10cSrcweir                 aPos = mPos + delta;
807*cdf0e10cSrcweir         }
808*cdf0e10cSrcweir     }
809*cdf0e10cSrcweir 
810*cdf0e10cSrcweir     Window* pWindow = pHelpWin->GetParent()->ImplGetFrameWindow();
811*cdf0e10cSrcweir     aPos = pWindow->AbsoluteScreenToOutputPixel( aPos );
812*cdf0e10cSrcweir 	pHelpWin->SetPosPixel( aPos );
813*cdf0e10cSrcweir }
814