**** Merged from MCS ****
[mono-project.git] / mcs / class / System.Windows.Forms / System.Windows.Forms / ListControl.cs
blob5741e62fa7f51f83b51f1a2624c08add8c0ecdc7
1 //
2 // System.Windows.Forms.ListControl.cs
3 //
4 // Author:
5 // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
6 // Dennis Hayes (dennish@raytek.com)
7 // Brian Takita (brian.takita@runbox.com)
8 // (C) 2002/3 Ximian, Inc
9 //
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System;
32 using System.Drawing;
33 using System.Collections;
34 using System.ComponentModel;
35 using System.Reflection;
37 namespace System.Windows.Forms {
39 // <summary>
41 // </summary>
43 public abstract class ListControl : Control {
45 internal string DisplayMember_ = String.Empty;
47 internal object DataSource_;
48 //ControlStyles controlStyles;
50 // --- Public Properties
52 [MonoTODO]
53 public object DataSource {
54 get {
55 return DataSource_;
57 set {
58 if (DataSource_ != value) {
59 if ((value is IList) || (value is IListSource)) {
60 DataSource_ = value;
61 OnDataSourceChanged (new EventArgs ());
63 } else {
64 throw new Exception ("Complex DataBinding accepts as a data source either an IList or an IListSource");
69 [MonoTODO]
70 public string DisplayMember {
71 get {
72 return DisplayMember_;
74 set {
75 if (DisplayMember_ != value) {
76 DisplayMember_ = value;
77 OnDisplayMemberChanged(new EventArgs());
82 internal string getDisplayMemberOfObj (object obj) {
83 string objectString = String.Empty;
84 Type t = obj.GetType();
86 if (DisplayMember != String.Empty) {
87 if (t != null) {
88 PropertyInfo prop = t.GetProperty (DisplayMember);
89 if (prop != null)
90 objectString = prop.GetValue (obj, null).ToString ();
93 if (objectString == String.Empty)
94 objectString = obj.ToString();
96 return objectString;
99 internal class ListControlComparer : IComparer {
100 private ListControl owner_ = null;
101 public ListControlComparer(ListControl owner) {
102 owner_ = owner;
106 public int Compare(object x, object y) {
107 return owner_.getDisplayMemberOfObj(x).CompareTo (owner_.getDisplayMemberOfObj (y));
112 [MonoTODO]
113 public abstract int SelectedIndex {get;set;}
115 [MonoTODO]
116 public object SelectedValue {
117 get {
118 throw new NotImplementedException ();
120 set {
121 //FIXME:
124 [MonoTODO]
125 public string ValueMember {
126 get {
127 throw new NotImplementedException ();
129 set {
130 //FIXME:
135 // --- Public Methods
138 [MonoTODO]
139 public string GetItemText (object item) {
140 throw new NotImplementedException ();
144 // --- Public Events
146 [MonoTODO]
147 public event EventHandler DataSourceChanged;
148 [MonoTODO]
149 public event EventHandler DisplayMemberChanged;
152 // --- Protected Constructor
154 [MonoTODO]
155 protected ListControl () {
160 // --- Protected Properties
162 [MonoTODO]
163 protected CurrencyManager DataManager {
164 get {
165 throw new NotImplementedException ();
170 // --- Protected Methods
173 [MonoTODO]
174 protected object FilterItemOnProperty(object item){
175 throw new NotImplementedException ();
178 [MonoTODO]
179 protected object FilterItemOnProperty(object item, string field){
180 throw new NotImplementedException ();
183 [MonoTODO]
184 protected override bool IsInputKey (Keys keyData) {
185 //FIXME:
186 return base.IsInputKey(keyData);
188 [MonoTODO]
189 protected virtual void OnDataSourceChanged (EventArgs e) {
190 //FIXME:
192 [MonoTODO]
193 protected virtual void OnDisplayMemberChanged (EventArgs e) {
194 //FIXME:
197 [MonoTODO]
198 protected virtual void OnSelectedIndexChanged (EventArgs e) {
199 //FIXME:
202 [MonoTODO]
203 protected virtual void OnSelectedValueChanged (EventArgs e) {
204 //FIXME:
207 public event EventHandler SelectedValueChanged;
208 public event EventHandler ValueMemberChanged;
210 [MonoTODO]
211 protected override void OnBindingContextChanged (EventArgs e) {
212 //FIXME:
213 base.OnBindingContextChanged(e);
216 [MonoTODO]
217 protected virtual void OnValueMemberChanged (EventArgs e) {
218 //FIXME:
221 [MonoTODO]
222 protected virtual void SetItemCore (int index, object value) {
223 //FIXME:
225 protected abstract void SetItemsCore (IList items);
227 [MonoTODO]
228 protected abstract void RefreshItem (int index);