Hi.

I made a patch to fix bugs.
Please review it.


Best regards.
Kazuki Oikawa


StatusBar.cs
- SizingGrip area should not be allocated when it is not displayed.
- Now it reflects MinWidth of the containing panel and fixed a crash that 
happens when its width becomes so small.

ListBox.cs
- Items should be fully shown.
- When resizing and vertical scrollbar disappeared, the item of index 0 should 
be on the top of the list.
- GetItemRectangle should consider the size of vertical scrollbar.

ThemeWin32Classic.cs
- Fixed a bug that ListBox items were wrapped at the right end.

ComboBox.cs
- When DropDownStyle is Simple, it does not show scrollbar to the last item of 
the list.
- When DropDownStyle is Simple, it crashed when the list was scrolled down with 
the down cursor key.
- Fixed a bug that when DropDownStyle is DropDownList, the selected item was 
not shown.
- The position of the selected item was not preserved when the next dropdown 
happened.

CheckedListBox.cs
- (Fixed #1 of CheckedListBoxTest.CheckedListBoxPropertyTest.)

Tooltip.cs
- Fixed #Mtd2 of ToolTipTest.RemoveToolTipTest.)
Index: CheckedListBox.cs
===================================================================
--- CheckedListBox.cs   (リビジョン 50025)
+++ CheckedListBox.cs   (作業コピー)
@@ -387,6 +387,7 @@
                                listbox_items.Add (box_item);
                                if (check == CheckState.Checked)
                                        owner.OnItemCheck (new 
ItemCheckEventArgs (cnt, check, CheckState.Unchecked));
+                               owner.UpdateItemInfo (UpdateOperation.AddItems, 
cnt, cnt);
                                return cnt;
                        }
                }
Index: ComboBox.cs
===================================================================
--- ComboBox.cs (リビジョン 50025)
+++ ComboBox.cs (作業コピー)
@@ -1024,7 +1024,7 @@
                                                        selected_index, state, 
ForeColor, BackColor));
                        }                                               
                        
-                       if (clip.IntersectsWith (combobox_info.listbox_area) == 
true) {
+                       if (DropDownStyle == ComboBoxStyle.Simple && 
clip.IntersectsWith (combobox_info.listbox_area) == true) {
                                dc.FillRectangle 
(ThemeEngine.Current.ResPool.GetSolidBrush (Parent.BackColor), 
                                                combobox_info.listbox_area);
                        }
@@ -1535,7 +1535,7 @@
                                        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;
+                                       vscrollbar_ctrl.Maximum = 
owner.Items.Count - (owner.DropDownStyle == ComboBoxStyle.Simple ? page_size : 
owner.maxdrop_items);
                                        show_scrollbar = 
vscrollbar_ctrl.Visible = true;
                                        
                                }
@@ -1793,9 +1793,10 @@
 
                        public void SetTopItem (int item)
                        {
-                               top_item = item;
-                               UpdateLastVisibleItem ();
-                               Refresh ();
+                               if (vscrollbar_ctrl.Maximum < item)
+                                       vscrollbar_ctrl.Value = 
vscrollbar_ctrl.Maximum;
+                               else
+                                       vscrollbar_ctrl.Value = item;
                        }                       
                        
                        private void OnMouseDownPUW (object sender, 
MouseEventArgs e)
@@ -1906,8 +1907,14 @@
                                if (owner.DropDownStyle != ComboBoxStyle.Simple 
&& owner.Items.Count == 0)
                                        return false;
                                        
-                               SetTopItem (0);
-                               SetHighLightedItem (owner.SelectedItem);
+                               if (owner.SelectedIndex >= 0) {
+                                       if (owner.SelectedIndex <= 
owner.Items.Count - owner.MaxDropDownItems) {
+                                               SetTopItem 
(owner.SelectedIndex);
+                                       } else {
+                                               SetTopItem (owner.Items.Count - 
owner.MaxDropDownItems);
+                                       }
+                                       SetHighLightedItem (owner.SelectedItem);
+                               }
                                
                                CalcListBoxArea ();                             
                                Show ();
Index: ListBox.cs
===================================================================
--- ListBox.cs  (リビジョン 50025)
+++ ListBox.cs  (作業コピー)
@@ -132,6 +132,7 @@
                private bool ctrl_pressed;
                private bool shift_pressed;
                private bool has_focus;
+               private bool use_item_height;
                
                internal int focused_item;              
                internal ListBoxInfo listbox_info;
