(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.Windows.Forms / System.Windows.Forms / ListViewItem.cs
blob85c98d406775c444f432bc3f395fe1d783dd7973
1 //
2 // System.Windows.Forms.ListViewItem.cs
3 //
4 // Author:
5 // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
6 // Dennis Hayes (dennish@Raytek.com)
7 // Implemented by Jordi Mas i Hernàndez (jmas@softcatala.org)
8 //
9 // (C) 2002/3 Ximian, Inc
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System.Runtime.Serialization;
33 using System.Drawing;
34 using System.Collections;
35 using System.Runtime.InteropServices;
37 namespace System.Windows.Forms
39 // <summary>
40 // </summary>
41 [Serializable]
42 public class ListViewItem : ICloneable, ISerializable
44 private ListView container = null;
45 private string text;
46 private ListViewSubItemCollection colSubItem = null;
47 private int index;
48 private bool bSelected = false;
49 private bool useItemStyleForSubItems = true;
50 private bool bChecked = false;
51 private bool bFocused = false;
52 private Color backColor = SystemColors.Window;
53 private Color foreColor = SystemColors.WindowText;
54 private object tag = null;
58 // --- Constructor
59 //
60 protected void CommonConstructor(){
61 colSubItem = new ListViewSubItemCollection(this);
64 public ListViewItem(){
65 CommonConstructor();
68 public ListViewItem(string str) {
69 Console.WriteLine("ListViewItem.ListViewItem str");
70 CommonConstructor();
71 text = str;
74 public ListViewItem(string[] strings){ // An array of strings that represent the subitems of the new item.
76 Console.WriteLine("ListView.ListView strings");
77 CommonConstructor();
79 if (strings.Length>0)
80 text = strings[0];
82 if (strings.Length>1)
84 for (int i=1; i<strings.Length; i++)
85 colSubItem.Add(strings[i]);
90 public ListViewItem(ListViewItem.ListViewSubItem[] subItems){
92 CommonConstructor();
93 for (int i=0; i<subItems.Length; i++)
94 colSubItem.Add(subItems[i]);
98 public ListViewItem(string str, int imageIndex){
99 //TODO: Image index
100 CommonConstructor();
101 text = str;
105 public ListViewItem(string[] strings, int imageIndex){
106 //TODO: Image index
107 CommonConstructor();
109 if (strings.Length>0)
110 text = strings[0];
112 if (strings.Length>1)
114 for (int i=1; i<strings.Length; i++)
115 colSubItem.Add(strings[i]);
120 public ListViewItem(string[] strings, int imageIndex, Color fColor, Color bColor, Font font){
122 //TODO: Image index
123 CommonConstructor();
125 if (strings.Length>0){
127 text = strings[0];
128 BackColor = bColor;
129 ForeColor = fColor;
132 if (strings.Length>1){
133 ListViewSubItem subItem;
135 for (int i=1; i<strings.Length; i++){
136 subItem = colSubItem.Add(strings[i]);
137 subItem.BackColor = bColor;
138 subItem.ForeColor = fColor;
144 [MonoTODO]
145 public ListViewItem (SerializationInfo info, StreamingContext context)
147 throw new NotImplementedException ();
150 [MonoTODO]
151 public void GetObjectData(SerializationInfo info, StreamingContext context)
153 throw new NotImplementedException ();
158 // --- Public Properties
160 public Color BackColor {
161 get {return backColor;}
162 set {backColor = value;}
166 public Rectangle Bounds {
167 get {return container.GetItemBoundInCtrl(Index);}
170 public bool Checked {
171 get {return bChecked;}
172 set {bChecked = value;}
176 public bool Focused {
177 get {return bFocused;}
178 set {bFocused = value;}
181 [MonoTODO]
182 public Font Font {
183 get { // see Control.DefaultFont
184 throw new NotImplementedException ();
186 set {
187 //FIXME:
191 public Color ForeColor {
192 get {return foreColor;}
193 set {foreColor = value;}
195 [MonoTODO]
196 public int ImageIndex {
197 get {
198 throw new NotImplementedException ();
200 set {
201 //FIXME:
204 [MonoTODO]
205 public ImageList ImageList {
206 get {
207 throw new NotImplementedException ();
211 public int Index {
212 get {return index;}
216 public ListView ListView {
217 get {return container;}
220 public bool Selected {
221 get {return bSelected;}
222 set {bSelected=value;}
224 [MonoTODO]
225 public int StateImageIndex {
226 get {
227 throw new NotImplementedException ();
229 set {
230 //FIXME:
234 public ListViewSubItemCollection SubItems {
235 get {return colSubItem;}
239 public object Tag {
240 get {return tag;}
241 set {tag = value;}
244 public string Text {
245 get { return text;}
246 set { text = value;}
250 public bool UseItemStyleForSubItems {
251 get { return useItemStyleForSubItems;}
252 set { useItemStyleForSubItems = value;}
256 // --- Private Methods
258 internal ListView Container {
259 set{container=value;}
262 internal int CtrlIndex{
263 set{index=value;}
267 // --- Public Methods
269 public void BeginEdit(){
271 if (!container.LabelEdit)
272 throw new InvalidOperationException("LabelEdit disabled");
274 container.LabelEditInCtrl(Index);
277 [MonoTODO]
278 public object Clone()
280 throw new NotImplementedException ();
282 [MonoTODO]
283 public virtual void EnsureVisible()
285 //FIXME:
287 [MonoTODO]
288 public Rectangle GetBounds(ItemBoundsPortion portion)
290 throw new NotImplementedException ();
292 [MonoTODO]
293 public void Remove()
295 //FIXME:
297 [MonoTODO]
298 public override string ToString()
300 //FIXME:
301 return base.ToString();
305 // --- Protected Methods
307 [MonoTODO]
308 protected virtual void Deserialize(SerializationInfo info, StreamingContext context)
310 //FIXME:
312 [MonoTODO]
313 protected virtual void Serialize(SerializationInfo info, StreamingContext context)
315 //FIXME:
318 // ISerializable.method:
319 [MonoTODO]
320 void ISerializable.GetObjectData(SerializationInfo info,StreamingContext context)
322 throw new NotImplementedException ();
326 // System.Windows.Forms.ListViewItem.ListViewSubItemCollection.cs
328 // Author:
329 // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
330 // stub ammended by Jaak Simm (jaaksimm@firm.ee)
331 // Implemented by Jordi Mas i Hernàndez (jmas@softcatala.org)
333 // (C) 2002/3 Ximian, Inc
335 // <summary>
336 // </summary>
337 [Serializable]
338 public class ListViewSubItemCollection : IList, ICollection, IEnumerable
341 private ArrayList collection = new ArrayList();
342 private ListViewItem owner = null;
346 // --- Constructor
348 public ListViewSubItemCollection(ListViewItem item) {
349 owner = item;
353 // --- Public Properties
355 public int Count {
356 get { return collection.Count; }
359 public bool IsReadOnly
361 get { return collection.IsReadOnly; }
364 public ListViewSubItem this[int index]
366 get {
367 if (index<0 || index>=Count) throw new ArgumentOutOfRangeException();
369 return (ListViewSubItem) collection[index];
371 set {
372 if (index<0 || index>=Count) throw new ArgumentOutOfRangeException();
373 collection[index] = value;
377 /// --- ICollection properties ---
378 bool IList.IsFixedSize
380 get { return collection.IsFixedSize; }
383 object IList.this[int index]
385 get { return collection[index]; }
386 set { collection[index] = value; }
389 object ICollection.SyncRoot
391 get { return collection.SyncRoot; }
394 bool ICollection.IsSynchronized
396 get { return collection.IsSynchronized; }
400 // --- Public Methods
402 public ListViewSubItem Add(ListViewItem.ListViewSubItem item)
404 if (item.ListViewItem==null) item.ListViewItem = owner;
405 int nIdx = collection.Add(item);
406 return (ListViewSubItem)collection[nIdx];
410 public ListViewSubItem Add(string text)
412 ListViewItem.ListViewSubItem item = new ListViewSubItem(owner, text);
413 return Add(item);
416 public ListViewSubItem Add(string text,Color fColor,Color bColor,Font font)
418 ListViewSubItem item = new ListViewSubItem(owner, text);
419 item.ForeColor = fColor;
420 item.BackColor = bColor;
421 return Add(item);
425 public void AddRange(ListViewItem.ListViewSubItem[] values) {
427 for (int i=0; i<values.Length; i++)
429 if (values[i].ListViewItem==null) values[i].ListViewItem = owner;
430 Add(values[i]);
434 public void AddRange(string[] values) {
436 for (int i=0; i<values.Length; i++)
437 Add(values[i]);
441 public void AddRange(string[] items,Color fColor, Color bColor, Font font) {
443 for (int i=0; i<items.Length; i++)
444 Add(items[i], fColor, bColor, font);
447 [MonoTODO]
448 public void Clear()
450 //FIXME:
453 public bool Contains(ListViewItem.ListViewSubItem subItem) {
455 return collection.Contains(subItem);
458 public IEnumerator GetEnumerator() {
459 return collection.GetEnumerator();
462 [MonoTODO]
463 void ICollection.CopyTo(Array dest,int index)
465 throw new NotImplementedException ();
468 [MonoTODO]
469 int IList.Add(object item)
471 throw new NotImplementedException ();
474 [MonoTODO]
475 bool IList.Contains(object subItem)
477 throw new NotImplementedException ();
480 [MonoTODO]
481 int IList.IndexOf(object subItem)
483 throw new NotImplementedException ();
486 [MonoTODO]
487 void IList.Insert(int index,object item)
489 //FIXME:
492 [MonoTODO]
493 void IList.Remove(object item)
495 //FIXME:
498 [MonoTODO]
499 public int IndexOf(ListViewItem.ListViewSubItem subItem)
501 throw new NotImplementedException();
504 [MonoTODO]
505 public void Insert(int index,ListViewItem.ListViewSubItem item)
507 //FIXME:
510 [MonoTODO]
511 public void Remove(ListViewItem.ListViewSubItem item)
513 //FIXME:
516 [MonoTODO]
517 public void RemoveAt(int index)
519 //FIXME:
523 // System.Windows.Forms.ListViewItem.ListViewSubItem.cs
525 // Author:
526 // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
528 // (C) 2002 Ximian, Inc
530 // <summary>
531 // </summary>
533 public class ListViewSubItem
536 private string sText;
537 private ListViewItem owner = null;
538 private Color backColor = SystemColors.Window;
539 private Color foreColor = SystemColors.WindowText;
540 private Font font;
543 internal ListViewItem ListViewItem{
544 get{return owner;}
545 set{owner=value;}
550 // --- Constructor
552 public ListViewSubItem(){
556 public ListViewSubItem(ListViewItem item, string str){
558 owner = item;
559 sText = str;
562 public ListViewSubItem(ListViewItem item, string str, Color foreClr, Color backClr, Font fnt){
564 owner = item;
565 sText = str;
566 BackColor = backClr;
567 ForeColor = foreClr;
568 font = fnt;
572 // --- Public Properties
574 public Color BackColor {
575 get {return backColor;}
576 set {backColor = value;}
580 public Font Font {
581 get {return font;}
582 set {font = value;}
585 public Color ForeColor {
586 get {return foreColor;}
587 set {foreColor = value;}
590 public string Text {
591 get {return sText;}
592 set {sText=value;}
596 // --- Public Methods
598 [MonoTODO]
599 public override bool Equals(object obj)
601 //FIXME:
602 return base.Equals(obj);
604 [MonoTODO]
605 public override int GetHashCode() {
606 //FIXME add our proprities
607 return base.GetHashCode();
609 [MonoTODO]
610 public void ResetStyle()
612 //FIXME:
614 [MonoTODO]
615 public override string ToString()
617 //FIXME:
618 return base.ToString();