Imported Upstream version 4.2.0.179

Former-commit-id: 0a113cb3a6feb7873f632839b1307cc6033cd595
This commit is contained in:
Xamarin Public Jenkins
2015-08-26 07:17:56 -04:00
committed by Jo Shields
parent 183bba2c9a
commit 6992685b86
7507 changed files with 90259 additions and 657307 deletions

View File

@@ -0,0 +1,76 @@
2008-07-10 George Giolfan <georgegiolfan@yahoo.com>
* ThemeElements.cs: Changed the XplatUI.ThemesEnabled check to
Application.VisualStylesEnabled because it does not work on X11.
2008-07-09 George Giolfan <georgegiolfan@yahoo.com>
* ThemeElements.cs: ThemeElementsVisualStyles is now selected if
Application.EnableVisualStyles has been called, even if the current system
configuration does not support rendering with Visual Styles.
2008-05-07 George Giolfan <georgegiolfan@yahoo.com>
* ThemeElementsVisualStyles.cs: Added ToolStripPainter.
2008-04-28 George Giolfan <georgegiolfan@yahoo.com>
* ThemeElementsVisualStyles.cs: Added TabControlPainter.
2008-04-27 George Giolfan <georgegiolfan@yahoo.com>
* ThemeElements.cs: Fixed the code to select ThemeElementsVisualStyles.
2008-04-25 George Giolfan <georgegiolfan@yahoo.com>
* ThemeElements.cs: Added code to select ThemeElementsVisualStyles.
* ThemeElementsVisualStyles.cs: Added.
2008-01-23 Everaldo Canuto <ecanuto@novell.com>
* ThemeElementsDefault.cs: Add LinkLabelPainter references.
* ThemeElements.cs: Add LinkLabelPainter references.
2008-01-22 Everaldo Canuto <ecanuto@novell.com>
* ThemeElementsDefault.cs: Add LinkLabelPainter references. Also add some
public properties to gets painters, it reduce some source line width because
we can refer to Painters using "ThemeElements.LinkLabelPainter" as example.
* ThemeElements.cs: Add LinkLabelPainter references.
2007-08-28 Jonathan Pobst <monkey@jpobst.com>
* ThemeElementsDefault.cs: Add accessor for RadioButtonPainter.
2007-08-22 Jonathan Pobst <monkey@jpobst.com>
* ThemeElementsDefault.cs: Add accessor for CheckBoxPainter.
* ThemeElements.cs: Add enum for button states.
2007-07-03 Jonathan Pobst <monkey@jpobst.com>
* ThemeElementsDefault.cs: Add accessor for ToolStripPainter.
2007-04-15 Andreia Gaita <avidigal@novell.com>
* ThemeElements.cs: Load themes by reflection according to theme
name. If the theme is not implemented yet, load the default theme.
Theme classes just give access to the *Painter classes, that
implement drawing of each control. Only the Default.*Painter
class needs to be implemented and referenced on ThemeDefault,
all others inherit from this one. Check the ThemeElementsNice
class for an example.
* ThemeElementsDefault.cs,
ThemeElementsClearlooks.cs (new),
ThemeElementsNice.cs (new),
ThemeElementsGtk.cs (new): Theme classes to access *Painter
implementations.
2007-03-02 Jonathan Pobst <monkey@jpobst.com>
* ThemeElements.cs: Driver code to theme class that actually draws
theme elements.
* ThemeElementsDefault.cs: Default [win32 style] implementation of
Standard, Flat, Popup buttons.

View File

@@ -0,0 +1,189 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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) 2007 Novell, Inc.
//
// Authors:
// Andreia Gaita (avidigal@novell.com)
using System;
using System.Drawing;
namespace System.Windows.Forms.Theming.Default
{
/// <summary>
/// Summary description for Button.
/// </summary>
internal class ButtonPainter
{
public ButtonPainter ()
{
}
protected SystemResPool ResPool { get { return ThemeEngine.Current.ResPool; } }
#region Buttons
#region Standard Button
public virtual void Draw (Graphics g, Rectangle bounds, ButtonThemeState state, Color backColor, Color foreColor) {
bool is_themecolor = backColor.ToArgb () == ThemeEngine.Current.ColorControl.ToArgb () || backColor == Color.Empty ? true : false;
CPColor cpcolor = is_themecolor ? CPColor.Empty : ResPool.GetCPColor (backColor);
Pen pen;
switch (state) {
case ButtonThemeState.Normal:
case ButtonThemeState.Entered:
case ButtonThemeState.Disabled:
pen = is_themecolor ? SystemPens.ControlLightLight : ResPool.GetPen (cpcolor.LightLight);
g.DrawLine (pen, bounds.X, bounds.Y, bounds.X, bounds.Bottom - 2);
g.DrawLine (pen, bounds.X + 1, bounds.Y, bounds.Right - 2, bounds.Y);
pen = is_themecolor ? SystemPens.Control : ResPool.GetPen (backColor);
g.DrawLine (pen, bounds.X + 1, bounds.Y + 1, bounds.X + 1, bounds.Bottom - 3);
g.DrawLine (pen, bounds.X + 2, bounds.Y + 1, bounds.Right - 3, bounds.Y + 1);
pen = is_themecolor ? SystemPens.ControlDark : ResPool.GetPen (cpcolor.Dark);
g.DrawLine (pen, bounds.X + 1, bounds.Bottom - 2, bounds.Right - 2, bounds.Bottom - 2);
g.DrawLine (pen, bounds.Right - 2, bounds.Y + 1, bounds.Right - 2, bounds.Bottom - 3);
pen = is_themecolor ? SystemPens.ControlDarkDark : ResPool.GetPen (cpcolor.DarkDark);
g.DrawLine (pen, bounds.X, bounds.Bottom - 1, bounds.Right - 1, bounds.Bottom - 1);
g.DrawLine (pen, bounds.Right - 1, bounds.Y, bounds.Right - 1, bounds.Bottom - 2);
break;
case ButtonThemeState.Pressed:
g.DrawRectangle (ResPool.GetPen (foreColor), bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1);
bounds.Inflate (-1, -1);
pen = is_themecolor ? SystemPens.ControlDark : ResPool.GetPen (cpcolor.Dark);
g.DrawRectangle (pen, bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1);
break;
case ButtonThemeState.Default:
g.DrawRectangle (ResPool.GetPen (foreColor), bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1);
bounds.Inflate (-1, -1);
pen = is_themecolor ? SystemPens.ControlLightLight : ResPool.GetPen (cpcolor.LightLight);
g.DrawLine (pen, bounds.X, bounds.Y, bounds.X, bounds.Bottom - 2);
g.DrawLine (pen, bounds.X + 1, bounds.Y, bounds.Right - 2, bounds.Y);
pen = is_themecolor ? SystemPens.Control : ResPool.GetPen (backColor);
g.DrawLine (pen, bounds.X + 1, bounds.Y + 1, bounds.X + 1, bounds.Bottom - 3);
g.DrawLine (pen, bounds.X + 2, bounds.Y + 1, bounds.Right - 3, bounds.Y + 1);
pen = is_themecolor ? SystemPens.ControlDark : ResPool.GetPen (cpcolor.Dark);
g.DrawLine (pen, bounds.X + 1, bounds.Bottom - 2, bounds.Right - 2, bounds.Bottom - 2);
g.DrawLine (pen, bounds.Right - 2, bounds.Y + 1, bounds.Right - 2, bounds.Bottom - 3);
pen = is_themecolor ? SystemPens.ControlDarkDark : ResPool.GetPen (cpcolor.DarkDark);
g.DrawLine (pen, bounds.X, bounds.Bottom - 1, bounds.Right - 1, bounds.Bottom - 1);
g.DrawLine (pen, bounds.Right - 1, bounds.Y, bounds.Right - 1, bounds.Bottom - 2);
break;
}
}
#endregion
#region FlatStyle Button
public virtual void DrawFlat (Graphics g, Rectangle bounds, ButtonThemeState state, Color backColor, Color foreColor, FlatButtonAppearance appearance) {
bool is_themecolor = backColor.ToArgb () == ThemeEngine.Current.ColorControl.ToArgb () || backColor == Color.Empty ? true : false;
CPColor cpcolor = is_themecolor ? CPColor.Empty : ResPool.GetCPColor (backColor);
Pen pen;
switch (state) {
case ButtonThemeState.Normal:
case ButtonThemeState.Disabled:
// This will just use the BackColor
break;
case ButtonThemeState.Entered:
case ButtonThemeState.Default | ButtonThemeState.Entered:
if (appearance.MouseOverBackColor != Color.Empty)
g.FillRectangle (ResPool.GetSolidBrush (appearance.MouseOverBackColor), bounds);
else
g.FillRectangle (ResPool.GetSolidBrush (ChangeIntensity (backColor, .9F)), bounds);
break;
case ButtonThemeState.Pressed:
if (appearance.MouseDownBackColor != Color.Empty)
g.FillRectangle (ResPool.GetSolidBrush (appearance.MouseDownBackColor), bounds);
else
g.FillRectangle (ResPool.GetSolidBrush (ChangeIntensity (backColor, .95F)), bounds);
break;
case ButtonThemeState.Default:
if (appearance.CheckedBackColor != Color.Empty)
g.FillRectangle (ResPool.GetSolidBrush (appearance.CheckedBackColor), bounds);
break;
}
if (appearance.BorderColor == Color.Empty)
pen = is_themecolor ? SystemPens.ControlDarkDark : ResPool.GetSizedPen (cpcolor.DarkDark, appearance.BorderSize);
else
pen = ResPool.GetSizedPen (appearance.BorderColor, appearance.BorderSize);
bounds.Width -= 1;
bounds.Height -= 1;
if (appearance.BorderSize > 0)
g.DrawRectangle (pen, bounds);
}
#endregion
#region Popup Button
public virtual void DrawPopup (Graphics g, Rectangle bounds, ButtonThemeState state, Color backColor, Color foreColor) {
bool is_themecolor = backColor.ToArgb () == ThemeEngine.Current.ColorControl.ToArgb () || backColor == Color.Empty ? true : false;
CPColor cpcolor = is_themecolor ? CPColor.Empty : ResPool.GetCPColor (backColor);
Pen pen;
switch (state) {
case ButtonThemeState.Normal:
case ButtonThemeState.Disabled:
case ButtonThemeState.Pressed:
case ButtonThemeState.Default:
pen = is_themecolor ? SystemPens.ControlDarkDark : ResPool.GetPen (cpcolor.DarkDark);
bounds.Width -= 1;
bounds.Height -= 1;
g.DrawRectangle (pen, bounds);
if (state == ButtonThemeState.Default || state == ButtonThemeState.Pressed) {
bounds.Inflate (-1, -1);
g.DrawRectangle (pen, bounds);
}
break;
case ButtonThemeState.Entered:
pen = is_themecolor ? SystemPens.ControlLightLight : ResPool.GetPen (cpcolor.LightLight);
g.DrawLine (pen, bounds.X, bounds.Y, bounds.X, bounds.Bottom - 2);
g.DrawLine (pen, bounds.X + 1, bounds.Y, bounds.Right - 2, bounds.Y);
pen = is_themecolor ? SystemPens.ControlDark : ResPool.GetPen (cpcolor.Dark);
g.DrawLine (pen, bounds.X, bounds.Bottom - 1, bounds.Right - 1, bounds.Bottom - 1);
g.DrawLine (pen, bounds.Right - 1, bounds.Y, bounds.Right - 1, bounds.Bottom - 2);
break;
}
}
#endregion
#endregion
private static Color ChangeIntensity (Color baseColor, float percent)
{
int H, I, S;
ControlPaint.Color2HBS (baseColor, out H, out I, out S);
int NewIntensity = Math.Min (255, (int)(I * percent));
return ControlPaint.HBS2Color (H, NewIntensity, S);
}
}
}

