2006-03-21 Alexander Olk <alex.olk@googlemail.com>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / ThemeWin32Classic.cs
index 4589faaa1298f450a9cea93d0ac9d70df7efeed2..b4da2611af4cfc42953cdd59f0ca3609e0307854 100644 (file)
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-// Copyright (c) 2004-2005 Novell, Inc.
+// Copyright (c) 2004-2006 Novell, Inc.
 //
 // Authors:
 //     Jordi Mas i Hernandez, jordi@ximian.com
 //     Peter Bartok, pbartok@novell.com
 //     John BouAntoun, jba-mono@optusnet.com.au
-//  Marek Safar, marek.safar@seznam.cz
+//     Marek Safar, marek.safar@seznam.cz
 //
 
 
@@ -43,37 +43,6 @@ namespace System.Windows.Forms
                        }
                }
 
-
-               /* Default colors for Win32 classic theme */
-               uint [] theme_colors = {                                                        /* AARRGGBB */
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_SCROLLBAR,                   0xffc0c0c0,
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_BACKGROUND,                  0xff008080,
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_ACTIVECAPTION,               0xff000080,
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_INACTIVECAPTION,             0xff808080,
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_MENU,                        0xffc0c0c0,
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_WINDOW,                      0xffffffff,
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_WINDOWFRAME,                 0xff000000,
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_MENUTEXT,                    0xff000000,
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_WINDOWTEXT,                  0xff000000,
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_CAPTIONTEXT,                 0xffffffff,
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_ACTIVEBORDER,                0xffc0c0c0,
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_INACTIVEBORDER,              0xffc0c0c0,
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_APPWORKSPACE,                0xff808080,
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_HIGHLIGHT,                   0xff000080,
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_HIGHLIGHTTEXT,               0xffffffff,
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_BTNFACE,                     0xffc0c0c0,
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_BTNSHADOW,                   0xff808080,
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_GRAYTEXT,                    0xff808080,
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_BTNTEXT,                     0xff000000,
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_INACTIVECAPTIONTEXT,         0xffc0c0c0,
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_BTNHIGHLIGHT,                0xffffffff,
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_3DDKSHADOW,                  0xff000000,                     
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_3DLIGHT,                     0xffe0e0e0,
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_INFOTEXT,                    0xff000000,
-                       (uint) XplatUIWin32.GetSysColorIndex.COLOR_INFOBK,                      0xffffffff,
-                 
-               };              
-                               
                /* Hardcoded colour values not exposed in the API constants in all configurations */
                protected static readonly Color arrow_color = Color.Black;
                protected static readonly Color pen_ticks_color = Color.Black;
@@ -92,14 +61,8 @@ namespace System.Windows.Forms
                #region Principal Theme Methods
                public ThemeWin32Classic ()
                {                       
-                       /* Init Default colour array*/
-                       syscolors =  Array.CreateInstance (typeof (Color), (uint) XplatUIWin32.GetSysColorIndex.COLOR_MAXVALUE+1);
-                       
-                       for (int i = 0; i < theme_colors.Length; i +=2) 
-                               syscolors.SetValue (Color.FromArgb ((int)theme_colors[i+1]), (int) theme_colors[i]);                    
-
-                       defaultWindowBackColor = SystemColors.Window;
-                       defaultWindowForeColor = ColorButtonText;
+                       defaultWindowBackColor = this.ColorWindow;
+                       defaultWindowForeColor = this.ColorControlText;
                        default_font =  new Font (FontFamily.GenericSansSerif, 8.25f);
                        
                        /* Menu string formats */
@@ -116,6 +79,7 @@ namespace System.Windows.Forms
                        string_format_menu_menubar_text.LineAlignment = StringAlignment.Center;
                        string_format_menu_menubar_text.Alignment = StringAlignment.Center;
                        string_format_menu_menubar_text.HotkeyPrefix = HotkeyPrefix.Show;
+                       always_draw_hotkeys = false;
                }       
 
                public override void ResetDefaults() {
@@ -130,14 +94,14 @@ namespace System.Windows.Forms
                #region Internal Methods
                protected SolidBrush GetControlBackBrush (Color c) {
                        if (c == DefaultControlBackColor)
-                               return ResPool.GetSolidBrush (ColorButtonFace);
-                       return new SolidBrush (c);
+                               return ResPool.GetSolidBrush (ColorControl);
+                       return ResPool.GetSolidBrush (c);
                }
 
                protected SolidBrush GetControlForeBrush (Color c) {
                        if (c == DefaultControlForeColor)
-                               return ResPool.GetSolidBrush (ColorButtonText);
-                       return new SolidBrush (c);
+                               return ResPool.GetSolidBrush (ColorControlText);
+                       return ResPool.GetSolidBrush (c);
                }
                #endregion      // Internal Methods
 
@@ -186,17 +150,20 @@ namespace System.Windows.Forms
                        
                        // set up the button rectangle
                        buttonRectangle = button.ClientRectangle;
-                       if (button.has_focus) {
+                       if (button.has_focus || button.paint_as_acceptbutton) {
                                // shrink the rectangle for the normal button drawing inside the focus rectangle
                                borderRectangle = Rectangle.Inflate(buttonRectangle, -1, -1);
                        } else {
                                borderRectangle = buttonRectangle;
                        }
-                       
+
                        if (button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup) {
                                DrawFlatStyleButton (dc, borderRectangle, button);
                        } else {
                                CPDrawButton(dc, borderRectangle, button.ButtonState);
+                               if (button.has_focus || button.paint_as_acceptbutton) {
+                                       dc.DrawRectangle(ResPool.GetPen(button.ForeColor), borderRectangle);
+                               }
                        }
                }
 
@@ -292,7 +259,7 @@ namespace System.Windows.Forms
                                dc.DrawImage(i, image_x, image_y); 
                        }
                        else {
-                               CPDrawImageDisabled(dc, i, image_x, image_y, ColorButtonFace);
+                               CPDrawImageDisabled(dc, i, image_x, image_y, ColorControl);
                        }
                }
                
@@ -301,7 +268,9 @@ namespace System.Windows.Forms
                        if (button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup) {
                                DrawFlatStyleFocusRectangle (dc, button.ClientRectangle, button, button.ForeColor, button.BackColor);
                        } else { 
-                               CPDrawFocusRectangle(dc, button.ClientRectangle, button.ForeColor, button.BackColor);
+                               Rectangle rect = button.ClientRectangle;
+                               rect.Inflate (-4, -4);
+                               CPDrawFocusRectangle(dc, rect, button.ForeColor, button.BackColor);
                        }
                }
                
@@ -319,9 +288,9 @@ namespace System.Windows.Forms
                                dc.DrawString(button.text, button.Font, ResPool.GetSolidBrush (button.ForeColor), text_rect, button.text_format);
                        } else {
                                if (button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup) {
-                                       dc.DrawString(button.text, button.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorButtonFace)), text_rect, button.text_format);
+                                       dc.DrawString(button.text, button.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorControl)), text_rect, button.text_format);
                                } else {
-                                       CPDrawStringDisabled(dc, button.text, button.Font, ColorButtonText, text_rect, button.text_format);
+                                       CPDrawStringDisabled(dc, button.text, button.Font, ColorControlText, text_rect, button.text_format);
                                }
                        }
                }
@@ -352,12 +321,12 @@ namespace System.Windows.Forms
                                                // else it must be a popup button
                                                
                                                if (button.Capture && button.is_entered) {
-                                                       graphics.DrawRectangle(ResPool.GetPen (this.ColorButtonText), trace_rectangle);
+                                                       graphics.DrawRectangle(ResPool.GetPen (this.ColorControlText), trace_rectangle);
                                                } else {
                                                        // draw a 3d border
                                                        CPDrawBorder3D (graphics, rectangle, Border3DStyle.RaisedInner, Border3DSide.Left | Border3DSide.Top, button.BackColor); 
-                                                       graphics.DrawLine ( ResPool.GetPen (this.ColorButtonText), trace_rectangle.X, trace_rectangle.Bottom, trace_rectangle.Right, trace_rectangle.Bottom);
-                                                       graphics.DrawLine ( ResPool.GetPen (this.ColorButtonText), trace_rectangle.Right, trace_rectangle.Y, trace_rectangle.Right, trace_rectangle.Bottom);
+                                                       graphics.DrawLine ( ResPool.GetPen (this.ColorControlText), trace_rectangle.X, trace_rectangle.Bottom, trace_rectangle.Right, trace_rectangle.Bottom);
+                                                       graphics.DrawLine ( ResPool.GetPen (this.ColorControlText), trace_rectangle.Right, trace_rectangle.Y, trace_rectangle.Right, trace_rectangle.Bottom);
                                                }
                                        }
                                        
@@ -366,7 +335,7 @@ namespace System.Windows.Forms
                                } else {
                                        // popup has a ButtonColorText forecolor, not a button.ForeCOlor
                                        if (button.FlatStyle == FlatStyle.Popup) {
-                                               rect_fore_color = this.ColorButtonText;
+                                               rect_fore_color = this.ColorControlText;
                                        }
                                        
                                        // fill then draw outer rect
@@ -381,7 +350,7 @@ namespace System.Windows.Forms
                                        (radiobutton != null && radiobutton.Checked)) {
                                        if (button.FlatStyle == FlatStyle.Flat && button.is_entered && !button.Capture) {
                                                // render the hover for flat flatstyle and cheked
-                                               graphics.DrawRectangle(ResPool.GetPen (this.ColorButtonText), trace_rectangle);
+                                               graphics.DrawRectangle(ResPool.GetPen (this.ColorControlText), trace_rectangle);
                                        } else if (!button.is_entered && !button.Capture) {
                                                // render the checked state for popup when unhovered
                                                CPDrawBorder3D (graphics, rectangle, Border3DStyle.SunkenInner, Border3DSide.Right | Border3DSide.Bottom, button.BackColor); 
@@ -394,7 +363,7 @@ namespace System.Windows.Forms
                                bool draw_popup_checked = false;
                                
                                if (button.FlatStyle == FlatStyle.Popup) {
-                                       rect_fore_color = this.ColorButtonText;
+                                       rect_fore_color = this.ColorControlText;
                                
                                        // see if we should draw a disabled checked popup button
                                        draw_popup_checked = ((checkbox != null && checkbox.Checked) ||
@@ -597,6 +566,8 @@ namespace System.Windows.Forms
                        CheckBox_DrawText(checkbox, text_rectangle, dc, text_format);
 
                        CheckBox_DrawFocus(checkbox, dc, text_rectangle);
+
+                       text_format.Dispose ();
                }
 
                protected virtual void CheckBox_DrawCheckBox( Graphics dc, CheckBox checkbox, ButtonState state, Rectangle checkbox_rectangle )
@@ -634,13 +605,18 @@ namespace System.Windows.Forms
                        }
                        
                        /* Place the text; to be compatible with Windows place it after the checkbox has been drawn */
+
+                       // Windows seems to not wrap text in certain situations, this matches as close as I could get it
+                       if ((float)(checkbox.Font.Height * 1.5f) > text_rectangle.Height) {
+                               text_format.FormatFlags |= StringFormatFlags.NoWrap;
+                       }
                        if (checkbox.Enabled) {
                                sb = ResPool.GetSolidBrush(checkbox.ForeColor);
                                dc.DrawString(checkbox.Text, checkbox.Font, sb, text_rectangle, text_format);                   
                        } else if (checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup) {
-                               dc.DrawString(checkbox.Text, checkbox.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorButtonFace)), text_rectangle, text_format);
+                               dc.DrawString(checkbox.Text, checkbox.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorControl)), text_rectangle, text_format);
                        } else {
-                               CPDrawStringDisabled(dc, checkbox.Text, checkbox.Font, ColorButtonText, text_rectangle, text_format);
+                               CPDrawStringDisabled(dc, checkbox.Text, checkbox.Font, ColorControlText, text_rectangle, text_format);
                        }
                }
                
@@ -695,7 +671,7 @@ namespace System.Windows.Forms
                                                ControlPaint.DrawBorder(graphics, checkbox_rectangle, checkbox.ForeColor, ButtonBorderStyle.Solid);
                                        } else {
                                                // draw sunken effect
-                                               CPDrawBorder3D (graphics, checkbox_rectangle, Border3DStyle.SunkenInner, Border3DSide.All, checkbox.BackColor);
+                                               CPDrawBorder3D (graphics, checkbox_rectangle, Border3DStyle.SunkenInner, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, checkbox.BackColor);
                                        }
                                } else {
                                        graphics.FillRectangle(ResPool.GetSolidBrush (ControlPaint.LightLight (checkbox.BackColor)), fill_rectangle);                           
@@ -713,7 +689,7 @@ namespace System.Windows.Forms
                                }       
                        
                                // draw disabled state,
-                               ControlPaint.DrawBorder(graphics, checkbox_rectangle, ColorButtonShadow, ButtonBorderStyle.Solid);
+                               ControlPaint.DrawBorder(graphics, checkbox_rectangle, ColorControlDark, ButtonBorderStyle.Solid);
                        }               
                        
                        /* Make sure we've got at least a line width of 1 */
@@ -774,23 +750,23 @@ namespace System.Windows.Forms
                        
                        /* Draw text*/
                        if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
-                               back_color = ThemeEngine.Current.ColorHilight;
-                               fore_color = ThemeEngine.Current.ColorHilightText;
+                               back_color = ColorHighlight;
+                               fore_color = ColorHighlightText;
                        }
                        else {
                                back_color = e.BackColor;
                                fore_color = e.ForeColor;
                        }
                        
-                       e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush
+                       e.Graphics.FillRectangle (ResPool.GetSolidBrush
                                (back_color), item_rect);
 
                        e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
-                               ThemeEngine.Current.ResPool.GetSolidBrush (fore_color),
+                               ResPool.GetSolidBrush (fore_color),
                                item_rect, string_format);
                                        
                        if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) {
-                               ThemeEngine.Current.CPDrawFocusRectangle (e.Graphics, item_rect,
+                               CPDrawFocusRectangle (e.Graphics, item_rect,
                                        fore_color, back_color);
                        }
                }
@@ -803,14 +779,14 @@ namespace System.Windows.Forms
                
                public override void DrawComboBoxEditDecorations (Graphics dc, ComboBox ctrl, Rectangle cl)
                {                               
-                       dc.DrawLine (ResPool.GetPen (ColorButtonShadow), cl.X, cl.Y, cl.X + cl.Width, cl.Y); //top 
-                       dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), cl.X + 1, cl.Y + 1, cl.X + cl.Width - 2, cl.Y + 1);
-                       dc.DrawLine (ResPool.GetPen (ColorButtonFace), cl.X, cl.Y + cl.Height - 2, cl.X + cl.Width, cl.Y + cl.Height - 2); //down
-                       dc.DrawLine (ResPool.GetPen (ColorButtonHilight), cl.X, cl.Y + cl.Height - 1, cl.X + cl.Width, cl.Y + cl.Height - 1);
-                       dc.DrawLine (ResPool.GetPen (ColorButtonShadow), cl.X, cl.Y, cl.X, cl.Y + cl.Height); //left
-                       dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), cl.X + 1, cl.Y + 1, cl.X + 1, cl.Y + cl.Height - 2); 
-                       dc.DrawLine (ResPool.GetPen (ColorButtonFace), cl.X + cl.Width - 2, cl.Y, cl.X + cl.Width - 2, cl.Y + cl.Height); //right
-                       dc.DrawLine (ResPool.GetPen (ColorButtonHilight), cl.X + cl.Width - 1, cl.Y + 1 , cl.X + cl.Width - 1, cl.Y + cl.Height - 1);                           
+                       dc.DrawLine (ResPool.GetPen (ColorControlDark), cl.X, cl.Y, cl.X + cl.Width, cl.Y); //top 
+                       dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), cl.X + 1, cl.Y + 1, cl.X + cl.Width - 2, cl.Y + 1);
+                       dc.DrawLine (ResPool.GetPen (ColorControl), cl.X, cl.Y + cl.Height - 2, cl.X + cl.Width, cl.Y + cl.Height - 2); //down
+                       dc.DrawLine (ResPool.GetPen (ColorControlLight), cl.X, cl.Y + cl.Height - 1, cl.X + cl.Width, cl.Y + cl.Height - 1);
+                       dc.DrawLine (ResPool.GetPen (ColorControlDark), cl.X, cl.Y, cl.X, cl.Y + cl.Height); //left
+                       dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), cl.X + 1, cl.Y + 1, cl.X + 1, cl.Y + cl.Height - 2); 
+                       dc.DrawLine (ResPool.GetPen (ColorControl), cl.X + cl.Width - 2, cl.Y, cl.X + cl.Width - 2, cl.Y + cl.Height); //right
+                       dc.DrawLine (ResPool.GetPen (ColorControlLight), cl.X + cl.Width - 1, cl.Y + 1 , cl.X + cl.Width - 1, cl.Y + cl.Height - 1);                            
                }               
                
                // Sizing                               
@@ -853,7 +829,7 @@ namespace System.Windows.Forms
                                DrawComboBoxEditDecorations (dc, ctrl, cl);
                        }
                        else {                  
-                               dc.DrawRectangle (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorWindowFrame),
+                               dc.DrawRectangle (ResPool.GetPen (ColorWindowFrame),
                                        cl.X, cl.Y, cl.Width - 1, cl.Height - 1);
                        }                       
                }
