[Mono-winforms-list] Small fix

Philip Van Hoof spamfrommailing@freax.org
23 May 2003 14:23:15 +0200


--=-quiGESaqPoitpLgYfn6j
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

More fixes and additions for that namespace ;)

I've added Cut, Copy and Paste in the TextBoxBase-class and tree
buttons : "Cut", "Copy", and "Paste" in the demo.cs-application 


On Fri, 2003-05-23 at 13:05, Philip Van Hoof wrote:

> Hi there Joel Basson,
> 
> I send you the E-mail because your are the author of Monos ComboBox.cs
> in /mcs/class/System.Windows.Forms/Gtk
> 
> This minor patch fixes a compilation-error ;)
> 
> ps. I've placed mono-winforms-list in CC
-- 
Philip Van Hoof a.k.a. freax
me at freax dot org
http://www.freax.be -- http://www.freax.eu.org -- http://www.freax.org



--=-quiGESaqPoitpLgYfn6j
Content-Disposition: attachment; filename=TextBoxBase_and_demo.cs.diff
Content-Type: text/plain; name=TextBoxBase_and_demo.cs.diff; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

? System.Windows.Forms.dll
Index: ComboBox.cs
===================================================================
RCS file: /mono/mcs/class/System.Windows.Forms/Gtk/ComboBox.cs,v
retrieving revision 1.3
diff -u -u -r1.3 ComboBox.cs
--- ComboBox.cs	8 May 2003 23:54:15 -0000	1.3
+++ ComboBox.cs	23 May 2003 12:21:12 -0000
@@ -11,15 +11,15 @@
 
 namespace System.Windows.Forms {
 
-	/// <summary>
-	/// Represents a Windows ComboBox control.
-	///
-	/// </summary>
+	/// <summary>
+	/// Represents a Windows ComboBox control.
+	///
+	/// </summary>
 
 	public class ComboBox: Control{
 		
 		private bool UpdateState;
-		public ItemCollection Items = new ItemCollection(this);
+		public ItemCollection Items;
  		GLib.List list = new GLib.List (IntPtr.Zero, typeof (string));
 		System.Collections.ArrayList alist = new System.Collections.ArrayList();
 
@@ -48,9 +48,10 @@
 		}
 
 		public ComboBox () : base (){
+			Items = new ItemCollection(this);
 	
 			UpdateState = false;
-		}
+		}
 
 		internal override Gtk.Widget CreateWidget () {
 			Gtk.Combo com1 = new Gtk.Combo();
Index: TextBoxBase.cs
===================================================================
RCS file: /mono/mcs/class/System.Windows.Forms/Gtk/TextBoxBase.cs,v
retrieving revision 1.5
diff -u -u -r1.5 TextBoxBase.cs
--- TextBoxBase.cs	8 May 2003 23:54:15 -0000	1.5
+++ TextBoxBase.cs	23 May 2003 12:21:12 -0000
@@ -22,7 +22,6 @@
 		private int maxlength = 0;
 		private Gtk.TextTagTable tagtable;
 		private Gtk.TextBuffer textbuffer = null;
-
 		//
 		//  --- Public Properties
 		//
@@ -281,20 +280,21 @@
 		{
 			throw new NotImplementedException ();
 		}
-		[MonoTODO]
+
 		public void Copy()
 		{
-			throw new NotImplementedException ();
+			TextBuffer.CopyClipboard (Gtk.Clipboard.Get (Gdk.Atom.Intern("GDK_NONE", false)));
 		}
-		[MonoTODO]
+
 		public void Cut()
 		{
-			throw new NotImplementedException ();
+			TextBuffer.CutClipboard (Gtk.Clipboard.Get (Gdk.Atom.Intern("GDK_NONE", false)), true);
 		}
 		[MonoTODO]
 		public void Paste()
 		{
-			throw new NotImplementedException ();
+			// Wait for my gtk-sharp patch
+			// TextBuffer.PasteClipboard(Gtk.Clipboard.Get (Gdk.Atom.Intern("GDK_NONE", false), true));
 		}
 		[MonoTODO]
 		public void ScrollToCaret()
@@ -447,5 +447,4 @@
 			throw new NotImplementedException ();
 		}
 */	}
-}
-
+}
Index: demo.cs
===================================================================
RCS file: /mono/mcs/class/System.Windows.Forms/Gtk/demo.cs,v
retrieving revision 1.8
diff -u -u -r1.8 demo.cs
--- demo.cs	6 May 2003 23:54:19 -0000	1.8
+++ demo.cs	23 May 2003 12:21:12 -0000
@@ -7,43 +7,62 @@
 //
 
 using System;
