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