summaryrefslogtreecommitdiffstats
path: root/qtsharp/src/bindings/static/TQObject.cs
blob: 1ef8c3543e16a960e578583a8adea7e81d7f1ed6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
// TQObject.cs - A Qt to C# binding.
//
// Copyright (C) 2002  Adam Treat ([email protected])
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
//
// Regenerated by Adam Treat on August 30 2002
//
// NOTES
// o Methods related to Qt reflection have been marked internal. Most of them
//   should eventually be throttled, and this file regenerated
// o Some event-related methods are also marked internal. I don't think we use
//   any of them, they can likely be throttled.
//
// TODO
// o Should use children() in object tree tracking for constructing
//   complete tree representations.

namespace Qt {

    using Qt;
    using System;
	using System.Collections;
    using System.Runtime.InteropServices;

	//[DeclareQtSignal ("ChildDestroyed(TQObject)")]
    public class TQObject : QtSupport, IDisposable {

		// Hold an instance of the TQApplication object
		private static TQApplication qapp;
		private QtSignalMap csSignalMap;
		private QtSignalMap cppSignalMap;

		public static TQApplication tqApp {
			get {return qapp;}
			set {qapp = value;}
		}

		internal QtSignalMap CsSignalMap {
			get { return csSignalMap; }
		}

		internal QtSignalMap CppSignalMap {
			get { return cppSignalMap; }
		}

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern IntPtr qt_new_QObject (IntPtr parent, string name);
        public TQObject (TQObject parent, string name) : this (TQNull.Instance)
        {
			qparent = parent;

			if (qparent == null)
				parent = new TQWidget (IntPtr.Zero);
			else
				qparent.AddChild (this);

			rawObject = qt_new_QObject (parent.RawObject, name);
            RegisterObject (this);
		}

        public TQObject (TQObject parent) : this (parent, "") {}

		internal TQObject () : this (TQNull.Instance) {}

        internal TQObject (IntPtr ptr) : this (TQNull.Instance)
        {
            rawObject = ptr;
            RegisterObject (this);
        }

		internal TQObject (TQNull dummy) : base (TQNull.Instance)
		{
			InitSignals ();
		}

		// FIXME This ctor used only by QtSignal
		internal TQObject (NoSignalInit dummy) : base (TQNull.Instance)
		{
			rawObject = qt_new_QObject (IntPtr.Zero, "");
			RegisterObject (this);
		}

        ~TQObject ()
        {
            Dispose(false);
        }

		protected override void Dispose (bool disposeManaged)
		{
			if (disposed)
				return;

			if (rawObject == IntPtr.Zero)
				deleted = true;

			if (disposeManaged) {
				disposed = true;

				UnregisterObject (this);

				if (qparent != null ) {
					if (qparent.Disposed)
						deleted = true;
					else
						qparent.RemoveChild (this);
				}

				Disconnect ();

				foreach (QtSupport qts in qchildren)
					qts.Dispose ();

				// UnregisterObject (); // FIXME
			}

			/*
			DbgMsg ("({0}) {1}:: {2} managed. {3} native instance.",
				deleted ? IntPtr.Zero : rawObject,
				this,
				disposeManaged ? "Disposing" : "Not disposing",
				deleted ? "Not deleting" : "Deleting");
			*/

			qparent = null;
			qchildren = null;

			Delete ();
		}

		[DllImport("libqtc", CharSet=CharSet.Ansi)]
		private static extern void qt_del_QObject (IntPtr obj);
		internal override void Delete ()
		{
			if (deleted) return;

			qt_del_QObject (rawObject);
			deleted = true;
		}

		private void InitSignals ()
		{
			csSignalMap = new QtSignalMap (this, "C# Signals");
			cppSignalMap = new QtSignalMap (this, "C++ Signals");

			object[] attrs = GetType ().GetCustomAttributes (typeof (DeclareQtSignalAttribute), true);

			foreach (DeclareQtSignalAttribute attr in attrs) {
				string signal = attr.SignalName;

				if (!CsSignalMap.Contains (signal))
					CsSignalMap[signal] = new QtSignal (this, signal);
			}
		}

		// [QtSlot]
		internal protected void NativeDestroyed ()
		{
			deleted = true;
			Dispose ();
		}