@@ -866,25 +842,27 @@ namespace System.Windows.Forms
                        string_format.FormatFlags = StringFormatFlags.LineLimit;
                        
                        if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
-                               back_color = ThemeEngine.Current.ColorHilight;
-                               fore_color = ThemeEngine.Current.ColorHilightText;
+                               back_color = ColorHighlight;
+                               fore_color = ColorHighlightText;
                        }
                        else {
                                back_color = e.BackColor;
                                fore_color = e.ForeColor;
                        }                       
                                                        
-                       e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (back_color), e.Bounds);
+                       e.Graphics.FillRectangle (ResPool.GetSolidBrush (back_color), e.Bounds);
 
                        if (e.Index != -1) {
                                e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
-                                       ThemeEngine.Current.ResPool.GetSolidBrush (fore_color),
+                                       ResPool.GetSolidBrush (fore_color),
                                        text_draw, string_format);
                        }
                        
                        if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) {
-                               ThemeEngine.Current.CPDrawFocusRectangle (e.Graphics, e.Bounds, fore_color, back_color);
+                               CPDrawFocusRectangle (e.Graphics, e.Bounds, fore_color, back_color);
                        }
+
+                       string_format.Dispose ();
                }
                
                #endregion ComboBox
@@ -895,18 +873,18 @@ namespace System.Windows.Forms
                public override int DataGridMinimumColumnCheckBoxWidth { get { return 16;} }
                public override Color DataGridAlternatingBackColor { get { return ColorWindow;} }
                public override Color DataGridBackColor { get  { return  ColorWindow;} }                
-               public override Color DataGridBackgroundColor { get  { return  ColorAppWorkSpace;} }
-               public override Color DataGridCaptionBackColor { get  { return ColorActiveTitle;} }
-               public override Color DataGridCaptionForeColor { get  { return SystemColors.ActiveCaptionText;} }
-               public override Color DataGridGridLineColor { get { return SystemColors.Control;} }
-               public override Color DataGridHeaderBackColor { get  { return SystemColors.Control;} }
-               public override Color DataGridHeaderForeColor { get  { return SystemColors.ControlText;} }
-               public override Color DataGridLinkColor { get  { return SystemColors.HotTrack;} }
-               public override Color DataGridLinkHoverColor { get  { return SystemColors.HotTrack;} }
-               public override Color DataGridParentRowsBackColor { get  { return SystemColors.Control;} }
-               public override Color DataGridParentRowsForeColor { get  { return SystemColors.WindowText;} }
-               public override Color DataGridSelectionBackColor { get  { return ColorActiveTitle;} }
-               public override Color DataGridSelectionForeColor { get  { return ColorTitleText;} }
+               public override Color DataGridBackgroundColor { get  { return  ColorAppWorkspace;} }
+               public override Color DataGridCaptionBackColor { get  { return ColorActiveCaption;} }
+               public override Color DataGridCaptionForeColor { get  { return ColorActiveCaptionText;} }
+               public override Color DataGridGridLineColor { get { return ColorControl;} }
+               public override Color DataGridHeaderBackColor { get  { return ColorControl;} }
+               public override Color DataGridHeaderForeColor { get  { return ColorControlText;} }
+               public override Color DataGridLinkColor { get  { return ColorHotTrack;} }
+               public override Color DataGridLinkHoverColor { get  { return ColorHotTrack;} }
+               public override Color DataGridParentRowsBackColor { get  { return ColorControl;} }
+               public override Color DataGridParentRowsForeColor { get  { return ColorWindowText;} }
+               public override Color DataGridSelectionBackColor { get  { return ColorActiveCaption;} }
+               public override Color DataGridSelectionForeColor { get  { return ColorActiveCaptionText;} }
                
                public override void DataGridPaint (PaintEventArgs pe, DataGrid grid)
                {
@@ -923,8 +901,8 @@ namespace System.Windows.Forms
                        // Paint scrollBar corner
                        if (grid.vert_scrollbar.Visible && grid.horiz_scrollbar.Visible) {
 
-                               Rectangle corner = new Rectangle (grid.grid_drawing.client_area.X + grid.grid_drawing.client_area.Width - grid.horiz_scrollbar.Height,
-                                        grid.grid_drawing.client_area.Y + grid.grid_drawing.client_area.Height - grid.horiz_scrollbar.Height,
+                               Rectangle corner = new Rectangle (grid.ClientRectangle.X + grid.ClientRectangle.Width - grid.horiz_scrollbar.Height,
+                                        grid.ClientRectangle.Y + grid.ClientRectangle.Height - grid.horiz_scrollbar.Height,
                                         grid.horiz_scrollbar.Height, grid.horiz_scrollbar.Height);
 
                                if (pe.ClipRectangle.IntersectsWith (corner)) {
@@ -932,8 +910,6 @@ namespace System.Windows.Forms
                                                corner);
                                }
                        }
-                       
-                       ThemeEngine.Current.CPDrawBorderStyle (pe.Graphics, grid.ClientRectangle, grid.border_style);
                }
                
                public override void DataGridPaintCaption (Graphics g, Rectangle clip, DataGrid grid)
@@ -945,7 +921,7 @@ namespace System.Windows.Forms
                                modified_area);
 
                        g.DrawString (grid.CaptionText, grid.CaptionFont,
-                               ThemeEngine.Current.ResPool.GetSolidBrush (grid.CaptionForeColor),
+                               ResPool.GetSolidBrush (grid.CaptionForeColor),
                                grid.grid_drawing.caption_area);                
                }
 
@@ -1003,17 +979,12 @@ namespace System.Windows.Forms
 
                        current_clip.Dispose ();
                        g.ResetClip ();
-                       
-                       // This fills with background colour the unused part in the row headers
-                       if (rect_columnhdr.X + rect_columnhdr.Height < grid.grid_drawing.client_area.X + grid.grid_drawing.client_area.Width) {
                                
-                               Rectangle not_usedarea = columnshdrs_area_complete;                             
-                               not_usedarea.X = rect_columnhdr.X + rect_columnhdr.Width;
-                               not_usedarea.Width = grid.grid_drawing.client_area.X + grid.grid_drawing.client_area.Width - rect_columnhdr.X - rect_columnhdr.Height;
+                       Rectangle not_usedarea = columnshdrs_area_complete;                             
+                       not_usedarea.X = rect_columnhdr.X + rect_columnhdr.Width;
+                       not_usedarea.Width = grid.ClientRectangle.X + grid.ClientRectangle.Width - rect_columnhdr.X - rect_columnhdr.Height;            
+                       g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), not_usedarea);
                        
-                               g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor),
-                                       not_usedarea);
-                       }
                }
 
                public override void DataGridPaintRowsHeaders (Graphics g, Rectangle clip, DataGrid grid)
@@ -1021,9 +992,9 @@ namespace System.Windows.Forms
                        Rectangle rowshdrs_area_complete = grid.grid_drawing.rowshdrs_area;
                        rowshdrs_area_complete.Height = grid.grid_drawing.rowshdrs_maxheight;
                        Rectangle rect_row = new Rectangle ();
-                       rect_row.X = grid.grid_drawing.rowshdrs_area.X;
-                       int last_y = 0;
+                       rect_row.X = grid.grid_drawing.rowshdrs_area.X;                 
                        int rowcnt = grid.FirstVisibleRow + grid.VisibleRowCount;
+                       Rectangle not_usedarea = rowshdrs_area_complete;                        
 
                        if (rowcnt < grid.RowsCount) { // Paint one row more for partial rows
                                rowcnt++;
@@ -1037,25 +1008,14 @@ namespace System.Windows.Forms
                                rect_row.Y = grid.grid_drawing.rowshdrs_area.Y + ((row - grid.FirstVisibleRow) * grid.RowHeight);
 
                                if (clip.IntersectsWith (rect_row)) {
-                                       DataGridPaintRowHeader (g, rect_row, row, grid);
-                                       last_y = rect_row.Y;
+                                       DataGridPaintRowHeader (g, rect_row, row, grid);                                        
                                }
                        }
                        
                        g.ResetClip ();
-
-                       // This fills with background colour the unused part in the row headers
-                       if (last_y > 0 && rect_row.Y + rect_row.Height < grid.grid_drawing.cells_area.Y + grid.grid_drawing.cells_area.Height) {
-                               Rectangle not_usedarea = clip;
-                               not_usedarea.Intersect (rowshdrs_area_complete);
-                               
-                               not_usedarea.Y = rect_row.Y + rect_row.Height;
-                               not_usedarea.Height = rowshdrs_area_complete.Y + rowshdrs_area_complete.Height - rect_row.Height - rect_row.Y;
-                               g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor),
-                                       not_usedarea);
-                       }                       
-
-                       
+                       not_usedarea.Height = grid.grid_drawing.rowshdrs_maxheight - grid.grid_drawing.rowshdrs_area.Height;
+                       not_usedarea.Y = grid.grid_drawing.rowshdrs_area.Y + grid.grid_drawing.rowshdrs_area.Height;
+                       g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), not_usedarea);
                }
                
                public override void DataGridPaintRowHeaderArrow (Graphics g, Rectangle bounds, DataGrid grid) 
@@ -1080,33 +1040,33 @@ namespace System.Windows.Forms
                        arrow[1] = P2;
                        arrow[2] = P3;
                        
-                       g.FillPolygon (ThemeEngine.Current.ResPool.GetSolidBrush 
+                       g.FillPolygon (ResPool.GetSolidBrush 
                                (grid.CurrentTableStyle.CurrentHeaderForeColor), arrow, FillMode.Winding);
                }
 
                public override void DataGridPaintRowHeader (Graphics g, Rectangle bounds, int row, DataGrid grid)
                {
                        // Background
-                       g.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderBackColor),
+                       g.FillRectangle (ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderBackColor),
                                bounds);
                                
                        if (grid.FlatMode == false) {
                                
                                // Paint Borders
-                               g.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonHilight),
+                               g.DrawLine (ResPool.GetPen (ColorControlLight),
                                        bounds.X, bounds.Y, bounds.X + bounds.Width, bounds.Y);
        
-                               g.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonHilight),
+                               g.DrawLine (ResPool.GetPen (ColorControlLight),
                                        bounds.X, bounds.Y + 1, bounds.X, bounds.Y + bounds.Height - 1);
        
-                               g.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonShadow),
+                               g.DrawLine (ResPool.GetPen (ColorControlDark),
                                        bounds.X + bounds.Width - 1, bounds.Y + 1 , bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);
        
-                               g.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonShadow),
+                               g.DrawLine (ResPool.GetPen (ColorControlDark),
                                        bounds.X, bounds.Y + bounds.Height -1, bounds.X + bounds.Width, bounds.Y  + bounds.Height -1);
                        }
 
-                       if (grid.ShowEditRow && row == grid.RowsCount  && !(row == grid.CurrentCell.RowNumber && grid.is_changing == true)) {
+                       if (grid.ShowEditRow && grid.RowsCount > 0 && row == grid.RowsCount  && !(row == grid.CurrentCell.RowNumber && grid.is_changing == true)) {
                                
                                g.DrawString ("*", grid.grid_drawing.font_newrow, ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderForeColor),
                                        bounds);
@@ -1117,7 +1077,7 @@ namespace System.Windows.Forms
        
                                        if (grid.is_changing == true) {
                                                g.DrawString ("...", grid.Font,
-                                                       ThemeEngine.Current.ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderForeColor),
+                                                       ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderForeColor),
                                                        bounds);
        
                                        } else {
@@ -1137,7 +1097,7 @@ namespace System.Windows.Forms
 
                        int rowcnt = grid.FirstVisibleRow + grid.VisibleRowCount;
                        
-                       if (grid.ShowEditRow) {
+                       if (grid.ShowEditRow && grid.RowsCount > 0) {
                                rowcnt--;
                        }                       
 
@@ -1154,20 +1114,19 @@ namespace System.Windows.Forms
                                }
                        }
                        
-                       if (grid.ShowEditRow && grid.FirstVisibleRow + grid.VisibleRowCount == grid.RowsCount + 1) {
+                       if (grid.ShowEditRow && grid.RowsCount > 0 && grid.FirstVisibleRow + grid.VisibleRowCount == grid.RowsCount + 1) {
                                rect_row.Y = cells.Y + ((rowcnt - grid.FirstVisibleRow) * grid.RowHeight);
                                if (clip.IntersectsWith (rect_row)) {
                                        DataGridPaintRow (g, rowcnt, rect_row, true, grid);
                                }
-                       }
-                       
+                       }                       
+
                        not_usedarea.Height = cells.Y + cells.Height - rect_row.Y - rect_row.Height;
                        not_usedarea.Y = rect_row.Y + rect_row.Height;
                        not_usedarea.Width = rect_row.Width = cells.Width;
-                       not_usedarea.X = cells.X;                       
-
-                       g.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (grid.BackgroundColor),
-                               not_usedarea);                  
+                       not_usedarea.X = cells.X;
+                       
+                       g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), not_usedarea);
                }
                
                public override void DataGridPaintRow (Graphics g, int row, Rectangle row_rect, bool is_newrow, DataGrid grid)
@@ -1209,13 +1168,13 @@ namespace System.Windows.Forms
 
                                if (is_newrow) {
                                        grid.CurrentTableStyle.GridColumnStyles[column].PaintNewRow (g, rect_cell, 
-                                               ThemeEngine.Current.ResPool.GetSolidBrush (backcolor),
-                                               ThemeEngine.Current.ResPool.GetSolidBrush (forecolor));                                         
+                                               ResPool.GetSolidBrush (backcolor),
+                                               ResPool.GetSolidBrush (forecolor));                                             
                                        
                                } else {
                                        grid.CurrentTableStyle.GridColumnStyles[column].Paint (g, rect_cell, grid.ListManager, row,
-                                               ThemeEngine.Current.ResPool.GetSolidBrush (backcolor),
-                                               ThemeEngine.Current.ResPool.GetSolidBrush (forecolor),
+                                               ResPool.GetSolidBrush (backcolor),
+                                               ResPool.GetSolidBrush (forecolor),
                                                grid.RightToLeft == RightToLeft.Yes);
                                }
 
@@ -1229,7 +1188,7 @@ namespace System.Windows.Forms
                                not_usedarea.Width = row_rect.X + row_rect.Width - rect_cell.X - rect_cell.Width;
                                not_usedarea.Y = row_rect.Y;
                                not_usedarea.Height = row_rect.Height;
-                               g.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (grid.BackgroundColor),
+                               g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor),
                                        not_usedarea);
                        }
                }
@@ -1243,7 +1202,7 @@ namespace System.Windows.Forms
                        if (!dtp.ShowUpDown && clip_rectangle.IntersectsWith (dtp.ClientRectangle)) {
                                // draw the outer border
                                Rectangle button_bounds = dtp.ClientRectangle;
-                               this.CPDrawBorder3D (dc, button_bounds, Border3DStyle.Sunken, Border3DSide.All, dtp.BackColor);
+                               this.CPDrawBorder3D (dc, button_bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, dtp.BackColor);
                                
                                // deflate by the border width
                                if (clip_rectangle.IntersectsWith (dtp.drop_down_arrow_rect)) {
@@ -1259,11 +1218,11 @@ namespace System.Windows.Forms
                        // render the date part
                        if (clip_rectangle.IntersectsWith (dtp.date_area_rect)) {
                                // fill the background
-                               dc.FillRectangle (ResPool.GetSolidBrush (ThemeEngine.Current.ColorWindow), dtp.date_area_rect);
+                               dc.FillRectangle (ResPool.GetSolidBrush (ColorWindow), dtp.date_area_rect);
                                
                                // fill the currently highlighted area
                                if (dtp.hilight_date_area != Rectangle.Empty) {
-                                       dc.FillRectangle (ResPool.GetSolidBrush (ThemeEngine.Current.ColorHilight), dtp.hilight_date_area);
+                                       dc.FillRectangle (ResPool.GetSolidBrush (ColorHighlight), dtp.hilight_date_area);
                                }
                                
                                // draw the text part
@@ -1272,6 +1231,7 @@ namespace System.Windows.Forms
                                text_format.LineAlignment = StringAlignment.Center;
                                text_format.Alignment = StringAlignment.Near;                                   
                                dc.DrawString (dtp.Text, dtp.Font, ResPool.GetSolidBrush (dtp.ForeColor), Rectangle.Inflate(dtp.date_area_rect, -1, -1), text_format);
+                               text_format.Dispose ();
                        }
                }
                
@@ -1333,7 +1293,7 @@ namespace System.Windows.Forms
                                CPDrawStringDisabled (dc, box.Text, box.Font, box.ForeColor, 
                                        new RectangleF (10, 0, width,  box.Font.Height), text_format);
                        }