View File

@@ -0,0 +1,200 @@
2010-06-25 Carlos Alberto Cortez <calberto.cortez@gmail.com>
* TabControlPainter.cs: Use TabControl.Font instead of the values of
TabPage.Font.
Fixes bits of #551032.
2010-06-20 Carlos Alberto Cortez <calberto.cortez@gmail.com>
* TabControlPainter.cs: Actually draw the focus rectangle - TabControl
ignores the value of ShowFocusCues. Also, properly compute the bounds
for the focus rectangle, since it should include the padding of the
tab page.
Fixes bits of #515045.
2010-05-17 Carlos Alberto Cortez <calberto.cortez@gmail.com>
* TabControlPainter.cs: Don't use FocusRectSpacing or BorderThickess
to calculate the interior rectangle to draw the tab contents, as
TabControl.Padding is enough - we had been ignoring it. This make
should our tab look more like that one in .net.
2010-05-17 Carlos Alberto Cortez <calberto.cortez@gmail.com>
* TabControlPainter.cs: When drawing tabs, use TabControl.Padding into
account for the interior rectangle for the text/image contents.
Fixes the remaining bits of #604034.
0201-05-16 Carlos Alberto Cortez <calberto.cortez@gmail.com>
* TabControlPainter.cs: The text for our tabs should always be
vertically centered, and it should be horizontally centered if the
size mode is Fixed. Patch from Thomas Goldstein (stifu@free.fr).
Fixes part of #599841.
2010-05-15 Carlos Alberto Cortez <calberto.cortez@gmail.com>
* TabControlPainter.cs: Reduce the height for our default item size,
as we were ignoring the padding before.
2008-10-20 Jonathan Pobst <monkey@jpobst.com>
* ToolStripPainter.cs: Don't paint over a set BackgroundImage.
2008-10-09 Everaldo Canuto <ecanuto@novell.com>
* LinkLabelPainter.cs: Take Padding into account when drawing the linklabel
text.
2008-10-08 Everaldo Canuto <ecanuto@novell.com>
* LabelPainter.cs: Use control.PaddingClientRectangle instead of calculate
rectangle with padding. Also break some lines that theres more than 120
characters.
2008-09-24 Jonathan Pobst <monkey@jpobst.com>
* TabControlPainter.cs: Add 1 pixel to the tab text rectangle
to keep the text from getting cut off on XP.
[Fixes bug #428116]
2008-09-16 Jonathan Pobst <monkey@jpobst.com>
* TabControlPainter.cs: Hook tab painting into ShowFocusCues.
2008-07-31 George Giolfan <georgegiolfan@yahoo.com>
* TabControlPainter.cs: Added DrawScrollButton, GetButtonState.
2008-06-09 Carlos Alberto Cortez <calberto.cortez@gmail.com>
* TabControlPainter.cs: When calculating the display rectangle for
TabPage elements, don't include TabControlSelectedDelta.Y as part of
the page height, since it is only added ad the end (this is the way
it's done in TabControl). This way having a lot of pages with
Multiline as true doesn't add much extra space between the tab pages
labels and the actual tab pages area.
Fixes #393912.
2008-05-21 George Giolfan <georgegiolfan@yahoo.com>
* TabControlPainter.cs: Added HasHotElementStyles.
2008-05-19 George Giolfan <georgegiolfan@yahoo.com>
* TabControlPainter.cs: Refactored: Extracted DrawBackground.
2008-05-16 Carlos Alberto Cortez <calberto.cortez@gmail.com>
* TabControlPainter.cs: Use HotPrefix.Show as the value of
StringFormat.HotPrefix when drawing the tab text.
Fixes #355193.
2008-05-16 Carlos Alberto Cortez <calberto.cortez@gmail.com>
* TabControlPainter.cs: Use StringAlignment.Near as the value for
StringFormat.Alignment when drawing the tab text.
Fixes part of #352399.
2008-02-25 Jonathan Pobst <monkey@jpobst.com>
* LabelPainter.cs: Take Padding into account when drawing
the label text.
2008-01-23 Everaldo Canuto <ecanuto@novell.com>
* LabelPainter.cs: Added.
2008-01-22 Everaldo Canuto <ecanuto@novell.com>
* LinkLabelPainter.cs: Change Draw method to virtual.
2008-01-22 Everaldo Canuto <ecanuto@novell.com>
* LinkLabelPainter.cs: Added.
2007-09-04 Everaldo Canuto <everaldo@simios.org>
* CheckBoxPainter.cs: Adjust checkbox light color to ControlLightLight to
mimic win32 look. Fixes #82656 (2.0).
2007-08-28 Jonathan Pobst <monkey@jpobst.com>
* RadioButtonPainter.cs: Added.
2007-08-22 Jonathan Pobst <monkey@jpobst.com>
* CheckBoxPainter.cs: Added.
2007-08-19 Everaldo Canuto <ecanuto@novell.com>
* TabControlPainter.cs: Fix regression in default padding x.
2007-08-19 Everaldo Canuto <ecanuto@novell.com>
* TabControlPainter.cs: Fix border thickness, padding and tab text format to
be horizontal centralized. Fixes #82471.
2007-08-18 Everaldo Canuto <ecanuto@novell.com>
* TabControlPainter.cs: Remove one vertical pixel from tab drawing, the
bottom line was one pixel more than needed.
2007-07-26 Everaldo Canuto <ecanuto@novell.com>
* TabControlPainter.cs: Adjust vertical image position on tab. Fixes #81837.
2007-07-26 Everaldo Canuto <ecanuto@novell.com>
* TabControlPainter.cs: Uses str_rect to draw text since it take in account
the image size. Fixes #81836.
2007-07-20 Jonathan Pobst <monkey@jpobst.com>
* ToolStripPainter.cs: Patch from Rolf. We weren't painting a
Checked button as sunken. [Fixes bug #82151]
2007-07-16 Jonathan Pobst <monkey@jpobst.com>
* ButtonPainter.cs: For flat buttons, draw mouse highlight when
button is focused. Remove random extra rectangle.
2007-07-16 Jonathan Pobst <monkey@jpobst.com>
* ButtonPainter.cs: For Flat button, if no mouse over / press
backcolor is specified, calculate one from the normal backcolor.
2007-07-12 Jonathan Pobst <monkey@jpobst.com>
* ButtonPainter.cs: For Flat button, if BorderSize is 0, don't
draw the rectangle. Setting the pen's width to 1 isn't good
enough, it still draws the border. [Fixes bug #82081]
2007-07-03 Jonathan Pobst <monkey@jpobst.com>
* ToolStripPainter.cs: Added. This is where we paint toolstrips
using the ToolStripSystemRenderer.
2007-05-04 Andreia Gaita <avidigal@novell.com>
* TabControlPainter.cs: Use ControlPaint static methods
instead of ThemeEngine ones (seeing as they're there and
all :p )
2007-04-15 Andreia Gaita <avidigal@novell.com>
* ButtonPainter.cs: refactoring of the button drawing
that was originally located in ThemeElementsDefault
* TabControlPainter.cs: refactoring of the tabcontrol
drawing code originally located in the ThemeWin32Classic.
Also, fixes and changes:
- replaced most hardcoded values with properties to
make it easier to customize implementations.
- fixed left and right alignment drawing problems
- fixed flatbutton border drawing on left and
right alignment
- fixed #79619
- fixed paddings, spacings and positioning.

View File

@@ -0,0 +1,357 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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) 2007 Novell, Inc.
//
// Authors:
// Jonathan Pobst (monkey@jpobst.com)
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace System.Windows.Forms.Theming.Default
{
/// <summary>
/// Summary description for Button.
/// </summary>
internal class CheckBoxPainter
{
public CheckBoxPainter ()
{
}
protected SystemResPool ResPool { get { return ThemeEngine.Current.ResPool; } }
public void PaintCheckBox (Graphics g, Rectangle bounds, Color backColor, Color foreColor, ElementState state, FlatStyle style, CheckState checkState)
{
switch (style) {
case FlatStyle.Standard:
case FlatStyle.System:
switch (state) {
case ElementState.Normal:
DrawNormalCheckBox (g, bounds, backColor, foreColor, checkState);
break;
case ElementState.Hot:
DrawHotCheckBox (g, bounds, backColor, foreColor, checkState);
break;
case ElementState.Pressed:
DrawPressedCheckBox (g, bounds, backColor, foreColor, checkState);
break;
case ElementState.Disabled:
DrawDisabledCheckBox (g, bounds, backColor, foreColor, checkState);
break;
}
break;
case FlatStyle.Flat:
switch (state) {
case ElementState.Normal:
DrawFlatNormalCheckBox (g, bounds, backColor, foreColor, checkState);
break;
case ElementState.Hot:
DrawFlatHotCheckBox (g, bounds, backColor, foreColor, checkState);
break;
case ElementState.Pressed:
DrawFlatPressedCheckBox (g, bounds, backColor, foreColor, checkState);
break;
case ElementState.Disabled:
DrawFlatDisabledCheckBox (g, bounds, backColor, foreColor, checkState);
break;
}
break;
case FlatStyle.Popup:
switch (state) {
case ElementState.Normal:
DrawPopupNormalCheckBox (g, bounds, backColor, foreColor, checkState);
break;
case ElementState.Hot:
DrawPopupHotCheckBox (g, bounds, backColor, foreColor, checkState);
break;
case ElementState.Pressed:
DrawPopupPressedCheckBox (g, bounds, backColor, foreColor, checkState);
break;
case ElementState.Disabled:
DrawPopupDisabledCheckBox (g, bounds, backColor, foreColor, checkState);
break;
}
break;
}
}
#region Standard
public virtual void DrawNormalCheckBox (Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
int check_box_visible_size = (bounds.Height > bounds.Width) ? bounds.Width : bounds.Height;
int x_pos = Math.Max (0, bounds.X + (bounds.Width / 2) - check_box_visible_size / 2);
int y_pos = Math.Max (0, bounds.Y + (bounds.Height / 2) - check_box_visible_size / 2);
Rectangle rect = new Rectangle (x_pos, y_pos, check_box_visible_size, check_box_visible_size);
g.FillRectangle (SystemBrushes.ControlLightLight, rect.X + 2, rect.Y + 2, rect.Width - 3, rect.Height - 3);
Pen pen = SystemPens.ControlDark;
g.DrawLine (pen, rect.X, rect.Y, rect.X, rect.Bottom - 2);
g.DrawLine (pen, rect.X + 1, rect.Y, rect.Right - 2, rect.Y);
pen = SystemPens.ControlDarkDark;
g.DrawLine (pen, rect.X + 1, rect.Y + 1, rect.X + 1, rect.Bottom - 3);
g.DrawLine (pen, rect.X + 2, rect.Y + 1, rect.Right - 3, rect.Y + 1);
pen = SystemPens.ControlLightLight;
g.DrawLine (pen, rect.Right - 1, rect.Y, rect.Right - 1, rect.Bottom - 1);
g.DrawLine (pen, rect.X, rect.Bottom - 1, rect.Right - 1, rect.Bottom - 1);
// oh boy, matching ms is like fighting against windmills
using (Pen h_pen = new Pen (ResPool.GetHatchBrush (HatchStyle.Percent50,
Color.FromArgb (Clamp (ColorControl.R + 3, 0, 255),
ColorControl.G, ColorControl.B), ColorControl))) {
g.DrawLine (h_pen, rect.X + 1, rect.Bottom - 2, rect.Right - 2, rect.Bottom - 2);
g.DrawLine (h_pen, rect.Right - 2, rect.Y + 1, rect.Right - 2, rect.Bottom - 2);
}
if (state == CheckState.Checked)
DrawCheck (g, bounds, Color.Black);
else if (state == CheckState.Indeterminate)
DrawCheck (g, bounds, SystemColors.ControlDark);
}
public virtual void DrawHotCheckBox (Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
DrawNormalCheckBox (g, bounds, backColor, foreColor, state);
}
public virtual void DrawPressedCheckBox (Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
int check_box_visible_size = (bounds.Height > bounds.Width) ? bounds.Width : bounds.Height;
int x_pos = Math.Max (0, bounds.X + (bounds.Width / 2) - check_box_visible_size / 2);
int y_pos = Math.Max (0, bounds.Y + (bounds.Height / 2) - check_box_visible_size / 2);
Rectangle rect = new Rectangle (x_pos, y_pos, check_box_visible_size, check_box_visible_size);
g.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50,
Color.FromArgb (Clamp (ColorControl.R + 3, 0, 255),
ColorControl.G, ColorControl.B),
ColorControl), rect.X + 2, rect.Y + 2, rect.Width - 3, rect.Height - 3);
Pen pen = SystemPens.ControlDark;
g.DrawLine (pen, rect.X, rect.Y, rect.X, rect.Bottom - 2);
g.DrawLine (pen, rect.X + 1, rect.Y, rect.Right - 2, rect.Y);
pen = SystemPens.ControlDarkDark;
g.DrawLine (pen, rect.X + 1, rect.Y + 1, rect.X + 1, rect.Bottom - 3);
g.DrawLine (pen, rect.X + 2, rect.Y + 1, rect.Right - 3, rect.Y + 1);
pen = SystemPens.ControlLightLight;
g.DrawLine (pen, rect.Right - 1, rect.Y, rect.Right - 1, rect.Bottom - 1);
g.DrawLine (pen, rect.X, rect.Bottom - 1, rect.Right - 1, rect.Bottom - 1);
// oh boy, matching ms is like fighting against windmills
using (Pen h_pen = new Pen (ResPool.GetHatchBrush (HatchStyle.Percent50,
Color.FromArgb (Clamp (ColorControl.R + 3, 0, 255),
ColorControl.G, ColorControl.B), ColorControl))) {
g.DrawLine (h_pen, rect.X + 1, rect.Bottom - 2, rect.Right - 2, rect.Bottom - 2);
g.DrawLine (h_pen, rect.Right - 2, rect.Y + 1, rect.Right - 2, rect.Bottom - 2);
}
if (state == CheckState.Checked)
DrawCheck (g, bounds, Color.Black);
else if (state == CheckState.Indeterminate)
DrawCheck (g, bounds, SystemColors.ControlDarkDark);
}
public virtual void DrawDisabledCheckBox (Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
DrawPressedCheckBox (g, bounds, backColor, foreColor, CheckState.Unchecked);
if (state == CheckState.Checked || state == CheckState.Indeterminate)
DrawCheck (g, bounds, SystemColors.ControlDark);
}
#endregion
#region FlatStyle
public virtual void DrawFlatNormalCheckBox (Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
Rectangle checkbox_rectangle;
Rectangle fill_rectangle;
// set up our rectangles first
// clip two pixels from bottom right for non popup rendered checkboxes
checkbox_rectangle = new Rectangle (bounds.X, bounds.Y, Math.Max (bounds.Width - 2, 0), Math.Max (bounds.Height - 2, 0));
fill_rectangle = new Rectangle (checkbox_rectangle.X + 1, checkbox_rectangle.Y + 1, Math.Max (checkbox_rectangle.Width - 2, 0), Math.Max (checkbox_rectangle.Height - 2, 0));
g.FillRectangle (ResPool.GetSolidBrush (ControlPaint.LightLight (backColor)), fill_rectangle);
ControlPaint.DrawBorder (g, checkbox_rectangle, foreColor, ButtonBorderStyle.Solid);
bounds.Offset (-1, 0);
if (state == CheckState.Checked)
DrawCheck (g, bounds, Color.Black);
else if (state == CheckState.Indeterminate)
DrawCheck (g, bounds, SystemColors.ControlDarkDark);
}
public virtual void DrawFlatHotCheckBox (Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
Rectangle checkbox_rectangle;
Rectangle fill_rectangle;
// set up our rectangles first
// clip two pixels from bottom right for non popup rendered checkboxes
checkbox_rectangle = new Rectangle (bounds.X, bounds.Y, Math.Max (bounds.Width - 2, 0), Math.Max (bounds.Height - 2, 0));
fill_rectangle = new Rectangle (checkbox_rectangle.X + 1, checkbox_rectangle.Y + 1, Math.Max (checkbox_rectangle.Width - 2, 0), Math.Max (checkbox_rectangle.Height - 2, 0));
g.FillRectangle (ResPool.GetSolidBrush (backColor), fill_rectangle);
ControlPaint.DrawBorder (g, checkbox_rectangle, foreColor, ButtonBorderStyle.Solid);
bounds.Offset (-1, 0);
if (state == CheckState.Checked)
DrawCheck (g, bounds, Color.Black);
else if (state == CheckState.Indeterminate)
DrawCheck (g, bounds, SystemColors.ControlDarkDark);
}
public virtual void DrawFlatPressedCheckBox (Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
DrawFlatNormalCheckBox (g, bounds, backColor, foreColor, state);
}
public virtual void DrawFlatDisabledCheckBox (Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
Rectangle checkbox_rectangle;
checkbox_rectangle = new Rectangle (bounds.X, bounds.Y, Math.Max (bounds.Width - 2, 0), Math.Max (bounds.Height - 2, 0));
ControlPaint.DrawBorder (g, checkbox_rectangle, foreColor, ButtonBorderStyle.Solid);
bounds.Offset (-1, 0);
if (state == CheckState.Checked || state == CheckState.Indeterminate)
DrawCheck (g, bounds, SystemColors.ControlDarkDark);
}
#endregion
#region Popup
public virtual void DrawPopupNormalCheckBox (Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
DrawFlatNormalCheckBox (g, bounds, backColor, foreColor, state);
}
public virtual void DrawPopupHotCheckBox (Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
Rectangle checkbox_rectangle;
Rectangle fill_rectangle;
// clip one pixel from bottom right for non popup rendered checkboxes
checkbox_rectangle = new Rectangle (bounds.X, bounds.Y, Math.Max (bounds.Width - 1, 0), Math.Max (bounds.Height - 1, 0));
fill_rectangle = new Rectangle (checkbox_rectangle.X + 1, checkbox_rectangle.Y + 1, Math.Max (checkbox_rectangle.Width - 3, 0), Math.Max (checkbox_rectangle.Height - 3, 0));
g.FillRectangle (ResPool.GetSolidBrush (ControlPaint.LightLight (backColor)), fill_rectangle);
// draw sunken effect
ThemeEngine.Current.CPDrawBorder3D (g, checkbox_rectangle, Border3DStyle.SunkenInner, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, backColor);
bounds.Offset (-1, 0);
if (state == CheckState.Checked)
DrawCheck (g, bounds, Color.Black);
else if (state == CheckState.Indeterminate)
DrawCheck (g, bounds, SystemColors.ControlDarkDark);
}
public virtual void DrawPopupPressedCheckBox (Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
Rectangle checkbox_rectangle;
Rectangle fill_rectangle;
// clip one pixel from bottom right for non popup rendered checkboxes
checkbox_rectangle = new Rectangle (bounds.X, bounds.Y, Math.Max (bounds.Width - 1, 0), Math.Max (bounds.Height - 1, 0));
fill_rectangle = new Rectangle (checkbox_rectangle.X + 1, checkbox_rectangle.Y + 1, Math.Max (checkbox_rectangle.Width - 3, 0), Math.Max (checkbox_rectangle.Height - 3, 0));
g.FillRectangle (ResPool.GetSolidBrush (backColor), fill_rectangle);
// draw sunken effect
ThemeEngine.Current.CPDrawBorder3D (g, checkbox_rectangle, Border3DStyle.SunkenInner, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, backColor);
bounds.Offset (-1, 0);
if (state == CheckState.Checked)
DrawCheck (g, bounds, Color.Black);
else if (state == CheckState.Indeterminate)
DrawCheck (g, bounds, SystemColors.ControlDarkDark);
}
public virtual void DrawPopupDisabledCheckBox (Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
DrawFlatDisabledCheckBox (g, bounds, backColor, foreColor, state);
}
#endregion
#region Check
public virtual void DrawCheck (Graphics g, Rectangle bounds, Color checkColor)
{
int check_size = (bounds.Height > bounds.Width) ? bounds.Width / 2 : bounds.Height / 2;
Pen check_pen = ResPool.GetPen (checkColor);
if (check_size < 7) {
int lineWidth = Math.Max (3, check_size / 3);
int Scale = Math.Max (1, check_size / 9);
Rectangle rect = new Rectangle (bounds.X + (bounds.Width / 2) - (check_size / 2) - 1, bounds.Y + (bounds.Height / 2) - (check_size / 2) - 1,
check_size, check_size);
for (int i = 0; i < lineWidth; i++) {
g.DrawLine (check_pen, rect.Left + lineWidth / 2, rect.Top + lineWidth + i, rect.Left + lineWidth / 2 + 2 * Scale, rect.Top + lineWidth + 2 * Scale + i);
g.DrawLine (check_pen, rect.Left + lineWidth / 2 + 2 * Scale, rect.Top + lineWidth + 2 * Scale + i, rect.Left + lineWidth / 2 + 6 * Scale, rect.Top + lineWidth - 2 * Scale + i);
}
} else {
int lineWidth = Math.Max (3, check_size / 3) + 1;
int x_half = bounds.Width / 2;
int y_half = bounds.Height / 2;
Rectangle rect = new Rectangle (bounds.X + x_half - (check_size / 2) - 1, bounds.Y + y_half - (check_size / 2),
check_size, check_size);
int gradient_left = check_size / 3;
int gradient_right = check_size - gradient_left - 1;
for (int i = 0; i < lineWidth; i++) {
g.DrawLine (check_pen, rect.X, rect.Bottom - 1 - gradient_left - i, rect.X + gradient_left, rect.Bottom - 1 - i);
g.DrawLine (check_pen, rect.X + gradient_left, rect.Bottom - 1 - i, rect.Right - 1, rect.Bottom - i - 1 - gradient_right);
}
}
}
#endregion
#region Private Methods
private int Clamp (int value, int lower, int upper)
{
if (value < lower) return lower;
else if (value > upper) return upper;
else return value;
}
private Color ColorControl {
get { return SystemColors.Control; }
}
#endregion
}
}

View File

@@ -0,0 +1,57 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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) 2007 Novell, Inc.
//
// Authors:
// Everaldo Canuto (ecanuto@novell.com)
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace System.Windows.Forms.Theming.Default
{
internal class LabelPainter
{
public LabelPainter ()
{
}
public virtual void Draw (Graphics dc, Rectangle client_rectangle, Label label)
{
Rectangle rect = label.PaddingClientRectangle;
label.DrawImage (dc, label.Image, rect, label.ImageAlign);
if (label.Enabled) {
dc.DrawString (label.Text, label.Font,
ThemeEngine.Current.ResPool.GetSolidBrush (label.ForeColor),
rect, label.string_format);
} else {
ControlPaint.DrawStringDisabled (
dc, label.Text, label.Font, label.BackColor, rect, label.string_format);
}
}
public virtual Size DefaultSize {
get { return new Size (100, 23); }
}
}
}

