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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon Dec 30 12:16:51 UTC 2019


 include/svx/dialcontrol.hxx       |   66 ----------
 svx/source/dialog/dialcontrol.cxx |  232 --------------------------------------
 2 files changed, 1 insertion(+), 297 deletions(-)

New commits:
commit df61a5e277074e016ceaecb2297bb307a5e71819
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Dec 23 21:25:23 2019 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Dec 30 13:16:16 2019 +0100

    DialControl is now unused
    
    Change-Id: Ifdaa6322c3eb12cb0df5130b0da0596ebca15321
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85769
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/svx/dialcontrol.hxx b/include/svx/dialcontrol.hxx
index 07f95bb04420..b17b39cf5615 100644
--- a/include/svx/dialcontrol.hxx
+++ b/include/svx/dialcontrol.hxx
@@ -21,9 +21,7 @@
 #define INCLUDED_SVX_DIALCONTROL_HXX
 
 #include <memory>
-#include <vcl/ctrl.hxx>
 #include <vcl/customweld.hxx>
-#include <vcl/field.hxx>
 #include <vcl/virdev.hxx>
 #include <svx/svxdllapi.h>
 
@@ -68,74 +66,12 @@ private:
     state of the control.
 
     It is possible to link a numeric field to this control using the function
-    SetLinkedField(). The DialControl will take full control of this numeric
+    SetLinkedField(). The SvxDialControl will take full control of this numeric
     field:
     -   Sets the rotation angle to the numeric field in mouse operations.
     -   Shows the value entered/modified in the numeric field.
     -   Enables/disables/shows/hides the field according to own state changes.
  */
-class SAL_WARN_UNUSED DialControl : public Control
-{
-public:
-    explicit            DialControl( vcl::Window* pParent, WinBits nBits );
-
-    virtual void        Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
-
-    virtual void        StateChanged( StateChangedType nStateChange ) override;
-    virtual void        DataChanged( const DataChangedEvent& rDCEvt ) override;
-
-    virtual void        MouseButtonDown( const MouseEvent& rMEvt ) override;
-    virtual void        MouseMove( const MouseEvent& rMEvt ) override;
-    virtual void        MouseButtonUp( const MouseEvent& rMEvt ) override;
-    virtual void        KeyInput( const KeyEvent& rKEvt ) override;
-    virtual void        LoseFocus() override;
-
-    virtual Size        GetOptimalSize() const override;
-    virtual void        Resize() override;
-
-    /** Returns the current rotation angle in 1/100 degrees. */
-    sal_Int32           GetRotation() const;
-    /** Sets the rotation to the passed value (in 1/100 degrees). */
-    void                SetRotation( sal_Int32 nAngle );
-
-    /** The passed handler is called whenever the rotation value changes. */
-    void                SetModifyHdl( const Link<DialControl*,void>& rLink );
-
-protected:
-    struct DialControl_Impl
-    {
-        ScopedVclPtr<DialControlBmp> mxBmpEnabled;
-        ScopedVclPtr<DialControlBmp> mxBmpDisabled;
-        ScopedVclPtr<DialControlBmp> mxBmpBuffered;
-        Link<DialControl*,void>      maModifyHdl;
-        VclPtr<NumericField>         mpLinkField;
-        sal_Int32           mnLinkedFieldValueMultiplyer;
-        Size                maWinSize;
-        vcl::Font           maWinFont;
-        sal_Int32           mnAngle;
-        sal_Int32           mnOldAngle;
-        long                mnCenterX;
-        long                mnCenterY;
-        bool                mbNoRot;
-
-        explicit            DialControl_Impl( vcl::Window& rParent );
-        void                Init( const Size& rWinSize, const vcl::Font& rWinFont );
-        void                SetSize( const Size& rWinSize );
-    };
-    std::unique_ptr< DialControl_Impl > mpImpl;
-
-    virtual void        HandleMouseEvent( const Point& rPos, bool bInitial );
-    void                HandleEscapeEvent();
-
-    void                SetRotation( sal_Int32 nAngle, bool bBroadcast );
-
-    void                Init( const Size& rWinSize, const vcl::Font& rWinFont );
-    void                Init( const Size& rWinSize );
-
-private:
-    void                InvalidateControl();
-};
-
 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxDialControl final : public weld::CustomWidgetController
 {
 public:
diff --git a/svx/source/dialog/dialcontrol.cxx b/svx/source/dialog/dialcontrol.cxx
index 35eae0a707ed..47bef93b3992 100644
--- a/svx/source/dialog/dialcontrol.cxx
+++ b/svx/source/dialog/dialcontrol.cxx
@@ -215,238 +215,6 @@ void DialControlBmp::DrawBackground()
     DrawEllipse( aEllipseRect );
 }
 
