diff options
-rw-r--r-- | include/svx/fillctrl.hxx | 43 | ||||
-rw-r--r-- | include/svx/itemwin.hxx | 54 | ||||
-rw-r--r-- | svx/UIConfig_svx.mk | 1 | ||||
-rw-r--r-- | svx/inc/pch/precompiled_svxcore.hxx | 3 | ||||
-rw-r--r-- | svx/source/tbxctrls/fillctrl.cxx | 497 | ||||
-rw-r--r-- | svx/source/tbxctrls/itemwin.cxx | 241 | ||||
-rw-r--r-- | svx/uiconfig/ui/fillctrlbox.ui | 110 |
7 files changed, 435 insertions, 514 deletions
diff --git a/include/svx/fillctrl.hxx b/include/svx/fillctrl.hxx index 5278fc31e718..e7a77692b129 100644 --- a/include/svx/fillctrl.hxx +++ b/include/svx/fillctrl.hxx @@ -21,7 +21,9 @@ #define INCLUDED_SVX_FILLCTRL_HXX #include <memory> +#include <sfx2/InterimItemWindow.hxx> #include <sfx2/tbxctrl.hxx> +#include <sfx2/weldutils.hxx> #include <svx/svxdllapi.h> #include <com/sun/star/drawing/FillStyle.hpp> @@ -31,9 +33,6 @@ class XFillGradientItem; class XFillHatchItem; class XFillBitmapItem; class FillControl; -class SvxFillTypeBox; -class SvxFillAttrBox; -class ListBox; /************************************************************************* |* @@ -50,18 +49,18 @@ private: std::unique_ptr< XFillHatchItem > mpHatchItem; std::unique_ptr< XFillBitmapItem > mpBitmapItem; - VclPtr<FillControl> mpFillControl; - VclPtr<SvxFillTypeBox> mpLbFillType; - VclPtr<ToolBox> mpToolBoxColor; - VclPtr<SvxFillAttrBox> mpLbFillAttr; + VclPtr<FillControl> mxFillControl; + weld::ComboBox* mpLbFillType; + weld::Toolbar* mpToolBoxColor; + weld::ComboBox* mpLbFillAttr; css::drawing::FillStyle meLastXFS; sal_Int32 mnLastPosGradient; sal_Int32 mnLastPosHatch; sal_Int32 mnLastPosBitmap; - DECL_LINK(SelectFillTypeHdl, ListBox&, void); - DECL_LINK(SelectFillAttrHdl, ListBox&, void); + DECL_LINK(SelectFillTypeHdl, weld::ComboBox&, void); + DECL_LINK(SelectFillAttrHdl, weld::ComboBox&, void); public: SFX_DECL_TOOLBOX_CONTROL(); @@ -74,25 +73,37 @@ public: virtual VclPtr<vcl::Window> CreateItemWindow(vcl::Window* pParent) override; }; -class SAL_WARN_UNUSED FillControl : public vcl::Window +class SAL_WARN_UNUSED FillControl final : public InterimItemWindow { private: friend class SvxFillToolBoxControl; - VclPtr<SvxFillTypeBox> mpLbFillType; - VclPtr<ToolBox> mpToolBoxColor; - VclPtr<SvxFillAttrBox> mpLbFillAttr; + std::unique_ptr<weld::ComboBox> mxLbFillType; + std::unique_ptr<weld::Toolbar> mxToolBoxColor; + std::unique_ptr<ToolbarUnoDispatcher> mxColorDispatch; + std::unique_ptr<weld::ComboBox> mxLbFillAttr; + int mnTypeCurPos; + int mnAttrCurPos; + + DECL_LINK(AttrKeyInputHdl, const KeyEvent&, bool); + DECL_LINK(TypeKeyInputHdl, const KeyEvent&, bool); + DECL_LINK(ColorKeyInputHdl, const KeyEvent&, bool); + DECL_STATIC_LINK(FillControl, DumpAsPropertyTreeHdl, boost::property_tree::ptree&, void); + DECL_LINK(AttrFocusHdl, weld::Widget&, void); + DECL_LINK(TypeFocusHdl, weld::Widget&, void); void SetOptimalSize(); virtual void DataChanged(const DataChangedEvent& rDCEvt) override; + static void ReleaseFocus_Impl(); + public: - FillControl(vcl::Window* pParent); - virtual ~FillControl() override; + FillControl(vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rFrame); virtual void dispose() override; + virtual ~FillControl() override; - virtual void Resize() override; + virtual void GetFocus() override; }; #endif // INCLUDED_SVX_FILLCTRL_HXX diff --git a/include/svx/itemwin.hxx b/include/svx/itemwin.hxx index 964d80f1a2e2..570a6cdbb4bd 100644 --- a/include/svx/itemwin.hxx +++ b/include/svx/itemwin.hxx @@ -19,8 +19,6 @@ #ifndef INCLUDED_SVX_ITEMWIN_HXX #define INCLUDED_SVX_ITEMWIN_HXX -#include <vcl/field.hxx> -#include <vcl/lstbox.hxx> #include <sfx2/InterimItemWindow.hxx> #include <svtools/toolbarmenu.hxx> #include <svx/dlgctrl.hxx> @@ -81,52 +79,18 @@ public: void set_sensitive(bool bSensitive); }; -class SVX_DLLPUBLIC SvxFillTypeBox final : public ListBox +namespace SvxFillTypeBox { -public: - SvxFillTypeBox( vcl::Window* pParent ); - - void Fill(); - - static void Fill(weld::ComboBox& rListBox); - - void Selected() { bSelect = true; } - virtual boost::property_tree::ptree DumpAsPropertyTree() override; - -private: - virtual bool PreNotify( NotifyEvent& rNEvt ) override; - virtual bool EventNotify( NotifyEvent& rNEvt ) override; - - sal_uInt16 nCurPos; - bool bSelect; - - static void ReleaseFocus_Impl(); -}; + SVX_DLLPUBLIC void Fill(weld::ComboBox& rListBox); +} -class SVX_DLLPUBLIC SvxFillAttrBox final : public ListBox +namespace SvxFillAttrBox { -public: - SvxFillAttrBox( vcl::Window* pParent ); - - void Fill( const XHatchListRef &pList ); - void Fill( const XGradientListRef &pList ); - void Fill( const XBitmapListRef &pList ); - void Fill( const XPatternListRef &pList ); - - static void Fill(weld::ComboBox&, const XHatchListRef &pList); - static void Fill(weld::ComboBox&, const XGradientListRef &pList); - static void Fill(weld::ComboBox&, const XBitmapListRef &pList); - static void Fill(weld::ComboBox&, const XPatternListRef &pList); - -private: - virtual bool PreNotify( NotifyEvent& rNEvt ) override; - virtual bool EventNotify( NotifyEvent& rNEvt ) override; - - sal_uInt16 nCurPos; - BitmapEx maBitmapEx; - - static void ReleaseFocus_Impl(); -}; + SVX_DLLPUBLIC void Fill(weld::ComboBox&, const XHatchListRef &pList); + SVX_DLLPUBLIC void Fill(weld::ComboBox&, const XGradientListRef &pList); + SVX_DLLPUBLIC void Fill(weld::ComboBox&, const XBitmapListRef &pList); + SVX_DLLPUBLIC void Fill(weld::ComboBox&, const XPatternListRef &pList); +} #endif // INCLUDED_SVX_ITEMWIN_HXX diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk index e7d478800185..186fdc818d38 100644 --- a/svx/UIConfig_svx.mk +++ b/svx/UIConfig_svx.mk @@ -47,6 +47,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\ svx/uiconfig/ui/docrecoveryrecoverdialog \ svx/uiconfig/ui/docrecoverysavedialog \ svx/uiconfig/ui/extrustiondepthdialog \ + svx/uiconfig/ui/fillctrlbox \ svx/uiconfig/ui/filtermenu \ svx/uiconfig/ui/findreplacedialog \ svx/uiconfig/ui/floatingareastyle \ diff --git a/svx/inc/pch/precompiled_svxcore.hxx b/svx/inc/pch/precompiled_svxcore.hxx index aa8b8295692a..a441ac85ab86 100644 --- a/svx/inc/pch/precompiled_svxcore.hxx +++ b/svx/inc/pch/precompiled_svxcore.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-06 17:42:27 using: + Generated on 2020-02-11 09:36:54 using: ./bin/update_pch svx svxcore --cutoff=7 --exclude:system --include:module --exclude:local If after updating build fails, use the following command to locate conflicting headers: @@ -119,7 +119,6 @@ #include <vcl/edit.hxx> #include <vcl/errcode.hxx> #include <vcl/event.hxx> -#include <vcl/field.hxx> #include <vcl/fixed.hxx> #include <vcl/floatwin.hxx> #include <vcl/fntstyle.hxx> diff --git a/svx/source/tbxctrls/fillctrl.cxx b/svx/source/tbxctrls/fillctrl.cxx index 52e0d8bc149e..7b39204f5392 100644 --- a/svx/source/tbxctrls/fillctrl.cxx +++ b/svx/source/tbxctrls/fillctrl.cxx @@ -42,9 +42,9 @@ #include <svx/xflgrit.hxx> #include <svx/xflhtit.hxx> #include <svx/xbtmpit.hxx> +#include <boost/property_tree/ptree.hpp> #include <memory> - using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::util; @@ -63,7 +63,7 @@ SvxFillToolBoxControl::SvxFillToolBoxControl( , mpFillGradientItem() , mpHatchItem() , mpBitmapItem() - , mpFillControl(nullptr) + , mxFillControl(nullptr) , mpLbFillType(nullptr) , mpLbFillAttr(nullptr) , meLastXFS(static_cast<drawing::FillStyle>(-1)) @@ -98,12 +98,12 @@ void SvxFillToolBoxControl::StateChanged( { if(bDisabled) { - mpLbFillType->Disable(); - mpLbFillType->SetNoSelection(); - mpLbFillAttr->Show(); - mpLbFillAttr->Disable(); - mpLbFillAttr->SetNoSelection(); - mpToolBoxColor->Hide(); + mpLbFillType->set_sensitive(false); + mpLbFillType->set_active(-1); + mpLbFillAttr->show(); + mpLbFillAttr->set_sensitive(false); + mpLbFillAttr->set_active(-1); + mpToolBoxColor->hide(); meLastXFS = static_cast<drawing::FillStyle>(-1); mpStyleItem.reset(); } @@ -115,15 +115,15 @@ void SvxFillToolBoxControl::StateChanged( if(pItem) { mpStyleItem.reset(pItem->Clone()); - mpLbFillType->Enable(); + mpLbFillType->set_sensitive(true); drawing::FillStyle eXFS = mpStyleItem->GetValue(); meLastXFS = eXFS; - mpLbFillType->SelectEntryPos(sal::static_int_cast< sal_Int32 >(eXFS)); + mpLbFillType->set_active(sal::static_int_cast< sal_Int32 >(eXFS)); if(drawing::FillStyle_NONE == eXFS) { - mpLbFillAttr->SetNoSelection(); - mpLbFillAttr->Disable(); + mpLbFillAttr->set_active(-1); + mpLbFillAttr->set_sensitive(false); } Update(); @@ -131,13 +131,14 @@ void SvxFillToolBoxControl::StateChanged( } } - mpLbFillType->SetNoSelection(); - mpLbFillAttr->Show(); - mpLbFillAttr->Disable(); - mpLbFillAttr->SetNoSelection(); - mpToolBoxColor->Hide(); + mpLbFillType->set_active(-1); + mpLbFillAttr->show(); + mpLbFillAttr->set_sensitive(false); + mpLbFillAttr->set_active(-1); + mpToolBoxColor->hide(); meLastXFS = static_cast<drawing::FillStyle>(-1); mpStyleItem.reset(); + mxFillControl->Resize(); break; } case SID_ATTR_FILL_COLOR: @@ -149,8 +150,9 @@ void SvxFillToolBoxControl::StateChanged( if(mpStyleItem && drawing::FillStyle_SOLID == mpStyleItem->GetValue()) { - mpLbFillAttr->Hide(); - mpToolBoxColor->Show(); + mpLbFillAttr->hide(); + mpToolBoxColor->show(); + mxFillControl->Resize(); Update(); } @@ -165,22 +167,23 @@ void SvxFillToolBoxControl::StateChanged( if(mpStyleItem && drawing::FillStyle_GRADIENT == mpStyleItem->GetValue()) { - mpLbFillAttr->Show(); - mpToolBoxColor->Hide(); + mpLbFillAttr->show(); + mpToolBoxColor->hide(); + mxFillControl->Resize(); if(SfxItemState::DEFAULT == eState) { - mpLbFillAttr->Enable(); + mpLbFillAttr->set_sensitive(true); Update(); } else if(SfxItemState::DISABLED == eState ) { - mpLbFillAttr->Disable(); - mpLbFillAttr->SetNoSelection(); + mpLbFillAttr->set_sensitive(false); + mpLbFillAttr->set_active(-1); } else { - mpLbFillAttr->SetNoSelection(); + mpLbFillAttr->set_active(-1); } } break; @@ -194,22 +197,23 @@ void SvxFillToolBoxControl::StateChanged( if(mpStyleItem && drawing::FillStyle_HATCH == mpStyleItem->GetValue()) { - mpLbFillAttr->Show(); - mpToolBoxColor->Hide(); + mpLbFillAttr->show(); + mpToolBoxColor->hide(); + mxFillControl->Resize(); if(SfxItemState::DEFAULT == eState) { - mpLbFillAttr->Enable(); + mpLbFillAttr->set_sensitive(true); Update(); } else if(SfxItemState::DISABLED == eState ) { - mpLbFillAttr->Disable(); - mpLbFillAttr->SetNoSelection(); + mpLbFillAttr->set_sensitive(false); + mpLbFillAttr->set_active(-1); } else { - mpLbFillAttr->SetNoSelection(); + mpLbFillAttr->set_active(-1); } } break; @@ -223,22 +227,23 @@ void SvxFillToolBoxControl::StateChanged( if(mpStyleItem && drawing::FillStyle_BITMAP == mpStyleItem->GetValue()) { - mpLbFillAttr->Show(); - mpToolBoxColor->Hide(); + mpLbFillAttr->show(); + mpToolBoxColor->hide(); + mxFillControl->Resize(); if(SfxItemState::DEFAULT == eState) { - mpLbFillAttr->Enable(); + mpLbFillAttr->set_sensitive(true); Update(); } else if(SfxItemState::DISABLED == eState ) { - mpLbFillAttr->Disable(); - mpLbFillAttr->SetNoSelection(); + mpLbFillAttr->set_sensitive(false); + mpLbFillAttr->set_active(-1); } else { - mpLbFillAttr->SetNoSelection(); + mpLbFillAttr->set_active(-1); } } break; @@ -254,14 +259,14 @@ void SvxFillToolBoxControl::StateChanged( const OUString aString( mpFillGradientItem->GetName() ); const SfxObjectShell* pSh = SfxObjectShell::Current(); - mpLbFillAttr->Clear(); - mpLbFillAttr->Enable(); - mpLbFillAttr->Fill(pSh->GetItem(SID_GRADIENT_LIST)->GetGradientList()); - mpLbFillAttr->SelectEntry(aString); + mpLbFillAttr->clear(); + mpLbFillAttr->set_sensitive(true); + SvxFillAttrBox::Fill(*mpLbFillAttr, pSh->GetItem(SID_GRADIENT_LIST)->GetGradientList()); + mpLbFillAttr->set_active_text(aString); } else { - mpLbFillAttr->SetNoSelection(); + mpLbFillAttr->set_active(-1); } } } @@ -278,14 +283,14 @@ void SvxFillToolBoxControl::StateChanged( const OUString aString( mpHatchItem->GetName() ); const SfxObjectShell* pSh = SfxObjectShell::Current(); - mpLbFillAttr->Clear(); - mpLbFillAttr->Enable(); - mpLbFillAttr->Fill(pSh->GetItem(SID_HATCH_LIST)->GetHatchList()); - mpLbFillAttr->SelectEntry(aString); + mpLbFillAttr->clear(); + mpLbFillAttr->set_sensitive(true); + SvxFillAttrBox::Fill(*mpLbFillAttr, pSh->GetItem(SID_HATCH_LIST)->GetHatchList()); + mpLbFillAttr->set_active_text(aString); } else { - mpLbFillAttr->SetNoSelection(); + mpLbFillAttr->set_active(-1); } } } @@ -302,14 +307,14 @@ void SvxFillToolBoxControl::StateChanged( const OUString aString( mpBitmapItem->GetName() ); const SfxObjectShell* pSh = SfxObjectShell::Current(); - mpLbFillAttr->Clear(); - mpLbFillAttr->Enable(); - mpLbFillAttr->Fill(pSh->GetItem(SID_BITMAP_LIST)->GetBitmapList()); - mpLbFillAttr->SelectEntry(aString); + mpLbFillAttr->clear(); + mpLbFillAttr->set_sensitive(true); + SvxFillAttrBox::Fill(*mpLbFillAttr, pSh->GetItem(SID_BITMAP_LIST)->GetBitmapList()); + mpLbFillAttr->set_active_text(aString); } else { - mpLbFillAttr->SetNoSelection(); + mpLbFillAttr->set_active(-1); } } } @@ -329,49 +334,52 @@ void SvxFillToolBoxControl::Update() { case drawing::FillStyle_NONE: { - mpLbFillAttr->Show(); - mpToolBoxColor->Hide(); + mpLbFillAttr->show(); + mpToolBoxColor->hide(); + mxFillControl->Resize(); break; } case drawing::FillStyle_SOLID: { if(mpColorItem) { - mpLbFillAttr->Hide(); - mpToolBoxColor->Show(); + mpLbFillAttr->hide(); + mpToolBoxColor->show(); + mxFillControl->Resize(); } break; } case drawing::FillStyle_GRADIENT: { - mpLbFillAttr->Show(); - mpToolBoxColor->Hide(); + mpLbFillAttr->show(); + mpToolBoxColor->hide(); + mxFillControl->Resize(); if(pSh && pSh->GetItem(SID_GRADIENT_LIST)) { - mpLbFillAttr->Enable(); - mpLbFillAttr->Clear(); - mpLbFillAttr->Fill(pSh->GetItem(SID_GRADIENT_LIST)->GetGradientList()); + mpLbFillAttr->set_sensitive(true); + mpLbFillAttr->clear(); + SvxFillAttrBox::Fill(*mpLbFillAttr, pSh->GetItem(SID_GRADIENT_LIST)->GetGradientList()); if(mpFillGradientItem) { const OUString aString(mpFillGradientItem->GetName()); - mpLbFillAttr->SelectEntry(aString); + mpLbFillAttr->set_active_text(aString); // Check if the entry is not in the list - if (mpLbFillAttr->GetSelectedEntry() != aString) + if (mpLbFillAttr->get_active_text() != aString) { - sal_Int32 nCount = mpLbFillAttr->GetEntryCount(); + sal_Int32 nCount = mpLbFillAttr->get_count(); OUString aTmpStr; if( nCount > 0 ) { // Last entry gets tested against temporary entry - aTmpStr = mpLbFillAttr->GetEntry( nCount - 1 ); + aTmpStr = mpLbFillAttr->get_text( nCount - 1 ); if( aTmpStr.startsWith(TMP_STR_BEGIN) && aTmpStr.endsWith(TMP_STR_END) ) { - mpLbFillAttr->RemoveEntry(nCount - 1); + mpLbFillAttr->remove(nCount - 1); } } aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END; @@ -381,55 +389,60 @@ void SvxFillToolBoxControl::Update() aGradientList.SetDirty( false ); const BitmapEx aBmp = aGradientList.GetUiBitmap( 0 ); - if(!aBmp.IsEmpty()) + if (!aBmp.IsEmpty()) { - mpLbFillAttr->InsertEntry(aGradientList.Get(0)->GetName(), Image(aBmp)); - mpLbFillAttr->SelectEntryPos(mpLbFillAttr->GetEntryCount() - 1); + ScopedVclPtrInstance< VirtualDevice > pVD; + const Size aBmpSize(aBmp.GetSizePixel()); + pVD->SetOutputSizePixel(aBmpSize, false); + pVD->DrawBitmapEx(Point(), aBmp); + mpLbFillAttr->append("", aGradientList.Get(0)->GetName(), *pVD); + mpLbFillAttr->set_active(mpLbFillAttr->get_count() - 1); } } } else { - mpLbFillAttr->SetNoSelection(); + mpLbFillAttr->set_active(-1); } } else { - mpLbFillAttr->SetNoSelection(); + mpLbFillAttr->set_active(-1); } break; } case drawing::FillStyle_HATCH: { - mpLbFillAttr->Show(); - mpToolBoxColor->Hide(); + mpLbFillAttr->show(); + mpToolBoxColor->hide(); + mxFillControl->Resize(); if(pSh && pSh->GetItem(SID_HATCH_LIST)) { - mpLbFillAttr->Enable(); - mpLbFillAttr->Clear(); - mpLbFillAttr->Fill(pSh->GetItem(SID_HATCH_LIST)->GetHatchList()); + mpLbFillAttr->set_sensitive(true); + mpLbFillAttr->clear(); + SvxFillAttrBox::Fill(*mpLbFillAttr, pSh->GetItem(SID_HATCH_LIST)->GetHatchList()); if(mpHatchItem) { const OUString aString(mpHatchItem->GetName()); - mpLbFillAttr->SelectEntry( aString ); + mpLbFillAttr->set_active_text( aString ); // Check if the entry is not in the list - if( mpLbFillAttr->GetSelectedEntry() != aString ) + if( mpLbFillAttr->get_active_text() != aString ) { - const sal_Int32 nCount = mpLbFillAttr->GetEntryCount(); + const sal_Int32 nCount = mpLbFillAttr->get_count(); OUString aTmpStr; if( nCount > 0 ) { // Last entry gets tested against temporary entry - aTmpStr = mpLbFillAttr->GetEntry( nCount - 1 ); + aTmpStr = mpLbFillAttr->get_text( nCount - 1 ); if( aTmpStr.startsWith(TMP_STR_BEGIN) && aTmpStr.endsWith(TMP_STR_END) ) { - mpLbFillAttr->RemoveEntry( nCount - 1 ); + mpLbFillAttr->remove( nCount - 1 ); } } aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END; @@ -441,53 +454,57 @@ void SvxFillToolBoxControl::Update() if( !aBmp.IsEmpty() ) { - mpLbFillAttr->InsertEntry(aHatchList.GetHatch(0)->GetName(), Image(aBmp)); - mpLbFillAttr->SelectEntryPos( mpLbFillAttr->GetEntryCount() - 1 ); - //delete pBmp; + ScopedVclPtrInstance< VirtualDevice > pVD; + const Size aBmpSize(aBmp.GetSizePixel()); + pVD->SetOutputSizePixel(aBmpSize, false); + pVD->DrawBitmapEx(Point(), aBmp); + mpLbFillAttr->append("", aHatchList.GetHatch(0)->GetName(), *pVD); + mpLbFillAttr->set_active(mpLbFillAttr->get_count() - 1); } } } else { - mpLbFillAttr->SetNoSelection(); + mpLbFillAttr->set_active(-1); } } else { - mpLbFillAttr->SetNoSelection(); + mpLbFillAttr->set_active(-1); } break; } case drawing::FillStyle_BITMAP: { - mpLbFillAttr->Show(); - mpToolBoxColor->Hide(); + mpLbFillAttr->show(); + mpToolBoxColor->hide(); + mxFillControl->Resize(); if(pSh && pSh->GetItem(SID_BITMAP_LIST)) { - mpLbFillAttr->Enable(); - mpLbFillAttr->Clear(); - mpLbFillAttr->Fill(pSh->GetItem(SID_BITMAP_LIST)->GetBitmapList()); + mpLbFillAttr->set_sensitive(true); + mpLbFillAttr->clear(); + SvxFillAttrBox::Fill(*mpLbFillAttr, pSh->GetItem(SID_BITMAP_LIST)->GetBitmapList()); if(mpBitmapItem) { const OUString aString(mpBitmapItem->GetName()); - mpLbFillAttr->SelectEntry(aString); + mpLbFillAttr->set_active_text(aString); // Check if the entry is not in the list - if (mpLbFillAttr->GetSelectedEntry() != aString) + if (mpLbFillAttr->get_active_text() != aString) { - sal_Int32 nCount = mpLbFillAttr->GetEntryCount(); + sal_Int32 nCount = mpLbFillAttr->get_count(); OUString aTmpStr; if( nCount > 0 ) { // Last entry gets tested against temporary entry - aTmpStr = mpLbFillAttr->GetEntry(nCount - 1); + aTmpStr = mpLbFillAttr->get_text(nCount - 1); if( aTmpStr.startsWith(TMP_STR_BEGIN) && aTmpStr.endsWith(TMP_STR_END) ) { - mpLbFillAttr->RemoveEntry(nCount - 1); + mpLbFillAttr->remove(nCount - 1); } } aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END; @@ -498,19 +515,19 @@ void SvxFillToolBoxControl::Update() XPropertyListType::Bitmap, "TmpList", ""/*TODO?*/)); xBitmapList->Insert(std::make_unique<XBitmapEntry>(mpBitmapItem->GetGraphicObject(), aTmpStr)); xBitmapList->SetDirty( false ); - mpLbFillAttr->Fill( xBitmapList ); - mpLbFillAttr->SelectEntryPos(mpLbFillAttr->GetEntryCount() - 1); + SvxFillAttrBox::Fill(*mpLbFillAttr, xBitmapList); + mpLbFillAttr->set_active(mpLbFillAttr->get_count() - 1); } } else { - mpLbFillAttr->SetNoSelection(); + mpLbFillAttr->set_active(-1); } } else { - mpLbFillAttr->SetNoSelection(); + mpLbFillAttr->set_active(-1); } break; } @@ -526,33 +543,118 @@ VclPtr<vcl::Window> SvxFillToolBoxControl::CreateItemWindow(vcl::Window *pParent { if(GetSlotId() == SID_ATTR_FILL_STYLE) { - mpFillControl.reset(VclPtr<FillControl>::Create(pParent)); + mxFillControl.reset(VclPtr<FillControl>::Create(pParent, m_xFrame)); + + mpLbFillType = mxFillControl->mxLbFillType.get(); + mpLbFillAttr = mxFillControl->mxLbFillAttr.get(); + mpToolBoxColor = mxFillControl->mxToolBoxColor.get(); - mpLbFillType = mpFillControl->mpLbFillType; - mpLbFillAttr = mpFillControl->mpLbFillAttr; - mpToolBoxColor = mpFillControl->mpToolBoxColor; - mpFillControl->SetBackground(); - mpFillControl->SetPaintTransparent( true ); - mpFillControl->Resize(); - mpToolBoxColor->InsertItem(".uno:FillColor", m_xFrame, ToolBoxItemBits::DROPDOWNONLY, Size(mpToolBoxColor->GetSizePixel().Width(), 0)); + mpLbFillType->connect_changed(LINK(this,SvxFillToolBoxControl,SelectFillTypeHdl)); + mpLbFillAttr->connect_changed(LINK(this,SvxFillToolBoxControl,SelectFillAttrHdl)); - mpLbFillType->SetSelectHdl(LINK(this,SvxFillToolBoxControl,SelectFillTypeHdl)); - mpLbFillAttr->SetSelectHdl(LINK(this,SvxFillToolBoxControl,SelectFillAttrHdl)); - return mpFillControl.get(); + return mxFillControl; } return VclPtr<vcl::Window>(); } -FillControl::FillControl(vcl::Window* pParent) - : Window(pParent, WB_DIALOGCONTROL) - , mpLbFillType(VclPtr<SvxFillTypeBox>::Create(this)) - , mpToolBoxColor(VclPtr<sfx2::sidebar::SidebarToolBox>::Create(this)) - , mpLbFillAttr(VclPtr<SvxFillAttrBox>::Create(this)) +FillControl::FillControl(vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rFrame) + : InterimItemWindow(pParent, "svx/ui/fillctrlbox.ui", "FillCtrlBox") + , mxLbFillType(m_xBuilder->weld_combo_box("type")) + , mxToolBoxColor(m_xBuilder->weld_toolbar("color")) + , mxColorDispatch(new ToolbarUnoDispatcher(*mxToolBoxColor, rFrame)) + , mxLbFillAttr(m_xBuilder->weld_combo_box("attr")) + , mnTypeCurPos(0) + , mnAttrCurPos(0) { + mxLbFillAttr->connect_key_press(LINK(this, FillControl, AttrKeyInputHdl)); + mxLbFillType->connect_key_press(LINK(this, FillControl, TypeKeyInputHdl)); + mxToolBoxColor->connect_key_press(LINK(this, FillControl, ColorKeyInputHdl)); + + mxLbFillType->connect_get_property_tree(LINK(this, FillControl, DumpAsPropertyTreeHdl)); + + mxLbFillType->connect_focus_in(LINK(this, FillControl, TypeFocusHdl)); + mxLbFillAttr->connect_focus_in(LINK(this, FillControl, AttrFocusHdl)); + + SvxFillTypeBox::Fill(*mxLbFillType); + SetOptimalSize(); } +IMPL_STATIC_LINK(FillControl, DumpAsPropertyTreeHdl, boost::property_tree::ptree&, rTree, void) +{ + rTree.put("command", ".uno:FillStyle"); +} + +void FillControl::ReleaseFocus_Impl() +{ + SfxViewShell* pCurSh = SfxViewShell::Current(); + if (pCurSh) + { + vcl::Window* pShellWnd = pCurSh->GetWindow(); + if (pShellWnd) + pShellWnd->GrabFocus(); + } +} + +IMPL_LINK(FillControl, TypeKeyInputHdl, const KeyEvent&, rKEvt, bool) +{ + const vcl::KeyCode& rKeyCode = rKEvt.GetKeyCode(); + sal_uInt16 nCode = rKeyCode.GetCode(); + + if (nCode == KEY_ESCAPE) + { + mxLbFillType->set_active(mnTypeCurPos); + ReleaseFocus_Impl(); + return true; + } + + if (nCode != KEY_TAB) + return false; + if (rKeyCode.IsShift()) + return ChildKeyInput(rKEvt); + if (mxLbFillAttr->get_visible() && !mxLbFillAttr->get_sensitive()) + return ChildKeyInput(rKEvt); + return false; +} + +IMPL_LINK_NOARG(FillControl, TypeFocusHdl, weld::Widget&, void) +{ + mnTypeCurPos = mxLbFillType->get_active(); +} + +IMPL_LINK_NOARG(FillControl, AttrFocusHdl, weld::Widget&, void) +{ + mnAttrCurPos = mxLbFillAttr->get_active(); +} + +IMPL_LINK(FillControl, AttrKeyInputHdl, const KeyEvent&, rKEvt, bool) +{ + const vcl::KeyCode& rKeyCode = rKEvt.GetKeyCode(); + sal_uInt16 nCode = rKeyCode.GetCode(); + + if (nCode == KEY_ESCAPE) + { + mxLbFillAttr->set_active(mnAttrCurPos); + ReleaseFocus_Impl(); + return true; + } + + return ChildKeyInput(rKEvt); +} + +IMPL_LINK(FillControl, ColorKeyInputHdl, const KeyEvent&, rKEvt, bool) +{ + return ChildKeyInput(rKEvt); +} + +void FillControl::GetFocus() +{ + if (mxLbFillType) + mxLbFillType->grab_focus(); + InterimItemWindow::GetFocus(); +} + FillControl::~FillControl() { disposeOnce(); @@ -560,19 +662,20 @@ FillControl::~FillControl() void FillControl::dispose() { - mpLbFillType.disposeAndClear(); - mpToolBoxColor.disposeAndClear(); - mpLbFillAttr.disposeAndClear(); - vcl::Window::dispose(); + mxLbFillAttr.reset(); + mxColorDispatch.reset(); + mxToolBoxColor.reset(); + mxLbFillType.reset(); + InterimItemWindow::dispose(); } -IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillTypeHdl, ListBox&, void) +IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillTypeHdl, weld::ComboBox&, void) { - const drawing::FillStyle eXFS = static_cast<drawing::FillStyle>(mpLbFillType->GetSelectedEntryPos()); + const drawing::FillStyle eXFS = static_cast<drawing::FillStyle>(mpLbFillType->get_active()); if(meLastXFS != eXFS) { - mpLbFillAttr->Clear(); + mpLbFillAttr->clear(); SfxObjectShell* pSh = SfxObjectShell::Current(); const XFillStyleItem aXFillStyleItem(eXFS); @@ -585,10 +688,9 @@ IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillTypeHdl, ListBox&, void) default: case drawing::FillStyle_NONE: { - mpLbFillAttr->Show(); - mpToolBoxColor->Hide(); - mpLbFillType->Selected(); - mpLbFillAttr->Disable(); + mpLbFillAttr->show(); + mpToolBoxColor->hide(); + mpLbFillAttr->set_sensitive(false); // #i122676# need to call a single SID_ATTR_FILL_STYLE change SfxViewFrame::Current()->GetDispatcher()->ExecuteList( @@ -598,8 +700,8 @@ IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillTypeHdl, ListBox&, void) } case drawing::FillStyle_SOLID: { - mpLbFillAttr->Hide(); - mpToolBoxColor->Show(); + mpLbFillAttr->hide(); + mpToolBoxColor->show(); const OUString aTmpStr; const ::Color aColor = mpColorItem->GetColorValue(); const XFillColorItem aXFillColorItem( aTmpStr, aColor ); @@ -612,118 +714,112 @@ IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillTypeHdl, ListBox&, void) } case drawing::FillStyle_GRADIENT: { - mpLbFillAttr->Show(); - mpToolBoxColor->Hide(); + mpLbFillAttr->show(); + mpToolBoxColor->hide(); if(pSh && pSh->GetItem(SID_GRADIENT_LIST)) { - if(!mpLbFillAttr->GetEntryCount()) + if(!mpLbFillAttr->get_count()) { - mpLbFillAttr->Enable(); - mpLbFillAttr->Clear(); - mpLbFillAttr->Fill(pSh->GetItem(SID_GRADIENT_LIST)->GetGradientList()); + mpLbFillAttr->set_sensitive(true); + mpLbFillAttr->clear(); + SvxFillAttrBox::Fill(*mpLbFillAttr, pSh->GetItem(SID_GRADIENT_LIST)->GetGradientList()); } - mpLbFillAttr->AdaptDropDownLineCountToMaximum(); - - if(LISTBOX_ENTRY_NOTFOUND != mnLastPosGradient) + if (mnLastPosGradient != -1) { const SvxGradientListItem * pItem = pSh->GetItem(SID_GRADIENT_LIST); if(mnLastPosGradient < pItem->GetGradientList()->Count()) { const XGradient aGradient = pItem->GetGradientList()->GetGradient(mnLastPosGradient)->GetGradient(); - const XFillGradientItem aXFillGradientItem(mpLbFillAttr->GetEntry(mnLastPosGradient), aGradient); + const XFillGradientItem aXFillGradientItem(mpLbFillAttr->get_text(mnLastPosGradient), aGradient); // #i122676# change FillStyle and Gradient in one call SfxViewFrame::Current()->GetDispatcher()->ExecuteList( SID_ATTR_FILL_GRADIENT, SfxCallMode::RECORD, { &aXFillGradientItem, &aXFillStyleItem }); - mpLbFillAttr->SelectEntryPos(mnLastPosGradient); + mpLbFillAttr->set_active(mnLastPosGradient); } } } else { - mpLbFillAttr->Disable(); + mpLbFillAttr->set_sensitive(false); } break; } case drawing::FillStyle_HATCH: { - mpLbFillAttr->Show(); - mpToolBoxColor->Hide(); + mpLbFillAttr->show(); + mpToolBoxColor->hide(); if(pSh && pSh->GetItem(SID_HATCH_LIST)) { - if(!mpLbFillAttr->GetEntryCount()) + if(!mpLbFillAttr->get_count()) { - mpLbFillAttr->Enable(); - mpLbFillAttr->Clear(); - mpLbFillAttr->Fill(pSh->GetItem(SID_HATCH_LIST)->GetHatchList()); + mpLbFillAttr->set_sensitive(true); + mpLbFillAttr->clear(); + SvxFillAttrBox::Fill(*mpLbFillAttr, pSh->GetItem(SID_HATCH_LIST)->GetHatchList()); } - mpLbFillAttr->AdaptDropDownLineCountToMaximum(); - - if(LISTBOX_ENTRY_NOTFOUND != mnLastPosHatch) + if (mnLastPosHatch != -1) { const SvxHatchListItem * pItem = pSh->GetItem(SID_HATCH_LIST); if(mnLastPosHatch < pItem->GetHatchList()->Count()) { const XHatch aHatch = pItem->GetHatchList()->GetHatch(mnLastPosHatch)->GetHatch(); - const XFillHatchItem aXFillHatchItem(mpLbFillAttr->GetSelectedEntry(), aHatch); + const XFillHatchItem aXFillHatchItem(mpLbFillAttr->get_active_text(), aHatch); // #i122676# change FillStyle and Hatch in one call SfxViewFrame::Current()->GetDispatcher()->ExecuteList( SID_ATTR_FILL_HATCH, SfxCallMode::RECORD, { &aXFillHatchItem, &aXFillStyleItem }); - mpLbFillAttr->SelectEntryPos(mnLastPosHatch); + mpLbFillAttr->set_active(mnLastPosHatch); } } } else { - mpLbFillAttr->Disable(); + mpLbFillAttr->set_sensitive(false); } break; } case drawing::FillStyle_BITMAP: { - mpLbFillAttr->Show(); - mpToolBoxColor->Hide(); + mpLbFillAttr->show(); + mpToolBoxColor->hide(); if(pSh && pSh->GetItem(SID_BITMAP_LIST)) { - if(!mpLbFillAttr->GetEntryCount()) + if(!mpLbFillAttr->get_count()) { - mpLbFillAttr->Enable(); - mpLbFillAttr->Clear(); - mpLbFillAttr->Fill(pSh->GetItem(SID_BITMAP_LIST)->GetBitmapList()); + mpLbFillAttr->set_sensitive(true); + mpLbFillAttr->clear(); + SvxFillAttrBox::Fill(*mpLbFillAttr, pSh->GetItem(SID_BITMAP_LIST)->GetBitmapList()); } - mpLbFillAttr->AdaptDropDownLineCountToMaximum(); - - if(LISTBOX_ENTRY_NOTFOUND != mnLastPosBitmap) + if (mnLastPosBitmap != -1) { const SvxBitmapListItem * pItem = pSh->GetItem(SID_BITMAP_LIST); if(mnLastPosBitmap < pItem->GetBitmapList()->Count()) { const XBitmapEntry* pXBitmapEntry = pItem->GetBitmapList()->GetBitmap(mnLastPosBitmap); - const XFillBitmapItem aXFillBitmapItem(mpLbFillAttr->GetSelectedEntry(), pXBitmapEntry->GetGraphicObject()); + const XFillBitmapItem aXFillBitmapItem(mpLbFillAttr->get_active_text(), pXBitmapEntry->GetGraphicObject()); // #i122676# change FillStyle and Bitmap in one call SfxViewFrame::Current()->GetDispatcher()->ExecuteList( SID_ATTR_FILL_BITMAP, SfxCallMode::RECORD, { &aXFillBitmapItem, &aXFillStyleItem }); - mpLbFillAttr->SelectEntryPos(mnLastPosBitmap); + mpLbFillAttr->set_active(mnLastPosBitmap); } } } else { - mpLbFillAttr->Disable(); + mpLbFillAttr->set_sensitive(false); } break; } @@ -731,16 +827,13 @@ IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillTypeHdl, ListBox&, void) meLastXFS = eXFS; - if(drawing::FillStyle_NONE != eXFS) - { - mpLbFillType->Selected(); - } + mxFillControl->Resize(); } } -IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillAttrHdl, ListBox&, void) +IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillAttrHdl, weld::ComboBox&, void) { - const drawing::FillStyle eXFS = static_cast<drawing::FillStyle>(mpLbFillType->GetSelectedEntryPos()); + const drawing::FillStyle eXFS = static_cast<drawing::FillStyle>(mpLbFillType->get_active()); const XFillStyleItem aXFillStyleItem(eXFS); SfxObjectShell* pSh = SfxObjectShell::Current(); @@ -763,21 +856,21 @@ IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillAttrHdl, ListBox&, void) } case drawing::FillStyle_GRADIENT: { - sal_Int32 nPos = mpLbFillAttr->GetSelectedEntryPos(); + sal_Int32 nPos = mpLbFillAttr->get_active(); - if(LISTBOX_ENTRY_NOTFOUND == nPos) + if (nPos == -1) { nPos = mnLastPosGradient; } - if(LISTBOX_ENTRY_NOTFOUND != nPos && pSh && pSh->GetItem(SID_GRADIENT_LIST)) + if (nPos != -1 && pSh && pSh->GetItem(SID_GRADIENT_LIST)) { const SvxGradientListItem * pItem = pSh->GetItem(SID_GRADIENT_LIST); if(nPos < pItem->GetGradientList()->Count()) { const XGradient aGradient = pItem->GetGradientList()->GetGradient(nPos)->GetGradient(); - const XFillGradientItem aXFillGradientItem(mpLbFillAttr->GetSelectedEntry(), aGradient); + const XFillGradientItem aXFillGradientItem(mpLbFillAttr->get_active_text(), aGradient); // #i122676# Change FillStyle and Gradinet in one call SfxViewFrame::Current()->GetDispatcher()->ExecuteList( @@ -788,7 +881,7 @@ IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillAttrHdl, ListBox&, void) } } - if(LISTBOX_ENTRY_NOTFOUND != nPos) + if (nPos != -1) { mnLastPosGradient = nPos; } @@ -796,21 +889,21 @@ IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillAttrHdl, ListBox&, void) } case drawing::FillStyle_HATCH: { - sal_Int32 nPos = mpLbFillAttr->GetSelectedEntryPos(); + sal_Int32 nPos = mpLbFillAttr->get_active(); - if(LISTBOX_ENTRY_NOTFOUND == nPos) + if (nPos == -1) { nPos = mnLastPosHatch; } - if(LISTBOX_ENTRY_NOTFOUND != nPos && pSh && pSh->GetItem(SID_HATCH_LIST)) + if (nPos != -1 && pSh && pSh->GetItem(SID_HATCH_LIST)) { const SvxHatchListItem * pItem = pSh->GetItem(SID_HATCH_LIST); if(nPos < pItem->GetHatchList()->Count()) { const XHatch aHatch = pItem->GetHatchList()->GetHatch(nPos)->GetHatch(); - const XFillHatchItem aXFillHatchItem( mpLbFillAttr->GetSelectedEntry(), aHatch); + const XFillHatchItem aXFillHatchItem( mpLbFillAttr->get_active_text(), aHatch); // #i122676# Change FillStyle and Hatch in one call SfxViewFrame::Current()->GetDispatcher()->ExecuteList( @@ -821,7 +914,7 @@ IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillAttrHdl, ListBox&, void) } } - if(LISTBOX_ENTRY_NOTFOUND != nPos) + if (nPos != -1) { mnLastPosHatch = nPos; } @@ -829,21 +922,21 @@ IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillAttrHdl, ListBox&, void) } case drawing::FillStyle_BITMAP: { - sal_Int32 nPos = mpLbFillAttr->GetSelectedEntryPos(); + sal_Int32 nPos = mpLbFillAttr->get_active(); - if(LISTBOX_ENTRY_NOTFOUND == nPos) + if (nPos == -1) { nPos = mnLastPosBitmap; } - if(LISTBOX_ENTRY_NOTFOUND != nPos && pSh && pSh->GetItem(SID_BITMAP_LIST)) + if (nPos != -1 && pSh && pSh->GetItem(SID_BITMAP_LIST)) { const SvxBitmapListItem * pItem = pSh->GetItem(SID_BITMAP_LIST); if(nPos < pItem->GetBitmapList()->Count()) { const XBitmapEntry* pXBitmapEntry = pItem->GetBitmapList()->GetBitmap(nPos); - const XFillBitmapItem aXFillBitmapItem(mpLbFillAttr->GetSelectedEntry(), pXBitmapEntry->GetGraphicObject()); + const XFillBitmapItem aXFillBitmapItem(mpLbFillAttr->get_active_text(), pXBitmapEntry->GetGraphicObject()); // #i122676# Change FillStyle and Bitmap in one call SfxViewFrame::Current()->GetDispatcher()->ExecuteList( @@ -854,7 +947,7 @@ IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillAttrHdl, ListBox&, void) } } - if(LISTBOX_ENTRY_NOTFOUND != nPos) + if (nPos != -1) { mnLastPosBitmap = nPos; } @@ -864,31 +957,15 @@ IMPL_LINK_NOARG(SvxFillToolBoxControl, SelectFillAttrHdl, ListBox&, void) } } -void FillControl::Resize() -{ - Size aSize(GetOutputSizePixel()); - long nH = aSize.Height(); - - Size aTypeSize(mpLbFillType->get_preferred_size()); - long nPrefHeight = aTypeSize.Height(); - long nOffset = (nH - nPrefHeight)/2; - mpLbFillType->SetPosSizePixel(Point(0, nOffset), Size(aTypeSize.Width(), nPrefHeight)); - nPrefHeight = mpToolBoxColor->get_preferred_size().Height(); - nOffset = (nH - nPrefHeight)/2; - mpToolBoxColor->SetPosSizePixel(Point(aTypeSize.Width(), nOffset),Size(aSize.Width() - aTypeSize.Width(), nPrefHeight)); - nPrefHeight = mpLbFillType->get_preferred_size().Height(); - nOffset = (nH - nPrefHeight)/2; - mpLbFillAttr->SetPosSizePixel(Point(aTypeSize.Width(), nOffset),Size(aSize.Width() - aTypeSize.Width(), nPrefHeight)); -} - void FillControl::SetOptimalSize() { - Size aSize(mpLbFillType->get_preferred_size()); - Size aFirstSize(mpToolBoxColor->get_preferred_size()); - Size aSecondSize(mpLbFillAttr->get_preferred_size()); - aSize.setHeight(std::max({aSize.Height(), aFirstSize.Height(), aSecondSize.Height()})); - aSize.setWidth(aSize.Width() + LogicToPixel(Size(55, 0), MapMode(MapUnit::MapAppFont)).Width()); - SetSizePixel(aSize); + Size aSize(mxLbFillType->get_preferred_size()); + Size aFirstSize(mxToolBoxColor->get_preferred_size()); + auto nWidth = std::max(aFirstSize.Width(), LogicToPixel(Size(55, 0), MapMode(MapUnit::MapAppFont)).Width()); + auto nHeight = std::max(aSize.Height(), aFirstSize.Height()); + mxToolBoxColor->set_size_request(nWidth, -1); + mxLbFillAttr->set_size_request(42, -1); //something narrow so the toolbar sets the overall size of this column + SetSizePixel(Size(m_xContainer->get_preferred_size().Width(), nHeight)); } void FillControl::DataChanged(const DataChangedEvent& rDCEvt) @@ -898,7 +975,7 @@ void FillControl::DataChanged(const DataChangedEvent& rDCEvt) { SetOptimalSize(); } - Window::DataChanged(rDCEvt); + InterimItemWindow::DataChanged(rDCEvt); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/itemwin.cxx b/svx/source/tbxctrls/itemwin.cxx index 52f28c91cb4d..f51110a55cd5 100644 --- a/svx/source/tbxctrls/itemwin.cxx +++ b/svx/source/tbxctrls/itemwin.cxx @@ -185,104 +185,6 @@ void SvxMetricField::GetFocus() InterimItemWindow::GetFocus(); } -SvxFillTypeBox::SvxFillTypeBox( vcl::Window* pParent ) : - ListBox( pParent, WB_BORDER | WB_DROPDOWN | WB_AUTOHSCROLL | WB_TABSTOP ), - nCurPos ( 0 ), - bSelect ( false ) -{ - Fill(); - SetSizePixel(get_preferred_size()); - SelectEntryPos( sal_Int32(drawing::FillStyle_SOLID) ); - Show(); -} - -bool SvxFillTypeBox::PreNotify( NotifyEvent& rNEvt ) -{ - MouseNotifyEvent nType = rNEvt.GetType(); - - if (!isDisposed()) - { - if ( MouseNotifyEvent::MOUSEBUTTONDOWN == nType || MouseNotifyEvent::GETFOCUS == nType ) - nCurPos = GetSelectedEntryPos(); - else if ( MouseNotifyEvent::LOSEFOCUS == nType - && Application::GetFocusWindow() - && !IsWindowOrChild( Application::GetFocusWindow(), true ) ) - { - if ( !bSelect ) - SelectEntryPos( nCurPos ); - else - bSelect = false; - } - } - - return ListBox::PreNotify( rNEvt ); -} - -bool SvxFillTypeBox::EventNotify( NotifyEvent& rNEvt ) -{ - bool bHandled = ListBox::EventNotify( rNEvt ); - - if (isDisposed()) - return false; - - if ( !bHandled && rNEvt.GetType() == MouseNotifyEvent::KEYINPUT ) - { - const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); - switch ( pKEvt->GetKeyCode().GetCode() ) - { - case KEY_RETURN: - bHandled = true; - GetSelectHdl().Call( *this ); - break; - - case KEY_TAB: - GetSelectHdl().Call( *this ); - break; - - case KEY_ESCAPE: - SelectEntryPos( nCurPos ); - ReleaseFocus_Impl(); - bHandled = true; - break; - } - } - return bHandled; -} - - -void SvxFillTypeBox::ReleaseFocus_Impl() -{ - if( SfxViewShell::Current() ) - { - vcl::Window* pShellWnd = SfxViewShell::Current()->GetWindow(); - - if ( pShellWnd ) - pShellWnd->GrabFocus(); - } -} - -boost::property_tree::ptree SvxFillTypeBox::DumpAsPropertyTree() -{ - boost::property_tree::ptree aTree = ListBox::DumpAsPropertyTree(); - aTree.put("command", ".uno:FillStyle"); - return aTree; -} - -void SvxFillTypeBox::Fill() -{ - SetUpdateMode( false ); - - InsertEntry( SvxResId(RID_SVXSTR_INVISIBLE) ); - InsertEntry( SvxResId(RID_SVXSTR_COLOR) ); - InsertEntry( SvxResId(RID_SVXSTR_GRADIENT) ); - InsertEntry( SvxResId(RID_SVXSTR_HATCH) ); - InsertEntry( SvxResId(RID_SVXSTR_BITMAP) ); - InsertEntry( SvxResId(RID_SVXSTR_PATTERN) ); - - AdaptDropDownLineCountToMaximum(); - SetUpdateMode( true ); -} - void SvxFillTypeBox::Fill(weld::ComboBox& rListBox) { rListBox.freeze(); @@ -299,107 +201,6 @@ void SvxFillTypeBox::Fill(weld::ComboBox& rListBox) rListBox.set_active(1); // solid color } -SvxFillAttrBox::SvxFillAttrBox( vcl::Window* pParent ) : - ListBox(pParent, WB_BORDER | WB_DROPDOWN | WB_AUTOHSCROLL | WB_TABSTOP), - nCurPos( 0 ) -{ - SetPosPixel( Point( 90, 0 ) ); - SetSizePixel(LogicToPixel(Size(50, 80), MapMode(MapUnit::MapAppFont))); - Show(); -} - -bool SvxFillAttrBox::PreNotify( NotifyEvent& rNEvt ) -{ - MouseNotifyEvent nType = rNEvt.GetType(); - - if ( MouseNotifyEvent::MOUSEBUTTONDOWN == nType || MouseNotifyEvent::GETFOCUS == nType ) - nCurPos = GetSelectedEntryPos(); - - return ListBox::PreNotify( rNEvt ); -} - - -bool SvxFillAttrBox::EventNotify( NotifyEvent& rNEvt ) -{ - bool bHandled = ListBox::EventNotify( rNEvt ); - - if ( !bHandled && rNEvt.GetType() == MouseNotifyEvent::KEYINPUT ) - { - const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); - - switch ( pKEvt->GetKeyCode().GetCode() ) - { - case KEY_RETURN: - GetSelectHdl().Call( *this ); - bHandled = true; - break; - case KEY_TAB: - GetSelectHdl().Call( *this ); - break; - case KEY_ESCAPE: - SelectEntryPos( nCurPos ); - ReleaseFocus_Impl(); - bHandled = true; - break; - } - } - return bHandled; -} - - -void SvxFillAttrBox::ReleaseFocus_Impl() -{ - if( SfxViewShell::Current() ) - { - vcl::Window* pShellWnd = SfxViewShell::Current()->GetWindow(); - - if ( pShellWnd ) - pShellWnd->GrabFocus(); - } -} - -// Fills the listbox (provisional) with strings - -void SvxFillAttrBox::Fill( const XHatchListRef &pList ) -{ - long nCount = pList->Count(); - ListBox::SetUpdateMode( false ); - - for( long i = 0; i < nCount; i++ ) - { - const XHatchEntry* pEntry = pList->GetHatch(i); - const BitmapEx aBitmap = pList->GetUiBitmap( i ); - if( !aBitmap.IsEmpty() ) - ListBox::InsertEntry(pEntry->GetName(), Image(aBitmap)); - else - InsertEntry( pEntry->GetName() ); - } - - AdaptDropDownLineCountToMaximum(); - ListBox::SetUpdateMode( true ); -} - -// Fills the listbox (provisional) with strings - -void SvxFillAttrBox::Fill( const XGradientListRef &pList ) -{ - long nCount = pList->Count(); - ListBox::SetUpdateMode( false ); - - for( long i = 0; i < nCount; i++ ) - { - const XGradientEntry* pEntry = pList->GetGradient(i); - const BitmapEx aBitmap = pList->GetUiBitmap( i ); - if( !aBitmap.IsEmpty() ) - ListBox::InsertEntry(pEntry->GetName(), Image(aBitmap)); - else - InsertEntry( pEntry->GetName() ); - } - - AdaptDropDownLineCountToMaximum(); - ListBox::SetUpdateMode( true ); -} - namespace { void formatBitmapExToSize(BitmapEx& rBitmapEx, const Size& rSize) @@ -454,48 +255,6 @@ namespace } } // end of anonymous namespace -void SvxFillAttrBox::Fill( const XBitmapListRef &pList ) -{ - const long nCount(pList->Count()); - const XBitmapEntry* pEntry; - const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize()); - - ListBox::SetUpdateMode(false); - - for(long i(0); i < nCount; i++) - { - pEntry = pList->GetBitmap( i ); - maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx(); - formatBitmapExToSize(maBitmapEx, aSize); - ListBox::InsertEntry(pEntry->GetName(), Image(maBitmapEx)); - } - - AdaptDropDownLineCountToMaximum(); - ListBox::SetUpdateMode(true); -} - -void SvxFillAttrBox::Fill( const XPatternListRef &pList ) -{ - const long nCount(pList->Count()); - const XBitmapEntry* pEntry; - const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize()); - - ListBox::SetUpdateMode(false); - - for(long i(0); i < nCount; i++) - { - pEntry = pList->GetBitmap( i ); - maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx(); - formatBitmapExToSize(maBitmapEx, aSize); - ListBox::InsertEntry(pEntry->GetName(), Image(maBitmapEx)); - } - - AdaptDropDownLineCountToMaximum(); - ListBox::SetUpdateMode(true); -} - void SvxFillAttrBox::Fill(weld::ComboBox& rBox, const XHatchListRef &pList) { if( !pList.is() ) diff --git a/svx/uiconfig/ui/fillctrlbox.ui b/svx/uiconfig/ui/fillctrlbox.ui new file mode 100644 index 000000000000..c39a87a887c2 --- /dev/null +++ b/svx/uiconfig/ui/fillctrlbox.ui @@ -0,0 +1,110 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.22.1 --> +<interface domain="svx"> + <requires lib="gtk+" version="3.18"/> + <object class="GtkListStore" id="fillctrlboxattrmodel"> + <columns> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + <!-- column-name image --> + <column type="GdkPixbuf"/> + <!-- column-name surface --> + <column type="CairoSurface"/> + </columns> + </object> + <object class="GtkBox" id="FillCtrlBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="valign">center</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="spacing">6</property> + <child> + <object class="GtkComboBoxText" id="type"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="valign">center</property> + <property name="vexpand">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="valign">center</property> + <property name="margin_right">6</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkToolbar" id="color"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="valign">center</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="toolbar_style">icons</property> + <property name="show_arrow">False</property> + <child> + <object class="GtkMenuToolButton" id=".uno:FillColor"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_underline">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="homogeneous">False</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="attr"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="valign">center</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="entry_text_column">0</property> + <property name="model">fillctrlboxattrmodel</property> + <property name="id_column">1</property> + <child> + <object class="GtkCellRendererText" id="cellrenderertext5"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + <child> + <object class="GtkCellRendererPixbuf" id="cellrenderertext6"/> + <attributes> + <attribute name="surface">3</attribute> + </attributes> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> +</interface> |