**** Merged from MCS ****
[mono-project.git] / mcs / class / System.Windows.Forms / Gtk / CommonDialog.cs
blobc83d19863fdbda779da0bbf1a1124deaab80fe0e
1 //
2 // System.Windows.Forms.CommonDialog.cs
3 //
4 // Author:
5 // stubbed out by Jaak Simm (jaaksimm@firm.ee)
6 // Dennis Hayes (dennish@Raytek.com)
7 // Aleksey Ryabchuk (ryabchuk@yahoo.com)
8 // (C) Ximian, Inc., 2002
9 //
11 using System.ComponentModel;
13 namespace System.Windows.Forms {
15 /// <summary>
16 /// Specifies the base class used for displaying dialog boxes on the screen.
17 /// </summary>
19 [MonoTODO]
20 public abstract class CommonDialog : Component {
22 internal bool dialogRetValue = false;
24 static CommonDialog(){
25 Gtk.Application.Init();
28 [MonoTODO]
29 public CommonDialog() : base (){
32 [MonoTODO]
33 protected virtual IntPtr HookProc(IntPtr hWnd,int msg,IntPtr wparam,IntPtr lparam){
34 return IntPtr.Zero;
37 protected virtual void OnHelpRequest(EventArgs e){
38 if ( HelpRequest != null )
39 HelpRequest ( this, e );
42 [MonoTODO]
43 protected virtual IntPtr OwnerWndProc(IntPtr hWnd,int msg,IntPtr wparam,IntPtr lparam) {
44 throw new NotImplementedException ();
47 public abstract void Reset();
48 protected abstract bool RunDialog(IntPtr hwndOwner);
50 [MonoTODO]
51 public DialogResult ShowDialog(){
52 bool res = RunDialog (IntPtr.Zero);
53 return res ? DialogResult.OK : DialogResult.Cancel;
56 public DialogResult ShowDialog(IWin32Window owner){
57 bool res = RunDialog ( IntPtr.Zero );
58 return res ? DialogResult.OK : DialogResult.Cancel;
60 public event EventHandler HelpRequest;
62 internal Gtk.Dialog dialog;
63 internal Gtk.Dialog Dialog{
64 get {
65 if (dialog == null){
66 dialog = CreateDialog();
67 dialog.Modal = true;
68 dialog.Response += new GtkSharp.ResponseHandler (OnResponse);
69 dialog.DeleteEvent += new GtkSharp.DeleteEventHandler (OnDelete);
71 return dialog;
75 internal abstract Gtk.Dialog CreateDialog();
77 internal void OnDelete (object sender, GtkSharp.DeleteEventArgs args){
78 Gtk.Window d = (Gtk.Window) sender;
79 d.Hide ();
80 dialogRetValue = false;
81 OnCancel();
82 args.RetVal = true;
84 internal virtual void OnResponse (object o, GtkSharp.ResponseArgs args){
85 switch (args.ResponseId){
86 case (int)Gtk.ResponseType.Accept:
87 case (int)Gtk.ResponseType.Ok:
88 case (int)Gtk.ResponseType.Yes:
89 case (int)Gtk.ResponseType.Apply:
90 dialogRetValue = true;
91 OnAccept();
92 Dialog.Hide();
93 break;
94 default:dialogRetValue = false;
95 OnCancel();
96 Dialog.Hide();
97 break;
100 internal virtual void OnCancel(){
103 internal virtual void OnAccept (){