(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.Windows.Forms / System.Windows.Forms / ListView.cs
blob17a45ade0d2f874c418b612a7cc970dcfbdd1871
1 //
2 // System.Windows.Forms.ListView.cs
3 //
4 // Author:
5 // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu), Dennis Hayes (dennish@raytek.com)
6 // Implemented by Jordi Mas i Hernàndez (jmas@softcatala.org)
7 // (C) 2002/3 Ximian, Inc
8 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 //
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 TODO
34 - Multiple insertions of the same items should thown an exception
35 - Images
36 - Drag and drop
37 - Font
40 using System.Collections;
41 using System;
42 using System.Drawing;
43 using System.ComponentModel;
44 using System.Runtime.InteropServices;
47 namespace System.Windows.Forms {
49 // <summary>
51 // </summary>
52 public class ListView : Control {
54 private ListViewItemCollection itemsCollection = null;
55 private ColumnHeaderCollection columCol = null;
56 private bool bInitialised = false;
57 private View viewMode = View.LargeIcon;
58 private bool bAllowColumnReorder = false;
59 private SortOrder sortOrder = SortOrder.None;
60 private bool bLabelEdit = false;
61 private bool bFullRowSelect = false;
62 private bool bGridLines = false;
63 private bool bAutoArrange = true;
64 private bool bLabelWrap = true;
65 private bool bMultiSelect = true;
66 private bool bCheckBoxes = false;
67 private Color backColor = SystemColors.Window;
68 private Color foreColor = SystemColors.WindowText;
69 private SelectedListViewItemCollection selItemsCol = null;
70 private SelectedIndexCollection selItemIndexs = null;
71 private CheckedListViewItemCollection chkItemCol = null;
72 private CheckedIndexCollection chkIndexCol = null;
73 private ItemActivation activation = ItemActivation.Standard;
74 private ColumnHeaderStyle headerStyle = ColumnHeaderStyle.Clickable;
75 private BorderStyle borderStyle = BorderStyle.Fixed3D;
76 bool bScrollable = true;
77 bool bHideSelection = true;
78 bool bHoverSelection = false;
82 // --- Constructor
83 //
84 public ListView() : base() {
86 itemsCollection = new ListViewItemCollection(this);
87 columCol = new ColumnHeaderCollection(this);
88 selItemsCol = new SelectedListViewItemCollection(this);
89 selItemIndexs = new SelectedIndexCollection(this);
90 chkItemCol = new CheckedListViewItemCollection(this);
91 chkIndexCol = new CheckedIndexCollection(this);
93 INITCOMMONCONTROLSEX initEx = new INITCOMMONCONTROLSEX();
94 initEx.dwICC = CommonControlInitFlags.ICC_LISTVIEW_CLASSES;
95 Win32.InitCommonControlsEx(initEx);
97 SubClassWndProc_ = true;
101 // --- Public Properties
104 public ItemActivation Activation {
105 get {return activation; }
106 set {
107 activation = value;
108 ItemActivationCtrl();
112 [MonoTODO]
113 public ListViewAlignment Alignment {
114 get {
115 return 0;
116 //throw new NotImplementedException ();
118 set {
119 //throw new NotImplementedException ();
123 public bool AllowColumnReorder {
125 get { return bAllowColumnReorder; }
126 set {
127 ExtendedStyleCtrl(ListViewExtendedFlags.LVS_EX_HEADERDRAGDROP, value);
128 bAllowColumnReorder = value;
133 public bool AutoArrange {
135 get {return bAutoArrange; }
136 set {bAutoArrange = value;}
139 public override Color BackColor {
141 get {return backColor; }
142 set {
144 backColor = value;
145 SetBkColorCtrl();
148 [MonoTODO]
149 public override Image BackgroundImage {
150 get {
151 //FIXME:
152 return base.BackgroundImage;
154 set {
155 //FIXME:
156 base.BackgroundImage = value;
160 public BorderStyle BorderStyle {
161 get { return borderStyle; }
162 set { borderStyle = value; }
165 public bool CheckBoxes {
167 get { return bCheckBoxes; }
168 set {
169 ExtendedStyleCtrl(ListViewExtendedFlags.LVS_EX_CHECKBOXES, value);
170 bCheckBoxes = value;
174 public CheckedIndexCollection CheckedIndices {
175 get {return chkIndexCol;}
178 public CheckedListViewItemCollection CheckedItems {
179 get {return chkItemCol;}
182 public ColumnHeaderCollection Columns {
183 get {return columCol;}
186 [MonoTODO]
187 protected override void Dispose(bool disposing){
188 base.Dispose(disposing);
192 public override Color ForeColor {
193 get {return foreColor; }
194 set {foreColor = value;}
197 public bool FullRowSelect {
199 get { return bFullRowSelect;}
200 set {
201 ExtendedStyleCtrl(ListViewExtendedFlags.LVS_EX_FULLROWSELECT, value);
202 bFullRowSelect = value;
206 public bool GridLines {
208 get { return bGridLines;}
209 set {
210 ExtendedStyleCtrl(ListViewExtendedFlags.LVS_EX_GRIDLINES, value);
211 bGridLines = value;
215 public ColumnHeaderStyle HeaderStyle {
216 get {return headerStyle; }
217 set {headerStyle = value;}
220 public bool HideSelection {
221 get {return bHideSelection;}
222 set {bHideSelection=value;}
225 public bool HoverSelection {
226 get {return bHideSelection;}
227 set {
228 ExtendedStyleCtrl(ListViewExtendedFlags.LVS_EX_TRACKSELECT, value);
229 bHideSelection=value;
233 public ListView.ListViewItemCollection Items {
234 get {return itemsCollection;}
238 public bool LabelEdit {
239 get {return bLabelEdit;}
240 set {bLabelEdit=value;}
243 public bool LabelWrap {
244 get {return bLabelWrap;}
245 set {bLabelWrap=value;}
248 [MonoTODO]
249 public ImageList LargeImageList {
250 get {
251 throw new NotImplementedException ();
253 set {
254 throw new NotImplementedException ();
258 public bool MultiSelect {
260 get {return bMultiSelect;}
261 set {bMultiSelect=value;}
265 public bool Scrollable {
266 get {return bScrollable;}
267 set {bScrollable=value;}
270 public ListView.SelectedIndexCollection SelectedIndices {
271 get {return selItemIndexs;}
275 public ListView.SelectedListViewItemCollection SelectedItems {
276 get {return selItemsCol;}
278 [MonoTODO]
279 public ImageList SmallImageList {
280 get {
281 throw new NotImplementedException ();
283 set {
284 throw new NotImplementedException ();
288 public SortOrder Sorting {
290 get {return sortOrder;}
291 set {
292 SortMsg(value);// Throw an exception if an invalid enum value is given
293 sortOrder = value;
298 [MonoTODO]
299 public ImageList StateImageList {
300 get {
301 throw new NotImplementedException ();
303 set {
304 throw new NotImplementedException ();
308 public override string Text {
309 get {
310 return base.Text;
312 set {
313 base.Text = value;
317 public View View {
318 get {return viewMode;}
320 set
322 ViewMode(value); // Throw an exception if an invalid enum value is given
323 viewMode = value;
328 // --- Public Methods
330 [MonoTODO]
331 public void ArrangeIcons() {
332 throw new NotImplementedException ();
334 [MonoTODO]
335 public void ArrangeIcons(ListViewAlignment value) {
336 throw new NotImplementedException ();
339 [MonoTODO]
340 public void BeginUpdate() {
341 throw new NotImplementedException ();
344 public void Clear() {
347 selItemsCol.Clear();
348 itemsCollection.Clear();
349 columCol.Clear();
351 if (!bInitialised) return;
353 Win32.SendMessage(Handle, (int)ListViewMessages.LVM_DELETEALLITEMS, 0,0);
357 [MonoTODO]
358 public void EndUpdate() {
359 throw new NotImplementedException ();
361 [MonoTODO]
362 public void EnsureVisible(int index) {
363 throw new NotImplementedException ();
365 [MonoTODO]
366 public ListViewItem GetItemAt(int x, int y) {
367 throw new NotImplementedException ();
369 [MonoTODO]
370 public Rectangle GetItemRect(int index) {
371 throw new NotImplementedException ();
373 [MonoTODO]
374 public Rectangle GetItemRect(int index, ItemBoundsPortion portion) {
375 throw new NotImplementedException ();
377 [MonoTODO]
378 public override string ToString() {
380 return "List View object";
384 // --- Public Events
386 public event LabelEditEventHandler AfterLabelEdit;
387 public event LabelEditEventHandler BeforeLabelEdit;
388 public event ColumnClickEventHandler ColumnClick;
389 public event EventHandler ItemActivate;
391 [MonoTODO]
392 public event ItemCheckEventHandler ItemCheck;
393 public event ItemDragEventHandler ItemDrag;
394 public event EventHandler SelectedIndexChanged;
397 // --- Protected Properties
399 protected override CreateParams CreateParams {
400 get {
402 CreateParams createParams = base.CreateParams;
404 createParams.ClassName = "SysListView32";
405 createParams.Style = ((int)WindowStyles.WS_CHILD |(int)WindowStyles.WS_VISIBLE|
406 ViewMode(viewMode)| SortMsg(sortOrder));
408 if (LabelEdit) createParams.Style |= (int) ListViewFlags.LVS_EDITLABELS;
409 if (AutoArrange) createParams.Style |= (int) ListViewFlags.LVS_AUTOARRANGE;
410 if (!bLabelWrap) createParams.Style |= (int) ListViewFlags.LVS_NOLABELWRAP;
411 if (!bMultiSelect) createParams.Style |= (int) ListViewFlags.LVS_SINGLESEL;
412 if (!bScrollable) createParams.Style |= (int) ListViewFlags.LVS_NOSCROLL;
413 if (!bHideSelection) createParams.Style |= (int) ListViewFlags.LVS_SHOWSELALWAYS;
415 switch (headerStyle)
417 case ColumnHeaderStyle.Clickable: // Default
418 break;
419 case ColumnHeaderStyle.Nonclickable:
420 createParams.Style |= (int) ListViewFlags.LVS_NOSORTHEADER;
421 break;
422 case ColumnHeaderStyle.None:
423 createParams.Style |= (int) ListViewFlags.LVS_NOCOLUMNHEADER;
424 break;
425 default:
426 break;
429 switch (borderStyle)
431 case BorderStyle.Fixed3D:
432 createParams.ExStyle |= (int) WindowExStyles.WS_EX_CLIENTEDGE;
433 break;
434 case BorderStyle.FixedSingle:
435 createParams.Style |= (int) WindowStyles.WS_BORDER;
436 break;
437 case BorderStyle.None:
438 //createParams.ExStyle |= (int) ListViewFlags.LVS_NOCOLUMNHEADER;
439 break;
440 default:
441 break;
444 return createParams;
447 [MonoTODO]
448 protected override Size DefaultSize {
449 get {
450 return new Size(121, 97); //Correct Size.
455 // --- Protected Methods
458 [MonoTODO]
459 protected override void CreateHandle() {
460 base.CreateHandle();
463 [MonoTODO]
464 protected override bool IsInputKey(Keys keyData) {
465 //FIXME:
466 return base.IsInputKey(keyData);
470 // Implemented
471 protected virtual void OnAfterLabelEdit(LabelEditEventArgs e) {}
472 protected virtual void OnBeforeLabelEdit(LabelEditEventArgs e) {}
473 protected virtual void OnColumnClick(ColumnClickEventArgs e) {}
474 protected virtual void OnItemActivate(EventArgs e) {}
476 [MonoTODO]
477 protected override void OnEnabledChanged(EventArgs e) {
478 //FIXME:
479 base.OnEnabledChanged(e);
482 [MonoTODO]
483 protected override void OnFontChanged(EventArgs e) {
484 //FIXME:
485 base.OnFontChanged(e);
487 [MonoTODO]
488 protected override void OnHandleCreated(EventArgs e) {
489 //FIXME:
490 base.OnHandleCreated(e);
492 [MonoTODO]
493 protected override void OnHandleDestroyed(EventArgs e) {
494 //FIXME:
498 [MonoTODO]
499 protected virtual void OnItemCheck(ItemCheckEventArgs e) {
500 //FIXME:
502 [MonoTODO]
503 protected virtual void OnItemDrag(ItemDragEventArgs e) {
504 //FIXME:
506 // [MonoTODO]
507 // protected virtual void OnSelectedItemChanged(EventArgs e) {
508 // //FIXME:
509 // }
511 [MonoTODO]
512 protected override void OnSystemColorsChanged(EventArgs e) {
513 //FIXME:
514 base.OnSystemColorsChanged(e);
516 [MonoTODO]
517 protected override void Select(bool directed, bool forward) {
518 //FIXME:
519 base.Select(directed, forward);
521 [MonoTODO]
522 protected void UpdateExtendedStyles() {
523 //FIXME:
528 // --- Private Methods
530 private int TextAlign(HorizontalAlignment textAlign)
532 int style = 0;
533 switch (textAlign)
535 case HorizontalAlignment.Left:
536 style = (int) ListViewColumnFlags.LVCFMT_LEFT;
537 break;
538 case HorizontalAlignment.Center:
539 style = (int) ListViewColumnFlags.LVCFMT_CENTER;
540 break;
541 case HorizontalAlignment.Right:
542 style = (int) ListViewColumnFlags.LVCFMT_RIGHT;
543 break;
545 default:
546 throw new InvalidEnumArgumentException(); // TODO: Is this ok?
549 return style;
552 // Converts from SortOrder enumerator to a LVS_ type
553 private int SortMsg(SortOrder sortOrder) {
555 int nRslt;
557 switch (sortOrder)
559 case SortOrder.Ascending:
560 nRslt = (int) ListViewFlags.LVS_SORTASCENDING;
561 break;
562 case SortOrder.Descending:
563 nRslt = (int) ListViewFlags.LVS_SORTDESCENDING;
564 break;
565 case SortOrder.None:
566 nRslt = 0;
567 break;
569 default:
570 throw new InvalidEnumArgumentException(); // TODO: Is this ok?
573 //Console.WriteLine("Sort value " + nRslt);
574 return nRslt;
577 // Convers from SortOrder enumerator to a LVS_ type
578 private ListViewExtendedFlags ItemActivationMsg(ItemActivation itemActivation) {
580 ListViewExtendedFlags nRslt;
582 switch (itemActivation)
584 case ItemActivation.OneClick:
585 nRslt = ListViewExtendedFlags.LVS_EX_ONECLICKACTIVATE;
586 break;
587 case ItemActivation.TwoClick:
588 nRslt = ListViewExtendedFlags.LVS_EX_TWOCLICKACTIVATE;
589 break;
590 case ItemActivation.Standard:
591 nRslt = 0;
592 break;
594 default:
595 throw new InvalidEnumArgumentException();
598 return nRslt;
602 // Converts from enum View to Win32 LCV_ flag
604 private int ViewMode(View view)
606 int viewCtrl = 0;
607 switch (view)
609 case View.Details:
610 viewCtrl = (int) ListViewFlags.LVS_REPORT;
611 break;
612 case View.LargeIcon:
613 viewCtrl = (int) ListViewFlags.LVS_ICON;
614 break;
615 case View.List:
616 viewCtrl = (int) ListViewFlags.LVS_LIST;
617 break;
618 case View.SmallIcon:
619 viewCtrl = (int) ListViewFlags.LVS_SMALLICON;
620 break;
622 default:
623 throw new InvalidEnumArgumentException();
626 return viewCtrl;
629 // Inserts a column in the control
630 internal void InsertColumnInCtrl(ColumnHeader column)
632 if (!bInitialised) return;
634 LVCOLUMN lvc = new LVCOLUMN();
635 bool bAutoSizing = false;
636 int iCol;
638 Console.WriteLine("Insert columns " + column.Text + " pos: " + column.Index+ " serial: "+ column.Serial+ " autosizing " + bAutoSizing);
640 lvc.mask = (int)( ListViewColumnFlags.LVCF_FMT | ListViewColumnFlags.LVCF_WIDTH | ListViewColumnFlags.LVCF_TEXT | ListViewColumnFlags.LVCF_SUBITEM);
641 lvc.iSubItem = column.Serial;
642 lvc.pszText = column.Text;
643 lvc.cx = column.Width;
644 lvc.fmt = TextAlign(column.TextAlign);
646 IntPtr lvcBuffer = Marshal.AllocHGlobal(Marshal.SizeOf(lvc));
647 Marshal.StructureToPtr(lvc, lvcBuffer, false);
648 iCol = (int) Win32.SendMessage(Handle, (int)ListViewMessages.LVM_INSERTCOLUMNA, column.Index, lvcBuffer);
649 Marshal.FreeHGlobal(lvcBuffer);
652 // Inserts an item in the control
653 internal void InsertItemInCtrl(ListViewItem listViewItem)
655 if (!bInitialised) return;
657 LVITEM item = new LVITEM();
659 item.pszText = listViewItem.Text;
660 item.iItem = listViewItem.Index;
661 item.iSubItem = 0;
662 item.lParam = 0;
663 item.mask = ListViewItemFlags.LVIF_TEXT;
665 IntPtr liBuffer = Marshal.AllocHGlobal(Marshal.SizeOf(item));
666 Marshal.StructureToPtr(item, liBuffer, false);
667 Win32.SendMessage(Handle, (int)ListViewMessages.LVM_INSERTITEMA, listViewItem.Index, liBuffer);
668 Marshal.FreeHGlobal(liBuffer);
670 Console.WriteLine("Inserting " + listViewItem.Index + "-" + listViewItem.Text);
673 // Removes an item in the control
674 internal void RemoveItemInCtrl(int iIndex)
676 if (!bInitialised) return;
677 Console.WriteLine("Deleting " + iIndex);
678 Win32.SendMessage(Handle, (int)ListViewMessages.LVM_DELETEITEM, iIndex, 0);
682 // Get item bound
683 internal Rectangle GetItemBoundInCtrl(int iIndex)
685 if (!bInitialised) return new Rectangle();
687 IntPtr lpBuffer = IntPtr.Zero;
689 try {
690 RECT rect = new RECT();
691 rect.left = (int) SubItemPortion.LVIR_BOUNDS;
692 lpBuffer = Marshal.AllocHGlobal(Marshal.SizeOf(rect));
693 Marshal.StructureToPtr(rect, lpBuffer, false);
694 Win32.SendMessage (Handle, (int) ListViewMessages.LVM_GETITEMRECT , iIndex, lpBuffer);
696 rect = (RECT) Marshal.PtrToStructure (lpBuffer, typeof (RECT));
697 return new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top );
699 finally {
700 Marshal.FreeHGlobal (lpBuffer);
704 // Forces label edit
705 internal void LabelEditInCtrl(int iIndex)
707 if (!bInitialised) return;
709 Win32.SetFocus(Handle); // Need focus first
710 Win32.SendMessage (Handle, (int) ListViewMessages.LVM_EDITLABEL, iIndex, 0);
714 // Sets a subitem
715 internal void SetItemInCtrl(ListViewItem.ListViewSubItem listViewSubItem, int nPos)
717 if (!bInitialised) return;
719 LVITEM item = new LVITEM();
721 item.pszText = listViewSubItem.Text;
722 item.iItem = listViewSubItem.ListViewItem.Index;
723 item.iSubItem = nPos;
724 item.lParam = 0;
725 item.mask = ListViewItemFlags.LVIF_TEXT;
727 Console.WriteLine("SetItemInCtrl " + nPos);
729 IntPtr liBuffer = Marshal.AllocHGlobal(Marshal.SizeOf(item));
730 Marshal.StructureToPtr(item, liBuffer, false);
731 Win32.SendMessage(Handle, (int)ListViewMessages.LVM_SETITEMA, 0, liBuffer);
732 Marshal.FreeHGlobal(liBuffer);
737 // Remove a column from the control
738 internal int DeleteColumnInCtrl(int nIndex){
740 if (!bInitialised) return 0;
742 Console.WriteLine("Delete column " + nIndex);
743 return Win32.SendMessage(Handle, (int)ListViewMessages.LVM_DELETECOLUMN, nIndex, 0);
746 // Get the check status of an item
747 internal bool GetCheckStateInCtrl(int nIndex){
749 if (!bInitialised) return false;
751 if ((Win32.SendMessage(Handle, (int)ListViewMessages.LVM_GETITEMSTATE, nIndex,
752 (int)ListViewItemState.LVIS_STATEIMAGEMASK) & (int)ListViewItemState.LVIS_CHECKED)==(int)ListViewItemState.LVIS_CHECKED)
753 return true;
754 else
755 return false;
759 // Sets item activation
760 internal void ItemActivationCtrl(){
762 ListViewExtendedFlags flags = ItemActivationMsg(Activation); // Thowns an exception
764 if (!bInitialised) return;
766 if (flags==0) // Standard mode
768 Win32.SendMessage(Handle, (int)ListViewMessages.LVM_SETEXTENDEDLISTVIEWSTYLE, (int)ListViewExtendedFlags.LVS_EX_ONECLICKACTIVATE, 0);
769 Win32.SendMessage(Handle, (int)ListViewMessages.LVM_SETEXTENDEDLISTVIEWSTYLE, (int)ListViewExtendedFlags.LVS_EX_TWOCLICKACTIVATE, 0);
771 else
772 Win32.SendMessage(Handle, (int)ListViewMessages.LVM_SETEXTENDEDLISTVIEWSTYLE, (int)flags, (int)flags);
775 // Sets or remove and extended style from the control
776 internal void ExtendedStyleCtrl(ListViewExtendedFlags ExStyle, bool bStatus){
778 if (!bInitialised) return;
780 if (bStatus)
781 Win32.SendMessage(Handle, (int)ListViewMessages.LVM_SETEXTENDEDLISTVIEWSTYLE, (int)ExStyle, (int)ExStyle);
782 else
783 Win32.SendMessage(Handle, (int)ListViewMessages.LVM_SETEXTENDEDLISTVIEWSTYLE, (int)ExStyle, 0);
787 // Sets Background color in control
788 internal void SetBkColorCtrl(){
790 if (!bInitialised) return;
791 Win32.SendMessage(Handle, (int)ListViewMessages.LVM_SETBKCOLOR, 0, (int) (backColor.R | backColor.G<<8 | backColor.B <<16));
794 // Sets Background color in an item
795 internal void SetItemBkColorCtrl(Color col){
797 if (!bInitialised) return;
798 Win32.SendMessage(Handle, (int)ListViewMessages.LVM_SETTEXTBKCOLOR, 0, (int) (col.R | col.G<<8 | col.B <<16));
801 internal void insertItemsInCtrl() {
803 Win32.SendMessage(Handle, (int)ListViewMessages.LVM_DELETEALLITEMS, 0,0);
804 Win32.SendMessage(Handle, (int)Msg.WM_SETREDRAW, 0,0);
805 for (int i=0; i<Items.Count; i++){ // Insert items
807 InsertItemInCtrl(Items[i]);
809 for (int s=0; s<Items[i].SubItems.Count; s++) // Insert subitems
810 SetItemInCtrl(Items[i].SubItems[s], s+1);
813 Win32.SendMessage(Handle, (int)Msg.WM_SETREDRAW, 1,0);
817 protected override void WndProc(ref Message m) {
819 if (!bInitialised) {
821 bInitialised=true;
823 if (bAllowColumnReorder) ExtendedStyleCtrl(ListViewExtendedFlags.LVS_EX_HEADERDRAGDROP, bAllowColumnReorder);
824 if (bFullRowSelect) ExtendedStyleCtrl(ListViewExtendedFlags.LVS_EX_FULLROWSELECT, bFullRowSelect);
825 if (bGridLines) ExtendedStyleCtrl(ListViewExtendedFlags.LVS_EX_GRIDLINES, bGridLines);
826 if (bCheckBoxes) ExtendedStyleCtrl(ListViewExtendedFlags.LVS_EX_CHECKBOXES, bCheckBoxes);
827 if (bHoverSelection) ExtendedStyleCtrl(ListViewExtendedFlags.LVS_EX_TRACKSELECT, bHoverSelection);
829 SetBkColorCtrl();
830 ItemActivationCtrl();
832 for (int i=0; i<Columns.Count; i++) // Insert columns
833 InsertColumnInCtrl(Columns[i]);
835 insertItemsInCtrl();
837 // We need to setup the column autoresizing flags after all the columns and items
838 // are inserted
839 for (int i=0; i<Columns.Count; i++) {
841 if (Columns[i].Width!=-1 && Columns[i].Width!=-2) continue;
843 Win32.SendMessage(Handle, (int)ListViewMessages.LVM_SETCOLUMNWIDTH, Columns[i].Index,
844 Columns[i].Width);
849 if (m.Msg == (int) Msg.WM_NOTIFY)
851 NMHDR nmhdr = (NMHDR)Marshal.PtrToStructure (m.LParam, typeof (NMHDR));
853 m.Result = IntPtr.Zero;
855 //Console.WriteLine("Notify->" + m);
857 switch (nmhdr.code ) {
858 case (int)ListViewNotifyMsg.LVN_COLUMNCLICK:
860 NMLISTVIEW NmLstView = (NMLISTVIEW)Marshal.PtrToStructure (m.LParam, typeof (NMLISTVIEW));
862 // Get get the index of the visual order, we have to we get the column unique ID to get its object
863 LVCOLUMN lvc = new LVCOLUMN();
864 lvc.mask = (int) ListViewColumnFlags.LVCF_SUBITEM;
866 IntPtr lvcBuffer = Marshal.AllocHGlobal(Marshal.SizeOf(lvc));
867 Marshal.StructureToPtr(lvc, lvcBuffer, false);
868 Win32.SendMessage(Handle, (int)ListViewMessages.LVM_GETCOLUMNA, NmLstView.iSubItem, lvcBuffer);
869 lvc = (LVCOLUMN) Marshal.PtrToStructure(lvcBuffer, typeof(LVCOLUMN));
871 ColumnHeader col = Columns.FromSerial(lvc.iSubItem);
872 ColumnClickEventArgs eventArg = new ColumnClickEventArgs(col.Index);
873 OnColumnClick(eventArg);
875 Marshal.FreeHGlobal(lvcBuffer);
876 break;
879 case (int)ListViewNotifyMsg.LVN_BEGINLABELEDITA:
881 Console.WriteLine("ListViewMessages.LVN_BEGINLABELEDITA");
883 LVDISPINFO lvDispInfo = (LVDISPINFO)Marshal.PtrToStructure (m.LParam, typeof (LVDISPINFO));
884 LabelEditEventArgs editEvent = new LabelEditEventArgs(lvDispInfo.item.iItem);
885 editEvent.CancelEdit = false;
887 OnBeforeLabelEdit(editEvent);
889 if (editEvent.CancelEdit)
890 m.Result = (System.IntPtr)1;
891 else
892 m.Result = (System.IntPtr)0;
894 return;
898 case (int)ListViewNotifyMsg.LVN_ENDLABELEDITA:
900 Console.WriteLine("ListViewMessages.LVN_ENDLABELEDITA");
902 LVDISPINFO lvDispInfo = (LVDISPINFO)Marshal.PtrToStructure (m.LParam, typeof (LVDISPINFO));
903 LabelEditEventArgs editEvent = new LabelEditEventArgs(lvDispInfo.item.iItem, lvDispInfo.item.pszText);
904 editEvent.CancelEdit = false;
906 OnAfterLabelEdit(editEvent);
908 if (editEvent.CancelEdit)
909 m.Result = (System.IntPtr)0;
910 else
911 m.Result = (System.IntPtr)1;
913 return;
916 case (int)ListViewNotifyMsg.LVN_ITEMACTIVATE:
918 //NMITEMACTIVATE is used instead of NMLISTVIEW in IE >= 0x400
919 NMITEMACTIVATE NmItemAct = (NMITEMACTIVATE)Marshal.PtrToStructure (m.LParam, typeof (NMITEMACTIVATE));
921 Console.WriteLine("ListViewMessages.LVN_ITEMACTIVATE " + NmItemAct.iItem + "sub: " + NmItemAct.iSubItem);
923 OnItemActivate(new EventArgs());
925 break;
928 case (int)ListViewNotifyMsg.LVN_ITEMCHANGED:
931 NMLISTVIEW NmLstView = (NMLISTVIEW)Marshal.PtrToStructure (m.LParam, typeof (NMLISTVIEW));
933 Console.WriteLine("ListViewMessages.LVN_ITEMCHANGED item:" + NmLstView.iItem + " sub: "+ NmLstView.iSubItem + "att:" +NmLstView.uChanged);
935 // NOTE: Using the LVIS_SELECTED status does not work well when you use the control
936 // to select diferent items.
938 // Selected
939 selItemsCol.Clear();
940 for (int i=0; i < selItemIndexs.Count; i++)
941 Items[selItemIndexs[i]].Selected=false;
943 int nItem = Win32.SendMessage(Handle, (int)ListViewMessages.LVM_GETNEXTITEM, -1, (int) ListViewNotifyItem.LVNI_SELECTED);
945 while (nItem!=-1)
947 selItemsCol.Add(nItem);
948 Items[nItem].Selected=true;
949 nItem = Win32.SendMessage(Handle, (int)ListViewMessages.LVM_GETNEXTITEM, nItem, (int) ListViewNotifyItem.LVNI_SELECTED);
952 // Check checked items
953 int nItems = Win32.SendMessage(Handle, (int)ListViewMessages.LVM_GETITEMCOUNT, 0, 0);
955 chkItemCol.Clear();
956 for (int i=0; i < chkItemCol.Count; i++)
957 Items[i].Checked = false;
959 for (int i=0; i<nItems; i++){
960 if (GetCheckStateInCtrl(i)) {
961 chkItemCol.Add(i);
962 Items[i].Checked = true;
966 break;
969 // Note: Under WinXP we get HDN_ITEMCHANGEDW
970 // seems that we change this using LVM_SETUNICODEFORMAT
971 case (int)HeaderCtrlNOtify.HDN_ITEMCHANGEDA:
972 case (int)HeaderCtrlNOtify.HDN_ITEMCHANGEDW:
975 NMHEADER NmHeader = (NMHEADER)Marshal.PtrToStructure (m.LParam, typeof (NMHEADER));
976 HDITEM HDItem = (HDITEM)Marshal.PtrToStructure(NmHeader.pitem, typeof (HDITEM));
978 if (((uint)HDItem.mask & (uint)HeaderItemFlags.HDI_HEIGHT)==(uint)HeaderItemFlags.HDI_HEIGHT)
980 Console.WriteLine("HDN_ITEMCHANGED item:" + NmHeader.iItem + " width: " +HDItem.cxy);
981 Columns[NmHeader.iItem].Width = HDItem.cxy;
984 break;
988 // Used to paint item colours and font
989 case (int)NotificationMessages.NM_CUSTOMDRAW:
992 NMLVCUSTOMDRAW LVNmCustom = (NMLVCUSTOMDRAW)Marshal.PtrToStructure (m.LParam, typeof (NMLVCUSTOMDRAW));
994 switch(LVNmCustom.nmcd.dwDrawStage) {
997 case (int)CustomDrawDrawStateFlags.CDDS_PREPAINT:
998 m.Result = (IntPtr)CustomDrawReturnFlags.CDRF_NOTIFYITEMDRAW;
999 return;
1001 case (int)CustomDrawDrawStateFlags.CDDS_ITEMPREPAINT:
1003 if (Items[(int)LVNmCustom.nmcd.dwItemSpec].UseItemStyleForSubItems) {
1005 LVNmCustom.clrTextBk = (uint) Win32.RGB (Items[(int)LVNmCustom.nmcd.dwItemSpec].BackColor);
1006 LVNmCustom.clrText = (uint) Win32.RGB (Items[(int)LVNmCustom.nmcd.dwItemSpec].ForeColor);
1007 Marshal.StructureToPtr(LVNmCustom, m.LParam, false);
1008 m.Result =(IntPtr)CustomDrawReturnFlags.CDRF_NEWFONT;
1010 else
1011 m.Result =(IntPtr)CustomDrawReturnFlags.CDRF_NOTIFYSUBITEMDRAW;
1013 return;
1015 case (int)(CustomDrawDrawStateFlags.CDDS_SUBITEM | CustomDrawDrawStateFlags.CDDS_ITEMPREPAINT):
1017 ListViewItem item = Items[(int)LVNmCustom.nmcd.dwItemSpec];
1020 if (LVNmCustom.iSubItem==0) {
1021 LVNmCustom.clrTextBk = (uint) Win32.RGB (Items[(int)LVNmCustom.nmcd.dwItemSpec].BackColor);
1022 LVNmCustom.clrText = (uint) Win32.RGB (Items[(int)LVNmCustom.nmcd.dwItemSpec].ForeColor);
1023 Marshal.StructureToPtr(LVNmCustom, m.LParam, false);
1024 m.Result =(IntPtr)CustomDrawReturnFlags.CDRF_NEWFONT;
1026 else{
1028 ListViewItem.ListViewSubItem subItem;
1029 int nIdx = (int) LVNmCustom.iSubItem-1;
1031 // We get an event by column even if the item is not inseted
1032 if (nIdx<item.SubItems.Count){
1033 subItem = item.SubItems[nIdx];
1034 LVNmCustom.clrTextBk = (uint) Win32.RGB (subItem.BackColor);
1035 LVNmCustom.clrText = (uint) Win32.RGB (subItem.ForeColor);
1036 Marshal.StructureToPtr(LVNmCustom, m.LParam, false);
1037 m.Result =(IntPtr)CustomDrawReturnFlags.CDRF_NEWFONT;
1041 return;
1044 default:
1045 break;
1048 break;
1051 default:
1052 break;
1056 CallControlWndProc (ref m);
1059 //start subclasses
1061 // System.Windows.Forms.ListView.SelectedListViewItemCollection.cs
1063 // Author:
1064 // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
1065 // implemented by Jordi Mas i Hernàndez <jmas@softcatala.org>
1067 // It has been implemented really as an array of indexes of ListViewItemCollection
1068 // to avoid information and item duplication in memory / Jordi
1070 // (C) 2002-3 Ximian, Inc
1072 // <summary>
1073 // </summary>
1075 public class SelectedListViewItemCollection : IList, ICollection, IEnumerable {
1077 private ListView container = null;
1078 private ArrayList collection = new ArrayList();
1081 // --- Constructor
1083 public SelectedListViewItemCollection(ListView owner) {
1084 container = owner;
1088 // --- Public Properties
1090 public int Count {
1091 get { return collection.Count; }
1093 public bool IsReadOnly {
1094 get { return collection.IsReadOnly; }
1097 public ListViewItem this[int index] {
1099 get {
1100 if (index<0 || index>=Count) throw new ArgumentOutOfRangeException();
1101 return container.Items[(int)collection[index]];
1103 set {
1104 if (index<0 || index>=Count) throw new ArgumentOutOfRangeException();
1105 collection[index] = value.Index;}
1109 // --- Internal Methods for the implementation
1111 internal void Add (int nIndex) {
1112 collection.Add(nIndex);
1115 internal void Remove (int nIndex) {
1116 collection.Remove(nIndex);
1120 // --- Public Methods
1123 public void Clear() {
1124 collection.Clear();
1127 public bool Contains(ListViewItem item) {
1128 return collection.Contains(item);
1131 public void CopyTo(Array dest, int index) {
1132 collection.CopyTo(dest, index);
1135 public override bool Equals(object obj) {
1136 return collection.Equals(obj);
1139 [MonoTODO]
1140 public override int GetHashCode() {
1141 //FIXME add our proprities
1142 return base.GetHashCode();
1145 public IEnumerator GetEnumerator() {
1146 return collection.GetEnumerator();
1149 public int IndexOf(ListViewItem item) {
1150 return collection.IndexOf(item);
1152 /// <summary>
1153 /// IList Interface implmentation.
1154 /// </summary>
1155 bool IList.IsReadOnly{
1156 get{return collection.IsReadOnly;}
1158 bool IList.IsFixedSize{
1159 get{return collection.IsFixedSize;}
1163 object IList.this[int index]{
1164 get { return collection[index]; }
1165 set { collection[index] = value; }
1168 void IList.Clear(){
1169 collection.Clear();
1173 int IList.Add( object value){
1174 return collection.Add(value);
1178 bool IList.Contains( object value){
1179 return collection.Contains(value);
1183 int IList.IndexOf( object value){
1184 return collection.IndexOf(value);
1188 void IList.Insert(int index, object value){
1189 collection.Insert(index, value);
1193 void IList.Remove( object value){
1194 collection.Remove(value);
1198 void IList.RemoveAt( int index){
1199 collection.RemoveAt(index);
1201 // End of IList interface
1202 /// <summary>
1203 /// ICollection Interface implmentation.
1204 /// </summary>
1205 int ICollection.Count{
1206 get{
1207 throw new NotImplementedException ();
1210 bool ICollection.IsSynchronized{
1211 get{
1212 throw new NotImplementedException ();
1215 object ICollection.SyncRoot{
1216 get{
1217 throw new NotImplementedException ();
1220 void ICollection.CopyTo(Array array, int index){
1221 //FIXME:
1223 // End Of ICollection
1226 // System.Windows.Forms.ListView.CheckedListViewItemCollection.cs
1228 // Author:
1229 // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
1230 // implemented by Jordi Mas i Hernàndez <jmas@softcatala.org>
1232 // It has been implemented really as an array of indexes of ListViewItemCollection
1233 // to avoid information and item duplication in memory / Jordi
1234 // (C) 2002-3 Ximian, Inc
1236 // <summary>
1237 // </summary>
1239 public class CheckedListViewItemCollection : IList, ICollection, IEnumerable {
1241 private ListView container = null;
1242 private ArrayList collection = new ArrayList();
1245 // --- Constructor
1247 public CheckedListViewItemCollection(ListView owner) {
1248 container = owner;
1252 // --- Public Properties
1254 public int Count {
1255 get { return collection.Count; }
1258 public bool IsReadOnly {
1259 get {return true;}
1262 public virtual ListViewItem this[int index] {
1263 get {
1264 if (index<0 || index>=Count) throw new ArgumentOutOfRangeException();
1265 return container.Items[(int)collection[index]];
1267 set {
1268 if (index<0 || index>=Count) throw new ArgumentOutOfRangeException();
1269 collection[index] = value.Index;
1274 // --- Internal Methods for the implementation
1276 internal void Clear() {
1277 collection.Clear();
1280 internal void Add (int nIndex) {
1281 collection.Add(nIndex);
1286 // --- Public Methods
1288 public bool Contains(ListViewItem item) {
1289 return collection.Contains(item);
1292 [MonoTODO]
1293 public object CopyTo(Array dest, int index) {
1294 throw new NotImplementedException ();
1297 public override bool Equals(object obj) {
1298 return collection.Equals(obj);
1300 [MonoTODO]
1301 public override int GetHashCode() {
1302 //FIXME add our proprities
1303 return base.GetHashCode();
1306 public IEnumerator GetEnumerator() {
1307 return collection.GetEnumerator();
1310 public int IndexOf(ListViewItem item) {
1311 return collection.IndexOf(item);
1313 /// <summary>
1314 /// IList Interface implementation.
1315 /// </summary>
1316 bool IList.IsReadOnly{
1317 get{return true;}
1319 bool IList.IsFixedSize{
1320 get{return true;}
1323 //[MonoTODO]
1324 object IList.this[int index]{
1325 get{
1326 throw new NotImplementedException ();
1328 set{
1329 //FIXME:
1333 [MonoTODO]
1334 void IList.Clear(){
1335 //FIXME:
1338 [MonoTODO]
1339 int IList.Add( object value){
1340 throw new NotImplementedException ();
1343 [MonoTODO]
1344 bool IList.Contains( object value){
1345 throw new NotImplementedException ();
1349 int IList.IndexOf( object value){
1350 return collection.IndexOf(value);
1353 [MonoTODO]
1354 void IList.Insert(int index, object value){
1355 //FIXME:
1358 [MonoTODO]
1359 void IList.Remove( object value){
1360 //FIXME:
1363 [MonoTODO]
1364 void IList.RemoveAt( int index){
1365 //FIXME:
1367 // End of IList interface
1368 /// <summary>
1369 /// ICollection Interface implmentation.
1370 /// </summary>
1371 int ICollection.Count{
1372 get{
1373 throw new NotImplementedException ();
1376 bool ICollection.IsSynchronized{
1377 get{
1378 throw new NotImplementedException ();
1381 object ICollection.SyncRoot{
1382 get{
1383 throw new NotImplementedException ();
1386 void ICollection.CopyTo(Array array, int index){
1387 //FIXME:
1389 // End Of ICollection
1392 // System.Windows.Forms.ListView.ColumnHeaderCollection.cs
1394 // Author:
1395 // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
1396 // Implemented by Jordi Mas i Hernàndez (jmas@softcatala.org)
1398 // (C) 2002-3 Ximian, Inc
1400 // <summary>
1401 // </summary>
1402 public class ColumnHeaderCollection : IList, ICollection, IEnumerable
1404 private ListView container = null;
1405 private ArrayList collection = new ArrayList();
1406 private int nUniqueSerial = 5000;
1409 // --- Constructor
1411 public ColumnHeaderCollection(ListView owner) {
1412 container = owner;
1416 // --- Public Properties
1418 public int Count{
1419 get { return collection.Count; }
1422 public bool IsReadOnly {
1423 get { return collection.IsReadOnly; }
1426 public virtual ColumnHeader this[int index] {
1427 get {
1428 if (index<0 || index>=Count) throw new ArgumentOutOfRangeException();
1429 return (ColumnHeader) collection[index];
1431 set {
1432 if (index<0 || index>=Count) throw new ArgumentOutOfRangeException();
1433 collection[index] = value;
1438 // --- Private methods used by the implementation
1440 public ColumnHeader FromSerial(int nSerial)
1442 for (int i=0; i < collection.Count; i++){
1443 ColumnHeader col = (ColumnHeader)collection[i];
1444 if (col.Serial==nSerial) return col;
1447 return null;
1450 // The indexes have to be re-calculated
1451 public void ReIndexCollection() {
1452 for (int i=0; i < collection.Count; i++)
1454 ColumnHeader col = (ColumnHeader)collection[i];
1455 col.CtrlIndex=i;
1457 container.insertItemsInCtrl();
1461 // --- Public Methods
1464 public virtual int Add(ColumnHeader column) {
1466 column.Serial = nUniqueSerial;
1467 column.CtrlIndex = Count;
1468 collection.Add(column);
1469 nUniqueSerial++;
1471 container.InsertColumnInCtrl(column);
1472 return Count-1;
1475 public virtual ColumnHeader Add(string s, int witdh, HorizontalAlignment align) {
1477 ColumnHeader column = new ColumnHeader();
1479 /* The zero-based index of the column header within the ListView.ColumnHeaderCollection of the ListView control it is contained in.*/
1480 column.CtrlIndex = Count;
1481 column.Text = s;
1482 column.TextAlign = align;
1483 column.Width = witdh;
1484 column.Container = container;
1485 column.Serial = nUniqueSerial;
1486 collection.Add(column);
1487 nUniqueSerial++;
1488 container.InsertColumnInCtrl(column);
1490 return column;
1493 public virtual void AddRange(ColumnHeader[] values) {
1494 for (int i=0; i<values.Length; i++) {
1495 Add(values[i]);
1499 public void Clear() {
1501 // Delete all columns
1502 int nRslt = 1;
1503 for (int n=0; nRslt!=0; n++)
1504 nRslt = container.DeleteColumnInCtrl(0);
1506 collection.Clear();
1509 public bool Contains(ColumnHeader value) {
1510 return collection.Contains(value);
1513 public override bool Equals(object obj) {
1515 if(obj!= null && obj is ColumnHeaderCollection) {
1516 ColumnHeaderCollection that = (ColumnHeaderCollection)obj;
1517 return (this.collection == that.collection);
1520 return false;
1523 [MonoTODO]
1524 public override int GetHashCode()
1526 //FIXME add our proprities
1527 return base.GetHashCode();
1530 public IEnumerator GetEnumerator(){
1531 return collection.GetEnumerator();
1534 public int IndexOf(ColumnHeader value) {
1535 return collection.IndexOf(value);
1538 public void Insert(int index, ColumnHeader column) {
1540 column.Serial = nUniqueSerial;
1541 column.CtrlIndex = index;
1542 collection.Insert(index, column);
1543 nUniqueSerial++;
1544 container.InsertColumnInCtrl(column);
1545 ReIndexCollection();
1548 public void Insert(int index, string str, int witdh, HorizontalAlignment align) {
1550 ColumnHeader column = new ColumnHeader();
1552 column.Text = str;
1553 column.TextAlign = align;
1554 column.Width = witdh;
1555 column.Container = container;
1556 Insert(index, column);
1560 public virtual void Remove(ColumnHeader value) {
1561 RemoveAt(value.Index);
1565 public virtual void RemoveAt(int index)
1567 if (index>=Count)
1568 throw new ArgumentOutOfRangeException("Invalid value for array index");
1570 container.DeleteColumnInCtrl(index);
1571 collection.Remove(collection[index]);
1573 ReIndexCollection();
1576 /// <summary>
1577 /// IList Interface implmentation.
1578 /// </summary>
1579 bool IList.IsReadOnly{
1580 get{
1581 // We allow addition, removeal, and editing of items after creation of the list.
1582 return false;
1585 bool IList.IsFixedSize{
1586 get{
1587 // We allow addition and removeal of items after creation of the list.
1588 return false;
1592 object IList.this[int index]{
1593 [MonoTODO] get { throw new NotImplementedException (); }
1594 [MonoTODO] set { throw new NotImplementedException (); }
1597 [MonoTODO]
1598 void IList.Clear(){
1599 //FIXME:
1602 [MonoTODO]
1603 int IList.Add( object value){
1604 throw new NotImplementedException ();
1607 [MonoTODO]
1608 bool IList.Contains( object value){
1609 throw new NotImplementedException ();
1613 int IList.IndexOf( object value){
1614 return collection.IndexOf(value);
1617 [MonoTODO]
1618 void IList.Insert(int index, object value){
1619 //FIXME:
1622 [MonoTODO]
1623 void IList.Remove( object value){
1624 //FIXME:
1627 [MonoTODO]
1628 void IList.RemoveAt( int index){
1629 //FIXME:
1631 // End of IList interface
1632 /// <summary>
1633 /// ICollection Interface implmentation.
1634 /// </summary>
1635 int ICollection.Count{
1636 get{
1637 throw new NotImplementedException ();
1640 bool ICollection.IsSynchronized{
1641 get{
1642 throw new NotImplementedException ();
1645 object ICollection.SyncRoot{
1646 get{
1647 throw new NotImplementedException ();
1650 void ICollection.CopyTo(Array array, int index){
1651 //FIXME:
1653 // End Of ICollection
1658 // System.Windows.Forms.ListView.ListViewItemCollection.cs
1660 // Author:
1661 // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
1662 // Implemented by Jordi i Hernàndez (jmas@softcatala.org)
1664 // (C) 2002/3 Ximian, Inc
1666 // <summary>
1667 // </summary>
1669 public class ListViewItemCollection : IList, ICollection, IEnumerable
1671 private ListView container = null;
1672 private ArrayList collection = new ArrayList();
1675 // --- Constructor
1677 public ListViewItemCollection (ListView owner) {
1678 container = owner;
1682 // --- Public Properties
1684 public int Count {
1685 get { return collection.Count; }
1688 public bool IsReadOnly {
1689 get { return collection.IsReadOnly; }
1692 public virtual ListViewItem this [int index] {
1693 get {
1695 if (index<0 || index>=Count) throw new ArgumentOutOfRangeException();
1696 return (ListViewItem) collection[index];
1698 set {
1699 if (index<0 || index>=Count) throw new ArgumentOutOfRangeException();
1700 collection[index] = value;
1705 // --- Public Methods
1707 public virtual ListViewItem Add (ListViewItem item) {
1709 Console.WriteLine("ListViewItem.Add " + item.Text + " idx: " + item.Index);
1711 item.CtrlIndex = Count;
1712 item.Container = container;
1713 container.InsertItemInCtrl(item);
1714 int nIdx = collection.Add(item);
1715 return (ListViewItem)collection[nIdx];
1718 [MonoTODO]
1719 public virtual ListViewItem Add (string str) {
1720 throw new NotImplementedException ();
1722 [MonoTODO]
1723 public virtual ListViewItem Add (string str, int val) {
1724 throw new NotImplementedException ();
1727 public void AddRange(ListViewItem[] values) {
1729 for (int i=0; i<values.Length; i++)
1731 container.InsertItemInCtrl(values[i]);
1732 Add(values[i]);
1737 public void Clear() {
1738 collection.Clear();
1740 [MonoTODO]
1741 public bool Contains(ListViewItem item) {
1742 throw new NotImplementedException ();
1744 [MonoTODO]
1745 public void CopyTo(Array dest, int index) {
1746 //FIXME:
1748 [MonoTODO]
1749 public override bool Equals(object obj) {
1750 //FIXME:
1751 return base.Equals(obj);
1754 [MonoTODO]
1755 public override int GetHashCode() {
1756 //FIXME add our proprities
1757 return base.GetHashCode();
1760 public IEnumerator GetEnumerator() {
1761 return collection.GetEnumerator();
1764 public int IndexOf(ListViewItem item) {
1765 return collection.IndexOf(item);
1767 [MonoTODO]
1768 public virtual void Remove(ListViewItem item) {
1769 //FIXME:
1772 public virtual void RemoveAt(int index) {
1774 if (index>=Count)
1775 throw new ArgumentOutOfRangeException("Invalid value for array index");
1777 container.RemoveItemInCtrl(index);
1778 collection.Remove(collection[index]);
1780 // The indexes have to be re-calculated
1781 for (int i=0; i < collection.Count; i++)
1783 ListViewItem item = (ListViewItem)collection[i];
1784 item.CtrlIndex=i;
1787 // Todo: Invalidate selection since indexes have changed
1790 /// <summary>
1791 /// IList Interface implmentation.
1792 /// </summary>
1793 bool IList.IsReadOnly{
1794 get{
1795 // We allow addition, removeal, and editing of items after creation of the list.
1796 return false;
1799 bool IList.IsFixedSize{
1800 get{
1801 // We allow addition and removeal of items after creation of the list.
1802 return false;
1806 //[MonoTODO]
1807 object IList.this[int index]{
1808 get{
1809 throw new NotImplementedException ();
1811 set{
1812 //FIXME:
1816 [MonoTODO]
1817 void IList.Clear(){
1818 //FIXME:
1821 [MonoTODO]
1822 int IList.Add( object value){
1823 throw new NotImplementedException ();
1826 [MonoTODO]
1827 bool IList.Contains( object value){
1828 throw new NotImplementedException ();
1832 int IList.IndexOf( object value){
1833 return collection.IndexOf(value);
1836 [MonoTODO]
1837 void IList.Insert(int index, object value){
1838 //FIXME:
1841 [MonoTODO]
1842 void IList.Remove( object value){
1843 //FIXME:
1846 [MonoTODO]
1847 void IList.RemoveAt( int index){
1848 //FIXME:
1850 // End of IList interface
1851 /// <summary>
1852 /// ICollection Interface implmentation.
1853 /// </summary>
1854 int ICollection.Count{
1855 get{
1856 throw new NotImplementedException ();
1859 bool ICollection.IsSynchronized{
1860 get{
1861 throw new NotImplementedException ();
1864 object ICollection.SyncRoot{
1865 get{
1866 throw new NotImplementedException ();
1869 void ICollection.CopyTo(Array array, int index){
1870 //FIXME:
1872 // End Of ICollection
1875 // System.Windows.Forms.ListView.SelectedIndexCollection.cs
1877 // Author:
1878 // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
1879 // Implemented by Jordi Mas i Hernàndez (jmas@softcatala.org)
1881 // Implemented as a wrapper to SelectedListViewItemCollection
1883 // (C) 2002-3 Ximian, Inc
1886 // <summary>
1887 // </summary>
1889 public class SelectedIndexCollection : IList, ICollection, IEnumerable {
1891 private ListView container = null;
1894 // --- Constructor
1896 public SelectedIndexCollection(ListView owner) {
1897 container = owner;
1901 // --- Public Properties
1903 public int Count {
1904 get { return container.SelectedItems.Count; }
1907 public bool IsReadOnly {
1908 get { return container.SelectedItems.IsReadOnly; }
1912 public int this [int index] {
1913 get {
1914 if (index<0 || index>=Count) throw new ArgumentOutOfRangeException();
1915 return container.SelectedItems[index].Index;
1920 // --- Public Methods
1922 [MonoTODO]
1923 public bool Contains(ListView item) {
1924 throw new NotImplementedException ();
1926 [MonoTODO]
1927 public void CopyTo(Array dest, int index) {
1928 //FIXME:
1930 [MonoTODO]
1931 public override bool Equals(object obj) {
1932 //FIXME:
1933 return base.Equals(obj);
1935 [MonoTODO]
1936 public override int GetHashCode() {
1937 //FIXME add our proprities
1938 return base.GetHashCode();
1940 [MonoTODO]
1941 public IEnumerator GetEnumerator() {
1942 throw new NotImplementedException ();
1945 public int IndexOf(int index) {
1946 throw new NotImplementedException ();
1948 /// <summary>
1949 /// IList Interface implmentation.
1950 /// </summary>
1951 bool IList.IsReadOnly{
1952 get{
1953 // We allow addition, removeal, and editing of items after creation of the list.
1954 return false;
1957 bool IList.IsFixedSize{
1958 get{
1959 // We allow addition and removeal of items after creation of the list.
1960 return false;
1964 object IList.this[int index]{
1965 [MonoTODO] get { throw new NotImplementedException (); }
1966 [MonoTODO] set { throw new NotImplementedException (); }
1969 [MonoTODO]
1970 void IList.Clear(){
1971 //FIXME:
1974 [MonoTODO]
1975 int IList.Add( object value){
1976 throw new NotImplementedException ();
1979 [MonoTODO]
1980 bool IList.Contains( object value){
1981 throw new NotImplementedException ();
1985 int IList.IndexOf( object value){
1986 throw new NotImplementedException ();
1989 [MonoTODO]
1990 void IList.Insert(int index, object value){
1991 //FIXME:
1994 [MonoTODO]
1995 void IList.Remove( object value){
1996 throw new NotImplementedException ();
1999 [MonoTODO]
2000 void IList.RemoveAt( int index){
2001 //FIXME:
2003 // End of IList interface
2004 /// <summary>
2005 /// ICollection Interface implmentation.
2006 /// </summary>
2007 int ICollection.Count{
2008 get{
2009 throw new NotImplementedException ();
2012 bool ICollection.IsSynchronized{
2013 get{
2014 throw new NotImplementedException ();
2017 object ICollection.SyncRoot{
2018 get{
2019 throw new NotImplementedException ();
2022 void ICollection.CopyTo(Array array, int index){
2023 throw new NotImplementedException ();
2025 // End Of ICollection
2028 // System.Windows.Forms.ListView.CheckedIndexCollection.cs
2030 // Author:
2031 // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
2032 // Implemented by Jordi Mas i Hernàndez (jmas@softcatala.org)
2034 // (C) 2002-3 Ximian, Inc
2036 // <summary>
2037 // </summary>
2038 public class CheckedIndexCollection : IList, ICollection, IEnumerable {
2040 private ListView container = null;
2043 // --- Constructor
2045 public CheckedIndexCollection(ListView owner) {
2046 container = owner;
2050 // --- Public Properties
2052 public int Count {
2053 get{return container.CheckedItems.Count;}
2056 public bool IsReadOnly {
2057 get {return container.CheckedItems.IsReadOnly;}
2060 public int this[int index] {
2061 get {
2062 if (index<0 || index>=Count) throw new ArgumentOutOfRangeException();
2063 return container.CheckedItems[index].Index;
2068 // --- Public Methods
2070 public bool Contains(int checkedIndex) {
2071 throw new NotImplementedException ();
2073 [MonoTODO]
2074 public override bool Equals(object obj) {
2075 //FIXME:
2076 return base.Equals(obj);
2078 [MonoTODO]
2079 public override int GetHashCode() {
2080 //FIXME add our proprities
2081 return base.GetHashCode();
2083 [MonoTODO]
2084 public IEnumerator GetEnumerator() {
2085 throw new NotImplementedException ();
2088 public int IndexOf(int checkedIndex) {
2089 throw new NotImplementedException ();
2091 /// <summary>
2092 /// IList Interface implmentation.
2093 /// </summary>
2094 bool IList.IsReadOnly{
2095 get{
2096 // We allow addition, removeal, and editing of items after creation of the list.
2097 return false;
2100 bool IList.IsFixedSize{
2101 get{
2102 // We allow addition and removeal of items after creation of the list.
2103 return false;
2107 //[MonoTODO]
2108 object IList.this[int index]{
2109 get{
2110 throw new NotImplementedException ();
2112 set{
2113 //FIXME:
2117 [MonoTODO]
2118 void IList.Clear(){
2119 //FIXME:
2122 [MonoTODO]
2123 int IList.Add( object value){
2124 throw new NotImplementedException ();
2127 [MonoTODO]
2128 bool IList.Contains( object value){
2129 throw new NotImplementedException ();
2133 int IList.IndexOf( object value){
2134 throw new NotImplementedException ();
2137 [MonoTODO]
2138 void IList.Insert(int index, object value){
2139 //FIXME:
2142 [MonoTODO]
2143 void IList.Remove( object value){
2144 throw new NotImplementedException ();
2147 [MonoTODO]
2148 void IList.RemoveAt( int index){
2149 throw new NotImplementedException ();
2151 // End of IList interface
2152 /// <summary>
2153 /// ICollection Interface implmentation.
2154 /// </summary>
2155 int ICollection.Count{
2156 get{
2157 throw new NotImplementedException ();
2160 bool ICollection.IsSynchronized{
2161 get{
2162 throw new NotImplementedException ();
2165 object ICollection.SyncRoot{
2166 get{
2167 throw new NotImplementedException ();
2170 void ICollection.CopyTo(Array array, int index){
2171 //FIXME:
2173 // End Of ICollection
2175 //***********************************
2176 // Sub Class
2177 //***********************************
2178 // [MonoTODO]
2179 // // FIXME this sub class has many members that have not been stubbed out.
2180 // public class CheckedListViewItemCollection {
2181 // CheckedListViewItemCollection(ListView owner){
2182 // throw new NotImplementedException ();
2183 // }
2184 // }
2185 // [MonoTODO]
2186 // // FIXME this sub class has many members that have not been stubbed out.
2187 // public class ColumnHeaderCollection {
2188 // ColumnHeaderCollection(ListView owner){
2189 // throw new NotImplementedException ();
2190 // }
2192 // }