Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEberhard Beilharz <eb1@sil.org>2014-10-07 19:34:44 +0400
committerEberhard Beilharz <eb1@sil.org>2014-10-07 19:34:44 +0400
commitaab88e769c048bb091c6f1ad564d260d1205fd03 (patch)
treeafc59966a259e0016c00fc180ecf373e579868d0 /mcs/class/Managed.Windows.Forms/System.Windows.Forms
parentfa2c2870e56fa25ee1142ebdba9910a07504eda8 (diff)
[MWF] Pass graphics when calculating button text and image
This fixes a problem with calculating the text width of a button which caused the text to get truncated under certain circumstances instead of being wrapped. This fixes Xamarin-23168. Change-Id: Iac0d8a2720a99cf5433e05d5123a04c4b019e493
Diffstat (limited to 'mcs/class/Managed.Windows.Forms/System.Windows.Forms')
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs2
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs2
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs10
3 files changed, 6 insertions, 8 deletions
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs
index dc640e836cd..e04f3997168 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs
@@ -175,7 +175,7 @@ namespace System.Windows.Forms {
Rectangle text_rectangle;
Rectangle image_rectangle;
- ThemeEngine.Current.CalculateButtonTextAndImageLayout (this, out text_rectangle, out image_rectangle);
+ ThemeEngine.Current.CalculateButtonTextAndImageLayout (pevent.Graphics, this, out text_rectangle, out image_rectangle);
// Draw our button
if (this.FlatStyle == FlatStyle.Standard)
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs
index 18ee3dd8117..b8cc63b7e81 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs
@@ -698,7 +698,7 @@ namespace System.Windows.Forms
#region Button
public abstract Size CalculateButtonAutoSize (Button button);
- public abstract void CalculateButtonTextAndImageLayout (ButtonBase b, out Rectangle textRectangle, out Rectangle imageRectangle);
+ public abstract void CalculateButtonTextAndImageLayout (Graphics g, ButtonBase b, out Rectangle textRectangle, out Rectangle imageRectangle);
public abstract void DrawButton (Graphics g, Button b, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle);
public abstract void DrawFlatButton (Graphics g, ButtonBase b, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle);
public abstract void DrawPopupButton (Graphics g, Button b, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle);
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
index 522dec40ec6..a9ed1ebec31 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
@@ -364,12 +364,14 @@ namespace System.Windows.Forms
return ret_size;
}
- public override void CalculateButtonTextAndImageLayout (ButtonBase button, out Rectangle textRectangle, out Rectangle imageRectangle)
+ public override void CalculateButtonTextAndImageLayout (Graphics g, ButtonBase button, out Rectangle textRectangle, out Rectangle imageRectangle)
{
Image image = button.Image;
string text = button.Text;
Rectangle content_rect = button.PaddingClientRectangle;
- Size text_size = TextRenderer.MeasureTextInternal (text, button.Font, content_rect.Size, button.TextFormatFlags, button.UseCompatibleTextRendering);
+ if (button.TextImageRelation != TextImageRelation.Overlay)
+ content_rect.Inflate(-4, -4);
+ Size text_size = TextRenderer.MeasureTextInternal (g, text, button.Font, content_rect.Size, button.TextFormatFlags, button.UseCompatibleTextRendering);
Size image_size = image == null ? Size.Empty : image.Size;
textRectangle = Rectangle.Empty;
@@ -438,19 +440,15 @@ namespace System.Windows.Forms
imageRectangle = new Rectangle (image_x, image_y, image_width, image_height);
break;
case TextImageRelation.ImageAboveText:
- content_rect.Inflate (-4, -4);
LayoutTextAboveOrBelowImage (content_rect, false, text_size, image_size, button.TextAlign, button.ImageAlign, out textRectangle, out imageRectangle);
break;
case TextImageRelation.TextAboveImage:
- content_rect.Inflate (-4, -4);
LayoutTextAboveOrBelowImage (content_rect, true, text_size, image_size, button.TextAlign, button.ImageAlign, out textRectangle, out imageRectangle);
break;
case TextImageRelation.ImageBeforeText:
- content_rect.Inflate (-4, -4);
LayoutTextBeforeOrAfterImage (content_rect, false, text_size, image_size, button.TextAlign, button.ImageAlign, out textRectangle, out imageRectangle);
break;
case TextImageRelation.TextBeforeImage:
- content_rect.Inflate (-4, -4);
LayoutTextBeforeOrAfterImage (content_rect, true, text_size, image_size, button.TextAlign, button.ImageAlign, out textRectangle, out imageRectangle);
break;
}