diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-10-26 09:15:43 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-10-26 12:12:03 +0100 |
commit | 55619c1028b31f55c5b205ce3615bd606f5414f0 (patch) | |
tree | 99753d34e49027821b742b96f14eff0fc55e1676 /vcl/source | |
parent | aed681368255b67f1c9de8d501d171a784118dd3 (diff) |
set width in chars for url field to avoid character dialog overgrowing
Change-Id: I892a77f65ad420d0fbf4b95179e4bcfc2ec55192
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/control/combobox.cxx | 6 | ||||
-rw-r--r-- | vcl/source/control/edit.cxx | 40 |
2 files changed, 30 insertions, 16 deletions
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx index 6dae2238da12..49558e25e3d1 100644 --- a/vcl/source/control/combobox.cxx +++ b/vcl/source/control/combobox.cxx @@ -61,7 +61,7 @@ ComboBox::ComboBox( WindowType nType ) : Edit( nType ) { ImplInitComboBoxData(); - SetMinWidthInChars(0); + SetWidthInChars(-1); } // ----------------------------------------------------------------------- @@ -71,7 +71,7 @@ ComboBox::ComboBox( Window* pParent, WinBits nStyle ) : { ImplInitComboBoxData(); ImplInit( pParent, nStyle ); - SetMinWidthInChars(0); + SetWidthInChars(-1); } // ----------------------------------------------------------------------- @@ -85,7 +85,7 @@ ComboBox::ComboBox( Window* pParent, const ResId& rResId ) : ImplInit( pParent, nStyle ); ImplLoadRes( rResId ); - SetMinWidthInChars(0); + SetWidthInChars(-1); if ( !(nStyle & WB_HIDE ) ) Show(); } diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index d3be1ba21656..f5a5f41bfb1d 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -219,11 +219,11 @@ Edit::Edit( Window* pParent, const ResId& rResId ) : Show(); } -void Edit::SetMinWidthInChars(sal_Int32 nMinWidthInChars) +void Edit::SetWidthInChars(sal_Int32 nWidthInChars) { - if (mnMinWidthInChars != nMinWidthInChars) + if (mnWidthInChars != nWidthInChars) { - mnMinWidthInChars = nMinWidthInChars; + mnWidthInChars = nWidthInChars; queue_resize(); } } @@ -231,7 +231,12 @@ void Edit::SetMinWidthInChars(sal_Int32 nMinWidthInChars) bool Edit::set_property(const rtl::OString &rKey, const rtl::OString &rValue) { if (rKey == "width-chars") - SetMinWidthInChars(rValue.toInt32()); + SetWidthInChars(rValue.toInt32()); + else if (rKey == "max-length") + { + sal_Int32 nTextLen = rValue.toInt32(); + SetMaxTextLen(nTextLen == 0 ? EDIT_NOLIMIT : nTextLen); + } else if (rKey == "editable") SetReadOnly(!toBool(rValue)); else if (rKey == "visibility") @@ -266,7 +271,7 @@ void Edit::take_properties(Window &rOther) maSelection = rOtherEdit.maSelection; mnAlign = rOtherEdit.mnAlign; mnMaxTextLen = rOtherEdit.mnMaxTextLen; - mnMinWidthInChars = rOtherEdit.mnMinWidthInChars; + mnWidthInChars = rOtherEdit.mnWidthInChars; meAutocompleteAction = rOtherEdit.meAutocompleteAction; mcEchoChar = rOtherEdit.mcEchoChar; mbModified = rOtherEdit.mbModified; @@ -341,7 +346,7 @@ void Edit::ImplInitEditData() mnXOffset = 0; mnAlign = EDIT_ALIGN_LEFT; mnMaxTextLen = EDIT_NOLIMIT; - mnMinWidthInChars = 3; + mnWidthInChars = -1; meAutocompleteAction = AUTOCOMPLETE_KEYINPUT; mbModified = sal_False; mbInternModified = sal_False; @@ -2890,13 +2895,22 @@ void Edit::SetSubEdit( Edit* pEdit ) Size Edit::CalcMinimumSizeForText(const rtl::OUString &rString) const { - Size aSize ( GetTextWidth( rString ), GetTextHeight() ); - aSize.Width() += ImplGetExtraOffset() * 2; - // do not create edit fields in which one cannot enter anything - // a default minimum width should exist for at least 3 characters - Size aMinSize ( CalcSize( mnMinWidthInChars ) ); - if( aSize.Width() < aMinSize.Width() ) - aSize.Width() = aMinSize.Width(); + Size aSize; + if (mnWidthInChars != -1) + { + aSize = CalcSize(mnWidthInChars); + } + else + { + aSize.Height() = GetTextHeight(); + aSize.Width() = GetTextWidth(rString); + aSize.Width() += ImplGetExtraOffset() * 2; + // do not create edit fields in which one cannot enter anything + // a default minimum width should exist for at least 3 characters + Size aMinSize(CalcSize(3)); + if (aSize.Width() < aMinSize.Width()) + aSize.Width() = aMinSize.Width(); + } // add some space between text entry and border aSize.Height() += 4; |