/// <summary> /// Refreshes this thread's theme handle cache. /// </summary> private static void RefreshCache() { ThemeHandle?tHandle = null; if (t_themeHandles != null) { string[] classNames = new string[t_themeHandles.Keys.Count]; t_themeHandles.Keys.CopyTo(classNames, 0); foreach (string className in classNames) { tHandle = (ThemeHandle?)t_themeHandles[className]; if (tHandle != null) { tHandle.Dispose(); } // We don't call IsSupported here, since that could cause RefreshCache to be called again, // leading to stack overflow. if (AreClientAreaVisualStylesSupported) { tHandle = ThemeHandle.Create(className, false); if (tHandle != null) { t_themeHandles[className] = tHandle; } } } } }
internal Size GetPartSize(IDeviceContext dc, ThemeSizeType type, IntPtr hWnd) { if (dc == null) { throw new ArgumentNullException(nameof(dc)); } // valid values are 0x0 to 0x2 if (!ClientUtils.IsEnumValid(type, (int)type, (int)ThemeSizeType.Minimum, (int)ThemeSizeType.Draw)) { throw new InvalidEnumArgumentException(nameof(type), (int)type, typeof(ThemeSizeType)); } NativeMethods.SIZE size = new NativeMethods.SIZE(); using (WindowsGraphicsWrapper wgr = new WindowsGraphicsWrapper(dc, AllGraphicsProperties)) { HandleRef hdc = new HandleRef(wgr, wgr.WindowsGraphics.DeviceContext.Hdc); if (DpiHelper.IsPerMonitorV2Awareness && (IntPtr.Zero != hWnd)) { using (ThemeHandle hTheme = ThemeHandle.Create(_class, true, new HandleRef(null, hWnd))) { lastHResult = SafeNativeMethods.GetThemePartSize(new HandleRef(this, hTheme.NativeHandle), hdc, part, state, null, type, size); } } else { lastHResult = SafeNativeMethods.GetThemePartSize(new HandleRef(this, Handle), hdc, part, state, null, type, size); } } return(new Size(size.cx, size.cy)); }
private static IntPtr GetHandle(string className, bool throwExceptionOnFail) { ThemeHandle handle; if (themeHandles == null) { CreateThemeHandleHashtable(); } if (threadCacheVersion != globalCacheVersion) { RefreshCache(); threadCacheVersion = globalCacheVersion; } if (!themeHandles.Contains(className)) { handle = ThemeHandle.Create(className, throwExceptionOnFail); if (handle == null) { return(IntPtr.Zero); } themeHandles.Add(className, handle); } else { handle = (ThemeHandle)themeHandles[className]; } return(handle.NativeHandle); }
internal void DrawBackground(IDeviceContext dc, Rectangle bounds, Rectangle clipRectangle, IntPtr hWnd) { if (dc == null) { throw new ArgumentNullException(nameof(dc)); } if (bounds.Width < 0 || bounds.Height < 0) { return; } if (clipRectangle.Width < 0 || clipRectangle.Height < 0) { return; } using (WindowsGraphicsWrapper wgr = new WindowsGraphicsWrapper(dc, AllGraphicsProperties)) { HandleRef hdc = new HandleRef(wgr, wgr.WindowsGraphics.DeviceContext.Hdc); if (IntPtr.Zero != hWnd) { using (ThemeHandle hTheme = ThemeHandle.Create(_class, true, new HandleRef(null, hWnd))) { lastHResult = SafeNativeMethods.DrawThemeBackground(new HandleRef(this, hTheme.NativeHandle), hdc, part, state, new NativeMethods.COMRECT(bounds), new NativeMethods.COMRECT(clipRectangle)); } } else { lastHResult = SafeNativeMethods.DrawThemeBackground(new HandleRef(this, Handle), hdc, part, state, new NativeMethods.COMRECT(bounds), new NativeMethods.COMRECT(clipRectangle)); } } }
/// <summary> /// Retrieves a IntPtr theme handle for the given class from the themeHandle cache. If its not /// present in the cache, it creates a new ThemeHandle object and stores it there. /// </summary> private static IntPtr GetHandle(string className, bool throwExceptionOnFail) { if (t_themeHandles == null) { CreateThemeHandleHashtable(); } if (t_threadCacheVersion != s_globalCacheVersion) { RefreshCache(); t_threadCacheVersion = s_globalCacheVersion; } if (!t_themeHandles !.Contains(className)) { // See if it is already in cache ThemeHandle?tHandle = ThemeHandle.Create(className, throwExceptionOnFail); if (tHandle == null) { return(IntPtr.Zero); } t_themeHandles.Add(className, tHandle); return(tHandle.Handle); } return(((ThemeHandle)t_themeHandles[className] !).Handle); }
internal unsafe Size GetPartSize(IDeviceContext dc, ThemeSizeType type, IntPtr hWnd) { if (dc == null) { throw new ArgumentNullException(nameof(dc)); } // valid values are 0x0 to 0x2 if (!ClientUtils.IsEnumValid(type, (int)type, (int)ThemeSizeType.Minimum, (int)ThemeSizeType.Draw)) { throw new InvalidEnumArgumentException(nameof(type), (int)type, typeof(ThemeSizeType)); } using var wgr = new WindowsGraphicsWrapper(dc, AllGraphicsProperties); var hdc = new HandleRef(wgr, wgr.WindowsGraphics.DeviceContext.Hdc); if (DpiHelper.IsPerMonitorV2Awareness && hWnd != IntPtr.Zero) { using (ThemeHandle hTheme = ThemeHandle.Create(_class, true, hWnd) !) { lastHResult = GetThemePartSize(new HandleRef(this, hTheme.Handle), hdc, part, state, null, type, out Size dpiSize); return(dpiSize); } } lastHResult = GetThemePartSize(this, hdc, part, state, null, type, out Size size); return(size); }
internal unsafe void DrawBackground(IDeviceContext dc, Rectangle bounds, Rectangle clipRectangle, IntPtr hWnd) { if (dc == null) { throw new ArgumentNullException(nameof(dc)); } if (bounds.Width < 0 || bounds.Height < 0) { return; } if (clipRectangle.Width < 0 || clipRectangle.Height < 0) { return; } using (WindowsGraphicsWrapper wgr = new WindowsGraphicsWrapper(dc, AllGraphicsProperties)) { HandleRef hdc = new HandleRef(wgr, wgr.WindowsGraphics.DeviceContext.Hdc); if (IntPtr.Zero != hWnd) { using (ThemeHandle hTheme = ThemeHandle.Create(_class, true, hWnd) !) { RECT rect = bounds; RECT clipRect = clipRectangle; lastHResult = UxTheme.DrawThemeBackground(hTheme, hdc, part, state, ref rect, &clipRect); } } else { RECT rect = bounds; RECT clipRect = clipRectangle; lastHResult = UxTheme.DrawThemeBackground(this, hdc, part, state, ref rect, &clipRect); } } }
private static void RefreshCache() { ThemeHandle handle = null; if (themeHandles != null) { string[] array = new string[themeHandles.Keys.Count]; themeHandles.Keys.CopyTo(array, 0); bool flag = VisualStyleInformation.IsEnabledByUser && ((Application.VisualStyleState == VisualStyleState.ClientAreaEnabled) || (Application.VisualStyleState == VisualStyleState.ClientAndNonClientAreasEnabled)); foreach (string str in array) { handle = (ThemeHandle)themeHandles[str]; if (handle != null) { handle.Dispose(); } if (flag) { handle = ThemeHandle.Create(str, false); if (handle != null) { themeHandles[str] = handle; } } } } }
internal static bool IsCombinationDefined(string className, int part) { bool returnVal = false; if (!IsSupported) { if (!VisualStyleInformation.IsEnabledByUser) { throw new InvalidOperationException(SR.VisualStyleNotActive); } else { throw new InvalidOperationException(SR.VisualStylesDisabledInClientArea); } } if (className == null) { throw new ArgumentNullException(nameof(className)); } IntPtr hTheme = GetHandle(className, false); if (hTheme != IntPtr.Zero) { // IsThemePartDefined doesn't work for part = 0, although there are valid parts numbered 0. We // allow these explicitly here. if (part == 0) { returnVal = true; } else { returnVal = SafeNativeMethods.IsThemePartDefined(new HandleRef(null, hTheme), part, 0); } } //if the combo isn't defined, check the validity of our theme handle cache if (!returnVal) { using (ThemeHandle tHandle = ThemeHandle.Create(className, false)) { if (tHandle != null) { returnVal = SafeNativeMethods.IsThemePartDefined(new HandleRef(null, tHandle.NativeHandle), part, 0); } //if we did, in fact get a new correct theme handle, our cache is out of date -- update it now. if (returnVal) { RefreshCache(); } } } return(returnVal); }
internal static bool IsCombinationDefined(string className, int part) { bool result = false; if (!IsSupported) { throw new InvalidOperationException(VisualStyleInformation.IsEnabledByUser ? SR.VisualStylesDisabledInClientArea : SR.VisualStyleNotActive); } IntPtr hTheme = GetHandle(className, false); if (hTheme != IntPtr.Zero) { // IsThemePartDefined doesn't work for part = 0, although there are valid parts numbered 0. We // allow these explicitly here. if (part == 0) { result = true; } else { result = IsThemePartDefined(hTheme, part, 0).IsTrue(); } } // If the combo isn't defined, check the validity of our theme handle cache. if (!result) { using ThemeHandle? handle = ThemeHandle.Create(className, false); if (handle is not null) { result = IsThemePartDefined(handle, part, 0).IsTrue(); } // If we did, in fact get a new correct theme handle, our cache is out of date -- update it now. if (result) { RefreshCache(); } } return(result); }
private static bool IsCombinationDefined(string className, int part) { bool flag = false; if (!IsSupported) { if (!VisualStyleInformation.IsEnabledByUser) { throw new InvalidOperationException(System.Windows.Forms.SR.GetString("VisualStyleNotActive")); } throw new InvalidOperationException(System.Windows.Forms.SR.GetString("VisualStylesDisabledInClientArea")); } if (className == null) { throw new ArgumentNullException("className"); } IntPtr ptr = GetHandle(className, false); if (ptr != IntPtr.Zero) { if (part == 0) { flag = true; } else { flag = System.Windows.Forms.SafeNativeMethods.IsThemePartDefined(new HandleRef(null, ptr), part, 0); } } if (!flag) { using (ThemeHandle handle = ThemeHandle.Create(className, false)) { if (handle != null) { flag = System.Windows.Forms.SafeNativeMethods.IsThemePartDefined(new HandleRef(null, handle.NativeHandle), part, 0); } if (flag) { RefreshCache(); } } } return(flag); }
internal unsafe Size GetPartSize(Gdi32.HDC dc, ThemeSizeType type, IntPtr hWnd = default) { // Valid values are 0x0 to 0x2 if (!ClientUtils.IsEnumValid(type, (int)type, (int)ThemeSizeType.Minimum, (int)ThemeSizeType.Draw)) { throw new InvalidEnumArgumentException(nameof(type), (int)type, typeof(ThemeSizeType)); } if (DpiHelper.IsPerMonitorV2Awareness && hWnd != IntPtr.Zero) { using ThemeHandle hTheme = ThemeHandle.Create(Class, true, hWnd) !; _lastHResult = GetThemePartSize(hTheme, dc, Part, State, null, type, out Size dpiSize); return(dpiSize); } _lastHResult = GetThemePartSize(this, dc, Part, State, null, type, out Size size); return(size); }
internal unsafe void DrawBackground(Gdi32.HDC dc, Rectangle bounds, IntPtr hWnd) { if (bounds.Width < 0 || bounds.Height < 0) { return; } if (IntPtr.Zero != hWnd) { using ThemeHandle hTheme = ThemeHandle.Create(Class, true, hWnd) !; RECT rect = bounds; _lastHResult = DrawThemeBackground(hTheme, dc, Part, State, ref rect, null); } else { RECT rect = bounds; _lastHResult = DrawThemeBackground(this, dc, Part, State, ref rect, null); } }
bool DrawBackground (ThemeHandle themeHandle, IDeviceContext dc, int part, int state, Rectangle bounds, Rectangle clipRectangle, Rectangle excludedArea) { GtkPlusState gtk_plus_state; GtkPlusToggleButtonValue gtk_plus_toggle_button_value; switch (themeHandle) { #region BUTTON case ThemeHandle.BUTTON: switch ((BUTTONPARTS)part) { #region BP_PUSHBUTTON case BUTTONPARTS.BP_PUSHBUTTON: switch ((PUSHBUTTONSTATES)state) { case PUSHBUTTONSTATES.PBS_NORMAL: gtk_plus_state = GtkPlusState.Normal; break; case PUSHBUTTONSTATES.PBS_HOT: gtk_plus_state = GtkPlusState.Hot; break; case PUSHBUTTONSTATES.PBS_PRESSED: gtk_plus_state = GtkPlusState.Pressed; break; case PUSHBUTTONSTATES.PBS_DISABLED: gtk_plus_state = GtkPlusState.Disabled; break; case PUSHBUTTONSTATES.PBS_DEFAULTED: gtk_plus_state = GtkPlusState.Normal; break; default: return false; } GtkPlus.ButtonPaint (dc, bounds, clipRectangle, (PUSHBUTTONSTATES)state == PUSHBUTTONSTATES.PBS_DEFAULTED, gtk_plus_state); return true; #endregion #region BP_RADIOBUTTON case BUTTONPARTS.BP_RADIOBUTTON: switch ((RADIOBUTTONSTATES)state) { case RADIOBUTTONSTATES.RBS_UNCHECKEDNORMAL: gtk_plus_state = GtkPlusState.Normal; gtk_plus_toggle_button_value = GtkPlusToggleButtonValue.Unchecked; break; case RADIOBUTTONSTATES.RBS_UNCHECKEDPRESSED: gtk_plus_state = GtkPlusState.Pressed; gtk_plus_toggle_button_value = GtkPlusToggleButtonValue.Unchecked; break; case RADIOBUTTONSTATES.RBS_UNCHECKEDHOT: gtk_plus_state = GtkPlusState.Hot; gtk_plus_toggle_button_value = GtkPlusToggleButtonValue.Unchecked; break; case RADIOBUTTONSTATES.RBS_UNCHECKEDDISABLED: gtk_plus_state = GtkPlusState.Disabled; gtk_plus_toggle_button_value = GtkPlusToggleButtonValue.Unchecked; break; case RADIOBUTTONSTATES.RBS_CHECKEDNORMAL: gtk_plus_state = GtkPlusState.Normal; gtk_plus_toggle_button_value = GtkPlusToggleButtonValue.Checked; break; case RADIOBUTTONSTATES.RBS_CHECKEDPRESSED: gtk_plus_state = GtkPlusState.Pressed; gtk_plus_toggle_button_value = GtkPlusToggleButtonValue.Checked; break; case RADIOBUTTONSTATES.RBS_CHECKEDHOT: gtk_plus_state = GtkPlusState.Hot; gtk_plus_toggle_button_value = GtkPlusToggleButtonValue.Checked; break; case RADIOBUTTONSTATES.RBS_CHECKEDDISABLED: gtk_plus_state = GtkPlusState.Disabled; gtk_plus_toggle_button_value = GtkPlusToggleButtonValue.Checked; break; default: return false; } GtkPlus.RadioButtonPaint (dc, bounds, clipRectangle, gtk_plus_state, gtk_plus_toggle_button_value); return true; #endregion #region BP_CHECKBOX case BUTTONPARTS.BP_CHECKBOX: switch ((CHECKBOXSTATES)state) { case CHECKBOXSTATES.CBS_UNCHECKEDNORMAL: gtk_plus_state = GtkPlusState.Normal; gtk_plus_toggle_button_value = GtkPlusToggleButtonValue.Unchecked; break; case CHECKBOXSTATES.CBS_UNCHECKEDPRESSED: gtk_plus_state = GtkPlusState.Pressed; gtk_plus_toggle_button_value = GtkPlusToggleButtonValue.Unchecked; break; case CHECKBOXSTATES.CBS_UNCHECKEDHOT: gtk_plus_state = GtkPlusState.Hot; gtk_plus_toggle_button_value = GtkPlusToggleButtonValue.Unchecked; break; case CHECKBOXSTATES.CBS_UNCHECKEDDISABLED: gtk_plus_state = GtkPlusState.Disabled; gtk_plus_toggle_button_value = GtkPlusToggleButtonValue.Unchecked; break; case CHECKBOXSTATES.CBS_CHECKEDNORMAL: gtk_plus_state = GtkPlusState.Normal; gtk_plus_toggle_button_value = GtkPlusToggleButtonValue.Checked; break; case CHECKBOXSTATES.CBS_CHECKEDPRESSED: gtk_plus_state = GtkPlusState.Pressed; gtk_plus_toggle_button_value = GtkPlusToggleButtonValue.Checked; break; case CHECKBOXSTATES.CBS_CHECKEDHOT: gtk_plus_state = GtkPlusState.Hot; gtk_plus_toggle_button_value = GtkPlusToggleButtonValue.Checked; break; case CHECKBOXSTATES.CBS_CHECKEDDISABLED: gtk_plus_state = GtkPlusState.Disabled; gtk_plus_toggle_button_value = GtkPlusToggleButtonValue.Checked; break; case CHECKBOXSTATES.CBS_MIXEDNORMAL: gtk_plus_state = GtkPlusState.Normal; gtk_plus_toggle_button_value = GtkPlusToggleButtonValue.Mixed; break; case CHECKBOXSTATES.CBS_MIXEDPRESSED: gtk_plus_state = GtkPlusState.Pressed; gtk_plus_toggle_button_value = GtkPlusToggleButtonValue.Mixed; break; case CHECKBOXSTATES.CBS_MIXEDHOT: gtk_plus_state = GtkPlusState.Hot; gtk_plus_toggle_button_value = GtkPlusToggleButtonValue.Mixed; break; case CHECKBOXSTATES.CBS_MIXEDDISABLED: gtk_plus_state = GtkPlusState.Disabled; gtk_plus_toggle_button_value = GtkPlusToggleButtonValue.Mixed; break; default: return false; } GtkPlus.CheckBoxPaint (dc, bounds, clipRectangle, gtk_plus_state, gtk_plus_toggle_button_value); return true; #endregion #region BP_GROUPBOX case BUTTONPARTS.BP_GROUPBOX: switch ((GROUPBOXSTATES)state) { case GROUPBOXSTATES.GBS_NORMAL: gtk_plus_state = GtkPlusState.Normal; break; case GROUPBOXSTATES.GBS_DISABLED: gtk_plus_state = GtkPlusState.Disabled; break; default: return false; } GtkPlus.GroupBoxPaint (dc, bounds, excludedArea, gtk_plus_state); return true; #endregion default: return false; } #endregion #region COMBOBOX #if NET_2_0 case ThemeHandle.COMBOBOX: switch ((COMBOBOXPARTS)part) { #region CP_DROPDOWNBUTTON case COMBOBOXPARTS.CP_DROPDOWNBUTTON: switch ((COMBOBOXSTYLESTATES)state) { case COMBOBOXSTYLESTATES.CBXS_NORMAL: gtk_plus_state = GtkPlusState.Normal; break; case COMBOBOXSTYLESTATES.CBXS_HOT: gtk_plus_state = GtkPlusState.Hot; break; case COMBOBOXSTYLESTATES.CBXS_PRESSED: gtk_plus_state = GtkPlusState.Pressed; break; case COMBOBOXSTYLESTATES.CBXS_DISABLED: gtk_plus_state = GtkPlusState.Disabled; break; default: return false; } GtkPlus.ComboBoxPaintDropDownButton (dc, bounds, clipRectangle, gtk_plus_state); return true; #endregion #region CP_BORDER case COMBOBOXPARTS.CP_BORDER: switch ((BORDERSTATES)state) { case BORDERSTATES.CBB_NORMAL: case BORDERSTATES.CBB_HOT: case BORDERSTATES.CBB_FOCUSED: case BORDERSTATES.CBB_DISABLED: GtkPlus.ComboBoxPaintBorder (dc, bounds, clipRectangle); return true; default: return false; } #endregion default: return false; } #endif #endregion #region EDIT case ThemeHandle.EDIT: switch ((EDITPARTS)part) { #region EP_EDITTEXT case EDITPARTS.EP_EDITTEXT: switch ((EDITTEXTSTATES)state) { case EDITTEXTSTATES.ETS_NORMAL: case EDITTEXTSTATES.ETS_ASSIST: case EDITTEXTSTATES.ETS_READONLY: case EDITTEXTSTATES.ETS_HOT: case EDITTEXTSTATES.ETS_SELECTED: case EDITTEXTSTATES.ETS_FOCUSED: gtk_plus_state = GtkPlusState.Normal; break; case EDITTEXTSTATES.ETS_DISABLED: gtk_plus_state = GtkPlusState.Disabled; break; default: return false; } GtkPlus.TextBoxPaint (dc, bounds, excludedArea, gtk_plus_state); return true; #endregion default: return false; } #endregion #region HEADER case ThemeHandle.HEADER: switch ((HEADERPARTS)part) { #region HP_HEADERITEM case HEADERPARTS.HP_HEADERITEM: switch ((HEADERITEMSTATES)state) { case HEADERITEMSTATES.HIS_NORMAL: gtk_plus_state = GtkPlusState.Normal; break; case HEADERITEMSTATES.HIS_HOT: gtk_plus_state = GtkPlusState.Hot; break; case HEADERITEMSTATES.HIS_PRESSED: gtk_plus_state = GtkPlusState.Pressed; break; default: return false; } GtkPlus.HeaderPaint (dc, bounds, clipRectangle, gtk_plus_state); return true; #endregion default: return false; } #endregion #region PROGRESS case ThemeHandle.PROGRESS: switch ((PROGRESSPARTS)part) { case PROGRESSPARTS.PP_BAR: case PROGRESSPARTS.PP_BARVERT: GtkPlus.ProgressBarPaintBar (dc, bounds, clipRectangle); return true; case PROGRESSPARTS.PP_CHUNK: case PROGRESSPARTS.PP_CHUNKVERT: GtkPlus.ProgressBarPaintChunk (dc, bounds, clipRectangle); return true; default: return false; } #endregion #region REBAR case ThemeHandle.REBAR: switch ((REBARPARTS)part) { case REBARPARTS.RP_BAND: GtkPlus.ToolBarPaint (dc, bounds, clipRectangle); return true; default: return false; } #endregion #region SCROLLBAR case ThemeHandle.SCROLLBAR: switch ((SCROLLBARPARTS)part) { #region SBP_ARROWBTN case SCROLLBARPARTS.SBP_ARROWBTN: bool horizontal; bool up_or_left; switch ((ARROWBTNSTATES)state) { case ARROWBTNSTATES.ABS_UPNORMAL: gtk_plus_state = GtkPlusState.Normal; horizontal = false; up_or_left = true; break; case ARROWBTNSTATES.ABS_UPHOT: gtk_plus_state = GtkPlusState.Hot; horizontal = false; up_or_left = true; break; case ARROWBTNSTATES.ABS_UPPRESSED: gtk_plus_state = GtkPlusState.Pressed; horizontal = false; up_or_left = true; break; case ARROWBTNSTATES.ABS_UPDISABLED: gtk_plus_state = GtkPlusState.Disabled; horizontal = false; up_or_left = true; break; case ARROWBTNSTATES.ABS_DOWNNORMAL: gtk_plus_state = GtkPlusState.Normal; horizontal = false; up_or_left = false; break; case ARROWBTNSTATES.ABS_DOWNHOT: gtk_plus_state = GtkPlusState.Hot; horizontal = false; up_or_left = false; break; case ARROWBTNSTATES.ABS_DOWNPRESSED: gtk_plus_state = GtkPlusState.Pressed; horizontal = false; up_or_left = false; break; case ARROWBTNSTATES.ABS_DOWNDISABLED: gtk_plus_state = GtkPlusState.Disabled; horizontal = false; up_or_left = false; break; case ARROWBTNSTATES.ABS_LEFTNORMAL: gtk_plus_state = GtkPlusState.Normal; horizontal = true; up_or_left = true; break; case ARROWBTNSTATES.ABS_LEFTHOT: gtk_plus_state = GtkPlusState.Hot; horizontal = true; up_or_left = true; break; case ARROWBTNSTATES.ABS_LEFTPRESSED: gtk_plus_state = GtkPlusState.Pressed; horizontal = true; up_or_left = true; break; case ARROWBTNSTATES.ABS_LEFTDISABLED: gtk_plus_state = GtkPlusState.Disabled; horizontal = true; up_or_left = true; break; case ARROWBTNSTATES.ABS_RIGHTNORMAL: gtk_plus_state = GtkPlusState.Normal; horizontal = true; up_or_left = false; break; case ARROWBTNSTATES.ABS_RIGHTHOT: gtk_plus_state = GtkPlusState.Hot; horizontal = true; up_or_left = false; break; case ARROWBTNSTATES.ABS_RIGHTPRESSED: gtk_plus_state = GtkPlusState.Pressed; horizontal = true; up_or_left = false; break; case ARROWBTNSTATES.ABS_RIGHTDISABLED: gtk_plus_state = GtkPlusState.Disabled; horizontal = true; up_or_left = false; break; default: return false; } GtkPlus.ScrollBarPaintArrowButton (dc, bounds, clipRectangle, gtk_plus_state, horizontal, up_or_left); return true; #endregion #region SBP_THUMBBTNHORZ, SBP_THUMBBTNVERT case SCROLLBARPARTS.SBP_THUMBBTNHORZ: case SCROLLBARPARTS.SBP_THUMBBTNVERT: if (!GetGtkPlusState ((SCROLLBARSTYLESTATES)state, out gtk_plus_state)) return false; GtkPlus.ScrollBarPaintThumbButton ( dc, bounds, clipRectangle, gtk_plus_state, (SCROLLBARPARTS)part == SCROLLBARPARTS.SBP_THUMBBTNHORZ); return true; #endregion #region SBP_LOWERTRACKHORZ, SBP_UPPERTRACKHORZ, SBP_LOWERTRACKVERT, SBP_UPPERTRACKVERT case SCROLLBARPARTS.SBP_LOWERTRACKHORZ: case SCROLLBARPARTS.SBP_UPPERTRACKHORZ: case SCROLLBARPARTS.SBP_LOWERTRACKVERT: case SCROLLBARPARTS.SBP_UPPERTRACKVERT: if (!GetGtkPlusState ((SCROLLBARSTYLESTATES)state, out gtk_plus_state)) return false; GtkPlus.ScrollBarPaintTrack ( dc, bounds, clipRectangle, gtk_plus_state, (SCROLLBARPARTS)part == SCROLLBARPARTS.SBP_LOWERTRACKHORZ || (SCROLLBARPARTS)part == SCROLLBARPARTS.SBP_UPPERTRACKHORZ, (SCROLLBARPARTS)part == SCROLLBARPARTS.SBP_UPPERTRACKHORZ || (SCROLLBARPARTS)part == SCROLLBARPARTS.SBP_UPPERTRACKVERT); return true; #endregion default: return false; } #endregion #region SPIN case ThemeHandle.SPIN: bool up; switch ((SPINPARTS)part) { #region SPNP_UP case SPINPARTS.SPNP_UP: up = true; switch ((UPSTATES)state) { case UPSTATES.UPS_NORMAL: gtk_plus_state = GtkPlusState.Normal; break; case UPSTATES.UPS_HOT: gtk_plus_state = GtkPlusState.Hot; break; case UPSTATES.UPS_PRESSED: gtk_plus_state = GtkPlusState.Pressed; break; case UPSTATES.UPS_DISABLED: gtk_plus_state = GtkPlusState.Disabled; break; default: return false; } break; #endregion #region SPNP_DOWN case SPINPARTS.SPNP_DOWN: up = false; switch ((DOWNSTATES)state) { case DOWNSTATES.DNS_NORMAL: gtk_plus_state = GtkPlusState.Normal; break; case DOWNSTATES.DNS_HOT: gtk_plus_state = GtkPlusState.Hot; break; case DOWNSTATES.DNS_PRESSED: gtk_plus_state = GtkPlusState.Pressed; break; case DOWNSTATES.DNS_DISABLED: gtk_plus_state = GtkPlusState.Disabled; break; default: return false; } break; #endregion default: return false; } GtkPlus.UpDownPaint (dc, bounds, clipRectangle, up, gtk_plus_state); return true; #endregion #region STATUS case ThemeHandle.STATUS: switch ((STATUSPARTS)part) { case STATUSPARTS.SP_GRIPPER: GtkPlus.StatusBarPaintGripper (dc, bounds, clipRectangle); return true; default: return false; } #endregion #region TABCONTROL case ThemeHandle.TAB: bool selected; switch ((TABPARTS)part) { #region TABP_TABITEM case TABPARTS.TABP_TABITEM: switch ((TABITEMSTATES)state) { case TABITEMSTATES.TIS_SELECTED: selected = true; break; case TABITEMSTATES.TIS_NORMAL: case TABITEMSTATES.TIS_HOT: case TABITEMSTATES.TIS_DISABLED: selected = false; break; default: return false; } break; #endregion #region TABP_TABITEMLEFTEDGE case TABPARTS.TABP_TABITEMLEFTEDGE: switch ((TABITEMLEFTEDGESTATES)state) { case TABITEMLEFTEDGESTATES.TILES_SELECTED: selected = true; break; case TABITEMLEFTEDGESTATES.TILES_NORMAL: case TABITEMLEFTEDGESTATES.TILES_HOT: case TABITEMLEFTEDGESTATES.TILES_DISABLED: selected = false; break; default: return false; } break; #endregion #region TABP_TABITEMRIGHTEDGE case TABPARTS.TABP_TABITEMRIGHTEDGE: switch ((TABITEMRIGHTEDGESTATES)state) { case TABITEMRIGHTEDGESTATES.TIRES_SELECTED: selected = true; break; case TABITEMRIGHTEDGESTATES.TIRES_NORMAL: case TABITEMRIGHTEDGESTATES.TIRES_HOT: case TABITEMRIGHTEDGESTATES.TIRES_DISABLED: selected = false; break; default: return false; } break; #endregion #region TABP_TABITEMBOTHEDGE case TABPARTS.TABP_TABITEMBOTHEDGE: selected = false; break; #endregion #region TABP_TOPTABITEM case TABPARTS.TABP_TOPTABITEM: switch ((TOPTABITEMSTATES)state) { case TOPTABITEMSTATES.TTIS_SELECTED: selected = true; break; case TOPTABITEMSTATES.TTIS_NORMAL: case TOPTABITEMSTATES.TTIS_HOT: case TOPTABITEMSTATES.TTIS_DISABLED: selected = false; break; default: return false; } break; #endregion #region TABP_TOPTABITEMLEFTEDGE case TABPARTS.TABP_TOPTABITEMLEFTEDGE: switch ((TOPTABITEMLEFTEDGESTATES)state) { case TOPTABITEMLEFTEDGESTATES.TTILES_SELECTED: selected = true; break; case TOPTABITEMLEFTEDGESTATES.TTILES_NORMAL: case TOPTABITEMLEFTEDGESTATES.TTILES_HOT: case TOPTABITEMLEFTEDGESTATES.TTILES_DISABLED: selected = false; break; default: return false; } break; #endregion #region TABP_TOPTABITEMRIGHTEDGE case TABPARTS.TABP_TOPTABITEMRIGHTEDGE: switch ((TOPTABITEMRIGHTEDGESTATES)state) { case TOPTABITEMRIGHTEDGESTATES.TTIRES_SELECTED: selected = true; break; case TOPTABITEMRIGHTEDGESTATES.TTIRES_NORMAL: case TOPTABITEMRIGHTEDGESTATES.TTIRES_HOT: case TOPTABITEMRIGHTEDGESTATES.TTIRES_DISABLED: selected = false; break; default: return false; } break; #endregion #region TABP_TOPTABITEMBOTHEDGE case TABPARTS.TABP_TOPTABITEMBOTHEDGE: selected = false; break; #endregion #region TABP_PANE case TABPARTS.TABP_PANE: GtkPlus.TabControlPaintPane (dc, bounds, clipRectangle); return true; #endregion default: return false; } GtkPlus.TabControlPaintTabItem (dc, bounds, clipRectangle, selected ? GtkPlusState.Pressed : GtkPlusState.Normal); return true; #endregion #region TOOLBAR case ThemeHandle.TOOLBAR: switch ((TOOLBARPARTS)part) { case TOOLBARPARTS.TP_BUTTON: switch ((TOOLBARSTYLESTATES)state) { case TOOLBARSTYLESTATES.TS_NORMAL: gtk_plus_state = GtkPlusState.Normal; break; case TOOLBARSTYLESTATES.TS_HOT: gtk_plus_state = GtkPlusState.Hot; break; case TOOLBARSTYLESTATES.TS_PRESSED: gtk_plus_state = GtkPlusState.Pressed; break; case TOOLBARSTYLESTATES.TS_DISABLED: gtk_plus_state = GtkPlusState.Disabled; break; case TOOLBARSTYLESTATES.TS_CHECKED: case TOOLBARSTYLESTATES.TS_HOTCHECKED: GtkPlus.ToolBarPaintCheckedButton (dc, bounds, clipRectangle); return true; default: return false; } GtkPlus.ToolBarPaintButton (dc, bounds, clipRectangle, gtk_plus_state); return true; default: return false; } #endregion #region TRACKBAR case ThemeHandle.TRACKBAR: switch ((TRACKBARPARTS)part) { #region TKP_TRACK case TRACKBARPARTS.TKP_TRACK: switch ((TRACKSTATES)state) { case TRACKSTATES.TRS_NORMAL: GtkPlus.TrackBarPaintTrack (dc, bounds, clipRectangle, true); return true; default: return false; } #endregion #region TKP_TRACKVERT case TRACKBARPARTS.TKP_TRACKVERT: switch ((TRACKVERTSTATES)state) { case TRACKVERTSTATES.TRVS_NORMAL: GtkPlus.TrackBarPaintTrack (dc, bounds, clipRectangle, false); return true; default: return false; } #endregion #region TKP_THUMB case TRACKBARPARTS.TKP_THUMB: switch ((THUMBSTATES)state) { case THUMBSTATES.TUS_NORMAL: gtk_plus_state = GtkPlusState.Normal; break; case THUMBSTATES.TUS_HOT: gtk_plus_state = GtkPlusState.Hot; break; case THUMBSTATES.TUS_PRESSED: gtk_plus_state = GtkPlusState.Pressed; break; case THUMBSTATES.TUS_FOCUSED: gtk_plus_state = GtkPlusState.Selected; break; case THUMBSTATES.TUS_DISABLED: gtk_plus_state = GtkPlusState.Disabled; break; default: return false; } GtkPlus.TrackBarPaintThumb (dc, bounds, clipRectangle, gtk_plus_state, true); return true; #endregion #region TKP_THUMBVERT case TRACKBARPARTS.TKP_THUMBVERT: switch ((THUMBVERTSTATES)state) { case THUMBVERTSTATES.TUVS_NORMAL: gtk_plus_state = GtkPlusState.Normal; break; case THUMBVERTSTATES.TUVS_HOT: gtk_plus_state = GtkPlusState.Hot; break; case THUMBVERTSTATES.TUVS_PRESSED: gtk_plus_state = GtkPlusState.Pressed; break; case THUMBVERTSTATES.TUVS_FOCUSED: gtk_plus_state = GtkPlusState.Selected; break; case THUMBVERTSTATES.TUVS_DISABLED: gtk_plus_state = GtkPlusState.Disabled; break; default: return false; } GtkPlus.TrackBarPaintThumb (dc, bounds, clipRectangle, gtk_plus_state, false); return true; #endregion default: return false; } #endregion #region TREEVIEW case ThemeHandle.TREEVIEW: switch ((TREEVIEWPARTS)part) { case TREEVIEWPARTS.TVP_GLYPH: bool closed; switch ((GLYPHSTATES)state) { case GLYPHSTATES.GLPS_CLOSED : closed = true; break; case GLYPHSTATES.GLPS_OPENED: closed = false; break; default: return false; } GtkPlus.TreeViewPaintGlyph (dc, bounds, clipRectangle, closed); return true; default: return false; } #endregion default: return false; } }
bool GetPartSize (ThemeHandle themeHandle, IDeviceContext dc, int part, int state, Rectangle bounds, bool rectangleSpecified, ThemeSizeType type, out Size result) { switch (themeHandle) { #region BUTTON case ThemeHandle.BUTTON: switch ((BUTTONPARTS)part) { case BUTTONPARTS.BP_RADIOBUTTON: result = GtkPlus.RadioButtonGetSize (); return true; case BUTTONPARTS.BP_CHECKBOX: result = GtkPlus.CheckBoxGetSize (); return true; } break; #endregion #region HEADER case ThemeHandle.HEADER: switch ((HEADERPARTS)part) { case HEADERPARTS.HP_HEADERITEM: result = new Size (0, ThemeWin32Classic.ListViewGetHeaderHeight ()); return true; } break; #endregion #region TRACKBAR case ThemeHandle.TRACKBAR: switch ((TRACKBARPARTS)part) { case TRACKBARPARTS.TKP_TRACK: result = new Size (0, ThemeWin32Classic.TrackBarHorizontalTrackHeight); return true; case TRACKBARPARTS.TKP_TRACKVERT: result = new Size (ThemeWin32Classic.TrackBarVerticalTrackWidth, 0); return true; case TRACKBARPARTS.TKP_THUMB: case TRACKBARPARTS.TKP_THUMBVERT: result = ThemeWin32Classic.TrackBarGetThumbSize (); if ((TRACKBARPARTS)part == TRACKBARPARTS.TKP_THUMBVERT) { int temporary = result.Width; result.Width = result.Height; result.Height = temporary; } return true; } break; #endregion } result = Size.Empty; return false; }
bool GetInteger (ThemeHandle handle, int part, int state, IntegerProperty property, out int result) { switch (handle) { case ThemeHandle.PROGRESS: switch ((PROGRESSPARTS)part) { case PROGRESSPARTS.PP_CHUNK: case PROGRESSPARTS.PP_CHUNKVERT: switch (property) { case IntegerProperty.ProgressChunkSize: result = ThemeWin32Classic.ProgressBarGetChunkSize (); return true; case IntegerProperty.ProgressSpaceSize: result = ThemeWin32Classic.ProgressBarChunkSpacing; return true; } break; } break; } result = 0; return false; }
bool GetBackgroundContentRectangle (ThemeHandle handle, int part, int state, Rectangle bounds, out Rectangle result) { switch (handle) { case ThemeHandle.PROGRESS: switch ((PROGRESSPARTS)part) { case PROGRESSPARTS.PP_BAR: case PROGRESSPARTS.PP_BARVERT: result = GtkPlus.ProgressBarGetBackgroundContentRectagle (bounds); return true; } break; } result = Rectangle.Empty; return false; }