Merge branch 'bugfix-main-thread-root'
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms.Theming / VisualStyles / TabControlPainter.cs
index 7b0cfe067c4a69cbb04b3d9e167bd8481db2111b..45f509b4b176792132e964fdbdb7e8a55c8291b1 100644 (file)
@@ -29,7 +29,8 @@ namespace System.Windows.Forms.Theming.VisualStyles
        class TabControlPainter : Default.TabControlPainter
        {
                static bool ShouldPaint (TabControl tabControl) {
-                       return tabControl.Alignment == TabAlignment.Top &&
+                       return ThemeVisualStyles.RenderClientAreas &&
+                               tabControl.Alignment == TabAlignment.Top &&
                                tabControl.DrawMode == TabDrawMode.Normal;
                }
                protected override void DrawBackground (Graphics dc, Rectangle area, TabControl tab)
@@ -57,8 +58,8 @@ namespace System.Windows.Forms.Theming.VisualStyles
                                return base.DrawTab (dc, page, tab, bounds, is_selected);
                        new VisualStyleRenderer (element).DrawBackground (dc, bounds);
                        bounds.Inflate (
-                               -(FocusRectSpacing.X + BorderThickness.X),
-                               -(FocusRectSpacing.Y + BorderThickness.Y));
+                               -(tab.Padding.X),
+                               -(tab.Padding.Y));
                        Rectangle text_area = bounds;
                        if (tab.ImageList != null && page.ImageIndex >= 0 && page.ImageIndex < tab.ImageList.Images.Count) {
                                int image_y = bounds.Y + (bounds.Height - tab.ImageList.ImageSize.Height) / 2;
@@ -68,8 +69,8 @@ namespace System.Windows.Forms.Theming.VisualStyles
                                text_area.Width -= image_occupied_space;
                        }
                        if (page.Text != null)
-                               dc.DrawString (page.Text, page.Font, SystemBrushes.ControlText, text_area, DefaultFormatting);
-                       if (tab.Focused && is_selected)
+                               dc.DrawString (page.Text, tab.Font, SystemBrushes.ControlText, text_area, DefaultFormatting);
+                       if (tab.Focused && is_selected && tab.ShowFocusCues)
                                ControlPaint.DrawFocusRectangle (dc, bounds);
                        return 0;
                }
@@ -197,5 +198,68 @@ namespace System.Windows.Forms.Theming.VisualStyles
                                return base.HasHotElementStyles (tabControl);
                        return true;
                }
+               protected override void DrawScrollButton (Graphics dc, Rectangle bounds, Rectangle clippingArea, ScrollButton button, PushButtonState state)
+               {
+                       if (!ThemeVisualStyles.RenderClientAreas) {
+                               base.DrawScrollButton (dc, bounds, clippingArea, button, state);
+                               return;
+                       }
+                       VisualStyleElement element;
+                       if (button == ScrollButton.Left)
+                               switch (state) {
+                               case PushButtonState.Hot:
+                                       element = VisualStyleElement.Spin.DownHorizontal.Hot;
+                                       break;
+                               case PushButtonState.Pressed:
+                                       element = VisualStyleElement.Spin.DownHorizontal.Pressed;
+                                       break;
+                               default:
+                                       element = VisualStyleElement.Spin.DownHorizontal.Normal;
+                                       break;
+                               }
+                       else
+                               switch (state) {
+                               case PushButtonState.Hot:
+                                       element = VisualStyleElement.Spin.UpHorizontal.Hot;
+                                       break;
+                               case PushButtonState.Pressed:
+                                       element = VisualStyleElement.Spin.UpHorizontal.Pressed;
+                                       break;
+                               default:
+                                       element = VisualStyleElement.Spin.UpHorizontal.Normal;
+                                       break;
+                               }
+                       if (!VisualStyleRenderer.IsElementDefined (element)) {
+                               if (button == ScrollButton.Left)
+                                       switch (state) {
+                                       case PushButtonState.Hot:
+                                               element = VisualStyleElement.ScrollBar.ArrowButton.LeftHot;
+                                               break;
+                                       case PushButtonState.Pressed:
+                                               element = VisualStyleElement.ScrollBar.ArrowButton.LeftPressed;
+                                               break;
+                                       default:
+                                               element = VisualStyleElement.ScrollBar.ArrowButton.LeftNormal;
+                                               break;
+                                       }
+                               else
+                                       switch (state) {
+                                       case PushButtonState.Hot:
+                                               element = VisualStyleElement.ScrollBar.ArrowButton.RightHot;
+                                               break;
+                                       case PushButtonState.Pressed:
+                                               element = VisualStyleElement.ScrollBar.ArrowButton.RightPressed;
+                                               break;
+                                       default:
+                                               element = VisualStyleElement.ScrollBar.ArrowButton.RightNormal;
+                                               break;
+                                       }
+                               if (!VisualStyleRenderer.IsElementDefined (element)) {
+                                       base.DrawScrollButton (dc, bounds, clippingArea, button, state);
+                                       return;
+                               }
+                       }
+                       new VisualStyleRenderer (element).DrawBackground (dc, bounds, clippingArea);
+               }
        }
 }