-                               
+                       text_format.Dispose (); 
                }
 
                public override Size GroupBoxDefaultSize {
@@ -1356,8 +1316,6 @@ namespace System.Windows.Forms
                public  override void DrawLabel (Graphics dc, Rectangle clip_rectangle, Label label) 
                {               
                        dc.FillRectangle (ResPool.GetSolidBrush (label.BackColor), clip_rectangle);
-                       
-                       CPDrawBorderStyle (dc, label.ClientRectangle, label.BorderStyle);               
 
                        if (label.Enabled) {
                                dc.DrawString (label.Text, label.Font, ResPool.GetSolidBrush (label.ForeColor), clip_rectangle, label.string_format);
@@ -1380,7 +1338,6 @@ namespace System.Windows.Forms
                        Color color;
 
                        dc.FillRectangle (ResPool.GetSolidBrush (label.BackColor), clip_rectangle);
-                       CPDrawBorderStyle (dc, label.ClientRectangle, label.BorderStyle);                                               
 
                        for (int i = 0; i < label.num_pieces; i++) {
                                
@@ -1396,7 +1353,7 @@ namespace System.Windows.Forms
                                else
                                        dc.DrawString (label.pieces[i].text, label.GetPieceFont (label.pieces[i]), ResPool.GetSolidBrush (color),
                                                label.pieces[i].rect.X, label.pieces[i].rect.Y);
-                                               
+
                                if (label.pieces[i].focused) {                                  
                                        CPDrawFocusRectangle (dc, label.pieces[i].rect, label.ForeColor, label.BackColor);
                                }
@@ -1407,31 +1364,6 @@ namespace System.Windows.Forms
                #region ListBox
                
                // Drawing              
-               public override void DrawListBoxDecorations (Graphics dc, ListBox ctrl)
-               {                       
-                       Rectangle cl = ctrl.LBoxInfo.client_rect;
-                       
-                       // Draw decorations
-                       switch (ctrl.BorderStyle) {
-                       case BorderStyle.Fixed3D: {                             
-                               dc.DrawLine (ResPool.GetPen (ColorButtonShadow), cl.X, cl.Y, cl.X + cl.Width, cl.Y); //top 
-                               dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), cl.X + 1, cl.Y + 1, cl.X + cl.Width - 2, cl.Y + 1);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonFace), cl.X, cl.Y + cl.Height - 2, cl.X + cl.Width, cl.Y + cl.Height - 2); //down
-                               dc.DrawLine (ResPool.GetPen (ColorButtonHilight), cl.X, cl.Y + cl.Height - 1, cl.X + cl.Width, cl.Y + cl.Height - 1);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonShadow), cl.X, cl.Y, cl.X, cl.Y + cl.Height); //left
-                               dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), cl.X + 1, cl.Y + 1, cl.X + 1, cl.Y + cl.Height - 2); 
-                               dc.DrawLine (ResPool.GetPen (ColorButtonFace), cl.X + cl.Width - 2, cl.Y, cl.X + cl.Width - 2, cl.Y + cl.Height); //right
-                               dc.DrawLine (ResPool.GetPen (ColorButtonHilight), cl.X + cl.Width - 1, cl.Y + 1 , cl.X + cl.Width - 1, cl.Y + cl.Height - 1);           
-                               break;
-                       }
-                       case BorderStyle.FixedSingle:
-                               dc.DrawRectangle (ResPool.GetPen (ColorWindowFrame), cl.X, cl.Y, cl.Width - 1, cl.Height - 1);
-                               break;
-                       case BorderStyle.None:
-                       default:
-                               break;
-                       }               
-               }               
                
                private int DrawListBoxDecorationSize (BorderStyle border_style)
                {
@@ -1449,34 +1381,29 @@ namespace System.Windows.Forms
                }                       
                
                // Sizing                               
-               public override int DrawListBoxDecorationTop  (BorderStyle border_style) { return DrawListBoxDecorationSize (border_style);}
-               public override int DrawListBoxDecorationBottom  (BorderStyle border_style) { return DrawListBoxDecorationSize (border_style);}
-               public override int DrawListBoxDecorationRight (BorderStyle border_style) { return DrawListBoxDecorationSize (border_style);}
-               public override int DrawListBoxDecorationLeft (BorderStyle border_style) { return DrawListBoxDecorationSize (border_style);}
-               
                public override void DrawListBoxItem (ListBox ctrl, DrawItemEventArgs e)
                {
                        Color back_color, fore_color;
                        StringFormat string_format = ctrl.GetFormatString ();
                        
                        if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
-                               back_color = ThemeEngine.Current.ColorHilight;
-                               fore_color = ThemeEngine.Current.ColorHilightText;
+                               back_color = ColorHighlight;
+                               fore_color = ColorHighlightText;
                        }
                        else {
                                back_color = e.BackColor;
                                fore_color = e.ForeColor;
                        }
                        
-                       e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush
+                       e.Graphics.FillRectangle (ResPool.GetSolidBrush
                                (back_color), e.Bounds);
 
                        e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
-                               ThemeEngine.Current.ResPool.GetSolidBrush (fore_color),
+                               ResPool.GetSolidBrush (fore_color),
                                e.Bounds.X, e.Bounds.Y, string_format);
                                        
                        if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) {
-                               ThemeEngine.Current.CPDrawFocusRectangle (e.Graphics, e.Bounds,
+                               CPDrawFocusRectangle (e.Graphics, e.Bounds,
                                        fore_color, back_color);
                        }
                }
@@ -1485,31 +1412,16 @@ namespace System.Windows.Forms
 
                #region ListView
                // Drawing
-               public override void DrawListView (Graphics dc, Rectangle clip, ListView control)
+               public override void DrawListViewItems (Graphics dc, Rectangle clip, ListView control)
                {
-                       bool details = (control.View == View.Details);
-                       Rectangle client_area_nohdrs;                   
-                       DrawListViewHeader (dc, clip, control);
-                       
-                       if (details && control.Columns.Count > 0) {
-                               client_area_nohdrs = control.client_area;
-                               client_area_nohdrs.Y += control.Columns[0].Ht;
-                               client_area_nohdrs.Height -= control.Columns[0].Ht;
-                               dc.SetClip (client_area_nohdrs);                                
-                       } else
-                               dc.SetClip (control.client_area);
-                       
+                       bool details = control.View == View.Details;
+
                        dc.FillRectangle (ResPool.GetSolidBrush (control.BackColor), clip);                                             
-                                               
-                       // In case of details view draw the items only if
-                       // columns are non-zero                 
-                       if (!details || control.Columns.Count > 0) {
-                               int first = control.FirstVisibleIndex;  
-                               
-                               for (int i = first; i <= control.LastItemIndex; i ++) {                                 
-                                       //if (clip.IntersectsWith (control.Items[i].entire_rect_real))
-                                               DrawListViewItem (dc, control, control.Items[i]);
-                               }                               
+                       int first = control.FirstVisibleIndex;  
+
+                       for (int i = first; i <= control.LastVisibleIndex; i ++) {                                      
+                               if (clip.IntersectsWith (control.Items[i].GetBounds (ItemBoundsPortion.Entire)))
+                                       DrawListViewItem (dc, control, control.Items [i]);
                        }       
                        
                        // draw the gridlines
@@ -1519,33 +1431,43 @@ namespace System.Windows.Forms
 
                                // draw vertical gridlines
                                foreach (ColumnHeader col in control.Columns)
-                                       dc.DrawLine (this.ResPool.GetPen (this.ColorButtonFace),
+                                       dc.DrawLine (this.ResPool.GetPen (this.ColorControl),
                                                     col.Rect.Right, top,
                                                     col.Rect.Right, control.TotalHeight);
                                // draw horizontal gridlines
                                ListViewItem last_item = null;
                                foreach (ListViewItem item in control.Items) {
-                                       dc.DrawLine (this.ResPool.GetPen (this.ColorButtonFace),
-                                                    item.entire_rect_real.Left, item.entire_rect_real.Top,
-                                                    control.TotalWidth, item.entire_rect_real.Top);
+                                       dc.DrawLine (this.ResPool.GetPen (this.ColorControl),
+                                                    item.GetBounds (ItemBoundsPortion.Entire).Left, item.GetBounds (ItemBoundsPortion.Entire).Top,
+                                                    control.TotalWidth, item.GetBounds (ItemBoundsPortion.Entire).Top);
                                        last_item = item;
                                }
 
                                // draw a line after at the bottom of the last item
                                if (last_item != null) {
-                                       dc.DrawLine (this.ResPool.GetPen (this.ColorButtonFace),
-                                                    last_item.entire_rect_real.Left,
-                                                    last_item.entire_rect_real.Bottom,
+                                       dc.DrawLine (this.ResPool.GetPen (this.ColorControl),
+                                                    last_item.GetBounds (ItemBoundsPortion.Entire).Left,
+                                                    last_item.GetBounds (ItemBoundsPortion.Entire).Bottom,
                                                     control.TotalWidth,
-                                                    last_item.entire_rect_real.Bottom);
-                               }                       
-                               
+                                                    last_item.GetBounds (ItemBoundsPortion.Entire).Bottom);
+                               }
                        }                       
                        
                        dc.ResetClip ();
+                       
+                       // Draw corner between the two scrollbars
+                       if (control.h_scroll.Visible == true && control.h_scroll.Visible == true) {
+                               Rectangle rect = new Rectangle ();
+                               rect.X = control.h_scroll.Location.X + control.h_scroll.Width;
+                               rect.Width = control.v_scroll.Width;
+                               rect.Y = control.v_scroll.Location.Y + control.v_scroll.Height;
+                               rect.Height = control.h_scroll.Height;
+                               dc.FillRectangle (ResPool.GetSolidBrush (ColorControl), rect);
+                       }
+
                }
                
-               private void DrawListViewHeader (Graphics dc, Rectangle clip, ListView control)
+               public override void DrawListViewHeader (Graphics dc, Rectangle clip, ListView control)
                {       
                        bool details = (control.View == View.Details);
                                
@@ -1554,50 +1476,61 @@ namespace System.Windows.Forms
                                dc.FillRectangle (ResPool.GetSolidBrush (control.BackColor),
                                                  0, 0, control.TotalWidth, control.Font.Height + 5);
                                if (control.Columns.Count > 0) {
-                                       if (control.HeaderStyle == ColumnHeaderStyle.Clickable) {
-                                               foreach (ColumnHeader col in control.Columns) {
-                                                       Rectangle rect = col.Rect;
-                                                       rect.X -= control.h_marker;
-                                                       this.CPDrawButton (dc, rect,
-                                                                          (col.Pressed ?
-                                                                           ButtonState.Pushed :
-                                                                           ButtonState.Normal));
-                                                       dc.DrawString (col.Text, ThemeEngine.Current.DefaultFont,
-                                                                      ResPool.GetSolidBrush
-                                                                      (this.ColorButtonText),
-                                                                      //col.Rect,
-                                                                       rect.X + 3,
-                                                                       rect.Y + rect.Height/2 + 1,
-                                                                       col.Format);
-                                               }
-                                       }
-                                       // Non-clickable columns
-                                       else {
-                                               foreach (ColumnHeader col in control.Columns) {
-                                                       Rectangle rect = col.Rect;
-                                                       rect.X -= control.h_marker;
-                                                       this.CPDrawButton (dc, rect, ButtonState.Flat);
-                                                       dc.DrawString (col.Text, ThemeEngine.Current.DefaultFont,
-                                                                      ResPool.GetSolidBrush
-                                                                      (this.ColorButtonText),
-                                                                       //col.Rect,
-                                                                       rect.X + 3,
-                                                                       rect.Y + rect.Height/2 + 1,
-                                                                       col.Format);
-                                               }
+                                       foreach (ColumnHeader col in control.Columns) {
+                                               Rectangle rect = col.Rect;
+                                               rect.X -= control.h_marker;
+                                               ButtonState state;
+                                               if (control.HeaderStyle == ColumnHeaderStyle.Clickable)
+                                                       state = col.Pressed ? ButtonState.Pushed : ButtonState.Normal;
+                                               else
+                                                       state = ButtonState.Flat;
+                                               this.CPDrawButton (dc, rect, state);
+                                               rect.X += 3;
+                                               rect.Width -= 8;
+                                               if (rect.Width <= 0)
+                                                       continue;
+                                               dc.DrawString (col.Text, DefaultFont,
+                                                              ResPool.GetSolidBrush (ColorControlText),
+                                                              rect, col.Format);
                                        }
                                }
                        }
                }
 
+               public override void DrawListViewHeaderDragDetails (Graphics dc, ListView view, ColumnHeader col, int target_x)
+               {
+                       Rectangle rect = col.Rect;
+                       rect.X -= view.h_marker;
+                       Color color = Color.FromArgb (0x7f, ColorControlDark.R, ColorControlDark.G, ColorControlDark.B);
+                       dc.FillRectangle (ResPool.GetSolidBrush (color), rect);
+                       rect.X += 3;
+                       rect.Width -= 8;
+                       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);
+                       Pen pen = new Pen (ColorHighlight, 2);
+                       dc.DrawLine (pen, target_x, 0, target_x, col.Rect.Height);
+               }
+
                // draws the ListViewItem of the given index
-               private void DrawListViewItem (Graphics dc, ListView control, ListViewItem item)
+               protected virtual void DrawListViewItem (Graphics dc, ListView control, ListViewItem item)
                {                               
-                       Rectangle rect_checkrect = item.checkbox_rect_real;
+                       int col_offset;
+                       if (control.View == View.Details && control.Columns.Count > 0)
+                               col_offset = control.Columns [0].Rect.X;
+                       else
+                               col_offset = 0;
+                       
+                       Rectangle rect_checkrect = item.CheckRectReal;
+                       rect_checkrect.X += col_offset;
                        Rectangle rect_iconrect = item.GetBounds (ItemBoundsPortion.Icon);
+                       rect_iconrect.X += col_offset;
                        Rectangle full_rect = item.GetBounds (ItemBoundsPortion.Entire);
-                       Rectangle text_rect = item.GetBounds (ItemBoundsPortion.Label);                                                                 
-                       
+                       full_rect.X += col_offset;
+                       Rectangle text_rect = item.GetBounds (ItemBoundsPortion.Label);                 
+                       text_rect.X += col_offset;
+
                        if (control.CheckBoxes) {
                                if (control.StateImageList == null) {
                                        // Make sure we've got at least a line width of 1
@@ -1663,7 +1596,10 @@ namespace System.Windows.Forms
                        // draw the item text                   
                        // format for the item text
                        StringFormat format = new StringFormat ();
-                       format.LineAlignment = StringAlignment.Center;
+                       if (control.View == View.SmallIcon)
+                               format.LineAlignment = StringAlignment.Near;
+                       else
+                               format.LineAlignment = StringAlignment.Center;
                        if (control.View == View.LargeIcon)
                                format.Alignment = StringAlignment.Center;
                        else
@@ -1676,16 +1612,16 @@ namespace System.Windows.Forms
                                if (control.View == View.Details) {
                                        if (control.FullRowSelect) {
                                                // fill the entire rect excluding the checkbox                                          
-                                               full_rect.Location = item.LabelRect.Location;
+                                               full_rect.Location = item.GetBounds (ItemBoundsPortion.Label).Location;
                                                dc.FillRectangle (this.ResPool.GetSolidBrush
-                                                                 (this.ColorHilight), full_rect);
+                                                                 (this.ColorHighlight), full_rect);
                                        }
                                        else {
                                                Size text_size = Size.Ceiling (dc.MeasureString (item.Text,
                                                                                                item.Font));
                                                text_rect.Width = text_size.Width;
                                                dc.FillRectangle (this.ResPool.GetSolidBrush
-                                                                 (this.ColorHilight), text_rect);
+                                                                 (this.ColorHighlight), text_rect);
                                        }
                                }
                                else {
@@ -1694,7 +1630,7 @@ namespace System.Windows.Forms
                                          Point loc = text_rect.Location;
                                          loc.X += (text_rect.Width - text_size.Width) / 2;
                                          text_rect.Width = text_size.Width;*/
-                                       dc.FillRectangle (this.ResPool.GetSolidBrush (this.ColorHilight),
+                                       dc.FillRectangle (this.ResPool.GetSolidBrush (this.ColorHighlight),
                                                          text_rect);
                                }
                        }
@@ -1704,7 +1640,7 @@ namespace System.Windows.Forms
                        if (item.Text != null && item.Text.Length > 0) {
                                if (item.Selected)
                                        dc.DrawString (item.Text, item.Font, this.ResPool.GetSolidBrush
-                                                      (this.ColorHilightText), text_rect, format);
+                                                      (this.ColorHighlightText), text_rect, format);
                                else
                                        dc.DrawString (item.Text, item.Font, this.ResPool.GetSolidBrush
                                                       (item.ForeColor), text_rect, format);
@@ -1723,14 +1659,14 @@ namespace System.Windows.Forms
 
                                        // set the format for subitems
                                        format.FormatFlags = StringFormatFlags.NoWrap;
-                                       format.Alignment = StringAlignment.Near;
 
                                        // 0th subitem is the item already drawn
                                        for (int index = 1; index < count; index++) {
                                                subItem = subItems [index];
                                                col = control.Columns [index];
-                                               sub_item_rect.X = col.Rect.Left;
-                                               sub_item_rect.Width = col.Wd;
+                                               format.Alignment = col.Format.Alignment;
+                                               sub_item_rect.X = col.Rect.Left + 3;
+                                               sub_item_rect.Width = col.Wd - 6;
                                                sub_item_rect.X -= control.h_marker;
 
                                                SolidBrush sub_item_back_br = null;
@@ -1758,7 +1694,7 @@ namespace System.Windows.Forms
                                                        if (subItem.Text != null && subItem.Text.Length > 0)
                                                                dc.DrawString (subItem.Text, sub_item_font,
                                                                               this.ResPool.GetSolidBrush
-                                                                              (this.ColorHilightText),
+                                                                              (this.ColorHighlightText),
                                                                               sub_item_rect, format);
                                                }
                                                else {
@@ -1772,6 +1708,15 @@ namespace System.Windows.Forms
                                        }
                                }
                        }
