* Application.cs: fix compilation errors when debug is enabled.
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / ToolBarButton.cs
index 1e867451204a5314bdc9426d279048eba1c29c7f..037b4ec731c2198443a737a72a002b82cd8a0970 100644 (file)
@@ -74,7 +74,7 @@ namespace System.Windows.Forms
                                        return;
 
                                hilight = value;
-                               InvalidateBorder ();
+                               Invalidate ();
                        }
                }
 
@@ -253,6 +253,8 @@ namespace System.Windows.Forms
                public string Text {
                        get { return text; }
                        set {
+                               if (value == null) value = "";
+
                                if (value == text)
                                        return;
 
@@ -266,7 +268,10 @@ namespace System.Windows.Forms
                [Localizable (true)]
                public string ToolTipText {
                        get { return tooltip; }
-                       set { tooltip = value; }
+                       set {
+                               if (value == null) value = "";
+                               tooltip = value;
+                       }
                }
 
                [DefaultValue (true)]
@@ -303,7 +308,7 @@ namespace System.Windows.Forms
 
                        Size psize = Parent.ButtonSize;
                        Size size = psize;
-                       if (!Parent.SizeSpecified) {
+                       if ((!Parent.SizeSpecified) || (Style == ToolBarButtonStyle.Separator)) {
                                size = CalculateSize ();
                                if (size.Width == 0 || size.Height == 0)
                                        size = psize;
@@ -325,10 +330,10 @@ namespace System.Windows.Forms
                        
                        if (Parent.TextAlign == ToolBarTextAlign.Underneath) {
                                new_image_rect = new Rectangle ((bounds.Size.Width - image_size.Width) / 2 - grip, 0, image_size.Width + 2 + grip, image_size.Height + 2 * grip);
-                               new_text_rect = new Rectangle (0, new_image_rect.Height, bounds.Size.Width, bounds.Size.Height - new_image_rect.Height);
+                               new_text_rect = new Rectangle (0, new_image_rect.Height, bounds.Size.Width, bounds.Size.Height - new_image_rect.Height - 2 * grip);
                        } else {
                                new_image_rect = new Rectangle (0, 0, image_size.Width + 2 * grip, image_size.Height + 2 * grip);
-                               new_text_rect = new Rectangle (new_image_rect.Width, 0, bounds.Size.Width - new_image_rect.Width, bounds.Size.Height);
+                               new_text_rect = new Rectangle (new_image_rect.Width, 0, bounds.Size.Width - new_image_rect.Width, bounds.Size.Height - 2 * grip);
                        }
 
                        bool changed = false;
@@ -384,28 +389,7 @@ namespace System.Windows.Forms
                        return size;
                }
 
-               internal void InvalidateBorder ()
-               {
-                       if (ThemeEngine.Current.ToolBarInvalidateEntireButton) {
-                               Invalidate ();
-                       }
-                       else {
-                               if (Rectangle == Rectangle.Empty)
-                                       return;
-
-                               /* invalidate the four sides of our border */
-                               Parent.Invalidate (new Rectangle (Rectangle.X - 2, Rectangle.Y - 2,
-                                                                 Rectangle.Width + 4, 4));
-                               Parent.Invalidate (new Rectangle (Rectangle.X - 2, Rectangle.Y - 2,
-                                                                 4, Rectangle.Height + 4));
-                               Parent.Invalidate (new Rectangle (Rectangle.X - 2, Rectangle.Y + Rectangle.Height - 2,
-                                                                 Rectangle.Width + 4, 4));
-                               Parent.Invalidate (new Rectangle (Rectangle.X + Rectangle.Width - 2, Rectangle.Y - 2,
-                                                                 4, Rectangle.Height + 4));
-                       }
-               }
-
-               void Invalidate ()
+               internal void Invalidate ()
                {
                        if (Parent != null)
                                Parent.Invalidate (Rectangle);