2008-07-10 George Giolfan <georgegiolfan@yahoo.com>
authorGeorge Giolfan <ggiolfan@mono-cvs.ximian.com>
Thu, 10 Jul 2008 07:53:11 +0000 (07:53 -0000)
committerGeorge Giolfan <ggiolfan@mono-cvs.ximian.com>
Thu, 10 Jul 2008 07:53:11 +0000 (07:53 -0000)
* Application.cs: Added VisualStylesEnabled because XplatUI.ThemesEnabled
cannot be used from the ThemeEngine constructor.
* ThemeEngine.cs: Changed the XplatUI.ThemesEnabled check to
Application.VisualStylesEnabled because it does not work on X11.
* ThemeElements.cs: Changed the XplatUI.ThemesEnabled check to
Application.VisualStylesEnabled because it does not work on X11.
* GtkPlus.cs, VisualStylesGtkPlus.cs: Implemented check box
size. Extended check box painting to allow all cases.
* VisualStyleElement.cs: Added some constants.
* VisualStylesEngine.cs: Now requires environment variable
MONO_VISUAL_STYLES to be set to GtkPlus in order to select the GTK+
implementation.

svn path=/trunk/mcs/; revision=107627

mcs/class/Managed.Windows.Forms/System.Windows.Forms.Theming/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms.Theming/ThemeElements.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms.VisualStyles/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms.VisualStyles/GtkPlus.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms.VisualStyles/VisualStyleElement.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms.VisualStyles/VisualStylesEngine.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms.VisualStyles/VisualStylesGtkPlus.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeEngine.cs

index 1ec26adf6751f3aa36853f0c9da101cfac6467ef..948d8d52f618c3a44e23abb5f4843c287c018007 100644 (file)
@@ -1,3 +1,8 @@
+2008-07-10  George Giolfan  <georgegiolfan@yahoo.com>\r
+\r
+       * ThemeElements.cs: Changed the XplatUI.ThemesEnabled check to\r
+       Application.VisualStylesEnabled because it does not work on X11.\r
+\r
 2008-07-09  George Giolfan  <georgegiolfan@yahoo.com>\r
 \r
        * ThemeElements.cs: ThemeElementsVisualStyles is now selected if\r
index f2c92e03d48d8d5f22f9b5f2483593ac282ee3a9..de33265af672f004a56045b3467ed61a75fc63a7 100644 (file)
@@ -54,7 +54,7 @@ namespace System.Windows.Forms.Theming
                private static ThemeElementsDefault LoadTheme (string themeName) \r
                {\r
                        if (themeName == "visualstyles")\r
-                               if (XplatUI.ThemesEnabled)\r
+                               if (Application.VisualStylesEnabled)\r
                                        return new ThemeElementsVisualStyles ();\r
                                else\r
                                        return new ThemeElementsDefault ();\r
index 67d3e1740fed01b73200b480015299f03604a827..f31b0d5dfd09163c624810a049844211bce0f082 100644 (file)
@@ -1,3 +1,12 @@
+2008-07-10  George Giolfan  <georgegiolfan@yahoo.com>
+
+       * GtkPlus.cs, VisualStylesGtkPlus.cs: Implemented check box
+       size. Extended check box painting to allow all cases.
+       * VisualStyleElement.cs: Added some constants.
+       * VisualStylesEngine.cs: Now requires environment variable
+       MONO_VISUAL_STYLES to be set to GtkPlus in order to select the GTK+
+       implementation.
+
 2008-06-19  George Giolfan  <georgegiolfan@yahoo.com>
 
        * GtkPlus.cs: Initialize now catches DllNotFoundException from both GTK+
index 012fb41d0ba0469bbb794c63c6ee6465dc4a32b8..7b5f89aca647294f9cc749b2ebc3fedbe65f837e 100644 (file)
@@ -82,9 +82,6 @@ namespace System.Windows.Forms.VisualStyles
                GtkWidgetPointer [] widgets;
                GtkStylePointer [] styles;
                IStylePainter [] style_painters;
-               GtkStateType state_type;
-               GtkShadowType shadow_type;
-               string detail;
                protected GtkPlus ()
                {
                        widgets = new GtkWidgetPointer [WidgetTypeCount];
@@ -111,33 +108,38 @@ namespace System.Windows.Forms.VisualStyles
                        }
                }
                #region Controls
