diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-05-22 10:38:34 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-05-24 14:24:06 +0200 |
commit | eeaf6dee2d278eaa037d95a756ad0ffab3314bc2 (patch) | |
tree | a997fee717ad079fb59ff0901d418938ab7585f7 /sw/source/uibase | |
parent | c10928e703366341ab912c42e8959a087a7fa9ff (diff) |
rework custom widget welding to enable inheritence
Change-Id: I0d391b3fe9d2d610ae41e2a03cd2e195a866e103
Reviewed-on: https://gerrit.libreoffice.org/54681
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source/uibase')
-rw-r--r-- | sw/source/uibase/inc/autoformatpreview.hxx | 15 | ||||
-rw-r--r-- | sw/source/uibase/inc/envlop.hxx | 15 | ||||
-rw-r--r-- | sw/source/uibase/inc/instable.hxx | 25 | ||||
-rw-r--r-- | sw/source/uibase/inc/num.hxx | 13 | ||||
-rw-r--r-- | sw/source/uibase/inc/numprevw.hxx | 24 | ||||
-rw-r--r-- | sw/source/uibase/inc/outline.hxx | 7 | ||||
-rw-r--r-- | sw/source/uibase/inc/tautofmt.hxx | 27 |
7 files changed, 59 insertions, 67 deletions
diff --git a/sw/source/uibase/inc/autoformatpreview.hxx b/sw/source/uibase/inc/autoformatpreview.hxx index c1e3b77c9f14..bf840d2f22c6 100644 --- a/sw/source/uibase/inc/autoformatpreview.hxx +++ b/sw/source/uibase/inc/autoformatpreview.hxx @@ -30,27 +30,22 @@ #include <vcl/vclptr.hxx> #include <vcl/virdev.hxx> #include <vcl/weld.hxx> +#include <vcl/customweld.hxx> #include <vcl/font.hxx> #include "wrtsh.hxx" #include <tblafmt.hxx> -class AutoFormatPreview +class AutoFormatPreview : public weld::CustomWidgetController { public: - AutoFormatPreview(weld::DrawingArea* pDrawingArea); + AutoFormatPreview(); void NotifyChange(const SwTableAutoFormat& rNewData); void DetectRTL(SwWrtShell const* pWrtShell); - void set_size_request(int nWidth, int nHeight) - { - mxDrawingArea->set_size_request(nWidth, nHeight); - } - private: - std::unique_ptr<weld::DrawingArea> mxDrawingArea; SwTableAutoFormat maCurrentData; svx::frame::Array maArray; /// Implementation to draw the frame borders. bool mbFitWidth; @@ -72,8 +67,8 @@ private: uno::Reference<i18n::XBreakIterator> m_xBreak; void Init(); - DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); - DECL_LINK(DoResize, const Size& rSize, void); + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + virtual void Resize() override; void CalcCellArray(bool bFitWidth); void CalcLineMap(); void PaintCells(vcl::RenderContext& rRenderContext); diff --git a/sw/source/uibase/inc/envlop.hxx b/sw/source/uibase/inc/envlop.hxx index 4d1b640b2bd1..89ba397ed987 100644 --- a/sw/source/uibase/inc/envlop.hxx +++ b/sw/source/uibase/inc/envlop.hxx @@ -27,6 +27,7 @@ #include <vcl/lstbox.hxx> #include <vcl/button.hxx> #include <vcl/weld.hxx> +#include <vcl/customweld.hxx> #include "envimg.hxx" @@ -49,20 +50,17 @@ class SwEnvFormatPage; class SwWrtShell; class Printer; -class SwEnvPreview +class SwEnvPreview : public weld::CustomWidgetController { private: - std::unique_ptr<weld::DrawingArea> m_xDrawingArea; SwEnvDlg* m_pDialog; - Size m_aSize; - DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); - DECL_LINK(DoResize, const Size& rSize, void); + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; public: - SwEnvPreview(weld::DrawingArea* pDrawingArea); + SwEnvPreview(); void SetDialog(SwEnvDlg* pDialog) { m_pDialog = pDialog; } - void queue_draw() { m_xDrawingArea->queue_draw(); } }; class SwEnvDlg : public SfxTabDialogController @@ -94,6 +92,7 @@ class SwEnvPage : public SfxTabPage SwWrtShell* m_pSh; OUString m_sActDBName; + SwEnvPreview m_aPreview; std::unique_ptr<weld::TextView> m_xAddrEdit; std::unique_ptr<weld::ComboBoxText> m_xDatabaseLB; std::unique_ptr<weld::ComboBoxText> m_xTableLB; @@ -101,7 +100,7 @@ class SwEnvPage : public SfxTabPage std::unique_ptr<weld::Button> m_xInsertBT; std::unique_ptr<weld::CheckButton> m_xSenderBox; std::unique_ptr<weld::TextView> m_xSenderEdit; - std::unique_ptr<SwEnvPreview> m_xPreview; + std::unique_ptr<weld::CustomWeld> m_xPreview; DECL_LINK(DatabaseHdl, weld::ComboBoxText&, void); DECL_LINK(FieldHdl, weld::Button&, void); diff --git a/sw/source/uibase/inc/instable.hxx b/sw/source/uibase/inc/instable.hxx index febda4e77613..3f1872fef089 100644 --- a/sw/source/uibase/inc/instable.hxx +++ b/sw/source/uibase/inc/instable.hxx @@ -37,17 +37,6 @@ class SwInsTableDlg : public weld::GenericDialogController { - std::unique_ptr<weld::Entry> m_xNameEdit; - std::unique_ptr<weld::SpinButton> m_xColNF; - std::unique_ptr<weld::SpinButton> m_xRowNF; - std::unique_ptr<weld::CheckButton> m_xHeaderCB; - std::unique_ptr<weld::CheckButton> m_xRepeatHeaderCB; - std::unique_ptr<weld::SpinButton> m_xRepeatHeaderNF; - std::unique_ptr<weld::Widget> m_xRepeatGroup; - std::unique_ptr<weld::CheckButton> m_xDontSplitCB; - std::unique_ptr<weld::Button> m_xInsertBtn; - std::unique_ptr<weld::TreeView> m_xLbFormat; - std::unique_ptr<AutoFormatPreview> m_xWndPreview; TextFilter m_aTextFilter; SwWrtShell* pShell; @@ -60,6 +49,20 @@ class SwInsTableDlg : public weld::GenericDialogController sal_uInt8 maxTableIndexInLb; sal_Int64 nEnteredValRepeatHeaderNF; + AutoFormatPreview m_aWndPreview; + + std::unique_ptr<weld::Entry> m_xNameEdit; + std::unique_ptr<weld::SpinButton> m_xColNF; + std::unique_ptr<weld::SpinButton> m_xRowNF; + std::unique_ptr<weld::CheckButton> m_xHeaderCB; + std::unique_ptr<weld::CheckButton> m_xRepeatHeaderCB; + std::unique_ptr<weld::SpinButton> m_xRepeatHeaderNF; + std::unique_ptr<weld::Widget> m_xRepeatGroup; + std::unique_ptr<weld::CheckButton> m_xDontSplitCB; + std::unique_ptr<weld::Button> m_xInsertBtn; + std::unique_ptr<weld::TreeView> m_xLbFormat; + std::unique_ptr<weld::CustomWeld> m_xWndPreview; + // Returns 255 if mapping is not possible. // This means there cannot be more than 255 autotable style. sal_uInt8 lbIndexToTableIndex( const sal_uInt8 listboxIndex ); diff --git a/sw/source/uibase/inc/num.hxx b/sw/source/uibase/inc/num.hxx index 6bedc870255f..f882c1d8ee3f 100644 --- a/sw/source/uibase/inc/num.hxx +++ b/sw/source/uibase/inc/num.hxx @@ -49,6 +49,8 @@ class SwNumPositionTabPage : public SfxTabPage bool bInInintControl : 1; // work around modify-error; should be resolved from 391 on bool bLabelAlignmentPosAndSpaceModeActive; + SwNumberingPreview m_aPreviewWIN; + std::unique_ptr<weld::TreeView> m_xLevelLB; std::unique_ptr<weld::Widget> m_xPositionFrame; @@ -77,7 +79,7 @@ class SwNumPositionTabPage : public SfxTabPage std::unique_ptr<weld::Label> m_xIndentAtFT; std::unique_ptr<weld::MetricSpinButton> m_xIndentAtMF; std::unique_ptr<weld::Button> m_xStandardPB; - std::unique_ptr<SwNumberingPreview> m_xPreviewWIN; + std::unique_ptr<weld::CustomWeld> m_xPreviewWIN; void InitControls(); @@ -119,10 +121,11 @@ public: void SetModified(); #else void SetModified() - { bModified = true; - m_xPreviewWIN->SetLevel(nActNumLvl); - m_xPreviewWIN->queue_draw(); - } + { + bModified = true; + m_aPreviewWIN.SetLevel(nActNumLvl); + m_aPreviewWIN.Invalidate(); + } #endif }; diff --git a/sw/source/uibase/inc/numprevw.hxx b/sw/source/uibase/inc/numprevw.hxx index b54bcf5ddbb1..44aa3ccc5e34 100644 --- a/sw/source/uibase/inc/numprevw.hxx +++ b/sw/source/uibase/inc/numprevw.hxx @@ -20,6 +20,7 @@ #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_NUMPREVW_HXX #define INCLUDED_SW_SOURCE_UIBASE_INC_NUMPREVW_HXX +#include <vcl/customweld.hxx> #include <vcl/window.hxx> class SwNumRule; @@ -59,10 +60,8 @@ class NumberingPreview : public vcl::Window }; -class SwNumberingPreview +class SwNumberingPreview : public weld::CustomWidgetController { - std::unique_ptr<weld::DrawingArea> m_xDrawingArea; - Size m_aSize; const SwNumRule* pActNum; vcl::Font aStdFont; long nPageWidth; @@ -71,31 +70,22 @@ class SwNumberingPreview sal_uInt16 nActLevel; private: - DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); - DECL_LINK(DoResize, const Size& rSize, void); + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; public: - SwNumberingPreview(weld::DrawingArea* pDrawingArea) - : m_xDrawingArea(pDrawingArea) - , pActNum(nullptr) + SwNumberingPreview() + : pActNum(nullptr) , nPageWidth(0) , pOutlineNames(nullptr) , bPosition(false) , nActLevel(USHRT_MAX) { - m_xDrawingArea->connect_size_allocate(LINK(this, SwNumberingPreview, DoResize)); - m_xDrawingArea->connect_draw(LINK(this, SwNumberingPreview, DoPaint)); - } - - void queue_draw() - { - m_xDrawingArea->queue_draw(); } void SetNumRule(const SwNumRule* pNum) { pActNum = pNum; - queue_draw(); + Invalidate(); } void SetPageWidth(long nPgWidth) @@ -105,10 +95,8 @@ public: void SetPositionMode() { bPosition = true;} void SetLevel(sal_uInt16 nSet) {nActLevel = nSet;} - }; - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/inc/outline.hxx b/sw/source/uibase/inc/outline.hxx index da5c0e94fddf..a9b8e6d5d529 100644 --- a/sw/source/uibase/inc/outline.hxx +++ b/sw/source/uibase/inc/outline.hxx @@ -84,6 +84,7 @@ class SwOutlineSettingsTabPage : public SfxTabPage SwNumRule* pNumRule; OUString* pCollNames; sal_uInt16 nActLevel; + SwNumberingPreview m_aPreviewWIN; std::unique_ptr<weld::TreeView> m_xLevelLB; std::unique_ptr<weld::ComboBoxText> m_xCollBox; @@ -94,7 +95,7 @@ class SwOutlineSettingsTabPage : public SfxTabPage std::unique_ptr<weld::Entry> m_xPrefixED; std::unique_ptr<weld::Entry> m_xSuffixED; std::unique_ptr<weld::SpinButton> m_xStartEdit; - std::unique_ptr<SwNumberingPreview> m_xPreviewWIN; + std::unique_ptr<weld::CustomWeld> m_xPreviewWIN; DECL_LINK( LevelHdl, weld::TreeView&, void ); DECL_LINK( ToggleComplete, weld::SpinButton&, void ); @@ -107,7 +108,7 @@ class SwOutlineSettingsTabPage : public SfxTabPage void Update(); - void SetModified() { m_xPreviewWIN->queue_draw(); } + void SetModified() { m_aPreviewWIN.Invalidate(); } void CheckForStartValue_Impl(sal_uInt16 nNumberingType); using SfxTabPage::ActivatePage; @@ -129,7 +130,7 @@ public: void SetNumRule(SwNumRule *pRule) { pNumRule = pRule; - m_xPreviewWIN->SetNumRule(pNumRule); + m_aPreviewWIN.SetNumRule(pNumRule); } }; diff --git a/sw/source/uibase/inc/tautofmt.hxx b/sw/source/uibase/inc/tautofmt.hxx index 137d08d0c1dc..59f80d722f69 100644 --- a/sw/source/uibase/inc/tautofmt.hxx +++ b/sw/source/uibase/inc/tautofmt.hxx @@ -37,18 +37,6 @@ enum AutoFormatLine { TOP_LINE, BOTTOM_LINE, LEFT_LINE, RIGHT_LINE }; class SwAutoFormatDlg : public weld::GenericDialogController { - std::unique_ptr<weld::TreeView> m_xLbFormat; - std::unique_ptr<weld::CheckButton> m_xBtnNumFormat; - std::unique_ptr<weld::CheckButton> m_xBtnBorder; - std::unique_ptr<weld::CheckButton> m_xBtnFont; - std::unique_ptr<weld::CheckButton> m_xBtnPattern; - std::unique_ptr<weld::CheckButton> m_xBtnAlignment; - std::unique_ptr<weld::Button> m_xBtnCancel; - std::unique_ptr<weld::Button> m_xBtnAdd; - std::unique_ptr<weld::Button> m_xBtnRemove; - std::unique_ptr<weld::Button> m_xBtnRename; - std::unique_ptr<AutoFormatPreview> m_xWndPreview; - std::unique_ptr<SwTableAutoFormatTable> m_xTableTable; OUString m_aStrTitle; OUString m_aStrLabel; OUString m_aStrClose; @@ -63,6 +51,21 @@ class SwAutoFormatDlg : public weld::GenericDialogController bool m_bCoreDataChanged : 1; bool m_bSetAutoFormat : 1; + AutoFormatPreview m_aWndPreview; + std::unique_ptr<SwTableAutoFormatTable> m_xTableTable; + + std::unique_ptr<weld::TreeView> m_xLbFormat; + std::unique_ptr<weld::CheckButton> m_xBtnNumFormat; + std::unique_ptr<weld::CheckButton> m_xBtnBorder; + std::unique_ptr<weld::CheckButton> m_xBtnFont; + std::unique_ptr<weld::CheckButton> m_xBtnPattern; + std::unique_ptr<weld::CheckButton> m_xBtnAlignment; + std::unique_ptr<weld::Button> m_xBtnCancel; + std::unique_ptr<weld::Button> m_xBtnAdd; + std::unique_ptr<weld::Button> m_xBtnRemove; + std::unique_ptr<weld::Button> m_xBtnRename; + std::unique_ptr<weld::CustomWeld> m_xWndPreview; + void Init( const SwTableAutoFormat* pSelFormat ); void UpdateChecks( const SwTableAutoFormat&, bool bEnableBtn ); |