Control.cs 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706
  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.
  21. //
  22. // Authors:
  23. // Peter Bartok [email protected]
  24. //
  25. // Based on work by:
  26. // Aleksey Ryabchuk [email protected]
  27. // Alexandre Pigolkine [email protected]
  28. // Dennis Hayes [email protected]
  29. // Jaak Simm [email protected]
  30. // John Sohn [email protected]
  31. //
  32. // $Revision: 1.1 $
  33. // $Modtime: $
  34. // $Log: Control.cs,v $
  35. // Revision 1.1 2004/07/09 05:21:25 pbartok
  36. // - Initial check-in
  37. //
  38. //
  39. // NOT COMPLETE
  40. using System;
  41. using System.Drawing;
  42. using System.ComponentModel;
  43. using System.Collections;
  44. using System.Diagnostics;
  45. using System.Threading;
  46. using System.Runtime.InteropServices;
  47. namespace System.Windows.Forms
  48. {
  49. public class Control : Component, ISynchronizeInvoke, IWin32Window
  50. {
  51. #region Local Variables
  52. // Basic
  53. internal Rectangle bounds; // bounding rectangle for control
  54. internal object creator_thread; // thread that created the control
  55. internal ControlNativeWindow window; // object for native window handle
  56. internal string name; // for object naming
  57. // State
  58. internal bool has_focus; // true if control has focus
  59. internal bool is_visible; // true if control is visible
  60. internal bool is_enabled; // true if control is enabled (usable/not grayed out)
  61. internal int tab_index; // position in tab order of siblings
  62. internal bool is_disposed; // has the window already been disposed?
  63. internal Size window_size; // size of the window (including decorations)
  64. internal Size client_size; // size of the client area (window excluding decorations)
  65. internal ControlStyles control_style; // win32-specific, style bits for control
  66. // Visuals
  67. internal Color foreground_color; // foreground color for control
  68. internal Color background_color; // background color for control
  69. internal Image background_image; // background image for control
  70. internal Font font; // font for control
  71. internal string text; // window/title text for control
  72. // to be categorized...
  73. static internal Hashtable controls; // All of the applications controls, in a flat list
  74. internal ControlCollection child_controls; // our children
  75. internal Control parent; // our parent control
  76. internal int num_of_children; // number of children the control has
  77. internal Control[] children; // our children
  78. internal AccessibleObject accessibility_object; // object that contains accessibility information about our control
  79. internal AnchorStyles anchor_style; // TODO
  80. internal BindingContext binding_context; // TODO
  81. internal RightToLeft right_to_left; // drawing direction for control
  82. #endregion // Local Variables
  83. #region Private Classes
  84. // This helper class allows us to dispatch messages to Control.WndProc
  85. internal class ControlNativeWindow : NativeWindow {
  86. private Control control;
  87. public ControlNativeWindow(Control control) : base() {
  88. this.control=control;
  89. }
  90. protected override void WndProc(ref Message m) {
  91. control.WndProc(ref m);
  92. }
  93. }
  94. #endregion
  95. #region Public Classes
  96. public class ControlCollection : IList, ICollection, ICloneable, IEnumerable {
  97. private class Enumerator : IEnumerator {
  98. private Control owner;
  99. private int current;
  100. public Enumerator(Control owner) {
  101. this.owner=owner;
  102. this.current=-1;
  103. }
  104. public bool MoveNext() {
  105. current++;
  106. if (current>=owner.num_of_children) {
  107. return false;
  108. }
  109. return true;
  110. }
  111. public void Reset() {
  112. current=-1;
  113. }
  114. public object Current {
  115. get {
  116. if (current>=0 && current<owner.num_of_children) {
  117. return owner.children[current];
  118. } else {
  119. throw new InvalidOperationException("enumerator out of range");
  120. }
  121. }
  122. }
  123. }
  124. protected Control owner;
  125. #region ControlCollection Public Constructor
  126. public ControlCollection(Control owner) {
  127. this.owner=owner;
  128. }
  129. #endregion
  130. #region ControlCollection Public Instance Properties
  131. public int Count {
  132. get {
  133. return owner.num_of_children;
  134. }
  135. }
  136. public bool IsReadOnly {
  137. get {
  138. return false;
  139. }
  140. }
  141. public virtual Control this [int index] {
  142. get {
  143. if ((uint)index>=owner.num_of_children) {
  144. throw new ArgumentOutOfRangeException();
  145. }
  146. return owner.children[index];
  147. }
  148. }
  149. #endregion // ControlCollection Public Instance Properties
  150. #region ControlCollection Public Instance Methods
  151. public virtual void Add(Control value) {
  152. // Don't add it if we already have it
  153. for (int i=0; i<owner.num_of_children; i++) {
  154. if (value==owner.child_controls[i]) {
  155. return;
  156. }
  157. }
  158. value.Parent=owner;
  159. owner.OnControlAdded(new ControlEventArgs(value));
  160. }
  161. public virtual void AddRange(Control[] controls) {
  162. for (int i=0; i<controls.Length; i++) {
  163. Add(controls[i]);
  164. }
  165. }
  166. public virtual void Clear() {
  167. owner.SuspendLayout();
  168. for (int i=0; i<owner.num_of_children; i++) {
  169. Remove(owner.children[i]);
  170. }
  171. owner.ResumeLayout();
  172. }
  173. public bool Contains(Control control) {
  174. for (int i=0; i<owner.num_of_children; i++) {
  175. if (owner.children[i]==control) {
  176. return true;
  177. }
  178. }
  179. return false;
  180. }
  181. public void CopyTo(Array dest, int index) {
  182. if (owner.num_of_children>0) {
  183. Array.Copy(owner.children, 0, dest, index, owner.num_of_children);
  184. }
  185. }
  186. public override bool Equals(object other) {
  187. if (other is ControlCollection && (((ControlCollection)other).owner==this.owner)) {
  188. return(true);
  189. } else {
  190. return(false);
  191. }
  192. }
  193. public int GetChildIndex(Control child) {
  194. return GetChildIndex(child, false);
  195. }
  196. public int GetChildIndex(Control child, bool throwException) {
  197. int index;
  198. index=IndexOf(child);
  199. if (index==-1 && throwException) {
  200. throw new ArgumentException("Not a child control", "child");
  201. }
  202. return index;
  203. }
  204. public IEnumerator GetEnumerator() {
  205. return new ControlCollection.Enumerator(this.owner);
  206. }
  207. public override int GetHashCode() {
  208. return base.GetHashCode();
  209. }
  210. public int IndexOf(Control control) {
  211. int index;
  212. for (index=0; index<owner.num_of_children; index++) {
  213. if (owner.children[index] == control) {
  214. return index;
  215. }
  216. }
  217. return -1;
  218. }
  219. public virtual void Remove(Control value) {
  220. for (int i=0; i<owner.num_of_children; i++) {
  221. if (owner.children[i]==value) {
  222. RemoveAt(i);
  223. }
  224. }
  225. }
  226. public void RemoveAt(int index) {
  227. for (int i=index; i<owner.num_of_children; i++) {
  228. owner.children[i]=owner.children[i+1];
  229. }
  230. }
  231. public void SetChildIndex(Control child, int new_index) {
  232. int old_index;
  233. old_index=IndexOf(child);
  234. if (old_index==-1) {
  235. throw new ArgumentException("Not a child control", "child");
  236. }
  237. if (old_index==new_index) {
  238. return;
  239. }
  240. RemoveAt(old_index);
  241. if (new_index>owner.num_of_children) {
  242. Add(child);
  243. } else {
  244. for (int i=owner.num_of_children-1;i>new_index; i--) {
  245. owner.children[i+1]=owner.children[i];
  246. }
  247. owner.children[new_index]=(Control)child;
  248. }
  249. }
  250. #endregion // ControlCollection Public Instance Methods
  251. #region ControlCollection Interface Methods
  252. #if nodef
  253. int IList.Add(Control value) {
  254. Add(value);
  255. }
  256. #endif
  257. int IList.Add(object value) {
  258. if (!(value is Control)) {
  259. throw new ArgumentException("Not of type Control", "value");
  260. }
  261. Add((Control)value);
  262. // Assumes the element was added to the end of the list
  263. return owner.num_of_children;
  264. }
  265. void IList.Clear() {
  266. this.Clear();
  267. }
  268. bool IList.Contains(object value) {
  269. if (!(value is Control)) {
  270. throw new ArgumentException("Not of type Control", "value");
  271. }
  272. return this.Contains((Control)value);
  273. }
  274. int IList.IndexOf(object value) {
  275. if (!(value is Control)) {
  276. throw new ArgumentException("Not of type Control", "value");
  277. }
  278. for (int i=0; i<owner.num_of_children; i++) {
  279. if (owner.children[i]==(Control)value) {
  280. return i;
  281. }
  282. }
  283. return -1;
  284. }
  285. void IList.Insert(int index, object value) {
  286. if (!(value is Control)) {
  287. throw new ArgumentException("Not of type Control", "value");
  288. }
  289. if (index>owner.num_of_children) {
  290. throw new ArgumentOutOfRangeException("index");
  291. }
  292. for (int i=owner.num_of_children-1;i>index; i--) {
  293. owner.children[i+1]=owner.children[i];
  294. }
  295. owner.children[index]=(Control)value;
  296. }
  297. void IList.Remove(object value) {
  298. if (!(value is Control)) {
  299. throw new ArgumentException("Not of type Control", "value");
  300. }
  301. this.Remove((Control)value);
  302. }
  303. object IList.this [int index] {
  304. get {
  305. return owner.children[index];
  306. }
  307. set {
  308. }
  309. }
  310. bool IList.IsFixedSize {
  311. get {
  312. return false;
  313. }
  314. }
  315. object ICollection.SyncRoot {
  316. get {
  317. return this;
  318. }
  319. }
  320. bool ICollection.IsSynchronized {
  321. get {
  322. return false;
  323. }
  324. }
  325. Object ICloneable.Clone() {
  326. ControlCollection clone = new ControlCollection(this.owner);
  327. return clone;
  328. }
  329. #endregion // ControlCollection Interface Methods
  330. class ControlComparer : IComparer {
  331. int IComparer.Compare(object x, object y) {
  332. int tab_index_x;
  333. int tab_index_y;
  334. tab_index_x=((Control)x).tab_index;
  335. tab_index_y=((Control)y).tab_index;
  336. if (tab_index_x<tab_index_y) {
  337. return -1;
  338. } else if (tab_index_x>tab_index_y) {
  339. return 1;
  340. }
  341. return 0;
  342. }
  343. }
  344. }
  345. #endregion // ControlCollection Class
  346. #region Public Constructors
  347. public Control() {
  348. creator_thread = Thread.CurrentThread;
  349. controls = new Hashtable();
  350. child_controls = CreateControlsInstance();
  351. bounds = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
  352. window_size = new Size(DefaultSize.Width, DefaultSize.Height);
  353. client_size = new Size(DefaultSize.Width, DefaultSize.Height);
  354. is_visible = true;
  355. is_disposed = false;
  356. is_enabled = true;
  357. has_focus = false;
  358. parent = null;
  359. background_image = null;
  360. }
  361. public Control(Control parent, string text) : this() {
  362. Text=text;
  363. Parent=parent;
  364. }
  365. public Control(Control parent, string text, int left, int top, int width, int height) : this() {
  366. Parent=parent;
  367. Left=left;
  368. Top=top;
  369. Width=width;
  370. Height=height;
  371. Text=text;
  372. }
  373. public Control(string text) : this() {
  374. Text=text;
  375. }
  376. public Control(string text, int left, int top, int width, int height) : this() {
  377. Left=left;
  378. Top=top;
  379. Width=width;
  380. Height=height;
  381. Text=text;
  382. }
  383. #endregion // Public Constructors
  384. #region Public Static Properties
  385. public static Color DefaultBackColor {
  386. get {
  387. return XplatUI.Defaults.BackColor;
  388. }
  389. }
  390. public static Font DefaultFont {
  391. get {
  392. return XplatUI.Defaults.Font;
  393. }
  394. }
  395. public static Color DefaultForeColor {
  396. get {
  397. return XplatUI.Defaults.ForeColor;
  398. }
  399. }
  400. public static Keys ModifierKeys {
  401. get {
  402. return XplatUI.State.ModifierKeys;
  403. }
  404. }
  405. public static MouseButtons MouseButtons {
  406. get {
  407. return XplatUI.State.MouseButtons;
  408. }
  409. }
  410. public static Point MousePosition {
  411. get {
  412. return XplatUI.State.MousePosition;
  413. }
  414. }
  415. #endregion // Public Static Properties
  416. #region Public Instance Properties
  417. public AccessibleObject AccessibilityObject {
  418. get {
  419. if (accessibility_object==null) {
  420. accessibility_object=CreateAccessibilityInstance();
  421. }
  422. return accessibility_object;
  423. }
  424. }
  425. public string AccessibleDefaultActionDescription {
  426. get {
  427. return AccessibilityObject.default_action;
  428. }
  429. set {
  430. AccessibilityObject.default_action=value;
  431. }
  432. }
  433. public string AccessibleDescription {
  434. get {
  435. return AccessibilityObject.description;
  436. }
  437. set {
  438. AccessibilityObject.description=value;
  439. }
  440. }
  441. public string AccessibleName {
  442. get {
  443. return AccessibilityObject.Name;
  444. }
  445. set {
  446. AccessibilityObject.Name=value;
  447. }
  448. }
  449. public AccessibleRole AccessibleRole {
  450. get {
  451. return AccessibilityObject.role;
  452. }
  453. set {
  454. AccessibilityObject.role=value;
  455. }
  456. }
  457. public virtual bool AllowDrop {
  458. get {
  459. return XplatUI.State.DropTarget;
  460. }
  461. set {
  462. XplatUI.State.DropTarget=value;
  463. }
  464. }
  465. public virtual AnchorStyles Anchor {
  466. get {
  467. return anchor_style;
  468. }
  469. set {
  470. anchor_style=value;
  471. }
  472. }
  473. public virtual Color BackColor {
  474. get {
  475. if (background_color.IsEmpty) {
  476. if (parent!=null) {
  477. return parent.BackColor;
  478. }
  479. return DefaultBackColor;
  480. }
  481. return background_color;
  482. }
  483. set {
  484. background_color=value;
  485. Refresh();
  486. }
  487. }
  488. public virtual Image BackgroundImage {
  489. get {
  490. return background_image;
  491. }
  492. set {
  493. if (background_image!=value) {
  494. background_image=value;
  495. OnBackgroundImageChanged(EventArgs.Empty);
  496. }
  497. }
  498. }
  499. public virtual BindingContext BindingContext {
  500. get {
  501. throw new NotImplementedException();
  502. }
  503. set {
  504. throw new NotImplementedException();
  505. }
  506. }
  507. public int Bottom {
  508. get {
  509. return bounds.Y+bounds.Height;
  510. }
  511. }
  512. public Rectangle Bounds {
  513. get {
  514. return this.bounds;
  515. }
  516. set {
  517. SetBounds(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
  518. }
  519. }
  520. public bool CanFocus {
  521. get {
  522. throw new NotImplementedException();
  523. }
  524. }
  525. public bool CanSelect {
  526. get {
  527. throw new NotImplementedException();
  528. }
  529. }
  530. public bool Capture {
  531. get {
  532. throw new NotImplementedException();
  533. }
  534. set {
  535. throw new NotImplementedException();
  536. }
  537. }
  538. public bool CausesValidation {
  539. get {
  540. throw new NotImplementedException();
  541. }
  542. set {
  543. throw new NotImplementedException();
  544. }
  545. }
  546. public Rectangle ClientRectangle {
  547. get {
  548. return new Rectangle(0, 0, client_size.Width, client_size.Height);
  549. }
  550. }
  551. public Size ClientSize {
  552. get {
  553. return client_size;
  554. }
  555. set {
  556. throw new NotImplementedException();
  557. }
  558. }
  559. public String CompanyName {
  560. get {
  561. return "Mono Project, Novell, Inc.";
  562. }
  563. }
  564. public bool ContainsFocus {
  565. get {
  566. throw new NotImplementedException();
  567. }
  568. }
  569. #if notdef
  570. public virtual ContextMenu ContextMenu {
  571. get {
  572. throw new NotImplementedException();
  573. }
  574. set {
  575. throw new NotImplementedException();
  576. }
  577. }
  578. #endif
  579. public ControlCollection Controls {
  580. get {
  581. return CreateControlsInstance();
  582. }
  583. }
  584. public bool Created {
  585. get {
  586. throw new NotImplementedException();
  587. }
  588. }
  589. #if notdef
  590. public virtual Cursor Cursor {
  591. get {
  592. throw new NotImplementedException();
  593. }
  594. set {
  595. throw new NotImplementedException();
  596. }
  597. }
  598. public ControlBidingsCollection DataBindings {
  599. get {
  600. throw new NotImplementedException();
  601. }
  602. }
  603. #endif
  604. public virtual Rectangle DisplayRectangle {
  605. get {
  606. return ClientRectangle;
  607. }
  608. }
  609. public bool Disposing {
  610. get {
  611. throw new NotImplementedException();
  612. }
  613. }
  614. public virtual DockStyle Dock {
  615. get {
  616. throw new NotImplementedException();
  617. }
  618. set {
  619. throw new NotImplementedException();
  620. }
  621. }
  622. public bool Enabled {
  623. get {
  624. return is_enabled;
  625. }
  626. set {
  627. throw new NotImplementedException();
  628. }
  629. }
  630. public virtual bool Focused {
  631. get {
  632. return this.has_focus;
  633. }
  634. set {
  635. throw new NotImplementedException();
  636. }
  637. }
  638. public virtual Font Font {
  639. get {
  640. if (font != null) {
  641. return font;
  642. }
  643. if (Parent != null && Parent.Font != null) {
  644. return Parent.Font;
  645. }
  646. return DefaultFont;
  647. }
  648. set {
  649. font=value;
  650. Refresh();
  651. }
  652. }
  653. public virtual Color ForeColor {
  654. get {
  655. if (foreground_color.IsEmpty) {
  656. if (parent!=null) {
  657. return parent.ForeColor;
  658. }
  659. return DefaultForeColor;
  660. }
  661. return foreground_color;
  662. }
  663. set {
  664. foreground_color=value;
  665. Refresh();
  666. }
  667. }
  668. public bool IsDisposed {
  669. get {
  670. return this.is_disposed;
  671. }
  672. }
  673. public bool IsHandleCreated {
  674. get {
  675. if ((window!=null) && (window.Handle!=IntPtr.Zero)) {
  676. return true;
  677. }
  678. return false;
  679. }
  680. }
  681. public string Name {
  682. get {
  683. return this.name;
  684. }
  685. set {
  686. this.name=value;
  687. }
  688. }
  689. public Control Parent {
  690. get {
  691. return this.parent;
  692. }
  693. set {
  694. if (parent!=value) {
  695. if (parent!=null) {
  696. parent.Controls.Remove(this);
  697. }
  698. parent=value;
  699. if (!parent.Controls.Contains(this)) {
  700. parent.Controls.Add(this);
  701. }
  702. XplatUI.SetParent(Handle, value.Handle);
  703. }
  704. }
  705. }
  706. public IntPtr Handle { // IWin32Window
  707. get
  708. {
  709. if (!IsHandleCreated) {
  710. CreateHandle();
  711. }
  712. return window.Handle;
  713. }
  714. }
  715. public bool InvokeRequired { // ISynchronizeInvoke
  716. get {
  717. if (creator_thread!=Thread.CurrentThread) {
  718. return true;
  719. }
  720. return false;
  721. }
  722. }
  723. public bool Visible {
  724. get {
  725. return this.is_visible;
  726. }
  727. set {
  728. if (value!=is_visible) {
  729. is_visible=value;
  730. XplatUI.SetVisible(Handle, value);
  731. }
  732. }
  733. }
  734. public virtual string Text {
  735. get {
  736. return this.text;
  737. }
  738. set {
  739. if (text!=value) {
  740. text=value;
  741. XplatUI.Text(Handle, text);
  742. }
  743. }
  744. }
  745. public int Left {
  746. get {
  747. return this.bounds.X;
  748. }
  749. set {
  750. SetBounds(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
  751. }
  752. }
  753. public int Top {
  754. get {
  755. return this.bounds.Y;
  756. }
  757. set {
  758. SetBounds(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
  759. }
  760. }
  761. public int Width {
  762. get {
  763. return this.bounds.Width;
  764. }
  765. set {
  766. SetBounds(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
  767. }
  768. }
  769. public int Height {
  770. get {
  771. return this.bounds.Height;
  772. }
  773. set {
  774. SetBounds(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
  775. }
  776. }
  777. public Point Location {
  778. get {
  779. return new Point(bounds.X, bounds.Y);
  780. }
  781. set {
  782. SetBounds(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
  783. }
  784. }
  785. public Size Size {
  786. get {
  787. return new Size(Width, Height);
  788. }
  789. set {
  790. SetBounds(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
  791. }
  792. }
  793. #endregion // Public Instance Properties
  794. #region Protected Instance Properties
  795. protected virtual CreateParams CreateParams {
  796. get {
  797. CreateParams create_params = new CreateParams();
  798. create_params.Caption = Text;
  799. create_params.X = Left;
  800. create_params.Y = Top;
  801. create_params.Width = Width;
  802. create_params.Height = Height;
  803. create_params.ClassName = XplatUI.DefaultClassName;
  804. create_params.ClassStyle = 0;
  805. create_params.ExStyle = 0;
  806. create_params.Param = 0;
  807. if (parent!=null) {
  808. create_params.Parent = parent.Handle;
  809. }
  810. create_params.Style = (int)WindowStyles.WS_OVERLAPPED;
  811. if (is_visible) {
  812. create_params.Style |= (int)WindowStyles.WS_VISIBLE;
  813. }
  814. return create_params;
  815. }
  816. }
  817. protected virtual ImeMode DefaultImeMode {
  818. get {
  819. return ImeMode.Inherit;
  820. }
  821. }
  822. protected virtual Size DefaultSize {
  823. get {
  824. return new Size(100, 23);
  825. }
  826. }
  827. #endregion // Protected Instance Properties
  828. #region Public Instance Methods
  829. public bool Contains(Control ctl) {
  830. Control current;
  831. current=ctl;
  832. while (current!=null) {
  833. if (current==ctl) {
  834. return true;
  835. }
  836. current=current.parent;
  837. }
  838. return false;
  839. }
  840. public void CreateControl() {
  841. Control child;
  842. CreateHandle();
  843. for (int i=0; i<num_of_children; i++) {
  844. child_controls[i].CreateControl();
  845. }
  846. OnCreateControl();
  847. }
  848. public virtual void Refresh() {
  849. XplatUI.RefreshWindow(window.Handle);
  850. }
  851. public void SetBounds(int x, int y, int width, int height) {
  852. SetBounds(x, y, width, height, BoundsSpecified.All);
  853. }
  854. public void SetBounds(int x, int y, int width, int height, BoundsSpecified bounds_specified) {
  855. if ((bounds_specified & BoundsSpecified.X)==0) {
  856. x = Left;
  857. }
  858. if ((bounds_specified & BoundsSpecified.Y)==0) {
  859. y = Top;
  860. }
  861. if ((bounds_specified & BoundsSpecified.Width)==0) {
  862. width = Width;
  863. }
  864. if ((bounds_specified & BoundsSpecified.Height)==0) {
  865. height = Height;
  866. }
  867. if (IsHandleCreated) {
  868. XplatUI.MoveWindow(Handle, x, y, width, height);
  869. }
  870. UpdateBounds(x, y, width, height);
  871. }
  872. public void Show() {
  873. if (!IsHandleCreated) {
  874. this.CreateHandle();
  875. }
  876. this.Visible=true;
  877. }
  878. public object Invoke(Delegate method) { // ISynchronizeInvoke
  879. return Invoke(method, null);
  880. }
  881. public object Invoke(Delegate method, object[] args) { // ISynchronizeInvoke
  882. IAsyncResult result;
  883. result=BeginInvoke(method, args);
  884. return EndInvoke(result);
  885. }
  886. public IAsyncResult BeginInvoke(Delegate method) { // ISynchronizeInvoke
  887. return BeginInvoke(method, null);
  888. }
  889. protected virtual AccessibleObject CreateAccessibilityInstance() {
  890. return new AccessibleObject(this);
  891. }
  892. protected virtual ControlCollection CreateControlsInstance() {
  893. return new ControlCollection(this);
  894. }
  895. protected void UpdateBounds() {
  896. UpdateBounds(bounds.X, bounds.Y, bounds.Width, bounds.Height);
  897. }
  898. protected void UpdateBounds(int x, int y, int width, int height) {
  899. bool moved = false;
  900. bool resized = false;
  901. // Generate required notifications
  902. if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
  903. moved=true;
  904. }
  905. if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
  906. resized=true;
  907. }
  908. bounds.X=x;
  909. bounds.Y=y;
  910. bounds.Width=width;
  911. bounds.Height=height;
  912. if (IsHandleCreated) {
  913. XplatUI.SetWindowPos(Handle, bounds);
  914. }
  915. if (moved) {
  916. OnLocationChanged(EventArgs.Empty);
  917. }
  918. if (resized) {
  919. OnSizeChanged(EventArgs.Empty);
  920. }
  921. }
  922. protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
  923. UpdateBounds(x, y, width, height);
  924. }
  925. public void Invalidate() {
  926. Invalidate(bounds, false);
  927. }
  928. public void Invalidate(bool invalidateChildren) {
  929. Invalidate(bounds, invalidateChildren);
  930. }
  931. public void Invalidate(System.Drawing.Rectangle rc) {
  932. Invalidate(rc, false);
  933. }
  934. public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
  935. if (!IsHandleCreated || !is_visible) {
  936. return;
  937. }
  938. XplatUI.Invalidate(Handle, rc);
  939. if (invalidateChildren) {
  940. for (int i=0; i<num_of_children; i++) children[i].Invalidate();
  941. }
  942. }
  943. public void Invalidate(System.Drawing.Region region) {
  944. Invalidate(region, false);
  945. }
  946. [MonoTODO]
  947. public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
  948. throw new NotImplementedException();
  949. // FIXME - should use the GetRegionScans function of the region to invalidate each area
  950. if (invalidateChildren) {
  951. for (int i=0; i<num_of_children; i++) children[i].Invalidate();
  952. }
  953. }
  954. [MonoTODO("BeginInvoke() : Figure out a cross-platform way to handle this")]
  955. public IAsyncResult BeginInvoke(Delegate method, object[] args) { // ISynchronizeInvoke
  956. IAsyncResult result = null;
  957. return result;
  958. }
  959. [MonoTODO]
  960. public object EndInvoke(IAsyncResult async_result) { // ISynchronizeInvoke
  961. object result = null;
  962. return result;
  963. }
  964. public void ResumeLayout() {
  965. ResumeLayout(true);
  966. }
  967. public void ResumeLayout(bool peformLayout) {
  968. throw new NotImplementedException();
  969. }
  970. public void SuspendLayout() {
  971. throw new NotImplementedException();
  972. }
  973. [MonoTODO]
  974. protected virtual void WndProc(ref Message m) {
  975. EventArgs e = new EventArgs();
  976. #if debug
  977. Console.WriteLine("Received message {0}", m);
  978. #endif
  979. switch((Msg)m.Msg) {
  980. #if notyet
  981. // Mouse handling
  982. case Msg.WM_LBUTTONDOWN: throw new NotImplementedException(); break;
  983. case Msg.WM_LBUTTONUP: throw new NotImplementedException(); break;
  984. case Msg.WM_LBUTTONDBLCLK: throw new NotImplementedException(); break;
  985. case Msg.WM_RBUTTONDOWN: throw new NotImplementedException(); break;
  986. case Msg.WM_RBUTTONUP: throw new NotImplementedException(); break;
  987. case Msg.WM_RBUTTONDBLCLK: throw new NotImplementedException(); break;
  988. case Msg.WM_MOUSEHOVER: throw new NotImplementedException(); break;
  989. case Msg.WM_MOUSELEAVE: throw new NotImplementedException(); break;
  990. case Msg.WM_MOUSEMOVE: throw new NotImplementedException(); break;
  991. // Keyboard handling
  992. case Msg.WM_CHAR: throw new NotImplementedException(); break;
  993. case Msg.WM_KEYDOWN: throw new NotImplementedException(); break;
  994. case Msg.WM_KEYUP: throw new NotImplementedException(); break;
  995. #endif
  996. // Window management
  997. case Msg.WM_PAINT: {
  998. Rectangle rect;
  999. PaintEventArgs paint_event;
  1000. paint_event = XplatUI.PaintEventStart(Handle);
  1001. OnPaint(paint_event);
  1002. XplatUI.PaintEventEnd(Handle);
  1003. break;
  1004. }
  1005. #if notyet
  1006. case Msg.WM_SIZE: throw new NotImplementedException(); break;
  1007. case Msg.WM_WINDOWPOSCHANGED: throw new NotImplementedException(); break;
  1008. case Msg.WM_SYSCOLORCHANGE: throw new NotImplementedException(); break;
  1009. #endif
  1010. }
  1011. DefWndProc(ref m);
  1012. }
  1013. #endregion // Public Instance Methods
  1014. #region // Protected Instance Methods
  1015. protected virtual void CreateHandle() {
  1016. if (IsDisposed) {
  1017. throw new ObjectDisposedException(Name);
  1018. }
  1019. if (IsHandleCreated) {
  1020. return;
  1021. }
  1022. if (window==null) {
  1023. window = new ControlNativeWindow(this);
  1024. window.CreateHandle(CreateParams);
  1025. }
  1026. if (window.Handle!=IntPtr.Zero) {
  1027. if (!controls.Contains(window.Handle)) {
  1028. controls.Add(window.Handle, this);
  1029. }
  1030. creator_thread = Thread.CurrentThread;
  1031. OnHandleCreated(EventArgs.Empty);
  1032. }
  1033. }
  1034. protected virtual void DefWndProc(ref Message m) {
  1035. window.DefWndProc(ref m);
  1036. }
  1037. protected virtual void DestroyHandle() {
  1038. if (IsHandleCreated) {
  1039. if (Handle != IntPtr.Zero) {
  1040. controls.Remove(Handle);
  1041. }
  1042. if (window != null) {
  1043. window.DestroyHandle();
  1044. }
  1045. }
  1046. }
  1047. protected bool GetStyle(ControlStyles flag) {
  1048. return (control_style & flag) != 0;
  1049. }
  1050. protected virtual bool ProcessDialogChar(char charCode) {
  1051. throw new NotImplementedException();
  1052. }
  1053. protected virtual bool ProcessDialogKey(Keys keyData) {
  1054. throw new NotImplementedException();
  1055. }
  1056. protected virtual bool ProcessMnemonic(char charCode) {
  1057. throw new NotImplementedException();
  1058. }
  1059. protected void RecreateHandle() {
  1060. IEnumerator child = child_controls.GetEnumerator();
  1061. if (IsHandleCreated) {
  1062. DestroyHandle();
  1063. CreateHandle();
  1064. // FIXME ZOrder?
  1065. while (child.MoveNext()) {
  1066. ((Control)child.Current).RecreateHandle();
  1067. }
  1068. }
  1069. }
  1070. protected virtual void ScaleCore(float dx, float dy) {
  1071. throw new NotImplementedException();
  1072. }
  1073. protected virtual void Select(bool directed, bool forward) {
  1074. throw new NotImplementedException();
  1075. }
  1076. protected void SetStyle(ControlStyles flag, bool value) {
  1077. if (value) {
  1078. control_style |= flag;
  1079. } else {
  1080. control_style &= ~flag;
  1081. }
  1082. }
  1083. #endregion // Public Instance Methods
  1084. #region Private Instance Methods
  1085. #endregion // Private Instance Methods
  1086. #region Private Instance Methods
  1087. internal virtual void DoDefaultAction() {
  1088. // Only here to be overriden by our actual controls; this is needed by the accessibility class
  1089. }
  1090. #endregion // Private Instance Methods
  1091. #region OnXXX methods
  1092. protected virtual void OnBackColorChanged(EventArgs e) {
  1093. if (BackColorChanged!=null) BackColorChanged(this, e);
  1094. for (int i=0; i<num_of_children; i++) children[i].OnParentBackColorChanged(e);
  1095. }
  1096. protected virtual void OnBackgroundImageChanged(EventArgs e) {
  1097. if (BackgroundImageChanged!=null) BackgroundImageChanged(this, e);
  1098. for (int i=0; i<num_of_children; i++) children[i].OnParentBackgroundImageChanged(e);
  1099. }
  1100. protected virtual void OnBindingContextChanged(EventArgs e) {
  1101. if (BindingContextChanged!=null) BindingContextChanged(this, e);
  1102. for (int i=0; i<num_of_children; i++) children[i].OnParentBindingContextChanged(e);
  1103. }
  1104. protected virtual void OnCausesValidationChanged(EventArgs e) {
  1105. if (CausesValidationChanged!=null) CausesValidationChanged(this, e);
  1106. }
  1107. protected virtual void OnChangeUICues(UICuesEventArgs e) {
  1108. if (CausesValidationChanged!=null) CausesValidationChanged(this, e);
  1109. }
  1110. protected virtual void OnClick(EventArgs e) {
  1111. if (Click!=null) Click(this, e);
  1112. }
  1113. protected virtual void OnContextMenuChanged(EventArgs e) {
  1114. if (ContextMenuChanged!=null) ContextMenuChanged(this, e);
  1115. }
  1116. protected virtual void OnControlAdded(ControlEventArgs e) {
  1117. if (ControlAdded!=null) ControlAdded(this, e);
  1118. }
  1119. protected virtual void OnControlRemoved(ControlEventArgs e) {
  1120. if (ControlRemoved!=null) ControlRemoved(this, e);
  1121. }
  1122. protected virtual void OnCreateControl() {
  1123. }
  1124. protected virtual void OnCursorChanged(EventArgs e) {
  1125. if (CursorChanged!=null) CursorChanged(this, e);
  1126. }
  1127. protected virtual void OnDockChanged(EventArgs e) {
  1128. if (DockChanged!=null) DockChanged(this, e);
  1129. }
  1130. protected virtual void OnDoubleClick(EventArgs e) {
  1131. if (DoubleClick!=null) DoubleClick(this, e);
  1132. }
  1133. protected virtual void OnDragDrop(DragEventArgs drgevent) {
  1134. if (DragDrop!=null) DragDrop(this, drgevent);
  1135. }
  1136. protected virtual void OnDragEnter(DragEventArgs drgevent) {
  1137. if (DragEnter!=null) DragEnter(this, drgevent);
  1138. }
  1139. protected virtual void OnDragLeave(EventArgs e) {
  1140. if (DragLeave!=null) DragLeave(this, e);
  1141. }
  1142. protected virtual void OnDragOver(DragEventArgs drgevent) {
  1143. if (DragOver!=null) DragOver(this, drgevent);
  1144. }
  1145. protected virtual void OnEnabledChanged(EventArgs e) {
  1146. if (EnabledChanged!=null) EnabledChanged(this, e);
  1147. for (int i=0; i<num_of_children; i++) children[i].OnParentEnabledChanged(e);
  1148. }
  1149. protected virtual void OnEnter(EventArgs e) {
  1150. if (Enter!=null) Enter(this, e);
  1151. }
  1152. protected virtual void OnFontChanged(EventArgs e) {
  1153. if (FontChanged!=null) FontChanged(this, e);
  1154. }
  1155. protected virtual void OnForeColorChanged(EventArgs e) {
  1156. if (ForeColorChanged!=null) ForeColorChanged(this, e);
  1157. for (int i=0; i<num_of_children; i++) children[i].OnParentForeColorChanged(e);
  1158. }
  1159. protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
  1160. if (GiveFeedback!=null) GiveFeedback(this, gfbevent);
  1161. }
  1162. protected virtual void OnGotFocus(EventArgs e) {
  1163. if (GotFocus!=null) GotFocus(this, e);
  1164. }
  1165. protected virtual void OnHandleCreated(EventArgs e) {
  1166. if (HandleCreated!=null) HandleCreated(this, e);
  1167. }
  1168. protected virtual void OnHandleDestroyed(EventArgs e) {
  1169. if (HandleDestroyed!=null) HandleDestroyed(this, e);
  1170. }
  1171. protected virtual void OnHelpRequested(HelpEventArgs hevent) {
  1172. if (HelpRequested!=null) HelpRequested(this, hevent);
  1173. }
  1174. protected virtual void OnImeModeChanged(EventArgs e) {
  1175. if (ImeModeChanged!=null) ImeModeChanged(this, e);
  1176. }
  1177. protected virtual void OnInvalidated(InvalidateEventArgs e) {
  1178. if (Invalidated!=null) Invalidated(this, e);
  1179. }
  1180. protected virtual void OnKeyDown(KeyEventArgs e) {
  1181. if (KeyDown!=null) KeyDown(this, e);
  1182. }
  1183. protected virtual void OnKeyUp(KeyEventArgs e) {
  1184. if (KeyUp!=null) KeyUp(this, e);
  1185. }
  1186. protected virtual void OnLayout(LayoutEventArgs levent) {
  1187. if (Layout!=null) Layout(this, levent);
  1188. }
  1189. protected virtual void OnLeave(EventArgs e) {
  1190. if (Leave!=null) Leave(this, e);
  1191. }
  1192. protected virtual void OnLocationChanged(EventArgs e) {
  1193. if (LocationChanged!=null) LocationChanged(this, e);
  1194. }
  1195. protected virtual void OnLostFocus(EventArgs e) {
  1196. if (LostFocus!=null) LostFocus(this, e);
  1197. }
  1198. protected virtual void OnMouseDown(MouseEventArgs e) {
  1199. if (MouseDown!=null) MouseDown(this, e);
  1200. }
  1201. protected virtual void OnMouseEnter(EventArgs e) {
  1202. if (MouseEnter!=null) MouseEnter(this, e);
  1203. }
  1204. protected virtual void OnMouseHover(EventArgs e) {
  1205. if (MouseHover!=null) MouseHover(this, e);
  1206. }
  1207. protected virtual void OnMouseLeave(EventArgs e) {
  1208. if (MouseLeave!=null) MouseLeave(this, e);
  1209. }
  1210. protected virtual void OnMouseMove(MouseEventArgs e) {
  1211. if (MouseMove!=null) MouseMove(this, e);
  1212. }
  1213. protected virtual void OnMouseUp(MouseEventArgs e) {
  1214. if (MouseUp!=null) MouseUp(this, e);
  1215. }
  1216. protected virtual void OnMouseWheel(MouseEventArgs e) {
  1217. if (MouseWheel!=null) MouseWheel(this, e);
  1218. }
  1219. protected virtual void OnMove(EventArgs e) {
  1220. if (Move!=null) Move(this, e);
  1221. }
  1222. protected virtual void OnNotifyMessage(Message m) {
  1223. // Override me!
  1224. }
  1225. protected virtual void OnPaint(PaintEventArgs e) {
  1226. if (Paint!=null) Paint(this, e);
  1227. }
  1228. protected virtual void OnPaintBackground(PaintEventArgs pevent) {
  1229. // Override me!
  1230. }
  1231. protected virtual void OnParentBackColorChanged(EventArgs e) {
  1232. if (background_color.IsEmpty && background_image==null) {
  1233. Invalidate();
  1234. OnBackColorChanged(e);
  1235. }
  1236. }
  1237. protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
  1238. if (background_color.IsEmpty && background_image==null) {
  1239. Invalidate();
  1240. OnBackgroundImageChanged(e);
  1241. }
  1242. }
  1243. protected virtual void OnParentBindingContextChanged(EventArgs e) {
  1244. if (binding_context==null) {
  1245. binding_context=Parent.binding_context;
  1246. OnBindingContextChanged(e);
  1247. }
  1248. }
  1249. protected virtual void OnParentChanged(EventArgs e) {
  1250. if (ParentChanged!=null) ParentChanged(this, e);
  1251. }
  1252. protected virtual void OnParentEnabledChanged(EventArgs e) {
  1253. if ((is_enabled && !Parent.is_enabled) || (!is_enabled && Parent.is_enabled)) {
  1254. is_enabled=false;
  1255. Invalidate();
  1256. EnabledChanged(this, e);
  1257. }
  1258. }
  1259. protected virtual void OnParentFontChanged(EventArgs e) {
  1260. if (font==null) {
  1261. Invalidate();
  1262. OnFontChanged(e);
  1263. }
  1264. }
  1265. protected virtual void OnParentForeColorChanged(EventArgs e) {
  1266. if (foreground_color.IsEmpty) {
  1267. Invalidate();
  1268. OnForeColorChanged(e);
  1269. }
  1270. }
  1271. protected virtual void OnParentRightToLeftChanged(EventArgs e) {
  1272. if (right_to_left==RightToLeft.Inherit) {
  1273. Invalidate();
  1274. OnRightToLeftChanged(e);
  1275. }
  1276. }
  1277. protected virtual void OnParentVisibleChanged(EventArgs e) {
  1278. if (is_visible!=Parent.is_visible) {
  1279. is_visible=false;
  1280. Invalidate();
  1281. OnVisibleChanged(e);
  1282. }
  1283. }
  1284. protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
  1285. if (QueryContinueDrag!=null) QueryContinueDrag(this, e);
  1286. }
  1287. protected virtual void OnResize(EventArgs e) {
  1288. if (Resize!=null) Resize(this, e);
  1289. }
  1290. protected virtual void OnRightToLeftChanged(EventArgs e) {
  1291. if (RightToLeftChanged!=null) RightToLeftChanged(this, e);
  1292. for (int i=0; i<num_of_children; i++) children[i].OnParentRightToLeftChanged(e);
  1293. }
  1294. protected virtual void OnSizeChanged(EventArgs e) {
  1295. if (SizeChanged!=null) SizeChanged(this, e);
  1296. }
  1297. protected virtual void OnStyleChanged(EventArgs e) {
  1298. if (StyleChanged!=null) StyleChanged(this, e);
  1299. }
  1300. protected virtual void OnSystemColorsChanged(EventArgs e) {
  1301. if (SystemColorsChanged!=null) SystemColorsChanged(this, e);
  1302. }
  1303. protected virtual void OnTabIndexChanged(EventArgs e) {
  1304. if (TabIndexChanged!=null) TabIndexChanged(this, e);
  1305. }
  1306. protected virtual void OnTabStopChanged(EventArgs e) {
  1307. if (TabStopChanged!=null) TabStopChanged(this, e);
  1308. }
  1309. protected virtual void OnTextChanged(EventArgs e) {
  1310. if (TextChanged!=null) TextChanged(this, e);
  1311. }
  1312. protected virtual void OnValidated(EventArgs e) {
  1313. if (Validated!=null) Validated(this, e);
  1314. }
  1315. protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
  1316. if (Validating!=null) Validating(this, e);
  1317. }
  1318. protected virtual void OnVisibleChanged(EventArgs e) {
  1319. if (VisibleChanged!=null) VisibleChanged(this, e);
  1320. }
  1321. #endregion // OnXXX methods
  1322. #region Events
  1323. public event EventHandler BackColorChanged;
  1324. public event EventHandler BackgroundImageChanged;
  1325. public event EventHandler BindingContextChanged;
  1326. public event EventHandler CausesValidationChanged;
  1327. public event UICuesEventHandler ChangeUICues;
  1328. public event EventHandler Click;
  1329. public event EventHandler ContextMenuChanged;
  1330. public event ControlEventHandler ControlAdded;
  1331. public event ControlEventHandler ControlRemoved;
  1332. public event EventHandler CursorChanged;
  1333. public event EventHandler DockChanged;
  1334. public event EventHandler DoubleClick;
  1335. public event DragEventHandler DragDrop;
  1336. public event DragEventHandler DragEnter;
  1337. public event EventHandler DragLeave;
  1338. public event DragEventHandler DragOver;
  1339. public event EventHandler EnabledChanged;
  1340. public event EventHandler Enter;
  1341. public event EventHandler FontChanged;
  1342. public event EventHandler ForeColorChanged;
  1343. public event GiveFeedbackEventHandler GiveFeedback;
  1344. public event EventHandler GotFocus;
  1345. public event EventHandler HandleCreated;
  1346. public event EventHandler HandleDestroyed;
  1347. public event HelpEventHandler HelpRequested;
  1348. public event EventHandler ImeModeChanged;
  1349. public event InvalidateEventHandler Invalidated;
  1350. public event KeyEventHandler KeyDown;
  1351. public event KeyPressEventHandler KeyPress;
  1352. public event KeyEventHandler KeyUp;
  1353. public event LayoutEventHandler Layout;
  1354. public event EventHandler Leave;
  1355. public event EventHandler LocationChanged;
  1356. public event EventHandler LostFocus;
  1357. public event MouseEventHandler MouseDown;
  1358. public event EventHandler MouseEnter;
  1359. public event EventHandler MouseHover;
  1360. public event EventHandler MouseLeave;
  1361. public event MouseEventHandler MouseMove;
  1362. public event MouseEventHandler MouseUp;
  1363. public event MouseEventHandler MouseWheel;
  1364. public event EventHandler Move;
  1365. public event PaintEventHandler Paint;
  1366. public event EventHandler ParentChanged;
  1367. public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp;
  1368. public event QueryContinueDragEventHandler QueryContinueDrag;
  1369. public event EventHandler Resize;
  1370. public event EventHandler RightToLeftChanged;
  1371. public event EventHandler SizeChanged;
  1372. public event EventHandler StyleChanged;
  1373. public event EventHandler SystemColorsChanged;
  1374. public event EventHandler TabIndexChanged;
  1375. public event EventHandler TabStopChanged;
  1376. public event EventHandler TextChanged;
  1377. public event EventHandler Validated;
  1378. public event CancelEventHandler Validating;
  1379. public event EventHandler VisibleChanged;
  1380. #endregion // Events
  1381. }
  1382. }