-               public void PaintCheckBox (IDeviceContext dc, Rectangle bounds, Rectangle clippingArea)
+               #region CheckBox
+               public void CheckBoxPaint (IDeviceContext dc, Rectangle bounds, Rectangle clippingArea, GtkPlusState state, GtkPlusCheckBoxValue value)
                {
-                       state_type = GtkStateType.GTK_STATE_NORMAL;
-                       shadow_type = GtkShadowType.GTK_SHADOW_ETCHED_OUT;
-                       detail = null;
-                       Paint (WidgetType.CheckBox, bounds, dc, clippingArea);
+                       Paint (WidgetType.CheckBox, bounds, dc, clippingArea, (GtkStateType)state, (GtkShadowType)value, "checkbutton");
+               }
+               public Size CheckBoxGetSize ()
+               {
+                       int indicator_size;
+                       gtk_widget_style_get (widgets [(int)WidgetType.CheckBox], "indicator-size", out indicator_size, IntPtr.Zero);
+                       return new Size (indicator_size, indicator_size);
                }
                #endregion
-               void Paint (WidgetType widget_type, Rectangle bounds, IDeviceContext dc, Rectangle clippingArea)
+               #endregion
+               void Paint (WidgetType widgetType, Rectangle bounds, IDeviceContext dc, Rectangle clippingArea, GtkStateType stateType, GtkShadowType shadowType, string detail)
                {
-                       Paint (widget_type, bounds, dc, TransparencyType.Alpha, Color.Black, DeviceContextType.Native, clippingArea);
+                       Paint (widgetType, bounds, dc, TransparencyType.Alpha, Color.Black, DeviceContextType.Native, clippingArea, stateType, shadowType, detail);
                }
-               void Paint (WidgetType widget_type, Rectangle bounds, IDeviceContext dc, TransparencyType transparencyType, Color background, DeviceContextType deviceContextType, Rectangle clippingArea)
+               void Paint (WidgetType widgetType, Rectangle bounds, IDeviceContext dc, TransparencyType transparencyType, Color background, DeviceContextType deviceContextType, Rectangle clippingArea, GtkStateType stateType, GtkShadowType shadowType, string detail)
                {
                        Rectangle painted_area = Rectangle.Intersect (bounds, clippingArea);
                        painted_area.Offset (-bounds.X, -bounds.Y);
                        if (painted_area.Width == 0 || painted_area.Height == 0)
                                return;
                        GdkDrawablePointer drawable = gdk_pixmap_new (IntPtr.Zero, bounds.Width, bounds.Height, 24);
-                       GtkStylePointer style = styles [(int)widget_type] = gtk_style_attach (styles [(int)widget_type], drawable);
+                       GtkStylePointer style = styles [(int)widgetType] = gtk_style_attach (styles [(int)widgetType], drawable);
                        GdkPixbufPointer pixbuf;
                        IntPtr pixel_data;
                        int rowstride;
                        GdkGCPointer gc = gdk_gc_new (drawable);
                        GdkColor color = new GdkColor (background);
                        gdk_gc_set_rgb_fg_color (gc, ref color);
-                       Paint (drawable, gc, bounds, widget_type, out pixbuf, out pixel_data, out rowstride, painted_area);
+                       Paint (drawable, gc, bounds, widgetType, out pixbuf, out pixel_data, out rowstride, painted_area, stateType, shadowType, detail);
                        GdkPixbufPointer white_pixbuf = IntPtr.Zero;
                        IntPtr white_pixel_data = IntPtr.Zero;
                        int white_rowstride = 0;
@@ -147,7 +149,7 @@ namespace System.Windows.Forms.VisualStyles
                                white_color.green = guint16.MaxValue;
                                white_color.blue = guint16.MaxValue;
                                gdk_gc_set_rgb_fg_color (gc, ref white_color);
-                               Paint (drawable, gc, bounds, widget_type, out white_pixbuf, out white_pixel_data, out white_rowstride, painted_area);
+                               Paint (drawable, gc, bounds, widgetType, out white_pixbuf, out white_pixel_data, out white_rowstride, painted_area, stateType, shadowType, detail);
                        }
                        g_object_unref (gc);
                        unsafe {
@@ -175,8 +177,8 @@ namespace System.Windows.Forms.VisualStyles
                                                                pixel [GdkRedOffset] == background.R &&
                                                                pixel [GdkGreenOffset] == background.G &&
                                                                pixel [GdkBlueOffset] == background.B) {
-                                                               const int AlphaFullTransparent = 0;
-                                                               pixel [BitmapAlphaOffset] = AlphaFullTransparent;
+                                                               const int AlphaFullyTransparent = 0;
+                                                               pixel [BitmapAlphaOffset] = AlphaFullyTransparent;
                                                        }
                                                        break;
                                                }
