Author: calberto
Date: 2007-05-28 15:29:53 -0400 (Mon, 28 May 2007)
New Revision: 78087

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs
Log:
2007-05-28  Carlos Alberto Cortez <[EMAIL PROTECTED]>

        * ListView.cs:
        * ListViewItem.cs: Implement 2.0 ToolTipText support for listview
        items.



Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-05-28 19:29:28 UTC (rev 78086)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-05-28 19:29:53 UTC (rev 78087)
@@ -1,3 +1,9 @@
+2007-05-28  Carlos Alberto Cortez <[EMAIL PROTECTED]>
+
+       * ListView.cs:
+       * ListViewItem.cs: Implement 2.0 ToolTipText support for listview
+       items.
+
 2007-05-28  Andreia Gaita  <[EMAIL PROTECTED]>
 
        * X11Dnd.cs: A direct cast to VirtualKeys is not allowed from

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs      
2007-05-28 19:29:28 UTC (rev 78086)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs      
2007-05-28 19:29:53 UTC (rev 78087)
@@ -103,6 +103,8 @@
                private ItemMatrixLocation [] items_matrix_location;
                private Size item_size; // used for caching item size
 #if NET_2_0
+               private bool show_item_tooltips;
+               private ToolTip item_tooltip;
                private Size tile_size;
                private bool virtual_mode;
                private int virtual_list_size;
@@ -248,6 +250,10 @@
                        selected_items = new SelectedListViewItemCollection 
(this);
                        items_location = new Point [16];
                        items_matrix_location = new ItemMatrixLocation [16];
+#if NET_2_0
+                       item_tooltip = new ToolTip ();
+                       item_tooltip.Active = false;
+#endif
 
                        InternalBorderStyle = BorderStyle.Fixed3D;
 
@@ -636,6 +642,17 @@
                public ListViewGroupCollection Groups {
                        get { return groups; }
                }
+
+               [DefaultValue (false)]
+               public bool ShowItemToolTips {
+                       get {
+                               return show_item_tooltips;
+                       }
+                       set {
+                               show_item_tooltips = value;
+                               item_tooltip.Active = false;
+                       }
+               }
 #endif
 
                [DefaultValue (null)]
@@ -1816,6 +1833,7 @@
                        bool hover_processed = false;
                        bool checking = false;
                        ListViewItem prev_hovered_item;
+                       ListViewItem prev_tooltip_item;
                        int clicks;
                        
                        ListViewLabelEditTextBox edit_text_box;
@@ -2076,15 +2094,31 @@
                                bool done = PerformBoxSelection (new Point 
(me.X, me.Y));
 
                                if (!done && hover_processed) {
-
                                        Point pt = PointToClient 
(Control.MousePosition);
                                        ListViewItem item = owner.GetItemAt 
(pt.X, pt.Y);
+
                                        if (item != null && item != 
prev_hovered_item) {
                                                hover_processed = false;
                                                XplatUI.ResetMouseHover 
(Handle);
                                        }
                                }
 
+#if NET_2_0
+                               if (!done && owner.ShowItemToolTips) {
+                                       Point pt = PointToClient 
(Control.MousePosition);
+                                       ListViewItem item = owner.GetItemAt 
(pt.X, pt.Y);
+
+                                       if (item == null) {
+                                               owner.item_tooltip.Active = 
false;
+                                               prev_tooltip_item = null;
+                                       } else if (item != prev_tooltip_item && 
item.ToolTipText.Length > 0) {
+                                               owner.item_tooltip.Active = 
true;
+                                               owner.item_tooltip.SetToolTip 
(owner, item.ToolTipText);
+                                               prev_tooltip_item = item;
+                                       }
+                               }
+#endif
+
                                owner.OnMouseMove 
(owner.TranslateMouseEventArgs (me));
                        }
 

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs  
2007-05-28 19:29:28 UTC (rev 78086)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs  
2007-05-28 19:29:53 UTC (rev 78087)
@@ -50,6 +50,7 @@
                private ListViewGroup group = null;
                private string name = String.Empty;
                private string image_key = String.Empty;
+               string tooltip_text = String.Empty;
                int index;                      // cached index for VirtualMode
 #endif
                Rectangle bounds;
@@ -531,6 +532,19 @@
                                }
                        }
                }
+
+               [DefaultValue ("")]
+               public string ToolTipText {
+                       get {
+                               return tooltip_text;
+                       }
+                       set {
+                               if (value == null)
+                                       value = String.Empty;
+
+                               tooltip_text = value;
+                       }
+               }
 #endif
 
                #endregion      // Public Instance Properties
@@ -568,6 +582,7 @@
                        clone.owner = null;
 #if NET_2_0
                        clone.name = name;
+                       clone.tooltip_text = tooltip_text;
 #endif
 
                        return clone;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to