2008-06-10 George Giolfan <georgegiolfan@yahoo.com>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / ThemeWin32Classic.cs
index 5e72edd1ddb329fbe6ed85987a7911dfe0ca8b76..1adc2e9c5ad1cd6d2aa8c4c40e379da719a9f1e3 100644 (file)
@@ -75,6 +75,8 @@ namespace System.Windows.Forms
                        string_format_menu_text.LineAlignment = StringAlignment.Center;
                        string_format_menu_text.Alignment = StringAlignment.Near;
                        string_format_menu_text.HotkeyPrefix = HotkeyPrefix.Show;
+                       string_format_menu_text.SetTabStops (0f, new float [] { 50f });
+                       string_format_menu_text.FormatFlags |= StringFormatFlags.NoWrap;
 
                        string_format_menu_shortcut = new StringFormat ();      
                        string_format_menu_shortcut.LineAlignment = StringAlignment.Center;
@@ -160,7 +162,7 @@ namespace System.Windows.Forms
                                DrawButtonImage (g, b, imageBounds);
 
                        // If we're focused, draw a focus rectangle
-                       if (b.Focused && b.Enabled)
+                       if (b.Focused && b.Enabled && b.ShowFocusCues)
                                DrawButtonFocus (g, b);
 
                        // If we have text, draw it
@@ -187,7 +189,7 @@ namespace System.Windows.Forms
                        ControlPaint.DrawFocusRectangle (g, Rectangle.Inflate (button.ClientRectangle, -4, -4));
                }
 
-               public virtual void DrawButtonImage (Graphics g, Button button, Rectangle imageBounds)
+               public virtual void DrawButtonImage (Graphics g, ButtonBase button, Rectangle imageBounds)
                {
                        if (button.Enabled)
                                g.DrawImage (button.Image, imageBounds);
@@ -195,8 +197,12 @@ namespace System.Windows.Forms
                                CPDrawImageDisabled (g, button.Image, imageBounds.Left, imageBounds.Top, ColorControl);
                }
 
-               public virtual void DrawButtonText (Graphics g, Button button, Rectangle textBounds)
+               public virtual void DrawButtonText (Graphics g, ButtonBase button, Rectangle textBounds)
                {
+                       // Ensure that at least one line is going to get displayed.
+                       // Line limit does not ensure that despite its description.
+                       textBounds.Height = Math.Max (textBounds.Height, button.Font.Height);
+                       
                        if (button.Enabled)
                                TextRenderer.DrawTextInternal (g, button.Text, button.Font, textBounds, button.ForeColor, button.TextFormatFlags, button.UseCompatibleTextRendering);
                        else
@@ -205,17 +211,18 @@ namespace System.Windows.Forms
                #endregion
 
                #region FlatStyle Button Style
-               public override void DrawFlatButton (Graphics g, Button b, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle)
+               public override void DrawFlatButton (Graphics g, ButtonBase b, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle)
                {
                        // Draw Button Background
-                       DrawFlatButtonBackground (g, b, clipRectangle);
+                       if (b.BackgroundImage == null)
+                               DrawFlatButtonBackground (g, b, clipRectangle);
 
                        // If we have an image, draw it
                        if (imageBounds.Size != Size.Empty)
                                DrawFlatButtonImage (g, b, imageBounds);
 
                        // If we're focused, draw a focus rectangle
-                       if (b.Focused && b.Enabled)
+                       if (b.Focused && b.Enabled && b.ShowFocusCues)
                                DrawFlatButtonFocus (g, b);
 
                        // If we have text, draw it
@@ -223,12 +230,16 @@ namespace System.Windows.Forms
                                DrawFlatButtonText (g, b, textBounds);
                }
 
-               public virtual void DrawFlatButtonBackground (Graphics g, Button button, Rectangle clipArea)
+               public virtual void DrawFlatButtonBackground (Graphics g, ButtonBase button, Rectangle clipArea)
                {
                        if (button.Pressed)
                                ThemeElements.DrawFlatButton (g, button.ClientRectangle, ButtonThemeState.Pressed, button.BackColor, button.ForeColor, button.FlatAppearance);
-                       else if (button.InternalSelected)
-                               ThemeElements.DrawFlatButton (g, button.ClientRectangle, ButtonThemeState.Default, button.BackColor, button.ForeColor, button.FlatAppearance);
+                       else if (button.InternalSelected) {
+                               if (button.Entered) 
+                                       ThemeElements.DrawFlatButton (g, button.ClientRectangle, ButtonThemeState.Default | ButtonThemeState.Entered, button.BackColor, button.ForeColor, button.FlatAppearance);
+                               else
+                                       ThemeElements.DrawFlatButton (g, button.ClientRectangle, ButtonThemeState.Default, button.BackColor, button.ForeColor, button.FlatAppearance);
+                       }
                        else if (button.Entered)
                                ThemeElements.DrawFlatButton (g, button.ClientRectangle, ButtonThemeState.Entered, button.BackColor, button.ForeColor, button.FlatAppearance);
                        else if (!button.Enabled)
@@ -237,21 +248,21 @@ namespace System.Windows.Forms
                                ThemeElements.DrawFlatButton (g, button.ClientRectangle, ButtonThemeState.Normal, button.BackColor, button.ForeColor, button.FlatAppearance);
                }
 
-               public virtual void DrawFlatButtonFocus (Graphics g, Button button)
+               public virtual void DrawFlatButtonFocus (Graphics g, ButtonBase button)
                {
                        if (!button.Pressed) {
-                               Color focus_color = ControlPaint.Light(button.BackColor);
+                               Color focus_color = ControlPaint.Dark (button.BackColor);
                                g.DrawRectangle (ResPool.GetPen (focus_color), new Rectangle (button.ClientRectangle.Left + 4, button.ClientRectangle.Top + 4, button.ClientRectangle.Width - 9, button.ClientRectangle.Height - 9));
                        }
                }
 
-               public virtual void DrawFlatButtonImage (Graphics g, Button button, Rectangle imageBounds)
+               public virtual void DrawFlatButtonImage (Graphics g, ButtonBase button, Rectangle imageBounds)
                {
                        // No changes from Standard for image for this theme
                        DrawButtonImage (g, button, imageBounds);
                }
 
-               public virtual void DrawFlatButtonText (Graphics g, Button button, Rectangle textBounds)
+               public virtual void DrawFlatButtonText (Graphics g, ButtonBase button, Rectangle textBounds)
                {
                        // No changes from Standard for text for this theme
                        DrawButtonText (g, button, textBounds);
@@ -269,7 +280,7 @@ namespace System.Windows.Forms
                                DrawPopupButtonImage (g, b, imageBounds);
 
                        // If we're focused, draw a focus rectangle
-                       if (b.Focused && b.Enabled)
+                       if (b.Focused && b.Enabled && b.ShowFocusCues)
                                DrawPopupButtonFocus (g, b);
 
                        // If we have text, draw it
@@ -618,7 +629,7 @@ namespace System.Windows.Forms
                                ButtonBase_DrawImage(button, dc);
                        
                        // Draw the focus rectangle
-                       if ((button.Focused || button.paint_as_acceptbutton) && button.Enabled)
+                       if (ShouldPaintFocusRectagle (button))
                                ButtonBase_DrawFocus(button, dc);
                        
                        // Now the text
@@ -626,6 +637,11 @@ namespace System.Windows.Forms
                                ButtonBase_DrawText(button, dc);
                }
 
+               protected static bool ShouldPaintFocusRectagle (ButtonBase button)
+               {
+                       return (button.Focused || button.paint_as_acceptbutton) && button.Enabled && button.ShowFocusCues;
+               }
+
                protected virtual void ButtonBase_DrawButton (ButtonBase button, Graphics dc)
                {
                        Rectangle borderRectangle;
@@ -851,6 +867,10 @@ namespace System.Windows.Forms
                                text_rect.Y++;
                        }
                        
+                       // Ensure that at least one line is going to get displayed.
+                       // Line limit does not ensure that despite its description.
+                       text_rect.Height = Math.Max (button.Font.Height, text_rect.Height);
+                       
                        if (button.Enabled) {                                   
                                dc.DrawString(button.Text, button.Font, ResPool.GetSolidBrush (button.ForeColor), text_rect, button.text_format);
                        } else {
@@ -870,6 +890,219 @@ namespace System.Windows.Forms
                #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
+                       if (cb.Appearance == Appearance.Button && cb.FlatStyle != FlatStyle.Flat)
+                               ButtonBase_DrawButton (cb, g);
+                       else if (cb.Appearance != Appearance.Button)
+                               DrawCheckBoxGlyph (g, cb, glyphArea);
+
+                       // Draw the borders and such for a Flat CheckBox Button
+                       if (cb.Appearance == Appearance.Button && cb.FlatStyle == FlatStyle.Flat)
+                       DrawFlatButton (g, cb, textBounds, imageBounds, clipRectangle);
+                       
+                       // If we have an image, draw it
+                       if (imageBounds.Size != Size.Empty)
+                               DrawCheckBoxImage (g, cb, imageBounds);
+
+                       if (cb.Focused && cb.Enabled && cb.ShowFocusCues && 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;
+                       
+                       if (button is CheckBox)
+                               check_size = (button as CheckBox).Appearance == Appearance.Normal ? 13 : 0;
+                               
+                       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 proposed = Size.Empty;
+                       
+                       // Force wrapping if we aren't AutoSize and our text is too long
+                       if (!button.AutoSize)
+                               proposed.Width = button.Width - glyphArea.Width - 2;
+
+                       Size text_size = TextRenderer.MeasureTextInternal (text, button.Font, proposed, button.TextFormatFlags, button.UseCompatibleTextRendering);
+                       
+                       // Text can't be bigger than the content rectangle
+                       text_size.Height = Math.Min (text_size.Height, content_rect.Height);
+                       text_size.Width = Math.Min (text_size.Width, content_rect.Width);
+                       
+                       Size image_size = image == null ? Size.Empty : image.Size;
+
+                       textRectangle = Rectangle.Empty;
+                       imageRectangle = Rectangle.Empty;
+
+                       switch (button.TextImageRelation) {
+                               case TextImageRelation.Overlay:
+                                       // Text is centered vertically, and 2 pixels to the right
+                                       textRectangle.X = content_rect.Left + 2;
+                                       textRectangle.Y = ((content_rect.Height - text_size.Height) / 2) - 1;
+                                       textRectangle.Size = text_size;
+
+                                       // 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;
+                       }
+               }
+
+               public override Size CalculateCheckBoxAutoSize (CheckBox checkBox)
+               {
+                       Size ret_size = Size.Empty;
+                       Size text_size = TextRenderer.MeasureTextInternal (checkBox.Text, checkBox.Font, checkBox.UseCompatibleTextRendering);
+                       Size image_size = checkBox.Image == null ? Size.Empty : checkBox.Image.Size;
+
+                       // Pad the text size
+                       if (checkBox.Text.Length != 0) {
+                               text_size.Height += 4;
+                               text_size.Width += 4;
+                       }
+
+                       switch (checkBox.TextImageRelation) {
+                               case TextImageRelation.Overlay:
+                                       ret_size.Height = Math.Max (checkBox.Text.Length == 0 ? 0 : text_size.Height, image_size.Height);
+                                       ret_size.Width = Math.Max (text_size.Width, image_size.Width);
+                                       break;
+                               case TextImageRelation.ImageAboveText:
+                               case TextImageRelation.TextAboveImage:
+                                       ret_size.Height = text_size.Height + image_size.Height;
+                                       ret_size.Width = Math.Max (text_size.Width, image_size.Width);
+                                       break;
+                               case TextImageRelation.ImageBeforeText:
+                               case TextImageRelation.TextBeforeImage:
+                                       ret_size.Height = Math.Max (text_size.Height, image_size.Height);
+                                       ret_size.Width = text_size.Width + image_size.Width;
+                                       break;
+                       }
+
+                       // Pad the result
+                       ret_size.Height += (checkBox.Padding.Vertical);
+                       ret_size.Width += (checkBox.Padding.Horizontal) + 15;
+
+                       // There seems to be a minimum height
+                       if (ret_size.Height == checkBox.Padding.Vertical)
+                               ret_size.Height += 14;
+                               
+                       return ret_size;
+               }
+#endif
+
                public override void DrawCheckBox(Graphics dc, Rectangle clip_area, CheckBox checkbox) {
                        StringFormat            text_format;
                        Rectangle               client_rectangle;
@@ -1051,7 +1284,15 @@ namespace System.Windows.Forms
                        
                        CheckBox_DrawText(checkbox, text_rectangle, dc, text_format);
 
-                       CheckBox_DrawFocus(checkbox, dc, text_rectangle);
+                       if (checkbox.Focused && checkbox.Enabled && checkbox.appearance != Appearance.Button && checkbox.Text != String.Empty && checkbox.ShowFocusCues) {
+                               SizeF text_size = dc.MeasureString (checkbox.Text, checkbox.Font);
+                               
+                               Rectangle focus_rect = Rectangle.Empty;
+                               focus_rect.X = text_rectangle.X;
+                               focus_rect.Y = (int)((text_rectangle.Height - text_size.Height) / 2);
+                               focus_rect.Size = text_size.ToSize ();
+                               CheckBox_DrawFocus (checkbox, dc, focus_rect);
+                       }
 
                        text_format.Dispose ();
                }
@@ -1084,8 +1325,7 @@ namespace System.Windows.Forms
                
                protected virtual void CheckBox_DrawFocus( CheckBox checkbox, Graphics dc, Rectangle text_rectangle )
                {
-                       if ( checkbox.Focused && checkbox.appearance != Appearance.Button && checkbox.Enabled )
-                               DrawInnerFocusRectangle( dc, text_rectangle, checkbox.BackColor );
+                       DrawInnerFocusRectangle (dc, text_rectangle, checkbox.BackColor);
                }
 
                // renders a checkBox with the Flat and Popup FlatStyle
@@ -1224,14 +1464,14 @@ namespace System.Windows.Forms
                        if (ctrl.ThreeDCheckBoxes == false)
                                state |= ButtonState.Flat;
 
-                       Rectangle checkbox_rect = new Rectangle (2, (item_rect.Height - 11) / 2, 11, 11);
+                       Rectangle checkbox_rect = new Rectangle (2, (item_rect.Height - 11) / 2, 13, 13);
                        ControlPaint.DrawCheckBox (e.Graphics,
                                item_rect.X + checkbox_rect.X, item_rect.Y + checkbox_rect.Y,
                                checkbox_rect.Width, checkbox_rect.Height,
                                state);
 
-                       item_rect.X += checkbox_rect.Width + checkbox_rect.X * 2;
-                       item_rect.Width -= checkbox_rect.Width + checkbox_rect.X * 2;
+                       item_rect.X += checkbox_rect.Right;
+                       item_rect.Width -= checkbox_rect.Right;
                        
                        /* Draw text*/
                        if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
@@ -1344,6 +1584,41 @@ namespace System.Windows.Forms
                                graphics.FillPolygon(SystemBrushes.ControlText, arrow, FillMode.Winding);
                        }               
                }
