[Mono-winforms-list] Patch: RadioButton Color FlatStyle fixes
John BouAntoun
jba-mono@optusnet.com.au
Thu, 21 Oct 2004 23:02:18 +1000
--=-yzF1wrK3cEPYtuUXuAx7
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hey guys,
This patch contains some revisions that make sure the following
flatstyle in radio button is rendered properly:
1) Hover and Click behaviour for Colored FlatStyle.Flat radiobuttons
2) Hover and click behaviour for Colored FlatStyle.Popup radiobuttons
3) Disabled rendering fixes for colored flatstyle radiobuttons (both)
4) Disabled text rendering for all radiobuttons
Regards,
JBA
--=-yzF1wrK3cEPYtuUXuAx7
Content-Disposition: attachment; filename=RadioButtonColorFlatStyleFixes.patch
Content-Type: text/x-patch; name=RadioButtonColorFlatStyleFixes.patch; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
? Makefile.SWF
? Makefile.solution.SWF
? RadioButtonColorFlatStyleFixes.patch
? SWF.cmbx
? SWF.mdsx
? SWF.pidb
? SWF.prjx
? make.sh
Index: System.Windows.Forms/ThemeWin32Classic.cs
===================================================================
RCS file: /cvs/public/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs,v
retrieving revision 1.49
diff -u -r1.49 ThemeWin32Classic.cs
--- System.Windows.Forms/ThemeWin32Classic.cs 18 Oct 2004 04:49:25 -0000 1.49
+++ System.Windows.Forms/ThemeWin32Classic.cs 21 Oct 2004 11:38:50 -0000
@@ -1122,6 +1122,14 @@
sb=new SolidBrush(radio_button.ForeColor);
dc.DrawString (radio_button.Text, radio_button.Font, sb, inner_text_rectangle, text_format);
sb.Dispose();
+ if (radio_button.Enabled) {
+ sb = ResPool.GetSolidBrush(radio_button.ForeColor);
+ dc.DrawString(radio_button.Text, radio_button.Font, sb, inner_text_rectangle, text_format);
+ } else if (radio_button.FlatStyle == FlatStyle.Flat) {
+ dc.DrawString(radio_button.Text, radio_button.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorButtonFace)), inner_text_rectangle, text_format);
+ } else {
+ CPDrawStringDisabled(dc, radio_button.Text, radio_button.Font, this.ColorButtonText, inner_text_rectangle, text_format);
+ }
if (radio_button.Focused) {
ControlPaint.DrawFocusRectangle(dc, text_rectangle);
@@ -1133,24 +1141,40 @@
{
int lineWidth;
- // win32 compat fill in the background of the knob
- graphics.FillPie (ResPool.GetSolidBrush (this.ColorWindow), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
-
- // draw the outer flatstyle arcs
- if (radio_button.FlatStyle == FlatStyle.Flat) {
- graphics.DrawArc (ResPool.GetPen (ColorButtonText), rectangle, 0, 359);
- } else {
- // must be a popup radio button
- if (radio_button.is_entered) {
- // draw the popup 3d button knob
- graphics.DrawArc (SystemPens.ControlLight, rectangle.X+1, rectangle.Y+1, rectangle.Width-2, rectangle.Height-2, 0, 359);
-
- graphics.DrawArc (SystemPens.ControlDark, rectangle, 135, 180);
- graphics.DrawArc (SystemPens.ControlLightLight, rectangle, 315, 180);
+ if (radio_button.Enabled) {
+ // draw the outer flatstyle arcs
+ if (radio_button.FlatStyle == FlatStyle.Flat) {
+ graphics.DrawArc (ResPool.GetPen (radio_button.ForeColor), rectangle, 0, 359);
+
+ // fill in the area depending on whether or not the mouse is hovering
+ if (radio_button.is_entered && radio_button.Capture) {
+ graphics.FillPie (ResPool.GetSolidBrush (ControlPaint.Light (radio_button.BackColor)), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
+ } else {
+ graphics.FillPie (ResPool.GetSolidBrush (ControlPaint.LightLight (radio_button.BackColor)), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
+ }
} else {
- // just draw lighter flatstyle outer circle
- graphics.DrawArc (SystemPens.ControlDark, rectangle, 0, 359);
+ // must be a popup radio button
+ // fill the control
+ graphics.FillPie (ResPool.GetSolidBrush (ControlPaint.LightLight (radio_button.BackColor)), rectangle, 0, 359);
+
+ if (radio_button.is_entered || radio_button.Capture) {
+ // draw the popup 3d button knob
+ graphics.DrawArc (ResPool.GetPen (ControlPaint.Light (radio_button.BackColor)), rectangle.X+1, rectangle.Y+1, rectangle.Width-2, rectangle.Height-2, 0, 359);
+
+ graphics.DrawArc (ResPool.GetPen (ControlPaint.Dark (radio_button.BackColor)), rectangle, 135, 180);
+ graphics.DrawArc (ResPool.GetPen (ControlPaint.LightLight (radio_button.BackColor)), rectangle, 315, 180);
+
+ } else {
+ // just draw lighter flatstyle outer circle
+ graphics.DrawArc (ResPool.GetPen (ControlPaint.Dark (this.ColorButtonFace)), rectangle, 0, 359);
+ }
}
+ } else {
+ // disabled
+ // fill control background color regardless of actual backcolor
+ graphics.FillPie (ResPool.GetSolidBrush (this.ColorButtonFace), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
+ // draw the ark as control dark
+ graphics.DrawArc (ResPool.GetPen (ControlPaint.Dark(this.ColorButtonFace)), rectangle, 0, 359);
}
// draw the check
@@ -1159,12 +1183,14 @@
SolidBrush buttonBrush;
if (!radio_button.Enabled) {
- buttonBrush = (SolidBrush) SystemBrushes.ControlDark;
+ buttonBrush = ResPool.GetSolidBrush (ControlPaint.Dark (this.ColorButtonFace));
+ } else if (radio_button.FlatStyle == FlatStyle.Popup && radio_button.is_entered && radio_button.Capture) {
+ buttonBrush = ResPool.GetSolidBrush (this.ColorButtonText);
} else {
- buttonBrush = (SolidBrush) SystemBrushes.ControlText;
+ buttonBrush = ResPool.GetSolidBrush (radio_button.ForeColor);
}
graphics.FillPie (buttonBrush, rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2, 0, 359);
- }
+ }
}
public override Size RadioButtonDefaultSize {
--=-yzF1wrK3cEPYtuUXuAx7--