Author: jordi
Date: 2005-10-10 18:52:40 -0400 (Mon, 10 Oct 2005)
New Revision: 51536

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListBox.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs
   
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
Log:
2005-10-11  Jordi Mas i Hernandez <[EMAIL PROTECTED]>

        * Theme.cs, ThemeWin32Classic.cs, ListBox.cs:
         - Fixed border calculations
         - Fixed horizontal scrolling in single column listboxes
         - Fixed drawing issues



Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2005-10-10 22:40:54 UTC (rev 51535)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2005-10-10 22:52:40 UTC (rev 51536)
@@ -1,3 +1,10 @@
+2005-10-11  Jordi Mas i Hernandez <[EMAIL PROTECTED]>
+
+       * Theme.cs, ThemeWin32Classic.cs, ListBox.cs:
+        - Fixed border calculations
+        - Fixed horizontal scrolling in single column listboxes
+        - Fixed drawing issues
+
 2005-10-10  Peter Dennis Bartok  <[EMAIL PROTECTED]>
 
        * XplatUI.cs, XplatUIOSX.cs, XplatUIWin32.cs: Switched from BorderStyle 
to 

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListBox.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListBox.cs       
2005-10-10 22:40:54 UTC (rev 51535)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListBox.cs       
2005-10-10 22:52:40 UTC (rev 51536)
@@ -417,9 +417,6 @@
                                                itemsHeight += 
items.GetListBoxItem (i).ItemHeight;
                                }
                                
-                               itemsHeight += 
ThemeEngine.Current.DrawListBoxDecorationTop (BorderStyle);
-                               itemsHeight += 
ThemeEngine.Current.DrawListBoxDecorationBottom (BorderStyle);
-                               
                                return itemsHeight;
                        }
                }
@@ -998,14 +995,9 @@
                #region Private Methods
 
                internal void CalcClientArea ()
