* TreeView.cs: Don't draw the selected node when we lose
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / GridEntry.cs
1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
8 //
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 //
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 //
20 // Copyright (c) 2004-2005 Novell, Inc.
21 //
22 // Authors:
23 //      Jonathan Chambers (jonathan.chambers@ansys.com)
24 //
25
26 // NOT COMPLETE
27
28 using System;
29 using System.Windows.Forms;
30 using System.ComponentModel;
31 using System.Drawing;
32
33 namespace System.Windows.Forms.PropertyGridInternal
34 {
35         internal class GridEntry : GridItem
36         {
37                 #region Local Variables
38                 private bool expanded = true;
39                 private GridItemCollection grid_items;
40                 private GridItem parent;
41                 private PropertyDescriptor property_descriptor;
42                 private object selected_object;
43                 private string label;
44                 private int top;
45                 private Rectangle plus_minus_bounds;
46                 private Rectangle bounds;
47                 #endregion      // Local Variables
48
49                 #region  Contructors
50                 public GridEntry() : base() {
51                         plus_minus_bounds = new Rectangle(0,0,0,0);
52                         bounds = new Rectangle(0,0,0,0);
53                         top = -1;
54                         grid_items = new GridItemCollection();
55                 }
56
57                 public GridEntry(object obj, PropertyDescriptor prop_desc) : this() {
58                         selected_object = obj;
59                         property_descriptor = prop_desc;
60                 }
61                 #endregion      // Constructors
62
63                 #region Public Instance Properties
64                 public override bool Expandable
65                 {
66                         get {
67                                 return grid_items.Count > 0;
68                         }
69                 }
70
71                 public override bool Expanded
72                 {
73                         get {
74                                 return expanded;
75                         }
76
77                         set {
78                                 expanded = value;
79                         }
80                 }
81
82                 public override System.Windows.Forms.GridItemCollection GridItems
83                 {
84                         get {
85                                 return grid_items;
86                         }
87                 }
88
89                 public override System.Windows.Forms.GridItemType GridItemType
90                 {
91                         get {
92                                 return GridItemType.Property;
93                         }
94                 }
95
96                 public override string Label
97                 {
98                         get {
99                                 return property_descriptor.Name;
100                         }
101                 }
102
103                 public override System.Windows.Forms.GridItem Parent
104                 {
105                         get {
106                                 return parent;
107                         }
108                 }
109
110                 public override System.ComponentModel.PropertyDescriptor PropertyDescriptor
111                 {
112                         get {
113                                 return property_descriptor;
114                         }
115                 }
116
117                 public override object Value
118                 {
119                         get {
120                                 object return_value = null;
121                                 if (selected_object != null)
122                                         return_value = property_descriptor.GetValue(selected_object);
123                                 return return_value;
124                         }
125                 }
126                 #endregion      // Public Instance Properties
127
128                 #region Public Instance Methods
129                 [MonoTODO]
130                 public override bool Select () {
131                         throw new NotImplementedException();
132                 }
133                 #endregion      // Public Instance Methods
134
135                 internal override int Top {
136                         get {
137                                 return top;
138                         }
139                         set {
140                                 top = value;
141                         }
142                 }
143
144                 internal override Rectangle PlusMinusBounds {
145                         get{
146                                 return plus_minus_bounds;
147                         }
148                         set{
149                                 plus_minus_bounds = value;
150                         }
151                 }
152
153                 internal override Rectangle Bounds
154                 {
155                         get
156                         {
157                                 return bounds;
158                         }
159                         set
160                         {
161                                 bounds = value;
162                         }
163                 }
164
165
166         }
167 }