+               public override void ComboBoxDrawNormalDropDownButton (ComboBox comboBox, Graphics g, Rectangle clippingArea, Rectangle area, ButtonState state)
+               {
+                       CPDrawComboButton (g, area, state);
+               }
+               public override bool ComboBoxNormalDropDownButtonHasTransparentBackground (ComboBox comboBox, ButtonState state)
+               {
+                       return true;
+               }
+               public override bool ComboBoxDropDownButtonHasHotElementStyle (ComboBox comboBox)
+               {
+                       return false;
+               }
+               public override void ComboBoxDrawBackground (ComboBox comboBox, Graphics g, Rectangle clippingArea, FlatStyle style)
+               {
+                       if (!comboBox.Enabled)
+                               g.FillRectangle (ResPool.GetSolidBrush (ColorControl), comboBox.Bounds);
+
+                       if (comboBox.DropDownStyle == ComboBoxStyle.Simple)
+                               g.FillRectangle (ResPool.GetSolidBrush (comboBox.Parent.BackColor), comboBox.ClientRectangle);
+
+                       if (style == FlatStyle.Popup && (comboBox.Entered || comboBox.Focused)) {
+                               Rectangle area = comboBox.TextArea;
+                               area.Height -= 1;
+                               area.Width -= 1;
+                               g.DrawRectangle (ResPool.GetPen (SystemColors.ControlDark), area);
+                               g.DrawLine (ResPool.GetPen (SystemColors.ControlDark), comboBox.ButtonArea.X - 1, comboBox.ButtonArea.Top, comboBox.ButtonArea.X - 1, comboBox.ButtonArea.Bottom);
+                       }
+                       bool is_flat = style == FlatStyle.Flat || style == FlatStyle.Popup;
+                       if (!is_flat && clippingArea.IntersectsWith (comboBox.TextArea))
+                               ControlPaint.DrawBorder3D (g, comboBox.TextArea, Border3DStyle.Sunken);
+               }
+               public override bool CombBoxBackgroundHasHotElementStyle (ComboBox comboBox)
+               {
+                       return false;
+               }
                #endregion ComboBox
                
                #region Datagrid
@@ -1910,8 +2185,67 @@ namespace System.Windows.Forms
                }
                
                #endregion // Datagrid
-               
+
+#if NET_2_0
+               #region DataGridView
+               #region DataGridViewHeaderCell
+               #region DataGridViewRowHeaderCell
+               public override bool DataGridViewRowHeaderCellDrawBackground (DataGridViewRowHeaderCell cell, Graphics g, Rectangle bounds)
+               {
+                       return false;
+               }
+
+               public override bool DataGridViewRowHeaderCellDrawSelectionBackground (DataGridViewRowHeaderCell cell)
+               {
+                       return false;
+               }
+
+               public override bool DataGridViewRowHeaderCellDrawBorder (DataGridViewRowHeaderCell cell, Graphics g, Rectangle bounds)
+               {
+                       return false;
+               }
+               #endregion
+
+               #region DataGridViewColumnHeaderCell
+               public override bool DataGridViewColumnHeaderCellDrawBackground (DataGridViewColumnHeaderCell cell, Graphics g, Rectangle bounds)
+               {
+                       return false;
+               }
+
+               public override bool DataGridViewColumnHeaderCellDrawBorder (DataGridViewColumnHeaderCell cell, Graphics g, Rectangle bounds)
+               {
+                       return false;
+               }
+               #endregion
+
+               public override bool DataGridViewHeaderCellHasPressedStyle  (DataGridView dataGridView)
+               {
+                       return false;
+               }
+
+               public override bool DataGridViewHeaderCellHasHotStyle (DataGridView dataGridView)
+               {
+                       return false;
+               }
+               #endregion
+               #endregion
+#endif
+
                #region DateTimePicker
+               protected virtual void DateTimePickerDrawBorder (DateTimePicker dateTimePicker, Graphics g, Rectangle clippingArea)
+               {
+                       this.CPDrawBorder3D (g, dateTimePicker.ClientRectangle, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, dateTimePicker.BackColor);
+               }
+
+               protected virtual void DateTimePickerDrawDropDownButton (DateTimePicker dateTimePicker, Graphics g, Rectangle clippingArea)
+               {
+                       ButtonState state = dateTimePicker.is_drop_down_visible ? ButtonState.Pushed : ButtonState.Normal;
+                       g.FillRectangle (ResPool.GetSolidBrush (ColorControl), dateTimePicker.drop_down_arrow_rect);
+                       this.CPDrawComboButton ( 
+                         g, 
+                         dateTimePicker.drop_down_arrow_rect, 
+                         state);
+               }
 
                public override void DrawDateTimePicker(Graphics dc, Rectangle clip_rectangle, DateTimePicker dtp)
                {
@@ -1921,18 +2255,13 @@ namespace System.Windows.Forms
 
                        // draw the outer border
                        Rectangle button_bounds = dtp.ClientRectangle;
-                       this.CPDrawBorder3D (dc, button_bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, dtp.BackColor);
+                       DateTimePickerDrawBorder (dtp, dc, clip_rectangle);
 
                        // deflate by the border width
                        if (clip_rectangle.IntersectsWith (dtp.drop_down_arrow_rect)) {
                                button_bounds.Inflate (-2,-2);
                                if (!dtp.ShowUpDown) {
-                                       ButtonState state = dtp.is_drop_down_visible ? ButtonState.Pushed : ButtonState.Normal;
-                                       dc.FillRectangle (ResPool.GetSolidBrush (ColorControl), dtp.drop_down_arrow_rect);
-                                       this.CPDrawComboButton ( 
-                                         dc, 
-                                         dtp.drop_down_arrow_rect, 
-                                         state);
+                                       DateTimePickerDrawDropDownButton (dtp, dc, clip_rectangle);
                                } else {
                                        ButtonState up_state = dtp.is_up_pressed ? ButtonState.Pushed : ButtonState.Normal;
                                        ButtonState down_state = dtp.is_down_pressed ? ButtonState.Pushed : ButtonState.Normal;
@@ -2055,7 +2384,55 @@ namespace System.Windows.Forms
                                }
                        }
                }
-               
+
+               public override bool DateTimePickerBorderHasHotElementStyle {
+                       get {
+                               return false;
+                       }
+               }
+
+               public override Rectangle DateTimePickerGetDropDownButtonArea (DateTimePicker dateTimePicker)
+               {
+                       Rectangle rect = dateTimePicker.ClientRectangle;
+                       rect.X = rect.Right - SystemInformation.VerticalScrollBarWidth - 2;
+                       if (rect.Width > (SystemInformation.VerticalScrollBarWidth + 2)) {
+                               rect.Width = SystemInformation.VerticalScrollBarWidth;
+                       } else {
+                               rect.Width = Math.Max (rect.Width - 2, 0);
+                       }
+                       
+                       rect.Inflate (0, -2);
+                       return rect;
+               }
+
+               public override Rectangle DateTimePickerGetDateArea (DateTimePicker dateTimePicker)
+               {
+                       Rectangle rect = dateTimePicker.ClientRectangle;
+                       if (dateTimePicker.ShowUpDown) {
+                               // set the space to the left of the up/down button
+                               if (rect.Width > (DateTimePicker.up_down_width + 4)) {
+                                       rect.Width -= (DateTimePicker.up_down_width + 4);
+                               } else {
+                                       rect.Width = 0;
+                               }
+                       } else {
+                               // set the space to the left of the up/down button
+                               // TODO make this use up down button
+                               if (rect.Width > (SystemInformation.VerticalScrollBarWidth + 4)) {
+                                       rect.Width -= SystemInformation.VerticalScrollBarWidth;
+                               } else {
+                                       rect.Width = 0;
+                               }
+                       }
+                       
+                       rect.Inflate (-2, -2);
+                       return rect;
+               }
+               public override bool DateTimePickerDropDownButtonHasHotElementStyle {
+                       get {
+                               return false;
+                       }
+               }
                #endregion // DateTimePicker
 
                #region GroupBox
@@ -2118,125 +2495,25 @@ namespace System.Windows.Forms
 
                #endregion      // HScrollBar
 
-               #region Label
-               public  override void DrawLabel (Graphics dc, Rectangle clip_rectangle, Label label) 
-               {               
-                       dc.FillRectangle (GetControlBackBrush (label.BackColor), clip_rectangle);
+               #region ListBox
 
-                       if (label.Enabled) {
-                               dc.DrawString (label.Text, label.Font, ResPool.GetSolidBrush (label.ForeColor), clip_rectangle, label.string_format);
+               public override void DrawListBoxItem (ListBox ctrl, DrawItemEventArgs e)
+               {
+                       Color back_color, fore_color;
+                       
+                       if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
+                               back_color = ColorHighlight;
+                               fore_color = ColorHighlightText;
                        } else {
-                               ControlPaint.DrawStringDisabled (dc, label.Text, label.Font, label.BackColor, clip_rectangle, label.string_format);
-                       }
-               
-               }
-
-               public override Size LabelDefaultSize {
-                       get {
-                               return new Size (100, 23);
+                               back_color = e.BackColor;
+                               fore_color = e.ForeColor;
                        }
-               }
-               #endregion      // Label
 
-               #region LinkLabel
-
-               private Color LinkLabelGetPieceColor (LinkLabel label, LinkLabel.Piece piece, int i)
-               {
-                       if (!label.Enabled)
-                               return label.DisabledLinkColor;
-
-                       if (piece.link == null)
-                               return label.ForeColor;
-
-                       if (!piece.link.Enabled)
-                               return label.DisabledLinkColor;
-                               
-                       if (piece.link.Active)
-                               return label.ActiveLinkColor;
-                               
-                       if ((label.LinkVisited && i == 0) || piece.link.Visited)
-                               return label.VisitedLinkColor;
-                       
-                       return label.LinkColor;
-               }
-               
-               public override void DrawLinkLabel (Graphics dc, Rectangle clip_rectangle, LinkLabel label)
-               {
-                       dc.FillRectangle (GetControlBackBrush (label.BackColor), clip_rectangle);
-
-                       if (label.pieces == null)
-                               return;
-
-                       // Paint all text as disabled.
-                       if (!label.Enabled) {
-                               dc.SetClip (clip_rectangle);
-                               CPDrawStringDisabled (dc, label.Text, label.Font, label.BackColor, label.ClientRectangle, label.string_format);
-                               return;
-                       }
-
-                       Font font, link_font = GetLinkFont (label);
-                       
-                       Region text_region = new Region (new Rectangle());
-
-                       // Draw links.
-                       for (int i = 0; i < label.pieces.Length; i ++) {
-                               LinkLabel.Piece piece = label.pieces[i];
-                               
-                               if (piece.link == null) {
-                                       text_region.Union (piece.region);
-                                       continue;
-                               }
-
-                               Color color = LinkLabelGetPieceColor (label, piece, i);
-
-                               if ( (label.LinkBehavior == LinkBehavior.AlwaysUnderline) || 
-                                        (label.LinkBehavior == LinkBehavior.SystemDefault) ||
-                                        ((label.LinkBehavior == LinkBehavior.HoverUnderline) && piece.link.Hovered) )
-                                       font = link_font;
-                               else
-                                       font = label.Font;
-                               
-                               dc.Clip = piece.region;
-                               dc.Clip.Intersect (clip_rectangle);
-                               dc.DrawString (label.Text, font, ResPool.GetSolidBrush (color), label.ClientRectangle, label.string_format);
-                       
-                               // Draw focus rectangle
-                               if ((piece.link != null) && piece.link.Focused) {
-                                       foreach (RectangleF rect in piece.region.GetRegionScans (dc.Transform))
-                                               ControlPaint.DrawFocusRectangle (dc, Rectangle.Round (rect), label.ForeColor, label.BackColor);
-                               }
-                       }
-                       
-                       // Draw normal text (without links).
-                       if (!text_region.IsEmpty (dc)) {
-                               dc.Clip = text_region;
-                               dc.Clip.Intersect (clip_rectangle);
-                               if (!dc.Clip.IsEmpty (dc))
-                                       dc.DrawString(label.Text, label.Font, ResPool.GetSolidBrush(label.ForeColor), label.ClientRectangle, label.string_format);
-                       }
-               }
-               
-               #endregion      // LinkLabel
-
-               #region ListBox
-
-               public override void DrawListBoxItem (ListBox ctrl, DrawItemEventArgs e)
-               {
-                       Color back_color, fore_color;
-                       
-                       if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
-                               back_color = ColorHighlight;
-                               fore_color = ColorHighlightText;
-                       } else {
-                               back_color = e.BackColor;
-                               fore_color = e.ForeColor;
-                       }
-
-                       e.Graphics.FillRectangle (ResPool.GetSolidBrush (back_color), e.Bounds);
+                       e.Graphics.FillRectangle (ResPool.GetSolidBrush (back_color), e.Bounds);
 
                        e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
                                               ResPool.GetSolidBrush (fore_color),
-                                              e.Bounds.X, e.Bounds.Y, ctrl.StringFormat);
+                                              e.Bounds, ctrl.StringFormat);
                                        
                        if ((e.State & DrawItemState.Focus) == DrawItemState.Focus)
                                CPDrawFocusRectangle (e.Graphics, e.Bounds, fore_color, back_color);
