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

weld SwLabPreview

Change-Id: I710eacd28f3b6c38890145cf82eeca8bec6ae1f6
Reviewed-on: https://gerrit.libreoffice.org/53328Tested-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 6440f3cd
......@@ -422,9 +422,6 @@
<glade-widget-class title="NUP Preview" name="vcllo-ShowNupOrderWindow"
generic-name="NUP Preview" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="Label Preview" name="swuilo-SwLabPreview"
generic-name="Label Preview" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="Envelope Preview" name="swuilo-SwEnvPreview"
generic-name="Envelope Preview" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
......
......@@ -166,12 +166,12 @@ SfxTabPage::SfxTabPage(vcl::Window *pParent, const OString& rID, const OUString&
}
SfxTabPage::SfxTabPage(TabPageParent pParent, const OUString& rUIXMLDescription, const OString& rID, const SfxItemSet *rAttrSet)
: TabPage(Application::GetDefDialogParent()) //just drag this along hidden in this scenario
: TabPage(pParent.pPage ? Application::GetDefDialogParent() : pParent.pParent.get()) //just drag this along hidden in this scenario
, pSet ( rAttrSet )
, bHasExchangeSupport ( false )
, pImpl ( new TabPageImpl )
, m_xBuilder(pParent.pPage ? Application::CreateBuilder(pParent.pPage, rUIXMLDescription)
: Application::CreateInterimBuilder(pParent.pParent, rUIXMLDescription))
: Application::CreateInterimBuilder(this, rUIXMLDescription))
, m_xContainer(m_xBuilder->weld_container(rID))
{
}
......
......@@ -272,21 +272,6 @@ SwLabPage::SwLabPage(vcl::Window* pParent, const SfxItemSet& rSet)
m_pTypeBox->SetSelectHdl(LINK(this, SwLabPage, TypeHdl ));
InitDatabaseBox();
size_t nLstGroup = 0;
const size_t nCount = GetParentSwLabDlg()->Makes().size();
for(size_t i = 0; i < nCount; ++i)
{
OUString& rStr = GetParentSwLabDlg()->Makes()[i];
m_pMakeBox->InsertEntry( rStr );
if ( rStr == aItem.m_aLstMake)
nLstGroup = i;
}
m_pMakeBox->SelectEntryPos( nLstGroup );
m_pMakeBox->GetSelectHdl().Call(*m_pMakeBox);
}
SwLabPage::~SwLabPage()
......@@ -526,6 +511,23 @@ bool SwLabPage::FillItemSet(SfxItemSet* rSet)
void SwLabPage::Reset(const SfxItemSet* rSet)
{
m_pMakeBox->Clear();
size_t nLstGroup = 0;
const size_t nCount = GetParentSwLabDlg()->Makes().size();
for(size_t i = 0; i < nCount; ++i)
{
OUString& rStr = GetParentSwLabDlg()->Makes()[i];
m_pMakeBox->InsertEntry( rStr );
if ( rStr == aItem.m_aLstMake)
nLstGroup = i;
}
m_pMakeBox->SelectEntryPos( nLstGroup );
m_pMakeBox->GetSelectHdl().Call(*m_pMakeBox);
aItem = static_cast<const SwLabItem&>( rSet->Get(FN_LABEL));
OUString sDBName = aItem.m_sDBName;
......
This diff is collapsed.
......@@ -26,8 +26,11 @@
class SwLabFormatPage;
class SwLabPreview : public vcl::Window
class SwLabPreview
{
std::unique_ptr<weld::DrawingArea> m_xDrawingArea;
Size m_aSize;
Color m_aGrayColor;
OUString m_aHDistStr;
......@@ -51,43 +54,42 @@ class SwLabPreview : public vcl::Window
SwLabItem m_aItem;
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
virtual Size GetOptimalSize() const override;
DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void);
DECL_LINK(DoResize, const Size& rSize, void);
public:
explicit SwLabPreview(vcl::Window* pParent);
explicit SwLabPreview(weld::DrawingArea* pDrawingArea);
void UpdateItem(const SwLabItem& rItem);
};
class SwLabFormatPage : public SfxTabPage
{
VclPtr<FixedText> m_pMakeFI;
VclPtr<FixedText> m_pTypeFI;
VclPtr<SwLabPreview> m_pPreview;
VclPtr<MetricField> m_pHDistField;
VclPtr<MetricField> m_pVDistField;
VclPtr<MetricField> m_pWidthField;
VclPtr<MetricField> m_pHeightField;
VclPtr<MetricField> m_pLeftField;
VclPtr<MetricField> m_pUpperField;
VclPtr<NumericField> m_pColsField;
VclPtr<NumericField> m_pRowsField;
VclPtr<MetricField> m_pPWidthField;
VclPtr<MetricField> m_pPHeightField;
VclPtr<PushButton> m_pSavePB;
Idle aPreviewIdle;
bool bModified;
SwLabItem aItem;
DECL_LINK( ModifyHdl, Edit&, void );
SwLabItem aItem;
bool bModified;
std::unique_ptr<weld::Label> m_xMakeFI;
std::unique_ptr<weld::Label> m_xTypeFI;
std::unique_ptr<SwLabPreview> m_xPreview;
std::unique_ptr<weld::MetricSpinButton> m_xHDistField;
std::unique_ptr<weld::MetricSpinButton> m_xVDistField;
std::unique_ptr<weld::MetricSpinButton> m_xWidthField;
std::unique_ptr<weld::MetricSpinButton> m_xHeightField;
std::unique_ptr<weld::MetricSpinButton> m_xLeftField;
std::unique_ptr<weld::MetricSpinButton> m_xUpperField;
std::unique_ptr<weld::SpinButton> m_xColsField;
std::unique_ptr<weld::SpinButton> m_xRowsField;
std::unique_ptr<weld::MetricSpinButton> m_xPWidthField;
std::unique_ptr<weld::MetricSpinButton> m_xPHeightField;
std::unique_ptr<weld::Button> m_xSavePB;
DECL_LINK( ModifyHdl, weld::SpinButton&, void );
DECL_LINK( MetricModifyHdl, weld::MetricSpinButton&, void );
DECL_LINK( PreviewHdl, Timer *, void );
DECL_LINK( LoseFocusHdl, Control&, void );
DECL_LINK( SaveHdl, Button*, void );
DECL_LINK( SaveHdl, weld::Button&, void );
void ChangeMinMax();
......@@ -95,9 +97,8 @@ class SwLabFormatPage : public SfxTabPage
using TabPage::DeactivatePage;
public:
SwLabFormatPage(vcl::Window* pParent, const SfxItemSet& rSet);
SwLabFormatPage(TabPageParent pParent, const SfxItemSet& rSet);
virtual ~SwLabFormatPage() override;
virtual void dispose() override;
static VclPtr<SfxTabPage> Create(TabPageParent pParent, const SfxItemSet* rSet);
......@@ -107,14 +108,14 @@ public:
virtual bool FillItemSet(SfxItemSet* rSet) override;
virtual void Reset(const SfxItemSet* rSet) override;
SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetParentDialog());}
SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetTabDialog());}
};
class SwSaveLabelDlg : public weld::GenericDialogController
{
bool bSuccess;
VclPtr<SwLabFormatPage> pLabPage;
SwLabRec& rLabRec;
VclPtr<SwLabDlg> m_pLabDialog;
SwLabRec& rLabRec;
std::unique_ptr<weld::ComboBoxText> m_xMakeCB;
std::unique_ptr<weld::Entry> m_xTypeED;
......@@ -127,7 +128,7 @@ class SwSaveLabelDlg : public weld::GenericDialogController
void Modify();
public:
SwSaveLabelDlg(SwLabFormatPage* pParent, SwLabRec& rRec);
SwSaveLabelDlg(SwLabDlg* pParent, SwLabRec& rRec);
virtual ~SwSaveLabelDlg() override;
void SetLabel(const OUString& rMake, const OUString& rType)
......
......@@ -31,6 +31,16 @@
#define GETFLDVAL(rField) (rField).Denormalize((rField).GetValue(FUNIT_TWIP))
#define SETFLDVAL(rField, lValue) (rField).SetValue((rField).Normalize(lValue), FUNIT_TWIP)
inline int getfldval(weld::MetricSpinButton& rField)
{
return rField.denormalize(rField.get_value(FUNIT_TWIP));
}
inline void setfldval(weld::MetricSpinButton& rField, int lValue)
{
rField.set_value(rField.normalize(lValue), FUNIT_TWIP);
}
#endif // INCLUDED_SW_SOURCE_UIBASE_INC_LABIMP_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -40,6 +40,7 @@ class SfxViewFrame;
// switch a metric
SW_DLLPUBLIC void SetMetric(MetricFormatter& rCtrl, FieldUnit eUnit);
SW_DLLPUBLIC void SetMetric(weld::MetricSpinButton& rCtrl, FieldUnit eUnit);
// fill BoxInfo attribute
SW_DLLPUBLIC void PrepareBoxInfo(SfxItemSet& rSet, const SwWrtShell& rSh);
......
......@@ -96,6 +96,14 @@ void SetMetric(MetricFormatter& rCtrl, FieldUnit eUnit)
rCtrl.SetMax(nMax, FUNIT_TWIP);
}
void SetMetric(weld::MetricSpinButton& rCtrl, FieldUnit eUnit)
{
int nMin, nMax;
rCtrl.get_range(nMin, nMax, FUNIT_TWIP);
rCtrl.set_unit(eUnit);
rCtrl.set_range(nMin, nMax, FUNIT_TWIP);
}
// Set boxinfo attribute
void PrepareBoxInfo(SfxItemSet& rSet, const SwWrtShell& rSh)
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.4 -->
<interface domain="sw">
<requires lib="gtk+" version="3.0"/>
<requires lib="gtk+" version="3.18"/>
<object class="GtkAdjustment" id="adjustment1">
<property name="lower">1</property>
<property name="upper">100</property>
......@@ -101,6 +101,7 @@
<object class="GtkSpinButton" id="cols">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activates_default">True</property>
<property name="adjustment">adjustment1</property>
</object>
<packing>
......@@ -137,6 +138,7 @@
<object class="GtkSpinButton" id="rows">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activates_default">True</property>
<property name="adjustment">adjustment2</property>
</object>
<packing>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment