diff --git a/include/sfx2/sidebar/SidebarToolBox.hxx b/include/sfx2/sidebar/SidebarToolBox.hxx index c5bbc144349b..c86106201aa0 100644 --- a/include/sfx2/sidebar/SidebarToolBox.hxx +++ b/include/sfx2/sidebar/SidebarToolBox.hxx @@ -56,6 +56,7 @@ public: virtual void InsertItem(const OUString& rCommand, const com::sun::star::uno::Reference& rFrame, ToolBoxItemBits nBits = 0, + const Size& rRequestedSize = Size(), sal_uInt16 nPos = TOOLBOX_APPEND); void SetBorderWindow (const Window* pBorderWindow); diff --git a/include/vcl/toolbox.hxx b/include/vcl/toolbox.hxx index 702f81920329..9c619ea35afd 100644 --- a/include/vcl/toolbox.hxx +++ b/include/vcl/toolbox.hxx @@ -343,6 +343,7 @@ public: virtual void InsertItem( const OUString& rCommand, const com::sun::star::uno::Reference& rFrame, ToolBoxItemBits nBits = 0, + const Size& rRequestedSize = Size(), sal_uInt16 nPos = TOOLBOX_APPEND ); void InsertItem( sal_uInt16 nItemId, const Image& rImage, ToolBoxItemBits nBits = 0, diff --git a/sfx2/source/sidebar/SidebarToolBox.cxx b/sfx2/source/sidebar/SidebarToolBox.cxx index 5039a1a675b0..be0187e17a0f 100644 --- a/sfx2/source/sidebar/SidebarToolBox.cxx +++ b/sfx2/source/sidebar/SidebarToolBox.cxx @@ -125,11 +125,11 @@ SidebarToolBox::~SidebarToolBox (void) void SidebarToolBox::InsertItem(const OUString& rCommand, const com::sun::star::uno::Reference& rFrame, - ToolBoxItemBits nBits, sal_uInt16 nPos) + ToolBoxItemBits nBits, const Size& rRequestedSize, sal_uInt16 nPos) { - ToolBox::InsertItem(rCommand, rFrame, nBits, nPos); + ToolBox::InsertItem(rCommand, rFrame, nBits, rRequestedSize, nPos); - CreateController(GetItemId(rCommand), rFrame, 0); + CreateController(GetItemId(rCommand), rFrame, std::max(rRequestedSize.Width(), 0L)); RegisterHandlers(); } diff --git a/vcl/inc/toolbox.h b/vcl/inc/toolbox.h index 6a00fadf6d07..8670aeeb101b 100644 --- a/vcl/inc/toolbox.h +++ b/vcl/inc/toolbox.h @@ -63,7 +63,9 @@ struct ImplToolItem OString maHelpId; Rectangle maRect; Rectangle maCalcRect; - // the overall horizontal item size, including one or more of [image size + textlength + dropdown arrow] + /// Widget layout may request size; set it as the minimal size. + Size maMinimalItemSize; + /// The overall horizontal item size, including one or more of [image size + textlength + dropdown arrow] Size maItemSize; long mnSepSize; long mnDropDownArrowWidth; diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 73a06c8730fd..7d44293f3196 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -633,6 +633,25 @@ namespace return sActionName; } + Size extractSizeRequest(VclBuilder::stringmap &rMap) + { + OString sWidthRequest("0"); + OString sHeightRequest("0"); + VclBuilder::stringmap::iterator aFind = rMap.find(OString("width-request")); + if (aFind != rMap.end()) + { + sWidthRequest = aFind->second; + rMap.erase(aFind); + } + aFind = rMap.find(OString("height-request")); + if (aFind != rMap.end()) + { + sHeightRequest = aFind->second; + rMap.erase(aFind); + } + return Size(sWidthRequest.toInt32(), sHeightRequest.toInt32()); + } + Window * extractStockAndBuildPushButton(Window *pParent, VclBuilder::stringmap &rMap) { WinBits nBits = WB_CENTER|WB_VCENTER|WB_3DLOOK; @@ -1259,7 +1278,7 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri nBits |= TIB_DROPDOWN; if (!aCommand.isEmpty()) - pToolBox->InsertItem(aCommand, m_xFrame, nBits); + pToolBox->InsertItem(aCommand, m_xFrame, nBits, extractSizeRequest(rMap)); return NULL; // no widget to be created } diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx index 7582fcedd78e..6f8b72a8075c 100644 --- a/vcl/source/window/toolbox.cxx +++ b/vcl/source/window/toolbox.cxx @@ -1935,10 +1935,13 @@ sal_Bool ToolBox::ImplCalcItem() if( it->meType == TOOLBOXITEM_BUTTON ) { - if( it->maItemSize.Width() < nMinWidth ) - it->maItemSize.Width() = nMinWidth; - if( it->maItemSize.Height() < nMinHeight ) - it->maItemSize.Height() = nMinHeight; + long nMinW = std::max(nMinWidth, it->maMinimalItemSize.Width()); + long nMinH = std::max(nMinHeight, it->maMinimalItemSize.Height()); + + if( it->maItemSize.Width() < nMinW ) + it->maItemSize.Width() = nMinW; + if( it->maItemSize.Height() < nMinH ) + it->maItemSize.Height() = nMinH; } // keep track of max item size diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx index 6634361a42db..69ee1252db7f 100644 --- a/vcl/source/window/toolbox2.cxx +++ b/vcl/source/window/toolbox2.cxx @@ -166,6 +166,7 @@ ImplToolItem::ImplToolItem( const ImplToolItem& rItem ) : maHelpId ( rItem.maHelpId ), maRect ( rItem.maRect ), maCalcRect ( rItem.maCalcRect ), + maMinimalItemSize ( rItem.maMinimalItemSize ), maItemSize ( rItem.maItemSize ), mnSepSize ( rItem.mnSepSize ), mnDropDownArrowWidth ( rItem.mnDropDownArrowWidth ), @@ -207,6 +208,7 @@ ImplToolItem& ImplToolItem::operator=( const ImplToolItem& rItem ) maCalcRect = rItem.maCalcRect; mnSepSize = rItem.mnSepSize; mnDropDownArrowWidth = rItem.mnDropDownArrowWidth; + maMinimalItemSize = rItem.maMinimalItemSize; maItemSize = rItem.maItemSize; mbVisibleText = rItem.mbVisibleText; meType = rItem.meType; @@ -758,7 +760,7 @@ static Image getCommandImage(const OUString& rCommand, bool bLarge, return Image(); } -void ToolBox::InsertItem(const OUString& rCommand, const uno::Reference& rFrame, ToolBoxItemBits nBits, sal_uInt16 nPos) +void ToolBox::InsertItem(const OUString& rCommand, const uno::Reference& rFrame, ToolBoxItemBits nBits, const Size& rRequestedSize, sal_uInt16 nPos) { uno::Reference xContext(comphelper::getProcessComponentContext()); uno::Reference xModuleManager(frame::ModuleManager::create(xContext)); @@ -773,6 +775,11 @@ void ToolBox::InsertItem(const OUString& rCommand, const uno::ReferencemaMinimalItemSize = rRequestedSize; } // -----------------------------------------------------------------------