dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] pnetlib ChangeLog System.Windows.Forms/StatusBa...


From: Radek Polak
Subject: [dotgnu-pnet-commits] pnetlib ChangeLog System.Windows.Forms/StatusBa...
Date: Wed, 25 Feb 2009 10:36:11 +0000

CVSROOT:        /sources/dotgnu-pnet
Module name:    pnetlib
Changes by:     Radek Polak <radekp>    09/02/25 10:36:11

Modified files:
        .              : ChangeLog 
        System.Windows.Forms: StatusBar.cs StatusBarPanel.cs 
        tests/System.Windows.Forms: TestCheckedListBox.cs TestForms.cs 
Added files:
        System.Windows.Forms: DateTimePicker.cs 
        tests/System.Windows.Forms: TestStatusBar.cs 

Log message:
        status bar fixes and dummy date time picker implementation

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnetlib/ChangeLog?cvsroot=dotgnu-pnet&r1=1.2561&r2=1.2562
http://cvs.savannah.gnu.org/viewcvs/pnetlib/System.Windows.Forms/StatusBar.cs?cvsroot=dotgnu-pnet&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/pnetlib/System.Windows.Forms/StatusBarPanel.cs?cvsroot=dotgnu-pnet&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/pnetlib/System.Windows.Forms/DateTimePicker.cs?cvsroot=dotgnu-pnet&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/pnetlib/tests/System.Windows.Forms/TestCheckedListBox.cs?cvsroot=dotgnu-pnet&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/pnetlib/tests/System.Windows.Forms/TestForms.cs?cvsroot=dotgnu-pnet&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/pnetlib/tests/System.Windows.Forms/TestStatusBar.cs?cvsroot=dotgnu-pnet&rev=1.1

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/dotgnu-pnet/pnetlib/ChangeLog,v
retrieving revision 1.2561
retrieving revision 1.2562
diff -u -b -r1.2561 -r1.2562
--- ChangeLog   22 Feb 2009 16:36:56 -0000      1.2561
+++ ChangeLog   25 Feb 2009 10:36:10 -0000      1.2562
@@ -1,3 +1,19 @@
+2009-02-25  Radek Polak  <address@hidden>
+
+       * System.Windows.Forms/DateTimePicker.cs: Dummy implementation.
+
+       * System.Windows.Forms/StatusBar.cs: Fixes to panel collection - check 
null
+       and duplicit values, always set panel parent.
+
+       * System.Windows.Forms/StatusBarPanel.cs: Invalidate parent status bar 
when
+       changing visible properties.
+
+       * tests/System.Windows.Forms/TestCheckedListBox.cs: Fix comment.
+
+       * tests/System.Windows.Forms/TestStatusBar.cs: Tests for panel 
collection.
+
+       * tests/System.Windows.Forms/TestForms.cs: Add tests for status bar.
+
 2009-02-22  Klaus Treichel  <address@hidden>
 
        * resources/en_US/runtime/Arg.txt: Add message for the invalid midpoint

Index: System.Windows.Forms/StatusBar.cs
===================================================================
RCS file: /sources/dotgnu-pnet/pnetlib/System.Windows.Forms/StatusBar.cs,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- System.Windows.Forms/StatusBar.cs   13 Aug 2005 03:20:13 -0000      1.11
+++ System.Windows.Forms/StatusBar.cs   25 Feb 2009 10:36:10 -0000      1.12
@@ -338,12 +338,12 @@
                        // Implement the ICollection interface.
                        void ICollection.CopyTo(Array array, int index)
                        {
-                               List.CopyTo(array, index);
+                               list.CopyTo(array, index);
                        }
 
                        public virtual int Count
                        {
-                               get { return List.Count; }
+                               get { return list.Count; }
                        }
 
                        bool ICollection.IsSynchronized
@@ -359,7 +359,7 @@
                        // Implement the IEnumerable interface.
                        public IEnumerator GetEnumerator()
                        {
-                               return List.GetEnumerator();
+                               return list.GetEnumerator();
                        }
 
                        // Determine if the collection is read-only.
