|
@@ -369,21 +369,18 @@ namespace System.Windows.Forms
|
|
|
Image image = button.Image;
|
|
Image image = button.Image;
|
|
|
string text = button.Text;
|
|
string text = button.Text;
|
|
|
Rectangle content_rect = button.PaddingClientRectangle;
|
|
Rectangle content_rect = button.PaddingClientRectangle;
|
|
|
- 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 text_size = TextRenderer.MeasureTextInternal (g, text, button.Font, content_rect.Size, button.TextFormatFlags | TextFormatFlags.NoPadding, button.UseCompatibleTextRendering);
|
|
|
Size image_size = image == null ? Size.Empty : image.Size;
|
|
Size image_size = image == null ? Size.Empty : image.Size;
|
|
|
|
|
|
|
|
- textRectangle = Rectangle.Empty;
|
|
|
|
|
|
|
+ textRectangle = Rectangle.Inflate (content_rect, -4, -4);
|
|
|
imageRectangle = Rectangle.Empty;
|
|
imageRectangle = Rectangle.Empty;
|
|
|
|
|
|
|
|
switch (button.TextImageRelation) {
|
|
switch (button.TextImageRelation) {
|
|
|
case TextImageRelation.Overlay:
|
|
case TextImageRelation.Overlay:
|
|
|
// Overlay is easy, text always goes here
|
|
// Overlay is easy, text always goes here
|
|
|
- textRectangle = Rectangle.Inflate (content_rect, -4, -4);
|
|
|
|
|
|
|
|
|
|
- if (button.Pressed)
|
|
|
|
|
- textRectangle.Offset (1, 1);
|
|
|
|
|
|
|
+ if (button.Pressed)
|
|
|
|
|
+ textRectangle.Offset (1, 1);
|
|
|
|
|
|
|
|
// Image is dependent on ImageAlign
|
|
// Image is dependent on ImageAlign
|
|
|
if (image == null)
|
|
if (image == null)
|
|
@@ -440,16 +437,16 @@ namespace System.Windows.Forms
|
|
|
imageRectangle = new Rectangle (image_x, image_y, image_width, image_height);
|
|
imageRectangle = new Rectangle (image_x, image_y, image_width, image_height);
|
|
|
break;
|
|
break;
|
|
|
case TextImageRelation.ImageAboveText:
|
|
case TextImageRelation.ImageAboveText:
|
|
|
- LayoutTextAboveOrBelowImage (content_rect, false, text_size, image_size, button.TextAlign, button.ImageAlign, out textRectangle, out imageRectangle);
|
|
|
|
|
|
|
+ LayoutTextAboveOrBelowImage (textRectangle, false, text_size, image_size, button.TextAlign, button.ImageAlign, out textRectangle, out imageRectangle);
|
|
|
break;
|
|
break;
|
|
|
case TextImageRelation.TextAboveImage:
|
|
case TextImageRelation.TextAboveImage:
|
|
|
- LayoutTextAboveOrBelowImage (content_rect, true, text_size, image_size, button.TextAlign, button.ImageAlign, out textRectangle, out imageRectangle);
|
|
|
|
|
|
|
+ LayoutTextAboveOrBelowImage (textRectangle, true, text_size, image_size, button.TextAlign, button.ImageAlign, out textRectangle, out imageRectangle);
|
|
|
break;
|
|
break;
|
|
|
case TextImageRelation.ImageBeforeText:
|
|
case TextImageRelation.ImageBeforeText:
|
|
|
- LayoutTextBeforeOrAfterImage (content_rect, false, text_size, image_size, button.TextAlign, button.ImageAlign, out textRectangle, out imageRectangle);
|
|
|
|
|
|
|
+ LayoutTextBeforeOrAfterImage (textRectangle, false, text_size, image_size, button.TextAlign, button.ImageAlign, out textRectangle, out imageRectangle);
|
|
|
break;
|
|
break;
|
|
|
case TextImageRelation.TextBeforeImage:
|
|
case TextImageRelation.TextBeforeImage:
|
|
|
- LayoutTextBeforeOrAfterImage (content_rect, true, text_size, image_size, button.TextAlign, button.ImageAlign, out textRectangle, out imageRectangle);
|
|
|
|
|
|
|
+ LayoutTextBeforeOrAfterImage (textRectangle, true, text_size, image_size, button.TextAlign, button.ImageAlign, out textRectangle, out imageRectangle);
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -535,12 +532,14 @@ namespace System.Windows.Forms
|
|
|
offset += (int)(2 * (excess_height / 3));
|
|
offset += (int)(2 * (excess_height / 3));
|
|
|
|
|
|
|
|
if (textFirst) {
|
|
if (textFirst) {
|
|
|
- final_text_rect = new Rectangle (AlignInRectangle (totalArea, textSize, textAlign).Left, totalArea.Top + offset, textSize.Width, textSize.Height);
|
|
|
|
|
|
|
+ var textHeight = excess_height >= 0 ? totalArea.Height - imageSize.Height - element_spacing: textSize.Height;
|
|
|
|
|
+ final_text_rect = new Rectangle (AlignInRectangle (totalArea, textSize, textAlign).Left, totalArea.Top + offset, textSize.Width, textHeight);
|
|
|
final_image_rect = new Rectangle (AlignInRectangle (totalArea, imageSize, imageAlign).Left, final_text_rect.Bottom + element_spacing, imageSize.Width, imageSize.Height);
|
|
final_image_rect = new Rectangle (AlignInRectangle (totalArea, imageSize, imageAlign).Left, final_text_rect.Bottom + element_spacing, imageSize.Width, imageSize.Height);
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
final_image_rect = new Rectangle (AlignInRectangle (totalArea, imageSize, imageAlign).Left, totalArea.Top + offset, imageSize.Width, imageSize.Height);
|
|
final_image_rect = new Rectangle (AlignInRectangle (totalArea, imageSize, imageAlign).Left, totalArea.Top + offset, imageSize.Width, imageSize.Height);
|
|
|
- final_text_rect = new Rectangle (AlignInRectangle (totalArea, textSize, textAlign).Left, final_image_rect.Bottom + element_spacing, textSize.Width, textSize.Height);
|
|
|
|
|
|
|
+ var textHeight = excess_height >= 0 ? totalArea.Height - final_image_rect.Height : textSize.Height;
|
|
|
|
|
+ final_text_rect = new Rectangle (AlignInRectangle (totalArea, textSize, textAlign).Left, final_image_rect.Bottom + element_spacing, textSize.Width, textHeight);
|
|
|
|
|
|
|
|
if (final_text_rect.Bottom > totalArea.Bottom)
|
|
if (final_text_rect.Bottom > totalArea.Bottom)
|
|
|
final_text_rect.Y = totalArea.Top;
|
|
final_text_rect.Y = totalArea.Top;
|