@@ -240,34 +242,34 @@ namespace System.Windows.Forms.VisualStyles
                        bitmap.Dispose ();
                        g_object_unref (pixbuf);
                }
-               void Paint (GdkDrawablePointer drawable, GdkGCPointer gc, Rectangle rectangle, WidgetType widget_type, out GdkPixbufPointer pixbuf, out IntPtr pixel_data, out int rowstride, Rectangle clippingArea)
+               void Paint (GdkDrawablePointer drawable, GdkGCPointer gc, Rectangle rectangle, WidgetType widgetType, out GdkPixbufPointer pixbuf, out IntPtr pixelData, out int rowstride, Rectangle clippingArea, GtkStateType stateType, GtkShadowType shadowType, string detail)
                {
                        gdk_draw_rectangle (drawable, gc, true, clippingArea.X, clippingArea.Y, clippingArea.Width, clippingArea.Height);
-                       style_painters [(int)widget_type].Paint (styles [(int)widget_type], drawable, state_type, shadow_type, new GdkRectangle(clippingArea), widgets [(int)widget_type], detail, 0, 0, rectangle.Width, rectangle.Height);
+                       style_painters [(int)widgetType].Paint (styles [(int)widgetType], drawable, stateType, shadowType, new GdkRectangle(clippingArea), widgets [(int)widgetType], detail, 0, 0, rectangle.Width, rectangle.Height);
                        if (
                                (pixbuf = gdk_pixbuf_new (GdkColorspace.GDK_COLORSPACE_RGB, true, 8, clippingArea.Width, clippingArea.Height)) == IntPtr.Zero ||
                                gdk_pixbuf_get_from_drawable (pixbuf, drawable, IntPtr.Zero, clippingArea.X, clippingArea.Y, 0, 0, clippingArea.Width, clippingArea.Height) == IntPtr.Zero)
                                throw new OutOfMemoryException ();
-                       pixel_data = gdk_pixbuf_get_pixels (pixbuf);
+                       pixelData = gdk_pixbuf_get_pixels (pixbuf);
                        rowstride = gdk_pixbuf_get_rowstride (pixbuf);
                }
                interface IStylePainter
                {
-                       void Paint (GtkStylePointer style, GdkWindowPointer window, GtkStateType state_type, GtkShadowType shadow_type, GdkRectangle area, GtkWidgetPointer widget, string detail, gint x, gint y, gint width, gint height);
+                       void Paint (GtkStylePointer style, GdkWindowPointer window, GtkStateType stateType, GtkShadowType shadowType, GdkRectangle area, GtkWidgetPointer widget, string detail, gint x, gint y, gint width, gint height);
                }
                #region Style painters
                class ButtonPainter : IStylePainter
                {
-                       public void Paint (GtkStylePointer style, GdkWindowPointer window, GtkStateType state_type, GtkShadowType shadow_type, GdkRectangle area, GtkWidgetPointer widget, string detail, gint x, gint y, gint width, gint height)
+                       public void Paint (GtkStylePointer style, GdkWindowPointer window, GtkStateType stateType, GtkShadowType shadowType, GdkRectangle area, GtkWidgetPointer widget, string detail, gint x, gint y, gint width, gint height)
                        {
-                               gtk_paint_box (style, window, state_type, shadow_type, ref area, widget, detail, x, y, width, height);
+                               gtk_paint_box (style, window, stateType, shadowType, ref area, widget, detail, x, y, width, height);
                        }
                }
                class CheckBoxPainter : IStylePainter
                {
-                       public void Paint (GtkStylePointer style, GdkWindowPointer window, GtkStateType state_type, GtkShadowType shadow_type, GdkRectangle area, GtkWidgetPointer widget, string detail, gint x, gint y, gint width, gint height)
+                       public void Paint (GtkStylePointer style, GdkWindowPointer window, GtkStateType stateType, GtkShadowType shadowType, GdkRectangle area, GtkWidgetPointer widget, string detail, gint x, gint y, gint width, gint height)
                        {
-                               gtk_paint_check (style, window, state_type, shadow_type, ref area, widget, detail, x, y, width,height);
+                               gtk_paint_check (style, window, stateType, shadowType, ref area, widget, detail, x, y, width,height);
                        }
                }
                #endregion