View File

@@ -0,0 +1,120 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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) 2007 Novell, Inc.
//
// Authors:
// Everaldo Canuto (ecanuto@novell.com)
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace System.Windows.Forms.Theming.Default
{
internal class LinkLabelPainter
{
public LinkLabelPainter ()
{
}
private Color GetPieceColor (LinkLabel label, LinkLabel.Piece piece, int i)
{
if (!label.Enabled)
return label.DisabledLinkColor;
if (piece.link == null)
return label.ForeColor;
if (!piece.link.Enabled)
return label.DisabledLinkColor;
if (piece.link.Active)
return label.ActiveLinkColor;
if ((label.LinkVisited && i == 0) || piece.link.Visited)
return label.VisitedLinkColor;
return label.LinkColor;
}
public virtual void Draw (Graphics dc, Rectangle clip_rectangle, LinkLabel label)
{
Rectangle client_rect = label.PaddingClientRectangle;
label.DrawImage (dc, label.Image, client_rect, label.ImageAlign);
if (label.pieces == null)
return;
// Paint all text as disabled.
if (!label.Enabled) {
dc.SetClip (clip_rectangle);
ThemeEngine.Current.CPDrawStringDisabled (
dc, label.Text, label.Font, label.BackColor, client_rect, label.string_format);
return;
}
Font font, link_font = ThemeEngine.Current.GetLinkFont (label);
Region text_region = new Region (new Rectangle());
// Draw links.
for (int i = 0; i < label.pieces.Length; i ++) {
LinkLabel.Piece piece = label.pieces[i];
if (piece.link == null) {
text_region.Union (piece.region);
continue;
}
Color color = GetPieceColor (label, piece, i);
if ( (label.LinkBehavior == LinkBehavior.AlwaysUnderline) ||
(label.LinkBehavior == LinkBehavior.SystemDefault) ||
((label.LinkBehavior == LinkBehavior.HoverUnderline) && piece.link.Hovered) )
font = link_font;
else
font = label.Font;
dc.Clip = piece.region;
dc.Clip.Intersect (clip_rectangle);
dc.DrawString (label.Text, font,
ThemeEngine.Current.ResPool.GetSolidBrush (color),
client_rect, label.string_format);
// Draw focus rectangle
if ((piece.link != null) && piece.link.Focused) {
foreach (RectangleF rect in piece.region.GetRegionScans (dc.Transform))
ControlPaint.DrawFocusRectangle (dc, Rectangle.Round (rect), label.ForeColor, label.BackColor);
}
}
// Draw normal text (without links).
if (!text_region.IsEmpty (dc)) {
dc.Clip = text_region;
dc.Clip.Intersect (clip_rectangle);
if (!dc.Clip.IsEmpty (dc))
dc.DrawString(label.Text, label.Font,
ThemeEngine.Current.ResPool.GetSolidBrush(label.ForeColor),
client_rect, label.string_format);
}
}
}
}

