Skip to content

Commit 46cd126

Browse files
Changing Tooltip to have owner and lazy instantiation for other 8 controls
(cherry picked from commit f98c58d)
1 parent 124672c commit 46cd126

File tree

8 files changed

+39
-24
lines changed

8 files changed

+39
-24
lines changed

mcs/class/System.Windows.Forms/System.Windows.Forms/DataGridView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6552,7 +6552,7 @@ private Timer ToolTipTimer {
65526552
private ToolTip ToolTipWindow {
65536553
get {
65546554
if (tooltip_window == null)
6555-
tooltip_window = new ToolTip ();
6555+
tooltip_window = new ToolTip (this);
65566556

65576557
return tooltip_window;
65586558
}

mcs/class/System.Windows.Forms/System.Windows.Forms/FileDialog.cs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2239,7 +2239,7 @@ internal class MWFFileView : ListView
22392239

22402240
private int filterIndex = 1;
22412241

2242-
private ToolTip toolTip;
2242+
public ToolTip toolTip;
22432243
private int oldItemIndexForToolTip = -1;
22442244

22452245
private ContextMenu contextMenu;
@@ -2296,10 +2296,6 @@ public MWFFileView (MWFVFS vfs)
22962296

22972297
contextMenu = new ContextMenu ();
22982298

2299-
toolTip = new ToolTip ();
2300-
toolTip.InitialDelay = 300;
2301-
toolTip.ReshowDelay = 0;
2302-
23032299
// contextMenu
23042300

23052301
// View menu item
@@ -2458,6 +2454,18 @@ public string SelectedFilesString {
24582454
return selectedFilesString;
24592455
}
24602456
}
2457+
2458+
private ToolTip ToolTipWindow {
2459+
get {
2460+
if (toolTip == null) {
2461+
toolTip = new ToolTip(this);
2462+
toolTip.InitialDelay = 300;
2463+
toolTip.ReshowDelay = 0;
2464+
}
2465+
2466+
return toolTip;
2467+
}
2468+
}
24612469

24622470
public void PushDir ()
24632471
{
@@ -2891,8 +2899,8 @@ protected override void OnMouseMove (MouseEventArgs e)
28912899
if (currentItemIndex != oldItemIndexForToolTip) {
28922900
oldItemIndexForToolTip = currentItemIndex;
28932901

2894-
if (toolTip != null && toolTip.Active)
2895-
toolTip.Active = false;
2902+
if (ToolTipWindow.Active)
2903+
ToolTipWindow.Active = false;
28962904

28972905
FSEntry fsEntry = item.FSEntry;
28982906

@@ -2907,12 +2915,12 @@ protected override void OnMouseMove (MouseEventArgs e)
29072915
else
29082916
output = Locale.GetText("File: {0}", fsEntry.FullName);
29092917

2910-
toolTip.SetToolTip (this, output);
2918+
ToolTipWindow.SetToolTip (this, output);
29112919

2912-
toolTip.Active = true;
2920+
ToolTipWindow.Active = true;
29132921
}
29142922
} else
2915-
toolTip.Active = false;
2923+
ToolTipWindow.Active = false;
29162924

29172925
base.OnMouseMove (e);
29182926
}

mcs/class/System.Windows.Forms/System.Windows.Forms/ListView.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,6 @@ public ListView ()
271271
items_location = new Point [16];
272272
items_matrix_location = new ItemMatrixLocation [16];
273273
reordered_items_indices = new int [16];
274-
item_tooltip = new ToolTip ();
275-
item_tooltip.Active = false;
276274
insertion_mark = new ListViewInsertionMark (this);
277275

278276
InternalBorderStyle = BorderStyle.Fixed3D;
@@ -289,7 +287,6 @@ public ListView ()
289287

290288
v_scroll = new ImplicitVScrollBar ();
291289
Controls.AddImplicit (this.v_scroll);
292-
293290
h_marker = v_marker = 0;
294291
keysearch_tickcnt = 0;
295292

