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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri May 8 08:11:07 UTC 2020


 include/vcl/button.hxx        |   10 -----
 vcl/source/control/button.cxx |   69 --------------------------------------
 vcl/source/window/layout.cxx  |   75 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 75 insertions(+), 79 deletions(-)

New commits:
commit fe2bc1012932cbb6c902b9034d9d1497609e57a5
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu May 7 20:09:01 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri May 8 10:10:22 2020 +0200

    move DisclosureButton out of public headers
    
    Change-Id: If267be2c5d02d185eddada7c4e0de0bc5af0b19c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93677
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/vcl/button.hxx b/include/vcl/button.hxx
index d9e2106ea6d5..bfdb4d5323b3 100644
--- a/include/vcl/button.hxx
+++ b/include/vcl/button.hxx
@@ -516,16 +516,6 @@ public:
     explicit        TriStateBox( vcl::Window* pParent, WinBits nStyle );
 };
 
-class DisclosureButton final : public CheckBox
-{
-    virtual void ImplDrawCheckBoxState(vcl::RenderContext& rRenderContext) override;
-
-public:
-    explicit DisclosureButton( vcl::Window* pParent );
-
-    virtual void    KeyInput( const KeyEvent& rKEvt ) override;
-};
-
 #endif // INCLUDED_VCL_BUTTON_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index 829b390a31f7..b818fef15f68 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -3702,73 +3702,4 @@ TriStateBox::TriStateBox( vcl::Window* pParent, WinBits nStyle ) :
     EnableTriState();
 }
 
-DisclosureButton::DisclosureButton( vcl::Window* pParent ) :
-    CheckBox( pParent, 0 )
-{
-}
-
-void DisclosureButton::ImplDrawCheckBoxState(vcl::RenderContext& rRenderContext)
-{
-    /* HACK: DisclosureButton is currently assuming, that the disclosure sign
-       will fit into the rectangle occupied by a normal checkbox on all themes.
-       If this does not hold true for some theme, ImplGetCheckImageSize
-       would have to be overridden for DisclosureButton; also GetNativeControlRegion
-       for ControlType::ListNode would have to be implemented and taken into account
-    */
-
-    tools::Rectangle aStateRect(GetStateRect());
-
-    ImplControlValue aControlValue(GetState() == TRISTATE_TRUE ? ButtonValue::On : ButtonValue::Off);
-    tools::Rectangle aCtrlRegion(aStateRect);
-    ControlState nState = ControlState::NONE;
-
-    if (HasFocus())
-        nState |= ControlState::FOCUSED;
-    if (GetButtonState() & DrawButtonFlags::Default)
-        nState |= ControlState::DEFAULT;
-    if (Window::IsEnabled())
-        nState |= ControlState::ENABLED;
-    if (IsMouseOver() && GetMouseRect().IsInside(GetPointerPosPixel()))
-        nState |= ControlState::ROLLOVER;
-
-    if (rRenderContext.DrawNativeControl(ControlType::ListNode, ControlPart::Entire, aCtrlRegion,
-                                          nState, aControlValue, OUString()))
-        return;
-
-    ImplSVCtrlData& rCtrlData(ImplGetSVData()->maCtrlData);
-    if (!rCtrlData.mpDisclosurePlus)
-        rCtrlData.mpDisclosurePlus.reset(new Image(StockImage::Yes, SV_DISCLOSURE_PLUS));
-    if (!rCtrlData.mpDisclosureMinus)
-        rCtrlData.mpDisclosureMinus.reset(new Image(StockImage::Yes, SV_DISCLOSURE_MINUS));
-
-    Image* pImg
-        = IsChecked() ? rCtrlData.mpDisclosureMinus.get() : rCtrlData.mpDisclosurePlus.get();
-
-    DrawImageFlags nStyle = DrawImageFlags::NONE;
-    if (!IsEnabled())
-        nStyle |= DrawImageFlags::Disable;
-
-    Size aSize(aStateRect.GetSize());
-    Size aImgSize(pImg->GetSizePixel());
-    Point aOff((aSize.Width() - aImgSize.Width()) / 2,
-               (aSize.Height() - aImgSize.Height()) / 2);
-    aOff += aStateRect.TopLeft();
-    rRenderContext.DrawImage(aOff, *pImg, nStyle);
-}
-
-void DisclosureButton::KeyInput( const KeyEvent& rKEvt )
-{
-    vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
-
-    if( !aKeyCode.GetModifier()  &&
-        ( ( aKeyCode.GetCode() == KEY_ADD ) ||
-          ( aKeyCode.GetCode() == KEY_SUBTRACT ) )
-        )
-    {
-        Check( aKeyCode.GetCode() == KEY_ADD );
-    }
-    else
-        CheckBox::KeyInput( rKEvt );
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index c8817699d39a..91324ed9bb67 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -19,7 +19,9 @@
 #include <vcl/split.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/settings.hxx>
+#include <bitmaps.hlst>
 #include <messagedialog.hxx>
+#include <svdata.hxx>
 #include <window.h>
 #include <boost/multi_array.hpp>
 #include <boost/property_tree/ptree.hpp>
@@ -1544,6 +1546,79 @@ bool VclAlignment::set_property(const OString &rKey, const OUString &rValue)
     return true;
 }
 
