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
diff --git a/cui/source/customize/acccfg.cxx b/cui/source/customize/acccfg.cxx
index 2d42b3c..ee07d7e 100644
--- a/cui/source/customize/acccfg.cxx
+++ b/cui/source/customize/acccfg.cxx
@@ -1108,7 +1108,7 @@ IMPL_LINK_NOARG_TYPED(SfxAcceleratorConfigPage, RemoveHdl, Button*, void)
IMPL_LINK_TYPED( SfxAcceleratorConfigPage, SelectHdl, SvTreeListBox*, pListBox, void )
{
// disable help
Help::ShowBalloon( this, Point(), OUString() );
Help::ShowBalloon( this, Point(), Rectangle(), OUString() );
if (pListBox == m_pEntriesBox)
{
sal_uLong nPos = SvTreeList::GetRelPos( m_pEntriesBox->FirstSelected() );
diff --git a/cui/source/customize/selector.cxx b/cui/source/customize/selector.cxx
index 7f4c65e..28fbd87 100644
--- a/cui/source/customize/selector.cxx
+++ b/cui/source/customize/selector.cxx
@@ -131,7 +131,8 @@ void SvxConfigFunctionListBox::MouseMove( const MouseEvent& rMEvt )
aTimer.Start();
else
{
Help::ShowBalloon( this, aMousePos, OUString() );
Rectangle aRect(GetPosPixel(), GetSizePixel());
Help::ShowBalloon( this, aMousePos, aRect, OUString() );
aTimer.Stop();
}
}
@@ -143,7 +144,10 @@ IMPL_LINK_NOARG_TYPED(SvxConfigFunctionListBox, TimerHdl, Timer *, void)
Point aMousePos = GetPointerPosPixel();
SvTreeListEntry *pEntry = GetCurEntry();
if ( pEntry && GetEntry( aMousePos ) == pEntry && pCurEntry == pEntry )
Help::ShowBalloon( this, OutputToScreenPixel( aMousePos ), GetHelpText( pEntry ) );
{
Rectangle aRect(GetPosPixel(), GetSizePixel());
Help::ShowBalloon( this, OutputToScreenPixel(aMousePos), aRect, GetHelpText( pEntry ) );
}
}
void SvxConfigFunctionListBox::ClearAll()
@@ -178,7 +182,7 @@ OUString SvxConfigFunctionListBox::GetHelpText( SvTreeListEntry *pEntry )
void SvxConfigFunctionListBox::FunctionSelected()
{
Help::ShowBalloon( this, Point(), OUString() );
Help::ShowBalloon( this, Point(), Rectangle(), OUString() );
}
// drag and drop support
diff --git a/include/vcl/help.hxx b/include/vcl/help.hxx
index 40dfcf2..4d226a8 100644
--- a/include/vcl/help.hxx
+++ b/include/vcl/help.hxx
@@ -86,9 +86,6 @@ public:
static bool IsBalloonHelpEnabled();
static bool ShowBalloon( vcl::Window* pParent,
const Point& rScreenPos,
const OUString& rHelpText );
static bool ShowBalloon( vcl::Window* pParent,
const Point& rScreenPos,
const Rectangle&,
const OUString& rHelpText );
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index 0577ad4..bc3fa4b 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -1366,7 +1366,7 @@ void CustomPropertiesDurationField::RequestHelp( const HelpEvent& rHEvt )
Size aSize( GetSizePixel() );
Rectangle aItemRect( rHEvt.GetMousePosPixel(), aSize );
if (Help::IsBalloonHelpEnabled())
Help::ShowBalloon( this, rHEvt.GetMousePosPixel(), GetText() );
Help::ShowBalloon( this, rHEvt.GetMousePosPixel(), aItemRect, GetText() );
else
Help::ShowQuickHelp( this, aItemRect, GetText(),
QuickHelpFlags::Left|QuickHelpFlags::VCenter );
diff --git a/sw/source/core/draw/dpage.cxx b/sw/source/core/draw/dpage.cxx
index f8ad9f6..c8773e8 100644
--- a/sw/source/core/draw/dpage.cxx
+++ b/sw/source/core/draw/dpage.cxx
@@ -237,14 +237,14 @@ bool SwDPage::RequestHelp( vcl::Window* pWindow, SdrView* pView,
sText = SwViewShell::GetShellRes()->aLinkClick + ": " + sText;
}
// then display the help:
Rectangle aRect( rEvt.GetMousePosPixel(), Size(1,1) );
if( rEvt.GetMode() & HelpEventMode::BALLOON )
{
Help::ShowBalloon( pWindow, rEvt.GetMousePosPixel(), sText );
Help::ShowBalloon( pWindow, rEvt.GetMousePosPixel(), aRect, sText );
}
else
{
// then display the help:
Rectangle aRect( rEvt.GetMousePosPixel(), Size(1,1) );
Help::ShowQuickHelp( pWindow, aRect, sText );
}
bContinue = false;
diff --git a/sw/source/uibase/docvw/edtwin2.cxx b/sw/source/uibase/docvw/edtwin2.cxx
index ba05744..a15a681 100644
--- a/sw/source/uibase/docvw/edtwin2.cxx
+++ b/sw/source/uibase/docvw/edtwin2.cxx
@@ -364,18 +364,19 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt)
}
if (!sText.isEmpty())
{
Rectangle aRect( aFieldRect.SVRect() );
Point aPt( OutputToScreenPixel( LogicToPixel( aRect.TopLeft() )));
aRect.Left() = aPt.X();
aRect.Top() = aPt.Y();
aPt = OutputToScreenPixel( LogicToPixel( aRect.BottomRight() ));
aRect.Right() = aPt.X();
aRect.Bottom() = aPt.Y();
if( bBalloon )
Help::ShowBalloon( this, rEvt.GetMousePosPixel(), sText );
Help::ShowBalloon( this, rEvt.GetMousePosPixel(), aRect, sText );
else
{
// the show the help
Rectangle aRect( aFieldRect.SVRect() );
Point aPt( OutputToScreenPixel( LogicToPixel( aRect.TopLeft() )));
aRect.Left() = aPt.X();
aRect.Top() = aPt.Y();
aPt = OutputToScreenPixel( LogicToPixel( aRect.BottomRight() ));
aRect.Right() = aPt.X();
aRect.Bottom() = aPt.Y();
OUString sDisplayText(ClipLongToolTip(sText));
Help::ShowQuickHelp(this, aRect, sDisplayText, nStyle);
}
diff --git a/vcl/inc/helpwin.hxx b/vcl/inc/helpwin.hxx
index e372962..cf35423 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 912607d..51a9e31f 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() ) );
// 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();
// 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::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();
}
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 72a1bae..83ca0b6 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 8901512..c988af6 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 )
{