View File

@@ -0,0 +1,239 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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) 2007 Novell, Inc.
//
// Authors:
// Jonathan Pobst (monkey@jpobst.com)
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace System.Windows.Forms.Theming.Default
{
/// <summary>
/// Summary description for Button.
/// </summary>
internal class RadioButtonPainter
{
public RadioButtonPainter ()
{
}
protected SystemResPool ResPool { get { return ThemeEngine.Current.ResPool; } }
public void PaintRadioButton (Graphics g, Rectangle bounds, Color backColor, Color foreColor, ElementState state, FlatStyle style, bool isChecked)
{
switch (style) {
case FlatStyle.Standard:
case FlatStyle.System:
switch (state) {
case ElementState.Normal:
DrawNormalRadioButton (g, bounds, backColor, foreColor, isChecked);
break;
case ElementState.Hot:
DrawHotRadioButton (g, bounds, backColor, foreColor, isChecked);
break;
case ElementState.Pressed:
DrawPressedRadioButton (g, bounds, backColor, foreColor, isChecked);
break;
case ElementState.Disabled:
DrawDisabledRadioButton (g, bounds, backColor, foreColor, isChecked);
break;
}
break;
case FlatStyle.Flat:
switch (state) {
case ElementState.Normal:
DrawFlatNormalRadioButton (g, bounds, backColor, foreColor, isChecked);
break;
case ElementState.Hot:
DrawFlatHotRadioButton (g, bounds, backColor, foreColor, isChecked);
break;
case ElementState.Pressed:
DrawFlatPressedRadioButton (g, bounds, backColor, foreColor, isChecked);
break;
case ElementState.Disabled:
DrawFlatDisabledRadioButton (g, bounds, backColor, foreColor, isChecked);
break;
}
break;
case FlatStyle.Popup:
switch (state) {
case ElementState.Normal:
DrawPopupNormalRadioButton (g, bounds, backColor, foreColor, isChecked);
break;
case ElementState.Hot:
DrawPopupHotRadioButton (g, bounds, backColor, foreColor, isChecked);
break;
case ElementState.Pressed:
DrawPopupPressedRadioButton (g, bounds, backColor, foreColor, isChecked);
break;
case ElementState.Disabled:
DrawPopupDisabledRadioButton (g, bounds, backColor, foreColor, isChecked);
break;
}
break;
}
}
#region Standard
public virtual void DrawNormalRadioButton (Graphics g, Rectangle bounds, Color backColor, Color foreColor, bool isChecked)
{
ButtonState bs = ButtonState.Normal;
if (isChecked)
bs |= ButtonState.Checked;
ControlPaint.DrawRadioButton (g, bounds, bs);
}
public virtual void DrawHotRadioButton (Graphics g, Rectangle bounds, Color backColor, Color foreColor, bool isChecked)
{
DrawNormalRadioButton (g, bounds, backColor, foreColor, isChecked);
}
public virtual void DrawPressedRadioButton (Graphics g, Rectangle bounds, Color backColor, Color foreColor, bool isChecked)
{
ButtonState bs = ButtonState.Pushed;
if (isChecked)
bs |= ButtonState.Checked;
ControlPaint.DrawRadioButton (g, bounds, bs);
}
public virtual void DrawDisabledRadioButton (Graphics g, Rectangle bounds, Color backColor, Color foreColor, bool isChecked)
{
ButtonState bs = ButtonState.Inactive;
if (isChecked)
bs |= ButtonState.Checked;
ControlPaint.DrawRadioButton (g, bounds, bs);
}
#endregion
#region FlatStyle
public virtual void DrawFlatNormalRadioButton (Graphics g, Rectangle bounds, Color backColor, Color foreColor, bool isChecked)
{
g.DrawArc (SystemPens.ControlDarkDark, bounds, 0, 359);
g.FillPie (SystemBrushes.ControlLightLight, bounds.X + 1, bounds.Y + 1, bounds.Width - 2, bounds.Height - 2, 0, 359);
if (isChecked)
DrawFlatRadioGlyphDot (g, bounds, SystemColors.ControlDarkDark);
}
public virtual void DrawFlatHotRadioButton (Graphics g, Rectangle bounds, Color backColor, Color foreColor, bool isChecked)
{
g.DrawArc (SystemPens.ControlDarkDark, bounds, 0, 359);
g.FillPie (SystemBrushes.ControlLight, bounds.X + 1, bounds.Y + 1, bounds.Width - 2, bounds.Height - 2, 0, 359);
if (isChecked)
DrawFlatRadioGlyphDot (g, bounds, SystemColors.ControlDarkDark);
}
public virtual void DrawFlatPressedRadioButton (Graphics g, Rectangle bounds, Color backColor, Color foreColor, bool isChecked)
{
g.DrawArc (SystemPens.ControlDarkDark, bounds, 0, 359);
g.FillPie (SystemBrushes.ControlLightLight, bounds.X + 1, bounds.Y + 1, bounds.Width - 2, bounds.Height - 2, 0, 359);
if (isChecked)
DrawFlatRadioGlyphDot (g, bounds, SystemColors.ControlDarkDark);
}
public virtual void DrawFlatDisabledRadioButton (Graphics g, Rectangle bounds, Color backColor, Color foreColor, bool isChecked)
{
g.FillPie (SystemBrushes.Control, bounds.X + 1, bounds.Y + 1, bounds.Width - 2, bounds.Height - 2, 0, 359);
g.DrawArc (SystemPens.ControlDark, bounds, 0, 359);
if (isChecked)
DrawFlatRadioGlyphDot (g, bounds, SystemColors.ControlDark);
}
#endregion
#region Popup
public virtual void DrawPopupNormalRadioButton (Graphics g, Rectangle bounds, Color backColor, Color foreColor, bool isChecked)
{
g.FillPie (SystemBrushes.ControlLightLight, bounds, 0, 359);
g.DrawArc (SystemPens.ControlDark, bounds, 0, 359);
if (isChecked)
DrawFlatRadioGlyphDot (g, bounds, SystemColors.ControlDarkDark);
}
public virtual void DrawPopupHotRadioButton (Graphics g, Rectangle bounds, Color backColor, Color foreColor, bool isChecked)
{
g.FillPie (SystemBrushes.ControlLightLight, bounds, 0, 359);
g.DrawArc (SystemPens.ControlLight, bounds.X + 1, bounds.Y + 1, bounds.Width - 2, bounds.Height - 2, 0, 359);
g.DrawArc (SystemPens.ControlDark, bounds, 135, 180);
g.DrawArc (SystemPens.ControlLightLight, bounds, 315, 180);
if (isChecked)
DrawFlatRadioGlyphDot (g, bounds, SystemColors.ControlDarkDark);
}
public virtual void DrawPopupPressedRadioButton (Graphics g, Rectangle bounds, Color backColor, Color foreColor, bool isChecked)
{
g.FillPie (SystemBrushes.ControlLightLight, bounds, 0, 359);
g.DrawArc (SystemPens.ControlLight, bounds.X + 1, bounds.Y + 1, bounds.Width - 2, bounds.Height - 2, 0, 359);
g.DrawArc (SystemPens.ControlDark, bounds, 135, 180);
g.DrawArc (SystemPens.ControlLightLight, bounds, 315, 180);
if (isChecked)
DrawFlatRadioGlyphDot (g, bounds, SystemColors.ControlDarkDark);
}
public virtual void DrawPopupDisabledRadioButton (Graphics g, Rectangle bounds, Color backColor, Color foreColor, bool isChecked)
{
g.FillPie (SystemBrushes.Control, bounds.X + 1, bounds.Y + 1, bounds.Width - 2, bounds.Height - 2, 0, 359);
g.DrawArc (SystemPens.ControlDark, bounds, 0, 359);
if (isChecked)
DrawFlatRadioGlyphDot (g, bounds, SystemColors.ControlDarkDark);
}
#endregion
#region Glyph
protected void DrawFlatRadioGlyphDot (Graphics g, Rectangle bounds, Color dotColor)
{
int lineWidth = Math.Max (1, Math.Min (bounds.Width, bounds.Height) / 3);
Pen dot_pen = ResPool.GetPen (dotColor);
Brush dot_brush = ResPool.GetSolidBrush (dotColor);
if (bounds.Height > 13) {
g.FillPie (dot_brush, bounds.X + lineWidth, bounds.Y + lineWidth, bounds.Width - lineWidth * 2, bounds.Height - lineWidth * 2, 0, 359);
} else {
int x_half_pos = (bounds.Width / 2) + bounds.X;
int y_half_pos = (bounds.Height / 2) + bounds.Y;
g.DrawLine (dot_pen, x_half_pos - 1, y_half_pos, x_half_pos + 2, y_half_pos);
g.DrawLine (dot_pen, x_half_pos - 1, y_half_pos + 1, x_half_pos + 2, y_half_pos + 1);
g.DrawLine (dot_pen, x_half_pos, y_half_pos - 1, x_half_pos, y_half_pos + 2);
g.DrawLine (dot_pen, x_half_pos + 1, y_half_pos - 1, x_half_pos + 1, y_half_pos + 2);
}
}
#endregion
}
}

