diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-04-20 11:06:07 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-04-22 21:29:36 +0200 |
commit | 60f3e4b843da89678e022eed837ee66e726b1920 (patch) | |
tree | 4cffea5d364e3ed9bd3e68c7b471f313c237a98e /starmath | |
parent | 4a7ebfea57094b914c4b1c3e46936dbf67dec499 (diff) |
place an intermediate class as parent for SfxTabPages
so a SfxTabPage can be parented by a vcl::Window or a welded native notebook tabpage.
That ways the same SfxTabPage can be used at the same time in both a native dialog
or a vcl dialog. The impl can be changed to the weld api, and when hosted in a native
dialog the vcl impl of that will be instantiated, while native otherwise. e.g.
print options appearing in print options dialog and general options.
This allows incremental changeover.
Change-Id: I6f1fed1e8d0898b01853bb878757bad41cbf9bba
Reviewed-on: https://gerrit.libreoffice.org/53193
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 'starmath')
-rw-r--r-- | starmath/inc/dialog.hxx | 29 | ||||
-rw-r--r-- | starmath/inc/smmod.hxx | 2 | ||||
-rw-r--r-- | starmath/inc/view.hxx | 2 | ||||
-rw-r--r-- | starmath/source/dialog.cxx | 95 | ||||
-rw-r--r-- | starmath/source/smmod.cxx | 4 | ||||
-rw-r--r-- | starmath/source/view.cxx | 2 | ||||
-rw-r--r-- | starmath/uiconfig/smath/ui/smathsettings.ui | 8 |
7 files changed, 60 insertions, 82 deletions
diff --git a/starmath/inc/dialog.hxx b/starmath/inc/dialog.hxx index cd860e5649b1..86d1753d974e 100644 --- a/starmath/inc/dialog.hxx +++ b/starmath/inc/dialog.hxx @@ -52,28 +52,27 @@ void SetFontStyle(const OUString &rStyleName, vcl::Font &rFont); class SmPrintOptionsTabPage : public SfxTabPage { - VclPtr<CheckBox> m_pTitle; - VclPtr<CheckBox> m_pText; - VclPtr<CheckBox> m_pFrame; - VclPtr<RadioButton> m_pSizeNormal; - VclPtr<RadioButton> m_pSizeScaled; - VclPtr<RadioButton> m_pSizeZoomed; - VclPtr<MetricField> m_pZoom; - VclPtr<CheckBox> m_pNoRightSpaces; - VclPtr<CheckBox> m_pSaveOnlyUsedSymbols; - VclPtr<CheckBox> m_pAutoCloseBrackets; - - DECL_LINK(SizeButtonClickHdl, Button *, void); + std::unique_ptr<weld::CheckButton> m_xTitle; + std::unique_ptr<weld::CheckButton> m_xText; + std::unique_ptr<weld::CheckButton> m_xFrame; + std::unique_ptr<weld::RadioButton> m_xSizeNormal; + std::unique_ptr<weld::RadioButton> m_xSizeScaled; + std::unique_ptr<weld::RadioButton> m_xSizeZoomed; + std::unique_ptr<weld::MetricSpinButton> m_xZoom; + std::unique_ptr<weld::CheckButton> m_xNoRightSpaces; + std::unique_ptr<weld::CheckButton> m_xSaveOnlyUsedSymbols; + std::unique_ptr<weld::CheckButton> m_xAutoCloseBrackets; + + DECL_LINK(SizeButtonClickHdl, weld::ToggleButton&, void); virtual bool FillItemSet(SfxItemSet* rSet) override; virtual void Reset(const SfxItemSet* rSet) override; public: - static VclPtr<SfxTabPage> Create(vcl::Window *pWindow, const SfxItemSet &rSet); + static VclPtr<SfxTabPage> Create(TabPageParent pWindow, const SfxItemSet &rSet); - SmPrintOptionsTabPage(vcl::Window *pParent, const SfxItemSet &rOptions); + SmPrintOptionsTabPage(TabPageParent pPage, const SfxItemSet &rOptions); virtual ~SmPrintOptionsTabPage() override; - virtual void dispose() override; }; /**************************************************************************/ diff --git a/starmath/inc/smmod.hxx b/starmath/inc/smmod.hxx index 81e21241264b..8080028aa44b 100644 --- a/starmath/inc/smmod.hxx +++ b/starmath/inc/smmod.hxx @@ -99,7 +99,7 @@ public: //virtual methods for options dialog virtual std::unique_ptr<SfxItemSet> CreateItemSet( sal_uInt16 nId ) override; virtual void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) override; - virtual VclPtr<SfxTabPage> CreateTabPage( sal_uInt16 nId, vcl::Window* pParent, const SfxItemSet& rSet ) override; + virtual VclPtr<SfxTabPage> CreateTabPage( sal_uInt16 nId, TabPageParent pParent, const SfxItemSet& rSet ) override; }; #define SM_MOD() ( static_cast<SmModule*>(SfxApplication::GetModule(SfxToolsModule::Math)) ) diff --git a/starmath/inc/view.hxx b/starmath/inc/view.hxx index 5950e9e7731e..7b6e741895bb 100644 --- a/starmath/inc/view.hxx +++ b/starmath/inc/view.hxx @@ -251,7 +251,7 @@ protected: void InsertFrom(SfxMedium &rMedium); virtual bool HasPrintOptionsPage() const override; - virtual VclPtr<SfxTabPage> CreatePrintOptionsPage(vcl::Window *pParent, + virtual VclPtr<SfxTabPage> CreatePrintOptionsPage(TabPageParent pParent, const SfxItemSet &rOptions) override; virtual void Deactivate(bool IsMDIActivate) override; virtual void Activate(bool IsMDIActivate) override; diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx index e1f744c053f3..267cdca90009 100644 --- a/starmath/source/dialog.cxx +++ b/starmath/source/dialog.cxx @@ -151,99 +151,78 @@ void SetFontStyle(const OUString &rStyleName, vcl::Font &rFont) rFont.SetWeight((nIndex & 0x2) ? WEIGHT_BOLD : WEIGHT_NORMAL); } -IMPL_LINK_NOARG( SmPrintOptionsTabPage, SizeButtonClickHdl, Button *, void ) +IMPL_LINK_NOARG(SmPrintOptionsTabPage, SizeButtonClickHdl, weld::ToggleButton&, void) { - m_pZoom->Enable(m_pSizeZoomed->IsChecked()); + m_xZoom->set_sensitive(m_xSizeZoomed->get_active()); } -SmPrintOptionsTabPage::SmPrintOptionsTabPage(vcl::Window* pParent, const SfxItemSet& rOptions) - : SfxTabPage(pParent, "SmathSettings", "modules/smath/ui/smathsettings.ui", &rOptions) +SmPrintOptionsTabPage::SmPrintOptionsTabPage(TabPageParent pPage, const SfxItemSet& rOptions) + : SfxTabPage(pPage, "modules/smath/ui/smathsettings.ui", "SmathSettings", &rOptions) + , m_xTitle(m_xBuilder->weld_check_button("title")) + , m_xText(m_xBuilder->weld_check_button("text")) + , m_xFrame(m_xBuilder->weld_check_button("frame")) + , m_xSizeNormal(m_xBuilder->weld_radio_button("sizenormal")) + , m_xSizeScaled(m_xBuilder->weld_radio_button("sizescaled")) + , m_xSizeZoomed(m_xBuilder->weld_radio_button("sizezoomed")) + , m_xZoom(m_xBuilder->weld_metric_spin_button("zoom", FUNIT_PERCENT)) + , m_xNoRightSpaces(m_xBuilder->weld_check_button("norightspaces")) + , m_xSaveOnlyUsedSymbols(m_xBuilder->weld_check_button("saveonlyusedsymbols")) + , m_xAutoCloseBrackets(m_xBuilder->weld_check_button("autoclosebrackets")) { - get( m_pTitle, "title"); - get( m_pText, "text"); - get( m_pFrame, "frame"); - get( m_pSizeNormal, "sizenormal"); - get( m_pSizeScaled, "sizescaled"); - get( m_pSizeZoomed, "sizezoomed"); - get( m_pZoom, "zoom"); - get( m_pNoRightSpaces, "norightspaces"); - get( m_pSaveOnlyUsedSymbols, "saveonlyusedsymbols"); - get( m_pAutoCloseBrackets, "autoclosebrackets"); - - m_pSizeNormal->SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl)); - m_pSizeScaled->SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl)); - m_pSizeZoomed->SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl)); + m_xSizeNormal->connect_toggled(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl)); + m_xSizeScaled->connect_toggled(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl)); + m_xSizeZoomed->connect_toggled(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl)); Reset(&rOptions); } SmPrintOptionsTabPage::~SmPrintOptionsTabPage() { - disposeOnce(); } -void SmPrintOptionsTabPage::dispose() -{ - m_pTitle.clear(); - m_pText.clear(); - m_pFrame.clear(); - m_pSizeNormal.clear(); - m_pSizeScaled.clear(); - m_pSizeZoomed.clear(); - m_pZoom.clear(); - m_pNoRightSpaces.clear(); - m_pSaveOnlyUsedSymbols.clear(); - m_pAutoCloseBrackets.clear(); - SfxTabPage::dispose(); -} - - bool SmPrintOptionsTabPage::FillItemSet(SfxItemSet* rSet) { sal_uInt16 nPrintSize; - if (m_pSizeNormal->IsChecked()) + if (m_xSizeNormal->get_active()) nPrintSize = PRINT_SIZE_NORMAL; - else if (m_pSizeScaled->IsChecked()) + else if (m_xSizeScaled->get_active()) nPrintSize = PRINT_SIZE_SCALED; else nPrintSize = PRINT_SIZE_ZOOMED; rSet->Put(SfxUInt16Item(GetWhich(SID_PRINTSIZE), nPrintSize)); - rSet->Put(SfxUInt16Item(GetWhich(SID_PRINTZOOM), sal::static_int_cast<sal_uInt16>(m_pZoom->GetValue()))); - rSet->Put(SfxBoolItem(GetWhich(SID_PRINTTITLE), m_pTitle->IsChecked())); - rSet->Put(SfxBoolItem(GetWhich(SID_PRINTTEXT), m_pText->IsChecked())); - rSet->Put(SfxBoolItem(GetWhich(SID_PRINTFRAME), m_pFrame->IsChecked())); - rSet->Put(SfxBoolItem(GetWhich(SID_NO_RIGHT_SPACES), m_pNoRightSpaces->IsChecked())); - rSet->Put(SfxBoolItem(GetWhich(SID_SAVE_ONLY_USED_SYMBOLS), m_pSaveOnlyUsedSymbols->IsChecked())); - rSet->Put(SfxBoolItem(GetWhich(SID_AUTO_CLOSE_BRACKETS), m_pAutoCloseBrackets->IsChecked())); + rSet->Put(SfxUInt16Item(GetWhich(SID_PRINTZOOM), sal::static_int_cast<sal_uInt16>(m_xZoom->get_value(FUNIT_PERCENT)))); + rSet->Put(SfxBoolItem(GetWhich(SID_PRINTTITLE), m_xTitle->get_active())); + rSet->Put(SfxBoolItem(GetWhich(SID_PRINTTEXT), m_xText->get_active())); + rSet->Put(SfxBoolItem(GetWhich(SID_PRINTFRAME), m_xFrame->get_active())); + rSet->Put(SfxBoolItem(GetWhich(SID_NO_RIGHT_SPACES), m_xNoRightSpaces->get_active())); + rSet->Put(SfxBoolItem(GetWhich(SID_SAVE_ONLY_USED_SYMBOLS), m_xSaveOnlyUsedSymbols->get_active())); + rSet->Put(SfxBoolItem(GetWhich(SID_AUTO_CLOSE_BRACKETS), m_xAutoCloseBrackets->get_active())); return true; } - void SmPrintOptionsTabPage::Reset(const SfxItemSet* rSet) { SmPrintSize ePrintSize = static_cast<SmPrintSize>(static_cast<const SfxUInt16Item &>(rSet->Get(GetWhich(SID_PRINTSIZE))).GetValue()); - m_pSizeNormal->Check(ePrintSize == PRINT_SIZE_NORMAL); - m_pSizeScaled->Check(ePrintSize == PRINT_SIZE_SCALED); - m_pSizeZoomed->Check(ePrintSize == PRINT_SIZE_ZOOMED); + m_xSizeNormal->set_active(ePrintSize == PRINT_SIZE_NORMAL); + m_xSizeScaled->set_active(ePrintSize == PRINT_SIZE_SCALED); + m_xSizeZoomed->set_active(ePrintSize == PRINT_SIZE_ZOOMED); - m_pZoom->Enable(m_pSizeZoomed->IsChecked()); + m_xZoom->set_sensitive(m_xSizeZoomed->get_active()); - m_pZoom->SetValue(static_cast<const SfxUInt16Item &>(rSet->Get(GetWhich(SID_PRINTZOOM))).GetValue()); + m_xZoom->set_value(static_cast<const SfxUInt16Item &>(rSet->Get(GetWhich(SID_PRINTZOOM))).GetValue(), FUNIT_PERCENT); - m_pTitle->Check(static_cast<const SfxBoolItem &>(rSet->Get(GetWhich(SID_PRINTTITLE))).GetValue()); - m_pText->Check(static_cast<const SfxBoolItem &>(rSet->Get(GetWhich(SID_PRINTTEXT))).GetValue()); - m_pFrame->Check(static_cast<const SfxBoolItem &>(rSet->Get(GetWhich(SID_PRINTFRAME))).GetValue()); - m_pNoRightSpaces->Check(static_cast<const SfxBoolItem &>(rSet->Get(GetWhich(SID_NO_RIGHT_SPACES))).GetValue()); - m_pSaveOnlyUsedSymbols->Check(static_cast<const SfxBoolItem &>(rSet->Get(GetWhich(SID_SAVE_ONLY_USED_SYMBOLS))).GetValue()); - m_pAutoCloseBrackets->Check(static_cast<const SfxBoolItem &>(rSet->Get(GetWhich(SID_AUTO_CLOSE_BRACKETS))).GetValue()); + m_xTitle->set_active(static_cast<const SfxBoolItem &>(rSet->Get(GetWhich(SID_PRINTTITLE))).GetValue()); + m_xNoRightSpaces->set_active(static_cast<const SfxBoolItem &>(rSet->Get(GetWhich(SID_NO_RIGHT_SPACES))).GetValue()); + m_xSaveOnlyUsedSymbols->set_active(static_cast<const SfxBoolItem &>(rSet->Get(GetWhich(SID_SAVE_ONLY_USED_SYMBOLS))).GetValue()); + m_xAutoCloseBrackets->set_active(static_cast<const SfxBoolItem &>(rSet->Get(GetWhich(SID_AUTO_CLOSE_BRACKETS))).GetValue()); } -VclPtr<SfxTabPage> SmPrintOptionsTabPage::Create(vcl::Window* pWindow, const SfxItemSet& rSet) +VclPtr<SfxTabPage> SmPrintOptionsTabPage::Create(TabPageParent pParent, const SfxItemSet& rSet) { - return VclPtr<SmPrintOptionsTabPage>::Create(pWindow, rSet).get(); + return VclPtr<SmPrintOptionsTabPage>::Create(pParent, rSet).get(); } void SmShowFont::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) diff --git a/starmath/source/smmod.cxx b/starmath/source/smmod.cxx index ba52877e6e21..3a4722da4b61 100644 --- a/starmath/source/smmod.cxx +++ b/starmath/source/smmod.cxx @@ -234,11 +234,11 @@ void SmModule::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) } } -VclPtr<SfxTabPage> SmModule::CreateTabPage( sal_uInt16 nId, vcl::Window* pParent, const SfxItemSet& rSet ) +VclPtr<SfxTabPage> SmModule::CreateTabPage( sal_uInt16 nId, TabPageParent pParent, const SfxItemSet& rSet ) { VclPtr<SfxTabPage> pRet; if(nId == SID_SM_TP_PRINTOPTIONS) - pRet = SmPrintOptionsTabPage::Create( pParent, rSet ); + pRet = SmPrintOptionsTabPage::Create( TabPageParent(pParent.pParent), rSet ); return pRet; } diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index d7a52d82caa3..819aaec2da13 100644 --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -1260,7 +1260,7 @@ bool SmViewShell::HasPrintOptionsPage() const return true; } -VclPtr<SfxTabPage> SmViewShell::CreatePrintOptionsPage(vcl::Window *pParent, +VclPtr<SfxTabPage> SmViewShell::CreatePrintOptionsPage(TabPageParent pParent, const SfxItemSet &rOptions) { return SmPrintOptionsTabPage::Create(pParent, rOptions); diff --git a/starmath/uiconfig/smath/ui/smathsettings.ui b/starmath/uiconfig/smath/ui/smathsettings.ui index b306831b33d3..f2b989a1e9f3 100644 --- a/starmath/uiconfig/smath/ui/smathsettings.ui +++ b/starmath/uiconfig/smath/ui/smathsettings.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.20.4 --> <interface domain="sm"> <requires lib="gtk+" version="3.18"/> <object class="GtkAdjustment" id="adjustment1"> @@ -132,7 +132,6 @@ <property name="xalign">0</property> <property name="active">True</property> <property name="draw_indicator">True</property> - <property name="group">sizescaled</property> </object> <packing> <property name="expand">False</property> @@ -149,7 +148,7 @@ <property name="use_underline">True</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> - <property name="group">sizezoomed</property> + <property name="group">sizenormal</property> </object> <packing> <property name="expand">False</property> @@ -180,9 +179,10 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="zoom:0%"> + <object class="GtkSpinButton" id="zoom"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="activates_default">True</property> <property name="adjustment">adjustment1</property> </object> <packing> |