Form.cs 17 KB

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