Permalink
Browse files

2006-10-12 Mike Kestner <mkestner@novell.com>

	* ErrorProvider.cs : new ToolTipWindow ctor sig.
	* HelpProvider.cs : new ToolTipWindow ctor sig.
	* ToolTip.cs : remove ToolTip param from Window sig since it is
	not used.
	* ToolBar.cs : add tooltip support.  Fixes #79565.

svn path=/trunk/mcs/; revision=66599
  • Loading branch information...
1 parent 4df8f73 commit bc2cbd1de2a630b140b709c8b9d19bf073d0fcb3 @mkestner mkestner committed Oct 12, 2006
View
8 mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
@@ -1,3 +1,11 @@
+2006-10-12 Mike Kestner <mkestner@novell.com>
+
+ * ErrorProvider.cs : new ToolTipWindow ctor sig.
+ * HelpProvider.cs : new ToolTipWindow ctor sig.
+ * ToolTip.cs : remove ToolTip param from Window sig since it is
+ not used.
+ * ToolBar.cs : add tooltip support. Fixes #79565.
+
2006-10-12 Rolf Bjarne Kvinge <rolfkvinge@ya.com>
* MonthCalendar.cs: When FirstDayOfWeek is default set firstday
View
2 mcs/class/Managed.Windows.Forms/System.Windows.Forms/ErrorProvider.cs
@@ -282,7 +282,7 @@ private class ErrorProperty {
blinkstyle = ErrorBlinkStyle.BlinkIfDifferentError;
icon = (Icon)Locale.GetResource("errorProvider.ico");
- tooltip = new ToolTip.ToolTipWindow(null);
+ tooltip = new ToolTip.ToolTipWindow();
}
public ErrorProvider(ContainerControl parentControl) : this() {
View
2 mcs/class/Managed.Windows.Forms/System.Windows.Forms/HelpProvider.cs
@@ -95,7 +95,7 @@ private class HelpProperty {
#region Public Constructors
public HelpProvider() {
controls = new Hashtable();
- tooltip = new ToolTip.ToolTipWindow(null);
+ tooltip = new ToolTip.ToolTipWindow();
HideToolTipHandler = new EventHandler(HideToolTip);
HideToolTipKeyHandler = new KeyPressEventHandler(HideToolTipKey);
View
90 mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolBar.cs
@@ -116,6 +116,7 @@ public ToolBar ()
GotFocus += new EventHandler (FocusChanged);
LostFocus += new EventHandler (FocusChanged);
MouseDown += new MouseEventHandler (ToolBar_MouseDown);
+ MouseHover += new EventHandler (ToolBar_MouseHover);
MouseLeave += new EventHandler (ToolBar_MouseLeave);
MouseMove += new MouseEventHandler (ToolBar_MouseMove);
MouseUp += new MouseEventHandler (ToolBar_MouseUp);
@@ -652,14 +653,66 @@ private void ToolBar_MouseUp (object sender, MouseEventArgs me)
}
}
+ private ToolBarButton ButtonAtPoint (Point pt)
+ {
+ foreach (ToolBarButton button in buttons)
+ if (button.Rectangle.Contains (pt))
+ return button;
+
+ return null;
+ }
+
+ ToolTip.ToolTipWindow tip_window = null;
+ Timer tipdown_timer = null;
+
+ private void PopDownTip (object o, EventArgs args)
+ {
+ tip_window.Hide ();
+ }
+
+ private Timer TipDownTimer {
+ get {
+ if (tipdown_timer == null) {
+ tipdown_timer = new Timer ();
+ tipdown_timer.Enabled = false;
+ tipdown_timer.Interval = 5000;
+ tipdown_timer.Tick += new EventHandler (PopDownTip);
+ }
+ return tipdown_timer;
+ }
+ }
+
+ private void ToolBar_MouseHover (object sender, EventArgs e)
+ {
+ if (Capture)
+ return;
+
+ tip_window = new ToolTip.ToolTipWindow ();
+
+ ToolBarButton btn = ButtonAtPoint (PointToClient (Control.MousePosition));
+ current_button = btn;
+
+ if (btn == null || btn.ToolTipText.Length == 0)
+ return;
+
+ tip_window.Present (this, btn.ToolTipText);
+ TipDownTimer.Start ();
+ }
+
private void ToolBar_MouseLeave (object sender, EventArgs e)
{
- if (!Enabled || appearance != ToolBarAppearance.Flat || current_button == null)
+ if (tipdown_timer != null)
+ tipdown_timer.Dispose ();
+ tipdown_timer = null;
+ if (tip_window != null)
+ tip_window.Dispose ();
+ tip_window = null;
+
+ if (!Enabled || current_button == null)
return;
- if (current_button.Hilight) {
+ if (appearance != ToolBarAppearance.Flat)
current_button.Hilight = false;
- }
current_button = null;
}
@@ -668,9 +721,14 @@ private void ToolBar_MouseMove (object sender, MouseEventArgs me)
if (!Enabled)
return;
+ if (tip_window != null && tip_window.Visible) {
+ TipDownTimer.Stop ();
+ TipDownTimer.Start ();
+ }
+
Point loc = new Point (me.X, me.Y);
- if (this.Capture) {
+ if (Capture) {
// If the button was pressed and we leave, release the
// button press and vice versa
foreach (ToolBarButton button in buttons) {
@@ -681,15 +739,29 @@ private void ToolBar_MouseMove (object sender, MouseEventArgs me)
break;
}
}
- }
- // following is only for flat style toolbar
- else if (appearance == ToolBarAppearance.Flat) {
- if (current_button != null && current_button.Rectangle.Contains (loc)) {
+ return;
+ }
+
+ if (current_button != null && current_button.Rectangle.Contains (loc)) {
+ if (appearance == ToolBarAppearance.Flat) {
if (current_button.Hilight || current_button.Pushed)
return;
current_button.Hilight = true;
}
- else {
+ } else {
+ if (tip_window != null) {
+ if (tip_window.Visible) {
+ tip_window.Hide ();
+ TipDownTimer.Stop ();
+ }
+ current_button = ButtonAtPoint (loc);
+ if (current_button != null && current_button.ToolTipText.Length > 0) {
+ tip_window.Present (this, current_button.ToolTipText);
+ TipDownTimer.Start ();
+ }
+ }
+
+ if (appearance == ToolBarAppearance.Flat) {
foreach (ToolBarButton button in buttons) {
if (button.Rectangle.Contains (loc) && button.Enabled) {
current_button = button;
View
6 mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolTip.cs
@@ -55,12 +55,10 @@ public sealed class ToolTip : System.ComponentModel.Component, System.ComponentM
internal class ToolTipWindow : Control {
#region ToolTipWindow Class Local Variables
internal StringFormat string_format;
- ToolTip owner;
#endregion // ToolTipWindow Class Local Variables
#region ToolTipWindow Class Constructor
- internal ToolTipWindow(ToolTip owner) : base() {
- this.owner = owner;
+ internal ToolTipWindow() {
string_format = new StringFormat();
string_format.LineAlignment = StringAlignment.Center;
@@ -185,7 +183,7 @@ public void Present (Control control, string text)
tooltip_strings = new Hashtable(5);
controls = new ArrayList(5);
- tooltip_window = new ToolTipWindow(this);
+ tooltip_window = new ToolTipWindow();
tooltip_window.MouseLeave += new EventHandler(control_MouseLeave);
timer = new Timer();

0 comments on commit bc2cbd1

Please sign in to comment.