@@ -2249,25 +2526,49 @@ namespace System.Windows.Forms
                public override void DrawListViewItems (Graphics dc, Rectangle clip, ListView control)
                {
                        bool details = control.View == View.Details;
-
-                       if (control.Enabled)
-                               dc.FillRectangle (GetControlBackBrush (control.BackColor), clip);
-                       else
-                               dc.FillRectangle (ResPool.GetSolidBrush (ColorControl), clip);
-
                        int first = control.FirstVisibleIndex;  
+                       int lastvisibleindex = control.LastVisibleIndex;
+
+#if NET_2_0
+                       if (control.VirtualMode)
+                               control.OnCacheVirtualItems (new CacheVirtualItemsEventArgs (first, lastvisibleindex));
+#endif
 
-                       for (int i = first; i <= control.LastVisibleIndex; i ++) {                                      
-                               if (clip.IntersectsWith (control.Items[i].GetBounds (ItemBoundsPortion.Entire))) {
+                       for (int i = first; i <= lastvisibleindex; i++) {                                       
+                               ListViewItem item = control.GetItemAtDisplayIndex (i);
+                               if (clip.IntersectsWith (item.Bounds)) {
 #if NET_2_0
                                        bool owner_draw = false;
                                        if (control.OwnerDraw)
-                                               owner_draw = DrawListViewItemOwnerDraw (dc, control.Items [i], i);
+                                               owner_draw = DrawListViewItemOwnerDraw (dc, item, i);
                                        if (!owner_draw)
 #endif
-                                               DrawListViewItem (dc, control, control.Items [i]);
+                                               DrawListViewItem (dc, control, item);
                                }
                        }       
+
+#if NET_2_0
+                       if (control.ShowGroups && control.View != View.List && control.Groups.Count > 0) {
+                               // Use InternalCount instead of Count to take into account Default Group as needed
+                               for (int i = 0; i < control.Groups.InternalCount; i++) {
+                                       ListViewGroup group = control.Groups.GetInternalGroup (i);
+                                       if (group.ItemCount > 0 && clip.IntersectsWith (group.HeaderBounds))
+                                               DrawListViewGroupHeader (dc, control, group);
+                               }
+                       }
+
+                       ListViewInsertionMark insertion_mark = control.InsertionMark;
+                       int insertion_mark_index = insertion_mark.Index;
+                       if (insertion_mark.Bounds != Rectangle.Empty &&
+                                       (control.View != View.Details && control.View != View.List) &&
+                                       insertion_mark_index > -1 && insertion_mark_index < control.Items.Count) {
+
+                               Brush brush = ResPool.GetSolidBrush (insertion_mark.Color);
+                               dc.FillRectangle (brush, insertion_mark.Line);
+                               dc.FillPolygon (brush, insertion_mark.TopTriangle);
+                               dc.FillPolygon (brush, insertion_mark.BottomTriangle);
+                       }
+#endif
                        
                        // draw the gridlines
                        if (details && control.GridLines) {
@@ -2335,18 +2636,13 @@ namespace System.Windows.Forms
                                                        continue;
 #endif
 
-                                               ButtonState state;
-                                               if (control.HeaderStyle == ColumnHeaderStyle.Clickable)
-                                                       state = col.Pressed ? ButtonState.Pushed : ButtonState.Normal;
-                                               else
-                                                       state = ButtonState.Flat;
-                                               CPDrawButton (dc, rect, state);
-                                               rect.X += 8;
-                                               rect.Width -= 13;
+                                               ListViewDrawColumnHeaderBackground (control, col, dc, rect, clip);
+                                               rect.X += 5;
+                                               rect.Width -= 10;
                                                if (rect.Width <= 0)
                                                        continue;
 
-                                               dc.DrawString (col.Text, DefaultFont,
+                                               dc.DrawString (col.Text, control.Font,
                                                               SystemBrushes.ControlText,
                                                               rect, col.Format);
                                        }
@@ -2355,17 +2651,32 @@ namespace System.Windows.Forms
                                                Rectangle rect = control.Columns [0].Rect;
                                                rect.X = right;
                                                rect.Width = control.Right - right;
-                                               ButtonState state;
-                                               if (control.HeaderStyle == ColumnHeaderStyle.Clickable)
-                                                       state = ButtonState.Normal;
-                                               else
-                                                       state = ButtonState.Flat;
-                                               CPDrawButton (dc, rect, state);
+                                               ListViewDrawUnusedHeaderBackground (control, dc, rect, clip);
                                        }
                                }
                        }
                }
 
+               protected virtual void ListViewDrawColumnHeaderBackground (ListView listView, ColumnHeader columnHeader, Graphics g, Rectangle area, Rectangle clippingArea)
+               {
+                       ButtonState state;
+                       if (listView.HeaderStyle == ColumnHeaderStyle.Clickable)
+                               state = columnHeader.Pressed ? ButtonState.Pushed : ButtonState.Normal;
+                       else
+                               state = ButtonState.Flat;
+                       CPDrawButton (g, area, state);
+               }
+               
+               protected virtual void ListViewDrawUnusedHeaderBackground (ListView listView, Graphics g, Rectangle area, Rectangle clippingArea)
+               {
+                       ButtonState state;
+                       if (listView.HeaderStyle == ColumnHeaderStyle.Clickable)
+                               state = ButtonState.Normal;
+                       else
+                               state = ButtonState.Flat;
+                       CPDrawButton (g, area, state);
+               }
+
                public override void DrawListViewHeaderDragDetails (Graphics dc, ListView view, ColumnHeader col, int target_x)
                {
                        Rectangle rect = col.Rect;
@@ -2377,7 +2688,7 @@ namespace System.Windows.Forms
                        if (rect.Width <= 0)
                                return;
                        color = Color.FromArgb (0x7f, ColorControlText.R, ColorControlText.G, ColorControlText.B);
-                       dc.DrawString (col.Text, DefaultFont, ResPool.GetSolidBrush (color), rect, col.Format);
+                       dc.DrawString (col.Text, view.Font, ResPool.GetSolidBrush (color), rect, col.Format);
                        dc.DrawLine (ResPool.GetSizedPen (ColorHighlight, 2), target_x, 0, target_x, col.Rect.Height);
                }
 
@@ -2410,16 +2721,15 @@ namespace System.Windows.Forms
                        if (args.DrawDefault)
                                return false;
 
-                       if (item.ListView.View == View.Details)
-                               for (int i = 0; i < item.SubItems.Count; i++) {
-                                       int count = Math.Min (item.ListView.Columns.Count, item.SubItems.Count);
-                                       
-                                       // Do system drawing for subitems if no owner draw is done
-                                       for (int j = 0; j < count; j++)
-                                               if (!DrawListViewSubItemOwnerDraw (dc, item, item_state, j))
-                                                       DrawListViewSubItem (dc, item.ListView, item, j);
-                               }
-
+                       if (item.ListView.View == View.Details) {
+                               int count = Math.Min (item.ListView.Columns.Count, item.SubItems.Count);
+                               
+                               // Do system drawing for subitems if no owner draw is done
+                               for (int j = 0; j < count; j++)
+                                       if (!DrawListViewSubItemOwnerDraw (dc, item, item_state, j))
+                                               DrawListViewSubItem (dc, item.ListView, item, j);
+                       }
+                       
                        return true;
                }
 #endif
@@ -2521,7 +2831,11 @@ namespace System.Windows.Forms
                        else
                                format.Alignment = StringAlignment.Near;
                        
-                       if (control.LabelWrap)
+#if NET_2_0
+                       if (control.LabelWrap && control.View != View.Details && control.View != View.Tile)
+#else
+                       if (control.LabelWrap && control.View != View.Details)
+#endif
                                format.FormatFlags = StringFormatFlags.LineLimit;
                        else
                                format.FormatFlags = StringFormatFlags.NoWrap;
@@ -2576,7 +2890,7 @@ namespace System.Windows.Forms
                        if (item.Text != null && item.Text.Length > 0) {
                                Font font = item.Font;
 #if NET_2_0
-                               if (control.HotTracking && control.HotItemIndex == item.Index)
+                               if (control.HotTracking && item.Hot)
                                        font = item.HotFont;
 #endif
 
@@ -2643,7 +2957,7 @@ namespace System.Windows.Forms
                        Rectangle sub_item_rect = subItem.Bounds;
                        Rectangle sub_item_text_rect = sub_item_rect;
                        sub_item_text_rect.X += 3;
-                       sub_item_text_rect.Width -= 6;
+                       sub_item_text_rect.Width -= ListViewItemPaddingWidth;
                                                
                        SolidBrush sub_item_back_br = null;
                        SolidBrush sub_item_fore_br = null;
@@ -2652,7 +2966,13 @@ namespace System.Windows.Forms
                        if (item.UseItemStyleForSubItems) {
                                sub_item_back_br = ResPool.GetSolidBrush (item.BackColor);
                                sub_item_fore_br = ResPool.GetSolidBrush (item.ForeColor);
-                               sub_item_font = item.Font;
+#if NET_2_0
+                               // Hot tracking for subitems only applies when UseStyle is true
+                               if (control.HotTracking && item.Hot)
+                                       sub_item_font = item.HotFont;
+                               else
+#endif
+                                       sub_item_font = item.Font;
                        } else {
                                sub_item_back_br = ResPool.GetSolidBrush (subItem.BackColor);
                                sub_item_fore_br = ResPool.GetSolidBrush (subItem.ForeColor);
@@ -2697,9 +3017,57 @@ namespace System.Windows.Forms
                        
                        return !args.DrawDefault;
                }
+
+               protected virtual void DrawListViewGroupHeader (Graphics dc, ListView control, ListViewGroup group)
+               {
+                       Rectangle text_bounds = group.HeaderBounds;
+                       Rectangle header_bounds = group.HeaderBounds;
+                       text_bounds.Offset (8, 0);
+                       text_bounds.Inflate (-8, 0);
+                       Size text_size = control.text_size;
+
+                       Font font = new Font (control.Font, control.Font.Style | FontStyle.Bold);
+                       Brush brush = new LinearGradientBrush (new Point (header_bounds.Left, 0), new Point (header_bounds.Left + ListViewGroupLineWidth, 0), 
+                                       SystemColors.Desktop, Color.White);
+                       Pen pen = new Pen (brush);
+
+                       StringFormat sformat = new StringFormat ();
+                       switch (group.HeaderAlignment) {
+                               case HorizontalAlignment.Left:
+                                       sformat.Alignment = StringAlignment.Near;
+                                       break;
+                               case HorizontalAlignment.Center:
+                                       sformat.Alignment = StringAlignment.Center;
+                                       break;
+                               case HorizontalAlignment.Right:
+                                       sformat.Alignment = StringAlignment.Far;
+                                       break;
+                       }
+
+                       sformat.LineAlignment = StringAlignment.Near;
+                       dc.DrawString (group.Header, font, SystemBrushes.ControlText, text_bounds, sformat);
+                       dc.DrawLine (pen, header_bounds.Left, header_bounds.Top + text_size.Height, header_bounds.Left + ListViewGroupLineWidth, 
+                                       header_bounds.Top + text_size.Height);
+
+                       sformat.Dispose ();
+                       font.Dispose ();
+                       pen.Dispose ();
+                       brush.Dispose ();
+               }
 #endif
 
+               public override bool ListViewHasHotHeaderStyle {
+                       get {
+                               return false;
+                       }
+               }
+
                // Sizing
+               public override int ListViewGetHeaderHeight (ListView listView, Font font)
+               {
+                       return font.Height + 5;
+               }
+
                public override Size ListViewCheckBoxSize {
                        get { return new Size (16, 16); }
                }
@@ -2724,6 +3092,10 @@ namespace System.Windows.Forms
                        get { return 4; }
                }
 
+               public override int ListViewItemPaddingWidth {
+                       get { return 6; }
+               }
+
                public override Size ListViewDefaultSize {
                        get { return new Size (121, 97); }
                }
@@ -2732,6 +3104,10 @@ namespace System.Windows.Forms
                        get { return 20; }
                }
 
+               public int ListViewGroupLineWidth {
+                       get { return 200; }
+               }
+
                public override int ListViewTileWidthFactor {
                        get { return 22; }
                }
@@ -2768,7 +3144,7 @@ namespace System.Windows.Forms
                                return;
                        } else {                
                                SizeF size;
-                               size =  dc.MeasureString (item.Text, MenuFont);
+                               size =  dc.MeasureString (item.Text, MenuFont, int.MaxValue, string_format_menu_text);
                                item.Width = (int) size.Width;
                                item.Height = (int) size.Height;
        
@@ -3136,12 +3512,19 @@ namespace System.Windows.Forms
                                }                               
                        }
                        
+                       Brush border_brush;
+                       
+                       if (mc.owner == null)
+                               border_brush = GetControlBackBrush (mc.BackColor);
+                       else
+                               border_brush = SystemBrushes.ControlDarkDark;
+                               
                        // finally paint the borders of the calendars as required
                        for (int i = 0; i <= mc.CalendarDimensions.Width; i++) {
                                if (i == 0 && clip_rectangle.X == client_rectangle.X) {
-                                       dc.FillRectangle (GetControlBackBrush (mc.BackColor), client_rectangle.X, client_rectangle.Y, 1, client_rectangle.Height);
+                                       dc.FillRectangle (border_brush, client_rectangle.X, client_rectangle.Y, 1, client_rectangle.Height);
                                } else if (i == mc.CalendarDimensions.Width && clip_rectangle.Right == client_rectangle.Right) {
-                                       dc.FillRectangle (GetControlBackBrush (mc.BackColor), client_rectangle.Right-1, client_rectangle.Y, 1, client_rectangle.Height);
+                                       dc.FillRectangle (border_brush, client_rectangle.Right - 1, client_rectangle.Y, 1, client_rectangle.Height);
                                } else { 
                                        Rectangle rect = new Rectangle (
                                                client_rectangle.X + (month_size.Width*i) + (calendar_spacing.Width * (i-1)) + 1,
@@ -3149,15 +3532,15 @@ namespace System.Windows.Forms
                                                calendar_spacing.Width,
                                                client_rectangle.Height);
                                        if (i < mc.CalendarDimensions.Width && i > 0 && clip_rectangle.IntersectsWith (rect)) {
-                                               dc.FillRectangle (GetControlBackBrush (mc.BackColor), rect);
+                                               dc.FillRectangle (border_brush, rect);
                                        }
                                }
                        }
                        for (int i = 0; i <= mc.CalendarDimensions.Height; i++) {
                                if (i == 0 && clip_rectangle.Y == client_rectangle.Y) {
-                                       dc.FillRectangle (GetControlBackBrush (mc.BackColor), client_rectangle.X, client_rectangle.Y, client_rectangle.Width, 1);
+                                       dc.FillRectangle (border_brush, client_rectangle.X, client_rectangle.Y, client_rectangle.Width, 1);
                                } else if (i == mc.CalendarDimensions.Height && clip_rectangle.Bottom == client_rectangle.Bottom) {
-                                       dc.FillRectangle (GetControlBackBrush (mc.BackColor), client_rectangle.X, client_rectangle.Bottom-1, client_rectangle.Width, 1);
+                                       dc.FillRectangle (border_brush, client_rectangle.X, client_rectangle.Bottom - 1, client_rectangle.Width, 1);
                                } else { 
                                        Rectangle rect = new Rectangle (
                                                client_rectangle.X,
@@ -3165,7 +3548,7 @@ namespace System.Windows.Forms
                                                client_rectangle.Width,
                                                calendar_spacing.Height);
                                        if (i < mc.CalendarDimensions.Height && i > 0 && clip_rectangle.IntersectsWith (rect)) {
-                                               dc.FillRectangle (GetControlBackBrush (mc.BackColor), rect);
+                                               dc.FillRectangle (border_brush, rect);
                                        }
                                }
                        }
