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

weld SwLabPrtPage

Change-Id: I64ae3826298ad210ec095256e4364b607684abca
Reviewed-on: https://gerrit.libreoffice.org/53327Tested-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 fb55ab7c
...@@ -27,35 +27,31 @@ ...@@ -27,35 +27,31 @@
#include <cmdid.h> #include <cmdid.h>
SwLabPrtPage::SwLabPrtPage(vcl::Window* pParent, const SfxItemSet& rSet) SwLabPrtPage::SwLabPrtPage(TabPageParent pParent, const SfxItemSet& rSet)
: SfxTabPage(pParent, "LabelOptionsPage", : SfxTabPage(pParent, "modules/swriter/ui/labeloptionspage.ui", "LabelOptionsPage", &rSet)
"modules/swriter/ui/labeloptionspage.ui", &rSet)
, pPrinter(nullptr) , pPrinter(nullptr)
, m_xPageButton(m_xBuilder->weld_radio_button("entirepage"))
, m_xSingleButton(m_xBuilder->weld_radio_button("singlelabel"))
, m_xSingleGrid(m_xBuilder->weld_widget("singlegrid"))
, m_xPrinterFrame(m_xBuilder->weld_widget("printerframe"))
, m_xColField(m_xBuilder->weld_spin_button("cols"))
, m_xRowField(m_xBuilder->weld_spin_button("rows"))
, m_xSynchronCB(m_xBuilder->weld_check_button("synchronize"))
, m_xPrinterInfo(m_xBuilder->weld_label("printername"))
, m_xPrtSetup(m_xBuilder->weld_button("setup"))
{ {
get(m_pPageButton, "entirepage");
get(m_pSingleButton, "singlelabel");
get(m_pSingleGrid, "singlegrid");
get(m_pColField, "cols");
get(m_pRowField, "rows");
get(m_pSynchronCB, "synchronize");
get(m_pPrinterFrame, "printerframe");
get(m_pPrinterInfo, "printername");
get(m_pPrtSetup, "setup");
SetExchangeSupport(); SetExchangeSupport();
// Install handlers // Install handlers
Link<Button*,void> aLk = LINK(this, SwLabPrtPage, CountHdl); Link<weld::Button&,void> aLk = LINK(this, SwLabPrtPage, CountHdl);
m_pPageButton->SetClickHdl( aLk ); m_xPageButton->connect_clicked( aLk );
m_pSingleButton->SetClickHdl( aLk ); m_xSingleButton->connect_clicked( aLk );
m_xPrtSetup->connect_clicked( aLk );
m_pPrtSetup->SetClickHdl( aLk );
SvtCommandOptions aCmdOpts; SvtCommandOptions aCmdOpts;
if ( aCmdOpts.Lookup( if (aCmdOpts.Lookup(SvtCommandOptions::CMDOPTION_DISABLED, "Print"))
SvtCommandOptions::CMDOPTION_DISABLED,
"Print" ) )
{ {
m_pPrinterFrame->Hide(); m_xPrinterFrame->hide();
} }
} }
...@@ -67,21 +63,12 @@ SwLabPrtPage::~SwLabPrtPage() ...@@ -67,21 +63,12 @@ SwLabPrtPage::~SwLabPrtPage()
void SwLabPrtPage::dispose() void SwLabPrtPage::dispose()
{ {
pPrinter.disposeAndClear(); pPrinter.disposeAndClear();
m_pPageButton.clear();
m_pSingleButton.clear();
m_pSingleGrid.clear();
m_pPrinterFrame.clear();
m_pColField.clear();
m_pRowField.clear();
m_pSynchronCB.clear();
m_pPrinterInfo.clear();
m_pPrtSetup.clear();
SfxTabPage::dispose(); SfxTabPage::dispose();
} }
IMPL_LINK( SwLabPrtPage, CountHdl, Button *, pButton, void ) IMPL_LINK( SwLabPrtPage, CountHdl, weld::Button&, rButton, void )
{ {
if (pButton == m_pPrtSetup) if (&rButton == m_xPrtSetup.get())
{ {
// Call printer setup // Call printer setup
if (!pPrinter) if (!pPrinter)
...@@ -90,24 +77,24 @@ IMPL_LINK( SwLabPrtPage, CountHdl, Button *, pButton, void ) ...@@ -90,24 +77,24 @@ IMPL_LINK( SwLabPrtPage, CountHdl, Button *, pButton, void )
PrinterSetupDialog aDlg(GetFrameWeld()); PrinterSetupDialog aDlg(GetFrameWeld());
aDlg.SetPrinter(pPrinter); aDlg.SetPrinter(pPrinter);
aDlg.execute(); aDlg.execute();
GrabFocus(); rButton.grab_focus();
m_pPrinterInfo->SetText(pPrinter->GetName()); m_xPrinterInfo->set_label(pPrinter->GetName());
return; return;
} }
const bool bEnable = pButton == m_pSingleButton; const bool bEnable = &rButton == m_xSingleButton.get();
m_pSingleGrid->Enable(bEnable); m_xSingleGrid->set_sensitive(bEnable);
m_pSynchronCB->Enable(!bEnable); m_xSynchronCB->set_sensitive(!bEnable);
OSL_ENSURE(!bEnable || pButton == m_pPageButton, "NewButton?" ); OSL_ENSURE(!bEnable || &rButton == m_xPageButton.get(), "NewButton?" );
if ( bEnable ) if ( bEnable )
{ {
m_pColField->GrabFocus(); m_xColField->grab_focus();
} }
} }
VclPtr<SfxTabPage> SwLabPrtPage::Create(TabPageParent pParent, const SfxItemSet* rSet) VclPtr<SfxTabPage> SwLabPrtPage::Create(TabPageParent pParent, const SfxItemSet* rSet)
{ {
return VclPtr<SwLabPrtPage>::Create( pParent.pParent, *rSet ); return VclPtr<SwLabPrtPage>::Create(pParent, *rSet );
} }
void SwLabPrtPage::ActivatePage( const SfxItemSet& rSet ) void SwLabPrtPage::ActivatePage( const SfxItemSet& rSet )
...@@ -125,10 +112,10 @@ DeactivateRC SwLabPrtPage::DeactivatePage(SfxItemSet* _pSet) ...@@ -125,10 +112,10 @@ DeactivateRC SwLabPrtPage::DeactivatePage(SfxItemSet* _pSet)
void SwLabPrtPage::FillItem(SwLabItem& rItem) void SwLabPrtPage::FillItem(SwLabItem& rItem)
{ {
rItem.m_bPage = m_pPageButton->IsChecked(); rItem.m_bPage = m_xPageButton->get_active();
rItem.m_nCol = static_cast<sal_Int32>(m_pColField->GetValue()); rItem.m_nCol = m_xColField->get_value();
rItem.m_nRow = static_cast<sal_Int32>(m_pRowField->GetValue()); rItem.m_nRow = m_xRowField->get_value();
rItem.m_bSynchron = m_pSynchronCB->IsChecked() && m_pSynchronCB->IsEnabled(); rItem.m_bSynchron = m_xSynchronCB->get_active() && m_xSynchronCB->get_sensitive();
} }
bool SwLabPrtPage::FillItemSet(SfxItemSet* rSet) bool SwLabPrtPage::FillItemSet(SfxItemSet* rSet)
...@@ -146,35 +133,32 @@ void SwLabPrtPage::Reset(const SfxItemSet* ) ...@@ -146,35 +133,32 @@ void SwLabPrtPage::Reset(const SfxItemSet* )
SwLabItem aItem; SwLabItem aItem;
GetParentSwLabDlg()->GetLabItem(aItem); GetParentSwLabDlg()->GetLabItem(aItem);
m_pColField->SetValue (aItem.m_nCol); m_xColField->set_value(aItem.m_nCol);
m_pRowField->SetValue (aItem.m_nRow); m_xRowField->set_value(aItem.m_nRow);
if (aItem.m_bPage) if (aItem.m_bPage)
{ {
m_pPageButton->Check(); m_xPageButton->set_active(true);
m_pPageButton->GetClickHdl().Call(m_pPageButton); CountHdl(*m_xPageButton);
} }
else else
{ {
m_pSingleButton->GetClickHdl().Call(m_pSingleButton); CountHdl(*m_xSingleButton);
m_pSingleButton->Check(); m_xSingleButton->set_active(true);
} }
if (pPrinter) if (pPrinter)
{ {
// show printer // show printer
m_pPrinterInfo->SetText(pPrinter->GetName()); m_xPrinterInfo->set_label(pPrinter->GetName());
} }
else else
m_pPrinterInfo->SetText(Printer::GetDefaultPrinterName()); m_xPrinterInfo->set_label(Printer::GetDefaultPrinterName());
m_pColField->SetMax(aItem.m_nCols);
m_pRowField->SetMax(aItem.m_nRows);
m_pColField->SetLast(m_pColField->GetMax()); m_xColField->set_max(aItem.m_nCols);
m_pRowField->SetLast(m_pRowField->GetMax()); m_xRowField->set_max(aItem.m_nRows);
m_pSynchronCB->Check(aItem.m_bSynchron); m_xSynchronCB->set_active(aItem.m_bSynchron);
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -32,18 +32,17 @@ class SwLabPrtPage : public SfxTabPage ...@@ -32,18 +32,17 @@ class SwLabPrtPage : public SfxTabPage
{ {
VclPtr<Printer> pPrinter; // for the shaft setting - unfortunately VclPtr<Printer> pPrinter; // for the shaft setting - unfortunately
VclPtr<RadioButton> m_pPageButton; std::unique_ptr<weld::RadioButton> m_xPageButton;
VclPtr<RadioButton> m_pSingleButton; std::unique_ptr<weld::RadioButton> m_xSingleButton;
VclPtr<VclContainer> m_pSingleGrid; std::unique_ptr<weld::Widget> m_xSingleGrid;
VclPtr<VclContainer> m_pPrinterFrame; std::unique_ptr<weld::Widget> m_xPrinterFrame;
VclPtr<NumericField> m_pColField; std::unique_ptr<weld::SpinButton> m_xColField;
VclPtr<NumericField> m_pRowField; std::unique_ptr<weld::SpinButton> m_xRowField;
VclPtr<CheckBox> m_pSynchronCB; std::unique_ptr<weld::CheckButton> m_xSynchronCB;
std::unique_ptr<weld::Label> m_xPrinterInfo;
std::unique_ptr<weld::Button> m_xPrtSetup;
VclPtr<FixedText> m_pPrinterInfo; DECL_LINK( CountHdl, weld::Button&, void );
VclPtr<PushButton> m_pPrtSetup;
DECL_LINK( CountHdl, Button *, void );
SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetTabDialog());} SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetTabDialog());}
...@@ -51,7 +50,7 @@ class SwLabPrtPage : public SfxTabPage ...@@ -51,7 +50,7 @@ class SwLabPrtPage : public SfxTabPage
using TabPage::DeactivatePage; using TabPage::DeactivatePage;
public: public:
SwLabPrtPage(vcl::Window* pParent, const SfxItemSet& rSet); SwLabPrtPage(TabPageParent pParent, const SfxItemSet& rSet);
virtual ~SwLabPrtPage() override; virtual ~SwLabPrtPage() override;
virtual void dispose() override; virtual void dispose() override;
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.4 -->
<interface domain="sw"> <interface domain="sw">
<!-- interface-requires gtk+ 3.0 --> <requires lib="gtk+" version="3.0"/>
<object class="GtkAdjustment" id="adjustment1"> <object class="GtkAdjustment" id="adjustment1">
<property name="lower">1</property> <property name="lower">1</property>
<property name="upper">100</property> <property name="upper">100</property>
...@@ -8,6 +9,12 @@ ...@@ -8,6 +9,12 @@
<property name="step_increment">1</property> <property name="step_increment">1</property>
<property name="page_increment">10</property> <property name="page_increment">10</property>
</object> </object>
<object class="GtkAdjustment" id="adjustment2">
<property name="lower">1</property>
<property name="upper">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkBox" id="LabelOptionsPage"> <object class="GtkBox" id="LabelOptionsPage">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
...@@ -42,13 +49,11 @@ ...@@ -42,13 +49,11 @@
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="active">True</property> <property name="active">True</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
<property name="group">singlelabel</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">0</property> <property name="top_attach">0</property>
<property name="width">2</property> <property name="width">2</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
...@@ -66,8 +71,6 @@ ...@@ -66,8 +71,6 @@
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">1</property> <property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
...@@ -84,16 +87,14 @@ ...@@ -84,16 +87,14 @@
<object class="GtkLabel" id="label4"> <object class="GtkLabel" id="label4">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="labeloptionspage|label4">Colu_mn</property> <property name="label" translatable="yes" context="labeloptionspage|label4">Colu_mn</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">cols</property> <property name="mnemonic_widget">cols</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">0</property> <property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
...@@ -105,16 +106,12 @@ ...@@ -105,16 +106,12 @@
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="top_attach">0</property> <property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">0</property> <property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
...@@ -126,45 +123,37 @@ ...@@ -126,45 +123,37 @@
<object class="GtkLabel" id="label5"> <object class="GtkLabel" id="label5">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="labeloptionspage|label5">Ro_w</property> <property name="label" translatable="yes" context="labeloptionspage|label5">Ro_w</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">rows</property> <property name="mnemonic_widget">rows</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">0</property> <property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkSpinButton" id="rows"> <object class="GtkSpinButton" id="rows">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="adjustment">adjustment1</property> <property name="adjustment">adjustment2</property>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="top_attach">0</property> <property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="top_attach">0</property> <property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="top_attach">1</property> <property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
...@@ -181,7 +170,6 @@ ...@@ -181,7 +170,6 @@
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">2</property> <property name="top_attach">2</property>
<property name="width">2</property> <property name="width">2</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
</object> </object>
...@@ -236,8 +224,6 @@ ...@@ -236,8 +224,6 @@
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="top_attach">0</property> <property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
...@@ -245,16 +231,14 @@ ...@@ -245,16 +231,14 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="labeloptionspage|printername">Printer Name</property> <property name="label" translatable="yes" context="labeloptionspage|printername">Printer Name</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">setup</property> <property name="mnemonic_widget">setup</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">0</property> <property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
</object> </object>
......
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