New tests, update
[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 //   Jordi Mas i Hernandez <jordimash@gmail.com>
8 //
9 // Copyright (C) 2002 Ximian, Inc. http://www.ximian.com
10 // Copyright (C) 2004 Novell, Inc. http://www.novell.com
11 //
12
13 //
14 // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
15 //
16 // Permission is hereby granted, free of charge, to any person obtaining
17 // a copy of this software and associated documentation files (the
18 // "Software"), to deal in the Software without restriction, including
19 // without limitation the rights to use, copy, modify, merge, publish,
20 // distribute, sublicense, and/or sell copies of the Software, and to
21 // permit persons to whom the Software is furnished to do so, subject to
22 // the following conditions:
23 // 
24 // The above copyright notice and this permission notice shall be
25 // included in all copies or substantial portions of the Software.
26 // 
27 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
31 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
32 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 //
35
36 using System;
37
38 namespace System.Drawing
39 {
40         /// <summary>
41         /// Summary description for SystemBrushes.
42         /// </summary>
43         public sealed class SystemBrushes
44         {
45                 static SolidBrush active_border;
46                 static SolidBrush active_caption;
47                 static SolidBrush active_caption_text;
48                 static SolidBrush app_workspace;
49                 static SolidBrush control;
50                 static SolidBrush control_dark;
51                 static SolidBrush control_dark_dark;
52                 static SolidBrush control_light;
53                 static SolidBrush control_light_light;
54                 static SolidBrush control_text;
55                 static SolidBrush desktop;
56                 static SolidBrush highlight;
57                 static SolidBrush highlight_text;
58                 static SolidBrush hot_track;
59                 static SolidBrush inactive_border;
60                 static SolidBrush inactive_caption;
61                 static SolidBrush info;
62                 static SolidBrush menu;
63                 static SolidBrush scroll_bar;
64                 static SolidBrush window;
65                 static SolidBrush window_text;
66                 static SolidBrush button_face;
67                 static SolidBrush button_highlight;
68                 static SolidBrush button_shadow;
69                 static SolidBrush gradient_activecaption;
70                 static SolidBrush gradient_inactivecaption;
71                 static SolidBrush graytext;
72                 static SolidBrush inactive_captiontext;
73                 static SolidBrush infotext;
74                 static SolidBrush menubar;
75                 static SolidBrush menu_highlight;
76                 static SolidBrush menu_text;            
77                 static SolidBrush window_fame;
78  
79                 private SystemBrushes() { }
80
81                 public static Brush ActiveBorder
82                 {       
83                         get {
84                                 if (active_border == null) {
85                                         active_border = new SolidBrush (SystemColors.ActiveBorder);
86                                         active_border.isModifiable = false;
87                                 }
88
89                                 return active_border;
90                         }
91                 }
92
93                 public static Brush ActiveCaption
94                 {       
95                         get {
96                                 if (active_caption == null) {
97                                         active_caption = new SolidBrush (SystemColors.ActiveCaption);
98                                         active_caption.isModifiable = false;
99                                 }
100
101                                 return active_caption;
102                         }
103                 }
104
105                 public static Brush ActiveCaptionText
106                 {       
107                         get {
108                                 if (active_caption_text == null) {
109                                         active_caption_text = new SolidBrush (SystemColors.ActiveCaptionText);
110                                         active_caption_text.isModifiable = false;
111                                 }
112
113                                 return active_caption_text;
114                         }
115                 }
116
117                 public static Brush AppWorkspace
118                 {       
119                         get {
120                                 if (app_workspace == null) {
121                                         app_workspace = new SolidBrush (SystemColors.AppWorkspace);
122                                         app_workspace.isModifiable = false;
123                                 }
124
125                                 return app_workspace;
126                         }
127                 }
128
129                 public static Brush Control {
130                         get {
131                                 if (control == null) {
132                                         control = new SolidBrush (SystemColors.Control);
133                                         control.isModifiable = false;
134                                 }
135
136                                 return control;
137                         }
138                 }
139                 
140                 public static Brush ControlLight {
141                         get {
142                                 if (control_light == null) {
143                                         control_light = new SolidBrush (SystemColors.ControlLight);
144                                         control_light.isModifiable = false;
145                                 }
146
147                                 return control_light;
148                         }
149                 }
150                 
151                 public static Brush ControlLightLight {
152                         get {
153                                 if (control_light_light == null) {
154                                         control_light_light = new SolidBrush (SystemColors.ControlLightLight);
155                                         control_light_light.isModifiable = false;
156                                 }
157
158                                 return control_light_light;
159                         }
160                 }
161
162                 public static Brush ControlDark {
163                         get {
164                                 if (control_dark == null) {
165                                         control_dark = new SolidBrush (SystemColors.ControlDark);
166                                         control_dark.isModifiable = false;
167                                 }
168
169                                 return control_dark;
170                         }
171                 }
172                 
173                 public static Brush ControlDarkDark {
174                         get {
175                                 if (control_dark_dark == null) {
176                                         control_dark_dark = new SolidBrush (SystemColors.ControlDarkDark);
177                                         control_dark_dark.isModifiable = false;
178                                 }
179
180                                 return control_dark_dark;
181                         }
182                 }
183
184                 public static Brush ControlText {
185                         get {
186                                 if (control_text == null) {
187                                         control_text = new SolidBrush (SystemColors.ControlText);
188                                         control_text.isModifiable = false;
189                                 }
190
191                                 return control_text;
192                         }
193                 }
194
195                 public static Brush Highlight {
196                         get {
197                                 if (highlight == null) {
198                                         highlight = new SolidBrush (SystemColors.Highlight);
199                                         highlight.isModifiable = false;
200                                 }
201
202                                 return highlight;
203                         }
204                 }
205
206                 public static Brush HighlightText {
207                         get {
208                                 if (highlight_text == null) {
209                                         highlight_text = new SolidBrush (SystemColors.HighlightText);
210                                         highlight_text.isModifiable = false;
211                                 }
212
213                                 return highlight_text;
214                         }
215                 }
216
217                 public static Brush Window {
218                         get {
219                                 if (window == null) {
220                                         window = new SolidBrush (SystemColors.Window);
221                                         window.isModifiable = false;
222                                 }
223
224                                 return window;
225                         }
226                 }
227                 public static Brush WindowText {
228                         get {
229                                 if (window_text == null) {
230                                         window_text = new SolidBrush (SystemColors.WindowText);
231                                         window_text.isModifiable = false;
232                                 }
233
234                                 return window_text;
235                         }
236                 }
237
238                 public static Brush InactiveBorder {
239                         get {
240                                 if (inactive_border == null) {
241                                         inactive_border = new SolidBrush (SystemColors.InactiveBorder);
242                                         inactive_border.isModifiable = false;
243                                 }
244
245                                 return inactive_border;
246                         }
247                 }
248
249                 public static Brush Desktop {
250                         get {
251                                 if (desktop == null) {
252                                         desktop = new SolidBrush (SystemColors.Desktop);
253                                         desktop.isModifiable = false;
254                                 }
255
256                                 return desktop;
257                         }
258                 }
259
260                 public static Brush HotTrack {
261                         get {
262                                 if (hot_track == null) {
263                                         hot_track = new SolidBrush (SystemColors.HotTrack);
264                                         hot_track.isModifiable = false;
265                                 }
266
267                                 return hot_track;
268                         }
269                 }
270
271                 public static Brush InactiveCaption {
272                         get {
273                                 if (inactive_caption == null) {
274                                         inactive_caption = new SolidBrush (SystemColors.InactiveCaption);
275                                         inactive_caption.isModifiable = false;
276                                 }
277
278                                 return inactive_caption;
279                         }
280                 }
281                 
282                 public static Brush Info {
283                         get {
284                                 if (info == null) {
285                                         info = new SolidBrush (SystemColors.Info);
286                                         info.isModifiable = false;
287                                 }
288
289                                 return info;
290                         }
291                 }
292                 
293                 public static Brush Menu {
294                         get {
295                                 if (menu == null) {
296                                         menu = new SolidBrush (SystemColors.Menu);
297                                         menu.isModifiable = false;
298                                 }
299
300                                 return menu;
301                         }
302                 }
303                 
304                 public static Brush ScrollBar {
305                         get {
306                                 if (scroll_bar == null) {
307                                         scroll_bar = new SolidBrush (SystemColors.ScrollBar);
308                                         scroll_bar.isModifiable = false;
309                                 }
310
311                                 return scroll_bar;
312                         }
313                 }
314
315                 public static Brush FromSystemColor (Color c) 
316                 {
317                         if (c.IsSystemColor) {
318                                 SolidBrush newBrush = new SolidBrush (c);
319                                 newBrush.isModifiable = false;
320                                 return newBrush;
321                         }
322
323                         String message = String.Format ("The color {0} is not a system color.", c);
324                         throw new ArgumentException (message);
325                 }
326
327 #if NET_2_0
328                 public static Brush ButtonFace {
329                         get {
330                                 if (button_face == null) {
331                                         button_face = new SolidBrush (SystemColors.ButtonFace);
332                                         button_face.isModifiable = false;
333                                 }
334
335                                 return button_face;
336                         }
337                 }
338
339                 public static Brush ButtonHighlight {
340                         get {
341                                 if (button_highlight == null) {
342                                         button_highlight = new SolidBrush (SystemColors.ButtonHighlight);
343                                         button_highlight.isModifiable = false;
344                                 }
345
346                                 return button_highlight;
347                         }
348                 }
349
350                 public static Brush ButtonShadow {
351                         get {
352                                 if (button_shadow == null) {
353                                         button_shadow = new SolidBrush (SystemColors.ButtonShadow);
354                                         button_shadow.isModifiable = false;
355                                 }
356
357                                 return button_shadow;
358                         }
359                 }
360
361                 public static Brush GradientActiveCaption {
362                         get {
363                                 if (gradient_activecaption == null) {
364                                         gradient_activecaption = new SolidBrush (SystemColors.GradientActiveCaption);
365                                         gradient_activecaption.isModifiable = false;
366                                 }
367
368                                 return gradient_activecaption;
369                         }
370                 }
371
372                 public static Brush GradientInactiveCaption {
373                         get {
374                                 if (gradient_inactivecaption == null) {
375                                         gradient_inactivecaption = new SolidBrush (SystemColors.GradientInactiveCaption);
376                                         gradient_inactivecaption.isModifiable = false;
377                                 }
378
379                                 return gradient_inactivecaption;
380                         }
381                 }
382
383                 public static Brush GrayText {
384                         get {
385                                 if (graytext == null) {
386                                         graytext = new SolidBrush (SystemColors.GrayText);
387                                         graytext.isModifiable = false;
388                                 }
389
390                                 return graytext;
391                         }
392                 }
393
394                 public static Brush InactiveCaptionText {
395                         get {
396                                 if (inactive_captiontext == null) {
397                                         inactive_captiontext = new SolidBrush (SystemColors.InactiveCaptionText);
398                                         inactive_captiontext.isModifiable = false;
399                                 }
400
401                                 return inactive_captiontext;
402                         }
403                 }
404
405                 public static Brush InfoText {
406                         get {
407                                 if (infotext == null) {
408                                         infotext = new SolidBrush (SystemColors.InfoText);
409                                         infotext.isModifiable = false;
410                                 }
411
412                                 return infotext;
413                         }
414                 }
415
416                 public static Brush MenuBar {
417                         get {
418                                 if (menubar == null) {
419                                         menubar = new SolidBrush (SystemColors.MenuBar);
420                                         menubar.isModifiable = false;
421                                 }
422
423                                 return menubar;
424                         }
425                 }
426
427                 public static Brush MenuHighlight {
428                         get {
429                                 if (menu_highlight == null) {
430                                         menu_highlight = new SolidBrush (SystemColors.MenuHighlight);
431                                         menu_highlight.isModifiable = false;
432                                 }
433
434                                 return menu_highlight;
435                         }
436                 }
437
438                 public static Brush MenuText {
439                         get {
440                                 if (menu_text == null) {
441                                         menu_text = new SolidBrush (SystemColors.MenuText);
442                                         menu_text.isModifiable = false;
443                                 }
444
445                                 return menu_text;
446                         }
447                 }
448
449                 public static Brush WindowFrame {
450                         get {
451                                 if (window_fame == null) {
452                                         window_fame = new SolidBrush (SystemColors.WindowFrame);
453                                         window_fame.isModifiable = false;
454                                 }
455
456                                 return window_fame;
457                         }
458                 }
459 #endif
460
461         }
462 }