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 Change-Id: I85cb3ff98f23d21d7cfdcc28188e36616a19b5e8
This commit is contained in:
@@ -50,9 +50,20 @@ private:
|
|||||||
Link maSelectHdl;
|
Link maSelectHdl;
|
||||||
Link maDoubleClickHdl;
|
Link maDoubleClickHdl;
|
||||||
|
|
||||||
|
struct ComboBoxBounds
|
||||||
|
{
|
||||||
|
Point aSubEditPos;
|
||||||
|
Size aSubEditSize;
|
||||||
|
|
||||||
|
Point aButtonPos;
|
||||||
|
Size aButtonSize;
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SAL_DLLPRIVATE void ImplInitComboBoxData();
|
SAL_DLLPRIVATE void ImplInitComboBoxData();
|
||||||
SAL_DLLPRIVATE void ImplUpdateFloatSelection();
|
SAL_DLLPRIVATE void ImplUpdateFloatSelection();
|
||||||
|
SAL_DLLPRIVATE ComboBoxBounds calcComboBoxDropDownComponentBounds(
|
||||||
|
const Size &rOutSize, const Size &rBorderOutSize) const;
|
||||||
|
|
||||||
DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* );
|
DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* );
|
||||||
DECL_DLLPRIVATE_LINK( ImplCancelHdl, void* );
|
DECL_DLLPRIVATE_LINK( ImplCancelHdl, void* );
|
||||||
|
@@ -597,50 +597,10 @@ void ComboBox::Resize()
|
|||||||
Size aOutSz = GetOutputSizePixel();
|
Size aOutSz = GetOutputSizePixel();
|
||||||
if( IsDropDownBox() )
|
if( IsDropDownBox() )
|
||||||
{
|
{
|
||||||
long nTop = 0;
|
ComboBoxBounds aBounds(calcComboBoxDropDownComponentBounds(aOutSz,
|
||||||
long nBottom = aOutSz.Height();
|
GetWindow(WINDOW_BORDER)->GetOutputSizePixel()));
|
||||||
|
mpSubEdit->SetPosSizePixel(aBounds.aSubEditPos, aBounds.aSubEditSize);
|
||||||
Window *pBorder = GetWindow( WINDOW_BORDER );
|
mpBtn->SetPosSizePixel(aBounds.aButtonPos, aBounds.aButtonSize);
|
||||||
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) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1106,12 +1066,15 @@ Size ComboBox::CalcMinimumSize() const
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
aSz.Height() = Edit::CalcMinimumSizeForText(GetText()).Height();
|
aSz.Height() = Edit::CalcMinimumSizeForText(GetText()).Height();
|
||||||
|
|
||||||
aSz.Width() = mpImplLB->GetMaxEntryWidth();
|
aSz.Width() = mpImplLB->GetMaxEntryWidth();
|
||||||
aSz.Width() += getMaxWidthScrollBarAndDownButton();
|
aSz.Width() += getMaxWidthScrollBarAndDownButton();
|
||||||
|
ComboBoxBounds aBounds(calcComboBoxDropDownComponentBounds(
|
||||||
|
Size(0xFFFF, 0xFFFF), Size(0xFFFF, 0xFFFF)));
|
||||||
|
aSz.Width() += aBounds.aSubEditPos.X()*2;
|
||||||
}
|
}
|
||||||
|
|
||||||
aSz.Width() += ImplGetExtraOffset() * 2;
|
aSz.Width() += ImplGetExtraOffset() * 2;
|
||||||
aSz.Width() += mpSubEdit->GetPosPixel().X();
|
|
||||||
|
|
||||||
aSz = CalcWindowSize( aSz );
|
aSz = CalcWindowSize( aSz );
|
||||||
return aSz;
|
return aSz;
|
||||||
@@ -1529,4 +1492,58 @@ long ComboBox::GetIndexForPoint( const Point& rPoint, sal_uInt16& rPos ) const
|
|||||||
return nIndex;
|
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: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
Reference in New Issue
Block a user