@@ -3387,44 +3770,62 @@ namespace System.Windows.Forms
                // draws the pervious or next button
                private void DrawMonthCalendarButton (Graphics dc, Rectangle rectangle, MonthCalendar mc, Size title_size, int x_offset, Size button_size, bool is_previous) 
                {
+                       const int arrow_width = 4;
+                       const int arrow_height = 7;
+
                        bool is_clicked = false;
                        Rectangle button_rect;
-                       Rectangle arrow_rect = new Rectangle (rectangle.X, rectangle.Y, 4, 7);
-                       Point[] arrow_path = new Point[3];
+                       PointF arrow_center;
+                       PointF [] arrow_path = new PointF [3];
+                       
                        // prepare the button
                        if (is_previous) 
                        {
                                is_clicked = mc.is_previous_clicked;
+
                                button_rect = new Rectangle (
                                        rectangle.X + 1 + x_offset,
                                        rectangle.Y + 1 + ((title_size.Height - button_size.Height)/2),
                                        Math.Max(button_size.Width - 1, 0),
                                        Math.Max(button_size.Height - 1, 0));
-                               arrow_rect.X = button_rect.X + ((button_rect.Width - arrow_rect.Width)/2);
-                               arrow_rect.Y = button_rect.Y + ((button_rect.Height - arrow_rect.Height)/2);
+
+                               arrow_center = new PointF (button_rect.X + ((button_rect.Width + arrow_width) / 2.0f), 
+                                                                                       rectangle.Y + ((button_rect.Height + arrow_height) / 2) + 1);
                                if (is_clicked) {
-                                       arrow_rect.Offset(1,1);
+                                       arrow_center.X += 1;
+                                       arrow_center.Y += 1;
                                }
-                               arrow_path[0] = new Point (arrow_rect.Right, arrow_rect.Y);
-                               arrow_path[1] = new Point (arrow_rect.X, arrow_rect.Y + arrow_rect.Height/2);
-                               arrow_path[2] = new Point (arrow_rect.Right, arrow_rect.Bottom);
+
+                               arrow_path [0].X = arrow_center.X;
+                               arrow_path [0].Y = arrow_center.Y - arrow_height / 2.0f + 0.5f;
+                               arrow_path [1].X = arrow_center.X;
+                               arrow_path [1].Y = arrow_center.Y + arrow_height / 2.0f + 0.5f;
+                               arrow_path [2].X = arrow_center.X - arrow_width;
+                               arrow_path [2].Y = arrow_center.Y + 0.5f;
                        }
                        else
                        {
                                is_clicked = mc.is_next_clicked;
+
                                button_rect = new Rectangle (
                                        rectangle.Right - 1 - x_offset - button_size.Width,
                                        rectangle.Y + 1 + ((title_size.Height - button_size.Height)/2),
                                        Math.Max(button_size.Width - 1, 0),
                                        Math.Max(button_size.Height - 1, 0));
-                               arrow_rect.X = button_rect.X + ((button_rect.Width - arrow_rect.Width)/2);
-                               arrow_rect.Y = button_rect.Y + ((button_rect.Height - arrow_rect.Height)/2);
+
+                               arrow_center = new PointF (button_rect.X + ((button_rect.Width + arrow_width) / 2.0f), 
+                                                                                       rectangle.Y + ((button_rect.Height + arrow_height) / 2) + 1);
                                if (is_clicked) {
-                                       arrow_rect.Offset(1,1);
+                                       arrow_center.X += 1;
+                                       arrow_center.Y += 1;
                                }
-                               arrow_path[0] = new Point (arrow_rect.X, arrow_rect.Y);
-                               arrow_path[1] = new Point (arrow_rect.Right, arrow_rect.Y + arrow_rect.Height/2);
-                               arrow_path[2] = new Point (arrow_rect.X, arrow_rect.Bottom);                            
+
+                               arrow_path [0].X = arrow_center.X - arrow_width;
+                               arrow_path [0].Y = arrow_center.Y - arrow_height / 2.0f + 0.5f;
+                               arrow_path [1].X = arrow_center.X - arrow_width;
+                               arrow_path [1].Y = arrow_center.Y + arrow_height / 2.0f + 0.5f;
+                               arrow_path [2].X = arrow_center.X;
+                               arrow_path [2].Y = arrow_center.Y + 0.5f;
                        }
 
                        // fill the background
@@ -3438,6 +3839,7 @@ namespace System.Windows.Forms
                        }
                        // draw the arrow
                        dc.FillPolygon (SystemBrushes.ControlText, arrow_path);                 
+                       //dc.FillPolygon (SystemBrushes.ControlText, arrow_path, FillMode.Winding);
                }
                
 
@@ -3466,39 +3868,40 @@ namespace System.Windows.Forms
                        }
 
                        const int inflate = -1;
-                       if (date == mc.SelectionStart && date == mc.SelectionEnd) {
+
+                       if (date == mc.SelectionStart.Date && date == mc.SelectionEnd.Date) {
                                // see if the date is in the start of selection
                                date_color = mc.BackColor;
                                // draw the left hand of the back ground
                                Rectangle selection_rect = Rectangle.Inflate (rectangle, inflate, inflate);                             
                                dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 0, 360);
-                       } else if (date == mc.SelectionStart) {
+                       } else if (date == mc.SelectionStart.Date) {
                                // see if the date is in the start of selection
                                date_color = mc.BackColor;
                                // draw the left hand of the back ground
                                Rectangle selection_rect = Rectangle.Inflate (rectangle, inflate, inflate);                             
                                dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 90, 180);
                                // fill the other side as a straight rect
-                               if (date < mc.SelectionEnd) 
+                               if (date < mc.SelectionEnd.Date
                                {
                                        // use rectangle instead of rectangle to go all the way to edge of rect
                                        selection_rect.X = (int) Math.Floor((double)(rectangle.X + rectangle.Width / 2));
                                        selection_rect.Width = Math.Max(rectangle.Right - selection_rect.X, 0);
                                        dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
                                }
-                       } else if (date == mc.SelectionEnd) {
+                       } else if (date == mc.SelectionEnd.Date) {
                                // see if it is the end of selection
                                date_color = mc.BackColor;
                                // draw the left hand of the back ground
                                Rectangle selection_rect = Rectangle.Inflate (rectangle, inflate, inflate);
                                dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 270, 180);
                                // fill the other side as a straight rect
-                               if (date > mc.SelectionStart) {
+                               if (date > mc.SelectionStart.Date) {
                                        selection_rect.X = rectangle.X;
                                        selection_rect.Width = rectangle.Width - (rectangle.Width / 2);
                                        dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
                                }
-                       } else if (date > mc.SelectionStart && date < mc.SelectionEnd) {
+                       } else if (date > mc.SelectionStart.Date && date < mc.SelectionEnd.Date) {
                                // now see if it's in the middle
                                date_color = mc.BackColor;
                                // draw the left hand of the back ground
@@ -3565,13 +3968,10 @@ namespace System.Windows.Forms
                                        break;
 
                                case PictureBoxSizeMode.CenterImage:
-                                       dc.FillRectangle(GetControlBackBrush (pb.BackColor), clip);
                                        dc.DrawImage (pb.Image, (client.Width / 2) - (pb.Image.Width / 2), (client.Height / 2) - (pb.Image.Height / 2));
                                        break;
 #if NET_2_0
                                case PictureBoxSizeMode.Zoom:
-                                       dc.FillRectangle (GetControlBackBrush (pb.BackColor), clip);
-                                       
                                        Size image_size;
                                        
                                        if (((float)pb.Image.Width / (float)pb.Image.Height) >= ((float)client.Width / (float)client.Height))
@@ -3583,7 +3983,6 @@ namespace System.Windows.Forms
                                        break;
 #endif
                                default:
-                                       dc.FillRectangle(GetControlBackBrush (pb.BackColor), clip);
                                        // Normal, AutoSize
                                        dc.DrawImage(pb.Image, 0, 0, pb.Image.Width, pb.Image.Height);
                                        break;
@@ -3591,9 +3990,6 @@ namespace System.Windows.Forms
 
                                return;
                        }
-
-                       // We only get here if no image is set. At least paint the background
-                       dc.FillRectangle(GetControlBackBrush (pb.BackColor), clip);
                }
 
                public override Size PictureBoxDefaultSize {
@@ -3729,7 +4125,7 @@ namespace System.Windows.Forms
                                int block_count = 0;
                                
                                block_width = (client_area.Height * 2) / 3;
-                               barpos_pixels = ((ctrl.Value - ctrl.Minimum) * client_area.Width) / (Math.Max(ctrl.Maximum - ctrl.Minimum, 1));
+                               barpos_pixels = (int)(((double)(ctrl.Value - ctrl.Minimum) * client_area.Width) / (Math.Max (ctrl.Maximum - ctrl.Minimum, 1)));
                                increment = block_width + space_betweenblocks;
                                
                                block_rect = new Rectangle (start_pixel, client_area.Y, block_width, client_area.Height);
@@ -3935,7 +4331,16 @@ namespace System.Windows.Forms
                        
                        RadioButton_DrawText(radio_button, text_rectangle, dc, text_format);
 
-                       RadioButton_DrawFocus(radio_button, dc, text_rectangle);
+                       if (radio_button.Focused && radio_button.Enabled && radio_button.appearance != Appearance.Button && radio_button.Text != String.Empty && radio_button.ShowFocusCues) {
+                               SizeF text_size = dc.MeasureString (radio_button.Text, radio_button.Font);
+                               
+                               Rectangle focus_rect = Rectangle.Empty;
+                               focus_rect.X = text_rectangle.X;
+                               focus_rect.Y = (int)((text_rectangle.Height - text_size.Height) / 2);
+                               focus_rect.Size = text_size.ToSize ();
+
+                               RadioButton_DrawFocus (radio_button, dc, focus_rect);
+                       }
                        
                        text_format.Dispose ();
                }
@@ -3967,8 +4372,7 @@ namespace System.Windows.Forms
                
                protected virtual void RadioButton_DrawFocus(RadioButton radio_button, Graphics dc, Rectangle text_rectangle)
                {
-                       if ( radio_button.Focused && radio_button.appearance != Appearance.Button && radio_button.Enabled )
-                               DrawInnerFocusRectangle( dc, text_rectangle, radio_button.BackColor );
+                       DrawInnerFocusRectangle (dc, text_rectangle, radio_button.BackColor);
                }
                
                
@@ -4046,6 +4450,110 @@ namespace System.Windows.Forms
                                return new Size (104,24);
                        }
                }
+
+#if NET_2_0
+               public override void DrawRadioButton (Graphics g, RadioButton rb, Rectangle glyphArea, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle)
+               {
+                       // Draw Button Background
+                       if (rb.FlatStyle == FlatStyle.Flat || rb.FlatStyle == FlatStyle.Popup) {
+                               glyphArea.Height -= 2;
+                               glyphArea.Width -= 2;
+                       }
+                       
+                       DrawRadioButtonGlyph (g, rb, glyphArea);
+
+                       // If we have an image, draw it
+                       if (imageBounds.Size != Size.Empty)
+                               DrawRadioButtonImage (g, rb, imageBounds);
+
+                       if (rb.Focused && rb.Enabled && rb.ShowFocusCues && textBounds.Size != Size.Empty)
+                               DrawRadioButtonFocus (g, rb, textBounds);
+
+                       // If we have text, draw it
+                       if (textBounds != Rectangle.Empty)
+                               DrawRadioButtonText (g, rb, textBounds);
+               }
+
+               public virtual void DrawRadioButtonGlyph (Graphics g, RadioButton rb, Rectangle glyphArea)
+               {
+                       if (rb.Pressed)
+                               ThemeElements.CurrentTheme.RadioButtonPainter.PaintRadioButton (g, glyphArea, rb.BackColor, rb.ForeColor, ElementState.Pressed, rb.FlatStyle, rb.Checked);
+                       else if (rb.InternalSelected)
+                               ThemeElements.CurrentTheme.RadioButtonPainter.PaintRadioButton (g, glyphArea, rb.BackColor, rb.ForeColor, ElementState.Normal, rb.FlatStyle, rb.Checked);
+                       else if (rb.Entered)
+                               ThemeElements.CurrentTheme.RadioButtonPainter.PaintRadioButton (g, glyphArea, rb.BackColor, rb.ForeColor, ElementState.Hot, rb.FlatStyle, rb.Checked);
+                       else if (!rb.Enabled)
+                               ThemeElements.CurrentTheme.RadioButtonPainter.PaintRadioButton (g, glyphArea, rb.BackColor, rb.ForeColor, ElementState.Disabled, rb.FlatStyle, rb.Checked);
+                       else
+                               ThemeElements.CurrentTheme.RadioButtonPainter.PaintRadioButton (g, glyphArea, rb.BackColor, rb.ForeColor, ElementState.Normal, rb.FlatStyle, rb.Checked);
+               }
+
+               public virtual void DrawRadioButtonFocus (Graphics g, RadioButton rb, Rectangle focusArea)
+               {
+                       ControlPaint.DrawFocusRectangle (g, focusArea);
+               }
+
+               public virtual void DrawRadioButtonImage (Graphics g, RadioButton rb, Rectangle imageBounds)
+               {
+                       if (rb.Enabled)
+                               g.DrawImage (rb.Image, imageBounds);
+                       else
+                               CPDrawImageDisabled (g, rb.Image, imageBounds.Left, imageBounds.Top, ColorControl);
+               }
+
+               public virtual void DrawRadioButtonText (Graphics g, RadioButton rb, Rectangle textBounds)
+               {
+                       if (rb.Enabled)
+                               TextRenderer.DrawTextInternal (g, rb.Text, rb.Font, textBounds, rb.ForeColor, rb.TextFormatFlags, rb.UseCompatibleTextRendering);
+                       else
+                               DrawStringDisabled20 (g, rb.Text, rb.Font, textBounds, rb.BackColor, rb.TextFormatFlags, rb.UseCompatibleTextRendering);
+               }
+
+               public override Size CalculateRadioButtonAutoSize (RadioButton rb)
+               {
+                       Size ret_size = Size.Empty;
+                       Size text_size = TextRenderer.MeasureTextInternal (rb.Text, rb.Font, rb.UseCompatibleTextRendering);
+                       Size image_size = rb.Image == null ? Size.Empty : rb.Image.Size;
+
+                       // Pad the text size
+                       if (rb.Text.Length != 0) {
+                               text_size.Height += 4;
+                               text_size.Width += 4;
+                       }
+
+                       switch (rb.TextImageRelation) {
+                               case TextImageRelation.Overlay:
+                                       ret_size.Height = Math.Max (rb.Text.Length == 0 ? 0 : text_size.Height, image_size.Height);
+                                       ret_size.Width = Math.Max (text_size.Width, image_size.Width);
+                                       break;
+                               case TextImageRelation.ImageAboveText:
+                               case TextImageRelation.TextAboveImage:
+                                       ret_size.Height = text_size.Height + image_size.Height;
+                                       ret_size.Width = Math.Max (text_size.Width, image_size.Width);
+                                       break;
+                               case TextImageRelation.ImageBeforeText:
+                               case TextImageRelation.TextBeforeImage:
+                                       ret_size.Height = Math.Max (text_size.Height, image_size.Height);
+                                       ret_size.Width = text_size.Width + image_size.Width;
+                                       break;
+                       }
+
+                       // Pad the result
+                       ret_size.Height += (rb.Padding.Vertical);
+                       ret_size.Width += (rb.Padding.Horizontal) + 15;
+
+                       // There seems to be a minimum height
+                       if (ret_size.Height == rb.Padding.Vertical)
+                               ret_size.Height += 14;
+
+                       return ret_size;
+               }
+
+               public override void CalculateRadioButtonTextAndImageLayout (ButtonBase b, Point offset, out Rectangle glyphArea, out Rectangle textRectangle, out Rectangle imageRectangle)
+               {
+                       CalculateCheckBoxTextAndImageLayout (b, offset, out glyphArea, out textRectangle, out imageRectangle);
+               }
+#endif
                #endregion      // RadioButton
 
                #region ScrollBar
