[Mono-winforms-list] Small fix

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


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



Okay,

this one implements 

System.Windows.Forms(Gtk).TextBoxBase.Copy ()
System.Windows.Forms(Gtk).TextBoxBase.Cut ()
System.Windows.Forms(Gtk).TextBoxBase.Paste ()

System.Windows.Forms(Gtk).TextBoxBase.Select(int begin, int length)
System.Windows.Forms(Gtk).TextBoxBase.SelectAll()

And it adds some testing code to demo.cs

Sorry for the 3th mail about this ;) well.. maybe even more will follow

Btw, JStrike .. if you want me to checkout a specific class in this
namespace : let me know on IRC (my nickname is freax on GIMPNet). At
this moment I am just going though all the classes in SWF/Gtk/* and am
fixing what I know ;)



-- 
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



--=-qb4qVZWYBCrmAYET7pGy
Content-Disposition: attachment; filename=SWF.gtk.diff
Content-Type: text/plain; name=SWF.gtk.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 13:45:02 -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 13:45:02 -0000
@@ -22,7 +22,6 @@
 		private int maxlength = 0;
 		private Gtk.TextTagTable tagtable;
 		private Gtk.TextBuffer textbuffer = null;
-
 		//
 		//  --- Public Properties
 		//
@@ -281,35 +280,46 @@
 		{
 			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()
 		{
 			throw new NotImplementedException ();
 		}
-		[MonoTODO]
+
 		public void Select(int start, int length) 
 		{
-			throw new NotImplementedException ();
+			Gtk.TextIter iter_start, iter_end;
+			TextBuffer.GetIterAtOffset (out iter_start, start);
+			TextBuffer.GetIterAtOffset (out iter_end, length);
+
+			TextBuffer.MoveMark(TextBuffer.InsertMark , iter_end);
+			TextBuffer.MoveMark (TextBuffer.SelectionBound, iter_start);
 		}
-		[MonoTODO]
+
 		public void SelectAll()
 		{
-			throw new NotImplementedException ();
+			Gtk.TextIter iter_start, iter_end;
+			TextBuffer.GetBounds (out iter_start, out iter_end);
+
+			TextBuffer.MoveMark(TextBuffer.InsertMark , iter_end);
+			TextBuffer.MoveMark (TextBuffer.SelectionBound, iter_start);
+
 		}
 		[MonoTODO]
 		public override string ToString()
@@ -447,5 +457,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 13:45:02 -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,30 @@
 									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.Select (1, 4);
+			text1.Copy();
+		}
+
+		private void pastebutton_Click(object sender, EventArgs e){ 
+			text1.SelectAll();
+			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 +142,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);
+		}
+	}
+}

--=-qb4qVZWYBCrmAYET7pGy--