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