+                       
+                       if (item.Focused) {                             
+                               if (item.Selected)
+                                       CPDrawFocusRectangle (dc, text_rect, ColorHighlightText, ColorHighlight);
+                               else
+                                       CPDrawFocusRectangle (dc, text_rect, control.ForeColor, control.BackColor);
+                       }
+
+                       format.Dispose ();
                }
 
                // Sizing
@@ -1805,118 +1750,109 @@ namespace System.Windows.Forms
                #endregion      // ListView
                
                #region Menus
-               public override void CalcItemSize (Graphics dc, MenuAPI.MENUITEM item, int y, int x, bool menuBar)
+               public override void CalcItemSize (Graphics dc, MenuItem item, int y, int x, bool menuBar)
                {
-                       item.rect.Y = y;
-                       item.rect.X = x;
+                       item.X = x;
+                       item.Y = y;
 
-                       if (item.item.Visible == false)
+                       if (item.Visible == false) {
+                               item.Width = 0;
+                               item.Height = 0;
                                return;
+                       }
 
-                       if (item.item.Separator == true) {
-                               item.rect.Height = SEPARATOR_HEIGHT / 2;
-                               item.rect.Width = -1;
+                       if (item.Separator == true) {
+                               item.Height = SEPARATOR_HEIGHT / 2;
+                               item.Width = -1;
                                return;
                        }
                        
-                       if (item.item.MeasureEventDefined) {
-                               MeasureItemEventArgs mi = new MeasureItemEventArgs (dc, item.pos);
-                               item.item.PerformMeasureItem (mi);
-                               item.rect.Height = mi.ItemHeight;
-                               item.rect.Width = mi.ItemWidth;
+                       if (item.MeasureEventDefined) {
+                               MeasureItemEventArgs mi = new MeasureItemEventArgs (dc, item.Index);
+                               item.PerformMeasureItem (mi);
+                               item.Height = mi.ItemHeight;
+                               item.Width = mi.ItemWidth;
                                return;
                        } else {                
-
                                SizeF size;
-                               size =  dc.MeasureString (item.item.Text, ThemeEngine.Current.MenuFont);
-                               item.rect.Width = (int) size.Width;
-                               item.rect.Height = (int) size.Height;
+                               size =  dc.MeasureString (item.Text, MenuFont);
+                               item.Width = (int) size.Width;
+                               item.Height = (int) size.Height;
        
                                if (!menuBar) {
-       
-                                       if (item.item.Shortcut != Shortcut.None && item.item.ShowShortcut) {
-                                               item.item.XTab = ThemeEngine.Current.MenuCheckSize.Width + MENU_TAB_SPACE + (int) size.Width;
-                                               size =  dc.MeasureString (" " + item.item.GetShortCutText (), ThemeEngine.Current.MenuFont);
-                                               item.rect.Width += MENU_TAB_SPACE + (int) size.Width;
+                                       if (item.Shortcut != Shortcut.None && item.ShowShortcut) {
+                                               item.XTab = MenuCheckSize.Width + MENU_TAB_SPACE + (int) size.Width;
+                                               size =  dc.MeasureString (" " + item.GetShortCutText (), MenuFont);
+                                               item.Width += MENU_TAB_SPACE + (int) size.Width;
                                        }
        
-                                       item.rect.Width += 4 + (ThemeEngine.Current.MenuCheckSize.Width * 2);
-                               }
-                               else {
-                                       item.rect.Width += MENU_BAR_ITEMS_SPACE;
-                                       x += item.rect.Width;
+                                       item.Width += 4 + (MenuCheckSize.Width * 2);
+                               } else {
+                                       item.Width += MENU_BAR_ITEMS_SPACE;
+                                       x += item.Width;
                                }
        
-                               if (item.rect.Height < ThemeEngine.Current.MenuHeight)
-                                       item.rect.Height = ThemeEngine.Current.MenuHeight;
-                               }
+                               if (item.Height < MenuHeight)
+                                       item.Height = MenuHeight;
+                       }
                }
                
                // Updates the menu rect and returns the height
-               public override int CalcMenuBarSize (Graphics dc, IntPtr hMenu, int width)
+               public override int CalcMenuBarSize (Graphics dc, Menu menu, int width)
                {
                        int x = 0;
-                       int i = 0;
                        int y = 0;
-                       MenuAPI.MENU menu = MenuAPI.GetMenuFromID (hMenu);
                        menu.Height = 0;
-                       MenuAPI.MENUITEM item;
 
-                       while (i < menu.items.Count) {
+                       foreach (MenuItem item in menu.MenuItems) {
 
-                               item = (MenuAPI.MENUITEM) menu.items[i];
                                CalcItemSize (dc, item, y, x, true);
-                               i = i + 1;
 
-                               if (x + item.rect.Width > width) {
-                                       item.rect.X = 0;
-                                       y += item.rect.Height;
-                                       item.rect.Y = y;
+                               if (x + item.Width > width) {
+                                       item.X = 0;
+                                       y += item.Height;
+                                       item.Y = y;
                                        x = 0;
                                }
 
-                               x += item.rect.Width;
-                               item.item.MenuBar = true;                               
+                               x += item.Width;
+                               item.MenuBar = true;                            
 
-                               if (y + item.rect.Height > menu.Height)
-                                       menu.Height = item.rect.Height + y;
+                               if (y + item.Height > menu.Height)
+                                       menu.Height = item.Height + y;
                        }
 
                        menu.Width = width;                                             
                        return menu.Height;
                }
 
-               
-               public override void CalcPopupMenuSize (Graphics dc, IntPtr hMenu)
+               public override void CalcPopupMenuSize (Graphics dc, Menu menu)
                {
                        int x = 3;
                        int start = 0;
                        int i, n, y, max;
 
-                       MenuAPI.MENU menu = MenuAPI.GetMenuFromID (hMenu);
                        menu.Height = 0;
 
-                       while (start < menu.items.Count) {
+                       while (start < menu.MenuItems.Count) {
                                y = 2;
                                max = 0;
-                               for (i = start; i < menu.items.Count; i++) {
-                                       MenuAPI.MENUITEM item = (MenuAPI.MENUITEM) menu.items[i];
+                               for (i = start; i < menu.MenuItems.Count; i++) {
+                                       MenuItem item = menu.MenuItems [i];
 
-                                       if ((i != start) && (item.item.Break || item.item.BarBreak))
+                                       if ((i != start) && (item.Break || item.BarBreak))
                                                break;
 
                                        CalcItemSize (dc, item, y, x, false);
-                                       y += item.rect.Height;
+                                       y += item.Height;
 
-                                       if (item.rect.Width > max)
-                                               max = item.rect.Width;
+                                       if (item.Width > max)
+                                               max = item.Width;
                                }
 
-                               // Reemplace the -1 by the menu width (separators)
-                               for (n = start; n < i; n++, start++) {
-                                       MenuAPI.MENUITEM item = (MenuAPI.MENUITEM) menu.items[n];
-                                       item.rect.Width = max;
-                               }
+                               // Replace the -1 by the menu width (separators)
+                               for (n = start; n < i; n++, start++)
+                                       menu.MenuItems [n].Width = max;
 
                                if (y > menu.Height)
                                        menu.Height = y;
@@ -1935,26 +1871,26 @@ namespace System.Windows.Forms
                }
                
                // Draws a menu bar in a window
-               public override void DrawMenuBar (Graphics dc, IntPtr hMenu, Rectangle rect)
+               public override void DrawMenuBar (Graphics dc, Menu menu, Rectangle rect)
                {
-                       MenuAPI.MENU menu = MenuAPI.GetMenuFromID (hMenu);                      
-                       Rectangle item_rect;
-
                        if (menu.Height == 0)
-                               ThemeEngine.Current.CalcMenuBarSize (dc, hMenu, rect.Width);
+                               CalcMenuBarSize (dc, menu, rect.Width);
                                
+                       bool keynav = (menu as MainMenu).tracker.Navigating;
+                       HotkeyPrefix hp = always_draw_hotkeys || keynav ? HotkeyPrefix.Show : HotkeyPrefix.Hide;
+                       string_format_menu_menubar_text.HotkeyPrefix = hp;
+                       string_format_menu_text.HotkeyPrefix = hp;
+
                        rect.Height = menu.Height;
-                       dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (menu.Wnd.BackColor), rect);
+                       dc.FillRectangle (ResPool.GetSolidBrush(ColorMenu), rect);
                                                
-                       for (int i = 0; i < menu.items.Count; i++) {
-                               MenuAPI.MENUITEM it = (MenuAPI.MENUITEM) menu.items[i];
-                               item_rect = it.rect;
+                       for (int i = 0; i < menu.MenuItems.Count; i++) {
+                               MenuItem item = menu.MenuItems [i];
+                               Rectangle item_rect = item.bounds;
                                item_rect.X += rect.X;
                                item_rect.Y += rect.Y;
-                               it.item.MenuHeight = menu.Height;
-                               it.item.PerformDrawItem (new DrawItemEventArgs (dc, ThemeEngine.Current.MenuFont,
-                                               item_rect, i, it.item.Status));                 
-                               
+                               item.MenuHeight = menu.Height;
+                               item.PerformDrawItem (new DrawItemEventArgs (dc, MenuFont, item_rect, i, item.Status));                 
                        }                               
                }               
                
@@ -1966,25 +1902,23 @@ namespace System.Windows.Forms
                        if (item.Visible == false)
                                return;
 
-                       if (item.MenuBar) {
+                       if (item.MenuBar)
                                string_format = string_format_menu_menubar_text;
-                       }
-                       else {
+                       else
                                string_format = string_format_menu_text;
-                       }               
 
                        if (item.Separator == true) {
-                               e.Graphics.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonShadow),
+                               e.Graphics.DrawLine (ResPool.GetPen (ColorControlDark),
                                        e.Bounds.X, e.Bounds.Y, e.Bounds.X + e.Bounds.Width, e.Bounds.Y);
 
-                               e.Graphics.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonHilight),
+                               e.Graphics.DrawLine (ResPool.GetPen (ColorControlLight),
                                        e.Bounds.X, e.Bounds.Y + 1, e.Bounds.X + e.Bounds.Width, e.Bounds.Y + 1);
 
                                return;
                        }
 
                        if (!item.MenuBar)
-                               rect_text.X += ThemeEngine.Current.MenuCheckSize.Width;
+                               rect_text.X += MenuCheckSize.Width;
 
                        if (item.BarBreak) { /* Draw vertical break bar*/
                                Rectangle rect = e.Bounds;
@@ -1992,10 +1926,10 @@ namespace System.Windows.Forms
                                rect.Width = 3;
                                rect.Height = item.MenuHeight - 6;
 
-                               e.Graphics.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonShadow),
+                               e.Graphics.DrawLine (ResPool.GetPen (ColorControlDark),
                                        rect.X, rect.Y , rect.X, rect.Y + rect.Height);
 
-                               e.Graphics.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonHilight),
+                               e.Graphics.DrawLine (ResPool.GetPen (ColorControlLight),
                                        rect.X + 1, rect.Y , rect.X +1, rect.Y + rect.Height);
                        }                       
                        
@@ -2003,23 +1937,22 @@ namespace System.Windows.Forms
                        Color color_back;
                        
                        if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
-                               color_text = ThemeEngine.Current.ColorHilightText;
-                               color_back = ThemeEngine.Current.ColorHilight;
-                       }
-                       else {
-                               color_text = ThemeEngine.Current.ColorMenuText;
-                               color_back = ThemeEngine.Current.ColorMenu;
+                               color_text = ColorHighlightText;
+                               color_back = ColorHighlight;
+                       } else {
+                               color_text = ColorMenuText;
+                               color_back = ColorMenu;
                        }
 
                        /* Draw background */
                        Rectangle rect_back = e.Bounds;
                        rect_back.X++;
                        rect_back.Width -=2;
-                       e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (color_back), rect_back);
+                       e.Graphics.FillRectangle (ResPool.GetSolidBrush (color_back), rect_back);
                        
                        if (item.Enabled) {
                                e.Graphics.DrawString (item.Text, e.Font,
-                                       ThemeEngine.Current.ResPool.GetSolidBrush (color_text),
+                                       ResPool.GetSolidBrush (color_text),
                                        rect_text, string_format);
 
                                if (!item.MenuBar && item.Shortcut != Shortcut.None && item.ShowShortcut) {
@@ -2028,20 +1961,19 @@ namespace System.Windows.Forms
                                        rect.X = item.XTab;
                                        rect.Width -= item.XTab;
 
-                                       e.Graphics.DrawString (str, e.Font, ThemeEngine.Current.ResPool.GetSolidBrush (color_text),
+                                       e.Graphics.DrawString (str, e.Font, ResPool.GetSolidBrush (color_text),
                                                rect, string_format_menu_shortcut);
                                }
-                       }
-                       else {
+                       } else {
                                ControlPaint.DrawStringDisabled (e.Graphics, item.Text, e.Font, 
                                        Color.Black, rect_text, string_format);
                        }
 
                        /* Draw arrow */
-                       if (item.MenuBar == false && item.IsPopup) {
+                       if (item.MenuBar == false && item.IsPopup || item.MdiList) {
 
-                               int cx = ThemeEngine.Current.MenuCheckSize.Width;
-                               int cy = ThemeEngine.Current.MenuCheckSize.Height;
+                               int cx = MenuCheckSize.Width;
+                               int cy = MenuCheckSize.Height;
                                Bitmap  bmp = new Bitmap (cx, cy);
                                Graphics gr = Graphics.FromImage (bmp);
                                Rectangle rect_arrow = new Rectangle (0, 0, cx, cy);
@@ -2064,8 +1996,8 @@ namespace System.Windows.Forms
                        if (item.MenuBar == false && item.Checked) {
 
                                Rectangle area = e.Bounds;
-                               int cx = ThemeEngine.Current.MenuCheckSize.Width;
-                               int cy = ThemeEngine.Current.MenuCheckSize.Height;
+                               int cx = MenuCheckSize.Width;
+                               int cy = MenuCheckSize.Height;
                                Bitmap  bmp = new Bitmap (cx, cy);
                                Graphics gr = Graphics.FromImage (bmp);
                                Rectangle rect_arrow = new Rectangle (0, 0, cx, cy);
@@ -2083,38 +2015,37 @@ namespace System.Windows.Forms
                        }                       
                }               
                        
-               public override void DrawPopupMenu (Graphics dc, IntPtr hMenu, Rectangle cliparea, Rectangle rect)
+               public override void DrawPopupMenu (Graphics dc, Menu menu, Rectangle cliparea, Rectangle rect)
                {
-                       MenuAPI.MENU menu = MenuAPI.GetMenuFromID (hMenu);
 
-                       dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush
-                               (ThemeEngine.Current.ColorMenu), cliparea);
+                       dc.FillRectangle (ResPool.GetSolidBrush
+                               (ColorMenu), cliparea);
 
                        /* Draw menu borders */
-                       dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorHilightText),
+                       dc.DrawLine (ResPool.GetPen (ColorHighlightText),
                                rect.X, rect.Y, rect.X + rect.Width, rect.Y);
 
-                       dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorHilightText),
+                       dc.DrawLine (ResPool.GetPen (ColorHighlightText),
                                rect.X, rect.Y, rect.X, rect.Y + rect.Height);
 
-                       dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonShadow),
+                       dc.DrawLine (ResPool.GetPen (ColorControlDark),
                                rect.X + rect.Width - 1 , rect.Y , rect.X + rect.Width - 1, rect.Y + rect.Height);
 
-                       dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonDkShadow),
+                       dc.DrawLine (ResPool.GetPen (ColorControlDarkDark),
                                rect.X + rect.Width, rect.Y , rect.X + rect.Width, rect.Y + rect.Height);
 
-                       dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonShadow),
+                       dc.DrawLine (ResPool.GetPen (ColorControlDark),
                                rect.X , rect.Y + rect.Height - 1 , rect.X + rect.Width - 1, rect.Y + rect.Height -1);
 
-                       dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonDkShadow),
+                       dc.DrawLine (ResPool.GetPen (ColorControlDarkDark),
                                rect.X , rect.Y + rect.Height, rect.X + rect.Width - 1, rect.Y + rect.Height);
 
-                       for (int i = 0; i < menu.items.Count; i++)
-                               if (cliparea.IntersectsWith (((MenuAPI.MENUITEM) menu.items[i]).rect)) {
-                                       MenuAPI.MENUITEM it = (MenuAPI.MENUITEM) menu.items[i];
-                                       it.item.MenuHeight = menu.Height;
-                                       it.item.PerformDrawItem (new DrawItemEventArgs (dc, ThemeEngine.Current.MenuFont,
-                                               it.rect, i, it.item.Status));
+                       for (int i = 0; i < menu.MenuItems.Count; i++)
+                               if (cliparea.IntersectsWith (menu.MenuItems [i].bounds)) {
+                                       MenuItem item = menu.MenuItems [i];
+                                       item.MenuHeight = menu.Height;
+                                       item.PerformDrawItem (new DrawItemEventArgs (dc, MenuFont,
+                                               item.bounds, i, item.Status));
                        }
                }
                
