From 9495e912797f67897a4a658d20137bb94f39e9ab Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 24 Jun 2013 12:42:39 +0100 Subject: Resolves: fdo#66105 set max growth width for labels/edits which take paths Change-Id: I12220821f76550baacdc8ce604f2e612d260c1a1 --- vcl/source/control/edit.cxx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'vcl') diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index cfd4d3353541..70f19f9004ec 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -214,10 +214,22 @@ void Edit::SetWidthInChars(sal_Int32 nWidthInChars) } } +void Edit::setMaxWidthChars(sal_Int32 nWidth) +{ + if (nWidth != mnMaxWidthChars) + { + mnMaxWidthChars = nWidth; + fprintf(stderr, "setMaxWidthChars of %d\n", nWidth); + queue_resize(); + } +} + bool Edit::set_property(const OString &rKey, const OString &rValue) { if (rKey == "width-chars") SetWidthInChars(rValue.toInt32()); + else if (rKey == "max-width-chars") + setMaxWidthChars(rValue.toInt32()); else if (rKey == "max-length") { sal_Int32 nTextLen = rValue.toInt32(); @@ -295,6 +307,7 @@ void Edit::ImplInitEditData() mnAlign = EDIT_ALIGN_LEFT; mnMaxTextLen = EDIT_NOLIMIT; mnWidthInChars = -1; + mnMaxWidthChars = -1; meAutocompleteAction = AUTOCOMPLETE_KEYINPUT; mbModified = sal_False; mbInternModified = sal_False; @@ -2886,8 +2899,14 @@ Size Edit::CalcMinimumSizeForText(const OUString &rString) const } else { + OUString aString; + if (mnMaxWidthChars != -1 && mnMaxWidthChars < rString.getLength()) + aString = rString.copy(0, mnMaxWidthChars); + else + aString = rString; + aSize.Height() = GetTextHeight(); - aSize.Width() = GetTextWidth(rString); + aSize.Width() = GetTextWidth(aString); 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 -- cgit