summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2013-06-15 14:01:12 +0200
committerJan Holesovsky <kendy@suse.cz>2013-06-15 14:42:09 +0200
commit0342b099d7079c8246684c8bafd79d98172ae029 (patch)
tree9cf53d6ae4db2b07f4887992cc1a143eaa791a2b /vcl
parent4f036439f7597d33a9f90860d9a5b6ac28b270c7 (diff)
sidebar: Make the color toolbox updater rendering more universal.
Render the color preview bigger if we have space for that. Change-Id: I5bbe5edbb8e354fc3009935d3ed6090271b72bf7
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/toolbox.h4
-rw-r--r--vcl/source/window/toolbox.cxx21
-rw-r--r--vcl/source/window/toolbox2.cxx14
3 files changed, 38 insertions, 1 deletions
diff --git a/vcl/inc/toolbox.h b/vcl/inc/toolbox.h
index 8670aeeb101b..db9370912e2a 100644
--- a/vcl/inc/toolbox.h
+++ b/vcl/inc/toolbox.h
@@ -63,12 +63,14 @@ struct ImplToolItem
OString maHelpId;
Rectangle maRect;
Rectangle maCalcRect;
- /// Widget layout may request size; set it as the minimal size.
+ /// Widget layout may request size; set it as the minimal size (like, the item will always have at least this size).
Size maMinimalItemSize;
/// The overall horizontal item size, including one or more of [image size + textlength + dropdown arrow]
Size maItemSize;
long mnSepSize;
long mnDropDownArrowWidth;
+ /// Size of the content (bitmap or text, without dropdown) that we have in the item.
+ Size maContentSize;
ToolBoxItemType meType;
ToolBoxItemBits mnBits;
TriState meState;
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 6f8b72a8075c..1a9d585ccf8c 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -1899,6 +1899,9 @@ sal_Bool ToolBox::ImplCalcItem()
it->mbEmptyBtn = sal_True;
}
+ // save the content size
+ it->maContentSize = it->maItemSize;
+
// if required, take window height into consideration
if ( it->mpWindow )
{
@@ -1921,11 +1924,16 @@ sal_Bool ToolBox::ImplCalcItem()
long tmp = it->maItemSize.Width();
it->maItemSize.Width() = it->maItemSize.Height();
it->maItemSize.Height() = tmp;
+
+ tmp = it->maContentSize.Width();
+ it->maContentSize.Width() = it->maContentSize.Height();
+ it->maContentSize.Height() = tmp;
}
}
else if ( it->meType == TOOLBOXITEM_SPACE )
{
it->maItemSize = Size( nDefWidth, nDefHeight );
+ it->maContentSize = it->maItemSize;
}
if ( it->meType == TOOLBOXITEM_BUTTON || it->meType == TOOLBOXITEM_SPACE )
@@ -1938,10 +1946,23 @@ sal_Bool ToolBox::ImplCalcItem()
long nMinW = std::max(nMinWidth, it->maMinimalItemSize.Width());
long nMinH = std::max(nMinHeight, it->maMinimalItemSize.Height());
+ long nGrowContentWidth = 0;
+ long nGrowContentHeight = 0;
+
if( it->maItemSize.Width() < nMinW )
+ {
+ nGrowContentWidth = nMinW - it->maItemSize.Width();
it->maItemSize.Width() = nMinW;
+ }
if( it->maItemSize.Height() < nMinH )
+ {
+ nGrowContentHeight = nMinH - it->maItemSize.Height();
it->maItemSize.Height() = nMinH;
+ }
+
+ // grow the content size by the additional available space
+ it->maContentSize.Width() += nGrowContentWidth;
+ it->maContentSize.Height() += nGrowContentHeight;
}
// keep track of max item size
diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx
index 69ee1252db7f..412fe331897a 100644
--- a/vcl/source/window/toolbox2.cxx
+++ b/vcl/source/window/toolbox2.cxx
@@ -170,6 +170,7 @@ ImplToolItem::ImplToolItem( const ImplToolItem& rItem ) :
maItemSize ( rItem.maItemSize ),
mnSepSize ( rItem.mnSepSize ),
mnDropDownArrowWidth ( rItem.mnDropDownArrowWidth ),
+ maContentSize ( rItem.maContentSize ),
meType ( rItem.meType ),
mnBits ( rItem.mnBits ),
meState ( rItem.meState ),
@@ -208,6 +209,7 @@ ImplToolItem& ImplToolItem::operator=( const ImplToolItem& rItem )
maCalcRect = rItem.maCalcRect;
mnSepSize = rItem.mnSepSize;
mnDropDownArrowWidth = rItem.mnDropDownArrowWidth;
+ maContentSize = rItem.maContentSize;
maMinimalItemSize = rItem.maMinimalItemSize;
maItemSize = rItem.maItemSize;
mbVisibleText = rItem.mbVisibleText;
@@ -1239,6 +1241,18 @@ Rectangle ToolBox::GetItemPosRect( sal_uInt16 nPos ) const
return Rectangle();
}
+Size ToolBox::GetItemContentSize( sal_uInt16 nItemId ) const
+{
+ if ( mbCalc || mbFormat )
+ ((ToolBox*)this)->ImplFormat();
+
+ sal_uInt16 nPos = GetItemPos( nItemId );
+ if ( nPos < mpData->m_aItems.size() )
+ return mpData->m_aItems[nPos].maContentSize;
+ else
+ return Size();
+}
+
// -----------------------------------------------------------------------
sal_Bool ToolBox::ImplHasExternalMenubutton()