Author: jpobst
Date: 2007-08-22 16:39:39 -0400 (Wed, 22 Aug 2007)
New Revision: 84661

Added:
   
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Theming/Default/CheckBoxPainter.cs
Modified:
   trunk/mcs/class/Managed.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Theming/ChangeLog
   
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Theming/Default/ChangeLog
   
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Theming/ThemeElements.cs
   
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Theming/ThemeElementsDefault.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CheckBox.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs
   
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
Log:
2007-08-22  Jonathan Pobst  <[EMAIL PROTECTED]>

        * CheckBox.cs: Use new 2.0 rendering for 2.0.
        * Theme.cs: Method declarations for 2.0 rendering path.
        * ThemeWin32Classic.cs: 2.0 rendering implementation for CheckBox.

2007-08-22  Jonathan Pobst  <[EMAIL PROTECTED]>

        * System.Windows.Forms.dll.sources: CheckBoxPainter.cs.

2007-08-22  Jonathan Pobst  <[EMAIL PROTECTED]>

        * CheckBoxPainter.cs: Added.

2007-08-22  Jonathan Pobst  <[EMAIL PROTECTED]>

        * ThemeElementsDefault.cs: Add accessor for CheckBoxPainter.

Modified: trunk/mcs/class/Managed.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/ChangeLog     2007-08-22 20:16:55 UTC 
(rev 84660)
+++ trunk/mcs/class/Managed.Windows.Forms/ChangeLog     2007-08-22 20:39:39 UTC 
(rev 84661)
@@ -1,3 +1,7 @@
+2007-08-22  Jonathan Pobst  <[EMAIL PROTECTED]>
+
+       * System.Windows.Forms.dll.sources: CheckBoxPainter.cs.
+
 2007-08-21  Rolf Bjarne Kvinge <[EMAIL PROTECTED]> 
 
        * System.Windows.Forms_test.dll.sources: Added

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-08-22 20:16:55 UTC (rev 84660)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-08-22 20:39:39 UTC (rev 84661)
@@ -1,3 +1,9 @@
+2007-08-22  Jonathan Pobst  <[EMAIL PROTECTED]>
+
+       * CheckBox.cs: Use new 2.0 rendering for 2.0.
+       * Theme.cs: Method declarations for 2.0 rendering path.
+       * ThemeWin32Classic.cs: 2.0 rendering implementation for CheckBox.
+
 2007-08-21  Carlos Alberto Cortez <[EMAIL PROTECTED]>
 
        * ListViewGroupCollection.cs: Fix a typo of the previous patch.

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CheckBox.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CheckBox.cs      
2007-08-22 20:16:55 UTC (rev 84660)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CheckBox.cs      
2007-08-22 20:39:39 UTC (rev 84661)
@@ -119,7 +119,25 @@
 
                #region Internal Methods
                internal override void Draw (PaintEventArgs pe) {
+#if NET_2_0
+                       // FIXME: This should be called every time something 
that can affect it
+                       // is changed, not every paint.  Can only change so 
many things at a time.
+
+                       // Figure out where our text and image should go
+                       Rectangle glyph_rectangle;
+                       Rectangle text_rectangle;
+                       Rectangle image_rectangle;
+
+                       ThemeEngine.Current.CalculateCheckBoxTextAndImageLayout 
(this, Point.Empty, out glyph_rectangle, out text_rectangle, out 
image_rectangle);
+
+                       // Draw our button
+                       if (FlatStyle != FlatStyle.System)
+                               ThemeEngine.Current.DrawCheckBox (pe.Graphics, 
this, glyph_rectangle, text_rectangle, image_rectangle, pe.ClipRectangle);
+                       else
+                               ThemeEngine.Current.DrawCheckBox (pe.Graphics, 
this.ClientRectangle, this);
+#else
                        ThemeEngine.Current.DrawCheckBox (pe.Graphics, 
this.ClientRectangle, this);
+#endif
                }
 
                internal override void HaveDoubleClick() {

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs 
2007-08-22 20:16:55 UTC (rev 84660)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs 
2007-08-22 20:39:39 UTC (rev 84661)
@@ -724,7 +724,12 @@
                #endregion      // ButtonBase
 
                #region CheckBox
-               public abstract void DrawCheckBox(Graphics dc, Rectangle 
clip_area, CheckBox checkbox);
+#if NET_2_0
+               public abstract void CalculateCheckBoxTextAndImageLayout 
(ButtonBase b, Point offset, out Rectangle glyphArea, out Rectangle 
textRectangle, out Rectangle imageRectangle);
+               public abstract void DrawCheckBox (Graphics g, CheckBox cb, 
Rectangle textBounds, Rectangle glyphArea, Rectangle imageBounds, Rectangle 
clipRectangle);
+#endif
+               public abstract void DrawCheckBox (Graphics dc, Rectangle 
clip_area, CheckBox checkbox);
+
                #endregion      // CheckBox
                
                #region CheckedListBox

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs 
    2007-08-22 20:16:55 UTC (rev 84660)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs 
    2007-08-22 20:39:39 UTC (rev 84661)
@@ -874,6 +874,156 @@
                #endregion      // ButtonBase
 
                #region CheckBox
+#if NET_2_0
+               public override void DrawCheckBox (Graphics g, CheckBox cb, 
Rectangle glyphArea, Rectangle textBounds, Rectangle imageBounds, Rectangle 
clipRectangle)
+               {
+                       // Draw Button Background
+                       DrawCheckBoxGlyph (g, cb, glyphArea);
+
+                       // If we have an image, draw it
+                       if (imageBounds.Size != Size.Empty)
+                               DrawCheckBoxImage (g, cb, imageBounds);
+
+                       if (cb.Focused && cb.Enabled && 
cb.ShowKeyboardCuesInternal && textBounds != Rectangle.Empty)
+                               DrawCheckBoxFocus (g, cb, textBounds);
+
+                       // If we have text, draw it
+                       if (textBounds != Rectangle.Empty)
+                               DrawCheckBoxText (g, cb, textBounds);
+               }
+
+               public virtual void DrawCheckBoxGlyph (Graphics g, CheckBox cb, 
Rectangle glyphArea)
+               {
+                       if (cb.Pressed)
+                               
ThemeElements.CurrentTheme.CheckBoxPainter.PaintCheckBox (g, glyphArea, 
cb.BackColor, cb.ForeColor, ElementState.Pressed, cb.FlatStyle, cb.CheckState);
+                       else if (cb.InternalSelected)
+                               
ThemeElements.CurrentTheme.CheckBoxPainter.PaintCheckBox (g, glyphArea, 
cb.BackColor, cb.ForeColor, ElementState.Normal, cb.FlatStyle, cb.CheckState);
+                       else if (cb.Entered)
+                               
ThemeElements.CurrentTheme.CheckBoxPainter.PaintCheckBox (g, glyphArea, 
cb.BackColor, cb.ForeColor, ElementState.Hot, cb.FlatStyle, cb.CheckState);
+                       else if (!cb.Enabled)
+                               
ThemeElements.CurrentTheme.CheckBoxPainter.PaintCheckBox (g, glyphArea, 
cb.BackColor, cb.ForeColor, ElementState.Disabled, cb.FlatStyle, cb.CheckState);
+                       else
+                               
ThemeElements.CurrentTheme.CheckBoxPainter.PaintCheckBox (g, glyphArea, 
cb.BackColor, cb.ForeColor, ElementState.Normal, cb.FlatStyle, cb.CheckState);
+               }
+
+               public virtual void DrawCheckBoxFocus (Graphics g, CheckBox cb, 
Rectangle focusArea)
+               {
+                       ControlPaint.DrawFocusRectangle (g, focusArea);
+               }
+
+               public virtual void DrawCheckBoxImage (Graphics g, CheckBox cb, 
Rectangle imageBounds)
+               {
+                       if (cb.Enabled)
+                               g.DrawImage (cb.Image, imageBounds);
+                       else
+                               CPDrawImageDisabled (g, cb.Image, 
imageBounds.Left, imageBounds.Top, ColorControl);
+               }
+
+               public virtual void DrawCheckBoxText (Graphics g, CheckBox cb, 
Rectangle textBounds)
+               {
+                       if (cb.Enabled)
+                               TextRenderer.DrawTextInternal (g, cb.Text, 
cb.Font, textBounds, cb.ForeColor, cb.TextFormatFlags, 
cb.UseCompatibleTextRendering);
+                       else
+                               DrawStringDisabled20 (g, cb.Text, cb.Font, 
textBounds, cb.BackColor, cb.TextFormatFlags, cb.UseCompatibleTextRendering);
+               }
+
+               public override void CalculateCheckBoxTextAndImageLayout 
(ButtonBase button, Point p, out Rectangle glyphArea, out Rectangle 
textRectangle, out Rectangle imageRectangle)
+               {
+                       int check_size = 13;
+                       glyphArea = new Rectangle (0, (button.Height - 
check_size) / 2, check_size, check_size);
+                       
+                       Image image = button.Image;
+                       string text = button.Text;
+                       Rectangle content_rect = button.ClientRectangle;
+                       content_rect.Width -= check_size;
+                       content_rect.Offset (check_size, 0);
+                       
+                       Size text_size = TextRenderer.MeasureTextInternal 
(text, button.Font, content_rect.Size, button.TextFormatFlags, 
button.UseCompatibleTextRendering);
+                       Size image_size = image == null ? Size.Empty : 
image.Size;
+
+                       textRectangle = Rectangle.Empty;
+                       imageRectangle = Rectangle.Empty;
+
+                       switch (button.TextImageRelation) {
+                               case TextImageRelation.Overlay:
+                                       // Overlay is easy, text always goes 
here
+                                       textRectangle = Rectangle.Inflate 
(content_rect, -4, -4);
+                                       textRectangle.Offset (0, -2);
+
+                                       // Image is dependent on ImageAlign
+                                       if (image == null)
+                                               return;
+
+                                       int image_x = 0;
+                                       int image_y = 0;
+                                       int image_height = image.Height;
+                                       int image_width = image.Width;
+
+                                       switch (button.ImageAlign) {
+                                               case 
System.Drawing.ContentAlignment.TopLeft:
+                                                       image_x = 5;
+                                                       image_y = 5;
+                                                       break;
+                                               case 
System.Drawing.ContentAlignment.TopCenter:
+                                                       image_x = 
(content_rect.Width - image_width) / 2;
+                                                       image_y = 5;
+                                                       break;
+                                               case 
System.Drawing.ContentAlignment.TopRight:
+                                                       image_x = 
content_rect.Width - image_width - 5;
+                                                       image_y = 5;
+                                                       break;
+                                               case 
System.Drawing.ContentAlignment.MiddleLeft:
+                                                       image_x = 5;
+                                                       image_y = 
(content_rect.Height - image_height) / 2;
+                                                       break;
+                                               case 
System.Drawing.ContentAlignment.MiddleCenter:
+                                                       image_x = 
(content_rect.Width - image_width) / 2;
+                                                       image_y = 
(content_rect.Height - image_height) / 2;
+                                                       break;
+                                               case 
System.Drawing.ContentAlignment.MiddleRight:
+                                                       image_x = 
content_rect.Width - image_width - 4;
+                                                       image_y = 
(content_rect.Height - image_height) / 2;
+                                                       break;
+                                               case 
System.Drawing.ContentAlignment.BottomLeft:
+                                                       image_x = 5;
+                                                       image_y = 
content_rect.Height - image_height - 4;
+                                                       break;
+                                               case 
System.Drawing.ContentAlignment.BottomCenter:
+                                                       image_x = 
(content_rect.Width - image_width) / 2;
+                                                       image_y = 
content_rect.Height - image_height - 4;
+                                                       break;
+                                               case 
System.Drawing.ContentAlignment.BottomRight:
+                                                       image_x = 
content_rect.Width - image_width - 4;
+                                                       image_y = 
content_rect.Height - image_height - 4;
+                                                       break;
+                                               default:
+                                                       image_x = 5;
+                                                       image_y = 5;
+                                                       break;
+                                       }
+
+                                       imageRectangle = new Rectangle (image_x 
+ check_size, 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;
+                       }
+               }
+#endif
+
                public override void DrawCheckBox(Graphics dc, Rectangle 
clip_area, CheckBox checkbox) {
                        StringFormat            text_format;
                        Rectangle               client_rectangle;

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Theming/ChangeLog
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Theming/ChangeLog    
    2007-08-22 20:16:55 UTC (rev 84660)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Theming/ChangeLog    
    2007-08-22 20:39:39 UTC (rev 84661)
@@ -1,3 +1,8 @@
+2007-08-22  Jonathan Pobst  <[EMAIL PROTECTED]>
+
+       * ThemeElementsDefault.cs: Add accessor for CheckBoxPainter.
+       * ThemeElements.cs: Add enum for button states.
+
 2007-07-03  Jonathan Pobst  <[EMAIL PROTECTED]>
 
        * ThemeElementsDefault.cs: Add accessor for ToolStripPainter.

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Theming/Default/ChangeLog
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Theming/Default/ChangeLog
        2007-08-22 20:16:55 UTC (rev 84660)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Theming/Default/ChangeLog
        2007-08-22 20:39:39 UTC (rev 84661)
@@ -1,26 +1,30 @@
-2007-08-19  Everaldo Canuto  <[EMAIL PROTECTED]>
-
-       * TabControlPainter.cs: Fix regression in default padding x.
-
-2007-08-19  Everaldo Canuto  <[EMAIL PROTECTED]>
-
-       * TabControlPainter.cs: Fix border thickness, padding and tab text 
format to 
-       be horizontal centralized. Fixes #82471.
-
-2007-08-18  Everaldo Canuto  <[EMAIL PROTECTED]>
-
-       * TabControlPainter.cs: Remove one vertical pixel from tab drawing, the 
-       bottom line was one pixel more than needed.
-
-2007-07-26  Everaldo Canuto  <[EMAIL PROTECTED]>
-
-       * TabControlPainter.cs: Adjust vertical image position on tab. Fixes 
#81837.
-
-2007-07-26  Everaldo Canuto  <[EMAIL PROTECTED]>
-
-       * TabControlPainter.cs: Uses str_rect to draw text since it take in 
account
-       the image size. Fixes #81836.
-
+2007-08-22  Jonathan Pobst  <[EMAIL PROTECTED]>
+
+       * CheckBoxPainter.cs: Added.
+
+2007-08-19  Everaldo Canuto  <[EMAIL PROTECTED]>
+
+       * TabControlPainter.cs: Fix regression in default padding x.
+
+2007-08-19  Everaldo Canuto  <[EMAIL PROTECTED]>
+
+       * TabControlPainter.cs: Fix border thickness, padding and tab text 
format to 
+       be horizontal centralized. Fixes #82471.
+
+2007-08-18  Everaldo Canuto  <[EMAIL PROTECTED]>
+
+       * TabControlPainter.cs: Remove one vertical pixel from tab drawing, the 
+       bottom line was one pixel more than needed.
+
+2007-07-26  Everaldo Canuto  <[EMAIL PROTECTED]>
+
+       * TabControlPainter.cs: Adjust vertical image position on tab. Fixes 
#81837.
+
+2007-07-26  Everaldo Canuto  <[EMAIL PROTECTED]>
+
+       * TabControlPainter.cs: Uses str_rect to draw text since it take in 
account
+       the image size. Fixes #81836.
+
 2007-07-20  Jonathan Pobst  <[EMAIL PROTECTED]>
 
        * ToolStripPainter.cs: Patch from Rolf.  We weren't painting a

Added: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Theming/Default/CheckBoxPainter.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Theming/Default/CheckBoxPainter.cs
       2007-08-22 20:16:55 UTC (rev 84660)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Theming/Default/CheckBoxPainter.cs
       2007-08-22 20:39:39 UTC (rev 84661)
@@ -0,0 +1,359 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2007 Novell, Inc.
+//
+// Authors:
+//     Jonathan Pobst ([EMAIL PROTECTED])
+
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+#if NET_2_0
+namespace System.Windows.Forms.Theming.Default
+{
+       /// <summary>
+       /// Summary description for Button.
+       /// </summary>
+       internal class CheckBoxPainter
+       {
+               public CheckBoxPainter ()
+               {
+               }
+
+               protected SystemResPool ResPool { get { return 
ThemeEngine.Current.ResPool; } }
+
+               public void PaintCheckBox (Graphics g, Rectangle bounds, Color 
backColor, Color foreColor, ElementState state, FlatStyle style, CheckState 
checkState)
+               {
+                       switch (style) {
+                               case FlatStyle.Standard:
+                               case FlatStyle.System:
+                                       switch (state) {
+                                               case ElementState.Normal:
+                                                       DrawNormalCheckBox (g, 
bounds, backColor, foreColor, checkState);
+                                                       break;
+                                               case ElementState.Hot:
+                                                       DrawHotCheckBox (g, 
bounds, backColor, foreColor, checkState);
+                                                       break;
+                                               case ElementState.Pressed:
+                                                       DrawPressedCheckBox (g, 
bounds, backColor, foreColor, checkState);
+                                                       break;
+                                               case ElementState.Disabled:
+                                                       DrawDisabledCheckBox 
(g, bounds, backColor, foreColor, checkState);
+                                                       break;
+                                       }
+                                       break;
+                               case FlatStyle.Flat:
+                                       switch (state) {
+                                               case ElementState.Normal:
+                                                       DrawFlatNormalCheckBox 
(g, bounds, backColor, foreColor, checkState);
+                                                       break;
+                                               case ElementState.Hot:
+                                                       DrawFlatHotCheckBox (g, 
bounds, backColor, foreColor, checkState);
+                                                       break;
+                                               case ElementState.Pressed:
+                                                       DrawFlatPressedCheckBox 
(g, bounds, backColor, foreColor, checkState);
+                                                       break;
+                                               case ElementState.Disabled:
+                                                       
DrawFlatDisabledCheckBox (g, bounds, backColor, foreColor, checkState);
+                                                       break;
+                                       }
+                                       break;
+                               case FlatStyle.Popup:
+                                       switch (state) {
+                                               case ElementState.Normal:
+                                                       DrawPopupNormalCheckBox 
(g, bounds, backColor, foreColor, checkState);
+                                                       break;
+                                               case ElementState.Hot:
+                                                       DrawPopupHotCheckBox 
(g, bounds, backColor, foreColor, checkState);
+                                                       break;
+                                               case ElementState.Pressed:
+                                                       
DrawPopupPressedCheckBox (g, bounds, backColor, foreColor, checkState);
+                                                       break;
+                                               case ElementState.Disabled:
+                                                       
DrawPopupDisabledCheckBox (g, bounds, backColor, foreColor, checkState);
+                                                       break;
+                                       }
+                                       break;
+                       }
+               }
+
+               #region Standard
+               public virtual void DrawNormalCheckBox (Graphics g, Rectangle 
bounds, Color backColor, Color foreColor, CheckState state)
+               {
+                       int check_box_visible_size = (bounds.Height > 
bounds.Width) ? bounds.Width : bounds.Height;
+                       int x_pos = Math.Max (0, bounds.X + (bounds.Width / 2) 
- check_box_visible_size / 2);
+                       int y_pos = Math.Max (0, bounds.Y + (bounds.Height / 2) 
- check_box_visible_size / 2);
+
+                       Rectangle rect = new Rectangle (x_pos, y_pos, 
check_box_visible_size, check_box_visible_size);
+
+                       g.FillRectangle (SystemBrushes.ControlLightLight, 
rect.X + 2, rect.Y + 2, rect.Width - 3, rect.Height - 3);
+
+                       Pen pen = SystemPens.ControlDark;
+                       g.DrawLine (pen, rect.X, rect.Y, rect.X, rect.Bottom - 
2);
+                       g.DrawLine (pen, rect.X + 1, rect.Y, rect.Right - 2, 
rect.Y);
+
+                       pen = SystemPens.ControlDarkDark;
+                       g.DrawLine (pen, rect.X + 1, rect.Y + 1, rect.X + 1, 
rect.Bottom - 3);
+                       g.DrawLine (pen, rect.X + 2, rect.Y + 1, rect.Right - 
3, rect.Y + 1);
+
+                       pen = SystemPens.ControlLight;
+                       g.DrawLine (pen, rect.Right - 1, rect.Y, rect.Right - 
1, rect.Bottom - 1);
+                       g.DrawLine (pen, rect.X, rect.Bottom - 1, rect.Right - 
1, rect.Bottom - 1);
+
+                       // oh boy, matching ms is like fighting against 
windmills
+                       using (Pen h_pen = new Pen (ResPool.GetHatchBrush 
(HatchStyle.Percent50,
+                                                                          
Color.FromArgb (Clamp (ColorControl.R + 3, 0, 255),
+                                                                               
           ColorControl.G, ColorControl.B), ColorControl))) {
+                               g.DrawLine (h_pen, rect.X + 1, rect.Bottom - 2, 
rect.Right - 2, rect.Bottom - 2);
+                               g.DrawLine (h_pen, rect.Right - 2, rect.Y + 1, 
rect.Right - 2, rect.Bottom - 2);
+                       }
+                       
+                       if (state == CheckState.Checked)
+                               DrawCheck (g, bounds, Color.Black);
+                       else if (state == CheckState.Indeterminate)
+                               DrawCheck (g, bounds, 
SystemColors.ControlDarkDark);
+               }
+               
+               public virtual void DrawHotCheckBox (Graphics g, Rectangle 
bounds, Color backColor, Color foreColor, CheckState state)
+               {
+                       DrawNormalCheckBox (g, bounds, backColor, foreColor, 
state);
+               }
+
+               public virtual void DrawPressedCheckBox (Graphics g, Rectangle 
bounds, Color backColor, Color foreColor, CheckState state)
+               {
+                       int check_box_visible_size = (bounds.Height > 
bounds.Width) ? bounds.Width : bounds.Height;
+                       int x_pos = Math.Max (0, bounds.X + (bounds.Width / 2) 
- check_box_visible_size / 2);
+                       int y_pos = Math.Max (0, bounds.Y + (bounds.Height / 2) 
- check_box_visible_size / 2);
+
+                       Rectangle rect = new Rectangle (x_pos, y_pos, 
check_box_visible_size, check_box_visible_size);
+
+                       g.FillRectangle (ResPool.GetHatchBrush 
(HatchStyle.Percent50,
+                                                                Color.FromArgb 
(Clamp (ColorControl.R + 3, 0, 255),
+                                                                               
 ColorControl.G, ColorControl.B),
+                                                                ColorControl), 
rect.X + 2, rect.Y + 2, rect.Width - 3, rect.Height - 3);
+
+                       Pen pen = SystemPens.ControlDark;
+                       g.DrawLine (pen, rect.X, rect.Y, rect.X, rect.Bottom - 
2);
+                       g.DrawLine (pen, rect.X + 1, rect.Y, rect.Right - 2, 
rect.Y);
+
+                       pen = SystemPens.ControlDarkDark;
+                       g.DrawLine (pen, rect.X + 1, rect.Y + 1, rect.X + 1, 
rect.Bottom - 3);
+                       g.DrawLine (pen, rect.X + 2, rect.Y + 1, rect.Right - 
3, rect.Y + 1);
+
+                       pen = SystemPens.ControlLight;
+                       g.DrawLine (pen, rect.Right - 1, rect.Y, rect.Right - 
1, rect.Bottom - 1);
+                       g.DrawLine (pen, rect.X, rect.Bottom - 1, rect.Right - 
1, rect.Bottom - 1);
+
+                       // oh boy, matching ms is like fighting against 
windmills
+                       using (Pen h_pen = new Pen (ResPool.GetHatchBrush 
(HatchStyle.Percent50,
+                                                                          
Color.FromArgb (Clamp (ColorControl.R + 3, 0, 255),
+                                                                               
           ColorControl.G, ColorControl.B), ColorControl))) {
+                               g.DrawLine (h_pen, rect.X + 1, rect.Bottom - 2, 
rect.Right - 2, rect.Bottom - 2);
+                               g.DrawLine (h_pen, rect.Right - 2, rect.Y + 1, 
rect.Right - 2, rect.Bottom - 2);
+                       }
+
+                       if (state == CheckState.Checked)
+                               DrawCheck (g, bounds, Color.Black);
+                       else if (state == CheckState.Indeterminate)
+                               DrawCheck (g, bounds, 
SystemColors.ControlDarkDark);
+               }
+
+               public virtual void DrawDisabledCheckBox (Graphics g, Rectangle 
bounds, Color backColor, Color foreColor, CheckState state)
+               {
+                       DrawPressedCheckBox (g, bounds, backColor, foreColor, 
CheckState.Unchecked);
+
+                       if (state == CheckState.Checked || state == 
CheckState.Indeterminate)
+                               DrawCheck (g, bounds, SystemColors.ControlDark);
+               }
+               #endregion
+
+               #region FlatStyle
+               public virtual void DrawFlatNormalCheckBox (Graphics g, 
Rectangle bounds, Color backColor, Color foreColor, CheckState state)
+               {
+                       Rectangle checkbox_rectangle;
+                       Rectangle fill_rectangle;
+
+                       // set up our rectangles first
+                       // clip two pixels from bottom right for non popup 
rendered checkboxes
+                       checkbox_rectangle = new Rectangle (bounds.X, bounds.Y, 
Math.Max (bounds.Width - 2, 0), Math.Max (bounds.Height - 2, 0));
+                       fill_rectangle = new Rectangle (checkbox_rectangle.X + 
1, checkbox_rectangle.Y + 1, Math.Max (checkbox_rectangle.Width - 2, 0), 
Math.Max (checkbox_rectangle.Height - 2, 0));
+
+                       g.FillRectangle (ResPool.GetSolidBrush 
(ControlPaint.LightLight (backColor)), fill_rectangle);
+                       ControlPaint.DrawBorder (g, checkbox_rectangle, 
foreColor, ButtonBorderStyle.Solid);
+
+                       bounds.Offset (-1, 0);
+                       
+                       if (state == CheckState.Checked)
+                               DrawCheck (g, bounds, Color.Black);
+                       else if (state == CheckState.Indeterminate)
+                               DrawCheck (g, bounds, 
SystemColors.ControlDarkDark);
+               }
+
+               public virtual void DrawFlatHotCheckBox (Graphics g, Rectangle 
bounds, Color backColor, Color foreColor, CheckState state)
+               {
+                       Rectangle checkbox_rectangle;
+                       Rectangle fill_rectangle;
+
+                       // set up our rectangles first
+                       // clip two pixels from bottom right for non popup 
rendered checkboxes
+                       checkbox_rectangle = new Rectangle (bounds.X, bounds.Y, 
Math.Max (bounds.Width - 2, 0), Math.Max (bounds.Height - 2, 0));
+                       fill_rectangle = new Rectangle (checkbox_rectangle.X + 
1, checkbox_rectangle.Y + 1, Math.Max (checkbox_rectangle.Width - 2, 0), 
Math.Max (checkbox_rectangle.Height - 2, 0));
+
+                       g.FillRectangle (ResPool.GetSolidBrush (backColor), 
fill_rectangle);
+                       ControlPaint.DrawBorder (g, checkbox_rectangle, 
foreColor, ButtonBorderStyle.Solid);
+
+                       bounds.Offset (-1, 0);
+
+                       if (state == CheckState.Checked)
+                               DrawCheck (g, bounds, Color.Black);
+                       else if (state == CheckState.Indeterminate)
+                               DrawCheck (g, bounds, 
SystemColors.ControlDarkDark);
+               }
+
+               public virtual void DrawFlatPressedCheckBox (Graphics g, 
Rectangle bounds, Color backColor, Color foreColor, CheckState state)
+               {
+                       DrawFlatNormalCheckBox (g, bounds, backColor, 
foreColor, state);
+               }
+
+               public virtual void DrawFlatDisabledCheckBox (Graphics g, 
Rectangle bounds, Color backColor, Color foreColor, CheckState state)
+               {
+                       Rectangle checkbox_rectangle;
+
+                       checkbox_rectangle = new Rectangle (bounds.X, bounds.Y, 
Math.Max (bounds.Width - 2, 0), Math.Max (bounds.Height - 2, 0));
+
+                       ControlPaint.DrawBorder (g, checkbox_rectangle, 
foreColor, ButtonBorderStyle.Solid);
+
+                       bounds.Offset (-1, 0);
+
+                       if (state == CheckState.Checked || state == 
CheckState.Indeterminate)
+                               DrawCheck (g, bounds, 
SystemColors.ControlDarkDark);
+               }
+               #endregion
+
+               #region Popup
+               public virtual void DrawPopupNormalCheckBox (Graphics g, 
Rectangle bounds, Color backColor, Color foreColor, CheckState state)
+               {
+                       DrawFlatNormalCheckBox (g, bounds, backColor, 
foreColor, state);
+               }
+
+               public virtual void DrawPopupHotCheckBox (Graphics g, Rectangle 
bounds, Color backColor, Color foreColor, CheckState state)
+               {
+                       Rectangle checkbox_rectangle;
+                       Rectangle fill_rectangle;
+
+                       // clip one pixel from bottom right for non popup 
rendered checkboxes
+                       checkbox_rectangle = new Rectangle (bounds.X, bounds.Y, 
Math.Max (bounds.Width - 1, 0), Math.Max (bounds.Height - 1, 0));
+                       fill_rectangle = new Rectangle (checkbox_rectangle.X + 
1, checkbox_rectangle.Y + 1, Math.Max (checkbox_rectangle.Width - 3, 0), 
Math.Max (checkbox_rectangle.Height - 3, 0));
+
+                       g.FillRectangle (ResPool.GetSolidBrush 
(ControlPaint.LightLight (backColor)), fill_rectangle);
+                       
+                       // draw sunken effect
+                       ThemeEngine.Current.CPDrawBorder3D (g, 
checkbox_rectangle, Border3DStyle.SunkenInner, Border3DSide.Left | 
Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, backColor);
+
+                       bounds.Offset (-1, 0);
+                       
+                       if (state == CheckState.Checked)
+                               DrawCheck (g, bounds, Color.Black);
+                       else if (state == CheckState.Indeterminate)
+                               DrawCheck (g, bounds, 
SystemColors.ControlDarkDark);
+               }
+
+               public virtual void DrawPopupPressedCheckBox (Graphics g, 
Rectangle bounds, Color backColor, Color foreColor, CheckState state)
+               {
+                       Rectangle checkbox_rectangle;
+                       Rectangle fill_rectangle;
+
+                       // clip one pixel from bottom right for non popup 
rendered checkboxes
+                       checkbox_rectangle = new Rectangle (bounds.X, bounds.Y, 
Math.Max (bounds.Width - 1, 0), Math.Max (bounds.Height - 1, 0));
+                       fill_rectangle = new Rectangle (checkbox_rectangle.X + 
1, checkbox_rectangle.Y + 1, Math.Max (checkbox_rectangle.Width - 3, 0), 
Math.Max (checkbox_rectangle.Height - 3, 0));
+
+                       g.FillRectangle (ResPool.GetSolidBrush (backColor), 
fill_rectangle);
+
+                       // draw sunken effect
+                       ThemeEngine.Current.CPDrawBorder3D (g, 
checkbox_rectangle, Border3DStyle.SunkenInner, Border3DSide.Left | 
Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, backColor);
+
+                       bounds.Offset (-1, 0);
+
+                       if (state == CheckState.Checked)
+                               DrawCheck (g, bounds, Color.Black);
+                       else if (state == CheckState.Indeterminate)
+                               DrawCheck (g, bounds, 
SystemColors.ControlDarkDark);
+               }
+
+               public virtual void DrawPopupDisabledCheckBox (Graphics g, 
Rectangle bounds, Color backColor, Color foreColor, CheckState state)
+               {
+                       DrawFlatDisabledCheckBox (g, bounds, backColor, 
foreColor, state);
+               }
+               #endregion
+
+               #region Check
+               public virtual void DrawCheck (Graphics g, Rectangle bounds, 
Color checkColor)
+               {
+                       int check_size = (bounds.Height > bounds.Width) ? 
bounds.Width / 2 : bounds.Height / 2;
+
+                       Pen check_pen = ResPool.GetPen (checkColor);
+
+                       if (check_size < 7) {
+                               int lineWidth = Math.Max (3, check_size / 3);
+                               int Scale = Math.Max (1, check_size / 9);
+
+                               Rectangle rect = new Rectangle (bounds.X + 
(bounds.Width / 2) - (check_size / 2) - 1, bounds.Y + (bounds.Height / 2) - 
(check_size / 2) - 1,
+                                                               check_size, 
check_size);
+
+                               for (int i = 0; i < lineWidth; i++) {
+                                       g.DrawLine (check_pen, rect.Left + 
lineWidth / 2, rect.Top + lineWidth + i, rect.Left + lineWidth / 2 + 2 * Scale, 
rect.Top + lineWidth + 2 * Scale + i);
+                                       g.DrawLine (check_pen, rect.Left + 
lineWidth / 2 + 2 * Scale, rect.Top + lineWidth + 2 * Scale + i, rect.Left + 
lineWidth / 2 + 6 * Scale, rect.Top + lineWidth - 2 * Scale + i);
+                               }
+                       } else {
+                               int lineWidth = Math.Max (3, check_size / 3) + 
1;
+
+                               int x_half = bounds.Width / 2;
+                               int y_half = bounds.Height / 2;
+
+                               Rectangle rect = new Rectangle (bounds.X + 
x_half - (check_size / 2) - 1, bounds.Y + y_half - (check_size / 2),
+                                                               check_size, 
check_size);
+
+                               int gradient_left = check_size / 3;
+                               int gradient_right = check_size - gradient_left 
- 1;
+
+                               for (int i = 0; i < lineWidth; i++) {
+                                       g.DrawLine (check_pen, rect.X, 
rect.Bottom - 1 - gradient_left - i, rect.X + gradient_left, rect.Bottom - 1 - 
i);
+                                       g.DrawLine (check_pen, rect.X + 
gradient_left, rect.Bottom - 1 - i, rect.Right - 1, rect.Bottom - i - 1 - 
gradient_right);
+                               }
+                       }
+               }
+               #endregion
+               
+               #region Private Methods
+               private int Clamp (int value, int lower, int upper)
+               {
+                       if (value < lower) return lower;
+                       else if (value > upper) return upper;
+                       else return value;
+               }
+
+               private Color ColorControl {
+                       get { return SystemColors.Control; }
+               }
+               #endregion
+       }
+}
+#endif
\ No newline at end of file

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Theming/ThemeElements.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Theming/ThemeElements.cs
 2007-08-22 20:16:55 UTC (rev 84660)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Theming/ThemeElements.cs
 2007-08-22 20:39:39 UTC (rev 84661)
@@ -92,5 +92,13 @@
                Disabled = 8,
                Default = 16
        }
+
+       internal enum ElementState
+       {
+               Normal = 1,
+               Hot = 2,
+               Pressed = 3,
+               Disabled = 4
+       }
        #endregion
 }
\ No newline at end of file

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Theming/ThemeElementsDefault.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Theming/ThemeElementsDefault.cs
  2007-08-22 20:16:55 UTC (rev 84660)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.Theming/ThemeElementsDefault.cs
  2007-08-22 20:39:39 UTC (rev 84661)
@@ -56,6 +56,15 @@
                                return toolStripPainter;
                        }
                }
+
+               protected Default.CheckBoxPainter checkBoxPainter;
+               public virtual Default.CheckBoxPainter CheckBoxPainter {
+                       get {
+                               if (checkBoxPainter == null)
+                                       checkBoxPainter = new 
Default.CheckBoxPainter ();
+                               return checkBoxPainter;
+                       }
+               }
 #endif
        }
 }

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources      
2007-08-22 20:16:55 UTC (rev 84660)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources      
2007-08-22 20:39:39 UTC (rev 84661)
@@ -802,6 +802,7 @@
 System.Windows.Forms.Theming/ThemeElementsGtk.cs
 System.Windows.Forms.Theming/ThemeElementsNice.cs
 System.Windows.Forms.Theming/Default/ButtonPainter.cs
+System.Windows.Forms.Theming/Default/CheckBoxPainter.cs
 System.Windows.Forms.Theming/Default/TabControlPainter.cs
 System.Windows.Forms.Theming/Default/ToolStripPainter.cs
 System.Windows.Forms.Theming/Nice/TabControlPainter.cs

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to