Form.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  1. //
  2. // System.Windows.Forms.Form
  3. //
  4. // Author:
  5. // Miguel de Icaza ([email protected])
  6. // stubbed out by Daniel Carrera ([email protected])
  7. // Joel Basson ([email protected])
  8. // (C) 2002 Ximian, Inc
  9. //
  10. using System;
  11. using System.Drawing;
  12. using Gtk;
  13. using GtkSharp;
  14. namespace System.Windows.Forms {
  15. public class Form : ContainerControl {
  16. internal Window win;
  17. string caption;
  18. Size csize;
  19. public Form () : base ()
  20. {
  21. }
  22. static Form ()
  23. {
  24. Gtk.Application.Init ();
  25. }
  26. void delete_cb (object o, DeleteEventArgs args)
  27. {
  28. //if (Closing != null)
  29. //Closing (o, args);
  30. if (Closed != null)
  31. Closed (o, args);
  32. }
  33. internal override Widget CreateWidget ()
  34. {
  35. Widget contents = base.CreateWidget ();
  36. win = new Window (WindowType.Toplevel);
  37. win.DeleteEvent += new DeleteEventHandler (delete_cb);
  38. win.Title = Text;
  39. win.Add (contents);
  40. return (Widget) win;
  41. }
  42. // --- Public Properties
  43. //
  44. // [MonoTODO]
  45. // public IButtonControl AcceptButton {
  46. // get {
  47. // throw new NotImplementedException ();
  48. // }
  49. // set {
  50. // throw new NotImplementedException ();
  51. // }
  52. //}
  53. // [MonoTODO]
  54. // public static Form ActiveForm {
  55. // get {
  56. // throw new NotImplementedException ();
  57. // }
  58. //}
  59. // [MonoTODO]
  60. // public Form ActiveMdiChild {
  61. // get {
  62. // throw new NotImplementedException ();
  63. // }
  64. //}
  65. // [MonoTODO]
  66. // public bool AutoScale {
  67. // get {
  68. // throw new NotImplementedException ();
  69. // }
  70. // set {
  71. // throw new NotImplementedException ();
  72. // }
  73. //}
  74. // [MonoTODO]
  75. //public virtual Size AutoScaleBaseSize {
  76. // get {
  77. // throw new NotImplementedException ();
  78. // }
  79. // set {
  80. // throw new NotImplementedException ();
  81. // }
  82. //}
  83. // [MonoTODO]
  84. // public override bool AutoScroll {
  85. // get {
  86. // throw new NotImplementedException ();
  87. // }
  88. // set {
  89. // throw new NotImplementedException ();
  90. // }
  91. //}
  92. // [MonoTODO]
  93. // public virtual Color BackColor {
  94. // get {
  95. // throw new NotImplementedException ();
  96. // }
  97. // set {
  98. // throw new NotImplementedException ();
  99. // }
  100. //}
  101. // [MonoTODO]
  102. // public IButtonControl CancelButton {
  103. // get {
  104. // throw new NotImplementedException ();
  105. // }
  106. // set {
  107. // throw new NotImplementedException ();
  108. // }
  109. //}
  110. // [MonoTODO]
  111. public Size ClientSize {
  112. get {
  113. return csize;
  114. }
  115. set {
  116. csize = value;
  117. Widget.SetSizeRequest (value.Width,value.Height);
  118. }
  119. }
  120. // [MonoTODO]
  121. // public bool ControlBox {
  122. // get {
  123. // throw new NotImplementedException ();
  124. // }
  125. // set {
  126. // throw new NotImplementedException ();
  127. // }
  128. //}
  129. // [MonoTODO]
  130. // public Rectangle DesktopBounds {
  131. // get {
  132. // throw new NotImplementedException ();
  133. // }
  134. // set {
  135. // throw new NotImplementedException ();
  136. // }
  137. //}
  138. // [MonoTODO]
  139. // public Point DesktopLocation {
  140. // get {
  141. // throw new NotImplementedException ();
  142. // }
  143. // set {
  144. // throw new NotImplementedException ();
  145. // }
  146. //}
  147. // [MonoTODO]
  148. // public DialogResult DialogResult {
  149. // get {
  150. // throw new NotImplementedException ();
  151. // }
  152. // set {
  153. // throw new NotImplementedException ();
  154. // }
  155. //}
  156. // [MonoTODO]
  157. // public FormBorderStyle FormBorderStyle {
  158. // get {
  159. // throw new NotImplementedException ();
  160. // }
  161. // set {
  162. // throw new NotImplementedException ();
  163. // }
  164. //}
  165. // [MonoTODO]
  166. // public bool HelpButton {
  167. // get {
  168. // throw new NotImplementedException ();
  169. // }
  170. // set {
  171. // throw new NotImplementedException ();
  172. // }
  173. //}
  174. // [MonoTODO]
  175. // public Icon Icon {
  176. // get {
  177. // throw new NotImplementedException ();
  178. // }
  179. // set {
  180. // throw new NotImplementedException ();
  181. // }
  182. //}
  183. // [MonoTODO]
  184. // public bool IsMidiChild {
  185. // get {
  186. // throw new NotImplementedException ();
  187. // }
  188. // set {
  189. // throw new NotImplementedException ();
  190. // }
  191. //}
  192. // [MonoTODO]
  193. // public bool IsMidiContainer {
  194. // get {
  195. // throw new NotImplementedException ();
  196. // }
  197. // set {
  198. // throw new NotImplementedException ();
  199. // }
  200. //}
  201. // [MonoTODO]
  202. // public bool KeyPreview {
  203. // get {
  204. // throw new NotImplementedException ();
  205. // }
  206. // set {
  207. // throw new NotImplementedException ();
  208. // }
  209. //}
  210. // [MonoTODO]
  211. // public bool MaximizeBox {
  212. // get {
  213. // throw new NotImplementedException ();
  214. // }
  215. // set {
  216. // throw new NotImplementedException ();
  217. // }
  218. //}
  219. // [MonoTODO]
  220. // public Size MaximumSize {
  221. // get {
  222. // throw new NotImplementedException ();
  223. // }
  224. // set {
  225. // throw new NotImplementedException ();
  226. // }
  227. //}
  228. // [MonoTODO]
  229. // public Form[] MdiChildren {
  230. // get {
  231. // throw new NotImplementedException ();
  232. // }
  233. // set {
  234. // throw new NotImplementedException ();
  235. // }
  236. //}
  237. // [MonoTODO]
  238. // public Form MdiParent {
  239. // get {
  240. // throw new NotImplementedException ();
  241. // }
  242. // set {
  243. // throw new NotImplementedException ();
  244. // }
  245. //}
  246. // [MonoTODO]
  247. public Control Menu {
  248. get {
  249. throw new NotImplementedException ();
  250. }
  251. set {
  252. Control.Controls.Add(value);
  253. }
  254. }
  255. // [MonoTODO]
  256. // public MainMenu MergedMenu {
  257. // get {
  258. // throw new NotImplementedException ();
  259. // }
  260. //}
  261. // [MonoTODO]
  262. // public bool MinimizeBox {
  263. // get {
  264. // throw new NotImplementedException ();
  265. // }
  266. // set {
  267. // throw new NotImplementedException ();
  268. // }
  269. //}
  270. // [MonoTODO]
  271. // public Size MinimumSize {
  272. // get {
  273. // throw new NotImplementedException ();
  274. // }
  275. // set {
  276. // throw new NotImplementedException ();
  277. // }
  278. //}
  279. // [MonoTODO]
  280. // public bool Modal {
  281. // get {
  282. // throw new NotImplementedException ();
  283. // }
  284. //}
  285. // [MonoTODO]
  286. // public double Opacity {
  287. // get {
  288. // throw new NotImplementedException ();
  289. // }
  290. // set {
  291. // throw new NotImplementedException ();
  292. // }
  293. //}
  294. // [MonoTODO]
  295. // public Form[] OwnedForms {
  296. // get {
  297. // throw new NotImplementedException ();
  298. // }
  299. //}
  300. // [MonoTODO]
  301. // public Form Owner {
  302. // get {
  303. // throw new NotImplementedException ();
  304. // }
  305. // set {
  306. // throw new NotImplementedException ();
  307. // }
  308. //}
  309. // [MonoTODO]
  310. // public bool ShowInTaskbar {
  311. // get {
  312. // throw new NotImplementedException ();
  313. // }
  314. // set {
  315. // throw new NotImplementedException ();
  316. // }
  317. //}
  318. // [MonoTODO]
  319. // public override ISite Site {
  320. // get {
  321. // throw new NotImplementedException ();
  322. // }
  323. // set {
  324. // throw new NotImplementedException ();
  325. // }
  326. //}
  327. // [MonoTODO]
  328. // public SizeGripStyle SizeGripStyle {
  329. // get {
  330. // throw new NotImplementedException ();
  331. // }
  332. // set {
  333. // throw new NotImplementedException ();
  334. // }
  335. //}
  336. // [MonoTODO]
  337. // public FormStartPosition StartPosition {
  338. // get {
  339. // throw new NotImplementedException ();
  340. // }
  341. // set {
  342. // throw new NotImplementedException ();
  343. // }
  344. //}
  345. // [MonoTODO]
  346. // public bool TopLevel {
  347. // get {
  348. // throw new NotImplementedException ();
  349. // }
  350. // set {
  351. // throw new NotImplementedException ();
  352. // }
  353. //}
  354. // [MonoTODO]
  355. // public bool TopMost {
  356. // get {
  357. // throw new NotImplementedException ();
  358. // }
  359. // set {
  360. // throw new NotImplementedException ();
  361. // }
  362. //}
  363. // [MonoTODO]
  364. // public Color TransparencyKey {
  365. // get {
  366. // throw new NotImplementedException ();
  367. // }
  368. // set {
  369. // throw new NotImplementedException ();
  370. // }
  371. //}
  372. // [MonoTODO]
  373. // public FormWindowState WindowState {
  374. // get {
  375. // throw new NotImplementedException ();
  376. // }
  377. // set {
  378. // throw new NotImplementedException ();
  379. // }
  380. //}
  381. //
  382. // --- Public Methods
  383. //
  384. // [MonoTODO]
  385. // public void Activate()
  386. // {
  387. // throw new NotImplementedException ();
  388. // }
  389. // [MonoTODO]
  390. // public void AddOwnedForm(Form ownedForm)
  391. // {
  392. // throw new NotImplementedException ();
  393. // }
  394. // [MonoTODO]
  395. // public void Close()
  396. // {
  397. // throw new NotImplementedException ();
  398. // }
  399. // [MonoTODO]
  400. // public void Dispose()
  401. // {
  402. // throw new NotImplementedException ();
  403. // }
  404. // [MonoTODO]
  405. // public virtual bool Equals(object o);
  406. // {
  407. // throw new NotImplementedException ();
  408. // }
  409. // [MonoTODO]
  410. // public static bool Equals(object o1, object o2);
  411. // {
  412. // throw new NotImplementedException ();
  413. // }
  414. // [MonoTODO]
  415. // public static SizeF GetAutoScaleSize(Font font)
  416. // {
  417. // throw new NotImplementedException ();
  418. // }
  419. // [MonoTODO]
  420. // public void Invalidate()
  421. // {
  422. // throw new NotImplementedException ();
  423. // }
  424. // [MonoTODO]
  425. // public object Invoke()
  426. // {
  427. // throw new NotImplementedException ();
  428. // }
  429. // [MonoTODO]
  430. // public void LayoutMdi(MdiLayout value)
  431. // {
  432. // throw new NotImplementedException ();
  433. // }
  434. // [MonoTODO]
  435. // public void PerformLayout()
  436. // {
  437. // throw new NotImplementedException ();
  438. // }
  439. // [MonoTODO]
  440. // public void RemoveOwnedForm(Form ownedForm)
  441. // {
  442. // throw new NotImplementedException ();
  443. // }
  444. // [MonoTODO]
  445. public void SuspendLayout()
  446. {
  447. throw new NotImplementedException ();
  448. }
  449. // [MonoTODO]
  450. public void ResumeLayout()
  451. {
  452. throw new NotImplementedException ();
  453. }
  454. // [MonoTODO]
  455. // public void Scale(float f)
  456. // {
  457. // throw new NotImplementedException ();
  458. // }
  459. // [MonoTODO]
  460. // public void Select()
  461. // {
  462. // throw new NotImplementedException ();
  463. // }
  464. // [MonoTODO]
  465. // public void SetBounds(int, int, int, int)
  466. // {
  467. // throw new NotImplementedException ();
  468. // }
  469. // [MonoTODO]
  470. // public void SetDesktopLocation(int x, int y)
  471. // {
  472. // throw new NotImplementedException ();
  473. // }
  474. // [MonoTODO]
  475. // public DialogResult ShowDialog()
  476. // {
  477. // throw new NotImplementedException ();
  478. // }
  479. // [MonoTODO]
  480. // public override string ToString()
  481. // {
  482. // throw new NotImplementedException ();
  483. // }
  484. //
  485. // --- Public Events
  486. //
  487. // [MonoTODO]
  488. // public event EventHandler Activated {
  489. // add {
  490. // throw new NotImplementedException ();
  491. // }
  492. // remove {
  493. // throw new NotImplementedException ();
  494. // }
  495. //}
  496. public event EventHandler Closed;
  497. // public event CancelEventHandler Closing;
  498. // [MonoTODO]
  499. // public event EventHandler Deactivate {
  500. // add {
  501. // throw new NotImplementedException ();
  502. // }
  503. // remove {
  504. // throw new NotImplementedException ();
  505. // }
  506. //}
  507. // [MonoTODO]
  508. // public event InputLanguageChangedEventHandler InputLanguageChanged {
  509. // add {
  510. // throw new NotImplementedException ();
  511. // }
  512. // remove {
  513. // throw new NotImplementedException ();
  514. // }
  515. //}
  516. // [MonoTODO]
  517. // public event InputLanguageChangingEventHandler InputLanguageChanging {
  518. // add {
  519. // throw new NotImplementedException ();
  520. // }
  521. // remove {
  522. // throw new NotImplementedException ();
  523. // }
  524. //}
  525. // [MonoTODO]
  526. // public event EventHandler Load {
  527. // add {
  528. // throw new NotImplementedException ();
  529. // }
  530. // remove {
  531. // throw new NotImplementedException ();
  532. // }
  533. //}
  534. // [MonoTODO]
  535. // public event EventHandler MaximizedBoundsChanged {
  536. // add {
  537. // throw new NotImplementedException ();
  538. // }
  539. // remove {
  540. // throw new NotImplementedException ();
  541. // }
  542. //}
  543. // [MonoTODO]
  544. // public event EventHandler MaximumSizeChanged {
  545. // add {
  546. // throw new NotImplementedException ();
  547. // }
  548. // remove {
  549. // throw new NotImplementedException ();
  550. // }
  551. //}
  552. // [MonoTODO]
  553. // public event EventHandler MdiChildActivate {
  554. // add {
  555. // throw new NotImplementedException ();
  556. // }
  557. // remove {
  558. // throw new NotImplementedException ();
  559. // }
  560. //}
  561. // [MonoTODO]
  562. // public event EventHandler MenuComplete {
  563. // add {
  564. // throw new NotImplementedException ();
  565. // }
  566. // remove {
  567. // throw new NotImplementedException ();
  568. // }
  569. //}
  570. // [MonoTODO]
  571. // public event EventHandler MenuStart {
  572. // add {
  573. // throw new NotImplementedException ();
  574. // }
  575. // remove {
  576. // throw new NotImplementedException ();
  577. // }
  578. //}
  579. // [MonoTODO]
  580. // public event EventHandler MinimumSizedChanged {
  581. // add {
  582. // throw new NotImplementedException ();
  583. // }
  584. // remove {
  585. // throw new NotImplementedException ();
  586. // }
  587. //}
  588. //
  589. // --- Protected Properties
  590. //
  591. // [MonoTODO]
  592. // protected override CreateParams CreateParams {
  593. // get {
  594. // throw new NotImplementedException ();
  595. // }
  596. //}
  597. // [MonoTODO]
  598. // protected override ImeMode DefaultImeMode {
  599. // get {
  600. // throw new NotImplementedException ();
  601. // }
  602. //}
  603. // [MonoTODO]
  604. // protected override Size DefaultSize {
  605. //}
  606. // [MonoTODO]
  607. // protected Rectangle MaximizedBounds {
  608. // get {
  609. // throw new NotImplementedException ();
  610. // }
  611. // set {
  612. // throw new NotImplementedException ();
  613. // }
  614. //}
  615. //
  616. // --- Protected Methods
  617. //
  618. // [MonoTODO]
  619. // protected override void AdjustFormScrollbars(bool displayScrollbars)
  620. // {
  621. // throw new NotImplementedException ();
  622. // }
  623. // [MonoTODO]
  624. // protected override ControlCollection CreateControlsInstnace()
  625. // {
  626. // throw new NotImplementedException ();
  627. // }
  628. // [MonoTODO]
  629. // protected override void CreateHandle()
  630. // {
  631. // throw new NotImplementedException ();
  632. // }
  633. // [MonoTODO]
  634. // protected override void DefWndProc(ref Message m)
  635. // {
  636. // throw new NotImplementedException ();
  637. // }
  638. // [MonoTODO]
  639. // protected override void Dispose(bool b)
  640. // {
  641. // throw new NotImplementedException ();
  642. // }
  643. // [MonoTODO]
  644. // protected virtual void OnClosed(EventArgs e)
  645. // {
  646. // throw new NotImplementedException ();
  647. // }
  648. // [MonoTODO]
  649. // protected virtual void OnClosing(CancelEventArgs e)
  650. // {
  651. // throw new NotImplementedException ();
  652. // }
  653. // [MonoTODO]
  654. // protected override void OnCreateControl()
  655. // {
  656. // throw new NotImplementedException ();
  657. // }
  658. // [MonoTODO]
  659. // protected override void OnFontChanged(EventArgs e)
  660. // {
  661. // throw new NotImplementedException ();
  662. // }
  663. // [MonoTODO]
  664. // protected override void OnHandleCreated(EventArgs e)
  665. // {
  666. // throw new NotImplementedException ();
  667. // }
  668. // [MonoTODO]
  669. // protected override void OnHandleDestroyed(EventArgs e)
  670. // {
  671. // throw new NotImplementedException ();
  672. // }
  673. // [MonoTODO]
  674. // protected virtual void OnInputLanguageChanged( OnInputLanguageChangedEventArgs e)
  675. // {
  676. // throw new NotImplementedException ();
  677. // }
  678. // [MonoTODO]
  679. // protected virtual void OnInputLanguagedChanging( OnInputLanguagedChangingEventArgs e)
  680. // {
  681. // throw new NotImplementedException ();
  682. // }
  683. // [MonoTODO]
  684. // protected virtual void OnLoad(EventArgs e)
  685. // {
  686. // throw new NotImplementedException ();
  687. // }
  688. // [MonoTODO]
  689. // protected virtual void OnMaximizedBoundsChanged(EventArgs e)
  690. // {
  691. // throw new NotImplementedException ();
  692. // }
  693. // [MonoTODO]
  694. // protected virtual void OnMaximumSizedChanged(EventArgs e)
  695. // {
  696. // throw new NotImplementedException ();
  697. // }
  698. // [MonoTODO]
  699. // protected virtual void OnMdiChildActive(EventArgs e)
  700. // {
  701. // throw new NotImplementedException ();
  702. // }
  703. // [MonoTODO]
  704. // protected virtual void OnMenuComplete(EventArgs e)
  705. // {
  706. // throw new NotImplementedException ();
  707. // }
  708. // [MonoTODO]
  709. // protected virtual void OnMenuStart(EventArgs e)
  710. // {
  711. // throw new NotImplementedException ();
  712. // }
  713. // [MonoTODO]
  714. // protected virtual void OnMinimumSizeChanged(EventArgs e)
  715. // {
  716. // throw new NotImplementedException ();
  717. // }
  718. // [MonoTODO]
  719. // protected override void OnPaint(EventArgs e)
  720. // {
  721. // throw new NotImplementedException ();
  722. // }
  723. // [MonoTODO]
  724. // protected override void OnResize(EventArgs e)
  725. // {
  726. // throw new NotImplementedException ();
  727. // }
  728. // [MonoTODO]
  729. // protected override void OnStyleChanged(EventArgs e)
  730. // {
  731. // throw new NotImplementedException ();
  732. // }
  733. protected override void OnTextChanged(EventArgs e)
  734. {
  735. if (win != null)
  736. win.Title = Text;
  737. }
  738. // [MonoTODO]
  739. // protected override void OnVisibleChanged(EventArgs e)
  740. // {
  741. // throw new NotImplementedException ();
  742. // }
  743. // [MonoTODO]
  744. // protected override bool ProcessCmdKey( ref Message msg, Keys keyData)
  745. // {
  746. // throw new NotImplementedException ();
  747. // }
  748. // [MonoTODO]
  749. // protected override bool ProcessDialogKey(Keys keyData)
  750. // {
  751. // throw new NotImplementedException ();
  752. // }
  753. // [MonoTODO]
  754. // protected override bool ProcessKeyPreview(ref Message m)
  755. // {
  756. // throw new NotImplementedException ();
  757. // }
  758. // [MonoTODO]
  759. // protected override bool ProcessTabKey(bool forward)
  760. // {
  761. // throw new NotImplementedException ();
  762. // }
  763. // [MonoTODO]
  764. // protected override void ScaleScore(float x, float y)
  765. // {
  766. // throw new NotImplementedException ();
  767. // }
  768. // [MonoTODO]
  769. // protected override void Select(bool b1, bool b2)
  770. // {
  771. // throw new NotImplementedException ();
  772. // }
  773. // [MonoTODO]
  774. // protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
  775. // {
  776. // throw new NotImplementedException ();
  777. // }
  778. // [MonoTODO]
  779. // protected override void SelectClientSizeCore(int x, int y)
  780. // {
  781. // throw new NotImplementedException ();
  782. // }
  783. // [MonoTODO]
  784. // protected override void SetVisibleCore(bool value)
  785. // {
  786. // throw new NotImplementedException ();
  787. // }
  788. // [MonoTODO]
  789. // protected void UpdateBounds()
  790. // {
  791. // throw new NotImplementedException ();
  792. // }
  793. // [MonoTODO]
  794. // protected override void WndProc(ref Message m)
  795. // {
  796. // throw new NotImplementedException ();
  797. // }
  798. }
  799. }