[PATCH] Change in core[libreoffice-4-0]: split out the ComboBox code that determines the positioning ...
Caolán McNamara (via_Code_Review)
gerrit at gerrit.libreoffice.org
Fri Jan 11 11:50:24 PST 2013
Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/1657
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/57/1657/1
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
---
M vcl/inc/vcl/combobox.hxx
M vcl/source/control/combobox.cxx
2 files changed, 73 insertions(+), 45 deletions(-)
diff --git a/vcl/inc/vcl/combobox.hxx b/vcl/inc/vcl/combobox.hxx
index d1704dc..72478c5 100644
--- a/vcl/inc/vcl/combobox.hxx
+++ b/vcl/inc/vcl/combobox.hxx
@@ -50,9 +50,20 @@
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 a0f8982..389929c3 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -597,50 +597,10 @@
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 @@
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 @@
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: */
--
To view, visit https://gerrit.libreoffice.org/1657
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I85cb3ff98f23d21d7cfdcc28188e36616a19b5e8
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Caolán McNamara <caolanm at redhat.com>
More information about the LibreOffice
mailing list