PanelStyle.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. //
  2. // System.Web.UI.WebControls.MenuItemStyle.cs
  3. //
  4. // Authors:
  5. // Igor Zelmanovich ([email protected])
  6. //
  7. // (C) 2007 Mainsoft, Inc (http://www.mainsoft.com)
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  29. //
  30. #if NET_2_0
  31. using System;
  32. using System.Web.UI;
  33. using System.ComponentModel;
  34. namespace System.Web.UI.WebControls
  35. {
  36. public class PanelStyle : Style
  37. {
  38. [Flags]
  39. enum PanelStyles
  40. {
  41. BackImageUrl = 0x00010000,
  42. Direction = 0x00020000,
  43. HorizontalAlign = 0x00040000,
  44. ScrollBars = 0x00080000,
  45. Wrap = 0x00100000,
  46. }
  47. public PanelStyle (StateBag bag)
  48. : base (bag)
  49. {
  50. }
  51. [DefaultValue ("")]
  52. [UrlProperty]
  53. public virtual string BackImageUrl {
  54. get {
  55. if (!CheckBit ((int) PanelStyles.BackImageUrl))
  56. return String.Empty;
  57. return ViewState.GetString ("BackImageUrl", String.Empty);
  58. }
  59. set {
  60. ViewState ["BackImageUrl"] = value;
  61. SetBit ((int) PanelStyles.BackImageUrl);
  62. }
  63. }
  64. [DefaultValue (ContentDirection.NotSet)]
  65. public virtual ContentDirection Direction {
  66. get {
  67. if (!CheckBit ((int) PanelStyles.Direction))
  68. return ContentDirection.NotSet;
  69. return (ContentDirection) ViewState ["Direction"];
  70. }
  71. set {
  72. ViewState ["Direction"] = value;
  73. SetBit ((int) PanelStyles.Direction);
  74. }
  75. }
  76. [DefaultValue (HorizontalAlign.NotSet)]
  77. public virtual HorizontalAlign HorizontalAlign {
  78. get {
  79. if (!CheckBit ((int) PanelStyles.HorizontalAlign))
  80. return HorizontalAlign.NotSet;
  81. return (HorizontalAlign) ViewState ["HorizontalAlign"];
  82. }
  83. set {
  84. ViewState ["HorizontalAlign"] = value;
  85. SetBit ((int) PanelStyles.HorizontalAlign);
  86. }
  87. }
  88. [DefaultValue (ScrollBars.None)]
  89. public virtual ScrollBars ScrollBars {
  90. get {
  91. if (!CheckBit ((int) PanelStyles.ScrollBars))
  92. return ScrollBars.None;
  93. return (ScrollBars) ViewState ["ScrollBars"];
  94. }
  95. set {
  96. ViewState ["ScrollBars"] = value;
  97. SetBit ((int) PanelStyles.ScrollBars);
  98. }
  99. }
  100. [DefaultValue (true)]
  101. public virtual bool Wrap {
  102. get {
  103. if (!CheckBit ((int) PanelStyles.Wrap))
  104. return true;
  105. return (bool) ViewState ["Wrap"];
  106. }
  107. set {
  108. ViewState ["Wrap"] = value;
  109. SetBit ((int) PanelStyles.Wrap);
  110. }
  111. }
  112. public override void CopyFrom (Style s)
  113. {
  114. if ((s == null) || s.IsEmpty)
  115. return;
  116. base.CopyFrom (s);
  117. PanelStyle ps = s as PanelStyle;
  118. if (ps == null)
  119. return;
  120. if (s.CheckBit ((int) PanelStyles.BackImageUrl)) {
  121. this.BackImageUrl = ps.BackImageUrl;
  122. }
  123. if (s.CheckBit ((int) PanelStyles.Direction)) {
  124. this.Direction = ps.Direction;
  125. }
  126. if (s.CheckBit ((int) PanelStyles.HorizontalAlign)) {
  127. this.HorizontalAlign = ps.HorizontalAlign;
  128. }
  129. if (s.CheckBit ((int) PanelStyles.ScrollBars)) {
  130. this.ScrollBars = ps.ScrollBars;
  131. }
  132. if (s.CheckBit ((int) PanelStyles.Wrap)) {
  133. this.Wrap = ps.Wrap;
  134. }
  135. }
  136. public override void MergeWith (Style s)
  137. {
  138. if ((s == null) || (s.IsEmpty))
  139. return;
  140. base.MergeWith (s);
  141. PanelStyle ps = s as PanelStyle;
  142. if (ps == null)
  143. return;
  144. if (!CheckBit ((int) PanelStyles.BackImageUrl) && s.CheckBit ((int) PanelStyles.BackImageUrl)) {
  145. this.BackImageUrl = ps.BackImageUrl;
  146. }
  147. if (!CheckBit ((int) PanelStyles.Direction) && s.CheckBit ((int) PanelStyles.Direction)) {
  148. this.Direction = ps.Direction;
  149. }
  150. if (!CheckBit ((int) PanelStyles.HorizontalAlign) && s.CheckBit ((int) PanelStyles.HorizontalAlign)) {
  151. this.HorizontalAlign = ps.HorizontalAlign;
  152. }
  153. if (!CheckBit ((int) PanelStyles.ScrollBars) && s.CheckBit ((int) PanelStyles.ScrollBars)) {
  154. this.ScrollBars = ps.ScrollBars;
  155. }
  156. if (!CheckBit ((int) PanelStyles.Wrap) && s.CheckBit ((int) PanelStyles.Wrap)) {
  157. this.Wrap = ps.Wrap;
  158. }
  159. }
  160. public override void Reset ()
  161. {
  162. base.Reset ();
  163. ViewState.Remove ("BackImageUrl");
  164. ViewState.Remove ("Direction");
  165. ViewState.Remove ("HorizontalAlign");
  166. ViewState.Remove ("ScrollBars");
  167. ViewState.Remove ("Wrap");
  168. }
  169. }
  170. }
  171. #endif