copying the latest Sys.Web.Services from trunk.
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls.WebParts / WebPart.cs
1 //
2 // System.Web.UI.WebControls.WebParts.Part.cs
3 //
4 // Authors:
5 //   Gaurav Vaish (gaurav[DOT]vaish[AT]gmail[DOT]com)
6 //   Sanjay Gupta (gsanjay@novell.com)
7 //
8 // (C) 2004 Gaurav Vaish (http://www.mastergaurav.org)
9 // (C) 2004 Novell Inc., (http://www.novell.com)
10 //
11
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 //
32
33 #if NET_2_0
34
35 using System;
36 using System.ComponentModel;
37 using System.Web;
38 using System.Web.UI.WebControls;
39
40 namespace System.Web.UI.WebControls.WebParts
41 {
42         [DesignerAttribute ("System.Web.UI.Design.WebControls.WebParts.WebPartDesigner, System.Design", 
43                 "System.ComponentModel.Design.IDesigner")]                      
44         public class WebPart : Part, IWebPart, IWebActionable
45         {
46                 private bool allowClose      = true;
47                 private bool allowEdit       = true;
48                 private bool allowHide       = true;
49                 private bool allowMinimize   = true;
50                 private bool allowZoneChange = true;
51                 private bool allowHelp       = true;
52
53                 private bool isStatic = true;
54                 private bool isStandalone = true;
55                 private bool isClosed = true;
56
57                 private PartChromeState chromeState = PartChromeState.Normal;
58                 private PartChromeType chromeType = PartChromeType.Default;
59                 private WebPartExportMode exportMode = WebPartExportMode.None;
60                 private WebPartHelpMode   helpMode   = WebPartHelpMode.Navigate;
61
62                 private string subtitle;
63                 private string catalogIconImageUrl;
64                 private string description;
65                 private string titleIconImageUrl;
66                 private string title;
67                 private string titleUrl;
68                 private WebPartVerbCollection verbCollection;
69                 
70                 protected WebPart()
71                 {
72                 }
73                 
74                 [WebSysDescriptionAttribute ("Determines Whether the Web Part can be closed."),
75                 DefaultValueAttribute (true), WebCategoryAttribute ("Behavior of Web Part")]
76                 //, PersonalizableAttribute 
77                 public virtual bool AllowClose {
78                         get { return allowClose; }
79                         set { allowClose = value; }
80                 }
81
82                 [WebSysDescriptionAttribute ("Determines Whether properties of the Web Part can be changed using the EditorZone."),
83                 DefaultValueAttribute (true), WebCategoryAttribute ("Behavior of Web Part")]
84                 //, PersonalizableAttribute 
85                 public virtual bool AllowEdit {
86                         get { return allowEdit; }
87                         set { allowEdit = value; }
88                 }
89
90                 [WebSysDescriptionAttribute ("Determines Whether properties of the Web Part can be changed using the EditorZone."),
91                 DefaultValueAttribute (true), WebCategoryAttribute ("Behavior of Web Part")]
92                 //, PersonalizableAttribute 
93                 public virtual bool AllowHelp {
94                         get { return AllowHelp; }
95                         set { allowHelp = value; }
96                 }
97
98                 [WebSysDescriptionAttribute ("Determines Whether the Web Part can be minimized."),
99                 DefaultValueAttribute (true), WebCategoryAttribute ("Behavior of Web Part")]
100                 //, PersonalizableAttribute 
101                 public virtual bool AllowMinimize {
102                         get { return allowMinimize; }
103                         set { allowMinimize = value; }
104                 }
105
106                 [WebSysDescriptionAttribute ("Determines Whether the Web Part can be moved to some other zone."),
107                 DefaultValueAttribute (true), WebCategoryAttribute ("Behavior of Web Part")]
108                 //, PersonalizableAttribute 
109                 public virtual bool AllowZoneChange {
110                         get { return allowZoneChange; }
111                         set { allowZoneChange = value; }
112                 }
113
114                 [BrowsableAttribute (false), 
115                 DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
116                 public bool IsClosed {
117                         get { return isClosed; }
118                 }
119
120                 [BrowsableAttribute (false),
121                 DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
122                 public bool IsStandalone
123                 {
124                         get { return isStandalone; }
125                 }
126                 
127                 //[PersonalizableAttribute ]
128                 public override PartChromeState ChromeState {
129                         get { return chromeState; }
130                         set {
131                                 if(!Enum.IsDefined (typeof (PartChromeState), value))
132                                         throw new ArgumentException ("value");
133                                 chromeState = value;
134                         }
135                 }
136                 
137                 //[PersonalizableAttribute ]
138                 public override PartChromeType ChromeType {
139                         get { return chromeType; }
140                         set {
141                                 if(!Enum.IsDefined (typeof (PartChromeType), value))
142                                         throw new ArgumentException ("value");
143                                 chromeType = value;
144                         }
145                 }
146
147                 [BrowsableAttribute (false), 
148                 DesignerSerializationVisibilityAttribute (System.ComponentModel.DesignerSerializationVisibility.Hidden),
149                 LocalizableAttribute (true)]                    
150                 string IWebPart.Subtitle { 
151                         get { return subtitle; }
152                 }
153         
154                 [DefaultValueAttribute (""), 
155                 EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, System.Design", 
156                                 "System.Drawing.Design.UITypeEditor, System.Drawing") , 
157                 WebCategoryAttribute ("Appearance of the Web Part"),
158                 WebSysDescriptionAttribute ("Specifies URL of image which is displayed in WebPart's Catalog.")]
159                 //UrlPropertyAttribute, PersonalizableAttribute
160                 string IWebPart.CatalogIconImageUrl { 
161                         get { return catalogIconImageUrl; }
162                         set { catalogIconImageUrl = value; }
163                 }
164
165                 string IWebPart.Description { 
166                         get { return description; }
167                         set { description = value; }
168                 }
169
170                 string IWebPart.Title { 
171                         get { return title; }
172                         set { title = value; }
173                 }
174
175                 [DefaultValueAttribute (""),
176                 EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, System.Design",
177                                 "System.Drawing.Design.UITypeEditor, System.Drawing"),
178                 WebCategoryAttribute ("Appearance of the Web Part"),
179                 WebSysDescriptionAttribute ("Specifies URL of image which is displayed in WebPart's title bar.")]
180                 //UrlPropertyAttribute, PersonalizableAttribute
181                 string IWebPart.TitleIconImageUrl
182                 {
183                         get { return titleIconImageUrl; }
184                         set { titleIconImageUrl = value; }
185                 }
186
187                 [DefaultValueAttribute (""),
188                 EditorAttribute ("System.Web.UI.Design.UrlEditor, System.Design",
189                                 "System.Drawing.Design.UITypeEditor, System.Drawing"),
190                 WebCategoryAttribute ("Behavior of the Web Part"),
191                 WebSysDescriptionAttribute ("Specifies URL of page, containing additional information about this WebPart.")]
192                 //UrlPropertyAttribute, PersonalizableAttribute
193                 string IWebPart.TitleUrl { 
194                         get { return titleUrl; }
195                         set { titleUrl = value; }
196                 }
197
198                 [BrowsableAttribute (false),
199                 DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
200                 WebPartVerbCollection IWebActionable.Verbs {
201                         get {
202                                 if (verbCollection == null) {
203                                         verbCollection = new WebPartVerbCollection ();
204                                 }
205                                 return verbCollection;
206                         }
207                 }
208         }
209 }
210 #endif