[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] pnetlib/System.Windows.Forms ButtonBase.cs, 1.14,
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] pnetlib/System.Windows.Forms ButtonBase.cs, 1.14, 1.15 CheckBox.cs, 1.12, 1.13 RadioButton.cs, 1.7, 1.8 |
Date: |
Tue, 02 Dec 2003 05:47:43 +0000 |
Update of /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms
In directory subversions:/tmp/cvs-serv18299/System.Windows.Forms
Modified Files:
ButtonBase.cs CheckBox.cs RadioButton.cs
Log Message:
Make some slight adjustments to the text on push buttons, check boxes,
and radio buttons so that middle-aligned text looks better (the text
descent is factored out of the centering calculation).
Index: ButtonBase.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/ButtonBase.cs,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** ButtonBase.cs 28 Nov 2003 18:51:04 -0000 1.14
--- ButtonBase.cs 2 Dec 2003 05:47:41 -0000 1.15
***************
*** 343,346 ****
--- 343,355 ----
}
+ // Get the descent in pixels for a font.
+ internal static float GetDescent(Graphics graphics, Font font)
+ {
+ FontFamily family = font.FontFamily;
+ int ascent = family.GetCellAscent(font.Style);
+ int descent = family.GetCellDescent(font.Style);
+ return font.GetHeight(graphics) * descent /
(ascent + descent);
+ }
+
// Draw the button in its current state on a Graphics surface.
internal virtual void Draw(Graphics graphics)
***************
*** 377,383 ****
}
// Draw the text on the button.
String text = Text;
- Font font = Font;
if(text != null && text != String.Empty)
{
--- 386,402 ----
}
+ // If we are using "middle" alignment, then
shift the
+ // text down to account for the descent. This
makes
+ // the button "look better".
+ Font font = Font;
+ if((TextAlign & (ContentAlignment.MiddleLeft |
+
ContentAlignment.MiddleCenter |
+
ContentAlignment.MiddleRight)) != 0)
+ {
+ layout.Offset(0.0f,
GetDescent(graphics, font) / 2.0f);
+ }
+
// Draw the text on the button.
String text = Text;
if(text != null && text != String.Empty)
{
Index: CheckBox.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/CheckBox.cs,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** CheckBox.cs 22 Nov 2003 23:37:48 -0000 1.12
--- CheckBox.cs 2 Dec 2003 05:47:41 -0000 1.13
***************
*** 251,257 ****
break;
}
! Rectangle rect = new Rectangle(x, y, width,
height);
String text = Text;
Font font = Font;
if(text != null && text != String.Empty)
{
--- 251,263 ----
break;
}
! RectangleF rect = new RectangleF(x, y, width,
height);
String text = Text;
Font font = Font;
+ if((TextAlign & (ContentAlignment.MiddleLeft |
+
ContentAlignment.MiddleCenter |
+
ContentAlignment.MiddleRight)) != 0)
+ {
+ rect.Offset(0.0f, GetDescent(graphics,
font) / 2.0f);
+ }
if(text != null && text != String.Empty)
{
Index: RadioButton.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/RadioButton.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** RadioButton.cs 22 Nov 2003 01:22:01 -0000 1.7
--- RadioButton.cs 2 Dec 2003 05:47:41 -0000 1.8
***************
*** 338,352 ****
rect = new Rectangle(x, y, width,
height);
}
!
if (Enabled)
{
using (Brush brush = new
SolidBrush(ForeColor))
{
! graphics.DrawString(Text, Font,
brush, rect, format);
}
}
else
{
!
ControlPaint.DrawStringDisabled(graphics, Text, Font, ForeColor, rect, format);
}
}
--- 338,359 ----
rect = new Rectangle(x, y, width,
height);
}
! RectangleF layout = rect;
! Font font = Font;
! if((TextAlign & (ContentAlignment.MiddleLeft |
!
ContentAlignment.MiddleCenter |
!
ContentAlignment.MiddleRight)) != 0)
! {
! layout.Offset(0.0f,
GetDescent(graphics, font) / 2.0f);
! }
if (Enabled)
{
using (Brush brush = new
SolidBrush(ForeColor))
{
! graphics.DrawString(Text, font,
brush, layout, format);
}
}
else
{
!
ControlPaint.DrawStringDisabled(graphics, Text, font, ForeColor, layout,
format);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] pnetlib/System.Windows.Forms ButtonBase.cs, 1.14, 1.15 CheckBox.cs, 1.12, 1.13 RadioButton.cs, 1.7, 1.8,
Rhys Weatherley <address@hidden> <=