summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-01-11 16:35:17 +0000
committerNoel Power <noel.power@suse.com>2013-01-14 10:59:16 +0000
commitc246579a807946e649ec009eba320b69ff56c03e (patch)
tree297944fca8dac5d01cb894fa6311a53d5c5bd2e8 /vcl
parentb825f95fa100f2a54032ec5a1ff51de0db17ea1d (diff)
split out the ComboBox code that determines the positioning of subwidgets
and re-use it to get a better calculation of the optimal size of a widget, rather than taking the current position of the subedit the upshot of this is that with CTL and/or CJK mode enabled in... a) calc, then the format->cells font dialog doesn't have squashed font size and font style listboxes b) writer, the 10.5 default size for CJK doesn't have part of the .5 clipped off it the calcComboBoxDropDownComponentBounds code should be entirely equivalent to the existing ::Resize calculation given the same input, we just call it with effectively unbounded available size in the GetOptimalSize case to find the desired margins around the subedit field (cherry picked from commit d19eab221f168aed12249ffc8a36a9f1aca5a94e) Change-Id: I85cb3ff98f23d21d7cfdcc28188e36616a19b5e8 Reviewed-on: https://gerrit.libreoffice.org/1657 Reviewed-by: Noel Power <noel.power@suse.com> Tested-by: Noel Power <noel.power@suse.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/vcl/combobox.hxx11
-rw-r--r--vcl/source/control/combobox.cxx107
2 files changed, 73 insertions, 45 deletions
diff --git a/vcl/inc/vcl/combobox.hxx b/vcl/inc/vcl/combobox.hxx
index d1704dcc9efe..72478c59a713 100644
--- a/vcl/inc/vcl/combobox.hxx
+++ b/vcl/inc/vcl/combobox.hxx
@@ -50,9 +50,20 @@ private:
Link maSelectHdl;
Link maDoubleClickHdl;
+ struct ComboBoxBounds
+ {
+ Point aSubEditPos;
+ Size aSubEditSize;
+
+ Point aButtonPos;
+ Size aButtonSize;
+ };
+
private:
SAL_DLLPRIVATE void ImplInitComboBoxData();
SAL_DLLPRIVATE void ImplUpdateFloatSelection();
+ SAL_DLLPRIVATE ComboBoxBounds calcComboBoxDropDownComponentBounds(
+ const Size &rOutSize, const Size &rBorderOutSize) const;
DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* );
DECL_DLLPRIVATE_LINK( ImplCancelHdl, void* );
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index a0f8982e9ec6..389929c34b53 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -597,50 +597,10 @@ void ComboBox::Resize()
Size aOutSz = GetOutputSizePixel();
if( IsDropDownBox() )
{
- long nTop = 0;
- long nBottom = aOutSz.Height();
-
- Window *pBorder = GetWindow( WINDOW_BORDER );
- ImplControlValue aControlValue;
- Point aPoint;
- Rectangle aContent, aBound;
-
- // use the full extent of the control
- Rectangle aArea( aPoint, pBorder->GetOutputSizePixel() );
-
- if ( GetNativeControlRegion(CTRL_COMBOBOX, PART_BUTTON_DOWN,
- aArea, 0, aControlValue, rtl::OUString(), aBound, aContent) )
- {
- // convert back from border space to local coordinates
- aPoint = pBorder->ScreenToOutputPixel( OutputToScreenPixel( aPoint ) );
- aContent.Move(-aPoint.X(), -aPoint.Y());
-
- mpBtn->setPosSizePixel( aContent.Left(), nTop, aContent.getWidth(), (nBottom-nTop) );
-
- // adjust the size of the edit field
- if ( GetNativeControlRegion(CTRL_COMBOBOX, PART_SUB_EDIT,
- aArea, 0, aControlValue, rtl::OUString(), aBound, aContent) )
- {
- // convert back from border space to local coordinates
- aContent.Move(-aPoint.X(), -aPoint.Y());
-
- // use the themes drop down size
- mpSubEdit->SetPosSizePixel( aContent.TopLeft(), aContent.GetSize() );
- }
- else
- {
- // use the themes drop down size for the button
- aOutSz.Width() -= aContent.getWidth();
- mpSubEdit->SetSizePixel( aOutSz );
- }
- }
- else
- {
- long nSBWidth = GetSettings().GetStyleSettings().GetScrollBarSize();
- nSBWidth = CalcZoom( nSBWidth );
- mpSubEdit->SetPosSizePixel( Point( 0, 0 ), Size( aOutSz.Width() - nSBWidth, aOutSz.Height() ) );
- mpBtn->setPosSizePixel( aOutSz.Width() - nSBWidth, nTop, nSBWidth, (nBottom-nTop) );
- }
+ ComboBoxBounds aBounds(calcComboBoxDropDownComponentBounds(aOutSz,
+ GetWindow(WINDOW_BORDER)->GetOutputSizePixel()));
+ mpSubEdit->SetPosSizePixel(aBounds.aSubEditPos, aBounds.aSubEditSize);
+ mpBtn->SetPosSizePixel(aBounds.aButtonPos, aBounds.aButtonSize);
}
else
{
@@ -1106,12 +1066,15 @@ Size ComboBox::CalcMinimumSize() const
else
{
aSz.Height() = Edit::CalcMinimumSizeForText(GetText()).Height();
+
aSz.Width() = mpImplLB->GetMaxEntryWidth();
aSz.Width() += getMaxWidthScrollBarAndDownButton();
+ ComboBoxBounds aBounds(calcComboBoxDropDownComponentBounds(
+ Size(0xFFFF, 0xFFFF), Size(0xFFFF, 0xFFFF)));
+ aSz.Width() += aBounds.aSubEditPos.X()*2;
}
aSz.Width() += ImplGetExtraOffset() * 2;
- aSz.Width() += mpSubEdit->GetPosPixel().X();
aSz = CalcWindowSize( aSz );
return aSz;
@@ -1529,4 +1492,58 @@ long ComboBox::GetIndexForPoint( const Point& rPoint, sal_uInt16& rPos ) const
return nIndex;
}
+ComboBox::ComboBoxBounds ComboBox::calcComboBoxDropDownComponentBounds(const Size &rOutSz,
+ const Size &rBorderOutSz) const
+{
+ ComboBoxBounds aBounds;
+
+ long nTop = 0;
+ long nBottom = rOutSz.Height();
+
+ Window *pBorder = GetWindow( WINDOW_BORDER );
+ ImplControlValue aControlValue;
+ Point aPoint;
+ Rectangle aContent, aBound;
+
+ // use the full extent of the control
+ Rectangle aArea( aPoint, rBorderOutSz );
+
+ if ( GetNativeControlRegion(CTRL_COMBOBOX, PART_BUTTON_DOWN,
+ aArea, 0, aControlValue, rtl::OUString(), aBound, aContent) )
+ {
+ // convert back from border space to local coordinates
+ aPoint = pBorder->ScreenToOutputPixel( OutputToScreenPixel( aPoint ) );
+ aContent.Move(-aPoint.X(), -aPoint.Y());
+
+ aBounds.aButtonPos = Point(aContent.Left(), nTop);
+ aBounds.aButtonSize = Size(aContent.getWidth(), (nBottom-nTop));
+
+ // adjust the size of the edit field
+ if ( GetNativeControlRegion(CTRL_COMBOBOX, PART_SUB_EDIT,
+ aArea, 0, aControlValue, rtl::OUString(), aBound, aContent) )
+ {
+ // convert back from border space to local coordinates
+ aContent.Move(-aPoint.X(), -aPoint.Y());
+
+ // use the themes drop down size
+ aBounds.aSubEditPos = aContent.TopLeft();
+ aBounds.aSubEditSize = aContent.GetSize();
+ }
+ else
+ {
+ // use the themes drop down size for the button
+ aBounds.aSubEditSize = Size(rOutSz.Width() - aContent.getWidth(), rOutSz.Height());
+ }
+ }
+ else
+ {
+ long nSBWidth = GetSettings().GetStyleSettings().GetScrollBarSize();
+ nSBWidth = CalcZoom( nSBWidth );
+ aBounds.aSubEditSize = Size(rOutSz.Width() - nSBWidth, rOutSz.Height());
+ aBounds.aButtonPos = Point(rOutSz.Width() - nSBWidth, nTop);
+ aBounds.aButtonSize = Size(nSBWidth, (nBottom-nTop));
+ }
+ return aBounds;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */