Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Component.cs « libsteticui « stetic « lib « MonoDevelop.GtkCore « Extras - github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1a1d495ccf796dbdcab458c32b7197c5c1046321 (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

using System;
using System.Collections;

namespace Stetic
{
	public class Component: MarshalByRefObject, IObjectFrontend
	{
		protected string name;
		protected ComponentType type;
		protected string typeName;
		protected object backend;
		protected Application app;
		
		public event EventHandler Changed;

		internal Component (Application app, object backend, string name, ComponentType type)
		{
			this.app = app;
			this.backend = backend;
			this.name = name;
			this.type = type;
		}
		
		public virtual void Dispose ()
		{
			System.Runtime.Remoting.RemotingServices.Disconnect (this);
			if (app != null)
				app.DisposeComponent (this);
		}
		
		public SignalCollection GetSignals ()
		{
			if (backend is ObjectWrapper)
				return ((ObjectWrapper)backend).Signals;
			else
				return new SignalCollection ();
		}
		
		public void RemoveSignal (Signal signal)
		{
			if (backend is ObjectWrapper && app != null)
				app.Backend.RemoveWidgetSignal ((ObjectWrapper) backend, signal);
		}
		
		public virtual Component[] GetChildren ()
		{
			return new Component [0];
		}
		
		void IObjectFrontend.NotifyChanged ()
		{
			OnChanged ();
		}
		
		protected virtual void OnChanged ()
		{
			if (Changed != null)
				Changed (this, EventArgs.Empty);
		}
		
		public virtual string Name {
			get { return name; }
			set { name = value; }
		}

		public virtual ComponentType Type {
			get {
				return type;
			}
		}
		
		public virtual bool GeneratePublic {
			get { return true; }
			set {}
		}
		
		internal object Backend {
			get { return backend; }
		}
		
		internal static MarshalByRefObject GetSafeReference (MarshalByRefObject ob)
		{
			// Make sure we don't leak the wrapper type to the frontend process
			
			if (ob is Wrapper.Window) {
				System.Runtime.Remoting.RemotingServices.Marshal (ob, null, typeof(Wrapper.Window));
			} else if (ob is Wrapper.Container) {
				System.Runtime.Remoting.RemotingServices.Marshal (ob, null, typeof(Wrapper.Container));
			} else if (ob is Wrapper.Widget) {
				System.Runtime.Remoting.RemotingServices.Marshal (ob, null, typeof(Wrapper.Widget));
			} else if (ob is ObjectWrapper) {
				System.Runtime.Remoting.RemotingServices.Marshal (ob, null, typeof(ObjectWrapper));
			}
			return ob;
		}
		
		public override string ToString ()
		{
			return base.ToString() + " " + backend;
		}
		
		public ObjectBindInfo[] GetObjectBindInfo ()
		{
			ObjectWrapper ww = backend as ObjectWrapper;
			if (ww != null)
				return app.Backend.GetBoundComponents (ww);
			else
				return new ObjectBindInfo [0];
		}
	}
}