From 6019cd9bb5606e0d3c2dfd3acbf3a24eee85ea11 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 18 Nov 2013 12:50:51 +0000 Subject: want to be able to support non homogeneous buttons in buttonboxes Change-Id: I7ea4c093d6318a24106542f851cfd58230bc3ea3 --- include/vcl/window.hxx | 7 +++++++ vcl/inc/window.h | 3 ++- vcl/source/window/builder.cxx | 4 ++++ vcl/source/window/layout.cxx | 13 +++++++++++-- vcl/source/window/window.cxx | 1 + vcl/source/window/window2.cxx | 12 ++++++++++++ 6 files changed, 37 insertions(+), 3 deletions(-) diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index e351fdd69e98..a8d6883b8ef4 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -1207,6 +1207,13 @@ public: bool get_secondary() const; void set_secondary(bool bSecondary); + /* + * If true this child is exempted from homogenous sizing + * e.g. special button in a buttonbox + */ + bool get_non_homogeneous() const; + void set_non_homogeneous(bool bNonHomogeneous); + /* * Sets a widget property * diff --git a/vcl/inc/window.h b/vcl/inc/window.h index 42998d025b01..87fb5aa331ab 100644 --- a/vcl/inc/window.h +++ b/vcl/inc/window.h @@ -396,7 +396,8 @@ public: mbVexpand:1, mbExpand:1, mbFill:1, - mbSecondary:1; + mbSecondary:1, + mbNonHomogeneous:1; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxDNDListenerContainer; }; diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index f581f59ba23d..e2f306dbf780 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -2706,6 +2706,10 @@ void VclBuilder::applyPackingProperty(Window *pCurrent, { pCurrent->set_secondary(toBool(sValue)); } + else if (sKey == "non-homogeneous") + { + pCurrent->set_non_homogeneous(toBool(sValue)); + } else { SAL_WARN("vcl.layout", "unknown packing: " << sKey.getStr()); diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index 973782905e93..1532ce929cc4 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -377,16 +377,19 @@ static long getMaxNonOutlier(const std::vector &rG, long nAvgDimension) } static std::vector setButtonSizes(const std::vector &rG, + const std::vector &rNonHomogeneous, long nAvgDimension, long nMaxNonOutlier, long nMinWidth) { std::vector aVec; //set everything < 1.5 times the average to the same width, leave the //outliers un-touched + std::vector::const_iterator aJ = rNonHomogeneous.begin(); for (std::vector::const_iterator aI = rG.begin(), aEnd = rG.end(); - aI != aEnd; ++aI) + aI != aEnd; ++aI, ++aJ) { long nPrimaryChildDimension = *aI; - if (nPrimaryChildDimension < nAvgDimension * 1.5) + bool bNonHomogeneous = *aJ; + if (!bNonHomogeneous && nPrimaryChildDimension < nAvgDimension * 1.5) { aVec.push_back(std::max(nMaxNonOutlier, nMinWidth)); } @@ -413,7 +416,9 @@ VclButtonBox::Requisition VclButtonBox::calculatePrimarySecondaryRequisitions() bool bIgnoreSecondaryPacking = (m_eLayoutStyle == VCL_BUTTONBOX_SPREAD || m_eLayoutStyle == VCL_BUTTONBOX_CENTER); std::vector aMainGroupSizes; + std::vector aMainGroupNonHomogeneous; std::vector aSubGroupSizes; + std::vector aSubGroupNonHomogeneous; for (const Window *pChild = GetWindow(WINDOW_FIRSTCHILD); pChild; pChild = pChild->GetWindow(WINDOW_NEXT)) { @@ -426,11 +431,13 @@ VclButtonBox::Requisition VclButtonBox::calculatePrimarySecondaryRequisitions() nMainGroupSecondary = std::max(nMainGroupSecondary, getSecondaryDimension(aChildSize)); //collect the primary dimensions aMainGroupSizes.push_back(getPrimaryDimension(aChildSize)); + aMainGroupNonHomogeneous.push_back(pChild->get_non_homogeneous()); } else { nSubGroupSecondary = std::max(nSubGroupSecondary, getSecondaryDimension(aChildSize)); aSubGroupSizes.push_back(getPrimaryDimension(aChildSize)); + aSubGroupNonHomogeneous.push_back(pChild->get_non_homogeneous()); } } @@ -468,8 +475,10 @@ VclButtonBox::Requisition VclButtonBox::calculatePrimarySecondaryRequisitions() long nMaxNonOutlier = std::max(nMaxMainNonOutlier, nMaxSubNonOutlier); aReq.m_aMainGroupDimensions = setButtonSizes(aMainGroupSizes, + aMainGroupNonHomogeneous, nAvgDimension, nMaxNonOutlier, nMinMainGroupPrimary); aReq.m_aSubGroupDimensions = setButtonSizes(aSubGroupSizes, + aSubGroupNonHomogeneous, nAvgDimension, nMaxNonOutlier, nMinSubGroupPrimary); } diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 24edbd1e2e4b..64664b167c15 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -295,6 +295,7 @@ WindowImpl::WindowImpl( WindowType nType ) mbExpand = false; mbFill = true; mbSecondary = false; + mbNonHomogeneous = false; } WindowImpl::~WindowImpl() diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx index 49f7650786ac..2a5f2e0d08f1 100644 --- a/vcl/source/window/window2.cxx +++ b/vcl/source/window/window2.cxx @@ -2336,6 +2336,18 @@ void Window::set_secondary(bool bSecondary) pWindowImpl->mbSecondary = bSecondary; } +bool Window::get_non_homogeneous() const +{ + WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl; + return pWindowImpl->mbNonHomogeneous; +} + +void Window::set_non_homogeneous(bool bNonHomogeneous) +{ + WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl; + pWindowImpl->mbNonHomogeneous = bNonHomogeneous; +} + void Window::add_to_size_group(boost::shared_ptr< VclSizeGroup > xGroup) { WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl; -- cgit v1.2.3