-
-DialControl::DialControl_Impl::DialControl_Impl ( vcl::Window& rParent ) :
-    mxBmpEnabled(VclPtr<DialControlBmp>::Create(rParent)),
-    mxBmpDisabled(VclPtr<DialControlBmp>::Create(rParent)),
-    mxBmpBuffered(VclPtr<DialControlBmp>::Create(rParent)),
-    mpLinkField( nullptr ),
-    mnLinkedFieldValueMultiplyer( 0 ),
-    mnAngle( 0 ),
-    mnOldAngle( 0 ),
-    mnCenterX( 0 ),
-    mnCenterY( 0 ),
-    mbNoRot( false )
-{
-}
-
-void DialControl::DialControl_Impl::Init( const Size& rWinSize, const vcl::Font& rWinFont )
-{
-    maWinFont = rWinFont;
-    maWinFont.SetTransparent(true);
-    mxBmpBuffered->InitBitmap(maWinFont);
-    SetSize(rWinSize);
-}
-
-void DialControl::DialControl_Impl::SetSize( const Size& rWinSize )
-{
-    // make the control squared, and adjusted so that we have a well-defined
-    // center ["(x - 1) | 1" creates odd value <= x]
-    long nMin = (std::min(rWinSize.Width(), rWinSize.Height()) - 1) | 1;
-
-    maWinSize = Size( nMin, nMin );
-
-    mnCenterX = maWinSize.Width() / 2;
-    mnCenterY = maWinSize.Height() / 2;
-
-    mxBmpEnabled->DrawBackground( maWinSize, true );
-    mxBmpDisabled->DrawBackground( maWinSize, false );
-    mxBmpBuffered->SetSize( maWinSize );
-}
-
-
-DialControl::DialControl( vcl::Window* pParent, WinBits nBits ) :
-    Control( pParent, nBits ),
-     mpImpl( new DialControl_Impl( *this ) )
-{
-    Init( GetOutputSizePixel() );
-}
-
-void DialControl::Resize()
-{
-    mpImpl->SetSize(GetOutputSizePixel());
-    InvalidateControl();
-}
-
-void DialControl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
-{
-    Point aPos;
-    rRenderContext.DrawBitmapEx(aPos, mpImpl->mxBmpBuffered->GetBitmapEx(aPos, mpImpl->maWinSize));
-}
-
-void DialControl::StateChanged( StateChangedType nStateChange )
-{
-    if( nStateChange == StateChangedType::Enable )
-        InvalidateControl();
-
-    // update the linked edit field
-    if( mpImpl->mpLinkField )
-    {
-        NumericField& rField = *mpImpl->mpLinkField;
-        switch( nStateChange )
-        {
-            case StateChangedType::Visible:  rField.Show( IsVisible() );     break;
-            case StateChangedType::Enable:   rField.Enable( IsEnabled() );   break;
-            default:;
-        }
-    }
-
-    Control::StateChanged( nStateChange );
-}
-
-void DialControl::DataChanged( const DataChangedEvent& rDCEvt )
-{
-    if( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) && (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
-    {
-        Init( mpImpl->maWinSize, mpImpl->maWinFont );
-        InvalidateControl();
-    }
-    Control::DataChanged( rDCEvt );
-}
-
-void DialControl::MouseButtonDown( const MouseEvent& rMEvt )
-{
-    if( rMEvt.IsLeft() )
-    {
-        GrabFocus();
-        CaptureMouse();
-        mpImpl->mnOldAngle = mpImpl->mnAngle;
-        HandleMouseEvent( rMEvt.GetPosPixel(), true );
-    }
-    Control::MouseButtonDown( rMEvt );
-}
-
-void DialControl::MouseMove( const MouseEvent& rMEvt )
-{
-    if( IsMouseCaptured() && rMEvt.IsLeft() )
-        HandleMouseEvent( rMEvt.GetPosPixel(), false );
-    Control::MouseMove(rMEvt );
-}
-
-void DialControl::MouseButtonUp( const MouseEvent& rMEvt )
-{
-    if( IsMouseCaptured() )
-    {
-        ReleaseMouse();
-        if( mpImpl->mpLinkField )
-            mpImpl->mpLinkField->GrabFocus();
-    }
-    Control::MouseButtonUp( rMEvt );
-}
-
-void DialControl::KeyInput( const KeyEvent& rKEvt )
-{
-    const vcl::KeyCode& rKCode = rKEvt.GetKeyCode();
-    if( !rKCode.GetModifier() && (rKCode.GetCode() == KEY_ESCAPE) )
-        HandleEscapeEvent();
-    else
-        Control::KeyInput( rKEvt );
-}
-
-void DialControl::LoseFocus()
-{
-    // release captured mouse
-    HandleEscapeEvent();
-    Control::LoseFocus();
-}
-
-sal_Int32 DialControl::GetRotation() const
-{
-    return mpImpl->mnAngle;
-}
-
-Size DialControl::GetOptimalSize() const
-{
-    return LogicToPixel(Size(42, 43), MapMode(MapUnit::MapAppFont));
-}
-
-void DialControl::SetRotation( sal_Int32 nAngle )
-{
-    SetRotation( nAngle, false );
-}
-
-void DialControl::SetModifyHdl( const Link<DialControl*,void>& rLink )
-{
-    mpImpl->maModifyHdl = rLink;
-}
-
-void DialControl::Init( const Size& rWinSize, const vcl::Font& rWinFont )
-{
-    mpImpl->Init( rWinSize, rWinFont );
-    EnableRTL( false ); // don't mirror mouse handling
-    SetOutputSizePixel( mpImpl->maWinSize );
-    SetBackground();
-}
-
-void DialControl::Init( const Size& rWinSize )
-{
-    //hidpi TODO: GetDefaultFont() picks a font size too small, so fix it here.
-    vcl::Font aDefaultSize = GetFont();
-
-    vcl::Font aFont( OutputDevice::GetDefaultFont(
-        DefaultFontType::UI_SANS, Application::GetSettings().GetUILanguageTag().getLanguageType(), GetDefaultFontFlags::OnlyOne ) );
-
-    aFont.SetFontHeight(aDefaultSize.GetFontHeight());
-    Init( rWinSize, aFont );
-}
-
-void DialControl::InvalidateControl()
-{
-    mpImpl->mxBmpBuffered->CopyBackground( IsEnabled() ? *mpImpl->mxBmpEnabled : *mpImpl->mxBmpDisabled );
-    if( !mpImpl->mbNoRot )
-        mpImpl->mxBmpBuffered->DrawElements( GetText(), mpImpl->mnAngle );
-    Invalidate();
-}
-
-void DialControl::SetRotation( sal_Int32 nAngle, bool bBroadcast )
-{
-    bool bOldSel = mpImpl->mbNoRot;
-    mpImpl->mbNoRot = false;
-
-    while( nAngle < 0 )
-        nAngle += 36000;
-
-    if( !bOldSel || (mpImpl->mnAngle != nAngle) )
-    {
-        mpImpl->mnAngle = nAngle;
-        InvalidateControl();
-        if( mpImpl->mpLinkField )
-            mpImpl->mpLinkField->SetValue( static_cast< long >( GetRotation() / mpImpl->mnLinkedFieldValueMultiplyer ) );
-        if( bBroadcast )
-            mpImpl->maModifyHdl.Call( this );
-    }
-}
-
-void DialControl::HandleMouseEvent( const Point& rPos, bool bInitial )
-{
-    long nX = rPos.X() - mpImpl->mnCenterX;
-    long nY = mpImpl->mnCenterY - rPos.Y();
-    double fH = sqrt( static_cast< double >( nX ) * nX + static_cast< double >( nY ) * nY );
-    if( fH != 0.0 )
-    {
-        double fAngle = acos( nX / fH );
-        sal_Int32 nAngle = static_cast<sal_Int32>(basegfx::rad2deg(fAngle) * 100.0);
-        if( nY < 0 )
-            nAngle = 36000 - nAngle;
-        if( bInitial )  // round to entire 15 degrees
-            nAngle = ((nAngle + 750) / 1500) * 1500;
-        // Round up to 1 degree
-        nAngle = (((nAngle + 50) / 100) * 100) % 36000;
-        SetRotation( nAngle, true );
-    }
-}
-
-void DialControl::HandleEscapeEvent()
-{
-    if( IsMouseCaptured() )
-    {
-        ReleaseMouse();
-        SetRotation( mpImpl->mnOldAngle, true );
-        if( mpImpl->mpLinkField )
-            mpImpl->mpLinkField->GrabFocus();
-    }
-}
-
 SvxDialControl::DialControl_Impl::DialControl_Impl(OutputDevice& rReference) :
     mxBmpEnabled(VclPtr<DialControlBmp>::Create(rReference)),
     mxBmpDisabled(VclPtr<DialControlBmp>::Create(rReference)),


More information about the Libreoffice-commits mailing list