// Author:
// stubbed out by Jackson Harper (jackson@latitudegeo.com)
// Dennis Hayes (dennish@Raytek.com)
+// Aleksey Ryabchuk (ryabchuk@yahoo.com)
//
// (C) 2002 Ximian, Inc
//
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
using System.ComponentModel;
namespace System.Windows.Forms {
// <summary>
- //
+ // Represents a Windows text box control.\r
// </summary>
public class TextBox : TextBoxBase {
HorizontalAlignment textAlign;
- //
- // --- Public Constructor
- //
+ bool acceptsReturn;
+ CharacterCasing characterCasing;
+ char passwordChar;
+ ScrollBars scrollbars;
+
[MonoTODO]
public TextBox()
{
textAlign = HorizontalAlignment.Left;
+ acceptsReturn = true;
+ characterCasing = CharacterCasing.Normal;
+ passwordChar = (char)0;
+ scrollbars = ScrollBars.None;
}
- // --- Public Properties
-
- [MonoTODO]
public bool AcceptsReturn {
-
- get
- {
- throw new NotImplementedException ();
- }
- set
- {
- //FIXME:
+ get { return acceptsReturn; }
+ set {
+ if ( acceptsReturn != value ) {
+ int oldStyle = acceptsReturn ? (int)EditControlStyles.ES_WANTRETURN : 0;
+ acceptsReturn = value;
+ int newStyle = acceptsReturn ? (int)EditControlStyles.ES_WANTRETURN : 0;
+ if ( IsHandleCreated )
+ Win32.UpdateWindowStyle ( Handle, oldStyle, newStyle );
+ }
}
}
- [MonoTODO]
+
public CharacterCasing CharacterCasing {
- get
- {
- throw new NotImplementedException ();
- }
- set
- {
- //FIXME:
+ get { return characterCasing; }
+ set {
+ if ( !Enum.IsDefined ( typeof(CharacterCasing), value ) )
+ throw new InvalidEnumArgumentException( "CharacterCasing",
+ (int)value,
+ typeof(CharacterCasing));
+
+ if ( characterCasing != value ) {
+ int oldStyle = CaseStyle;
+ characterCasing = value;
+ if ( IsHandleCreated )
+ Win32.UpdateWindowStyle ( Handle, oldStyle, CaseStyle );
+ }
}
}
- [MonoTODO]
+
public char PasswordChar {
- get
- {
- throw new NotImplementedException ();
- }
- set
- {
- //FIXME:
+ get { return passwordChar; }
+ set {
+ passwordChar = value;
+ if ( IsHandleCreated )
+ Win32.SendMessage ( Handle, (int) EditControlMessages.EM_SETPASSWORDCHAR, passwordChar, 0 );
}
}
- [MonoTODO]
+
public ScrollBars ScrollBars {
- get
- {
- throw new NotImplementedException ();
- }
- set
- {
- //FIXME:
+ get { return scrollbars; }
+ set {
+ if ( !Enum.IsDefined ( typeof(ScrollBars), value ) )
+ throw new InvalidEnumArgumentException( "ScrollBars",
+ (int)value,
+ typeof(ScrollBars));
+
+ if ( scrollbars != value ) {
+ int oldStyle = ScrollBarStyle;
+ scrollbars = value;
+ if ( IsHandleCreated )
+ Win32.UpdateWindowStyle ( Handle, oldStyle, ScrollBarStyle );
+ }
}
}
}
}
- // --- Public Events
-
- [MonoTODO]
public event EventHandler TextAlignChanged;
- // --- Protected Properties
-
[MonoTODO]
protected override CreateParams CreateParams {
get {
CreateParams createParams = base.CreateParams;
createParams.ClassName = "EDIT";
- createParams.ExStyle = (int)WindowExStyles.WS_EX_CLIENTEDGE;
- createParams.Style = (int) (
- WindowStyles.WS_CHILD |
- WindowStyles.WS_VISIBLE) | TextAlignStyle;
+ createParams.Style |= (int) ( WindowStyles.WS_CHILD ) | TextAlignStyle | ScrollBarStyle | CaseStyle;
+ if ( AcceptsReturn )
+ createParams.Style |= (int)EditControlStyles.ES_WANTRETURN;
+
return createParams;
}
}
[MonoTODO]
protected override ImeMode DefaultImeMode {
- get {
- //FIXME:
- return base.ImeMode;
- }
- }
- [MonoTODO]
- public override int SelectionLength {
- get {
- //FIXME:
- return base.SelectionLength;
- }
- set {
- //FIXME:
- base.SelectionLength = value;
- }
+ get { return ImeMode.Inherit; }
}
// --- Protected Members
-
protected override bool IsInputKey(Keys keyData)
{
{
//FIXME:
base.OnHandleCreated(e);
+ if ( PasswordChar != 0 )
+ Win32.SendMessage ( Handle, (int) EditControlMessages.EM_SETPASSWORDCHAR, PasswordChar, 0 );
}
[MonoTODO]
- protected override void OnMouseUp(MouseEventArgs e)
+ protected override void OnMouseUp(MouseEventArgs mevent)
{
//FIXME:
- base.OnMouseUp(e);
+ base.OnMouseUp(mevent);
}
- [MonoTODO]
- //[Lame Spec] spec says this should be virtural
- //Spec was right!
- protected virtual void OnTextAlignChanged(EventArgs e)
+
+ [MonoTODO]
+ protected override void OnGotFocus(EventArgs e) {
+ //FIXME:
+ base.OnGotFocus(e);
+ }
+
+ protected virtual void OnTextAlignChanged(EventArgs e)
{
- //FIXME:
+ if ( TextAlignChanged != null )
+ TextAlignChanged ( this, EventArgs.Empty );
}
[MonoTODO]
protected override void WndProc(ref Message m)
return style;
}
}
+
+ private int ScrollBarStyle
+ {
+ get {
+ int style = 0;
+ switch ( this.ScrollBars ) {
+ case ScrollBars.Vertical:
+ style = (int) WindowStyles.WS_VSCROLL;
+ break;
+ case ScrollBars.Horizontal:
+ if ( !WordWrap )
+ style = (int) WindowStyles.WS_HSCROLL;
+ break;
+ case ScrollBars.Both:
+ style = (int) WindowStyles.WS_VSCROLL;
+ if ( !WordWrap )
+ style = (int) WindowStyles.WS_HSCROLL;
+
+ break;
+ }
+ return style;
+ }
+ }
+
+ private int CaseStyle
+ {
+ get {
+ int style = 0;
+ switch ( this.CharacterCasing ) {
+ case CharacterCasing.Lower:
+ style = (int) EditControlStyles.ES_LOWERCASE;
+ break;
+ case CharacterCasing.Upper:
+ style = (int) EditControlStyles.ES_UPPERCASE;
+ break;
+ }
+ return style;
+ }
+ }
}
}