@@ -360,6 +362,8 @@ namespace System.Windows.Forms.VisualStyles
                static extern GtkStylePointer gtk_rc_get_style (GtkWidgetPointer widget);
                [DllImport (GtkLibraryName)]
                static extern GtkStylePointer gtk_style_attach (GtkStylePointer style, GdkWindowPointer window);
+               [DllImport (GtkLibraryName)]
+               static extern void gtk_widget_style_get (GtkWidgetPointer widget, string property, out int value, IntPtr nullTerminator);
                #region Widget creation
                [DllImport (GtkLibraryName)]
                static extern GtkWidgetPointer gtk_button_new ();
@@ -372,7 +376,7 @@ namespace System.Windows.Forms.VisualStyles
                [DllImport (GtkLibraryName)]
                static extern void gtk_paint_check (GtkStylePointer style, GdkWindowPointer window, GtkStateType state_type, GtkShadowType shadow_type, ref GdkRectangle area, GtkWidgetPointer widget, string detail, gint x, gint y, gint width, gint height);
                #endregion
-               enum GtkShadowType
+               internal enum GtkShadowType
                {
                        GTK_SHADOW_NONE,
                        GTK_SHADOW_IN,
@@ -399,4 +403,18 @@ namespace System.Windows.Forms.VisualStyles
                #endregion
                #endregion
        }
+       enum GtkPlusCheckBoxValue
+       {
+               Unchecked = GtkPlus.GtkShadowType.GTK_SHADOW_OUT,
+               Mixed = GtkPlus.GtkShadowType.GTK_SHADOW_ETCHED_IN,
+               Checked = GtkPlus.GtkShadowType.GTK_SHADOW_IN
+       }
+       enum GtkPlusState
+       {
+               Normal,
+               Pressed,
+               Hot,
+               Selected,
+               Disabled
+       }
 }
