diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-12-14 14:05:53 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-01-28 10:41:44 +0000 |
commit | 77e21efcdde2589a56c029c663cd75e105edd1fd (patch) | |
tree | 34809299b00750c427d3989e97fc7b1010f6551b /vcl | |
parent | 32333afd215ffcdc320845937dd524a08fe4f9b0 (diff) |
Related: rhbz#1289394 always provide the screen area the tip applies to
this will make it easier to implement native help tips
Change-Id: I984dfadaf02e9b7bf542ba82cf070911c89cb699
(cherry picked from commit 01ef12d173fb2c54a49186c8eb4fa40288b82945)
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/helpwin.hxx | 4 | ||||
-rw-r--r-- | vcl/source/app/help.cxx | 68 | ||||
-rw-r--r-- | vcl/source/window/menuwindow.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/window.cxx | 9 |
4 files changed, 37 insertions, 46 deletions
diff --git a/vcl/inc/helpwin.hxx b/vcl/inc/helpwin.hxx index e37296269398..cf35423e262b 100644 --- a/vcl/inc/helpwin.hxx +++ b/vcl/inc/helpwin.hxx @@ -75,10 +75,10 @@ public: void ImplShowHelpWindow( vcl::Window* pParent, sal_uInt16 nHelpWinStyle, QuickHelpFlags nStyle, const OUString& rHelpText, const OUString& rStatusText, - const Point& rScreenPos, const Rectangle* pHelpArea = nullptr ); + const Point& rScreenPos, const Rectangle& rHelpArea ); void ImplDestroyHelpWindow( bool bUpdateHideTime ); void ImplSetHelpWindowPos( vcl::Window* pHelpWindow, sal_uInt16 nHelpWinStyle, QuickHelpFlags nStyle, - const Point& rPos, const Rectangle* pHelpArea ); + const Point& rPos, const Rectangle& rHelpArea ); #endif // INCLUDED_VCL_INC_HELPWIN_HXX diff --git a/vcl/source/app/help.cxx b/vcl/source/app/help.cxx index 912607d788b5..51a9e31ff2f3 100644 --- a/vcl/source/app/help.cxx +++ b/vcl/source/app/help.cxx @@ -147,21 +147,11 @@ bool Help::IsBalloonHelpEnabled() } bool Help::ShowBalloon( vcl::Window* pParent, - const Point& rScreenPos, - const OUString& rHelpText ) -{ - ImplShowHelpWindow( pParent, HELPWINSTYLE_BALLOON, QuickHelpFlags::NONE, - rHelpText, OUString(), rScreenPos ); - - return true; -} - -bool Help::ShowBalloon( vcl::Window* pParent, const Point& rScreenPos, const Rectangle& rRect, const OUString& rHelpText ) { ImplShowHelpWindow( pParent, HELPWINSTYLE_BALLOON, QuickHelpFlags::NONE, - rHelpText, OUString(), rScreenPos, &rRect ); + rHelpText, OUString(), rScreenPos, rRect ); return true; } @@ -189,7 +179,7 @@ bool Help::ShowQuickHelp( vcl::Window* pParent, { ImplShowHelpWindow( pParent, HELPWINSTYLE_QUICK, nStyle, rHelpText, rLongHelpText, - pParent->OutputToScreenPixel( pParent->GetPointerPosPixel() ), &rScreenRect ); + pParent->OutputToScreenPixel( pParent->GetPointerPosPixel() ), rScreenRect ); return true; } @@ -221,7 +211,7 @@ void Help::UpdateTip( sal_uIntPtr nId, vcl::Window* pParent, const Rectangle& rS Size aSz = pHelpWin->CalcOutSize(); pHelpWin->SetOutputSizePixel( aSz ); ImplSetHelpWindowPos( pHelpWin, pHelpWin->GetWinStyle(), pHelpWin->GetStyle(), - pParent->OutputToScreenPixel( pParent->GetPointerPosPixel() ), &rScreenRect ); + pParent->OutputToScreenPixel( pParent->GetPointerPosPixel() ), rScreenRect ); pHelpWin->SetHelpText( rText ); pHelpWin->Invalidate(); @@ -470,7 +460,7 @@ OUString HelpTextWindow::GetText() const void ImplShowHelpWindow( vcl::Window* pParent, sal_uInt16 nHelpWinStyle, QuickHelpFlags nStyle, const OUString& rHelpText, const OUString& rStatusText, - const Point& rScreenPos, const Rectangle* pHelpArea ) + const Point& rScreenPos, const Rectangle& rHelpArea ) { ImplSVData* pSVData = ImplGetSVData(); @@ -485,9 +475,7 @@ void ImplShowHelpWindow( vcl::Window* pParent, sal_uInt16 nHelpWinStyle, QuickHe if ( ( ( pHelpWin->GetHelpText() != rHelpText ) || ( pHelpWin->GetWinStyle() != nHelpWinStyle ) - || ( pHelpArea - && ( pHelpWin->GetHelpArea() != *pHelpArea ) - ) + || ( pHelpWin->GetHelpArea() != rHelpArea ) ) && pSVData->maHelpData.mbRequestingHelp ) @@ -512,7 +500,7 @@ void ImplShowHelpWindow( vcl::Window* pParent, sal_uInt16 nHelpWinStyle, QuickHe pHelpWin->SetHelpText( rHelpText ); // approach mouse position - ImplSetHelpWindowPos( pHelpWin, nHelpWinStyle, nStyle, rScreenPos, pHelpArea ); + ImplSetHelpWindowPos( pHelpWin, nHelpWinStyle, nStyle, rScreenPos, rHelpArea ); if( pHelpWin->IsVisible() ) pHelpWin->Invalidate(); } @@ -531,13 +519,12 @@ void ImplShowHelpWindow( vcl::Window* pParent, sal_uInt16 nHelpWinStyle, QuickHe pHelpWin = VclPtr<HelpTextWindow>::Create( pParent, rHelpText, nHelpWinStyle, nStyle ); pSVData->maHelpData.mpHelpWin = pHelpWin; pHelpWin->SetStatusText( rStatusText ); - if ( pHelpArea ) - pHelpWin->SetHelpArea( *pHelpArea ); + pHelpWin->SetHelpArea( rHelpArea ); // positioning Size aSz = pHelpWin->CalcOutSize(); pHelpWin->SetOutputSizePixel( aSz ); - ImplSetHelpWindowPos( pHelpWin, nHelpWinStyle, nStyle, rScreenPos, pHelpArea ); + ImplSetHelpWindowPos( pHelpWin, nHelpWinStyle, nStyle, rScreenPos, rHelpArea ); // if not called from Window::RequestHelp, then without delay... if ( !pSVData->maHelpData.mbRequestingHelp ) nDelayMode = HELPDELAY_NONE; @@ -566,7 +553,7 @@ void ImplDestroyHelpWindow( bool bUpdateHideTime ) } void ImplSetHelpWindowPos( vcl::Window* pHelpWin, sal_uInt16 nHelpWinStyle, QuickHelpFlags nStyle, - const Point& rPos, const Rectangle* pHelpArea ) + const Point& rPos, const Rectangle& rHelpArea ) { Point aPos = rPos; Size aSz = pHelpWin->GetSizePixel(); @@ -601,26 +588,23 @@ void ImplSetHelpWindowPos( vcl::Window* pHelpWin, sal_uInt16 nHelpWinStyle, Quic if ( nStyle & QuickHelpFlags::NoAutoPos ) { - if ( pHelpArea ) - { - // convert help area to screen coords - Rectangle devHelpArea( - pHelpWin->GetParent()->ImplGetFrameWindow()->OutputToAbsoluteScreenPixel( pHelpArea->TopLeft() ), - pHelpWin->GetParent()->ImplGetFrameWindow()->OutputToAbsoluteScreenPixel( pHelpArea->BottomRight() ) ); - - // Welche Position vom Rechteck? - aPos = devHelpArea.Center(); - - if ( nStyle & QuickHelpFlags::Left ) - aPos.X() = devHelpArea.Left(); - else if ( nStyle & QuickHelpFlags::Right ) - aPos.X() = devHelpArea.Right(); - - if ( nStyle & QuickHelpFlags::Top ) - aPos.Y() = devHelpArea.Top(); - else if ( nStyle & QuickHelpFlags::Bottom ) - aPos.Y() = devHelpArea.Bottom(); - } + // convert help area to screen coords + Rectangle devHelpArea( + pHelpWin->GetParent()->ImplGetFrameWindow()->OutputToAbsoluteScreenPixel( rHelpArea.TopLeft() ), + pHelpWin->GetParent()->ImplGetFrameWindow()->OutputToAbsoluteScreenPixel( rHelpArea.BottomRight() ) ); + + // Welche Position vom Rechteck? + aPos = devHelpArea.Center(); + + if ( nStyle & QuickHelpFlags::Left ) + aPos.X() = devHelpArea.Left(); + else if ( nStyle & QuickHelpFlags::Right ) + aPos.X() = devHelpArea.Right(); + + if ( nStyle & QuickHelpFlags::Top ) + aPos.Y() = devHelpArea.Top(); + else if ( nStyle & QuickHelpFlags::Bottom ) + aPos.Y() = devHelpArea.Bottom(); // which direction? if ( nStyle & QuickHelpFlags::Left ) diff --git a/vcl/source/window/menuwindow.cxx b/vcl/source/window/menuwindow.cxx index 72a1baecbb3f..83ca0b610975 100644 --- a/vcl/source/window/menuwindow.cxx +++ b/vcl/source/window/menuwindow.cxx @@ -63,7 +63,7 @@ bool MenuWindow::ImplHandleHelpEvent(vcl::Window* pMenuWindow, Menu* pMenu, sal_ Rectangle aRect( aPos, Size() ); if (!pMenu->GetHelpText(nId).isEmpty()) - Help::ShowBalloon( pMenuWindow, aPos, pMenu->GetHelpText( nId ) ); + Help::ShowBalloon( pMenuWindow, aPos, aRect, pMenu->GetHelpText( nId ) ); else { // give user a chance to read the full filename diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index a064650f40bb..d1b5bc1a5842 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -2007,7 +2007,14 @@ void Window::RequestHelp( const HelpEvent& rHEvt ) if ( rStr.isEmpty() && ImplGetParent() && !ImplIsOverlapWindow() ) ImplGetParent()->RequestHelp( rHEvt ); else - Help::ShowBalloon( this, rHEvt.GetMousePosPixel(), rStr ); + { + Point aPos = GetPosPixel(); + if ( ImplGetParent() && !ImplIsOverlapWindow() ) + aPos = ImplGetParent()->OutputToScreenPixel( aPos ); + Rectangle aRect( aPos, GetSizePixel() ); + + Help::ShowBalloon( this, rHEvt.GetMousePosPixel(), aRect, rStr ); + } } else if ( rHEvt.GetMode() & HelpEventMode::QUICK ) { |