@@ -373,17 +373,69 @@
                                get { return false; }
                        }
 
+                       private static StatusBarPanel ValueAsPanel(object value)
+                       {
+                               if(value is StatusBarPanel)
+                               {
+                                       return (StatusBarPanel)value;
+                               }
+                               throw new ArgumentException("value");
+                       }
+
+                       private static void CheckNull(StatusBarPanel value)
+                       {
+                               if(value == null)
+                               {
+                                       throw new 
ArgumentNullException("value");
+                               }
+                       }
+
+                       private void CheckSame(StatusBarPanel value)
+                       {
+                               if(list.IndexOf(value) >= 0)
+                               {
+                                       throw new ArgumentException("value");
+                               }
+                       }
+
+                       private void CheckAdd(StatusBarPanel value)
+                       {
+                               CheckNull(value);
+                               CheckSame(value);
+                       }
+
                        // Get the array list that underlies this collection
                        Object IList.this[int index]
                        {
-                               get { return List[index]; }
-                               set { List[index] = value; }
+                               get
+                               {
+                                       return list[index];
+                               }
+                               set
+                               {
+                                       this[index] = ValueAsPanel(value);
+                               }
                        }
 
                        public StatusBarPanel this[int index]
                        {
-                               get { return (StatusBarPanel)List[index]; }
-                               set { List[index] = value; }
+                               get
+                               {
+                                       return (StatusBarPanel)(list[index]);
+                               }
+                               set
+                               {
+                                       StatusBarPanel old = 
(StatusBarPanel)(list[index]);
+                                       if(old == value)
+                                       {
+                                               return;
+                                       }
+                                       CheckAdd(value);
+                                       list[index] = value;
+                                       old.parent = null;
+                                       value.parent = owner;
+                                       owner.Invalidate();
+                               }
                        }
 
                        protected virtual ArrayList List
@@ -393,11 +445,12 @@
 
                        int IList.Add(Object value)
                        {
-                               return Add(value as StatusBarPanel);            
                
+                               return Add(ValueAsPanel(value));
                        }
 
                        public virtual int Add(StatusBarPanel value)
                        {
+                               CheckAdd(value);
                                int result = list.Add(value);
                                value.parent = owner;
                                owner.Invalidate();
@@ -408,67 +461,85 @@
                        {
                                StatusBarPanel panel = new StatusBarPanel();
                                panel.Text = text;
-                               List.Add(panel);
+                               Add(panel);
                                return panel;
                        }
 
                        public virtual void AddRange(StatusBarPanel[] panels)
                        {
-                               List.AddRange(panels);
+                               for(int i = 0; i < panels.Length; i++)
+                               {
+                                       StatusBarPanel value = panels[i];
+                                       CheckAdd(value);
+                                       value.parent = owner;
+                                       list.Add(value);
+                               }
                                owner.Invalidate();
                        }
 
                        public virtual void Clear()
                        {
-                               List.Clear();
+                               for(int i = 0; i < list.Count; i++)
+                               {
+                                       this[i].parent = null;
+                               }
+                               list.Clear();
                                owner.Invalidate();
                        }
 
                        bool IList.Contains(Object value)
                        {
-                               return List.Contains(value);
+                               return list.Contains(value);
                        }
 
                        public bool Contains(StatusBarPanel panel)
                        {
-                               return List.Contains(panel);
+                               return list.Contains(panel);
                        }
 
                        int IList.IndexOf(Object value)
                        {
-                               return List.IndexOf(value);
+                               return list.IndexOf(value);
                        }
 
                        public int IndexOf(StatusBarPanel panel)
                        {
-                               return List.IndexOf(panel);
+                               return list.IndexOf(panel);
                        }
 
                        void IList.Insert(int index, Object value)
                        {
-                               List.Insert(index, value);
-                               owner.Invalidate();
+                               Insert(index, ValueAsPanel(value));
                        }
 
                        public virtual void Insert(int index, StatusBarPanel 
value)
                        {
-                               List.Insert(index, value);
+                               CheckAdd(value);
+                               list.Insert(index, value);
+                               value.parent = owner;
+                               owner.Invalidate();
                        }
 
                        void IList.Remove(Object value)
                        {
-                               List.Remove(value);
-                               owner.Invalidate();
+                               Remove(ValueAsPanel(value));
                        }
 
                        public virtual void Remove(StatusBarPanel value)
                        {
-                               List.Remove(value);
+                               CheckNull(value);
+                               int index = list.IndexOf(value);
+                               if(index >= 0)
+                               {
+                                       RemoveAt(index);
+                               }
                        }
 
-                       void IList.RemoveAt(int index)
+                       public void RemoveAt(int index)
                        {
-                               List.RemoveAt(index);
+                               StatusBarPanel value = 
(StatusBarPanel)(list[index]);
+                               value.parent = null;
+                               list.RemoveAt(index);
                        }
                }
        }