index 2b225bc1fb10d769ffdd842089419e19a41dac19..4853066175f648001074de3fd11d0a602e525d68 100644 (file)
@@ -143,16 +143,86 @@ namespace System.Windows.Forms.VisualStyles
                {
                        public static class CheckBox
                        {
-                               public static VisualStyleElement CheckedDisabled { get { return VisualStyleElement.CreateElement (VisualStyleElement.BUTTON, 3, 8); } }
-                               public static VisualStyleElement CheckedHot { get { return VisualStyleElement.CreateElement (VisualStyleElement.BUTTON, 3, 6); } }
-                               public static VisualStyleElement CheckedNormal { get { return VisualStyleElement.CreateElement (VisualStyleElement.BUTTON, 3, 5); } }
-                               public static VisualStyleElement CheckedPressed { get { return VisualStyleElement.CreateElement (VisualStyleElement.BUTTON, 3, 7); } }
-                               public static VisualStyleElement MixedDisabled { get { return VisualStyleElement.CreateElement (VisualStyleElement.BUTTON, 3, 12); } }
-                               public static VisualStyleElement MixedHot { get { return VisualStyleElement.CreateElement (VisualStyleElement.BUTTON, 3, 10); } }
-                               public static VisualStyleElement MixedNormal { get { return VisualStyleElement.CreateElement (VisualStyleElement.BUTTON, 3, 9); } }
-                               public static VisualStyleElement MixedPressed { get { return VisualStyleElement.CreateElement (VisualStyleElement.BUTTON, 3, 11); } }
-                               public static VisualStyleElement UncheckedDisabled { get { return VisualStyleElement.CreateElement (VisualStyleElement.BUTTON, 3, 4); } }
-                               public static VisualStyleElement UncheckedHot { get { return VisualStyleElement.CreateElement (VisualStyleElement.BUTTON, 3, 2); } }
+                               public static VisualStyleElement CheckedDisabled {
+                                       get {
+                                               return VisualStyleElement.CreateElement (
+                                                       BUTTON,
+                                                       (int)BUTTONPARTS.BP_CHECKBOX,
+                                                       (int)CHECKBOXSTATES.CBS_CHECKEDDISABLED);
+                                       }
+                               }
+                               public static VisualStyleElement CheckedHot {
+                                       get {
+                                               return VisualStyleElement.CreateElement (
+                                                       BUTTON,
+                                                       (int)BUTTONPARTS.BP_CHECKBOX,
+                                                       (int)CHECKBOXSTATES.CBS_CHECKEDHOT);
+                                       }
+                               }
+                               public static VisualStyleElement CheckedNormal {
+                                       get {
+                                               return VisualStyleElement.CreateElement (
+                                                       BUTTON,
+                                                       (int)BUTTONPARTS.BP_CHECKBOX,
+                                                       (int)CHECKBOXSTATES.CBS_CHECKEDNORMAL);
+                                       }
+                               }
+                               public static VisualStyleElement CheckedPressed {
+                                       get {
+                                               return VisualStyleElement.CreateElement (
+                                                       BUTTON,
+                                                       (int)BUTTONPARTS.BP_CHECKBOX,
+                                                       (int)CHECKBOXSTATES.CBS_CHECKEDPRESSED);
+                                       }
+                               }
+                               public static VisualStyleElement MixedDisabled {
+                                       get {
+                                               return VisualStyleElement.CreateElement (
+                                                       BUTTON,
+                                                       (int)BUTTONPARTS.BP_CHECKBOX,
+                                                       (int)CHECKBOXSTATES.CBS_MIXEDDISABLED);
+                                       }
+                               }
+                               public static VisualStyleElement MixedHot {
+                                       get {
+                                               return VisualStyleElement.CreateElement (
+                                                       BUTTON,
+                                                       (int)BUTTONPARTS.BP_CHECKBOX,
+                                                       (int)CHECKBOXSTATES.CBS_MIXEDHOT);
+                                       }
+                               }
+                               public static VisualStyleElement MixedNormal {
+                                       get {
+                                               return VisualStyleElement.CreateElement (
+                                                       BUTTON,
+                                                       (int)BUTTONPARTS.BP_CHECKBOX,
+                                                       (int)CHECKBOXSTATES.CBS_MIXEDNORMAL);
+                                       }
+                               }
+                               public static VisualStyleElement MixedPressed {
+                                       get {
+                                               return VisualStyleElement.CreateElement (
+                                                       BUTTON,
+                                                       (int)BUTTONPARTS.BP_CHECKBOX,
+                                                       (int)CHECKBOXSTATES.CBS_MIXEDPRESSED);
+                                       }
+                               }
+                               public static VisualStyleElement UncheckedDisabled {
+                                       get {
+                                               return VisualStyleElement.CreateElement (
+                                                       BUTTON,
+                                                       (int)BUTTONPARTS.BP_CHECKBOX,
+                                                       (int)CHECKBOXSTATES.CBS_UNCHECKEDDISABLED);
+                                       }
+                               }
+                               public static VisualStyleElement UncheckedHot {
+                                       get {
+                                               return VisualStyleElement.CreateElement (
+                                                       BUTTON,
+                                                       (int)BUTTONPARTS.BP_CHECKBOX,
+                                                       (int)CHECKBOXSTATES.CBS_UNCHECKEDHOT);
+                                       }
+                               }
                                public static VisualStyleElement UncheckedNormal {
                                        get {
                                                return VisualStyleElement.CreateElement (
@@ -161,7 +231,14 @@ namespace System.Windows.Forms.VisualStyles
                                                        (int)CHECKBOXSTATES.CBS_UNCHECKEDNORMAL);
                                        }
                                }
-                               public static VisualStyleElement UncheckedPressed { get { return VisualStyleElement.CreateElement (VisualStyleElement.BUTTON, 3, 3); } }
+                               public static VisualStyleElement UncheckedPressed {
+                                       get {
+                                               return VisualStyleElement.CreateElement (
+                                                       BUTTON,
+                                                       (int)BUTTONPARTS.BP_CHECKBOX,
+                                                       (int)CHECKBOXSTATES.CBS_UNCHECKEDPRESSED);
+                                       }
+                               }
                        }
                        public static class GroupBox
                        {
@@ -1346,6 +1423,17 @@ namespace System.Windows.Forms.VisualStyles
        }
        enum CHECKBOXSTATES
        {
-               CBS_UNCHECKEDNORMAL = 1
+               CBS_UNCHECKEDNORMAL = 1,
+               CBS_UNCHECKEDHOT,
+               CBS_UNCHECKEDPRESSED,
+               CBS_UNCHECKEDDISABLED,
+               CBS_CHECKEDNORMAL,
+               CBS_CHECKEDHOT,
+               CBS_CHECKEDPRESSED,
+               CBS_CHECKEDDISABLED,
+               CBS_MIXEDNORMAL,
+               CBS_MIXEDHOT,
+               CBS_MIXEDPRESSED,
+               CBS_MIXEDDISABLED
        }
 }
