Kaydet (Commit) eeaf6dee authored tarafından Caolán McNamara's avatar Caolán McNamara

rework custom widget welding to enable inheritence

Change-Id: I0d391b3fe9d2d610ae41e2a03cd2e195a866e103
Reviewed-on: https://gerrit.libreoffice.org/54681Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst c10928e7
......@@ -24,6 +24,7 @@
#include <vcl/button.hxx>
#include <vcl/fixed.hxx>
#include <vcl/lstbox.hxx>
#include <vcl/customweld.hxx>
#include <vcl/weld.hxx>
#include <sfx2/basedlgs.hxx>
#include <svl/itemset.hxx>
......@@ -41,21 +42,20 @@ namespace svx
struct SvxShowCharSetItem;
}
class SvxShowText
class SvxShowText : public weld::CustomWidgetController
{
private:
std::unique_ptr<weld::DrawingArea> m_xDrawingArea;
VclPtr<VirtualDevice> m_xVirDev;
Size m_aSize;
OUString m_sText;
long mnY;
bool mbCenter;
vcl::Font m_aFont;
DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void);
DECL_LINK(DoResize, const Size& rSize, void);
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
virtual void Resize() override;
virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
public:
SvxShowText(weld::Builder& rBuilder, const OString& rId, const VclPtr<VirtualDevice>& rVirDev);
SvxShowText(const VclPtr<VirtualDevice>& rVirDev);
void SetFont(const vcl::Font& rFont);
vcl::Font GetFont() const { return m_aFont; }
......@@ -63,8 +63,7 @@ public:
OUString GetText() const { return m_sText; }
void SetCentered(bool bCenter) { mbCenter = bCenter; }
void queue_draw() { m_xDrawingArea->queue_draw(); }
Size get_preferred_size() const { return m_xDrawingArea->get_preferred_size(); }
Size get_preferred_size() const { return GetDrawingArea()->get_preferred_size(); }
};
/** The main purpose of this dialog is to enable the use of characters
......@@ -86,6 +85,10 @@ private:
std::deque<OUString> maFavCharFontList;
uno::Reference< uno::XComponentContext > mxContext;
SvxCharView m_aRecentCharView[16];
SvxCharView m_aFavCharView[16];
SvxShowText m_aShowChar;
std::unique_ptr<weld::Button> m_xOKBtn;
std::unique_ptr<weld::Label> m_xFontText;
std::unique_ptr<weld::ComboBoxText> m_xFontLB;
......@@ -98,11 +101,13 @@ private:
std::unique_ptr<weld::Label> m_xCharName;
std::unique_ptr<weld::Widget> m_xRecentGrid;
std::unique_ptr<weld::Widget> m_xFavGrid;
std::unique_ptr<SvxShowText> m_xShowChar;
std::unique_ptr<SvxCharView> m_xRecentCharView[16];
std::unique_ptr<SvxCharView> m_xFavCharView[16];
std::unique_ptr<weld::CustomWeld> m_xShowChar;
std::unique_ptr<weld::CustomWeld> m_xRecentCharView[16];
std::unique_ptr<weld::CustomWeld> m_xFavCharView[16];
std::unique_ptr<SvxShowCharSet> m_xShowSet;
std::unique_ptr<weld::CustomWeld> m_xShowSetArea;
std::unique_ptr<SvxSearchCharSet> m_xSearchSet;
std::unique_ptr<weld::CustomWeld> m_xSearchSetArea;
std::unique_ptr<SfxAllItemSet> m_xOutputSet;
......
......@@ -50,6 +50,8 @@ private:
bool bWordWrapTextEnabled;
bool bFitToSizeEnabled;
RectCtl m_aCtlPosition;
std::unique_ptr<weld::Widget> m_xDrawingText;
std::unique_ptr<weld::Widget> m_xCustomShapeText;
std::unique_ptr<weld::CheckButton> m_xTsbAutoGrowWidth;
......@@ -64,7 +66,7 @@ private:
std::unique_ptr<weld::MetricSpinButton> m_xMtrFldTop;
std::unique_ptr<weld::MetricSpinButton> m_xMtrFldBottom;
std::unique_ptr<weld::Frame> m_xFlPosition;
std::unique_ptr<RectCtl> m_xCtlPosition;
std::unique_ptr<weld::CustomWeld> m_xCtlPosition;
std::unique_ptr<weld::CheckButton> m_xTsbFullWidth;
DECL_LINK(ClickFullWidthHdl_Impl, weld::Button&, void);
......
......@@ -63,6 +63,7 @@ SvxTextAttrPage::SvxTextAttrPage(TabPageParent pPage, const SfxItemSet& rInAttrs
, bAutoGrowHeightEnabled(false)
, bWordWrapTextEnabled(false)
, bFitToSizeEnabled(false)
, m_aCtlPosition(this)
, m_xDrawingText(m_xBuilder->weld_widget("drawingtext"))
, m_xCustomShapeText(m_xBuilder->weld_widget("customshapetext"))
, m_xTsbAutoGrowWidth(m_xBuilder->weld_check_button("TSB_AUTOGROW_WIDTH"))
......@@ -77,10 +78,10 @@ SvxTextAttrPage::SvxTextAttrPage(TabPageParent pPage, const SfxItemSet& rInAttrs
, m_xMtrFldTop(m_xBuilder->weld_metric_spin_button("MTR_FLD_TOP", FUNIT_CM))
, m_xMtrFldBottom(m_xBuilder->weld_metric_spin_button("MTR_FLD_BOTTOM", FUNIT_CM))
, m_xFlPosition(m_xBuilder->weld_frame("FL_POSITION"))
, m_xCtlPosition(new RectCtl(*m_xBuilder, "CTL_POSITION", this))
, m_xCtlPosition(new weld::CustomWeld(*m_xBuilder, "CTL_POSITION", m_aCtlPosition))
, m_xTsbFullWidth(m_xBuilder->weld_check_button("TSB_FULL_WIDTH"))
{
m_xCtlPosition->SetControlSettings(RectPoint::MM, 240, 100);
m_aCtlPosition.SetControlSettings(RectPoint::MM, 240, 100);
FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs );
SetFieldUnit( *m_xMtrFldLeft, eFUnit );
......@@ -264,15 +265,15 @@ void SvxTextAttrPage::Reset( const SfxItemSet* rAttrs )
m_xTsbFullWidth->set_state(TRISTATE_TRUE);
}
m_xCtlPosition->SetActualRP( eRP );
m_aCtlPosition.SetActualRP( eRP );
}
else
{
// VertAdjust or HorAdjust is not unequivocal
m_xCtlPosition->Reset();
m_aCtlPosition.Reset();
m_xCtlPosition->SetState(CTL_STATE::NOVERT);
m_xCtlPosition->DoCompletelyDisable(true);
m_aCtlPosition.SetState(CTL_STATE::NOVERT);
m_aCtlPosition.DoCompletelyDisable(true);
m_xTsbFullWidth->set_state(TRISTATE_INDET);
m_xFlPosition->set_sensitive( false );
......@@ -389,7 +390,7 @@ bool SvxTextAttrPage::FillItemSet( SfxItemSet* rAttrs)
}
// centered
RectPoint eRP = m_xCtlPosition->GetActualRP();
RectPoint eRP = m_aCtlPosition.GetActualRP();
SdrTextVertAdjust eTVA, eOldTVA;
SdrTextHorzAdjust eTHA, eOldTHA;
......@@ -417,7 +418,7 @@ bool SvxTextAttrPage::FillItemSet( SfxItemSet* rAttrs)
}
// #103516# Do not change values if adjust controls were disabled.
bool bIsDisabled(m_xCtlPosition->IsCompletelyDisabled());
bool bIsDisabled(m_aCtlPosition.IsCompletelyDisabled());
if(!bIsDisabled)
{
......@@ -591,21 +592,21 @@ IMPL_LINK_NOARG(SvxTextAttrPage, ClickFullWidthHdl_Impl, weld::Button&, void)
if (IsTextDirectionLeftToRight())
{
// Move text anchor to horizontal middle axis.
switch( m_xCtlPosition->GetActualRP() )
switch( m_aCtlPosition.GetActualRP() )
{
case RectPoint::LT:
case RectPoint::RT:
m_xCtlPosition->SetActualRP( RectPoint::MT );
m_aCtlPosition.SetActualRP( RectPoint::MT );
break;
case RectPoint::LM:
case RectPoint::RM:
m_xCtlPosition->SetActualRP( RectPoint::MM );
m_aCtlPosition.SetActualRP( RectPoint::MM );
break;
case RectPoint::LB:
case RectPoint::RB:
m_xCtlPosition->SetActualRP( RectPoint::MB );
m_aCtlPosition.SetActualRP( RectPoint::MB );
break;
default: ;//prevent warning
}
......@@ -613,21 +614,21 @@ IMPL_LINK_NOARG(SvxTextAttrPage, ClickFullWidthHdl_Impl, weld::Button&, void)
else
{
// Move text anchor to vertical middle axis.
switch( m_xCtlPosition->GetActualRP() )
switch( m_aCtlPosition.GetActualRP() )
{
case RectPoint::LT:
case RectPoint::LB:
m_xCtlPosition->SetActualRP( RectPoint::LM );
m_aCtlPosition.SetActualRP( RectPoint::LM );
break;
case RectPoint::MT:
case RectPoint::MB:
m_xCtlPosition->SetActualRP( RectPoint::MM );
m_aCtlPosition.SetActualRP( RectPoint::MM );
break;
case RectPoint::RT:
case RectPoint::RB:
m_xCtlPosition->SetActualRP( RectPoint::RM );
m_aCtlPosition.SetActualRP( RectPoint::RM );
break;
default: ;//prevent warning
}
......
......@@ -22,14 +22,13 @@
#include <sfx2/tbxctrl.hxx>
#include <sfx2/dllapi.h>
#include <vcl/customweld.hxx>
#include <vcl/weld.hxx>
class SFX2_DLLPUBLIC SvxCharView
class SFX2_DLLPUBLIC SvxCharView : public weld::CustomWidgetController
{
private:
VclPtr<VirtualDevice> mxVirDev;
std::unique_ptr<weld::DrawingArea> mxDrawingArea;
Size m_aSize;
long mnY;
Point maPosition;
vcl::Font maFont;
......@@ -40,34 +39,29 @@ private:
Link<SvxCharView*, void> maClearClickHdl;
Link<SvxCharView*, void> maClearAllClickHdl;
DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void);
DECL_LINK(DoResize, const Size& rSize, void);
DECL_LINK(DoMouseButtonDown, const MouseEvent&, void);
DECL_LINK(DoKeyDown, const KeyEvent&, bool);
DECL_LINK(DoGetFocus, weld::Widget&, void);
DECL_LINK(DoLoseFocus, weld::Widget&, void);
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
virtual void Resize() override;
virtual void MouseButtonDown(const MouseEvent&) override;
virtual void GetFocus() override;
virtual void LoseFocus() override;
virtual bool KeyInput(const KeyEvent&) override;
virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
public:
SvxCharView(weld::Builder& rBuilder, const OString& rId, const VclPtr<VirtualDevice>& rVirDev);
SvxCharView(const VclPtr<VirtualDevice>& rVirDev);
void SetFont( const vcl::Font& rFont );
vcl::Font GetFont() const { return maFont; }
void SetText( const OUString& rText );
OUString GetText() const { return m_sText; }
void Show() { mxDrawingArea->show(); }
void Hide() { mxDrawingArea->hide(); }
void SetHasInsert( bool bInsert );
void InsertCharToDoc();
void createContextMenu();
void grab_focus() { mxDrawingArea->grab_focus(); }
void queue_draw() { mxDrawingArea->queue_draw(); }
Size get_preferred_size() const { return mxDrawingArea->get_preferred_size(); }
void connect_focus_in(const Link<weld::Widget&, void>& rLink) { mxDrawingArea->connect_focus_in(rLink); }
void connect_focus_out(const Link<weld::Widget&, void>& rLink) { mxDrawingArea->connect_focus_out(rLink); }
Size get_preferred_size() const { return GetDrawingArea()->get_preferred_size(); }
void connect_focus_in(const Link<weld::Widget&, void>& rLink);
void connect_focus_out(const Link<weld::Widget&, void>& rLink);
void setMouseClickHdl(const Link<SvxCharView*,void> &rLink);
void setClearClickHdl(const Link<SvxCharView*,void> &rLink);
......
......@@ -25,6 +25,7 @@
#include <sfx2/objsh.hxx>
#include <vcl/idle.hxx>
#include <vcl/customweld.hxx>
#include <vcl/weld.hxx>
#include <sfx2/doctempl.hxx>
#include <o3tl/typed_flags_set.hxx>
......@@ -57,6 +58,13 @@ namespace o3tl
class SFX2_DLLPUBLIC SfxNewFileDialog : public weld::GenericDialogController
{
private:
Idle m_aPrevIdle;
SfxNewFileDialogMode m_nFlags;
SfxDocumentTemplates m_aTemplates;
SfxObjectShellLock m_xDocShell;
std::unique_ptr<SfxPreviewWin_Impl> m_xPreviewController;
std::unique_ptr<weld::TreeView> m_xRegionLb;
std::unique_ptr<weld::TreeView> m_xTemplateLb;
std::unique_ptr<weld::CheckButton> m_xTextStyleCB;
......@@ -66,13 +74,8 @@ private:
std::unique_ptr<weld::CheckButton> m_xMergeStyleCB;
std::unique_ptr<weld::Button> m_xLoadFilePB;
std::unique_ptr<weld::Expander> m_xMoreBt;
std::unique_ptr<SfxPreviewWin_Impl> m_xPreviewWin;
std::unique_ptr<weld::CustomWeld> m_xPreviewWin;
std::unique_ptr<weld::Label> m_xAltTitleFt;
Idle m_aPrevIdle;
SfxNewFileDialogMode m_nFlags;
SfxDocumentTemplates m_aTemplates;
SfxObjectShellLock m_xDocShell;
DECL_LINK( Update, Timer *, void );
......
......@@ -35,6 +35,7 @@
#include <vcl/outdev.hxx>
#include <vcl/metric.hxx>
#include <vcl/vclptr.hxx>
#include <vcl/customweld.hxx>
#include <vcl/weld.hxx>
#include <vcl/window.hxx>
#include <vcl/textview.hxx>
......@@ -56,19 +57,15 @@ namespace svx
class SvxShowCharSetAcc;
}
class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxShowCharSet
class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxShowCharSet : public weld::CustomWidgetController
{
protected:
VclPtr<VirtualDevice> mxVirDev;
std::unique_ptr<weld::DrawingArea> mxDrawingArea;
std::unique_ptr<weld::ScrolledWindow> mxScrollArea;
vcl::Font maFont;
Size maSize;
std::unique_ptr<weld::ScrolledWindow> mxScrollArea;
public:
SvxShowCharSet(weld::Builder& rBuilder, const OString& rDrawingId,
const OString& rScrollId, const VclPtr<VirtualDevice>& rVirDev);
virtual ~SvxShowCharSet();
SvxShowCharSet(weld::ScrolledWindow* pScrollArea, const VclPtr<VirtualDevice>& rVirDev);
virtual ~SvxShowCharSet() override;
virtual void RecalculateFont(vcl::RenderContext& rRenderContext);
......@@ -106,25 +103,22 @@ public:
void Show() { mxScrollArea->show(); }
void Hide() { mxScrollArea->hide(); }
bool HasFocus() const { return mxDrawingArea->has_focus(); }
void GrabFocus() { mxDrawingArea->grab_focus(); }
bool IsEnabled() const { return mxDrawingArea->get_sensitive(); }
bool IsVisible() const { return mxDrawingArea->get_visible(); }
const Size& GetSize() const { return maSize; }
uno::Reference<css::accessibility::XAccessible> getAccessibleParent() { return mxDrawingArea->get_accessible_parent(); }
uno::Reference<css::accessibility::XAccessible> getAccessibleParent() { return GetDrawingArea()->get_accessible_parent(); }
private:
DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void);
DECL_LINK(DoResize, const Size& rSize, void);
DECL_LINK(DoMouseButtonDown, const MouseEvent& rMEvt, void);
DECL_LINK(DoMouseMove, const MouseEvent& rMEvt, void);
DECL_LINK(DoMouseButtonUp, const MouseEvent& rMEvt, void);
DECL_LINK(DoKeyDown, const KeyEvent& rKEvt, bool);
DECL_LINK(DoGetFocus, weld::Widget&, void);
DECL_LINK(DoLoseFocus, weld::Widget&, void);
css::uno::Reference<css::accessibility::XAccessible> CreateAccessible();
virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
virtual void Resize() override;
virtual void MouseButtonDown(const MouseEvent& rMEvt) override;
virtual void MouseMove(const MouseEvent& rMEvt) override;
virtual void MouseButtonUp(const MouseEvent& rMEvt) override;
virtual void GetFocus() override;
virtual void LoseFocus() override;
virtual bool KeyInput(const KeyEvent&) override;
virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
virtual FactoryFunction GetUITestFactory() const override;
protected:
typedef std::map<sal_Int32, std::shared_ptr<svx::SvxShowCharSetItem> > ItemsMap;
......
......@@ -24,6 +24,7 @@
#include <svx/svxdllapi.h>
#include <svx/rectenum.hxx>
#include <vcl/graph.hxx>
#include <vcl/customweld.hxx>
#include <vcl/weld.hxx>
#include <svx/xtable.hxx>
#include <rtl/ref.hxx>
......@@ -146,10 +147,9 @@ public:
bool IsCompletelyDisabled() const { return mbCompleteDisable; }
};
class SAL_WARN_UNUSED SVX_DLLPUBLIC RectCtl
class SAL_WARN_UNUSED SVX_DLLPUBLIC RectCtl : public weld::CustomWidgetController
{
private:
std::unique_ptr<weld::DrawingArea> m_xControl;
VclPtr<SvxTabPage> m_pPage;
SVX_DLLPRIVATE void InitSettings(vcl::RenderContext& rRenderContext);
......@@ -157,11 +157,13 @@ private:
SVX_DLLPRIVATE BitmapEx& GetRectBitmap();
SVX_DLLPRIVATE void Resize_Impl();
RectCtl(const RectCtl&) = delete;
RectCtl& operator=(const RectCtl&) = delete;
protected:
rtl::Reference<RectCtlAccessibleContext> pAccContext;
sal_uInt16 nBorderWidth;
sal_uInt16 nRadius;
Size m_aSize;
Point aPtLT, aPtMT, aPtRT;
Point aPtLM, aPtMM, aPtRM;
Point aPtLB, aPtMB, aPtRB;
......@@ -178,19 +180,19 @@ protected:
Point GetApproxLogPtFromPixPt( const Point& rRoughPixelPoint ) const;
public:
RectCtl(weld::Builder& rBuilder, const OString& rDrawingId, SvxTabPage* pPage,
RectPoint eRpt = RectPoint::MM, sal_uInt16 nBorder = 200, sal_uInt16 nCircle = 80);
RectCtl(SvxTabPage* pPage, RectPoint eRpt = RectPoint::MM, sal_uInt16 nBorder = 200, sal_uInt16 nCircle = 80);
void SetControlSettings(RectPoint eRpt, sal_uInt16 nBorder, sal_uInt16 nCircl);
~RectCtl();
virtual ~RectCtl() override;
DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void);
DECL_LINK(DoResize, const Size& rSize, void);
DECL_LINK(DoMouseButtonDown, const MouseEvent&, void);
DECL_LINK(DoKeyDown, const KeyEvent&, bool);
DECL_LINK(DoGetFocus, weld::Widget&, void);
DECL_LINK(DoLoseFocus, weld::Widget&, void);
DECL_LINK(MarkToResetSettings, weld::Widget&, void);
DECL_LINK(DoFocusRect, weld::Widget&, tools::Rectangle);
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
virtual void Resize() override;
virtual void MouseButtonDown(const MouseEvent&) override;
virtual bool KeyInput(const KeyEvent&) override;
virtual void GetFocus() override;
virtual void LoseFocus() override;
virtual tools::Rectangle GetFocusRect() override;
virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
virtual void StyleUpdated() override;
void Reset();
RectPoint GetActualRP() const { return eRP;}
......@@ -203,19 +205,14 @@ public:
tools::Rectangle CalculateFocusRectangle() const;
tools::Rectangle CalculateFocusRectangle( RectPoint eRectPoint ) const;
css::uno::Reference<css::accessibility::XAccessible> getAccessibleParent() { return m_xControl->get_accessible_parent(); }
css::uno::Reference<css::accessibility::XAccessible> CreateAccessible();
a11yrelationset get_accessible_relation_set() { return m_xControl->get_accessible_relation_set(); }
css::uno::Reference<css::accessibility::XAccessible> getAccessibleParent() { return GetDrawingArea()->get_accessible_parent(); }
virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
a11yrelationset get_accessible_relation_set() { return GetDrawingArea()->get_accessible_relation_set(); }
RectPoint GetApproxRPFromPixPt( const css::awt::Point& rPixelPoint ) const;
bool IsCompletelyDisabled() const { return mbCompleteDisable; }
void DoCompletelyDisable(bool bNew);
bool IsVisible() const { return m_xControl->get_visible(); }
bool HasFocus() const { return m_xControl->has_focus(); }
void GrabFocus() { m_xControl->grab_focus(); }
Size GetSize() const { return m_aSize; }
};
/*************************************************************************
......
......@@ -21,6 +21,7 @@
#include <vcl/ctrl.hxx>
#include <vcl/graph.hxx>
#include <vcl/customweld.hxx>
#include <vcl/weld.hxx>
#include <svx/svxdllapi.h>
......@@ -124,31 +125,19 @@ public:
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
};
class SVX_DLLPUBLIC SvxGraphCtrl
class SVX_DLLPUBLIC SvxGraphCtrl : public weld::CustomWidgetController
{
MapMode aMap100;
Graphic aGraphic;
Size aGraphSize;
Size maSize;
std::unique_ptr<weld::DrawingArea> mxDrawingArea;
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:
SvxGraphCtrl(weld::Builder& rBuilder, const OString& rDrawingId);
virtual ~SvxGraphCtrl();
SvxGraphCtrl();
virtual ~SvxGraphCtrl() override;
void SetGraphic( const Graphic& rGraphic );
const Size& GetSize() const { return maSize; }
void set_size_request(int nWidth, int nHeight)
{
mxDrawingArea->set_size_request(nWidth, nHeight);
}
};
class GraphCtrlView : public SdrView
......
......@@ -53,8 +53,7 @@ class ScrollBar;
class SVX_DLLPUBLIC SvxSearchCharSet : public SvxShowCharSet
{
public:
SvxSearchCharSet(weld::Builder& rBuilder, const OString& rDrawingId,
const OString& rScrollId, const VclPtr<VirtualDevice> &rDevice);
SvxSearchCharSet(weld::ScrolledWindow* pScrolledWindow, const VclPtr<VirtualDevice> &rDevice);
virtual ~SvxSearchCharSet() override;
virtual void RecalculateFont(vcl::RenderContext& rRenderContext) override;
......@@ -77,9 +76,9 @@ private:
//to uniquely identify each appended element
std::unordered_map<sal_Int32, sal_UCS4> m_aItemList;
private:
virtual void DrawChars_Impl(vcl::RenderContext& rRenderContext, int n1, int n2) override;
DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void);
DECL_LINK(DoKeyDown, const KeyEvent&, bool);
virtual void DrawChars_Impl(vcl::RenderContext& rRenderContext, int n1, int n2) override;
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
virtual bool KeyInput(const KeyEvent& rKEvt) override;
};
#endif
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_VCL_CUSTOMWELD_HXX
#define INCLUDED_VCL_CUSTOMWELD_HXX
#include <vcl/weld.hxx>
namespace weld
{
class VCL_DLLPUBLIC CustomWidgetController
{
private:
Size m_aSize;
weld::DrawingArea* m_pDrawingArea;
public:
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) = 0;
virtual void Resize() {}
virtual void MouseButtonDown(const MouseEvent&) {}
virtual void MouseMove(const MouseEvent&) {}
virtual void MouseButtonUp(const MouseEvent&) {}
virtual void GetFocus() {}
virtual void LoseFocus() {}
virtual void StyleUpdated() { Invalidate(); }
virtual bool KeyInput(const KeyEvent&) { return false; }
virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible()
{
return css::uno::Reference<css::accessibility::XAccessible>();
}
virtual tools::Rectangle GetFocusRect() { return tools::Rectangle(); }
virtual FactoryFunction GetUITestFactory() const { return nullptr; }
Size GetOutputSizePixel() const { return m_aSize; }
void SetOutputSizePixel(const Size& rSize) { m_aSize = rSize; }
virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) { m_pDrawingArea = pDrawingArea; }
weld::DrawingArea* GetDrawingArea() const { return m_pDrawingArea; }
void Invalidate() { m_pDrawingArea->queue_draw(); }
void Invalidate(const tools::Rectangle& rRect)
{
m_pDrawingArea->queue_draw_area(rRect.Left(), rRect.Top(), rRect.GetWidth(),
rRect.GetHeight());
}
void Show() { m_pDrawingArea->show(); }
void Hide() { m_pDrawingArea->hide(); }
void GrabFocus() { m_pDrawingArea->grab_focus(); }
bool HasFocus() const { return m_pDrawingArea->has_focus(); }
bool IsVisible() const { return m_pDrawingArea->get_visible(); }
bool IsEnabled() const { return m_pDrawingArea->get_sensitive(); }
void grab_add() { m_pDrawingArea->grab_add(); }
void grab_remove() { m_pDrawingArea->grab_remove(); }
void set_size_request(int nWidth, int nHeight)
{
m_pDrawingArea->set_size_request(nWidth, nHeight);
}
virtual ~CustomWidgetController();
};
class VCL_DLLPUBLIC CustomWeld
{
private:
weld::CustomWidgetController& m_rWidgetController;
std::unique_ptr<weld::DrawingArea> m_xDrawingArea;
DECL_LINK(DoResize, const Size& rSize, void);
DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void);
DECL_LINK(DoMouseButtonDown, const MouseEvent&, void);
DECL_LINK(DoMouseMove, const MouseEvent&, void);
DECL_LINK(DoMouseButtonUp, const MouseEvent&, void);
DECL_LINK(DoGetFocus, weld::Widget&, void);
DECL_LINK(DoLoseFocus, weld::Widget&, void);
DECL_LINK(DoKeyPress, const KeyEvent&, bool);
DECL_LINK(DoFocusRect, weld::Widget&, tools::Rectangle);
DECL_LINK(DoStyleUpdated, weld::Widget&, void);
public:
CustomWeld(weld::Builder& rBuilder, const OString& rDrawingId,
CustomWidgetController& rWidgetController);
void queue_draw() { m_xDrawingArea->queue_draw(); }
void queue_draw_area(int x, int y, int width, int height)
{
m_xDrawingArea->queue_draw_area(x, y, width, height);
}
void set_size_request(int nWidth, int nHeight)
{
m_xDrawingArea->set_size_request(nWidth, nHeight);
}
void show() { m_xDrawingArea->show(); }
void set_margin_top(int nMargin) { m_xDrawingArea->set_margin_top(nMargin); }
void set_margin_bottom(int nMargin) { m_xDrawingArea->set_margin_bottom(nMargin); }
};
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -49,7 +49,7 @@ SdPhotoAlbumDialog::SdPhotoAlbumDialog(weld::Window* pWindow, SdDrawDocument* pA
, m_xDownBtn(m_xBuilder->weld_button("down_btn"))
, m_xRemoveBtn(m_xBuilder->weld_button("rem_btn"))
, m_xImagesLst(m_xBuilder->weld_tree_view("images_tree"))
, m_xImg(new SvxGraphCtrl(*m_xBuilder, "preview_img"))
, m_xImg(new weld::CustomWeld(*m_xBuilder, "preview_img", m_aImg))
, m_xInsTypeCombo(m_xBuilder->weld_combo_box_text("opt_combo"))
, m_xASRCheck(m_xBuilder->weld_check_button("asr_check"))
, m_xASRCheckCrop(m_xBuilder->weld_check_button("asr_check_crop"))
......@@ -583,7 +583,7 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, DownHdl, weld::Button&, void)
IMPL_LINK_NOARG(SdPhotoAlbumDialog, RemoveHdl, weld::Button&, void)
{
m_xImagesLst->remove(m_xImagesLst->get_selected_index());
m_xImg->SetGraphic(Graphic());
m_aImg.SetGraphic(Graphic());
EnableDisableButtons();
}
......@@ -635,11 +635,11 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, SelectHdl, weld::TreeView&, void)
aBmp.Scale( nYRatio, nYRatio );
aBmp.Convert( BmpConversion::N24Bit );
m_xImg->SetGraphic(Graphic(aBmp));
m_aImg.SetGraphic(Graphic(aBmp));
}
else
{
m_xImg->SetGraphic(Graphic());
m_aImg.SetGraphic(Graphic());
}
EnableDisableButtons();
}
......
......@@ -48,6 +48,8 @@ private:
SdDrawDocument* m_pDoc;
GraphicFilter* m_pGraphicFilter;
SvxGraphCtrl m_aImg;
std::unique_ptr<weld::Button> m_xCancelBtn;
std::unique_ptr<weld::Button> m_xCreateBtn;
std::unique_ptr<weld::Button> m_xAddBtn;
......@@ -55,7 +57,7 @@ private:
std::unique_ptr<weld::Button> m_xDownBtn;
std::unique_ptr<weld::Button> m_xRemoveBtn;
std::unique_ptr<weld::TreeView> m_xImagesLst;
std::unique_ptr<SvxGraphCtrl> m_xImg;
std::unique_ptr<weld::CustomWeld> m_xImg;
std::unique_ptr<weld::ComboBoxText> m_xInsTypeCombo;
std::unique_ptr<weld::CheckButton> m_xASRCheck;
std::unique_ptr<weld::CheckButton> m_xASRCheckCrop;
......
......@@ -39,8 +39,8 @@ SdVectorizeDlg::SdVectorizeDlg(weld::Window* pParent, const Bitmap& rBmp, ::sd::