diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-02-08 20:43:30 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-02-10 15:20:26 +0100 |
commit | abfdfe6ac1bfc917d1693874f9dec80167e0806f (patch) | |
tree | add0fa41f3d148ca9efaf844ae19552a2a504fb3 /svx | |
parent | 56f79ad5d70226ca64423044c0ba92e265776802 (diff) |
weld SvxFmTbxCtlRecTotal label item window
and SvxFmTbxCtlRecText label item window
and SvxFmTbxCtlRecFromText label item window
Change-Id: I5c5bbdacfe7e69abd44b9a548deadbf6c4d2a7d0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88283
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/UIConfig_svx.mk | 1 | ||||
-rw-r--r-- | svx/inc/pch/precompiled_svx.hxx | 4 | ||||
-rw-r--r-- | svx/source/form/tbxform.cxx | 94 | ||||
-rw-r--r-- | svx/source/inc/tbxform.hxx | 3 | ||||
-rw-r--r-- | svx/source/tbxctrls/grafctrl.cxx | 7 | ||||
-rw-r--r-- | svx/uiconfig/ui/labelbox.ui | 23 |
6 files changed, 87 insertions, 45 deletions
diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk index 69a7e7ea6e92..48f8b24c3e09 100644 --- a/svx/UIConfig_svx.mk +++ b/svx/UIConfig_svx.mk @@ -75,6 +75,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\ svx/uiconfig/ui/imapmenu \ svx/uiconfig/ui/interimdockparent \ svx/uiconfig/ui/interimparent \ + svx/uiconfig/ui/labelbox \ svx/uiconfig/ui/lightingwindow \ svx/uiconfig/ui/linkwarndialog \ svx/uiconfig/ui/measurewidthbar \ diff --git a/svx/inc/pch/precompiled_svx.hxx b/svx/inc/pch/precompiled_svx.hxx index 335be47a3561..c463eccb9b4a 100644 --- a/svx/inc/pch/precompiled_svx.hxx +++ b/svx/inc/pch/precompiled_svx.hxx @@ -13,7 +13,7 @@ manual changes will be rewritten by the next run of update_pch.sh (which presumably also fixes all possible problems, so it's usually better to use it). - Generated on 2020-02-07 12:03:14 using: + Generated on 2020-02-08 20:53:08 using: ./bin/update_pch svx svx --cutoff=3 --exclude:system --exclude:module --include:local If after updating build fails, use the following command to locate conflicting headers: @@ -82,11 +82,11 @@ #include <vcl/customweld.hxx> #include <vcl/dllapi.h> #include <vcl/dockwin.hxx> +#include <vcl/edit.hxx> #include <vcl/errcode.hxx> #include <vcl/errinf.hxx> #include <vcl/event.hxx> #include <vcl/field.hxx> -#include <vcl/fixed.hxx> #include <vcl/font.hxx> #include <vcl/gdimtf.hxx> #include <vcl/graph.hxx> diff --git a/svx/source/form/tbxform.cxx b/svx/source/form/tbxform.cxx index ab80e13aa4ba..94e00643b897 100644 --- a/svx/source/form/tbxform.cxx +++ b/svx/source/form/tbxform.cxx @@ -21,14 +21,13 @@ #include <svl/intitem.hxx> #include <svl/eitem.hxx> #include <svl/stritem.hxx> +#include <sfx2/InterimItemWindow.hxx> #include <sfx2/dispatch.hxx> #include <vcl/event.hxx> #include <vcl/toolbox.hxx> -#include <vcl/fixed.hxx> #include <vcl/settings.hxx> #include <formtoolbars.hxx> - #include <svx/dialmgr.hxx> #include <svx/svxids.hrc> #include <svx/strings.hrc> @@ -143,23 +142,57 @@ SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxCtlRecText, SfxBoolItem ); SvxFmTbxCtlRecText::SvxFmTbxCtlRecText( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :SfxToolBoxControl( nSlotId, nId, rTbx ) { + rTbx.SetItemWindowNonInteractive(nId, true); } SvxFmTbxCtlRecText::~SvxFmTbxCtlRecText() { } +class LabelItemWindow final : public InterimItemWindow +{ +private: + std::unique_ptr<weld::Label> m_xLabel; +public: + LabelItemWindow(vcl::Window *pParent, const OUString& rLabel) + : InterimItemWindow(pParent, "svx/ui/labelbox.ui", "LabelBox") + , m_xLabel(m_xBuilder->weld_label("label")) + { + m_xLabel->set_label(rLabel); + Size aSize(m_xLabel->get_preferred_size()); + aSize.AdjustWidth(12); + m_xLabel->set_size_request(aSize.Width(), -1); + + SetSizePixel(m_xLabel->get_preferred_size()); + + m_xLabel->set_toolbar_background(); + } + + void set_label(const OUString& rLabel) + { + m_xLabel->set_label(rLabel); + } + + virtual void dispose() override + { + m_xLabel.reset(); + InterimItemWindow::dispose(); + } + + virtual ~LabelItemWindow() override + { + disposeOnce(); + } +}; + VclPtr<vcl::Window> SvxFmTbxCtlRecText::CreateItemWindow( vcl::Window* pParent ) { OUString aText(SvxResId(RID_STR_REC_TEXT)); - VclPtrInstance<FixedText> pFixedText( pParent ); - Size aSize( pFixedText->GetTextWidth( aText ), pFixedText->GetTextHeight( ) ); - pFixedText->SetText( aText ); - aSize.AdjustWidth(6 ); - pFixedText->SetSizePixel( aSize ); - pFixedText->SetBackground(Wallpaper(COL_TRANSPARENT)); - - return pFixedText; + VclPtrInstance<LabelItemWindow> xFixedText(pParent, aText); + + xFixedText->Show(); + + return xFixedText; } SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxCtlRecFromText, SfxBoolItem ); @@ -167,57 +200,48 @@ SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxCtlRecFromText, SfxBoolItem ); SvxFmTbxCtlRecFromText::SvxFmTbxCtlRecFromText( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :SfxToolBoxControl( nSlotId, nId, rTbx ) { + rTbx.SetItemWindowNonInteractive(nId, true); } - SvxFmTbxCtlRecFromText::~SvxFmTbxCtlRecFromText() { } - VclPtr<vcl::Window> SvxFmTbxCtlRecFromText::CreateItemWindow( vcl::Window* pParent ) { OUString aText(SvxResId(RID_STR_REC_FROM_TEXT)); - VclPtrInstance<FixedText> pFixedText( pParent, WB_CENTER ); - Size aSize( pFixedText->GetTextWidth( aText ), pFixedText->GetTextHeight( ) ); - aSize.AdjustWidth(12 ); - pFixedText->SetText( aText ); - pFixedText->SetSizePixel( aSize ); - pFixedText->SetBackground(Wallpaper(COL_TRANSPARENT)); - return pFixedText.get(); + VclPtrInstance<LabelItemWindow> xFixedText(pParent, aText); + + xFixedText->Show(); + + return xFixedText; } SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxCtlRecTotal, SfxStringItem ); - SvxFmTbxCtlRecTotal::SvxFmTbxCtlRecTotal( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) - :SfxToolBoxControl( nSlotId, nId, rTbx ) - ,pFixedText( nullptr ) + : SfxToolBoxControl( nSlotId, nId, rTbx ) { + rTbx.SetItemWindowNonInteractive(nId, true); } - SvxFmTbxCtlRecTotal::~SvxFmTbxCtlRecTotal() { } - VclPtr<vcl::Window> SvxFmTbxCtlRecTotal::CreateItemWindow( vcl::Window* pParent ) { - pFixedText.reset(VclPtr<FixedText>::Create( pParent )); OUString const aSample("123456"); - Size aSize( pFixedText->GetTextWidth( aSample ), pFixedText->GetTextHeight( ) ); - aSize.AdjustWidth(12 ); - pFixedText->SetSizePixel( aSize ); - pFixedText->SetBackground(); - pFixedText->SetPaintTransparent(true); - return pFixedText; -} + m_xFixedText.reset(VclPtr<LabelItemWindow>::Create(pParent, aSample)); + m_xFixedText->set_label(""); + m_xFixedText->Show(); + + return m_xFixedText; +} void SvxFmTbxCtlRecTotal::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) { - // setting the FixedText if (GetSlotId() != SID_FM_RECORD_TOTAL) return; @@ -228,9 +252,7 @@ void SvxFmTbxCtlRecTotal::StateChanged( sal_uInt16 nSID, SfxItemState eState, co else aText = "?"; - pFixedText->SetText( aText ); - pFixedText->Update(); - pFixedText->Flush(); + m_xFixedText->set_label(aText); SfxToolBoxControl::StateChanged( nSID, eState,pState ); } diff --git a/svx/source/inc/tbxform.hxx b/svx/source/inc/tbxform.hxx index 95546f3ce80e..f436a91b2275 100644 --- a/svx/source/inc/tbxform.hxx +++ b/svx/source/inc/tbxform.hxx @@ -77,10 +77,11 @@ public: virtual VclPtr<vcl::Window> CreateItemWindow( vcl::Window* pParent ) override; }; +class LabelItemWindow; class SvxFmTbxCtlRecTotal : public SfxToolBoxControl { - VclPtr<FixedText> pFixedText; + VclPtr<LabelItemWindow> m_xFixedText; public: SFX_DECL_TOOLBOX_CONTROL(); diff --git a/svx/source/tbxctrls/grafctrl.cxx b/svx/source/tbxctrls/grafctrl.cxx index dbbea77c8d37..0fcf01de5d32 100644 --- a/svx/source/tbxctrls/grafctrl.cxx +++ b/svx/source/tbxctrls/grafctrl.cxx @@ -22,7 +22,6 @@ #include <i18nutil/unicode.hxx> #include <vcl/toolbox.hxx> #include <vcl/field.hxx> -#include <vcl/fixed.hxx> #include <vcl/idle.hxx> #include <vcl/svapp.hxx> #include <svl/intitem.hxx> @@ -215,11 +214,7 @@ ImplGrafControl::ImplGrafControl( { OUString sResId(ImplGetRID(rCmd)); mxImage->set_from_icon_name(sResId); -#if 0 - // we want to see the background of the toolbox, not of the FixedImage or Control - maImage->SetBackground( Wallpaper( COL_TRANSPARENT ) ); - SetBackground( Wallpaper( COL_TRANSPARENT ) ); -#endif + mxImage->set_toolbar_background(); SetBackground( Wallpaper() ); // transparent background diff --git a/svx/uiconfig/ui/labelbox.ui b/svx/uiconfig/ui/labelbox.ui new file mode 100644 index 000000000000..5f07290f56ee --- /dev/null +++ b/svx/uiconfig/ui/labelbox.ui @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.22.1 --> +<interface domain="svx"> + <requires lib="gtk+" version="3.18"/> + <object class="GtkBox" id="LabelBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="spacing">4</property> + <child> + <object class="GtkLabel" id="label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + </object> +</interface> |