View File

@@ -0,0 +1,189 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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) 2007 Novell, Inc.
//
// Authors:
// Jonathan Pobst (monkey@jpobst.com)
using System;
using System.Drawing;
namespace System.Windows.Forms.Theming.Default
{
internal class ToolStripPainter
{
public ToolStripPainter ()
{
}
protected SystemResPool ResPool { get { return ThemeEngine.Current.ResPool; } }
#region Painting
public virtual void OnRenderButtonBackground (ToolStripItemRenderEventArgs e)
{
if (e.Item.Enabled == false)
return;
Rectangle paint_here = new Rectangle (0, 0, e.Item.Width, e.Item.Height);
ToolStripButton tsb = e.Item as ToolStripButton;
if (e.Item.Pressed || (tsb != null && tsb.Checked))
ControlPaint.DrawBorder3D (e.Graphics, paint_here, Border3DStyle.SunkenOuter);
else if (e.Item.Selected)
ControlPaint.DrawBorder3D (e.Graphics, paint_here, Border3DStyle.RaisedInner);
else if (e.Item.BackColor != Control.DefaultBackColor && e.Item.BackColor != Color.Empty)
e.Graphics.FillRectangle (ResPool.GetSolidBrush (e.Item.BackColor), paint_here);
}
public virtual void OnRenderDropDownButtonBackground (ToolStripItemRenderEventArgs e)
{
if (e.Item.Enabled == false)
return;
Rectangle paint_here = new Rectangle (0, 0, e.Item.Width, e.Item.Height);
if (e.Item.Pressed)
ControlPaint.DrawBorder3D (e.Graphics, paint_here, Border3DStyle.SunkenOuter);
else if (e.Item.Selected)
ControlPaint.DrawBorder3D (e.Graphics, paint_here, Border3DStyle.RaisedInner);
else if (e.Item.BackColor != Control.DefaultBackColor && e.Item.BackColor != Color.Empty)
e.Graphics.FillRectangle (ResPool.GetSolidBrush (e.Item.BackColor), paint_here);
}
public virtual void OnRenderGrip (ToolStripGripRenderEventArgs e)
{
if (e.GripStyle == ToolStripGripStyle.Hidden)
return;
if (e.GripDisplayStyle == ToolStripGripDisplayStyle.Vertical) {
e.Graphics.DrawLine (Pens.White, 0, 2, 1, 2);
e.Graphics.DrawLine (Pens.White, 0, 2, 0, e.GripBounds.Height - 3);
e.Graphics.DrawLine (SystemPens.ControlDark, 2, 2, 2, e.GripBounds.Height - 3);
e.Graphics.DrawLine (SystemPens.ControlDark, 2, e.GripBounds.Height - 3, 0, e.GripBounds.Height - 3);
}
else {
e.Graphics.DrawLine (Pens.White, 2, 0, e.GripBounds.Width - 3, 0);
e.Graphics.DrawLine (Pens.White, 2, 0, 2, 1);
e.Graphics.DrawLine (SystemPens.ControlDark, e.GripBounds.Width - 3, 0, e.GripBounds.Width - 3, 2);
e.Graphics.DrawLine (SystemPens.ControlDark, 2, 2, e.GripBounds.Width - 3, 2);
}
}
public virtual void OnRenderMenuItemBackground (ToolStripItemRenderEventArgs e)
{
ToolStripMenuItem tsmi = (ToolStripMenuItem)e.Item;
Rectangle paint_here = new Rectangle (Point.Empty, tsmi.Size);
if (tsmi.IsOnDropDown) {
// Drop down menu item
if (e.Item.Selected || e.Item.Pressed)
e.Graphics.FillRectangle (SystemBrushes.Highlight, paint_here);
} else {
// Top level menu item
if (e.Item.Pressed)
ControlPaint.DrawBorder3D (e.Graphics, paint_here, Border3DStyle.SunkenOuter);
else if (e.Item.Selected)
ControlPaint.DrawBorder3D (e.Graphics, paint_here, Border3DStyle.RaisedInner);
else if (e.Item.BackColor != Control.DefaultBackColor && e.Item.BackColor != Color.Empty)
e.Graphics.FillRectangle (ResPool.GetSolidBrush (e.Item.BackColor), paint_here);
}
}
public virtual void OnRenderOverflowButtonBackground (ToolStripItemRenderEventArgs e)
{
Rectangle paint_here = new Rectangle (Point.Empty, e.Item.Size);
if (e.Item.Pressed)
ControlPaint.DrawBorder3D (e.Graphics, paint_here, Border3DStyle.SunkenOuter);
else if (e.Item.Selected)
ControlPaint.DrawBorder3D (e.Graphics, paint_here, Border3DStyle.RaisedInner);
else if (e.Item.BackColor != Control.DefaultBackColor && e.Item.BackColor != Color.Empty)
e.Graphics.FillRectangle (ResPool.GetSolidBrush (e.Item.BackColor), paint_here);
// Paint the arrow
ToolStripRenderer.DrawDownArrow (e.Graphics, SystemPens.ControlText, e.Item.Width / 2 - 3, e.Item.Height / 2 - 1);
}
public virtual void OnRenderSeparator (ToolStripSeparatorRenderEventArgs e)
{
if (e.Vertical) {
e.Graphics.DrawLine (Pens.White, 4, 3, 4, e.Item.Height - 1);
e.Graphics.DrawLine (SystemPens.ControlDark, 3, 3, 3, e.Item.Height - 1);
} else {
if (!e.Item.IsOnDropDown) {
e.Graphics.DrawLine (Pens.White, 2, 4, e.Item.Right - 1, 4);
e.Graphics.DrawLine (SystemPens.ControlDark, 2, 3, e.Item.Right - 1, 3);
} else {
e.Graphics.DrawLine (Pens.White, 3, 4, e.Item.Right - 4, 4);
e.Graphics.DrawLine (SystemPens.ControlDark, 3, 3, e.Item.Right - 4, 3);
}
}
}
public virtual void OnRenderSplitButtonBackground (ToolStripItemRenderEventArgs e)
{
ToolStripSplitButton tssb = (ToolStripSplitButton)e.Item;
Rectangle button_part = new Rectangle (Point.Empty, tssb.ButtonBounds.Size);
Point drop_start = new Point (tssb.Width - tssb.DropDownButtonBounds.Width, 0);
Rectangle drop_part = new Rectangle (drop_start, tssb.DropDownButtonBounds.Size);
// Regular button part
if (tssb.ButtonPressed)
ControlPaint.DrawBorder3D (e.Graphics, button_part, Border3DStyle.SunkenOuter);
else if (tssb.ButtonSelected)
ControlPaint.DrawBorder3D (e.Graphics, button_part, Border3DStyle.RaisedInner);
else if (e.Item.BackColor != Control.DefaultBackColor && e.Item.BackColor != Color.Empty)
e.Graphics.FillRectangle (ResPool.GetSolidBrush (e.Item.BackColor), button_part);
// Drop down button part
if (tssb.DropDownButtonPressed || tssb.ButtonPressed)
ControlPaint.DrawBorder3D (e.Graphics, drop_part, Border3DStyle.SunkenOuter);
else if (tssb.DropDownButtonSelected || tssb.ButtonSelected)
ControlPaint.DrawBorder3D (e.Graphics, drop_part, Border3DStyle.RaisedInner);
else if (e.Item.BackColor != Control.DefaultBackColor && e.Item.BackColor != Color.Empty)
e.Graphics.FillRectangle (ResPool.GetSolidBrush (e.Item.BackColor), drop_part);
}
public virtual void OnRenderToolStripBackground (ToolStripRenderEventArgs e)
{
if (e.ToolStrip.BackgroundImage == null)
e.Graphics.Clear (e.BackColor);
if (e.ToolStrip is StatusStrip)
e.Graphics.DrawLine (Pens.White, e.AffectedBounds.Left, e.AffectedBounds.Top, e.AffectedBounds.Right, e.AffectedBounds.Top);
}
public virtual void OnRenderToolStripBorder (ToolStripRenderEventArgs e)
{
if (e.ToolStrip is StatusStrip)
return;
if (e.ToolStrip is ToolStripDropDown)
ControlPaint.DrawBorder3D (e.Graphics, e.AffectedBounds, Border3DStyle.Raised);
else {
e.Graphics.DrawLine (SystemPens.ControlDark, new Point (e.ToolStrip.Left, e.ToolStrip.Height - 2), new Point (e.ToolStrip.Right, e.ToolStrip.Height - 2));
e.Graphics.DrawLine (Pens.White, new Point (e.ToolStrip.Left, e.ToolStrip.Height - 1), new Point (e.ToolStrip.Right, e.ToolStrip.Height - 1));
}
}
#endregion
}
}