@@ -2198,6 +2129,8 @@ namespace System.Windows.Forms
                                                        Math.Max(client_rectangle.Width - today_offset, 0),
                                                        date_cell_size.Height);
                                        dc.DrawString ("Today: " + DateTime.Now.ToShortDateString(), bold_font, ResPool.GetSolidBrush (mc.ForeColor), today_rect, text_format);
+                                       text_format.Dispose ();
+                                       bold_font.Dispose ();
                                }                               
                        }
                        
@@ -2436,6 +2369,7 @@ namespace System.Windows.Forms
                                        rectangle.X + date_cell_size.Width - 1,
                                        rectangle.Y + title_size.Height + date_cell_size.Height + (month_row_count * date_cell_size.Height) - mc.divider_line_offset);
                        }
+                       text_format.Dispose ();
                }
 
                // draws the pervious or next button
@@ -2488,7 +2422,7 @@ namespace System.Windows.Forms
                                dc.DrawRectangle (SystemPens.ControlDark, button_rect);
                        }
                        else {
-                               CPDrawBorder3D (dc, button_rect, Border3DStyle.Raised, Border3DSide.All);
+                               CPDrawBorder3D (dc, button_rect, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
                        }
                        // draw the arrow
                        dc.FillPolygon (SystemBrushes.ControlText, arrow_path);                 
@@ -2589,6 +2523,7 @@ namespace System.Windows.Forms
                                        dc.DrawRectangle (pen, interior);
                                }
                        }
+                       text_format.Dispose ();
                }
 
                private void DrawTodayCircle (Graphics dc, Rectangle rectangle) {
@@ -2623,6 +2558,9 @@ namespace System.Windows.Forms
                public override void DrawPictureBox (Graphics dc, Rectangle clip, PictureBox pb) {
                        Rectangle client = pb.ClientRectangle;
 
+                       // FIXME - instead of drawing the whole picturebox every time
+                       // intersect the clip rectangle with the drawn picture and only draw what's needed,
+                       // Also, we only need a background fill where no image goes
                        if (pb.Image != null) {
                                switch (pb.SizeMode) {
                                case PictureBoxSizeMode.StretchImage:
@@ -2630,15 +2568,21 @@ namespace System.Windows.Forms
                                        break;
 
                                case PictureBoxSizeMode.CenterImage:
+                                       dc.FillRectangle(ResPool.GetSolidBrush(pb.BackColor), clip);
                                        dc.DrawImage (pb.Image, (client.Width / 2) - (pb.Image.Width / 2), (client.Height / 2) - (pb.Image.Height / 2));
                                        break;
                                default:
+                                       dc.FillRectangle(ResPool.GetSolidBrush(pb.BackColor), clip);
                                        // Normal, AutoSize
                                        dc.DrawImage(pb.Image, 0, 0, pb.Image.Width, pb.Image.Height);
                                        break;
                                }
+
+                               return;
                        }
-                       CPDrawBorderStyle (dc, client, pb.BorderStyle);
+
+                       // We only get here if no image is set. At least paint the background
+                       dc.FillRectangle(ResPool.GetSolidBrush(pb.BackColor), clip);
                }
 
                public override Size PictureBoxDefaultSize {
@@ -2663,7 +2607,7 @@ namespace System.Windows.Forms
                        increment = block_width + space_betweenblocks;
 
                        /* Draw border */
-                       CPDrawBorder3D (dc, ctrl.ClientRectangle, Border3DStyle.SunkenInner, Border3DSide.All & ~Border3DSide.Middle, ColorButtonFace);
+                       CPDrawBorder3D (dc, ctrl.ClientRectangle, Border3DStyle.SunkenInner, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom & ~Border3DSide.Middle, ColorControl);
                        
                        /* Draw Blocks */
                        block_rect = new Rectangle (client_area.X, client_area.Y, block_width, client_area.Height);
@@ -2850,6 +2794,7 @@ namespace System.Windows.Forms
                        RadioButton_DrawText(radio_button, text_rectangle, dc, text_format);
 
                        RadioButton_DrawFocus(radio_button, dc, text_rectangle);                        
+                       text_format.Dispose ();
                }
 
                protected virtual void RadioButton_DrawButton(RadioButton radio_button, Graphics dc, ButtonState state, Rectangle radiobutton_rectangle)
@@ -2876,8 +2821,6 @@ namespace System.Windows.Forms
                
                protected virtual void RadioButton_DrawText(RadioButton radio_button, Rectangle text_rectangle, Graphics dc, StringFormat text_format)
                {
-                       SolidBrush sb;
-                       
                        // offset the text if it's pressed and a button
                        if (radio_button.Appearance == Appearance.Button) {
                                if (radio_button.Checked || (radio_button.Capture && radio_button.FlatStyle != FlatStyle.Flat)) {
@@ -2889,15 +2832,18 @@ namespace System.Windows.Forms
                        } 
                        
                        /* Place the text; to be compatible with Windows place it after the radiobutton has been drawn */                       
-                       dc.DrawString (radio_button.Text, radio_button.Font, ThemeEngine.Current.ResPool.GetSolidBrush (radio_button.ForeColor), text_rectangle, text_format);
-                       
+
+                       // Windows seems to not wrap text in certain situations, this matches as close as I could get it
+                       if ((float)(radio_button.Font.Height * 1.5f) > text_rectangle.Height) {
+                               text_format.FormatFlags |= StringFormatFlags.NoWrap;
+                       }
+
                        if (radio_button.Enabled) {
-                               sb = ResPool.GetSolidBrush(radio_button.ForeColor);
-                               dc.DrawString(radio_button.Text, radio_button.Font, sb, text_rectangle, text_format);
+                               dc.DrawString (radio_button.Text, radio_button.Font, ResPool.GetSolidBrush (radio_button.ForeColor), text_rectangle, text_format);
                        } else if (radio_button.FlatStyle == FlatStyle.Flat) {
-                               dc.DrawString(radio_button.Text, radio_button.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorButtonFace)), text_rectangle, text_format);
+                               dc.DrawString(radio_button.Text, radio_button.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorControl)), text_rectangle, text_format);
                        } else {
-                               CPDrawStringDisabled(dc, radio_button.Text, radio_button.Font, this.ColorButtonText, text_rectangle, text_format);
+                               CPDrawStringDisabled(dc, radio_button.Text, radio_button.Font, this.ColorControlText, text_rectangle, text_format);
                        }
                }
                
@@ -2913,7 +2859,7 @@ namespace System.Windows.Forms
                }
 
                // renders a radio button with the Flat and Popup FlatStyle
-               private void DrawFlatStyleRadioButton (Graphics graphics, Rectangle rectangle, RadioButton radio_button)
+               protected void DrawFlatStyleRadioButton (Graphics graphics, Rectangle rectangle, RadioButton radio_button)
                {
                        int     lineWidth;
                        
@@ -2942,15 +2888,15 @@ namespace System.Windows.Forms
                                                
                                        } else {
                                                // just draw lighter flatstyle outer circle
-                                               graphics.DrawArc (ResPool.GetPen (ControlPaint.Dark (this.ColorButtonFace)), rectangle, 0, 359);                                                
+                                               graphics.DrawArc (ResPool.GetPen (ControlPaint.Dark (this.ColorControl)), rectangle, 0, 359);                                           
                                        }                                                                               
                                }
                        } else {
                                // disabled
                                // fill control background color regardless of actual backcolor
-                               graphics.FillPie (ResPool.GetSolidBrush (this.ColorButtonFace), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
+                               graphics.FillPie (ResPool.GetSolidBrush (this.ColorControl), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
                                // draw the ark as control dark
-                               graphics.DrawArc (ResPool.GetPen (ControlPaint.Dark(this.ColorButtonFace)), rectangle, 0, 359);
+                               graphics.DrawArc (ResPool.GetPen (ControlPaint.Dark(this.ColorControl)), rectangle, 0, 359);
                        }
 
                        // draw the check
@@ -2959,9 +2905,9 @@ namespace System.Windows.Forms
                                SolidBrush buttonBrush;
 
                                if (!radio_button.Enabled) {
-                                       buttonBrush = ResPool.GetSolidBrush (ControlPaint.Dark (this.ColorButtonFace));
+                                       buttonBrush = ResPool.GetSolidBrush (ControlPaint.Dark (this.ColorControl));
                                } else if (radio_button.FlatStyle == FlatStyle.Popup && radio_button.is_entered && radio_button.Capture) {
-                                       buttonBrush = ResPool.GetSolidBrush (this.ColorButtonText);
+                                       buttonBrush = ResPool.GetSolidBrush (this.ColorControlText);
                                } else {
                                        buttonBrush = ResPool.GetSolidBrush (radio_button.ForeColor);
                                }
@@ -3075,7 +3021,7 @@ namespace System.Windows.Forms
                        
                        if ( intersect != Rectangle.Empty )
                        {
-                               Brush h = ResPool.GetHatchBrush( HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace );
+                               Brush h = ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White);
                                dc.FillRectangle( h, intersect );
                        }
                }
@@ -3087,7 +3033,7 @@ namespace System.Windows.Forms
                        Rectangle intersect = Rectangle.Intersect( clip, r );
                        
                        if ( intersect != Rectangle.Empty )
-                               dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace ), intersect );
+                               dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White ), intersect );
                        
                        r.X = 0;
                        r.Y = thumb_pos.Y + thumb_pos.Height;
@@ -3115,7 +3061,7 @@ namespace System.Windows.Forms
                        
                        intersect = Rectangle.Intersect( clip, r );
                        if ( intersect != Rectangle.Empty )
-                               dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace ), intersect );
+                               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 )
@@ -3125,7 +3071,7 @@ namespace System.Windows.Forms
                        Rectangle intersect = Rectangle.Intersect( clip, r );
                        
                        if ( intersect != Rectangle.Empty )
-                               dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace ), intersect );
+                               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 )
@@ -3135,7 +3081,7 @@ namespace System.Windows.Forms
                        Rectangle intersect = Rectangle.Intersect( clip, r );
                        
                        if ( intersect != Rectangle.Empty )
-                               dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace ), intersect );
+                               dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White), intersect );
                        
                        r.X = thumb_pos.X + thumb_pos.Width;
                        r.Y = 0;
@@ -3163,7 +3109,7 @@ namespace System.Windows.Forms
                        
                        intersect = Rectangle.Intersect( clip, r );
                        if ( intersect != Rectangle.Empty )
-                               dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace ), intersect );
+                               dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White), intersect );
                }
 
                public override int ScrollBarButtonSize {
@@ -3196,6 +3142,7 @@ namespace System.Windows.Forms
                
                                dc.DrawString (text, sb.Font, ResPool.GetSolidBrush (sb.ForeColor),
                                                new Rectangle(area.X + 2, area.Y + 2, area.Width - 4, area.Height - 4), string_format);
+                               string_format.Dispose ();
                        } else if (sb.ShowPanels) {
                                SolidBrush br_forecolor = GetControlForeBrush (sb.ForeColor);
                                int prev_x = area.X + horz_border;
@@ -3210,7 +3157,7 @@ namespace System.Windows.Forms
                        }
 
                        if (sb.SizingGrip)
-                               CPDrawSizeGrip (dc, ColorButtonFace, area);
+                               CPDrawSizeGrip (dc, ColorControl, area);
 
                }
 
@@ -3224,7 +3171,7 @@ namespace System.Windows.Forms
                                Border3DStyle border_style = Border3DStyle.SunkenInner;
                                if (panel.BorderStyle == StatusBarPanelBorderStyle.Raised)
                                        border_style = Border3DStyle.RaisedOuter;
-                               CPDrawBorder3D(dc, area, border_style, Border3DSide.All, ColorButtonFace);
+                               CPDrawBorder3D(dc, area, border_style, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, panel.Parent.BackColor);
                        }
 
                        if (panel.Style == StatusBarPanelStyle.OwnerDraw) {
@@ -3266,6 +3213,7 @@ namespace System.Windows.Forms
                                area.Bottom - y - border_size);
                        
                        dc.DrawString (text, panel.Parent.Font, br_forecolor, r, string_format);
