Author: jordi
Date: 2005-02-28 06:25:12 -0500 (Mon, 28 Feb 2005)
New Revision: 41278

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs
Log:
2005-02-28  Jordi Mas i Hernandez <[EMAIL PROTECTED]>

        * ComboBox.cs: show/hide scrollbar instead of creating it



Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2005-02-28 10:49:29 UTC (rev 41277)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2005-02-28 11:25:12 UTC (rev 41278)
@@ -1,3 +1,7 @@
+2005-02-28  Jordi Mas i Hernandez <[EMAIL PROTECTED]>
+
+       * ComboBox.cs: show/hide scrollbar instead of creating it
+
 2005-02-27  Jackson Harper  <[EMAIL PROTECTED]>
 
        * CurrencyManager.cs: Add PositionChanged stuff.

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs      
2005-02-28 10:49:29 UTC (rev 41277)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs      
2005-02-28 11:25:12 UTC (rev 41278)
@@ -1324,7 +1324,8 @@
                                public void FireMouseMove (MouseEventArgs e) 
                                {
                                        OnMouseMove (e);
-                               }
+                               }                       
+                               
                        }
 
                        public ComboListBox (ComboBox owner) : base ()
@@ -1341,8 +1342,7 @@
                                KeyDown += new KeyEventHandler (OnKeyDownPUW);
                                Paint += new PaintEventHandler (OnPaintPUW);    
                        
                                SetStyle (ControlStyles.UserPaint | 
ControlStyles.AllPaintingInWmPaint, true);
-                               SetStyle (ControlStyles.ResizeRedraw | 
ControlStyles.Opaque, true);
-                               
+                               SetStyle (ControlStyles.ResizeRedraw | 
ControlStyles.Opaque, true);                             
                        }
 
                        protected override CreateParams CreateParams
@@ -1408,29 +1408,31 @@
                                if (owner.Items.Count <= 
owner.MaxDropDownItems) {                                      
                                        
                                        /* Does not need vertical scrollbar*/
-                                       if (vscrollbar_ctrl != null) {
-                                               vscrollbar_ctrl.Dispose ();
-                                               Controls.Remove 
(vscrollbar_ctrl);
-                                               vscrollbar_ctrl = null;
+                                       if (vscrollbar_ctrl != null) {          
                                
+                                               vscrollbar_ctrl.Visible = 
false;                                                
                                        }                                       
                                }
                                else {
                                        /* Need vertical scrollbar */
-                                       vscrollbar_ctrl = new VScrollBarLB ();
-                                       vscrollbar_ctrl.Minimum = 0;
-                                       vscrollbar_ctrl.SmallChange = 1;
-                                       vscrollbar_ctrl.LargeChange = 1;
-                                       vscrollbar_ctrl.Maximum = 0;
-                                       vscrollbar_ctrl.ValueChanged += new 
EventHandler (VerticalScrollEvent);
+                                       if (vscrollbar_ctrl == null) {
+                                               vscrollbar_ctrl = new 
VScrollBarLB ();
+                                               vscrollbar_ctrl.Minimum = 0;
+                                               vscrollbar_ctrl.SmallChange = 1;
+                                               vscrollbar_ctrl.LargeChange = 1;
+                                               vscrollbar_ctrl.Maximum = 0;
+                                               vscrollbar_ctrl.ValueChanged += 
new EventHandler (VerticalScrollEvent);
+                                               
+                                               vscrollbar_ctrl.Height = height 
- ThemeEngine.Current.DrawComboListBoxDecorationBottom (owner.DropDownStyle) -
+                                                       
ThemeEngine.Current.DrawComboListBoxDecorationTop (owner.DropDownStyle);
+                                                       
+                                               vscrollbar_ctrl.Location = new 
Point (width - vscrollbar_ctrl.Width - 
ThemeEngine.Current.DrawComboListBoxDecorationRight (owner.DropDownStyle), 
+                                                       
ThemeEngine.Current.DrawComboListBoxDecorationTop (owner.DropDownStyle));
+                                               Controls.Add (vscrollbar_ctrl);
+                                       }
                                        
-                                       vscrollbar_ctrl.Height = height - 
ThemeEngine.Current.DrawComboListBoxDecorationBottom (owner.DropDownStyle) -
-                                               
ThemeEngine.Current.DrawComboListBoxDecorationTop (owner.DropDownStyle);
-                                               
-                                       vscrollbar_ctrl.Location = new Point 
(width - vscrollbar_ctrl.Width - 
ThemeEngine.Current.DrawComboListBoxDecorationRight (owner.DropDownStyle), 
-                                               
ThemeEngine.Current.DrawComboListBoxDecorationTop (owner.DropDownStyle));       
                                
-                                               
                                        vscrollbar_ctrl.Maximum = 
owner.Items.Count - owner.MaxDropDownItems;
-                                       Controls.Add (vscrollbar_ctrl);
+                                       vscrollbar_ctrl.Visible = true;         
                                
+                                       
                                }
                                
                                Size = new Size (width, height);
@@ -1445,9 +1447,10 @@
                                textarea_drawable.Width -= 
ThemeEngine.Current.DrawComboListBoxDecorationLeft (owner.DropDownStyle);
                                textarea_drawable.Height -= 
ThemeEngine.Current.DrawComboListBoxDecorationBottom (owner.DropDownStyle);     
                    
                                textarea_drawable.Height -= 
ThemeEngine.Current.DrawComboListBoxDecorationTop (owner.DropDownStyle);
+                                                               
                                
-                               if (vscrollbar_ctrl != null)
-                                       textarea_drawable.Width -= 
vscrollbar_ctrl.Width;
+                               if (vscrollbar_ctrl != null && 
vscrollbar_ctrl.Visible)
+                                       textarea_drawable.Width -= 
vscrollbar_ctrl.Width;                               
 
                                last_item = LastVisibleItem ();                 
        
                                page_size = textarea_drawable.Height / 
(item_height - 2);                               
@@ -1456,14 +1459,14 @@
                        private void Draw (Rectangle clip)
                        {       
                                DeviceContext.FillRectangle 
(ThemeEngine.Current.ResPool.GetSolidBrush
-                                       (owner.BackColor), ClientRectangle);
+                                       (owner.BackColor), ClientRectangle);    
                        
 
                                if (owner.Items.Count > 0) {
                                        Rectangle item_rect;
                                        DrawItemState state = 
DrawItemState.None;
                                        
                                        for (int i = top_item; i <= last_item; 
i++) {
-                                               item_rect = 
GetItemDisplayRectangle (i, top_item);
+                                               item_rect = 
GetItemDisplayRectangle (i, top_item);                                          
    
 
                                                if (clip.IntersectsWith 
(item_rect) == false)
                                                        continue;

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

Reply via email to