Author: jpobst
Date: 2006-12-07 18:29:21 -0500 (Thu, 07 Dec 2006)
New Revision: 69212
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuStrip.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusStrip.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStrip.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripButton.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripItem.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripLabel.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripRenderer.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripSeparator.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripSplitStackLayout.cs
Log:
2006-12-07 Jonathan Pobst <[EMAIL PROTECTED]>
* ToolStrip*: Add some small properties reported by MoMA, fix event
firing and default properties based off of unit tests, and add some
attributes based off of the class status page.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-12-07 22:39:54 UTC (rev 69211)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-12-07 23:29:21 UTC (rev 69212)
@@ -1,3 +1,9 @@
+2006-12-07 Jonathan Pobst <[EMAIL PROTECTED]>
+
+ * ToolStrip*: Add some small properties reported by MoMA, fix event
+ firing and default properties based off of unit tests, and add some
+ attributes based off of the class status page.
+
2006-12-07 Jackson Harper <[EMAIL PROTECTED]>
* TextBoxBase.cs: Take HideSelection into account when determining
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuStrip.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuStrip.cs
2006-12-07 22:39:54 UTC (rev 69211)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuStrip.cs
2006-12-07 23:29:21 UTC (rev 69212)
@@ -43,7 +43,7 @@
public MenuStrip () : base ()
{
this.GripStyle = ToolStripGripStyle.Hidden;
- this.stretch = true;
+ this.Stretch = true;
this.Dock = DockStyle.Top;
}
@@ -68,8 +68,8 @@
[DefaultValue (true)]
public new bool Stretch {
- get { return base.stretch; }
- set { base.stretch = value; }
+ get { return base.Stretch; }
+ set { base.Stretch = value; }
}
#endregion
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusStrip.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusStrip.cs
2006-12-07 22:39:54 UTC (rev 69211)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusStrip.cs
2006-12-07 23:29:21 UTC (rev 69212)
@@ -46,7 +46,7 @@
this.GripStyle = ToolStripGripStyle.Hidden;
this.layout_style = ToolStripLayoutStyle.Table;
this.sizing_grip = false;
- base.stretch = true;
+ base.Stretch = true;
}
#region Public Properties
@@ -92,8 +92,8 @@
}
public new bool Stretch {
- get { return this.stretch; }
- set { this.stretch = value; }
+ get { return this.Stretch; }
+ set { this.Stretch = value; }
}
#endregion
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStrip.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStrip.cs
2006-12-07 22:39:54 UTC (rev 69211)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStrip.cs
2006-12-07 23:29:21 UTC (rev 69212)
@@ -57,7 +57,7 @@
private ToolStripRenderer renderer;
private ToolStripRenderMode render_mode;
private bool show_item_tool_tips;
- internal bool stretch;
+ private bool stretch;
private ToolStripItem mouse_currently_over;
private bool menu_selected;
@@ -71,13 +71,15 @@
public ToolStrip (params ToolStripItem[] items) : base ()
{
+ SetStyle (ControlStyles.AllPaintingInWmPaint, true);
+ SetStyle (ControlStyles.OptimizedDoubleBuffer, true);
SetStyle (ControlStyles.Selectable, false);
SetStyle (ControlStyles.SupportsTransparentBackColor,
true);
- SetStyle (ControlStyles.AllPaintingInWmPaint, true);
this.SuspendLayout ();
base.AutoSize = true;
this.back_color = Control.DefaultBackColor;
+ base.CausesValidation = false;
this.dock_style = this.DefaultDock;
base.Font = new Font ("Tahoma", 8.25f);
this.fore_color = Control.DefaultForeColor;
@@ -118,9 +120,14 @@
set { this.back_color = value; }
}
+ public new bool CausesValidation {
+ get { return base.CausesValidation; }
+ set { base.CausesValidation = value; }
+ }
+
public override Cursor Cursor {
get { return base.Cursor; }
- set { base.Cursor = value; this.OnCursorChanged
(EventArgs.Empty); }
+ set { base.Cursor = value; }
}
public override Rectangle DisplayRectangle {
@@ -142,7 +149,9 @@
public override DockStyle Dock {
get { return base.Dock; }
set {
- if (base.Dock != value) {
+ if (base.Dock != value) {
+ if (!Enum.IsDefined (typeof
(DockStyle), value))
+ throw new
InvalidEnumArgumentException (string.Format ("Enum argument value '{0}' is not
valid for DockStyle", value));
base.Dock = value;
base.anchor_style = AnchorStyles.Left |
AnchorStyles.Top;
@@ -225,6 +234,8 @@
}
}
+ [Browsable (false)]
+ [DefaultValue (null)]
public ImageList ImageList {
get { return this.image_list; }
set { this.image_list = value; }
@@ -253,6 +264,8 @@
get { return new ToolStripSplitStackLayout(); }
}
+ [Browsable (false)]
+ [DefaultValue (null)]
public LayoutSettings LayoutSettings {
get { return this.layout_settings; }
set { this.layout_settings = value; }
@@ -290,7 +303,7 @@
this.renderer = value;
this.render_mode =
ToolStripRenderMode.Custom;
this.PerformLayout ();
- this.OnRendererChange (EventArgs.Empty);
+ this.OnRendererChanged
(EventArgs.Empty);
}
}
}
@@ -317,7 +330,8 @@
set { this.show_item_tool_tips = value; }
}
- public bool Stretch {
+ [DefaultValue (false)]
+ public virtual bool Stretch {
get { return this.stretch; }
set { this.stretch = value; }
}
@@ -621,6 +635,7 @@
}
}
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
protected override void OnPaintBackground (PaintEventArgs
pevent)
{
base.OnPaintBackground (pevent);
@@ -655,13 +670,14 @@
e.Graphics.ResetTransform ();
}
- protected virtual void OnRendererChange (EventArgs e)
+ protected virtual void OnRendererChanged (EventArgs e)
{
EventHandler eh = (EventHandler)(Events
[RendererChangedEvent]);
if (eh != null)
eh (this, e);
}
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
protected override void OnRightToLeftChanged (EventArgs e)
{
base.OnRightToLeftChanged (e);
@@ -727,11 +743,18 @@
static object PaintGripEvent = new object ();
static object RendererChangedEvent = new object ();
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
public event EventHandler AutoSizeChanged {
add { Events.AddHandler (AutoSizeChangedEvent, value); }
remove { Events.RemoveHandler (AutoSizeChangedEvent,
value); }
}
+ public new event EventHandler CausesValidationChanged {
+ add { base.CausesValidationChanged += value; }
+ remove { base.CausesValidationChanged -= value; }
+ }
+
public new event EventHandler CursorChanged {
add { base.CursorChanged += value; }
remove { base.CursorChanged -= value; }
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripButton.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripButton.cs
2006-12-07 22:39:54 UTC (rev 69211)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripButton.cs
2006-12-07 23:29:21 UTC (rev 69212)
@@ -30,9 +30,11 @@
using System;
using System.Drawing;
using System.ComponentModel;
+using System.Windows.Forms.Design;
namespace System.Windows.Forms
{
+ [ToolStripItemDesignerAvailability
(ToolStripItemDesignerAvailability.ToolStrip)]
public class ToolStripButton : ToolStripItem
{
private CheckState checked_state;
@@ -40,12 +42,12 @@
#region Public Constructors
public ToolStripButton ()
- : this (String.Empty, null, null, String.Empty)
+ : this (null, null, null, String.Empty)
{
}
public ToolStripButton (Image image)
- : this (String.Empty, image, null, String.Empty)
+ : this (null, image, null, String.Empty)
{
}
@@ -73,7 +75,6 @@
#endregion
#region Public Properties
- [MonoTODO ("Need 2.0 ToolTip to implement tool tips.")]
[DefaultValue (true)]
public new bool AutoToolTip {
get { return base.AutoToolTip; }
@@ -100,6 +101,7 @@
if (this.checked_state != (value ?
CheckState.Checked : CheckState.Unchecked)) {
this.checked_state = value ?
CheckState.Checked : CheckState.Unchecked;
this.OnCheckedChanged (EventArgs.Empty);
+ this.OnCheckStateChanged
(EventArgs.Empty);
this.Invalidate ();
}
}
@@ -115,12 +117,15 @@
public CheckState CheckState {
get { return this.checked_state; }
set {
- if (!Enum.IsDefined (typeof (CheckState),
value))
- throw new InvalidEnumArgumentException
(string.Format ("Enum argument value '{0}' is not valid for CheckState",
value));
+ if (this.checked_state != value) {
+ if (!Enum.IsDefined (typeof
(CheckState), value))
+ throw new
InvalidEnumArgumentException (string.Format ("Enum argument value '{0}' is not
valid for CheckState", value));
- this.checked_state = value;
- OnCheckStateChanged (EventArgs.Empty);
- this.Invalidate ();
+ this.checked_state = value;
+ this.OnCheckedChanged (EventArgs.Empty);
+ this.OnCheckStateChanged
(EventArgs.Empty);
+ this.Invalidate ();
+ }
}
}
#endregion
@@ -137,6 +142,7 @@
#endregion
#region Protected Methods
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
protected override AccessibleObject CreateAccessibilityInstance
()
{
ToolStripItemAccessibleObject ao = new
ToolStripItemAccessibleObject (this);
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripItem.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripItem.cs
2006-12-07 22:39:54 UTC (rev 69211)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripItem.cs
2006-12-07 23:29:21 UTC (rev 69212)
@@ -46,18 +46,22 @@
private bool auto_size;
private bool auto_tool_tip;
private Color back_color;
+ private Image background_image;
+ private ImageLayout background_image_layout;
private Rectangle bounds;
private bool can_select;
private ToolStripItemDisplayStyle display_style;
private DockStyle dock;
private bool double_click_enabled;
private bool enabled;
+ private Size explicit_size;
private Font font;
private Color fore_color;
private Image image;
private ContentAlignment image_align;
private int image_index;
private ToolStripItemImageScaling image_scaling;
+ private Color image_transparent_color;
internal bool is_pressed;
private bool is_selected;
private Padding margin;
@@ -93,6 +97,8 @@
this.auto_size = true;
this.auto_tool_tip = this.DefaultAutoToolTip;
this.back_color = Control.DefaultBackColor;
+ this.background_image_layout = ImageLayout.Tile;
+ this.can_select = true;
this.display_style = this.DefaultDisplayStyle;
this.dock = DockStyle.None;
this.enabled = true;
@@ -102,6 +108,7 @@
this.image_align = ContentAlignment.MiddleCenter;
this.image_index = -1;
this.image_scaling =
ToolStripItemImageScaling.SizeToFit;
+ this.image_transparent_color = Color.Empty;
this.margin = this.DefaultMargin;
this.name = name;
this.padding = this.DefaultPadding;
@@ -112,12 +119,13 @@
this.visible = true;
this.Click += onClick;
- this.can_select = this is ToolStripMenuItem || this is
ToolStripDropDownButton || this is ToolStripSplitButton ? true : false;
OnLayout (new LayoutEventArgs (null, string.Empty));
}
#endregion
#region Public Properties
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
public AccessibleObject AccessibilityObject {
get {
if (this.accessibility_object == null)
@@ -126,7 +134,9 @@
return this.accessibility_object;
}
}
-
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
public string AccessibleDefaultActionDescription {
get {
if (this.accessibility_object == null)
@@ -138,6 +148,7 @@
}
[Localizable (true)]
+ [DefaultValue (null)]
public string AccessibleDescription {
get {
if (this.accessibility_object == null)
@@ -149,6 +160,7 @@
}
[Localizable (true)]
+ [DefaultValue (null)]
public string AccessibleName {
get {
if (this.accessibility_object == null)
@@ -159,6 +171,7 @@
set { this.AccessibilityObject.Name = value; }
}
+ [DefaultValue (AccessibleRole.Default)]
public AccessibleRole AccessibleRole {
get
{
@@ -210,6 +223,7 @@
owner.PerformLayout ();
OnAvailableChanged (EventArgs.Empty);
+ OnVisibleChanged (EventArgs.Empty);
}
}
}
@@ -225,6 +239,28 @@
}
}
+ [Localizable (true)]
+ public virtual Image BackgroundImage {
+ get { return this.background_image; }
+ set {
+ if (this.background_image != value) {
+ this.background_image = value;
+ this.Invalidate ();
+ }
+ }
+ }
+
+ [Localizable (true)]
+ public virtual ImageLayout BackgroundImageLayout {
+ get { return this.background_image_layout; }
+ set {
+ if (this.background_image_layout != value) {
+ this.background_image_layout = value;
+ this.Invalidate ();
+ }
+ }
+ }
+
[Browsable (false)]
public virtual Rectangle Bounds {
get { return this.bounds; }
@@ -321,13 +357,16 @@
}
[Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
public int Height {
- get { return this.bounds.Height; }
+ get { return this.Size.Height; }
set {
this.bounds.Height = value;
+ this.explicit_size.Height = value;
+ if (this.visible) {
this.CalculateAutoSize ();
this.OnBoundsChanged ();
- this.Invalidate ();
+ this.Invalidate (); }
}
}
@@ -355,11 +394,13 @@
}
[Localizable (true)]
+ [Browsable (false)]
public int ImageIndex {
get { return this.image_index; }
set {
+ // Lamespec: MSDN says ArgumentException, tests
say otherwise
if (value < -1)
- throw new ArgumentException
("ImageIndex cannot be less than -1");
+ throw new ArgumentOutOfRangeException
("ImageIndex cannot be less than -1");
this.image_index = value;
this.CalculateAutoSize ();
@@ -381,8 +422,8 @@
[Localizable (true)]
[MonoTODO ("Stub, doesn't actually do anything yet.")]
public Color ImageTransparentColor {
- get { return Color.Transparent; }
- set { }
+ get { return this.image_transparent_color; }
+ set { this.image_transparent_color = value; }
}
[Browsable (false)]
@@ -404,6 +445,7 @@
}
[DefaultValue (null)]
+ [Browsable (false)]
public string Name {
get { return this.name; }
set { this.name = value; }
@@ -447,17 +489,26 @@
[Localizable (true)]
public virtual Size Size {
- get { return this.bounds.Size; }
+ get {
+ if (this.explicit_size != Size.Empty)
+ return this.explicit_size;
+
+ return this.bounds.Size;
+ }
set {
this.bounds.Size = value;
+ this.explicit_size = value;
+
+ if (this.visible) {
this.CalculateAutoSize ();
- OnBoundsChanged ();
+ OnBoundsChanged (); }
}
}
[Localizable (false)]
[Bindable (true)]
[DefaultValue (null)]
+ [TypeConverter (typeof (StringConverter))]
public Object Tag {
get { return this.tag; }
set { this.tag = value; }
@@ -525,12 +576,15 @@
}
[Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
public int Width {
- get { return this.bounds.Width; }
+ get { return this.Size.Width; }
set {
this.bounds.Width = value;
+ this.explicit_size.Width = value;
+ if (this.visible) {
this.CalculateAutoSize ();
- this.OnBoundsChanged();
+ this.OnBoundsChanged(); }
}
}
#endregion
@@ -541,7 +595,7 @@
protected internal virtual Padding DefaultMargin { get { return
new Padding (0, 1, 0, 2); } }
protected virtual Padding DefaultPadding { get { return new
Padding (); } }
protected virtual Size DefaultSize { get { return new Size (23,
23); } }
- protected internal virtual bool DismissWhenClicked { get {
return false; } }
+ protected internal virtual bool DismissWhenClicked { get {
return true; } }
[Browsable (false)]
[DesignerSerializationVisibility
(DesignerSerializationVisibility.Hidden)]
protected internal ToolStrip Parent {
@@ -552,7 +606,7 @@
OnParentChanged(old_parent, this.parent);
}
}
- protected internal virtual bool ShowKeyboardCues { get { return
true; } }
+ protected internal virtual bool ShowKeyboardCues { get { return
false; } }
#endregion
#region Public Methods
@@ -619,6 +673,7 @@
#endregion
#region Protected Methods
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
protected virtual AccessibleObject CreateAccessibilityInstance
()
{
return new ToolStripItemAccessibleObject (this);
@@ -636,6 +691,7 @@
eh (this, e);
}
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
protected virtual void OnBackColorChanged (EventArgs e)
{
EventHandler eh = (EventHandler)(Events
[BackColorChangedEvent]);
@@ -655,6 +711,7 @@
eh (this, e);
}
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
protected virtual void OnDisplayStyleChanged (EventArgs e)
{
EventHandler eh = (EventHandler)(Events
[DisplayStyleChangedEvent]);
@@ -679,10 +736,12 @@
eh (this, e);
}
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
protected virtual void OnFontChanged (EventArgs e)
{
}
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
protected virtual void OnForeColorChanged (EventArgs e)
{
EventHandler eh = (EventHandler)(Events
[ForeColorChangedEvent]);
@@ -777,6 +836,9 @@
protected virtual void OnPaint (PaintEventArgs e)
{
+ if (this.Owner != null)
+ this.Owner.Renderer.DrawItemBackground (new
ToolStripItemRenderEventArgs (e.Graphics, this));
+
PaintEventHandler eh = (PaintEventHandler)(Events
[PaintEvent]);
if (eh != null)
eh (this, e);
@@ -785,7 +847,8 @@
protected virtual void OnParentChanged (ToolStrip oldParent,
ToolStrip newParent)
{
}
-
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
protected virtual void OnTextChanged (EventArgs e)
{
EventHandler eh = (EventHandler)(Events
[TextChangedEvent]);
@@ -948,7 +1011,7 @@
if (!this.auto_size || this is ToolStripControlHost)
return;
- this.text_size = TextRenderer.MeasureText (this.Text,
this.Font, Size.Empty, TextFormatFlags.HidePrefix);
+ this.text_size = TextRenderer.MeasureText (this.Text ==
null ? string.Empty: this.text, this.Font, Size.Empty,
TextFormatFlags.HidePrefix);
//this.text_size.Width += 6;
Size final_size = this.CalculatePreferredSize
(Size.Empty);
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripLabel.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripLabel.cs
2006-12-07 22:39:54 UTC (rev 69211)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripLabel.cs
2006-12-07 23:29:21 UTC (rev 69212)
@@ -29,9 +29,11 @@
using System.Drawing;
using System.ComponentModel;
+using System.Windows.Forms.Design;
namespace System.Windows.Forms
{
+ [ToolStripItemDesignerAvailability
(ToolStripItemDesignerAvailability.ToolStrip)]
public class ToolStripLabel : ToolStripItem
{
private Color active_link_color;
@@ -43,12 +45,12 @@
#region Public Constructors
public ToolStripLabel ()
- : this (String.Empty, null, false, null, String.Empty)
+ : this (null, null, false, null, String.Empty)
{
}
public ToolStripLabel (Image image)
- : this (String.Empty, image, false, null, String.Empty)
+ : this (null, image, false, null, String.Empty)
{
}
@@ -78,9 +80,9 @@
this.active_link_color = Color.Red;
this.is_link = isLink;
this.link_behavior = LinkBehavior.SystemDefault;
- this.link_color = Color.Blue;
+ this.link_color = Color.FromArgb (0, 0, 255);
this.link_visited = false;
- this.visited_link_color = Color.Purple;
+ this.visited_link_color = Color.FromArgb (128, 0, 128);
}
#endregion
@@ -141,6 +143,7 @@
#endregion
#region Protected Methods
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
protected override AccessibleObject CreateAccessibilityInstance
()
{
ToolStripItemAccessibleObject ao = new
ToolStripItemAccessibleObject (this);
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripRenderer.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripRenderer.cs
2006-12-07 22:39:54 UTC (rev 69211)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripRenderer.cs
2006-12-07 23:29:21 UTC (rev 69212)
@@ -175,6 +175,12 @@
protected virtual void OnRenderItemBackground
(ToolStripItemRenderEventArgs e)
{
+ if (e.Item.BackgroundImage != null) {
+ Rectangle item_bounds = new Rectangle (0, 0,
e.Item.Width, e.Item.Height);
+ e.Graphics.FillRectangle
(ThemeEngine.Current.ResPool.GetSolidBrush (e.Item.BackColor), item_bounds);
+ DrawBackground (e.Graphics, item_bounds,
e.Item.BackgroundImage, e.Item.BackgroundImageLayout);
+ }
+
ToolStripItemRenderEventHandler eh =
(ToolStripItemRenderEventHandler)Events [RenderItemBackgroundEvent];
if (eh != null)
eh (this, e);
@@ -392,6 +398,53 @@
remove {Events.RemoveHandler
(RenderToolStripStatusLabelBackgroundEvent, value); }
}
#endregion
+
+ #region Private Methods
+ private void DrawBackground (Graphics g, Rectangle bounds,
Image image, ImageLayout layout)
+ {
+ // Center and Tile don't matter if the image is larger
than the control
+ if (layout == ImageLayout.Center || layout ==
ImageLayout.Tile)
+ if (image.Size.Width >= bounds.Size.Width &&
image.Size.Height >= bounds.Size.Height)
+ layout = ImageLayout.None;
+
+ switch (layout) {
+ case ImageLayout.None:
+ g.DrawImageUnscaledAndClipped (image,
bounds);
+ break;
+ case ImageLayout.Tile:
+ int x = 0;
+ int y = 0;
+
+ while (y < bounds.Height) {
+ while (x < bounds.Width) {
+
g.DrawImageUnscaledAndClipped (image, bounds);
+ x += image.Width;
+ }
+ x = 0;
+ y += image.Height;
+ }
+ break;
+ case ImageLayout.Center:
+ Rectangle r = new Rectangle
((bounds.Size.Width - image.Size.Width) / 2, (bounds.Size.Height -
image.Size.Height) / 2, image.Width, image.Height);
+ g.DrawImageUnscaledAndClipped (image,
r);
+ break;
+ case ImageLayout.Stretch:
+ g.DrawImage (image, bounds);
+ break;
+ case ImageLayout.Zoom:
+ if (((float)image.Height /
(float)image.Width) < ((float)bounds.Height / (float)bounds.Width)) {
+ Rectangle rzoom = new Rectangle
(0, 0, bounds.Width, (int)((float)bounds.Width * ((float)image.Height /
(float)image.Width)));
+ rzoom.Y = (bounds.Height -
rzoom.Height)/ 2;
+ g.DrawImage (image, rzoom);
+ } else {
+ Rectangle rzoom = new Rectangle
(0, 0, (int)((float)bounds.Height * ((float)image.Width /
(float)image.Height)), bounds.Height);
+ rzoom.X = (bounds.Width -
rzoom.Width) / 2;
+ g.DrawImage (image, rzoom);
+ }
+ break;
+ }
+ }
+ #endregion
}
}
#endif
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripSeparator.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripSeparator.cs
2006-12-07 22:39:54 UTC (rev 69211)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripSeparator.cs
2006-12-07 23:29:21 UTC (rev 69212)
@@ -29,52 +29,63 @@
using System.Drawing;
using System.ComponentModel;
+using System.Windows.Forms.Design;
namespace System.Windows.Forms
{
+ [ToolStripItemDesignerAvailability
(ToolStripItemDesignerAvailability.ToolStrip |
ToolStripItemDesignerAvailability.ContextMenuStrip)]
public class ToolStripSeparator : ToolStripItem
{
- private bool auto_tool_tip;
- private ToolStripItemDisplayStyle display_style;
- private bool double_click_enabled;
- private ContentAlignment image_align;
- private int image_index;
- private ToolStripItemImageScaling image_scaling;
- private ContentAlignment text_align;
- private TextImageRelation text_image_relation;
- private string tool_tip_text;
-
- public ToolStripSeparator ()
+ public ToolStripSeparator () : base ()
{
- this.ForeColor = SystemColors.ControlDark;
}
#region Public Properties
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility
(DesignerSerializationVisibility.Hidden)]
public new bool AutoToolTip {
- get { return this.auto_tool_tip; }
- set { this.auto_tool_tip = value; }
+ get { return base.AutoToolTip; }
+ set { base.AutoToolTip = value; }
}
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility
(DesignerSerializationVisibility.Hidden)]
+ public override Image BackgroundImage {
+ get { return base.BackgroundImage; }
+ set { base.BackgroundImage = value; }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility
(DesignerSerializationVisibility.Hidden)]
+ public override ImageLayout BackgroundImageLayout {
+ get { return base.BackgroundImageLayout; }
+ set { base.BackgroundImageLayout = value; }
+ }
+
public override bool CanSelect { get { return false; } }
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility
(DesignerSerializationVisibility.Hidden)]
public new ToolStripItemDisplayStyle DisplayStyle {
- get { return this.display_style; }
- set { this.display_style = value; }
+ get { return base.DisplayStyle; }
+ set { base.DisplayStyle = value; }
}
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility
(DesignerSerializationVisibility.Hidden)]
public new bool DoubleClickEnabled {
- get { return this.double_click_enabled; }
- set { this.double_click_enabled = value; }
+ get { return base.DoubleClickEnabled; }
+ set { base.DoubleClickEnabled = value; }
}
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility
(DesignerSerializationVisibility.Hidden)]
public override bool Enabled {
get { return base.Enabled; }
set { base.Enabled = value; }
@@ -82,6 +93,7 @@
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility
(DesignerSerializationVisibility.Hidden)]
public override Font Font {
get { return base.Font; }
set { base.Font = value; }
@@ -89,6 +101,7 @@
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility
(DesignerSerializationVisibility.Hidden)]
public override Image Image {
get { return base.Image; }
set { base.Image = value; }
@@ -96,37 +109,39 @@
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility
(DesignerSerializationVisibility.Hidden)]
public new ContentAlignment ImageAlign {
- get { return this.image_align; }
- set {
- if (!Enum.IsDefined (typeof (ContentAlignment),
value))
- throw new InvalidEnumArgumentException
(string.Format ("Enum argument value '{0}' is not valid for ContentAlignment",
value));
-
- this.image_align = value;
- }
+ get { return base.ImageAlign; }
+ set { base.ImageAlign = value; }
}
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility
(DesignerSerializationVisibility.Hidden)]
public new int ImageIndex {
- get { return this.image_index; }
- set {
- if (value < -1)
- throw new ArgumentException
("ImageIndex cannot be less than -1");
-
- this.image_index = value;
- }
+ get { return base.ImageIndex; }
+ set { base.ImageIndex = value; }
}
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility
(DesignerSerializationVisibility.Hidden)]
public new ToolStripItemImageScaling ImageScaling {
- get { return this.image_scaling; }
- set { this.image_scaling = value; }
+ get { return base.ImageScaling; }
+ set { base.ImageScaling = value; }
}
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility
(DesignerSerializationVisibility.Hidden)]
+ public new Color ImageTransparentColor {
+ get { return base.ImageTransparentColor; }
+ set { base.ImageTransparentColor = value; }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility
(DesignerSerializationVisibility.Hidden)]
public override string Text {
get { return base.Text; }
set { base.Text = value; }
@@ -134,28 +149,26 @@
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility
(DesignerSerializationVisibility.Hidden)]
public new ContentAlignment TextAlign {
- get { return this.text_align; }
- set {
- if (!Enum.IsDefined (typeof (ContentAlignment),
value))
- throw new InvalidEnumArgumentException
(string.Format ("Enum argument value '{0}' is not valid for ContentAlignment",
value));
-
- this.text_align = value;
- }
+ get { return base.TextAlign; }
+ set { base.TextAlign = value; }
}
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility
(DesignerSerializationVisibility.Hidden)]
public new TextImageRelation TextImageRelation {
- get { return this.text_image_relation; }
- set { this.text_image_relation = value; }
+ get { return base.TextImageRelation; }
+ set { base.TextImageRelation = value; }
}
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility
(DesignerSerializationVisibility.Hidden)]
public new string ToolTipText {
- get { return this.tool_tip_text; }
- set { this.tool_tip_text = value; }
+ get { return base.ToolTipText; }
+ set { base.ToolTipText = value; }
}
#endregion
@@ -172,6 +185,7 @@
#endregion
#region Protected Methods
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
protected override AccessibleObject CreateAccessibilityInstance
()
{
ToolStripItemAccessibleObject ao = new
ToolStripItemAccessibleObject (this);
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripSplitStackLayout.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripSplitStackLayout.cs
2006-12-07 22:39:54 UTC (rev 69211)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripSplitStackLayout.cs
2006-12-07 23:29:21 UTC (rev 69212)
@@ -41,6 +41,9 @@
{
ToolStrip ts = (ToolStrip)container;
+ if (ts.Items == null)
+ return false;
+
if (ts.Orientation == Orientation.Horizontal) {
int x = ts.DisplayRectangle.Left;
if (!(ts is MenuStrip))
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches