TextBox.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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:
  8. //
  9. // The above copyright notice and this permission notice shall be
  10. // included in all copies or substantial portions of the Software.
  11. //
  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.
  19. //
  20. // Copyright (c) 2004 Novell, Inc. (http://www.novell.com)
  21. //
  22. // Authors:
  23. // Peter Bartok [email protected]
  24. //
  25. //
  26. // NOT COMPLETE
  27. using System;
  28. using System.Drawing;
  29. namespace System.Windows.Forms {
  30. public class TextBox : TextBoxBase {
  31. #region Local Variables
  32. internal char password_char;
  33. #endregion // Local Variables
  34. #region Public Constructors
  35. public TextBox() {
  36. accepts_return = false;
  37. password_char = '\u25cf';
  38. scrollbars = ScrollBars.None;
  39. alignment = HorizontalAlignment.Left;
  40. }
  41. #endregion // Public Constructors
  42. #region Public Instance Properties
  43. public bool AcceptsReturn {
  44. get {
  45. return accepts_return;
  46. }
  47. set {
  48. if (value != accepts_return) {
  49. accepts_return = value;
  50. }
  51. }
  52. }
  53. public CharacterCasing CharacterCasing {
  54. get {
  55. return character_casing;
  56. }
  57. set {
  58. if (value != character_casing) {
  59. character_casing = value;
  60. }
  61. }
  62. }
  63. public char PasswordChar {
  64. get {
  65. return password_char;
  66. }
  67. set {
  68. if (value != password_char) {
  69. password_char = value;
  70. }
  71. }
  72. }
  73. public ScrollBars ScrollBars {
  74. get {
  75. return scrollbars;
  76. }
  77. set {
  78. if (value != scrollbars) {
  79. scrollbars = value;
  80. }
  81. }
  82. }
  83. public override string Text {
  84. get {
  85. return base.Text;
  86. }
  87. set {
  88. base.Text = value;
  89. }
  90. }
  91. public HorizontalAlignment TextAlign {
  92. get {
  93. return alignment;
  94. }
  95. set {
  96. if (value != alignment) {
  97. alignment = value;
  98. for (int i = 1; i <= document.Lines; i++) {
  99. document.GetLine(i).Alignment = value;
  100. }
  101. document.RecalculateDocument(CreateGraphics());
  102. OnTextAlignChanged(EventArgs.Empty);
  103. }
  104. }
  105. }
  106. #endregion // Public Instance Properties
  107. #region Protected Instance Methods
  108. protected override CreateParams CreateParams {
  109. get {
  110. return base.CreateParams;
  111. }
  112. }
  113. protected override ImeMode DefaultImeMode {
  114. get {
  115. return base.DefaultImeMode;
  116. }
  117. }
  118. #endregion // Protected Instance Methods
  119. #region Protected Instance Methods
  120. protected override bool IsInputKey(Keys keyData) {
  121. return base.IsInputKey (keyData);
  122. }
  123. protected override void OnGotFocus(EventArgs e) {
  124. base.OnGotFocus (e);
  125. }
  126. protected override void OnHandleCreated(EventArgs e) {
  127. base.OnHandleCreated (e);
  128. }
  129. protected override void OnMouseUp(MouseEventArgs e) {
  130. base.OnMouseUp (e);
  131. }
  132. protected virtual void OnTextAlignChanged(EventArgs e) {
  133. if (TextAlignChanged != null) {
  134. TextAlignChanged(this, e);
  135. }
  136. }
  137. protected override void WndProc(ref Message m) {
  138. base.WndProc(ref m);
  139. }
  140. #endregion // Protected Instance Methods
  141. #region Events
  142. public event EventHandler TextAlignChanged;
  143. #endregion // Events
  144. }
  145. }