TextBoxBase.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. //
  2. // System.Windows.Forms.TextBoxBase
  3. //
  4. // Author:
  5. // stubbed out by Jackson Harper ([email protected])
  6. // Dennis Hayes ([email protected])
  7. // Remco de Jong ([email protected])
  8. //
  9. // (C) 2002 Ximian, Inc
  10. //
  11. using System.Drawing;
  12. namespace System.Windows.Forms {
  13. // <summary>
  14. // This is only a template. Nothing is implemented yet.
  15. //
  16. // </summary>
  17. public class TextBoxBase : Control {
  18. private int maxlength = 0;
  19. private Gtk.TextTagTable tagtable;
  20. private Gtk.TextBuffer textbuffer = null;
  21. //
  22. // --- Public Properties
  23. //
  24. public TextBoxBase () {
  25. }
  26. protected Gtk.TextBuffer TextBuffer {
  27. get {
  28. if (textbuffer == null) {
  29. tagtable = new Gtk.TextTagTable ();
  30. textbuffer = new Gtk.TextBuffer (tagtable);
  31. // attach events
  32. textbuffer.ModifiedChanged += new EventHandler (modified_changed_cb);
  33. }
  34. return textbuffer;
  35. }
  36. }
  37. protected override void OnTextChanged(EventArgs e)
  38. {
  39. TextBuffer.SetText(Text, Text.Length);
  40. }
  41. [MonoTODO]
  42. public bool AcceptsTab {
  43. get
  44. {
  45. throw new NotImplementedException ();
  46. }
  47. set
  48. {
  49. throw new NotImplementedException ();
  50. }
  51. }
  52. [MonoTODO]
  53. public virtual bool AutoSize {
  54. get
  55. {
  56. throw new NotImplementedException ();
  57. }
  58. set
  59. {
  60. throw new NotImplementedException ();
  61. }
  62. }
  63. /* [MonoTODO]
  64. public override Color BackColor {
  65. get
  66. {
  67. throw new NotImplementedException ();
  68. }
  69. set
  70. {
  71. throw new NotImplementedException ();
  72. }
  73. }
  74. [MonoTODO]
  75. public override Color ForeColor {
  76. get
  77. {
  78. throw new NotImplementedException ();
  79. }
  80. set
  81. {
  82. throw new NotImplementedException ();
  83. }
  84. }
  85. [MonoTODO]
  86. public override Image BackgroundImage {
  87. get
  88. {
  89. throw new NotImplementedException ();
  90. }
  91. set
  92. {
  93. throw new NotImplementedException ();
  94. }
  95. }
  96. [MonoTODO]
  97. public BorderStyle BorderStyle {
  98. get
  99. {
  100. throw new NotImplementedException ();
  101. }
  102. set
  103. {
  104. throw new NotImplementedException ();
  105. }
  106. }
  107. */ [MonoTODO]
  108. public bool CanUndo {
  109. get
  110. {
  111. throw new NotImplementedException ();
  112. }
  113. }
  114. [MonoTODO]
  115. public bool HideSelection {
  116. get
  117. {
  118. throw new NotImplementedException ();
  119. }
  120. set
  121. {
  122. throw new NotImplementedException ();
  123. }
  124. }
  125. [MonoTODO]
  126. public string[] Lines {
  127. get
  128. {
  129. throw new NotImplementedException ();
  130. }
  131. set
  132. {
  133. Clear ();
  134. foreach (String s in value) {
  135. AppendText (s + "\n");
  136. }
  137. }
  138. }
  139. [MonoTODO]
  140. public virtual int MaxLength {
  141. get
  142. {
  143. return maxlength;
  144. }
  145. set
  146. {
  147. maxlength = value;
  148. }
  149. }
  150. public bool Modified {
  151. get
  152. {
  153. return TextBuffer.Modified;
  154. }
  155. set
  156. {
  157. if (TextBuffer.Modified != value) { // only call if it has really been changed since this will trigger an event, is this correct behavior?
  158. TextBuffer.Modified = value;
  159. }
  160. }
  161. }
  162. [MonoTODO]
  163. public virtual bool Multiline {
  164. get
  165. {
  166. throw new NotImplementedException ();
  167. }
  168. set
  169. {
  170. throw new NotImplementedException ();
  171. }
  172. }
  173. [MonoTODO]
  174. public int PreferredHeight {
  175. get
  176. {
  177. throw new NotImplementedException ();
  178. }
  179. }
  180. public virtual bool ReadOnly {
  181. // needs to be overwritten by child classes
  182. get { return false; }
  183. set {}
  184. }
  185. [MonoTODO]
  186. public virtual string SelectedText {
  187. get
  188. {
  189. String selection = "";
  190. Gtk.TextIter start;
  191. Gtk.TextIter end;
  192. if (TextBuffer.GetSelectionBounds(ref start, ref end))
  193. selection = TextBuffer.GetText(start, end, true);
  194. return selection;
  195. }
  196. set
  197. {
  198. // paste text over selection
  199. }
  200. }
  201. [MonoTODO]
  202. public virtual int SelectionLength {
  203. get
  204. {
  205. throw new NotImplementedException ();
  206. }
  207. set
  208. {
  209. throw new NotImplementedException ();
  210. }
  211. }
  212. [MonoTODO]
  213. public int SelectionStart {
  214. get
  215. {
  216. throw new NotImplementedException ();
  217. }
  218. set
  219. {
  220. throw new NotImplementedException ();
  221. }
  222. }
  223. [MonoTODO]
  224. public virtual int TextLength {
  225. get
  226. {
  227. return Text.Length;
  228. }
  229. }
  230. [MonoTODO]
  231. public virtual bool WordWrap {
  232. get
  233. {
  234. return false;
  235. }
  236. set
  237. {
  238. }
  239. }
  240. // --- Public Methods
  241. public void AppendText(string text)
  242. {
  243. Text += text;
  244. }
  245. public void Clear()
  246. {
  247. TextBuffer.SetText("", 0);
  248. }
  249. [MonoTODO]
  250. public void ClearUndo()
  251. {
  252. throw new NotImplementedException ();
  253. }
  254. [MonoTODO]
  255. public void Copy()
  256. {
  257. throw new NotImplementedException ();
  258. }
  259. [MonoTODO]
  260. public void Cut()
  261. {
  262. throw new NotImplementedException ();
  263. }
  264. [MonoTODO]
  265. public void Paste()
  266. {
  267. throw new NotImplementedException ();
  268. }
  269. [MonoTODO]
  270. public void ScrollToCaret()
  271. {
  272. throw new NotImplementedException ();
  273. }
  274. [MonoTODO]
  275. public void Select(int start, int length)
  276. {
  277. throw new NotImplementedException ();
  278. }
  279. [MonoTODO]
  280. public void SelectAll()
  281. {
  282. throw new NotImplementedException ();
  283. }
  284. [MonoTODO]
  285. public override string ToString()
  286. {
  287. throw new NotImplementedException ();
  288. }
  289. [MonoTODO]
  290. public void Undo()
  291. {
  292. throw new NotImplementedException ();
  293. }
  294. // --- Internal Events (Gtk)
  295. internal protected void modified_changed_cb (object o, EventArgs args)
  296. {
  297. OnModifiedChanged (EventArgs.Empty);
  298. }
  299. // --- Public Events
  300. [MonoTODO]
  301. public event EventHandler AcceptsTabChanged;
  302. [MonoTODO]
  303. public event EventHandler AutoSizeChanged;
  304. [MonoTODO]
  305. public event EventHandler BorderStyleChanged;
  306. [MonoTODO]
  307. //public override event EventHandler Click;
  308. [MonoTODO]
  309. public event EventHandler HideSelectionChanged;
  310. public event EventHandler ModifiedChanged;
  311. [MonoTODO]
  312. public event EventHandler MultilineChanged;
  313. public event EventHandler ReadOnlyChanged;
  314. // --- Protected Properties
  315. /*
  316. [MonoTODO]
  317. protected override CreateParams CreateParams {
  318. get
  319. {
  320. throw new NotImplementedException ();
  321. }
  322. }
  323. [MonoTODO]
  324. protected override Size DefaultSize {
  325. get
  326. {
  327. throw new NotImplementedException ();
  328. }
  329. }
  330. // --- Protected Methods
  331. [MonoTODO]
  332. protected override void CreateHandle()
  333. {
  334. throw new NotImplementedException ();
  335. }
  336. */
  337. [MonoTODO]
  338. /* protected override bool IsInputKey(Keys keyData)
  339. {
  340. throw new NotImplementedException ();
  341. }
  342. */ [MonoTODO]
  343. protected virtual void OnAcceptsTabChanged(EventArgs e)
  344. {
  345. throw new NotImplementedException ();
  346. }
  347. [MonoTODO]
  348. protected virtual void OnAutoSizeChanged(EventArgs e)
  349. {
  350. throw new NotImplementedException ();
  351. }
  352. [MonoTODO]
  353. protected virtual void OnBorderStyleChanged(EventArgs e)
  354. {
  355. throw new NotImplementedException ();
  356. }
  357. /*
  358. [MonoTODO]
  359. protected override void OnFontChanged(EventArgs e)
  360. {
  361. throw new NotImplementedException ();
  362. }
  363. [MonoTODO]
  364. protected override void OnHandleCreated(EventArgs e)
  365. {
  366. throw new NotImplementedException ();
  367. }
  368. [MonoTODO]
  369. protected override void OnHandleDestroyed(EventArgs e)
  370. {
  371. throw new NotImplementedException ();
  372. }
  373. */
  374. [MonoTODO]
  375. protected virtual void OnHideSelectionChanged(EventArgs e)
  376. {
  377. throw new NotImplementedException ();
  378. }
  379. [MonoTODO]
  380. protected virtual void OnModifiedChanged(EventArgs e)
  381. {
  382. if (ModifiedChanged != null)
  383. ModifiedChanged (this, e);
  384. }
  385. [MonoTODO]
  386. protected virtual void OnMultilineChanged(EventArgs e)
  387. {
  388. throw new NotImplementedException ();
  389. }
  390. protected virtual void OnReadOnlyChanged(EventArgs e)
  391. {
  392. if (ReadOnlyChanged != null)
  393. ReadOnlyChanged (this, e);
  394. }
  395. /* [MonoTODO]
  396. protected override bool ProcessDialogKey(Keys keyData)
  397. {
  398. throw new NotImplementedException ();
  399. }
  400. [MonoTODO]
  401. protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
  402. {
  403. throw new NotImplementedException ();
  404. }
  405. [MonoTODO]
  406. protected override void WndProc(ref Message m)
  407. {
  408. throw new NotImplementedException ();
  409. }
  410. */ }
  411. }