View File

@@ -0,0 +1,142 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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) 2007 Novell, Inc.
//
// Authors:
// Jonathan Pobst (monkey@jpobst.com)
// Everaldo Canuto <ecanuto@novell.com>
using System;
using System.Drawing;
using System.Reflection;
namespace System.Windows.Forms.Theming
{
internal class ThemeElements
{
private static ThemeElementsDefault theme;
public static ThemeElementsDefault CurrentTheme {
get { return theme; }
}
static ThemeElements ()
{
string theme_var;
theme_var = Environment.GetEnvironmentVariable ("MONO_THEME");
if (theme_var == null)
theme_var = "win32";
else
theme_var = theme_var.ToLower ();
theme = LoadTheme (theme_var);
}
private static ThemeElementsDefault LoadTheme (string themeName)
{
if (themeName == "visualstyles")
if (Application.VisualStylesEnabled)
return new ThemeElementsVisualStyles ();
else
return new ThemeElementsDefault ();
Assembly ass = Assembly.GetExecutingAssembly ();
string iname = typeof(ThemeElements).FullName;
string assemblyname = iname + themeName;
Type type = ass.GetType (assemblyname, false, true);
if (type != null) {
object o = ass.CreateInstance (type.FullName);
if (o != null)
return (ThemeElementsDefault) o;
}
return new ThemeElementsDefault ();
}
#region Buttons
public static void DrawButton (Graphics g, Rectangle bounds, ButtonThemeState state, Color backColor, Color foreColor)
{
theme.ButtonPainter.Draw (g, bounds, state, backColor, foreColor);
}
public static void DrawFlatButton (Graphics g, Rectangle bounds, ButtonThemeState state, Color backColor, Color foreColor, FlatButtonAppearance appearance)
{
theme.ButtonPainter.DrawFlat (g, bounds, state, backColor, foreColor, appearance);
}
public static void DrawPopupButton (Graphics g, Rectangle bounds, ButtonThemeState state, Color backColor, Color foreColor)
{
theme.ButtonPainter.DrawPopup (g, bounds, state, backColor, foreColor);
}
#endregion
#region Painters
public virtual Default.ButtonPainter ButtonPainter {
get { return theme.ButtonPainter; }
}
public static Default.LabelPainter LabelPainter {
get { return theme.LabelPainter; }
}
public static Default.LinkLabelPainter LinkLabelPainter {
get { return theme.LinkLabelPainter; }
}
public virtual Default.TabControlPainter TabControlPainter {
get { return theme.TabControlPainter; }
}
public virtual Default.CheckBoxPainter CheckBoxPainter {
get { return theme.CheckBoxPainter; }
}
public virtual Default.RadioButtonPainter RadioButtonPainter {
get { return theme.RadioButtonPainter; }
}
public virtual Default.ToolStripPainter ToolStripPainter {
get { return theme.ToolStripPainter; }
}
#endregion
}
#region Internal Enums
[Flags]
internal enum ButtonThemeState
{
Normal = 1,
Entered = 2,
Pressed = 4,
Disabled = 8,
Default = 16
}
internal enum ElementState
{
Normal = 1,
Hot = 2,
Pressed = 3,
Disabled = 4
}
#endregion
}

View File

@@ -0,0 +1,95 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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) 2007 Novell, Inc.
//
// Authors:
// Jonathan Pobst (monkey@jpobst.com)
// Andreia Gaita (avidigal@novell.com)
using System;
namespace System.Windows.Forms.Theming
{
internal class ThemeElementsDefault
{
protected Default.TabControlPainter tabControlPainter;
public virtual Default.TabControlPainter TabControlPainter {
get {
if (tabControlPainter == null)
tabControlPainter = new Default.TabControlPainter ();
return tabControlPainter;
}
}
protected Default.ButtonPainter buttonPainter;
public virtual Default.ButtonPainter ButtonPainter {
get {
if (buttonPainter == null)
buttonPainter = new Default.ButtonPainter ();
return buttonPainter;
}
}
protected Default.LabelPainter labelPainter;
public virtual Default.LabelPainter LabelPainter {
get {
if (labelPainter == null)
labelPainter = new Default.LabelPainter ();
return labelPainter;
}
}
protected Default.LinkLabelPainter linklabelPainter;
public virtual Default.LinkLabelPainter LinkLabelPainter {
get {
if (linklabelPainter == null)
linklabelPainter = new Default.LinkLabelPainter ();
return linklabelPainter;
}
}
protected Default.ToolStripPainter toolStripPainter;
public virtual Default.ToolStripPainter ToolStripPainter {
get {
if (toolStripPainter == null)
toolStripPainter = new Default.ToolStripPainter ();
return toolStripPainter;
}
}
protected Default.CheckBoxPainter checkBoxPainter;
public virtual Default.CheckBoxPainter CheckBoxPainter {
get {
if (checkBoxPainter == null)
checkBoxPainter = new Default.CheckBoxPainter ();
return checkBoxPainter;
}
}
protected Default.RadioButtonPainter radioButtonPainter;
public virtual Default.RadioButtonPainter RadioButtonPainter {
get {
if (radioButtonPainter == null)
radioButtonPainter = new Default.RadioButtonPainter ();
return radioButtonPainter;
}
}
}
}

View File

@@ -0,0 +1,58 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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) 2008 George Giolfan
//
// Authors:
// George Giolfan (georgegiolfan@yahoo.com)
namespace System.Windows.Forms.Theming
{
class ThemeElementsVisualStyles : ThemeElementsDefault
{
public override Default.CheckBoxPainter CheckBoxPainter {
get {
if (checkBoxPainter == null)
checkBoxPainter = new VisualStyles.CheckBoxPainter ();
return checkBoxPainter;
}
}
public override Default.RadioButtonPainter RadioButtonPainter {
get {
if (radioButtonPainter == null)
radioButtonPainter = new VisualStyles.RadioButtonPainter ();
return radioButtonPainter;
}
}
public override Default.ToolStripPainter ToolStripPainter {
get {
if (toolStripPainter == null)
toolStripPainter = new VisualStyles.ToolStripPainter ();
return toolStripPainter;
}
}
public override Default.TabControlPainter TabControlPainter {
get {
if (tabControlPainter == null)
tabControlPainter = new VisualStyles.TabControlPainter ();
return tabControlPainter;
}
}
}
}