@@ -4069,31 +4577,30 @@ namespace System.Windows.Forms
                                thumb_pos.Width = bar.Width;
                                bar.ThumbPos = thumb_pos;
 
+                               Brush VerticalBrush;
+                               /* Background, upper track */
+                               if (bar.thumb_moving == ScrollBar.ThumbMoving.Backwards)
+                                       VerticalBrush = ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63, 63, 63), Color.Black);
+                               else
+                                       VerticalBrush = ResPool.GetHatchBrush (HatchStyle.Percent50, ColorScrollBar, Color.White);
+                               Rectangle UpperTrack = new Rectangle (0, 0, bar.ClientRectangle.Width, bar.ThumbPos.Bottom);
+                               if (clip.IntersectsWith (UpperTrack))
+                                       dc.FillRectangle (VerticalBrush, UpperTrack);
+
+                               /* Background, lower track */
+                               if (bar.thumb_moving == ScrollBar.ThumbMoving.Forward)
+                                       VerticalBrush = ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63, 63, 63), Color.Black);
+                               else
+                                       VerticalBrush = ResPool.GetHatchBrush (HatchStyle.Percent50, ColorScrollBar, Color.White);
+                               Rectangle LowerTrack = new Rectangle (0, bar.ThumbPos.Bottom, bar.ClientRectangle.Width, bar.ClientRectangle.Height - bar.ThumbPos.Bottom);
+                               if (clip.IntersectsWith (LowerTrack))
+                                       dc.FillRectangle (VerticalBrush, LowerTrack);
+
                                /* Buttons */
                                if (clip.IntersectsWith (first_arrow_area))
                                        CPDrawScrollButton (dc, first_arrow_area, ScrollButton.Up, bar.firstbutton_state);
                                if (clip.IntersectsWith (second_arrow_area))
                                        CPDrawScrollButton (dc, second_arrow_area, ScrollButton.Down, bar.secondbutton_state);
-
-                               /* Background */
-                               switch (bar.thumb_moving) {
-                               case ScrollBar.ThumbMoving.None: {
-                                       ScrollBar_Vertical_Draw_ThumbMoving_None(scrollbutton_height, bar, clip, dc);
-                                       break;
-                               }
-                               case ScrollBar.ThumbMoving.Forward: {
-                                       ScrollBar_Vertical_Draw_ThumbMoving_Forward(scrollbutton_height, bar, thumb_pos, clip, dc);
-                                       break;
-                               }
-                               
-                               case ScrollBar.ThumbMoving.Backwards: {
-                                       ScrollBar_Vertical_Draw_ThumbMoving_Backwards(scrollbutton_height, bar, thumb_pos, clip, dc);
-                                       break;
-                               }
-                               
-                               default:
-                                       break;
-                               }
                        } else {
                                first_arrow_area = new Rectangle(0, 0, scrollbutton_width, bar.Height);
                                bar.FirstArrowArea = first_arrow_area;
@@ -4104,29 +4611,30 @@ namespace System.Windows.Forms
                                thumb_pos.Height = bar.Height;
                                bar.ThumbPos = thumb_pos;
 
+                               Brush HorizontalBrush;
+                               //Background, left track
+                               if (bar.thumb_moving == ScrollBar.ThumbMoving.Backwards)
+                                       HorizontalBrush = ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63, 63, 63), Color.Black);
+                               else
+                                       HorizontalBrush = ResPool.GetHatchBrush (HatchStyle.Percent50, ColorScrollBar, Color.White);
+                               Rectangle LeftTrack = new Rectangle (0, 0, bar.ThumbPos.Right, bar.ClientRectangle.Height);
+                               if (clip.IntersectsWith (LeftTrack))
+                                       dc.FillRectangle (HorizontalBrush, LeftTrack);
+
+                               //Background, right track
+                               if (bar.thumb_moving == ScrollBar.ThumbMoving.Forward)
+                                       HorizontalBrush = ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63, 63, 63), Color.Black);
+                               else
+                                       HorizontalBrush = ResPool.GetHatchBrush (HatchStyle.Percent50, ColorScrollBar, Color.White);
+                               Rectangle RightTrack = new Rectangle (bar.ThumbPos.Right, 0, bar.ClientRectangle.Width - bar.ThumbPos.Right, bar.ClientRectangle.Height);
+                               if (clip.IntersectsWith (RightTrack))
+                                       dc.FillRectangle (HorizontalBrush, RightTrack);
+
                                /* Buttons */
                                if (clip.IntersectsWith (first_arrow_area))
                                        CPDrawScrollButton (dc, first_arrow_area, ScrollButton.Left, bar.firstbutton_state);
                                if (clip.IntersectsWith (second_arrow_area))
                                        CPDrawScrollButton (dc, second_arrow_area, ScrollButton.Right, bar.secondbutton_state);
-
-                               /* Background */                                        
-                               switch (bar.thumb_moving) {
-                               case ScrollBar.ThumbMoving.None: {
-                                       ScrollBar_Horizontal_Draw_ThumbMoving_None(scrollbutton_width, bar, clip, dc);
-                                       break;
-                               }
-                               
-                               case ScrollBar.ThumbMoving.Forward: {
-                                       ScrollBar_Horizontal_Draw_ThumbMoving_Forward(scrollbutton_width, thumb_pos, bar, clip, dc);
-                                       break;
-                               }
-                               
-                               case ScrollBar.ThumbMoving.Backwards: {
-                                       ScrollBar_Horizontal_Draw_ThumbMoving_Backwards(scrollbutton_width, thumb_pos, bar, clip, dc);
-                                       break;
-                               }
-                               }
                        }
 
                        /* Thumb */
@@ -4139,107 +4647,26 @@ namespace System.Windows.Forms
                                DrawScrollButtonPrimitive(dc, thumb_pos, ButtonState.Normal);
                }
 
-               protected virtual void ScrollBar_Vertical_Draw_ThumbMoving_None( int scrollbutton_height, ScrollBar bar, Rectangle clip, Graphics dc )
-               {
-                       Rectangle r = new Rectangle( 0,  
-                                                   scrollbutton_height, bar.ClientRectangle.Width, bar.ClientRectangle.Height - ( scrollbutton_height * 2 ) );
-                       Rectangle intersect = Rectangle.Intersect( clip, r );
+               public override int ScrollBarButtonSize {
+                       get { return 16; }
+               }
 
-                       if ( intersect != Rectangle.Empty )
-                       {
-                               Brush h = ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White);
-                               dc.FillRectangle( h, intersect );
+               public override bool ScrollBarHasHotElementStyles {
+                       get {
+                               return false;
                        }
                }
-               
-               protected virtual void ScrollBar_Vertical_Draw_ThumbMoving_Forward( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
-               {
-                       Rectangle r = new Rectangle( 0,  scrollbutton_height,
-                                                   bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
-                       Rectangle intersect = Rectangle.Intersect( clip, r );
-                       
-                       if ( intersect != Rectangle.Empty )
-                               dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White ), intersect );
-                       
-                       r.X = 0;
-                       r.Y = thumb_pos.Y + thumb_pos.Height;
-                       r.Width = bar.ClientRectangle.Width;
-                       r.Height = bar.ClientRectangle.Height -  ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
-                       
-                       intersect = Rectangle.Intersect( clip, r );
-                       if ( intersect != Rectangle.Empty )
-                               dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, Color.FromArgb( 255, 63, 63, 63 ), Color.Black ), intersect );
-               }
-               
-               protected virtual void ScrollBar_Vertical_Draw_ThumbMoving_Backwards( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
-               {
-                       Rectangle r = new Rectangle( 0,  scrollbutton_height,
-                                                   bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
-                       Rectangle intersect = Rectangle.Intersect( clip, r );
-                       
-                       if ( intersect != Rectangle.Empty )
-                               dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, Color.FromArgb( 255, 63, 63, 63 ), Color.Black ), intersect );
-                       
-                       r.X = 0;
-                       r.Y = thumb_pos.Y + thumb_pos.Height;
-                       r.Width = bar.ClientRectangle.Width; 
-                       r.Height = bar.ClientRectangle.Height -  ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
-                       
-                       intersect = Rectangle.Intersect( clip, r );
-                       if ( intersect != Rectangle.Empty )
-                               dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White), intersect );
-               }
-               
-               protected virtual void ScrollBar_Horizontal_Draw_ThumbMoving_None( int scrollbutton_width, ScrollBar bar, Rectangle clip, Graphics dc )
-               {
-                       Rectangle r = new Rectangle( scrollbutton_width,
-                                                   0, bar.ClientRectangle.Width - ( scrollbutton_width * 2 ), bar.ClientRectangle.Height );
-                       Rectangle intersect = Rectangle.Intersect( clip, r );
-                       
-                       if ( intersect != Rectangle.Empty )
-                               dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White), intersect );
-               }
-               
-               protected virtual void ScrollBar_Horizontal_Draw_ThumbMoving_Forward( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc )
-               {
-                       Rectangle r = new Rectangle( scrollbutton_width,  0,
-                                                   thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
-                       Rectangle intersect = Rectangle.Intersect( clip, r );
-                       
-                       if ( intersect != Rectangle.Empty )
-                               dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White), intersect );
-                       
-                       r.X = thumb_pos.X + thumb_pos.Width;
-                       r.Y = 0;
-                       r.Width = bar.ClientRectangle.Width -  ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
-                       r.Height = bar.ClientRectangle.Height;
-                       
-                       intersect = Rectangle.Intersect( clip, r );
-                       if ( intersect != Rectangle.Empty )
-                               dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, Color.FromArgb( 255, 63, 63, 63 ), Color.Black ), intersect );
-               }
-               
-               protected virtual void ScrollBar_Horizontal_Draw_ThumbMoving_Backwards( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc )
-               {
-                       Rectangle r = new Rectangle( scrollbutton_width,  0,
-                                                   thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
-                       Rectangle intersect = Rectangle.Intersect( clip, r );
-                       
-                       if ( intersect != Rectangle.Empty )
-                               dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, Color.FromArgb( 255, 63, 63, 63 ), Color.Black ), intersect );
-                       
-                       r.X = thumb_pos.X + thumb_pos.Width;
-                       r.Y = 0;
-                       r.Width = bar.ClientRectangle.Width -  ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
-                       r.Height = bar.ClientRectangle.Height;
-                       
-                       intersect = Rectangle.Intersect( clip, r );
-                       if ( intersect != Rectangle.Empty )
-                               dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White), intersect );
+
+               public override bool ScrollBarHasPressedThumbStyle {
+                       get { 
+                               return false;
+                       }
                }
 
-               public override int ScrollBarButtonSize {
-                       get { return 16; }
+               public override bool ScrollBarHasHoverArrowButtonStyle {
+                       get {
+                               return false;
+                       }
                }
                #endregion      // ScrollBar
 
@@ -4252,10 +4679,7 @@ namespace System.Windows.Forms
                        Image backbuffer = new Bitmap (sb.ClientSize.Width, sb.ClientSize.Height, real_dc);
                        Graphics dc = Graphics.FromImage (backbuffer);
                        
-                       bool is_color_control = sb.BackColor.ToArgb () == ColorControl.ToArgb ();
-
-                       Brush brush = is_color_control ? SystemBrushes.Control : ResPool.GetSolidBrush (sb.BackColor);
-                       dc.FillRectangle (brush, clip);
+                       DrawStatusBarBackground (dc, clip, sb);
                        
                        if (!sb.ShowPanels && sb.Text != String.Empty) {
                                string text = sb.Text;
@@ -4291,10 +4715,8 @@ namespace System.Windows.Forms
                                }
                        }
 
-                       if (sb.SizingGrip) {
-                               area = new Rectangle (area.Right - 16 - 2, area.Bottom - 12 - 1, 16, 16);
-                               CPDrawSizeGrip (dc, ColorControl, area);
-                       }
+                       if (sb.SizingGrip)
+                               DrawStatusBarSizingGrip (dc, clip, sb, area);
                        
                        real_dc.DrawImage (backbuffer, 0, 0);
                        dc.Dispose ();
@@ -4302,6 +4724,19 @@ namespace System.Windows.Forms
 
                }
 
