Merge pull request #1275 from ranma42/fix-lib64
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / ProgressBarRenderer.cs
1 //
2 // ProgressBarRenderer.cs
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
11 // 
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
14 // 
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 //
23 // Copyright (c) 2006 Novell, Inc.
24 //
25 // Authors:
26 //      Jonathan Pobst (monkey@jpobst.com)
27 //
28
29 using System.Drawing;
30 using System.Windows.Forms.VisualStyles;
31
32 namespace System.Windows.Forms
33 {
34         public sealed class ProgressBarRenderer
35         {
36                 #region Private Constructor
37                 private ProgressBarRenderer () { }
38                 #endregion
39
40                 #region Public Static Methods
41                 public static void DrawHorizontalBar (Graphics g, Rectangle bounds)
42                 {
43                         if (!IsSupported)
44                                 throw new InvalidOperationException ();
45
46                         VisualStyleRenderer vsr = new VisualStyleRenderer(VisualStyleElement.ProgressBar.Bar.Normal);
47                         
48                         vsr.DrawBackground(g, bounds);
49                 }
50
51                 public static void DrawHorizontalChunks (Graphics g, Rectangle bounds)
52                 {
53                         if (!IsSupported)
54                                 throw new InvalidOperationException ();
55
56                         VisualStyleRenderer vsr = new VisualStyleRenderer (VisualStyleElement.ProgressBar.Chunk.Normal);
57
58                         vsr.DrawBackground (g, bounds);
59                 }
60
61                 public static void DrawVerticalBar (Graphics g, Rectangle bounds)
62                 {
63                         if (!IsSupported)
64                                 throw new InvalidOperationException ();
65
66                         VisualStyleRenderer vsr = new VisualStyleRenderer (VisualStyleElement.ProgressBar.BarVertical.Normal);
67
68                         vsr.DrawBackground (g, bounds);
69                 }
70
71                 public static void DrawVerticalChunks (Graphics g, Rectangle bounds)
72                 {
73                         if (!IsSupported)
74                                 throw new InvalidOperationException ();
75
76                         VisualStyleRenderer vsr = new VisualStyleRenderer (VisualStyleElement.ProgressBar.ChunkVertical.Normal);
77
78                         vsr.DrawBackground (g, bounds);
79                 }
80                 #endregion
81                 
82                 #region Public Static Properties
83                 public static bool IsSupported {
84                         get { return VisualStyleInformation.IsEnabledByUser && (Application.VisualStyleState == VisualStyleState.ClientAndNonClientAreasEnabled || Application.VisualStyleState == VisualStyleState.ClientAreaEnabled); }
85                 }
86                 
87                 public static int ChunkSpaceThickness {
88                         get {
89                                 if (!IsSupported)
90                                         throw new InvalidOperationException();
91                                         
92                                 VisualStyleRenderer vsr = new VisualStyleRenderer(VisualStyleElement.ProgressBar.Chunk.Normal);
93                                 
94                                 return vsr.GetInteger(IntegerProperty.ProgressSpaceSize);
95                         }
96                 }
97
98                 public static int ChunkThickness {
99                         get {
100                                 if (!IsSupported)
101                                         throw new InvalidOperationException ();
102
103                                 VisualStyleRenderer vsr = new VisualStyleRenderer (VisualStyleElement.ProgressBar.Chunk.Normal);
104
105                                 return vsr.GetInteger (IntegerProperty.ProgressChunkSize);
106                         }
107                 }
108                 #endregion
109         }
110 }