vcl/inc/helpwin.hxx     |   18 +++++++------
 vcl/source/app/help.cxx |   65 +++++++++++++++++++++++++-----------------------
 2 files changed, 45 insertions(+), 38 deletions(-)

New commits:
commit 4dcb25e23da452a345db38a3a04d08b8441dcd42
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Apr 23 13:17:02 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Wed Apr 23 15:33:52 2025 +0200

    vcl: Replace HELPWINSTYLE_* constants by enum class
    
    Introduce enum class HelpWinStyle
    to replace the HELPWINSTYLE_BALLOON
    and HELPWINSTYLE_QUICK defines.
    
    Change-Id: Ic70b6356af0073eef3e4a0fe588688fa3c81b3b9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184498
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/inc/helpwin.hxx b/vcl/inc/helpwin.hxx
index 2ad43c2fc455..bfcfd2162804 100644
--- a/vcl/inc/helpwin.hxx
+++ b/vcl/inc/helpwin.hxx
@@ -25,6 +25,12 @@
 enum class QuickHelpFlags;
 struct ImplSVHelpData;
 
+enum class HelpWinStyle
+{
+    Quick,
+    Balloon,
+};
+
 /// A tooltip: adds tips to widgets in a floating / popup window.
 class HelpTextWindow final : public FloatingWindow
 {
@@ -38,7 +44,7 @@ private:
     Timer               maShowTimer;
     Timer               maHideTimer;
 
-    sal_uInt16          mnHelpWinStyle;
+    HelpWinStyle        meHelpWinStyle;
     QuickHelpFlags      mnStyle;
 
 private:
@@ -53,12 +59,13 @@ private:
 
     virtual void        dispose() override;
 public:
-                        HelpTextWindow( vcl::Window* pParent, const OUString& 
rText, sal_uInt16 nHelpWinStyle, QuickHelpFlags nStyle );
+    HelpTextWindow(vcl::Window* pParent, const OUString& rText, HelpWinStyle 
eHelpWinStyle,
+                   QuickHelpFlags nStyle);
     virtual             ~HelpTextWindow() override;
 
     const OUString&     GetHelpText() const { return maHelpText; }
     void                SetHelpText( const OUString& rHelpText );
-    sal_uInt16          GetWinStyle() const { return mnHelpWinStyle; }
+    HelpWinStyle GetWinStyle() const { return meHelpWinStyle; }
     QuickHelpFlags      GetStyle() const { return mnStyle; }
 
     // only remember:
diff --git a/vcl/source/app/help.cxx b/vcl/source/app/help.cxx
index 4e3f5a7f96d7..1d109d3b16f8 100644
--- a/vcl/source/app/help.cxx
+++ b/vcl/source/app/help.cxx
@@ -34,18 +34,15 @@
 #include <salframe.hxx>
 #include <svdata.hxx>
 
-#define HELPWINSTYLE_QUICK      0
-#define HELPWINSTYLE_BALLOON    1
-
 #define HELPTEXTMARGIN_QUICK    3
 #define HELPTEXTMARGIN_BALLOON  6
 
 #define HELPTEXTMAXLEN        150
 
-static void ImplShowHelpWindow(vcl::Window* pParent, sal_uInt16 nHelpWinStyle,
+static void ImplShowHelpWindow(vcl::Window* pParent, HelpWinStyle 
eHelpWinStyle,
                                QuickHelpFlags nStyle, const OUString& 
rHelpText,
                                const Point& rScreenPos, const 
tools::Rectangle& rHelpArea);
-static void ImplSetHelpWindowPos(vcl::Window* pHelpWindow, sal_uInt16 
nHelpWinStyle,
+static void ImplSetHelpWindowPos(vcl::Window* pHelpWindow, HelpWinStyle 
eHelpWinStyle,
                                  QuickHelpFlags nStyle, const Point& rPos,
                                  const tools::Rectangle& rHelpArea);
 
@@ -155,8 +152,8 @@ void Help::ShowBalloon( vcl::Window* pParent,
                         const Point& rScreenPos, const tools::Rectangle& rRect,
                         const OUString& rHelpText )
 {
-    ImplShowHelpWindow( pParent, HELPWINSTYLE_BALLOON, QuickHelpFlags::NONE,
-                        rHelpText, rScreenPos, rRect );
+    ImplShowHelpWindow(pParent, HelpWinStyle::Balloon, QuickHelpFlags::NONE, 
rHelpText, rScreenPos,
+                       rRect);
 }
 
 void Help::EnableQuickHelp()
@@ -179,12 +176,11 @@ void Help::ShowQuickHelp( vcl::Window* pParent,
                           const OUString& rHelpText,
                           QuickHelpFlags nStyle )
 {
-    sal_uInt16 nHelpWinStyle = ( nStyle & QuickHelpFlags::TipStyleBalloon ) ? 
HELPWINSTYLE_BALLOON : HELPWINSTYLE_QUICK;
+    HelpWinStyle eHelpWinStyle = (nStyle & QuickHelpFlags::TipStyleBalloon) ? 
HelpWinStyle::Balloon : HelpWinStyle::Quick;
     Point aScreenPos = nStyle & QuickHelpFlags::NoAutoPos
                            ? Point()
                            : 
pParent->OutputToScreenPixel(pParent->GetPointerPosPixel());
-    ImplShowHelpWindow( pParent, nHelpWinStyle, nStyle,
-                        rHelpText, aScreenPos, rScreenRect );
+    ImplShowHelpWindow(pParent, eHelpWinStyle, nStyle, rHelpText, aScreenPos, 
rScreenRect);
 }
 
 void Help::HideBalloonAndQuickHelp()
@@ -204,8 +200,8 @@ void* Help::ShowPopover(vcl::Window* pParent, const 
tools::Rectangle& rScreenRec
         return nId;
     }
 
-    sal_uInt16 nHelpWinStyle = ( nStyle & QuickHelpFlags::TipStyleBalloon ) ? 
HELPWINSTYLE_BALLOON : HELPWINSTYLE_QUICK;
-    VclPtrInstance<HelpTextWindow> pHelpWin( pParent, rText, nHelpWinStyle, 
nStyle );
+    HelpWinStyle eHelpWinStyle = (nStyle & QuickHelpFlags::TipStyleBalloon) ? 
HelpWinStyle::Balloon : HelpWinStyle::Quick;
+    VclPtrInstance<HelpTextWindow> pHelpWin( pParent, rText, eHelpWinStyle, 
nStyle );
 
     nId = pHelpWin.get();
     UpdatePopover(nId, pParent, rScreenRect, rText);
@@ -252,7 +248,7 @@ void Help::HidePopover(vcl::Window const * pParent, void* 
nId)
     ImplGetSVHelpData().mnLastHelpHideTime = tools::Time::GetSystemTicks();
 }
 
-HelpTextWindow::HelpTextWindow( vcl::Window* pParent, const OUString& rText, 
sal_uInt16 nHelpWinStyle, QuickHelpFlags nStyle ) :
+HelpTextWindow::HelpTextWindow( vcl::Window* pParent, const OUString& rText, 
HelpWinStyle eHelpWinStyle, QuickHelpFlags nStyle ) :
     FloatingWindow( pParent, WB_SYSTEMWINDOW|WB_TOOLTIPWIN ), // #105827# if 
we change the parent, mirroring will not work correctly when positioning this 
window
     maHelpText( rText ),
     maShowTimer( "vcl::HelpTextWindow maShowTimer" ),
@@ -260,7 +256,7 @@ HelpTextWindow::HelpTextWindow( vcl::Window* pParent, const 
OUString& rText, sal
 {
     SetType( WindowType::HELPTEXTWINDOW );
     ImplSetMouseTransparent( true );
-    mnHelpWinStyle = nHelpWinStyle;
+    meHelpWinStyle = eHelpWinStyle;
     mnStyle = nStyle;
 
     if( mnStyle & QuickHelpFlags::BiDiRtl )
@@ -326,7 +322,7 @@ void HelpTextWindow::SetHelpText( const OUString& rHelpText 
)
 {
     maHelpText = rHelpText;
     ApplySettings(*GetOutDev());
-    if ( mnHelpWinStyle == HELPWINSTYLE_QUICK && maHelpText.getLength() < 
HELPTEXTMAXLEN && maHelpText.indexOf('
') < 0)
+    if ( meHelpWinStyle == HelpWinStyle::Quick && maHelpText.getLength() < 
HELPTEXTMAXLEN && maHelpText.indexOf('
') < 0)
     {
         Size aSize;
         aSize.setHeight( GetTextHeight() );
@@ -336,10 +332,10 @@ void HelpTextWindow::SetHelpText( const OUString& 
rHelpText )
             aSize.setWidth( GetTextWidth( maHelpText ) );
         maTextRect = tools::Rectangle( Point( HELPTEXTMARGIN_QUICK, 
HELPTEXTMARGIN_QUICK ), aSize );
     }
-    else // HELPWINSTYLE_BALLOON
+    else // HelpWinStyle::Balloon
     {
         sal_Int32 nCharsInLine;
-        if (mnHelpWinStyle == HELPWINSTYLE_QUICK)
+        if (meHelpWinStyle == HelpWinStyle::Quick)
             nCharsInLine = maHelpText.getLength();
         else
             nCharsInLine = 35 + ((maHelpText.getLength() / 100) * 5);
@@ -389,14 +385,14 @@ void HelpTextWindow::Paint( vcl::RenderContext& 
rRenderContext, const tools::Rec
     }
 
     // paint text
-    if (mnHelpWinStyle == HELPWINSTYLE_QUICK && maHelpText.getLength() < 
HELPTEXTMAXLEN && maHelpText.indexOf('
') < 0)
+    if (meHelpWinStyle == HelpWinStyle::Quick && maHelpText.getLength() < 
HELPTEXTMAXLEN && maHelpText.indexOf('
') < 0)
     {
         if ( mnStyle & QuickHelpFlags::CtrlText )
             rRenderContext.DrawCtrlText(maTextRect.TopLeft(), maHelpText);
         else
             rRenderContext.DrawText(maTextRect.TopLeft(), maHelpText);
     }
-    else // HELPWINSTYLE_BALLOON
+    else // HelpWinStyle::Balloon
     {
         DrawTextFlags nDrawFlags = 
DrawTextFlags::MultiLine|DrawTextFlags::WordBreak|
                                 DrawTextFlags::Left|DrawTextFlags::Top;
@@ -411,7 +407,7 @@ void HelpTextWindow::Paint( vcl::RenderContext& 
rRenderContext, const tools::Rec
 
     Size aSz = GetOutputSizePixel();
     rRenderContext.DrawRect(tools::Rectangle(Point(), aSz));
-    if (mnHelpWinStyle == HELPWINSTYLE_BALLOON)
+    if (meHelpWinStyle == HelpWinStyle::Balloon)
     {
         aSz.AdjustWidth( -2 );
         aSz.AdjustHeight( -2 );
@@ -432,7 +428,7 @@ void HelpTextWindow::ShowHelp(bool bNoDelay)
             nTimeout = 15;
         else
         {
-            if ( mnHelpWinStyle == HELPWINSTYLE_QUICK )
+            if (meHelpWinStyle == HelpWinStyle::Quick)
                 nTimeout = HelpSettings::GetTipDelay();
             else
                 nTimeout = HelpSettings::GetBalloonDelay();
@@ -478,7 +474,7 @@ OUString HelpTextWindow::GetText() const
 
 void HelpTextWindow::ResetHideTimer()
 {
-    if (mnHelpWinStyle == HELPWINSTYLE_QUICK)
+    if (meHelpWinStyle == HelpWinStyle::Quick)
     {
         // start auto-hide-timer for non-ShowTip windows
         if (this == ImplGetSVHelpData().mpHelpWin)
@@ -486,7 +482,7 @@ void HelpTextWindow::ResetHideTimer()
     }
 }
 
-static void ImplShowHelpWindow(vcl::Window* pParent, sal_uInt16 nHelpWinStyle,
+static void ImplShowHelpWindow(vcl::Window* pParent, HelpWinStyle 
eHelpWinStyle,
                                QuickHelpFlags nStyle, const OUString& 
rHelpText,
                                const Point& rScreenPos, const 
tools::Rectangle& rHelpArea)
 {
@@ -506,7 +502,7 @@ static void ImplShowHelpWindow(vcl::Window* pParent, 
sal_uInt16 nHelpWinStyle,
     {
         SAL_WARN_IF( pHelpWin == pParent, "vcl", "HelpInHelp ?!" );
 
-        bool bRemoveHelp = (rHelpText.isEmpty() || (pHelpWin->GetWinStyle() != 
nHelpWinStyle))
+        bool bRemoveHelp = (rHelpText.isEmpty() || (pHelpWin->GetWinStyle() != 
eHelpWinStyle))
                             && aHelpData.mbRequestingHelp;
 
         if (!bRemoveHelp && pHelpWin->GetParent() == pParent)
@@ -517,7 +513,7 @@ static void ImplShowHelpWindow(vcl::Window* pParent, 
sal_uInt16 nHelpWinStyle,
             {
                 pHelpWin->SetHelpText( rHelpText );
                 // approach mouse position
-                ImplSetHelpWindowPos( pHelpWin, nHelpWinStyle, nStyle, 
rScreenPos, rHelpArea );
+                ImplSetHelpWindowPos(pHelpWin, eHelpWinStyle, nStyle, 
rScreenPos, rHelpArea);
                 if( pHelpWin->IsVisible() )
                     pHelpWin->Invalidate();
             }
@@ -536,14 +532,15 @@ static void ImplShowHelpWindow(vcl::Window* pParent, 
sal_uInt16 nHelpWinStyle,
     if (rHelpText.isEmpty())
         return;
 
-    VclPtr<HelpTextWindow> pHelpWin = VclPtr<HelpTextWindow>::Create( pParent, 
rHelpText, nHelpWinStyle, nStyle );
+    VclPtr<HelpTextWindow> pHelpWin
+        = VclPtr<HelpTextWindow>::Create(pParent, rHelpText, eHelpWinStyle, 
nStyle);
     aHelpData.mpHelpWin = pHelpWin;
     pHelpWin->SetHelpArea( rHelpArea );
 
     //  positioning
     Size aSz = pHelpWin->CalcOutSize();
     pHelpWin->SetOutputSizePixel( aSz );
-    ImplSetHelpWindowPos( pHelpWin, nHelpWinStyle, nStyle, rScreenPos, 
rHelpArea );
+    ImplSetHelpWindowPos(pHelpWin, eHelpWinStyle, nStyle, rScreenPos, 
rHelpArea);
     // if not called from Window::RequestHelp, then without delay...
     if (!bNoDelay)
     {
@@ -580,7 +577,7 @@ void ImplDestroyHelpWindow(ImplSVHelpData& rHelpData, bool 
bUpdateHideTime)
     }
 }
 
-static void ImplSetHelpWindowPos(vcl::Window* pHelpWin, sal_uInt16 
nHelpWinStyle,
+static void ImplSetHelpWindowPos(vcl::Window* pHelpWin, HelpWinStyle 
eHelpWinStyle,
                                  QuickHelpFlags nStyle, const Point& rPos,
                                  const tools::Rectangle& rHelpArea)
 {
@@ -629,7 +626,7 @@ static void ImplSetHelpWindowPos(vcl::Window* pHelpWin, 
sal_uInt16 nHelpWinStyle
     else
     {
         aPos = pWindow->OutputToAbsoluteScreenPixel(rPos);
-        if ( nHelpWinStyle == HELPWINSTYLE_QUICK )
+        if (eHelpWinStyle == HelpWinStyle::Quick)
         {
             tools::Long nScreenHeight = aScreenRect.GetHeight();
             aPos.AdjustX( -4 );
commit 0687c3633295ab64f72139a662c3b1f41573493c
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Apr 23 12:52:36 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Wed Apr 23 15:33:47 2025 +0200

    vcl: Move help win helper declarations to .cxx
    
    Drop declaration from header and make these helper functions
    static, since they are only used inside of vcl/source/app/help.cxx.
    
    Change-Id: Ib7f595212ccaf5f21f0687c6aad6afbad60edaa3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184497
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/inc/helpwin.hxx b/vcl/inc/helpwin.hxx
index 72af82e27937..2ad43c2fc455 100644
--- a/vcl/inc/helpwin.hxx
+++ b/vcl/inc/helpwin.hxx
@@ -72,12 +72,7 @@ public:
     void ResetHideTimer();
 };
 
-void ImplShowHelpWindow( vcl::Window* pParent, sal_uInt16 nHelpWinStyle, 
QuickHelpFlags nStyle,
-        const OUString& rHelpText,
-        const Point& rScreenPos, const tools::Rectangle& rHelpArea );
 VCL_DLLPUBLIC void ImplDestroyHelpWindow( bool bUpdateHideTime );
 void ImplDestroyHelpWindow(ImplSVHelpData& rHelpData, bool bUpdateHideTime);
-void ImplSetHelpWindowPos( vcl::Window* pHelpWindow, sal_uInt16 nHelpWinStyle, 
QuickHelpFlags nStyle,
-                            const Point& rPos, const tools::Rectangle& 
rHelpArea );
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/app/help.cxx b/vcl/source/app/help.cxx
index 0fa849b4b358..4e3f5a7f96d7 100644
--- a/vcl/source/app/help.cxx
+++ b/vcl/source/app/help.cxx
@@ -42,6 +42,13 @@
 
 #define HELPTEXTMAXLEN        150
 
+static void ImplShowHelpWindow(vcl::Window* pParent, sal_uInt16 nHelpWinStyle,
+                               QuickHelpFlags nStyle, const OUString& 
rHelpText,
+                               const Point& rScreenPos, const 
tools::Rectangle& rHelpArea);
+static void ImplSetHelpWindowPos(vcl::Window* pHelpWindow, sal_uInt16 
nHelpWinStyle,
+                                 QuickHelpFlags nStyle, const Point& rPos,
+                                 const tools::Rectangle& rHelpArea);
+
 Help::Help()
 {
 }
@@ -479,9 +486,9 @@ void HelpTextWindow::ResetHideTimer()
     }
 }
 
-void ImplShowHelpWindow( vcl::Window* pParent, sal_uInt16 nHelpWinStyle, 
QuickHelpFlags nStyle,
-                         const OUString& rHelpText,
-                         const Point& rScreenPos, const tools::Rectangle& 
rHelpArea )
+static void ImplShowHelpWindow(vcl::Window* pParent, sal_uInt16 nHelpWinStyle,
+                               QuickHelpFlags nStyle, const OUString& 
rHelpText,
+                               const Point& rScreenPos, const 
tools::Rectangle& rHelpArea)
 {
     if (pParent->ImplGetFrame()->ShowTooltip(rHelpText, rHelpArea))
     {
@@ -573,8 +580,9 @@ void ImplDestroyHelpWindow(ImplSVHelpData& rHelpData, bool 
bUpdateHideTime)
     }
 }
 
-void ImplSetHelpWindowPos( vcl::Window* pHelpWin, sal_uInt16 nHelpWinStyle, 
QuickHelpFlags nStyle,
-                           const Point& rPos, const tools::Rectangle& 
rHelpArea )
+static void ImplSetHelpWindowPos(vcl::Window* pHelpWin, sal_uInt16 
nHelpWinStyle,
+                                 QuickHelpFlags nStyle, const Point& rPos,
+                                 const tools::Rectangle& rHelpArea)
 {
     AbsoluteScreenPixelPoint aPos;
     AbsoluteScreenPixelSize aSz( pHelpWin->GetSizePixel() );

Reply via email to