+               protected virtual void DrawStatusBarBackground (Graphics dc, Rectangle clip, StatusBar sb)
+               {
+                       bool is_color_control = sb.BackColor.ToArgb () == ColorControl.ToArgb ();
+
+                       Brush brush = is_color_control ? SystemBrushes.Control : ResPool.GetSolidBrush (sb.BackColor);
+                       dc.FillRectangle (brush, clip);
+               }
+
+               protected virtual void DrawStatusBarSizingGrip (Graphics dc, Rectangle clip, StatusBar sb, Rectangle area)
+               {
+                       area = new Rectangle (area.Right - 16 - 2, area.Bottom - 12 - 1, 16, 16);
+                       CPDrawSizeGrip (dc, ColorControl, area);
+               }
 
                protected virtual void DrawStatusBarPanel (Graphics dc, Rectangle area, int index,
                        Brush br_forecolor, StatusBarPanel panel) {
@@ -4309,15 +4744,9 @@ namespace System.Windows.Forms
                        int icon_width = 16;
                        
                        area.Height -= border_size;
-                       
-                       if (panel.BorderStyle != StatusBarPanelBorderStyle.None) {
-                               Border3DStyle border_style = Border3DStyle.SunkenOuter;
-                               if (panel.BorderStyle == StatusBarPanelBorderStyle.Raised)
-                                       border_style = Border3DStyle.RaisedInner;
-                                       
-                               CPDrawBorder3D(dc, area, border_style, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, panel.Parent.BackColor);
-                       }
-                       
+
+                       DrawStatusBarPanelBackground (dc, area, panel);
+
                        if (panel.Style == StatusBarPanelStyle.OwnerDraw) {
                                StatusBarDrawItemEventArgs e = new StatusBarDrawItemEventArgs (
                                        dc, panel.Parent.Font, area, index, DrawItemState.Default,
@@ -4398,6 +4827,17 @@ namespace System.Windows.Forms
                        }
                }
 
+               protected virtual void DrawStatusBarPanelBackground (Graphics dc, Rectangle area, StatusBarPanel panel)
+               {
+                       if (panel.BorderStyle != StatusBarPanelBorderStyle.None) {
+                               Border3DStyle border_style = Border3DStyle.SunkenOuter;
+                               if (panel.BorderStyle == StatusBarPanelBorderStyle.Raised)
+                                       border_style = Border3DStyle.RaisedInner;
+                                       
+                               CPDrawBorder3D(dc, area, border_style, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, panel.Parent.BackColor);
+                       }
+               }
+
                public override int StatusBarSizeGripWidth {
                        get { return 15; }
                }
@@ -4495,6 +4935,27 @@ namespace System.Windows.Forms
 
                #endregion
 
+               #region TextBox
+               public override void TextBoxBaseFillBackground (TextBoxBase textBoxBase, Graphics g, Rectangle clippingArea)
+               {
+                       if (textBoxBase.backcolor_set || (textBoxBase.Enabled && !textBoxBase.read_only)) {
+                               g.FillRectangle(ResPool.GetSolidBrush(textBoxBase.BackColor), clippingArea);
+                       } else {
+                               g.FillRectangle(ResPool.GetSolidBrush(ColorControl), clippingArea);
+                       }
+               }
+
+               public override bool TextBoxBaseHandleWmNcPaint (TextBoxBase textBoxBase, ref Message m)
+               {
+                       return false;
+               }
+
+               public override bool TextBoxBaseShouldPaintBackground (TextBoxBase textBoxBase)
+               {
+                       return true;
+               }
+               #endregion
+
                #region ToolBar
                public  override void DrawToolBar (Graphics dc, Rectangle clip_rectangle, ToolBar control) 
                {
@@ -4510,7 +4971,7 @@ namespace System.Windows.Forms
                                format.Alignment = StringAlignment.Center;
                        else
                                format.Alignment = StringAlignment.Near;
-
+#if !NET_2_0
                        if (control is PropertyGrid.PropertyToolBar) {
                                dc.FillRectangle (ResPool.GetSolidBrush(control.BackColor), clip_rectangle);
                                
@@ -4530,15 +4991,8 @@ namespace System.Windows.Forms
                                        dc.DrawLine (SystemPens.ControlDark, clip_rectangle.Right - 1, 1, clip_rectangle.Right - 1, control.Bottom - 1);
                                }
                        } else {
-
-                               if (control.Appearance == ToolBarAppearance.Flat && control.Parent != null) {
-                                       if (control.Parent.BackgroundImage != null) {
-                                               using (TextureBrush b = new TextureBrush (control.Parent.BackgroundImage, WrapMode.Tile))
-                                                       dc.FillRectangle (b, clip_rectangle);
-                                       } else {
-                                               dc.FillRectangle (ResPool.GetSolidBrush (control.Parent.BackColor), clip_rectangle);
-                                       }
-                               } else {
+#endif
+                               if (control.Appearance != ToolBarAppearance.Flat || control.Parent == null) {
                                        dc.FillRectangle (SystemBrushes.Control, clip_rectangle);
                                }
 
@@ -4548,7 +5002,9 @@ namespace System.Windows.Forms
                                        }
                                        dc.DrawLine (SystemPens.ControlLightLight, clip_rectangle.X, 1, clip_rectangle.Right, 1);
                                }
+#if !NET_2_0
                        }
+#endif
 
                        foreach (ToolBarItem item in control.items)
                                if (item.Button.Visible && clip_rectangle.IntersectsWith (item.Rectangle))
@@ -4753,25 +5209,59 @@ namespace System.Windows.Forms
                        }
                }
 
+               public override bool ToolBarHasHotElementStyles (ToolBar toolBar)
+               {
+                       return toolBar.Appearance == ToolBarAppearance.Flat;
+               }
+
+               public override bool ToolBarHasHotCheckedElementStyles {
+                       get {
+                               return false;
+                       }
+               }
                #endregion      // ToolBar
 
                #region ToolTip
                public override void DrawToolTip(Graphics dc, Rectangle clip_rectangle, ToolTip.ToolTipWindow control)
                {
+                       ToolTipDrawBackground (dc, clip_rectangle, control);
+
                        Rectangle text_rect = Rectangle.Inflate (control.ClientRectangle, -2, -1);
-                       
-                       dc.FillRectangle(SystemBrushes.Info, control.ClientRectangle);
-                       dc.DrawRectangle(SystemPens.WindowFrame, 0, 0, control.Width-1, control.Height-1);
-                       dc.DrawString(control.Text, control.Font, ResPool.GetSolidBrush(this.ColorInfoText), text_rect, control.string_format);
+#if NET_2_0
+                       Color foreground = control.ForeColor;
+#else
+                       Color foreground = this.ColorInfoText;
+#endif
+                       TextFormatFlags flags = TextFormatFlags.HidePrefix | TextFormatFlags.SingleLine | TextFormatFlags.VerticalCenter;
+                       TextRenderer.DrawTextInternal (dc, control.Text, control.Font, text_rect, foreground, flags, false);
+               }
+
+               protected virtual void ToolTipDrawBackground (Graphics dc, Rectangle clip_rectangle, ToolTip.ToolTipWindow control)
+               {
+#if NET_2_0
+                       Brush back_brush = ResPool.GetSolidBrush (control.BackColor);;
+#else
+                       Brush back_brush = SystemBrushes.Info;
+#endif
+                       dc.FillRectangle (back_brush, control.ClientRectangle);
+                       dc.DrawRectangle (SystemPens.WindowFrame, 0, 0, control.Width - 1, control.Height - 1);
                }
 
                public override Size ToolTipSize(ToolTip.ToolTipWindow tt, string text)
                {
-                       SizeF   sizef;
+                       Size size = TextRenderer.MeasureTextInternal (text, tt.Font, false);
 
-                       sizef = tt.DeviceContext.MeasureString(text, tt.Font, SizeF.Empty, tt.string_format);
-                       return new Size((int)sizef.Width+8, (int)sizef.Height+3);       // Need space for the border
+                       size.Width += 4;
+                       size.Height += 3;
+                       
+                       return size;
                }
+               
+               public override bool ToolTipTransparentBackground {
+                       get {
+                               return false;
+                       }
+               }
                #endregion      // ToolTip
 
                #region BalloonWindow
@@ -4863,8 +5353,8 @@ namespace System.Windows.Forms
                        Rectangle deskrect = Screen.GetWorkingArea (control);
                        SizeF maxsize = new SizeF (250, 200);
 
-                       SizeF titlesize = control.DeviceContext.MeasureString (control.Title, control.Font, maxsize, control.Format);
-                       SizeF textsize = control.DeviceContext.MeasureString (control.Text, control.Font, maxsize, control.Format);
+                       SizeF titlesize = TextRenderer.MeasureString (control.Title, control.Font, maxsize, control.Format);
+                       SizeF textsize = TextRenderer.MeasureString (control.Text, control.Font, maxsize, control.Format);
                        
                        if (titlesize.Height < balloon_iconsize)
                                titlesize.Height = balloon_iconsize;
@@ -4893,7 +5383,7 @@ namespace System.Windows.Forms
                        
                        /* Convert thumb position from mouse position to value*/
                        if (tb.Orientation == Orientation.Vertical) {
-                               value_pos = (int)((thumb_area.Bottom - y -(float)pixels_betweenticks / 2) / (float)pixels_betweenticks);
+                               value_pos = (int)Math.Round (((thumb_area.Bottom - y - (float)thumb_pos.Height / 2) / (float)pixels_betweenticks), 0);
 
                                if (value_pos + tb.Minimum > tb.Maximum)
                                        value_pos = tb.Maximum - tb.Minimum;
@@ -4902,7 +5392,7 @@ namespace System.Windows.Forms
 
                                result = value_pos + tb.Minimum;
                        } else {
-                               value_pos = (int) ((x - channel_startpoint.X - (float) pixels_betweenticks / 2) / (float) pixels_betweenticks);
+                               value_pos = (int)Math.Round (((x - channel_startpoint.X - (float)thumb_pos.Width / 2) / (float) pixels_betweenticks), 0);
 
                                if (value_pos + tb.Minimum > tb.Maximum)
                                        value_pos = tb.Maximum - tb.Minimum;
@@ -4969,10 +5459,6 @@ namespace System.Windows.Forms
                                }
 
                                thumb_pos.Y = thumb_area.Bottom - space_from_bottom - (int)(pixels_betweenticks * (float)(tb.Value - tb.Minimum));
-
-                               /* Draw thumb fixed 10x22 size */
-                               thumb_pos.Width = 10;
-                               thumb_pos.Height = 22;
                        } else {        
                                toptick_startpoint = new Point ();
                                bottomtick_startpoint = new Point ();
@@ -5021,13 +5507,44 @@ namespace System.Windows.Forms
                                }
 
                                thumb_pos.X = channel_startpoint.X + (int)(pixels_betweenticks * (float) (tb.Value - tb.Minimum));
+                       }
+
+                       thumb_pos.Size = TrackBarGetThumbSize (tb);
+               }
 
-                               /* Draw thumb fixed 10x22 size */
-                               thumb_pos.Width = 10;
-                               thumb_pos.Height = 22;
+               protected virtual Size TrackBarGetThumbSize (TrackBar trackBar)
+               {
+                       /* Draw thumb fixed 10x22 size */
+                       return new Size (10, 22);
+               }
+
+               #region Ticks
+               protected interface ITrackBarTickPainter
+               {
+                       void Paint (float x1, float y1, float x2, float y2);
+               }
+
+               class TrackBarTickPainter : ITrackBarTickPainter
+               {
+                       readonly Graphics g;
+                       readonly Pen pen;
+                       public TrackBarTickPainter (Graphics g, Pen pen)
+                       {
+                               this.g = g;
+                               this.pen = pen;
+                       }
+                       public void Paint (float x1, float y1, float x2, float y2)
+                       {
+                               g.DrawLine (pen, x1, y1, x2, y2);
                        }
                }
-               
+               protected virtual ITrackBarTickPainter GetTrackBarTickPainter (Graphics g)
+               {
+                       return new TrackBarTickPainter (g, ResPool.GetPen (pen_ticks_color));
+               }
+               #endregion
+
+               #region DrawTrackBar_Vertical
                private void DrawTrackBar_Vertical (Graphics dc, Rectangle clip_rectangle, TrackBar tb,
                        ref Rectangle thumb_pos, ref Rectangle thumb_area,  Brush br_thumb,
                        float ticks, int value_pos, bool mouse_value) {                 
@@ -5041,89 +5558,27 @@ namespace System.Windows.Forms
                        
                        GetTrackBarDrawingInfo (tb, out pixels_betweenticks, out thumb_area, out thumb_pos, out channel_startpoint, out bottomtick_startpoint, out toptick_startpoint);
 
-                       /* Draw channel */
-                       dc.FillRectangle (SystemBrushes.ControlDark, channel_startpoint.X, channel_startpoint.Y,
-                               1, thumb_area.Height);
-                       
-                       dc.FillRectangle (SystemBrushes.ControlDarkDark, channel_startpoint.X + 1, channel_startpoint.Y,
-                               1, thumb_area.Height);
-
-                       dc.FillRectangle (SystemBrushes.ControlLight, channel_startpoint.X + 3, channel_startpoint.Y,
-                               1, thumb_area.Height);
+                       #region Track
+                       TrackBarDrawVerticalTrack (dc, thumb_area, channel_startpoint, clip_rectangle);
+                       #endregion
 
+                       #region Thumb
                        switch (tb.TickStyle)   {
                        case TickStyle.BottomRight:
-                       case TickStyle.None: {
+                       case TickStyle.None:
                                thumb_pos.X = channel_startpoint.X - 8;
-
-                               Pen pen = SystemPens.ControlLightLight;
-                               dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X , thumb_pos.Y + 10);
-                               dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X + 16, thumb_pos.Y);
-                               dc.DrawLine (pen, thumb_pos.X + 16, thumb_pos.Y, thumb_pos.X + 16 + 4, thumb_pos.Y + 4);
-                               
-                               pen = SystemPens.ControlDark;
-                               dc.DrawLine (pen, thumb_pos.X +1, thumb_pos.Y + 9, thumb_pos.X +15, thumb_pos.Y  +9);
-                               dc.DrawLine (pen, thumb_pos.X + 16, thumb_pos.Y + 9, thumb_pos.X +16 + 4, thumb_pos.Y  +9 - 4);
-
-                               pen = SystemPens.ControlDarkDark;
-                               dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y  + 10, thumb_pos.X +16, thumb_pos.Y +10);
-                               dc.DrawLine (pen, thumb_pos.X + 16, thumb_pos.Y  + 10, thumb_pos.X  +16 + 5, thumb_pos.Y +10 - 5);
-
-                               dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 16, 8);
-                               dc.FillRectangle (br_thumb, thumb_pos.X + 17, thumb_pos.Y + 2, 1, 6);
-                               dc.FillRectangle (br_thumb, thumb_pos.X + 18, thumb_pos.Y + 3, 1, 4);
-                               dc.FillRectangle (br_thumb, thumb_pos.X + 19, thumb_pos.Y + 4, 1, 2);
-
+                               TrackBarDrawVerticalThumbRight (dc, thumb_pos, br_thumb, clip_rectangle, tb);
                                break;
-                       }
-                       case TickStyle.TopLeft: {
+                       case TickStyle.TopLeft:
                                thumb_pos.X = channel_startpoint.X - 10;
-
-                               Pen pen = SystemPens.ControlLightLight;
-                               dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y, thumb_pos.X + 4 + 16, thumb_pos.Y);
-                               dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 4);
-
-                               pen = SystemPens.ControlDark;
-                               dc.DrawLine (pen, thumb_pos.X  + 4, thumb_pos.Y + 9, thumb_pos.X + 4 + 16 , thumb_pos.Y+ 9);
-                               dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y  + 9, thumb_pos.X, thumb_pos.Y + 5);
-                               dc.DrawLine (pen, thumb_pos.X  + 19, thumb_pos.Y + 9, thumb_pos.X  +19 , thumb_pos.Y+ 1);
-
-                               pen = SystemPens.ControlDarkDark;
-                               dc.DrawLine (pen, thumb_pos.X  + 4, thumb_pos.Y+ 10, thumb_pos.X  + 4 + 16, thumb_pos.Y+ 10);
-                               dc.DrawLine (pen, thumb_pos.X  + 4, thumb_pos.Y + 10, thumb_pos.X  -1, thumb_pos.Y+ 5);
-                               dc.DrawLine (pen, thumb_pos.X + 20, thumb_pos.Y, thumb_pos.X+ 20, thumb_pos.Y + 10);
-
-                               dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 1, 15, 8);
-                               dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 2, 1, 6);
-                               dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 3, 1, 4);
-                               dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 4, 1, 2);
-
+                               TrackBarDrawVerticalThumbLeft (dc, thumb_pos, br_thumb, clip_rectangle, tb);
                                break;
