[Libreoffice-commits] core.git: 2 commits - include/vcl vcl/source

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Wed May 22 21:02:17 UTC 2019


 include/vcl/toolbox.hxx            |    6 ++
 vcl/source/control/edit.cxx        |   21 --------
 vcl/source/control/imp_listbox.cxx |   28 ++---------
 vcl/source/control/prgsbar.cxx     |    8 ---
 vcl/source/window/status.cxx       |    7 --
 vcl/source/window/toolbox.cxx      |   87 ++++++++-----------------------------
 6 files changed, 37 insertions(+), 120 deletions(-)

New commits:
commit 6f1c83b3a84705b8efb4745d8c6c62025ea48f37
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Wed May 22 17:18:06 2019 +0200
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Wed May 22 23:01:32 2019 +0200

    VCL refactor duplicate code in Toolbox
    
    Moves duplicate code from ImplInitSettings and ApplySettings into
    their own functions.
    
    Change-Id: I65b5a052b171a661ee22762e373745c28779a9e9
    Reviewed-on: https://gerrit.libreoffice.org/72790
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>

diff --git a/include/vcl/toolbox.hxx b/include/vcl/toolbox.hxx
index 115b9e32261d..19e02a0d85e7 100644
--- a/include/vcl/toolbox.hxx
+++ b/include/vcl/toolbox.hxx
@@ -40,6 +40,7 @@ struct ImplToolItem;
 struct ImplToolBoxPrivateData;
 class  PopupMenu;
 class VclMenuEvent;
+class StyleSettings;
 
 #define TOOLBOX_STYLE_FLAT          (sal_uInt16(0x0004))
 
@@ -251,12 +252,15 @@ public:
     SAL_DLLPRIVATE ImplToolItems::size_type ImplCalcLines( long nToolSize ) const;
     SAL_DLLPRIVATE sal_uInt16 ImplTestLineSize( const Point& rPos ) const;
     SAL_DLLPRIVATE void ImplLineSizing( const Point& rPos, tools::Rectangle& rRect, sal_uInt16 nLineMode );
-    static SAL_DLLPRIVATE ImplToolItems::size_type ImplFindItemPos( const ImplToolItem* pItem, const ImplToolItems& rList );
+    SAL_DLLPRIVATE static ImplToolItems::size_type ImplFindItemPos( const ImplToolItem* pItem, const ImplToolItems& rList );
     SAL_DLLPRIVATE void ImplDrawMenuButton(vcl::RenderContext& rRenderContext, bool bHighlight);
     SAL_DLLPRIVATE void ImplDrawButton(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect, sal_uInt16 highlight, bool bChecked, bool bEnabled, bool bIsWindow);
     SAL_DLLPRIVATE ImplToolItems::size_type ImplCountLineBreaks() const;
     SAL_DLLPRIVATE ImplToolBoxPrivateData* ImplGetToolBoxPrivateData() const { return mpData.get(); }
 
+    SAL_DLLPRIVATE void ApplyBackgroundSettings(vcl::RenderContext&, const StyleSettings&);
+    SAL_DLLPRIVATE void ApplyForegroundSettings(vcl::RenderContext&, const StyleSettings&);
+
 protected:
     virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
     void SetCurItemId(sal_uInt16 nSet)
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 6ff26a004ad5..c2dfb8567296 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -1176,19 +1176,8 @@ void ToolBox::ImplInit( vcl::Window* pParent, WinBits nStyle )
     ImplInitSettings(true, true, true);
 }
 
-void ToolBox::ApplySettings(vcl::RenderContext& rRenderContext)
+void ToolBox::ApplyForegroundSettings(vcl::RenderContext& rRenderContext, const StyleSettings& rStyleSettings)
 {
-    mpData->mbNativeButtons = rRenderContext.IsNativeControlSupported(ControlType::Toolbar, ControlPart::Button);
-
-    const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
-
-    // Font
-    vcl::Font aFont = rStyleSettings.GetToolFont();
-    if (IsControlFont())
-        aFont.Merge(GetControlFont());
-    SetZoomedPointFont(rRenderContext, aFont);
-
-    // ControlForeground
     Color aColor;
     if (IsControlForeground())
         aColor = GetControlForeground();
@@ -1198,11 +1187,13 @@ void ToolBox::ApplySettings(vcl::RenderContext& rRenderContext)
         aColor = rStyleSettings.GetWindowTextColor();
     rRenderContext.SetTextColor(aColor);
     rRenderContext.SetTextFillColor();
+}
 
