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) ...@@ -129,7 +129,7 @@ void ReturnActionEdit::KeyInput( const KeyEvent& rEvt)
extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeTableNameEdit(Window *pParent, VclBuilder::stringmap &) extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeTableNameEdit(Window *pParent, VclBuilder::stringmap &)
{ {
TableNameEdit* pTableNameEdit = new TableNameEdit(pParent); TableNameEdit* pTableNameEdit = new TableNameEdit(pParent);
pTableNameEdit->SetMinWidthInChars(25); pTableNameEdit->SetWidthInChars(25);
return pTableNameEdit; return pTableNameEdit;
} }
......
...@@ -101,6 +101,7 @@ ...@@ -101,6 +101,7 @@
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="invisible_char"></property> <property name="invisible_char"></property>
<property name="width_chars">32</property>
<property name="invisible_char_set">True</property> <property name="invisible_char_set">True</property>
</object> </object>
<packing> <packing>
...@@ -115,6 +116,7 @@ ...@@ -115,6 +116,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="invisible_char"></property> <property name="invisible_char"></property>
<property name="width_chars">32</property>
<property name="invisible_char_set">True</property> <property name="invisible_char_set">True</property>
</object> </object>
<packing> <packing>
...@@ -129,6 +131,7 @@ ...@@ -129,6 +131,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="invisible_char"></property> <property name="invisible_char"></property>
<property name="width_chars">32</property>
<property name="invisible_char_set">True</property> <property name="invisible_char_set">True</property>
</object> </object>
<packing> <packing>
......
...@@ -78,7 +78,7 @@ private: ...@@ -78,7 +78,7 @@ private:
Selection maSelection; Selection maSelection;
sal_uInt16 mnAlign; sal_uInt16 mnAlign;
xub_StrLen mnMaxTextLen; xub_StrLen mnMaxTextLen;
sal_Int32 mnMinWidthInChars; sal_Int32 mnWidthInChars;
AutocompleteAction meAutocompleteAction; AutocompleteAction meAutocompleteAction;
sal_Unicode mcEchoChar; sal_Unicode mcEchoChar;
sal_Bool mbModified:1, sal_Bool mbModified:1,
...@@ -199,8 +199,8 @@ public: ...@@ -199,8 +199,8 @@ public:
virtual void SetMaxTextLen( xub_StrLen nMaxLen = EDIT_NOLIMIT ); virtual void SetMaxTextLen( xub_StrLen nMaxLen = EDIT_NOLIMIT );
virtual xub_StrLen GetMaxTextLen() const { return mnMaxTextLen; } virtual xub_StrLen GetMaxTextLen() const { return mnMaxTextLen; }
void SetMinWidthInChars(sal_Int32 nMinWidthInChars); void SetWidthInChars(sal_Int32 nWidthInChars);
sal_Int32 GetMinWidthInChars() const { return mnMinWidthInChars; } sal_Int32 GetWidthInChars() const { return mnWidthInChars; }
virtual void SetSelection( const Selection& rSelection ); virtual void SetSelection( const Selection& rSelection );
virtual const Selection& GetSelection() const; virtual const Selection& GetSelection() const;
......
...@@ -61,7 +61,7 @@ ComboBox::ComboBox( WindowType nType ) : ...@@ -61,7 +61,7 @@ ComboBox::ComboBox( WindowType nType ) :
Edit( nType ) Edit( nType )
{ {
ImplInitComboBoxData(); ImplInitComboBoxData();
SetMinWidthInChars(0); SetWidthInChars(-1);
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
...@@ -71,7 +71,7 @@ ComboBox::ComboBox( Window* pParent, WinBits nStyle ) : ...@@ -71,7 +71,7 @@ ComboBox::ComboBox( Window* pParent, WinBits nStyle ) :
{ {
ImplInitComboBoxData(); ImplInitComboBoxData();
ImplInit( pParent, nStyle ); ImplInit( pParent, nStyle );
SetMinWidthInChars(0); SetWidthInChars(-1);
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
...@@ -85,7 +85,7 @@ ComboBox::ComboBox( Window* pParent, const ResId& rResId ) : ...@@ -85,7 +85,7 @@ ComboBox::ComboBox( Window* pParent, const ResId& rResId ) :
ImplInit( pParent, nStyle ); ImplInit( pParent, nStyle );
ImplLoadRes( rResId ); ImplLoadRes( rResId );
SetMinWidthInChars(0); SetWidthInChars(-1);
if ( !(nStyle & WB_HIDE ) ) if ( !(nStyle & WB_HIDE ) )
Show(); Show();
} }
......
...@@ -219,11 +219,11 @@ Edit::Edit( Window* pParent, const ResId& rResId ) : ...@@ -219,11 +219,11 @@ Edit::Edit( Window* pParent, const ResId& rResId ) :
Show(); 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(); queue_resize();
} }
} }
...@@ -231,7 +231,12 @@ void Edit::SetMinWidthInChars(sal_Int32 nMinWidthInChars) ...@@ -231,7 +231,12 @@ void Edit::SetMinWidthInChars(sal_Int32 nMinWidthInChars)
bool Edit::set_property(const rtl::OString &rKey, const rtl::OString &rValue) bool Edit::set_property(const rtl::OString &rKey, const rtl::OString &rValue)
{ {
if (rKey == "width-chars") 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") else if (rKey == "editable")
SetReadOnly(!toBool(rValue)); SetReadOnly(!toBool(rValue));
else if (rKey == "visibility") else if (rKey == "visibility")
...@@ -266,7 +271,7 @@ void Edit::take_properties(Window &rOther) ...@@ -266,7 +271,7 @@ void Edit::take_properties(Window &rOther)
maSelection = rOtherEdit.maSelection; maSelection = rOtherEdit.maSelection;
mnAlign = rOtherEdit.mnAlign; mnAlign = rOtherEdit.mnAlign;
mnMaxTextLen = rOtherEdit.mnMaxTextLen; mnMaxTextLen = rOtherEdit.mnMaxTextLen;
mnMinWidthInChars = rOtherEdit.mnMinWidthInChars; mnWidthInChars = rOtherEdit.mnWidthInChars;
meAutocompleteAction = rOtherEdit.meAutocompleteAction; meAutocompleteAction = rOtherEdit.meAutocompleteAction;
mcEchoChar = rOtherEdit.mcEchoChar; mcEchoChar = rOtherEdit.mcEchoChar;
mbModified = rOtherEdit.mbModified; mbModified = rOtherEdit.mbModified;
...@@ -341,7 +346,7 @@ void Edit::ImplInitEditData() ...@@ -341,7 +346,7 @@ void Edit::ImplInitEditData()
mnXOffset = 0; mnXOffset = 0;
mnAlign = EDIT_ALIGN_LEFT; mnAlign = EDIT_ALIGN_LEFT;
mnMaxTextLen = EDIT_NOLIMIT; mnMaxTextLen = EDIT_NOLIMIT;
mnMinWidthInChars = 3; mnWidthInChars = -1;
meAutocompleteAction = AUTOCOMPLETE_KEYINPUT; meAutocompleteAction = AUTOCOMPLETE_KEYINPUT;
mbModified = sal_False; mbModified = sal_False;
mbInternModified = sal_False; mbInternModified = sal_False;
...@@ -2890,13 +2895,22 @@ void Edit::SetSubEdit( Edit* pEdit ) ...@@ -2890,13 +2895,22 @@ void Edit::SetSubEdit( Edit* pEdit )
Size Edit::CalcMinimumSizeForText(const rtl::OUString &rString) const Size Edit::CalcMinimumSizeForText(const rtl::OUString &rString) const
{ {
Size aSize ( GetTextWidth( rString ), GetTextHeight() ); Size aSize;
aSize.Width() += ImplGetExtraOffset() * 2; if (mnWidthInChars != -1)
// do not create edit fields in which one cannot enter anything {
// a default minimum width should exist for at least 3 characters aSize = CalcSize(mnWidthInChars);
Size aMinSize ( CalcSize( mnMinWidthInChars ) ); }
if( aSize.Width() < aMinSize.Width() ) else
aSize.Width() = aMinSize.Width(); {
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 // add some space between text entry and border
aSize.Height() += 4; 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