+class DisclosureButton final : public CheckBox
+{
+    virtual void ImplDrawCheckBoxState(vcl::RenderContext& rRenderContext) override
+    {
+        /* HACK: DisclosureButton is currently assuming, that the disclosure sign
+           will fit into the rectangle occupied by a normal checkbox on all themes.
+           If this does not hold true for some theme, ImplGetCheckImageSize
+           would have to be overridden for DisclosureButton; also GetNativeControlRegion
+           for ControlType::ListNode would have to be implemented and taken into account
+        */
+
+        tools::Rectangle aStateRect(GetStateRect());
+
+        ImplControlValue aControlValue(GetState() == TRISTATE_TRUE ? ButtonValue::On : ButtonValue::Off);
+        tools::Rectangle aCtrlRegion(aStateRect);
+        ControlState nState = ControlState::NONE;
+
+        if (HasFocus())
+            nState |= ControlState::FOCUSED;
+        if (GetButtonState() & DrawButtonFlags::Default)
+            nState |= ControlState::DEFAULT;
+        if (Window::IsEnabled())
+            nState |= ControlState::ENABLED;
+        if (IsMouseOver() && GetMouseRect().IsInside(GetPointerPosPixel()))
+            nState |= ControlState::ROLLOVER;
+
+        if (rRenderContext.DrawNativeControl(ControlType::ListNode, ControlPart::Entire, aCtrlRegion,
+                                              nState, aControlValue, OUString()))
+            return;
+
+        ImplSVCtrlData& rCtrlData(ImplGetSVData()->maCtrlData);
+        if (!rCtrlData.mpDisclosurePlus)
+            rCtrlData.mpDisclosurePlus.reset(new Image(StockImage::Yes, SV_DISCLOSURE_PLUS));
+        if (!rCtrlData.mpDisclosureMinus)
+            rCtrlData.mpDisclosureMinus.reset(new Image(StockImage::Yes, SV_DISCLOSURE_MINUS));
+
+        Image* pImg
+            = IsChecked() ? rCtrlData.mpDisclosureMinus.get() : rCtrlData.mpDisclosurePlus.get();
+
+        DrawImageFlags nStyle = DrawImageFlags::NONE;
+        if (!IsEnabled())
+            nStyle |= DrawImageFlags::Disable;
+
+        Size aSize(aStateRect.GetSize());
+        Size aImgSize(pImg->GetSizePixel());
+        Point aOff((aSize.Width() - aImgSize.Width()) / 2,
+                   (aSize.Height() - aImgSize.Height()) / 2);
+        aOff += aStateRect.TopLeft();
+        rRenderContext.DrawImage(aOff, *pImg, nStyle);
+    }
+
+public:
+    explicit DisclosureButton(vcl::Window* pParent)
+        : CheckBox(pParent, 0)
+    {
+    }
+
+    virtual void KeyInput( const KeyEvent& rKEvt ) override
+    {
+        vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
+
+        if( !aKeyCode.GetModifier()  &&
+            ( ( aKeyCode.GetCode() == KEY_ADD ) ||
+              ( aKeyCode.GetCode() == KEY_SUBTRACT ) )
+            )
+        {
+            Check( aKeyCode.GetCode() == KEY_ADD );
+        }
+        else
+            CheckBox::KeyInput( rKEvt );
+    }
+};
+
 VclExpander::VclExpander(vcl::Window *pParent)
     : VclBin(pParent)
     , m_bResizeTopLevel(true)


More information about the Libreoffice-commits mailing list