View File

@@ -0,0 +1,55 @@
2010-06-25 Carlos Alberto Cortez <calberto.cortez@gmail.com>
* TabControlPainter.cs: Use TabControl.Font to draw instead of
TabPage.Font values.
Fixes bits of #551032.
2010-05-17 Carlos Alberto Cortez <calberto.cortez@gmail.com>
* TabControlPainter.cs: When drawing the contents of our tabs use
TabControl.Padding instead of BorderThickness and FocusRectSpacing.
2008-10-20 Jonathan Pobst <monkey@jpobst.com>
* ToolStripPainter.cs: Don't paint over a set BackgroundImage.
2008-09-16 Jonathan Pobst <monkey@jpobst.com>
* TabControlPainter.cs: Hook tab painting into ShowFocusCues.
2008-07-31 George Giolfan <georgegiolfan@yahoo.com>
* TabControlPainter.cs: Added DrawScrollButton.
2008-07-09 George Giolfan <georgegiolfan@yahoo.com>
* TabControlPainter.cs, ToolStripPainter.cs: Now falls back to the default
implementation when Visual Styles should not be used.
2008-05-21 George Giolfan <georgegiolfan@yahoo.com>
* TabControlPainter.cs: Enabled support for the hot style.
2008-05-19 George Giolfan <georgegiolfan@yahoo.com>
* TabControlPainter.cs: Refactored: Used DrawBackground instead of Draw.
2008-05-07 George Giolfan <georgegiolfan@yahoo.com>
* ToolStripPainter.cs: Added.
2008-04-30 George Giolfan <georgegiolfan@yahoo.com>
* TabControlPainter.cs: Ordered usings.
2008-04-28 George Giolfan <georgegiolfan@yahoo.com>
* TabControlPainter.cs: Fixed duplication.
2008-04-28 George Giolfan <georgegiolfan@yahoo.com>
* TabControlPainter.cs: Added.
2008-04-25 George Giolfan <georgegiolfan@yahoo.com>
* CheckBoxPainter.cs, RadioButtonPainter.cs: Added.

View File

@@ -0,0 +1,104 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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) 2008 George Giolfan
//
// Authors:
// George Giolfan (georgegiolfan@yahoo.com)
using System.Drawing;
using System.Windows.Forms.VisualStyles;
namespace System.Windows.Forms.Theming.VisualStyles
{
class CheckBoxPainter : Default.CheckBoxPainter
{
public override void DrawNormalCheckBox (Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
CheckBoxState check_box_state;
switch (state) {
case CheckState.Checked:
check_box_state = CheckBoxState.CheckedNormal;
break;
case CheckState.Indeterminate:
check_box_state = CheckBoxState.MixedNormal;
break;
default:
check_box_state = CheckBoxState.UncheckedNormal;
break;
}
DrawCheckBox (g, bounds, check_box_state);
}
public override void DrawHotCheckBox (Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
CheckBoxState check_box_state;
switch (state) {
case CheckState.Checked:
check_box_state = CheckBoxState.CheckedHot;
break;
case CheckState.Indeterminate:
check_box_state = CheckBoxState.MixedHot;
break;
default:
check_box_state = CheckBoxState.UncheckedHot;
break;
}
DrawCheckBox (g, bounds, check_box_state);
}
public override void DrawPressedCheckBox (Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
CheckBoxState check_box_state;
switch (state) {
case CheckState.Checked:
check_box_state = CheckBoxState.CheckedPressed;
break;
case CheckState.Indeterminate:
check_box_state = CheckBoxState.MixedPressed;
break;
default:
check_box_state = CheckBoxState.UncheckedPressed;
break;
}
DrawCheckBox (g, bounds, check_box_state);
}
public override void DrawDisabledCheckBox (Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
CheckBoxState check_box_state;
switch (state) {
case CheckState.Checked:
check_box_state = CheckBoxState.CheckedDisabled;
break;
case CheckState.Indeterminate:
check_box_state = CheckBoxState.MixedDisabled;
break;
default:
check_box_state = CheckBoxState.UncheckedDisabled;
break;
}
DrawCheckBox (g, bounds, check_box_state);
}
static void DrawCheckBox (Graphics g, Rectangle bounds, CheckBoxState state)
{
CheckBoxRenderer.DrawCheckBox (
g,
bounds.Location,
state
);
}
}
}

View File

@@ -0,0 +1,56 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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) 2008 George Giolfan
//
// Authors:
// George Giolfan (georgegiolfan@yahoo.com)
using System.Drawing;
using System.Windows.Forms.VisualStyles;
namespace System.Windows.Forms.Theming.VisualStyles
{
class RadioButtonPainter : Default.RadioButtonPainter
{
public override void DrawNormalRadioButton (Graphics g, Rectangle bounds, Color backColor, Color foreColor, bool isChecked)
{
DrawRadioButton (g, bounds, isChecked ? RadioButtonState.CheckedNormal : RadioButtonState.UncheckedNormal);
}
public override void DrawHotRadioButton(Graphics g, Rectangle bounds, Color backColor, Color foreColor, bool isChecked)
{
DrawRadioButton (g, bounds, isChecked ? RadioButtonState.CheckedHot : RadioButtonState.UncheckedHot);
}
public override void DrawPressedRadioButton(Graphics g, Rectangle bounds, Color backColor, Color foreColor, bool isChecked)
{
DrawRadioButton (g, bounds, isChecked ? RadioButtonState.CheckedPressed : RadioButtonState.UncheckedPressed);
}
public override void DrawDisabledRadioButton(Graphics g, Rectangle bounds, Color backColor, Color foreColor, bool isChecked)
{
DrawRadioButton (g, bounds, isChecked ? RadioButtonState.CheckedDisabled : RadioButtonState.UncheckedDisabled);
}
static void DrawRadioButton (Graphics g, Rectangle bounds, RadioButtonState state)
{
RadioButtonRenderer.DrawRadioButton (
g,
bounds.Location,
state
);
}
}
}

View File

@@ -0,0 +1,265 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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) 2008 George Giolfan
//
// Authors:
// George Giolfan (georgegiolfan@yahoo.com)
using System.Drawing;
using System.Windows.Forms.VisualStyles;
namespace System.Windows.Forms.Theming.VisualStyles
{
class TabControlPainter : Default.TabControlPainter
{
static bool ShouldPaint (TabControl tabControl) {
return ThemeVisualStyles.RenderClientAreas &&
tabControl.Alignment == TabAlignment.Top &&
tabControl.DrawMode == TabDrawMode.Normal;
}
protected override void DrawBackground (Graphics dc, Rectangle area, TabControl tab)
{
if (!ShouldPaint (tab)) {
base.DrawBackground (dc, area, tab);
return;
}
VisualStyleElement element = VisualStyleElement.Tab.Pane.Normal;
if (!VisualStyleRenderer.IsElementDefined (element)) {
base.DrawBackground (dc, area, tab);
return;
}
Rectangle panel_rectangle = GetTabPanelRect (tab);
if (panel_rectangle.IntersectsWith (area))
new VisualStyleRenderer (element).DrawBackground (dc, panel_rectangle, area);
}
protected override int DrawTab (Graphics dc, TabPage page, TabControl tab, Rectangle bounds, bool is_selected)
{
if (!ShouldPaint (tab))
return base.DrawTab (dc, page, tab, bounds, is_selected);
VisualStyleElement element = GetVisualStyleElement (tab, page, is_selected);
if (!VisualStyleRenderer.IsElementDefined (element))
return base.DrawTab (dc, page, tab, bounds, is_selected);
new VisualStyleRenderer (element).DrawBackground (dc, bounds);
bounds.Inflate (
-(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;
tab.ImageList.Draw (dc, new Point (bounds.X, image_y), page.ImageIndex);
int image_occupied_space = tab.ImageList.ImageSize.Width + 2;
text_area.X += image_occupied_space;
text_area.Width -= image_occupied_space;
}
if (page.Text != null)
dc.DrawString (page.Text, tab.Font, SystemBrushes.ControlText, text_area, DefaultFormatting);
if (tab.Focused && is_selected && tab.ShowFocusCues)
ControlPaint.DrawFocusRectangle (dc, bounds);
return 0;
}
static VisualStyleElement GetVisualStyleElement (TabControl tabControl, TabPage tabPage, bool selected)
{
bool top_edge = tabPage.Row == tabControl.RowCount;
int tab_page_index = tabControl.TabPages.IndexOf (tabPage);
bool left_edge = true;
int index;
for (index = tabControl.SliderPos; index < tab_page_index; index++)
if (tabControl.TabPages [index].Row == tabPage.Row) {
left_edge = false;
break;
}
bool right_edge = true;
for (index = tab_page_index; index < tabControl.TabCount; index++)
if (tabControl.TabPages [index].Row == tabPage.Row) {
right_edge = false;
break;
}
if (!tabPage.Enabled)
#region Disabled
if (top_edge)
if (left_edge)
if (right_edge)
return VisualStyleElement.Tab.TopTabItem.Disabled;
else
return VisualStyleElement.Tab.TopTabItemLeftEdge.Disabled;
else
if (right_edge)
return VisualStyleElement.Tab.TopTabItemRightEdge.Disabled;
else
return VisualStyleElement.Tab.TopTabItem.Disabled;
else
if (left_edge)
if (right_edge)
return VisualStyleElement.Tab.TabItem.Disabled;
else
return VisualStyleElement.Tab.TabItemLeftEdge.Disabled;
else
if (right_edge)
return VisualStyleElement.Tab.TabItemRightEdge.Disabled;
else
return VisualStyleElement.Tab.TabItem.Disabled;
#endregion
else if (selected)
#region Pressed
if (top_edge)
if (left_edge)
if (right_edge)
return VisualStyleElement.Tab.TopTabItem.Pressed;
else
return VisualStyleElement.Tab.TopTabItemLeftEdge.Pressed;
else
if (right_edge)
return VisualStyleElement.Tab.TopTabItemRightEdge.Pressed;
else
return VisualStyleElement.Tab.TopTabItem.Pressed;
else
if (left_edge)
if (right_edge)
return VisualStyleElement.Tab.TabItem.Pressed;
else
return VisualStyleElement.Tab.TabItemLeftEdge.Pressed;
else
if (right_edge)
return VisualStyleElement.Tab.TabItemRightEdge.Pressed;
else
return VisualStyleElement.Tab.TabItem.Pressed;
#endregion
else if (tabControl.EnteredTabPage == tabPage)
#region Hot
if (top_edge)
if (left_edge)
if (right_edge)
return VisualStyleElement.Tab.TopTabItem.Hot;
else
return VisualStyleElement.Tab.TopTabItemLeftEdge.Hot;
else
if (right_edge)
return VisualStyleElement.Tab.TopTabItemRightEdge.Hot;
else
return VisualStyleElement.Tab.TopTabItem.Hot;
else
if (left_edge)
if (right_edge)
return VisualStyleElement.Tab.TabItem.Hot;
else
return VisualStyleElement.Tab.TabItemLeftEdge.Hot;
else
if (right_edge)
return VisualStyleElement.Tab.TabItemRightEdge.Hot;
else
return VisualStyleElement.Tab.TabItem.Hot;
#endregion
else
#region Normal
if (top_edge)
if (left_edge)
if (right_edge)
return VisualStyleElement.Tab.TopTabItemBothEdges.Normal;
else
return VisualStyleElement.Tab.TopTabItemLeftEdge.Normal;
else
if (right_edge)
return VisualStyleElement.Tab.TopTabItemRightEdge.Normal;
else
return VisualStyleElement.Tab.TopTabItem.Normal;
else
if (left_edge)
if (right_edge)
return VisualStyleElement.Tab.TabItemBothEdges.Normal;
else
return VisualStyleElement.Tab.TabItemLeftEdge.Normal;
else
if (right_edge)
return VisualStyleElement.Tab.TabItemRightEdge.Normal;
else
return VisualStyleElement.Tab.TabItem.Normal;
#endregion
}
public override bool HasHotElementStyles (TabControl tabControl)
{
if (!ShouldPaint (tabControl))
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);
}
}
}

