TextBoxBase.cs 8.4 KB

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