[Kde-bindings] playground/bindings/kimono

Richard Dale Richard_Dale at tipitina.demon.co.uk
Thu Dec 8 19:09:15 UTC 2005


SVN commit 486789 by rdale:

* Added improved QApplication constructors from Arno Rehn. The argv array now contains the
  executable name as the first element, and Init_Qyoto() is called to initialize the bindings.

CCMAIL: kde-bindings at kde.org



 M  +3 -8      Hello.cs  
 M  +40 -5     qt3qyoto/QApplication.cs  
 M  +4 -4      t1.cs  


--- trunk/playground/bindings/kimono/Hello.cs #486788:486789
@@ -4,11 +4,7 @@
 
 class MainForm : QDialog
 {
-        [DllImport("libqyoto", CharSet=CharSet.Ansi)]
-        static extern void Init_qyoto();
-
-	    static void Main(String[] args) {
-                Init_qyoto();
+	static void Main(String[] args) {
                 Qt.QApplication qa = new Qt.QApplication(args);
                 MainForm mf = new MainForm();
                 mf.Show();
@@ -23,9 +19,8 @@
                 qgrid.SetAutoAdd(true);
                 QTextEdit te = new QTextEdit(this);
                 te.Show();
-				SetCaption("My Caption");
-                QPushButton button = new QPushButton(this);
-                button.SetCaption("Hello World!");
+				SetCaption("Qyoto C# bindings test");
+                QPushButton button = new QPushButton("Hello World! Are you getting warmer?", this);
                 button.Show();
         }
 }
--- trunk/playground/bindings/kimono/qt3qyoto/QApplication.cs #486788:486789
@@ -129,9 +129,18 @@
 		public new virtual string ClassName() {
 			return ProxyQApplication().ClassName();
 		}
+		
+		
+		/* Constructor #1 */
 		public QApplication(string[] argv) : this((Type) null) {
+			Qyoto.Init_qyoto();
 			CreateQApplicationProxy();
-			NewQApplication(argv);
+			
+			string[] args = new string[argv.Length + 1];
+			args[0] = System.Reflection.Assembly.GetExecutingAssembly().Location;
+			argv.CopyTo(args, 1);
+			
+			NewQApplication(args);
 		}
 		private void NewQApplication(string[] argv) {
 			ProxyQApplication().NewQApplication(argv.Length, argv);
@@ -139,20 +148,46 @@
 		private void NewQApplication(int argc, string[] argv) {
 			ProxyQApplication().NewQApplication(argc, argv);
 		}
+		/* end Constructor #1 */
+		
+		/* Constructor #2 */
 		public QApplication(string[] argv, bool GUIenabled) : this((Type) null) {
+			Qyoto.Init_qyoto();
 			CreateQApplicationProxy();
-			NewQApplication(argv,GUIenabled);
+			
+			string[] args = new string[argv.Length + 1];
+			args[0] = System.Reflection.Assembly.GetExecutingAssembly().Location;
+			argv.CopyTo(args, 1);
+
+			NewQApplication(args,GUIenabled);
 		}
 		private void NewQApplication(string[] argv, bool GUIenabled) {
-			ProxyQApplication().NewQApplication(argv,GUIenabled);
+			ProxyQApplication().NewQApplication(argv.Length, argv,GUIenabled);
 		}
+		private void NewQApplication(int argc, string[] argv, bool GUIenabled) {
+			ProxyQApplication().NewQApplication(argc, argv,GUIenabled);
+		}
+		/* end Constructor #2 */
+		
+		/* Constructor #3 */
 		public QApplication(string[] argv, int arg3) : this((Type) null) {
+			Qyoto.Init_qyoto();
 			CreateQApplicationProxy();
-			NewQApplication(argv,arg3);
+			
+			string[] args = new string[argv.Length + 1];
+			args[0] = System.Reflection.Assembly.GetExecutingAssembly().Location;
+			argv.CopyTo(args, 1);
+
+			NewQApplication(args,arg3);
 		}
 		private void NewQApplication(string[] argv, int arg3) {
-			ProxyQApplication().NewQApplication(argv,arg3);
+			ProxyQApplication().NewQApplication(argv.Length,argv,arg3);
 		}
+		private void NewQApplication(int argc, string[] argv, int arg3) {
+			ProxyQApplication().NewQApplication(argc,argv,arg3);
+		}
+		/* end Constructor #3 */
+		
 		public int Type() {
 			return ProxyQApplication().Type();
 		}
--- trunk/playground/bindings/kimono/t1.cs #486788:486789
@@ -4,11 +4,11 @@
 
 public class T1 
 {
-	[DllImport("libqyoto", CharSet=CharSet.Ansi)]
-	static extern void Init_qyoto();
+	public static int Main(String[] args) {
+string[] myargs = System.Environment.GetCommandLineArgs();
+Console.WriteLine("myargs[0]: {0}", myargs[0]);
+Console.WriteLine("GetExecutionAssembly: {0}", System.Reflection.Assembly.GetExecutingAssembly().Location);
 
-	public static int Main(String[] args) {
-		Init_qyoto();
 		QApplication a = new QApplication(args);
 		
 		QPushButton hello = new QPushButton("Hello world!", null);



More information about the Kde-bindings mailing list