-using System.Drawing;
-using System.Windows.Forms;
-
-namespace demo
-{
-	
-	public class GtkForm : System.Windows.Forms.Form
-  	{
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace demo
+{
+	
+	public class GtkForm : System.Windows.Forms.Form
+  	{
+		private Button copybutton = new Button();
+		private Button pastebutton = new Button();
+		private Button cutbutton = new Button();
 	    	private Button button1 = new Button(); 
 			private Button button2 = new Button(); 
-			private Label label1 = new Label();
-	    	private TextBox text1 = new TextBox(); 
+			private Label label1 = new Label();
+	    	private TextBox text1 = new TextBox(); 
 	    	private ProgressBar bar1 = new ProgressBar();
-			private CheckBox check1 = new CheckBox();
+			private CheckBox check1 = new CheckBox();
 	    	private RadioButton opt1 = new RadioButton();
 			private RadioButton opt2 = new RadioButton();
 			private GroupBox frame1 = new GroupBox();
 			private PictureBox pbox = new PictureBox();
 			private FileDialog fdialog = new FileDialog();
 		
-	    	private void InitializeWidgets()
-	    	{
-    		  	button1.Location = new Point(150, 28);
-       	  	button1.Name = "button1";
-    	  	  	button1.Size = new Size(128, 44);
-       	 	button1.Text = "Apply";
-    	  		button1.Click += new EventHandler(this.button1_Click);    
+	    	private void InitializeWidgets()
+	    	{
+    		  	button1.Location = new Point(150, 28);
+       	  	button1.Name = "button1";
+    	  	  	button1.Size = new Size(128, 44);
+       	 	button1.Text = "Apply";
+    	  		button1.Click += new EventHandler(this.button1_Click);    
          	button1.Enabled = false;
   
-				button2.Location = new Point(150, 85);
-       	  	button2.Name = "button2";
-    	  	  	button2.Size = new Size(128, 44);
-       	 	button2.Text = "File";
+				button2.Location = new Point(150, 85);
+       	  	button2.Name = "button2";
+    	  	  	button2.Size = new Size(128, 44);
+       	 	button2.Text = "File";
     	  		button2.Click += new EventHandler(this.button2_Click); 
- 
-    	    	text1.Location = new Point(320,48);
-    	    	text1.Name = "textBox1";
+
+  	  	copybutton.Click += new EventHandler(this.copybutton_Click); 
+  	  	pastebutton.Click += new EventHandler(this.pastebutton_Click); 
+  	  	cutbutton.Click += new EventHandler(this.cutbutton_Click); 
+
+		copybutton.Location = new Point(320, 80); 
+		pastebutton.Location = new Point(320, 100); 
+		cutbutton.Location = new Point(320, 120);
+
+		copybutton.Size = new Size(150, 20); 
+		pastebutton.Size = new Size(150, 20); 
+		cutbutton.Size = new Size(150, 20); 
+
+		copybutton.Text ="Copy";
+		pastebutton.Text ="Paste";
+		cutbutton.Text ="Cut";
+
+    	    	text1.Location = new Point(320,48);
+    	    	text1.Name = "textBox1";
    	    	text1.Size = new Size(150, 22);
 	 			text1.Text = this.button1.Name;
 
@@ -77,10 +96,13 @@
 				//
 				//Add you image name and path below
 				//pbox.File = "/home/jstrike/Shared/7804.jpg";
-
+
           this.Controls.AddRange(new System.Windows.Forms.Control[] { 
 									this.button1,
-									this.button2,
+									this.button2,
+									this.copybutton,
+									this.pastebutton,
+									this.cutbutton,
                      	this.text1, 
 									this.bar1, 
 									this.check1,
@@ -89,16 +111,28 @@
 									this.frame1,
 									this.pbox,
 									fdialog,
-									this.label1 });
-          this.Size = new Size(512, 250);
-    		}
-    	
-    	public GtkForm()
-    	{
+									this.label1 });
+          this.Size = new Size(512, 250);
+    		}
+    	
+    	public GtkForm()
+    	{
     	   	InitializeWidgets();
-
-    	}
-
+
+    	}
+
+		private void copybutton_Click(object sender, EventArgs e){ 
+			text1.Copy();			
+		}
+
+		private void pastebutton_Click(object sender, EventArgs e){ 
+			text1.Paste();
+		}
+
+		private void cutbutton_Click(object sender, EventArgs e){ 
+			text1.Cut();
+		}
+
 		private void button1_Click(object sender, EventArgs e){ 
 			pbox.File = fdialog.OpenFile;
 				if (this.check1.Checked) { 
@@ -106,23 +140,23 @@
 				}
 				if (!this.check1.Checked){
 					this.pbox.Stretch = false;
-				}			
+				}			
   		}
 
-		private void button2_Click(object sender, EventArgs e){ 							
+		private void button2_Click(object sender, EventArgs e){ 							
   			fdialog.ShowDialog();
 			button1.Enabled = true;
 		}
 
 		}
-	
-	public class GtkMain
-	{
-		public static void Main()
-		{
-			GtkForm form1 = new GtkForm ();
-			form1.Text = "System.Windows.Forms at work!";			
-			Application.Run(form1);
-		}
-	}
-}
+	
+	public class GtkMain
+	{
+		public static void Main()
+		{
+			GtkForm form1 = new GtkForm ();
+			form1.Text = "System.Windows.Forms at work!";			
+			Application.Run(form1);
+		}
+	}
+}

--=-quiGESaqPoitpLgYfn6j--