[jit] Enable partial generic sharing when not using AOT as an experiment.
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms.Design / ComponentEditorPage.cs
1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
8 // 
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 // 
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 //
20 // Copyright (c) 2004 Novell, Inc.
21 //
22 // Authors:
23 //      Andreas Nahr    (ClassDevelopment@A-SoftTech.com)
24 //
25
26 using System.ComponentModel;
27 using System.Drawing;
28 using System.Runtime.InteropServices;
29
30 namespace System.Windows.Forms.Design
31 {
32         [ClassInterfaceAttribute (ClassInterfaceType.AutoDispatch)]
33         [ComVisible (true)]
34         public abstract class ComponentEditorPage : Panel
35         {
36                 private bool commitOnDeactivate = false;
37                 private IComponent component;
38                 private bool firstActivate = true;
39                 private Icon icon;
40                 private int loading = 0;
41                 private bool loadRequired = false;
42                 private IComponentEditorPageSite pageSite;
43
44                 public ComponentEditorPage ()
45                 {
46                 }
47
48                 [Browsable (false)]
49                 [EditorBrowsable (EditorBrowsableState.Never)]
50                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
51                 new public virtual bool AutoSize {
52                         get { return base.AutoSize; }
53                         set { base.AutoSize = value; }
54                 }
55
56                 public bool CommitOnDeactivate
57                 {
58                         get { return commitOnDeactivate; }
59                         set { commitOnDeactivate = value; }
60                 }
61
62                 protected IComponent Component {
63                         get { return component; }
64                         set { component = value; }
65                 }
66
67                 [MonoTODO ("Find out what this does.")]
68                 protected override CreateParams CreateParams {
69                         get {
70                                 throw new NotImplementedException ();
71                         }
72                 }
73
74                 protected bool FirstActivate {
75                         get { return firstActivate; }
76                         set { firstActivate = value; }
77                 }
78
79                 public Icon Icon {
80                         get { return icon; }
81                         set { icon = value; }
82                 }
83
84                 protected int Loading {
85                         get { return loading; }
86                         set { loading = value; }
87                 }
88
89                 protected bool LoadRequired {
90                         get { return loadRequired; }
91                         set { loadRequired = value; }
92                 }
93
94                 protected IComponentEditorPageSite PageSite {
95                         get { return pageSite; }
96                         set { pageSite = value; }
97                 }
98
99                 public virtual string Title {
100                         get { return base.Text; }
101                 }
102
103                 public virtual void Activate ()
104                 {
105                         Visible = true;
106                         firstActivate = false;
107                         if (loadRequired) {
108                                 EnterLoadingMode ();
109                                 LoadComponent ();
110                                 ExitLoadingMode ();
111                         }
112                 }
113
114                 public virtual void ApplyChanges ()
115                 {
116                         SaveComponent ();
117                 }
118
119                 public virtual void Deactivate ()
120                 {
121                         Visible = false;
122                 }
123
124                 protected void EnterLoadingMode ()
125                 {
126                         loading++;
127                 }
128
129                 protected void ExitLoadingMode ()
130                 {
131                         loading--;
132                 }
133
134                 public virtual Control GetControl ()
135                 {
136                         return this;
137                 }
138
139                 protected IComponent GetSelectedComponent ()
140                 {
141                         return component;
142                 }
143
144                 protected bool IsFirstActivate ()
145                 {
146                         return firstActivate;
147                 }
148
149                 protected bool IsLoading ()
150                 {
151                         return (loading != 0);
152                 }
153
154                 public virtual bool IsPageMessage (ref Message msg)
155                 {
156                         return PreProcessMessage (ref msg);
157                 }
158
159                 protected abstract void LoadComponent ();
160
161                 [MonoTODO ("Find out what this does.")]
162                 public virtual void OnApplyComplete ()
163                 {
164                 }
165
166                 protected virtual void ReloadComponent ()
167                 {
168                         loadRequired = true;
169                 }
170
171                 protected abstract void SaveComponent ();
172
173                 public virtual void SetComponent (IComponent component)
174                 {
175                         this.component = component;
176                         ReloadComponent ();
177                 }
178
179                 [MonoTODO ("Find out what this does.")]
180                 protected virtual void SetDirty ()
181                 {
182                 }
183
184                 public virtual void SetSite (IComponentEditorPageSite site)
185                 {
186                         pageSite = site;
187                         pageSite.GetControl ().Controls.Add (this);
188
189                 }
190
191                 public virtual void ShowHelp ()
192                 {
193                 }
194
195                 public virtual bool SupportsHelp ()
196                 {
197                         return false;
198                 }
199
200                 #region Public Events
201                 [Browsable (false)]
202                 [EditorBrowsable (EditorBrowsableState.Never)]
203                 public new event EventHandler AutoSizeChanged {
204                         add { base.AutoSizeChanged += value; }
205                         remove { base.AutoSizeChanged -= value; }
206                 }
207                 #endregion
208         }
209 }