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/ui/table | |
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/ui/table')
-rw-r--r-- | sw/source/ui/table/autoformatpreview.cxx | 19 | ||||
-rw-r--r-- | sw/source/ui/table/instable.cxx | 16 | ||||
-rw-r--r-- | sw/source/ui/table/tautofmt.cxx | 32 |
3 files changed, 31 insertions, 36 deletions
diff --git a/sw/source/ui/table/autoformatpreview.cxx b/sw/source/ui/table/autoformatpreview.cxx index 7b302a401703..61af87bdf6e6 100644 --- a/sw/source/ui/table/autoformatpreview.cxx +++ b/sw/source/ui/table/autoformatpreview.cxx @@ -28,9 +28,8 @@ #define FRAME_OFFSET 4 -AutoFormatPreview::AutoFormatPreview(weld::DrawingArea* pDrawingArea) - : mxDrawingArea(pDrawingArea) - , maCurrentData(OUString()) +AutoFormatPreview::AutoFormatPreview() + : maCurrentData(OUString()) , mbFitWidth(false) , mbRTL(false) , maStringJan(SwResId(STR_JAN)) @@ -46,14 +45,12 @@ AutoFormatPreview::AutoFormatPreview(weld::DrawingArea* pDrawingArea) mxNumFormat.reset(new SvNumberFormatter(xContext, LANGUAGE_SYSTEM)); Init(); - - mxDrawingArea->connect_size_allocate(LINK(this, AutoFormatPreview, DoResize)); - mxDrawingArea->connect_draw(LINK(this, AutoFormatPreview, DoPaint)); } -IMPL_LINK(AutoFormatPreview, DoResize, const Size&, rSize, void) +void AutoFormatPreview::Resize() { - maPreviousSize = Size(rSize.Width() - 6, rSize.Height() - 30); + Size aSize = GetOutputSizePixel(); + maPreviousSize = Size(aSize.Width() - 6, aSize.Height() - 30); mnLabelColumnWidth = (maPreviousSize.Width() - 4) / 4 - 12; mnDataColumnWidth1 = (maPreviousSize.Width() - 4 - 2 * mnLabelColumnWidth) / 3; mnDataColumnWidth2 = (maPreviousSize.Width() - 4 - 2 * mnLabelColumnWidth) / 4; @@ -413,13 +410,11 @@ void AutoFormatPreview::NotifyChange(const SwTableAutoFormat& rNewData) mbFitWidth = maCurrentData.IsJustify(); // true; //??? CalcCellArray(mbFitWidth); CalcLineMap(); - mxDrawingArea->queue_draw(); + Invalidate(); } -IMPL_LINK(AutoFormatPreview, DoPaint, weld::DrawingArea::draw_args, aPayload, void) +void AutoFormatPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) { - vcl::RenderContext& rRenderContext = aPayload.first; - rRenderContext.Push(PushFlags::ALL); DrawModeFlags nOldDrawMode = rRenderContext.GetDrawMode(); diff --git a/sw/source/ui/table/instable.cxx b/sw/source/ui/table/instable.cxx index 51a9315b1760..82dff402d7dd 100644 --- a/sw/source/ui/table/instable.cxx +++ b/sw/source/ui/table/instable.cxx @@ -61,6 +61,10 @@ IMPL_LINK(SwInsTableDlg, TextFilterHdl, OUString&, rTest, bool) SwInsTableDlg::SwInsTableDlg(SwView& rView) : weld::GenericDialogController(rView.GetFrameWeld(), "modules/swriter/ui/inserttable.ui", "InsertTableDialog") + , m_aTextFilter(" .<>") + , pShell(&rView.GetWrtShell()) + , pTAutoFormat(nullptr) + , nEnteredValRepeatHeaderNF(-1) , m_xNameEdit(m_xBuilder->weld_entry("nameedit")) , m_xColNF(m_xBuilder->weld_spin_button("colspin")) , m_xRowNF(m_xBuilder->weld_spin_button("rowspin")) @@ -71,11 +75,7 @@ SwInsTableDlg::SwInsTableDlg(SwView& rView) , m_xDontSplitCB(m_xBuilder->weld_check_button("dontsplitcb")) , m_xInsertBtn(m_xBuilder->weld_button("ok")) , m_xLbFormat(m_xBuilder->weld_tree_view("formatlbinstable")) - , m_xWndPreview(new AutoFormatPreview(m_xBuilder->weld_drawing_area("previewinstable"))) - , m_aTextFilter(" .<>") - , pShell(&rView.GetWrtShell()) - , pTAutoFormat(nullptr) - , nEnteredValRepeatHeaderNF(-1) + , m_xWndPreview(new weld::CustomWeld(*m_xBuilder, "previewinstable", m_aWndPreview)) { const int nWidth = m_xLbFormat->get_approximate_digit_width() * 32; const int nHeight = m_xLbFormat->get_height_rows(8); @@ -124,7 +124,7 @@ SwInsTableDlg::SwInsTableDlg(SwView& rView) void SwInsTableDlg::InitAutoTableFormat() { - m_xWndPreview->DetectRTL(pShell); + m_aWndPreview.DetectRTL(pShell); m_xLbFormat->connect_changed(LINK(this, SwInsTableDlg, SelFormatHdl)); @@ -185,13 +185,13 @@ IMPL_LINK_NOARG(SwInsTableDlg, SelFormatHdl, weld::TreeView&, void) // To understand this index maping, look InitAutoTableFormat function to // see how listbox item is implemented. if( tbIndex < 255 ) - m_xWndPreview->NotifyChange( (*pTableTable)[tbIndex] ); + m_aWndPreview.NotifyChange( (*pTableTable)[tbIndex] ); else { SwTableAutoFormat aTmp( SwViewShell::GetShellRes()->aStrNone ); lcl_SetProperties( &aTmp, false ); - m_xWndPreview->NotifyChange( aTmp ); + m_aWndPreview.NotifyChange( aTmp ); } } diff --git a/sw/source/ui/table/tautofmt.cxx b/sw/source/ui/table/tautofmt.cxx index c8d8b0fd2395..4c716726aafb 100644 --- a/sw/source/ui/table/tautofmt.cxx +++ b/sw/source/ui/table/tautofmt.cxx @@ -55,18 +55,6 @@ SwAutoFormatDlg::SwAutoFormatDlg(weld::Window* pParent, SwWrtShell* pWrtShell, bool bAutoFormat, const SwTableAutoFormat* pSelFormat) : GenericDialogController(pParent, "modules/swriter/ui/autoformattable.ui", "AutoFormatTableDialog") - , m_xLbFormat(m_xBuilder->weld_tree_view("formatlb")) - , m_xBtnNumFormat(m_xBuilder->weld_check_button("numformatcb")) - , m_xBtnBorder(m_xBuilder->weld_check_button("bordercb")) - , m_xBtnFont(m_xBuilder->weld_check_button("fontcb")) - , m_xBtnPattern(m_xBuilder->weld_check_button("patterncb")) - , m_xBtnAlignment(m_xBuilder->weld_check_button("alignmentcb")) - , m_xBtnCancel(m_xBuilder->weld_button("cancel")) - , m_xBtnAdd(m_xBuilder->weld_button("add")) - , m_xBtnRemove(m_xBuilder->weld_button("remove")) - , m_xBtnRename(m_xBuilder->weld_button("rename")) - , m_xWndPreview(new AutoFormatPreview(m_xBuilder->weld_drawing_area("preview"))) - , m_xTableTable(new SwTableAutoFormatTable) , m_aStrTitle(SwResId(STR_ADD_AUTOFORMAT_TITLE)) , m_aStrLabel(SwResId(STR_ADD_AUTOFORMAT_LABEL)) , m_aStrClose(SwResId(STR_BTN_AUTOFORMAT_CLOSE)) @@ -79,8 +67,20 @@ SwAutoFormatDlg::SwAutoFormatDlg(weld::Window* pParent, SwWrtShell* pWrtShell, , m_nDfltStylePos(0) , m_bCoreDataChanged(false) , m_bSetAutoFormat(bAutoFormat) + , m_xTableTable(new SwTableAutoFormatTable) + , m_xLbFormat(m_xBuilder->weld_tree_view("formatlb")) + , m_xBtnNumFormat(m_xBuilder->weld_check_button("numformatcb")) + , m_xBtnBorder(m_xBuilder->weld_check_button("bordercb")) + , m_xBtnFont(m_xBuilder->weld_check_button("fontcb")) + , m_xBtnPattern(m_xBuilder->weld_check_button("patterncb")) + , m_xBtnAlignment(m_xBuilder->weld_check_button("alignmentcb")) + , m_xBtnCancel(m_xBuilder->weld_button("cancel")) + , m_xBtnAdd(m_xBuilder->weld_button("add")) + , m_xBtnRemove(m_xBuilder->weld_button("remove")) + , m_xBtnRename(m_xBuilder->weld_button("rename")) + , m_xWndPreview(new weld::CustomWeld(*m_xBuilder, "preview", m_aWndPreview)) { - m_xWndPreview->DetectRTL(pWrtShell); + m_aWndPreview.DetectRTL(pWrtShell); m_xTableTable->Load(); const int nWidth = m_xLbFormat->get_approximate_digit_width() * 32; @@ -200,7 +200,7 @@ IMPL_LINK(SwAutoFormatDlg, CheckHdl, weld::ToggleButton&, rBtn, void) m_bCoreDataChanged = true; } - m_xWndPreview->NotifyChange(rData); + m_aWndPreview.NotifyChange(rData); } } @@ -369,7 +369,7 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, SelFormatHdl, weld::TreeView&, void) if (nSelPos >= m_nDfltStylePos) { m_nIndex = nSelPos - m_nDfltStylePos; - m_xWndPreview->NotifyChange((*m_xTableTable)[m_nIndex]); + m_aWndPreview.NotifyChange((*m_xTableTable)[m_nIndex]); bBtnEnable = 0 != m_nIndex; UpdateChecks( (*m_xTableTable)[m_nIndex], true ); } @@ -386,7 +386,7 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, SelFormatHdl, weld::TreeView&, void) aTmp.SetWidthHeight( false ); if (nOldIdx != m_nIndex) - m_xWndPreview->NotifyChange(aTmp); + m_aWndPreview.NotifyChange(aTmp); UpdateChecks( aTmp, false ); } |