+                       string_format.Dispose ();
                }
 
                public override int StatusBarSizeGripWidth {
@@ -3290,8 +3238,8 @@ namespace System.Windows.Forms
                        Rectangle panel_rect = GetTabPanelRectExt (tab);
 
                        if (tab.Appearance == TabAppearance.Normal) {
-                               CPDrawBorder3D (dc, panel_rect, Border3DStyle.RaisedInner, Border3DSide.Left | Border3DSide.Top, ColorButtonFace);
-                               CPDrawBorder3D (dc, panel_rect, Border3DStyle.Raised, Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
+                               CPDrawBorder3D (dc, panel_rect, Border3DStyle.RaisedInner, Border3DSide.Left | Border3DSide.Top, ColorControl);
+                               CPDrawBorder3D (dc, panel_rect, Border3DStyle.Raised, Border3DSide.Right | Border3DSide.Bottom, ColorControl);
                        }
 
                        if (tab.Alignment == TabAlignment.Top) {
@@ -3426,14 +3374,16 @@ namespace System.Windows.Forms
 
                protected virtual int DrawTab (Graphics dc, TabPage page, TabControl tab, Rectangle bounds, bool is_selected)
                {
-                       int FlatButtonSpacing = 8;                      
+                       int FlatButtonSpacing = 8;
                        Rectangle interior;
                        int res = bounds.Width;
 
+                       
+                       
                        // we can't fill the background right away because the bounds might be adjusted if the tab is selected
 
+                       StringFormat string_format = new StringFormat ();
                        if (tab.Appearance == TabAppearance.Buttons || tab.Appearance == TabAppearance.FlatButtons) {
-
                                dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
 
                                // Separators
@@ -3446,22 +3396,17 @@ namespace System.Windows.Forms
                                }
 
                                if (is_selected) {
-                                       CPDrawBorder3D (dc, bounds, Border3DStyle.Sunken, Border3DSide.All);
+                                       CPDrawBorder3D (dc, bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
                                } else if (tab.Appearance != TabAppearance.FlatButtons) {
-                                       CPDrawBorder3D (dc, bounds, Border3DStyle.Raised, Border3DSide.All);
+                                       CPDrawBorder3D (dc, bounds, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
                                }
 
                                interior = new Rectangle (bounds.Left + 2, bounds.Top + 2, bounds.Width - 4, bounds.Height - 4);
 
                                 
-                               StringFormat string_format = new StringFormat ();
                                string_format.Alignment = StringAlignment.Center;
                                string_format.LineAlignment = StringAlignment.Center;
                                string_format.FormatFlags = StringFormatFlags.NoWrap;
-
-                               interior.Y++;
-                               dc.DrawString (page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush (SystemColors.ControlText), interior, string_format);
-                               interior.Y--;
                        } else {
                                Pen light = ResPool.GetPen (ControlPaint.LightLight (tab.BackColor));
 
@@ -3482,15 +3427,9 @@ namespace System.Windows.Forms
 
                                        interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
 
-                                       if (page.Text != String.Empty) {
-                                               StringFormat string_format = new StringFormat ();
-                                               string_format.Alignment = StringAlignment.Center;
-                                               string_format.LineAlignment = StringAlignment.Center;
-                                               string_format.FormatFlags = StringFormatFlags.NoWrap;
-                                               interior.Y++;
-                                               dc.DrawString (page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush (SystemColors.ControlText), interior, string_format);
-                                               interior.Y--;
-                                       }
+                                       string_format.Alignment = StringAlignment.Center;
+                                       string_format.LineAlignment = StringAlignment.Center;
+                                       string_format.FormatFlags = StringFormatFlags.NoWrap;
 
                                        break;
 
@@ -3510,15 +3449,9 @@ namespace System.Windows.Forms
 
                                        interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
 
-                                       if (page.Text != String.Empty) {
-                                               StringFormat string_format = new StringFormat ();
-                                               string_format.Alignment = StringAlignment.Center;
-                                               string_format.LineAlignment = StringAlignment.Center;
-                                               string_format.FormatFlags = StringFormatFlags.NoWrap;
-                                               interior.Y++;
-                                               dc.DrawString (page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush (SystemColors.ControlText), interior, string_format);
-                                               interior.Y--;
-                                       }
+                                       string_format.Alignment = StringAlignment.Center;
+                                       string_format.LineAlignment = StringAlignment.Center;
+                                       string_format.FormatFlags = StringFormatFlags.NoWrap;
 
                                        break;
 
@@ -3537,20 +3470,10 @@ namespace System.Windows.Forms
 
                                        interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
 
-                                       if (page.Text != String.Empty) {
-                                               StringFormat string_format = new StringFormat ();
-                                               // Flip the text around
-                                               string_format.Alignment = StringAlignment.Center;
-                                               string_format.LineAlignment = StringAlignment.Center;
-                                               string_format.FormatFlags = StringFormatFlags.NoWrap;
-                                               string_format.FormatFlags = StringFormatFlags.DirectionVertical;
-                                               int wo = interior.Width / 2;
-                                               int ho = interior.Height / 2;
-                                               dc.TranslateTransform (interior.X + wo, interior.Y + ho);
-                                               dc.RotateTransform (180);
-                                               dc.DrawString (page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush (SystemColors.ControlText), 0, 0, string_format);
-                                               dc.ResetTransform ();
-                                       }
+                                       string_format.Alignment = StringAlignment.Center;
+                                       string_format.LineAlignment = StringAlignment.Center;
+                                       string_format.FormatFlags = StringFormatFlags.NoWrap;
+                                       string_format.FormatFlags = StringFormatFlags.DirectionVertical;
 
                                        break;
 
@@ -3570,22 +3493,40 @@ namespace System.Windows.Forms
 
                                        interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
 
-                                       if (page.Text != String.Empty) {
-                                               StringFormat string_format = new StringFormat ();
-                                               string_format.Alignment = StringAlignment.Center;
-                                               string_format.LineAlignment = StringAlignment.Center;
-                                               string_format.FormatFlags = StringFormatFlags.NoWrap;
-                                               string_format.FormatFlags = StringFormatFlags.DirectionVertical;
-                                               interior.X++;
-                                               dc.DrawString (page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush (SystemColors.ControlText), interior, string_format);
-                                               interior.X--;
-                                       }
+                                       string_format.Alignment = StringAlignment.Center;
+                                       string_format.LineAlignment = StringAlignment.Center;
+                                       string_format.FormatFlags = StringFormatFlags.NoWrap;
+                                       string_format.FormatFlags = StringFormatFlags.DirectionVertical;
 
                                        break;
                                }
                        }
 
-                       if (page.Focused) {
+                       if (tab.DrawMode == TabDrawMode.Normal && page.Text != null) {
+                               if (tab.Alignment == TabAlignment.Left) {
+                                       int wo = interior.Width / 2;
+                                       int ho = interior.Height / 2;
+                                       dc.TranslateTransform (interior.X + wo, interior.Y + ho);
+                                       dc.RotateTransform (180);
+                                       dc.DrawString (page.Text, page.Font, ResPool.GetSolidBrush (SystemColors.ControlText), 0, 0, string_format);
+                                       dc.ResetTransform ();
+                               } else {
+                                       dc.DrawString (page.Text, page.Font,
+                                                       ResPool.GetSolidBrush (SystemColors.ControlText),
+                                                       interior, string_format);
+                               }
+                       } else if (page.Text != null) {
+                               DrawItemState state = DrawItemState.None;
+                               if (page == tab.SelectedTab)
+                                       state |= DrawItemState.Selected;
+                               DrawItemEventArgs e = new DrawItemEventArgs (dc,
+                                               tab.Font, bounds, tab.IndexForTabPage (page),
+                                               state, page.ForeColor, page.BackColor);
+                               tab.OnDrawItemInternal (e);
+                               return res;
+                       }
+
+                       if (page.parent.Focused && is_selected) {
                                CPDrawFocusRectangle (dc, interior, tab.ForeColor, tab.BackColor);
                        }
 
@@ -3609,10 +3550,8 @@ namespace System.Windows.Forms
                                control.Width, control.Height - ToolBarGripWidth / 2);
                        bool flat = (control.Appearance == ToolBarAppearance.Flat);
                        dc.FillRectangle (ResPool.GetSolidBrush( DefaultControlBackColor ), paint_area);
-                       CPDrawBorderStyle (dc, paint_area, control.BorderStyle);
-
                        if (control.Divider)
-                               dc.DrawLine (ResPool.GetPen (ColorButtonHilight), 0, 0, paint_area.Width, 0);
+                               dc.DrawLine (ResPool.GetPen (ColorControlLight), 0, 0, paint_area.Width, 0);
 
                        foreach (ToolBarButton button in control.Buttons) {
 
@@ -3667,11 +3606,11 @@ namespace System.Windows.Forms
                                        /* Draw the button frame, only if it is not a separator */
                                        if (flat) { 
                                                if (button.Pushed || button.Pressed) {
-                                                       CPDrawBorder3D (dc, buttonArea, Border3DStyle.SunkenOuter, Border3DSide.All, ColorButtonFace);
+                                                       CPDrawBorder3D (dc, buttonArea, Border3DStyle.SunkenOuter, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, ColorControl);
                                                } else if (button.Hilight) {
-                                                       dc.DrawRectangle (ResPool.GetPen (ColorButtonText), buttonArea);
+                                                       dc.DrawRectangle (ResPool.GetPen (ColorControlText), buttonArea);
                                                        if (! ddRect.IsEmpty) {
-                                                               dc.DrawLine (ResPool.GetPen (ColorButtonText), ddRect.X, ddRect.Y, ddRect.X, 
+                                                               dc.DrawLine (ResPool.GetPen (ColorControlText), ddRect.X, ddRect.Y, ddRect.X, 
                                                                        ddRect.Y + ddRect.Height);
                                                                buttonArea.Width -= this.ToolBarDropDownWidth;
                                                        }
@@ -3680,19 +3619,19 @@ namespace System.Windows.Forms
                                        else { // normal toolbar
                                                if (button.Pushed || button.Pressed) {
                                                        CPDrawBorder3D (dc, buttonArea, Border3DStyle.SunkenInner,
-                                                               Border3DSide.All, ColorButtonFace);
+                                                               Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, ColorControl);
                                                        if (! ddRect.IsEmpty) {
                                                                CPDrawBorder3D (dc, ddRect, Border3DStyle.SunkenInner,
-                                                                       Border3DSide.Left, ColorButtonFace);
+                                                                       Border3DSide.Left, ColorControl);
                                                                buttonArea.Width -= this.ToolBarDropDownWidth;
                                                        }
                                                }
                                                else {
                                                        CPDrawBorder3D (dc, buttonArea, Border3DStyle.RaisedInner,
-                                                               Border3DSide.All, ColorButtonFace);
+                                                               Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, ColorControl);
                                                        if (! ddRect.IsEmpty) {
                                                                CPDrawBorder3D (dc, ddRect, Border3DStyle.RaisedInner,
-                                                                       Border3DSide.Left, ColorButtonFace);
+                                                                       Border3DSide.Left, ColorControl);
                                                                buttonArea.Width -= this.ToolBarDropDownWidth;
                                                        }
                                                }
@@ -3701,6 +3640,7 @@ namespace System.Windows.Forms
                                DrawToolBarButton (dc, button, control.Font, format, paint_area, buttonArea,
                                        imgRect, image, txtRect, ddRect, flat);
                        }
+                       format.Dispose ();
                }
 
                private void DrawToolBarButton (Graphics dc, ToolBarButton button, Font font, StringFormat format,
@@ -3714,16 +3654,16 @@ namespace System.Windows.Forms
                        case ToolBarButtonStyle.Separator:
                                // separator is drawn only in the case of flat appearance
                                if (flat) {
-                                       dc.DrawLine (ResPool.GetPen (ColorButtonShadow), buttonArea.X + 1, buttonArea.Y, 
+                                       dc.DrawLine (ResPool.GetPen (ColorControlDark), buttonArea.X + 1, buttonArea.Y, 
                                                buttonArea.X + 1, buttonArea.Height);
-                                       dc.DrawLine (ResPool.GetPen (ColorButtonHilight), buttonArea.X + 1 + (int) ResPool.GetPen (ColorButtonFace).Width,
-                                               buttonArea.Y, buttonArea.X + 1 + (int) ResPool.GetPen (ColorButtonFace).Width, buttonArea.Height);
+                                       dc.DrawLine (ResPool.GetPen (ColorControlLight), buttonArea.X + 1 + (int) ResPool.GetPen (ColorControl).Width,
+                                               buttonArea.Y, buttonArea.X + 1 + (int) ResPool.GetPen (ColorControl).Width, buttonArea.Height);
                                        /* draw a horizontal separator */
                                        if (button.Wrapper) {
                                                int y = buttonArea.Height + this.ToolBarSeparatorWidth / 2;
-                                               dc.DrawLine (ResPool.GetPen (ColorButtonShadow), 0, y, controlArea.Width, y);
-                                               dc.DrawLine (ResPool.GetPen (ColorButtonHilight), 0, y + 1 + (int) ResPool.GetPen (ColorButtonFace).Width, controlArea.Width,
-                                                       y + 1 + (int) ResPool.GetPen (ColorButtonFace).Width);
+                                               dc.DrawLine (ResPool.GetPen (ColorControlDark), 0, y, controlArea.Width, y);
+                                               dc.DrawLine (ResPool.GetPen (ColorControlLight), 0, y + 1 + (int) ResPool.GetPen (ColorControl).Width, controlArea.Width,
+                                                       y + 1 + (int) ResPool.GetPen (ColorControl).Width);
                                        }
                                }
                                break;
@@ -3741,7 +3681,7 @@ namespace System.Windows.Forms
                                                        button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width, 
                                                                imgRect.Height, button.ImageIndex);
                                                else {
-                                                       dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ColorGrayText), imgRect);
+                                                       dc.FillRectangle (ResPool.GetSolidBrush (ColorGrayText), imgRect);
                                                        ControlPaint.DrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
                                                                Border3DSide.Right | Border3DSide.Bottom);
                                                }
@@ -3749,7 +3689,7 @@ namespace System.Windows.Forms
                                        if (button.Enabled)
                                                dc.DrawString (button.Text, font, SystemBrushes.ControlText, txtRect, format);
                                        else
-                                               CPDrawStringDisabled (dc, button.Text, font, ColorButtonHilight, txtRect, format);
+                                               CPDrawStringDisabled (dc, button.Text, font, ColorControlLight, txtRect, format);
                                }
 
                                else if (button.PartialPush) {
@@ -3759,7 +3699,7 @@ namespace System.Windows.Forms
                                                        button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
                                                                imgRect.Height, button.ImageIndex);
                                                else {
-                                                       dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ColorGrayText), imgRect);
+                                                       dc.FillRectangle (ResPool.GetSolidBrush (ColorGrayText), imgRect);
                                                        ControlPaint.DrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
                                                                Border3DSide.Right | Border3DSide.Bottom);
                                                }
@@ -3767,7 +3707,7 @@ namespace System.Windows.Forms
                                        if (button.Enabled)
                                                dc.DrawString (button.Text, font, SystemBrushes.ControlText, txtRect, format);
                                        else
-                                               CPDrawStringDisabled (dc, button.Text, font, ColorButtonHilight,
+                                               CPDrawStringDisabled (dc, button.Text, font, ColorControlLight,
                                                        txtRect, format);
                                }
 
@@ -3778,15 +3718,15 @@ namespace System.Windows.Forms
                                                        button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
                                                                imgRect.Height, button.ImageIndex);
                                                else {
-                                                       dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ColorGrayText), imgRect);
+                                                       dc.FillRectangle (ResPool.GetSolidBrush (ColorGrayText), imgRect);
                                                        CPDrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
-                                                               Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
+                                                               Border3DSide.Right | Border3DSide.Bottom, ColorControl);
                                                }
                                        }
                                        if (button.Enabled)
                                                dc.DrawString (button.Text, font, SystemBrushes.ControlText, txtRect, format);
                                        else
-                                               CPDrawStringDisabled (dc, button.Text, font, ColorButtonHilight,
+                                               CPDrawStringDisabled (dc, button.Text, font, ColorControlLight,
                                                        txtRect, format);
                                }
 
@@ -3797,15 +3737,15 @@ namespace System.Windows.Forms
                                                        button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
                                                                imgRect.Height, button.ImageIndex);
                                                else {
-                                                       dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ColorGrayText), imgRect);
+                                                       dc.FillRectangle (ResPool.GetSolidBrush (ColorGrayText), imgRect);
                                                        CPDrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
-                                                               Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
+                                                               Border3DSide.Right | Border3DSide.Bottom, ColorControl);
                                                }
                                        }
                                        if (button.Enabled)
                                                dc.DrawString (button.Text, font, SystemBrushes.ControlText, txtRect, format);
                                        else
-                                               CPDrawStringDisabled (dc, button.Text, font, ColorButtonHilight,
+                                               CPDrawStringDisabled (dc, button.Text, font, ColorControlLight,
                                                        txtRect, format);
                                }
                                break;
@@ -3831,15 +3771,15 @@ namespace System.Windows.Forms
                                                button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width, imgRect.Height,
                                                        button.ImageIndex);
                                        else {
-                                               dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ColorGrayText), imgRect);
+                                               dc.FillRectangle (ResPool.GetSolidBrush (ColorGrayText), imgRect);
                                                CPDrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
-                                                       Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
+                                                       Border3DSide.Right | Border3DSide.Bottom, ColorControl);
                                        }
                                }
                                if (button.Enabled)
                                        dc.DrawString (button.Text, font, SystemBrushes.ControlText, txtRect, format);
                                else
-                                       CPDrawStringDisabled (dc, button.Text, font, ColorButtonHilight,
+                                       CPDrawStringDisabled (dc, button.Text, font, ColorControlLight,
                                                txtRect, format);
                                break;
                        }
@@ -3884,7 +3824,7 @@ namespace System.Windows.Forms
 
                #region ToolTip
                public override void DrawToolTip(Graphics dc, Rectangle clip_rectangle, ToolTip.ToolTipWindow control) {
-                       dc.FillRectangle(ResPool.GetSolidBrush(this.ColorInfoWindow), control.client_rect);
+                       dc.FillRectangle(ResPool.GetSolidBrush(this.ColorInfo), control.client_rect);
                        dc.DrawRectangle(ResPool.GetPen(this.ColorWindowFrame), 0, 0, control.Width-1, control.Height-1);
                        dc.DrawString(control.text, control.Font, ResPool.GetSolidBrush(this.ColorInfoText), control.client_rect, control.string_format);
                }
@@ -3909,6 +3849,7 @@ namespace System.Windows.Forms
                        float pixels_betweenticks;
                        const int space_from_right = 8;
                        const int space_from_left = 8;
+                       const int space_from_bottom = 11;
                        Rectangle area = tb.ClientRectangle;
                        
                        switch (tb.TickStyle)   {
@@ -3943,13 +3884,13 @@ namespace System.Windows.Forms
                        thumb_area.Width = 4;
 
                        /* Draw channel */
-                       dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonShadow), channel_startpoint.X, channel_startpoint.Y,
+                       dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDark), channel_startpoint.X, channel_startpoint.Y,
                                1, thumb_area.Height);
                        
-                       dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonDkShadow), channel_startpoint.X + 1, channel_startpoint.Y,
+                       dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDarkDark), channel_startpoint.X + 1, channel_startpoint.Y,
                                1, thumb_area.Height);
 
-                       dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonHilight), channel_startpoint.X + 3, channel_startpoint.Y,
+                       dc.FillRectangle (ResPool.GetSolidBrush (ColorControlLight), channel_startpoint.X + 3, channel_startpoint.Y,
                                1, thumb_area.Height);
 
                        pixel_len = thumb_area.Height - 11;
@@ -3957,19 +3898,19 @@ namespace System.Windows.Forms
                        
                        /* Convert thumb position from mouse position to value*/
                        if (mouse_value) {
-                               
-                               if (value_pos >= channel_startpoint.Y)
-                                       value_pos = (int)(((float) (value_pos - channel_startpoint.Y)) / pixels_betweenticks);
+                               if (value_pos < thumb_area.Bottom)
+                                       value_pos = (int) ((thumb_area.Bottom - value_pos) / pixels_betweenticks);
                                else
                                        value_pos = 0;                  
 
                                if (value_pos + tb.Minimum > tb.Maximum)
                                        value_pos = tb.Maximum - tb.Minimum;
-                                
+
                                tb.Value = value_pos + tb.Minimum;
                        }                       
-                       
-                       thumb_pos.Y = channel_startpoint.Y + (int) (pixels_betweenticks * (float) value_pos);
+
+                       // thumb_pos.Y = channel_startpoint.Y ; // + (int) (pixels_betweenticks * (float) value_pos);
+                       thumb_pos.Y = thumb_area.Bottom - space_from_bottom - (int) (pixels_betweenticks * (float) value_pos);
                        
                        /* Draw thumb fixed 10x22 size */
                        thumb_pos.Width = 10;
@@ -3980,15 +3921,15 @@ namespace System.Windows.Forms
                        case TickStyle.None: {
                                thumb_pos.X = channel_startpoint.X - 8;
 
-                               dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X , thumb_pos.Y + 10);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 16, thumb_pos.Y);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X + 16, thumb_pos.Y, thumb_pos.X + 16 + 4, thumb_pos.Y + 4);
+                               dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X , thumb_pos.Y + 10);
+                               dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 16, thumb_pos.Y);
+                               dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X + 16, thumb_pos.Y, thumb_pos.X + 16 + 4, thumb_pos.Y + 4);
                                
-                               dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X +1, thumb_pos.Y + 9, thumb_pos.X +15, thumb_pos.Y  +9);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 16, thumb_pos.Y + 9, thumb_pos.X +16 + 4, thumb_pos.Y  +9 - 4);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X +1, thumb_pos.Y + 9, thumb_pos.X +15, thumb_pos.Y  +9);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 16, thumb_pos.Y + 9, thumb_pos.X +16 + 4, thumb_pos.Y  +9 - 4);
 
