diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-04-03 12:02:13 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-04-04 10:31:58 +0200 |
commit | b9c10ee923308f336a694bbc0212396ed5317b6a (patch) | |
tree | 72bf09a9eb69802a8e09227934bdb0b6c3150023 /include | |
parent | c8c0292c2152df8c353aeff32896f0cfa8a53a64 (diff) |
weld ClassificationDialog
with the extra problem of hosting an EditView/EditEngine within a
weld::DrawingArea
Change-Id: Id48a57ed0dfd2d92217209c43f752edd9cf8e1bd
Reviewed-on: https://gerrit.libreoffice.org/70219
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/editeng/editview.hxx | 7 | ||||
-rw-r--r-- | include/svx/ClassificationDialog.hxx | 79 | ||||
-rw-r--r-- | include/svx/ClassificationEditView.hxx | 37 | ||||
-rw-r--r-- | include/svx/svdedxv.hxx | 3 | ||||
-rw-r--r-- | include/vcl/cursor.hxx | 4 | ||||
-rw-r--r-- | include/vcl/weld.hxx | 3 |
6 files changed, 74 insertions, 59 deletions
diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx index fbb6a614efa2..5dd839ba07f6 100644 --- a/include/editeng/editview.hxx +++ b/include/editeng/editview.hxx @@ -95,12 +95,15 @@ public: // call this when text visualization changed in any way. It // will also update selection, so no need to call this self // additionally (but will also do no harm) - virtual void EditViewInvalidate() const = 0; + virtual void EditViewInvalidate(const tools::Rectangle& rRect) const = 0; // call this when only selection is changed. Text change will // then *not* be checked and not be reacted on. Still, when // only the selection is changed, this is useful and faster virtual void EditViewSelectionChange() const = 0; + + // return the OutputDevice that the EditView will draw to + virtual OutputDevice& EditViewOutputDevice() const = 0; }; class EDITENG_DLLPUBLIC EditView final @@ -130,7 +133,7 @@ public: // set EditViewCallbacks for external handling of Repaints/Visualization void setEditViewCallbacks(const EditViewCallbacks* pEditViewCallbacks); - bool hasEditViewCallbacks() const; + const EditViewCallbacks* getEditViewCallbacks() const; void SetEditEngine( EditEngine* pEditEngine ); EditEngine* GetEditEngine() const; diff --git a/include/svx/ClassificationDialog.hxx b/include/svx/ClassificationDialog.hxx index 3efa8fbc7a8b..2aaed9d16fca 100644 --- a/include/svx/ClassificationDialog.hxx +++ b/include/svx/ClassificationDialog.hxx @@ -12,13 +12,8 @@ #define INCLUDED_SVX_CLASSIFICATIONDIALOG_HXX #include <sal/config.h> -#include <vcl/dialog.hxx> -#include <vcl/button.hxx> -#include <vcl/lstbox.hxx> -#include <vcl/toolbox.hxx> -#include <vcl/fixed.hxx> -#include <vcl/edit.hxx> -#include <vcl/layout.hxx> +#include <vcl/customweld.hxx> +#include <vcl/weld.hxx> #include <svx/svxdllapi.h> #include <svx/ClassificationEditView.hxx> #include <sfx2/classificationhelper.hxx> @@ -26,33 +21,9 @@ namespace svx { -class IntellectualPropertyPartEdit : public Edit -{ -public: - IntellectualPropertyPartEdit(vcl::Window* pParent); - -protected: - virtual void KeyInput(const KeyEvent &rKEvt) override; -}; - -class SVX_DLLPUBLIC ClassificationDialog : public ModalDialog +class SVX_DLLPUBLIC ClassificationDialog : public weld::GenericDialogController { private: - VclPtr<PushButton> m_pOkButton; - VclPtr<ClassificationEditView> m_pEditWindow; - VclPtr<PushButton> m_pSignButton; - VclPtr<ToolBox> m_pToolBox; - VclPtr<ListBox> m_pClassificationListBox; - VclPtr<ListBox> m_pRecentlyUsedListBox; - VclPtr<ListBox> m_pInternationalClassificationListBox; - VclPtr<FixedText> m_pMarkingLabel; - VclPtr<ListBox> m_pMarkingListBox; - VclPtr<ListBox> m_pIntellectualPropertyPartListBox; - VclPtr<ListBox> m_pIntellectualPropertyPartNumberListBox; - VclPtr<PushButton> m_pIntellectualPropertyPartAddButton; - VclPtr<IntellectualPropertyPartEdit> m_pIntellectualPropertyPartEdit; - VclPtr<VclExpander> m_pIntellectualPropertyExpander; - SfxClassificationHelper maHelper; SfxClassificationHelper maInternationalHelper; @@ -61,33 +32,49 @@ private: sal_Int32 m_nCurrentSelectedCategory; - DECL_LINK(ButtonClicked, Button*, void); - DECL_LINK(SelectToolboxHdl, ToolBox*, void); - DECL_LINK(SelectClassificationHdl, ListBox&, void); - DECL_LINK(SelectMarkingHdl, ListBox&, void); - DECL_LINK(SelectIPPartNumbersHdl, ListBox&, void); - DECL_LINK(SelectRecentlyUsedHdl, ListBox&, void); - DECL_LINK(SelectIPPartHdl, ListBox&, void); + std::vector<std::vector<ClassificationResult>> m_aRecentlyUsedValuesCollection; + std::vector<ClassificationResult> m_aInitialValues; + + std::unique_ptr<weld::Button> m_xOkButton; + std::unique_ptr<weld::Button> m_xSignButton; + std::unique_ptr<weld::ToggleButton> m_xToolBox; + std::unique_ptr<weld::ComboBox> m_xRecentlyUsedListBox; + std::unique_ptr<weld::ComboBox> m_xClassificationListBox; + std::unique_ptr<weld::ComboBox> m_xInternationalClassificationListBox; + std::unique_ptr<weld::Label> m_xMarkingLabel; + std::unique_ptr<weld::TreeView> m_xMarkingListBox; + std::unique_ptr<weld::TreeView> m_xIntellectualPropertyPartListBox; + std::unique_ptr<weld::TreeView> m_xIntellectualPropertyPartNumberListBox; + std::unique_ptr<weld::Button> m_xIntellectualPropertyPartAddButton; + std::unique_ptr<weld::Entry> m_xIntellectualPropertyPartEdit; + std::unique_ptr<weld::Expander> m_xIntellectualPropertyExpander; + std::unique_ptr<ClassificationEditView> m_xEditWindow; + std::unique_ptr<weld::CustomWeld> m_xEditWindowWeld; + + DECL_LINK(ButtonClicked, weld::Button&, void); + DECL_LINK(SelectToolboxHdl, weld::ToggleButton&, void); + DECL_LINK(SelectClassificationHdl, weld::ComboBox&, void); + DECL_LINK(SelectMarkingHdl, weld::TreeView&, void); + DECL_LINK(SelectIPPartNumbersHdl, weld::TreeView&, void); + DECL_LINK(SelectRecentlyUsedHdl, weld::ComboBox&, void); + DECL_LINK(SelectIPPartHdl, weld::TreeView&, void); DECL_LINK(EditWindowModifiedHdl, LinkParamNone*, void); - DECL_STATIC_LINK(ClassificationDialog, ExpandedHdl, VclExpander&, void); + DECL_STATIC_LINK(ClassificationDialog, ExpandedHdl, weld::Expander&, void); + DECL_STATIC_LINK(ClassificationDialog, KeyInput, const KeyEvent&, bool); void insertField(ClassificationType eType, OUString const & rString, OUString const & rFullString, OUString const & rIdentifier = OUString()); void insertCategoryField(sal_Int32 nID); - std::vector<std::vector<ClassificationResult>> m_aRecentlyUsedValuesCollection; - std::vector<ClassificationResult> m_aInitialValues; - void readIn(std::vector<ClassificationResult> const & rInput); void readRecentlyUsed(); void writeRecentlyUsed(); void toggleWidgetsDependingOnCategory(); public: - ClassificationDialog(vcl::Window* pParent, bool bPerParagraph, const std::function<void()>& rParagraphSignHandler = [](){}); + ClassificationDialog(weld::Window* pParent, bool bPerParagraph, const std::function<void()>& rParagraphSignHandler = [](){}); ~ClassificationDialog() override; - void dispose() override; - short Execute() override; + short run() override; std::vector<ClassificationResult> getResult(); void setupValues(std::vector<ClassificationResult> const & rInput); diff --git a/include/svx/ClassificationEditView.hxx b/include/svx/ClassificationEditView.hxx index 4f421b400243..656219c141f2 100644 --- a/include/svx/ClassificationEditView.hxx +++ b/include/svx/ClassificationEditView.hxx @@ -18,6 +18,7 @@ #include <editeng/numitem.hxx> #include <editeng/editeng.hxx> #include <editeng/editview.hxx> +#include <vcl/customweld.hxx> namespace svx { @@ -29,15 +30,14 @@ public: virtual OUString CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor) override; }; -class SVX_DLLPUBLIC ClassificationEditView : public Control +class SVX_DLLPUBLIC ClassificationEditView : public weld::CustomWidgetController, + public EditViewCallbacks { public: - ClassificationEditView(vcl::Window* pParent, WinBits nBits); + ClassificationEditView(); + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; virtual ~ClassificationEditView() override; - using Control::SetFont; - using Control::SetText; - void SetCharAttributes(); void InsertField(const SvxFieldItem& rField); @@ -61,13 +61,30 @@ public: protected: virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; - virtual void MouseMove( const MouseEvent& rMEvt ) override; - virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; - virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; - virtual void KeyInput( const KeyEvent& rKEvt ) override; - virtual void Command( const CommandEvent& rCEvt ) override; + virtual bool MouseMove( const MouseEvent& rMEvt ) override; + virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual bool MouseButtonUp( const MouseEvent& rMEvt ) override; + virtual bool KeyInput( const KeyEvent& rKEvt ) override; virtual void GetFocus() override; virtual void Resize() override; + + + virtual void EditViewInvalidate(const tools::Rectangle& rRect) const override + { + weld::DrawingArea* pDrawingArea = GetDrawingArea(); + pDrawingArea->queue_draw_area(rRect.Left(), rRect.Top(), rRect.GetWidth(), rRect.GetHeight()); + } + + virtual void EditViewSelectionChange() const override + { + weld::DrawingArea* pDrawingArea = GetDrawingArea(); + pDrawingArea->queue_draw(); + } + + virtual OutputDevice& EditViewOutputDevice() const override + { + return GetDrawingArea()->get_ref_device(); + } }; } // end svx namespace diff --git a/include/svx/svdedxv.hxx b/include/svx/svdedxv.hxx index 1730e427539d..596e830f8bd3 100644 --- a/include/svx/svdedxv.hxx +++ b/include/svx/svdedxv.hxx @@ -65,8 +65,9 @@ class SVX_DLLPUBLIC SdrObjEditView : public SdrGlueEditView, public EditViewCall // Now derived from EditViewCallbacks and overriding these callbacks to // allow own EditText visualization - virtual void EditViewInvalidate() const override; + virtual void EditViewInvalidate(const tools::Rectangle& rRect) const override; virtual void EditViewSelectionChange() const override; + virtual OutputDevice& EditViewOutputDevice() const override; // The OverlayObjects used for visualizing active TextEdit (currently // using TextEditOverlayObject, but not limited to it diff --git a/include/vcl/cursor.hxx b/include/vcl/cursor.hxx index 0051a0b7df29..714d6f569e80 100644 --- a/include/vcl/cursor.hxx +++ b/include/vcl/cursor.hxx @@ -29,6 +29,7 @@ class Timer; struct ImplCursorData; +class OutputDevice; namespace vcl { class Window; } // Cursor styles @@ -95,8 +96,11 @@ public: bool operator!=( const Cursor& rCursor ) const { return !(Cursor::operator==( rCursor )); } + void DrawToDevice(OutputDevice& rRenderContext); + private: void LOKNotify( vcl::Window* pWindow, const OUString& rAction ); + bool ImplPrepForDraw(OutputDevice* pDevice, ImplCursorData& rData); void ImplRestore(); void ImplDoShow( bool bDrawDirect, bool bRestore ); bool ImplDoHide( bool bStop ); diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index 83f0809ec906..a7a195a9d39d 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -1509,6 +1509,9 @@ public: virtual void queue_draw() = 0; virtual void queue_draw_area(int x, int y, int width, int height) = 0; virtual void queue_resize() = 0; + + virtual void set_text_cursor() = 0; + // use return here just to generate matching VirtualDevices virtual OutputDevice& get_ref_device() = 0; |