+void ToolBox::ApplyBackgroundSettings(vcl::RenderContext& rRenderContext, const StyleSettings& rStyleSettings)
+{
     if (IsControlBackground())
     {
-        aColor = GetControlBackground();
-        SetBackground( aColor );
+        rRenderContext.SetBackground(GetControlBackground());
         SetPaintTransparent(false);
         SetParentClipMode();
     }
@@ -1220,11 +1211,11 @@ void ToolBox::ApplySettings(vcl::RenderContext& rRenderContext)
         }
         else
         {
+            Color aColor;
             if (Window::GetStyle() & WB_3DLOOK)
                 aColor = rStyleSettings.GetFaceColor();
             else
                 aColor = rStyleSettings.GetWindowColor();
-
             rRenderContext.SetBackground(aColor);
             SetPaintTransparent(false);
             SetParentClipMode();
@@ -1232,6 +1223,17 @@ void ToolBox::ApplySettings(vcl::RenderContext& rRenderContext)
     }
 }
 
+void ToolBox::ApplySettings(vcl::RenderContext& rRenderContext)
+{
+    mpData->mbNativeButtons = rRenderContext.IsNativeControlSupported(ControlType::Toolbar, ControlPart::Button);
+
+    const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+
+    ApplyControlFont(rRenderContext, rStyleSettings.GetToolFont());
+    ApplyForegroundSettings(rRenderContext, rStyleSettings);
+    ApplyBackgroundSettings(rRenderContext, rStyleSettings);
+}
+
 void ToolBox::ImplInitSettings(bool bFont, bool bForeground, bool bBackground)
 {
     mpData->mbNativeButtons = IsNativeControlSupported( ControlType::Toolbar, ControlPart::Button );
@@ -1239,61 +1241,12 @@ void ToolBox::ImplInitSettings(bool bFont, bool bForeground, bool bBackground)
     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
 
     if (bFont)
-    {
-        vcl::Font aFont = rStyleSettings.GetToolFont();
-        if (IsControlFont())
-            aFont.Merge(GetControlFont());
-        SetZoomedPointFont(*this, aFont);
-    }
-
+        ApplyControlFont(*this, rStyleSettings.GetToolFont());
     if (bForeground || bFont)
-    {
-        Color aColor;
-        if (IsControlForeground())
-            aColor = GetControlForeground();
-        else if (Window::GetStyle() & WB_3DLOOK)
-            aColor = rStyleSettings.GetButtonTextColor();
-        else
-            aColor = rStyleSettings.GetWindowTextColor();
-        SetTextColor(aColor);
-        SetTextFillColor();
-    }
-
+        ApplyForegroundSettings(*this, rStyleSettings);
     if (bBackground)
     {
-        Color aColor;
-        if (IsControlBackground())
-        {
-            aColor = GetControlBackground();
-            SetBackground( aColor );
-            SetPaintTransparent(false);
-            SetParentClipMode();
-        }
-        else
-        {
-            if (IsNativeControlSupported(ControlType::Toolbar, ControlPart::Entire)
-                || (GetAlign() == WindowAlign::Top && !Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty())
-                || (GetAlign() == WindowAlign::Bottom && !Application::GetSettings().GetStyleSettings().GetPersonaFooter().IsEmpty()))
-            {
-                SetBackground();
-                SetTextColor(rStyleSettings.GetMenuBarTextColor());
-                SetPaintTransparent( true );
-                SetParentClipMode( ParentClipMode::NoClip );
-                mpData->maDisplayBackground = Wallpaper( rStyleSettings.GetFaceColor() );
-            }
-            else
-            {
-                if (Window::GetStyle() & WB_3DLOOK)
-                    aColor = rStyleSettings.GetFaceColor();
-                else
-                    aColor = rStyleSettings.GetWindowColor();
-
-                SetBackground(aColor);
-                SetPaintTransparent(false);
-                SetParentClipMode();
-            }
-        }
-
+        ApplyBackgroundSettings(*this, rStyleSettings);
         EnableChildTransparentMode(IsPaintTransparent());
     }
 }
commit 4a149da412dc72fa92c944edc91cc96eb7267636
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Wed May 22 17:13:31 2019 +0200
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Wed May 22 23:01:07 2019 +0200

    VCL replace some code with common function calls
    
    Replaces some code with calls to ApplyControlForeground and
    ApplyControlFont.
    
    Change-Id: I16837ad7c48ed46fa48b1f2a33a84c7e94f63482
    Reviewed-on: https://gerrit.libreoffice.org/72789
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>

diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index 3f20145b5736..a1b1af252dc5 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -2225,7 +2225,7 @@ void Edit::StateChanged( StateChangedType nType )
         }
 
     }
-    else if (nType == StateChangedType::Zoom)
+    else if ((nType == StateChangedType::Zoom) || (nType == StateChangedType::ControlFont))
     {
         if (!mpSubEdit)
         {
@@ -2234,24 +2234,7 @@ void Edit::StateChanged( StateChangedType nType )
             Invalidate();
         }
     }