-               {
-                       listbox_info.textdrawing_rect = 
listbox_info.client_rect;
-                       listbox_info.textdrawing_rect.Y += 
ThemeEngine.Current.DrawListBoxDecorationTop (BorderStyle);
-                       listbox_info.textdrawing_rect.X += 
ThemeEngine.Current.DrawListBoxDecorationLeft (BorderStyle);
-                       //BUG: Top and Left decorations
-                       listbox_info.textdrawing_rect.Height -= 
ThemeEngine.Current.DrawListBoxDecorationBottom (BorderStyle) + 
ThemeEngine.Current.DrawListBoxDecorationTop (BorderStyle);
-                       listbox_info.textdrawing_rect.Width -= 
ThemeEngine.Current.DrawListBoxDecorationRight (BorderStyle) + 
ThemeEngine.Current.DrawListBoxDecorationLeft (BorderStyle);
-
+               {               
+                       listbox_info.textdrawing_rect = 
listbox_info.client_rect;                       
+                       
                        if (listbox_info.show_verticalsb)
                                listbox_info.textdrawing_rect.Width -= 
vscrollbar_ctrl.Width;
 
@@ -1032,17 +1024,14 @@
                                listbox_info.page_size = 1;
                        }
 
-                       /* Adjust size to visible the maxim number of 
displayable items */
+                       /* Adjust size to visible the maximum number of 
displayable items */
                        if (IntegralHeight == true) {
 
                                // From MS Docs: The integral height is based 
on the height of the ListBox, rather than
                                // the client area height. As a result, when 
the IntegralHeight property is set true,
                                // items can still be partially shown if scroll 
bars are displayed.
 
-                               int remaining =  
(listbox_info.client_rect.Height -
-                                       
ThemeEngine.Current.DrawListBoxDecorationTop (BorderStyle) -
-                                       
ThemeEngine.Current.DrawListBoxDecorationBottom (BorderStyle)) %
-                                       listbox_info.item_height;
+                               int remaining = listbox_info.client_rect.Height 
% listbox_info.item_height;
 
                                if (remaining > 0) {
                                        listbox_info.client_rect.Height -= 
remaining;
@@ -1054,20 +1043,28 @@
                }
 
                internal void Draw (Rectangle clip, Graphics dc)
-               {       
-                       if (LBoxInfo.textdrawing_rect.Contains (clip) == false) 
{
-                               // IntegralHeight has effect, we also have to 
paint the unused area
+               {                               
+                       // IntegralHeight has effect, we also have to paint the 
unused area     
+                       if (IntegralHeight) {                           
                                if (ClientRectangle.Height > 
listbox_info.client_rect.Height) {
                                        Region area = new Region 
(ClientRectangle);
-                                       area.Exclude (listbox_info.client_rect);
+                                       area.Exclude 
(LBoxInfo.textdrawing_rect);
 
-                                       dc.FillRectangle 
(ThemeEngine.Current.ResPool.GetSolidBrush (Parent.BackColor),
+                                       if (listbox_info.show_horizontalsb) {
+                                               area.Exclude (new Rectangle 
(hscrollbar_ctrl.Location.X, hscrollbar_ctrl.Location.Y,
+                                                       hscrollbar_ctrl.Width, 
hscrollbar_ctrl.Height));
+                                       }                                       
        
+
+                                       dc.FillRectangle 
(ThemeEngine.Current.ResPool.GetSolidBrush (BackColor),
                                                area.GetBounds (dc));
+
+                                       area.Dispose ();
                                }
+                       }
+                       
+                       dc.FillRectangle 
(ThemeEngine.Current.ResPool.GetSolidBrush (BackColor),
+                                       LBoxInfo.textdrawing_rect);
 
-                               dc.FillRectangle 
(ThemeEngine.Current.ResPool.GetSolidBrush (BackColor), 
LBoxInfo.textdrawing_rect);                            
-                       }                                       
-
                        if (Items.Count > 0) {
                                Rectangle item_rect;
                                DrawItemState state = DrawItemState.None;
@@ -1096,9 +1093,8 @@
                                        OnDrawItem (new DrawItemEventArgs (dc, 
Font, item_rect,
                                                i, state, ForeColor, 
BackColor));
                                }
-                       }                       
+                       }
                        
-                       ThemeEngine.Current.DrawListBoxDecorations (dc, this);
                }
 
                // Converts a GetItemRectangle to a one that we can display
@@ -1109,19 +1105,18 @@
                        item_rect = GetItemRectangle (index);
                        item_rect.X -= first_item_rect.X;
                        item_rect.Y -= first_item_rect.Y;
-
-                       item_rect.Y += 
ThemeEngine.Current.DrawListBoxDecorationTop (BorderStyle);
-                       item_rect.X += 
ThemeEngine.Current.DrawListBoxDecorationLeft (BorderStyle);
-                       item_rect.Width -= 
ThemeEngine.Current.DrawListBoxDecorationRight (BorderStyle);// + 
ThemeEngine.Current.DrawListBoxDecorationLeft (BorderStyle);
-
+                       
                        return item_rect;
                }
 
                // Value Changed
                private void HorizontalScrollEvent (object sender, EventArgs e)
                {
-                       if (!multicolumn)
+                       if (!multicolumn) {
+                               base.Refresh ();
                                return;
+                       }
+
                        int top_item = LBoxInfo.top_item;
                        int last_item = LBoxInfo.last_item;
 
@@ -1164,16 +1159,10 @@
                                        if (item_rect.X > 
LBoxInfo.textdrawing_rect.Width)
                                                return i - 1;
                                }
-                               else {
-                                       if (IntegralHeight) {
-                                               if (item_rect.Y + 
item_rect.Height > top_y) {
-                                                       return i - 1;
-                                               }
+                               else {                                  
+                                       if (item_rect.Y + item_rect.Height > 
top_y) {
+                                               return i;
                                        }
-                                       else {
-                                               if (item_rect.Y + 
item_rect.Height > top_y)
-                                                       return i;
-                                       }
                                }
                        }
                        return i - 1;
@@ -1484,31 +1473,18 @@
                internal void RellocateScrollBars ()
                {
                        if (listbox_info.show_verticalsb) {
-
-                               vscrollbar_ctrl.Size = new Size 
(vscrollbar_ctrl.Width,
-                                       listbox_info.client_rect.Height - 
ThemeEngine.Current.DrawListBoxDecorationTop (BorderStyle) -
-                                       
ThemeEngine.Current.DrawListBoxDecorationBottom (BorderStyle));
-
-                               vscrollbar_ctrl.Location = new Point 
(listbox_info.client_rect.Width - vscrollbar_ctrl.Width
-                                       - 
ThemeEngine.Current.DrawListBoxDecorationRight (BorderStyle),
-                                       
ThemeEngine.Current.DrawListBoxDecorationTop (BorderStyle));
-
+                               vscrollbar_ctrl.Size = new Size 
(vscrollbar_ctrl.Width, ClientRectangle.Height);
+                               vscrollbar_ctrl.Location = new Point 
(ClientRectangle.Width - vscrollbar_ctrl.Width, 0);
                        }
 
                        if (listbox_info.show_horizontalsb) {
+                               int width = listbox_info.client_rect.Width;
 
-                               int width;
-
-                               width = listbox_info.client_rect.Width - 
(ThemeEngine.Current.DrawListBoxDecorationLeft (BorderStyle) + 
ThemeEngine.Current.DrawListBoxDecorationRight (BorderStyle));
-
                                if (listbox_info.show_verticalsb)
                                        width -= vscrollbar_ctrl.Width;
 
                                hscrollbar_ctrl.Size = new Size (width, 
hscrollbar_ctrl.Height);
-
-                               hscrollbar_ctrl.Location = new Point 
(ThemeEngine.Current.DrawListBoxDecorationLeft (BorderStyle),
-                                       listbox_info.client_rect.Height - 
hscrollbar_ctrl.Height
-                                       - 
ThemeEngine.Current.DrawListBoxDecorationTop (BorderStyle));
+                               hscrollbar_ctrl.Location = new Point (0, 
ClientRectangle.Height - hscrollbar_ctrl.Height);
                        }
 
                        CalcClientArea ();

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs 
2005-10-10 22:40:54 UTC (rev 51535)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs 
2005-10-10 22:52:40 UTC (rev 51536)
@@ -543,14 +543,7 @@
                
                #region ListBox
                // Drawing
-               public abstract void DrawListBoxDecorations (Graphics dc, 
ListBox ctrl);
-               public abstract void DrawListBoxItem (ListBox ctrl, 
DrawItemEventArgs e);
-               
-               // Sizing
-               public abstract int DrawListBoxDecorationTop (BorderStyle 
border_style);
-               public abstract int DrawListBoxDecorationBottom (BorderStyle 
border_style);
-               public abstract int DrawListBoxDecorationRight (BorderStyle 
border_style);
-               public abstract int DrawListBoxDecorationLeft (BorderStyle 
border_style);
+               public abstract void DrawListBoxItem (ListBox ctrl, 
DrawItemEventArgs e);               
                #endregion      // ListBox              
                
                #region ListView

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs 
    2005-10-10 22:40:54 UTC (rev 51535)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs 
    2005-10-10 22:52:40 UTC (rev 51536)
@@ -1365,31 +1365,6 @@
                #region ListBox
                
                // Drawing              
-               public override void DrawListBoxDecorations (Graphics dc, 
ListBox ctrl)
-               {                       
-                       Rectangle cl = ctrl.LBoxInfo.client_rect;
-                       
-                       // Draw decorations
-                       switch (ctrl.BorderStyle) {
-                       case BorderStyle.Fixed3D: {                             
-                               dc.DrawLine (ResPool.GetPen (ColorControlDark), 
cl.X, cl.Y, cl.X + cl.Width, cl.Y); //top 
-                               dc.DrawLine (ResPool.GetPen 
(ColorControlDarkDark), cl.X + 1, cl.Y + 1, cl.X + cl.Width - 2, cl.Y + 1);
-                               dc.DrawLine (ResPool.GetPen (ColorControl), 
cl.X, cl.Y + cl.Height - 2, cl.X + cl.Width, cl.Y + cl.Height - 2); //down
-                               dc.DrawLine (ResPool.GetPen 
(ColorControlLight), cl.X, cl.Y + cl.Height - 1, cl.X + cl.Width, cl.Y + 
cl.Height - 1);
-                               dc.DrawLine (ResPool.GetPen (ColorControlDark), 
cl.X, cl.Y, cl.X, cl.Y + cl.Height); //left
-                               dc.DrawLine (ResPool.GetPen 
(ColorControlDarkDark), cl.X + 1, cl.Y + 1, cl.X + 1, cl.Y + cl.Height - 2); 
-                               dc.DrawLine (ResPool.GetPen (ColorControl), 
cl.X + cl.Width - 2, cl.Y, cl.X + cl.Width - 2, cl.Y + cl.Height); //right
-                               dc.DrawLine (ResPool.GetPen 
(ColorControlLight), cl.X + cl.Width - 1, cl.Y + 1 , cl.X + cl.Width - 1, cl.Y 
+ cl.Height - 1);            
-                               break;
-                       }
-                       case BorderStyle.FixedSingle:
-                               dc.DrawRectangle (ResPool.GetPen 
(ColorWindowFrame), cl.X, cl.Y, cl.Width - 1, cl.Height - 1);
-                               break;
-                       case BorderStyle.None:
-                       default:
-                               break;
-                       }               
-               }               
                
                private int DrawListBoxDecorationSize (BorderStyle border_style)
                {
@@ -1407,11 +1382,6 @@
                }                       
                
                // Sizing                               
-               public override int DrawListBoxDecorationTop  (BorderStyle 
border_style) { return DrawListBoxDecorationSize (border_style);}
-               public override int DrawListBoxDecorationBottom  (BorderStyle 
border_style) { return DrawListBoxDecorationSize (border_style);}
-               public override int DrawListBoxDecorationRight (BorderStyle 
border_style) { return DrawListBoxDecorationSize (border_style);}
-               public override int DrawListBoxDecorationLeft (BorderStyle 
border_style) { return DrawListBoxDecorationSize (border_style);}
-               
                public override void DrawListBoxItem (ListBox ctrl, 
DrawItemEventArgs e)
                {
                        Color back_color, fore_color;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to