View File

@@ -0,0 +1,213 @@
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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) 2008 George Giolfan
//
// Authors:
// George Giolfan (georgegiolfan@yahoo.com)
using System.Drawing;
using System.Windows.Forms.VisualStyles;
namespace System.Windows.Forms.Theming.VisualStyles
{
class ToolStripPainter : Default.ToolStripPainter
{
static bool IsDisabled (ToolStripItem toolStripItem)
{
return !toolStripItem.Enabled;
}
static bool IsPressed (ToolStripItem toolStripItem)
{
return toolStripItem.Pressed;
}
static bool IsChecked (ToolStripItem toolStripItem)
{
ToolStripButton tool_strip_button = toolStripItem as ToolStripButton;
if (tool_strip_button == null)
return false;
return tool_strip_button.Checked;
}
static bool IsHot (ToolStripItem toolStripItem)
{
return toolStripItem.Selected;
}
public override void OnRenderButtonBackground (ToolStripItemRenderEventArgs e)
{
if (!ThemeVisualStyles.RenderClientAreas) {
base.OnRenderButtonBackground (e);
return;
}
VisualStyleElement element;
if (IsDisabled (e.Item))
element = VisualStyleElement.ToolBar.Button.Disabled;
else if (IsPressed (e.Item))
element = VisualStyleElement.ToolBar.Button.Pressed;
else if (IsChecked (e.Item))
if (IsHot (e.Item))
element = VisualStyleElement.ToolBar.Button.HotChecked;
else
element = VisualStyleElement.ToolBar.Button.Checked;
else if (IsHot (e.Item))
element = VisualStyleElement.ToolBar.Button.Hot;
else
element = VisualStyleElement.ToolBar.Button.Normal;
if (!VisualStyleRenderer.IsElementDefined (element)) {
base.OnRenderButtonBackground (e);
return;
}
new VisualStyleRenderer (element).DrawBackground (e.Graphics, e.Item.Bounds);
}
public override void OnRenderDropDownButtonBackground (ToolStripItemRenderEventArgs e)
{
if (!ThemeVisualStyles.RenderClientAreas) {
base.OnRenderDropDownButtonBackground (e);
return;
}
VisualStyleElement element;
if (IsDisabled (e.Item))
element = VisualStyleElement.ToolBar.DropDownButton.Disabled;
else if (IsPressed (e.Item))
element = VisualStyleElement.ToolBar.DropDownButton.Pressed;
else if (IsChecked (e.Item))
if (IsHot (e.Item))
element = VisualStyleElement.ToolBar.DropDownButton.HotChecked;
else
element = VisualStyleElement.ToolBar.DropDownButton.Checked;
else if (IsHot (e.Item))
element = VisualStyleElement.ToolBar.DropDownButton.Hot;
else
element = VisualStyleElement.ToolBar.DropDownButton.Normal;
if (!VisualStyleRenderer.IsElementDefined (element)) {
base.OnRenderDropDownButtonBackground (e);
return;
}
new VisualStyleRenderer (element).DrawBackground (e.Graphics, e.Item.Bounds);
}
public override void OnRenderGrip (ToolStripGripRenderEventArgs e)
{
if (!ThemeVisualStyles.RenderClientAreas) {
base.OnRenderGrip (e);
return;
}
if (e.GripStyle == ToolStripGripStyle.Hidden)
return;
VisualStyleElement element = e.GripDisplayStyle == ToolStripGripDisplayStyle.Vertical ?
VisualStyleElement.Rebar.Gripper.Normal :
VisualStyleElement.Rebar.GripperVertical.Normal;
if (!VisualStyleRenderer.IsElementDefined (element)) {
base.OnRenderGrip (e);
return;
}
new VisualStyleRenderer (element).DrawBackground (e.Graphics, e.GripDisplayStyle == ToolStripGripDisplayStyle.Vertical ?
// GetPartSize seems to return useless values.
new Rectangle (2, 0, 5, 20) :
new Rectangle (0, 2, 20, 5));
}
public override void OnRenderOverflowButtonBackground (ToolStripItemRenderEventArgs e)
{
if (!ThemeVisualStyles.RenderClientAreas) {
base.OnRenderOverflowButtonBackground (e);
return;
}
VisualStyleElement element = e.ToolStrip.Orientation == Orientation.Horizontal ?
VisualStyleElement.Rebar.Chevron.Normal :
VisualStyleElement.Rebar.ChevronVertical.Normal;
if (!VisualStyleRenderer.IsElementDefined (element)) {
base.OnRenderOverflowButtonBackground (e);
return;
}
OnRenderButtonBackground (e);
new VisualStyleRenderer (element).DrawBackground (e.Graphics, e.Item.Bounds);
}
public override void OnRenderSeparator (ToolStripSeparatorRenderEventArgs e)
{
if (!ThemeVisualStyles.RenderClientAreas) {
base.OnRenderSeparator (e);
return;
}
VisualStyleElement element = e.ToolStrip.Orientation == Orientation.Horizontal ?
VisualStyleElement.ToolBar.SeparatorHorizontal.Normal :
VisualStyleElement.ToolBar.SeparatorVertical.Normal;
if (!VisualStyleRenderer.IsElementDefined (element)) {
base.OnRenderSeparator (e);
return;
}
new VisualStyleRenderer (element).DrawBackground (e.Graphics, e.Item.Bounds);
}
public override void OnRenderSplitButtonBackground (ToolStripItemRenderEventArgs e)
{
if (!ThemeVisualStyles.RenderClientAreas) {
base.OnRenderSplitButtonBackground (e);
return;
}
VisualStyleElement element, drop_down_element;
if (IsDisabled (e.Item)) {
element = VisualStyleElement.ToolBar.SplitButton.Disabled;
drop_down_element = VisualStyleElement.ToolBar.SplitButtonDropDown.Disabled;;
} else if (IsPressed (e.Item)) {
element = VisualStyleElement.ToolBar.SplitButton.Pressed;
drop_down_element = VisualStyleElement.ToolBar.SplitButtonDropDown.Pressed;
} else if (IsChecked (e.Item))
if (IsHot (e.Item)) {
element = VisualStyleElement.ToolBar.SplitButton.HotChecked;
drop_down_element = VisualStyleElement.ToolBar.SplitButtonDropDown.HotChecked;
} else {
element = VisualStyleElement.ToolBar.Button.Checked;
drop_down_element = VisualStyleElement.ToolBar.SplitButtonDropDown.Checked;
}
else if (IsHot (e.Item)) {
element = VisualStyleElement.ToolBar.SplitButton.Hot;
drop_down_element = VisualStyleElement.ToolBar.SplitButtonDropDown.Hot;
} else {
element = VisualStyleElement.ToolBar.SplitButton.Normal;
drop_down_element = VisualStyleElement.ToolBar.SplitButtonDropDown.Normal;
}
if (!VisualStyleRenderer.IsElementDefined (element) ||
!VisualStyleRenderer.IsElementDefined (drop_down_element)) {
base.OnRenderSplitButtonBackground (e);
return;
}
ToolStripSplitButton tool_strip_split_button = (ToolStripSplitButton)e.Item;
VisualStyleRenderer renderer = new VisualStyleRenderer (element);
renderer.DrawBackground (e.Graphics, tool_strip_split_button.ButtonBounds);
renderer.SetParameters (drop_down_element);
renderer.DrawBackground (e.Graphics, tool_strip_split_button.DropDownButtonBounds);
}
public override void OnRenderToolStripBackground (ToolStripRenderEventArgs e)
{
if (e.ToolStrip.BackgroundImage != null)
return;
if (!ThemeVisualStyles.RenderClientAreas) {
base.OnRenderToolStripBackground (e);
return;
}
VisualStyleElement element;
if (e.ToolStrip is StatusStrip)
element = VisualStyleElement.Status.Bar.Normal;
else
element = VisualStyleElement.Rebar.Band.Normal;
if (!VisualStyleRenderer.IsElementDefined (element)) {
base.OnRenderToolStripBackground (e);
return;
}
new VisualStyleRenderer (element).DrawBackground (e.Graphics, e.ToolStrip.Bounds, e.AffectedBounds);
}
}
}