Kaydet (Commit) 55619c10 authored tarafından Caolán McNamara's avatar Caolán McNamara

set width in chars for url field to avoid character dialog overgrowing

Change-Id: I892a77f65ad420d0fbf4b95179e4bcfc2ec55192
üst aed68136
......@@ -129,7 +129,7 @@ void ReturnActionEdit::KeyInput( const KeyEvent& rEvt)
extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeTableNameEdit(Window *pParent, VclBuilder::stringmap &)
{
TableNameEdit* pTableNameEdit = new TableNameEdit(pParent);
pTableNameEdit->SetMinWidthInChars(25);
pTableNameEdit->SetWidthInChars(25);
return pTableNameEdit;
}
......
......@@ -101,6 +101,7 @@
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="invisible_char"></property>
<property name="width_chars">32</property>
<property name="invisible_char_set">True</property>
</object>
<packing>
......@@ -115,6 +116,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char"></property>
<property name="width_chars">32</property>
<property name="invisible_char_set">True</property>
</object>
<packing>
......@@ -129,6 +131,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char"></property>
<property name="width_chars">32</property>
<property name="invisible_char_set">True</property>
</object>
<packing>
......
......@@ -78,7 +78,7 @@ private:
Selection maSelection;
sal_uInt16 mnAlign;
xub_StrLen mnMaxTextLen;
sal_Int32 mnMinWidthInChars;
sal_Int32 mnWidthInChars;
AutocompleteAction meAutocompleteAction;
sal_Unicode mcEchoChar;
sal_Bool mbModified:1,
......@@ -199,8 +199,8 @@ public:
virtual void SetMaxTextLen( xub_StrLen nMaxLen = EDIT_NOLIMIT );
virtual xub_StrLen GetMaxTextLen() const { return mnMaxTextLen; }
void SetMinWidthInChars(sal_Int32 nMinWidthInChars);
sal_Int32 GetMinWidthInChars() const { return mnMinWidthInChars; }
void SetWidthInChars(sal_Int32 nWidthInChars);
sal_Int32 GetWidthInChars() const { return mnWidthInChars; }
virtual void SetSelection( const Selection& rSelection );
virtual const Selection& GetSelection() const;
......
......@@ -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();
}
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment