Control.cs 104 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240
  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-2005 Novell, Inc.
  21. //
  22. // Authors:
  23. // Peter Bartok [email protected]
  24. //
  25. // Partially 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. // COMPLETE
  33. using System;
  34. using System.ComponentModel;
  35. using System.ComponentModel.Design;
  36. using System.ComponentModel.Design.Serialization;
  37. using System.Collections;
  38. using System.Diagnostics;
  39. using System.Drawing;
  40. using System.Reflection;
  41. using System.Runtime.InteropServices;
  42. using System.Security;
  43. using System.Threading;
  44. namespace System.Windows.Forms
  45. {
  46. [Designer("System.Windows.Forms.Design.ControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
  47. [DefaultProperty("Text")]
  48. [DefaultEvent("Click")]
  49. [DesignerSerializer("System.Windows.Forms.Design.ControlCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
  50. [ToolboxItemFilter("System.Windows.Forms")]
  51. public class Control : Component, ISynchronizeInvoke, IWin32Window
  52. {
  53. #region Local Variables
  54. // Basic
  55. internal Rectangle bounds; // bounding rectangle for control (client area + decorations)
  56. internal object creator_thread; // thread that created the control
  57. internal ControlNativeWindow window; // object for native window handle
  58. internal string name; // for object naming
  59. // State
  60. private bool create_handled; // true if OnCreateControl has been sent
  61. internal bool has_focus; // true if control has focus
  62. internal bool is_visible; // true if control is visible
  63. internal bool is_entered; // is the mouse inside the control?
  64. internal bool is_enabled; // true if control is enabled (usable/not grayed out)
  65. internal bool is_selected; // true if control is selected
  66. internal bool is_accessible; // true if the control is visible to accessibility applications
  67. internal bool is_captured; // tracks if the control has captured the mouse
  68. internal bool is_toplevel; // tracks if the control is a toplevel window
  69. internal bool is_recreating; // tracks if the handle for the control is being recreated
  70. internal bool causes_validation; // tracks if validation is executed on changes
  71. internal int tab_index; // position in tab order of siblings
  72. internal bool tab_stop = true; // is the control a tab stop?
  73. internal bool is_disposed; // has the window already been disposed?
  74. internal Size client_size; // size of the client area (window excluding decorations)
  75. internal Rectangle client_rect; // rectangle with the client area (window excluding decorations)
  76. internal ControlStyles control_style; // rather win32-specific, style bits for control
  77. internal ImeMode ime_mode = ImeMode.Inherit;
  78. internal bool layout_pending; // true if our parent needs to re-layout us
  79. internal object control_tag; // object that contains data about our control
  80. internal int mouse_clicks; // Counter for mouse clicks
  81. internal Cursor cursor; // Cursor for the window
  82. internal bool allow_drop; // true if the control accepts droping objects on it
  83. // Visuals
  84. internal Color foreground_color; // foreground color for control
  85. internal Color background_color; // background color for control
  86. internal Image background_image; // background image for control
  87. internal Font font; // font for control
  88. internal string text; // window/title text for control
  89. internal BorderStyle border_style; // Border style of control
  90. // Layout
  91. internal AnchorStyles anchor_style; // anchoring requirements for our control
  92. internal DockStyle dock_style; // docking requirements for our control (supercedes anchoring)
  93. internal int dist_left; // distance to the left border of the parent
  94. internal int dist_top; // distance to the top border of the parent
  95. internal int dist_right; // distance to the right border of the parent
  96. internal int dist_bottom; // distance to the bottom border of the parent
  97. // to be categorized...
  98. static internal ArrayList controls = new ArrayList(); // All of the application's controls, in a flat list
  99. internal ControlCollection child_controls; // our children
  100. internal Control parent; // our parent control
  101. internal AccessibleObject accessibility_object; // object that contains accessibility information about our control
  102. internal BindingContext binding_context; // TODO
  103. internal RightToLeft right_to_left; // drawing direction for control
  104. internal int layout_suspended;
  105. internal ContextMenu context_menu; // Context menu associated with the control
  106. private Graphics dc_mem; // Graphics context for double buffering
  107. private Bitmap bmp_mem; // Bitmap for double buffering control
  108. private bool needs_redraw = true;
  109. private ControlBindingsCollection data_bindings;
  110. #endregion // Local Variables
  111. #region Private Classes
  112. // This helper class allows us to dispatch messages to Control.WndProc
  113. internal class ControlNativeWindow : NativeWindow {
  114. private Control owner;
  115. public ControlNativeWindow(Control control) : base() {
  116. this.owner=control;
  117. }
  118. public Control Owner {
  119. get {
  120. return owner;
  121. }
  122. }
  123. static internal Control ControlFromHandle(IntPtr hWnd) {
  124. ControlNativeWindow window;
  125. window = (ControlNativeWindow)window_collection[hWnd];
  126. return window.owner;
  127. }
  128. protected override void WndProc(ref Message m) {
  129. owner.WndProc(ref m);
  130. }
  131. }
  132. #endregion
  133. #region Public Classes
  134. [ComVisible(true)]
  135. public class ControlAccessibleObject : AccessibleObject {
  136. #region ControlAccessibleObject Local Variables
  137. private Control owner;
  138. #endregion // ControlAccessibleObject Local Variables
  139. #region ControlAccessibleObject Constructors
  140. public ControlAccessibleObject(Control ownerControl) {
  141. this.owner = ownerControl;
  142. }
  143. #endregion // ControlAccessibleObject Constructors
  144. #region ControlAccessibleObject Public Instance Properties
  145. public override string DefaultAction {
  146. get {
  147. return base.DefaultAction;
  148. }
  149. }
  150. public override string Description {
  151. get {
  152. return base.Description;
  153. }
  154. }
  155. public IntPtr Handle {
  156. get {
  157. return owner.Handle;
  158. }
  159. set {
  160. // We don't want to let them set it
  161. }
  162. }
  163. public override string Help {
  164. get {
  165. return base.Help;
  166. }
  167. }
  168. public override string KeyboardShortcut {
  169. get {
  170. return base.KeyboardShortcut;
  171. }
  172. }
  173. public override string Name {
  174. get {
  175. return base.Name;
  176. }
  177. set {
  178. base.Name = value;
  179. }
  180. }
  181. public Control Owner {
  182. get {
  183. return owner;
  184. }
  185. }
  186. public override AccessibleObject Parent {
  187. get {
  188. return base.Parent;
  189. }
  190. }
  191. public override AccessibleRole Role {
  192. get {
  193. return base.Role;
  194. }
  195. }
  196. #endregion // ControlAccessibleObject Public Instance Properties
  197. #region ControlAccessibleObject Public Instance Methods
  198. public override int GetHelpTopic(out string FileName) {
  199. return base.GetHelpTopic (out FileName);
  200. }
  201. [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
  202. public void NotifyClients(AccessibleEvents accEvent) {
  203. throw new NotImplementedException();
  204. }
  205. [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
  206. public void NotifyClients(AccessibleEvents accEvent, int childID) {
  207. throw new NotImplementedException();
  208. }
  209. public override string ToString() {
  210. return "ControlAccessibleObject: Owner = " + owner.ToString() + ", Text: " + owner.text;
  211. }
  212. #endregion // ControlAccessibleObject Public Instance Methods
  213. }
  214. [DesignerSerializer("System.Windows.Forms.Design.ControlCollectionCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
  215. [ListBindable(false)]
  216. public class ControlCollection : IList, ICollection, ICloneable, IEnumerable {
  217. #region ControlCollection Local Variables
  218. private ArrayList list;
  219. private ArrayList impl_list;
  220. private Control [] all_controls;
  221. internal Control owner;
  222. #endregion // ControlCollection Local Variables
  223. #region ControlCollection Public Constructor
  224. public ControlCollection(Control owner) {
  225. this.owner=owner;
  226. this.list=new ArrayList();
  227. }
  228. #endregion
  229. #region ControlCollection Public Instance Properties
  230. public int Count {
  231. get {
  232. return list.Count;
  233. }
  234. }
  235. public virtual bool IsReadOnly {
  236. get {
  237. return list.IsReadOnly;
  238. }
  239. }
  240. public virtual Control this[int index] {
  241. get {
  242. if (index < 0 || index >= list.Count) {
  243. throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
  244. }
  245. return (Control)list[index];
  246. }
  247. }
  248. #endregion // ControlCollection Public Instance Properties
  249. #region ControlCollection Private Instance Methods
  250. public virtual void Add (Control value)
  251. {
  252. if (value == null)
  253. return;
  254. if (Contains (value))
  255. return;
  256. if (value.tab_index == -1) {
  257. int end;
  258. int index;
  259. int use;
  260. use = 0;
  261. end = owner.child_controls.Count;
  262. for (int i = 0; i < end; i++) {
  263. index = owner.child_controls[i].tab_index;
  264. if (index >= use) {
  265. use = index + 1;
  266. }
  267. }
  268. value.tab_index = use;
  269. }
  270. all_controls = null;
  271. list.Add (value);
  272. value.Parent = owner;
  273. owner.UpdateZOrder();
  274. owner.OnControlAdded(new ControlEventArgs(value));
  275. }
  276. internal void AddToList (Control c)
  277. {
  278. all_controls = null;
  279. list.Add (c);
  280. }
  281. internal virtual void AddImplicit (Control control)
  282. {
  283. if (impl_list == null)
  284. impl_list = new ArrayList ();
  285. all_controls = null;
  286. impl_list.Add (control);
  287. control.Parent = owner;
  288. owner.UpdateZOrder ();
  289. }
  290. public virtual void AddRange (Control[] controls)
  291. {
  292. if (controls == null)
  293. throw new ArgumentNullException ("controls");
  294. owner.SuspendLayout ();
  295. try {
  296. for (int i = 0; i < controls.Length; i++)
  297. Add (controls[i]);
  298. } finally {
  299. owner.ResumeLayout ();
  300. }
  301. }
  302. internal virtual void AddRangeImplicit (Control [] controls)
  303. {
  304. if (controls == null)
  305. throw new ArgumentNullException ("controls");
  306. owner.SuspendLayout ();
  307. try {
  308. for (int i = 0; i < controls.Length; i++)
  309. AddImplicit (controls [i]);
  310. } finally {
  311. owner.ResumeLayout ();
  312. }
  313. }
  314. public virtual void Clear ()
  315. {
  316. owner.SuspendLayout();
  317. all_controls = null;
  318. for (int i = 0; i < list.Count; i++) {
  319. owner.OnControlRemoved(new ControlEventArgs((Control)list[i]));
  320. }
  321. list.Clear();
  322. owner.ResumeLayout();
  323. }
  324. internal virtual void ClearImplicit ()
  325. {
  326. if (impl_list == null)
  327. return;
  328. all_controls = null;
  329. impl_list.Clear ();
  330. }
  331. public bool Contains (Control value)
  332. {
  333. for (int i = list.Count; i > 0; ) {
  334. i--;
  335. if (list [i] == value) {
  336. // Do we need to do anything here?
  337. return true;
  338. }
  339. }
  340. return false;
  341. }
  342. internal bool ImplicitContains (Control value)
  343. {
  344. if (impl_list == null)
  345. return false;
  346. for (int i = impl_list.Count; i > 0; ) {
  347. i--;
  348. if (impl_list [i] == value) {
  349. // Do we need to do anything here?
  350. return true;
  351. }
  352. }
  353. return false;
  354. }
  355. internal bool AllContains (Control value)
  356. {
  357. return Contains (value) || ImplicitContains (value);
  358. }
  359. public virtual void CopyTo (Array array, int index)
  360. {
  361. list.CopyTo(array, index);
  362. }
  363. public override bool Equals(object other) {
  364. if (other is ControlCollection && (((ControlCollection)other).owner==this.owner)) {
  365. return(true);
  366. } else {
  367. return(false);
  368. }
  369. }
  370. public int GetChildIndex(Control child) {
  371. return GetChildIndex(child, false);
  372. }
  373. public int GetChildIndex(Control child, bool throwException) {
  374. int index;
  375. index=list.IndexOf(child);
  376. if (index==-1 && throwException) {
  377. throw new ArgumentException("Not a child control", "child");
  378. }
  379. return index;
  380. }
  381. public IEnumerator GetEnumerator() {
  382. return list.GetEnumerator();
  383. }
  384. internal IEnumerator GetAllEnumerator ()
  385. {
  386. Control [] res = GetAllControls ();
  387. return res.GetEnumerator ();
  388. }
  389. internal Control [] GetAllControls ()
  390. {
  391. if (all_controls != null)
  392. return all_controls;
  393. if (impl_list == null)
  394. return (Control []) list.ToArray (typeof (Control));
  395. Control [] res = new Control [list.Count + impl_list.Count];
  396. list.CopyTo (res);
  397. impl_list.CopyTo (res, list.Count);
  398. return res;
  399. }
  400. public override int GetHashCode() {
  401. return base.GetHashCode();
  402. }
  403. public int IndexOf(Control control) {
  404. return list.IndexOf(control);
  405. }
  406. public virtual void Remove(Control value) {
  407. all_controls = null;
  408. owner.OnControlRemoved(new ControlEventArgs(value));
  409. list.Remove(value);
  410. value.parent = null;
  411. owner.UpdateZOrder();
  412. }
  413. internal virtual void RemoveImplicit (Control control)
  414. {
  415. if (impl_list != null) {
  416. all_controls = null;
  417. impl_list.Remove (control);
  418. }
  419. control.Parent = null;
  420. owner.UpdateZOrder ();
  421. }
  422. public void RemoveAt(int index) {
  423. if (index < 0 || index >= list.Count) {
  424. throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
  425. }
  426. Remove ((Control)list[index]);
  427. }
  428. public void SetChildIndex(Control child, int newIndex) {
  429. int old_index;
  430. old_index=list.IndexOf(child);
  431. if (old_index==-1) {
  432. throw new ArgumentException("Not a child control", "child");
  433. }
  434. if (old_index==newIndex) {
  435. return;
  436. }
  437. RemoveAt(old_index);
  438. if (newIndex>list.Count) {
  439. list.Add(child);
  440. } else {
  441. list.Insert(newIndex, child);
  442. }
  443. child.parent = owner;
  444. owner.UpdateZOrder();
  445. }
  446. #endregion // ControlCollection Private Instance Methods
  447. #region ControlCollection Interface Properties
  448. object IList.this[int index] {
  449. get {
  450. if (index<0 || index>=list.Count) {
  451. throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
  452. }
  453. return this[index];
  454. }
  455. set {
  456. if (!(value is Control)) {
  457. throw new ArgumentException("Object of type Control required", "value");
  458. }
  459. list[index]=(Control)value;
  460. }
  461. }
  462. bool IList.IsFixedSize {
  463. get {
  464. return false;
  465. }
  466. }
  467. bool IList.IsReadOnly {
  468. get {
  469. return list.IsReadOnly;
  470. }
  471. }
  472. bool ICollection.IsSynchronized {
  473. get {
  474. return list.IsSynchronized;
  475. }
  476. }
  477. object ICollection.SyncRoot {
  478. get {
  479. return list.SyncRoot;
  480. }
  481. }
  482. #endregion // ControlCollection Interface Properties
  483. #region ControlCollection Interface Methods
  484. int IList.Add(object value) {
  485. if (value == null) {
  486. throw new ArgumentNullException("value", "Cannot add null controls");
  487. }
  488. if (!(value is Control)) {
  489. throw new ArgumentException("Object of type Control required", "value");
  490. }
  491. return list.Add(value);
  492. }
  493. bool IList.Contains(object value) {
  494. if (!(value is Control)) {
  495. throw new ArgumentException("Object of type Control required", "value");
  496. }
  497. return this.Contains((Control) value);
  498. }
  499. int IList.IndexOf(object value) {
  500. if (!(value is Control)) {
  501. throw new ArgumentException("Object of type Control required", "value");
  502. }
  503. return this.IndexOf((Control) value);
  504. }
  505. void IList.Insert(int index, object value) {
  506. if (!(value is Control)) {
  507. throw new ArgumentException("Object of type Control required", "value");
  508. }
  509. all_controls = null;
  510. list.Insert(index, value);
  511. }
  512. void IList.Remove(object value) {
  513. if (!(value is Control)) {
  514. throw new ArgumentException("Object of type Control required", "value");
  515. }
  516. all_controls = null;
  517. list.Remove(value);
  518. }
  519. void ICollection.CopyTo(Array array, int index) {
  520. if (list.Count>0) {
  521. list.CopyTo(array, index);
  522. }
  523. }
  524. Object ICloneable.Clone() {
  525. ControlCollection clone = new ControlCollection(this.owner);
  526. clone.list=(ArrayList)list.Clone(); // FIXME: Do we need this?
  527. return clone;
  528. }
  529. #endregion // ControlCollection Interface Methods
  530. }
  531. #endregion // ControlCollection Class
  532. #region Public Constructors
  533. public Control() {
  534. creator_thread = Thread.CurrentThread;
  535. anchor_style = AnchorStyles.Top | AnchorStyles.Left;
  536. create_handled = false;
  537. is_visible = true;
  538. is_captured = false;
  539. is_disposed = false;
  540. is_enabled = true;
  541. is_entered = false;
  542. layout_pending = false;
  543. is_toplevel = false;
  544. causes_validation = true;
  545. has_focus = false;
  546. layout_suspended = 0;
  547. mouse_clicks = 1;
  548. tab_index = -1;
  549. cursor = null;
  550. right_to_left = RightToLeft.Inherit;
  551. border_style = BorderStyle.None;
  552. background_color = Color.Empty;
  553. dist_left = 0;
  554. dist_right = 0;
  555. dist_top = 0;
  556. dist_bottom = 0;
  557. control_style = ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
  558. ControlStyles.Selectable | ControlStyles.StandardClick |
  559. ControlStyles.StandardDoubleClick;
  560. parent = null;
  561. background_image = null;
  562. text = string.Empty;
  563. name = string.Empty;
  564. window = new ControlNativeWindow(this);
  565. child_controls = CreateControlsInstance();
  566. client_size = new Size(DefaultSize.Width, DefaultSize.Height);
  567. client_rect = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
  568. XplatUI.CalculateWindowRect(IntPtr.Zero, ref client_rect, CreateParams.Style, CreateParams.ExStyle, IntPtr.Zero, out bounds);
  569. if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) == 0) {
  570. bounds.X=-1;
  571. bounds.Y=-1;
  572. }
  573. }
  574. public Control(Control parent, string text) : this() {
  575. Text=text;
  576. Parent=parent;
  577. }
  578. public Control(Control parent, string text, int left, int top, int width, int height) : this() {
  579. Parent=parent;
  580. bounds.X=left;
  581. bounds.Y=top;
  582. bounds.Width=width;
  583. bounds.Height=height;
  584. SetBoundsCore(left, top, width, height, BoundsSpecified.All);
  585. Text=text;
  586. }
  587. public Control(string text) : this() {
  588. Text=text;
  589. }
  590. public Control(string text, int left, int top, int width, int height) : this() {
  591. bounds.X=left;
  592. bounds.Y=top;
  593. bounds.Width=width;
  594. bounds.Height=height;
  595. SetBoundsCore(left, top, width, height, BoundsSpecified.All);
  596. Text=text;
  597. }
  598. private delegate void RemoveDelegate(object c);
  599. protected override void Dispose(bool disposing) {
  600. is_disposed = true;
  601. if (dc_mem!=null) {
  602. dc_mem.Dispose();
  603. dc_mem=null;
  604. }
  605. if (bmp_mem!=null) {
  606. bmp_mem.Dispose();
  607. bmp_mem=null;
  608. }
  609. if (this.InvokeRequired) {
  610. this.Invoke(new MethodInvoker(DestroyHandle));
  611. this.Invoke(new RemoveDelegate(controls.Remove), new object[] {this});
  612. } else {
  613. DestroyHandle();
  614. controls.Remove(this);
  615. }
  616. }
  617. #endregion // Public Constructors
  618. #region Internal Properties
  619. internal BorderStyle InternalBorderStyle {
  620. get {
  621. return border_style;
  622. }
  623. set {
  624. if (!Enum.IsDefined (typeof (BorderStyle), value))
  625. throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for BorderStyle", value));
  626. if (border_style != value) {
  627. border_style = value;
  628. if (IsHandleCreated) {
  629. XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
  630. Refresh();
  631. }
  632. }
  633. }
  634. }
  635. #endregion // Internal Properties
  636. #region Private & Internal Methods
  637. internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args) {
  638. AsyncMethodResult result;
  639. AsyncMethodData data;
  640. Control p;
  641. p = this;
  642. do {
  643. if (!p.IsHandleCreated) {
  644. throw new InvalidOperationException("Cannot call Invoke or InvokeAsync on a control until the window handle is created");
  645. }
  646. p = p.parent;
  647. } while (p != null);
  648. result = new AsyncMethodResult ();
  649. data = new AsyncMethodData ();
  650. data.Method = method;
  651. data.Args = args;
  652. data.Result = new WeakReference (result);
  653. #if NET_2_0
  654. if (!ExecutionContext.IsFlowSuppressed ()) {
  655. data.Context = ExecutionContext.Capture ();
  656. }
  657. #else
  658. #if !MWF_ON_MSRUNTIME
  659. if (SecurityManager.SecurityEnabled) {
  660. data.Stack = CompressedStack.GetCompressedStack ();
  661. }
  662. #endif
  663. #endif
  664. XplatUI.SendAsyncMethod (data);
  665. return result;
  666. }
  667. internal Graphics DeviceContext {
  668. get {
  669. if (dc_mem==null) {
  670. CreateBuffers(this.Width, this.Height);
  671. }
  672. return dc_mem;
  673. }
  674. }
  675. private Bitmap ImageBuffer {
  676. get {
  677. if (bmp_mem==null) {
  678. CreateBuffers(this.Width, this.Height);
  679. }
  680. return bmp_mem;
  681. }
  682. }
  683. internal void CreateBuffers (int width, int height) {
  684. if (dc_mem != null) {
  685. dc_mem.Dispose ();
  686. }
  687. if (bmp_mem != null)
  688. bmp_mem.Dispose ();
  689. if (width < 1) {
  690. width = 1;
  691. }
  692. if (height < 1) {
  693. height = 1;
  694. }
  695. bmp_mem = new Bitmap (width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
  696. dc_mem = Graphics.FromImage (bmp_mem);
  697. needs_redraw = true;
  698. }
  699. internal void InvalidateBuffers ()
  700. {
  701. if (dc_mem != null) {
  702. dc_mem.Dispose ();
  703. }
  704. if (bmp_mem != null)
  705. bmp_mem.Dispose ();
  706. dc_mem = null;
  707. bmp_mem = null;
  708. needs_redraw = true;
  709. }
  710. internal static void SetChildColor(Control parent) {
  711. Control child;
  712. for (int i=0; i < parent.child_controls.Count; i++) {
  713. child=parent.child_controls[i];
  714. if (child.child_controls.Count>0) {
  715. SetChildColor(child);
  716. }
  717. }
  718. }
  719. internal bool Select(Control control) {
  720. Control parent;
  721. IContainerControl container;
  722. if (control == null) {
  723. return false;
  724. }
  725. parent = control.parent;
  726. if (((control.control_style & ControlStyles.Selectable) !=0) && (parent != null)) {
  727. while (parent != null) {
  728. if (!parent.Visible || !parent.is_enabled) {
  729. return false;
  730. }
  731. parent = parent.parent;
  732. }
  733. }
  734. control.is_selected = true;
  735. container = GetContainerControl();
  736. if (container != null) {
  737. container.ActiveControl = control;
  738. }
  739. if (control.IsHandleCreated) {
  740. XplatUI.SetFocus(control.window.Handle);
  741. }
  742. return true;
  743. }
  744. internal virtual void DoDefaultAction() {
  745. // Only here to be overriden by our actual controls; this is needed by the accessibility class
  746. }
  747. internal static int LowOrder (int param) {
  748. return ((int)(short)(param & 0xffff));
  749. }
  750. internal static int HighOrder (int param) {
  751. return ((int)(short)(param >> 16));
  752. }
  753. // This method exists so controls overriding OnPaintBackground can have default background painting done
  754. internal virtual void PaintControlBackground (PaintEventArgs pevent)
  755. {
  756. if (background_image == null) {
  757. pevent.Graphics.FillRectangle(ThemeEngine.Current.ResPool.GetSolidBrush(BackColor), new Rectangle(pevent.ClipRectangle.X - 1, pevent.ClipRectangle.Y - 1, pevent.ClipRectangle.Width + 2, pevent.ClipRectangle.Height + 2));
  758. return;
  759. }
  760. DrawBackgroundImage (pevent.Graphics);
  761. }
  762. void DrawBackgroundImage (Graphics g)
  763. {
  764. using (TextureBrush b = new TextureBrush (background_image)) {
  765. g.FillRectangle (b, ClientRectangle);
  766. }
  767. }
  768. internal virtual void DndEnter (DragEventArgs e)
  769. {
  770. try {
  771. OnDragEnter (e);
  772. } catch { }
  773. }
  774. internal virtual void DndOver (DragEventArgs e)
  775. {
  776. try {
  777. OnDragOver (e);
  778. } catch { }
  779. }
  780. internal virtual void DndDrop (DragEventArgs e)
  781. {
  782. try {
  783. OnDragDrop (e);
  784. } catch (Exception exc) {
  785. Console.Error.WriteLine ("MWF: Exception while dropping:");
  786. Console.Error.WriteLine (exc);
  787. }
  788. }
  789. internal virtual void DndLeave (EventArgs e)
  790. {
  791. try {
  792. OnDragLeave (e);
  793. } catch { }
  794. }
  795. internal virtual void DndFeedback(GiveFeedbackEventArgs e)
  796. {
  797. try {
  798. OnGiveFeedback(e);
  799. } catch { }
  800. }
  801. internal virtual void DndContinueDrag(QueryContinueDragEventArgs e)
  802. {
  803. try {
  804. OnQueryContinueDrag(e);
  805. } catch { }
  806. }
  807. internal static MouseButtons FromParamToMouseButtons (int param) {
  808. MouseButtons buttons = MouseButtons.None;
  809. if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
  810. buttons |= MouseButtons.Left;
  811. if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
  812. buttons |= MouseButtons.Middle;
  813. if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
  814. buttons |= MouseButtons.Right;
  815. return buttons;
  816. }
  817. internal virtual bool ProcessControlMnemonic(char charCode) {
  818. return ProcessMnemonic(charCode);
  819. }
  820. private static Control FindFlatForward(Control container, Control start) {
  821. Control found;
  822. int index;
  823. int end;
  824. found = null;
  825. end = container.child_controls.Count;
  826. if (start != null) {
  827. index = start.tab_index;
  828. } else {
  829. index = -1;
  830. }
  831. for (int i = 0; i < end; i++) {
  832. if (found == null) {
  833. if (container.child_controls[i].tab_index > index) {
  834. found = container.child_controls[i];
  835. }
  836. } else if (found.tab_index > container.child_controls[i].tab_index) {
  837. if (container.child_controls[i].tab_index > index) {
  838. found = container.child_controls[i];
  839. }
  840. }
  841. }
  842. return found;
  843. }
  844. private static Control FindControlForward(Control container, Control start) {
  845. Control found;
  846. Control p;
  847. found = null;
  848. if (start != null) {
  849. if ((start is IContainerControl) || start.GetStyle(ControlStyles.ContainerControl)) {
  850. found = FindControlForward(start, null);
  851. if (found != null) {
  852. return found;
  853. }
  854. }
  855. p = start.parent;
  856. while (p != container) {
  857. found = FindFlatForward(p, start);
  858. if (found != null) {
  859. return found;
  860. }
  861. start = p;
  862. p = p.parent;
  863. }
  864. }
  865. return FindFlatForward(container, start);
  866. }
  867. private static Control FindFlatBackward(Control container, Control start) {
  868. Control found;
  869. int index;
  870. int end;
  871. found = null;
  872. end = container.child_controls.Count;
  873. if (start != null) {
  874. index = start.tab_index;
  875. } else {
  876. // FIXME: Possible speed-up: Keep the highest taborder index in the container
  877. index = -1;
  878. for (int i = 0; i < end; i++) {
  879. if (container.child_controls[i].tab_index > index) {
  880. index = container.child_controls[i].tab_index;
  881. }
  882. }
  883. index++;
  884. }
  885. for (int i = 0; i < end; i++) {
  886. if (found == null) {
  887. if (container.child_controls[i].tab_index < index) {
  888. found = container.child_controls[i];
  889. }
  890. } else if (found.tab_index < container.child_controls[i].tab_index) {
  891. if (container.child_controls[i].tab_index < index) {
  892. found = container.child_controls[i];
  893. }
  894. }
  895. }
  896. return found;
  897. }
  898. private static Control FindControlBackward(Control container, Control start) {
  899. Control found;
  900. found = null;
  901. if (start != null) {
  902. found = FindFlatBackward(start.parent, start);
  903. if (found == null && start.parent != container) {
  904. return start.parent;
  905. }
  906. }
  907. if (found == null) {
  908. found = FindFlatBackward(container, start);
  909. }
  910. while ((found != null) && ((found is IContainerControl) || found.GetStyle(ControlStyles.ContainerControl))) {
  911. found = FindControlBackward(found, null);
  912. if (found != null) {
  913. return found;
  914. }
  915. }
  916. return found;
  917. }
  918. private void HandleClick(int clicks) {
  919. if (GetStyle(ControlStyles.StandardClick)) {
  920. if (clicks > 1) {
  921. if (GetStyle(ControlStyles.StandardDoubleClick)) {
  922. OnDoubleClick(EventArgs.Empty);
  923. } else {
  924. OnClick(EventArgs.Empty);
  925. }
  926. } else {
  927. OnClick(EventArgs.Empty);
  928. }
  929. }
  930. }
  931. private void CheckDataBindings ()
  932. {
  933. if (data_bindings == null)
  934. return;
  935. BindingContext binding_context = BindingContext;
  936. foreach (Binding binding in data_bindings) {
  937. binding.Check (binding_context);
  938. }
  939. }
  940. #endregion // Private & Internal Methods
  941. #region Public Static Properties
  942. public static Color DefaultBackColor {
  943. get {
  944. return ThemeEngine.Current.DefaultControlBackColor;
  945. }
  946. }
  947. public static Font DefaultFont {
  948. get {
  949. return ThemeEngine.Current.DefaultFont;
  950. }
  951. }
  952. public static Color DefaultForeColor {
  953. get {
  954. return ThemeEngine.Current.DefaultControlForeColor;
  955. }
  956. }
  957. public static Keys ModifierKeys {
  958. get {
  959. return XplatUI.State.ModifierKeys;
  960. }
  961. }
  962. public static MouseButtons MouseButtons {
  963. get {
  964. return XplatUI.State.MouseButtons;
  965. }
  966. }
  967. public static Point MousePosition {
  968. get {
  969. return Cursor.Position;
  970. }
  971. }
  972. #if NET_2_0
  973. [MonoTODO]
  974. public static bool CheckForIllegalCrossThreadCalls
  975. {
  976. set {
  977. }
  978. get {
  979. return false;
  980. }
  981. }
  982. #endif
  983. #endregion // Public Static Properties
  984. #region Public Instance Properties
  985. [EditorBrowsable(EditorBrowsableState.Advanced)]
  986. [Browsable(false)]
  987. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  988. public AccessibleObject AccessibilityObject {
  989. get {
  990. if (accessibility_object==null) {
  991. accessibility_object=CreateAccessibilityInstance();
  992. }
  993. return accessibility_object;
  994. }
  995. }
  996. [EditorBrowsable(EditorBrowsableState.Advanced)]
  997. [Browsable(false)]
  998. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  999. public string AccessibleDefaultActionDescription {
  1000. get {
  1001. return AccessibilityObject.default_action;
  1002. }
  1003. set {
  1004. AccessibilityObject.default_action=value;
  1005. }
  1006. }
  1007. [Localizable(true)]
  1008. [DefaultValue(null)]
  1009. public string AccessibleDescription {
  1010. get {
  1011. return AccessibilityObject.description;
  1012. }
  1013. set {
  1014. AccessibilityObject.description=value;
  1015. }
  1016. }
  1017. [Localizable(true)]
  1018. [DefaultValue(null)]
  1019. public string AccessibleName {
  1020. get {
  1021. return AccessibilityObject.Name;
  1022. }
  1023. set {
  1024. AccessibilityObject.Name=value;
  1025. }
  1026. }
  1027. [DefaultValue(AccessibleRole.Default)]
  1028. [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
  1029. public AccessibleRole AccessibleRole {
  1030. get {
  1031. return AccessibilityObject.role;
  1032. }
  1033. set {
  1034. AccessibilityObject.role=value;
  1035. }
  1036. }
  1037. [DefaultValue(false)]
  1038. public virtual bool AllowDrop {
  1039. get {
  1040. return allow_drop;
  1041. }
  1042. set {
  1043. if (allow_drop == value)
  1044. return;
  1045. allow_drop = value;
  1046. UpdateStyles();
  1047. XplatUI.SetAllowDrop (Handle, value);
  1048. }
  1049. }
  1050. [Localizable(true)]
  1051. [RefreshProperties(RefreshProperties.Repaint)]
  1052. [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
  1053. public virtual AnchorStyles Anchor {
  1054. get {
  1055. return anchor_style;
  1056. }
  1057. set {
  1058. anchor_style=value;
  1059. if (parent != null) {
  1060. parent.PerformLayout(this, "Parent");
  1061. }
  1062. }
  1063. }
  1064. [DispId(-501)]
  1065. public virtual Color BackColor {
  1066. get {
  1067. if (background_color.IsEmpty) {
  1068. if (parent!=null) {
  1069. return parent.BackColor;
  1070. }
  1071. return DefaultBackColor;
  1072. }
  1073. return background_color;
  1074. }
  1075. set {
  1076. background_color=value;
  1077. SetChildColor(this);
  1078. OnBackColorChanged(EventArgs.Empty);
  1079. Invalidate();
  1080. }
  1081. }
  1082. [Localizable(true)]
  1083. [DefaultValue(null)]
  1084. public virtual Image BackgroundImage {
  1085. get {
  1086. return background_image;
  1087. }
  1088. set {
  1089. if (background_image!=value) {
  1090. background_image=value;
  1091. OnBackgroundImageChanged(EventArgs.Empty);
  1092. }
  1093. }
  1094. }
  1095. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1096. [Browsable(false)]
  1097. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1098. public virtual BindingContext BindingContext {
  1099. get {
  1100. if (binding_context != null)
  1101. return binding_context;
  1102. if (Parent == null)
  1103. return null;
  1104. binding_context = Parent.BindingContext;
  1105. return binding_context;
  1106. }
  1107. set {
  1108. if (binding_context != value) {
  1109. binding_context = value;
  1110. OnBindingContextChanged(EventArgs.Empty);
  1111. }
  1112. }
  1113. }
  1114. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1115. [Browsable(false)]
  1116. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1117. public int Bottom {
  1118. get {
  1119. return bounds.Y+bounds.Height;
  1120. }
  1121. }
  1122. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1123. [Browsable(false)]
  1124. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1125. public Rectangle Bounds {
  1126. get {
  1127. return this.bounds;
  1128. }
  1129. set {
  1130. SetBoundsCore(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
  1131. }
  1132. }
  1133. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1134. [Browsable(false)]
  1135. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1136. public bool CanFocus {
  1137. get {
  1138. if (Visible && is_enabled && GetStyle(ControlStyles.Selectable)) {
  1139. return true;
  1140. }
  1141. return false;
  1142. }
  1143. }
  1144. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1145. [Browsable(false)]
  1146. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1147. public bool CanSelect {
  1148. get {
  1149. Control parent;
  1150. if (!GetStyle(ControlStyles.Selectable) || this.parent == null) {
  1151. return false;
  1152. }
  1153. parent = this.parent;
  1154. while (parent != null) {
  1155. if (!parent.is_visible || !parent.is_enabled) {
  1156. return false;
  1157. }
  1158. parent = parent.parent;
  1159. }
  1160. return true;
  1161. }
  1162. }
  1163. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1164. [Browsable(false)]
  1165. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1166. public bool Capture {
  1167. get {
  1168. return this.is_captured;
  1169. }
  1170. set {
  1171. if (this.IsHandleCreated) {
  1172. if (value && !is_captured) {
  1173. is_captured = true;
  1174. XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
  1175. } else if (!value && is_captured) {
  1176. XplatUI.UngrabWindow(this.window.Handle);
  1177. is_captured = false;
  1178. }
  1179. }
  1180. }
  1181. }
  1182. [DefaultValue(true)]
  1183. public bool CausesValidation {
  1184. get {
  1185. return this.causes_validation;
  1186. }
  1187. set {
  1188. if (this.causes_validation != value) {
  1189. causes_validation = value;
  1190. OnCausesValidationChanged(EventArgs.Empty);
  1191. }
  1192. }
  1193. }
  1194. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1195. [Browsable(false)]
  1196. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1197. public Rectangle ClientRectangle {
  1198. get {
  1199. client_rect.Width = client_size.Width;
  1200. client_rect.Height = client_size.Height;
  1201. return client_rect;
  1202. }
  1203. }
  1204. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1205. [Browsable(false)]
  1206. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1207. public Size ClientSize {
  1208. get {
  1209. #if notneeded
  1210. if ((this is Form) && (((Form)this).form_parent_window != null)) {
  1211. return ((Form)this).form_parent_window.ClientSize;
  1212. }
  1213. #endif
  1214. return client_size;
  1215. }
  1216. set {
  1217. this.SetClientSizeCore(value.Width, value.Height);
  1218. }
  1219. }
  1220. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1221. [Browsable(false)]
  1222. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1223. [DescriptionAttribute("ControlCompanyNameDescr")]
  1224. public String CompanyName {
  1225. get {
  1226. return "Mono Project, Novell, Inc.";
  1227. }
  1228. }
  1229. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1230. [Browsable(false)]
  1231. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1232. public bool ContainsFocus {
  1233. get {
  1234. if (this.Focused) {
  1235. return true;
  1236. }
  1237. for (int i=0; i < child_controls.Count; i++) {
  1238. if (child_controls[i].ContainsFocus) {
  1239. return true;
  1240. }
  1241. }
  1242. return false;
  1243. }
  1244. }
  1245. [DefaultValue(null)]
  1246. public virtual ContextMenu ContextMenu {
  1247. get {
  1248. return context_menu;
  1249. }
  1250. set {
  1251. if (context_menu != value) {
  1252. context_menu = value;
  1253. OnContextMenuChanged(EventArgs.Empty);
  1254. }
  1255. }
  1256. }
  1257. [Browsable(false)]
  1258. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  1259. public ControlCollection Controls {
  1260. get {
  1261. return this.child_controls;
  1262. }
  1263. }
  1264. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1265. [Browsable(false)]
  1266. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1267. public bool Created {
  1268. get {
  1269. if (!this.is_disposed && (this.window.Handle != IntPtr.Zero)) {
  1270. return true;
  1271. }
  1272. return false;
  1273. }
  1274. }
  1275. [AmbientValue(null)]
  1276. public virtual Cursor Cursor {
  1277. get {
  1278. if (cursor != null) {
  1279. return cursor;
  1280. }
  1281. if (parent != null) {
  1282. return parent.Cursor;
  1283. }
  1284. return Cursors.Default;
  1285. }
  1286. set {
  1287. if (cursor != value) {
  1288. Point pt;
  1289. cursor = value;
  1290. pt = Cursor.Position;
  1291. if (bounds.Contains(pt)) {
  1292. if (GetChildAtPoint(pt) == null) {
  1293. if (cursor != null) {
  1294. XplatUI.SetCursor(window.Handle, cursor.handle);
  1295. } else {
  1296. if (parent != null) {
  1297. XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
  1298. } else {
  1299. XplatUI.SetCursor(window.Handle, Cursors.def.handle);
  1300. }
  1301. }
  1302. }
  1303. }
  1304. OnCursorChanged(EventArgs.Empty);
  1305. }
  1306. }
  1307. }
  1308. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  1309. [ParenthesizePropertyName(true)]
  1310. [RefreshProperties(RefreshProperties.All)]
  1311. public ControlBindingsCollection DataBindings {
  1312. get {
  1313. if (data_bindings == null)
  1314. data_bindings = new ControlBindingsCollection (this);
  1315. return data_bindings;
  1316. }
  1317. }
  1318. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1319. [Browsable(false)]
  1320. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1321. public virtual Rectangle DisplayRectangle {
  1322. get {
  1323. return ClientRectangle;
  1324. }
  1325. }
  1326. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1327. [Browsable(false)]
  1328. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1329. public bool Disposing {
  1330. get {
  1331. return is_disposed;
  1332. }
  1333. }
  1334. [Localizable(true)]
  1335. [RefreshProperties(RefreshProperties.Repaint)]
  1336. [DefaultValue(DockStyle.None)]
  1337. public virtual DockStyle Dock {
  1338. get {
  1339. return dock_style;
  1340. }
  1341. set {
  1342. if (dock_style == value) {
  1343. return;
  1344. }
  1345. dock_style = value;
  1346. if (parent != null) {
  1347. parent.PerformLayout(this, "Parent");
  1348. }
  1349. OnDockChanged(EventArgs.Empty);
  1350. }
  1351. }
  1352. [DispId(-514)]
  1353. [Localizable(true)]
  1354. public bool Enabled {
  1355. get {
  1356. return is_enabled;
  1357. }
  1358. set {
  1359. if (is_enabled == value) {
  1360. return;
  1361. }
  1362. is_enabled = value;
  1363. Refresh();
  1364. OnEnabledChanged (EventArgs.Empty);
  1365. }
  1366. }
  1367. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1368. [Browsable(false)]
  1369. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1370. public virtual bool Focused {
  1371. get {
  1372. return this.has_focus;
  1373. }
  1374. }
  1375. [DispId(-512)]
  1376. [AmbientValue(null)]
  1377. [Localizable(true)]
  1378. public virtual Font Font {
  1379. get {
  1380. if (font != null) {
  1381. return font;
  1382. }
  1383. if (Parent != null && Parent.Font != null) {
  1384. return Parent.Font;
  1385. }
  1386. return DefaultFont;
  1387. }
  1388. set {
  1389. if (font != null && font.Equals (value)) {
  1390. return;
  1391. }
  1392. font = value;
  1393. Invalidate();
  1394. OnFontChanged (EventArgs.Empty);
  1395. }
  1396. }
  1397. [DispId(-513)]
  1398. public virtual Color ForeColor {
  1399. get {
  1400. if (foreground_color.IsEmpty) {
  1401. if (parent!=null) {
  1402. return parent.ForeColor;
  1403. }
  1404. return DefaultForeColor;
  1405. }
  1406. return foreground_color;
  1407. }
  1408. set {
  1409. if (foreground_color != value) {
  1410. foreground_color=value;
  1411. Invalidate();
  1412. OnForeColorChanged(EventArgs.Empty);
  1413. }
  1414. }
  1415. }
  1416. [DispId(-515)]
  1417. [Browsable(false)]
  1418. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1419. public IntPtr Handle { // IWin32Window
  1420. get {
  1421. if (!IsHandleCreated) {
  1422. CreateHandle();
  1423. }
  1424. return window.Handle;
  1425. }
  1426. }
  1427. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1428. [Browsable(false)]
  1429. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1430. public bool HasChildren {
  1431. get {
  1432. if (this.child_controls.Count>0) {
  1433. return true;
  1434. }
  1435. return false;
  1436. }
  1437. }
  1438. [EditorBrowsable(EditorBrowsableState.Always)]
  1439. [Browsable(false)]
  1440. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1441. public int Height {
  1442. get {
  1443. return this.bounds.Height;
  1444. }
  1445. set {
  1446. SetBoundsCore(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
  1447. }
  1448. }
  1449. [AmbientValue(ImeMode.Inherit)]
  1450. [Localizable(true)]
  1451. public ImeMode ImeMode {
  1452. get {
  1453. if (ime_mode == DefaultImeMode) {
  1454. if (parent != null)
  1455. return parent.ImeMode;
  1456. else
  1457. return ImeMode.NoControl; // default value
  1458. }
  1459. return ime_mode;
  1460. }
  1461. set {
  1462. if (ime_mode != value) {
  1463. ime_mode = value;
  1464. OnImeModeChanged(EventArgs.Empty);
  1465. }
  1466. }
  1467. }
  1468. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1469. [Browsable(false)]
  1470. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1471. public bool InvokeRequired { // ISynchronizeInvoke
  1472. get {
  1473. if (creator_thread!=Thread.CurrentThread) {
  1474. return true;
  1475. }
  1476. return false;
  1477. }
  1478. }
  1479. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1480. [Browsable(false)]
  1481. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1482. public bool IsAccessible {
  1483. get {
  1484. return is_accessible;
  1485. }
  1486. set {
  1487. is_accessible = value;
  1488. }
  1489. }
  1490. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1491. [Browsable(false)]
  1492. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1493. public bool IsDisposed {
  1494. get {
  1495. return this.is_disposed;
  1496. }
  1497. }
  1498. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1499. [Browsable(false)]
  1500. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1501. public bool IsHandleCreated {
  1502. get {
  1503. if ((window!=null) && (window.Handle!=IntPtr.Zero)) {
  1504. return true;
  1505. }
  1506. return false;
  1507. }
  1508. }
  1509. [EditorBrowsable(EditorBrowsableState.Always)]
  1510. [Browsable(false)]
  1511. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1512. public int Left {
  1513. get {
  1514. return this.bounds.X;
  1515. }
  1516. set {
  1517. SetBoundsCore(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
  1518. }
  1519. }
  1520. [Localizable(true)]
  1521. public Point Location {
  1522. get {
  1523. return new Point(bounds.X, bounds.Y);
  1524. }
  1525. set {
  1526. SetBoundsCore(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
  1527. }
  1528. }
  1529. [Browsable(false)]
  1530. public string Name {
  1531. get {
  1532. return this.name;
  1533. }
  1534. set {
  1535. this.name=value;
  1536. }
  1537. }
  1538. [Browsable(false)]
  1539. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1540. public Control Parent {
  1541. get {
  1542. return this.parent;
  1543. }
  1544. set {
  1545. if (value == this) {
  1546. throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
  1547. }
  1548. if (parent!=value) {
  1549. if (value==null) {
  1550. parent.Controls.Remove(this);
  1551. return;
  1552. }
  1553. parent=value;
  1554. if (!parent.Controls.AllContains (this)) {
  1555. Console.WriteLine ("Adding child: " + this);
  1556. parent.Controls.Add(this);
  1557. }
  1558. if (IsHandleCreated) {
  1559. XplatUI.SetParent(Handle, value.Handle);
  1560. }
  1561. OnParentChanged(EventArgs.Empty);
  1562. InitLayout();
  1563. }
  1564. }
  1565. }
  1566. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1567. [Browsable(false)]
  1568. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1569. public string ProductName {
  1570. get {
  1571. Type t = typeof (AssemblyProductAttribute);
  1572. Assembly assembly = GetType().Module.Assembly;
  1573. object [] attrs = assembly.GetCustomAttributes (t, false);
  1574. AssemblyProductAttribute a = null;
  1575. // On MS we get a NullRefException if product attribute is not
  1576. // set.
  1577. if (attrs != null && attrs.Length > 0)
  1578. a = (AssemblyProductAttribute) attrs [0];
  1579. return a.Product;
  1580. }
  1581. }
  1582. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1583. [Browsable(false)]
  1584. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1585. public string ProductVersion {
  1586. get {
  1587. Type t = typeof (AssemblyVersionAttribute);
  1588. Assembly assembly = GetType().Module.Assembly;
  1589. object [] attrs = assembly.GetCustomAttributes (t, false);
  1590. if (attrs == null || attrs.Length < 1)
  1591. return "1.0.0.0";
  1592. return ((AssemblyVersionAttribute)attrs [0]).Version;
  1593. }
  1594. }
  1595. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1596. [Browsable(false)]
  1597. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1598. public bool RecreatingHandle {
  1599. get {
  1600. return is_recreating;
  1601. }
  1602. }
  1603. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1604. [Browsable(false)]
  1605. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1606. public Region Region {
  1607. get {
  1608. return new Region(this.bounds);
  1609. }
  1610. set {
  1611. Graphics g;
  1612. RectangleF r;
  1613. g = this.CreateGraphics();
  1614. r = value.GetBounds(g);
  1615. SetBounds((int)r.X, (int)r.Y, (int)r.Width, (int)r.Height);
  1616. g.Dispose();
  1617. }
  1618. }
  1619. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1620. [Browsable(false)]
  1621. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1622. public int Right {
  1623. get {
  1624. return this.bounds.X+this.bounds.Width;
  1625. }
  1626. }
  1627. [AmbientValue(RightToLeft.Inherit)]
  1628. [Localizable(true)]
  1629. public virtual RightToLeft RightToLeft {
  1630. get {
  1631. if (right_to_left == RightToLeft.Inherit) {
  1632. if (parent != null)
  1633. return parent.RightToLeft;
  1634. else
  1635. return RightToLeft.No; // default value
  1636. }
  1637. return right_to_left;
  1638. }
  1639. set {
  1640. if (value != right_to_left) {
  1641. right_to_left = value;
  1642. OnRightToLeftChanged(EventArgs.Empty);
  1643. }
  1644. }
  1645. }
  1646. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1647. public override ISite Site {
  1648. get {
  1649. return base.Site;
  1650. }
  1651. set {
  1652. base.Site = value;
  1653. }
  1654. }
  1655. [Localizable(true)]
  1656. public Size Size {
  1657. get {
  1658. return new Size(Width, Height);
  1659. }
  1660. set {
  1661. SetBoundsCore(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
  1662. }
  1663. }
  1664. [Localizable(true)]
  1665. [MergableProperty(false)]
  1666. public int TabIndex {
  1667. get {
  1668. if (tab_index != -1) {
  1669. return tab_index;
  1670. }
  1671. return 0;
  1672. }
  1673. set {
  1674. if (tab_index != value) {
  1675. tab_index = value;
  1676. OnTabIndexChanged(EventArgs.Empty);
  1677. }
  1678. }
  1679. }
  1680. [DispId(-516)]
  1681. [DefaultValue(true)]
  1682. public bool TabStop {
  1683. get {
  1684. return tab_stop;
  1685. }
  1686. set {
  1687. if (tab_stop != value) {
  1688. tab_stop = value;
  1689. OnTabStopChanged(EventArgs.Empty);
  1690. }
  1691. }
  1692. }
  1693. [Localizable(false)]
  1694. [Bindable(true)]
  1695. [TypeConverter(typeof(StringConverter))]
  1696. [DefaultValue(null)]
  1697. public object Tag {
  1698. get {
  1699. return control_tag;
  1700. }
  1701. set {
  1702. control_tag = value;
  1703. }
  1704. }
  1705. [DispId(-517)]
  1706. [Localizable(true)]
  1707. [BindableAttribute(true)]
  1708. public virtual string Text {
  1709. get {
  1710. // Our implementation ignores ControlStyles.CacheText - we always cache
  1711. return this.text;
  1712. }
  1713. set {
  1714. if (value == null) {
  1715. value = String.Empty;
  1716. }
  1717. if (text!=value) {
  1718. text=value;
  1719. if (IsHandleCreated) {
  1720. XplatUI.Text(Handle, text);
  1721. }
  1722. OnTextChanged (EventArgs.Empty);
  1723. }
  1724. }
  1725. }
  1726. [EditorBrowsable(EditorBrowsableState.Always)]
  1727. [Browsable(false)]
  1728. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1729. public int Top {
  1730. get {
  1731. return this.bounds.Y;
  1732. }
  1733. set {
  1734. SetBoundsCore(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
  1735. }
  1736. }
  1737. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1738. [Browsable(false)]
  1739. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1740. public Control TopLevelControl {
  1741. get {
  1742. Control p = this;
  1743. while (p.parent != null) {
  1744. p = p.parent;
  1745. }
  1746. return p;
  1747. }
  1748. }
  1749. [Localizable(true)]
  1750. public bool Visible {
  1751. get {
  1752. if (!is_visible) {
  1753. return false;
  1754. } else if (parent != null) {
  1755. return parent.Visible;
  1756. }
  1757. return true;
  1758. }
  1759. set {
  1760. SetVisibleCore(value);
  1761. }
  1762. }
  1763. [EditorBrowsable(EditorBrowsableState.Always)]
  1764. [Browsable(false)]
  1765. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1766. public int Width {
  1767. get {
  1768. return this.bounds.Width;
  1769. }
  1770. set {
  1771. SetBoundsCore(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
  1772. }
  1773. }
  1774. [EditorBrowsable(EditorBrowsableState.Never)]
  1775. [Browsable(false)]
  1776. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1777. public IWindowTarget WindowTarget {
  1778. get {
  1779. return null;
  1780. }
  1781. set {
  1782. ; // MS Internal
  1783. }
  1784. }
  1785. #endregion // Public Instance Properties
  1786. #region Protected Instance Properties
  1787. protected virtual CreateParams CreateParams {
  1788. get {
  1789. CreateParams create_params = new CreateParams();
  1790. try {
  1791. create_params.Caption = Text;
  1792. }
  1793. catch {
  1794. create_params.Caption = text;
  1795. }
  1796. try {
  1797. create_params.X = Left;
  1798. }
  1799. catch {
  1800. create_params.X = this.bounds.X;
  1801. }
  1802. try {
  1803. create_params.Y = Top;
  1804. }
  1805. catch {
  1806. create_params.Y = this.bounds.Y;
  1807. }
  1808. try {
  1809. create_params.Width = Width;
  1810. }
  1811. catch {
  1812. create_params.Width = this.bounds.Width;
  1813. }
  1814. try {
  1815. create_params.Height = Height;
  1816. }
  1817. catch {
  1818. create_params.Height = this.bounds.Height;
  1819. }
  1820. create_params.ClassName = XplatUI.DefaultClassName;
  1821. create_params.ClassStyle = 0;
  1822. create_params.ExStyle = 0;
  1823. create_params.Param = 0;
  1824. if (allow_drop) {
  1825. create_params.ExStyle |= (int)WindowStyles.WS_EX_ACCEPTFILES;
  1826. }
  1827. if (parent!=null) {
  1828. create_params.Parent = parent.Handle;
  1829. }
  1830. create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
  1831. if (is_visible) {
  1832. create_params.Style |= (int)WindowStyles.WS_VISIBLE;
  1833. }
  1834. return create_params;
  1835. }
  1836. }
  1837. protected virtual ImeMode DefaultImeMode {
  1838. get {
  1839. return ImeMode.Inherit;
  1840. }
  1841. }
  1842. protected virtual Size DefaultSize {
  1843. get {
  1844. return new Size(100, 23);
  1845. }
  1846. }
  1847. protected int FontHeight {
  1848. get {
  1849. return Font.Height;
  1850. }
  1851. set {
  1852. ;; // Nothing to do
  1853. }
  1854. }
  1855. protected bool RenderRightToLeft {
  1856. get {
  1857. return (this.right_to_left == RightToLeft.Yes);
  1858. }
  1859. }
  1860. protected bool ResizeRedraw {
  1861. get {
  1862. return GetStyle(ControlStyles.ResizeRedraw);
  1863. }
  1864. set {
  1865. SetStyle(ControlStyles.ResizeRedraw, value);
  1866. }
  1867. }
  1868. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1869. [Browsable(false)]
  1870. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1871. protected virtual bool ShowFocusCues {
  1872. get {
  1873. return true;
  1874. }
  1875. }
  1876. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1877. [Browsable(false)]
  1878. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  1879. protected bool ShowKeyboardCues {
  1880. get {
  1881. return true;
  1882. }
  1883. }
  1884. #endregion // Protected Instance Properties
  1885. #region Public Static Methods
  1886. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1887. public static Control FromChildHandle(IntPtr handle) {
  1888. IEnumerator control = Control.controls.GetEnumerator();
  1889. while (control.MoveNext()) {
  1890. if (((Control)control.Current).window.Handle == handle) {
  1891. // Found it
  1892. if (((Control)control.Current).Parent != null) {
  1893. return ((Control)control.Current).Parent;
  1894. }
  1895. }
  1896. }
  1897. return null;
  1898. }
  1899. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1900. public static Control FromHandle(IntPtr handle) {
  1901. IEnumerator control = Control.controls.GetEnumerator();
  1902. while (control.MoveNext()) {
  1903. if (((Control)control.Current).window.Handle == handle) {
  1904. // Found it
  1905. return ((Control)control.Current);
  1906. }
  1907. }
  1908. return null;
  1909. }
  1910. public static bool IsMnemonic(char charCode, string text) {
  1911. int amp;
  1912. amp = text.IndexOf('&');
  1913. if (amp != -1) {
  1914. if (amp + 1 < text.Length) {
  1915. if (text[amp + 1] != '&') {
  1916. if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
  1917. return true;
  1918. }
  1919. }
  1920. }
  1921. }
  1922. return false;
  1923. }
  1924. #endregion
  1925. #region Protected Static Methods
  1926. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1927. protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
  1928. Control c;
  1929. c = Control.FromHandle(hWnd);
  1930. if (c != null) {
  1931. c.WndProc(ref m);
  1932. return true;
  1933. }
  1934. return false;
  1935. }
  1936. #endregion
  1937. #region Public Instance Methods
  1938. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1939. public IAsyncResult BeginInvoke(Delegate method) {
  1940. return BeginInvokeInternal(method, null);
  1941. }
  1942. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1943. public IAsyncResult BeginInvoke (Delegate method, object[] args) {
  1944. return BeginInvokeInternal (method, args);
  1945. }
  1946. public void BringToFront() {
  1947. if ((parent != null) && (parent.child_controls[0]!=this)) {
  1948. if (parent.child_controls.Contains(this)) {
  1949. parent.child_controls.SetChildIndex(this, 0);
  1950. }
  1951. }
  1952. XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, true, false);
  1953. if (parent != null) {
  1954. parent.Refresh();
  1955. }
  1956. }
  1957. public bool Contains(Control ctl) {
  1958. while (ctl != null) {
  1959. ctl = ctl.parent;
  1960. if (ctl == this) {
  1961. return true;
  1962. }
  1963. }
  1964. return false;
  1965. }
  1966. public void CreateControl() {
  1967. if (!IsHandleCreated) {
  1968. CreateHandle();
  1969. }
  1970. if (!create_handled) {
  1971. create_handled = true;
  1972. OnCreateControl();
  1973. }
  1974. Control [] controls = child_controls.GetAllControls ();
  1975. for (int i=0; i<controls.Length; i++) {
  1976. controls [i].CreateControl ();
  1977. }
  1978. }
  1979. public Graphics CreateGraphics() {
  1980. if (!IsHandleCreated) {
  1981. this.CreateControl();
  1982. }
  1983. return Graphics.FromHwnd(this.window.Handle);
  1984. }
  1985. public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
  1986. return XplatUI.StartDrag(this.window.Handle, data, allowedEffects);
  1987. }
  1988. [EditorBrowsable(EditorBrowsableState.Advanced)]
  1989. public object EndInvoke (IAsyncResult async_result) {
  1990. AsyncMethodResult result = (AsyncMethodResult) async_result;
  1991. return result.EndInvoke ();
  1992. }
  1993. public Form FindForm() {
  1994. Control c;
  1995. c = this;
  1996. while (c != null) {
  1997. if (c is Form) {
  1998. return (Form)c;
  1999. }
  2000. c = c.Parent;
  2001. }
  2002. return null;
  2003. }
  2004. public bool Focus() {
  2005. if (IsHandleCreated && !has_focus) {
  2006. has_focus = true;
  2007. XplatUI.SetFocus(window.Handle);
  2008. }
  2009. return true;
  2010. }
  2011. public Control GetChildAtPoint(Point pt) {
  2012. // Microsoft's version of this function doesn't seem to work, so I can't check
  2013. // if we only consider children or also grandchildren, etc.
  2014. // I'm gonna say 'children only'
  2015. for (int i=0; i<child_controls.Count; i++) {
  2016. if (child_controls[i].Bounds.Contains(pt)) {
  2017. return child_controls[i];
  2018. }
  2019. }
  2020. return null;
  2021. }
  2022. public IContainerControl GetContainerControl() {
  2023. Control current = this;
  2024. while (current!=null) {
  2025. if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
  2026. return (IContainerControl)current;
  2027. }
  2028. current = current.parent;
  2029. }
  2030. return null;
  2031. }
  2032. public Control GetNextControl(Control ctl, bool forward) {
  2033. // If we're not a container we don't play
  2034. if (!(this is IContainerControl) && !this.GetStyle(ControlStyles.ContainerControl)) {
  2035. return null;
  2036. }
  2037. // If ctl is not contained by this, we start at the first child of this
  2038. if (!this.Contains(ctl)) {
  2039. ctl = null;
  2040. }
  2041. // Search through our controls, starting at ctl, stepping into children as we encounter them
  2042. // try to find the control with the tabindex closest to our own, or, if we're looking into
  2043. // child controls, the one with the smallest tabindex
  2044. if (forward) {
  2045. return FindControlForward(this, ctl);
  2046. }
  2047. return FindControlBackward(this, ctl);
  2048. }
  2049. public void Hide() {
  2050. this.Visible = false;
  2051. }
  2052. public void Invalidate() {
  2053. Invalidate(ClientRectangle, false);
  2054. }
  2055. public void Invalidate(bool invalidateChildren) {
  2056. Invalidate(ClientRectangle, invalidateChildren);
  2057. }
  2058. public void Invalidate(System.Drawing.Rectangle rc) {
  2059. Invalidate(rc, false);
  2060. }
  2061. public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
  2062. if (!IsHandleCreated || !Visible || rc.Width == 0 || rc.Height == 0) {
  2063. return;
  2064. }
  2065. NotifyInvalidate(rc);
  2066. XplatUI.Invalidate(Handle, rc, false);
  2067. if (invalidateChildren) {
  2068. Control [] controls = child_controls.GetAllControls ();
  2069. for (int i=0; i<controls.Length; i++)
  2070. controls [i].Invalidate ();
  2071. }
  2072. OnInvalidated(new InvalidateEventArgs(rc));
  2073. }
  2074. public void Invalidate(System.Drawing.Region region) {
  2075. Invalidate(region, false);
  2076. }
  2077. [MonoTODO("Figure out if GetRegionScans is usable")]
  2078. public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
  2079. throw new NotImplementedException();
  2080. // FIXME - should use the GetRegionScans function of the region to invalidate each area
  2081. //if (invalidateChildren) {
  2082. // for (int i=0; i<child_controls.Count; i++) child_controls[i].Invalidate();
  2083. //}
  2084. }
  2085. public object Invoke (Delegate method) {
  2086. return Invoke(method, null);
  2087. }
  2088. public object Invoke (Delegate method, object[] args) {
  2089. if (!this.InvokeRequired) {
  2090. return method.DynamicInvoke(args);
  2091. }
  2092. IAsyncResult result = BeginInvoke (method, args);
  2093. return EndInvoke(result);
  2094. }
  2095. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2096. public void PerformLayout() {
  2097. PerformLayout(null, null);
  2098. }
  2099. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2100. public void PerformLayout(Control affectedControl, string affectedProperty) {
  2101. LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
  2102. if (layout_suspended > 0) {
  2103. layout_pending = true;
  2104. return;
  2105. }
  2106. layout_pending = false;
  2107. // Prevent us from getting messed up
  2108. layout_suspended++;
  2109. // Perform all Dock and Anchor calculations
  2110. try {
  2111. Control child;
  2112. AnchorStyles anchor;
  2113. Rectangle space;
  2114. space=this.DisplayRectangle;
  2115. // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
  2116. Control [] controls = child_controls.GetAllControls ();
  2117. for (int i = controls.Length - 1; i >= 0; i--) {
  2118. child = controls [i];
  2119. switch (child.Dock) {
  2120. case DockStyle.None: {
  2121. // Do nothing
  2122. break;
  2123. }
  2124. case DockStyle.Left: {
  2125. child.SetBounds(space.Left, space.Y, child.Width, space.Height);
  2126. space.X+=child.Width;
  2127. space.Width-=child.Width;
  2128. break;
  2129. }
  2130. case DockStyle.Top: {
  2131. child.SetBounds(space.Left, space.Y, space.Width, child.Height);
  2132. space.Y+=child.Height;
  2133. space.Height-=child.Height;
  2134. break;
  2135. }
  2136. case DockStyle.Right: {
  2137. child.SetBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
  2138. space.Width-=child.Width;
  2139. break;
  2140. }
  2141. case DockStyle.Bottom: {
  2142. child.SetBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
  2143. space.Height-=child.Height;
  2144. break;
  2145. }
  2146. }
  2147. }
  2148. for (int i = controls.Length - 1; i >= 0; i--) {
  2149. child=controls[i];
  2150. if (child.Dock == DockStyle.Fill) {
  2151. child.SetBounds(space.Left, space.Top, space.Width, space.Height);
  2152. space.Width=0;
  2153. space.Height=0;
  2154. }
  2155. }
  2156. space=this.DisplayRectangle;
  2157. for (int i=0; i < controls.Length; i++) {
  2158. int left;
  2159. int top;
  2160. int width;
  2161. int height;
  2162. child = controls[i];
  2163. anchor = child.Anchor;
  2164. left = child.Left;
  2165. top = child.Top;
  2166. width = child.Width;
  2167. height = child.Height;
  2168. // If the control is docked we don't need to do anything
  2169. if (child.Dock != DockStyle.None) {
  2170. continue;
  2171. }
  2172. if ((anchor & AnchorStyles.Left) !=0 ) {
  2173. if ((anchor & AnchorStyles.Right) != 0) {
  2174. width = client_size.Width - child.dist_right - left;
  2175. } else {
  2176. ; // Left anchored only, nothing to be done
  2177. }
  2178. } else if ((anchor & AnchorStyles.Right) != 0) {
  2179. left = client_size.Width - child.dist_right - width;
  2180. } else {
  2181. // left+=diff_width/2 will introduce rounding errors (diff_width removed from svn after r51780)
  2182. // This calculates from scratch every time:
  2183. left = child.dist_left + (client_size.Width - (child.dist_left + width + child.dist_right)) / 2;
  2184. }
  2185. if ((anchor & AnchorStyles.Top) !=0 ) {
  2186. if ((anchor & AnchorStyles.Bottom) != 0) {
  2187. height = client_size.Height - child.dist_bottom - top;
  2188. } else {
  2189. ; // Top anchored only, nothing to be done
  2190. }
  2191. } else if ((anchor & AnchorStyles.Bottom) != 0) {
  2192. top = client_size.Height - child.dist_bottom - height;
  2193. } else {
  2194. // top += diff_height/2 will introduce rounding errors (diff_height removed from after r51780)
  2195. // This calculates from scratch every time:
  2196. top = child.dist_top + (client_size.Height - (child.dist_top + height + child.dist_bottom)) / 2;
  2197. }
  2198. // Sanity
  2199. if (width < 0) {
  2200. width=0;
  2201. }
  2202. if (height < 0) {
  2203. height=0;
  2204. }
  2205. child.SetBounds(left, top, width, height);
  2206. }
  2207. // Let everyone know
  2208. OnLayout(levent);
  2209. }
  2210. // Need to make sure we decremend layout_suspended
  2211. finally {
  2212. layout_suspended--;
  2213. }
  2214. }
  2215. public Point PointToClient (Point p) {
  2216. int x = p.X;
  2217. int y = p.Y;
  2218. XplatUI.ScreenToClient (Handle, ref x, ref y);
  2219. return new Point (x, y);
  2220. }
  2221. public Point PointToScreen(Point p) {
  2222. int x = p.X;
  2223. int y = p.Y;
  2224. XplatUI.ClientToScreen(Handle, ref x, ref y);
  2225. return new Point(x, y);
  2226. }
  2227. public virtual bool PreProcessMessage(ref Message msg) {
  2228. Keys key_data;
  2229. if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
  2230. key_data = (Keys)msg.WParam.ToInt32();
  2231. if (!ProcessCmdKey(ref msg, key_data)) {
  2232. if (IsInputKey(key_data)) {
  2233. return true;
  2234. }
  2235. return ProcessDialogKey(key_data);
  2236. }
  2237. return true;
  2238. } else if (msg.Msg == (int)Msg.WM_CHAR) {
  2239. if (IsInputChar((char)msg.WParam)) {
  2240. return true;
  2241. }
  2242. } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
  2243. if (IsInputChar((char)msg.WParam)) {
  2244. return true;
  2245. }
  2246. return ProcessDialogChar((char)msg.WParam);
  2247. }
  2248. return false;
  2249. }
  2250. public Rectangle RectangleToClient(Rectangle r) {
  2251. return new Rectangle(PointToClient(r.Location), r.Size);
  2252. }
  2253. public Rectangle RectangleToScreen(Rectangle r) {
  2254. return new Rectangle(PointToScreen(r.Location), r.Size);
  2255. }
  2256. public virtual void Refresh() {
  2257. if (IsHandleCreated == true) {
  2258. Invalidate();
  2259. XplatUI.UpdateWindow(window.Handle);
  2260. Control [] controls = child_controls.GetAllControls ();
  2261. for (int i=0; i < controls.Length; i++) {
  2262. controls[i].Refresh();
  2263. }
  2264. }
  2265. }
  2266. [EditorBrowsable(EditorBrowsableState.Never)]
  2267. public virtual void ResetBackColor() {
  2268. background_color = Color.Empty;
  2269. }
  2270. [EditorBrowsable(EditorBrowsableState.Never)]
  2271. [MonoTODO]
  2272. public void ResetBindings() {
  2273. // Do something
  2274. }
  2275. [EditorBrowsable(EditorBrowsableState.Never)]
  2276. public virtual void ResetCursor() {
  2277. cursor = null;
  2278. }
  2279. [EditorBrowsable(EditorBrowsableState.Never)]
  2280. public virtual void ResetFont() {
  2281. font = null;
  2282. }
  2283. [EditorBrowsable(EditorBrowsableState.Never)]
  2284. public virtual void ResetForeColor() {
  2285. foreground_color = Color.Empty;
  2286. }
  2287. [EditorBrowsable(EditorBrowsableState.Never)]
  2288. public void ResetImeMode() {
  2289. ime_mode = DefaultImeMode;
  2290. }
  2291. [EditorBrowsable(EditorBrowsableState.Never)]
  2292. public virtual void ResetRightToLeft() {
  2293. right_to_left = RightToLeft.Inherit;
  2294. }
  2295. public virtual void ResetText() {
  2296. text = String.Empty;
  2297. }
  2298. public void ResumeLayout() {
  2299. ResumeLayout (true);
  2300. }
  2301. public void ResumeLayout(bool performLayout) {
  2302. layout_suspended--;
  2303. if (layout_suspended > 0) {
  2304. return;
  2305. }
  2306. if (performLayout || layout_pending) {
  2307. PerformLayout();
  2308. }
  2309. }
  2310. public void Scale(float ratio) {
  2311. ScaleCore(ratio, ratio);
  2312. }
  2313. public void Scale(float dx, float dy) {
  2314. ScaleCore(dx, dy);
  2315. }
  2316. public void Select() {
  2317. Select(false, false);
  2318. }
  2319. public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
  2320. Control c;
  2321. c = ctl;
  2322. do {
  2323. c = GetNextControl(c, forward);
  2324. if (c == null) {
  2325. if (wrap) {
  2326. wrap = false;
  2327. continue;
  2328. }
  2329. break;
  2330. }
  2331. if (c.CanSelect && ((c.parent == ctl.parent) || nested) && (c.tab_stop || !tabStopOnly)) {
  2332. Select(c);
  2333. return true;
  2334. }
  2335. } while (c != ctl); // If we wrap back to ourselves we stop
  2336. return false;
  2337. }
  2338. public void SendToBack() {
  2339. if ((parent != null) && (parent.child_controls[parent.child_controls.Count-1]!=this)) {
  2340. if (parent.child_controls.Contains(this)) {
  2341. parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
  2342. }
  2343. }
  2344. XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, false, true);
  2345. if (parent != null) {
  2346. parent.Refresh();
  2347. }
  2348. }
  2349. public void SetBounds(int x, int y, int width, int height) {
  2350. SetBoundsCore(x, y, width, height, BoundsSpecified.All);
  2351. }
  2352. public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
  2353. SetBoundsCore(x, y, width, height, specified);
  2354. }
  2355. public void Show() {
  2356. if (!IsHandleCreated) {
  2357. this.CreateControl();
  2358. }
  2359. this.Visible=true;
  2360. }
  2361. public void SuspendLayout() {
  2362. layout_suspended++;
  2363. }
  2364. public void Update() {
  2365. needs_redraw = true;
  2366. if (IsHandleCreated) {
  2367. XplatUI.UpdateWindow(window.Handle);
  2368. }
  2369. }
  2370. #endregion // Public Instance Methods
  2371. #region Protected Instance Methods
  2372. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2373. [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
  2374. protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
  2375. throw new NotImplementedException();
  2376. }
  2377. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2378. protected virtual AccessibleObject CreateAccessibilityInstance() {
  2379. return new Control.ControlAccessibleObject(this);
  2380. }
  2381. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2382. protected virtual ControlCollection CreateControlsInstance() {
  2383. return new ControlCollection(this);
  2384. }
  2385. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2386. protected virtual void CreateHandle() {
  2387. if (IsDisposed) {
  2388. throw new ObjectDisposedException(Name);
  2389. }
  2390. if (IsHandleCreated) {
  2391. return;
  2392. }
  2393. window.CreateHandle(CreateParams);
  2394. // Find out where the window manager placed us
  2395. UpdateStyles();
  2396. if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
  2397. XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
  2398. }
  2399. UpdateBounds();
  2400. if (window.Handle!=IntPtr.Zero) {
  2401. if (!controls.Contains(window.Handle)) {
  2402. controls.Add(this);
  2403. }
  2404. creator_thread = Thread.CurrentThread;
  2405. OnHandleCreated(EventArgs.Empty);
  2406. }
  2407. }
  2408. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2409. protected virtual void DefWndProc(ref Message m) {
  2410. window.DefWndProc(ref m);
  2411. }
  2412. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2413. protected virtual void DestroyHandle() {
  2414. if (IsHandleCreated) {
  2415. // Destroy our children before we destroy ourselves, to prevent them from
  2416. // being implictly (without us knowing) destroyed
  2417. Control [] controls = child_controls.GetAllControls ();
  2418. for (int i=0; i < controls.Length; i++) {
  2419. controls[i].DestroyHandle();
  2420. }
  2421. if (window != null) {
  2422. window.DestroyHandle();
  2423. }
  2424. OnHandleDestroyed(EventArgs.Empty);
  2425. }
  2426. }
  2427. protected bool GetStyle(ControlStyles flag) {
  2428. return (control_style & flag) != 0;
  2429. }
  2430. protected bool GetTopLevel() {
  2431. return is_toplevel;
  2432. }
  2433. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2434. protected virtual void InitLayout() {
  2435. dist_left = bounds.X;
  2436. dist_top = bounds.Y;
  2437. if (parent != null) {
  2438. dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
  2439. dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
  2440. }
  2441. }
  2442. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2443. protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
  2444. toInvoke.OnGotFocus(e);
  2445. }
  2446. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2447. protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
  2448. toInvoke.OnLostFocus(e);
  2449. }
  2450. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2451. protected void InvokeOnClick(Control toInvoke, EventArgs e) {
  2452. toInvoke.OnClick(e);
  2453. }
  2454. protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
  2455. toInvoke.OnPaint(e);
  2456. }
  2457. protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
  2458. toInvoke.OnPaintBackground(e);
  2459. }
  2460. protected virtual bool IsInputChar (char charCode) {
  2461. if (parent != null) {
  2462. return parent.IsInputChar(charCode);
  2463. }
  2464. return false;
  2465. }
  2466. protected virtual bool IsInputKey (Keys keyData) {
  2467. // Doc says this one calls IsInputChar; not sure what to do with that
  2468. return false;
  2469. }
  2470. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2471. protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
  2472. // override me?
  2473. }
  2474. protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
  2475. if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
  2476. return true;
  2477. }
  2478. if (parent != null) {
  2479. return parent.ProcessCmdKey(ref msg, keyData);
  2480. }
  2481. return false;
  2482. }
  2483. protected virtual bool ProcessDialogChar(char charCode) {
  2484. if (parent != null) {
  2485. return parent.ProcessDialogChar (charCode);
  2486. }
  2487. return false;
  2488. }
  2489. protected virtual bool ProcessDialogKey (Keys keyData) {
  2490. if (parent != null) {
  2491. return parent.ProcessDialogKey (keyData);
  2492. }
  2493. return false;
  2494. }
  2495. protected virtual bool ProcessKeyEventArgs (ref Message msg)
  2496. {
  2497. KeyEventArgs key_event;
  2498. switch (msg.Msg) {
  2499. case (int)Msg.WM_KEYDOWN: {
  2500. key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
  2501. OnKeyDown (key_event);
  2502. return key_event.Handled;
  2503. }
  2504. case (int)Msg.WM_KEYUP: {
  2505. key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
  2506. OnKeyUp (key_event);
  2507. return key_event.Handled;
  2508. }
  2509. case (int)Msg.WM_CHAR: {
  2510. KeyPressEventArgs key_press_event;
  2511. key_press_event = new KeyPressEventArgs((char)msg.WParam);
  2512. OnKeyPress(key_press_event);
  2513. return key_press_event.Handled;
  2514. }
  2515. default: {
  2516. break;
  2517. }
  2518. }
  2519. return false;
  2520. }
  2521. protected internal virtual bool ProcessKeyMessage(ref Message msg) {
  2522. if (parent != null) {
  2523. if (parent.ProcessKeyPreview(ref msg)) {
  2524. return true;
  2525. }
  2526. }
  2527. return false;
  2528. }
  2529. protected virtual bool ProcessKeyPreview(ref Message msg) {
  2530. if (parent != null) {
  2531. return parent.ProcessKeyPreview(ref msg);
  2532. }
  2533. return false;
  2534. }
  2535. protected virtual bool ProcessMnemonic(char charCode) {
  2536. // override me
  2537. return false;
  2538. }
  2539. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2540. protected void RaiseDragEvent(object key, DragEventArgs e) {
  2541. // MS Internal
  2542. }
  2543. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2544. protected void RaiseKeyEvent(object key, KeyEventArgs e) {
  2545. // MS Internal
  2546. }
  2547. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2548. protected void RaiseMouseEvent(object key, MouseEventArgs e) {
  2549. // MS Internal
  2550. }
  2551. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2552. protected void RaisePaintEvent(object key, PaintEventArgs e) {
  2553. // MS Internal
  2554. }
  2555. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2556. protected void RecreateHandle() {
  2557. IEnumerator child = child_controls.GetAllEnumerator();
  2558. is_recreating=true;
  2559. if (IsHandleCreated) {
  2560. DestroyHandle();
  2561. CreateHandle();
  2562. // FIXME ZOrder?
  2563. while (child.MoveNext()) {
  2564. ((Control)child.Current).RecreateHandle();
  2565. }
  2566. } else {
  2567. CreateControl();
  2568. }
  2569. is_recreating = false;
  2570. }
  2571. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2572. protected void ResetMouseEventArgs() {
  2573. // MS Internal
  2574. }
  2575. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2576. protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
  2577. if (right_to_left == RightToLeft.No) {
  2578. return align;
  2579. }
  2580. switch (align) {
  2581. case ContentAlignment.TopLeft: {
  2582. return ContentAlignment.TopRight;
  2583. }
  2584. case ContentAlignment.TopRight: {
  2585. return ContentAlignment.TopLeft;
  2586. }
  2587. case ContentAlignment.MiddleLeft: {
  2588. return ContentAlignment.MiddleRight;
  2589. }
  2590. case ContentAlignment.MiddleRight: {
  2591. return ContentAlignment.MiddleLeft;
  2592. }
  2593. case ContentAlignment.BottomLeft: {
  2594. return ContentAlignment.BottomRight;
  2595. }
  2596. case ContentAlignment.BottomRight: {
  2597. return ContentAlignment.BottomLeft;
  2598. }
  2599. default: {
  2600. // if it's center it doesn't change
  2601. return align;
  2602. }
  2603. }
  2604. }
  2605. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2606. protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
  2607. if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
  2608. return align;
  2609. }
  2610. if (align == HorizontalAlignment.Left) {
  2611. return HorizontalAlignment.Right;
  2612. }
  2613. // align must be HorizontalAlignment.Right
  2614. return HorizontalAlignment.Left;
  2615. }
  2616. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2617. protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
  2618. if (right_to_left == RightToLeft.No) {
  2619. return align;
  2620. }
  2621. if (align == LeftRightAlignment.Left) {
  2622. return LeftRightAlignment.Right;
  2623. }
  2624. // align must be LeftRightAlignment.Right;
  2625. return LeftRightAlignment.Left;
  2626. }
  2627. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2628. protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
  2629. return RtlTranslateAlignment(align);
  2630. }
  2631. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2632. protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
  2633. return RtlTranslateAlignment(align);
  2634. }
  2635. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2636. protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
  2637. return RtlTranslateAlignment(align);
  2638. }
  2639. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2640. protected virtual void ScaleCore(float dx, float dy) {
  2641. Point location;
  2642. Size size;
  2643. SuspendLayout();
  2644. location = new Point((int)(Left * dx), (int)(Top * dy));
  2645. size = this.ClientSize;
  2646. if (!GetStyle(ControlStyles.FixedWidth)) {
  2647. size.Width = (int)(size.Width * dx);
  2648. }
  2649. if (!GetStyle(ControlStyles.FixedHeight)) {
  2650. size.Height = (int)(size.Height * dy);
  2651. }
  2652. Location = location;
  2653. ClientSize = size;
  2654. /* Now scale our children */
  2655. Control [] controls = child_controls.GetAllControls ();
  2656. for (int i=0; i < controls.Length; i++) {
  2657. controls[i].Scale(dx, dy);
  2658. }
  2659. ResumeLayout();
  2660. }
  2661. protected virtual void Select(bool directed, bool forward) {
  2662. int index;
  2663. bool result;
  2664. if (!directed) {
  2665. // Select this control
  2666. Select(this);
  2667. return;
  2668. }
  2669. if (parent == null) {
  2670. return;
  2671. }
  2672. // FIXME - this thing is doing the wrong stuff, needs to be similar to SelectNextControl
  2673. index = parent.child_controls.IndexOf(this);
  2674. result = false;
  2675. do {
  2676. if (forward) {
  2677. if ((index+1) < parent.child_controls.Count) {
  2678. index++;
  2679. } else {
  2680. index = 0;
  2681. }
  2682. } else {
  2683. if (index>0) {
  2684. index++;
  2685. } else {
  2686. index = parent.child_controls.Count-1;
  2687. }
  2688. }
  2689. result = Select(parent.child_controls[index]);
  2690. } while (!result && parent.child_controls[index] != this);
  2691. }
  2692. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2693. protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
  2694. // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
  2695. if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
  2696. x = Left;
  2697. }
  2698. if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
  2699. y = Top;
  2700. }
  2701. if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
  2702. width = Width;
  2703. }
  2704. if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
  2705. height = Height;
  2706. }
  2707. if (IsHandleCreated) {
  2708. XplatUI.SetWindowPos(Handle, x, y, width, height);
  2709. }
  2710. UpdateBounds(x, y, width, height);
  2711. //
  2712. Control [] controls = child_controls.GetAllControls ();
  2713. for (int i = controls.Length - 1; i >= 0; i--) {
  2714. controls[i].InitLayout();
  2715. }
  2716. }
  2717. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2718. protected virtual void SetClientSizeCore(int x, int y) {
  2719. // Calculate the actual window size from the client size (it usually stays the same or grows)
  2720. Rectangle ClientRect;
  2721. Rectangle WindowRect;
  2722. CreateParams cp;
  2723. ClientRect = new Rectangle(0, 0, x, y);
  2724. cp = this.CreateParams;
  2725. if (XplatUI.CalculateWindowRect(Handle, ref ClientRect, cp.Style, cp.ExStyle, IntPtr.Zero, out WindowRect)==false) {
  2726. return;
  2727. }
  2728. SetBoundsCore(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
  2729. }
  2730. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2731. protected void SetStyle(ControlStyles flag, bool value) {
  2732. if (value) {
  2733. control_style |= flag;
  2734. } else {
  2735. control_style &= ~flag;
  2736. }
  2737. OnStyleChanged(EventArgs.Empty);
  2738. }
  2739. protected void SetTopLevel(bool value) {
  2740. if ((GetTopLevel() != value) && (parent != null)) {
  2741. throw new Exception();
  2742. }
  2743. if (this is Form) {
  2744. if (value == true) {
  2745. if (!Visible) {
  2746. Visible = true;
  2747. }
  2748. } else {
  2749. if (Visible) {
  2750. Visible = false;
  2751. }
  2752. }
  2753. }
  2754. is_toplevel = value;
  2755. }
  2756. protected virtual void SetVisibleCore(bool value) {
  2757. if (value!=is_visible) {
  2758. is_visible=value;
  2759. if (IsHandleCreated) {
  2760. XplatUI.SetVisible(Handle, value);
  2761. // Explicitly move Toplevel windows to where we want them;
  2762. // apparently moving unmapped toplevel windows doesn't work
  2763. if (is_visible && (this is Form)) {
  2764. XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
  2765. }
  2766. }
  2767. OnVisibleChanged(EventArgs.Empty);
  2768. if (!is_visible) {
  2769. if (dc_mem != null) {
  2770. dc_mem.Dispose();
  2771. dc_mem = null;
  2772. }
  2773. if (bmp_mem != null) {
  2774. bmp_mem.Dispose();
  2775. bmp_mem = null;
  2776. }
  2777. } else {
  2778. this.CreateBuffers(bounds.Width, bounds.Height);
  2779. CreateControl();
  2780. }
  2781. if (value == false && parent != null) {
  2782. Control container;
  2783. // Need to start at parent, GetContainerControl might return ourselves if we're a container
  2784. container = (Control)parent.GetContainerControl();
  2785. if (container != null) {
  2786. container.SelectNextControl(this, true, true, true, true);
  2787. }
  2788. }
  2789. if (parent != null) {
  2790. parent.PerformLayout(this, "visible");
  2791. } else {
  2792. PerformLayout(this, "visible");
  2793. }
  2794. }
  2795. }
  2796. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2797. protected void UpdateBounds() {
  2798. int x;
  2799. int y;
  2800. int width;
  2801. int height;
  2802. int client_width;
  2803. int client_height;
  2804. if (!IsHandleCreated) {
  2805. CreateHandle();
  2806. }
  2807. XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
  2808. UpdateBounds(x, y, width, height, client_width, client_height);
  2809. }
  2810. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2811. protected void UpdateBounds(int x, int y, int width, int height) {
  2812. // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
  2813. bool moved = false;
  2814. bool resized = false;
  2815. int client_x_diff = this.bounds.Width-this.client_size.Width;
  2816. int client_y_diff = this.bounds.Height-this.client_size.Height;
  2817. // Needed to generate required notifications
  2818. if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
  2819. moved=true;
  2820. }
  2821. if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
  2822. resized=true;
  2823. }
  2824. bounds.X=x;
  2825. bounds.Y=y;
  2826. bounds.Width=width;
  2827. bounds.Height=height;
  2828. // Update client rectangle as well
  2829. client_size.Width=width-client_x_diff;
  2830. client_size.Height=height-client_y_diff;
  2831. if (moved) {
  2832. OnLocationChanged(EventArgs.Empty);
  2833. }
  2834. if (resized) {
  2835. OnSizeChanged(EventArgs.Empty);
  2836. }
  2837. }
  2838. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2839. protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
  2840. UpdateBounds(x, y, width, height);
  2841. this.client_size.Width=clientWidth;
  2842. this.client_size.Height=clientHeight;
  2843. }
  2844. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2845. protected void UpdateStyles() {
  2846. if (!IsHandleCreated) {
  2847. return;
  2848. }
  2849. XplatUI.SetWindowStyle(window.Handle, CreateParams);
  2850. }
  2851. [EditorBrowsable(EditorBrowsableState.Advanced)]
  2852. protected void UpdateZOrder() {
  2853. Control [] controls;
  2854. #if not
  2855. Control ctl;
  2856. if (parent == null) {
  2857. return;
  2858. }
  2859. ctl = parent;
  2860. controls = ctl.child_controls.GetAllControls ();
  2861. for (int i = 1; i < controls.Length; i++ ) {
  2862. XplatUI.SetZOrder(controls[i].window.Handle, controls[i-1].window.Handle, false, false);
  2863. }
  2864. #else
  2865. if (!IsHandleCreated) {
  2866. return;
  2867. }
  2868. controls = child_controls.GetAllControls ();
  2869. for (int i = 1; i < controls.Length; i++ ) {
  2870. XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
  2871. }
  2872. #endif
  2873. }
  2874. protected virtual void WndProc(ref Message m) {
  2875. #if debug
  2876. Console.WriteLine("Control received message {0}", (Msg)m.Msg);
  2877. #endif
  2878. if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
  2879. OnNotifyMessage(m);
  2880. }
  2881. switch((Msg)m.Msg) {
  2882. case Msg.WM_WINDOWPOSCHANGED: {
  2883. if (Visible) {
  2884. UpdateBounds();
  2885. if (GetStyle(ControlStyles.ResizeRedraw)) {
  2886. Invalidate();
  2887. }
  2888. }
  2889. return;
  2890. }
  2891. case Msg.WM_PAINT: {
  2892. PaintEventArgs paint_event;
  2893. paint_event = XplatUI.PaintEventStart(Handle, true);
  2894. if (!needs_redraw) {
  2895. // Just blit the previous image
  2896. paint_event.Graphics.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
  2897. XplatUI.PaintEventEnd(Handle, true);
  2898. return;
  2899. }
  2900. Graphics dc = null;
  2901. if ((control_style & ControlStyles.DoubleBuffer) != 0) {
  2902. dc = paint_event.SetGraphics (DeviceContext);
  2903. }
  2904. OnPaintBackground(paint_event);
  2905. OnPaint(paint_event);
  2906. if ((control_style & ControlStyles.DoubleBuffer) != 0) {
  2907. dc.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
  2908. paint_event.SetGraphics (dc);
  2909. needs_redraw = false;
  2910. }
  2911. XplatUI.PaintEventEnd(Handle, true);
  2912. return;
  2913. }
  2914. case Msg.WM_ERASEBKGND: {
  2915. // The DefWndProc will never have to handle this, we always paint the background in managed code
  2916. m.Result = (IntPtr)1;
  2917. return;
  2918. }
  2919. case Msg.WM_LBUTTONUP: {
  2920. HandleClick(mouse_clicks);
  2921. OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
  2922. mouse_clicks,
  2923. LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
  2924. 0));
  2925. if (mouse_clicks > 1) {
  2926. mouse_clicks = 1;
  2927. }
  2928. return;
  2929. }
  2930. case Msg.WM_LBUTTONDOWN: {
  2931. if (CanSelect && !is_selected) {
  2932. Select(this);
  2933. }
  2934. OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
  2935. mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
  2936. 0));
  2937. return;
  2938. }
  2939. case Msg.WM_LBUTTONDBLCLK: {
  2940. mouse_clicks++;
  2941. OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
  2942. mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
  2943. 0));
  2944. return;
  2945. }
  2946. case Msg.WM_MBUTTONUP: {
  2947. HandleClick(mouse_clicks);
  2948. OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
  2949. mouse_clicks,
  2950. LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
  2951. 0));
  2952. if (mouse_clicks > 1) {
  2953. mouse_clicks = 1;
  2954. }
  2955. return;
  2956. }
  2957. case Msg.WM_MBUTTONDOWN: {
  2958. OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
  2959. mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
  2960. 0));
  2961. return;
  2962. }
  2963. case Msg.WM_MBUTTONDBLCLK: {
  2964. mouse_clicks++;
  2965. OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
  2966. mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
  2967. 0));
  2968. return;
  2969. }
  2970. case Msg.WM_RBUTTONUP: {
  2971. if (context_menu != null) {
  2972. context_menu.Show(this, new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ())));
  2973. }
  2974. HandleClick(mouse_clicks);
  2975. OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
  2976. mouse_clicks,
  2977. LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
  2978. 0));
  2979. if (mouse_clicks > 1) {
  2980. mouse_clicks = 1;
  2981. }
  2982. return;
  2983. }
  2984. case Msg.WM_RBUTTONDOWN: {
  2985. OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
  2986. mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
  2987. 0));
  2988. return;
  2989. }
  2990. case Msg.WM_RBUTTONDBLCLK: {
  2991. mouse_clicks++;
  2992. OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
  2993. mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
  2994. 0));
  2995. return;
  2996. }
  2997. case Msg.WM_MOUSEWHEEL: {
  2998. OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
  2999. mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
  3000. HighOrder(m.WParam.ToInt32())));
  3001. return;
  3002. }
  3003. case Msg.WM_MOUSEMOVE: {
  3004. OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
  3005. mouse_clicks,
  3006. LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
  3007. 0));
  3008. return;
  3009. }
  3010. case Msg.WM_MOUSE_ENTER: {
  3011. if (is_entered) {
  3012. return;
  3013. }
  3014. is_entered = true;
  3015. OnMouseEnter(EventArgs.Empty);
  3016. return;
  3017. }
  3018. case Msg.WM_MOUSE_LEAVE: {
  3019. is_entered=false;
  3020. OnMouseLeave(EventArgs.Empty);
  3021. return;
  3022. }
  3023. case Msg.WM_MOUSEHOVER: {
  3024. OnMouseHover(EventArgs.Empty);
  3025. return;
  3026. }
  3027. case Msg.WM_SYSKEYDOWN:
  3028. case Msg.WM_KEYDOWN:
  3029. case Msg.WM_SYSKEYUP:
  3030. case Msg.WM_KEYUP:
  3031. case Msg.WM_SYSCHAR:
  3032. case Msg.WM_CHAR: {
  3033. Console.WriteLine("Got {0}", (Msg)m.Msg);
  3034. if (ProcessKeyEventArgs(ref m)) {
  3035. return;
  3036. }
  3037. if (PreProcessMessage(ref m)) {
  3038. return;
  3039. }
  3040. if (ProcessKeyMessage(ref m)) {
  3041. return;
  3042. }
  3043. DefWndProc (ref m);
  3044. return;
  3045. }
  3046. case Msg.WM_HELP: {
  3047. Point mouse_pos;
  3048. if (m.LParam != IntPtr.Zero) {
  3049. HELPINFO hi;
  3050. hi = new HELPINFO();
  3051. hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
  3052. mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
  3053. } else {
  3054. mouse_pos = Control.MousePosition;
  3055. }
  3056. OnHelpRequested(new HelpEventArgs(mouse_pos));
  3057. m.Result = (IntPtr)1;
  3058. return;
  3059. }
  3060. case Msg.WM_KILLFOCUS: {
  3061. OnLeave(EventArgs.Empty);
  3062. if (CausesValidation) {
  3063. CancelEventArgs e;
  3064. e = new CancelEventArgs(false);
  3065. OnValidating(e);
  3066. if (e.Cancel) {
  3067. Focus();
  3068. return;
  3069. }
  3070. OnValidated(EventArgs.Empty);
  3071. }
  3072. this.has_focus = false;
  3073. this.is_selected = false;
  3074. OnLostFocus(EventArgs.Empty);
  3075. return;
  3076. }
  3077. case Msg.WM_SETFOCUS: {
  3078. OnEnter(EventArgs.Empty);
  3079. this.has_focus = true;
  3080. OnGotFocus(EventArgs.Empty);
  3081. return;
  3082. }
  3083. case Msg.WM_SYSCOLORCHANGE: {
  3084. ThemeEngine.Current.ResetDefaults();
  3085. OnSystemColorsChanged(EventArgs.Empty);
  3086. return;
  3087. }
  3088. case Msg.WM_SETCURSOR: {
  3089. if (cursor == null) {
  3090. DefWndProc(ref m);
  3091. return;
  3092. }
  3093. XplatUI.SetCursor(window.Handle, cursor.handle);
  3094. m.Result = (IntPtr)1;
  3095. return;
  3096. }
  3097. default: {
  3098. DefWndProc(ref m);
  3099. return;
  3100. }
  3101. }
  3102. }
  3103. #endregion // Public Instance Methods
  3104. #region OnXXX methods
  3105. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3106. protected virtual void OnBackColorChanged(EventArgs e) {
  3107. if (BackColorChanged!=null) BackColorChanged(this, e);
  3108. for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
  3109. }
  3110. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3111. protected virtual void OnBackgroundImageChanged(EventArgs e) {
  3112. if (BackgroundImageChanged!=null) BackgroundImageChanged(this, e);
  3113. for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
  3114. }
  3115. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3116. protected virtual void OnBindingContextChanged(EventArgs e) {
  3117. CheckDataBindings ();
  3118. if (BindingContextChanged!=null) {
  3119. BindingContextChanged(this, e);
  3120. }
  3121. for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
  3122. }
  3123. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3124. protected virtual void OnCausesValidationChanged(EventArgs e) {
  3125. if (CausesValidationChanged!=null) CausesValidationChanged(this, e);
  3126. }
  3127. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3128. protected virtual void OnChangeUICues(UICuesEventArgs e) {
  3129. if (ChangeUICues!=null) ChangeUICues(this, e);
  3130. }
  3131. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3132. protected virtual void OnClick(EventArgs e) {
  3133. if (Click!=null) Click(this, e);
  3134. }
  3135. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3136. protected virtual void OnContextMenuChanged(EventArgs e) {
  3137. if (ContextMenuChanged!=null) ContextMenuChanged(this, e);
  3138. }
  3139. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3140. protected virtual void OnControlAdded(ControlEventArgs e) {
  3141. if (ControlAdded!=null) ControlAdded(this, e);
  3142. }
  3143. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3144. protected virtual void OnControlRemoved(ControlEventArgs e) {
  3145. if (ControlRemoved!=null) ControlRemoved(this, e);
  3146. }
  3147. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3148. protected virtual void OnCreateControl() {
  3149. // Override me!
  3150. }
  3151. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3152. protected virtual void OnCursorChanged(EventArgs e) {
  3153. if (CursorChanged!=null) CursorChanged(this, e);
  3154. }
  3155. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3156. protected virtual void OnDockChanged(EventArgs e) {
  3157. if (DockChanged!=null) DockChanged(this, e);
  3158. }
  3159. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3160. protected virtual void OnDoubleClick(EventArgs e) {
  3161. if (DoubleClick!=null) DoubleClick(this, e);
  3162. }
  3163. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3164. protected virtual void OnDragDrop(DragEventArgs drgevent) {
  3165. if (DragDrop!=null) DragDrop(this, drgevent);
  3166. }
  3167. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3168. protected virtual void OnDragEnter(DragEventArgs drgevent) {
  3169. if (DragEnter!=null) DragEnter(this, drgevent);
  3170. }
  3171. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3172. protected virtual void OnDragLeave(EventArgs e) {
  3173. if (DragLeave!=null) DragLeave(this, e);
  3174. }
  3175. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3176. protected virtual void OnDragOver(DragEventArgs drgevent) {
  3177. if (DragOver!=null) DragOver(this, drgevent);
  3178. }
  3179. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3180. protected virtual void OnEnabledChanged(EventArgs e) {
  3181. if (EnabledChanged!=null) EnabledChanged(this, e);
  3182. for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentEnabledChanged(e);
  3183. }
  3184. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3185. protected virtual void OnEnter(EventArgs e) {
  3186. if (Enter!=null) Enter(this, e);
  3187. }
  3188. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3189. protected virtual void OnFontChanged(EventArgs e) {
  3190. if (FontChanged!=null) FontChanged(this, e);
  3191. for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
  3192. }
  3193. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3194. protected virtual void OnForeColorChanged(EventArgs e) {
  3195. if (ForeColorChanged!=null) ForeColorChanged(this, e);
  3196. for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
  3197. }
  3198. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3199. protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
  3200. if (GiveFeedback!=null) GiveFeedback(this, gfbevent);
  3201. }
  3202. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3203. protected virtual void OnGotFocus(EventArgs e) {
  3204. if (GotFocus!=null) GotFocus(this, e);
  3205. }
  3206. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3207. protected virtual void OnHandleCreated(EventArgs e) {
  3208. if (HandleCreated!=null) HandleCreated(this, e);
  3209. }
  3210. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3211. protected virtual void OnHandleDestroyed(EventArgs e) {
  3212. if (HandleDestroyed!=null) HandleDestroyed(this, e);
  3213. }
  3214. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3215. protected virtual void OnHelpRequested(HelpEventArgs hevent) {
  3216. if (HelpRequested!=null) HelpRequested(this, hevent);
  3217. }
  3218. protected virtual void OnImeModeChanged(EventArgs e) {
  3219. if (ImeModeChanged!=null) ImeModeChanged(this, e);
  3220. }
  3221. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3222. protected virtual void OnInvalidated(InvalidateEventArgs e) {
  3223. needs_redraw = true;
  3224. if (Invalidated!=null) Invalidated(this, e);
  3225. }
  3226. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3227. protected virtual void OnKeyDown(KeyEventArgs e) {
  3228. if (KeyDown!=null) KeyDown(this, e);
  3229. }
  3230. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3231. protected virtual void OnKeyPress(KeyPressEventArgs e) {
  3232. if (KeyPress!=null) KeyPress(this, e);
  3233. }
  3234. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3235. protected virtual void OnKeyUp(KeyEventArgs e) {
  3236. if (KeyUp!=null) KeyUp(this, e);
  3237. }
  3238. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3239. protected virtual void OnLayout(LayoutEventArgs levent) {
  3240. if (Layout!=null) Layout(this, levent);
  3241. }
  3242. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3243. protected virtual void OnLeave(EventArgs e) {
  3244. if (Leave!=null) Leave(this, e);
  3245. }
  3246. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3247. protected virtual void OnLocationChanged(EventArgs e) {
  3248. OnMove(e);
  3249. if (LocationChanged!=null) LocationChanged(this, e);
  3250. }
  3251. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3252. protected virtual void OnLostFocus(EventArgs e) {
  3253. if (LostFocus!=null) LostFocus(this, e);
  3254. }
  3255. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3256. protected virtual void OnMouseDown(MouseEventArgs e) {
  3257. if (MouseDown!=null) MouseDown(this, e);
  3258. }
  3259. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3260. protected virtual void OnMouseEnter(EventArgs e) {
  3261. if (MouseEnter!=null) MouseEnter(this, e);
  3262. }
  3263. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3264. protected virtual void OnMouseHover(EventArgs e) {
  3265. if (MouseHover!=null) MouseHover(this, e);
  3266. }
  3267. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3268. protected virtual void OnMouseLeave(EventArgs e) {
  3269. if (MouseLeave!=null) MouseLeave(this, e);
  3270. }
  3271. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3272. protected virtual void OnMouseMove(MouseEventArgs e) {
  3273. if (MouseMove!=null) MouseMove(this, e);
  3274. }
  3275. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3276. protected virtual void OnMouseUp(MouseEventArgs e) {
  3277. if (MouseUp!=null) MouseUp(this, e);
  3278. }
  3279. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3280. protected virtual void OnMouseWheel(MouseEventArgs e) {
  3281. if (MouseWheel!=null) MouseWheel(this, e);
  3282. }
  3283. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3284. protected virtual void OnMove(EventArgs e) {
  3285. if (Move!=null) Move(this, e);
  3286. }
  3287. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3288. protected virtual void OnNotifyMessage(Message m) {
  3289. // Override me!
  3290. }
  3291. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3292. protected virtual void OnPaint(PaintEventArgs e) {
  3293. if (Paint!=null) Paint(this, e);
  3294. }
  3295. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3296. protected virtual void OnPaintBackground(PaintEventArgs pevent) {
  3297. PaintControlBackground (pevent);
  3298. }
  3299. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3300. protected virtual void OnParentBackColorChanged(EventArgs e) {
  3301. if (background_color.IsEmpty && background_image==null) {
  3302. Invalidate();
  3303. OnBackColorChanged(e);
  3304. }
  3305. }
  3306. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3307. protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
  3308. if (background_color.IsEmpty && background_image==null) {
  3309. Invalidate();
  3310. OnBackgroundImageChanged(e);
  3311. }
  3312. }
  3313. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3314. protected virtual void OnParentBindingContextChanged(EventArgs e) {
  3315. if (binding_context==null) {
  3316. binding_context=Parent.binding_context;
  3317. OnBindingContextChanged(e);
  3318. }
  3319. }
  3320. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3321. protected virtual void OnParentChanged(EventArgs e) {
  3322. if (ParentChanged!=null) ParentChanged(this, e);
  3323. }
  3324. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3325. protected virtual void OnParentEnabledChanged(EventArgs e) {
  3326. if (is_enabled != Parent.is_enabled) {
  3327. is_enabled=Parent.is_enabled;
  3328. Invalidate();
  3329. if (EnabledChanged != null) {
  3330. EnabledChanged(this, e);
  3331. }
  3332. }
  3333. }
  3334. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3335. protected virtual void OnParentFontChanged(EventArgs e) {
  3336. if (font==null) {
  3337. Invalidate();
  3338. OnFontChanged(e);
  3339. }
  3340. }
  3341. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3342. protected virtual void OnParentForeColorChanged(EventArgs e) {
  3343. if (foreground_color.IsEmpty) {
  3344. Invalidate();
  3345. OnForeColorChanged(e);
  3346. }
  3347. }
  3348. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3349. protected virtual void OnParentRightToLeftChanged(EventArgs e) {
  3350. if (right_to_left==RightToLeft.Inherit) {
  3351. Invalidate();
  3352. OnRightToLeftChanged(e);
  3353. }
  3354. }
  3355. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3356. protected virtual void OnParentVisibleChanged(EventArgs e) {
  3357. if (is_visible) {
  3358. OnVisibleChanged(e);
  3359. }
  3360. }
  3361. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3362. protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
  3363. if (QueryContinueDrag!=null) QueryContinueDrag(this, e);
  3364. }
  3365. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3366. protected virtual void OnResize(EventArgs e) {
  3367. if (Resize!=null) Resize(this, e);
  3368. PerformLayout(this, "bounds");
  3369. if (parent != null) {
  3370. parent.PerformLayout();
  3371. }
  3372. }
  3373. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3374. protected virtual void OnRightToLeftChanged(EventArgs e) {
  3375. if (RightToLeftChanged!=null) RightToLeftChanged(this, e);
  3376. for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
  3377. }
  3378. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3379. protected virtual void OnSizeChanged(EventArgs e) {
  3380. InvalidateBuffers ();
  3381. OnResize(e);
  3382. if (SizeChanged!=null) SizeChanged(this, e);
  3383. }
  3384. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3385. protected virtual void OnStyleChanged(EventArgs e) {
  3386. if (StyleChanged!=null) StyleChanged(this, e);
  3387. }
  3388. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3389. protected virtual void OnSystemColorsChanged(EventArgs e) {
  3390. if (SystemColorsChanged!=null) SystemColorsChanged(this, e);
  3391. }
  3392. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3393. protected virtual void OnTabIndexChanged(EventArgs e) {
  3394. if (TabIndexChanged!=null) TabIndexChanged(this, e);
  3395. }
  3396. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3397. protected virtual void OnTabStopChanged(EventArgs e) {
  3398. if (TabStopChanged!=null) TabStopChanged(this, e);
  3399. }
  3400. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3401. protected virtual void OnTextChanged(EventArgs e) {
  3402. if (TextChanged!=null) TextChanged(this, e);
  3403. }
  3404. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3405. protected virtual void OnValidated(EventArgs e) {
  3406. if (Validated!=null) Validated(this, e);
  3407. }
  3408. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3409. protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
  3410. if (Validating!=null) Validating(this, e);
  3411. }
  3412. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3413. protected virtual void OnVisibleChanged(EventArgs e) {
  3414. if (!is_visible) {
  3415. if (dc_mem!=null) {
  3416. dc_mem.Dispose ();
  3417. dc_mem=null;
  3418. }
  3419. if (bmp_mem!=null) {
  3420. bmp_mem.Dispose();
  3421. bmp_mem=null;
  3422. }
  3423. } else {
  3424. if (!is_disposed) {
  3425. if (!this.IsHandleCreated) {
  3426. this.CreateControl();
  3427. }
  3428. PerformLayout();
  3429. }
  3430. }
  3431. if (VisibleChanged!=null) VisibleChanged(this, e);
  3432. // We need to tell our kids
  3433. for (int i=0; i<child_controls.Count; i++) {
  3434. child_controls[i].OnParentVisibleChanged(e);
  3435. }
  3436. }
  3437. #endregion // OnXXX methods
  3438. #region Events
  3439. public event EventHandler BackColorChanged;
  3440. public event EventHandler BackgroundImageChanged;
  3441. public event EventHandler BindingContextChanged;
  3442. public event EventHandler CausesValidationChanged;
  3443. public event UICuesEventHandler ChangeUICues;
  3444. public event EventHandler Click;
  3445. public event EventHandler ContextMenuChanged;
  3446. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3447. [Browsable(false)]
  3448. public event ControlEventHandler ControlAdded;
  3449. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3450. [Browsable(false)]
  3451. public event ControlEventHandler ControlRemoved;
  3452. [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
  3453. public event EventHandler CursorChanged;
  3454. public event EventHandler DockChanged;
  3455. public event EventHandler DoubleClick;
  3456. public event DragEventHandler DragDrop;
  3457. public event DragEventHandler DragEnter;
  3458. public event EventHandler DragLeave;
  3459. public event DragEventHandler DragOver;
  3460. public event EventHandler EnabledChanged;
  3461. public event EventHandler Enter;
  3462. public event EventHandler FontChanged;
  3463. public event EventHandler ForeColorChanged;
  3464. public event GiveFeedbackEventHandler GiveFeedback;
  3465. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3466. [Browsable(false)]
  3467. public event EventHandler GotFocus;
  3468. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3469. [Browsable(false)]
  3470. public event EventHandler HandleCreated;
  3471. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3472. [Browsable(false)]
  3473. public event EventHandler HandleDestroyed;
  3474. public event HelpEventHandler HelpRequested;
  3475. public event EventHandler ImeModeChanged;
  3476. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3477. [Browsable(false)]
  3478. public event InvalidateEventHandler Invalidated;
  3479. public event KeyEventHandler KeyDown;
  3480. public event KeyPressEventHandler KeyPress;
  3481. public event KeyEventHandler KeyUp;
  3482. public event LayoutEventHandler Layout;
  3483. public event EventHandler Leave;
  3484. public event EventHandler LocationChanged;
  3485. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3486. [Browsable(false)]
  3487. public event EventHandler LostFocus;
  3488. public event MouseEventHandler MouseDown;
  3489. public event EventHandler MouseEnter;
  3490. public event EventHandler MouseHover;
  3491. public event EventHandler MouseLeave;
  3492. public event MouseEventHandler MouseMove;
  3493. public event MouseEventHandler MouseUp;
  3494. [EditorBrowsable(EditorBrowsableState.Advanced)]
  3495. [Browsable(false)]
  3496. public event MouseEventHandler MouseWheel;
  3497. public event EventHandler Move;
  3498. public event PaintEventHandler Paint;
  3499. public event EventHandler ParentChanged;
  3500. public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp;
  3501. public event QueryContinueDragEventHandler QueryContinueDrag;
  3502. public event EventHandler Resize;
  3503. public event EventHandler RightToLeftChanged;
  3504. public event EventHandler SizeChanged;
  3505. public event EventHandler StyleChanged;
  3506. public event EventHandler SystemColorsChanged;
  3507. public event EventHandler TabIndexChanged;
  3508. public event EventHandler TabStopChanged;
  3509. public event EventHandler TextChanged;
  3510. public event EventHandler Validated;
  3511. public event CancelEventHandler Validating;
  3512. public event EventHandler VisibleChanged;
  3513. #endregion // Events
  3514. }
  3515. }