ChangeLog: Updated ChangeLog.
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / DataGridPagerStyle.cs
index 8e15bb77b79bd237748f15ee63a387e91b556f1e..5fd349d98070996cc5c2721229a8f71be2d650b4 100644 (file)
-/**\r
- * Namespace: System.Web.UI.WebControls\r
- * Class:     DataGridPagerStyle\r
- *\r
- * Author:  Gaurav Vaish\r
- * Maintainer: gvaish@iitk.ac.in\r
- * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>\r
- * Implementation: yes\r
- * Status:  100%\r
- *\r
- * (C) Gaurav Vaish (2002)\r
- */\r
-\r
-using System;\r
-using System.Web;\r
-using System.Web.UI;\r
-\r
-namespace System.Web.UI.WebControls\r
-{\r
-       public class DataGridPagerStyle : TableItemStyle\r
-       {\r
-               DataGrid owner;\r
-\r
-               private static int MODE         = (0x01 << 19);\r
-               private static int NEXT_PG_TEXT = (0x01 << 20);\r
-               private static int PG_BTN_COUNT = (0x01 << 21);\r
-               private static int POSITION     = (0x01 << 22);\r
-               private static int VISIBLE      = (0x01 << 23);\r
-               private static int PREV_PG_TEXT = (0x01 << 24);\r
-\r
-               internal DataGridPagerStyle(DataGrid owner): base()\r
-               {\r
-                       this.owner = owner;\r
-               }\r
-\r
-               public PagerMode Mode\r
-               {\r
-                       get\r
-                       {\r
-                               if(IsSet(MODE))\r
-                               {\r
-                                       return (PagerMode)ViewState["Mode"];\r
-                               }\r
-                               return PagerMode.NextPrev;\r
-                       }\r
-                       set\r
-                       {\r
-                               if(!Enum.IsDefined(typeof(PagerMode), value))\r
-                               {\r
-                                       throw new NotImplementedException();\r
-                               }\r
-                               ViewState["Mode"] = value;\r
-                               Set(MODE);\r
-                       }\r
-               }\r
-\r
-               public string NextPageText\r
-               {\r
-                       get\r
-                       {\r
-                               if(IsSet(NEXT_PG_TEXT))\r
-                               {\r
-                                       return (string)ViewState["NextPageText"];\r
-                               }\r
-                               return "&gt;";\r
-                       }\r
-                       set\r
-                       {\r
-                               ViewState["NextPageText"] = value;\r
-                               Set(NEXT_PG_TEXT);\r
-                       }\r
-               }\r
-\r
-               public string PrevPageText\r
-               {\r
-                       get\r
-                       {\r
-                               if(IsSet(PREV_PG_TEXT))\r
-                               {\r
-                                       return (string)ViewState["PrevPageText"];\r
-                               }\r
-                               return "&lt;";\r
-                       }\r
-                       set\r
-                       {\r
-                               ViewState["PrevPageText"] = value;\r
-                               Set(PREV_PG_TEXT);\r
-                       }\r
-               }\r
-\r
-               public int PageButtonCount\r
-               {\r
-                       get\r
-                       {\r
-                               if(IsSet(PG_BTN_COUNT))\r
-                               {\r
-                                       return (int)ViewState["PageButtonCount"];\r
-                               }\r
-                               return 10;\r
-                       }\r
-                       set\r
-                       {\r
-                               ViewState["PageButtonCount"] = value;\r
-                               Set(PG_BTN_COUNT);\r
-                       }\r
-               }\r
-\r
-               public PagerPosition Position\r
-               {\r
-                       get\r
-                       {\r
-                               if(IsSet(POSITION))\r
-                               {\r
-                                       return (PagerPosition)ViewState["Position"];\r
-                               }\r
-                               return PagerPosition.Bottom;\r
-                       }\r
-                       set\r
-                       {\r
-                               if(!Enum.IsDefined(typeof(PagerPosition), value))\r
-                               {\r
-                                       throw new ArgumentException();\r
-                               }\r
-                               ViewState["Position"] = value;\r
-                               Set(POSITION);\r
-                       }\r
-               }\r
-\r
-               public bool Visible\r
-               {\r
-                       get\r
-                       {\r
-                               if(IsSet(VISIBLE))\r
-                               {\r
-                                       return (bool)ViewState["Visible"];\r
-                               }\r
-                               return true;\r
-                       }\r
-                       set\r
-                       {\r
-                               ViewState["Visible"] = value;\r
-                               Set(PG_BTN_COUNT);\r
-                       }\r
-               }\r
-\r
-               public override void CopyFrom(Style s)\r
-               {\r
-                       if(s != null && !s.IsEmpty && s is DataGridPagerStyle)\r
-                       {\r
-                               base.CopyFrom(s);\r
-                               DataGridPagerStyle from = (DataGridPagerStyle)s;\r
-                               if(from.IsSet(MODE))\r
-                               {\r
-                                       Mode = from.Mode;\r
-                               }\r
-                               if(from.IsSet(NEXT_PG_TEXT))\r
-                               {\r
-                                       NextPageText = from.NextPageText;\r
-                               }\r
-                               if(from.IsSet(PG_BTN_COUNT))\r
-                               {\r
-                                       PageButtonCount = from.PageButtonCount;\r
-                               }\r
-                               if(from.IsSet(POSITION))\r
-                               {\r
-                                       Position = from.Position;\r
-                               }\r
-                               if(from.IsSet(VISIBLE))\r
-                               {\r
-                                       Visible = from.Visible;\r
-                               }\r
-                               if(from.IsSet(PREV_PG_TEXT))\r
-                               {\r
-                                       PrevPageText = from.PrevPageText;\r
-                               }\r
-                       }\r
-               }\r
-\r
-               public override void MergeWith(Style s)\r
-               {\r
-                       if(s != null && !s.IsEmpty && s is DataGridPagerStyle)\r
-                       {\r
-                               base.MergeWith(s);\r
-                               DataGridPagerStyle with = (DataGridPagerStyle)s;\r
-                               if(with.IsSet(MODE) && !IsSet(MODE))\r
-                               {\r
-                                       Mode = with.Mode;\r
-                               }\r
-                               if(with.IsSet(NEXT_PG_TEXT) && !IsSet(NEXT_PG_TEXT))\r
-                               {\r
-                                       NextPageText = with.NextPageText;\r
-                               }\r
-                               if(with.IsSet(PG_BTN_COUNT) && !IsSet(PG_BTN_COUNT))\r
-                               {\r
-                                       PageButtonCount = with.PageButtonCount;\r
-                               }\r
-                               if(with.IsSet(POSITION) && !IsSet(POSITION))\r
-                               {\r
-                                       Position = with.Position;\r
-                               }\r
-                               if(with.IsSet(VISIBLE) && !IsSet(VISIBLE))\r
-                               {\r
-                                       Visible = with.Visible;\r
-                               }\r
-                               if(with.IsSet(PREV_PG_TEXT) && !IsSet(PREV_PG_TEXT))\r
-                               {\r
-                                       PrevPageText = with.PrevPageText;\r
-                               }\r
-                       }\r
-               }\r
-\r
-               public override void Reset()\r
-               {\r
-                       if(IsSet(MODE))\r
-                       {\r
-                               ViewState.Remove("Mode");\r
-                       }\r
-                       if(IsSet(NEXT_PG_TEXT))\r
-                       {\r
-                               ViewState.Remove("NextPageText");\r
-                       }\r
-                       if(IsSet(PG_BTN_COUNT))\r
-                       {\r
-                               ViewState.Remove("PageButtonCount");\r
-                       }\r
-                       if(IsSet(POSITION))\r
-                       {\r
-                               ViewState.Remove("Position");\r
-                       }\r
-                       if(IsSet(VISIBLE))\r
-                       {\r
-                               ViewState.Remove("Visible");\r
-                       }\r
-                       if(IsSet(PREV_PG_TEXT))\r
-                       {\r
-                               ViewState.Remove("PrevPageText");\r
-                       }\r
-                       base.Reset();\r
-               }\r
-       }\r
-}\r
+//
+// System.Web.UI.WebControls.DataGridPagerStyle.cs
+//
+// Authors:
+//   Gaurav Vaish (gvaish@iitk.ac.in)
+//   Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) Gaurav Vaish (2002)
+// (C) 2003 Andreas Nahr
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+       public sealed class DataGridPagerStyle : TableItemStyle
+       {
+               DataGrid owner;
+
+               private static int MODE         = (0x01 << 19);
+               private static int NEXT_PG_TEXT = (0x01 << 20);
+               private static int PG_BTN_COUNT = (0x01 << 21);
+               private static int POSITION     = (0x01 << 22);
+               private static int VISIBLE      = (0x01 << 23);
+               private static int PREV_PG_TEXT = (0x01 << 24);
+
+               internal DataGridPagerStyle(DataGrid owner): base()
+               {
+                       this.owner = owner;
+               }
+
+               internal bool IsPagerOnTop
+               {
+                       get {
+                               PagerPosition p = Position;
+                               return (p == PagerPosition.Top || p == PagerPosition.TopAndBottom);
+                       }
+               }
+               
+               internal bool IsPagerOnBottom
+               {
+                       get {
+                               PagerPosition p = Position;
+                               return (p == PagerPosition.Bottom || p == PagerPosition.TopAndBottom);
+                       }
+               }
+
+               [DefaultValue (typeof (PagerMode), "NextPrev"), Bindable (true), WebCategory ("Misc")]
+               [NotifyParentProperty (true)]
+               [WebSysDescription ("The mode used for displaying multiple pages.")]
+               public PagerMode Mode
+               {
+                       get
+                       {
+                               if(IsSet(MODE))
+                               {
+                                       return (PagerMode)ViewState["Mode"];
+                               }
+                               return PagerMode.NextPrev;
+                       }
+                       set
+                       {
+                               if(!Enum.IsDefined(typeof(PagerMode), value))
+                               {
+                                       throw new ArgumentOutOfRangeException("value");
+                               }
+                               ViewState["Mode"] = value;
+                               Set(MODE);
+                       }
+               }
+
+               [DefaultValue (">"), Bindable (true), WebCategory ("Misc")]
+               [NotifyParentProperty (true)]
+               [WebSysDescription ("The text for the 'next page' button.")]
+               public string NextPageText
+               {
+                       get
+                       {
+                               if(IsSet(NEXT_PG_TEXT))
+                               {
+                                       return (string)ViewState["NextPageText"];
+                               }
+                               return "&gt;";
+                       }
+                       set
+                       {
+                               ViewState["NextPageText"] = value;
+                               Set(NEXT_PG_TEXT);
+                       }
+               }
+
+               [DefaultValue ("<"), Bindable (true), WebCategory ("Misc")]
+               [NotifyParentProperty (true)]
+               [WebSysDescription ("The text for the 'previous page' button.")]
+               public string PrevPageText
+               {
+                       get
+                       {
+                               if(IsSet(PREV_PG_TEXT))
+                               {
+                                       return (string)ViewState["PrevPageText"];
+                               }
+                               return "&lt;";
+                       }
+                       set
+                       {
+                               ViewState["PrevPageText"] = value;
+                               Set(PREV_PG_TEXT);
+                       }
+               }
+
+               [DefaultValue (10), Bindable (true), WebCategory ("Misc")]
+               [NotifyParentProperty (true)]
+               [WebSysDescription ("The maximum number of pages to show as direct links.")]
+               public int PageButtonCount
+               {
+                       get
+                       {
+                               if(IsSet(PG_BTN_COUNT))
+                               {
+                                       return (int)ViewState["PageButtonCount"];
+                               }
+                               return 10;
+                       }
+                       set
+                       {
+                               if (value < 1)
+                                       throw new ArgumentOutOfRangeException("value");
+                                
+                               ViewState["PageButtonCount"] = value;
+                               Set(PG_BTN_COUNT);
+                       }
+               }
+
+               [DefaultValue (typeof (PagerPosition), "Bottom"), Bindable (true), WebCategory ("Misc")]
+               [NotifyParentProperty (true)]
+               [WebSysDescription ("The position for the page display.")]
+               public PagerPosition Position
+               {
+                       get
+                       {
+                               if(IsSet(POSITION))
+                               {
+                                       return (PagerPosition)ViewState["Position"];
+                               }
+                               return PagerPosition.Bottom;
+                       }
+                       set
+                       {
+                               if(!Enum.IsDefined(typeof(PagerPosition), value))
+                               {
+                                       throw new ArgumentException();
+                               }
+                               ViewState["Position"] = value;
+                               Set(POSITION);
+                       }
+               }
+
+               [DefaultValue (true), Bindable (true), WebCategory ("Misc")]
+               [NotifyParentProperty (true)]
+               [WebSysDescription ("Determines if paging functionallity is visible to the user.")]
+               public bool Visible
+               {
+                       get
+                       {
+                               if(IsSet(VISIBLE))
+                               {
+                                       return (bool)ViewState["PagerVisible"];
+                               }
+                               return true;
+                       }
+                       set
+                       {
+                               ViewState["PagerVisible"] = value;
+                               Set(VISIBLE);
+                               owner.OnPagerChanged();
+                       }
+               }
+
+               public override void CopyFrom(Style s)
+               {
+                       if(s != null && !s.IsEmpty)
+                       {
+                               base.CopyFrom(s);
+                               if(!(s is DataGridPagerStyle)) return;
+
+                               DataGridPagerStyle from = (DataGridPagerStyle)s;
+                               if(from.IsSet(MODE))
+                               {
+                                       Mode = from.Mode;
+                               }
+                               if(from.IsSet(NEXT_PG_TEXT))
+                               {
+                                       NextPageText = from.NextPageText;
+                               }
+                               if(from.IsSet(PG_BTN_COUNT))
+                               {
+                                       PageButtonCount = from.PageButtonCount;
+                               }
+                               if(from.IsSet(POSITION))
+                               {
+                                       Position = from.Position;
+                               }
+                               if(from.IsSet(VISIBLE))
+                               {
+                                       Visible = from.Visible;
+                               }
+                               if(from.IsSet(PREV_PG_TEXT))
+                               {
+                                       PrevPageText = from.PrevPageText;
+                               }
+                       }
+               }
+
+               public override void MergeWith(Style s)
+               {
+                       if(s != null && !s.IsEmpty)
+                       {
+                               if(IsEmpty)
+                               {
+                                       CopyFrom(s);
+                                       return;
+                               }
+
+                               base.MergeWith(s);
+
+                               if(!(s is DataGridPagerStyle)) return;
+
+                               DataGridPagerStyle with = (DataGridPagerStyle)s;
+                               if(with.IsSet(MODE) && !IsSet(MODE))
+                               {
+                                       Mode = with.Mode;
+                               }
+                               if(with.IsSet(NEXT_PG_TEXT) && !IsSet(NEXT_PG_TEXT))
+                               {
+                                       NextPageText = with.NextPageText;
+                               }
+                               if(with.IsSet(PG_BTN_COUNT) && !IsSet(PG_BTN_COUNT))
+                               {
+                                       PageButtonCount = with.PageButtonCount;
+                               }
+                               if(with.IsSet(POSITION) && !IsSet(POSITION))
+                               {
+                                       Position = with.Position;
+                               }
+                               if(with.IsSet(VISIBLE) && !IsSet(VISIBLE))
+                               {
+                                       Visible = with.Visible;
+                               }
+                               if(with.IsSet(PREV_PG_TEXT) && !IsSet(PREV_PG_TEXT))
+                               {
+                                       PrevPageText = with.PrevPageText;
+                               }
+                       }
+               }
+
+               public override void Reset()
+               {
+                       if(IsSet(MODE))
+                       {
+                               ViewState.Remove("Mode");
+                       }
+                       if(IsSet(NEXT_PG_TEXT))
+                       {
+                               ViewState.Remove("NextPageText");
+                       }
+                       if(IsSet(PG_BTN_COUNT))
+                       {
+                               ViewState.Remove("PageButtonCount");
+                       }
+                       if(IsSet(POSITION))
+                       {
+                               ViewState.Remove("Position");
+                       }
+                       if(IsSet(VISIBLE))
+                       {
+                               ViewState.Remove("PagerVisible");
+                       }
+                       if(IsSet(PREV_PG_TEXT))
+                       {
+                               ViewState.Remove("PrevPageText");
+                       }
+                       base.Reset();
+               }
+       }
+}