summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-01-15 09:30:37 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-01-15 14:58:05 +0000
commitf70713257f47f341ffa6b500b973597d2dfc9657 (patch)
tree306fab39b4214c01f590a1bc3c082f5210b158ba /svtools
parent356f6c5d89dd4dd92b2351898e07f99b96cb34cc (diff)
teach ValueSet to calc an optimal size
Change-Id: Ibb0eb8caf61a8310850f6b9889cdb1304c5be5e4
Diffstat (limited to 'svtools')
-rw-r--r--svtools/inc/svtools/valueset.hxx3
-rw-r--r--svtools/source/control/valueset.cxx35
2 files changed, 36 insertions, 2 deletions
diff --git a/svtools/inc/svtools/valueset.hxx b/svtools/inc/svtools/valueset.hxx
index 9d0885676c8c..cdbbd4d8ba33 100644
--- a/svtools/inc/svtools/valueset.hxx
+++ b/svtools/inc/svtools/valueset.hxx
@@ -301,6 +301,7 @@ public:
virtual void GetFocus();
virtual void LoseFocus();
virtual void Resize();
+ virtual Size GetOptimalSize() const;
virtual void RequestHelp( const HelpEvent& rHEvt );
virtual void StateChanged( StateChangedType nStateChange );
virtual void DataChanged( const DataChangedEvent& rDCEvt );
@@ -373,7 +374,7 @@ public:
Size CalcWindowSizePixel( const Size& rItemSize,
sal_uInt16 nCalcCols = 0,
- sal_uInt16 nCalcLines = 0 );
+ sal_uInt16 nCalcLines = 0 ) const;
Size CalcItemSizePixel( const Size& rSize, bool bOut = true ) const;
long GetScrollWidth() const;
diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx
index 3513b11280ba..faf526325be7 100644
--- a/svtools/source/control/valueset.cxx
+++ b/svtools/source/control/valueset.cxx
@@ -1702,6 +1702,8 @@ void ValueSet::ImplInsertItem( ValueSetItem *const pItem, const size_t nPos )
mItemList.push_back( pItem );
}
+ queue_resize();
+
mbFormat = true;
if ( IsReallyVisible() && IsUpdateMode() )
Invalidate();
@@ -1754,6 +1756,8 @@ void ValueSet::RemoveItem( sal_uInt16 nItemId )
mbNoSelection = true;
}
+ queue_resize();
+
mbFormat = true;
if ( IsReallyVisible() && IsUpdateMode() )
Invalidate();
@@ -1841,6 +1845,7 @@ void ValueSet::SetColCount( sal_uInt16 nNewCols )
{
mnUserCols = nNewCols;
mbFormat = true;
+ queue_resize();
if ( IsReallyVisible() && IsUpdateMode() )
Invalidate();
}
@@ -1854,6 +1859,7 @@ void ValueSet::SetLineCount( sal_uInt16 nNewLines )
{
mnUserVisLines = nNewLines;
mbFormat = true;
+ queue_resize();
if ( IsReallyVisible() && IsUpdateMode() )
Invalidate();
}
@@ -1867,6 +1873,7 @@ void ValueSet::SetItemWidth( long nNewItemWidth )
{
mnUserItemWidth = nNewItemWidth;
mbFormat = true;
+ queue_resize();
if ( IsReallyVisible() && IsUpdateMode() )
Invalidate();
}
@@ -1880,6 +1887,7 @@ void ValueSet::SetItemHeight( long nNewItemHeight )
{
mnUserItemHeight = nNewItemHeight;
mbFormat = true;
+ queue_resize();
if ( IsReallyVisible() && IsUpdateMode() )
Invalidate();
}
@@ -2199,6 +2207,7 @@ void ValueSet::SetExtraSpacing( sal_uInt16 nNewSpacing )
mnSpacing = nNewSpacing;
mbFormat = true;
+ queue_resize();
if ( IsReallyVisible() && IsUpdateMode() )
Invalidate();
}
@@ -2271,7 +2280,7 @@ bool ValueSet::StartDrag( const CommandEvent& rCEvt, Region& rRegion )
// -----------------------------------------------------------------------
Size ValueSet::CalcWindowSizePixel( const Size& rItemSize, sal_uInt16 nDesireCols,
- sal_uInt16 nDesireLines )
+ sal_uInt16 nDesireLines ) const
{
size_t nCalcCols = nDesireCols;
size_t nCalcLines = nDesireLines;
@@ -2397,4 +2406,28 @@ void ValueSet::SetHighlightHdl( const Link& rLink )
maHighlightHdl = rLink;
}
+Size ValueSet::GetOptimalSize() const
+{
+ Size aLargestItemSize;
+
+ for (size_t i = 0, n = mItemList.size(); i < n; ++i)
+ {
+ const ValueSetItem* pItem = mItemList[i];
+ if (!pItem->mbVisible)
+ continue;
+
+ if (pItem->meType != VALUESETITEM_IMAGE)
+ {
+ //handle determining an optimal size for this case
+ continue;
+ }
+
+ Size aImageSize = pItem->maImage.GetSizePixel();
+ aLargestItemSize.Width() = std::max(aLargestItemSize.Width(), aImageSize.Width());
+ aLargestItemSize.Height() = std::max(aLargestItemSize.Height(), aImageSize.Height());
+ }
+
+ return CalcWindowSizePixel(aLargestItemSize);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */