2007-03-29 Jonathan Pobst <monkey@jpobst.com>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / FlatButtonAppearance.cs
1 //
2 //  FlatButtonAppearance.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 Daniel Nauck
24 //
25 // Author:
26 //      Daniel Nauck    (dna(at)mono-project(dot)de)
27
28
29 using System;
30 using System.ComponentModel;
31 using System.Drawing;
32 using System.Windows.Forms;
33
34 namespace System.Windows.Forms
35 {
36 #if NET_2_0
37         public 
38 #endif
39         class FlatButtonAppearance
40         {
41                 private Color borderColor = Color.Empty;
42                 private int borderSize = 1;
43                 private Color checkedBackColor = Color.Empty;
44                 private Color mouseDownBackColor = Color.Empty;
45                 private Color mouseOverBackColor = Color.Empty;
46                 private ButtonBase owner = null;
47
48                 internal FlatButtonAppearance (ButtonBase owner)
49                 {
50                         this.owner = owner;
51                 }
52
53                 [EditorBrowsable(EditorBrowsableState.Always)]
54                 [DefaultValue(typeof(Color), "")]
55                 [NotifyParentProperty(true)]
56                 [Browsable(true)]
57                 public Color BorderColor
58                 {
59                         get { return borderColor; }
60                         set {
61                                 if(borderColor == value)
62                                         return;
63
64                                 borderColor = value;
65                                 
66                                 if(owner != null)
67                                         owner.Invalidate ();
68                         }
69                 }
70
71                 [EditorBrowsable(EditorBrowsableState.Always)]
72                 [DefaultValue(1)]
73                 [NotifyParentProperty(true)]
74                 [Browsable(true)]
75                 public int BorderSize
76                 {
77                         get { return borderSize; }
78                         set {
79                                 if(borderSize == value)
80                                         return;
81
82                                 if (value < 0)
83                                         throw new ArgumentOutOfRangeException ("value", string.Format ("'{0}' is not a valid value for 'BorderSize'. 'BorderSize' must be greater or equal than {1}.", value, 0));
84
85                                 borderSize = value;
86
87                                 if(owner != null)
88                                         owner.Invalidate ();
89                         }
90                 }
91
92                 [EditorBrowsable(EditorBrowsableState.Always)]
93                 [DefaultValue(typeof(Color), "")]
94                 [NotifyParentProperty(true)]
95                 [Browsable(true)]
96                 public Color CheckedBackColor 
97                 {
98                         get { return checkedBackColor; }
99                         set {
100                                 if(checkedBackColor == value)
101                                         return;
102
103                                 checkedBackColor = value;
104
105                                 if(owner != null)
106                                         owner.Invalidate ();
107                         }
108                 }
109
110                 [EditorBrowsable(EditorBrowsableState.Always)]
111                 [DefaultValue(typeof(Color), "")]
112                 [Browsable(true)]
113                 [NotifyParentProperty(true)]
114                 public Color MouseDownBackColor
115                 {
116                         get { return mouseDownBackColor; }
117                         set {
118                                 if(mouseDownBackColor == value)
119                                         return;
120
121                                 mouseDownBackColor = value;
122
123                                 if(owner != null)
124                                         owner.Invalidate ();
125                         }
126                 }
127
128                 [EditorBrowsable(EditorBrowsableState.Always)]
129                 [DefaultValue(typeof(Color), "")]
130                 [NotifyParentProperty(true)]
131                 [Browsable(true)]
132                 public Color MouseOverBackColor
133                 {
134                         get { return mouseOverBackColor; }
135                         set {
136                                 if(mouseOverBackColor == value)
137                                         return;
138
139                                 mouseOverBackColor = value;
140
141                                 if(owner != null)
142                                         owner.Invalidate ();
143                         }
144                 }
145         }
146 }