		public TQObject QtCast()
		{
			string QtType = this.ClassName();
			Type newType = Type.GetType( "Qt." + QtType );
			object[] paramArray = { this.RawObject };
			return (TQObject) Activator.CreateInstance( newType, paramArray );
		}

		public static bool Connect(TQObject sender, string signal, TQObject receiver, string slot)
		{
			return QtSignal.Connect(sender, signal, receiver, slot);
		}

		public bool Connect (TQObject sender, string signal, string member)
		{
			return Connect (sender, signal, this, member);
		}

		public static bool Disconnect(TQObject sender, string signal, TQObject receiver, string slot)
		{
			return QtSignal.Disconnect(sender, signal, receiver, slot);
		}

		public bool Disconnect ()
		{
			return Disconnect (this, null, null, null);
		}

		public bool Disconnect (string signal, TQObject receiver, string member)
		{
			return Disconnect(this, signal, receiver, member);
		}

		public bool Disconnect (TQObject receiver, string slot)
		{
			return Disconnect (this, null, receiver, slot);
		}

		public void Emit (string signal, params object[] args)
		{
			string sig = signal.Replace (" ", "");

			if (CsSignalMap.Contains (sig))
				CsSignalMap[sig].Emit (args);
			else
				throw new ArgumentException (this+" does not emit requested signal '"+sig+"'");
		}

