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/ListBox....


From: Heiko Weiss
Subject: [dotgnu-pnet-commits] pnetlib ChangeLog System.Windows.Forms/ListBox....
Date: Thu, 25 Jan 2007 10:22:05 +0000

CVSROOT:        /sources/dotgnu-pnet
Module name:    pnetlib
Changes by:     Heiko Weiss <brubbel>   07/01/25 10:22:04

Modified files:
        .              : ChangeLog 
        System.Windows.Forms: ListBox.cs CheckListBox.cs 

Log message:
        fixed some div by zero exceptions.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnetlib/ChangeLog?cvsroot=dotgnu-pnet&r1=1.2463&r2=1.2464
http://cvs.savannah.gnu.org/viewcvs/pnetlib/System.Windows.Forms/ListBox.cs?cvsroot=dotgnu-pnet&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/pnetlib/System.Windows.Forms/CheckListBox.cs?cvsroot=dotgnu-pnet&r1=1.4&r2=1.5

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/dotgnu-pnet/pnetlib/ChangeLog,v
retrieving revision 1.2463
retrieving revision 1.2464
diff -u -b -r1.2463 -r1.2464
--- ChangeLog   17 Jan 2007 12:58:13 -0000      1.2463
+++ ChangeLog   25 Jan 2007 10:22:04 -0000      1.2464
@@ -1,3 +1,8 @@
+2007-01-25  Heiko Weiss <address@hidden>
+
+       *System.Windows.Forms/CheckListBox.cs: set ItemHeight enabled.
+       *System.Windows.Forms/ListBox.cs: fixed some div by zero exceptions.
+
 2007-01-17  Klaus Treichel  <address@hidden>
 
        * System/Net/AuthenticationSchemeSelector.cs,

Index: System.Windows.Forms/ListBox.cs
===================================================================
RCS file: /sources/dotgnu-pnet/pnetlib/System.Windows.Forms/ListBox.cs,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- System.Windows.Forms/ListBox.cs     6 Jun 2006 18:25:39 -0000       1.14
+++ System.Windows.Forms/ListBox.cs     25 Jan 2007 10:22:04 -0000      1.15
@@ -802,8 +802,12 @@
        [TODO]
        public virtual int ItemHeight
        {
-               get { return itemHeight; }
-               set { itemHeight = value; }
+               get {
+                       return itemHeight; 
+               }
+               set { 
+                       itemHeight = value; 
+               }
        }
 
        public ListBox.ObjectCollection Items
@@ -1055,7 +1059,7 @@
        [TODO]
        public int GetItemHeight()
        {
-               return 0;
+               return this.ItemHeight;
        }
 
        public Rectangle GetItemRectangle(int index)
@@ -1321,6 +1325,8 @@
        {
                get
                {
+                       if( this.NumItemsPerColumn <= 0 ) return 0; // avoid 
div by zero
+                       
                        IList data = (IList) base.dataSource;
                        double dColumnsNeeded = (double) data.Count / 
this.NumItemsPerColumn;
 
@@ -1555,6 +1561,8 @@
        {
                get
                {
+                       if( this.columnWidth <= 0 ) return 0; // avoid div by 
zero
+                       
                        int vscrollWidth = 0;
                        if(this.vertScrollbar.Visible)
                                vscrollWidth = this.vertScrollbar.Width;
@@ -1602,8 +1610,13 @@
        {
                get
                {
+                       if( this.ItemHeight > 0 ) { // avoid div by zero
                        return (this.Height) / this.ItemHeight;
                }
+                       else {
+                               return (this.Height) / DefaultItemHeight;
+                       }
+               }
        }
        
        private Rectangle GetItemRect(int dataIndex)
@@ -1615,6 +1628,7 @@
                
                        if(this.multiColumn)
                        {
+                               if( this.NumItemsPerColumn <= 0 ) return new 
Rectangle(-1, -1, -1, -1); // avoid div by zero
                                int col = screenIndex / this.NumItemsPerColumn;
                                int row = screenIndex - this.NumItemsPerColumn 
* col;
                                
@@ -2076,6 +2090,7 @@
                        // In a multi-column listbox, only scroll by entire 
columns.
                        if(this.multiColumn)
                        {
+                               if( this.NumItemsPerColumn <= 0 ) return; // 
avoid div by zero
                                col = this.FocusedItem / this.NumItemsPerColumn;
                        
                                if(this.FocusedItem >= this.topIndex + 
this.NumItemsVisible)
@@ -2117,12 +2132,14 @@
                        case Keys.Left:
                                if(this.multiColumn && e.KeyCode == Keys.Left)
                                {
+                                       if( this.NumItemsPerColumn > 0 ) { // 
avoid div by zero
                                        int col = this.FocusedItem / 
this.NumItemsPerColumn;
                                        int row = this.FocusedItem - 
this.NumItemsPerColumn * col;
                                        col--;
                                        this.FocusedItem = Math_Max(row,
                                                row + col * 
this.NumItemsPerColumn);
                                }
+                               }
                                else if(this.FocusedItem > 0)
                                        this.FocusedItem--;
                                
@@ -2136,6 +2153,7 @@
                        case Keys.Right:
                                if(this.multiColumn && e.KeyCode == Keys.Right)
                                {
+                                       if( this.NumItemsPerColumn > 0 ) { // 
avoid div by zero
                                        int col = this.FocusedItem / 
this.NumItemsPerColumn;
                                        int row = this.FocusedItem - 
this.NumItemsPerColumn * col;
                                        col++;
@@ -2145,6 +2163,7 @@
                                                        row + col * 
this.NumItemsPerColumn);
                                        }
                                }
+                               }
                                else if(this.FocusedItem < maxInd)
                                        this.FocusedItem++;
                                        
@@ -2238,6 +2257,8 @@
        
                if(listArea.Contains(x, y))
                {
+                       if( this.ItemHeight <= 0 ) return -1; // avoid div by 
zero
+
                        y -= listArea.Top;
                        int row = y / this.ItemHeight;
                        if(this.multiColumn)
@@ -2246,6 +2267,7 @@
                                        return -1;
                                        
                                x -= listArea.Left;
+                               if( this.columnWidth <= 0 ) return -1; // avoid 
div by zero
                                int col = x / this.columnWidth;
                                int ind = row + col * this.NumItemsPerColumn;
                                return ind;

Index: System.Windows.Forms/CheckListBox.cs
===================================================================
RCS file: /sources/dotgnu-pnet/pnetlib/System.Windows.Forms/CheckListBox.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- System.Windows.Forms/CheckListBox.cs        9 Feb 2005 10:48:58 -0000       
1.4
+++ System.Windows.Forms/CheckListBox.cs        25 Jan 2007 10:22:04 -0000      
1.5
@@ -178,11 +178,12 @@
                {
                        get
                        {
-                               return 0;
+                               return base.ItemHeight;
                        }
 
                        set
                        {
+                               base.ItemHeight = value;
                        }
                }
 




reply via email to

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