-                               dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X, thumb_pos.Y  + 10, thumb_pos.X +16, thumb_pos.Y +10);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 16, thumb_pos.Y  + 10, thumb_pos.X  +16 + 5, thumb_pos.Y +10 - 5);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X, thumb_pos.Y  + 10, thumb_pos.X +16, thumb_pos.Y +10);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), 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);
@@ -4000,16 +3941,16 @@ namespace System.Windows.Forms
                        case TickStyle.TopLeft: {
                                thumb_pos.X = channel_startpoint.X - 10;
 
-                               dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X + 4, thumb_pos.Y, thumb_pos.X + 4 + 16, thumb_pos.Y);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X + 4, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 4);
+                               dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X + 4, thumb_pos.Y, thumb_pos.X + 4 + 16, thumb_pos.Y);
+                               dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X + 4, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 4);
 
-                               dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X  + 4, thumb_pos.Y + 9, thumb_pos.X + 4 + 16 , thumb_pos.Y+ 9);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 4, thumb_pos.Y  + 9, thumb_pos.X, thumb_pos.Y + 5);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X  + 19, thumb_pos.Y + 9, thumb_pos.X  +19 , thumb_pos.Y+ 1);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X  + 4, thumb_pos.Y + 9, thumb_pos.X + 4 + 16 , thumb_pos.Y+ 9);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 4, thumb_pos.Y  + 9, thumb_pos.X, thumb_pos.Y + 5);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X  + 19, thumb_pos.Y + 9, thumb_pos.X  +19 , thumb_pos.Y+ 1);
 
-                               dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X  + 4, thumb_pos.Y+ 10, thumb_pos.X  + 4 + 16, thumb_pos.Y+ 10);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X  + 4, thumb_pos.Y + 10, thumb_pos.X  -1, thumb_pos.Y+ 5);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 20, thumb_pos.Y, thumb_pos.X+ 20, thumb_pos.Y + 10);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X  + 4, thumb_pos.Y+ 10, thumb_pos.X  + 4 + 16, thumb_pos.Y+ 10);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X  + 4, thumb_pos.Y + 10, thumb_pos.X  -1, thumb_pos.Y+ 5);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), 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);
@@ -4021,14 +3962,14 @@ namespace System.Windows.Forms
 
                        case TickStyle.Both: {
                                thumb_pos.X = area.X + 10;
-                               dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 9);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 19, thumb_pos.Y);
+                               dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 9);
+                               dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 19, thumb_pos.Y);
 
-                               dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 1, thumb_pos.Y + 9, thumb_pos.X+ 19, thumb_pos.Y  + 9);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X  + 10, thumb_pos.Y+ 1, thumb_pos.X + 19, thumb_pos.Y  + 8);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 1, thumb_pos.Y + 9, thumb_pos.X+ 19, thumb_pos.Y  + 9);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X  + 10, thumb_pos.Y+ 1, thumb_pos.X + 19, thumb_pos.Y  + 8);
 
-                               dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X, thumb_pos.Y + 10, thumb_pos.X+ 20, thumb_pos.Y  +10);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X  + 20, thumb_pos.Y, thumb_pos.X  + 20, thumb_pos.Y+ 9);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X, thumb_pos.Y + 10, thumb_pos.X+ 20, thumb_pos.Y  +10);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), 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);
 
@@ -4139,13 +4080,13 @@ namespace System.Windows.Forms
                        thumb_area.Height = 4;
                        
                        /* Draw channel */
-                       dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonShadow), channel_startpoint.X, channel_startpoint.Y,
+                       dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDark), channel_startpoint.X, channel_startpoint.Y,
                                thumb_area.Width, 1);
                        
-                       dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonDkShadow), channel_startpoint.X, channel_startpoint.Y + 1,
+                       dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDarkDark), channel_startpoint.X, channel_startpoint.Y + 1,
                                thumb_area.Width, 1);
 
-                       dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonHilight), channel_startpoint.X, channel_startpoint.Y +3,
+                       dc.FillRectangle (ResPool.GetSolidBrush (ColorControlLight), channel_startpoint.X, channel_startpoint.Y +3,
                                thumb_area.Width, 1);
 
                        pixel_len = thumb_area.Width - 11;
@@ -4175,15 +4116,15 @@ namespace System.Windows.Forms
                        case TickStyle.None: {
                                thumb_pos.Y = channel_startpoint.Y - 8;
 
-                               dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 10, thumb_pos.Y);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 16);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y + 16, thumb_pos.X + 4, thumb_pos.Y + 16 + 4);
+                               dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 10, thumb_pos.Y);
+                               dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 16);
+                               dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y + 16, thumb_pos.X + 4, thumb_pos.Y + 16 + 4);
 
-                               dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 9, thumb_pos.Y + 1, thumb_pos.X +9, thumb_pos.Y +15);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 9, thumb_pos.Y + 16, thumb_pos.X +9 - 4, thumb_pos.Y +16 + 4);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 9, thumb_pos.Y + 1, thumb_pos.X +9, thumb_pos.Y +15);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 9, thumb_pos.Y + 16, thumb_pos.X +9 - 4, thumb_pos.Y +16 + 4);
 
-                               dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X +10, thumb_pos.Y +16);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 10, thumb_pos.Y + 16, thumb_pos.X +10 - 5, thumb_pos.Y +16 + 5);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X +10, thumb_pos.Y +16);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), 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);
@@ -4194,16 +4135,16 @@ namespace System.Windows.Forms
                        case TickStyle.TopLeft: {
                                thumb_pos.Y = channel_startpoint.Y - 10;
 
-                               dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X, thumb_pos.Y + 4 + 16);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X + 4, thumb_pos.Y);
+                               dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X, thumb_pos.Y + 4 + 16);
+                               dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X + 4, thumb_pos.Y);
 
-                               dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 9, thumb_pos.Y + 4 + 16);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 9, thumb_pos.Y + 19, thumb_pos.X + 1 , thumb_pos.Y +19);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 9, thumb_pos.Y + 4 + 16);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 9, thumb_pos.Y + 19, thumb_pos.X + 1 , thumb_pos.Y +19);
 
-                               dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 10, thumb_pos.Y + 4 + 16);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y -1);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X, thumb_pos.Y + 20, thumb_pos.X + 10, thumb_pos.Y + 20);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 10, thumb_pos.Y + 4 + 16);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y -1);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), 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);
@@ -4214,14 +4155,14 @@ namespace System.Windows.Forms
 
                        case TickStyle.Both: {
                                thumb_pos.Y = area.Y + 10;
-                               dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 9, thumb_pos.Y);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 19);
+                               dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 9, thumb_pos.Y);
+                               dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 19);
 
-                               dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 9, thumb_pos.Y + 1, thumb_pos.X + 9, thumb_pos.Y + 19);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 1, thumb_pos.Y + 10, thumb_pos.X + 8, thumb_pos.Y + 19);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 9, thumb_pos.Y + 1, thumb_pos.X + 9, thumb_pos.Y + 19);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 1, thumb_pos.Y + 10, thumb_pos.X + 8, thumb_pos.Y + 19);
 
-                               dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X +10, thumb_pos.Y + 20);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X, thumb_pos.Y + 20, thumb_pos.X + 9, thumb_pos.Y + 20);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X +10, thumb_pos.Y + 20);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), 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);
 
@@ -4294,25 +4235,25 @@ namespace System.Windows.Forms
                        area = tb.ClientRectangle;
 
                        if (tb.thumb_pressed == true) {
-                               br_thumb = (Brush) ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace);
+                               br_thumb = (Brush) ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControlLight, ColorControl);
                        } else {
-                               br_thumb = ResPool.GetSolidBrush (ColorButtonFace);
+                               br_thumb = ResPool.GetSolidBrush (ColorControl);
                        }
 
                        
                        /* Control Background */
                        if (tb.BackColor == DefaultControlBackColor) {
-                               dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonFace), clip_rectangle);
+                               dc.FillRectangle (ResPool.GetSolidBrush (ColorControl), clip_rectangle);
                        } else {
                                dc.FillRectangle (ResPool.GetSolidBrush (tb.BackColor), clip_rectangle);
                        }
                        
 
                        if (tb.Focused) {
-                               dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonFace, Color.Black), area.X, area.Y, area.Width - 1, 1);
-                               dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonFace, Color.Black), area.X, area.Y + area.Height - 1, area.Width - 1, 1);
-                               dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonFace, Color.Black), area.X, area.Y, 1, area.Height - 1);
-                               dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonFace, Color.Black), area.X + area.Width - 1, area.Y, 1, area.Height - 1);
+                               dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControl, Color.Black), area.X, area.Y, area.Width - 1, 1);
+                               dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControl, Color.Black), area.X, area.Y + area.Height - 1, area.Width - 1, 1);
+                               dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControl, Color.Black), area.X, area.Y, 1, area.Height - 1);
+                               dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControl, Color.Black), area.X + area.Width - 1, area.Y, 1, area.Height - 1);
                        }
 
                        if (tb.Orientation == Orientation.Vertical) {
@@ -4410,7 +4351,7 @@ namespace System.Windows.Forms
                }
 
                public override void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides) {
-                       CPDrawBorder3D(graphics, rectangle, style, sides, ColorButtonFace);
+                       CPDrawBorder3D(graphics, rectangle, style, sides, ColorControl);
                }
 
                private void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides, Color control_color) {
@@ -4568,17 +4509,17 @@ namespace System.Windows.Forms
                                Pen     pen;
 
                                if ((state & ButtonState.Inactive)!=0) {
-                                       pen=new Pen(ColorButtonHilight, lineWidth);
-                                       DrawCaptionHelper(graphics, ColorButtonHilight, pen, lineWidth, 1, captionRect, button);
+                                       pen=new Pen(ColorControlLight, lineWidth);
+                                       DrawCaptionHelper(graphics, ColorControlLight, pen, lineWidth, 1, captionRect, button);
                                        pen.Dispose();
 
-                                       pen=new Pen(ColorButtonShadow, lineWidth);
-                                       DrawCaptionHelper(graphics, ColorButtonShadow, pen, lineWidth, 0, captionRect, button);
+                                       pen=new Pen(ColorControlDark, lineWidth);
+                                       DrawCaptionHelper(graphics, ColorControlDark, pen, lineWidth, 0, captionRect, button);
                                        pen.Dispose();
                                        return;
                                } else {
-                                       pen=new Pen(ColorButtonText, lineWidth);
-                                       DrawCaptionHelper(graphics, ColorButtonText, pen, lineWidth, 0, captionRect, button);
+                                       pen=new Pen(ColorControlText, lineWidth);
+                                       DrawCaptionHelper(graphics, ColorControlText, pen, lineWidth, 0, captionRect, button);
                                        pen.Dispose();
                                        return;
                                }
@@ -4589,12 +4530,12 @@ namespace System.Windows.Forms
                        case CaptionButton.Minimize:
                        case CaptionButton.Restore: {
                                if ((state & ButtonState.Inactive)!=0) {
-                                       DrawCaptionHelper(graphics, ColorButtonHilight, SystemPens.ControlLightLight, lineWidth, 1, captionRect, button);
+                                       DrawCaptionHelper(graphics, ColorControlLight, SystemPens.ControlLightLight, lineWidth, 1, captionRect, button);
 
-                                       DrawCaptionHelper(graphics, ColorButtonShadow, SystemPens.ControlDark, lineWidth, 0, captionRect, button);
+                                       DrawCaptionHelper(graphics, ColorControlDark, SystemPens.ControlDark, lineWidth, 0, captionRect, button);
                                        return;
                                } else {
-                                       DrawCaptionHelper(graphics, ColorButtonText, SystemPens.ControlText, lineWidth, 0, captionRect, button);
+                                       DrawCaptionHelper(graphics, ColorControlText, SystemPens.ControlText, lineWidth, 0, captionRect, button);
                                        return;
                                }
                        }
@@ -4637,19 +4578,19 @@ namespace System.Windows.Forms
                        Rectangle               rect;
 
                        if ((state & ButtonState.Checked)!=0) {
-                               graphics.FillRectangle(ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonLight, ColorButtonHilight),rectangle);                           
+                               graphics.FillRectangle(ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControlLightLight, ColorControlLight),rectangle);                              
                        }
 
                        if ((state & ButtonState.Flat)!=0) {
-                               ControlPaint.DrawBorder(graphics, rectangle, ColorButtonShadow, ButtonBorderStyle.Solid);
+                               ControlPaint.DrawBorder(graphics, rectangle, ColorControlDark, ButtonBorderStyle.Solid);
                        } else {
                                if ((state & (ButtonState.Pushed | ButtonState.Checked))!=0) {
                                        // this needs to render like a pushed button - jba
-                                       // CPDrawBorder3D(graphics, rectangle, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
+                                       // CPDrawBorder3D(graphics, rectangle, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl);
                                        Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
-                                       graphics.DrawRectangle (ResPool.GetPen (ControlPaint.Dark (ColorButtonFace)), trace_rectangle);
+                                       graphics.DrawRectangle (ResPool.GetPen (ControlPaint.Dark (ColorControl)), trace_rectangle);
                                } else {
-                                       CPDrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
+                                       CPDrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl);
                                }
                        }
 
@@ -4702,7 +4643,7 @@ namespace System.Windows.Forms
                        int                     X;
                        int                     Y;
 
-                       graphics.FillRectangle(ResPool.GetSolidBrush (ColorButtonText), rect);
+                       graphics.FillRectangle(ResPool.GetSolidBrush (ColorControlText), rect);
                        graphics.DrawRectangle(pen, rect);
 
                        X=rect.X+rect.Width/2;
@@ -4719,6 +4660,7 @@ namespace System.Windows.Forms
                        /* Draw 'arrows' for horizontal lines */
                        graphics.DrawLine(pen, rect.X+3, Y-1, rect.X+3, Y+1);
                        graphics.DrawLine(pen, rect.Right-3, Y-1, rect.Right-3, Y+1);
+                       pen.Dispose ();
 
                }
 
@@ -4729,7 +4671,7 @@ namespace System.Windows.Forms
                        Color outerColor = foreColor;
                        // adjust focus color according to the flatstyle
                        if (button.FlatStyle == FlatStyle.Popup && !button.is_pressed) {
-                               outerColor = (backColor == ColorButtonFace) ? ControlPaint.Dark(ColorButtonFace) : ColorButtonText;                             
+                               outerColor = (backColor == ColorControl) ? ControlPaint.Dark(ColorControl) : ColorControlText;                          
                        }
                        
                        // draw the outer rectangle
@@ -4750,14 +4692,19 @@ namespace System.Windows.Forms
                        // make a rectange to trace around border of the button
                        Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
                        
+#if NotUntilCairoIsFixed
                        Color colorBackInverted = Color.FromArgb (Math.Abs (backColor.R-255), Math.Abs (backColor.G-255), Math.Abs (backColor.B-255));
                        DashStyle oldStyle; // used for caching old penstyle
                        Pen pen = ResPool.GetPen (colorBackInverted);
-                       
+
                        oldStyle = pen.DashStyle; 
                        pen.DashStyle = DashStyle.Dot;
+
                        graphics.DrawRectangle (pen, trace_rectangle);
                        pen.DashStyle = oldStyle;
+#else
+                       CPDrawFocusRectangle(graphics, trace_rectangle, Color.Wheat, backColor);
+#endif
                }
                                
 
@@ -4793,16 +4740,16 @@ namespace System.Windows.Forms
                        if (primary==true) {
                                pen=new Pen(Color.Black, 1);
                                if (enabled==true) {
-                                       sb=ResPool.GetSolidBrush (ColorButtonText);
+                                       sb=ResPool.GetSolidBrush (ColorControlText);
                                } else {
-                                       sb=ResPool.GetSolidBrush (ColorButtonFace);
+                                       sb=ResPool.GetSolidBrush (ColorControl);
                                }
                        } else {
                                pen=new Pen(Color.White, 1);
                                if (enabled==true) {
-                                       sb=ThemeEngine.Current.ResPool.GetSolidBrush (Color.Black);
+                                       sb=ResPool.GetSolidBrush (Color.Black);
                                } else {
-                                       sb=ResPool.GetSolidBrush (ColorButtonFace);
+                                       sb=ResPool.GetSolidBrush (ColorControl);
                                }
                        }
                        graphics.FillRectangle(sb, rectangle);
@@ -4963,7 +4910,7 @@ namespace System.Windows.Forms
                                lineWidth=Math.Max(2, rectangle.Width/3);
                                rect=new Rectangle(rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2);
                                
-                               graphics.FillEllipse(ResPool.GetSolidBrush (ColorButtonText), rect);
+                               graphics.FillEllipse(ResPool.GetSolidBrush (ColorControlText), rect);
                                
                                return;
                        }