Index: System.Windows.Forms/StatusBarPanel.cs
===================================================================
RCS file: /sources/dotgnu-pnet/pnetlib/System.Windows.Forms/StatusBarPanel.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- System.Windows.Forms/StatusBarPanel.cs      28 Sep 2003 22:06:36 -0000      
1.4
+++ System.Windows.Forms/StatusBarPanel.cs      25 Feb 2009 10:36:10 -0000      
1.5
@@ -80,34 +80,77 @@
                {
                }
 
+               private void InvalidateParent()
+               {
+                       if(parent != null)
+                       {
+                               parent.Invalidate();
+                       }
+               }
+
                public HorizontalAlignment Alignment
                {
-                       get { return alignment; }
-                       set { alignment = value; }
+                       get
+                       {
+                               return alignment;
+                       }
+                       set
+                       {
+                               alignment = value;
+                               InvalidateParent();
+                       }
                }
 
                public StatusBarPanelAutoSize AutoSize
                {
-                       get { return autosize; }
-                       set { autosize = value; }
+                       get
+                       {
+                               return autosize;
+                       }
+                       set
+                       {
+                               autosize = value;
+                               InvalidateParent();
+                       }
                }
 
                public StatusBarPanelBorderStyle BorderStyle 
                {
-                       get { return borderStyle; }
-                       set { borderStyle = value; }
+                       get
+                       {
+                               return borderStyle;
+                       }
+                       set
+                       {
+                               borderStyle = value;
+                               InvalidateParent();
+                       }
                }
 
                public Icon Icon 
                {
-                       get { return icon; }
-                       set { icon = value; }
+                       get
+                       {
+                               return icon;
+                       }
+                       set
+                       {
+                               icon = value;
+                               InvalidateParent();
+                       }
                }
 
                public int MinWidth 
                {
-                       get { return minWidth; }
-                       set { minWidth = value; }
+                       get
+                       {
+                               return minWidth;
+                       }
+                       set
+                       {
+                               minWidth = value;
+                               InvalidateParent();
+                       }
                }
 
                public StatusBar Parent 
@@ -117,26 +160,54 @@
 
                public StatusBarPanelStyle Style 
                {
-                       get { return style; }
-                       set { style = value; }
+                       get
+                       {
+                               return style;
+                       }
+                       set
+                       {
+                               style = value;
+                               InvalidateParent();
+                       }
                }
 
                public string Text
                {
-                       get { return text; }
-                       set { text = value; }
+                       get
+                       {
+                               return text;
+                       }
+                       set
+                       {
+                               text = value;
+                               InvalidateParent();
+                       }
                }
 
                public string ToolTipText 
                {
-                       get { return toolTipText; }
-                       set { toolTipText = value; }
+                       get
+                       {
+                               return toolTipText;
+                       }
+                       set
+                       {
+                               toolTipText = value;
+                               InvalidateParent();
+                       }
                }
 
                public int Width 
                {
-                       get { return width; }
-                       set { width = value; }
+                       get
+                       {
+                               return width;
+                       }
+                       set
+                       {
+                               width = value;
+                               InvalidateParent();
+                       }
                }
 
                public override string ToString()
