1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2007 Novell, Inc.
23 // Jonathan Pobst (monkey@jpobst.com)
24 // Everaldo Canuto <ecanuto@novell.com>
28 using System
.Reflection
;
30 namespace System
.Windows
.Forms
.Theming
32 internal class ThemeElements
34 private static ThemeElementsDefault theme
;
35 public static ThemeElementsDefault CurrentTheme
{
39 static ThemeElements ()
43 theme_var
= Environment
.GetEnvironmentVariable ("MONO_THEME");
45 if (theme_var
== null)
48 theme_var
= theme_var
.ToLower ();
50 theme
= LoadTheme (theme_var
);
54 private static ThemeElementsDefault
LoadTheme (string themeName
)
56 if (themeName
== "visualstyles")
57 if (Application
.VisualStylesEnabled
)
58 return new ThemeElementsVisualStyles ();
60 return new ThemeElementsDefault ();
61 Assembly ass
= Assembly
.GetExecutingAssembly ();
62 string iname
= typeof(ThemeElements
).FullName
;
63 string assemblyname
= iname
+ themeName
;
64 Type type
= ass
.GetType (assemblyname
, false, true);
66 object o
= ass
.CreateInstance (type
.FullName
);
68 return (ThemeElementsDefault
) o
;
70 return new ThemeElementsDefault ();
74 public static void DrawButton (Graphics g
, Rectangle bounds
, ButtonThemeState state
, Color backColor
, Color foreColor
)
76 theme
.ButtonPainter
.Draw (g
, bounds
, state
, backColor
, foreColor
);
79 public static void DrawFlatButton (Graphics g
, Rectangle bounds
, ButtonThemeState state
, Color backColor
, Color foreColor
, FlatButtonAppearance appearance
)
81 theme
.ButtonPainter
.DrawFlat (g
, bounds
, state
, backColor
, foreColor
, appearance
);
84 public static void DrawPopupButton (Graphics g
, Rectangle bounds
, ButtonThemeState state
, Color backColor
, Color foreColor
)
86 theme
.ButtonPainter
.DrawPopup (g
, bounds
, state
, backColor
, foreColor
);
92 public virtual Default
.ButtonPainter ButtonPainter
{
93 get { return theme.ButtonPainter; }
96 public static Default
.LabelPainter LabelPainter
{
97 get { return theme.LabelPainter; }
100 public static Default
.LinkLabelPainter LinkLabelPainter
{
101 get { return theme.LinkLabelPainter; }
104 public virtual Default
.TabControlPainter TabControlPainter
{
105 get { return theme.TabControlPainter; }
109 public virtual Default
.CheckBoxPainter CheckBoxPainter
{
110 get { return theme.CheckBoxPainter; }
113 public virtual Default
.RadioButtonPainter RadioButtonPainter
{
114 get { return theme.RadioButtonPainter; }
117 public virtual Default
.ToolStripPainter ToolStripPainter
{
118 get { return theme.ToolStripPainter; }
125 #region Internal Enums
127 internal enum ButtonThemeState
136 internal enum ElementState