1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2004-2005 Novell, Inc. (http://www.novell.com)
23 // Peter Bartok pbartok@novell.com
30 using System.ComponentModel;
31 using System.ComponentModel.Design;
34 namespace System.Windows.Forms {
35 public class TextBox : TextBoxBase {
36 #region Local Variables
37 internal char password_char;
38 #endregion // Local Variables
40 #region Public Constructors
42 accepts_return = false;
43 password_char = '\u25cf';
44 scrollbars = ScrollBars.None;
45 alignment = HorizontalAlignment.Left;
46 this.LostFocus +=new EventHandler(TextBox_LostFocus);
47 this.BackColor = ThemeEngine.Current.ColorWindow;
48 this.ForeColor = ThemeEngine.Current.ColorWindowText;
50 #endregion // Public Constructors
53 #region Private & Internal Methods
54 private void TextBox_LostFocus(object sender, EventArgs e) {
\r
58 #endregion // Private & Internal Methods
60 #region Public Instance Properties
62 public bool AcceptsReturn {
64 return accepts_return;
68 if (value != accepts_return) {
69 accepts_return = value;
74 [DefaultValue(CharacterCasing.Normal)]
75 public CharacterCasing CharacterCasing {
77 return character_casing;
81 if (value != character_casing) {
82 character_casing = value;
89 public char PasswordChar {
95 if (value != password_char) {
96 password_char = value;
101 [DefaultValue(ScrollBars.None)]
103 public ScrollBars ScrollBars {
109 if (value != scrollbars) {
116 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
117 public override int SelectionLength {
\r
119 return base.SelectionLength;
\r
122 base.SelectionLength = value;
\r
127 public override string Text {
137 [DefaultValue(HorizontalAlignment.Left)]
139 public HorizontalAlignment TextAlign {
145 if (value != alignment) {
147 for (int i = 1; i <= document.Lines; i++) {
148 document.GetLine(i).Alignment = value;
150 document.RecalculateDocument(CreateGraphics());
151 OnTextAlignChanged(EventArgs.Empty);
155 #endregion // Public Instance Properties
157 #region Protected Instance Methods
158 protected override CreateParams CreateParams {
160 return base.CreateParams;
164 protected override ImeMode DefaultImeMode {
166 return base.DefaultImeMode;
169 #endregion // Protected Instance Methods
171 #region Protected Instance Methods
172 protected override bool IsInputKey(Keys keyData) {
173 return base.IsInputKey (keyData);
176 protected override void OnGotFocus(EventArgs e) {
182 protected override void OnHandleCreated(EventArgs e) {
183 base.OnHandleCreated (e);
186 protected override void OnMouseUp(MouseEventArgs e) {
190 protected virtual void OnTextAlignChanged(EventArgs e) {
191 if (TextAlignChanged != null) {
192 TextAlignChanged(this, e);
196 protected override void WndProc(ref Message m) {
199 #endregion // Protected Instance Methods
202 public event EventHandler TextAlignChanged;
203 #endregion // Events
\r