-                       }
-
-                       case TickStyle.Both: {
-                               thumb_pos.X = area.X + 10;
-
-                               Pen pen = SystemPens.ControlLightLight;
-                               dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 9);
-                               dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X + 19, thumb_pos.Y);
-
-                               pen = SystemPens.ControlDark;
-                               dc.DrawLine (pen, thumb_pos.X + 1, thumb_pos.Y + 9, thumb_pos.X+ 19, thumb_pos.Y  + 9);
-                               dc.DrawLine (pen, thumb_pos.X  + 10, thumb_pos.Y+ 1, thumb_pos.X + 19, thumb_pos.Y  + 8);
-
-                               pen = SystemPens.ControlDarkDark;
-                               dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 10, thumb_pos.X+ 20, thumb_pos.Y  +10);
-                               dc.DrawLine (pen, thumb_pos.X  + 20, thumb_pos.Y, thumb_pos.X  + 20, thumb_pos.Y+ 9);
-
-                               dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 18, 8);
-
-                               break;
-                       }
-
                        default:
+                               thumb_pos.X = area.X + 10;
+                               TrackBarDrawVerticalThumb (dc, thumb_pos, br_thumb, clip_rectangle, tb);
                                break;
                        }
+                       #endregion
 
                        pixel_len = thumb_area.Height - 11;
                        pixels_betweenticks = pixel_len / ticks;
@@ -5131,46 +5586,128 @@ namespace System.Windows.Forms
                        thumb_area.X = thumb_pos.X;
                        thumb_area.Y = channel_startpoint.Y;
                        thumb_area.Width = thumb_pos.Height;
-                       
-                       /* Draw ticks*/
+
+                       #region Ticks
+                       if (pixels_betweenticks <= 0)
+                               return;
+                       if (tb.TickStyle == TickStyle.None)
+                               return;
                        Region outside = new Region (area);
                        outside.Exclude (thumb_area);                   
                        
-                       if (outside.IsVisible (clip_rectangle)) {                               
-                               if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
-                                       ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) { 
-                                       
-                                       for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks)  {                                       
-                                               if (inc == 0 || (inc +  pixels_betweenticks) >= pixel_len +1)
-                                                       dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X , area.Y + bottomtick_startpoint.Y  + inc, 
-                                                               area.X + bottomtick_startpoint.X  + 3, area.Y + bottomtick_startpoint.Y + inc);
-                                               else
-                                                       dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X, area.Y + bottomtick_startpoint.Y  + inc, 
-                                                               area.X + bottomtick_startpoint.X  + 2, area.Y + bottomtick_startpoint.Y + inc);
+                       if (outside.IsVisible (clip_rectangle)) {
+                               ITrackBarTickPainter tick_painter = TrackBarGetVerticalTickPainter (dc);
+
+                               if ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight) {
+                                       float x = area.X + bottomtick_startpoint.X;
+                                       for (float inc = 0; inc < pixel_len + 1; inc += pixels_betweenticks)    {
+                                               float y = area.Y + bottomtick_startpoint.Y + inc;
+                                               tick_painter.Paint (
+                                                       x, y,
+                                                       x + (inc == 0 || inc + pixels_betweenticks >= pixel_len + 1 ? 3 : 2), y);
                                        }
                                }
-       
-                               if (pixels_betweenticks > 0 &&  ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
-                                       ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
-       
-                                       pixel_len = thumb_area.Height - 11;
-                                       pixels_betweenticks = pixel_len / ticks;
-                                       
+
+                               if ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft) {
+                                       float x = area.X + toptick_startpoint.X; 
                                        for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {                                        
-                                               if (inc == 0 || (inc +  pixels_betweenticks) >= pixel_len +1)
-                                                       dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X  - 3 , area.Y + toptick_startpoint.Y + inc, 
-                                                               area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc);
-                                               else
-                                                       dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X  - 2, area.Y + toptick_startpoint.Y + inc, 
-                                                               area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y  + inc);
+                                               float y = area.Y + toptick_startpoint.Y + inc;
+                                               tick_painter.Paint (
+                                                       x - (inc == 0 || inc + pixels_betweenticks >= pixel_len + 1 ? 3 : 2), y,
+                                                       x, y);
                                        }                       
                                }
                        }
                        
                        outside.Dispose ();
-                       
+                       #endregion
+               }
+
+               #region Track
+               protected virtual void TrackBarDrawVerticalTrack (Graphics dc, Rectangle thumb_area, Point channel_startpoint, Rectangle clippingArea)
+               {
+                       dc.FillRectangle (SystemBrushes.ControlDark, channel_startpoint.X, channel_startpoint.Y,
+                               1, thumb_area.Height);
+
+                       dc.FillRectangle (SystemBrushes.ControlDarkDark, channel_startpoint.X + 1, channel_startpoint.Y,
+                               1, thumb_area.Height);
+
+                       dc.FillRectangle (SystemBrushes.ControlLight, channel_startpoint.X + 3, channel_startpoint.Y,
+                               1, thumb_area.Height);
+               }
+               #endregion
+
+               #region Thumb
+               protected virtual void TrackBarDrawVerticalThumbRight (Graphics dc, Rectangle thumb_pos, Brush br_thumb, Rectangle clippingArea, TrackBar trackBar)
+               {
+                       Pen pen = SystemPens.ControlLightLight;
+                       dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 10);
+                       dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X + 16, thumb_pos.Y);
+                       dc.DrawLine (pen, thumb_pos.X + 16, thumb_pos.Y, thumb_pos.X + 16 + 4, thumb_pos.Y + 4);
+
+                       pen = SystemPens.ControlDark;
+                       dc.DrawLine (pen, thumb_pos.X + 1, thumb_pos.Y + 9, thumb_pos.X + 15, thumb_pos.Y + 9);
+                       dc.DrawLine (pen, thumb_pos.X + 16, thumb_pos.Y + 9, thumb_pos.X + 16 + 4, thumb_pos.Y + 9 - 4);
+
+                       pen = SystemPens.ControlDarkDark;
+                       dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 10, thumb_pos.X + 16, thumb_pos.Y + 10);
+                       dc.DrawLine (pen, thumb_pos.X + 16, thumb_pos.Y + 10, thumb_pos.X + 16 + 5, thumb_pos.Y + 10 - 5);
+
+                       dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 16, 8);
+                       dc.FillRectangle (br_thumb, thumb_pos.X + 17, thumb_pos.Y + 2, 1, 6);
+                       dc.FillRectangle (br_thumb, thumb_pos.X + 18, thumb_pos.Y + 3, 1, 4);
+                       dc.FillRectangle (br_thumb, thumb_pos.X + 19, thumb_pos.Y + 4, 1, 2);
+               }
+
+               protected virtual void TrackBarDrawVerticalThumbLeft (Graphics dc, Rectangle thumb_pos, Brush br_thumb, Rectangle clippingArea, TrackBar trackBar)
+               {
+                       Pen pen = SystemPens.ControlLightLight;
+                       dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y, thumb_pos.X + 4 + 16, thumb_pos.Y);
+                       dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 4);
+
+                       pen = SystemPens.ControlDark;
+                       dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y + 9, thumb_pos.X + 4 + 16, thumb_pos.Y + 9);
+                       dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y + 9, thumb_pos.X, thumb_pos.Y + 5);
+                       dc.DrawLine (pen, thumb_pos.X + 19, thumb_pos.Y + 9, thumb_pos.X + 19, thumb_pos.Y + 1);
+
+                       pen = SystemPens.ControlDarkDark;
+                       dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y + 10, thumb_pos.X + 4 + 16, thumb_pos.Y + 10);
+                       dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y + 10, thumb_pos.X - 1, thumb_pos.Y + 5);
+                       dc.DrawLine (pen, thumb_pos.X + 20, thumb_pos.Y, thumb_pos.X + 20, thumb_pos.Y + 10);
+
+                       dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 1, 15, 8);
+                       dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 2, 1, 6);
+                       dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 3, 1, 4);
+                       dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 4, 1, 2);
+               }
+
+               protected virtual void TrackBarDrawVerticalThumb (Graphics dc, Rectangle thumb_pos, Brush br_thumb, Rectangle clippingArea, TrackBar trackBar)
+               {
+                       Pen pen = SystemPens.ControlLightLight;
+                       dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 9);
+                       dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X + 19, thumb_pos.Y);
+
+                       pen = SystemPens.ControlDark;
+                       dc.DrawLine (pen, thumb_pos.X + 1, thumb_pos.Y + 9, thumb_pos.X + 19, thumb_pos.Y + 9);
+                       dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y + 1, thumb_pos.X + 19, thumb_pos.Y + 8);
+
+                       pen = SystemPens.ControlDarkDark;
+                       dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 10, thumb_pos.X + 20, thumb_pos.Y + 10);
+                       dc.DrawLine (pen, thumb_pos.X + 20, thumb_pos.Y, thumb_pos.X + 20, thumb_pos.Y + 9);
+
+                       dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 18, 8);
                }
+               #endregion
 
+               #region Ticks
+               protected virtual ITrackBarTickPainter TrackBarGetVerticalTickPainter (Graphics g)
+               {
+                       return GetTrackBarTickPainter (g);
+               }
+               #endregion
+               #endregion
+
+               #region DrawTrackBar_Horizontal
                /* 
                        Horizontal trackbar 
                  
@@ -5192,129 +5729,154 @@ namespace System.Windows.Forms
                        Rectangle area = tb.ClientRectangle;
                        
                        GetTrackBarDrawingInfo (tb , out pixels_betweenticks, out thumb_area, out thumb_pos, out channel_startpoint, out bottomtick_startpoint, out toptick_startpoint);
-                       
-                       /* Draw channel */
-                       dc.FillRectangle (SystemBrushes.ControlDark, channel_startpoint.X, channel_startpoint.Y,
-                               thumb_area.Width, 1);
-                       
-                       dc.FillRectangle (SystemBrushes.ControlDarkDark, channel_startpoint.X, channel_startpoint.Y + 1,
-                               thumb_area.Width, 1);
 
-                       dc.FillRectangle (SystemBrushes.ControlLight, channel_startpoint.X, channel_startpoint.Y +3,
-                               thumb_area.Width, 1);
+                       #region Track
+                       TrackBarDrawHorizontalTrack (dc, thumb_area, channel_startpoint, clip_rectangle);
+                       #endregion
 
+                       #region Thumb
                        switch (tb.TickStyle) {
                        case TickStyle.BottomRight:
-                       case TickStyle.None: {
+                       case TickStyle.None:
                                thumb_pos.Y = channel_startpoint.Y - 8;
-
-                               Pen pen = SystemPens.ControlLightLight;
-                               dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X + 10, thumb_pos.Y);
-                               dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 16);
-                               dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 16, thumb_pos.X + 4, thumb_pos.Y + 16 + 4);
-
-                               pen = SystemPens.ControlDark;
-                               dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 1, thumb_pos.X +9, thumb_pos.Y +15);
-                               dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 16, thumb_pos.X +9 - 4, thumb_pos.Y +16 + 4);
-
-                               pen = SystemPens.ControlDarkDark;
-                               dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X +10, thumb_pos.Y +16);
-                               dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y + 16, thumb_pos.X +10 - 5, thumb_pos.Y +16 + 5);
-
-                               dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 8, 16);
-                               dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 17, 6, 1);
-                               dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 18, 4, 1);
-                               dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 19, 2, 1);
+                               TrackBarDrawHorizontalThumbBottom (dc, thumb_pos, br_thumb, clip_rectangle, tb);
                                break;
-                       }
-                       case TickStyle.TopLeft: {
+                       case TickStyle.TopLeft:
                                thumb_pos.Y = channel_startpoint.Y - 10;
-
-                               Pen pen = SystemPens.ControlLightLight;
-                               dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X, thumb_pos.Y + 4 + 16);
-                               dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X + 4, thumb_pos.Y);
-
-                               pen = SystemPens.ControlDark;
-                               dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 9, thumb_pos.Y + 4 + 16);
-                               dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y);
-                               dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 19, thumb_pos.X + 1 , thumb_pos.Y +19);
-
-                               pen = SystemPens.ControlDarkDark;
-                               dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 10, thumb_pos.Y + 4 + 16);
-                               dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y -1);
-                               dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 20, thumb_pos.X + 10, thumb_pos.Y + 20);
-
-                               dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 4, 8, 15);
-                               dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 3, 6, 1);
-                               dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 2, 4, 1);
-                               dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 1, 2, 1);
+                               TrackBarDrawHorizontalThumbTop (dc, thumb_pos, br_thumb, clip_rectangle, tb);
                                break;
-                       }
-
-                       case TickStyle.Both: {
-                               thumb_pos.Y = area.Y + 10;
-                                       
-                               Pen pen = SystemPens.ControlLightLight;
-                               dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X + 9, thumb_pos.Y);
-                               dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 19);
-
-                               pen = SystemPens.ControlDark;
-                               dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 1, thumb_pos.X + 9, thumb_pos.Y + 19);
-                               dc.DrawLine (pen, thumb_pos.X + 1, thumb_pos.Y + 10, thumb_pos.X + 8, thumb_pos.Y + 19);
-
-                               pen = SystemPens.ControlDarkDark;
-                               dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X +10, thumb_pos.Y + 20);
-                               dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 20, thumb_pos.X + 9, thumb_pos.Y + 20);
-
-                               dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 8, 18);
-
-                               break;
-                       }
-
                        default:
+                               thumb_pos.Y = area.Y + 10;
+                               TrackBarDrawHorizontalThumb (dc, thumb_pos, br_thumb, clip_rectangle, tb);
                                break;
                        }
+                       #endregion
 
                        pixel_len = thumb_area.Width - 11;
                        pixels_betweenticks = pixel_len / ticks;
 
-                       /* Draw ticks*/
                        thumb_area.Y = thumb_pos.Y;
                        thumb_area.X = channel_startpoint.X;
                        thumb_area.Height = thumb_pos.Height;
+                       #region Ticks
+                       if (pixels_betweenticks <= 0)
+                               return;
+                       if (tb.TickStyle == TickStyle.None)
+                               return;
                        Region outside = new Region (area);