index 9371985cce25b76b6b44e159663e884665e57950..e96794c96f1b8c07df7a2d30135e18b9e4a1e3c6 100644 (file)
@@ -36,9 +36,12 @@ namespace System.Windows.Forms.VisualStyles
                }
                static IVisualStyles Initialize ()
                {
+                       string environment_variable = Environment.GetEnvironmentVariable("MONO_VISUAL_STYLES");
+                       if (environment_variable != null)
+                               environment_variable = environment_variable.ToLower ();
                        if (
 #if !VISUAL_STYLES_USE_GTKPLUS_ON_WINDOWS
-                               !VisualStylesNative.IsSupported () &&
+                               environment_variable == "gtkplus" &&
 #endif
                                VisualStylesGtkPlus.Initialize ())
                                return new VisualStylesGtkPlus ();
index e29f93f13144521b6464e09360d586ca97eba47e..4f1b50169414de4967bef5281775e7f28772c6e1 100644 (file)
@@ -71,15 +71,67 @@ namespace System.Windows.Forms.VisualStyles
                {
                        return UxThemeDrawThemeBackground (hTheme, dc, iPartId, iStateId, bounds, bounds);
                }
-               static bool DrawBackground (ThemeHandle themHandle, IDeviceContext dc, int part, int state, Rectangle bounds, Rectangle clipRectangle) {
-                       switch (themHandle) {
+               static bool DrawBackground (ThemeHandle themeHandle, IDeviceContext dc, int part, int state, Rectangle bounds, Rectangle clipRectangle) {
+                       switch (themeHandle) {
                        case ThemeHandle.BUTTON:
                                switch ((BUTTONPARTS)part) {
                                case BUTTONPARTS.BP_CHECKBOX:
+                                       GtkPlusState gtk_plus_state;
+                                       GtkPlusCheckBoxValue gtk_plus_check_box_value;
                                        switch ((CHECKBOXSTATES)state) {
-                                       case CHECKBOXSTATES.CBS_UNCHECKEDNORMAL: GtkPlus.PaintCheckBox (dc, bounds, clipRectangle); return true;
-                                       default: return false;
+                                       case CHECKBOXSTATES.CBS_UNCHECKEDNORMAL:
+                                               gtk_plus_state = GtkPlusState.Normal;
+                                               gtk_plus_check_box_value = GtkPlusCheckBoxValue.Unchecked;
+                                               break;
+                                       case CHECKBOXSTATES.CBS_UNCHECKEDPRESSED:
+                                               gtk_plus_state = GtkPlusState.Pressed;
+                                               gtk_plus_check_box_value = GtkPlusCheckBoxValue.Unchecked;
+                                               break;
+                                       case CHECKBOXSTATES.CBS_UNCHECKEDHOT:
+                                               gtk_plus_state = GtkPlusState.Hot;
+                                               gtk_plus_check_box_value = GtkPlusCheckBoxValue.Unchecked;
+                                               break;
+                                       case CHECKBOXSTATES.CBS_UNCHECKEDDISABLED:
+                                               gtk_plus_state = GtkPlusState.Disabled;
+                                               gtk_plus_check_box_value = GtkPlusCheckBoxValue.Unchecked;
+                                               break;
+                                       case CHECKBOXSTATES.CBS_CHECKEDNORMAL:
+                                               gtk_plus_state = GtkPlusState.Normal;
+                                               gtk_plus_check_box_value = GtkPlusCheckBoxValue.Checked;
+                                               break;
+                                       case CHECKBOXSTATES.CBS_CHECKEDPRESSED:
+                                               gtk_plus_state = GtkPlusState.Pressed;
+                                               gtk_plus_check_box_value = GtkPlusCheckBoxValue.Checked;
+                                               break;
+                                       case CHECKBOXSTATES.CBS_CHECKEDHOT:
+                                               gtk_plus_state = GtkPlusState.Hot;
+                                               gtk_plus_check_box_value = GtkPlusCheckBoxValue.Checked;
+                                               break;
+                                       case CHECKBOXSTATES.CBS_CHECKEDDISABLED:
+                                               gtk_plus_state = GtkPlusState.Disabled;
+                                               gtk_plus_check_box_value = GtkPlusCheckBoxValue.Checked;
+                                               break;
+                                       case CHECKBOXSTATES.CBS_MIXEDNORMAL:
+                                               gtk_plus_state = GtkPlusState.Normal;
+                                               gtk_plus_check_box_value = GtkPlusCheckBoxValue.Mixed;
+                                               break;
+                                       case CHECKBOXSTATES.CBS_MIXEDPRESSED:
+                                               gtk_plus_state = GtkPlusState.Pressed;
+                                               gtk_plus_check_box_value = GtkPlusCheckBoxValue.Mixed;
+                                               break;
+                                       case CHECKBOXSTATES.CBS_MIXEDHOT:
+                                               gtk_plus_state = GtkPlusState.Hot;
+                                               gtk_plus_check_box_value = GtkPlusCheckBoxValue.Mixed;
+                                               break;
+                                       case CHECKBOXSTATES.CBS_MIXEDDISABLED:
+                                               gtk_plus_state = GtkPlusState.Disabled;
+                                               gtk_plus_check_box_value = GtkPlusCheckBoxValue.Mixed;
+                                               break;
+                                       default:
+                                               return false;
                                        }
+                                       GtkPlus.CheckBoxPaint (dc, bounds, clipRectangle, gtk_plus_state, gtk_plus_check_box_value);
+                                       return true;
                                default: return false;
                                }
                        default: return false;
@@ -141,13 +193,25 @@ namespace System.Windows.Forms.VisualStyles
                }
                public int UxThemeGetThemePartSize (IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, Rectangle bounds, ThemeSizeType type, out Size result)
                {
-                       result = Size.Empty;
-                       return (int)S.S_FALSE;
+                       return (int)(GetPartSize ((ThemeHandle)(int)hTheme, dc, iPartId, iStateId, bounds, true, type, out result) ? S.S_OK : S.S_FALSE);
                }
                public int UxThemeGetThemePartSize (IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, ThemeSizeType type, out Size result)
                {
+                       return (int)(GetPartSize ((ThemeHandle)(int)hTheme, dc, iPartId, iStateId, Rectangle.Empty, false, type, out result) ? S.S_OK : S.S_FALSE);
+               }
+               bool GetPartSize (ThemeHandle themeHandle, IDeviceContext dc, int part, int state, Rectangle bounds, bool rectangleSpecified, ThemeSizeType type, out Size result)
+               {
+                       switch (themeHandle) {
+                       case ThemeHandle.BUTTON:
+                               switch ((BUTTONPARTS)part) {
+                               case BUTTONPARTS.BP_CHECKBOX:
+                                       result = GtkPlus.CheckBoxGetSize ();
+                                       return true;
+                               }
+                               break;
+                       }
                        result = Size.Empty;
-                       return (int)S.S_FALSE;
+                       return false;
                }
                public int UxThemeGetThemePosition (IntPtr hTheme, int iPartId, int iStateId, PointProperty prop, out Point result)
                {
index 1f0810f4d2fb11bf05fca419f445bd146ea2e672..c5e673df5f89e743367a0331779a58f0b18be78c 100644 (file)
@@ -153,6 +153,7 @@ namespace System.Windows.Forms
                private static ToolStrip keyboard_capture;
 #endif
                private static VisualStyleState visual_style_state = VisualStyleState.ClientAndNonClientAreasEnabled;
+               static bool visual_styles_enabled;
 
                private Application ()
                {
@@ -486,6 +487,7 @@ namespace System.Windows.Forms
 
                public static void EnableVisualStyles ()
                {
+                       visual_styles_enabled = true;
                        XplatUI.EnableThemes ();
                }
 
@@ -1049,6 +1051,10 @@ namespace System.Windows.Forms
                        set { keyboard_capture = value; }
                }
 #endif
+
+               internal static bool VisualStylesEnabled {
+                       get { return visual_styles_enabled; }
+               }
                #endregion
                
                #region Internal Methods
index 9b9f039ddb8df9ad309d0202cbd4c3457cb9a4fd..85f578f58c4ef8ed9f353eb7fe9e82b0b620f395 100644 (file)
@@ -1,3 +1,10 @@
+2008-07-10  George Giolfan  <georgegiolfan@yahoo.com>
+
+       * Application.cs: Added VisualStylesEnabled because XplatUI.ThemesEnabled
+       cannot be used from the ThemeEngine constructor.
+       * ThemeEngine.cs: Changed the XplatUI.ThemesEnabled check to
+       Application.VisualStylesEnabled because it does not work on X11.
+
 2008-07-09  Jonathan Pobst  <monkey@jpobst.com>
 
        * StatusBar.cs: Apply patch from Andy Hume to remove lazy instantiation
index c750d277787f57e67c83aac42e3f009663db6207..71341b6d331684ca1f3ccc98e05383858846ed2e 100644 (file)
@@ -51,7 +51,7 @@ namespace System.Windows.Forms
                                theme = new ThemeNice ();
                        } else if ( theme_var == "clearlooks" ) {
                                theme = new ThemeClearlooks ();
-                       } else if (theme_var == "visualstyles" && XplatUI.ThemesEnabled) {
+                       } else if (theme_var == "visualstyles" && Application.VisualStylesEnabled) {
                                theme = new ThemeVisualStyles ();
                        } else {
                                theme = new ThemeWin32Classic ();