@@ -144,5 +215,6 @@
                        return text;
                }
 
-       }
-}
+       }  // class StatusBarPanel
+
+} // namespace System.Windows.Forms

Index: tests/System.Windows.Forms/TestCheckedListBox.cs
===================================================================
RCS file: 
/sources/dotgnu-pnet/pnetlib/tests/System.Windows.Forms/TestCheckedListBox.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- tests/System.Windows.Forms/TestCheckedListBox.cs    26 Jan 2007 13:24:29 
-0000      1.1
+++ tests/System.Windows.Forms/TestCheckedListBox.cs    25 Feb 2009 10:36:10 
-0000      1.2
@@ -86,4 +86,4 @@
                                AssertEquals("Index of (3)", 1, 
items.IndexOf(item2));
                                AssertEquals("Index of (4)", -1, 
items.IndexOf(item3));
                        }
-}; // class TestXmlTextReader
+}; // class TestCheckedListBox

Index: tests/System.Windows.Forms/TestForms.cs
===================================================================
RCS file: /sources/dotgnu-pnet/pnetlib/tests/System.Windows.Forms/TestForms.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- tests/System.Windows.Forms/TestForms.cs     26 Jan 2007 13:24:29 -0000      
1.1
+++ tests/System.Windows.Forms/TestForms.cs     25 Feb 2009 10:36:10 -0000      
1.2
@@ -33,6 +33,10 @@
                                suite.AddTests(typeof(TestCheckedListBox));
                                fullSuite.AddTest(suite);
 
+                               suite = new TestSuite("StatusBar tests");
+                               suite.AddTests(typeof(TestStatusBar));
+                               fullSuite.AddTest(suite);
+
                                return fullSuite;
                        }
 