-                       outside.Exclude (thumb_area);                   
-                       
-                       if (outside.IsVisible (clip_rectangle)) {                               
-                               if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
-                                       ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {                         
-                                       
-                                       for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {                                        
-                                               if (inc == 0 || (inc +  pixels_betweenticks) >= pixel_len +1)
-                                                       dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y, 
-                                                               area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y + 3);
-                                               else
-                                                       dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y, 
-                                                               area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y + 2);
+                       outside.Exclude (thumb_area);
+
+                       if (outside.IsVisible (clip_rectangle)) {
+                               ITrackBarTickPainter tick_painter = TrackBarGetHorizontalTickPainter (dc);
+
+                               if ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight) {
+                                       float y = area.Y + bottomtick_startpoint.Y;
+                                       for (float inc = 0; inc < pixel_len + 1; inc += pixels_betweenticks) {                                  
+                                               float x = area.X + bottomtick_startpoint.X + inc;
+                                               tick_painter.Paint (
+                                                       x, y, 
+                                                       x, y + (inc == 0 || inc + pixels_betweenticks >= pixel_len + 1 ? 3 : 2));
                                        }
                                }
-       
-                               if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
-                                       ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
-                                       
-                                       for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {                                        
-                                               if (inc == 0 || (inc +  pixels_betweenticks) >= pixel_len +1)
-                                                       dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y - 3, 
-                                                               area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y);
-                                               else
-                                                       dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y - 2, 
-                                                               area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y );
+
+                               if ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft) {
+                                       float y = area.Y + toptick_startpoint.Y;
+                                       for (float inc = 0; inc < pixel_len + 1; inc += pixels_betweenticks) {                                  
+                                               float x = area.X + toptick_startpoint.X + inc;
+                                               tick_painter.Paint (
+                                                       x, y - (inc == 0 || (inc + pixels_betweenticks) >= pixel_len + 1 ? 3 : 2), 
+                                                       x, y);
                                        }                       
                                }
                        }
                        
-                       outside.Dispose ();                     
+                       outside.Dispose ();
+                       #endregion
+               }
+
+               #region Track
+               protected virtual void TrackBarDrawHorizontalTrack (Graphics dc, Rectangle thumb_area, Point channel_startpoint, Rectangle clippingArea)
+               {
+                       dc.FillRectangle (SystemBrushes.ControlDark, channel_startpoint.X, channel_startpoint.Y,
+                               thumb_area.Width, 1);
+
+                       dc.FillRectangle (SystemBrushes.ControlDarkDark, channel_startpoint.X, channel_startpoint.Y + 1,
+                               thumb_area.Width, 1);
+
+                       dc.FillRectangle (SystemBrushes.ControlLight, channel_startpoint.X, channel_startpoint.Y + 3,
+                               thumb_area.Width, 1);
+               }
+               #endregion
+
+               #region Thumb
+               protected virtual void TrackBarDrawHorizontalThumbBottom (Graphics dc, Rectangle thumb_pos, Brush br_thumb, Rectangle clippingArea, TrackBar trackBar)
+               {
+                       Pen pen = SystemPens.ControlLightLight;
+                       dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X + 10, thumb_pos.Y);
+                       dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 16);
+                       dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 16, thumb_pos.X + 4, thumb_pos.Y + 16 + 4);
+
+                       pen = SystemPens.ControlDark;
+                       dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 1, thumb_pos.X + 9, thumb_pos.Y + 15);
+                       dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 16, thumb_pos.X + 9 - 4, thumb_pos.Y + 16 + 4);
+
+                       pen = SystemPens.ControlDarkDark;
+                       dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X + 10, thumb_pos.Y + 16);
+                       dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y + 16, thumb_pos.X + 10 - 5, thumb_pos.Y + 16 + 5);
+
+                       dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 8, 16);
+                       dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 17, 6, 1);
+                       dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 18, 4, 1);
+                       dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 19, 2, 1);
+               }
+
+               protected virtual void TrackBarDrawHorizontalThumbTop (Graphics dc, Rectangle thumb_pos, Brush br_thumb, Rectangle clippingArea, TrackBar trackBar)
+               {
+                       Pen pen = SystemPens.ControlLightLight;
+                       dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X, thumb_pos.Y + 4 + 16);
+                       dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X + 4, thumb_pos.Y);
+
+                       pen = SystemPens.ControlDark;
+                       dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 9, thumb_pos.Y + 4 + 16);
+                       dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y);
+                       dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 19, thumb_pos.X + 1, thumb_pos.Y + 19);
+
+                       pen = SystemPens.ControlDarkDark;
+                       dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 10, thumb_pos.Y + 4 + 16);
+                       dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y - 1);
+                       dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 20, thumb_pos.X + 10, thumb_pos.Y + 20);
+
+                       dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 4, 8, 15);
+                       dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 3, 6, 1);
+                       dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 2, 4, 1);
+                       dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 1, 2, 1);
+               }
+
+               protected virtual void TrackBarDrawHorizontalThumb (Graphics dc, Rectangle thumb_pos, Brush br_thumb, Rectangle clippingArea, TrackBar trackBar)
+               {
+                       Pen pen = SystemPens.ControlLightLight;
+                       dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X + 9, thumb_pos.Y);
+                       dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 19);
+
+                       pen = SystemPens.ControlDark;
+                       dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 1, thumb_pos.X + 9, thumb_pos.Y + 19);
+                       dc.DrawLine (pen, thumb_pos.X + 1, thumb_pos.Y + 10, thumb_pos.X + 8, thumb_pos.Y + 19);
+
+                       pen = SystemPens.ControlDarkDark;
+                       dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X + 10, thumb_pos.Y + 20);
+                       dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 20, thumb_pos.X + 9, thumb_pos.Y + 20);
+
+                       dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 8, 18);
                }
+               #endregion
+
+               #region Ticks
+               protected virtual ITrackBarTickPainter TrackBarGetHorizontalTickPainter (Graphics g)
+               {
+                       return GetTrackBarTickPainter (g);
+               }
+               #endregion
+               #endregion
 
                public override void DrawTrackBar (Graphics dc, Rectangle clip_rectangle, TrackBar tb) 
                {
@@ -5375,8 +5937,26 @@ namespace System.Windows.Forms
                        }
                }
 
+               public override bool TrackBarHasHotThumbStyle {
+                       get {
+                               return false;
+                       }
+               }
                #endregion      // TrackBar
 
+               #region UpDownBase
+               public override void UpDownBaseDrawButton (Graphics g, Rectangle bounds, bool top, VisualStyles.PushButtonState state)
+               {
+                       ControlPaint.DrawScrollButton (g, bounds, top ? ScrollButton.Up : ScrollButton.Down, state == VisualStyles.PushButtonState.Pressed ? ButtonState.Pushed : ButtonState.Normal);
+               }
+
+               public override bool UpDownBaseHasHotButtonStyle {
+                       get {
+                               return false;
+                       }
+               }
+               #endregion
+
                #region VScrollBar
                public override Size VScrollBarDefaultSize {
                        get {
@@ -5392,8 +5972,23 @@ namespace System.Windows.Forms
                        }
                }
 
+               public override void TreeViewDrawNodePlusMinus (TreeView treeView, TreeNode node, Graphics dc, int x, int middle)
+               {
+                       int height = treeView.ActualItemHeight - 2;
+                       dc.FillRectangle (ResPool.GetSolidBrush (treeView.BackColor), (x + 4) - (height / 2), node.GetY() + 1, height, height);
+                       
+                       dc.DrawRectangle (SystemPens.ControlDarkDark, x, middle - 4, 8, 8);
+
+                       if (node.IsExpanded) {
+                               dc.DrawLine (SystemPens.ControlDarkDark, x + 2, middle, x + 6, middle); 
+                       } else {
+                               dc.DrawLine (SystemPens.ControlDarkDark, x + 2, middle, x + 6, middle);
+                               dc.DrawLine (SystemPens.ControlDarkDark, x + 4, middle - 2, x + 4, middle + 2);
+                       }
+               }
                #endregion
 
+               #region Managed window
                public override int ManagedWindowTitleBarHeight (InternalWindowManager wm)
                {
                        if (wm.IsToolWindow && !wm.IsMinimized)
@@ -5405,7 +6000,10 @@ namespace System.Windows.Forms
 
                public override int ManagedWindowBorderWidth (InternalWindowManager wm)
                {
-                       return 4;
+                       if (wm is ToolWindowManager && wm.form.FormBorderStyle == FormBorderStyle.FixedToolWindow)
+                               return 3;
+                       else
+                               return 4;
                }
 
                public override int ManagedWindowIconWidth (InternalWindowManager wm)
@@ -5503,17 +6101,15 @@ namespace System.Windows.Forms
                        dc.FillRectangle (Brushes.Black, clip);
 #endif
                        
-                       if (wm.HasBorders) {
-                               Pen pen = ResPool.GetPen (ColorControl);
-                               Rectangle borders = new Rectangle (0, 0, form.Width, form.Height);
-                               ControlPaint.DrawBorder3D (dc, borders, Border3DStyle.Raised);
-                               // The 3d border is only 2 pixels wide, so we draw the innermost pixels ourselves
-                               borders = new Rectangle (2, 2, form.Width - 5, form.Height - 5);
-                               for (int i = 2; i < bdwidth; i++) {
-                                       dc.DrawRectangle (pen, borders);
-                                       borders.Inflate (-1, -1);
-                               }                               
-                       }
+                       Pen pen = ResPool.GetPen (ColorControl);
+                       Rectangle borders = new Rectangle (0, 0, form.Width, form.Height);
+                       ControlPaint.DrawBorder3D (dc, borders, Border3DStyle.Raised);
+                       // The 3d border is only 2 pixels wide, so we draw the innermost pixels ourselves
+                       borders = new Rectangle (2, 2, form.Width - 5, form.Height - 5);
+                       for (int i = 2; i < bdwidth; i++) {
+                               dc.DrawRectangle (pen, borders);
+                               borders.Inflate (-1, -1);
+                       }                               
 
 
                        bool draw_titlebar_enabled = false;
@@ -5547,35 +6143,29 @@ namespace System.Windows.Forms
                                tb.Width = (form.Width - 62) - tb.X;
                        }
 
-                       if (form.Text != null && form.Text != string.Empty) {
+                       string window_caption = form.Text;
+                       window_caption = window_caption.Replace (Environment.NewLine, string.Empty);
+
+                       if (window_caption != null && window_caption != string.Empty) {
                                StringFormat format = new StringFormat ();
                                format.FormatFlags = StringFormatFlags.NoWrap;
                                format.Trimming = StringTrimming.EllipsisCharacter;
                                format.LineAlignment = StringAlignment.Center;
 
                                if (tb.IntersectsWith (clip))
-                                       dc.DrawString (form.Text, WindowBorderFont,
+                                       dc.DrawString (window_caption, WindowBorderFont,
                                                ThemeEngine.Current.ResPool.GetSolidBrush (Color.White),
                                                tb, format);
                        }
 
-                       if (wm.HasBorders) {
-                               bool draw_icon = false;
-#if NET_2_0
-                               draw_icon = !wm.IsToolWindow && form.Icon != null && form.ShowIcon;
-#else
-                               draw_icon = !wm.IsToolWindow && form.Icon != null;
-#endif
-                               if (draw_icon) {
-                                       Rectangle icon = new Rectangle (bdwidth + 3,
-                                                       bdwidth + 2, wm.IconWidth, wm.IconWidth);
-                                       if (icon.IntersectsWith (clip))
-                                               dc.DrawIcon (form.Icon, icon);
-                               }
-                               
-                               foreach (TitleButton button in wm.TitleButtons.AllButtons) {
-                                       DrawTitleButton (dc, button, clip);
-                               }
+                       if (wm.ShowIcon) {
+                               Rectangle icon = ManagedWindowGetTitleBarIconArea (wm);
+                               if (icon.IntersectsWith (clip))
+                                       dc.DrawIcon (form.Icon, icon);
+                       }
+                       
+                       foreach (TitleButton button in wm.TitleButtons.AllButtons) {
+                               DrawTitleButton (dc, button, clip);
                        }
                }
 
@@ -5610,6 +6200,13 @@ namespace System.Windows.Forms
                                        button.Caption, button.State);
                }
 
+               public override Rectangle ManagedWindowGetTitleBarIconArea (InternalWindowManager wm)
+               {
+                       int bw = ManagedWindowBorderWidth (wm);
+                       return new Rectangle (bw + 3, bw + 2, wm.IconWidth, wm.IconWidth);
+               }
+               #endregion
+
                #region ControlPaint
                public override void CPDrawBorder (Graphics graphics, Rectangle bounds, Color leftColor, int leftWidth,
                        ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle,
@@ -5868,7 +6465,10 @@ namespace System.Windows.Forms
                                cb_rect.Width -= 2;
                                cb_rect.Height -= 2;
                                
-                               dc.FillRectangle (SystemBrushes.ControlLight, cb_rect.X, cb_rect.Y, cb_rect.Width - 1, cb_rect.Height - 1);
+                               if ((state & ButtonState.Inactive) == ButtonState.Inactive)
+                                       dc.FillRectangle (SystemBrushes.ControlLight, cb_rect.X, cb_rect.Y, cb_rect.Width - 1, cb_rect.Height - 1);
+                               else
+                                       dc.FillRectangle (Brushes.White, cb_rect.X, cb_rect.Y, cb_rect.Width - 1, cb_rect.Height - 1);
                                dc.DrawRectangle (SystemPens.ControlDark, cb_rect.X, cb_rect.Y, cb_rect.Width - 1, cb_rect.Height - 1);
                        } else {
                                cb_rect.Width -= 1;
@@ -5897,7 +6497,7 @@ namespace System.Windows.Forms
                                dc.DrawLine (pen, rect.X + 1, rect.Y + 1, rect.X + 1, rect.Bottom - 2);
                                dc.DrawLine (pen, rect.X + 2, rect.Y + 1, rect.Right - 2, rect.Y + 1);
                                
-                               pen = SystemPens.ControlLight;
+                               pen = SystemPens.ControlLightLight;
                                dc.DrawLine (pen, rect.Right, rect.Y, rect.Right, rect.Bottom);
                                dc.DrawLine (pen, rect.X, rect.Bottom, rect.Right, rect.Bottom);
                                
@@ -5920,7 +6520,7 @@ namespace System.Windows.Forms
                                        int lineWidth = Math.Max (3, check_size / 3);
                                        int Scale = Math.Max (1, check_size / 9);
                                        
-                                       Rectangle rect = new Rectangle (cb_rect.X + (cb_rect.Width / 2) - (check_size / 2) - 1, cb_rect.Y + (cb_rect.Height / 2) - (check_size / 2) - 1, 
+                                       Rectangle rect = new Rectangle (cb_rect.X + (cb_rect.Width / 2) - (int)Math.Ceiling ((float)check_size / 2) - 1, cb_rect.Y + (cb_rect.Height / 2) - (check_size / 2) - 1, 
                                                                        check_size, check_size);
                                        
                                        for (int i = 0; i < lineWidth; i++) {
@@ -6274,6 +6874,12 @@ namespace System.Windows.Forms
 
                }
 
+               [MonoTODO]
+               public override void CPDrawMixedCheckBox (Graphics graphics, Rectangle rectangle, ButtonState state)
+               {
+                       CPDrawCheckBox (graphics, rectangle, state);
+               }
+
                public override void CPDrawRadioButton (Graphics dc, Rectangle rectangle, ButtonState state)
                {
                        CPColor cpcolor = ResPool.GetCPColor (ColorControl);