@@ -5021,84 +4968,79 @@ namespace System.Windows.Forms
 
                /* Scroll button: regular button + direction arrow */
                public override void CPDrawScrollButton (Graphics dc, Rectangle area, ScrollButton type, ButtonState state) {
-                       bool enabled = (state == ButtonState.Inactive) ? false: true;                   
-                                       
                        DrawScrollButtonPrimitive (dc, area, state);
-                                               
-                       if (area.Width < 12 || area.Height < 12) /* Cannot see a thing at smaller sizes */
-                               return;
-
-                       /* Paint arrows */
-                       switch (type) {
-                       case ScrollButton.Up: {
-                               int x = area.X +  (area.Width / 2) - 4;
-                               int y = area.Y + 9;
 
-                               for (int i = 0; i < 3; i++)
-                                       if (enabled)
-                                               dc.DrawLine (ResPool.GetPen (arrow_color), x + i, y - i, x + i + 6 - 2*i, y - i);
-                                       else
-                                               dc.DrawLine (ResPool.GetPen (ColorGrayText), x + i, y - i, x + i + 6 - 2*i, y - i);
-
-                               
-                               dc.FillRectangle (enabled ? ResPool.GetSolidBrush (arrow_color) :  ResPool.GetSolidBrush (ColorGrayText),
-                                       x + 3, area.Y + 6, 1, 1);
-                                       
-                               break;
+                       // A lot of the following is adapted from the rewind project
+                       Rectangle rect = new Rectangle (area.X - 3, area.Y - 3,
+                                       area.Width + 6, area.Height + 6);
+                       int small_diam = rect.Width > rect.Height ? rect.Height : rect.Width;
+                       if (rect.Width < rect.Height) {
+                               rect.Y += (rect.Height - rect.Width) / 2;
+                               rect.Height = small_diam;
+                       } else if (rect.Width > rect.Height) {
+                               rect.X += (rect.Width - rect.Height) / 2;
+                               rect.Width = small_diam;
                        }
-                       case ScrollButton.Down: {
-                               int x = area.X +  (area.Width / 2) - 5;
-                               int y = area.Y + 5;
 
-                               for (int i = 4; i != 0; i--)
-                                       if (enabled)
-                                               dc.DrawLine (ResPool.GetPen (arrow_color), x + i, y + i, x + i + 8 - 2*i, y + i);
-                                       else
-                                               dc.DrawLine (ResPool.GetPen (ColorGrayText), x + i, y + i, x + i + 8 - 2*i, y + i);
-
-                               
-                               dc.FillRectangle (enabled ? ResPool.GetSolidBrush (arrow_color) :  ResPool.GetSolidBrush (ColorGrayText),
-                                       x + 4, y + 4, 1, 1);
-                               break;
-                       }
+                       small_diam -= 2;
 
-                       case ScrollButton.Left: {
-                               int y = area.Y +  (area.Height / 2) - 4;
-                               int x = area.X + 9;
+                       int tri = 290 * small_diam / 1000 - 1;
+                       if (tri == 0)
+                               tri = 1;
 
-                               for (int i = 0; i < 3; i++)
-                                       if (enabled)
-                                               dc.DrawLine (ResPool.GetPen (arrow_color), x - i, y + i, x - i, y + i + 6 - 2*i);
-                                       else
-                                               dc.DrawLine (ResPool.GetPen (ColorGrayText), x - i, y + i, x - i, y + i + 6 - 2*i);
+                       Point [] arrow = new Point [3];
+                       for (int i = 0; i < 3; i++)
+                               arrow [i] = new Point ();
 
-                               dc.FillRectangle (enabled ? ResPool.GetSolidBrush (arrow_color) :  ResPool.GetSolidBrush (ColorGrayText),
-                                       x - 3, y + 3, 1, 1);
+                       switch(type) {
+                       default:
+                       case ScrollButton.Down:
+                               arrow [2].X = rect.Left + 470 * small_diam / 1000 + 2;
+                               arrow [2].Y = rect.Top + 687 * small_diam / 1000 + 1;
+                               arrow [0].X = arrow [2].X - tri;
+                               arrow [1].X = arrow [2].X + tri;
+                               arrow [0].Y = arrow [1].Y = arrow [2].Y - tri;
                                break;
-                       }
-
-                       case ScrollButton.Right: {
-                               int y = area.Y +  (area.Height / 2) - 5;
-                               int x = area.X + 5;
 
-                               for (int i = 4; i != 0; i--)
-                                       if (enabled)
-                                               dc.DrawLine (ResPool.GetPen (arrow_color), x + i, y + i, x + i, y + i + 8 - 2*i);
-                                       else
-                                               dc.DrawLine (ResPool.GetPen (ColorGrayText), x + i, y + i, x + i, y + i + 8 - 2*i);
+                       case ScrollButton.Up:
+                               arrow [2].X = rect.Left + 470 * small_diam / 1000 + 2;
+                               arrow [2].Y = rect.Bottom - (687 * small_diam / 1000 + 1);
+                               arrow [0].X = arrow [2].X - tri;
+                               arrow [1].X = arrow [2].X + tri;
+                               arrow [0].Y = arrow [1].Y = arrow [2].Y + tri;
+                               break;
 
-                               dc.FillRectangle (enabled ? ResPool.GetSolidBrush (arrow_color) :  ResPool.GetSolidBrush (ColorGrayText),
-                                       x + 4, y + 4, 1, 1);
+                       case ScrollButton.Left:
+                               arrow [2].X = rect.Right - (687 * small_diam / 1000 + 1);
+                               arrow [2].Y = rect.Top + 470 * small_diam / 1000 + 2;
+                               arrow [0].Y = arrow [2].Y - tri;
+                               arrow [1].Y = arrow [2].Y + tri;
+                               arrow [0].X = arrow [1].X = arrow [2].X + tri;
+                               break;
+                       case ScrollButton.Right:
+                               arrow [2].X = rect.Left + 687 * small_diam / 1000 + 1;
+                               arrow [2].Y = rect.Top + 470 * small_diam / 1000 + 2;
+                               arrow [0].Y = arrow [2].Y - tri;
+                               arrow [1].Y = arrow [2].Y + tri;
+                               arrow [0].X = arrow [1].X = arrow [2].X - tri;
                                break;
                        }
 
-                       default:
-                               break;
+                       /* Draw the arrow */
+                       if ((state & ButtonState.Inactive)!=0) {
+                               dc.FillPolygon (SystemBrushes.ControlLightLight, arrow, FillMode.Winding);
 
+                               for (int i = 0; i < 3; i++) {
+                                       arrow [i].X--;
+                                       arrow [i].Y--;
+                               }
+                               
+                               dc.FillPolygon (SystemBrushes.ControlDark, arrow, FillMode.Winding);
+                       } else {
+                               dc.FillPolygon (SystemBrushes.ControlText, arrow, FillMode.Winding);
                        }
                }
 
-
                public  override void CPDrawSelectionFrame (Graphics graphics, bool active, Rectangle outsideRect, Rectangle insideRect,
                        Color backColor) {
 
@@ -5108,27 +5050,24 @@ namespace System.Windows.Forms
                public override void CPDrawSizeGrip (Graphics dc, Color backColor, Rectangle bounds) {
                        Point pt = new Point (bounds.Right - 2, bounds.Bottom - 1);
 
-                       dc.DrawLine (ResPool.GetPen (ColorButtonFace), pt.X - 12, pt.Y, pt.X, pt.Y);
-                       dc.DrawLine (ResPool.GetPen (ColorButtonFace), pt.X, pt.Y, pt.X, pt.Y - 13);
+                       dc.DrawLine (ResPool.GetPen (ColorControl), pt.X - 12, pt.Y, pt.X, pt.Y);
+                       dc.DrawLine (ResPool.GetPen (ColorControl), pt.X, pt.Y, pt.X, pt.Y - 13);
 
                        // diagonals
                        for (int i = 0; i < 11; i += 4) {
-                               dc.DrawLine (ResPool.GetPen (ColorButtonShadow), pt.X - i, pt.Y, pt.X + 1, pt.Y - i - 2);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonShadow), pt.X - i - 1, pt.Y, pt.X + 1, pt.Y - i - 2);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDark), pt.X - i, pt.Y, pt.X + 1, pt.Y - i - 2);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDark), pt.X - i - 1, pt.Y, pt.X + 1, pt.Y - i - 2);
                        }
 
                        for (int i = 3; i < 13; i += 4)
-                               dc.DrawLine (ResPool.GetPen (ColorButtonHilight), pt.X - i, pt.Y, pt.X + 1, pt.Y - i - 1);
+                               dc.DrawLine (ResPool.GetPen (ColorControlLight), pt.X - i, pt.Y, pt.X + 1, pt.Y - i - 1);
                }
 
 
                public  override void CPDrawStringDisabled (Graphics graphics, string s, Font font, Color color, RectangleF layoutRectangle,
                        StringFormat format) {                  
 
-                       layoutRectangle.Offset(1.0f, 1.0f);
-                       graphics.DrawString(s, font, ResPool.GetSolidBrush (ControlPaint.Light(color, 95)), layoutRectangle, format);                   
-                       layoutRectangle.Offset(-1.0f, -1.0f);
-                       graphics.DrawString(s, font, ResPool.GetSolidBrush (ControlPaint.Light(color, 50)), layoutRectangle, format);
+                       graphics.DrawString(s, font, ResPool.GetSolidBrush (ColorGrayText), layoutRectangle, format);
                        
                }
 
@@ -5325,7 +5264,7 @@ namespace System.Windows.Forms
                        still look like MS's scaled caption buttons. (as opposed to scaling a bitmap)
                */
 
-               private static void DrawCaptionHelper(Graphics graphics, Color color, Pen pen, int lineWidth, int shift, Rectangle captionRect, CaptionButton button) {
+               private void DrawCaptionHelper(Graphics graphics, Color color, Pen pen, int lineWidth, int shift, Rectangle captionRect, CaptionButton button) {
                        switch(button) {
                        case CaptionButton.Close: {
                                pen.StartCap=LineCap.Triangle;
@@ -5348,7 +5287,7 @@ namespace System.Windows.Forms
                                sf.LineAlignment=StringAlignment.Center;
 
 
-                               graphics.DrawString("?", font, ThemeEngine.Current.ResPool.GetSolidBrush (color), captionRect.X+captionRect.Width/2+shift, captionRect.Y+captionRect.Height/2+shift+lineWidth/2, sf);
+                               graphics.DrawString("?", font, ResPool.GetSolidBrush (color), captionRect.X+captionRect.Width/2+shift, captionRect.Y+captionRect.Height/2+shift+lineWidth/2, sf);
 
                                sf.Dispose();                           
                                font.Dispose();
@@ -5447,27 +5386,24 @@ namespace System.Windows.Forms
 // JBA 31 oct 2004 - I don't think that button style should be rendered like this
 //                                     /* Goes first, affects the background */
 //                                     if ((State & DrawFrameControlStates.Checked)!=0) {
-//                                             HatchBrush      hatchBrush=new HatchBrush(HatchStyle.Percent50, ColorButtonLight, ColorButtonHilight);
+//                                             HatchBrush      hatchBrush=new HatchBrush(HatchStyle.Percent50, ColorControlLightLight, ColorControlLight);
 //                                             graphics.FillRectangle(hatchBrush,rectangle);
 //                                             hatchBrush.Dispose();
 //                                     }
 
-                                       // Clear the background
-                                       graphics.FillRectangle (SystemBrushes.Control, rectangle);
-
                                        if ((State & DrawFrameControlStates.Pushed)!=0 || (State & DrawFrameControlStates.Checked)!=0) {
-                                               graphics.DrawRectangle (ResPool.GetPen (ControlPaint.Dark (ColorButtonFace)), trace_rectangle);
+                                               graphics.DrawRectangle (ResPool.GetPen (ControlPaint.Dark (ColorControl)), trace_rectangle);
                                        } else if ((State & DrawFrameControlStates.Flat)!=0) {
-                                               ControlPaint.DrawBorder(graphics, rectangle, ColorButtonShadow, ButtonBorderStyle.Solid);
+                                               ControlPaint.DrawBorder(graphics, rectangle, ColorControlDark, ButtonBorderStyle.Solid);
                                        } else if ((State & DrawFrameControlStates.Inactive)!=0) {
                                                /* Same as normal, it would seem */
-                                               CPDrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
+                                               CPDrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl);
                                        } else {
-                                               CPDrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
+                                               CPDrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl);
                                        }
                                } else if ((State & DrawFrameControlStates.ButtonRadio)!=0) {
-                                       Pen                     penFatDark      = new Pen(ColorButtonShadow, 1);
-                                       Pen                     penFatLight     = new Pen(ColorButtonLight, 1);
+                                       Pen                     penFatDark      = new Pen(ColorControlDark, 1);
+                                       Pen                     penFatLight     = new Pen(ColorControlLightLight, 1);
                                        int                     lineWidth;
 
                                        graphics.FillPie (ResPool.GetSolidBrush (this.ColorWindow), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
@@ -5512,9 +5448,9 @@ namespace System.Windows.Forms
 
                                        /* Draw the sunken frame */
                                        if ((State & DrawFrameControlStates.Flat)!=0) {
-                                               ControlPaint.DrawBorder(graphics, rectangle, ColorButtonShadow, ButtonBorderStyle.Solid);
+                                               ControlPaint.DrawBorder(graphics, rectangle, ColorControlDark, ButtonBorderStyle.Solid);
                                        } else {
-                                               CPDrawBorder3D(graphics, rectangle, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
+                                               CPDrawBorder3D(graphics, rectangle, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl);
                                        }
 
                                        /* Make sure we've got at least a line width of 1 */
@@ -5561,35 +5497,35 @@ namespace System.Windows.Forms
                /* Generic scroll button */
                public void DrawScrollButtonPrimitive (Graphics dc, Rectangle area, ButtonState state) {
                        if ((state & ButtonState.Pushed) == ButtonState.Pushed) {
-                               dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonFace), area.X + 1,
+                               dc.FillRectangle (ResPool.GetSolidBrush (ColorControl), area.X + 1,
                                        area.Y + 1, area.Width - 2 , area.Height - 2);
 
-                               dc.DrawRectangle (ResPool.GetPen (ColorButtonShadow), area.X,
+                               dc.DrawRectangle (ResPool.GetPen (ColorControlDark), area.X,
                                        area.Y, area.Width, area.Height);
 
                                return;
                        }                       
        
-                       dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonFace), area.X, area.Y, area.Width, 1);
-                       dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonFace), area.X, area.Y, 1, area.Height);
+                       dc.FillRectangle (ResPool.GetSolidBrush (ColorControl), area.X, area.Y, area.Width, 1);
+                       dc.FillRectangle (ResPool.GetSolidBrush (ColorControl), area.X, area.Y, 1, area.Height);
 
-                       dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonHilight), area.X + 1, area.Y + 1, area.Width - 1, 1);
-                       dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonHilight), area.X + 1, area.Y + 2, 1,
+                       dc.FillRectangle (ResPool.GetSolidBrush (ColorControlLight), area.X + 1, area.Y + 1, area.Width - 1, 1);
+                       dc.FillRectangle (ResPool.GetSolidBrush (ColorControlLight), area.X + 1, area.Y + 2, 1,
                                area.Height - 4);
 
-                       dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonShadow), area.X + 1, area.Y + area.Height - 2,
+                       dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDark), area.X + 1, area.Y + area.Height - 2,
                                area.Width - 2, 1);
 
-                       dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonDkShadow), area.X, area.Y + area.Height -1,
+                       dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDarkDark), area.X, area.Y + area.Height -1,
                                area.Width , 1);
 
-                       dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonShadow), area.X + area.Width - 2,
+                       dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDark), area.X + area.Width - 2,
                                area.Y + 1, 1, area.Height -3);
 
-                       dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonDkShadow), area.X + area.Width -1,
+                       dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDarkDark), area.X + area.Width -1,
                                area.Y, 1, area.Height - 1);
 
-                       dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonFace), area.X + 2,
+                       dc.FillRectangle (ResPool.GetSolidBrush (ColorControl), area.X + 2,
                                area.Y + 2, area.Width - 4, area.Height - 4);
                        
                }
@@ -5597,17 +5533,17 @@ namespace System.Windows.Forms
                public override void CPDrawBorderStyle (Graphics dc, Rectangle area, BorderStyle border_style) {
                        switch (border_style){
                        case BorderStyle.Fixed3D:
-                               dc.DrawLine (ResPool.GetPen (ColorButtonShadow), area.X, area.Y, area.X +area.Width, area.Y);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonShadow), area.X, area.Y, area.X, area.Y + area.Height);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonHilight), area.X , area.Y + area.Height - 1, area.X + area.Width , 
+                               dc.DrawLine (ResPool.GetPen (ColorControlDark), area.X, area.Y, area.X +area.Width, area.Y);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDark), area.X, area.Y, area.X, area.Y + area.Height);
+                               dc.DrawLine (ResPool.GetPen (ColorControlLight), area.X , area.Y + area.Height - 1, area.X + area.Width , 
                                        area.Y + area.Height - 1);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonHilight), area.X + area.Width -1 , area.Y, area.X + area.Width -1, 
+                               dc.DrawLine (ResPool.GetPen (ColorControlLight), area.X + area.Width -1 , area.Y, area.X + area.Width -1, 
                                        area.Y + area.Height);
 
                                dc.DrawLine (ResPool.GetPen (ColorActiveBorder), area.X + 1, area.Bottom - 2, area.Right - 2, area.Bottom - 2);
                                dc.DrawLine (ResPool.GetPen (ColorActiveBorder), area.Right - 2, area.Top + 1, area.Right - 2, area.Bottom - 2);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), area.X + 1, area.Top + 1, area.X + 1, area.Bottom - 3);
-                               dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), area.X + 1, area.Top + 1, area.Right - 3, area.Top + 1);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), area.X + 1, area.Top + 1, area.X + 1, area.Bottom - 3);
+                               dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), area.X + 1, area.Top + 1, area.Right - 3, area.Top + 1);
                                break;
                        case BorderStyle.FixedSingle:
                                dc.DrawRectangle (ResPool.GetPen (ColorWindowFrame), area.X, area.Y, area.Width - 1, area.Height - 1);