Index: System.Windows.Forms/DateTimePicker.cs
===================================================================
RCS file: System.Windows.Forms/DateTimePicker.cs
diff -N System.Windows.Forms/DateTimePicker.cs
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ System.Windows.Forms/DateTimePicker.cs      25 Feb 2009 10:36:10 -0000      
1.1
@@ -0,0 +1,55 @@
+/*
+ * DateTimePicker.cs - Implementation of "System.Windows.Forms.DateTimePicker"
+ *
+ * Copyright (C) 2009  Free Software Foundation Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+namespace System.Windows.Forms
+{
+
+using System;
+using System.Drawing;
+using System.Collections;
+using System.Globalization;
+using System.Drawing.Toolkit;
+using System.Windows.Forms.Themes;
+
+
+[TODO]
+public class DateTimePicker : Control
+{
+       private DateTime value;
+
+       public DateTimePicker()
+                       {
+                       }
+
+       public DateTime Value
+                       {
+                               get
+                               {
+                                       return value;
+                               }
+                               set
+                               {
+                                       this.value = value;
+                               }
+                       }
+
+}; // class DateTimePicker
+
+}; // namespace System.Windows.Forms

Index: tests/System.Windows.Forms/TestStatusBar.cs
===================================================================
RCS file: tests/System.Windows.Forms/TestStatusBar.cs
diff -N tests/System.Windows.Forms/TestStatusBar.cs
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ tests/System.Windows.Forms/TestStatusBar.cs 25 Feb 2009 10:36:11 -0000      
1.1
@@ -0,0 +1,142 @@
+/*
+ * TestStatusBar.cs - Tests for the
+ *             "System.Windows.Forms.StatusBar" class.
+ *
+ * Copyright (C) 2009  Free Software Foundation Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+using CSUnit;
+using System;
+using System.Collections;
+using System.Windows.Forms;
+
+public class TestStatusBar : TestCase
+{
+       // Constructor.
+       public TestStatusBar(String name)
+                       : base(name)
+                       {
+                               // Nothing to do here.
+                       }
+
+       // Set up for the tests.
+       protected override void Setup()
+                       {
+                               // Nothing to do here.
+                       }
+
+       // Clean up after the tests.
+       protected override void Cleanup()
+                       {
+                               // Nothing to do here.
+                       }
+
+       // Test the constructors
+       public void TestPanelCollections()
+                       {
+                               StatusBar bar = new StatusBar();
+                               StatusBar.StatusBarPanelCollection panels = 
bar.Panels;
+
+                               StatusBarPanel p1 = new StatusBarPanel();
+                               StatusBarPanel p2 = new StatusBarPanel();
+                               StatusBarPanel p3 = new StatusBarPanel();
+                               StatusBarPanel p4 = new StatusBarPanel();
+               
+                               AssertEquals("Count (1)", 0, panels.Count);
+
+                               panels.Add(p2);
+                               AssertEquals("Count (2)", 1, panels.Count);
+
+                               panels[0] = p2;
+                               AssertEquals("Count (3)", 1, panels.Count);
+                               AssertEquals("Indexer (1)", p2, panels[0]);
+
+                               panels[0] = p1;
+                               AssertEquals("Count (4)", 1, panels.Count);
+                               AssertEquals("Indexer (2)", p1, panels[0]);
+
+                               panels.AddRange(new StatusBarPanel[] { p2, p3 
});
+                               AssertEquals("Count (5)", 3, panels.Count);
+                               AssertEquals("Indexer (3)", p1, panels[0]);
+                               AssertEquals("Indexer (4)", p2, panels[1]);
+                               AssertEquals("Indexer (5)", p3, panels[2]);
+
+                               AssertEquals("Contains (1)", true, 
panels.Contains(p1));
+                               AssertEquals("Contains (2)", true, 
panels.Contains(p2));
+                               AssertEquals("Contains (3)", true, 
panels.Contains(p3));
+                               AssertEquals("Contains (4)", false, 
panels.Contains(p4));
+
+                               AssertEquals("IndexOf (1)", 0, 
panels.IndexOf(p1));
+                               AssertEquals("IndexOf (2)", 1, 
panels.IndexOf(p2));
+                               AssertEquals("IndexOf (3)", -1, 
panels.IndexOf(p4));
+
+                               panels.Insert(0, p4);
+                               AssertEquals("IndexOf (4)", 1, 
panels.IndexOf(p1));
+                               AssertEquals("IndexOf (5)", 2, 
panels.IndexOf(p2));
+                               AssertEquals("IndexOf (6)", 0, 
panels.IndexOf(p4));
+
+                               panels.Remove(p4);
+                               AssertEquals("Count (6)", 3, panels.Count);
+                               AssertEquals("IndexOf (7)", 0, 
panels.IndexOf(p1));
+                               AssertEquals("IndexOf (8)", 1, 
panels.IndexOf(p2));
+                               AssertEquals("IndexOf (9)", -1, 
panels.IndexOf(p4));
+
+                               try
+                               {
+                                       panels.Add(p1);
+                                       Fail("Add (1)");
+                               }
+                               catch(ArgumentException)
+                               {
+                                       // Success - already in collection
+                               }
+
+                               try
+                               {
+                                       StatusBarPanel nullPanel = null;
+                                       panels.Add(nullPanel);
+                                       Fail("Add (2)");
+                               }
+                               catch(ArgumentNullException)
+                               {
+                                       // Success - null argument
+                               }
+
+                               try
+                               {
+                                       panels.AddRange(new StatusBarPanel[] 
{p1, p2});
+                                       Fail("AddRange (1)");
+                               }
+                               catch(ArgumentException)
+                               {
+                                       // Success - already in collection
+                               }
+
+                               try
+                               {
+                                       panels[1] = p1;
+                                       Fail("Indexer (6)");
+                               }
+                               catch(ArgumentException)
+                               {
+                                       // Success- already in collection
+                               }
+
+                               panels.Clear();
+                               AssertEquals("Count (7)", 0, panels.Count);
+                       }
+}; // class TestStatusBar




reply via email to

[Prev in Thread] Current Thread [Next in Thread]