		public void DumpConnections()
		{
			ErrMsg ("** ({0}) {1}: Dumping '{2}' map.", rawObject, this, CsSignalMap.Name);
			CsSignalMap.DumpMap ();

			ErrMsg ("** ({0}) {1}: Dumping '{2}' map.", rawObject, this, CppSignalMap.Name);
			CppSignalMap.DumpMap ();
		}

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern string qt_QObject_className (IntPtr raw);
        public string ClassName ()
        {
            return qt_QObject_className (rawObject);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern IntPtr qt_QObject_tr (IntPtr raw, string arg1, string arg2);
        public string Tr (string arg1, string arg2)
        {
			TQString qstr = new TQString (qt_QObject_tr (rawObject, arg1, arg2));
			string str = qstr.Latin1 ();
			qstr.Dispose ();
			return str;
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern IntPtr qt_QObject_trUtf8 (IntPtr raw, string arg1, string arg2);
        public string TrUtf8 (string arg1, string arg2)
        {
			TQString qstr = new TQString (qt_QObject_trUtf8 (rawObject, arg1, arg2));
			string str = qstr.Latin1 ();
			qstr.Dispose ();
			return str;
		}

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern IntPtr qt_QObject_metaObject (IntPtr raw);
        public TQMetaObject MetaObject ()
        {
            return (TQMetaObject)LookupObject (qt_QObject_metaObject (rawObject), typeof(TQMetaObject));
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern bool qt_QObject_event (IntPtr raw, IntPtr arg1);
        public bool Q_event (TQEvent arg1)
        {
            return qt_QObject_event (rawObject, arg1.RawObject);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern bool qt_QObject_eventFilter (IntPtr raw, IntPtr arg1, IntPtr arg2);
        public bool EventFilter (TQObject arg1, TQEvent arg2)
        {
            return qt_QObject_eventFilter (rawObject, arg1.RawObject, arg2.RawObject);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern bool qt_QObject_isA (IntPtr raw, string arg1);
        public bool IsA (string arg1)
        {
            return qt_QObject_isA (rawObject, arg1);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern bool qt_QObject_inherits (IntPtr raw, string arg1);
        public bool Inherits (string arg1)
        {
            return qt_QObject_inherits (rawObject, arg1);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern string qt_QObject_name (IntPtr raw);
        public string Name ()
        {
            return qt_QObject_name (rawObject);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern string qt_QObject_name1 (IntPtr raw, string defaultName);
        public string Name (string defaultName)
        {
            return qt_QObject_name1 (rawObject, defaultName);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern void qt_QObject_setName (IntPtr raw, string name);
        public void SetName (string name)
        {
            qt_QObject_setName (rawObject, name);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern bool qt_QObject_isWidgetType (IntPtr raw);
        public bool IsWidgetType ()
        {
            return qt_QObject_isWidgetType (rawObject);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern bool qt_QObject_highPriority (IntPtr raw);
        public bool HighPriority ()
        {
            return qt_QObject_highPriority (rawObject);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern bool qt_QObject_signalsBlocked (IntPtr raw);
        public bool SignalsBlocked ()
        {
            return qt_QObject_signalsBlocked (rawObject);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern void qt_QObject_blockSignals (IntPtr raw, bool b);
        public void BlockSignals (bool b)
        {
            qt_QObject_blockSignals (rawObject, b);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern int qt_QObject_startTimer (IntPtr raw, int interval);
        public int StartTimer (int interval)
        {
            return qt_QObject_startTimer (rawObject, interval);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern void qt_QObject_killTimer (IntPtr raw, int identifier);
        public void KillTimer (int identifier)
        {
            qt_QObject_killTimer (rawObject, identifier);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern void qt_QObject_killTimers (IntPtr raw);
        public void KillTimers ()
        {
            qt_QObject_killTimers (rawObject);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern IntPtr qt_QObject_child (IntPtr raw, string objName, string inheritsClass, bool recursiveSearch);
        public TQObject Child (string objName, string inheritsClass, bool recursiveSearch)
        {
			return (TQObject)LookupObject (qt_QObject_child (rawObject, objName, inheritsClass, recursiveSearch), typeof(TQObject));
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern IntPtr qt_QObject_children (IntPtr raw);
        public TQObjectList Children ()
        {
            return (TQObjectList)LookupObject (qt_QObject_children (rawObject), typeof(TQObjectList));
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern IntPtr qt_QObject_queryList (IntPtr raw, string inheritsClass, string objName, bool regexpMatch, bool recursiveSearch);
        public TQObjectList QueryList (string inheritsClass, string objName, bool regexpMatch, bool recursiveSearch)
        {
            return (TQObjectList)LookupObject (qt_QObject_queryList (rawObject, inheritsClass, objName, regexpMatch, recursiveSearch), typeof(TQObjectList));
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern void qt_QObject_insertChild (IntPtr raw, IntPtr arg1);
        public void InsertChild (TQObject arg1)
        {
            qt_QObject_insertChild (rawObject, arg1.RawObject);
        }

        /*[DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern void qt_QObject_removeChild (IntPtr raw, IntPtr arg1);
        public void RemoveChild (TQObject arg1)
        {
            qt_QObject_removeChild (rawObject, arg1.RawObject);
        }*/

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern void qt_QObject_installEventFilter (IntPtr raw, IntPtr arg1);
        public void InstallEventFilter (TQObject arg1)
        {
            qt_QObject_installEventFilter (rawObject, arg1.RawObject);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern void qt_QObject_removeEventFilter (IntPtr raw, IntPtr arg1);
        public void RemoveEventFilter (TQObject arg1)
        {
            qt_QObject_removeEventFilter (rawObject, arg1.RawObject);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern void qt_QObject_dumpObjectTree (IntPtr raw);
        public void DumpObjectTree ()
        {
            qt_QObject_dumpObjectTree (rawObject);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern void qt_QObject_dumpObjectInfo (IntPtr raw);
        public void DumpObjectInfo ()
        {
            qt_QObject_dumpObjectInfo (rawObject);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern bool qt_QObject_setProperty (IntPtr raw, string name, IntPtr value);
        public bool SetProperty (string name, TQVariant value)
        {
            return qt_QObject_setProperty (rawObject, name, value.RawObject);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern IntPtr qt_QObject_property (IntPtr raw, string name);
        public TQVariant Property (string name)
        {
            return (TQVariant)LookupObject (qt_QObject_property (rawObject, name), typeof(TQVariant));
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern IntPtr qt_QObject_parent (IntPtr raw);
        public TQObject Parent ()
        {
            return (TQObject)LookupObject (qt_QObject_parent (rawObject), typeof(TQObject));
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern void qt_QObject_deleteLater (IntPtr raw);
        public void DeleteLater ()
        {
            qt_QObject_deleteLater (rawObject);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern IntPtr qt_QObject_objectTrees ();
        public static TQObjectList ObjectTrees ()
        {
            return (TQObjectList)LookupObject (qt_QObject_objectTrees (), typeof(TQObjectList));
        }

		/*FIXME
        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern void qt_QObject_connectInternal (IntPtr sender, int signal_index, IntPtr receiver, int membcode, int member_index);
        public static void ConnectInternal (TQObject sender, int signal_index, TQObject receiver, int membcode, int member_index)
        {
            qt_QObject_connectInternal (sender.RawObject, signal_index, receiver.RawObject, membcode, member_index);
        }
		*/

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern bool qt_QObject_activate_filters (IntPtr raw, IntPtr arg1);
        protected bool Activate_filters (TQEvent arg1)
        {
            return qt_QObject_activate_filters (rawObject, arg1.RawObject);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern IntPtr qt_QObject_receivers (IntPtr raw, string signal);
        protected TQConnectionList Receivers (string signal)
        {
            return (TQConnectionList)LookupObject (qt_QObject_receivers (rawObject, signal), typeof(TQConnectionList));
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern IntPtr qt_QObject_receivers1 (IntPtr raw, int signal);
        protected TQConnectionList Receivers (int signal)
        {
            return (TQConnectionList)LookupObject (qt_QObject_receivers1 (rawObject, signal), typeof(TQConnectionList));
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern void qt_QObject_activate_signal (IntPtr raw, int signal);
        protected void Activate_signal (int signal)
        {
            qt_QObject_activate_signal (rawObject, signal);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern void qt_QObject_activate_signal1 (IntPtr raw, int signal, int arg1);
        protected void Activate_signal (int signal, int arg1)
        {
            qt_QObject_activate_signal1 (rawObject, signal, arg1);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern void qt_QObject_activate_signal2 (IntPtr raw, int signal, double arg1);
        protected void Activate_signal (int signal, double arg1)
        {
            qt_QObject_activate_signal2 (rawObject, signal, arg1);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern void qt_QObject_activate_signal3 (IntPtr raw, int signal, IntPtr arg1);
        protected void Activate_signal (int signal, string arg1)
        {
            qt_QObject_activate_signal3 (rawObject, signal, new TQString (arg1).RawObject);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern void qt_QObject_activate_signal_bool (IntPtr raw, int signal, bool arg1);
        protected void Activate_signal_bool (int signal, bool arg1)
        {
            qt_QObject_activate_signal_bool (rawObject, signal, arg1);
        }

		/*
        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern void qt_QObject_activate_signal4 (IntPtr raw, IntPtr clist, IntPtr o);
        protected void Activate_signal (TQConnectionList clist, IntPtr o)
        {
            qt_QObject_activate_signal4 (rawObject, clist.RawObject, o);
        }
		*/

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern IntPtr qt_QObject_sender (IntPtr raw);
        protected TQObject Sender ()
        {
            return (TQObject)LookupObject (qt_QObject_sender (rawObject), typeof(TQObject));
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern void qt_QObject_connectNotify (IntPtr raw, string signal);
        protected void ConnectNotify (string signal)
        {
            qt_QObject_connectNotify (rawObject, signal);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern void qt_QObject_disconnectNotify (IntPtr raw, string signal);
        protected void DisconnectNotify (string signal)
        {
            qt_QObject_disconnectNotify (rawObject, signal);
        }

        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern bool qt_QObject_checkConnectArgs (IntPtr raw, string signal, IntPtr receiver, string member);
        protected bool CheckConnectArgs (string signal, TQObject receiver, string member)
        {
            return qt_QObject_checkConnectArgs (rawObject, signal, receiver.RawObject, member);
        }

		/*
        [DllImport("libqtc", CharSet=CharSet.Ansi)]
        private static extern IntPtr qt_QObject_normalizeSignalSlot (string signalSlot);
        protected static TQCString NormalizeSignalSlot (string signalSlot)
        {
            return (TQCString)LookupObject (qt_QObject_normalizeSignalSlot (signalSlot), typeof(TQCString));
        }
		*/

        public TQObject Child (string objName)
        {
            return Child(objName, null);
        }

        public TQObject Child (string objName, string inheritsClass)
        {
            return Child(objName, inheritsClass, true);
        }

        public TQObjectList QueryList ()
        {
            return QueryList("");
        }

        public TQObjectList QueryList (string inheritsClass)
        {
            return QueryList(inheritsClass, "");
        }

        public TQObjectList QueryList (string inheritsClass, string objName)
        {
            return QueryList(inheritsClass, objName, true);
        }

        public TQObjectList QueryList (string inheritsClass, string objName, bool regexpMatch)
        {
            return QueryList(inheritsClass, objName, regexpMatch, true);
        }
    }

	// FIXME Used only by QtSignal
	internal class NoSignalInit
	{
		public static readonly NoSignalInit Instance = new NoSignalInit ();
	}
}