Author: jpobst
Date: 2007-03-07 14:40:32 -0500 (Wed, 07 Mar 2007)
New Revision: 73901
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripItem.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripMenuItem.cs
Log:
2007-03-07 Jonathan Pobst <[EMAIL PROTECTED]>
* ToolStripItem.cs: Make CalculatePreferredSize virtual.
* ToolStripMenuItem.cs: Modify CalculatePreferredSize and OnPaint
to draw the menu shortcut string.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-03-07 19:08:24 UTC (rev 73900)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-03-07 19:40:32 UTC (rev 73901)
@@ -1,3 +1,9 @@
+2007-03-07 Jonathan Pobst <[EMAIL PROTECTED]>
+
+ * ToolStripItem.cs: Make CalculatePreferredSize virtual.
+ * ToolStripMenuItem.cs: Modify CalculatePreferredSize and OnPaint
+ to draw the menu shortcut string.
+
2007-03-07 Jackson Harper <[EMAIL PROTECTED]>
* TreeNode.cs: Add the 2.0 collapse method.
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripItem.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripItem.cs
2007-03-07 19:08:24 UTC (rev 73900)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripItem.cs
2007-03-07 19:40:32 UTC (rev 73901)
@@ -1164,7 +1164,7 @@
}
}
- internal Size CalculatePreferredSize (Size constrainingSize)
+ internal virtual Size CalculatePreferredSize (Size
constrainingSize)
{
if (!this.auto_size)
return this.explicit_size;
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripMenuItem.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripMenuItem.cs
2007-03-07 19:08:24 UTC (rev 73900)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripMenuItem.cs
2007-03-07 19:40:32 UTC (rev 73901)
@@ -337,6 +337,15 @@
if (text_layout_rect != Rectangle.Empty)
this.Owner.Renderer.DrawItemText (new
System.Windows.Forms.ToolStripItemTextRenderEventArgs (e.Graphics, this,
this.Text, text_layout_rect, font_color, this.Font, this.TextAlign));
+ string key_string = GetShortcutDisplayString ();
+
+ if (!string.IsNullOrEmpty (key_string) &&
!this.HasDropDownItems) {
+ int offset = 15;
+ Size key_string_size =
TextRenderer.MeasureText (key_string, this.Font);
+ Rectangle key_string_rect = new
Rectangle (this.ContentRectangle.Right - key_string_size.Width - offset,
text_layout_rect.Top, key_string_size.Width, text_layout_rect.Height);
+ this.Owner.Renderer.DrawItemText (new
System.Windows.Forms.ToolStripItemTextRenderEventArgs (e.Graphics, this,
key_string, key_string_rect, font_color, this.Font, this.TextAlign));
+ }
+
if (image_layout_rect != Rectangle.Empty)
this.Owner.Renderer.DrawItemImage (new
System.Windows.Forms.ToolStripItemImageRenderEventArgs (e.Graphics, this,
draw_image, image_layout_rect));
@@ -373,6 +382,39 @@
set { this.mdi_client_form = value; }
}
#endregion
+
+ #region Internal Methods
+ internal override Size CalculatePreferredSize (Size
constrainingSize)
+ {
+ Size base_size = base.CalculatePreferredSize
(constrainingSize);
+
+ string key_string = GetShortcutDisplayString ();
+
+ if (string.IsNullOrEmpty (key_string))
+ return base_size;
+
+ Size text_size = TextRenderer.MeasureText (key_string,
this.Font);
+
+ return new Size (base_size.Width + text_size.Width -
25, base_size.Height);
+ }
+
+ internal string GetShortcutDisplayString ()
+ {
+ if (this.show_shortcut_keys == false ||
this.shortcut_keys == Keys.None)
+ return string.Empty;
+
+ string key_string;
+
+ if (!string.IsNullOrEmpty
(this.shortcut_display_string))
+ key_string = this.shortcut_display_string;
+ else {
+ KeysConverter kc = new KeysConverter ();
+ key_string = kc.ConvertToString
(this.shortcut_keys);
+ }
+
+ return key_string;
+ }
+ #endregion
}
}
#endif
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches