2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / System.Drawing / System.Drawing / SystemBrushes.cs
1 //
2 // System.Drawing.SystemBrushes.cs
3 //
4 // Authors:
5 //   Dennis Hayes (dennish@Raytek.com)
6 //   Ravindra (rkumar@novell.com)
7 //
8 // Copyright (C) 2002 Ximian, Inc. http://www.ximian.com
9 // Copyright (C) 2004 Novell, Inc. http://www.novell.com
10 //
11
12 //
13 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
14 //
15 // Permission is hereby granted, free of charge, to any person obtaining
16 // a copy of this software and associated documentation files (the
17 // "Software"), to deal in the Software without restriction, including
18 // without limitation the rights to use, copy, modify, merge, publish,
19 // distribute, sublicense, and/or sell copies of the Software, and to
20 // permit persons to whom the Software is furnished to do so, subject to
21 // the following conditions:
22 // 
23 // The above copyright notice and this permission notice shall be
24 // included in all copies or substantial portions of the Software.
25 // 
26 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 //
34
35 using System;
36
37 namespace System.Drawing
38 {
39         /// <summary>
40         /// Summary description for SystemBrushes.
41         /// </summary>
42         public sealed class SystemBrushes
43         {
44                 static SolidBrush active_border;
45                 static SolidBrush active_caption;
46                 static SolidBrush active_caption_text;
47                 static SolidBrush app_workspace;
48                 static SolidBrush control;
49                 static SolidBrush control_dark;
50                 static SolidBrush control_dark_dark;
51                 static SolidBrush control_light;
52                 static SolidBrush control_light_light;
53                 static SolidBrush control_text;
54                 static SolidBrush desktop;
55                 static SolidBrush highlight;
56                 static SolidBrush highlight_text;
57                 static SolidBrush hot_track;
58                 static SolidBrush inactive_border;
59                 static SolidBrush inactive_caption;
60                 static SolidBrush info;
61                 static SolidBrush menu;
62                 static SolidBrush scroll_bar;
63                 static SolidBrush window;
64                 static SolidBrush window_text;
65
66                 private SystemBrushes() { }
67
68                 public static Brush ActiveBorder
69                 {       
70                         get {
71                                 if (active_border == null) {
72                                         active_border = new SolidBrush (SystemColors.ActiveBorder);
73                                         active_border.isModifiable = false;
74                                 }
75
76                                 return active_border;
77                         }
78                 }
79
80                 public static Brush ActiveCaption
81                 {       
82                         get {
83                                 if (active_caption == null) {
84                                         active_caption = new SolidBrush (SystemColors.ActiveCaption);
85                                         active_caption.isModifiable = false;
86                                 }
87
88                                 return active_caption;
89                         }
90                 }
91
92                 public static Brush ActiveCaptionText
93                 {       
94                         get {
95                                 if (active_caption_text == null) {
96                                         active_caption_text = new SolidBrush (SystemColors.ActiveCaptionText);
97                                         active_caption_text.isModifiable = false;
98                                 }
99
100                                 return active_caption_text;
101                         }
102                 }
103
104                 public static Brush AppWorkspace
105                 {       
106                         get {
107                                 if (app_workspace == null) {
108                                         app_workspace = new SolidBrush (SystemColors.AppWorkspace);
109                                         app_workspace.isModifiable = false;
110                                 }
111
112                                 return app_workspace;
113                         }
114                 }
115
116                 public static Brush Control {
117                         get {
118                                 if (control == null) {
119                                         control = new SolidBrush (SystemColors.Control);
120                                         control.isModifiable = false;
121                                 }
122
123                                 return control;
124                         }
125                 }
126                 
127                 public static Brush ControlLight {
128                         get {
129                                 if (control_light == null) {
130                                         control_light = new SolidBrush (SystemColors.ControlLight);
131                                         control_light.isModifiable = false;
132                                 }
133
134                                 return control_light;
135                         }
136                 }
137                 
138                 public static Brush ControlLightLight {
139                         get {
140                                 if (control_light_light == null) {
141                                         control_light_light = new SolidBrush (SystemColors.ControlLightLight);
142                                         control_light_light.isModifiable = false;
143                                 }
144
145                                 return control_light_light;
146                         }
147                 }
148
149                 public static Brush ControlDark {
150                         get {
151                                 if (control_dark == null) {
152                                         control_dark = new SolidBrush (SystemColors.ControlDark);
153                                         control_dark.isModifiable = false;
154                                 }
155
156                                 return control_dark;
157                         }
158                 }
159                 
160                 public static Brush ControlDarkDark {
161                         get {
162                                 if (control_dark_dark == null) {
163                                         control_dark_dark = new SolidBrush (SystemColors.ControlDarkDark);
164                                         control_dark_dark.isModifiable = false;
165                                 }
166
167                                 return control_dark_dark;
168                         }
169                 }
170
171                 public static Brush ControlText {
172                         get {
173                                 if (control_text == null) {
174                                         control_text = new SolidBrush (SystemColors.ControlText);
175                                         control_text.isModifiable = false;
176                                 }
177
178                                 return control_text;
179                         }
180                 }
181
182                 public static Brush Highlight {
183                         get {
184                                 if (highlight == null) {
185                                         highlight = new SolidBrush (SystemColors.Highlight);
186                                         highlight.isModifiable = false;
187                                 }
188
189                                 return highlight;
190                         }
191                 }
192
193                 public static Brush HighlightText {
194                         get {
195                                 if (highlight_text == null) {
196                                         highlight_text = new SolidBrush (SystemColors.HighlightText);
197                                         highlight_text.isModifiable = false;
198                                 }
199
200                                 return highlight_text;
201                         }
202                 }
203
204                 public static Brush Window {
205                         get {
206                                 if (window == null) {
207                                         window = new SolidBrush (SystemColors.Window);
208                                         window.isModifiable = false;
209                                 }
210
211                                 return window;
212                         }
213                 }
214                 public static Brush WindowText {
215                         get {
216                                 if (window_text == null) {
217                                         window_text = new SolidBrush (SystemColors.WindowText);
218                                         window_text.isModifiable = false;
219                                 }
220
221                                 return window_text;
222                         }
223                 }
224
225                 public static Brush InactiveBorder {
226                         get {
227                                 if (inactive_border == null) {
228                                         inactive_border = new SolidBrush (SystemColors.InactiveBorder);
229                                         inactive_border.isModifiable = false;
230                                 }
231
232                                 return inactive_border;
233                         }
234                 }
235
236                 public static Brush Desktop {
237                         get {
238                                 if (desktop == null) {
239                                         desktop = new SolidBrush (SystemColors.Desktop);
240                                         desktop.isModifiable = false;
241                                 }
242
243                                 return desktop;
244                         }
245                 }
246
247                 public static Brush HotTrack {
248                         get {
249                                 if (hot_track == null) {
250                                         hot_track = new SolidBrush (SystemColors.HotTrack);
251                                         hot_track.isModifiable = false;
252                                 }
253
254                                 return hot_track;
255                         }
256                 }
257
258                 public static Brush InactiveCaption {
259                         get {
260                                 if (inactive_caption == null) {
261                                         inactive_caption = new SolidBrush (SystemColors.InactiveCaption);
262                                         inactive_caption.isModifiable = false;
263                                 }
264
265                                 return inactive_caption;
266                         }
267                 }
268                 
269                 public static Brush Info {
270                         get {
271                                 if (info == null) {
272                                         info = new SolidBrush (SystemColors.Info);
273                                         info.isModifiable = false;
274                                 }
275
276                                 return info;
277                         }
278                 }
279                 
280                 public static Brush Menu {
281                         get {
282                                 if (menu == null) {
283                                         menu = new SolidBrush (SystemColors.Menu);
284                                         menu.isModifiable = false;
285                                 }
286
287                                 return menu;
288                         }
289                 }
290                 
291                 public static Brush ScrollBar {
292                         get {
293                                 if (scroll_bar == null) {
294                                         scroll_bar = new SolidBrush (SystemColors.ScrollBar);
295                                         scroll_bar.isModifiable = false;
296                                 }
297
298                                 return scroll_bar;
299                         }
300                 }
301
302                 public static Brush FromSystemColor (Color c) 
303                 {
304                         if (c.IsSystemColor) {
305                                 SolidBrush newBrush = new SolidBrush (c);
306                                 newBrush.isModifiable = false;
307                                 return newBrush;
308                         }
309
310                         String message = String.Format ("The color {0} is not a system color.", c);
311                         throw new ArgumentException (message);
312                 }
313         }
314 }