summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-11-18 12:50:51 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-11-18 14:08:08 +0000
commit6019cd9bb5606e0d3c2dfd3acbf3a24eee85ea11 (patch)
tree03231ddea48217ad0ca0b08af33b2a63a5645493
parent079852ce8fd9d45f3cc02829c03d0ca6ddd20aa7 (diff)
want to be able to support non homogeneous buttons in buttonboxes
Change-Id: I7ea4c093d6318a24106542f851cfd58230bc3ea3
-rw-r--r--include/vcl/window.hxx7
-rw-r--r--vcl/inc/window.h3
-rw-r--r--vcl/source/window/builder.cxx4
-rw-r--r--vcl/source/window/layout.cxx13
-rw-r--r--vcl/source/window/window.cxx1
-rw-r--r--vcl/source/window/window2.cxx12
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
@@ -1208,6 +1208,13 @@ public:
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
*
* @return false if property is unknown
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<long> &rG, long nAvgDimension)
}
static std::vector<long> setButtonSizes(const std::vector<long> &rG,
+ const std::vector<bool> &rNonHomogeneous,
long nAvgDimension, long nMaxNonOutlier, long nMinWidth)
{
std::vector<long> aVec;
//set everything < 1.5 times the average to the same width, leave the
//outliers un-touched
+ std::vector<bool>::const_iterator aJ = rNonHomogeneous.begin();
for (std::vector<long>::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<long> aMainGroupSizes;
+ std::vector<bool> aMainGroupNonHomogeneous;
std::vector<long> aSubGroupSizes;
+ std::vector<bool> 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;