From bdd77ead0399f63949501b53d9dfe23b241e0704 Mon Sep 17 00:00:00 2001 From: Alexander Corrado Date: Sun, 14 Aug 2011 22:16:39 -0400 Subject: [PATCH] Reorganize Qt bindings --- qt/Makefile.am | 29 ++++++ qt/demos/hello.cs | 23 +++++ {src/qt => qt}/qt-gui-filters.txt | 0 {src/qt => qt}/qt-gui.cpp | 4 +- qt/qt-gui.h | 2 + qt/src/QApplication.cs | 17 ++++ qt/src/QCoreApplication.cs | 46 ++++++++++ qt/src/QSize.cs | 27 ++++++ {src/qt => qt/src}/QString.cs | 5 + src/QtBindings/AssemblyInfo.cs | 29 ------ src/QtBindings/Core/QCoreApplication.cs | 85 ----------------- src/QtBindings/Core/QGlobal.cs | 10 -- src/QtBindings/Core/QObject.cs | 63 ------------- src/QtBindings/Core/QSize.cs | 18 ---- src/QtBindings/Core/QString.cs | 67 -------------- src/QtBindings/Gui/QAbstractButton.cs | 35 ------- src/QtBindings/Gui/QApplication.cs | 63 ------------- src/QtBindings/Gui/QPaintDevice.cs | 40 -------- src/QtBindings/Gui/QPushButton.cs | 51 ----------- src/QtBindings/Gui/QWidget.cs | 116 ------------------------ src/QtBindings/Libs.cs | 34 ------- src/QtBindings/Makefile.am | 110 ---------------------- src/QtBindings/QtBindings.csproj | 103 --------------------- src/QtBindings/QtBindings.dll.config | 5 - src/QtBindings/qtbindings.pc.in | 6 -- src/qt/Makefile.am | 29 ------ src/qt/hello.cs | 20 ---- src/qt/qt-gui.h | 2 - 28 files changed, 151 insertions(+), 888 deletions(-) create mode 100644 qt/Makefile.am create mode 100644 qt/demos/hello.cs rename {src/qt => qt}/qt-gui-filters.txt (100%) rename {src/qt => qt}/qt-gui.cpp (87%) create mode 100644 qt/qt-gui.h create mode 100644 qt/src/QApplication.cs create mode 100644 qt/src/QCoreApplication.cs create mode 100644 qt/src/QSize.cs rename {src/qt => qt/src}/QString.cs (93%) delete mode 100644 src/QtBindings/AssemblyInfo.cs delete mode 100644 src/QtBindings/Core/QCoreApplication.cs delete mode 100644 src/QtBindings/Core/QGlobal.cs delete mode 100644 src/QtBindings/Core/QObject.cs delete mode 100644 src/QtBindings/Core/QSize.cs delete mode 100644 src/QtBindings/Core/QString.cs delete mode 100644 src/QtBindings/Gui/QAbstractButton.cs delete mode 100644 src/QtBindings/Gui/QApplication.cs delete mode 100644 src/QtBindings/Gui/QPaintDevice.cs delete mode 100644 src/QtBindings/Gui/QPushButton.cs delete mode 100644 src/QtBindings/Gui/QWidget.cs delete mode 100644 src/QtBindings/Libs.cs delete mode 100644 src/QtBindings/Makefile.am delete mode 100644 src/QtBindings/QtBindings.csproj delete mode 100644 src/QtBindings/QtBindings.dll.config delete mode 100644 src/QtBindings/qtbindings.pc.in delete mode 100644 src/qt/Makefile.am delete mode 100644 src/qt/hello.cs delete mode 100644 src/qt/qt-gui.h diff --git a/qt/Makefile.am b/qt/Makefile.am new file mode 100644 index 00000000..19485b5d --- /dev/null +++ b/qt/Makefile.am @@ -0,0 +1,29 @@ +top_srcdir = ../.. + +INTEROP_DLL = \ + $(top_srcdir)/bin/Debug/Mono.Cxxi.dll + +all: hello.exe + +qt-gui.xml: qt-gui.h + $(GCCXML) -fxml=$@ --gccxml-cxxflags "-m32 -I." /Library/Frameworks/QtGui.framework/Versions/Current/Headers/QtGui + +generated: qt-gui.xml + $(RM) -r generated + $(MONO) --debug $(top_srcdir)/bin/Debug/generator.exe -o=generated -ns=Qt.Gui -lib=QtGui --filters=qt-gui-filters.txt qt-gui.xml + +#libQtGui-inline.so: qt-gui.cpp +# $(CXX) -m32 -I. -framework QtGui -framework QtCore -DQ_WS_MAC --shared -fPIC -o $@ -fkeep-inline-functions qt-gui.cpp + +Qt.Gui-binding.dll: generated QString.cs QSize.cs QApplication.cs QCoreApplication.cs + $(RM) -f generated/QString.cs generated/QSize.cs + $(GMCS) -debug -out:$@ -target:library -unsafe -r:$(INTEROP_DLL) generated/*.cs QString.cs QApplication.cs QCoreApplication.cs QSize.cs + +hello.exe: Qt.Gui-binding.dll hello.cs #libQtGui-inline.so + $(GMCS) -debug -out:$@ -target:exe -r:$(INTEROP_DLL) -r:Qt.Gui-binding.dll hello.cs + +clean: + $(RM) -rf generated hello.exe* qt-gui.xml Qt.Gui-binding.dll* libQtGui-inline.so + +run: hello.exe + MONO_PATH=.:$(top_srcdir)/bin/Debug $(MONO) --debug --trace=__CppLibraryImplAssembly hello.exe diff --git a/qt/demos/hello.cs b/qt/demos/hello.cs new file mode 100644 index 00000000..6f89fb68 --- /dev/null +++ b/qt/demos/hello.cs @@ -0,0 +1,23 @@ +using System; +using System.Diagnostics; +using Qt.Gui; + +using Mono.Cxxi; + +namespace QtTest { + class MainClass { + public static void Main (string[] args) + { + using (QApplication app = new QApplication ()) { + using (QPushButton hello = new QPushButton ("Hello world!", null)) { + + hello.Resize (new QSize (100, 30)); + + hello.SetVisible (true); + QApplication.Exec (); + } + } + } + } +} + diff --git a/src/qt/qt-gui-filters.txt b/qt/qt-gui-filters.txt similarity index 100% rename from src/qt/qt-gui-filters.txt rename to qt/qt-gui-filters.txt diff --git a/src/qt/qt-gui.cpp b/qt/qt-gui.cpp similarity index 87% rename from src/qt/qt-gui.cpp rename to qt/qt-gui.cpp index c37cb5b3..19a4bc32 100644 --- a/src/qt/qt-gui.cpp +++ b/qt/qt-gui.cpp @@ -13,8 +13,8 @@ // this one was annoying to track down! #define QT_NO_TRANSLATION -#include -#include +#include "QtGui/QApplication" +#include "QtGui/QPushButton" int main () { diff --git a/qt/qt-gui.h b/qt/qt-gui.h new file mode 100644 index 00000000..98ccd6e6 --- /dev/null +++ b/qt/qt-gui.h @@ -0,0 +1,2 @@ +#include "QApplication" +#include "QPushButton" diff --git a/qt/src/QApplication.cs b/qt/src/QApplication.cs new file mode 100644 index 00000000..8b3d698f --- /dev/null +++ b/qt/src/QApplication.cs @@ -0,0 +1,17 @@ +using System; +using System.Runtime.InteropServices; +using Mono.Cxxi; + +namespace Qt.Gui { + public partial class QApplication { + + + public QApplication () : base (impl.TypeInfo) + { + InitArgcAndArgv (); + Native = impl.QApplication (impl.Alloc (this), argc, argv, 0x040602); + } + + } +} + diff --git a/qt/src/QCoreApplication.cs b/qt/src/QCoreApplication.cs new file mode 100644 index 00000000..f40afced --- /dev/null +++ b/qt/src/QCoreApplication.cs @@ -0,0 +1,46 @@ +using System; +using System.Runtime.InteropServices; +using Mono.Cxxi; + +namespace Qt.Gui { + public partial class QCoreApplication { + + protected IntPtr argc, argv; + + public QCoreApplication () : base (impl.TypeInfo) + { + InitArgcAndArgv (); + Native = impl.QCoreApplication (impl.Alloc (this), argc, argv); + } + + partial void AfterDestruct () + { + FreeArgcAndArgv (); + } + + protected void InitArgcAndArgv () + { + var args = Environment.GetCommandLineArgs (); + var argCount = args.Length; + + argc = Marshal.AllocHGlobal (sizeof(int)); + Marshal.WriteInt32 (argc, argCount); + + argv = Marshal.AllocHGlobal (Marshal.SizeOf (typeof(IntPtr)) * argCount); + for (var i = 0; i < argCount; i++) { + IntPtr arg = Marshal.StringToHGlobalAnsi (args [i]); + Marshal.WriteIntPtr (argv, i * Marshal.SizeOf (typeof(IntPtr)), arg); + } + } + + protected void FreeArgcAndArgv () + { + Marshal.FreeHGlobal (argc); + for (var i = 0; i < Environment.GetCommandLineArgs ().Length; i++) + Marshal.FreeHGlobal (Marshal.ReadIntPtr (argv, i * Marshal.SizeOf (typeof(IntPtr)))); + Marshal.FreeHGlobal (argv); + } + + } +} + diff --git a/qt/src/QSize.cs b/qt/src/QSize.cs new file mode 100644 index 00000000..6a07c24e --- /dev/null +++ b/qt/src/QSize.cs @@ -0,0 +1,27 @@ +// ------------------------------------------------------------------------- +// Managed wrapper for QSize +// Generated from qt-gui.xml on 07/24/2011 11:57:03 +// +// This file was auto generated. Do not edit. +// ------------------------------------------------------------------------- + +using System; +using System.Runtime.InteropServices; +using Mono.Cxxi; + +namespace Qt.Gui { + + [StructLayout (LayoutKind.Sequential)] + public struct QSize { + + public int wd; + public int ht; + + public QSize (int w, int h) + { + wd = w; + ht = h; + } + } +} + diff --git a/src/qt/QString.cs b/qt/src/QString.cs similarity index 93% rename from src/qt/QString.cs rename to qt/src/QString.cs index 260e0ac3..1a326c07 100644 --- a/src/qt/QString.cs +++ b/qt/src/QString.cs @@ -50,6 +50,11 @@ namespace Qt.Gui { return new QString (str); } + public override string ToString () + { + return Marshal.PtrToStringUni (d->data, d->size); + } + public QString AddRef () { d->@ref++; diff --git a/src/QtBindings/AssemblyInfo.cs b/src/QtBindings/AssemblyInfo.cs deleted file mode 100644 index 87ae2a27..00000000 --- a/src/QtBindings/AssemblyInfo.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. - -[assembly: AssemblyTitle("QtBindings")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. - -[assembly: AssemblyVersion("1.0.*")] -[assembly: CLSCompliant(true)] - -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. - -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] - diff --git a/src/QtBindings/Core/QCoreApplication.cs b/src/QtBindings/Core/QCoreApplication.cs deleted file mode 100644 index 9572c59c..00000000 --- a/src/QtBindings/Core/QCoreApplication.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using Mono.VisualC.Interop; - -namespace Qt.Core { - public class QCoreApplication : QObject { - #region Sync with qcoreapplication.h - // C++ interface - public interface IQCoreApplication : ICppClassOverridable { - // ... - [Constructor] void QCoreApplication (CppInstancePtr @this, [MangleAs ("int&")] IntPtr argc, - [MangleAs ("char**")] IntPtr argv); - // ... - [Static] int exec (); - // ... - [Virtual] bool notify (CppInstancePtr @this, IntPtr qObject, IntPtr qEvent); - [Virtual] bool compressEvent (CppInstancePtr @this, IntPtr qEvent, IntPtr qObject, IntPtr qPostEventList); - - [Virtual, Destructor] void Destruct (CppInstancePtr @this); - } - // C++ fields - private struct _QCoreApplication { - } - #endregion - - private static IQCoreApplication impl = Qt.Libs.QtCore.GetClass ("QCoreApplication"); - protected IntPtr argc; - protected IntPtr argv; - - - public QCoreApplication () : base (impl.TypeInfo) - { - Native = impl.Alloc (this); - InitArgcAndArgv (); - impl.QCoreApplication (Native, argc, argv); - } - - public QCoreApplication (IntPtr native) : base (impl.TypeInfo) - { - Native = native; - } - - internal QCoreApplication (CppTypeInfo subClass) : base (impl.TypeInfo) - { - subClass.AddBase (impl.TypeInfo); - } - - public virtual int Exec () - { - return impl.exec (); - } - - public override void Dispose () - { - impl.Destruct (Native); - FreeArgcAndArgv (); - Native.Dispose (); - } - - protected void InitArgcAndArgv () - { - // for some reason, this includes arg0, but the args passed to Main (string[]) do not! - string[] args = Environment.GetCommandLineArgs (); - - int argCount = args.Length; - argc = Marshal.AllocHGlobal (sizeof (int)); - Marshal.WriteInt32 (argc, argCount); - - argv = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (IntPtr)) * argCount); - for (var i = 0; i < argCount; i++) { - IntPtr arg = Marshal.StringToHGlobalAnsi (args [i]); - Marshal.WriteIntPtr (argv, i * Marshal.SizeOf (typeof (IntPtr)), arg); - } - } - - protected void FreeArgcAndArgv () - { - Marshal.FreeHGlobal (argc); - for (var i = 0; i < Environment.GetCommandLineArgs ().Length; i++) - Marshal.FreeHGlobal (Marshal.ReadIntPtr (argv, i * Marshal.SizeOf (typeof (IntPtr)))); - Marshal.FreeHGlobal (argv); - } - } -} - diff --git a/src/QtBindings/Core/QGlobal.cs b/src/QtBindings/Core/QGlobal.cs deleted file mode 100644 index 4bbea66e..00000000 --- a/src/QtBindings/Core/QGlobal.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -namespace Qt.Core { - public static class QGlobal { - - public const string QT_VERSION_STR = "4.6.2"; - public const int QT_VERSION = 0x040602; - - } -} - diff --git a/src/QtBindings/Core/QObject.cs b/src/QtBindings/Core/QObject.cs deleted file mode 100644 index 73458940..00000000 --- a/src/QtBindings/Core/QObject.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using Mono.VisualC.Interop; - -namespace Qt.Core { - public class QObject : ICppObject { - #region Sync with qobject.h - // C++ interface - public interface IQObject : ICppClassOverridable { - // ... - [Virtual] /*QMetaObject */ IntPtr metaObject(CppInstancePtr @this); - [Virtual] /*void */ IntPtr qt_metacast(CppInstancePtr @this, string s); - [Virtual] int qt_metacall(CppInstancePtr @this, /*QMetaObject::Call */ int qMetaObjectCall, int x, /*void **/ IntPtr p); - // ... - [Constructor] void QObject (CppInstancePtr @this, QObject parent); - [Virtual, Destructor] void Destruct (CppInstancePtr @this); - // ... - [Virtual] bool @event (CppInstancePtr @this, IntPtr qEvent); - [Virtual] bool eventFilter (CppInstancePtr @this, IntPtr qObject, IntPtr qEvent); - [Virtual] void timerEvent (CppInstancePtr @this, IntPtr qTimerEvent); - [Virtual] void childEvent (CppInstancePtr @this, IntPtr qChildEvent); - [Virtual] void customEvent (CppInstancePtr @this, IntPtr qEvent); - [Virtual] void connectNotify (CppInstancePtr @this, string signal); - [Virtual] void disconnectNotify (CppInstancePtr @this, string signal); - } - // C++ fields - private struct _QObject { - public IntPtr d_ptr; - } - #endregion - - private static IQObject impl = Qt.Libs.QtCore.GetClass ("QObject"); - public CppInstancePtr Native { get; protected set; } - - public QObject (QObject parent) - { - Native = impl.Alloc (this); - impl.QObject (Native, parent); - } - - public QObject () : this ((QObject)null) - { - } - - public QObject (IntPtr native) - { - Native = native; - } - - internal QObject (CppTypeInfo subClass) - { - subClass.AddBase (impl.TypeInfo); - } - - public virtual void Dispose () - { - impl.Destruct (Native); - Native.Dispose (); - } - - } -} - diff --git a/src/QtBindings/Core/QSize.cs b/src/QtBindings/Core/QSize.cs deleted file mode 100644 index 6fd36d9b..00000000 --- a/src/QtBindings/Core/QSize.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using Mono.VisualC.Interop; - -namespace Qt.Core { - [StructLayout (LayoutKind.Sequential)] - public struct QSize { - public int wd; - public int ht; - - public QSize (int w, int h) - { - this.wd = w; - this.ht = h; - } - } -} - diff --git a/src/QtBindings/Core/QString.cs b/src/QtBindings/Core/QString.cs deleted file mode 100644 index abc157e6..00000000 --- a/src/QtBindings/Core/QString.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Text; -using System.Runtime.InteropServices; - -using Mono.VisualC.Interop; -using Mono.VisualC.Interop.ABI; - -namespace Qt.Core { - //TODO: Will this leak? - [StructLayout (LayoutKind.Sequential)] - public unsafe struct QString { - #region Sync with qstring.h - public interface IQString : ICppClass { - [Constructor] void QString(ref QString @this, [MangleAs ("const QChar*")] IntPtr unicode, int size); - } - - [StructLayout (LayoutKind.Sequential)] - public struct Data { - public int @ref; - public int alloc, size; - public IntPtr data; - public ushort clean; - public ushort simpletext; - public ushort righttoleft; - public ushort asciiCache; - public ushort capacity; - public ushort reserved; - public IntPtr array; - } - - - public Data* d; - #endregion - - private static IQString impl = Qt.Libs.QtCore.GetClass ("QString"); - - public QString (string str) : this () - { - IntPtr strPtr = Marshal.StringToHGlobalUni (str); - impl.QString (ref this, strPtr, str.Length); - Marshal.FreeHGlobal (strPtr); - - // TODO: I deref this on construction to let Qt free it when it's done with it. - // My assumption is that this struct will only be used to interop with Qt and - // no managed class is going to hold on to it. - this.DeRef (); - } - - public static implicit operator QString (string str) - { - return new QString (str); - } - - public QString AddRef () - { - d->@ref++; - return this; - } - - public QString DeRef () - { - d->@ref--; - return this; - } - } -} - diff --git a/src/QtBindings/Gui/QAbstractButton.cs b/src/QtBindings/Gui/QAbstractButton.cs deleted file mode 100644 index f8a8d40e..00000000 --- a/src/QtBindings/Gui/QAbstractButton.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using Mono.VisualC.Interop; - -namespace Qt.Gui { - public class QAbstractButton : QWidget { - #region Sync with qabstractbutton.h - // C++ interface - public interface IQAbstractButton : ICppClassOverridable { - [Virtual] void paintEvent (CppInstancePtr @this, /*QPaintEvent */ IntPtr e); // abstract - [Virtual] bool hitButton (CppInstancePtr @this, /*const QPoint &*/ IntPtr pos); - [Virtual] void checkStateSet (CppInstancePtr @this); - [Virtual] void nextCheckState (CppInstancePtr @this); - } - private struct _QAbstractButton { - } - #endregion - - private static IQAbstractButton impl = Qt.Libs.QtGui.GetClass ("QAbstractButton"); - - public QAbstractButton (IntPtr native) : base (impl.TypeInfo) - { - Native = native; - } - - internal QAbstractButton (CppTypeInfo subClass) : base (impl.TypeInfo) - { - subClass.AddBase (impl.TypeInfo); - } - - public override void Dispose () - { - } - } -} - diff --git a/src/QtBindings/Gui/QApplication.cs b/src/QtBindings/Gui/QApplication.cs deleted file mode 100644 index c894b654..00000000 --- a/src/QtBindings/Gui/QApplication.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using Mono.VisualC.Interop; - -using Qt.Core; - -namespace Qt.Gui { - public class QApplication : QCoreApplication { - #region Sync with qapplication.h - // C++ interface - public interface IQApplication : ICppClassOverridable { - // ... - [Constructor] void QApplication (CppInstancePtr @this, [MangleAs ("int&")] IntPtr argc, - [MangleAs ("char**")] IntPtr argv, int version); - // ... - [Virtual] bool macEventFilter(CppInstancePtr @this, IntPtr eventHandlerCallRef, IntPtr eventRef); - // ... - [Virtual] void commitData(CppInstancePtr @this, IntPtr qSessionManager); // was QSessionManager& - [Virtual] void saveState(CppInstancePtr @this, IntPtr qSessionManager); // was QSessionManager& - // ... - [Static] int exec (); - - [Virtual, Destructor] void Destruct (CppInstancePtr @this); - } - // C++ fields - private struct _QApplication { - } - #endregion - - private static IQApplication impl = Qt.Libs.QtGui.GetClass ("QApplication"); - - public QApplication () : base (impl.TypeInfo) - { - Native = impl.Alloc (this); - InitArgcAndArgv (); - impl.QApplication (Native, argc, argv, QGlobal.QT_VERSION); - } - - public QApplication (IntPtr native) : base (impl.TypeInfo) - { - Native = native; - } - - internal QApplication (CppTypeInfo subClass) : base (impl.TypeInfo) - { - subClass.AddBase (impl.TypeInfo); - } - - public override int Exec () - { - return impl.exec (); - } - - public override void Dispose () - { - impl.Destruct (Native); - FreeArgcAndArgv (); - Native.Dispose (); - } - - } -} - diff --git a/src/QtBindings/Gui/QPaintDevice.cs b/src/QtBindings/Gui/QPaintDevice.cs deleted file mode 100644 index bfba852b..00000000 --- a/src/QtBindings/Gui/QPaintDevice.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using Mono.VisualC.Interop; -using Mono.VisualC.Interop.ABI; - -namespace Qt.Gui { - public class QPaintDevice : ICppObject { - #region Sync with qpaintdevice.h - // C++ interface - public interface IQPaintDevice : ICppClassOverridable { - [Virtual] int devType (CppInstancePtr @this); - [Virtual] /*QPaintEngine */ IntPtr paintEngine (CppInstancePtr @this); // abstract - //... - void QPaintDevice (CppInstancePtr @this); - [Virtual] int metric (CppInstancePtr @this, /*PaintDeviceMetric*/ IntPtr metric); - } - // C++ fields - private struct _QPaintDevice { - public ushort painters; - } - #endregion - - private static IQPaintDevice impl = Qt.Libs.QtGui.GetClass ("QPaintDevice"); - public CppInstancePtr Native { get; protected set; } - - public QPaintDevice (IntPtr native) - { - Native = native; - } - - internal QPaintDevice (CppTypeInfo subClass) - { - subClass.AddBase (impl.TypeInfo); - } - - public void Dispose () - { - } - } -} - diff --git a/src/QtBindings/Gui/QPushButton.cs b/src/QtBindings/Gui/QPushButton.cs deleted file mode 100644 index a2837e0f..00000000 --- a/src/QtBindings/Gui/QPushButton.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using Mono.VisualC.Interop; -using Qt.Core; - -namespace Qt.Gui { - public class QPushButton : QAbstractButton { - #region Sync with qpushbutton.h - // C++ interface - public interface IQPushButton : ICppClassOverridable { - // ... - [Constructor] void QPushButton (CppInstancePtr @this, [MangleAs ("const QString &")] ref QString text, QWidget parent); - // ... - [Virtual, Destructor] void Destruct (CppInstancePtr @this); - } - // C++ fields - private struct _QPushButton { - } - #endregion - - private static IQPushButton impl = Qt.Libs.QtGui.GetClass ("QPushButton"); - - public QPushButton (string btnText, QWidget parent) : base (impl.TypeInfo) - { - Native = impl.Alloc (this); - - QString text = btnText; - impl.QPushButton (Native, ref text, parent); - } - - public QPushButton (string text) : this (text, (QWidget)null) - { - } - - public QPushButton (IntPtr native) : base (impl.TypeInfo) - { - Native = native; - } - - internal QPushButton (CppTypeInfo subClass) : base (impl.TypeInfo) - { - subClass.AddBase (impl.TypeInfo); - } - - public override void Dispose () - { - impl.Destruct (Native); - Native.Dispose (); - } - } -} - diff --git a/src/QtBindings/Gui/QWidget.cs b/src/QtBindings/Gui/QWidget.cs deleted file mode 100644 index f595c429..00000000 --- a/src/QtBindings/Gui/QWidget.cs +++ /dev/null @@ -1,116 +0,0 @@ -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; -using Mono.VisualC.Interop; - -using Qt.Core; - -namespace Qt.Gui { - public class QWidget : QObject { - #region Sync with qwidget.h - // C++ interface - public interface IQWidget : ICppClassOverridable { - // ... - [Constructor] void QWidget (CppInstancePtr @this, QWidget parent, /*Qt::WindowFlags */ int f); - // ... - [Virtual] void setVisible (CppInstancePtr @this, bool visible); - // ... - void resize (CppInstancePtr @this, [MangleAs ("const QSize &")] ref QSize size); - // ... - [Virtual] /*QSize*/ int sizeHint (CppInstancePtr @this); - [Virtual] /*QSize*/ int minimumSizeHint (CppInstancePtr @this); - // ... - [Virtual] int heightForWidth (CppInstancePtr @this, int width); - // ... protected: - [Virtual] void mousePressEvent (CppInstancePtr @this, /*QMouseEvent */ IntPtr p); - [Virtual] void mouseReleaseEvent (CppInstancePtr @this, /*QMouseEvent */ IntPtr p); - [Virtual] void mouseDoubleClickEvent (CppInstancePtr @this, /*QMouseEvent */ IntPtr p); - [Virtual] void mouseMoveEvent (CppInstancePtr @this, /*QMouseEvent */ IntPtr p); - [Virtual] void wheelEvent (CppInstancePtr @this, /*QWheelEvent */ IntPtr p); - [Virtual] void keyPressEvent (CppInstancePtr @this, /*QKeyEvent */ IntPtr p); - [Virtual] void keyReleaseEvent (CppInstancePtr @this, /*QKeyEvent */ IntPtr p); - [Virtual] void focusInEvent (CppInstancePtr @this, /*QFocusEvent */ IntPtr p); - [Virtual] void focusOutEvent (CppInstancePtr @this, /*QFocusEvent */ IntPtr p); - [Virtual] void enterEvent (CppInstancePtr @this, /*QEvent */ IntPtr p); - [Virtual] void leaveEvent (CppInstancePtr @this, /*QEvent */ IntPtr p); - [Virtual] void paintEvent (CppInstancePtr @this, /*QPaintEvent */ IntPtr p); - [Virtual] void moveEvent (CppInstancePtr @this, /*QMoveEvent */ IntPtr p); - [Virtual] void resizeEvent (CppInstancePtr @this, /*QResizeEvent */ IntPtr p); - [Virtual] void closeEvent (CppInstancePtr @this, /*QCloseEvent */ IntPtr p); - [Virtual] void contextMenuEvent (CppInstancePtr @this, /*QContextMenuEvent */ IntPtr p); - [Virtual] void tabletEvent (CppInstancePtr @this, /*QTabletEvent */ IntPtr p); - [Virtual] void actionEvent (CppInstancePtr @this, /*QActionEvent */ IntPtr p); - [Virtual] void dragEnterEvent (CppInstancePtr @this, /*QDragEnterEvent */ IntPtr p); - [Virtual] void dragMoveEvent (CppInstancePtr @this, /*QDragMoveEvent */ IntPtr p); - [Virtual] void dragLeaveEvent (CppInstancePtr @this, /*QDragLeaveEvent */ IntPtr p); - [Virtual] void dropEvent (CppInstancePtr @this, /*QDropEvent */ IntPtr p); - [Virtual] void showEvent (CppInstancePtr @this, /*QShowEvent */ IntPtr p); - [Virtual] void hideEvent (CppInstancePtr @this, /*QHideEvent */ IntPtr p); - [Virtual] bool macEvent (CppInstancePtr @this, /*EventHandlerCallRef */ IntPtr p1, /*EventRef */ IntPtr p2); - [Virtual] void changeEvent (CppInstancePtr @this, /*QEvent */ IntPtr p); - // ... - [Virtual] void inputMethodEvent (CppInstancePtr @this, /*QInputMethodEvent */ IntPtr p); - - //public: - [Virtual] /*QVariant*/ IntPtr inputMethodQuery (CppInstancePtr @this, /*Qt::InputMethodQuery */ int x); - // ... protected: - [Virtual] bool focusNextPrevChild (CppInstancePtr @this, bool next); - - [Virtual] void styleChange (CppInstancePtr @this, IntPtr qStyle); // compat - [Virtual] void enabledChange (CppInstancePtr @this, bool arg); // compat - [Virtual] void paletteChange (CppInstancePtr @this, /*const QPalette &*/ IntPtr qPalette); // compat - [Virtual] void fontChange (CppInstancePtr @this, /*const QFont &*/ IntPtr qFont); // compat - [Virtual] void windowActivationChange (CppInstancePtr @this, bool arg); // compat - [Virtual] void languageChange(CppInstancePtr @this); // compat - } - // C++ fields - private struct _QWidget { - public IntPtr data; - } - #endregion - - private static IQWidget impl = Qt.Libs.QtGui.GetClass ("QWidget"); - - // TODO: ctor ... - - public QWidget (IntPtr native) : this () - { - Native = native; - } - - internal QWidget (CppTypeInfo subClass) : this () - { - subClass.AddBase (impl.TypeInfo); - } - - private QWidget () - : base (impl.TypeInfo) // Add QObject as base class - { - // FIXME: Hold on to this object and create methods for it on this class? - new QPaintDevice (impl.TypeInfo); // Add QPaintDevice as base class - } - - public bool Visible { - get { - throw new NotImplementedException (); - } - set { - //Debug.Assert (false, "Attach debugger now."); - impl.setVisible (Native, value); - } - } - - public void Resize (int width, int height) - { - QSize s = new QSize (width, height); - impl.resize (Native, ref s); - } - - public override void Dispose () - { - throw new NotImplementedException (); - } - - } -} - diff --git a/src/QtBindings/Libs.cs b/src/QtBindings/Libs.cs deleted file mode 100644 index a7c9cd32..00000000 --- a/src/QtBindings/Libs.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; - -using Mono.VisualC.Interop; -using Mono.VisualC.Interop.ABI; - -namespace Qt { - // Will be internal; public for testing - public static class Libs { - public static CppLibrary QtCore = null; - public static CppLibrary QtGui = null; - - static Libs () - { - string lib; - CppAbi abi; - if (Environment.OSVersion.Platform == PlatformID.Unix) { - lib = "{0}.so"; - abi = new ItaniumAbi (); - } else if (Environment.OSVersion.Platform == PlatformID.Win32NT) - { // for Windows... - lib = "{0}d4.dll"; - abi = new MsvcAbi (); - } else { // for Mac... - lib = "/Library/Frameworks/{0}.framework/Versions/Current/{0}"; - abi = new ItaniumAbi (); - } - - - QtCore = new CppLibrary (string.Format(lib, "QtCore"), abi); - QtGui = new CppLibrary (string.Format(lib, "QtGui"), abi); - } - } -} - diff --git a/src/QtBindings/Makefile.am b/src/QtBindings/Makefile.am deleted file mode 100644 index ab26871b..00000000 --- a/src/QtBindings/Makefile.am +++ /dev/null @@ -1,110 +0,0 @@ - -EXTRA_DIST = - -# Warning: This is an automatically generated file, do not edit! - -if ENABLE_DEBUG -ASSEMBLY_COMPILER_COMMAND = gmcs -ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -unsafe -warn:4 -optimize- -debug "-define:DEBUG" -ASSEMBLY = bin/Debug/QtBindings.dll -ASSEMBLY_MDB = $(ASSEMBLY).mdb -COMPILE_TARGET = library -PROJECT_REFERENCES = \ - ../Mono.VisualC.Interop/bin/Debug/Mono.VisualC.Interop.dll -BUILD_DIR = bin/Debug - -QTBINDINGS_DLL_CONFIG_SOURCE=QtBindings.dll.config -MONO_VISUALC_INTEROP_DLL_SOURCE=../Mono.VisualC.Interop/bin/Debug/Mono.VisualC.Interop.dll -MONO_VISUALC_INTEROP_DLL=$(BUILD_DIR)/Mono.VisualC.Interop.dll -QTBINDINGS_DLL_MDB_SOURCE=bin/Debug/QtBindings.dll.mdb -QTBINDINGS_DLL_MDB=$(BUILD_DIR)/QtBindings.dll.mdb -CPPINTEROP_DLL= - -endif - -if ENABLE_RELEASE -ASSEMBLY_COMPILER_COMMAND = gmcs -ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -unsafe -warn:4 -optimize- -ASSEMBLY = bin/Release/QtBindings.dll -ASSEMBLY_MDB = -COMPILE_TARGET = library -PROJECT_REFERENCES = \ - ../Mono.VisualC.Interop/bin/Release/CPPInterop.dll -BUILD_DIR = bin/Release - -QTBINDINGS_DLL_CONFIG_SOURCE=QtBindings.dll.config -MONO_VISUALC_INTEROP_DLL= -QTBINDINGS_DLL_MDB= -CPPINTEROP_DLL_SOURCE=../Mono.VisualC.Interop/bin/Release/CPPInterop.dll -CPPINTEROP_DLL=$(BUILD_DIR)/CPPInterop.dll - -endif - -AL=al2 -SATELLITE_ASSEMBLY_NAME=$(notdir $(basename $(ASSEMBLY))).resources.dll - -PROGRAMFILES = \ - $(QTBINDINGS_DLL_CONFIG) \ - $(MONO_VISUALC_INTEROP_DLL) \ - $(QTBINDINGS_DLL_MDB) \ - $(CPPINTEROP_DLL) - -LINUX_PKGCONFIG = \ - $(QTBINDINGS_PC) - - -RESGEN=resgen2 - -all: $(ASSEMBLY) $(PROGRAMFILES) $(LINUX_PKGCONFIG) - -FILES = \ - AssemblyInfo.cs \ - Libs.cs \ - Gui/QApplication.cs \ - Core/QGlobal.cs \ - Core/QCoreApplication.cs \ - Core/QObject.cs \ - Gui/QPushButton.cs \ - Gui/QPaintDevice.cs \ - Gui/QWidget.cs \ - Gui/QAbstractButton.cs \ - Core/QString.cs \ - Core/QSize.cs - -DATA_FILES = - -RESOURCES = - -EXTRAS = \ - QtBindings.dll.config \ - Gui \ - Core \ - qtbindings.pc.in - -REFERENCES = \ - System - -DLL_REFERENCES = - -CLEANFILES = $(PROGRAMFILES) $(LINUX_PKGCONFIG) - -include $(top_srcdir)/Makefile.include - -QTBINDINGS_DLL_CONFIG = $(BUILD_DIR)/QtBindings.dll.config -QTBINDINGS_PC = $(BUILD_DIR)/qtbindings.pc - -$(eval $(call emit-deploy-target,QTBINDINGS_DLL_CONFIG)) -$(eval $(call emit-deploy-target,MONO_VISUALC_INTEROP_DLL)) -$(eval $(call emit-deploy-wrapper,QTBINDINGS_PC,qtbindings.pc)) -$(eval $(call emit-deploy-target,CPPINTEROP_DLL)) - - -$(eval $(call emit_resgen_targets)) -$(build_xamlg_list): %.xaml.g.cs: %.xaml - xamlg '$<' - -$(ASSEMBLY_MDB): $(ASSEMBLY) - -$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) $(DLL_REFERENCES) $(PROJECT_REFERENCES) $(build_xamlg_list) $(build_satellite_assembly_list) - mkdir -p $(shell dirname $(ASSEMBLY)) - $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$(ASSEMBLY) -target:$(COMPILE_TARGET) $(build_sources_embed) $(build_resources_embed) $(build_references_ref) diff --git a/src/QtBindings/QtBindings.csproj b/src/QtBindings/QtBindings.csproj deleted file mode 100644 index 12ed80f4..00000000 --- a/src/QtBindings/QtBindings.csproj +++ /dev/null @@ -1,103 +0,0 @@ - - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {66212CA6-B8C2-4307-ADDE-DAFEAAB339B9} - Library - Qt - QtBindings - v3.5 - - - - - 2.0 - http://localhost/QtBindings/ - true - Web - true - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - true - false - true - - - - true - full - false - bin\Debug - DEBUG - prompt - 4 - false - true - AllRules.ruleset - - - none - false - bin\Release - prompt - 4 - false - true - AllRules.ruleset - - - - - - - - - - - - - - - - - - - - - {4A864586-93C5-4DC1-8A80-F094A88506D7} - Mono.VisualC.Interop - - - - - PreserveNewest - - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Windows Installer 3.1 - true - - - - \ No newline at end of file diff --git a/src/QtBindings/QtBindings.dll.config b/src/QtBindings/QtBindings.dll.config deleted file mode 100644 index 1d4e76db..00000000 --- a/src/QtBindings/QtBindings.dll.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/src/QtBindings/qtbindings.pc.in b/src/QtBindings/qtbindings.pc.in deleted file mode 100644 index 978d0379..00000000 --- a/src/QtBindings/qtbindings.pc.in +++ /dev/null @@ -1,6 +0,0 @@ -Name: QtBindings -Description: QtBindings -Version: 0.1 - -Requires: -Libs: -r:@expanded_libdir@/@PACKAGE@/QtBindings.dll diff --git a/src/qt/Makefile.am b/src/qt/Makefile.am deleted file mode 100644 index 0e60e972..00000000 --- a/src/qt/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ -top_srcdir = ../.. - -INTEROP_DLL = \ - $(top_srcdir)/bin/Debug/Mono.Cxxi.dll - -all: hello.exe - -qt-gui.xml: qt-gui.h - $(GCCXML) -fxml=$@ --gccxml-cxxflags "`pkg-config --cflags QtCore QtGui`" qt-gui.h - -generated: qt-gui.xml - $(RM) -r generated - $(MONO) --debug $(top_srcdir)/bin/Debug/generator.exe -o=generated -ns=Qt.Gui -lib=QtGui --filters=qt-gui-filters.txt qt-gui.xml - -#libQtGui-inline.so: qt-gui.cpp -# $(CXX) `pkg-config --cflags QtCore QtGui` --shared -fPIC -o $@ -fkeep-inline-functions qt-gui.cpp `pkg-config --libs QtCore QtGui` - -Qt.Gui-binding.dll: generated QString.cs - $(RM) -f generated/QString.cs - $(GMCS) -out:$@ -target:library -unsafe -r:$(INTEROP_DLL) generated/*.cs QString.cs - -hello.exe: Qt.Gui-binding.dll hello.cs #libQtGui-inline.so - $(GMCS) -out:$@ -target:exe -r:$(INTEROP_DLL) -r:Qt.Gui-binding.dll hello.cs - -clean: - $(RM) -rf generated hello.exe qt-gui.xml Qt.Gui-binding.dll libQtGui-inline.so - -run: hello.exe - MONO_PATH=$(top_srcdir)/bin/Debug $(MONO) hello.exe diff --git a/src/qt/hello.cs b/src/qt/hello.cs deleted file mode 100644 index 00a63e2d..00000000 --- a/src/qt/hello.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using Qt.Gui; - -using Mono.Cxxi; - -namespace QtTest { - class MainClass { - public static void Main (string[] args) - { - int argc = args.Length; - using (QApplication app = new QApplication (ref argc, args, 0x040602)) { - QPushButton hello = new QPushButton ("Hello", null); - hello.Resize (100, 30); - hello.Show (); - QApplication.Exec (); - } - } - } -} - diff --git a/src/qt/qt-gui.h b/src/qt/qt-gui.h deleted file mode 100644 index 7f769651..00000000 --- a/src/qt/qt-gui.h +++ /dev/null @@ -1,2 +0,0 @@ -#include -#include