@@ -158,6 +159,7 @@
                        ctrl_pressed = false;
                        shift_pressed = false;
                        has_focus = false;
+                       use_item_height = false;
 
                        items = new ObjectCollection (this);
                        selected_indices = new SelectedIndexCollection (this);
@@ -379,6 +381,7 @@
                                        return;
 
                                listbox_info.item_height = value;
+                               use_item_height = true;
                                CalcClientArea ();
                        }
                }
@@ -747,18 +750,24 @@
                                
                                if (DrawMode == DrawMode.OwnerDrawVariable) {
                                        rect.Y = 0;
-                                       for (int i = 0; i < index; i++) {
-                                               rect.Y += GetItemHeight (i);
-                                       }                                       
+                                       if (index >= listbox_info.top_item) {
+                                               for (int i = 
listbox_info.top_item; i < index; i++) {
+                                                       rect.Y += GetItemHeight 
(i);
+                                               }
+                                       } else {
+                                               for (int i = index; i < 
listbox_info.top_item; i++) {
+                                                       rect.Y -= GetItemHeight 
(i);
+                                               }
+                                       }
                                } else {
-                                       rect.Y = ItemHeight * index;    
+                                       rect.Y = ItemHeight * (index - 
listbox_info.top_item);  
                                }                               
                        }
                        else {
                                int which_page;
 
                                which_page = index / listbox_info.page_size;
-                               rect.Y = (index % listbox_info.page_size) * 
ItemHeight;
+                               rect.Y = ((index - listbox_info.top_item) % 
listbox_info.page_size) * ItemHeight;
                                rect.X = which_page * ColumnWidthInternal;
                                rect.Height = ItemHeight;
                                rect.Width = ColumnWidthInternal;
@@ -834,11 +843,14 @@
                protected override void OnFontChanged (EventArgs e)
                {
                        base.OnFontChanged (e);
-                       listbox_info.item_height = FontHeight;
-
-                       RellocateScrollBars ();
-                       CalcClientArea ();
-                       UpdateItemInfo (UpdateOperation.AllItems, 0, 0);
+                       if (!use_item_height) {
+                               listbox_info.item_height = FontHeight;
+                               RellocateScrollBars ();
+                               CalcClientArea ();
+                               UpdateItemInfo (UpdateOperation.AllItems, 0, 0);
+                       } else {
+                               base.Refresh ();
+                       }
                }
 
                protected override void OnHandleCreated (EventArgs e)
@@ -1000,8 +1012,8 @@
                        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);
-                       listbox_info.textdrawing_rect.Width -= 
ThemeEngine.Current.DrawListBoxDecorationRight (BorderStyle);
+                       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);
 
                        if (listbox_info.show_verticalsb)
                                listbox_info.textdrawing_rect.Width -= 
vscrollbar_ctrl.Width;
@@ -1022,7 +1034,7 @@
                                }
                                                                
                        } else {                        
-                               listbox_info.page_size = 
listbox_info.textdrawing_rect.Height / listbox_info.item_height;
+                               listbox_info.page_size = 
listbox_info.textdrawing_rect.Height / ItemHeight;
                        }
 
                        if (listbox_info.page_size == 0) {
@@ -1037,7 +1049,7 @@
                                // items can still be partially shown if scroll 
bars are displayed.
 
                                int remaining =  
(listbox_info.client_rect.Height -
-                                       
ThemeEngine.Current.DrawListBoxDecorationBottom (BorderStyle) -
+                                       
ThemeEngine.Current.DrawListBoxDecorationTop (BorderStyle) -
                                        
ThemeEngine.Current.DrawListBoxDecorationBottom (BorderStyle)) %
                                        listbox_info.item_height;
 
@@ -1109,7 +1121,7 @@
 
                        item_rect.Y += 
ThemeEngine.Current.DrawListBoxDecorationTop (BorderStyle);
                        item_rect.X += 
ThemeEngine.Current.DrawListBoxDecorationLeft (BorderStyle);
-                       item_rect.Width -= 
ThemeEngine.Current.DrawListBoxDecorationRight (BorderStyle);
+                       item_rect.Width -= 
ThemeEngine.Current.DrawListBoxDecorationRight (BorderStyle);// + 
ThemeEngine.Current.DrawListBoxDecorationLeft (BorderStyle);
 
                        return item_rect;
                }
