New tests.
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / ToolTip.cs
index 0623d2ce155ff81b946ae18ca3ab6fa5d13a130e..a5d4a7fea118bf6232e8af7ebf8aa4236c905465 100644 (file)
@@ -64,7 +64,6 @@ namespace System.Windows.Forms {
                private bool owner_draw;
                private bool stripAmpersands;
                private ToolTipIcon tool_tip_icon;
-               private string tool_tip_title;
                private bool useAnimation;
                private bool useFading;
                private object tag;
@@ -76,6 +75,11 @@ namespace System.Windows.Forms {
                internal class ToolTipWindow : Control {
                        #region ToolTipWindow Class Local Variables
                        private Control associated_control;
+                       internal Icon icon;
+                       internal string title = String.Empty;
+                       internal Rectangle icon_rect;
+                       internal Rectangle title_rect;
+                       internal Rectangle text_rect;
                        #endregion      // ToolTipWindow Class Local Variables
                        
                        #region ToolTipWindow Class Constructor
@@ -531,13 +535,35 @@ namespace System.Windows.Forms {
                [DefaultValue (ToolTipIcon.None)]
                public ToolTipIcon ToolTipIcon {
                        get { return this.tool_tip_icon; }
-                       set { this.tool_tip_icon = value; }
+                       set {
+                               switch (value) {
+                                       case ToolTipIcon.None:
+                                               tooltip_window.icon = null;
+                                               break;
+                                       case ToolTipIcon.Error:
+                                               tooltip_window.icon = SystemIcons.Error;
+                                               break;
+                                       case ToolTipIcon.Warning:
+                                               tooltip_window.icon = SystemIcons.Warning;
+                                               break;
+                                       case ToolTipIcon.Info:
+                                               tooltip_window.icon = SystemIcons.Information;
+                                               break;
+                               }
+
+                               tool_tip_icon = value;
+                       }
                }
                
                [DefaultValue ("")]
                public string ToolTipTitle {
-                       get { return this.tool_tip_title; }
-                       set { this.tool_tip_title = value; }
+                       get { return tooltip_window.title; }
+                       set {
+                              if (value == null)
+                                      value = String.Empty;
+                              
+                              tooltip_window.title = value; 
+                       }
                }
                
                [Browsable (true)]
@@ -747,6 +773,9 @@ namespace System.Windows.Forms {
 
                #region Protected Instance Methods
                protected override void Dispose(bool disposing) {
+                       // call the base impl first to avoid conflicts with any parent's events
+                       base.Dispose (disposing);
+
                        if (disposing) {
                                // Mop up the mess; or should we wait for the GC to kick in?
                                timer.Stop();
@@ -774,7 +803,7 @@ namespace System.Windows.Forms {
 #endif
                #endregion      // Protected Instance Methods
 
-               enum TipState {
+               internal enum TipState {
                        Initial,
                        Show,
                        Down
@@ -866,17 +895,11 @@ namespace System.Windows.Forms {
                        if (!is_active)
                                return;
 
-                       // Display tooltips only for the controls in the active form
-                       if (control.FindForm () != Form.ActiveForm)
+                       // ShowAlways controls whether the controls in non-active forms
+                       // can display its tooltips, even if they are not current active control.
+                       if (!show_always && control.FindForm () != Form.ActiveForm)
                                return;
 
-                       if (!show_always) {
-                               IContainerControl cc = last_control.GetContainerControl ();
-                               if ((cc == null) || (cc.ActiveControl == null)) {
-                                       return;
-                               }
-                       }
-
                        string text = (string)tooltip_strings[control];
                        if (text != null && text.Length > 0) {
                                if (active_control == null) {