@@ -316,7 +313,7 @@ public ListView ()
316313
}
317314
#endregion // Public Constructors
318315

319-
#region Private Internal Properties
316+
#region Private & Internal Properties
320317
internal Size CheckBoxSize {
321318
get {
322319
if (this.check_boxes) {
@@ -377,6 +374,16 @@ internal ColumnHeader EnteredColumnHeader {
377374
return header_control.EnteredColumnHeader;
378375
}
379376
}
377+
378+
private ToolTip ToolTipWindow {
379+
get {
380+
if (item_tooltip == null) {
381+
item_tooltip = new ToolTip(this);
382+
item_tooltip.Active = false;
383+
}
384+
return item_tooltip;
385+
}
386+
}
380387
#endregion // Private Internal Properties
381388

382389
#region Protected Properties
@@ -815,7 +822,7 @@ public bool ShowItemToolTips {
815822
}
816823
set {
817824
show_item_tooltips = value;
818-
item_tooltip.Active = false;
825+
ToolTipWindow.Active = false;
819826
}
820827
}
821828

@@ -2779,11 +2786,11 @@ private void ItemsMouseMove (object sender, MouseEventArgs me)
27792786

27802787
if (owner.ShowItemToolTips) {
27812788
if (item == null) {
2782-
owner.item_tooltip.Active = false;
2789+
owner.ToolTipWindow.Active = false;
27832790
prev_tooltip_item = null;
27842791
} else if (item != prev_tooltip_item && item.ToolTipText.Length > 0) {
2785-
owner.item_tooltip.Active = true;
2786-
owner.item_tooltip.SetToolTip (owner, item.ToolTipText);
2792+
owner.ToolTipWindow.Active = true;
2793+
owner.ToolTipWindow.SetToolTip (owner, item.ToolTipText);
27872794
prev_tooltip_item = item;
27882795
}
27892796
}

mcs/class/System.Windows.Forms/System.Windows.Forms/StatusBar.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ private Timer ToolTipTimer {
466466
private ToolTip ToolTipWindow {
467467
get {
468468
if (tooltip_window == null)
469-
tooltip_window = new ToolTip ();
469+
tooltip_window = new ToolTip (this);
470470

471471
return tooltip_window;
472472
}

mcs/class/System.Windows.Forms/System.Windows.Forms/TabControl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,7 @@ void SetToolTip (string text)
15091509
}
15101510

15111511
if (tooltip == null) {
1512-
tooltip = new ToolTip ();
1512+
tooltip = new ToolTip (this);
15131513
tooltip_timer = new Timer ();
15141514
tooltip_timer.Tick += new EventHandler (ToolTipTimerTick);
15151515
}

mcs/class/System.Windows.Forms/System.Windows.Forms/ToolBar.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ private void ToolBar_MouseHover (object sender, EventArgs e)
899899
return;
900900

901901
if (tip_window == null)
902-
tip_window = new ToolTip ();
902+
tip_window = new ToolTip (this);
903903

904904
ToolBarItem item = ItemAtPoint (PointToClient (Control.MousePosition));
905905
current_item = item;

mcs/class/System.Windows.Forms/System.Windows.Forms/ToolStrip.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,7 @@ private Timer ToolTipTimer {
15721572
private ToolTip ToolTipWindow {
15731573
get {
15741574
if (tooltip_window == null)
1575-
tooltip_window = new ToolTip ();
1575+
tooltip_window = new ToolTip (this);
15761576

15771577
return tooltip_window;
15781578
}

mcs/class/System.Windows.Forms/System.Windows.Forms/ToolStripTextBox.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ private Timer ToolTipTimer {
568568
private ToolTip ToolTipWindow {
569569
get {
570570
if (tooltip_window == null)
571-
tooltip_window = new ToolTip ();
571+
tooltip_window = new ToolTip (this);
572572

573573
return tooltip_window;
574574
}

0 commit comments

Comments
 (0)