@@ -1165,7 +1177,7 @@
                                        }
                                        else {
                                                if (item_rect.Y + 
item_rect.Height > top_y)
-                                                       return i - 1;
+                                                       return i;
                                        }
                                }
                        }
@@ -1254,10 +1266,20 @@
 
                        case ItemNavigation.Next: {
                                if (focused_item + 1 < Items.Count) {   
-                                       if (focused_item + 1 > 
LBoxInfo.last_item) {
-                                               LBoxInfo.top_item++;
-                                               UpdatedTopItem ();              
                                
+                                       int actualHeight = 0;
+                                       if (draw_mode == 
DrawMode.OwnerDrawVariable) {
+                                               for (int i = LBoxInfo.top_item; 
i <= focused_item + 1; i++)
+                                                       actualHeight += 
GetItemHeight (i);
+                                       } else {
+                                               actualHeight = ((focused_item + 
1) - LBoxInfo.top_item + 1) * ItemHeight;
                                        }
+                                       if (actualHeight >= 
LBoxInfo.textdrawing_rect.Height) {
+                                               int bal = IntegralHeight ? 0 : 
(listbox_info.textdrawing_rect.Height == actualHeight ? 0 : 1);
+                                               if (focused_item + bal >= 
LBoxInfo.last_item) {
+                                                       LBoxInfo.top_item++;
+                                                       UpdatedTopItem ();      
                                        
+                                               }
+                                       }
                                        selected_index = focused_item + 1;
                                }
                                break;
@@ -1798,6 +1820,8 @@
                                        vscrollbar_ctrl.Maximum = Items.Count - 
listbox_info.page_size;
 
                                RellocateScrollBars ();
+                       } else if (vscrollbar_ctrl.Maximum > 0) {
+                               vscrollbar_ctrl.Maximum = 0;
                        }
 
                        CalcClientArea ();
Index: StatusBar.cs
===================================================================
--- StatusBar.cs        (リビジョン 50025)
+++ StatusBar.cs        (作業コピー)
@@ -324,7 +324,7 @@
                                }
                                if (p.AutoSize == 
StatusBarPanelAutoSize.Contents) {
                                        int len = (int) 
(DeviceContext.MeasureString (p.Text, Font).Width + 0.5F);
-                                       p.Width = (int) (len * 1.5F);
+                                       p.Width = (int) (len + 8);
                                        taken += p.Width;
                                        taken += gap;
                                        continue;
@@ -342,10 +342,11 @@
                                return;
 
                        int spring_total = springs.Count;
-                       int total_width = Width - taken - 
ThemeEngine.Current.StatusBarSizeGripWidth;
+                       int total_width = Width - taken - (SizingGrip ? 
ThemeEngine.Current.StatusBarSizeGripWidth : 0);
                        for (int i = 0; i < spring_total; i++) {
                                StatusBarPanel p = (StatusBarPanel) springs [i];
-                               p.Width = total_width / spring_total;
+                               int width = total_width / spring_total;
+                               p.Width = (width >= p.MinWidth ? width : 
p.MinWidth);
                        }
                }
 
Index: ThemeWin32Classic.cs
===================================================================
--- ThemeWin32Classic.cs        (リビジョン 50025)
+++ ThemeWin32Classic.cs        (作業コピー)
@@ -1437,7 +1437,7 @@
 
                        e.Graphics.DrawString (ctrl.GetItemText 
(ctrl.Items[e.Index]), e.Font,
                                ThemeEngine.Current.ResPool.GetSolidBrush 
(fore_color),
-                               e.Bounds, string_format);
+                               e.Bounds.X, e.Bounds.Y, string_format);
                                        
                        if ((e.State & DrawItemState.Focus) == 
DrawItemState.Focus) {
                                ThemeEngine.Current.CPDrawFocusRectangle 
(e.Graphics, e.Bounds,
Index: ToolTip.cs
===================================================================
--- ToolTip.cs  (リビジョン 50025)
+++ ToolTip.cs  (作業コピー)
@@ -270,7 +270,10 @@
                [Localizable (true)]
                [DefaultValue ("")]
                public string GetToolTip(Control control) {
-                       return (string)tooltip_strings[control];
+                       string tooltip = (string)tooltip_strings[control];
+                       if (tooltip == null)
+                               return "";
+                       return tooltip;
                }
 
                public void RemoveAll() {
_______________________________________________
Mono-winforms-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-winforms-list

Reply via email to