summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-05-22 10:38:34 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-05-24 14:24:06 +0200
commiteeaf6dee2d278eaa037d95a756ad0ffab3314bc2 (patch)
treea997fee717ad079fb59ff0901d418938ab7585f7 /sw
parentc10928e703366341ab912c42e8959a087a7fa9ff (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')
-rw-r--r--sw/source/ui/envelp/envfmt.cxx4
-rw-r--r--sw/source/ui/envelp/envfmt.hxx3
-rw-r--r--sw/source/ui/envelp/envlop1.cxx33
-rw-r--r--sw/source/ui/envelp/labfmt.cxx42
-rw-r--r--sw/source/ui/envelp/labfmt.hxx16
-rw-r--r--sw/source/ui/misc/num.cxx14
-rw-r--r--sw/source/ui/misc/outline.cxx17
-rw-r--r--sw/source/ui/table/autoformatpreview.cxx19
-rw-r--r--sw/source/ui/table/instable.cxx16
-rw-r--r--sw/source/ui/table/tautofmt.cxx32
-rw-r--r--sw/source/uibase/inc/autoformatpreview.hxx15
-rw-r--r--sw/source/uibase/inc/envlop.hxx15
-rw-r--r--sw/source/uibase/inc/instable.hxx25
-rw-r--r--sw/source/uibase/inc/num.hxx13
-rw-r--r--sw/source/uibase/inc/numprevw.hxx24
-rw-r--r--sw/source/uibase/inc/outline.hxx7
-rw-r--r--sw/source/uibase/inc/tautofmt.hxx27
17 files changed, 152 insertions, 170 deletions
diff --git a/sw/source/ui/envelp/envfmt.cxx b/sw/source/ui/envelp/envfmt.cxx
index 2862d520c57e..b46b795fdaac 100644
--- a/sw/source/ui/envelp/envfmt.cxx
+++ b/sw/source/ui/envelp/envfmt.cxx
@@ -126,7 +126,7 @@ SwEnvFormatPage::SwEnvFormatPage(TabPageParent pParent, const SfxItemSet& rSet)
, m_xSizeFormatBox(m_xBuilder->weld_combo_box_text("format"))
, m_xSizeWidthField(m_xBuilder->weld_metric_spin_button("width", FUNIT_CM))
, m_xSizeHeightField(m_xBuilder->weld_metric_spin_button("height", FUNIT_CM))
- , m_xPreview(new SwEnvPreview(m_xBuilder->weld_drawing_area("preview")))
+ , m_xPreview(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreview))
{
SetExchangeSupport();
@@ -180,7 +180,7 @@ SwEnvFormatPage::SwEnvFormatPage(TabPageParent pParent, const SfxItemSet& rSet)
void SwEnvFormatPage::Init(SwEnvDlg* pDialog)
{
m_pDialog = pDialog;
- m_xPreview->SetDialog(m_pDialog);
+ m_aPreview.SetDialog(m_pDialog);
}
SwEnvFormatPage::~SwEnvFormatPage()
diff --git a/sw/source/ui/envelp/envfmt.hxx b/sw/source/ui/envelp/envfmt.hxx
index 20d445f14c61..5fa0bda77de6 100644
--- a/sw/source/ui/envelp/envfmt.hxx
+++ b/sw/source/ui/envelp/envfmt.hxx
@@ -29,6 +29,7 @@ class SwEnvFormatPage : public SfxTabPage
SwEnvDlg* m_pDialog;
std::vector<sal_uInt16> m_aIDs;
+ SwEnvPreview m_aPreview;
std::unique_ptr<weld::MetricSpinButton> m_xAddrLeftField;
std::unique_ptr<weld::MetricSpinButton> m_xAddrTopField;
std::unique_ptr<weld::MenuButton> m_xAddrEditButton;
@@ -38,7 +39,7 @@ class SwEnvFormatPage : public SfxTabPage
std::unique_ptr<weld::ComboBoxText> m_xSizeFormatBox;
std::unique_ptr<weld::MetricSpinButton> m_xSizeWidthField;
std::unique_ptr<weld::MetricSpinButton> m_xSizeHeightField;
- std::unique_ptr<SwEnvPreview> m_xPreview;
+ std::unique_ptr<weld::CustomWeld> m_xPreview;
DECL_LINK(ModifyHdl, weld::MetricSpinButton&, void);
DECL_LINK(AddrEditHdl, const OString&, void);
diff --git a/sw/source/ui/envelp/envlop1.cxx b/sw/source/ui/envelp/envlop1.cxx
index 9d25bf201544..756a61a6465d 100644
--- a/sw/source/ui/envelp/envlop1.cxx
+++ b/sw/source/ui/envelp/envlop1.cxx
@@ -44,25 +44,20 @@ using namespace ::com::sun::star::container;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star;
-SwEnvPreview::SwEnvPreview(weld::DrawingArea* pDrawingArea)
- : m_xDrawingArea(pDrawingArea)
- , m_pDialog(nullptr)
+SwEnvPreview::SwEnvPreview()
+ : m_pDialog(nullptr)
{
- m_xDrawingArea->set_size_request(m_xDrawingArea->get_approximate_digit_width() * 20,
- m_xDrawingArea->get_text_height() * 8);
- m_xDrawingArea->connect_size_allocate(LINK(this, SwEnvPreview, DoResize));
- m_xDrawingArea->connect_draw(LINK(this, SwEnvPreview, DoPaint));
}
-IMPL_LINK(SwEnvPreview, DoResize, const Size&, rSize, void)
+void SwEnvPreview::SetDrawingArea(weld::DrawingArea* pDrawingArea)
{
- m_aSize = rSize;
+ pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 20,
+ pDrawingArea->get_text_height() * 8);
+ CustomWidgetController::SetDrawingArea(pDrawingArea);
}
-IMPL_LINK(SwEnvPreview, DoPaint, weld::DrawingArea::draw_args, aPayload, void)
+void SwEnvPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
{
- vcl::RenderContext& rRenderContext = aPayload.first;
-
const StyleSettings& rSettings = rRenderContext.GetSettings().GetStyleSettings();
rRenderContext.SetBackground(rRenderContext.GetSettings().GetStyleSettings().GetDialogColor());
rRenderContext.Erase();
@@ -72,9 +67,11 @@ IMPL_LINK(SwEnvPreview, DoPaint, weld::DrawingArea::draw_args, aPayload, void)
const long nPageW = std::max(rItem.m_nWidth, rItem.m_nHeight);
const long nPageH = std::min(rItem.m_nWidth, rItem.m_nHeight);
+ Size aSize(GetOutputSizePixel());
+
const double f = 0.8 * std::min(
- double(m_aSize.Width()) / double(nPageW),
- double(m_aSize.Height()) / double(nPageH));
+ double(aSize.Width()) / double(nPageW),
+ double(aSize.Height()) / double(nPageH));
Color aBack = rSettings.GetWindowColor();
Color aFront = SwViewOption::GetFontColor();
@@ -87,8 +84,8 @@ IMPL_LINK(SwEnvPreview, DoPaint, weld::DrawingArea::draw_args, aPayload, void)
// Envelope
const long nW = static_cast<long>(f * nPageW);
const long nH = static_cast<long>(f * nPageH);
- const long nX = (m_aSize.Width () - nW) / 2;
- const long nY = (m_aSize.Height() - nH) / 2;
+ const long nX = (aSize.Width () - nW) / 2;
+ const long nY = (aSize.Height() - nH) / 2;
rRenderContext.SetFillColor(aBack);
rRenderContext.DrawRect(tools::Rectangle(Point(nX, nY), Size(nW, nH)));
@@ -196,7 +193,7 @@ SwEnvPage::SwEnvPage(TabPageParent pParent, const SfxItemSet& rSet)
, m_xInsertBT(m_xBuilder->weld_button("insert"))
, m_xSenderBox(m_xBuilder->weld_check_button("sender"))
, m_xSenderEdit(m_xBuilder->weld_text_view("senderedit"))
- , m_xPreview(new SwEnvPreview(m_xBuilder->weld_drawing_area("preview")))
+ , m_xPreview(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreview))
{
auto nTextBoxHeight(m_xAddrEdit->get_height_rows(10));
auto nTextBoxWidth(m_xAddrEdit->get_approximate_digit_width() * 25);
@@ -216,7 +213,7 @@ void SwEnvPage::Init(SwEnvDlg* pDialog)
{
m_pDialog = pDialog;
m_pSh = m_pDialog->pSh;
- m_xPreview->SetDialog(pDialog);
+ m_aPreview.SetDialog(pDialog);
// Install handlers
m_xDatabaseLB->connect_changed(LINK(this, SwEnvPage, DatabaseHdl));
diff --git a/sw/source/ui/envelp/labfmt.cxx b/sw/source/ui/envelp/labfmt.cxx
index b016700362f0..1f3b81e20c22 100644
--- a/sw/source/ui/envelp/labfmt.cxx
+++ b/sw/source/ui/envelp/labfmt.cxx
@@ -98,9 +98,8 @@ void DrawArrow(vcl::RenderContext& rRenderContext, const Point &rP1, const Point
}
-SwLabPreview::SwLabPreview(weld::DrawingArea* pWidget)
- : m_xDrawingArea(pWidget)
- , m_aGrayColor(COL_LIGHTGRAY)
+SwLabPreview::SwLabPreview()
+ : m_aGrayColor(COL_LIGHTGRAY)
, m_aHDistStr(SwResId(STR_HDIST))
, m_aVDistStr(SwResId(STR_VDIST))
, m_aWidthStr(SwResId(STR_WIDTH))
@@ -109,34 +108,39 @@ SwLabPreview::SwLabPreview(weld::DrawingArea* pWidget)
, m_aUpperStr(SwResId(STR_UPPER))
, m_aColsStr(SwResId(STR_COLS))
, m_aRowsStr(SwResId(STR_ROWS))
+ , m_lHDistWidth(0)
+ , m_lVDistWidth(0)
+ , m_lHeightWidth(0)
+ , m_lLeftWidth(0)
+ , m_lUpperWidth(0)
+ , m_lColsWidth(0)
+ , m_lXWidth(0)
+ , m_lXHeight(0)
+{
+}
+
+void SwLabPreview::SetDrawingArea(weld::DrawingArea* pWidget)
{
pWidget->set_size_request(pWidget->get_approximate_digit_width() * 54,
pWidget->get_text_height() * 15);
- m_xDrawingArea->connect_size_allocate(LINK(this, SwLabPreview, DoResize));
- m_xDrawingArea->connect_draw(LINK(this, SwLabPreview, DoPaint));
-
m_lHDistWidth = pWidget->get_pixel_size(m_aHDistStr).Width();
m_lVDistWidth = pWidget->get_pixel_size(m_aVDistStr).Width();
m_lHeightWidth = pWidget->get_pixel_size(m_aHeightStr).Width();
m_lLeftWidth = pWidget->get_pixel_size(m_aLeftStr).Width();
m_lUpperWidth = pWidget->get_pixel_size(m_aUpperStr).Width();
m_lColsWidth = pWidget->get_pixel_size(m_aColsStr).Width();
- m_lXHeight = pWidget->get_text_height();
m_lXWidth = pWidget->get_pixel_size(OUString('X')).Width();
-}
+ m_lXHeight = pWidget->get_text_height();
-IMPL_LINK(SwLabPreview, DoResize, const Size&, rSize, void)
-{
- m_aSize = rSize;
+ CustomWidgetController::SetDrawingArea(pWidget);
}
-IMPL_LINK(SwLabPreview, DoPaint, weld::DrawingArea::draw_args, aPayload, void)
+void SwLabPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
{
- vcl::RenderContext& rRenderContext = aPayload.first;
-
- const long lOutWPix = m_aSize.Width();
- const long lOutHPix = m_aSize.Height();
+ const Size aSize(GetOutputSizePixel());
+ const long lOutWPix = aSize.Width();
+ const long lOutHPix = aSize.Height();
// Scale factor
const double fxpix = double(lOutWPix - (2 * (m_lLeftWidth + 15))) / double(lOutWPix);
@@ -276,7 +280,7 @@ IMPL_LINK(SwLabPreview, DoPaint, weld::DrawingArea::draw_args, aPayload, void)
void SwLabPreview::UpdateItem(const SwLabItem& rItem)
{
m_aItem = rItem;
- m_xDrawingArea->queue_draw();
+ Invalidate();
}
SwLabFormatPage::SwLabFormatPage(TabPageParent pParent, const SfxItemSet& rSet)
@@ -286,7 +290,7 @@ SwLabFormatPage::SwLabFormatPage(TabPageParent pParent, const SfxItemSet& rSet)
, bModified(false)
, m_xMakeFI(m_xBuilder->weld_label("make"))
, m_xTypeFI(m_xBuilder->weld_label("type"))
- , m_xPreview(new SwLabPreview(m_xBuilder->weld_drawing_area("preview")))
+ , m_xPreview(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreview))
, m_xHDistField(m_xBuilder->weld_metric_spin_button("hori", FUNIT_CM))
, m_xVDistField(m_xBuilder->weld_metric_spin_button("vert", FUNIT_CM))
, m_xWidthField(m_xBuilder->weld_metric_spin_button("width", FUNIT_CM))
@@ -355,7 +359,7 @@ IMPL_LINK_NOARG(SwLabFormatPage, PreviewHdl, Timer *, void)
aPreviewIdle.Stop();
ChangeMinMax();
FillItem( aItem );
- m_xPreview->UpdateItem( aItem );
+ m_aPreview.UpdateItem(aItem);
}
void SwLabFormatPage::ChangeMinMax()
diff --git a/sw/source/ui/envelp/labfmt.hxx b/sw/source/ui/envelp/labfmt.hxx
index 1be3737a1e0b..7415792f4642 100644
--- a/sw/source/ui/envelp/labfmt.hxx
+++ b/sw/source/ui/envelp/labfmt.hxx
@@ -22,15 +22,13 @@
#include "swuilabimp.hxx"
#include <labimg.hxx>
#include <vcl/idle.hxx>
+#include <vcl/customweld.hxx>
#include <vcl/weld.hxx>
class SwLabFormatPage;
-class SwLabPreview
+class SwLabPreview : public weld::CustomWidgetController
{
- std::unique_ptr<weld::DrawingArea> m_xDrawingArea;
-
- Size m_aSize;
Color m_aGrayColor;
OUString m_aHDistStr;
@@ -54,12 +52,12 @@ class SwLabPreview
SwLabItem m_aItem;
- DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void);
- DECL_LINK(DoResize, const Size& rSize, void);
+ virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
+ virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
public:
- explicit SwLabPreview(weld::DrawingArea* pDrawingArea);
+ SwLabPreview();
void UpdateItem(const SwLabItem& rItem);
};
@@ -70,9 +68,11 @@ class SwLabFormatPage : public SfxTabPage
SwLabItem aItem;
bool bModified;
+ SwLabPreview m_aPreview;
+
std::unique_ptr<weld::Label> m_xMakeFI;
std::unique_ptr<weld::Label> m_xTypeFI;
- std::unique_ptr<SwLabPreview> m_xPreview;
+ std::unique_ptr<weld::CustomWeld> m_xPreview;
std::unique_ptr<weld::MetricSpinButton> m_xHDistField;
std::unique_ptr<weld::MetricSpinButton> m_xVDistField;
std::unique_ptr<weld::MetricSpinButton> m_xWidthField;
diff --git a/sw/source/ui/misc/num.cxx b/sw/source/ui/misc/num.cxx
index 906d46d580f0..69e0261c494f 100644
--- a/sw/source/ui/misc/num.cxx
+++ b/sw/source/ui/misc/num.cxx
@@ -87,7 +87,7 @@ SwNumPositionTabPage::SwNumPositionTabPage(TabPageParent pParent, const SfxItemS
, m_xIndentAtFT(m_xBuilder->weld_label("indentat"))
, m_xIndentAtMF(m_xBuilder->weld_metric_spin_button("indentatmf", FUNIT_CM))
, m_xStandardPB(m_xBuilder->weld_button("standard"))
- , m_xPreviewWIN(new SwNumberingPreview(m_xBuilder->weld_drawing_area("preview")))
+ , m_xPreviewWIN(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWIN))
{
SetExchangeSupport();
@@ -131,7 +131,7 @@ SwNumPositionTabPage::SwNumPositionTabPage(TabPageParent pParent, const SfxItemS
m_xLevelLB->select_text(sEntry);
m_xRelativeCB->set_active(bLastRelative);
- m_xPreviewWIN->SetPositionMode();
+ m_aPreviewWIN.SetPositionMode();
}
SwNumPositionTabPage::~SwNumPositionTabPage()
@@ -380,7 +380,7 @@ void SwNumPositionTabPage::ActivatePage(const SfxItemSet& )
InitControls();
}
m_xRelativeCB->set_sensitive(1 != nActNumLvl);
- m_xPreviewWIN->queue_draw();
+ m_aPreviewWIN.Invalidate();
}
DeactivateRC SwNumPositionTabPage::DeactivatePage(SfxItemSet *_pSet)
@@ -437,7 +437,7 @@ void SwNumPositionTabPage::Reset( const SfxItemSet* rSet )
pActNum = new SwNumRule(*pSaveNum);
else if(*pSaveNum != *pActNum)
*pActNum = *pSaveNum;
- m_xPreviewWIN->SetNumRule(pActNum);
+ m_aPreviewWIN.SetNumRule(pActNum);
InitPosAndSpaceMode();
ShowControlsDependingOnPosAndSpaceMode();
InitControls();
@@ -517,7 +517,7 @@ void SwNumPositionTabPage::SetWrtShell(SwWrtShell* pSh)
m_xIndentAtMF->set_max(m_xIndentAtMF->normalize( nWidth ), FUNIT_TWIP );
const SwRect& rPrtRect = pWrtSh->GetAnyCurRect(CurRectType::Page);
- m_xPreviewWIN->SetPageWidth(rPrtRect.Width());
+ m_aPreviewWIN.SetPageWidth(rPrtRect.Width());
FieldUnit eMetric = ::GetDfltMetric( dynamic_cast<SwWebView*>( &pWrtSh->GetView()) != nullptr );
if(eMetric == FUNIT_MM)
{
@@ -872,8 +872,8 @@ IMPL_LINK_NOARG(SwNumPositionTabPage, StandardHdl, weld::Button&, void)
void SwNumPositionTabPage::SetModified()
{
bModified = true;
- m_xPreviewWIN->SetLevel(nActNumLvl);
- m_xPreviewWIN->queue_draw();
+ m_aPreviewWIN.SetLevel(nActNumLvl);
+ m_aPreviewWIN.Invalidate();
}
#endif
diff --git a/sw/source/ui/misc/outline.cxx b/sw/source/ui/misc/outline.cxx
index 8f225ec20ba2..7595495ba044 100644
--- a/sw/source/ui/misc/outline.cxx
+++ b/sw/source/ui/misc/outline.cxx
@@ -400,7 +400,7 @@ SwOutlineSettingsTabPage::SwOutlineSettingsTabPage(TabPageParent pPage,
, m_xPrefixED(m_xBuilder->weld_entry("prefix"))
, m_xSuffixED(m_xBuilder->weld_entry("suffix"))
, m_xStartEdit(m_xBuilder->weld_spin_button("startat"))
- , m_xPreviewWIN(new SwNumberingPreview(m_xBuilder->weld_drawing_area("preview")))
+ , m_xPreviewWIN(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWIN))
{
SetExchangeSupport();
@@ -723,8 +723,8 @@ void SwOutlineSettingsTabPage::SetWrtShell(SwWrtShell* pShell)
pNumRule = static_cast<SwOutlineTabDialog*>(GetDialogController())->GetNumRule();
pCollNames = static_cast<SwOutlineTabDialog*>(GetDialogController())->GetCollNames();
- m_xPreviewWIN->SetNumRule(pNumRule);
- m_xPreviewWIN->SetOutlineNames(pCollNames);
+ m_aPreviewWIN.SetNumRule(pNumRule);
+ m_aPreviewWIN.SetOutlineNames(pCollNames);
// set start value - nActLevel must be 1 here
sal_uInt16 nTmpLevel = lcl_BitToLevel(nActLevel);
const SwNumFormat& rNumFormat = pNumRule->Get( nTmpLevel );
@@ -1058,16 +1058,9 @@ void NumberingPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Re
rRenderContext.DrawOutDev(Point(0,0), aSize, Point(0,0), aSize, *pVDev);
}
-IMPL_LINK(SwNumberingPreview, DoResize, const Size&, rSize, void)
+void SwNumberingPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
{
- m_aSize = rSize;
-}
-
-IMPL_LINK(SwNumberingPreview, DoPaint, weld::DrawingArea::draw_args, aPayload, void)
-{
- vcl::RenderContext& rRenderContext = aPayload.first;
-
- const Size aSize(rRenderContext.PixelToLogic(m_aSize));
+ const Size aSize(rRenderContext.PixelToLogic(GetOutputSizePixel()));
ScopedVclPtrInstance<VirtualDevice> pVDev(rRenderContext);
pVDev->SetMapMode(rRenderContext.GetMapMode());
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 );
}
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 );