2007-02-28 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mcs / class / System.Drawing / System.Drawing / SystemPens.cs
1 //
2 // System.Drawing.SystemPens.cs
3 //
4 // Authors:
5 //   Miguel de Icaza (miguel@ximian.com)
6 //   Ravindra (rkumar@novell.com)
7 //   Jordi Mas i Hernandez <jordimash@gmail.com>
8 //
9 // Copyright (C) 2003-2005 Novell, Inc. http://www.novell.com
10 //
11
12 //
13 // Copyright (C) 2004-2005 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         public sealed class SystemPens
40         {
41                 static private Pen active_caption_text;
42                 static private Pen control;
43                 static private Pen control_dark;
44                 static private Pen control_dark_dark;
45                 static private Pen control_light;
46                 static private Pen control_light_light;
47                 static private Pen control_text;
48                 static private Pen gray_text;
49                 static private Pen highlight;
50                 static private Pen highlight_text;
51                 static private Pen inactive_caption_text;
52                 static private Pen info_text;
53                 static private Pen menu_text;
54                 static private Pen window_frame;
55                 static private Pen window_text;
56                 static private Pen active_border;
57                 static private Pen active_caption;
58                 static private Pen app_workspace;
59                 static private Pen button_face;
60                 static private Pen button_highlight;
61                 static private Pen button_shadow;
62                 static private Pen desktop;
63                 static private Pen gradient_activecaption;
64                 static private Pen gradient_inactivecaption;
65                 static private Pen hot_track;
66                 static private Pen inactive_border;
67                 static private Pen inactive_caption;
68                 static private Pen info;
69                 static private Pen menu;
70                 static private Pen menu_bar;
71                 static private Pen menu_highlight;
72                 static private Pen scroll_bar;
73                 static private Pen window;
74                 
75                 private SystemPens () { }
76                 
77                 public static Pen ActiveCaptionText {
78                         get {
79                                 if (active_caption_text == null) {
80                                         active_caption_text = new Pen (SystemColors.ActiveCaptionText);
81                                         active_caption_text.isModifiable = false;
82                                 }
83                                 
84                                 return active_caption_text;
85                         }
86                 }
87                 
88                 public static Pen Control {
89                         get {
90                                 if (control == null) {
91                                         control = new Pen (SystemColors.Control);
92                                         control.isModifiable = false;
93                                 }
94                                                                 
95                                 return control;
96                         }
97                 }
98                 
99                 public static Pen ControlDark {
100                         get {
101                                 if (control_dark == null) {
102                                         control_dark = new Pen (SystemColors.ControlDark);
103                                         control_dark.isModifiable = false;
104                                 }
105
106                                 return control_dark;
107                         }
108                 }
109                 
110                 public static Pen ControlDarkDark {
111                         get {
112                                 if (control_dark_dark == null) {
113                                         control_dark_dark = new Pen (SystemColors.ControlDarkDark);
114                                         control_dark_dark.isModifiable = false;
115                                 }
116                                 
117                                 return control_dark_dark;
118                         }
119                 }
120                 
121                 public static Pen ControlLight {
122                         get {
123                                 if (control_light == null) {
124                                         control_light = new Pen (SystemColors.ControlLight);
125                                         control_light.isModifiable = false;
126                                 }
127                                 
128                                 return control_light;
129                         }
130                 }
131                 
132                 public static Pen ControlLightLight {
133                         get {
134                                 if (control_light_light == null) {
135                                         control_light_light = new Pen (SystemColors.ControlLightLight);
136                                         control_light_light.isModifiable = false;
137                                 }
138                                 
139                                 return control_light_light;
140                         }
141                 }
142                 
143                 public static Pen ControlText {
144                         get {
145                                 if (control_text == null) {
146                                         control_text = new Pen (SystemColors.ControlText);
147                                         control_text.isModifiable = false;
148                                 }
149                                 
150                                 return control_text;
151                         }
152                 }
153                 
154                 public static Pen GrayText {
155                         get {
156                                 if (gray_text == null) {
157                                         gray_text = new Pen (SystemColors.GrayText);
158                                         gray_text.isModifiable = false;
159                                 }
160                                 
161                                 return gray_text;
162                         }
163                 }
164                 
165                 public static Pen Highlight {
166                         get {
167                                 if (highlight == null) {
168                                         highlight = new Pen (SystemColors.Highlight);
169                                         highlight.isModifiable = false;
170                                 }
171                                 
172                                 return highlight;
173                         }
174                 }
175                 
176                 public static Pen HighlightText {
177                         get {
178                                 if (highlight_text == null) {
179                                         highlight_text = new Pen (SystemColors.HighlightText);
180                                         highlight_text.isModifiable = false;
181                                 }
182                                 
183                                 return highlight_text;
184                         }
185                 }
186                 
187                 public static Pen InactiveCaptionText {
188                         get {
189                                 if (inactive_caption_text == null) {
190                                         inactive_caption_text = new Pen (SystemColors.InactiveCaptionText);
191                                         inactive_caption_text.isModifiable = false;
192                                 }
193                                 
194                                 return inactive_caption_text;
195                         }
196                 }
197                 
198                 public static Pen InfoText {
199                         get {
200                                 if (info_text == null) {
201                                         info_text = new Pen (SystemColors.InfoText);
202                                         info_text.isModifiable = false;
203                                 }
204                                 
205                                 return info_text;
206                         }
207                 }
208                 
209                 public static Pen MenuText {
210                         get {
211                                 if (menu_text == null) {
212                                         menu_text = new Pen (SystemColors.MenuText);
213                                         menu_text.isModifiable = false;
214                                 }
215                                 
216                                 return menu_text;
217                         }
218                 }
219                 
220                 public static Pen WindowFrame {
221                         get {
222                                 if (window_frame == null) {
223                                         window_frame = new Pen (SystemColors.WindowFrame);
224                                         window_frame.isModifiable = false;
225                                 }
226                                 
227                                 return window_frame;
228                         }
229                 }
230                 
231                 public static Pen WindowText {
232                         get {
233                                 if (window_text == null) {
234                                         window_text = new Pen (SystemColors.WindowText);
235                                         window_text.isModifiable = false;
236                                 }
237                                 
238                                 return window_text;
239                         }
240                 }
241                 
242                 public static Pen FromSystemColor (Color c)
243                 {
244                         if (c.IsSystemColor) {
245                                 Pen newPen = new Pen (c);
246                                 newPen.isModifiable = false;
247                                 return newPen;
248                         }
249                         
250                         String message = String.Format ("The color {0} is not a system color.", c);
251                         throw new ArgumentException (message);
252                 }
253
254 #if NET_2_0
255                 public static Pen ActiveBorder {
256                         get {
257                                 if (active_border == null) {
258                                         active_border = new Pen (SystemColors.ActiveBorder);
259                                         active_border.isModifiable = false;
260                                 }
261                                 
262                                 return active_border;
263                         }
264                 }
265
266                 public static Pen ActiveCaption {
267                         get {
268                                 if (active_caption == null) {
269                                         active_caption = new Pen (SystemColors.ActiveCaption);
270                                         active_caption.isModifiable = false;
271                                 }
272                                 
273                                 return active_caption;
274                         }
275                 }
276
277                 public static Pen AppWorkspace {
278                         get {
279                                 if (app_workspace == null) {
280                                         app_workspace = new Pen (SystemColors.AppWorkspace);
281                                         app_workspace.isModifiable = false;
282                                 }
283                                 
284                                 return app_workspace;
285                         }
286                 }
287
288                 public static Pen ButtonFace {
289                         get {
290                                 if (button_face == null) {
291                                         button_face = new Pen (SystemColors.ButtonFace);
292                                         button_face.isModifiable = false;
293                                 }
294                                 
295                                 return button_face;
296                         }
297                 }
298
299                 public static Pen ButtonHighlight {
300                         get {
301                                 if (button_highlight == null) {
302                                         button_highlight = new Pen (SystemColors.ButtonHighlight);
303                                         button_highlight.isModifiable = false;
304                                 }
305                                 
306                                 return button_highlight;
307                         }
308                 }
309
310                 public static Pen ButtonShadow {
311                         get {
312                                 if (button_shadow == null) {
313                                         button_shadow = new Pen (SystemColors.ButtonShadow);
314                                         button_shadow.isModifiable = false;
315                                 }       
316                         
317                                 return button_shadow;
318                         }
319                 }
320
321                 public static Pen Desktop {
322                         get {
323                                 if (desktop == null) {
324                                         desktop = new Pen (SystemColors.Desktop);
325                                         desktop.isModifiable = false;
326                                 }
327                                 
328                                 return desktop;
329                         }
330                 }
331
332                 public static Pen GradientActiveCaption {
333                         get {
334                                 if (gradient_activecaption == null) {
335                                         gradient_activecaption = new Pen (SystemColors.GradientActiveCaption);
336                                         gradient_activecaption.isModifiable = false;
337                                 }
338                                 
339                                 return gradient_activecaption;
340                         }
341                 }
342
343                 public static Pen GradientInactiveCaption {
344                         get {
345                                 if (gradient_inactivecaption == null) {
346                                         gradient_inactivecaption = new Pen (SystemColors.GradientInactiveCaption);
347                                         gradient_inactivecaption.isModifiable = false;
348                                 }
349                                 
350                                 return gradient_inactivecaption;
351                         }
352                 }
353
354                 public static Pen HotTrack {
355                         get {
356                                 if (hot_track == null) {
357                                         hot_track = new Pen (SystemColors.HotTrack);
358                                         hot_track.isModifiable = false;
359                                 }
360                                 
361                                 return hot_track;
362                         }
363                 }
364
365                 public static Pen InactiveBorder {
366                         get {
367                                 if (inactive_border == null) {
368                                         inactive_border = new Pen (SystemColors.InactiveBorder);
369                                         inactive_border.isModifiable = false;
370                                 }
371                                 
372                                 return inactive_border;
373                         }
374                 }
375
376                 public static Pen InactiveCaption {
377                         get {
378                                 if (inactive_caption == null) {
379                                         inactive_caption = new Pen (SystemColors.InactiveCaption);
380                                         inactive_caption.isModifiable = false;
381                                 }
382                                 
383                                 return inactive_caption;
384                         }
385                 }
386
387                 public static Pen Info {
388                         get {
389                                 if (info == null) {
390                                         info = new Pen (SystemColors.Info);
391                                         info.isModifiable = false;
392                                 }
393                                 
394                                 return info;
395                         }
396                 }
397
398                 public static Pen Menu {
399                         get {
400                                 if (menu == null) {
401                                         menu = new Pen (SystemColors.Menu);
402                                         menu.isModifiable = false;
403                                 }
404                                 
405                                 return menu;
406                         }
407                 }
408
409                 public static Pen MenuBar {
410                         get {
411                                 if (menu_bar == null) {
412                                         menu_bar = new Pen (SystemColors.MenuBar);
413                                         menu_bar.isModifiable = false;
414                                 }
415                                 
416                                 return menu_bar;
417                         }
418                 }
419
420                 public static Pen MenuHighlight {
421                         get {
422                                 if (menu_highlight == null) {
423                                         menu_highlight = new Pen (SystemColors.MenuHighlight);
424                                         menu_highlight.isModifiable = false;
425                                 }
426                                 
427                                 return menu_highlight;
428                         }
429                 }
430
431                 public static Pen ScrollBar {
432                         get {
433                                 if (scroll_bar == null) {
434                                         scroll_bar = new Pen (SystemColors.ScrollBar);
435                                         scroll_bar.isModifiable = false;
436                                 }
437                                 
438                                 return scroll_bar;
439                         }
440                 }
441
442                 public static Pen Window {
443                         get {
444                                 if (window == null) {
445                                         window = new Pen (SystemColors.Window);
446                                         window.isModifiable = false;
447                                 }
448                                 
449                                 return window;
450                         }
451                 }
452 #endif
453                 
454         }
455 }               
456