Kaydet (Commit) 681294d5 authored tarafından Caolán McNamara's avatar Caolán McNamara

gtk3: use native GtkPopover for calc formula prompt, etc

Change-Id: I9aa7e977228780b6273daa03be5e872342414437
üst 7decc419
......@@ -43,7 +43,7 @@ enum class QuickHelpFlags
CtrlText = 0x0040,
/// no delay when opening the quick help. Applies to ShowBallon and ShowQuickHelp
NoDelay = 0x0080,
/// force balloon-style in ShowTip
/// force balloon-style in ShowPopover
TipStyleBalloon = 0x0100,
NoEvadePointer = 0x0200,
BiDiRtl = 0x0400,
......@@ -100,14 +100,15 @@ public:
static void HideBalloonAndQuickHelp();
static sal_uLong ShowTip( vcl::Window* pParent,
const Rectangle& rScreenRect,
const OUString& rText, QuickHelpFlags nStyle = QuickHelpFlags::NONE );
static void UpdateTip( sal_uLong nId,
vcl::Window* pParent,
const Rectangle& rScreenRect,
const OUString& rText );
static void HideTip( sal_uLong nId );
static sal_uLong ShowPopover(vcl::Window* pParent,
const Rectangle& rScreenRect,
const OUString& rText,
QuickHelpFlags nStyle = QuickHelpFlags::NONE);
static void UpdatePopover(sal_uLong nId,
vcl::Window* pParent,
const Rectangle& rScreenRect,
const OUString& rText);
static void HidePopover(vcl::Window* pParent, sal_uLong nId);
};
#endif // INCLUDED_VCL_HELP_HXX
......
......@@ -868,9 +868,8 @@ void ScInputHandler::HideTip()
{
if ( nTipVisible )
{
if (pTipVisibleParent)
pTipVisibleParent->RemoveEventListener( LINK( this, ScInputHandler, ShowHideTipVisibleParentListener ) );
Help::HideTip( nTipVisible );
pTipVisibleParent->RemoveEventListener( LINK( this, ScInputHandler, ShowHideTipVisibleParentListener ) );
Help::HidePopover(pTipVisibleParent, nTipVisible );
nTipVisible = 0;
pTipVisibleParent = nullptr;
}
......@@ -880,9 +879,8 @@ void ScInputHandler::HideTipBelow()
{
if ( nTipVisibleSec )
{
if (pTipVisibleSecParent)
pTipVisibleSecParent->RemoveEventListener( LINK( this, ScInputHandler, ShowHideTipVisibleSecParentListener ) );
Help::HideTip( nTipVisibleSec );
pTipVisibleSecParent->RemoveEventListener( LINK( this, ScInputHandler, ShowHideTipVisibleSecParentListener ) );
Help::HidePopover(pTipVisibleSecParent, nTipVisibleSec);
nTipVisibleSec = 0;
pTipVisibleSecParent = nullptr;
}
......@@ -1082,7 +1080,7 @@ void ScInputHandler::ShowTip( const OUString& rText )
Rectangle aRect( aPos, aPos );
QuickHelpFlags nAlign = QuickHelpFlags::Left|QuickHelpFlags::Bottom;
nTipVisible = Help::ShowTip(pTipVisibleParent, aRect, rText, nAlign);
nTipVisible = Help::ShowPopover(pTipVisibleParent, aRect, rText, nAlign);
pTipVisibleParent->AddEventListener( LINK( this, ScInputHandler, ShowHideTipVisibleParentListener ) );
}
}
......@@ -1106,7 +1104,7 @@ void ScInputHandler::ShowTipBelow( const OUString& rText )
aPos = pTipVisibleSecParent->OutputToScreenPixel( aPos );
Rectangle aRect( aPos, aPos );
QuickHelpFlags nAlign = QuickHelpFlags::Left | QuickHelpFlags::Top | QuickHelpFlags::NoEvadePointer;
nTipVisibleSec = Help::ShowTip(pTipVisibleSecParent, aRect, rText, nAlign);
nTipVisibleSec = Help::ShowPopover(pTipVisibleSecParent, aRect, rText, nAlign);
pTipVisibleSecParent->AddEventListener( LINK( this, ScInputHandler, ShowHideTipVisibleSecParentListener ) );
}
}
......
......@@ -2066,7 +2066,10 @@ void ScPosWnd::HideTip()
{
if ( nTipVisible )
{
Help::HideTip( nTipVisible );
vcl::Window* pWin = GetSubEdit();
if (!pWin)
pWin = this;
Help::HidePopover(pWin, nTipVisible);
nTipVisible = 0;
}
}
......@@ -2174,7 +2177,7 @@ void ScPosWnd::Modify()
OUString aText = ScGlobal::GetRscString( nStrId );
QuickHelpFlags nAlign = QuickHelpFlags::Left|QuickHelpFlags::Bottom;
nTipVisible = Help::ShowTip(pWin, aRect, aText, nAlign);
nTipVisible = Help::ShowPopover(pWin, aRect, aText, nAlign);
}
}
}
......
......@@ -37,7 +37,9 @@ void ScTabView::HideTip()
{
if ( nTipVisible )
{
Help::HideTip( nTipVisible );
ScSplitPos eWhich = aViewData.GetActivePart();
vcl::Window* pWin = pGridWin[eWhich];
Help::HidePopover(pWin, nTipVisible);
nTipVisible = 0;
}
}
......@@ -90,7 +92,7 @@ void ScTabView::ShowRefTip()
//! Test, ob geaendert ??
HideTip();
nTipVisible = Help::ShowTip( pWin, aRect, aHelp, nFlags );
nTipVisible = Help::ShowPopover(pWin, aRect, aHelp, nFlags);
bDone = true;
}
}
......
......@@ -134,7 +134,7 @@ void ToolTip::DoShow()
// the preview). Therefore we use a little trick and place the tool
// tip at the top of a rectangle that is placed below the preview.
aBox.Move(aOffset.X(), aOffset.Y() + aBox.GetHeight() + 3);
mnHelpWindowHandle = Help::ShowTip(
mnHelpWindowHandle = Help::ShowPopover(
pWindow,
aBox,
msCurrentHelpText,
......@@ -146,7 +146,8 @@ bool ToolTip::Hide()
{
if (mnHelpWindowHandle>0)
{
Help::HideTip(mnHelpWindowHandle);
sd::Window *pWindow (mrSlideSorter.GetContentWindow());
Help::HidePopover(pWindow, mnHelpWindowHandle);
mnHelpWindowHandle = 0;
return true;
}
......
......@@ -146,7 +146,6 @@ private:
int mnHighlightId;
Size maImageSize;
sal_uLong mnTip;
};
ImageButtonHdl::ImageButtonHdl( const SmartTagReference& xTag /*, sal_uInt16 nSID, const Image& rImage, const Image& rImageMO*/, const Point& rPnt )
......@@ -154,7 +153,6 @@ ImageButtonHdl::ImageButtonHdl( const SmartTagReference& xTag /*, sal_uInt16 nSI
, mxTag( dynamic_cast< ChangePlaceholderTag* >( xTag.get() ) )
, mnHighlightId( -1 )
, maImageSize( 42, 42 )
, mnTip( 0 )
{
}
......@@ -165,11 +163,7 @@ ImageButtonHdl::~ImageButtonHdl()
void ImageButtonHdl::HideTip()
{
if( mnTip )
{
Help::HideTip( mnTip );
mnTip = 0;
}
Help::HideBalloonAndQuickHelp();
}
void ImageButtonHdl::onMouseEnter(const MouseEvent& rMEvt)
......@@ -201,7 +195,7 @@ void ImageButtonHdl::onMouseEnter(const MouseEvent& rMEvt)
OUString aHelpText( aResId );
Rectangle aScreenRect( pDev->LogicToPixel( GetPos() ), maImageSize );
mnTip = Help::ShowTip( static_cast< vcl::Window* >( pHdlList->GetView()->GetFirstOutputDevice() ), aScreenRect, aHelpText ) ;
Help::ShowQuickHelp(static_cast< vcl::Window* >( pHdlList->GetView()->GetFirstOutputDevice() ), aScreenRect, aHelpText);
}
Touch();
}
......
......@@ -713,24 +713,17 @@ void BrowserScrollBar::Tracking( const TrackingEvent& rTEvt )
aTip += OUString::number(GetRangeMax());
Rectangle aRect(GetPointerPosPixel(), Size(GetTextWidth(aTip), GetTextHeight()));
if ( _nTip )
Help::UpdateTip( _nTip, this, aRect, aTip );
else
_nTip = Help::ShowTip( this, aRect, aTip );
Help::ShowQuickHelp(this, aRect, aTip);
_nLastPos = nPos;
}
ScrollBar::Tracking( rTEvt );
}
void BrowserScrollBar::EndScroll()
{
if ( _nTip )
Help::HideTip( _nTip );
_nTip = 0;
Help::HideBalloonAndQuickHelp();
ScrollBar::EndScroll();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -178,7 +178,6 @@ protected:
class BrowserScrollBar: public ScrollBar
{
sal_uLong _nTip;
sal_uLong _nLastPos;
VclPtr<BrowserDataWin> _pDataWin;
......@@ -186,7 +185,6 @@ public:
BrowserScrollBar( vcl::Window* pParent, WinBits nStyle,
BrowserDataWin *pDataWin )
: ScrollBar( pParent, nStyle ),
_nTip( 0 ),
_nLastPos( ULONG_MAX ),
_pDataWin( pDataWin )
{}
......
......@@ -33,7 +33,6 @@ namespace svt { namespace table
TableDataWindow::TableDataWindow( TableControl_Impl& _rTableControl )
:Window( &_rTableControl.getAntiImpl() )
,m_rTableControl( _rTableControl )
,m_nTipWindowHandle( 0 )
{
// by default, use the background as determined by the style settings
const Color aWindowColor( GetSettings().GetStyleSettings().GetFieldColor() );
......@@ -123,12 +122,7 @@ namespace svt { namespace table
GetOutputSizePixel()
);
if ( m_nTipWindowHandle )
{
Help::UpdateTip( m_nTipWindowHandle, this, aControlScreenRect, sHelpText );
}
else
m_nTipWindowHandle = Help::ShowTip( this, aControlScreenRect, sHelpText, nHelpStyle );
Help::ShowQuickHelp(this, aControlScreenRect, sHelpText, nHelpStyle);
}
else
{
......@@ -137,17 +131,11 @@ namespace svt { namespace table
}
}
void TableDataWindow::impl_hideTipWindow()
{
if ( m_nTipWindowHandle != 0 )
{
Help::HideTip( m_nTipWindowHandle );
m_nTipWindowHandle = 0;
}
Help::HideBalloonAndQuickHelp();
}
void TableDataWindow::MouseMove( const MouseEvent& rMEvt )
{
if ( rMEvt.IsLeaveWindow() )
......
......@@ -38,7 +38,6 @@ namespace svt { namespace table
private:
TableControl_Impl& m_rTableControl;
Link<LinkParamNone*,void> m_aSelectHdl;
sal_uLong m_nTipWindowHandle;
public:
explicit TableDataWindow( TableControl_Impl& _rTableControl );
......
......@@ -5916,9 +5916,9 @@ void QuickHelpData::Start( SwWrtShell& rSh, sal_uInt16 nWrdLen )
Point aPt( rWin.OutputToScreenPixel( rWin.LogicToPixel(
rSh.GetCharRect().Pos() )));
aPt.Y() -= 3;
nTipId = Help::ShowTip( &rWin, Rectangle( aPt, Size( 1, 1 )),
nTipId = Help::ShowPopover(&rWin, Rectangle( aPt, Size( 1, 1 )),
m_aHelpStrings[ nCurArrPos ],
QuickHelpFlags::Left | QuickHelpFlags::Bottom );
QuickHelpFlags::Left | QuickHelpFlags::Bottom);
}
else
{
......@@ -5951,7 +5951,10 @@ void QuickHelpData::Stop( SwWrtShell& rSh )
if( !m_bIsTip )
rSh.DeleteExtTextInput( nullptr, false );
else if( nTipId )
Help::HideTip( nTipId );
{
vcl::Window& rWin = rSh.GetView().GetEditWin();
Help::HidePopover(&rWin, nTipId);
}
ClearContent();
}
......
......@@ -23,6 +23,7 @@
#include "salwtype.hxx"
#include "salgeom.hxx"
#include <vcl/help.hxx>
#include <vcl/window.hxx>
// complete vcl::Window for SalFrame::CallCallback under -fsanitize=function
......@@ -231,7 +232,25 @@ public:
}
// return true to indicate tooltips are shown natively, false otherwise
virtual bool ShowTooltip(const OUString& /*rHelpText*/, const Rectangle& /*rHelpArea*/ )
virtual bool ShowTooltip(const OUString& /*rHelpText*/, const Rectangle& /*rHelpArea*/)
{
return false;
}
// return !0 to indicate popovers are shown natively, 0 otherwise
virtual sal_uIntPtr ShowPopover(const OUString& /*rHelpText*/, const Rectangle& /*rHelpArea*/, QuickHelpFlags /*nFlags*/)
{
return 0;
}
// return true to indicate popovers are shown natively, false otherwise
virtual bool UpdatePopover(sal_uIntPtr /*nId*/, const OUString& /*rHelpText*/, const Rectangle& /*rHelpArea*/)
{
return false;
}
// return true to indicate popovers are shown natively, false otherwise
virtual bool HidePopover(sal_uIntPtr /*nId*/)
{
return false;
}
......
......@@ -517,6 +517,9 @@ public:
#if GTK_CHECK_VERSION(3,0,0)
virtual void SetModal(bool bModal) override;
virtual bool ShowTooltip(const OUString& rHelpText, const Rectangle& rHelpArea) override;
virtual sal_uIntPtr ShowPopover(const OUString& rHelpText, const Rectangle& rHelpArea, QuickHelpFlags nFlags) override;
virtual bool UpdatePopover(sal_uIntPtr nId, const OUString& rHelpText, const Rectangle& rHelpArea) override;
virtual bool HidePopover(sal_uIntPtr nId) override;
#endif
static GtkSalFrame *getFromWindow( GtkWindow *pWindow );
......
......@@ -191,23 +191,37 @@ void Help::HideBalloonAndQuickHelp()
ImplDestroyHelpWindow( bIsVisible );
}
sal_uIntPtr Help::ShowTip( vcl::Window* pParent, const Rectangle& rScreenRect,
const OUString& rText, QuickHelpFlags nStyle )
sal_uIntPtr Help::ShowPopover(vcl::Window* pParent, const Rectangle& rScreenRect,
const OUString& rText, QuickHelpFlags nStyle)
{
sal_uIntPtr nId = pParent->ImplGetFrame()->ShowPopover(rText, rScreenRect, nStyle);
if (nId)
{
//popovers are handled natively, return early
return nId;
}
sal_uInt16 nHelpWinStyle = ( nStyle & QuickHelpFlags::TipStyleBalloon ) ? HELPWINSTYLE_BALLOON : HELPWINSTYLE_QUICK;
VclPtrInstance<HelpTextWindow> pHelpWin( pParent, rText, nHelpWinStyle, nStyle );
sal_uIntPtr nId = reinterpret_cast< sal_uIntPtr >( pHelpWin.get() );
UpdateTip( nId, pParent, rScreenRect, rText );
nId = reinterpret_cast< sal_uIntPtr >( pHelpWin.get() );
UpdatePopover(nId, pParent, rScreenRect, rText);
pHelpWin->ShowHelp( HELPDELAY_NONE );
return nId;
}
void Help::UpdateTip( sal_uIntPtr nId, vcl::Window* pParent, const Rectangle& rScreenRect, const OUString& rText )
void Help::UpdatePopover(sal_uIntPtr nId, vcl::Window* pParent, const Rectangle& rScreenRect,
const OUString& rText)
{
if (pParent->ImplGetFrame()->UpdatePopover(nId, rText, rScreenRect))
{
//popovers are handled natively, return early
return;
}
HelpTextWindow* pHelpWin = reinterpret_cast< HelpTextWindow* >( nId );
ENSURE_OR_RETURN_VOID( pHelpWin != nullptr, "Help::UpdateTip: invalid ID!" );
ENSURE_OR_RETURN_VOID( pHelpWin != nullptr, "Help::UpdatePopover: invalid ID!" );
Size aSz = pHelpWin->CalcOutSize();
pHelpWin->SetOutputSizePixel( aSz );
......@@ -218,8 +232,14 @@ void Help::UpdateTip( sal_uIntPtr nId, vcl::Window* pParent, const Rectangle& rS
pHelpWin->Invalidate();
}
void Help::HideTip( sal_uLong nId )
void Help::HidePopover(vcl::Window* pParent, sal_uLong nId)
{
if (pParent->ImplGetFrame()->HidePopover(nId))
{
//popovers are handled natively, return early
return;
}
VclPtr<HelpTextWindow> pHelpWin = reinterpret_cast<HelpTextWindow*>(nId);
vcl::Window* pFrameWindow = pHelpWin->ImplGetFrameWindow();
pHelpWin->Hide();
......
......@@ -2449,6 +2449,82 @@ bool GtkSalFrame::ShowTooltip(const OUString& rHelpText, const Rectangle& rHelpA
return true;
}
sal_uIntPtr GtkSalFrame::ShowPopover(const OUString& rHelpText, const Rectangle& rHelpArea, QuickHelpFlags nFlags)
{
#if GTK_CHECK_VERSION(3,12,0)
GtkWidget *pWidget = gtk_popover_new(getMouseEventWidget());
OString sUTF = OUStringToOString(rHelpText, RTL_TEXTENCODING_UTF8);
GtkWidget *pLabel = gtk_label_new(sUTF.getStr());
gtk_container_add(GTK_CONTAINER(pWidget), pLabel);
GdkRectangle aRect;
aRect.x = rHelpArea.Left();
aRect.y = rHelpArea.Top();
aRect.width = rHelpArea.GetWidth();
aRect.height = rHelpArea.GetHeight();
gtk_popover_set_pointing_to(GTK_POPOVER(pWidget), &aRect);
if (nFlags & QuickHelpFlags::Top)
gtk_popover_set_position(GTK_POPOVER(pWidget), GTK_POS_BOTTOM);
else if (nFlags & QuickHelpFlags::Bottom)
gtk_popover_set_position(GTK_POPOVER(pWidget), GTK_POS_TOP);
else if (nFlags & QuickHelpFlags::Left)
gtk_popover_set_position(GTK_POPOVER(pWidget), GTK_POS_RIGHT);
else if (nFlags & QuickHelpFlags::Right)
gtk_popover_set_position(GTK_POPOVER(pWidget), GTK_POS_LEFT);
gtk_popover_set_modal(GTK_POPOVER(pWidget), false);
gtk_widget_show_all(pWidget);
return reinterpret_cast<sal_uIntPtr>(pWidget);
#else
(void)rHelpText;
(void)rHelpArea;
(void)nFlags;
return 0;
#endif
}
bool GtkSalFrame::UpdatePopover(sal_uIntPtr nId, const OUString& rHelpText, const Rectangle& rHelpArea)
{
#if GTK_CHECK_VERSION(3,12,0)
GtkWidget *pWidget = reinterpret_cast<GtkWidget*>(nId);
GdkRectangle aRect;
aRect.x = rHelpArea.Left();
aRect.y = rHelpArea.Top();
aRect.width = rHelpArea.GetWidth();
aRect.height = rHelpArea.GetHeight();
gtk_popover_set_pointing_to(GTK_POPOVER(pWidget), &aRect);
GtkWidget *pLabel = gtk_bin_get_child(GTK_BIN(pWidget));
OString sUTF = OUStringToOString(rHelpText, RTL_TEXTENCODING_UTF8);
gtk_label_set_text(GTK_LABEL(pLabel), sUTF.getStr());
return true;
#else
(void)nId;
(void)rHelpText;
(void)rHelpArea;
return false
#endif
}
bool GtkSalFrame::HidePopover(sal_uIntPtr nId)
{
#if GTK_CHECK_VERSION(3,12,0)
GtkWidget *pWidget = reinterpret_cast<GtkWidget*>(nId);
gtk_widget_destroy(pWidget);
return true;
#else
(void)nId;
return false;
#endif
}
gboolean GtkSalFrame::signalButton( GtkWidget*, GdkEventButton* pEvent, gpointer frame )
{
GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment