From 66cd438e3545edecaa05aa27beb289c6a6df53fc Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 25 May 2018 16:54:30 +0100 Subject: weld SvxAngleTabPage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I03bd0a6a0805d549570ce44030a0f58ca2b98d05 Reviewed-on: https://gerrit.libreoffice.org/54818 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- include/svx/dialcontrol.hxx | 93 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 2 deletions(-) (limited to 'include/svx/dialcontrol.hxx') diff --git a/include/svx/dialcontrol.hxx b/include/svx/dialcontrol.hxx index a62377f8251a..6388a0d2c2aa 100644 --- a/include/svx/dialcontrol.hxx +++ b/include/svx/dialcontrol.hxx @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -33,7 +34,7 @@ namespace svx { class SAL_WARN_UNUSED DialControlBmp final : public VirtualDevice { public: - explicit DialControlBmp( vcl::Window& rParent ); + explicit DialControlBmp(OutputDevice& rReference); void InitBitmap(const vcl::Font& rFont); void SetSize(const Size& rSize); @@ -53,7 +54,7 @@ private: tools::Rectangle maRect; bool mbEnabled; - vcl::Window& mrParent; + OutputDevice& mrParent; long mnCenterX; long mnCenterY; }; @@ -157,6 +158,94 @@ private: void LinkedFieldModifyHdl(); }; +class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxDialControl : public weld::CustomWidgetController +{ +private: + OUString m_aText; +public: + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; + + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + + virtual void StyleUpdated() override; + + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void MouseMove( const MouseEvent& rMEvt ) override; + virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; + virtual bool KeyInput(const KeyEvent& rKEvt) override; + virtual void LoseFocus() override; + + virtual void Resize() override; + + const OUString& GetText() const { return m_aText; } + void SetText(const OUString& rText) { m_aText = rText; } + + /** Returns true, if the control is not in "don't care" state. */ + bool HasRotation() const; + /** Sets the control to "don't care" state. */ + void SetNoRotation(); + + /** 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 ); + + /** Links the passed numeric edit field to the control (bi-directional). + * nDecimalPlaces: + * field value is unsign given decimal places + * default is 0 which means field values are in degrees, + * 2 means 100th of degree + */ + void SetLinkedField(weld::SpinButton* pField, sal_Int32 nDecimalPlaces = 0); + + /** The passed handler is called whenever the rotation value changes. */ + void SetModifyHdl( const Link& rLink ); + + /** Save value for later comparison */ + void SaveValue(); + + /** Compare value with the saved value */ + bool IsValueModified(); + +protected: + struct DialControl_Impl + { + ScopedVclPtr mxBmpEnabled; + ScopedVclPtr mxBmpDisabled; + ScopedVclPtr mxBmpBuffered; + Link maModifyHdl; + weld::SpinButton* mpLinkField; + sal_Int32 mnLinkedFieldValueMultiplyer; + Size maWinSize; + vcl::Font maWinFont; + sal_Int32 mnAngle; + sal_Int32 mnInitialAngle; + sal_Int32 mnOldAngle; + long mnCenterX; + long mnCenterY; + bool mbNoRot; + + explicit DialControl_Impl(OutputDevice& rReference); + 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(); + + DECL_LINK( LinkedFieldModifyHdl, weld::SpinButton&, void ); + void LinkedFieldModifyHdl(); +}; + /** Wrapper for usage of a DialControl in item connections. */ class SAL_WARN_UNUSED SVX_DLLPUBLIC DialControlWrapper : public sfx::SingleControlWrapper< DialControl, sal_Int32 > { -- cgit