Panel.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. //
  2. // System.Web.UI.WebControls.Panel.cs
  3. //
  4. // Authors:
  5. // Ben Maurer ([email protected])
  6. //
  7. // (C) 2005 Novell, Inc (http://www.novell.com)
  8. //
  9. // TODO: Are we missing something in LoadViewState?
  10. // What to do in AddParsedSubObject
  11. //
  12. // Permission is hereby granted, free of charge, to any person obtaining
  13. // a copy of this software and associated documentation files (the
  14. // "Software"), to deal in the Software without restriction, including
  15. // without limitation the rights to use, copy, modify, merge, publish,
  16. // distribute, sublicense, and/or sell copies of the Software, and to
  17. // permit persons to whom the Software is furnished to do so, subject to
  18. // the following conditions:
  19. //
  20. // The above copyright notice and this permission notice shall be
  21. // included in all copies or substantial portions of the Software.
  22. //
  23. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  27. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  28. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  29. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  30. //
  31. using System.ComponentModel;
  32. namespace System.Web.UI.WebControls {
  33. [Designer ("System.Web.UI.Design.WebControls.PanelDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
  34. [ParseChildren (false)]
  35. [PersistChildren (true)]
  36. [ToolboxData ("<{0}:Panel runat=server>Panel</{0}:Panel>")]
  37. public class Panel : WebControl {
  38. public Panel () : base (HtmlTextWriterTag.Div)
  39. {
  40. }
  41. protected override void AddAttributesToRender (HtmlTextWriter w)
  42. {
  43. base.AddAttributesToRender (w);
  44. if (BackImageUrl != "")
  45. w.AddStyleAttribute (HtmlTextWriterStyle.BackgroundImage, BackImageUrl);
  46. if (!Wrap) {
  47. #if NET_2_0
  48. w.AddStyleAttribute (HtmlTextWriterStyle.WhiteSpace, "nowrap");
  49. #else
  50. w.AddAttribute (HtmlTextWriterAttribute.Nowrap, "nowrap");
  51. #endif
  52. }
  53. string align = "";
  54. switch (HorizontalAlign) {
  55. case HorizontalAlign.Center: align = "center"; break;
  56. case HorizontalAlign.Justify: align = "justify"; break;
  57. case HorizontalAlign.Left: align = "left"; break;
  58. case HorizontalAlign.Right: align = "right"; break;
  59. }
  60. if (align != "")
  61. w.AddAttribute (HtmlTextWriterAttribute.Align, align);
  62. }
  63. [Bindable(true)]
  64. [DefaultValue("")]
  65. [Editor("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
  66. [WebSysDescription ("")]
  67. [WebCategory ("Appearance")]
  68. public virtual string BackImageUrl {
  69. get {
  70. return ViewState.GetString ("BackImageUrl", "");
  71. }
  72. set {
  73. ViewState ["BackImageUrl"] = value;
  74. }
  75. }
  76. [Bindable(true)]
  77. [DefaultValue(HorizontalAlign.NotSet)]
  78. [WebSysDescription ("")]
  79. [WebCategory ("Layout")]
  80. public virtual HorizontalAlign HorizontalAlign {
  81. get {
  82. return (HorizontalAlign) ViewState.GetInt ("HorizontalAlign", (int) HorizontalAlign.NotSet);
  83. }
  84. set {
  85. ViewState ["HorizontalAlign"] = (int) value;
  86. }
  87. }
  88. [Bindable(true)]
  89. [DefaultValue(true)]
  90. [WebSysDescription ("")]
  91. [WebCategory ("Layout")]
  92. public virtual bool Wrap {
  93. get {
  94. return ViewState.GetBool ("Wrap", true);
  95. }
  96. set {
  97. ViewState ["Wrap"] = value;
  98. }
  99. }
  100. }
  101. }