-    else if (nType == StateChangedType::ControlFont)
-    {
-        if (!mpSubEdit)
-        {
-            ApplySettings(*this);
-            ImplShowCursor();
-            Invalidate();
-        }
-    }
-    else if (nType == StateChangedType::ControlForeground)
-    {
-        if (!mpSubEdit)
-        {
-            ApplySettings(*this);
-            Invalidate();
-        }
-    }
-    else if (nType == StateChangedType::ControlBackground)
+    else if ((nType == StateChangedType::ControlForeground) || (nType == StateChangedType::ControlBackground))
     {
         if (!mpSubEdit)
         {
diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx
index e7e2344f5096..d6efa0e726ab 100644
--- a/vcl/source/control/imp_listbox.cxx
+++ b/vcl/source/control/imp_listbox.cxx
@@ -520,15 +520,8 @@ void ImplListBoxWindow::ApplySettings(vcl::RenderContext& rRenderContext)
 {
     const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
 
-    vcl::Font aFont = rStyleSettings.GetFieldFont();
-    if (IsControlFont())
-        aFont.Merge(GetControlFont());
-    SetZoomedPointFont(rRenderContext, aFont);
-
-    Color aTextColor = rStyleSettings.GetFieldTextColor();
-    if (IsControlForeground())
-        aTextColor = GetControlForeground();
-    rRenderContext.SetTextColor(aTextColor);
+    ApplyControlFont(rRenderContext, rStyleSettings.GetFieldFont());
+    ApplyControlForeground(rRenderContext, rStyleSettings.GetFieldTextColor());
 
     if (IsControlBackground())
         rRenderContext.SetBackground(GetControlBackground());
@@ -2733,7 +2726,9 @@ void ImplWin::ImplDraw(vcl::RenderContext& rRenderContext, bool bLayout)
             else
             {
                 Color aColor;
-                if( ImplGetSVData()->maNWFData.mbDDListBoxNoTextArea )
+                if (IsControlForeground())
+                    aColor = GetControlForeground();
+                else if (ImplGetSVData()->maNWFData.mbDDListBoxNoTextArea)
                 {
                     if( bNativeOK && (nState & ControlState::ROLLOVER) )
                         aColor = rStyleSettings.GetButtonRolloverTextColor();
@@ -2747,8 +2742,6 @@ void ImplWin::ImplDraw(vcl::RenderContext& rRenderContext, bool bLayout)
                     else
                         aColor = rStyleSettings.GetFieldTextColor();
                 }
-                if (IsControlForeground())
-                    aColor = GetControlForeground();
                 rRenderContext.SetTextColor(aColor);
                 if (!bNativeOK)
                     rRenderContext.Erase(maFocusRect);
@@ -2777,15 +2770,8 @@ void ImplWin::ApplySettings(vcl::RenderContext& rRenderContext)
 {
     const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
 
-    vcl::Font aFont = rStyleSettings.GetFieldFont();
-    if (IsControlFont())
-        aFont.Merge(GetControlFont());
-    SetZoomedPointFont(rRenderContext, aFont);
-
-    Color aTextColor = rStyleSettings.GetFieldTextColor();
-    if (IsControlForeground())
-        aTextColor = GetControlForeground();
-    rRenderContext.SetTextColor(aTextColor);
+    ApplyControlFont(rRenderContext, rStyleSettings.GetFieldFont());
+    ApplyControlForeground(rRenderContext, rStyleSettings.GetFieldTextColor());
 
     if (IsControlBackground())
         rRenderContext.SetBackground(GetControlBackground());
diff --git a/vcl/source/control/prgsbar.cxx b/vcl/source/control/prgsbar.cxx
index 08a0296dacdb..61ba2b67a1fe 100644
--- a/vcl/source/control/prgsbar.cxx
+++ b/vcl/source/control/prgsbar.cxx
@@ -65,13 +65,7 @@ void ProgressBar::ImplInitSettings( bool bFont,
 
 /* FIXME: !!! We do not support text output at the moment
     if ( bFont )
-    {
-        Font aFont;
-        aFont = rStyleSettings.GetAppFont();
-        if ( IsControlFont() )
-            aFont.Merge( GetControlFont() );
-        SetZoomedPointFont( aFont );
-    }
+        ApplyControlFont(*this, rStyleSettings.GetAppFont());
 */
 
     if ( bBackground )
diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx
index 723ab9d07b4f..61c17df48dab 100644
--- a/vcl/source/window/status.cxx
+++ b/vcl/source/window/status.cxx
@@ -164,10 +164,7 @@ void StatusBar::ApplySettings(vcl::RenderContext& rRenderContext)
     rRenderContext.SetLineColor();
 
     const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
-    vcl::Font aFont = rStyleSettings.GetToolFont();
-    if (IsControlFont())
-        aFont.Merge(GetControlFont());
-    SetZoomedPointFont(rRenderContext, aFont);
+    ApplyControlFont(rRenderContext, rStyleSettings.GetToolFont());
 
     Color aColor;
     if (IsControlForeground())
@@ -176,8 +173,8 @@ void StatusBar::ApplySettings(vcl::RenderContext& rRenderContext)
         aColor = rStyleSettings.GetButtonTextColor();
     else
         aColor = rStyleSettings.GetWindowTextColor();
-
     rRenderContext.SetTextColor(aColor);
+
     rRenderContext.SetTextFillColor();
 
     if (IsControlBackground())


More information about the Libreoffice-commits mailing list