Przeglądaj źródła

2003-05-24 Joel Basson <[email protected]>
* MainMenu.cs
* MenuItems.cs
* Some more work done to MessageBox.cs

svn path=/trunk/mcs/; revision=14843

Joel Basson 22 lat temu
rodzic
commit
55a17580fc

+ 13 - 3
mcs/class/System.Windows.Forms/Gtk/ComboBox.cs

@@ -18,11 +18,12 @@ namespace System.Windows.Forms {
 
 	public class ComboBox: Control{
 		
+		private int menusize;
 		private bool UpdateState;
 		public ItemCollection Items = new ItemCollection(this);
  		GLib.List list = new GLib.List (IntPtr.Zero, typeof (string));
 		System.Collections.ArrayList alist = new System.Collections.ArrayList();
-
+		
 		public class ItemCollection {
 
 			ComboBox owner;
@@ -74,8 +75,9 @@ namespace System.Windows.Forms {
 		}
 
 		public int FindString (string value){
-
-			return alist.BinarySearch(value);	
+			
+			//return alist.BinarySearch(value);	
+			return alist.IndexOf(value);
 		}
 		
 		public int SelectedIndex{
@@ -96,5 +98,13 @@ namespace System.Windows.Forms {
 			}
 		}
 
+		public int DropDownWidth {
+			get {		
+				return menusize;
+			}
+			set {	
+				menusize = value;
+			}
+		}
 	}
 }

+ 9 - 9
mcs/class/System.Windows.Forms/Gtk/Form.cs

@@ -16,7 +16,7 @@ using GtkSharp;
 namespace System.Windows.Forms {
 
 	public class Form : ContainerControl {
-		Window win;
+		internal Window win;
 		string caption;
 		Size csize;
 
@@ -255,14 +255,14 @@ namespace System.Windows.Forms {
 		//	}
 		//}
 		// [MonoTODO]
-		//public Control Menu {
-		//	get {
-		//		throw new NotImplementedException ();
-		//	}
-		//	set {
-		//			Controls.AddRange(new System.Windows.Forms.Control[] {value}); 
-		//	}
-		//}
+		public Control Menu {
+			get {
+				throw new NotImplementedException ();
+			}
+			set {
+				Control.Controls.Add(value);
+			}
+		}
 		// [MonoTODO]
 		// public MainMenu MergedMenu {
 		//	get {

+ 130 - 0
mcs/class/System.Windows.Forms/Gtk/MessageBox.cs

@@ -0,0 +1,130 @@
+//		
+//			System.Windows.Forms.ComboBox
+//
+//			Author: 
+//						Joel Basson		([email protected])
+//
+//
+
+using System.Drawing;
+using Gtk;
+using GtkSharp;
+
+namespace System.Windows.Forms{
+	
+	public class MessageBox : Control {
+
+		Gtk.MessageDialog dialog;
+
+		private MessageBox (){
+		}
+
+		public static void Show (String text) {
+
+			Gtk.MessageDialog dialog = new Gtk.MessageDialog(null, Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, text);			
+			dialog.Run();
+			dialog.Destroy();
+		}
+
+		public static void Show (Form myform, String text) {
+
+			Gtk.MessageDialog dialog = new Gtk.MessageDialog(myform.win, Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, text);			
+			dialog.Run();
+			dialog.Destroy();
+		}
+
+
+
+		public static void Show (String text, String caption) {
+
+			Gtk.MessageDialog dialog = new Gtk.MessageDialog(null, Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, text);	
+			dialog.Title = caption; 		
+			dialog.Run();
+			dialog.Destroy();
+		}
+
+		public static void Show (Form myform, String text, String caption) {
+
+			Gtk.MessageDialog dialog = new Gtk.MessageDialog(myform.win, Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, text);	
+			dialog.Title = caption; 		
+			dialog.Run();
+			dialog.Destroy();
+		}
+
+		public static void Show (String text, String caption, MessageBoxButtons but) {
+			
+			if (but == MessageBoxButtons.OK){
+				Gtk.MessageDialog dialog = new Gtk.MessageDialog(null, Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, text);	
+				dialog.Title = caption; 		
+				dialog.Run();
+				dialog.Destroy();
+			}	
+			if (but == MessageBoxButtons.OKCancel){
+				Gtk.MessageDialog dialog = new Gtk.MessageDialog(null, Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Info, Gtk.ButtonsType.OkCancel, text);	
+				dialog.Title = caption; 		
+				dialog.Run();
+				dialog.Destroy();
+			}
+			if (but == MessageBoxButtons.YesNo){
+				Gtk.MessageDialog dialog = new Gtk.MessageDialog(null, Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Info, Gtk.ButtonsType.YesNo, text);	
+				dialog.Title = caption; 		
+				dialog.Run();
+				dialog.Destroy();
+			}
+			if (but == MessageBoxButtons.YesNoCancel){
+				Gtk.MessageDialog dialog = new Gtk.MessageDialog(null, Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Info, Gtk.ButtonsType.YesNo, text);	
+				dialog.Title = caption; 
+				dialog.AddButton(Gtk.Stock.Cancel, 2);		
+				dialog.Run();
+				dialog.Destroy();
+			}		
+			if (but == MessageBoxButtons.RetryCancel){
+				Gtk.MessageDialog dialog = new Gtk.MessageDialog(null, Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Info, Gtk.ButtonsType.None, text);	
+				dialog.Title = caption; 
+				dialog.AddButton(Gtk.Stock.Redo, 4);
+				dialog.AddButton(Gtk.Stock.Cancel, 2);		
+				dialog.Run();
+				dialog.Destroy();
+			} 
+		}
+			public static void Show (Form myform ,String text, String caption, MessageBoxButtons but) {
+			
+			if (but == MessageBoxButtons.OK){
+				Gtk.MessageDialog dialog = new Gtk.MessageDialog(myform.win, Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, text);	
+				dialog.Title = caption; 		
+				dialog.Run();
+				dialog.Destroy();
+			}	
+			if (but == MessageBoxButtons.OKCancel){
+				Gtk.MessageDialog dialog = new Gtk.MessageDialog(myform.win, Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Info, Gtk.ButtonsType.OkCancel, text);	
+				dialog.Title = caption; 		
+				dialog.Run();
+				dialog.Destroy();
+			}
+			if (but == MessageBoxButtons.YesNo){
+				Gtk.MessageDialog dialog = new Gtk.MessageDialog(myform.win, Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Info, Gtk.ButtonsType.YesNo, text);	
+				dialog.Title = caption; 		
+				dialog.Run();
+				dialog.Destroy();
+			}
+			if (but == MessageBoxButtons.YesNoCancel){
+				Gtk.MessageDialog dialog = new Gtk.MessageDialog(myform.win, Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Info, Gtk.ButtonsType.YesNo, text);	
+				dialog.Title = caption; 
+				dialog.AddButton(Gtk.Stock.Cancel, 2);		
+				dialog.Run();
+				dialog.Destroy();
+			}		
+			if (but == MessageBoxButtons.RetryCancel){
+				Gtk.MessageDialog dialog = new Gtk.MessageDialog(myform.win, Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Info, Gtk.ButtonsType.None, text);	
+				dialog.Title = caption; 
+				dialog.AddButton(Gtk.Stock.Redo, 4);
+				dialog.AddButton(Gtk.Stock.Cancel, 2);		
+				dialog.Run();
+				dialog.Destroy();
+			} 
+
+		}
+
+	}
+
+} 

+ 11 - 0
mcs/class/System.Windows.Forms/Gtk/changelog

@@ -1,3 +1,14 @@
+2003-05-24  Joel Basson  <[email protected]>
+* MainMenu.cs
+* MenuItems.cs
+* Some more work done to MessageBox.cs
+
+2003-05-11  Joel Basson  <[email protected]>
+
+* MessageBox.cs
+* Bugfix to ComboBox.cs
+* Small update to Form.cs 
+
 2003-05-09  Joel Basson  <[email protected]>
 
 * Added many new properties to Combo.cs

+ 4 - 0
mcs/class/System.Windows.Forms/Gtk/makefile

@@ -28,6 +28,10 @@ SOURCES = \
 	FontDialog.cs	\
 	ColorDialog.cs	\
 	ComboBox.cs	\
+	MessageBox.cs	\
+	MessageBoxButtons.cs	\
+	MenuItem.cs	\
+	MainMenu.cs	\
 	ScrollableControl.cs
 
 all: demo.exe