From 200f34ab9a1bd229e061dbf1803020b0ee009ef5 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Mon, 27 Feb 2006 19:47:05 +0000 Subject: * ListSourceHelper.cs: this class is static. * Page.cs: add some EditorBrowsable attributes to the 2.0 events. 2006-02-27 Chris Toshok svn path=/trunk/mcs/; revision=57348 --- mcs/class/System.Web/System.Web.UI/ChangeLog | 6 ++++++ mcs/class/System.Web/System.Web.UI/ListSourceHelper.cs | 4 +--- mcs/class/System.Web/System.Web.UI/Page.cs | 8 ++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) (limited to 'mcs') diff --git a/mcs/class/System.Web/System.Web.UI/ChangeLog b/mcs/class/System.Web/System.Web.UI/ChangeLog index d095829ff9c..ece5f6e1924 100644 --- a/mcs/class/System.Web/System.Web.UI/ChangeLog +++ b/mcs/class/System.Web/System.Web.UI/ChangeLog @@ -1,3 +1,9 @@ +2006-02-27 Chris Toshok + + * ListSourceHelper.cs: this class is static. + + * Page.cs: add some EditorBrowsable attributes to the 2.0 events. + 2006-02-27 Chris Toshok * DataSourceView.cs: Name isn't virtual. diff --git a/mcs/class/System.Web/System.Web.UI/ListSourceHelper.cs b/mcs/class/System.Web/System.Web.UI/ListSourceHelper.cs index d423f9e47de..bbc2808ee23 100644 --- a/mcs/class/System.Web/System.Web.UI/ListSourceHelper.cs +++ b/mcs/class/System.Web/System.Web.UI/ListSourceHelper.cs @@ -34,9 +34,7 @@ using System.Collections.Specialized; using System.Text; namespace System.Web.UI { - public sealed class ListSourceHelper { - private ListSourceHelper () {} - + public static class ListSourceHelper { [MonoTODO] public static bool ContainsListCollection (IDataSource dataSource) { diff --git a/mcs/class/System.Web/System.Web.UI/Page.cs b/mcs/class/System.Web/System.Web.UI/Page.cs index a6648721050..54cc0cffd9e 100644 --- a/mcs/class/System.Web/System.Web.UI/Page.cs +++ b/mcs/class/System.Web/System.Web.UI/Page.cs @@ -320,6 +320,9 @@ public class Page : TemplateControl, IHttpHandler } [Browsable (false)] +#if NET_2_0 + [EditorBrowsable (EditorBrowsableState.Never)] +#endif public override string ID { get { return base.ID; } @@ -1366,6 +1369,7 @@ public class Page : TemplateControl, IHttpHandler const int prerendercomplete_mask = 1 << 4; const int savestatecomplete_mask = 1 << 5; + [EditorBrowsable (EditorBrowsableState.Advanced)] public event EventHandler InitComplete { add { event_mask |= initcomplete_mask; @@ -1374,6 +1378,7 @@ public class Page : TemplateControl, IHttpHandler remove { Events.RemoveHandler (InitCompleteEvent, value); } } + [EditorBrowsable (EditorBrowsableState.Advanced)] public event EventHandler LoadComplete { add { event_mask |= loadcomplete_mask; @@ -1390,6 +1395,7 @@ public class Page : TemplateControl, IHttpHandler remove { Events.RemoveHandler (PreInitEvent, value); } } + [EditorBrowsable (EditorBrowsableState.Advanced)] public event EventHandler PreLoad { add { event_mask |= preload_mask; @@ -1398,6 +1404,7 @@ public class Page : TemplateControl, IHttpHandler remove { Events.RemoveHandler (PreLoadEvent, value); } } + [EditorBrowsable (EditorBrowsableState.Advanced)] public event EventHandler PreRenderComplete { add { event_mask |= prerendercomplete_mask; @@ -1406,6 +1413,7 @@ public class Page : TemplateControl, IHttpHandler remove { Events.RemoveHandler (PreRenderCompleteEvent, value); } } + [EditorBrowsable (EditorBrowsableState.Advanced)] public event EventHandler SaveStateComplete { add { event_mask |= savestatecomplete_mask; -- cgit v1.2.3 From 926e80a36485e0f48229631092243c701fd86fa7 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Mon, 27 Feb 2006 20:02:26 +0000 Subject: * Control.cs: Change where implicit controls fall in the * zorder. They are now on top of all children. - Synced AddImplicit code with Add - Removed unused enumerator. svn path=/trunk/mcs/; revision=57349 --- .../System.Windows.Forms/ChangeLog | 27 +++++++++++++++++++++- .../System.Windows.Forms/Control.cs | 21 +++++++++++------ 2 files changed, 40 insertions(+), 8 deletions(-) (limited to 'mcs') diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index fb85ce087bc..6674be3ad06 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -1,3 +1,10 @@ +2006-02-27 Jackson Harper + + * Control.cs: Change where implicit controls fall in the zorder. + They are now on top of all children. + - Synced AddImplicit code with Add + - Removed unused enumerator. + 2006-02-26 Peter Dennis Bartok * TextControl.cs(Insert): Combine the last lines unless the insertion @@ -57,7 +64,25 @@ draw all the decorations ourselves. - Set a clipping rectangle on the non client paint event, the window manager drawing code needs one. - + * Form.cs: The window manager needs to know when the window state + has been updated. + * Hwnd.cs: The window manager stuff now does a proper NCCALC so we + don't need to factor in border and title sizes in these + methods. TODO: Remove the args and fix the call points. + * InternalWindowManager.cs: Handle NCHITTEST and NCCALCAREA + properly. + - Let the driver set the cursors. + - Improve active window handling + - Correct sizes for title bars and buttons. + - Match MS drawing better + * MdiWindowManager.cs: We don't need to handle border style + updates specially anymore. + - Check for scrollbars when windows are done moving + - Handle Active properly. + * MimeIcon.cs: Don't crash when we can't load the GNOME stuff + correctly. I am spewing the exception though, so we don't hide the + bugs. + 2006-02-26 Pedro Martinez Julia * DataGridViewRowPostPaintEventArgs.cs, diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs index ac21d9425f2..82a058af643 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs @@ -264,7 +264,7 @@ namespace System.Windows.Forms public class ControlCollection : IList, ICollection, ICloneable, IEnumerable { #region ControlCollection Local Variables private ArrayList list; - private ArrayList impl_list; + internal ArrayList impl_list; private Control [] all_controls; internal Control owner; #endregion // ControlCollection Local Variables @@ -354,7 +354,9 @@ namespace System.Windows.Forms impl_list = new ArrayList (); all_controls = null; impl_list.Add (control); + control.ChangeParent (owner); + control.InitLayout (); owner.UpdateZOrder (); owner.PerformLayout (control, "Parent"); owner.OnControlAdded (new ControlEventArgs (control)); @@ -487,9 +489,11 @@ namespace System.Windows.Forms if (impl_list == null) return (Control []) list.ToArray (typeof (Control)); + Control [] res = new Control [list.Count + impl_list.Count]; - list.CopyTo (res); - impl_list.CopyTo (res, list.Count); + impl_list.CopyTo (res); + list.CopyTo (res, impl_list.Count); + return res; } @@ -2456,10 +2460,15 @@ namespace System.Windows.Forms if (parent.child_controls.Contains(this)) { parent.child_controls.SetChildIndex(this, 0); } + } else { + if (parent.child_controls.impl_list != null) { + Control last_impl = (Control) parent.child_controls.impl_list [parent.child_controls.impl_list.Count - 1]; + XplatUI.SetZOrder (this.window.Handle, last_impl.Handle, false, false); + } else { + XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, true, false); + } } - XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, true, false); - if (parent != null) { parent.Refresh(); } @@ -3246,8 +3255,6 @@ namespace System.Windows.Forms [EditorBrowsable(EditorBrowsableState.Advanced)] protected void RecreateHandle() { - IEnumerator child = child_controls.GetAllEnumerator(); - is_recreating=true; if (IsHandleCreated) { -- cgit v1.2.3 From e6df6ce78f97bc89774fa9e88ec8acb0e98e4664 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Mon, 27 Feb 2006 20:42:44 +0000 Subject: * SizeGrip.cs: Remove the TODO as its been TODONE. svn path=/trunk/mcs/; revision=57350 --- mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog | 3 ++- mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeGrip.cs | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'mcs') diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index 6674be3ad06..3929d8802cf 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -4,7 +4,8 @@ They are now on top of all children. - Synced AddImplicit code with Add - Removed unused enumerator. - + * SizeGrip.cs: Remove the TODO as its been TODONE. + 2006-02-26 Peter Dennis Bartok * TextControl.cs(Insert): Combine the last lines unless the insertion diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeGrip.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeGrip.cs index 3acff5c509a..39219ebc5a7 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeGrip.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeGrip.cs @@ -22,8 +22,6 @@ // Authors: // Jackson Harper (jackson@ximian.com) -// TODO: Eventually we need to handle the cursor and resizing the parent - using System; using System.Drawing; -- cgit v1.2.3 From 3e620e6a87e53dd00c496e17e2ae0bfd3974d86f Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Mon, 27 Feb 2006 21:36:53 +0000 Subject: Commit a bunch of stubs I did months ago, might be useful to someone picking it up svn path=/trunk/mcs/; revision=57355 --- .../System.Windows.Forms/ColumnStyle.cs | 57 ++++++ .../System.Windows.Forms/LayoutEngine.cs | 43 +++++ .../System.Windows.Forms/LayoutSettings.cs | 39 ++++ .../System.Windows.Forms/RowStyle.cs | 57 ++++++ .../System.Windows.Forms/SizeType.cs | 33 ++++ .../System.Windows.Forms/TableLayout.cs | 43 +++++ .../System.Windows.Forms/TableLayoutPanel.cs | 85 +++++++++ .../TableLayoutPanelGrowStyle.cs | 33 ++++ .../System.Windows.Forms/TableLayoutSettings.cs | 206 +++++++++++++++++++++ 9 files changed, 596 insertions(+) create mode 100644 mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnStyle.cs create mode 100644 mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutEngine.cs create mode 100644 mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutSettings.cs create mode 100644 mcs/class/Managed.Windows.Forms/System.Windows.Forms/RowStyle.cs create mode 100644 mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeType.cs create mode 100644 mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayout.cs create mode 100644 mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanel.cs create mode 100644 mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanelGrowStyle.cs create mode 100644 mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutSettings.cs (limited to 'mcs') diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnStyle.cs new file mode 100644 index 00000000000..a2f0fc1e340 --- /dev/null +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnStyle.cs @@ -0,0 +1,57 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// +// Author: +// Miguel de Icaza (miguel@gnome.org) +// +// (C) 2004 Novell, Inc. +// + +namespace System.Windows.Forms { + + public class ColumnStyle : TableLayoutSettings.Style { + float width; + + public ColumnStyle () + { + } + + public ColumnStyle (SizeType st) + { + size_type = st; + } + + public ColumnStyle (SizeType st, float width) + { + size_type = st; + this.width = width; + } + + public float Width { + get { + return width; + } + + set { + width = value; + } + } + } +} diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutEngine.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutEngine.cs new file mode 100644 index 00000000000..1d8a23e0f1a --- /dev/null +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutEngine.cs @@ -0,0 +1,43 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// +// Author: +// Miguel de Icaza (miguel@gnome.org) +// +// (C) 2004 Novell, Inc. +// +using System; +using System.ComponentModel; + +namespace System.Windows.Forms.Layout { + + public abstract class LayoutEngine { + + public virtual void InitLayout (object child, BoundsSpecified specified) + { + } + + public virtual bool Layout (object container, LayoutEventArgs args) + { + return false; + } + } +} + diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutSettings.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutSettings.cs new file mode 100644 index 00000000000..3fbded33d91 --- /dev/null +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutSettings.cs @@ -0,0 +1,39 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// +// Author: +// Miguel de Icaza (miguel@gnome.org) +// +// (C) 2004 Novell, Inc. +// +using System; +using System.ComponentModel; +using System.Windows.Forms.Layout; + +namespace System.Windows.Forms { + + public abstract class LayoutSettings { + public virtual LayoutEngine LayoutEngine { + get { + return null; + } + } + } +} diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RowStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RowStyle.cs new file mode 100644 index 00000000000..83e1f49d29d --- /dev/null +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RowStyle.cs @@ -0,0 +1,57 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// +// Author: +// Miguel de Icaza (miguel@gnome.org) +// +// (C) 2004 Novell, Inc. +// + +namespace System.Windows.Forms { + + public class RowStyle : TableLayoutSettings.Style { + float height; + + public RowStyle () + { + } + + public RowStyle (SizeType st) + { + size_type = st; + } + + public RowStyle (SizeType st, float height) + { + size_type = st; + this.height = height; + } + + public float Height { + get { + return height; + } + + set { + height = value; + } + } + } +} diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeType.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeType.cs new file mode 100644 index 00000000000..7fcb66e22a5 --- /dev/null +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeType.cs @@ -0,0 +1,33 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// +// Author: +// Miguel de Icaza (miguel@gnome.org) +// +// (C) 2004 Novell, Inc. +// + +namespace System.Windows.Forms { + public enum SizeType { + AutoSize = 0, + Absolute = 1, + Percent = 2 + } +} diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayout.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayout.cs new file mode 100644 index 00000000000..05fb95b2a7b --- /dev/null +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayout.cs @@ -0,0 +1,43 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// +// Author: +// Miguel de Icaza (miguel@gnome.org) +// +// (C) 2004 Novell, Inc. +// +using System; +using System.ComponentModel; +using System.Windows.Forms.Layout; + +namespace System.Windows.Forms { + + public class TableLayout : LayoutEngine { + + public override void InitLayout (object child, BoundsSpecified specified) + { + } + + public override bool Layout (object container, LayoutEventArgs args) + { + return false; + } + } +} diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanel.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanel.cs new file mode 100644 index 00000000000..780fcd9e193 --- /dev/null +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanel.cs @@ -0,0 +1,85 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// +// Author: +// Miguel de Icaza (miguel@gnome.org) +// +// (C) 2004 Novell, Inc. +// +using System; +using System.ComponentModel; + +namespace System.Windows.Forms { + + public class TableLayoutPanel : Panel, IExtenderProvider { + TableLayoutSettings settings; + + public TableLayoutPanel () + { + settings = new TableLayoutSettings (this); + } + + internal void Relayout () + { + } + +#region Proxy Properties + new public BorderStyle BorderStyle { + get { + return base.BorderStyle; + } + + set { + base.BorderStyle = value; + } + } + + public int ColumnCount { + get { + return settings.ColumnCount; + } + + set { + settings.ColumnCount = value; + } + } + + public int RowCount { + get { + return settings.RowCount; + } + + set { + settings.RowCount = value; + } + } +#endregion + +#region IExtenderProvider + bool IExtenderProvider.CanExtend (object extendee) + { + // + // Read: `Implementing an Extender Provider' + // + throw new NotImplementedException (); + } +#endregion + } +} diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanelGrowStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanelGrowStyle.cs new file mode 100644 index 00000000000..1c50a7ab936 --- /dev/null +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanelGrowStyle.cs @@ -0,0 +1,33 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// +// Author: +// Miguel de Icaza (miguel@gnome.org) +// +// (C) 2004 Novell, Inc. +// + +namespace System.Windows.Forms { + public enum TableLayoutPanelGrowStyle { + FixedSize, + AddRows, + AddColumns, + } +} diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutSettings.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutSettings.cs new file mode 100644 index 00000000000..c9657c595d6 --- /dev/null +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutSettings.cs @@ -0,0 +1,206 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// +// Author: +// Miguel de Icaza (miguel@gnome.org) +// +// (C) 2004 Novell, Inc. +// +using System; +using System.ComponentModel; +using System.Collections; +using System.Windows.Forms.Layout; + +namespace System.Windows.Forms { + + public class TableLayoutSettings : LayoutSettings { + TableLayoutPanel panel; + ColumnStyleCollection column_style; + TableLayoutPanelGrowStyle grow_style; + int column_count; + int row_count; + + // Statics + static LayoutEngine layout_engine = new TableLayout (); + + internal TableLayoutSettings (TableLayoutPanel panel) + { + this.panel = panel; + column_count = 0; + row_count = 0; + grow_style = TableLayoutPanelGrowStyle.AddRows; + column_style = new ColumnStyleCollection (panel); + } + + public int ColumnCount { + get { + return column_count; + } + + set { + column_count = value; + } + } + + public int RowCount { + get { + return row_count; + } + + set { + row_count = value; + } + } + + public TableLayoutPanelGrowStyle GrowStyle { + get { + return grow_style; + } + } + + public override LayoutEngine LayoutEngine { + get { + return layout_engine; + } + } + + public TableLayoutSettings.ColumnStyleCollection ColumnStyle { + get { + return column_style; + } + } + + public abstract class StyleCollection { + ArrayList al = new ArrayList (); + TableLayoutPanel table; + + internal StyleCollection (TableLayoutPanel table) + { + this.table = table; + } + + public int Add (TableLayoutSettings.Style style) + { + return al.Add (style); + } + + // FIXME; later this should be an override. + public void Clear () + { + al.Clear (); + + // FIXME: Need to investigate what happens when the style is gone. + table.Relayout (); + } + +#region IList methods + // + // The IList methods will later be implemeneted, this is to get us started + // + internal bool Contains (Style style) + { + return al.Contains (style); + } + + internal int IndexOf (Style style) + { + return al.IndexOf (style); + } + + internal void Insert (int index, Style style) + { + al.Insert (index, style); + } + + internal void Remove (Style style) + { + al.Remove (style); + } + +#endregion + public Style this [int idx] { + get { + return (Style) al [idx]; + } + + set { + al [idx] = value; + } + } + } + + public class ColumnStyleCollection : StyleCollection { + + internal ColumnStyleCollection (TableLayoutPanel panel) : base (panel) + { + } + + public void Add (ColumnStyle style) + { + base.Add (style); + } + + public bool Contains (ColumnStyle style) + { + return base.Contains (style); + } + + public int IndexOf (ColumnStyle style) + { + return base.IndexOf (style); + } + + public void Insert (int index, ColumnStyle style) + { + base.Insert (index, style); + } + + public void Remove (ColumnStyle style) + { + base.Remove (style); + } + + public new ColumnStyle this [int index] { + get { + return (ColumnStyle) base [index]; + } + + set { + base [index] = value; + } + } + } + + public class Style { + internal SizeType size_type; + + public SizeType SizeType { + get { + return size_type; + } + + set { + size_type = value; + } + } + } + } + +} -- cgit v1.2.3 From 57fbaa058bc5806970bc9b2c1fd06398008ba3d4 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Mon, 27 Feb 2006 21:39:24 +0000 Subject: Only in 2.0 svn path=/trunk/mcs/; revision=57356 --- mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnStyle.cs | 2 ++ mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutEngine.cs | 2 ++ mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutSettings.cs | 2 ++ mcs/class/Managed.Windows.Forms/System.Windows.Forms/RowStyle.cs | 3 ++- mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeType.cs | 3 ++- mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayout.cs | 2 ++ .../Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanel.cs | 2 ++ .../System.Windows.Forms/TableLayoutPanelGrowStyle.cs | 3 ++- .../Managed.Windows.Forms/System.Windows.Forms/TableLayoutSettings.cs | 2 ++ 9 files changed, 18 insertions(+), 3 deletions(-) (limited to 'mcs') diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnStyle.cs index a2f0fc1e340..fe6f87b41c0 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnStyle.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnStyle.cs @@ -24,6 +24,7 @@ // (C) 2004 Novell, Inc. // +#if NET_2_0 namespace System.Windows.Forms { public class ColumnStyle : TableLayoutSettings.Style { @@ -55,3 +56,4 @@ namespace System.Windows.Forms { } } } +#endif diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutEngine.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutEngine.cs index 1d8a23e0f1a..8f58577f9b4 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutEngine.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutEngine.cs @@ -23,6 +23,7 @@ // // (C) 2004 Novell, Inc. // +#if NET_2_0 using System; using System.ComponentModel; @@ -41,3 +42,4 @@ namespace System.Windows.Forms.Layout { } } +#endif diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutSettings.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutSettings.cs index 3fbded33d91..84c96235535 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutSettings.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LayoutSettings.cs @@ -23,6 +23,7 @@ // // (C) 2004 Novell, Inc. // +#if NET_2_0 using System; using System.ComponentModel; using System.Windows.Forms.Layout; @@ -37,3 +38,4 @@ namespace System.Windows.Forms { } } } +#endif diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RowStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RowStyle.cs index 83e1f49d29d..c8e4ba1d120 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RowStyle.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RowStyle.cs @@ -23,7 +23,7 @@ // // (C) 2004 Novell, Inc. // - +#if NET_2_0 namespace System.Windows.Forms { public class RowStyle : TableLayoutSettings.Style { @@ -55,3 +55,4 @@ namespace System.Windows.Forms { } } } +#endif diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeType.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeType.cs index 7fcb66e22a5..464dcea3390 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeType.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeType.cs @@ -23,7 +23,7 @@ // // (C) 2004 Novell, Inc. // - +#if NET_2_0 namespace System.Windows.Forms { public enum SizeType { AutoSize = 0, @@ -31,3 +31,4 @@ namespace System.Windows.Forms { Percent = 2 } } +#endif diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayout.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayout.cs index 05fb95b2a7b..8065e61e253 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayout.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayout.cs @@ -23,6 +23,7 @@ // // (C) 2004 Novell, Inc. // +#if NET_2_0 using System; using System.ComponentModel; using System.Windows.Forms.Layout; @@ -41,3 +42,4 @@ namespace System.Windows.Forms { } } } +#endif diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanel.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanel.cs index 780fcd9e193..005736fa1bb 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanel.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanel.cs @@ -23,6 +23,7 @@ // // (C) 2004 Novell, Inc. // +#if NET_2_0 using System; using System.ComponentModel; @@ -83,3 +84,4 @@ namespace System.Windows.Forms { #endregion } } +#endif diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanelGrowStyle.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanelGrowStyle.cs index 1c50a7ab936..7a3593c1f88 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanelGrowStyle.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanelGrowStyle.cs @@ -23,7 +23,7 @@ // // (C) 2004 Novell, Inc. // - +#if NET_2_0 namespace System.Windows.Forms { public enum TableLayoutPanelGrowStyle { FixedSize, @@ -31,3 +31,4 @@ namespace System.Windows.Forms { AddColumns, } } +#endif diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutSettings.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutSettings.cs index c9657c595d6..cd48738c2bc 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutSettings.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutSettings.cs @@ -23,6 +23,7 @@ // // (C) 2004 Novell, Inc. // +#if NET_2_0 using System; using System.ComponentModel; using System.Collections; @@ -204,3 +205,4 @@ namespace System.Windows.Forms { } } +#endif -- cgit v1.2.3 From 385e817034a3625fbbe1f65bafe7d94359840269 Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Mon, 27 Feb 2006 22:11:58 +0000 Subject: 2006-02-27 Mike Kestner * ListView.cs: - Restructure layout and invalidation model to remove a ton of flicker from the control and speed up performance in general. - Add manual column resize, flickers like crazy, but I already have some ideas on how I'll fix that. (#76822) - Merge the three Icon-based views into a single layout method. - Move item selection interaction logic from the item since interaction with the collections is more appropriate to the view. - Deselection on non-item clicks. * ListViewItem.cs: - Encapsulate most of the layout. Add some internal props to trigger layout. Move to a model where Items invalidate themselves instead of just invalidating the whole control every time something changes. - Invalidate on Text/Caption changes. - switch to an offset based layout model to avoid having to absolute position every element on item moves. - correct checkbox layout to conform to MS layout. * ThemeWin32Classic.cs: - refactor some column header drawing code. - fix string justification for column headers (#76821) - make SmallIcon labels top justified for compat with MS impl. * ThemeClearlooks.cs: - adjust to new ListViewItem internal checkbox bounds api. svn path=/trunk/mcs/; revision=57357 --- .../System.Windows.Forms/ChangeLog | 26 ++ .../System.Windows.Forms/ListView.cs | 384 ++++++++++----------- .../System.Windows.Forms/ListViewItem.cs | 255 +++++++------- .../System.Windows.Forms/ThemeClearlooks.cs | 2 +- .../System.Windows.Forms/ThemeWin32Classic.cs | 58 ++-- 5 files changed, 357 insertions(+), 368 deletions(-) (limited to 'mcs') diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index 3929d8802cf..08b274fdbfe 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -1,3 +1,29 @@ +2006-02-27 Mike Kestner + + * ListView.cs: + - Restructure layout and invalidation model to remove a ton of + flicker from the control and speed up performance in general. + - Add manual column resize, flickers like crazy, but I already have + some ideas on how I'll fix that. (#76822) + - Merge the three Icon-based views into a single layout method. + - Move item selection interaction logic from the item since + interaction with the collections is more appropriate to the view. + - Deselection on non-item clicks. + * ListViewItem.cs: + - Encapsulate most of the layout. Add some internal props to trigger + layout. Move to a model where Items invalidate themselves instead + of just invalidating the whole control every time something changes. + - Invalidate on Text/Caption changes. + - switch to an offset based layout model to avoid having to absolute + position every element on item moves. + - correct checkbox layout to conform to MS layout. + * ThemeWin32Classic.cs: + - refactor some column header drawing code. + - fix string justification for column headers (#76821) + - make SmallIcon labels top justified for compat with MS impl. + * ThemeClearlooks.cs: + - adjust to new ListViewItem internal checkbox bounds api. + 2006-02-27 Jackson Harper * Control.cs: Change where implicit controls fall in the zorder. diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs index 9066811f135..70ec71df299 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs @@ -22,6 +22,7 @@ // Authors: // Ravindra Kumar (rkumar@novell.com) // Jordi Mas i Hernandez, jordi@ximian.com +// Mike Kestner (mkestner@novell.com) // // TODO: // - Item text editing @@ -29,7 +30,6 @@ // - Feedback for item activation, change in cursor types as mouse moves. // - HideSelection // - LabelEdit -// - Manual column resizing // - Drag and drop @@ -61,6 +61,8 @@ namespace System.Windows.Forms private ListViewItem clicked_item; private ListViewItem last_clicked_item; private ColumnHeaderCollection columns; + private ColumnHeader resize_column; + private bool column_resize_active = false; private bool ctrl_pressed; private bool shift_pressed; internal ListViewItem focused_item; @@ -525,7 +527,7 @@ namespace System.Windows.Forms // do a hit test for the scrolled position else { foreach (ListViewItem item in this.items) { - if (item.EntireRect.X >= h_marker && item.EntireRect.Y >= v_marker) + if (item.Bounds.X >= 0 && item.Bounds.Y >= 0) return item; } return null; @@ -564,8 +566,7 @@ namespace System.Windows.Forms return 0; foreach (ListViewItem item in this.items) { - if (item.EntireRect.X + item.EntireRect.Width >= h_marker - && item.EntireRect.Y + item.EntireRect.Height >= v_marker) + if (item.Bounds.Right >= 0 && item.Bounds.Bottom >= 0) return item.Index; } return 0; @@ -574,10 +575,10 @@ namespace System.Windows.Forms } - internal int LastItemIndex { + internal int LastVisibleIndex { get { for (int i = FirstVisibleIndex; i < Items.Count; i++) { - if (Items[i].EntireRect.Y > v_marker + ClientRectangle.Bottom) + if (Items[i].Bounds.Y > ClientRectangle.Bottom) return i -1; } @@ -786,19 +787,72 @@ namespace System.Windows.Forms } } - + Size LargeIconItemSize { + get { + int w = Math.Max (text_size.Width, 2 + CheckBoxSize.Width + LargeImageList.ImageSize.Width); + int h = text_size.Height + 2 + Math.Max (CheckBoxSize.Height, LargeImageList.ImageSize.Height); + return new Size (w, h); + } + } + + Size SmallIconItemSize { + get { + int w = text_size.Width + 2 + CheckBoxSize.Width + SmallImageList.ImageSize.Width; + int h = Math.Max (text_size.Height, Math.Max (CheckBoxSize.Height, SmallImageList.ImageSize.Height)); + return new Size (w, h); + } + } + + void LayoutIcons (bool large_icons, bool left_aligned, int x_spacing, int y_spacing) + { + if (items.Count == 0) + return; + + Size sz = large_icons ? LargeIconItemSize : SmallIconItemSize; + + int rows, cols; + + if (left_aligned) { + rows = (int) Math.Floor ((double)client_area.Height / (double)(sz.Height + y_spacing)); + if (rows == 0) + rows = 1; + cols = (int) Math.Ceiling ((double)items.Count / (double)rows); + } else { + cols = (int) Math.Floor ((double)client_area.Width / (double)(sz.Width + x_spacing)); + if (cols == 0) + cols = 1; + rows = (int) Math.Ceiling ((double)items.Count / (double)cols); + } + + layout_ht = rows * (sz.Height + y_spacing) - y_spacing; + layout_wd = cols * (sz.Width + x_spacing) - x_spacing; + int row = 0; + int col = 0; + foreach (ListViewItem item in items) { + int x = col * (sz.Width + x_spacing); + int y = row * (sz.Height + y_spacing); + item.Location = new Point (x, y); + item.Layout (); + if (left_aligned) { + if (++row == rows) { + row = 0; + col++; + } + } else { + if (++col == cols) { + col = 0; + row++; + } + } + } + } + // Sets the location of every item on // the ListView as per the view private void CalculateListView (ListViewAlignment align) { int current_pos_x = 0; // our x-position marker int current_pos_y = 0; // our y-position marker - int item_ht; - int item_wd; - int max; // max x_pos or y_pos depending on the alignment - int current = 0; // current row or column - int vertical_spacing = ThemeEngine.Current.ListViewVerticalSpacing; - int horizontal_spacing = ThemeEngine.Current.ListViewHorizontalSpacing; CalcTextSize (); @@ -806,8 +860,7 @@ namespace System.Windows.Forms case View.Details: // ColumnHeaders are not drawn if headerstyle is none - int ht = (this.header_style == ColumnHeaderStyle.None) ? - 0 : this.Font.Height + 3; + int ht = 0; if (columns.Count > 0) { foreach (ColumnHeader col in columns) { @@ -816,149 +869,41 @@ namespace System.Windows.Forms col.CalcColumnHeader (); current_pos_x += col.Wd; } - this.layout_wd = current_pos_x; + + if (header_style != ColumnHeaderStyle.None) + ht = columns [0].Ht; + layout_wd = current_pos_x; } // set the position marker for placing items // vertically down - current_pos_y = ht; + current_pos_y = ht + 2; if (items.Count > 0) { foreach (ListViewItem item in items) { - item.location.X = 0; - item.location.Y = current_pos_y; - item.CalcListViewItem (); - current_pos_y += item.EntireRect.Height; + item.Layout (); + item.Location = new Point (0, current_pos_y); + current_pos_y += item.Bounds.Height + 2; } - this.layout_ht = current_pos_y; + layout_ht = current_pos_y; // some space for bottom gridline - if (this.grid_lines) - this.layout_ht += 2; + if (grid_lines) + layout_ht += 2; } break; case View.SmallIcon: - vertical_spacing = 0; - horizontal_spacing = 0; - goto case View.LargeIcon; + LayoutIcons (false, alignment == ListViewAlignment.Left, 4, 2); + break; case View.LargeIcon: - if (items.Count > 0) { - items [0].CalcListViewItem (); - item_ht = items [0].EntireRect.Height; - item_wd = items [0].EntireRect.Width; - - // top (default) and snaptogrid alignments are handled same way - if (align == ListViewAlignment.Left) { - max = client_area.Height; - foreach (ListViewItem item in items) { - item.location.X = current_pos_x + - horizontal_spacing; - item.location.Y = 0; - item.CalcListViewItem (); - current_pos_y += item_ht; - - current ++; // just to know about the last element - // we just did the last item - if (current == items.Count) { - if (max < current_pos_y) - max = current_pos_y; - current_pos_x = item.EntireRect.Right; - break; - } - else { - // is there enough space for another row ? - if ((current_pos_y + vertical_spacing - + item_ht) <= client_area.Height) - current_pos_y += vertical_spacing; - else { - // start another column - // make current_pos_y as the - // max value and reset - // current_pos_y value. - max = current_pos_y; - current_pos_x += item_wd; - current_pos_y = 0; - } - } - } - // adjust the layout dimensions - this.layout_ht = max; - this.layout_wd = current_pos_x; - } - else { // other default/top alignment - max = client_area.Width; - foreach (ListViewItem item in items) { - item.location.X = current_pos_x + - horizontal_spacing; - - item.location.Y = current_pos_y; - item.CalcListViewItem (); - current_pos_x += item_wd; - - current ++; // just to know about the last element - // we just did the last item - if (current == items.Count) { - if (max < current_pos_x) - max = current_pos_x; - current_pos_y = item.EntireRect.Bottom; - break; - } - else { - // is there enough space for another column? - if ((current_pos_x + horizontal_spacing - + item_wd) <= client_area.Width) - continue; - else { - // start another row - // make current_pos_x as the - // max value and reset - // current_pos_x value. - max = current_pos_x; - current_pos_y += (item_ht + - vertical_spacing); - current_pos_x = 0; - } - } - } - // adjust the layout dimensions - this.layout_wd = max; - this.layout_ht = current_pos_y; - } - } + LayoutIcons (true, alignment == ListViewAlignment.Left, + ThemeEngine.Current.ListViewHorizontalSpacing, + ThemeEngine.Current.ListViewVerticalSpacing); break; case View.List: - if (items.Count > 0) { - items [0].CalcListViewItem (); - item_ht = items [0].EntireRect.Height; - item_wd = items [0].EntireRect.Width; - - max = client_area.Height / item_ht; - if (max == 0) - max = 1; // we draw at least one row - - foreach (ListViewItem item in items) { - item.location.X = current_pos_x; - item.location.Y = current_pos_y; - item.CalcListViewItem (); - current ++; - if (current == max) { - current_pos_x += item_wd; - current_pos_y = 0; - current = 0; - } - else - current_pos_y += item_ht; - } - - // adjust the layout dimensions - this.layout_ht = max * item_ht; - if (current == 0) // we have fully filled layout - this.layout_wd = current_pos_x; - else - this.layout_wd = current_pos_x + item_wd; - } + LayoutIcons (false, true, 4, 2); break; } @@ -966,6 +911,20 @@ namespace System.Windows.Forms } + void SelectItem (ListViewItem item) + { + if (!CanMultiselect && SelectedItems.Count > 0) { + SelectedItems.Clear (); + SelectedIndices.list.Clear (); + } + + if (!SelectedItems.Contains (item)) { + SelectedItems.list.Add (item); + SelectedIndices.list.Add (item.Index); + } + item.Selected = true; + } + private bool KeySearchString (KeyEventArgs ke) { int current_tickcnt = Environment.TickCount; @@ -981,7 +940,7 @@ namespace System.Windows.Forms if (CultureInfo.CurrentCulture.CompareInfo.IsPrefix (Items[i].Text, keysearch_text, CompareOptions.IgnoreCase)) { SetFocusedItem (Items [i]); - items [i].Selected = true; + SelectItem (items [i]); EnsureVisible (i); break; } @@ -1081,7 +1040,7 @@ namespace System.Windows.Forms } if (index != -1) { - items [index].Selected = true; + SelectItem (items [index]); SetFocusedItem (items [index]); EnsureVisible (index); } @@ -1111,6 +1070,12 @@ namespace System.Windows.Forms // hit test on columns if (this.view == View.Details && this.columns.Count > 0) { + if (resize_column != null) { + column_resize_active = true; + Capture = true; + return; + } + foreach (ColumnHeader col in this.columns) { if (col.Rect.Contains (hit)) { this.clicked_column = col; @@ -1121,7 +1086,9 @@ namespace System.Windows.Forms if (this.clicked_column != null) { this.clicked_column.pressed = true; - this.Redraw (false); + Rectangle bounds = clicked_column.Rect; + bounds.X -= h_marker; + Invalidate (bounds); return; } } @@ -1129,9 +1096,9 @@ namespace System.Windows.Forms // hit test on items // we need to take scrolling into account - hit = new Point (me.X + h_marker, me.Y + v_marker); + hit = new Point (me.X, me.Y); foreach (ListViewItem item in this.items) { - if (item.CheckRect.Contains (hit)) { + if (item.CheckRectReal.Contains (hit)) { CheckState curr_state = item.Checked ? CheckState.Checked : CheckState.Unchecked; if (item.Checked) @@ -1141,7 +1108,6 @@ namespace System.Windows.Forms CheckState new_state = item.Checked ? CheckState.Checked : CheckState.Unchecked; - this.Redraw (false); // Raise the ItemCheck event ItemCheckEventArgs ice = new ItemCheckEventArgs (item.Index, @@ -1153,25 +1119,24 @@ namespace System.Windows.Forms if (this.view == View.Details && this.FullRowSelect == false) { - if (item.LabelRect.Contains (hit)) { + if (item.GetBounds (ItemBoundsPortion.Label).Contains (hit)) { this.clicked_item = item; break; } } else { - if (item.EntireRect.Contains (hit)) { + if (item.Bounds.Contains (hit)) { this.clicked_item = item; break; } } } - // set the FocusedItem to be the current clicked_item SetFocusedItem (clicked_item); if (clicked_item != null) { bool changed = !clicked_item.Selected; - clicked_item.Selected = true; + SelectItem (clicked_item); // Only Raise the event if the selected item has changed if (changed) @@ -1183,16 +1148,12 @@ namespace System.Windows.Forms OnDoubleClick (EventArgs.Empty); else if (me.Clicks == 1 && clicked_item != null) OnClick (EventArgs.Empty); - - this.Redraw (false); } else if (selected_indices.Count > 0) { - // NOTE: selected_indices isn't computed properly so - // this doesn't actually work - // Raise the event if there was at least one item // selected and the user click on a dead area (unselecting all) + SelectedItems.Clear (); + SelectedIndices.list.Clear (); OnSelectedIndexChanged (EventArgs.Empty); - Redraw (false); } } @@ -1208,23 +1169,49 @@ namespace System.Windows.Forms ListViewItem item = this.GetItemAt (hit.X, hit.Y); if (item != null) { - item.Selected = true; + SelectItem (item); // Raise the event this.OnSelectedIndexChanged (new EventArgs ()); - - this.Redraw (false); } } private void ListView_MouseMove (object sender, MouseEventArgs me) { + if (View != View.Details || Columns.Count < 2) + return; + // Column header is always at the top. It can // scroll only horizontally. So, we have to take // only horizontal scrolling into account Point hit = new Point (me.X + h_marker, me.Y); + if (column_resize_active) { + resize_column.Width = hit.X - resize_column.X; + if (resize_column.Width < 0) + resize_column.Width = 0; + return; + } + + resize_column = null; + + for (int i = 0; i < Columns.Count; i++) { + Rectangle zone = Columns [i].Rect; + zone.X = zone.Right - 5; + zone.Width = 10; + if (zone.Contains (hit)) { + resize_column = Columns [i]; + break; + } + } + + if (resize_column == null) + Cursor = Cursors.Default; + else + Cursor = Cursors.VSplit; + // non-null clicked_col means mouse down has happened // on a column + // FIXME: this seems to be drag related if (this.clicked_column != null) { if (this.clicked_column.pressed == false && this.clicked_column.Rect.Contains (hit)) { @@ -1245,12 +1232,22 @@ namespace System.Windows.Forms if (items.Count == 0) return; + if (column_resize_active) { + Capture = false; + column_resize_active = false; + resize_column = null; + Cursor = Cursors.Default; + return; + } + Point hit = new Point (me.X, me.Y); if (this.clicked_column != null) { if (this.clicked_column.pressed) { this.clicked_column.pressed = false; - this.Redraw (false); + Rectangle bounds = clicked_column.Rect; + bounds.X -= h_marker; + Invalidate (bounds); // Raise the ColumnClick event this.OnColumnClick (new ColumnClickEventArgs @@ -1262,9 +1259,9 @@ namespace System.Windows.Forms Rectangle rect = Rectangle.Empty; if (this.clicked_item != null) { if (this.view == View.Details && !this.full_row_select) - rect = this.clicked_item.LabelRect; + rect = this.clicked_item.GetBounds (ItemBoundsPortion.Label); else - rect = this.clicked_item.EntireRect; + rect = this.clicked_item.Bounds; // We handle double click in a separate handler if (this.activation != ItemActivation.Standard && @@ -1290,8 +1287,7 @@ namespace System.Windows.Forms private void ListView_Paint (object sender, PaintEventArgs pe) { - if (this.Width <= 0 || this.Height <= 0 || - this.Visible == false || this.updating == true) + if (Width <= 0 || Height <= 0 || !Visible || updating) return; CalculateScrollBars (); @@ -1329,11 +1325,6 @@ namespace System.Windows.Forms int pixels = h_marker - h_scroll.Value; Rectangle area = client_area; - if (View == View.Details && Columns.Count > 0) { - area.Y += Columns[0].Ht; - area.Height -= Columns[0].Ht; - } - h_marker = h_scroll.Value; XplatUI.ScrollWindow (Handle, area, pixels, 0, false); } @@ -1525,37 +1516,24 @@ namespace System.Windows.Forms public void EnsureVisible (int index) { - if (index < 0 || index >= this.items.Count || this.scrollable == false) + if (index < 0 || index >= items.Count || scrollable == false) return; - // dimensions of visible area - int view_wd = client_area.Width; - int view_ht = client_area.Height; - // visible area is decided by the h_marker and v_marker - Rectangle view_rect = new Rectangle (h_marker, v_marker, view_wd, view_ht); - - // an item's bounding rect - Rectangle rect = this.items [index].EntireRect; + Rectangle view_rect = new Rectangle (0, 0, client_area.Width, client_area.Height); + Rectangle bounds = items [index].Bounds; - // we don't need to do anything if item is visible. - // visible area is represented by (0,0,view_wd,view_ht) - if (view_rect.Contains (rect)) + if (view_rect.Contains (bounds)) return; - // Scroll Left or Up - if ((rect.Left < view_rect.Left) || (rect.Top < view_rect.Top)) { - if (rect.Left < view_rect.Left) - this.h_scroll.Value -= (view_rect.Left - rect.Left); - if (rect.Top < view_rect.Top) - this.v_scroll.Value -= (view_rect.Top - rect.Top); - } - // Scroll Right or Down - else { - if (rect.Right > view_rect.Right) - this.h_scroll.Value += (rect.Right - view_rect.Right); - if (rect.Bottom > view_rect.Bottom) - this.v_scroll.Value += (rect.Bottom - view_rect.Bottom); - } + if (bounds.Left < 0) + h_scroll.Value += bounds.Left; + else if (bounds.Right > view_rect.Right) + h_scroll.Value += (bounds.Right - view_rect.Right); + + if (bounds.Top < 0) + v_scroll.Value += bounds.Top; + else if (bounds.Bottom > view_rect.Bottom) + v_scroll.Value += (bounds.Bottom - view_rect.Bottom); } public ListViewItem GetItemAt (int x, int y) @@ -2043,7 +2021,7 @@ namespace System.Windows.Forms if (list.Contains (value)) throw new ArgumentException ("An item cannot be added more than once. To add an item again, you need to clone it.", "value"); - value.owner = this.owner; + value.Owner = owner; list [displayIndex] = value; owner.Redraw (true); @@ -2079,7 +2057,7 @@ namespace System.Windows.Forms if (list.Contains (value)) throw new ArgumentException ("An item cannot be added more than once. To add an item again, you need to clone it.", "value"); - value.owner = this.owner; + value.Owner = owner; list.Add (value); if (owner.Sorting != SortOrder.None) @@ -2111,7 +2089,7 @@ namespace System.Windows.Forms owner.CheckedIndices.list.Clear (); foreach (ListViewItem item in values) { - item.owner = this.owner; + item.Owner = owner; list.Add (item); } @@ -2161,7 +2139,7 @@ namespace System.Windows.Forms else li = new ListViewItem (item.ToString ()); - li.owner = this.owner; + li.Owner = owner; result = list.Add (li); owner.Redraw (true); @@ -2206,7 +2184,7 @@ namespace System.Windows.Forms if (list.Contains (item)) throw new ArgumentException ("An item cannot be added more than once. To add an item again, you need to clone it.", "item"); - item.owner = this.owner; + item.Owner = owner; list.Insert (index, item); owner.Redraw (true); return item; @@ -2411,14 +2389,10 @@ namespace System.Windows.Forms #region Public Methods public virtual void Clear () { - // mark the items as unselected before clearing the list for (int i = 0; i < list.Count; i++) - ((ListViewItem) list [i]).selected = false; + ((ListViewItem) list [i]).Selected = false; list.Clear (); - - if (owner != null) - owner.Invalidate (); } public bool Contains (ListViewItem item) diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs index dc223d13aef..6e5d38ef7fc 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs @@ -53,15 +53,13 @@ namespace System.Windows.Forms private object tag; private bool use_item_style = true; - // internal variables - internal Rectangle checkbox_rect; // calculated by CalcListViewItem method - internal Rectangle entire_rect; - internal Rectangle icon_rect; - internal Rectangle item_rect; - internal Rectangle label_rect; - internal Point location = Point.Empty; // set by the ListView control - internal ListView owner; - internal bool selected; + Rectangle bounds; + Rectangle checkbox_rect; // calculated by CalcListViewItem method + Rectangle icon_rect; + Rectangle item_rect; + Rectangle label_rect; + ListView owner; + bool selected; #endregion Instance Variables @@ -144,8 +142,9 @@ namespace System.Windows.Forms if (is_checked == value) return; + is_checked = value; + if (owner != null) { - is_checked = value; if (is_checked) { if (owner.CheckedItems.Contains (this) == false) { owner.CheckedItems.list.Add (this); @@ -157,8 +156,9 @@ namespace System.Windows.Forms owner.CheckedIndices.list.Remove (this.Index); } - owner.Invalidate (Bounds); + Layout (); } + Invalidate (); } } @@ -173,7 +173,8 @@ namespace System.Windows.Forms is_focused = value; if (owner != null) - owner.Invalidate (Bounds); + Layout (); + Invalidate (); } } @@ -196,7 +197,8 @@ namespace System.Windows.Forms sub_items[0].Font = value; if (owner != null) - owner.Invalidate (Bounds); + Layout (); + Invalidate (); } } @@ -229,7 +231,8 @@ namespace System.Windows.Forms image_index = value; if (owner != null) - owner.Invalidate (Bounds); + Layout (); + Invalidate (); } } @@ -265,27 +268,14 @@ namespace System.Windows.Forms public bool Selected { get { return selected; } set { - if (owner != null) { - if (owner.CanMultiselect == false && - owner.SelectedItems.Count > 0) { - owner.SelectedItems.Clear (); - owner.SelectedIndices.list.Clear (); - } + if (selected == value) + return; - selected = value; - if (selected) { - if (owner.SelectedItems.Contains (this) == false) { - owner.SelectedItems.list.Add (this); - owner.SelectedIndices.list.Add (this.Index); - } - } - else { - owner.SelectedItems.list.Remove (this); - owner.SelectedIndices.list.Remove (this.Index); - } - - owner.Invalidate (Bounds); - } + selected = value; + + if (owner != null) + Layout (); + Invalidate (); } } @@ -327,7 +317,16 @@ namespace System.Windows.Forms else return ""; } - set { this.sub_items [0].Text = value; } + set { + if (sub_items [0].Text == value) + return; + + sub_items [0].Text = value; + + if (owner != null) + Layout (); + Invalidate (); + } } [DefaultValue (true)] @@ -380,42 +379,34 @@ namespace System.Windows.Forms if (owner == null) return Rectangle.Empty; - /* Original Ravi's design calculated all items in a virtual space - We convert them real screen positions - */ - switch (portion) { + Rectangle rect; - case ItemBoundsPortion.Icon: { - Rectangle rect = icon_rect; - rect.X -= owner.h_marker; - rect.Y -= owner.v_marker; - return rect; - } + switch (portion) { + case ItemBoundsPortion.Icon: + rect = icon_rect; + break; - case ItemBoundsPortion.Label: { - Rectangle rect = label_rect; - rect.X -= owner.h_marker; - rect.Y -= owner.v_marker; - return rect; - } + case ItemBoundsPortion.Label: + rect = label_rect; + break; - case ItemBoundsPortion.ItemOnly: { - Rectangle rect = item_rect; - rect.X -= owner.h_marker; - rect.Y -= owner.v_marker; - return rect; - } + case ItemBoundsPortion.ItemOnly: + rect = item_rect; + break; - case ItemBoundsPortion.Entire: { - Rectangle rect = entire_rect; + case ItemBoundsPortion.Entire: + rect = bounds; rect.X -= owner.h_marker; rect.Y -= owner.v_marker; return rect; - } default: throw new ArgumentException ("Invalid value for portion."); } + + rect.X += bounds.X - owner.h_marker; + rect.Y += bounds.Y - owner.v_marker; + return rect; } void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context) @@ -452,42 +443,71 @@ namespace System.Windows.Forms internal Rectangle CheckRectReal { get { Rectangle rect = checkbox_rect; - rect.X -= owner.h_marker; - rect.Y -= owner.v_marker; + rect.X += bounds.X - owner.h_marker; + rect.Y += bounds.Y - owner.v_marker; return rect; } } - internal Rectangle CheckRect { + Rectangle CheckRect { get { return this.checkbox_rect; } } - internal Rectangle EntireRect { - get { return this.entire_rect; } - } - - internal Rectangle IconRect { + Rectangle IconRect { get { return this.icon_rect; } } - internal Rectangle LabelRect { + Rectangle LabelRect { get { return this.label_rect; } } - internal void CalcListViewItem () + internal Point Location { + set { + if (bounds.X == value.X && bounds.Y == value.Y) + return; + + Rectangle prev = Bounds; + bounds.X = value.X; + bounds.Y = value.Y; + if (owner != null) { + if (prev != Rectangle.Empty) + owner.Invalidate (prev); + owner.Invalidate (Bounds); + } + } + } + + internal ListView Owner { + set { + if (owner == value) + return; + + owner = value; + if (owner != null) + Layout (); + Invalidate (); + } + } + + private void Invalidate () + { + if (owner == null) + return; + + owner.Invalidate (Bounds); + } + + internal void Layout () { int item_ht; + Rectangle total; Size text_size = owner.text_size; + checkbox_rect = Rectangle.Empty; if (owner.CheckBoxes) checkbox_rect.Size = owner.CheckBoxSize; - else - checkbox_rect = Rectangle.Empty; - - checkbox_rect.Location = this.location; switch (owner.View) { - case View.Details: // LAMESPEC: MSDN says, "In all views except the details // view of the ListView, this value specifies the same @@ -495,104 +515,85 @@ namespace System.Windows.Forms // returns same bounding rectangles for Item and Entire // values in the case of Details view. - icon_rect.X = checkbox_rect.X + checkbox_rect.Width + 2; - icon_rect.Y = checkbox_rect.Y; - - item_ht = Math.Max (owner.CheckBoxSize.Height + 1, - text_size.Height); + icon_rect = label_rect = Rectangle.Empty; + icon_rect.X = checkbox_rect.Width + 2; + item_ht = Math.Max (owner.CheckBoxSize.Height, text_size.Height); if (owner.SmallImageList != null) { - item_ht = Math.Max (item_ht, - owner.SmallImageList.ImageSize.Height + 1); + item_ht = Math.Max (item_ht, owner.SmallImageList.ImageSize.Height); icon_rect.Width = owner.SmallImageList.ImageSize.Width; } - else - icon_rect.Width = 0; - label_rect.Height = checkbox_rect.Height = icon_rect.Height = item_ht; + label_rect.Height = icon_rect.Height = item_ht; + checkbox_rect.Y = icon_rect.Height - checkbox_rect.Height - 1; - label_rect.X = icon_rect.X + icon_rect.Width; - label_rect.Y = icon_rect.Y; + label_rect.X = icon_rect.Right + 1; if (owner.Columns.Count > 0) label_rect.Width = Math.Max (text_size.Width, owner.Columns[0].Wd); else label_rect.Width = text_size.Width; - item_rect = entire_rect = Rectangle.Union + item_rect = total = Rectangle.Union (Rectangle.Union (checkbox_rect, icon_rect), label_rect); + bounds.Size = total.Size; // Take into account the rest of columns. First column // is already taken into account above. for (int i = 1; i < owner.Columns.Count; i++) { item_rect.Width += owner.Columns [i].Wd; - entire_rect.Width += owner.Columns [i].Wd; + bounds.Width += owner.Columns [i].Wd; } break; case View.LargeIcon: + label_rect = icon_rect = Rectangle.Empty; + if (owner.LargeImageList != null) { - icon_rect.Width = owner.LargeImageList.ImageSize.Width + 16; - icon_rect.Height = owner.LargeImageList.ImageSize.Height + 4; - } - else { - icon_rect.Width = 16; - icon_rect.Height = 4; + icon_rect.Width = owner.LargeImageList.ImageSize.Width; + icon_rect.Height = owner.LargeImageList.ImageSize.Height; } - if (text_size.Width <= (checkbox_rect.Width + icon_rect.Width)) { - icon_rect.X = checkbox_rect.X + checkbox_rect.Width; - icon_rect.Y = checkbox_rect.Y; + checkbox_rect.Y = icon_rect.Height - checkbox_rect.Height - 1; - label_rect.X = icon_rect.X + (icon_rect.Width - - text_size.Width) / 2; - label_rect.Y = Math.Max (checkbox_rect.Bottom, - icon_rect.Bottom) + 2; + if (text_size.Width <= (checkbox_rect.Width + icon_rect.Width)) { + icon_rect.X = checkbox_rect.Width + 1; + label_rect.X = icon_rect.X + (icon_rect.Width - text_size.Width) / 2; + label_rect.Y = Math.Max (checkbox_rect.Bottom, icon_rect.Bottom) + 2; label_rect.Size = text_size; - } - else { - label_rect.X = this.location.X; - - int centerX = label_rect.X + text_size.Width / 2; + } else { + int centerX = text_size.Width / 2; icon_rect.X = centerX - icon_rect.Width / 2; checkbox_rect.X = (icon_rect.X - checkbox_rect.Width); - - icon_rect.Y = checkbox_rect.Y; - - label_rect.Y = Math.Max (checkbox_rect.Bottom, - icon_rect.Bottom) + 2; + label_rect.Y = Math.Max (checkbox_rect.Bottom, icon_rect.Bottom) + 2; label_rect.Size = text_size; } item_rect = Rectangle.Union (icon_rect, label_rect); - entire_rect = Rectangle.Union (item_rect, checkbox_rect); + total = Rectangle.Union (item_rect, checkbox_rect); + bounds.Size = total.Size; break; case View.List: - goto case View.SmallIcon; - case View.SmallIcon: - icon_rect.X = checkbox_rect.X + checkbox_rect.Width; - icon_rect.Y = checkbox_rect.Y; - + label_rect = icon_rect = Rectangle.Empty; + icon_rect.X = checkbox_rect.Width + 1; item_ht = Math.Max (owner.CheckBoxSize.Height, text_size.Height); if (owner.SmallImageList != null) { - item_ht = Math.Max (item_ht, - owner.SmallImageList.ImageSize.Height + 1); + item_ht = Math.Max (item_ht, owner.SmallImageList.ImageSize.Height); icon_rect.Width = owner.SmallImageList.ImageSize.Width; + icon_rect.Height = owner.SmallImageList.ImageSize.Height; } - else - icon_rect.Width = 0; - - label_rect.Height = checkbox_rect.Height = icon_rect.Height = item_ht; - label_rect.X = icon_rect.X + icon_rect.Width; - label_rect.Y = icon_rect.Y; + checkbox_rect.Y = icon_rect.Height - checkbox_rect.Height + 1; + label_rect.X = icon_rect.Right + 1; label_rect.Width = text_size.Width; + label_rect.Height = icon_rect.Height = item_ht; item_rect = Rectangle.Union (icon_rect, label_rect); - entire_rect = Rectangle.Union (item_rect, checkbox_rect); + total = Rectangle.Union (item_rect, checkbox_rect); + bounds.Size = total.Size; break; } diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeClearlooks.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeClearlooks.cs index 08ded7e05d8..2697229e025 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeClearlooks.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeClearlooks.cs @@ -2486,7 +2486,7 @@ namespace System.Windows.Forms { if ( control.View == View.Details ) { if ( control.FullRowSelect ) { // fill the entire rect excluding the checkbox - full_rect.Location = item.LabelRect.Location; + full_rect.Location = item.GetBounds (ItemBoundsPortion.Label).Location; dc.FillRectangle( this.ResPool.GetSolidBrush ( this.ColorHighlight ), full_rect ); } else { diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs index f3a596777c7..1dcb7cceef2 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs @@ -1428,7 +1428,7 @@ namespace System.Windows.Forms if (!details || control.Columns.Count > 0) { int first = control.FirstVisibleIndex; - for (int i = first; i <= control.LastItemIndex; i ++) { + for (int i = first; i <= control.LastVisibleIndex; i ++) { if (clip.IntersectsWith (control.Items[i].GetBounds (ItemBoundsPortion.Entire))) DrawListViewItem (dc, control, control.Items[i]); } @@ -1486,35 +1486,20 @@ namespace System.Windows.Forms dc.FillRectangle (ResPool.GetSolidBrush (control.BackColor), 0, 0, control.TotalWidth, control.Font.Height + 5); if (control.Columns.Count > 0) { - if (control.HeaderStyle == ColumnHeaderStyle.Clickable) { - foreach (ColumnHeader col in control.Columns) { - Rectangle rect = col.Rect; - rect.X -= control.h_marker; - this.CPDrawButton (dc, rect, - (col.Pressed ? - ButtonState.Pushed : - ButtonState.Normal)); - dc.DrawString (col.Text, DefaultFont, - ResPool.GetSolidBrush - (this.ColorControlText), - rect.X + 3, - rect.Y + rect.Height/2 + 1, - col.Format); - } - } - // Non-clickable columns - else { - foreach (ColumnHeader col in control.Columns) { - Rectangle rect = col.Rect; - rect.X -= control.h_marker; - this.CPDrawButton (dc, rect, ButtonState.Flat); - dc.DrawString (col.Text, DefaultFont, - ResPool.GetSolidBrush - (this.ColorControlText), - rect.X + 3, - rect.Y + rect.Height/2 + 1, - col.Format); - } + foreach (ColumnHeader col in control.Columns) { + Rectangle rect = col.Rect; + rect.X -= control.h_marker; + ButtonState state; + if (control.HeaderStyle == ColumnHeaderStyle.Clickable) + state = col.Pressed ? ButtonState.Pushed : ButtonState.Normal; + else + state = ButtonState.Flat; + this.CPDrawButton (dc, rect, state); + rect.X += 3; + rect.Width -= 8; + dc.DrawString (col.Text, DefaultFont, + ResPool.GetSolidBrush (ColorControlText), + rect, col.Format); } } } @@ -1593,7 +1578,10 @@ namespace System.Windows.Forms // draw the item text // format for the item text StringFormat format = new StringFormat (); - format.LineAlignment = StringAlignment.Center; + if (control.View == View.SmallIcon) + format.LineAlignment = StringAlignment.Near; + else + format.LineAlignment = StringAlignment.Center; if (control.View == View.LargeIcon) format.Alignment = StringAlignment.Center; else @@ -1606,7 +1594,7 @@ namespace System.Windows.Forms if (control.View == View.Details) { if (control.FullRowSelect) { // fill the entire rect excluding the checkbox - full_rect.Location = item.LabelRect.Location; + full_rect.Location = item.GetBounds (ItemBoundsPortion.Label).Location; dc.FillRectangle (this.ResPool.GetSolidBrush (this.ColorHighlight), full_rect); } @@ -1653,14 +1641,14 @@ namespace System.Windows.Forms // set the format for subitems format.FormatFlags = StringFormatFlags.NoWrap; - format.Alignment = StringAlignment.Near; // 0th subitem is the item already drawn for (int index = 1; index < count; index++) { subItem = subItems [index]; col = control.Columns [index]; - sub_item_rect.X = col.Rect.Left; - sub_item_rect.Width = col.Wd; + format.Alignment = col.Format.Alignment; + sub_item_rect.X = col.Rect.Left + 3; + sub_item_rect.Width = col.Wd - 6; sub_item_rect.X -= control.h_marker; SolidBrush sub_item_back_br = null; -- cgit v1.2.3 From ce9291281593887d381a429ab947004424c376d2 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Mon, 27 Feb 2006 22:44:20 +0000 Subject: 2006-02-27 Marek Safar * attribute.cs (Attribute.PosArguments, Attribute.NamedArguments): Use these two separated members to simplify the code. (Attribute.Resolve): Refactored to use new fields and methods. (Attribute.ResolveConstructor): Extracted from ResolveArguments and implemented obsolete attribute checking. (Attribute.ResolveNamedArguments): Extracted from ResolveArguments and implemented obsolete checking again. It look line never ending quest ;-) (GlobalAttribute.ResolveConstructor): Need to override as the rest. * cfold.cs (BinaryFold): TryReduce throws an exception to indicate error. * constanct.cs (TryReduce): Throws OverflowException to indicate error. *class.cs (Property.Define): Add RegisterProperty call. * cs-parser.jay: Replaced ArrayList with fixed array for attribute argument groups (only 2). * ecore.cs (Expression.GetAttributableValue): New virtual method used for encoding expression to arguments. (Expression.ExprClassToResolveFlags): Just turned to property. * expression.cs (ArrayCreation.ValidateInitializers): Slightly optimized. (ArrayCreation.GetAttributableValue): Renamed from EncodeAsAttribute and optimized as well as implemented support for zero-length attributes. * typemanager.cs (TypeManager.RegisterProperty, TypeManager.GetProperty): Add caching of PropertyInfo's. svn path=/trunk/mcs/; revision=57358 --- mcs/mcs/ChangeLog | 31 ++++ mcs/mcs/attribute.cs | 470 ++++++++++++++++++++++--------------------------- mcs/mcs/cfold.cs | 20 ++- mcs/mcs/class.cs | 1 + mcs/mcs/constant.cs | 18 +- mcs/mcs/cs-parser.jay | 25 +-- mcs/mcs/ecore.cs | 59 ++++--- mcs/mcs/expression.cs | 77 ++++---- mcs/mcs/typemanager.cs | 16 +- 9 files changed, 371 insertions(+), 346 deletions(-) (limited to 'mcs') diff --git a/mcs/mcs/ChangeLog b/mcs/mcs/ChangeLog index 8b9423aa8e2..315b25dad1c 100644 --- a/mcs/mcs/ChangeLog +++ b/mcs/mcs/ChangeLog @@ -1,3 +1,34 @@ +2006-02-27 Marek Safar + + * attribute.cs (Attribute.PosArguments, Attribute.NamedArguments): Use + these two separated members to simplify the code. + (Attribute.Resolve): Refactored to use new fields and methods. + (Attribute.ResolveConstructor): Extracted from ResolveArguments and + implemented obsolete attribute checking. + (Attribute.ResolveNamedArguments): Extracted from ResolveArguments and + implemented obsolete checking again. It look line never ending quest ;-) + (GlobalAttribute.ResolveConstructor): Need to override as the rest. + + * cfold.cs (BinaryFold): TryReduce throws an exception to indicate error. + + * constanct.cs (TryReduce): Throws OverflowException to indicate error. + + *class.cs (Property.Define): Add RegisterProperty call. + + * cs-parser.jay: Replaced ArrayList with fixed array for attribute + argument groups (only 2). + + * ecore.cs (Expression.GetAttributableValue): New virtual method used for + encoding expression to arguments. + (Expression.ExprClassToResolveFlags): Just turned to property. + + * expression.cs (ArrayCreation.ValidateInitializers): Slightly optimized. + (ArrayCreation.GetAttributableValue): Renamed from EncodeAsAttribute and + optimized as well as implemented support for zero-length attributes. + + * typemanager.cs (TypeManager.RegisterProperty, TypeManager.GetProperty): + Add caching of PropertyInfo's. + 2006-02-25 Marek Safar * delegate.cs (DelegateCreation.ResolveMethodGroupExpr): Don't report diff --git a/mcs/mcs/attribute.cs b/mcs/mcs/attribute.cs index c474d0c4d84..2b8c8031ea4 100644 --- a/mcs/mcs/attribute.cs +++ b/mcs/mcs/attribute.cs @@ -83,7 +83,8 @@ namespace Mono.CSharp { public readonly Expression LeftExpr; public readonly string Identifier; - public readonly ArrayList Arguments; + readonly ArrayList PosArguments; + readonly ArrayList NamedArguments; public readonly Location Location; @@ -93,8 +94,9 @@ namespace Mono.CSharp { readonly bool nameEscaped; Attributable owner; - static AttributeUsageAttribute DefaultUsageAttribute = new AttributeUsageAttribute (AttributeTargets.All); + static readonly AttributeUsageAttribute DefaultUsageAttribute = new AttributeUsageAttribute (AttributeTargets.All); static Assembly orig_sec_assembly; + public static readonly object[] EmptyObject = new object [0]; // non-null if named args present after Resolve () is called PropertyInfo [] prop_info_arr; @@ -104,13 +106,19 @@ namespace Mono.CSharp { object [] pos_values; static PtrHashtable usage_attr_cache = new PtrHashtable (); + + // Cache for parameter-less attributes + static PtrHashtable att_cache = new PtrHashtable (); - public Attribute (string target, Expression left_expr, string identifier, ArrayList args, Location loc, bool nameEscaped) + public Attribute (string target, Expression left_expr, string identifier, object[] args, Location loc, bool nameEscaped) { LeftExpr = left_expr; Identifier = identifier; Name = LeftExpr == null ? identifier : LeftExpr + "." + identifier; - Arguments = args; + if (args != null) { + PosArguments = (ArrayList)args [0]; + NamedArguments = (ArrayList)args [1]; + } Location = loc; ExplicitTarget = target; this.nameEscaped = nameEscaped; @@ -135,18 +143,12 @@ namespace Mono.CSharp { "attribute parameter type", name); } - static void Error_AttributeArgumentNotValid (string extra, Location loc) + public static void Error_AttributeArgumentNotValid (Location loc) { Report.Error (182, loc, "An attribute argument must be a constant expression, typeof " + - "expression or array creation expression" + extra); - } - - static void Error_AttributeArgumentNotValid (Location loc) - { - Error_AttributeArgumentNotValid ("", loc); - } - + "expression or array creation expression"); + } /// /// This is rather hack. We report many emit attribute error with same error to be compatible with @@ -255,41 +257,6 @@ namespace Mono.CSharp { return LeftExpr == null ? Identifier : LeftExpr.GetSignatureForError () + "." + Identifier; } - // - // Given an expression, if the expression is a valid attribute-argument-expression - // returns an object that can be used to encode it, or null on failure. - // - public static bool GetAttributeArgumentExpression (Expression e, Location loc, Type arg_type, out object result) - { - Constant constant = e as Constant; - if (constant != null) { - constant = constant.ToType (arg_type, loc); - if (constant == null) { - result = null; - return false; - } - result = constant.GetTypedValue (); - return true; - } else if (e is TypeOf) { - result = ((TypeOf) e).TypeArg; - return true; - } else if (e is ArrayCreation){ - result = ((ArrayCreation) e).EncodeAsAttribute (); - if (result != null) - return true; - } else if (e is EmptyCast) { - Expression child = ((EmptyCast)e).Child; - return GetAttributeArgumentExpression (child, loc, child.Type, out result); - } else if (e is As) { - As as_e = (As) e; - return GetAttributeArgumentExpression (as_e.Expr, loc, as_e.ProbeType.Type, out result); - } - - result = null; - Error_AttributeArgumentNotValid (loc); - return false; - } - bool IsValidArgumentType (Type t) { if (t.IsArray) @@ -302,9 +269,6 @@ namespace Mono.CSharp { t == TypeManager.type_type; } - // Cache for parameter-less attributes - static PtrHashtable att_cache = new PtrHashtable (); - public CustomAttributeBuilder Resolve () { if (resolve_error) @@ -328,7 +292,7 @@ namespace Mono.CSharp { AttributeTester.Report_ObsoleteMessage (obsolete_attr, TypeManager.CSharpName (Type), Location); } - if (Arguments == null) { + if (PosArguments == null && NamedArguments == null) { object o = att_cache [Type]; if (o != null) { resolve_error = false; @@ -336,118 +300,177 @@ namespace Mono.CSharp { } } - ConstructorInfo ctor = ResolveArguments (); + EmitContext ec = new EmitContext (owner.ResolveContext, owner.ResolveContext.DeclContainer, owner.ResolveContext.DeclContainer, + Location, null, null, owner.ResolveContext.DeclContainer.ModFlags, false); + + ConstructorInfo ctor = ResolveConstructor (ec); if (ctor == null) return null; CustomAttributeBuilder cb; try { - if (prop_info_arr != null || field_info_arr != null) { - cb = new CustomAttributeBuilder ( - ctor, pos_values, - prop_info_arr, prop_values_arr, - field_info_arr, field_values_arr); - } else { - cb = new CustomAttributeBuilder ( - ctor, pos_values); + if (NamedArguments == null) { + cb = new CustomAttributeBuilder (ctor, pos_values); if (pos_values.Length == 0) att_cache.Add (Type, cb); + + resolve_error = false; + return cb; + } + + if (!ResolveNamedArguments (ec)) { + return null; } + + cb = new CustomAttributeBuilder (ctor, pos_values, + prop_info_arr, prop_values_arr, + field_info_arr, field_values_arr); + + resolve_error = false; + return cb; } catch (Exception) { Error_AttributeArgumentNotValid (Location); return null; } - - resolve_error = false; - return cb; } - protected virtual ConstructorInfo ResolveArguments () + protected virtual ConstructorInfo ResolveConstructor (EmitContext ec) { - // Now we extract the positional and named arguments - - ArrayList pos_args = null; - ArrayList named_args = null; - int pos_arg_count = 0; - int named_arg_count = 0; - - if (Arguments != null) { - pos_args = (ArrayList) Arguments [0]; - if (pos_args != null) - pos_arg_count = pos_args.Count; - if (Arguments.Count > 1) { - named_args = (ArrayList) Arguments [1]; - named_arg_count = named_args.Count; + if (PosArguments != null) { + for (int i = 0; i < PosArguments.Count; i++) { + Argument a = (Argument) PosArguments [i]; + + if (!a.Resolve (ec, Location)) + return null; } } - pos_values = new object [pos_arg_count]; + Expression mg = Expression.MemberLookup (ec.ContainerType, + Type, ".ctor", MemberTypes.Constructor, + BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly, + Location); - // - // First process positional arguments - // + MethodBase constructor = Invocation.OverloadResolve ( + ec, (MethodGroupExpr) mg, PosArguments, false, Location); - EmitContext ec = new EmitContext (owner.ResolveContext, owner.ResolveContext.DeclContainer, owner.ResolveContext.DeclContainer, - Location, null, null, owner.ResolveContext.DeclContainer.ModFlags, false); + if (constructor == null) + return null; - int i; - for (i = 0; i < pos_arg_count; i++) { - Argument a = (Argument) pos_args [i]; - Expression e; + ObsoleteAttribute oa = AttributeTester.GetMethodObsoleteAttribute (constructor); + if (oa != null && !owner.ResolveContext.IsInObsoleteScope) { + AttributeTester.Report_ObsoleteMessage (oa, mg.GetSignatureForError (), mg.Location); + } - if (!a.Resolve (ec, Location)) - return null; + if (PosArguments == null) { + pos_values = EmptyObject; + return (ConstructorInfo)constructor; + } - e = a.Expr; + ParameterData pd = TypeManager.GetParameterData (constructor); - object val; - if (!GetAttributeArgumentExpression (e, Location, a.Type, out val)) - return null; + int pos_arg_count = PosArguments.Count; + int last_real_param = pd.Count; + + pos_values = new object [pos_arg_count]; - pos_values [i] = val; + if (pd.HasParams) { + // When the params is not filled we need to put one + if (last_real_param > pos_arg_count) { + object [] new_pos_values = new object [pos_arg_count + 1]; + pos_values.CopyTo (new_pos_values, 0); + new_pos_values [pos_arg_count] = new object [] {} ; + pos_values = new_pos_values; + } + last_real_param--; + } + + for (int j = 0; j < pos_arg_count; ++j) { + Argument a = (Argument) PosArguments [j]; - if (i == 0 && Type == TypeManager.attribute_usage_type && (int)val == 0) { - Report.Error (591, Location, "Invalid value for argument to 'System.AttributeUsage' attribute"); + if (!a.Expr.GetAttributableValue (out pos_values [j])) return null; + + if (TypeManager.IsPrimitiveType (a.Type) && a.Type != pos_values [j].GetType ()) { + bool fail; + // This can happen only for constants in same range + pos_values [j] = TypeManager.ChangeType (pos_values [j], a.Type, out fail); } + + if (j < last_real_param) + continue; + + if (j == last_real_param) { + object [] array = new object [pos_arg_count - last_real_param]; + array [0] = pos_values [j]; + pos_values [j] = array; + continue; + } + + object [] params_array = (object []) pos_values [last_real_param]; + params_array [j - last_real_param] = pos_values [j]; } - // - // Now process named arguments - // + // Adjust the size of the pos_values if it had params + if (last_real_param != pos_arg_count) { + object [] new_pos_values = new object [last_real_param + 1]; + Array.Copy (pos_values, new_pos_values, last_real_param + 1); + pos_values = new_pos_values; + } - ArrayList field_infos = null; - ArrayList prop_infos = null; - ArrayList field_values = null; - ArrayList prop_values = null; - Hashtable seen_names = null; + // Here we do the checks which should be done by corlib or by runtime. + // However Zoltan doesn't like it and every Mono compiler has to do it again. + + if (Type == TypeManager.guid_attr_type) { + try { + new Guid ((string)pos_values [0]); + } + catch (Exception e) { + Error_AttributeEmitError (e.Message); + return null; + } + } - if (named_arg_count > 0) { - field_infos = new ArrayList (4); - prop_infos = new ArrayList (4); - field_values = new ArrayList (4); - prop_values = new ArrayList (4); + if (Type == TypeManager.attribute_usage_type && (int)pos_values [0] == 0) { + Report.Error (591, Location, "Invalid value for argument to 'System.AttributeUsage' attribute"); + return null; + } - seen_names = new Hashtable(4); + if (Type == TypeManager.methodimpl_attr_type && pos_values.Length == 1 && + pd.ParameterType (0) == TypeManager.short_type && + !System.Enum.IsDefined (typeof (MethodImplOptions), pos_values [0].ToString ())) { + Error_AttributeEmitError ("Incorrect argument value."); + return null; } + + return (ConstructorInfo)constructor; + } + + protected virtual bool ResolveNamedArguments (EmitContext ec) + { + int named_arg_count = NamedArguments.Count; + + ArrayList field_infos = new ArrayList (named_arg_count); + ArrayList prop_infos = new ArrayList (named_arg_count); + ArrayList field_values = new ArrayList (named_arg_count); + ArrayList prop_values = new ArrayList (named_arg_count); + + ArrayList seen_names = new ArrayList(named_arg_count); - for (i = 0; i < named_arg_count; i++) { - DictionaryEntry de = (DictionaryEntry) named_args [i]; + foreach (DictionaryEntry de in NamedArguments) { string member_name = (string) de.Key; - Argument a = (Argument) de.Value; - Expression e; if (seen_names.Contains(member_name)) { Report.Error(643, Location, "'" + member_name + "' duplicate named attribute argument"); - return null; + return false; } - seen_names.Add(member_name, 1); - + seen_names.Add(member_name); + + Argument a = (Argument) de.Value; if (!a.Resolve (ec, Location)) - return null; + return false; Expression member = Expression.MemberLookup ( ec.ContainerType, Type, member_name, @@ -462,175 +485,103 @@ namespace Mono.CSharp { if (member != null) { Expression.ErrorIsInaccesible (Location, member.GetSignatureForError ()); - return null; + return false; } } if (member == null){ Report.Error (117, Location, "`{0}' does not contain a definition for `{1}'", TypeManager.CSharpName (Type), member_name); - return null; + return false; } if (!(member is PropertyExpr || member is FieldExpr)) { Error_InvalidNamedArgument (member_name); - return null; + return false; } - e = a.Expr; + ObsoleteAttribute obsolete_attr; + if (member is PropertyExpr) { - PropertyExpr pe = (PropertyExpr) member; - PropertyInfo pi = pe.PropertyInfo; + PropertyInfo pi = ((PropertyExpr) member).PropertyInfo; if (!pi.CanWrite || !pi.CanRead) { Report.SymbolRelatedToPreviousError (pi); Error_InvalidNamedArgument (member_name); - return null; + return false; } if (!IsValidArgumentType (pi.PropertyType)) { Report.SymbolRelatedToPreviousError (pi); Error_InvalidNamedAgrumentType (member_name); - return null; + return false; } + Expression e = Convert.ImplicitConversionRequired (ec, a.Expr, pi.PropertyType, a.Expr.Location); + if (e == null) + return false; + object value; - if (!GetAttributeArgumentExpression (e, Location, pi.PropertyType, out value)) - return null; + if (!e.GetAttributableValue (out value)) + return false; + + PropertyBase pb = TypeManager.GetProperty (pi); + if (pb != null) + obsolete_attr = pb.GetObsoleteAttribute (); + else + obsolete_attr = AttributeTester.GetMemberObsoleteAttribute (pi); prop_values.Add (value); prop_infos.Add (pi); - } else if (member is FieldExpr) { - FieldExpr fe = (FieldExpr) member; - FieldInfo fi = fe.FieldInfo; + } else { + FieldInfo fi = ((FieldExpr) member).FieldInfo; if (fi.IsInitOnly) { Error_InvalidNamedArgument (member_name); - return null; + return false; } if (!IsValidArgumentType (fi.FieldType)) { Report.SymbolRelatedToPreviousError (fi); Error_InvalidNamedAgrumentType (member_name); - return null; + return false; } + Expression e = Convert.ImplicitConversionRequired (ec, a.Expr, fi.FieldType, a.Expr.Location); + if (e == null) + return false; + object value; - if (!GetAttributeArgumentExpression (e, Location, fi.FieldType, out value)) - return null; + if (!e.GetAttributableValue (out value)) + return false; + + FieldBase fb = TypeManager.GetField (fi); + if (fb != null) + obsolete_attr = fb.GetObsoleteAttribute (); + else + obsolete_attr = AttributeTester.GetMemberObsoleteAttribute (fi); field_values.Add (value); field_infos.Add (fi); } - } - - Expression mg = Expression.MemberLookup (ec.ContainerType, - Type, ".ctor", MemberTypes.Constructor, - BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly, - Location); - - MethodBase constructor = Invocation.OverloadResolve ( - ec, (MethodGroupExpr) mg, pos_args, false, Location); - if (constructor == null) { - return null; - } - - - // Here we do the checks which should be done by corlib or by runtime. - // However Zoltan doesn't like it and every Mono compiler has to do it again. - - if (Type == TypeManager.guid_attr_type) { - try { - new Guid ((string)pos_values [0]); - } - catch (Exception e) { - Error_AttributeEmitError (e.Message); - return null; - } + if (obsolete_attr != null && !owner.ResolveContext.IsInObsoleteScope) + AttributeTester.Report_ObsoleteMessage (obsolete_attr, member.GetSignatureForError (), member.Location); } - if (Type == TypeManager.methodimpl_attr_type && - pos_values.Length == 1 && ((Argument)pos_args [0]).Type == TypeManager.short_type && - !System.Enum.IsDefined (typeof (MethodImplOptions), pos_values [0])) { - Error_AttributeEmitError ("Incorrect argument value."); - return null; - } + prop_info_arr = new PropertyInfo [prop_infos.Count]; + field_info_arr = new FieldInfo [field_infos.Count]; + field_values_arr = new object [field_values.Count]; + prop_values_arr = new object [prop_values.Count]; - // - // Now we perform some checks on the positional args as they - // cannot be null for a constructor which expects a parameter - // of type object - // + field_infos.CopyTo (field_info_arr, 0); + field_values.CopyTo (field_values_arr, 0); - ParameterData pd = TypeManager.GetParameterData (constructor); + prop_values.CopyTo (prop_values_arr, 0); + prop_infos.CopyTo (prop_info_arr, 0); - int last_real_param = pd.Count; - if (pd.HasParams) { - // When the params is not filled we need to put one - if (last_real_param > pos_arg_count) { - object [] new_pos_values = new object [pos_arg_count + 1]; - pos_values.CopyTo (new_pos_values, 0); - new_pos_values [pos_arg_count] = new object [] {} ; - pos_values = new_pos_values; - } - last_real_param--; - } - - for (int j = 0; j < pos_arg_count; ++j) { - Argument a = (Argument) pos_args [j]; - - if (a.Expr is NullLiteral && pd.ParameterType (j) == TypeManager.object_type) { - Error_AttributeArgumentNotValid (Location); - return null; - } - - object value = pos_values [j]; - if (value != null && a.Type != value.GetType () && TypeManager.IsPrimitiveType (a.Type)) { - bool fail; - pos_values [j] = TypeManager.ChangeType (value, a.Type, out fail); - if (fail) { - // TODO: Can failed ? - throw new NotImplementedException (); - } - } - - if (j < last_real_param) - continue; - - if (j == last_real_param) { - object [] array = new object [pos_arg_count - last_real_param]; - array [0] = pos_values [j]; - pos_values [j] = array; - continue; - } - - object [] params_array = (object []) pos_values [last_real_param]; - params_array [j - last_real_param] = pos_values [j]; - } - - // Adjust the size of the pos_values if it had params - if (last_real_param != pos_arg_count) { - object [] new_pos_values = new object [last_real_param + 1]; - Array.Copy (pos_values, new_pos_values, last_real_param + 1); - pos_values = new_pos_values; - } - - if (named_arg_count > 0) { - prop_info_arr = new PropertyInfo [prop_infos.Count]; - field_info_arr = new FieldInfo [field_infos.Count]; - field_values_arr = new object [field_values.Count]; - prop_values_arr = new object [prop_values.Count]; - - field_infos.CopyTo (field_info_arr, 0); - field_values.CopyTo (field_values_arr, 0); - - prop_values.CopyTo (prop_values_arr, 0); - prop_infos.CopyTo (prop_info_arr, 0); - } - - return (ConstructorInfo) constructor; + return true; } /// @@ -1174,12 +1125,8 @@ namespace Mono.CSharp { // Here we are testing attribute arguments for array usage (error 3016) if (owner.IsClsComplianceRequired ()) { - if (Arguments == null) - return; - - ArrayList pos_args = (ArrayList) Arguments [0]; - if (pos_args != null) { - foreach (Argument arg in pos_args) { + if (PosArguments != null) { + foreach (Argument arg in PosArguments) { // Type is undefined (was error 246) if (arg.Type == null) return; @@ -1191,11 +1138,10 @@ namespace Mono.CSharp { } } - if (Arguments.Count < 2) + if (NamedArguments == null) return; - ArrayList named_args = (ArrayList) Arguments [1]; - foreach (DictionaryEntry de in named_args) { + foreach (DictionaryEntry de in NamedArguments) { Argument arg = (Argument) de.Value; // Type is undefined (was error 246) @@ -1327,15 +1273,10 @@ namespace Mono.CSharp { private Expression GetValue () { - if ((Arguments == null) || (Arguments.Count < 1)) - return null; - ArrayList al = (ArrayList) Arguments [0]; - if ((al == null) || (al.Count < 1)) - return null; - Argument arg = (Argument) al [0]; - if ((arg == null) || (arg.Expr == null)) + if (PosArguments == null || PosArguments.Count < 1) return null; - return arg.Expr; + + return ((Argument) PosArguments [0]).Expr; } public string GetString () @@ -1365,7 +1306,7 @@ namespace Mono.CSharp { public readonly NamespaceEntry ns; public GlobalAttribute (NamespaceEntry ns, string target, - Expression left_expr, string identifier, ArrayList args, Location loc, bool nameEscaped): + Expression left_expr, string identifier, object[] args, Location loc, bool nameEscaped): base (target, left_expr, identifier, args, loc, nameEscaped) { this.ns = ns; @@ -1414,11 +1355,22 @@ namespace Mono.CSharp { } } - protected override ConstructorInfo ResolveArguments () + protected override ConstructorInfo ResolveConstructor (EmitContext ec) + { + try { + Enter (); + return base.ResolveConstructor (ec); + } + finally { + Leave (); + } + } + + protected override bool ResolveNamedArguments (EmitContext ec) { try { Enter (); - return base.ResolveArguments (); + return base.ResolveNamedArguments (ec); } finally { Leave (); diff --git a/mcs/mcs/cfold.cs b/mcs/mcs/cfold.cs index 303002901a6..aba3ad37c48 100644 --- a/mcs/mcs/cfold.cs +++ b/mcs/mcs/cfold.cs @@ -550,8 +550,14 @@ namespace Mono.CSharp { Error_CompileTimeOverflow (loc); } - if (wrap_as != null) - return result.TryReduce (ec, wrap_as, loc); + if (wrap_as != null) { + try { + return result.TryReduce (ec, wrap_as, loc); + } + catch (OverflowException) { + return null; + } + } else return result; @@ -682,8 +688,14 @@ namespace Mono.CSharp { Error_CompileTimeOverflow (loc); } - if (wrap_as != null) - return result.TryReduce (ec, wrap_as, loc); + if (wrap_as != null) { + try { + return result.TryReduce (ec, wrap_as, loc); + } + catch (OverflowException) { + return null; + } + } return result; diff --git a/mcs/mcs/class.cs b/mcs/mcs/class.cs index 514388e8a2f..d98381da6c6 100644 --- a/mcs/mcs/class.cs +++ b/mcs/mcs/class.cs @@ -6194,6 +6194,7 @@ namespace Mono.CSharp { if (!Set.IsDummy) PropertyBuilder.SetSetMethod (SetBuilder); + TypeManager.RegisterProperty (PropertyBuilder, this); return true; } } diff --git a/mcs/mcs/constant.cs b/mcs/mcs/constant.cs index 76c2c5667a8..0ccf630311d 100644 --- a/mcs/mcs/constant.cs +++ b/mcs/mcs/constant.cs @@ -39,6 +39,12 @@ namespace Mono.CSharp { return this.GetType ().Name + " (" + AsString () + ")"; } + public override bool GetAttributableValue (out object value) + { + value = GetTypedValue (); + return true; + } + /// /// This is used to obtain the actual value of the literal /// cast into an object. @@ -233,6 +239,10 @@ namespace Mono.CSharp { throw new OverflowException (); } + /// + /// Maybe ConvertTo name is better. It tries to convert `this' constant to target_type. + /// It throws OverflowException + /// public abstract Constant Reduce (EmitContext ec, Type target_type); /// @@ -244,11 +254,9 @@ namespace Mono.CSharp { return TryReduce (ec, target_type); } catch (OverflowException) { - if (ec.ConstantCheckState) { - Report.Error (221, loc, "Constant value `{0}' cannot be converted to a `{1}' (use `unchecked' syntax to override)", - GetValue ().ToString (), TypeManager.CSharpName (target_type)); - } - return null; + Report.Error (221, loc, "Constant value `{0}' cannot be converted to a `{1}' (use `unchecked' syntax to override)", + GetValue ().ToString (), TypeManager.CSharpName (target_type)); + throw; } } diff --git a/mcs/mcs/cs-parser.jay b/mcs/mcs/cs-parser.jay index 2b709ec23bb..3b1c82ec761 100644 --- a/mcs/mcs/cs-parser.jay +++ b/mcs/mcs/cs-parser.jay @@ -620,7 +620,7 @@ attribute : attribute_name opt_attribute_arguments { MemberName mname = (MemberName) $1; - ArrayList arguments = (ArrayList) $2; + object[] arguments = (object[]) $2; MemberName left = mname.Left; string identifier = mname.Name; @@ -654,29 +654,18 @@ attribute_arguments if ($1 == null) $$ = null; else { - ArrayList args = new ArrayList (4); - args.Add ($1); - - $$ = args; + $$ = new object [] { $1, null }; } } - | positional_argument_list COMMA named_argument_list + | positional_argument_list COMMA named_argument_list { - ArrayList args = new ArrayList (4); - args.Add ($1); - args.Add ($3); - - $$ = args; + $$ = new object[] { $1, $3 }; } - | named_argument_list + | named_argument_list { - ArrayList args = new ArrayList (4); - args.Add (null); - args.Add ($1); - - $$ = args; + $$ = new object [] { null, $1 }; } - ; + ; opt_positional_argument_list diff --git a/mcs/mcs/ecore.cs b/mcs/mcs/ecore.cs index dc2324a363b..8b3e61aa012 100644 --- a/mcs/mcs/ecore.cs +++ b/mcs/mcs/ecore.cs @@ -137,6 +137,13 @@ namespace Mono.CSharp { // Not nice but we have broken hierarchy public virtual void CheckMarshallByRefAccess (Type container) {} + public virtual bool GetAttributableValue (out object value) + { + Attribute.Error_AttributeArgumentNotValid (loc); + value = null; + return false; + } + public virtual string GetSignatureForError () { return TypeManager.CSharpName (type); @@ -315,28 +322,29 @@ namespace Mono.CSharp { TypeManager.CSharpName (type), name); } - ResolveFlags ExprClassToResolveFlags () + ResolveFlags ExprClassToResolveFlags { - switch (eclass) { - case ExprClass.Type: - case ExprClass.Namespace: - return ResolveFlags.Type; + get { + switch (eclass) { + case ExprClass.Type: + case ExprClass.Namespace: + return ResolveFlags.Type; - case ExprClass.MethodGroup: - return ResolveFlags.MethodGroup; + case ExprClass.MethodGroup: + return ResolveFlags.MethodGroup; - case ExprClass.Value: - case ExprClass.Variable: - case ExprClass.PropertyAccess: - case ExprClass.EventAccess: - case ExprClass.IndexerAccess: - return ResolveFlags.VariableOrValue; + case ExprClass.Value: + case ExprClass.Variable: + case ExprClass.PropertyAccess: + case ExprClass.EventAccess: + case ExprClass.IndexerAccess: + return ResolveFlags.VariableOrValue; - default: - throw new Exception ("Expression " + GetType () + - " ExprClass is Invalid after resolve"); + default: + throw new Exception ("Expression " + GetType () + + " ExprClass is Invalid after resolve"); + } } - } /// @@ -360,10 +368,10 @@ namespace Mono.CSharp { ec.OmitStructFlowAnalysis = true; Expression e; - bool intermediate = (flags & ResolveFlags.Intermediate) == ResolveFlags.Intermediate; - if (this is SimpleName) + if (this is SimpleName) { + bool intermediate = (flags & ResolveFlags.Intermediate) == ResolveFlags.Intermediate; e = ((SimpleName) this).DoResolve (ec, intermediate); - + } else e = DoResolve (ec); @@ -373,7 +381,7 @@ namespace Mono.CSharp { if (e == null) return null; - if ((flags & e.ExprClassToResolveFlags ()) == 0) { + if ((flags & e.ExprClassToResolveFlags) == 0) { e.Error_UnexpectedKind (flags, loc); return null; } @@ -1123,7 +1131,7 @@ namespace Mono.CSharp { /// /// public class EmptyCast : Expression { - protected Expression child; + protected readonly Expression child; public Expression Child { get { @@ -1151,6 +1159,12 @@ namespace Mono.CSharp { { child.Emit (ec); } + + public override bool GetAttributableValue (out object value) + { + return child.GetAttributableValue (out value); + } + } /// /// This is a numeric cast to a Decimal @@ -3194,6 +3208,7 @@ namespace Mono.CSharp { // We also perform the permission checking here, as the PropertyInfo does not // hold the information for the accessibility of its setter/getter // + // TODO: can use TypeManager.GetProperty to boost performance void ResolveAccessors (Type containerType) { FindAccessors (containerType); diff --git a/mcs/mcs/expression.cs b/mcs/mcs/expression.cs index 432c83d840c..9005f6641e6 100644 --- a/mcs/mcs/expression.cs +++ b/mcs/mcs/expression.cs @@ -1252,7 +1252,12 @@ namespace Mono.CSharp { Error_CannotConvertType (etype, probe_type, loc); return null; - } + } + + public override bool GetAttributableValue (out object value) + { + return expr.GetAttributableValue (out value); + } } /// @@ -1327,9 +1332,14 @@ namespace Mono.CSharp { Constant c = expr as Constant; if (c != null) { - c = c.TryReduce (ec, type, loc); - if (c != null) - return c; + try { + c = c.TryReduce (ec, type, loc); + if (c != null) + return c; + } + catch (OverflowException) { + return null; + } } if (type.IsPointer && !ec.InUnsafe) { @@ -6014,10 +6024,7 @@ namespace Mono.CSharp { public bool ValidateInitializers (EmitContext ec, Type array_type) { if (initializers == null) { - if (expect_initializers) - return false; - else - return true; + return !expect_initializers; } if (underlying_type == null) @@ -6030,17 +6037,12 @@ namespace Mono.CSharp { array_data = new ArrayList (); bounds = new Hashtable (); - bool ret; - if (arguments != null) { - ret = CheckIndices (ec, initializers, 0, true); - return ret; + return CheckIndices (ec, initializers, 0, true); } else { arguments = new ArrayList (); - ret = CheckIndices (ec, initializers, 0, false); - - if (!ret) + if (!CheckIndices (ec, initializers, 0, false)) return false; UpdateIndices (ec); @@ -6050,7 +6052,7 @@ namespace Mono.CSharp { return false; } - return ret; + return true; } } @@ -6508,32 +6510,33 @@ namespace Mono.CSharp { } } - public object EncodeAsAttribute () + public override bool GetAttributableValue (out object value) { if (!is_one_dimensional){ - Report.Error (-211, Location, "attribute can not encode multi-dimensional arrays"); - return null; +// Report.Error (-211, Location, "attribute can not encode multi-dimensional arrays"); + return base.GetAttributableValue (out value); } - if (array_data == null){ - Report.Error (-212, Location, "array should be initialized when passing it to an attribute"); - return null; + if (array_data == null) { + Constant c = (Constant)((Argument)arguments [0]).Expr; + if (c.IsDefaultValue) { + value = new object [0]; + return true; + } +// Report.Error (-212, Location, "array should be initialized when passing it to an attribute"); + return base.GetAttributableValue (out value); } object [] ret = new object [array_data.Count]; - int i = 0; - foreach (Expression e in array_data){ - object v; - - if (e is NullLiteral) - v = null; - else { - if (!Attribute.GetAttributeArgumentExpression (e, Location, array_element_type, out v)) - return null; + for (int i = 0; i < ret.Length; ++i) + { + if (!((Expression)array_data [i]).GetAttributableValue (out ret [i])) { + value = null; + return false; } - ret [i++] = v; } - return ret; + value = ret; + return true; } } @@ -6794,7 +6797,7 @@ namespace Mono.CSharp { /// Implements the typeof operator /// public class TypeOf : Expression { - public Expression QueriedType; + readonly Expression QueriedType; protected Type typearg; public TypeOf (Expression queried_type, Location l) @@ -6834,8 +6837,10 @@ namespace Mono.CSharp { ec.ig.Emit (OpCodes.Call, TypeManager.system_type_get_type_from_handle); } - public Type TypeArg { - get { return typearg; } + public override bool GetAttributableValue (out object value) + { + value = typearg; + return true; } } diff --git a/mcs/mcs/typemanager.cs b/mcs/mcs/typemanager.cs index f132af41948..e797fd0c0e2 100644 --- a/mcs/mcs/typemanager.cs +++ b/mcs/mcs/typemanager.cs @@ -244,7 +244,9 @@ public class TypeManager { public static Hashtable AllClsTopLevelTypes; static Hashtable fieldbuilders_to_fields; + static Hashtable propertybuilder_to_property; static Hashtable fields; + static Hashtable events; struct Signature { public string name; @@ -266,6 +268,7 @@ public class TypeManager { events = null; priv_fields_events = null; type_hash = null; + propertybuilder_to_property = null; TypeHandle.CleanUp (); } @@ -360,6 +363,7 @@ public class TypeManager { builder_to_ifaces = new PtrHashtable (); fieldbuilders_to_fields = new Hashtable (); + propertybuilder_to_property = new Hashtable (); fields = new Hashtable (); type_hash = new DoubleHash (); @@ -1553,6 +1557,16 @@ public class TypeManager { return (IConstant)fields [fb]; } + public static void RegisterProperty (PropertyInfo pi, PropertyBase pb) + { + propertybuilder_to_property.Add (pi, pb); + } + + public static PropertyBase GetProperty (PropertyInfo pi) + { + return (PropertyBase)propertybuilder_to_property [pi]; + } + static public bool RegisterFieldBase (FieldBuilder fb, FieldBase f) { if (fieldbuilders_to_fields.Contains (fb)) @@ -1572,8 +1586,6 @@ public class TypeManager { return (FieldBase) fieldbuilders_to_fields [fb]; } - static Hashtable events; - static public void RegisterEvent (MyEventBuilder eb, MethodBase add, MethodBase remove) { if (events == null) -- cgit v1.2.3 From 495b44170fd02e82cfefb985128218ea61758e38 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Mon, 27 Feb 2006 22:46:25 +0000 Subject: 2006-02-27 Marek Safar * test-492.cs: Another attribute tests. svn path=/trunk/mcs/; revision=57359 --- mcs/tests/ChangeLog | 4 ++++ mcs/tests/known-issues-gmcs | 1 + mcs/tests/test-492.cs | 53 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 mcs/tests/test-492.cs (limited to 'mcs') diff --git a/mcs/tests/ChangeLog b/mcs/tests/ChangeLog index 2c63ebabb8c..edfa77218f2 100644 --- a/mcs/tests/ChangeLog +++ b/mcs/tests/ChangeLog @@ -1,3 +1,7 @@ +2006-02-27 Marek Safar + + * test-492.cs: Another attribute tests. + 2006-02-14 Martin Baulig * known-issues-gmcs: Add test-473.cs. diff --git a/mcs/tests/known-issues-gmcs b/mcs/tests/known-issues-gmcs index 8814f0419fc..91ac1488ade 100644 --- a/mcs/tests/known-issues-gmcs +++ b/mcs/tests/known-issues-gmcs @@ -15,6 +15,7 @@ test-cls-01.cs test-partial-07.cs test-partial-11.cs test-partial-12.cs +test-492.cs test-473.cs diff --git a/mcs/tests/test-492.cs b/mcs/tests/test-492.cs new file mode 100644 index 00000000000..45ed1bdbfde --- /dev/null +++ b/mcs/tests/test-492.cs @@ -0,0 +1,53 @@ +using System; +using System.Reflection; + +namespace Test { + [AttributeUsage (AttributeTargets.All, AllowMultiple = true)] + public class My1Attribute : Attribute + { + public My1Attribute (object o) + { + if (o != null) + throw new ApplicationException (); + } + } + + public class My2Attribute : Attribute + { + public My2Attribute (string[] s) + { + if (s.Length != 0) + throw new ApplicationException (); + } + } + + public class My3Attribute : Attribute + { + public My3Attribute (byte b) + { + if (b != 0xFF) + throw new ApplicationException (); + } + } + + + [My3(unchecked((byte)-1))] + [My1((object)null)] + [My1(null)] + [My2(new string[0])] + public class Test { + static public int Main() { + System.Reflection.MemberInfo info = typeof (Test); + object[] attributes = info.GetCustomAttributes (false); + + if (attributes.Length != 4) + return 1; + + for (int i = 0; i < attributes.Length; i ++) { + Console.WriteLine (attributes [i]); + } + + return 0; + } + } +} -- cgit v1.2.3 From 9a948a55e1b200698edc92e1a3ffaeb4fe1a351a Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Mon, 27 Feb 2006 22:48:30 +0000 Subject: 6 new tests. svn path=/trunk/mcs/; revision=57360 --- mcs/errors/cs0029-2.cs | 15 +++++++++++++++ mcs/errors/cs0037-6.cs | 15 +++++++++++++++ mcs/errors/cs0221-5.cs | 12 ++++++++++++ mcs/errors/cs0619-47.cs | 13 +++++++++++++ mcs/errors/cs0619-48.cs | 15 +++++++++++++++ mcs/errors/cs0619-49.cs | 14 ++++++++++++++ 6 files changed, 84 insertions(+) create mode 100644 mcs/errors/cs0029-2.cs create mode 100644 mcs/errors/cs0037-6.cs create mode 100644 mcs/errors/cs0221-5.cs create mode 100644 mcs/errors/cs0619-47.cs create mode 100644 mcs/errors/cs0619-48.cs create mode 100644 mcs/errors/cs0619-49.cs (limited to 'mcs') diff --git a/mcs/errors/cs0029-2.cs b/mcs/errors/cs0029-2.cs new file mode 100644 index 00000000000..118d7818bd1 --- /dev/null +++ b/mcs/errors/cs0029-2.cs @@ -0,0 +1,15 @@ +// cs0029-2.cs: Cannot implicitly convert type `string' to `double' +// Line: 11 + +using System; + +public sealed class BoundAttribute : System.Attribute +{ + public double D; +} + +class C +{ + [Bound (D = "Dude!")] + double d2; +} \ No newline at end of file diff --git a/mcs/errors/cs0037-6.cs b/mcs/errors/cs0037-6.cs new file mode 100644 index 00000000000..4563ed13adf --- /dev/null +++ b/mcs/errors/cs0037-6.cs @@ -0,0 +1,15 @@ +// cs0037.cs: Cannot convert null to `bool' because it is a value type +// Line: 13 + +using System; + +public sealed class BoundAttribute : System.Attribute +{ + public bool Dec { set { } get { return false; } } +} + +class C +{ + [Bound (Dec = null)] + double d2; +} \ No newline at end of file diff --git a/mcs/errors/cs0221-5.cs b/mcs/errors/cs0221-5.cs new file mode 100644 index 00000000000..d30b25fa82e --- /dev/null +++ b/mcs/errors/cs0221-5.cs @@ -0,0 +1,12 @@ +// cs0221.cs: Constant value `-1' cannot be converted to a `byte' (use `unchecked' syntax to override) +// Line: 11 + +using System; + +public class My3Attribute : Attribute +{ + public My3Attribute (byte b) {} +} + +[My3((byte)-1)] +public class Test { } \ No newline at end of file diff --git a/mcs/errors/cs0619-47.cs b/mcs/errors/cs0619-47.cs new file mode 100644 index 00000000000..32c6fc9a875 --- /dev/null +++ b/mcs/errors/cs0619-47.cs @@ -0,0 +1,13 @@ +// cs0619-47.cs: `A.Field' is obsolete: `!!!' +// Line: 11 + +class A: System.Attribute +{ + [System.Obsolete("!!!", true)] + public int Field; +} + +class Obsolete { + [A(Field=2)] + public int Foo; +} diff --git a/mcs/errors/cs0619-48.cs b/mcs/errors/cs0619-48.cs new file mode 100644 index 00000000000..3c0f15168bb --- /dev/null +++ b/mcs/errors/cs0619-48.cs @@ -0,0 +1,15 @@ +// cs0619-48.cs: `A.Prop' is obsolete: `!!!' +// Line: 13 + +class A: System.Attribute +{ + [System.Obsolete("!!!", true)] + public string Prop { + set { } + get { return ""; } + } +} + +[A(Prop="System.String.Empty")] +class Obsolete { +} diff --git a/mcs/errors/cs0619-49.cs b/mcs/errors/cs0619-49.cs new file mode 100644 index 00000000000..d719f512c5c --- /dev/null +++ b/mcs/errors/cs0619-49.cs @@ -0,0 +1,14 @@ +// cs0619-49.cs: `A.A(string[])' is obsolete: `!!!' +// Line: 12 + +class A: System.Attribute +{ + [System.Obsolete("!!!", true)] + public A (string[] s) + { + } +} + +[A(new string[0])] +class Obsolete { +} -- cgit v1.2.3 From 9fb0a744993baf9732f235342f59c7ddda89e97e Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Mon, 27 Feb 2006 23:30:46 +0000 Subject: * SizeGrip.cs: Paint the background color before painting the * grip so things look right. svn path=/trunk/mcs/; revision=57361 --- mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog | 5 +++++ mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeGrip.cs | 1 + 2 files changed, 6 insertions(+) (limited to 'mcs') diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index 08b274fdbfe..3c5e30262bf 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -1,3 +1,8 @@ +2006-02-27 Jackson Harper + + * SizeGrip.cs: Paint the background color before painting the grip + so things look right. + 2006-02-27 Mike Kestner * ListView.cs: diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeGrip.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeGrip.cs index 39219ebc5a7..c2056a6844f 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeGrip.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SizeGrip.cs @@ -63,6 +63,7 @@ namespace System.Windows.Forms { #region Methods protected override void OnPaint (PaintEventArgs pe) { if (redraw && show_grip) { + pe.Graphics.FillRectangle (new SolidBrush (ThemeEngine.Current.ColorControl), ClientRectangle); ControlPaint.DrawSizeGrip (pe.Graphics, BackColor, ClientRectangle); } base.OnPaint (pe); -- cgit v1.2.3 From ba62056db0634deb22c521e89307459987beedb9 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Mon, 27 Feb 2006 23:42:10 +0000 Subject: * MdiClient.cs: Add the sizegrip when both scrollbars are used. svn path=/trunk/mcs/; revision=57362 --- .../System.Windows.Forms/ChangeLog | 1 + .../System.Windows.Forms/MdiClient.cs | 24 ++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'mcs') diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index 3c5e30262bf..304dceb8b6b 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -2,6 +2,7 @@ * SizeGrip.cs: Paint the background color before painting the grip so things look right. + * MdiClient.cs: Add the sizegrip when both scrollbars are used. 2006-02-27 Mike Kestner diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs index 8c1b7e76895..9dd830b8e1a 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs @@ -39,6 +39,7 @@ namespace System.Windows.Forms { private Form active; private HScrollBar hbar; private VScrollBar vbar; + private SizeGrip sizegrip; #endregion // Local Variables @@ -153,8 +154,6 @@ namespace System.Windows.Forms { internal void EnsureScrollBars (int right, int bottom) { - Console.WriteLine ("Ensuring scrollbars"); - int width = Width; int height = Height; @@ -213,8 +212,6 @@ namespace System.Windows.Forms { private void SizeScrollBars () { - Console.WriteLine ("sizing the scrollbars"); - bool hbar_required = false; bool vbar_required = false; @@ -287,6 +284,19 @@ namespace System.Windows.Forms { CalcVBar (bottom, hbar != null && hbar.Visible); } else if (vbar != null) vbar.Visible = false; + + if (need_hbar && need_vbar) { + if (sizegrip == null) { + sizegrip = new SizeGrip (); + Controls.AddImplicit (sizegrip); + } + sizegrip.Location = new Point (hbar.Right, vbar.Bottom); + sizegrip.Width = vbar.Width; + sizegrip.Height = hbar.Height; + sizegrip.Visible = true; + } else if (sizegrip != null) { + sizegrip.Visible = false; + } } private void CalcHBar (int right, bool vert_vis) @@ -324,6 +334,12 @@ namespace System.Windows.Forms { { form.BringToFront (); active = form; + + foreach (Form child in Controls) { + if (child == form) + continue; + // TODO: We need to repaint the decorations here + } } internal int ChildrenCreated { -- cgit v1.2.3 From 1b88f8ea789ac56f768d9964e64dfd528f524c14 Mon Sep 17 00:00:00 2001 From: Peter Dennis Bartok Date: Tue, 28 Feb 2006 00:09:01 +0000 Subject: 2006-02-27 Peter Dennis Bartok * Control.cs: Separated special WM_SYSKEYUP keyboard handling. That way it's easier for a child control to handle the other messages without having to duplicate the special functionality * TextBoxBase.cs - WndProc: Removed calling base handler for WM_KEYDOWN and added code to handle processing the key ourselves, in order to get access to the result of KeyEventArgs.Handled. We now only call ProcessKey if they key hasn't been handled already. Fixes #77526. - set_Text: If null or empty string is given, just clear the document. Fixes part of #77526 svn path=/trunk/mcs/; revision=57363 --- .../System.Windows.Forms/ChangeLog | 13 ++++++++++++ .../System.Windows.Forms/Control.cs | 23 +++++++++++++++------- .../System.Windows.Forms/TextBoxBase.cs | 11 ++++++++--- 3 files changed, 37 insertions(+), 10 deletions(-) (limited to 'mcs') diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index 304dceb8b6b..835bb1f15cd 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -1,3 +1,16 @@ +2006-02-27 Peter Dennis Bartok + + * Control.cs: Separated special WM_SYSKEYUP keyboard handling. That way + it's easier for a child control to handle the other messages without + having to duplicate the special functionality + * TextBoxBase.cs + - WndProc: Removed calling base handler for WM_KEYDOWN and added + code to handle processing the key ourselves, in order to get + access to the result of KeyEventArgs.Handled. We now only call + ProcessKey if they key hasn't been handled already. Fixes #77526. + - set_Text: If null or empty string is given, just clear the + document. Fixes part of #77526 + 2006-02-27 Jackson Harper * SizeGrip.cs: Paint the background color before painting the grip diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs index 82a058af643..dfb50eaa5ed 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs @@ -3823,17 +3823,13 @@ namespace System.Windows.Forms return; } - case Msg.WM_SYSKEYDOWN: - case Msg.WM_KEYDOWN: - case Msg.WM_SYSKEYUP: - case Msg.WM_KEYUP: - case Msg.WM_SYSCHAR: - case Msg.WM_CHAR: { + case Msg.WM_SYSKEYUP: { if (ProcessKeyMessage(ref m)) { + m.Result = IntPtr.Zero; return; } - if ((m.Msg == (int)Msg.WM_SYSKEYUP) && ((m.WParam.ToInt32() & (int)Keys.KeyCode) == (int)Keys.Menu)) { + if ((m.WParam.ToInt32() & (int)Keys.KeyCode) == (int)Keys.Menu) { Form form; form = FindForm(); @@ -3846,6 +3842,19 @@ namespace System.Windows.Forms return; } + case Msg.WM_SYSKEYDOWN: + case Msg.WM_KEYDOWN: + case Msg.WM_KEYUP: + case Msg.WM_SYSCHAR: + case Msg.WM_CHAR: { + if (ProcessKeyMessage(ref m)) { + m.Result = IntPtr.Zero; + return; + } + DefWndProc (ref m); + return; + } + case Msg.WM_HELP: { Point mouse_pos; if (m.LParam != IntPtr.Zero) { diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs index bf884756d6d..a7f80416f8a 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs @@ -474,7 +474,7 @@ namespace System.Windows.Forms { return; } - if (value != null) { + if ((value != null) && (value != "")) { Line line; if (multiline) { @@ -504,6 +504,8 @@ namespace System.Windows.Forms { document.SetSelectionEnd(line, value.Length); document.PositionCaret(line, value.Length); } + } else { + document.Empty(); } base.Text = value; // Not needed, base.Text already fires it @@ -1128,8 +1130,11 @@ namespace System.Windows.Forms { } case Msg.WM_KEYDOWN: { - base.WndProc(ref m); - ProcessKey((Keys)m.WParam.ToInt32() | XplatUI.State.ModifierKeys); + if (ProcessKeyMessage(ref m) || ProcessKey((Keys)m.WParam.ToInt32() | XplatUI.State.ModifierKeys)) { + m.Result = IntPtr.Zero; + return; + } + DefWndProc (ref m); return; } -- cgit v1.2.3 From e06fd0b53d69263f0568b0ff73c31637f76525c5 Mon Sep 17 00:00:00 2001 From: Peter Dennis Bartok Date: Tue, 28 Feb 2006 01:40:04 +0000 Subject: 2006-02-27 Peter Dennis Bartok * TextControl.cs: Added property and implemented means to allow disabling recalculation of a document (can be used to speed up multiple inserts and is needed to make RTF inserts predictable, see bug #77659) * RichTextBox.cs: Using the new NoRecalc property of Document to keep x/y insert locations predictable. Also makes it faster inserting large chunks of RTF svn path=/trunk/mcs/; revision=57366 --- .../System.Windows.Forms/ChangeLog | 10 +++++ .../System.Windows.Forms/RichTextBox.cs | 4 ++ .../System.Windows.Forms/TextControl.cs | 52 ++++++++++++++++++++++ 3 files changed, 66 insertions(+) (limited to 'mcs') diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index 835bb1f15cd..9e7f3a5d6ba 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -1,3 +1,13 @@ +2006-02-27 Peter Dennis Bartok + + * TextControl.cs: Added property and implemented means to allow + disabling recalculation of a document (can be used to speed up + multiple inserts and is needed to make RTF inserts predictable, see + bug #77659) + * RichTextBox.cs: Using the new NoRecalc property of Document to + keep x/y insert locations predictable. Also makes it faster inserting + large chunks of RTF + 2006-02-27 Peter Dennis Bartok * Control.cs: Separated special WM_SYSKEYUP keyboard handling. That way diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs index 6662c87d5dd..1fc221f6bc4 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs @@ -1352,6 +1352,8 @@ namespace System.Windows.Forms { rtf_text_map = new RTF.TextMap(); RTF.TextMap.SetupStandardTable(rtf_text_map.Table); + document.NoRecalc = true; + try { rtf.Read(); // That's it FlushText(rtf, false); @@ -1366,6 +1368,8 @@ namespace System.Windows.Forms { to_y = rtf_cursor_y; document.RecalculateDocument(CreateGraphics(), cursor_y, document.Lines, false); + document.NoRecalc = false; + document.Invalidate(document.GetLine(cursor_y), 0, document.GetLine(document.Lines), -1); } diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs index 69a447c6144..98960cb1c0a 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs @@ -726,6 +726,12 @@ namespace System.Windows.Forms { private bool calc_pass; private int char_count; + private bool no_recalc; + private bool recalc_pending; + private int recalc_start; + private int recalc_end; + private bool recalc_optimize; + internal bool multiline; internal bool wrap; @@ -763,6 +769,8 @@ namespace System.Windows.Forms { multiline = true; password_char = ""; calc_pass = false; + no_recalc = false; + recalc_pending = false; // Tree related stuff sentinel = new Line(); @@ -908,6 +916,22 @@ namespace System.Windows.Forms { } } + ///Setting NoRecalc to true will prevent the document from being recalculated. + ///This ensures that coordinates of added text are predictable after adding the text even with wrapped view + internal bool NoRecalc { + get { + return no_recalc; + } + + set { + no_recalc = value; + if (!no_recalc && recalc_pending) { + RecalculateDocument(owner.CreateGraphics(), recalc_start, recalc_end, recalc_optimize); + recalc_pending = false; + } + } + } + internal int ViewPortY { get { return viewport_y; @@ -1247,6 +1271,14 @@ namespace System.Windows.Forms { return; } + if (no_recalc) { + recalc_start = line.line_no; + recalc_end = line.line_no; + recalc_optimize = true; + recalc_pending = true; + return; + } + if (RecalculateDocument(owner.CreateGraphics(), line.line_no, line.line_no, true)) { // Lineheight changed, invalidate the rest of the document if ((line.Y - viewport_y) >=0 ) { @@ -1264,6 +1296,18 @@ namespace System.Windows.Forms { // Update display from line, down line_count lines; pos is unused, but required for the signature internal void UpdateView(Line line, int line_count, int pos) { + if (!owner.IsHandleCreated) { + return; + } + + if (no_recalc) { + recalc_start = line.line_no; + recalc_end = line.line_no + line_count - 1; + recalc_optimize = true; + recalc_pending = true; + return; + } + if (RecalculateDocument(owner.CreateGraphics(), line.line_no, line.line_no + line_count - 1, true)) { // Lineheight changed, invalidate the rest of the document if ((line.Y - viewport_y) >=0 ) { @@ -3442,6 +3486,14 @@ namespace System.Windows.Forms { bool changed; int shift; + if (no_recalc) { + recalc_pending = true; + recalc_start = start; + recalc_end = end; + recalc_optimize = optimize; + return false; + } + Y = GetLine(start).Y; line_no = start; new_width = 0; -- cgit v1.2.3 From 5295cd8a570b7ca0f8ae6468cd444434f6be2696 Mon Sep 17 00:00:00 2001 From: Peter Dennis Bartok Date: Tue, 28 Feb 2006 02:14:39 +0000 Subject: 2006-02-27 Peter Dennis Bartok * TextControl.cs: - InsertRTFFromStream: Added 'number of characters inserted' argument - set_SelectedRTF: Now using the number of characters to calculate the new location for the selection and cursor (x/y cannot be used due to potentially already wrapped text) svn path=/trunk/mcs/; revision=57367 --- .../System.Windows.Forms/ChangeLog | 8 ++++++++ .../System.Windows.Forms/RichTextBox.cs | 23 ++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) (limited to 'mcs') diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index 9e7f3a5d6ba..8a3faaaaded 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -1,3 +1,11 @@ +2006-02-27 Peter Dennis Bartok + + * TextControl.cs: + - InsertRTFFromStream: Added 'number of characters inserted' argument + - set_SelectedRTF: Now using the number of characters to calculate + the new location for the selection and cursor (x/y cannot be used + due to potentially already wrapped text) + 2006-02-27 Peter Dennis Bartok * TextControl.cs: Added property and implemented means to allow diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs index 1fc221f6bc4..f4e18289edd 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs @@ -57,6 +57,7 @@ namespace System.Windows.Forms { private HorizontalAlignment rtf_rtfalign; private int rtf_cursor_x; private int rtf_cursor_y; + private int rtf_chars; #endregion // Local Variables #region Public Constructors @@ -305,19 +306,24 @@ namespace System.Windows.Forms { MemoryStream data; int x; int y; + int sel_start; + int chars; Line line; + LineTag tag; if (document.selection_visible) { document.ReplaceSelection(""); } + sel_start = document.LineTagToCharIndex(document.selection_start.line, document.selection_start.pos); + data = new MemoryStream(Encoding.ASCII.GetBytes(value), false); - InsertRTFFromStream(data, document.selection_start.pos, document.selection_start.line.line_no, out x, out y); + InsertRTFFromStream(data, document.selection_start.pos, document.selection_start.line.line_no, out x, out y, out chars); data.Close(); - line = document.GetLine(y); - document.SetSelection(document.GetLine(y), x); - document.PositionCaret(line, x); + document.CharIndexToLineTag(sel_start + chars + (y - document.selection_start.line.line_no) * 2, out line, out tag, out sel_start); + document.SetSelection(line, sel_start); + document.PositionCaret(line, sel_start); document.DisplayCaret(); OnTextChanged(EventArgs.Empty); @@ -1299,6 +1305,8 @@ namespace System.Windows.Forms { } } + rtf_chars += rtf_line.Length; + if (rtf_cursor_x == 0) { document.Add(rtf_cursor_y, rtf_line.ToString(), rtf_rtfalign, font, rtf_color); } else { @@ -1324,11 +1332,12 @@ namespace System.Windows.Forms { private void InsertRTFFromStream(Stream data, int cursor_x, int cursor_y) { int x; int y; + int chars; - InsertRTFFromStream(data, cursor_x, cursor_y, out x, out y); + InsertRTFFromStream(data, cursor_x, cursor_y, out x, out y, out chars); } - private void InsertRTFFromStream(Stream data, int cursor_x, int cursor_y, out int to_x, out int to_y) { + private void InsertRTFFromStream(Stream data, int cursor_x, int cursor_y, out int to_x, out int to_y, out int chars) { RTF.RTF rtf; rtf = new RTF.RTF(data); @@ -1347,6 +1356,7 @@ namespace System.Windows.Forms { rtf_rtffont = null; rtf_cursor_x = cursor_x; rtf_cursor_y = cursor_y; + rtf_chars = 0; rtf.DefaultFont(this.Font.Name); rtf_text_map = new RTF.TextMap(); @@ -1366,6 +1376,7 @@ namespace System.Windows.Forms { to_x = rtf_cursor_x; to_y = rtf_cursor_y; + chars = rtf_chars; document.RecalculateDocument(CreateGraphics(), cursor_y, document.Lines, false); document.NoRecalc = false; -- cgit v1.2.3 From bf06a9b5be67891dc18d365e8576e3eb572b33f8 Mon Sep 17 00:00:00 2001 From: Carlos Alberto Cortez Date: Tue, 28 Feb 2006 08:38:29 +0000 Subject: 2006-02-28 Carlos Alberto Cortez * System.dll.sources: Forgot to add inside System.IO.Ports: SerialData.cs, SerialError.cs, SerialPinChange.cs svn path=/trunk/mcs/; revision=57384 --- mcs/class/System/ChangeLog | 5 +++++ mcs/class/System/System.dll.sources | 3 +++ 2 files changed, 8 insertions(+) (limited to 'mcs') diff --git a/mcs/class/System/ChangeLog b/mcs/class/System/ChangeLog index 00e8188d4d7..0db8e766b44 100644 --- a/mcs/class/System/ChangeLog +++ b/mcs/class/System/ChangeLog @@ -1,3 +1,8 @@ +2006-02-28 Carlos Alberto Cortez + + * System.dll.sources: Forgot to add inside System.IO.Ports: + SerialData.cs, SerialError.cs, SerialPinChange.cs + 2006-02-22 Kornél Pál * System.dll.sources: Added System.IO.Ports.SerialPortStream.cs diff --git a/mcs/class/System/System.dll.sources b/mcs/class/System/System.dll.sources index 95b7657dc09..9190a0f48a6 100644 --- a/mcs/class/System/System.dll.sources +++ b/mcs/class/System/System.dll.sources @@ -482,7 +482,10 @@ System.IO/MonoIOError.cs System.IO/NotifyFilters.cs System.IO.Ports/Handshake.cs System.IO.Ports/Parity.cs +System.IO.Ports/SerialData.cs +System.IO.Ports/SerialError.cs System.IO.Ports/SerialErrorEventArgs.cs +System.IO.Ports/SerialPinChange.cs System.IO.Ports/SerialPinChangedEventArgs.cs System.IO.Ports/SerialPort.cs System.IO.Ports/SerialPortStream.cs -- cgit v1.2.3 From cd35e907282abebeab30570bf8fd797e6e74f78b Mon Sep 17 00:00:00 2001 From: Carlos Alberto Cortez Date: Tue, 28 Feb 2006 09:11:27 +0000 Subject: 2006-02-28 Carlos Alberto Cortez * SerialPort.cs: * SerialPortStream.cs: Cleanups and some small funcionalities added. Also, some code was moved to SerialPortStream, to have a better design. svn path=/trunk/mcs/; revision=57386 --- mcs/class/System/System.IO.Ports/ChangeLog | 7 + mcs/class/System/System.IO.Ports/SerialPort.cs | 293 ++++++++++----------- .../System/System.IO.Ports/SerialPortStream.cs | 224 +++++++++++++++- 3 files changed, 357 insertions(+), 167 deletions(-) (limited to 'mcs') diff --git a/mcs/class/System/System.IO.Ports/ChangeLog b/mcs/class/System/System.IO.Ports/ChangeLog index f50f309a5af..1ccf92bc504 100644 --- a/mcs/class/System/System.IO.Ports/ChangeLog +++ b/mcs/class/System/System.IO.Ports/ChangeLog @@ -1,3 +1,10 @@ +2006-02-28 Carlos Alberto Cortez + + * SerialPort.cs: + * SerialPortStream.cs: Cleanups and some small funcionalities + added. Also, some code was moved to SerialPortStream, to have a + better design. + 2006-02-21 Carlos Alberto Cortez * SerialPort.cs: diff --git a/mcs/class/System/System.IO.Ports/SerialPort.cs b/mcs/class/System/System.IO.Ports/SerialPort.cs index ca0035abc52..1360e544133 100644 --- a/mcs/class/System/System.IO.Ports/SerialPort.cs +++ b/mcs/class/System/System.IO.Ports/SerialPort.cs @@ -10,8 +10,9 @@ namespace System.IO.Ports { public class SerialPort /* : Component */ { - public const int InfiniteTimeout = -1; + const int DefaultReadBufferSize = 4096; + const int DefaultWriteBufferSize = 2048; bool isOpen = false; int baudRate = 9600; @@ -20,13 +21,20 @@ namespace System.IO.Ports Handshake handshake = Handshake.None; int dataBits = 8; bool breakState = false; - Stream baseStream; + SerialPortStream stream; Encoding encoding = Encoding.ASCII; string newLine = Environment.NewLine; string portName; - int unixFd; int readTimeout = InfiniteTimeout; int writeTimeout = InfiniteTimeout; + int readBufferSize = DefaultReadBufferSize; + int writeBufferSize = DefaultWriteBufferSize; + int readBufferOffset; + int readBufferLength; + int writeBufferOffset; + int writeBufferLength; + byte [] readBuffer; + byte [] writeBuffer; public SerialPort () { @@ -65,7 +73,8 @@ namespace System.IO.Ports this.dataBits = dataBits; } - public SerialPort (string portName, int baudRate, Parity parity, int dataBits, StopBits stopBits) { + public SerialPort (string portName, int baudRate, Parity parity, int dataBits, StopBits stopBits) + { this.portName = portName; this.baudRate = baudRate; this.parity = parity; @@ -73,22 +82,15 @@ namespace System.IO.Ports this.stopBits = stopBits; } - public Stream BaseStream - { + public Stream BaseStream { get { if (!isOpen) throw new InvalidOperationException (); - if (baseStream == null) - baseStream = new SerialPortStream (this); - - return baseStream; + return stream; } } - [DllImport("MonoPosixHelper")] - private static extern bool set_attributes (int unix_fd, int baud_rate, Parity parity, int dataBits, StopBits stopBits, Handshake handshake); - public int BaudRate { get { return baudRate; @@ -98,7 +100,8 @@ namespace System.IO.Ports throw new ArgumentOutOfRangeException ("value"); baudRate = value; - set_attributes (unixFd, baudRate, parity, dataBits, stopBits, handshake); + if (isOpen) + stream.BaudRate = value; } } @@ -107,8 +110,7 @@ namespace System.IO.Ports return breakState; } set { - if (!isOpen) - throw new InvalidOperationException (); + CheckOpen (); if (value == breakState) return; // Do nothing. @@ -117,42 +119,30 @@ namespace System.IO.Ports } } - public int BytesToRead - { + public int BytesToRead { get { - if (!isOpen) - throw new InvalidOperationException (); - - throw new NotImplementedException (); + CheckOpen (); + return readBufferLength + stream.BytesToRead; } } - public int BytesToWrite - { + public int BytesToWrite { get { - if (!isOpen) - throw new InvalidOperationException (); - - throw new NotImplementedException (); + CheckOpen (); + return writeBufferLength + stream.BytesToWrite; } } - public bool CDHolding - { + public bool CDHolding { get { - if (!isOpen) - throw new InvalidOperationException (); - + CheckOpen (); throw new NotImplementedException (); } } - public bool CtsHolding - { + public bool CtsHolding { get { - if (!isOpen) - throw new InvalidOperationException (); - + CheckOpen (); throw new NotImplementedException (); } } @@ -166,39 +156,32 @@ namespace System.IO.Ports throw new ArgumentOutOfRangeException ("value"); dataBits = value; - set_attributes (unixFd, baudRate, parity, dataBits, stopBits, handshake); + if (isOpen) + stream.DataBits = value; } } - public bool DiscardNull - { + public bool DiscardNull { get { - if (!isOpen) - throw new InvalidOperationException (); - + CheckOpen (); throw new NotImplementedException (); } set { - if (!isOpen) - throw new InvalidOperationException (); - + CheckOpen (); throw new NotImplementedException (); } } - public bool DsrHolding - { + public bool DsrHolding { get { - if (!isOpen) - throw new InvalidOperationException (); - + CheckOpen (); throw new NotImplementedException (); } } - public bool DtrEnable - { + public bool DtrEnable { get { + CheckOpen (); throw new NotImplementedException (); } } @@ -217,25 +200,19 @@ namespace System.IO.Ports public Handshake Handshake { get { - if (!isOpen) - throw new InvalidOperationException (); - return handshake; } set { - if (!isOpen) - throw new InvalidOperationException (); if (value < Handshake.None || value > Handshake.RequestToSendXOnXOff) throw new ArgumentOutOfRangeException ("value"); handshake = value; - - set_attributes (unixFd, baudRate, parity, dataBits, stopBits, handshake); + if (isOpen) + stream.Handshake = value; } } - public bool IsOpen - { + public bool IsOpen { get { return isOpen; } @@ -255,24 +232,19 @@ namespace System.IO.Ports public Parity Parity { get { - if (!isOpen) - throw new InvalidOperationException (); - return parity; } set { - if (!isOpen) - throw new InvalidOperationException (); if (value < Parity.None || value > Parity.Space) throw new ArgumentOutOfRangeException ("value"); parity = value; - set_attributes (unixFd, baudRate, parity, dataBits, stopBits, handshake); + if (isOpen) + stream.Parity = value; } } - public byte ParityReplace - { + public byte ParityReplace { get { throw new NotImplementedException (); } @@ -287,31 +259,33 @@ namespace System.IO.Ports } set { if (isOpen) - throw new InvalidOperationException (); + throw new InvalidOperationException ("Port name cannot be set while port is open."); if (value == null) throw new ArgumentNullException ("value"); - if (value.Length == 0 || value.StartsWith ("\\")) + if (value.Length == 0 || value.StartsWith ("\\\\")) throw new ArgumentException ("value"); - - throw new NotImplementedException (); + + portName = value; } } - public int ReadBufferSize - { + public int ReadBufferSize { get { - throw new NotImplementedException (); + return readBufferSize; } set { + if (isOpen) + throw new InvalidOperationException (); if (value <= 0) throw new ArgumentOutOfRangeException ("value"); + if (value <= DefaultReadBufferSize) + return; - throw new NotImplementedException (); + readBufferSize = value; } } - public int ReadTimeout - { + public int ReadTimeout { get { return readTimeout; } @@ -320,6 +294,8 @@ namespace System.IO.Ports throw new ArgumentOutOfRangeException ("value"); readTimeout = value; + /*if (isOpen) + stream.ReadTimeout = value;*/ } } @@ -335,12 +311,13 @@ namespace System.IO.Ports } } - public bool RtsEnable - { + public bool RtsEnable { get { + CheckOpen (); throw new NotImplementedException (); } set { + CheckOpen (); throw new NotImplementedException (); } } @@ -353,26 +330,29 @@ namespace System.IO.Ports if (value < StopBits.One || value > StopBits.OnePointFive) throw new ArgumentOutOfRangeException ("value"); - this.stopBits = value; - set_attributes (unixFd, baudRate, parity, dataBits, stopBits, handshake); + stopBits = value; + if (isOpen) + stream.StopBits = value; } } - public int WriteBufferSize - { + public int WriteBufferSize { get { - throw new NotImplementedException (); + return writeBufferSize; } set { + if (isOpen) + throw new InvalidOperationException (); if (value <= 0) throw new ArgumentOutOfRangeException ("value"); + if (value <= DefaultWriteBufferSize) + return; - throw new NotImplementedException (); + writeBufferSize = value; } } - public int WriteTimeout - { + public int WriteTimeout { get { return writeTimeout; } @@ -381,70 +361,56 @@ namespace System.IO.Ports throw new ArgumentOutOfRangeException ("value"); writeTimeout = value; + /*if (isOpen) + stream.WriteTimeout = value;*/ } } // methods - [DllImport("MonoPosixHelper")] - private static extern void close_serial (int unixFd); public void Close () { - if (!isOpen) - return; - isOpen = false; - close_serial (unixFd); + if (stream != null) + stream.Close (); + + stream = null; + readBuffer = null; + writeBuffer = null; } - [DllImport("MonoPosixHelper")] - private static extern void discard_buffer (int unixFd, bool input_buffer); public void DiscardInBuffer () { - if (!isOpen) - throw new InvalidOperationException (); - discard_buffer (unixFd, true); + CheckOpen (); + stream.DiscardInputBuffer (); } public void DiscardOutBuffer () { - if (!isOpen) - throw new InvalidOperationException (); - discard_buffer (unixFd, false); + CheckOpen (); + stream.DiscardOutputBuffer (); } - [DllImport("MonoPosixHelper")] - private static extern string[] list_serial_devices (); - public static string[] GetPortNames() + public static string [] GetPortNames () { - return list_serial_devices (); + return new string [0]; // Return empty by now } - [DllImport("MonoPosixHelper")] - private static extern int open_serial (string portName); - public void Open () { - if (portName == null || portName.StartsWith ("\\\\")) - throw new ArgumentException (); - - unixFd = open_serial (portName); - if (unixFd == -1) - throw new IOException(); - - set_attributes (unixFd, baudRate, parity, dataBits, stopBits, handshake); - + if (isOpen) + throw new InvalidOperationException ("Port is already open"); + isOpen = true; + stream = new SerialPortStream (this); + readBuffer = new byte [readBufferSize]; + writeBuffer = new byte [writeBufferSize]; } - [DllImport("MonoPosixHelper")] - private static extern int read_serial (int unixFd, byte[] buffer, int offset, int count, int timeout); - public int Read (byte[] buffer, int offset, int count) { - if (!isOpen) - throw new InvalidOperationException (); + CheckOpen (); if (buffer == null) throw new ArgumentNullException ("buffer"); if (offset < 0 || offset >= buffer.Length) @@ -454,13 +420,27 @@ namespace System.IO.Ports if (count > buffer.Length - offset) throw new ArgumentException ("count > buffer.Length - offset"); - return read_serial (unixFd, buffer, offset, count, readTimeout); + if (readBufferLength <= 0) { + readBufferOffset = 0; + readBufferLength = stream.Read (readBuffer, 0, readBuffer.Length); + } + + if (readBufferLength == 0) + return 0; // No bytes left + + if (count > readBufferLength) + count = readBufferLength; // Update count if needed + + Buffer.BlockCopy (readBuffer, readBufferOffset, buffer, offset, count); + readBufferOffset += count; + readBufferLength -= count; + + return count; } public int Read (char[] buffer, int offset, int count) { - if (!isOpen) - throw new InvalidOperationException (); + CheckOpen (); if (buffer == null) throw new ArgumentNullException ("buffer"); if (offset < 0 || offset >= buffer.Length) @@ -471,16 +451,15 @@ namespace System.IO.Ports throw new ArgumentException ("count > buffer.Length - offset"); byte [] bytes = encoding.GetBytes (buffer, offset, count); - return read_serial (unixFd, bytes, 0, bytes.Length, readTimeout); + return Read (bytes, 0, bytes.Length); } - byte[] read_buffer = new byte[4096]; - public int ReadByte () { - if (Read (read_buffer, 0, 1) == 1) - return read_buffer [0]; - + byte [] buff = new byte [1]; + if (Read (buff, 0, 1) > 0) + return buff [0]; + return -1; } @@ -501,56 +480,54 @@ namespace System.IO.Ports public string ReadTo (string value) { + CheckOpen (); + if (value == null) + throw new ArgumentNullException ("value"); + if (value.Length == 0) + throw new ArgumentException ("value"); + throw new NotImplementedException (); } - [DllImport("MonoPosixHelper")] - private static extern void write_serial (int unixFd, byte[] buffer, int offset, int count, int timeout); - public void Write (string str) { + CheckOpen (); if (str == null) throw new ArgumentNullException ("str"); - if (!isOpen) - throw new InvalidOperationException ("Specified port is not open"); byte [] buffer = encoding.GetBytes (str); Write (buffer, 0, buffer.Length); } - public void Write (byte[] buffer, int offset, int count) + public void Write (byte [] buffer, int offset, int count) { + CheckOpen (); if (buffer == null) throw new ArgumentNullException ("buffer"); if (offset < 0 || offset >= buffer.Length) throw new ArgumentOutOfRangeException ("offset"); if (count < 0 || count > buffer.Length) throw new ArgumentOutOfRangeException ("count"); - if (offset + count > buffer.Length) - throw new ArgumentException ("offset+count > buffer.Length"); - - if (!isOpen) - throw new InvalidOperationException ("Specified port is not open"); - - write_serial (unixFd, buffer, offset, count, writeTimeout); + if (count > buffer.Length - offset) + throw new ArgumentException ("count > buffer.Length - offset"); + + stream.Write (buffer, offset, count); } - public void Write (char[] buffer, int offset, int count) + public void Write (char [] buffer, int offset, int count) { + CheckOpen (); if (buffer == null) throw new ArgumentNullException ("buffer"); if (offset < 0 || offset >= buffer.Length) throw new ArgumentOutOfRangeException ("offset"); if (count < 0 || count > buffer.Length) throw new ArgumentOutOfRangeException ("count"); - if (offset + count > buffer.Length) - throw new ArgumentException ("offset+count > buffer.Length"); + if (count > buffer.Length - offset) + throw new ArgumentException ("count > buffer.Length - offset"); - if (!isOpen) - throw new InvalidOperationException ("Specified port is not open"); - byte [] bytes = encoding.GetBytes (buffer, offset, count); - write_serial (unixFd, bytes, offset, count, writeTimeout); + stream.Write (bytes, 0, bytes.Length); } public void WriteLine (string str) @@ -558,6 +535,12 @@ namespace System.IO.Ports Write (str + newLine); } + void CheckOpen () + { + if (!isOpen) + throw new InvalidOperationException ("Specified port is not open."); + } + // events public delegate void SerialReceivedEventHandler (object sender, SerialReceivedEventArgs e); diff --git a/mcs/class/System/System.IO.Ports/SerialPortStream.cs b/mcs/class/System/System.IO.Ports/SerialPortStream.cs index ea6170ac07f..eb8fe896391 100644 --- a/mcs/class/System/System.IO.Ports/SerialPortStream.cs +++ b/mcs/class/System/System.IO.Ports/SerialPortStream.cs @@ -1,8 +1,9 @@ // -// System.IO.Ports.Handshake.cs +// System.IO.Ports.SerialPortStream.cs // // Authors: // Chris Toshok (toshok@ximian.com) +// Carlos Alberto Cortez (calberto.cortez@gmail.com) // // (c) Copyright 2006 Novell, Inc. (http://www.novell.com) // @@ -16,13 +17,37 @@ using System.Runtime.InteropServices; namespace System.IO.Ports { - class SerialPortStream : Stream + class SerialPortStream : Stream, IDisposable { - SerialPort port; + int fd; + int baudRate; + int dataBits; + Parity parity; + StopBits stopBits; + Handshake handshake; + int readTimeout; + int writeTimeout; + bool disposed; + + [DllImport ("MonoPosixHelper")] + static extern int open_serial (string portName); public SerialPortStream (SerialPort port) { - this.port = port; + fd = open_serial (port.PortName); + if (fd == -1) + throw new IOException (); + + readTimeout = port.ReadTimeout; + writeTimeout = port.WriteTimeout; + baudRate = port.BaudRate; + parity = port.Parity; + dataBits = port.DataBits; + stopBits = port.StopBits; + handshake = port.Handshake; + + if (!set_attributes (fd, port.BaudRate, port.Parity, port.DataBits, port.StopBits, port.Handshake)) + throw new IOException (); } public override bool CanRead { @@ -43,45 +68,220 @@ namespace System.IO.Ports } } + // Remove this comments as soon as these properties + // are added to System.IO.Stream + /* + public override bool CanTimeout { + get { + return true; + } + } + + public override int ReadTimeout { + get { + return readTimeout; + } + set { + if (value < 0 && value != SerialPort.InfiniteTimeout) + throw new ArgumentOutOfRangeException ("value"); + + readTimeout = value; + } + } + + public override int WriteTimeout { + get { + return writeTimeout; + } + set { + if (value < 0 && value != SerialPort.InfiniteTimeout) + throw new ArgumentOutOfRangeException ("value"); + + writeTimeout = value; + } + }*/ + public override long Length { get { - return -1; + throw new NotSupportedException (); } } public override long Position { get { - return -1; + throw new NotSupportedException (); } set { - throw new InvalidOperationException (); + throw new NotSupportedException (); } } public override void Flush () { - throw new NotImplementedException (); + // If used, this _could_ flush the serial port + // buffer (not the SerialPort class buffer) } + [DllImport ("MonoPosixHelper")] + static extern int read_serial (int fd, byte [] buffer, int offset, int count, int timeout); + public override int Read ([In,Out] byte[] buffer, int offset, int count) { - return port.Read (buffer, offset, count); + CheckDisposed (); + if (buffer == null) + throw new ArgumentNullException ("buffer"); + if (offset < 0 || offset >= buffer.Length) + throw new ArgumentOutOfRangeException ("offset"); + if (count < 0 || count > buffer.Length) + throw new ArgumentOutOfRangeException ("count"); + if (count > buffer.Length - offset) + throw new ArgumentException ("count > buffer.Length - offset"); + + return read_serial (fd, buffer, offset, count, readTimeout); } public override long Seek (long offset, SeekOrigin origin) { - throw new InvalidOperationException (); + throw new NotSupportedException (); } public override void SetLength (long value) { - throw new InvalidOperationException (); + throw new NotSupportedException (); } + [DllImport ("MonoPosixHelper")] + static extern void write_serial (int fd, byte [] buffer, int offset, int count, int timeout); + public override void Write (byte[] buffer, int offset, int count) { - port.Write (buffer, offset, count); + CheckDisposed (); + if (buffer == null) + throw new ArgumentNullException ("buffer"); + if (offset < 0 || offset >= buffer.Length) + throw new ArgumentOutOfRangeException ("offset"); + if (count < 0 || count > buffer.Length) + throw new ArgumentOutOfRangeException ("count"); + if (count > buffer.Length - offset) + throw new ArgumentException ("offset+count > buffer.Length"); + + write_serial (fd, buffer, offset, count, writeTimeout); + } + + protected void Dispose (bool disposing) + { + if (disposed) + return; + + disposed = true; + close_serial (fd); + } + + [DllImport ("MonoPosixHelper")] + static extern void close_serial (int fd); + + public override void Close () + { + ((IDisposable) this).Dispose (); + } + + void IDisposable.Dispose () + { + Dispose (true); + GC.SuppressFinalize (this); } + + ~SerialPortStream () + { + Dispose (false); + } + + void CheckDisposed () + { + if (disposed) + throw new ObjectDisposedException (GetType ().FullName); + } + + [DllImport ("MonoPosixHelper")] + static extern bool set_attributes (int fd, int baudRate, Parity parity, int dataBits, StopBits stopBits, Handshake handshake); + + // FIXME - Separate baud rate from the other values, + // since it can be set individually + internal int BaudRate { + get { + return baudRate; + } + set { + baudRate = value; + set_attributes (fd, baudRate, parity, dataBits, stopBits, handshake); + } + } + + internal Parity Parity { + get { + return parity; + } + set { + parity = value; + set_attributes (fd, baudRate, parity, dataBits, stopBits, handshake); + } + } + + internal int DataBits { + get { + return dataBits; + } + set { + dataBits = value; + set_attributes (fd, baudRate, parity, dataBits, stopBits, handshake); + } + } + + internal StopBits StopBits { + get { + return stopBits; + } + set { + stopBits = stopBits; + set_attributes (fd, baudRate, parity, dataBits, stopBits, handshake); + } + } + + internal Handshake Handshake { + get { + return handshake; + } + set { + handshake = value; + set_attributes (fd, baudRate, parity, dataBits, stopBits, handshake); + } + } + + internal int BytesToRead { + get { + return 0; // Not implemented yet + } + } + + internal int BytesToWrite { + get { + return 0; // Not implemented yet + } + } + + [DllImport ("MonoPosixHelper")] + static extern void discard_buffer (int fd, bool inputBuffer); + + internal void DiscardInputBuffer () + { + discard_buffer (fd, true); + } + + internal void DiscardOutputBuffer () + { + discard_buffer (fd, false); + } + } } -- cgit v1.2.3 From d4d091c6e565606e945bbb1f25d556c18adc9ba7 Mon Sep 17 00:00:00 2001 From: Paolo Molaro Date: Tue, 28 Feb 2006 13:22:44 +0000 Subject: Tue Feb 28 14:16:25 CET 2006 Paolo Molaro * BitArray.cs: reintroduce optimization carelessly removed by Robitaille. svn path=/trunk/mcs/; revision=57389 --- mcs/class/corlib/System.Collections/BitArray.cs | 6 +++--- mcs/class/corlib/System.Collections/ChangeLog | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'mcs') diff --git a/mcs/class/corlib/System.Collections/BitArray.cs b/mcs/class/corlib/System.Collections/BitArray.cs index 320ff9868c8..1ecb765c932 100644 --- a/mcs/class/corlib/System.Collections/BitArray.cs +++ b/mcs/class/corlib/System.Collections/BitArray.cs @@ -291,7 +291,7 @@ namespace System.Collections { if (index < 0 || index >= m_length) throw new ArgumentOutOfRangeException (); - return (m_array [index / 32] & (1 << (index % 32))) != 0; + return (m_array [index >> 5] & (1 << (index & 31))) != 0; } public void Set (int index, bool value) @@ -300,9 +300,9 @@ namespace System.Collections { throw new ArgumentOutOfRangeException (); if (value) - m_array [index / 32] |= (1 << (index % 32)); + m_array [index >> 5] |= (1 << (index & 31)); else - m_array [index / 32] &= ~(1 << (index % 32)); + m_array [index >> 5] &= ~(1 << (index & 31)); _version++; } diff --git a/mcs/class/corlib/System.Collections/ChangeLog b/mcs/class/corlib/System.Collections/ChangeLog index 0b0c78b0b6a..a4f41200ed2 100644 --- a/mcs/class/corlib/System.Collections/ChangeLog +++ b/mcs/class/corlib/System.Collections/ChangeLog @@ -1,3 +1,9 @@ + +Tue Feb 28 14:16:25 CET 2006 Paolo Molaro + + * BitArray.cs: reintroduce optimization carelessly removed by + Robitaille. + 2006-02-03 Sebastien Robitaille * BitArray.cs: Renamed members for interoperability with MS. -- cgit v1.2.3 From b767344ef4667f639ba805438005fe727465a591 Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Tue, 28 Feb 2006 14:19:08 +0000 Subject: 2006-02-28 Sebastien Pouliot * CryptoConvert.cs: Make sure we can import a keypair into our RSA instance (even if the key store isn't available). See bug #77559. * PKCS8.cs: Make sure we can import a keypair into our RSA instance (even if the key store isn't available). See bug #77559. svn path=/trunk/mcs/; revision=57390 --- .../Mono.Security.Cryptography/ChangeLog | 7 ++++ .../Mono.Security.Cryptography/CryptoConvert.cs | 38 +++++++++++++++++----- .../Mono.Security.Cryptography/PKCS8.cs | 18 ++++++++-- 3 files changed, 51 insertions(+), 12 deletions(-) (limited to 'mcs') diff --git a/mcs/class/Mono.Security/Mono.Security.Cryptography/ChangeLog b/mcs/class/Mono.Security/Mono.Security.Cryptography/ChangeLog index f4c50707dcc..3353d513a6e 100644 --- a/mcs/class/Mono.Security/Mono.Security.Cryptography/ChangeLog +++ b/mcs/class/Mono.Security/Mono.Security.Cryptography/ChangeLog @@ -1,3 +1,10 @@ +2006-02-28 Sebastien Pouliot + + * CryptoConvert.cs: Make sure we can import a keypair into our RSA + instance (even if the key store isn't available). See bug #77559. + * PKCS8.cs: Make sure we can import a keypair into our RSA instance + (even if the key store isn't available). See bug #77559. + 2005-11-23 Sebastien Pouliot * SymmetricTransform.cs: Synched with corlib version (IV behaviour for diff --git a/mcs/class/Mono.Security/Mono.Security.Cryptography/CryptoConvert.cs b/mcs/class/Mono.Security/Mono.Security.Cryptography/CryptoConvert.cs index 1d876703f0c..e0e9cbd7ede 100644 --- a/mcs/class/Mono.Security/Mono.Security.Cryptography/CryptoConvert.cs +++ b/mcs/class/Mono.Security/Mono.Security.Cryptography/CryptoConvert.cs @@ -5,11 +5,7 @@ // Sebastien Pouliot // // (C) 2003 Motus Technologies Inc. (http://www.motus.com) -// (C) 2004 Novell (http://www.novell.com) -// - -// -// Copyright (C) 2004 Novell, Inc (http://www.novell.com) +// Copyright (C) 2004-2006 Novell Inc. (http://www.novell.com) // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -166,8 +162,20 @@ namespace Mono.Security.Cryptography { Array.Reverse (rsap.D); } - RSA rsa = (RSA)RSA.Create (); - rsa.ImportParameters (rsap); + RSA rsa = null; + try { + rsa = RSA.Create (); + rsa.ImportParameters (rsap); + } + catch (CryptographicException) { + // this may cause problem when this code is run under + // the SYSTEM identity on Windows (e.g. ASP.NET). See + // http://bugzilla.ximian.com/show_bug.cgi?id=77559 + CspParameters csp = new CspParameters (); + csp.Flags = CspProviderFlags.UseMachineKeyStore; + rsa = new RSACryptoServiceProvider (csp); + rsa.ImportParameters (rsap); + } return rsa; } catch (Exception e) { @@ -287,8 +295,20 @@ namespace Mono.Security.Cryptography { Buffer.BlockCopy (blob, pos, rsap.Modulus, 0, byteLen); Array.Reverse (rsap.Modulus); - RSA rsa = (RSA)RSA.Create (); - rsa.ImportParameters (rsap); + RSA rsa = null; + try { + rsa = RSA.Create (); + rsa.ImportParameters (rsap); + } + catch (CryptographicException) { + // this may cause problem when this code is run under + // the SYSTEM identity on Windows (e.g. ASP.NET). See + // http://bugzilla.ximian.com/show_bug.cgi?id=77559 + CspParameters csp = new CspParameters (); + csp.Flags = CspProviderFlags.UseMachineKeyStore; + rsa = new RSACryptoServiceProvider (csp); + rsa.ImportParameters (rsap); + } return rsa; } catch (Exception e) { diff --git a/mcs/class/Mono.Security/Mono.Security.Cryptography/PKCS8.cs b/mcs/class/Mono.Security/Mono.Security.Cryptography/PKCS8.cs index d7cedf758f6..cc83e116844 100644 --- a/mcs/class/Mono.Security/Mono.Security.Cryptography/PKCS8.cs +++ b/mcs/class/Mono.Security/Mono.Security.Cryptography/PKCS8.cs @@ -6,7 +6,7 @@ // Sebastien Pouliot // // (C) 2003 Motus Technologies Inc. (http://www.motus.com) -// Copyright (C) 2004-2005 Novell Inc. (http://www.novell.com) +// Copyright (C) 2004-2006 Novell Inc. (http://www.novell.com) // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -273,8 +273,20 @@ namespace Mono.Security.Cryptography { param.P = Normalize (privateKey [4].Value, keysize2); param.Q = Normalize (privateKey [5].Value, keysize2); - RSA rsa = RSA.Create (); - rsa.ImportParameters (param); + RSA rsa = null; + try { + rsa = RSA.Create (); + rsa.ImportParameters (param); + } + catch (CryptographicException) { + // this may cause problem when this code is run under + // the SYSTEM identity on Windows (e.g. ASP.NET). See + // http://bugzilla.ximian.com/show_bug.cgi?id=77559 + CspParameters csp = new CspParameters (); + csp.Flags = CspProviderFlags.UseMachineKeyStore; + rsa = new RSACryptoServiceProvider (csp); + rsa.ImportParameters (param); + } return rsa; } -- cgit v1.2.3 From c01749afbcef97791029a28f7e8245055af58c44 Mon Sep 17 00:00:00 2001 From: Atsushi Eno Date: Tue, 28 Feb 2006 15:59:55 +0000 Subject: 2006-02-28 Atsushi Enomoto * XmlElement.cs : (WriteTo) use IsEmpty to determine which to use: WriteEndElement() and WriteFullEndElement(). Fixed sys.security regression. svn path=/trunk/mcs/; revision=57395 --- mcs/class/System.XML/System.Xml/ChangeLog | 6 ++++++ mcs/class/System.XML/System.Xml/XmlElement.cs | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'mcs') diff --git a/mcs/class/System.XML/System.Xml/ChangeLog b/mcs/class/System.XML/System.Xml/ChangeLog index eb9e65c3056..0a9cd36faa3 100644 --- a/mcs/class/System.XML/System.Xml/ChangeLog +++ b/mcs/class/System.XML/System.Xml/ChangeLog @@ -1,3 +1,9 @@ +2006-02-28 Atsushi Enomoto + + * XmlElement.cs : (WriteTo) use IsEmpty to determine which to use: + WriteEndElement() and WriteFullEndElement(). Fixed sys.security + regression. + 2006-02-24 Atsushi Enomoto * XmlTextWriter2.cs : diff --git a/mcs/class/System.XML/System.Xml/XmlElement.cs b/mcs/class/System.XML/System.Xml/XmlElement.cs index 34566dac902..a49eb3108b9 100644 --- a/mcs/class/System.XML/System.Xml/XmlElement.cs +++ b/mcs/class/System.XML/System.Xml/XmlElement.cs @@ -425,10 +425,10 @@ namespace System.Xml WriteContentTo (w); - if (isNotEmpty) - w.WriteFullEndElement (); - else + if (IsEmpty) w.WriteEndElement (); + else + w.WriteFullEndElement (); } #endregion -- cgit v1.2.3 From 70fdef1c23a95d9fc5525997df5cc924f6e1df0c Mon Sep 17 00:00:00 2001 From: Peter Dennis Bartok Date: Tue, 28 Feb 2006 17:10:26 +0000 Subject: 2006-02-28 Jonathan Chambers , Peter Dennis Bartok * Font.cs: - ToLogFont: Reworked to allow running under MS runtime and to support it being called with both boxed structs and formatted classes (MS runtime PtrToStructure cannot marshal boxed value types, but Marshal.AsAny can) - Switched all usage of LOGFONTA to more generic CharSet-driven LOGFONT structure - FromLogFont: Switched to use charset-agnostic GdipCreateFontFromLogfont * gdipStructs.cs: Dropped LOGFONTA and LOGFONTW and switched to CharSet-driven LOGFONT structure (needed because of ToLogFont fix) * gdipFunctions.cs: Switched GdipGetLogFont, GdipCreateFontFromLogfont and CreateFontIndirect to use LOGFONT structure, set to be CharSet=Auto (needed because of ToLogFont fix) svn path=/trunk/mcs/; revision=57405 --- mcs/class/System.Drawing/System.Drawing/ChangeLog | 17 +++++ mcs/class/System.Drawing/System.Drawing/Font.cs | 75 ++++++++++------------ .../System.Drawing/System.Drawing/gdipFunctions.cs | 20 +++--- .../System.Drawing/System.Drawing/gdipStructs.cs | 74 ++++++++------------- 4 files changed, 87 insertions(+), 99 deletions(-) (limited to 'mcs') diff --git a/mcs/class/System.Drawing/System.Drawing/ChangeLog b/mcs/class/System.Drawing/System.Drawing/ChangeLog index 39986582e63..22ee550ff01 100644 --- a/mcs/class/System.Drawing/System.Drawing/ChangeLog +++ b/mcs/class/System.Drawing/System.Drawing/ChangeLog @@ -1,3 +1,20 @@ +2006-02-28 Jonathan Chambers , + Peter Dennis Bartok + + * Font.cs: + - ToLogFont: Reworked to allow running under MS runtime and to + support it being called with both boxed structs and formatted + classes (MS runtime PtrToStructure cannot marshal boxed value + types, but Marshal.AsAny can) + - Switched all usage of LOGFONTA to more generic CharSet-driven + LOGFONT structure + - FromLogFont: Switched to use charset-agnostic GdipCreateFontFromLogfont + * gdipStructs.cs: Dropped LOGFONTA and LOGFONTW and switched to + CharSet-driven LOGFONT structure (needed because of ToLogFont fix) + * gdipFunctions.cs: Switched GdipGetLogFont, GdipCreateFontFromLogfont and + CreateFontIndirect to use LOGFONT structure, set to be CharSet=Auto + (needed because of ToLogFont fix) + 2006-02-18 Duncan Mak * Graphics.cs (DrawBeziers): Patch from Alexander Olk to fix diff --git a/mcs/class/System.Drawing/System.Drawing/Font.cs b/mcs/class/System.Drawing/System.Drawing/Font.cs index 0f73861eeff..4f45c85b6ef 100644 --- a/mcs/class/System.Drawing/System.Drawing/Font.cs +++ b/mcs/class/System.Drawing/System.Drawing/Font.cs @@ -45,7 +45,7 @@ namespace System.Drawing { private IntPtr fontObject = IntPtr.Zero; private string systemFontName; - private float _size; + private float _size; private void CreateFont(string familyName, float emSize, FontStyle style, GraphicsUnit unit, byte charSet, bool isVertical) { Status status; @@ -192,7 +192,7 @@ namespace System.Drawing IntPtr hdc; FontStyle newStyle = FontStyle.Regular; float newSize; - LOGFONTA lf = new LOGFONTA (); + LOGFONT lf = new LOGFONT (); // Sanity. Should we throw an exception? if (Hfont == IntPtr.Zero) { @@ -257,9 +257,9 @@ namespace System.Drawing if ((int) osInfo.Platform == 128 || (int) osInfo.Platform == 4) { return fontObject; } else { - LOGFONTA lf = new LOGFONTA (); + LOGFONT lf = new LOGFONT (); ToLogFont(lf); - Hfont = GDIPlus.CreateFontIndirectA (ref lf); + Hfont = GDIPlus.CreateFontIndirect (ref lf); } return Hfont; } @@ -368,13 +368,13 @@ namespace System.Drawing } } -#if NET_2_0 - internal string SysFontName { - set { - systemFontName = value; - } - } -#endif +#if NET_2_0 + internal string SysFontName { + set { + systemFontName = value; + } + } +#endif private bool _bold; @@ -419,17 +419,17 @@ namespace System.Drawing } } -#if NET_2_0 - [Browsable(false)] - public bool IsSystemFont { - get { - if (systemFontName == null) - return false; - - return StringComparer.InvariantCulture.Compare (systemFontName, string.Empty) != 0; - } - } -#endif +#if NET_2_0 + [Browsable(false)] + public bool IsSystemFont { + get { + if (systemFontName == null) + return false; + + return StringComparer.InvariantCulture.Compare (systemFontName, string.Empty) != 0; + } + } +#endif private bool _italic; @@ -484,14 +484,14 @@ namespace System.Drawing } } -#if NET_2_0 - [Browsable(false)] - public string SystemFontName { - get { - return systemFontName; - } - } -#endif +#if NET_2_0 + [Browsable(false)] + public string SystemFontName { + get { + return systemFontName; + } + } +#endif private bool _underline; [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] @@ -541,8 +541,8 @@ namespace System.Drawing public static Font FromLogFont (object lf, IntPtr hdc) { IntPtr newObject; - LOGFONTA o = (LOGFONTA)lf; - GDIPlus.GdipCreateFontFromLogfontA (hdc, ref o, out newObject); + LOGFONT o = (LOGFONT)lf; + GDIPlus.GdipCreateFontFromLogfont (hdc, ref o, out newObject); return new Font (newObject, "Microsoft Sans Serif", FontStyle.Regular, 10); } @@ -627,19 +627,12 @@ namespace System.Drawing public void ToLogFont (object logFont, Graphics graphics) { - IntPtr lf; - if (graphics == null) { throw new ArgumentNullException ("graphics"); } - lf = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(LOGFONTW))); - try { - GDIPlus.CheckStatus (GDIPlus.GdipGetLogFontW(NativeObject, graphics.NativeObject, lf)); - Marshal.PtrToStructure(lf, logFont); - } - finally { - Marshal.FreeHGlobal (lf); + if (Marshal.SizeOf(logFont) >= Marshal.SizeOf(typeof(LOGFONT))) { + GDIPlus.CheckStatus (GDIPlus.GdipGetLogFont(NativeObject, graphics.NativeObject, logFont)); } } diff --git a/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs b/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs index ae4419aeacf..9a6b1fa71b4 100644 --- a/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs +++ b/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs @@ -73,7 +73,7 @@ namespace System.Drawing // Called all pending objects and claim any pending handle before // shutting down GC.Collect (); - GC.WaitForPendingFinalizers (); + GC.WaitForPendingFinalizers (); // This causes crashes in MS GDI+ because this call occurs before // all managed GDI objects are finalized. When they are finalized they call // into a shutdown GDI+ and we crash. @@ -1371,26 +1371,24 @@ namespace System.Drawing internal static extern Status GdipCreateFont (IntPtr fontFamily, float emSize, FontStyle style, GraphicsUnit unit, out IntPtr font); [DllImport("gdiplus.dll")] internal static extern Status GdipDeleteFont (IntPtr font); - [DllImport("gdiplus.dll", CharSet=CharSet.Ansi)] - internal static extern Status GdipGetLogFontA(IntPtr font, IntPtr graphics, IntPtr logfontA); - [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)] - internal static extern Status GdipGetLogFontW(IntPtr font, IntPtr graphics, IntPtr logfontW); + [DllImport("gdiplus.dll", CharSet=CharSet.Auto)] + internal static extern Status GdipGetLogFont(IntPtr font, IntPtr graphics, [MarshalAs(UnmanagedType.AsAny), Out] object logfontA); [DllImport("gdiplus.dll")] internal static extern Status GdipCreateFontFromDC(IntPtr hdc, out IntPtr font); - [DllImport("gdiplus.dll", SetLastError=true)] - internal static extern Status GdipCreateFontFromLogfontA(IntPtr hdc, ref LOGFONTA lf, out IntPtr ptr); + [DllImport("gdiplus.dll", SetLastError=true, CharSet=CharSet.Auto)] + internal static extern Status GdipCreateFontFromLogfont(IntPtr hdc, ref LOGFONT lf, out IntPtr ptr); // These are our private functions, they exists in our own libgdiplus library, this way we // avoid relying on wine in System.Drawing [DllImport("gdiplus.dll")] internal static extern Status GdipGetHfont (IntPtr font, out IntPtr Hfont); - [DllImport("gdiplus.dll")] - internal static extern Status GdipCreateFontFromHfont(IntPtr hdc, out IntPtr font, ref LOGFONTA lf); + [DllImport("gdiplus.dll", CharSet=CharSet.Ansi)] + internal static extern Status GdipCreateFontFromHfont(IntPtr hdc, out IntPtr font, ref LOGFONT lf); // This is win32/gdi, not gdiplus, but it's easier to keep in here, also see above comment - [DllImport("gdi32.dll", EntryPoint="CreateFontIndirectA", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)] - internal static extern IntPtr CreateFontIndirectA (ref LOGFONTA logfontA); + [DllImport("gdi32.dll", CallingConvention=CallingConvention.StdCall, CharSet = CharSet.Auto)] + internal static extern IntPtr CreateFontIndirect (ref LOGFONT logfont); [DllImport("user32.dll", EntryPoint="GetDC", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)] internal static extern IntPtr GetDC(IntPtr hwnd); [DllImport("user32.dll", EntryPoint="ReleaseDC", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)] diff --git a/mcs/class/System.Drawing/System.Drawing/gdipStructs.cs b/mcs/class/System.Drawing/System.Drawing/gdipStructs.cs index 060f6e5399e..6d9b49294bd 100644 --- a/mcs/class/System.Drawing/System.Drawing/gdipStructs.cs +++ b/mcs/class/System.Drawing/System.Drawing/gdipStructs.cs @@ -85,28 +85,8 @@ namespace System.Drawing internal int to; } - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)] - internal struct LOGFONTA - { - internal int lfHeight; - internal uint lfWidth; - internal uint lfEscapement; - internal uint lfOrientation; - internal uint lfWeight; - internal byte lfItalic; - internal byte lfUnderline; - internal byte lfStrikeOut; - internal byte lfCharSet; - internal byte lfOutPrecision; - internal byte lfClipPrecision; - internal byte lfQuality; - internal byte lfPitchAndFamily; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)] - internal string lfFaceName; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] - internal struct LOGFONTW + [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] + internal struct LOGFONT { internal int lfHeight; internal uint lfWidth; @@ -182,34 +162,34 @@ namespace System.Drawing } } - [StructLayout(LayoutKind.Sequential)] - internal struct IconInfo - { - int fIcon; - public int xHotspot; - public int yHotspot; - IntPtr hbmMask; - IntPtr hbmColor; - - public bool IsIcon { - get { - return fIcon == 1; - } - } + [StructLayout(LayoutKind.Sequential)] + internal struct IconInfo + { + int fIcon; + public int xHotspot; + public int yHotspot; + IntPtr hbmMask; + IntPtr hbmColor; + + public bool IsIcon { + get { + return fIcon == 1; + } + } } - [StructLayout(LayoutKind.Sequential)] - internal struct XColor - { - public int pixel; - public ushort red, green, blue; - public sbyte flags; - public sbyte pad; + [StructLayout(LayoutKind.Sequential)] + internal struct XColor + { + public int pixel; + public ushort red, green, blue; + public sbyte flags; + public sbyte pad; } - [StructLayout(LayoutKind.Sequential)] - internal struct XVisualInfo - { + [StructLayout(LayoutKind.Sequential)] + internal struct XVisualInfo + { internal IntPtr visual; internal int visualid; internal int screen; @@ -219,7 +199,7 @@ namespace System.Drawing internal uint green_mask; internal uint blue_mask; internal int colormap_size; - internal int bits_per_rgb; + internal int bits_per_rgb; } } -- cgit v1.2.3 From 03c23396357e305e9835a3d0f90a14f94300c10b Mon Sep 17 00:00:00 2001 From: Gonzalo Paniagua Javier Date: Tue, 28 Feb 2006 17:30:03 +0000 Subject: 2006-02-28 Gonzalo Paniagua Javier * ApplicationManager.cs: implemented ShutdownAll(). * HostingEnvironment.cs: remove MonoTODO. svn path=/trunk/mcs/; revision=57406 --- .../System.Web/System.Web.Hosting/ApplicationManager.cs | 13 +++++++++++-- mcs/class/System.Web/System.Web.Hosting/ChangeLog | 5 +++++ .../System.Web/System.Web.Hosting/HostingEnvironment.cs | 1 - 3 files changed, 16 insertions(+), 3 deletions(-) (limited to 'mcs') diff --git a/mcs/class/System.Web/System.Web.Hosting/ApplicationManager.cs b/mcs/class/System.Web/System.Web.Hosting/ApplicationManager.cs index d6d41719fa3..db69516d8d0 100644 --- a/mcs/class/System.Web/System.Web.Hosting/ApplicationManager.cs +++ b/mcs/class/System.Web/System.Web.Hosting/ApplicationManager.cs @@ -179,10 +179,19 @@ namespace System.Web.Hosting { Interlocked.Increment (ref users); } - [MonoTODO] public void ShutdownAll () { - // == HostingEnvironment.InitiateShutdown in all appdomains managed by this instance + ICollection coll = id_to_host.Keys; + string [] keys = new string [coll.Count]; + coll.CopyTo (keys, 0); + ApplicationInfo [] result = new ApplicationInfo [coll.Count]; + int i = 0; + foreach (string str in keys) { + BareApplicationHost host = id_to_host [str]; + host.Shutdown (); + } + + id_to_host.Clear (); } public void ShutdownApplication (string appId) diff --git a/mcs/class/System.Web/System.Web.Hosting/ChangeLog b/mcs/class/System.Web/System.Web.Hosting/ChangeLog index 34d2af117e3..de4e5e4438f 100644 --- a/mcs/class/System.Web/System.Web.Hosting/ChangeLog +++ b/mcs/class/System.Web/System.Web.Hosting/ChangeLog @@ -1,3 +1,8 @@ +2006-02-28 Gonzalo Paniagua Javier + + * ApplicationManager.cs: implemented ShutdownAll(). + * HostingEnvironment.cs: remove MonoTODO. + 2006-02-22 Gonzalo Paniagua Javier * BareApplicationHost.cs: class used as an entry point into each diff --git a/mcs/class/System.Web/System.Web.Hosting/HostingEnvironment.cs b/mcs/class/System.Web/System.Web.Hosting/HostingEnvironment.cs index 8e176e98def..92de7eda54b 100644 --- a/mcs/class/System.Web/System.Web.Hosting/HostingEnvironment.cs +++ b/mcs/class/System.Web/System.Web.Hosting/HostingEnvironment.cs @@ -95,7 +95,6 @@ namespace System.Web.Hosting { get { return vpath_provider; } } - [MonoTODO] public static void DecrementBusyCount () { Interlocked.Decrement (ref busy_count); -- cgit v1.2.3 From a4bd10ca7d8eac7dbd0214818b5a7bc73a4eabab Mon Sep 17 00:00:00 2001 From: Alexander Olk Date: Tue, 28 Feb 2006 18:00:40 +0000 Subject: 2006-02-28 Alexander Olk * FontDialog.cs: - Got rid of the panel. All controls are now directly added to the dialog form - It is now possible to set a font with the Font property - MinSize and MaxSize property do now what they should - ShowApply, ShowHelp, ShowColor, ShowEffects likewise - Searching and selecting a font with the font textbox works now, the same applies to the style and size textbox - Draw the correct 3D border in the example panel - Fixed a little mem leak (unused fonts didn't get disposed) - Many other internal updates/rewrites... svn path=/trunk/mcs/; revision=57407 --- .../System.Windows.Forms/ChangeLog | 14 + .../System.Windows.Forms/FontDialog.cs | 1002 +++++++++++--------- 2 files changed, 591 insertions(+), 425 deletions(-) (limited to 'mcs') diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index 8a3faaaaded..332eb527ad0 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -1,3 +1,17 @@ +2006-02-28 Alexander Olk + + * FontDialog.cs: + - Got rid of the panel. All controls are now directly added to + the dialog form + - It is now possible to set a font with the Font property + - MinSize and MaxSize property do now what they should + - ShowApply, ShowHelp, ShowColor, ShowEffects likewise + - Searching and selecting a font with the font textbox works now, + the same applies to the style and size textbox + - Draw the correct 3D border in the example panel + - Fixed a little mem leak (unused fonts didn't get disposed) + - Many other internal updates/rewrites... + 2006-02-27 Peter Dennis Bartok * TextControl.cs: diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FontDialog.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FontDialog.cs index e31f17a3753..da89b180aca 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FontDialog.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FontDialog.cs @@ -33,6 +33,8 @@ using System.ComponentModel; using System.Drawing; using System.Text.RegularExpressions; +using System; +using System.Collections; namespace System.Windows.Forms { @@ -42,8 +44,6 @@ namespace System.Windows.Forms { protected static readonly object EventApply = new object (); - private FontDialogPanel fontDialogPanel; - private Font font; private Color color = Color.Black; private bool allowSimulations = true; @@ -61,14 +61,272 @@ namespace System.Windows.Forms private bool fontMustExist = false; + private Panel examplePanel; + + private Button okButton; + private Button cancelButton; + private Button applyButton; + private Button helpButton; + + private TextBox fontTextBox; + private TextBox fontstyleTextBox; + private TextBox fontsizeTextBox; + + private ListBox fontListBox; + private ListBox fontstyleListBox; + private ListBox fontsizeListBox; + + private GroupBox effectsGroupBox; + private CheckBox strikethroughCheckBox; + private CheckBox underlinedCheckBox; + private ComboBox scriptComboBox; + + private Label fontLabel; + private Label fontstyleLabel; + private Label sizeLabel; + private Label scriptLabel; + + private GroupBox exampleGroupBox; + + private ColorComboBox colorComboBox; + + private FontFamily[] fontFamilies; + + private string currentFontName; + + private float currentSize; + + private FontFamily currentFamily; + + private FontStyle currentFontStyle; + + private bool underlined = false; + private bool strikethrough = false; + + private Hashtable fontHash = new Hashtable(); + + private int[] a_sizes = { + 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72 + }; + + private bool internal_change = false; + #region Public Constructors public FontDialog( ) { - form.ClientSize = new Size( 430, 318 ); + okButton = new Button( ); + cancelButton = new Button( ); + applyButton = new Button( ); + helpButton = new Button( ); + + fontTextBox = new TextBox( ); + fontstyleTextBox = new TextBox( ); + fontsizeTextBox = new TextBox( ); + + fontListBox = new ListBox( ); + fontsizeListBox = new ListBox( ); + + fontLabel = new Label( ); + fontstyleLabel = new Label( ); + sizeLabel = new Label( ); + scriptLabel = new Label( ); + + exampleGroupBox = new GroupBox( ); + fontstyleListBox = new ListBox( ); + + effectsGroupBox = new GroupBox( ); + underlinedCheckBox = new CheckBox( ); + strikethroughCheckBox = new CheckBox( ); + scriptComboBox = new ComboBox( ); + + examplePanel = new Panel( ); + + colorComboBox = new ColorComboBox( this ); + + exampleGroupBox.SuspendLayout( ); + effectsGroupBox.SuspendLayout( ); + form.SuspendLayout( ); + + // fontsizeListBox + fontsizeListBox.Location = new Point( 284, 47 ); + fontsizeListBox.Size = new Size( 52, 95 ); + fontsizeListBox.TabIndex = 10; + fontListBox.Sorted = true; + // fontTextBox + fontTextBox.Location = new Point( 16, 26 ); + fontTextBox.Size = new Size( 140, 21 ); + fontTextBox.TabIndex = 5; + fontTextBox.Text = ""; + // fontstyleLabel + fontstyleLabel.Location = new Point( 164, 10 ); + fontstyleLabel.Size = new Size( 100, 16 ); + fontstyleLabel.TabIndex = 1; + fontstyleLabel.Text = "Font Style:"; + // typesizeTextBox + fontsizeTextBox.Location = new Point( 284, 26 ); + fontsizeTextBox.Size = new Size( 52, 21 ); + fontsizeTextBox.TabIndex = 7; + fontsizeTextBox.Text = ""; + // schriftartListBox + fontListBox.Location = new Point( 16, 47 ); + fontListBox.Size = new Size( 140, 95 ); + fontListBox.TabIndex = 8; + fontListBox.Sorted = true; + // exampleGroupBox + exampleGroupBox.Controls.Add( examplePanel ); + exampleGroupBox.FlatStyle = FlatStyle.System; + exampleGroupBox.Location = new Point( 164, 158 ); + exampleGroupBox.Size = new Size( 172, 70 ); + exampleGroupBox.TabIndex = 12; + exampleGroupBox.TabStop = false; + exampleGroupBox.Text = "Example"; + // fontstyleListBox + fontstyleListBox.Location = new Point( 164, 47 ); + fontstyleListBox.Size = new Size( 112, 95 ); + fontstyleListBox.TabIndex = 9; + // schriftartLabel + fontLabel.Location = new Point( 16, 10 ); + fontLabel.Size = new Size( 88, 16 ); + fontLabel.TabIndex = 0; + fontLabel.Text = "Font:"; + // effectsGroupBox + effectsGroupBox.Controls.Add( underlinedCheckBox ); + effectsGroupBox.Controls.Add( strikethroughCheckBox ); + effectsGroupBox.Controls.Add( colorComboBox ); + effectsGroupBox.FlatStyle = FlatStyle.System; + effectsGroupBox.Location = new Point( 16, 158 ); + effectsGroupBox.Size = new Size( 140, 116 ); + effectsGroupBox.TabIndex = 11; + effectsGroupBox.TabStop = false; + effectsGroupBox.Text = "Effects"; + // strikethroughCheckBox + strikethroughCheckBox.FlatStyle = FlatStyle.System; + strikethroughCheckBox.Location = new Point( 8, 16 ); + strikethroughCheckBox.TabIndex = 0; + strikethroughCheckBox.Text = "Strikethrough"; + // colorComboBox + colorComboBox.Location = new Point( 8, 70 ); + colorComboBox.Size = new Size( 130, 21 ); + // sizeLabel + sizeLabel.Location = new Point( 284, 10 ); + sizeLabel.Size = new Size( 100, 16 ); + sizeLabel.TabIndex = 2; + sizeLabel.Text = "Size:"; + // scriptComboBox + scriptComboBox.Location = new Point( 164, 253 ); + scriptComboBox.Size = new Size( 172, 21 ); + scriptComboBox.TabIndex = 14; + scriptComboBox.Text = "-/-"; + // okButton + okButton.FlatStyle = FlatStyle.System; + okButton.Location = new Point( 352, 26 ); + okButton.Size = new Size( 70, 23 ); + okButton.TabIndex = 3; + okButton.Text = "OK"; + // cancelButton + cancelButton.FlatStyle = FlatStyle.System; + cancelButton.Location = new Point( 352, 52 ); + cancelButton.Size = new Size( 70, 23 ); + cancelButton.TabIndex = 4; + cancelButton.Text = "Cancel"; + // applyButton + applyButton.FlatStyle = FlatStyle.System; + applyButton.Location = new Point( 352, 78 ); + applyButton.Size = new Size( 70, 23 ); + applyButton.TabIndex = 5; + applyButton.Text = "Apply"; + // helpButton + helpButton.FlatStyle = FlatStyle.System; + helpButton.Location = new Point( 352, 104 ); + helpButton.Size = new Size( 70, 23 ); + helpButton.TabIndex = 6; + helpButton.Text = "Help"; + // underlinedCheckBox + underlinedCheckBox.FlatStyle = FlatStyle.System; + underlinedCheckBox.Location = new Point( 8, 36 ); + underlinedCheckBox.TabIndex = 1; + underlinedCheckBox.Text = "Underlined"; + // fontstyleTextBox + fontstyleTextBox.Location = new Point( 164, 26 ); + fontstyleTextBox.Size = new Size( 112, 21 ); + fontstyleTextBox.TabIndex = 6; + fontstyleTextBox.Text = ""; + // scriptLabel + scriptLabel.Location = new Point( 164, 236 ); + scriptLabel.Size = new Size( 100, 16 ); + scriptLabel.TabIndex = 13; + scriptLabel.Text = "Script:"; + // examplePanel + examplePanel.Location = new Point( 8, 20 ); + examplePanel.TabIndex = 0; + examplePanel.Size = new Size( 156, 40 ); + + form.AcceptButton = okButton; + + form.Controls.Add( scriptComboBox ); + form.Controls.Add( scriptLabel ); + form.Controls.Add( exampleGroupBox ); + form.Controls.Add( effectsGroupBox ); + form.Controls.Add( fontsizeListBox ); + form.Controls.Add( fontstyleListBox ); + form.Controls.Add( fontListBox ); + form.Controls.Add( fontsizeTextBox ); + form.Controls.Add( fontstyleTextBox ); + form.Controls.Add( fontTextBox ); + form.Controls.Add( cancelButton ); + form.Controls.Add( okButton ); + form.Controls.Add( sizeLabel ); + form.Controls.Add( fontstyleLabel ); + form.Controls.Add( fontLabel ); + form.Controls.Add( applyButton ); + form.Controls.Add( helpButton ); + + exampleGroupBox.ResumeLayout( false ); + effectsGroupBox.ResumeLayout( false ); form.Size = new Size( 430, 318 ); + form.MinimumSize = new Size( 430, 318 ); + + form.FormBorderStyle = FormBorderStyle.FixedDialog; + form.MaximizeBox = false; form.Text = "Font"; + + form.ResumeLayout( false ); + + fontFamilies = FontFamily.Families; + + fontListBox.BeginUpdate( ); + foreach ( FontFamily ff in fontFamilies ) + { + if ( !fontHash.ContainsKey (ff.Name) ) { + fontListBox.Items.Add( ff.Name ); + fontHash.Add( ff.Name, ff ); + } + } + fontListBox.EndUpdate( ); + + CreateFontSizeListBoxItems (); + + applyButton.Hide( ); + helpButton.Hide( ); + colorComboBox.Hide( ); + + cancelButton.Click += new EventHandler( OnClickCancelButton ); + okButton.Click += new EventHandler( OnClickOkButton ); + applyButton.Click += new EventHandler (OnApplyButton); + examplePanel.Paint += new PaintEventHandler( OnPaintExamplePanel ); + fontListBox.SelectedIndexChanged += new EventHandler( OnSelectedIndexChangedFontListBox ); + fontsizeListBox.SelectedIndexChanged += new EventHandler( OnSelectedIndexChangedSizeListBox ); + fontstyleListBox.SelectedIndexChanged += new EventHandler( OnSelectedIndexChangedFontStyleListBox ); + underlinedCheckBox.CheckedChanged += new EventHandler( OnCheckedChangedUnderlinedCheckBox ); + strikethroughCheckBox.CheckedChanged += new EventHandler( OnCheckedChangedStrikethroughCheckBox ); + + fontTextBox.KeyUp += new KeyEventHandler (OnFontTextBoxKeyUp); + fontstyleTextBox.KeyUp += new KeyEventHandler (OnFontStyleTextBoxKeyUp); + fontsizeTextBox.KeyUp += new KeyEventHandler (OnFontSizeTextBoxKeyUp); + + Font = form.Font; } #endregion // Public Constructors @@ -80,7 +338,23 @@ namespace System.Windows.Forms } set { - font = value; + if (value != null) { + font = new Font(value, value.Style); + + currentFontStyle = font.Style; + currentSize = font.Size; + currentFontName = font.Name; + + int index = fontListBox.FindString (currentFontName); + + if (index != -1) { + fontListBox.SelectedIndex = index; + } else { + fontListBox.SelectedIndex = 0; + } + + fontListBox.TopIndex = fontListBox.SelectedIndex; + } } } @@ -100,6 +374,7 @@ namespace System.Windows.Forms { set { color = value; + examplePanel.Invalidate( ); } get { @@ -172,6 +447,14 @@ namespace System.Windows.Forms { set { maxSize = value; + + if (maxSize < 0) + maxSize = 0; + + if (maxSize < minSize) + minSize = maxSize; + + CreateFontSizeListBoxItems (); } get { @@ -184,6 +467,27 @@ namespace System.Windows.Forms { set { minSize = value; + + if (minSize < 0) + minSize = 0; + + if (minSize > maxSize) + maxSize = minSize; + + CreateFontSizeListBoxItems (); + + if (minSize > currentSize) + if (font != null) { + font.Dispose(); + + currentSize = minSize; + + font = new Font( currentFamily, currentSize, currentFontStyle ); + + UpdateExamplePanel (); + + fontsizeTextBox.Text = currentSize.ToString (); + } } get { @@ -207,7 +511,17 @@ namespace System.Windows.Forms public bool ShowApply { set { - showApply = value; + if (value != showApply) + { + showApply = value; + if (showApply) + applyButton.Show (); + else + applyButton.Hide (); + + form.Refresh(); + } + } get { @@ -219,7 +533,16 @@ namespace System.Windows.Forms public bool ShowColor { set { - showColor = value; + if (value != showColor) + { + showColor = value; + if (showColor) + colorComboBox.Show (); + else + colorComboBox.Hide (); + + form.Refresh(); + } } get { @@ -231,7 +554,16 @@ namespace System.Windows.Forms public bool ShowEffects { set { - showEffects = value; + if (value != showEffects) + { + showEffects = value; + if (showEffects) + effectsGroupBox.Show (); + else + effectsGroupBox.Hide (); + + form.Refresh(); + } } get { @@ -243,7 +575,16 @@ namespace System.Windows.Forms public bool ShowHelp { set { - showHelp = value; + if (value != showHelp) + { + showHelp = value; + if (showHelp) + helpButton.Show (); + else + helpButton.Hide (); + + form.Refresh(); + } } get { @@ -266,13 +607,26 @@ namespace System.Windows.Forms allowVerticalFonts = true; allowScriptChange = true; fixedPitchOnly = false; + maxSize = 0; minSize = 0; + CreateFontSizeListBoxItems (); + scriptsOnly = false; + showApply = false; + applyButton.Hide (); + showColor = false; + colorComboBox.Hide (); + showEffects = true; + effectsGroupBox.Show (); + showHelp = false; + helpButton.Hide (); + + form.Refresh (); } public override string ToString () @@ -287,8 +641,7 @@ namespace System.Windows.Forms [MonoTODO] protected override bool RunDialog( IntPtr hwndOwner ) { - fontDialogPanel = new FontDialogPanel (this); - form.Controls.Add( fontDialogPanel ); + form.Refresh(); return true; } @@ -305,394 +658,28 @@ namespace System.Windows.Forms apply (this, e); } #endregion // Protected Instance Methods - - public event EventHandler Apply { - add { Events.AddHandler (EventApply, value); } - remove { Events.RemoveHandler (EventApply, value); } - } - } - - internal class FontDialogPanel : Panel - { - private Panel examplePanel; - private Button okButton; - private Button cancelButton; - private Button applyButton; - private Button helpButton; - - private TextBox fontTextBox; - private TextBox fontstyleTextBox; - private TextBox sizeTextBox; - - private ListBox fontListBox; - private ListBox fontstyleListBox; - private ListBox sizeListBox; - - private GroupBox effectsGroupBox; - private CheckBox strikethroughCheckBox; - private CheckBox underlinedCheckBox; - private ComboBox scriptComboBox; - - private Label fontLabel; - private Label fontstyleLabel; - private Label sizeLabel; - private Label scriptLabel; - - private GroupBox exampleGroupBox; - - private ColorComboBox colorComboBox; - - private FontFamily[] fontFamilies; - - private string currentFontName; - - private Font currentFont; - - private int currentSize; - - private FontFamily currentFamily; - - private Color currentColor; - - private FontStyle currentFontStyle; - - private FontDialog fontDialog; - - private System.Collections.ArrayList fontStyleArray = new System.Collections.ArrayList(); - - private System.Collections.Hashtable fontHash = new System.Collections.Hashtable(); - - public FontDialogPanel( FontDialog fontDialog ) - { - this.fontDialog = fontDialog; - - okButton = new Button( ); - cancelButton = new Button( ); - applyButton = new Button( ); - helpButton = new Button( ); - - fontTextBox = new TextBox( ); - fontstyleTextBox = new TextBox( ); - sizeTextBox = new TextBox( ); - - fontListBox = new ListBox( ); - sizeListBox = new ListBox( ); - - fontLabel = new Label( ); - fontstyleLabel = new Label( ); - sizeLabel = new Label( ); - scriptLabel = new Label( ); - - exampleGroupBox = new GroupBox( ); - fontstyleListBox = new ListBox( ); - - effectsGroupBox = new GroupBox( ); - underlinedCheckBox = new CheckBox( ); - strikethroughCheckBox = new CheckBox( ); - scriptComboBox = new ComboBox( ); - - examplePanel = new Panel( ); - - colorComboBox = new ColorComboBox( this ); - - exampleGroupBox.SuspendLayout( ); - effectsGroupBox.SuspendLayout( ); - SuspendLayout( ); - - // typesizeListBox - sizeListBox.Location = new Point( 284, 47 ); - sizeListBox.Size = new Size( 52, 95 ); - sizeListBox.TabIndex = 10; - // fontTextBox - fontTextBox.Location = new Point( 16, 26 ); - fontTextBox.Size = new Size( 140, 21 ); - fontTextBox.TabIndex = 5; - fontTextBox.Text = ""; - // fontstyleLabel - fontstyleLabel.Location = new Point( 164, 10 ); - fontstyleLabel.Size = new Size( 100, 16 ); - fontstyleLabel.TabIndex = 1; - fontstyleLabel.Text = "Font Style:"; - // typesizeTextBox - sizeTextBox.Location = new Point( 284, 26 ); - sizeTextBox.Size = new Size( 52, 21 ); - sizeTextBox.TabIndex = 7; - sizeTextBox.Text = ""; - // schriftartListBox - fontListBox.Location = new Point( 16, 47 ); - fontListBox.Size = new Size( 140, 95 ); - fontListBox.TabIndex = 8; - fontListBox.Sorted = true; - // exampleGroupBox - exampleGroupBox.Controls.Add( examplePanel ); - exampleGroupBox.FlatStyle = FlatStyle.System; - exampleGroupBox.Location = new Point( 164, 158 ); - exampleGroupBox.Size = new Size( 172, 70 ); - exampleGroupBox.TabIndex = 12; - exampleGroupBox.TabStop = false; - exampleGroupBox.Text = "Example"; - // fontstyleListBox - fontstyleListBox.Location = new Point( 164, 47 ); - fontstyleListBox.Size = new Size( 112, 95 ); - fontstyleListBox.TabIndex = 9; - // schriftartLabel - fontLabel.Location = new Point( 16, 10 ); - fontLabel.Size = new Size( 88, 16 ); - fontLabel.TabIndex = 0; - fontLabel.Text = "Font:"; - // effectsGroupBox - effectsGroupBox.Controls.Add( underlinedCheckBox ); - effectsGroupBox.Controls.Add( strikethroughCheckBox ); - effectsGroupBox.Controls.Add( colorComboBox ); - effectsGroupBox.FlatStyle = FlatStyle.System; - effectsGroupBox.Location = new Point( 16, 158 ); - effectsGroupBox.Size = new Size( 140, 116 ); - effectsGroupBox.TabIndex = 11; - effectsGroupBox.TabStop = false; - effectsGroupBox.Text = "Effects"; - // strikethroughCheckBox - strikethroughCheckBox.FlatStyle = FlatStyle.System; - strikethroughCheckBox.Location = new Point( 8, 16 ); - strikethroughCheckBox.TabIndex = 0; - strikethroughCheckBox.Text = "Strikethrough"; - // colorComboBox - colorComboBox.Location = new Point( 8, 70 ); - colorComboBox.Size = new Size( 130, 21 ); - // sizeLabel - sizeLabel.Location = new Point( 284, 10 ); - sizeLabel.Size = new Size( 100, 16 ); - sizeLabel.TabIndex = 2; - sizeLabel.Text = "Size:"; - // scriptComboBox - scriptComboBox.Location = new Point( 164, 253 ); - scriptComboBox.Size = new Size( 172, 21 ); - scriptComboBox.TabIndex = 14; - scriptComboBox.Text = "-/-"; - // okButton - okButton.FlatStyle = FlatStyle.System; - okButton.Location = new Point( 352, 26 ); - okButton.Size = new Size( 70, 23 ); - okButton.TabIndex = 3; - okButton.Text = "OK"; - // cancelButton - cancelButton.FlatStyle = FlatStyle.System; - cancelButton.Location = new Point( 352, 52 ); - cancelButton.Size = new Size( 70, 23 ); - cancelButton.TabIndex = 4; - cancelButton.Text = "Cancel"; - // applyButton - applyButton.FlatStyle = FlatStyle.System; - applyButton.Location = new Point( 352, 78 ); - applyButton.Size = new Size( 70, 23 ); - applyButton.TabIndex = 5; - applyButton.Text = "Apply"; - // helpButton - helpButton.FlatStyle = FlatStyle.System; - helpButton.Location = new Point( 352, 104 ); - helpButton.Size = new Size( 70, 23 ); - helpButton.TabIndex = 6; - helpButton.Text = "Help"; - // underlinedCheckBox - underlinedCheckBox.FlatStyle = FlatStyle.System; - underlinedCheckBox.Location = new Point( 8, 36 ); - underlinedCheckBox.TabIndex = 1; - underlinedCheckBox.Text = "Underlined"; - // fontstyleTextBox - fontstyleTextBox.Location = new Point( 164, 26 ); - fontstyleTextBox.Size = new Size( 112, 21 ); - fontstyleTextBox.TabIndex = 6; - fontstyleTextBox.Text = ""; - // scriptLabel - scriptLabel.Location = new Point( 164, 236 ); - scriptLabel.Size = new Size( 100, 16 ); - scriptLabel.TabIndex = 13; - scriptLabel.Text = "Script:"; - // examplePanel - examplePanel.Location = new Point( 8, 20 ); - examplePanel.TabIndex = 0; - examplePanel.BorderStyle = BorderStyle.Fixed3D; - examplePanel.Size = new Size( 156, 40 ); - - ClientSize = new Size( 430, 318 ); - - Controls.Add( scriptComboBox ); - Controls.Add( scriptLabel ); - Controls.Add( exampleGroupBox ); - Controls.Add( effectsGroupBox ); - Controls.Add( sizeListBox ); - Controls.Add( fontstyleListBox ); - Controls.Add( fontListBox ); - Controls.Add( sizeTextBox ); - Controls.Add( fontstyleTextBox ); - Controls.Add( fontTextBox ); - Controls.Add( cancelButton ); - Controls.Add( okButton ); - Controls.Add( sizeLabel ); - Controls.Add( fontstyleLabel ); - Controls.Add( fontLabel ); - Controls.Add( applyButton ); - Controls.Add( helpButton ); - - exampleGroupBox.ResumeLayout( false ); - effectsGroupBox.ResumeLayout( false ); - - ResumeLayout( false ); - - fontFamilies = FontFamily.Families; - - fontListBox.BeginUpdate( ); - foreach ( FontFamily ff in fontFamilies ) - { - if ( !fontHash.ContainsKey (ff.Name) ) { - fontListBox.Items.Add( ff.Name ); - fontHash.Add( ff.Name, ff ); - } - } - fontListBox.EndUpdate( ); - - fontListBox.SelectedIndex = 0; - - // TODO: If Font is provided via FontDialog.Font property set correct font in FontListBox - currentFontName = fontListBox.Items[ 0 ].ToString( ); - fontTextBox.Text = currentFontName; - - // default 12 ?!? - currentSize = 12; - - currentFamily = FindByName( currentFontName ); - - currentFontStyle = FontStyle.Regular; - - currentFont = new Font( currentFamily, currentSize, currentFontStyle ); - - currentColor = fontDialog.Color; - - UpdateFontStyleListBox( ); - - fontstyleTextBox.Text = "Regular"; - - fontstyleListBox.SelectedIndex = 0 ; - - sizeTextBox.Text = currentSize.ToString( ); - - sizeListBox.Items.AddRange( new object[] { - "8", - "9", - "10", - "11", - "12", - "14", - "16", - "18", - "20", - "22", - "24", - "26", - "28", - "36", - "48", - "72" } ); - - sizeListBox.SelectedIndex = 4; - - if ( !fontDialog.ShowApply ) - applyButton.Hide( ); - if ( !fontDialog.ShowHelp ) - helpButton.Hide( ); - if ( !fontDialog.ShowEffects ) - effectsGroupBox.Hide( ); - if ( !fontDialog.ShowColor ) - colorComboBox.Hide( ); - - cancelButton.Click += new EventHandler( OnClickCancelButton ); - okButton.Click += new EventHandler( OnClickOkButton ); - applyButton.Click += new EventHandler (fontDialog.OnApplyButton); - examplePanel.Paint += new PaintEventHandler( OnPaintExamplePanel ); - fontListBox.SelectedIndexChanged += new EventHandler( OnSelectedIndexChangedFontListBox ); - sizeListBox.SelectedIndexChanged += new EventHandler( OnSelectedIndexChangedSizeListBox ); - fontstyleListBox.SelectedIndexChanged += new EventHandler( OnSelectedIndexChangedFontStyleListBox ); - underlinedCheckBox.CheckedChanged += new EventHandler( OnCheckedChangedUnderlinedCheckBox ); - strikethroughCheckBox.CheckedChanged += new EventHandler( OnCheckedChangedStrikethroughCheckBox ); - } - - public Color CurrentColor - { - set { - currentColor = value; - examplePanel.Invalidate( ); - } - - get { - return currentColor; - } - } - - private void UpdateFontStyleListBox( ) - { - // don't know if that works, IsStyleAvailable returns true for all styles under X - - fontStyleArray.Clear( ); - - fontstyleListBox.BeginUpdate( ); - - fontstyleListBox.Items.Clear( ); - - if ( currentFamily.IsStyleAvailable( FontStyle.Regular ) ) - { - fontstyleListBox.Items.Add( "Regular" ); - fontStyleArray.Add( 0 ); - } - - if ( currentFamily.IsStyleAvailable( FontStyle.Bold ) ) - { - fontstyleListBox.Items.Add( "Bold" ); - fontStyleArray.Add( 1 ); - } - - if ( currentFamily.IsStyleAvailable( FontStyle.Italic ) ) - { - fontstyleListBox.Items.Add( "Italic" ); - fontStyleArray.Add( 2 ); - } - - if ( currentFamily.IsStyleAvailable( FontStyle.Bold ) && currentFamily.IsStyleAvailable( FontStyle.Italic ) ) - { - fontstyleListBox.Items.Add( "Bold Italic" ); - fontStyleArray.Add( 3 ); - } - - fontstyleListBox.EndUpdate( ); - } - - private FontFamily FindByName( string name ) - { - return fontHash[ name ] as FontFamily; - } - - void OnClickCancelButton( object sender, EventArgs e ) - { - fontDialog.form.Controls.Remove( this ); - fontDialog.form.DialogResult = DialogResult.Cancel; - } + void OnClickCancelButton( object sender, EventArgs e ) + { + form.DialogResult = DialogResult.Cancel; + } void OnClickOkButton( object sender, EventArgs e ) { - fontDialog.form.Controls.Remove( this ); - fontDialog.Font = currentFont; - fontDialog.Color = currentColor; - fontDialog.form.DialogResult = DialogResult.OK; + form.DialogResult = DialogResult.OK; } - + void OnPaintExamplePanel( object sender, PaintEventArgs e ) { - SolidBrush brush = ThemeEngine.Current.ResPool.GetSolidBrush( currentColor ); + SolidBrush brush = ThemeEngine.Current.ResPool.GetSolidBrush( color ); e.Graphics.FillRectangle( ThemeEngine.Current.ResPool.GetSolidBrush( SystemColors.Control ), 0, 0, 156, 40 ); + ControlPaint.DrawBorder3D(e.Graphics, e.ClipRectangle, Border3DStyle.SunkenInner); + string text = "AaBbYyZz"; - SizeF fontSizeF = e.Graphics.MeasureString( text, currentFont ); + SizeF fontSizeF = e.Graphics.MeasureString( text, font ); int text_width = (int)fontSizeF.Width; int text_height = (int)fontSizeF.Height; @@ -702,7 +689,7 @@ namespace System.Windows.Forms int y = ( examplePanel.Height / 2 ) - ( text_height / 2 ); - e.Graphics.DrawString( text, currentFont, brush, new Point( x, y ) ); + e.Graphics.DrawString( text, font, brush, new Point( x, y ) ); } void OnSelectedIndexChangedFontListBox( object sender, EventArgs e ) @@ -713,21 +700,30 @@ namespace System.Windows.Forms fontTextBox.Text = currentFamily.Name; + internal_change = true; + UpdateFontStyleListBox( ); - UpdateExamplePanel( ); + UpdateFontSizeListBox (); + + form.Select(fontTextBox); + + internal_change = false; } } void OnSelectedIndexChangedSizeListBox( object sender, EventArgs e ) { - if ( sizeListBox.SelectedIndex != -1 ) + if ( fontsizeListBox.SelectedIndex != -1 ) { - currentSize = System.Convert.ToInt32( sizeListBox.Items[ sizeListBox.SelectedIndex ] ); + currentSize = (float)System.Convert.ToDouble( fontsizeListBox.Items[ fontsizeListBox.SelectedIndex ] ); - sizeTextBox.Text = currentSize.ToString( ); + fontsizeTextBox.Text = currentSize.ToString( ); UpdateExamplePanel( ); + + if (!internal_change) + form.Select(fontsizeTextBox); } } @@ -735,57 +731,209 @@ namespace System.Windows.Forms { if ( fontstyleListBox.SelectedIndex != -1 ) { - switch ( (int)fontStyleArray[ fontstyleListBox.SelectedIndex ] ) + switch ( fontstyleListBox.SelectedIndex ) { - case 0: - currentFontStyle = FontStyle.Regular; - break; - case 1: - currentFontStyle = FontStyle.Bold; - break; - case 2: - currentFontStyle = FontStyle.Italic; - break; - case 3: - currentFontStyle = FontStyle.Bold | FontStyle.Italic; - break; - default: - currentFontStyle = FontStyle.Regular; - break; + case 0: + currentFontStyle = FontStyle.Regular; + break; + case 1: + currentFontStyle = FontStyle.Bold; + break; + case 2: + currentFontStyle = FontStyle.Italic; + break; + case 3: + currentFontStyle = FontStyle.Bold | FontStyle.Italic; + break; + default: + currentFontStyle = FontStyle.Regular; + break; } + if (underlined) + currentFontStyle = currentFontStyle | FontStyle.Underline; + + if (strikethrough) + currentFontStyle = currentFontStyle | FontStyle.Strikeout; + fontstyleTextBox.Text = fontstyleListBox.Items[ fontstyleListBox.SelectedIndex ].ToString( ); - UpdateExamplePanel( ); + if (!internal_change) { + UpdateExamplePanel( ); + + form.Select(fontstyleTextBox); + } } } void OnCheckedChangedUnderlinedCheckBox( object sender, EventArgs e ) { - if ( underlinedCheckBox.Checked ) + if ( underlinedCheckBox.Checked ) { currentFontStyle = currentFontStyle | FontStyle.Underline; - else + underlined = true; + } + else { currentFontStyle = currentFontStyle ^ FontStyle.Underline; + underlined = false; + } UpdateExamplePanel( ); } void OnCheckedChangedStrikethroughCheckBox( object sender, EventArgs e ) { - if ( strikethroughCheckBox.Checked ) + if ( strikethroughCheckBox.Checked ) { currentFontStyle = currentFontStyle | FontStyle.Strikeout; - else + strikethrough = true; + } + else { currentFontStyle = currentFontStyle ^ FontStyle.Strikeout; + strikethrough = false; + } UpdateExamplePanel( ); } - private void UpdateExamplePanel( ) + void OnFontTextBoxKeyUp (object sender, EventArgs e) + { + for (int i = 0; i < fontListBox.Items.Count; i++) { + string name = fontListBox.Items [i] as string; + + if (name.StartsWith(fontTextBox.Text)) { + if (name == fontTextBox.Text) + fontListBox.SelectedIndex = i; + else + fontListBox.TopIndex = i; + + break; + } + } + } + + void OnFontStyleTextBoxKeyUp (object sender, KeyEventArgs e) + { + for (int i = 0; i < fontstyleListBox.Items.Count; i++) { + string name = fontstyleListBox.Items [i] as string; + + if (name.StartsWith(fontstyleTextBox.Text)) { + if (name == fontstyleTextBox.Text) + fontstyleListBox.SelectedIndex = i; + else + fontstyleListBox.TopIndex = i; + + break; + } + } + } + + void OnFontSizeTextBoxKeyUp (object sender, KeyEventArgs e) { - currentFont = new Font( currentFamily, currentSize, currentFontStyle ); + for (int i = 0; i < fontsizeListBox.Items.Count; i++) { + string name = fontsizeListBox.Items [i] as string; + + if (name.StartsWith(fontsizeTextBox.Text)) { + if (name == fontsizeTextBox.Text) + fontsizeListBox.SelectedIndex = i; + else + fontsizeListBox.TopIndex = i; + + break; + } + } + } + + void UpdateExamplePanel( ) + { + if (font != null) + font.Dispose(); + + font = new Font( currentFamily, currentSize, currentFontStyle ); examplePanel.Invalidate( ); - examplePanel.Update( ); + } + + void UpdateFontSizeListBox () + { + int index = fontsizeListBox.FindString(currentSize.ToString()); + + if (index != -1) + fontsizeListBox.SelectedIndex = index; + else + fontsizeListBox.SelectedIndex = 0; + } + + void UpdateFontStyleListBox( ) + { + // don't know if that works, IsStyleAvailable returns true for all styles under X + + fontstyleListBox.BeginUpdate( ); + + fontstyleListBox.Items.Clear( ); + + int index = -1; + int to_select = 0; + + if ( currentFamily.IsStyleAvailable( FontStyle.Regular ) ) + { + index = fontstyleListBox.Items.Add( "Regular" ); + + if ((currentFontStyle & FontStyle.Regular) == FontStyle.Regular) + to_select = index; + } + + if ( currentFamily.IsStyleAvailable( FontStyle.Bold ) ) + { + index = fontstyleListBox.Items.Add( "Bold" ); + + if ((currentFontStyle & FontStyle.Bold) == FontStyle.Bold) + to_select = index; + } + + if ( currentFamily.IsStyleAvailable( FontStyle.Italic ) ) + { + index = fontstyleListBox.Items.Add( "Italic" ); + + if ((currentFontStyle & FontStyle.Italic) == FontStyle.Italic) + to_select = index; + } + + if ( currentFamily.IsStyleAvailable( FontStyle.Bold ) && currentFamily.IsStyleAvailable( FontStyle.Italic ) ) + { + index = fontstyleListBox.Items.Add( "Bold Italic" ); + + if ((currentFontStyle & (FontStyle.Bold | FontStyle.Italic)) == (FontStyle.Bold | FontStyle.Italic)) + to_select = index; + } + + if (fontstyleListBox.Items.Count > 0) + fontstyleListBox.SelectedIndex = to_select; + + fontstyleListBox.EndUpdate( ); + } + + FontFamily FindByName( string name ) + { + return fontHash[ name ] as FontFamily; + } + + void CreateFontSizeListBoxItems () + { + fontsizeListBox.BeginUpdate (); + + fontsizeListBox.Items. Clear(); + + if (minSize == 0 && maxSize == 0) + { + foreach (int i in a_sizes) + fontsizeListBox.Items.Add (i.ToString()); + } else { + foreach (int i in a_sizes) { + if (i >= minSize && i <= maxSize) + fontsizeListBox.Items.Add (i.ToString()); + } + } + + fontsizeListBox.EndUpdate (); } internal class ColorComboBox : ComboBox @@ -826,13 +974,11 @@ namespace System.Windows.Forms private Color selectedColor; - private FontDialogPanel fontDialogPanel; + private FontDialog fontDialog; - // FIXME: TextBox backcolor shouldn't be the same as the selected item in the ListBox/ListCtrl - - public ColorComboBox( FontDialogPanel fontDialogPanel ) + public ColorComboBox( FontDialog fontDialog ) { - this.fontDialogPanel = fontDialogPanel; + this.fontDialog = fontDialog; DropDownStyle = ComboBoxStyle.DropDownList; DrawMode = DrawMode.OwnerDrawFixed; @@ -872,15 +1018,15 @@ namespace System.Windows.Forms if ( ( e.State & DrawItemState.Selected ) == DrawItemState.Selected ) { e.Graphics.FillRectangle( ThemeEngine.Current.ResPool.GetSolidBrush( Color.Blue ), e.Bounds ); // bot blue - e.Graphics.FillRectangle( ThemeEngine.Current.ResPool.GetSolidBrush( ccbi.Color ), e.Bounds.X + 3, e.Bounds.Y + 3, e.Bounds.X + 16, e.Bounds.Y + e.Bounds.Height - 2 ); - e.Graphics.DrawRectangle( ThemeEngine.Current.ResPool.GetPen( Color.Black ), e.Bounds.X + 2, e. Bounds.Y + 2, e.Bounds.X + 17, e.Bounds.Y + e.Bounds.Height - 1 ); + e.Graphics.FillRectangle( ThemeEngine.Current.ResPool.GetSolidBrush( ccbi.Color ), e.Bounds.X + 3, e.Bounds.Y + 3, e.Bounds.X + 16, e.Bounds.Bottom - 3 ); + e.Graphics.DrawRectangle( ThemeEngine.Current.ResPool.GetPen( Color.Black ), e.Bounds.X + 2, e. Bounds.Y + 2, e.Bounds.X + 17, e.Bounds.Bottom - 3 ); e.Graphics.DrawString( ccbi.Name, this.Font, ThemeEngine.Current.ResPool.GetSolidBrush( Color.White ), r ); } else { e.Graphics.FillRectangle( ThemeEngine.Current.ResPool.GetSolidBrush( Color.White ), e.Bounds ); - e.Graphics.FillRectangle( ThemeEngine.Current.ResPool.GetSolidBrush( ccbi.Color ), e.Bounds.X + 3, e.Bounds.Y + 3, e.Bounds.X + 16, e.Bounds.Y + e.Bounds.Height - 2 ); - e.Graphics.DrawRectangle( ThemeEngine.Current.ResPool.GetPen( Color.Black ), e.Bounds.X + 2, e. Bounds.Y + 2, e.Bounds.X + 17, e.Bounds.Y + e.Bounds.Height - 1 ); + e.Graphics.FillRectangle( ThemeEngine.Current.ResPool.GetSolidBrush( ccbi.Color ), e.Bounds.X + 3, e.Bounds.Y + 3, e.Bounds.X + 16, e.Bounds.Bottom - 3 ); + e.Graphics.DrawRectangle( ThemeEngine.Current.ResPool.GetPen( Color.Black ), e.Bounds.X + 2, e. Bounds.Y + 2, e.Bounds.X + 17, e.Bounds.Bottom - 3 ); e.Graphics.DrawString( ccbi.Name, this.Font, ThemeEngine.Current.ResPool.GetSolidBrush( Color.Black ), r ); } } @@ -890,8 +1036,14 @@ namespace System.Windows.Forms ColorComboBoxItem ccbi = Items[ SelectedIndex ] as ColorComboBoxItem; selectedColor = ccbi.Color; - fontDialogPanel.CurrentColor = selectedColor; + fontDialog.Color = selectedColor; } } + + public event EventHandler Apply { + add { Events.AddHandler (EventApply, value); } + remove { Events.RemoveHandler (EventApply, value); } + } } } + -- cgit v1.2.3 From c0fea8c79efa5b43f1afa52290f75411ac923ac9 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Tue, 28 Feb 2006 19:15:28 +0000 Subject: In System.Web: 2006-02-28 Chris Toshok * HttpCookieMode.cs: corcompare work. * ProcessShutdownReason.cs: same. * SiteMapNodeCollection.cs: same. * SiteMapNode.cs: same. * SiteMapProvider.cs: same. * HttpCacheRevalidation.cs: same. * HttpCacheability.cs: same. * StaticSiteMapProvider.cs: same. * HttpValidationStatus.cs: same. In System.Web.SessionState: * SessionStateActions.cs: oops, actually rename the enum, not just the file. 2006-02-28 Chris Toshok svn path=/trunk/mcs/; revision=57414 --- .../System.Web/System.Web.SessionState/ChangeLog | 5 +++++ .../System.Web.SessionState/SessionStateActions.cs | 4 ++-- mcs/class/System.Web/System.Web/ChangeLog | 20 ++++++++++++++++++++ .../System.Web/System.Web/HttpCacheRevalidation.cs | 2 ++ mcs/class/System.Web/System.Web/HttpCacheability.cs | 2 ++ mcs/class/System.Web/System.Web/HttpCookieMode.cs | 2 ++ .../System.Web/System.Web/HttpValidationStatus.cs | 2 ++ .../System.Web/System.Web/ProcessShutdownReason.cs | 2 ++ mcs/class/System.Web/System.Web/SiteMapNode.cs | 8 ++++---- .../System.Web/System.Web/SiteMapNodeCollection.cs | 6 +++--- mcs/class/System.Web/System.Web/SiteMapProvider.cs | 2 +- .../System.Web/System.Web/StaticSiteMapProvider.cs | 2 +- 12 files changed, 46 insertions(+), 11 deletions(-) (limited to 'mcs') diff --git a/mcs/class/System.Web/System.Web.SessionState/ChangeLog b/mcs/class/System.Web/System.Web.SessionState/ChangeLog index 05c42bdbff2..6c6833ac848 100644 --- a/mcs/class/System.Web/System.Web.SessionState/ChangeLog +++ b/mcs/class/System.Web/System.Web.SessionState/ChangeLog @@ -1,3 +1,8 @@ +2006-02-28 Chris Toshok + + * SessionStateActions.cs: oops, actually rename the enum, not just + the file. + 2006-02-28 Chris Toshok * SessionStateActions.cs: rename SessionStateActionFlags to this. diff --git a/mcs/class/System.Web/System.Web.SessionState/SessionStateActions.cs b/mcs/class/System.Web/System.Web.SessionState/SessionStateActions.cs index 52a10def8ee..f3bfc7ec039 100644 --- a/mcs/class/System.Web/System.Web.SessionState/SessionStateActions.cs +++ b/mcs/class/System.Web/System.Web.SessionState/SessionStateActions.cs @@ -1,5 +1,5 @@ // -// System.Web.SessionState.SessionStateActionFlags.cs +// System.Web.SessionState.SessionStateActions.cs // // Authors: // Sanjay Gupta (gsanjay@novell.com) @@ -28,7 +28,7 @@ #if NET_2_0 namespace System.Web.SessionState { - public enum SessionStateActionFlags { + public enum SessionStateActions { InitializeItem = 1 } } diff --git a/mcs/class/System.Web/System.Web/ChangeLog b/mcs/class/System.Web/System.Web/ChangeLog index 23974f448bd..f5d79e55ac4 100644 --- a/mcs/class/System.Web/System.Web/ChangeLog +++ b/mcs/class/System.Web/System.Web/ChangeLog @@ -1,3 +1,23 @@ +2006-02-28 Chris Toshok + + * HttpCookieMode.cs: corcompare work. + + * ProcessShutdownReason.cs: same. + + * SiteMapNodeCollection.cs: same. + + * SiteMapNode.cs: same. + + * SiteMapProvider.cs: same. + + * HttpCacheRevalidation.cs: same. + + * HttpCacheability.cs: same. + + * StaticSiteMapProvider.cs: same. + + * HttpValidationStatus.cs: same. + 2006-02-06 Gonzalo Paniagua Javier * DefaultHttpHandler.cs: New file. diff --git a/mcs/class/System.Web/System.Web/HttpCacheRevalidation.cs b/mcs/class/System.Web/System.Web/HttpCacheRevalidation.cs index afb4f5181eb..81fdf21ff2c 100644 --- a/mcs/class/System.Web/System.Web/HttpCacheRevalidation.cs +++ b/mcs/class/System.Web/System.Web/HttpCacheRevalidation.cs @@ -29,7 +29,9 @@ // namespace System.Web { +#if !NET_2_0 [Serializable] +#endif public enum HttpCacheRevalidation { AllCaches = 0x1, ProxyCaches, diff --git a/mcs/class/System.Web/System.Web/HttpCacheability.cs b/mcs/class/System.Web/System.Web/HttpCacheability.cs index f8f4fcb2923..abf0a0c2af4 100644 --- a/mcs/class/System.Web/System.Web/HttpCacheability.cs +++ b/mcs/class/System.Web/System.Web/HttpCacheability.cs @@ -29,7 +29,9 @@ // namespace System.Web { +#if !NET_2_0 [Serializable] +#endif public enum HttpCacheability { NoCache = 0x1, Private, diff --git a/mcs/class/System.Web/System.Web/HttpCookieMode.cs b/mcs/class/System.Web/System.Web/HttpCookieMode.cs index bc48d6bb95a..9bcadf217d2 100644 --- a/mcs/class/System.Web/System.Web/HttpCookieMode.cs +++ b/mcs/class/System.Web/System.Web/HttpCookieMode.cs @@ -29,7 +29,9 @@ #if NET_2_0 namespace System.Web { +#if !NET_2_0 [Serializable] +#endif public enum HttpCookieMode { UseUri = 0, diff --git a/mcs/class/System.Web/System.Web/HttpValidationStatus.cs b/mcs/class/System.Web/System.Web/HttpValidationStatus.cs index b8e873452f6..d30201becaf 100644 --- a/mcs/class/System.Web/System.Web/HttpValidationStatus.cs +++ b/mcs/class/System.Web/System.Web/HttpValidationStatus.cs @@ -29,7 +29,9 @@ // namespace System.Web { +#if !NET_2_0 [Serializable] +#endif public enum HttpValidationStatus { Invalid = 0x1, IgnoreThisRequest, diff --git a/mcs/class/System.Web/System.Web/ProcessShutdownReason.cs b/mcs/class/System.Web/System.Web/ProcessShutdownReason.cs index b8cba9d6809..f98a9d9793a 100644 --- a/mcs/class/System.Web/System.Web/ProcessShutdownReason.cs +++ b/mcs/class/System.Web/System.Web/ProcessShutdownReason.cs @@ -29,7 +29,9 @@ // namespace System.Web { +#if !NET_2_0 [Serializable] +#endif public enum ProcessShutdownReason { None, Unexpected, diff --git a/mcs/class/System.Web/System.Web/SiteMapNode.cs b/mcs/class/System.Web/System.Web/SiteMapNode.cs index 1ffac4dcf38..388a7e3a70f 100644 --- a/mcs/class/System.Web/System.Web/SiteMapNode.cs +++ b/mcs/class/System.Web/System.Web/SiteMapNode.cs @@ -73,7 +73,7 @@ namespace System.Web { return new SiteMapHierarchicalDataSourceView (this); } - public bool IsAccessibleToUser (System.Web.HttpContext ctx) + public virtual bool IsAccessibleToUser (System.Web.HttpContext ctx) { return provider.IsAccessibleToUser (ctx, this); } @@ -200,7 +200,7 @@ namespace System.Web { } [MonoTODO ("resource string?")] - public string this [string key] + public virtual string this [string key] { get { string val = null; @@ -284,7 +284,7 @@ namespace System.Web { #region Field Accessors - public virtual NameValueCollection Attributes { + protected NameValueCollection Attributes { get { return attributes; } set { CheckWritable (); attributes = value; } } @@ -306,7 +306,7 @@ namespace System.Web { set { CheckWritable (); url = value; } } - public virtual IList Roles { + public IList Roles { get { return roles; } set { CheckWritable (); roles = value; } } diff --git a/mcs/class/System.Web/System.Web/SiteMapNodeCollection.cs b/mcs/class/System.Web/System.Web/SiteMapNodeCollection.cs index 2c5bd5e1478..13b1536666b 100644 --- a/mcs/class/System.Web/System.Web/SiteMapNodeCollection.cs +++ b/mcs/class/System.Web/System.Web/SiteMapNodeCollection.cs @@ -137,17 +137,17 @@ namespace System.Web List.AddRange (value); } - public bool Contains (SiteMapNode value) + public virtual bool Contains (SiteMapNode value) { return this.List.Contains (value); } - public void CopyTo (System.Web.SiteMapNode[] array, int index) + public virtual void CopyTo (System.Web.SiteMapNode[] array, int index) { this.List.CopyTo (array, index); } - public int IndexOf (SiteMapNode value) + public virtual int IndexOf (SiteMapNode value) { return this.List.IndexOf (value); } diff --git a/mcs/class/System.Web/System.Web/SiteMapProvider.cs b/mcs/class/System.Web/System.Web/SiteMapProvider.cs index 731c2773fed..b427c399192 100644 --- a/mcs/class/System.Web/System.Web/SiteMapProvider.cs +++ b/mcs/class/System.Web/System.Web/SiteMapProvider.cs @@ -150,7 +150,7 @@ namespace System.Web { if (node == null) throw new ArgumentNullException ("node"); } - public virtual void RemoveNode (SiteMapNode node) + protected virtual void RemoveNode (SiteMapNode node) { if (node == null) throw new ArgumentNullException("node"); diff --git a/mcs/class/System.Web/System.Web/StaticSiteMapProvider.cs b/mcs/class/System.Web/System.Web/StaticSiteMapProvider.cs index 3f12df44b0f..474ece1c7bc 100644 --- a/mcs/class/System.Web/System.Web/StaticSiteMapProvider.cs +++ b/mcs/class/System.Web/System.Web/StaticSiteMapProvider.cs @@ -195,7 +195,7 @@ namespace System.Web return parent != null && IsAccessibleToUser (HttpContext.Current, parent) ? parent : null; } - public override void RemoveNode (SiteMapNode node) + protected override void RemoveNode (SiteMapNode node) { if (node == null) throw new ArgumentNullException("node"); -- cgit v1.2.3 From 181d10350c45a24acf0e79dabdaeb3acd03fc1aa Mon Sep 17 00:00:00 2001 From: Gert Driesen Date: Tue, 28 Feb 2006 19:18:36 +0000 Subject: * XmlSchema.cs: Do not define namespace for zero-length TargetNamespace and report XmlSchemaException when compiling XmlSchema with zero-length TargetNamespace. Fixes bug #77391. * XmlSchemaTests.cs: Added test for writing XmlSchema with zero-length TargetNamespace. Added test for compiling XmlSchema with zero-length TargetNamespace. Replaced Console.WriteLine with AssertEquals. svn path=/trunk/mcs/; revision=57415 --- mcs/class/System.XML/System.Xml.Schema/ChangeLog | 6 +++++ .../System.XML/System.Xml.Schema/XmlSchema.cs | 5 +++- .../System.XML/Test/System.Xml.Schema/ChangeLog | 7 ++++++ .../Test/System.Xml.Schema/XmlSchemaTests.cs | 27 ++++++++++++++++++++-- 4 files changed, 42 insertions(+), 3 deletions(-) (limited to 'mcs') diff --git a/mcs/class/System.XML/System.Xml.Schema/ChangeLog b/mcs/class/System.XML/System.Xml.Schema/ChangeLog index f63091447d8..8b742ced204 100644 --- a/mcs/class/System.XML/System.Xml.Schema/ChangeLog +++ b/mcs/class/System.XML/System.Xml.Schema/ChangeLog @@ -1,3 +1,9 @@ +2006-02-28 Gert Driesen + + * XmlSchema.cs: Do not define namespace for zero-length TargetNamespace + and report XmlSchemaException when compiling XmlSchema with + zero-length TargetNamespace. + 2006-02-01 Atsushi Enomoto * BuiltInDatatype.cs : anyURI could be such relative path that diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs index c415f13c6f8..10fdeedadc2 100644 --- a/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs +++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs @@ -337,6 +337,9 @@ namespace System.Xml.Schema //4. targetNamespace should be of type anyURI or absent if (TargetNamespace != null) { + if (TargetNamespace.Length == 0) + error (handler, "The targetNamespace attribute cannot have have empty string as its value."); + if(!XmlSchemaUtil.CheckAnyUri (TargetNamespace)) error(handler, TargetNamespace+" is not a valid value for targetNamespace attribute of schema"); } @@ -905,7 +908,7 @@ namespace System.Xml.Schema // Add the xml schema namespace. (It is done // only when no entry exists in Namespaces). nss.Add ("xs", XmlSchema.Namespace); - if (TargetNamespace != null) + if (TargetNamespace != null && TargetNamespace.Length != 0) nss.Add ("tns", TargetNamespace); } diff --git a/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog b/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog index fd3032e8ad0..74cc73333c9 100644 --- a/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog +++ b/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog @@ -1,3 +1,10 @@ +2006-02-28 Gert Driesen + + * XmlSchemaTests.cs: Added test for writing XmlSchema with + zero-length TargetNamespace. Added test for compiling XmlSchema + with zero-length TargetNamespace. Replaced Console.WriteLine with + AssertEquals. + 2006-02-06 Atsushi Enomoto * XmlSchemaDatatypeTests.cs: (TestAnyType) NotDotNet -> Ignore. diff --git a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTests.cs b/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTests.cs index cf2e11bf26b..ceb0c971933 100644 --- a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTests.cs +++ b/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTests.cs @@ -130,13 +130,26 @@ namespace MonoTests.System.Xml AssertCompiledElement (element, qname, cType); } + [Test] + [ExpectedException (typeof (XmlSchemaException))] + public void TestCompile_ZeroLength_TargetNamespace () + { + XmlSchema schema = new XmlSchema (); + schema.TargetNamespace = string.Empty; + Assert (!schema.IsCompiled); + + // MS.NET 1.x: The Namespace '' is an invalid URI. + // MS.NET 2.0: The targetNamespace attribute cannot have empty string as its value. + schema.Compile (null); + } + [Test] [ExpectedException (typeof (XmlSchemaException))] public void TestCompileNonSchema () { XmlTextReader xtr = new XmlTextReader ("", XmlNodeType.Document, null); XmlSchema schema = XmlSchema.Read (xtr, null); - xtr.Close (); + xtr.Close (); } [Test] @@ -200,7 +213,17 @@ namespace MonoTests.System.Xml xw = new XmlTextWriter (sw); xs.TargetNamespace = "urn:foo"; xs.Write (xw); - Console.WriteLine ("#2", "", doc.DocumentElement.OuterXml); + doc.LoadXml (sw.ToString ()); + AssertEquals ("#2", "", doc.DocumentElement.OuterXml); + + // Zero-length TargetNamespace + xs = new XmlSchema (); + sw = new StringWriter (); + xw = new XmlTextWriter (sw); + xs.TargetNamespace = string.Empty; + xs.Write (xw); + doc.LoadXml (sw.ToString ()); + AssertEquals ("#2b", "", doc.DocumentElement.OuterXml); // XmlSerializerNamespaces xs = new XmlSchema (); -- cgit v1.2.3 From c11dad3d2fcab65203b5a96f7c58f15cc25e49a4 Mon Sep 17 00:00:00 2001 From: Peter Dennis Bartok Date: Tue, 28 Feb 2006 19:23:42 +0000 Subject: 2006-02-28 Peter Dennis Bartok * ComboBox.cs: Allow setting SelectedIndex to -1. Fixes #77665 svn path=/trunk/mcs/; revision=57416 --- mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog | 4 ++++ mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'mcs') diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index 332eb527ad0..f4c0f751d38 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -1,3 +1,7 @@ +2006-02-28 Peter Dennis Bartok + + * ComboBox.cs: Allow setting SelectedIndex to -1. Fixes #77665 + 2006-02-28 Alexander Olk * FontDialog.cs: diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs index 48e4d9c297d..0ed21f71af4 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs @@ -435,7 +435,11 @@ namespace System.Windows.Forms selected_index = value; if (dropdown_style != ComboBoxStyle.DropDownList) { - SetControlText (GetItemText (Items[selected_index])); + if (selected_index != -1) { + SetControlText (GetItemText (Items[selected_index])); + } else { + SetControlText(""); + } } OnSelectedIndexChanged (new EventArgs ()); -- cgit v1.2.3 From 89944111162bd34d833f3cba592b2d1a78d7085a Mon Sep 17 00:00:00 2001 From: Alexander Olk Date: Tue, 28 Feb 2006 19:25:41 +0000 Subject: - Fix typo svn path=/trunk/mcs/; revision=57417 --- mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog | 1 + mcs/class/Managed.Windows.Forms/System.Windows.Forms/FontDialog.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'mcs') diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index f4c0f751d38..9183d769fc1 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -15,6 +15,7 @@ - Draw the correct 3D border in the example panel - Fixed a little mem leak (unused fonts didn't get disposed) - Many other internal updates/rewrites... + - Fix typo 2006-02-27 Peter Dennis Bartok diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FontDialog.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FontDialog.cs index da89b180aca..a9068149620 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FontDialog.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FontDialog.cs @@ -794,7 +794,7 @@ namespace System.Windows.Forms UpdateExamplePanel( ); } - void OnFontTextBoxKeyUp (object sender, EventArgs e) + void OnFontTextBoxKeyUp (object sender, KeyEventArgs e) { for (int i = 0; i < fontListBox.Items.Count; i++) { string name = fontListBox.Items [i] as string; -- cgit v1.2.3 From 1d51fe5a1bc9f3a6cfca377f449ce4a52cd0dd2f Mon Sep 17 00:00:00 2001 From: Gert Driesen Date: Tue, 28 Feb 2006 19:27:46 +0000 Subject: * XmlSchemaAssertion.cs: Set eol-style to native. * XmlSchemaBuiltInDatatypeTests.cs: Set eol-style to CRLF. * XmlSchemaCollectionTests.cs: Set eol-style to native. Fixed line endings. * XmlSchemaDatatypeTests.cs: Set eol-style to native. * XmlSchemaExceptionCas.cs: Set eol-style to native. * XmlSchemaLengthFacetTests.cs: Set eol-style to CRLF. * XmlSchemaSetTests.cs: Set eol-style to native. * XmlSchemaTests.cs: Set eol-style to native. * XmlSchemaTypeTests.cs: Set eol-style to native.> svn path=/trunk/mcs/; revision=57418 --- mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog | 13 +++++++++++++ .../Test/System.Xml.Schema/XmlSchemaCollectionTests.cs | 18 +++++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) (limited to 'mcs') diff --git a/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog b/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog index 74cc73333c9..bd8051de300 100644 --- a/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog +++ b/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog @@ -1,3 +1,16 @@ +2006-02-28 Gert Driesen + + * XmlSchemaAssertion.cs: Set eol-style to native. + * XmlSchemaBuiltInDatatypeTests.cs: Set eol-style to CRLF. + * XmlSchemaCollectionTests.cs: Set eol-style to native. Fixed line + endings. + * XmlSchemaDatatypeTests.cs: Set eol-style to native. + * XmlSchemaExceptionCas.cs: Set eol-style to native. + * XmlSchemaLengthFacetTests.cs: Set eol-style to CRLF. + * XmlSchemaSetTests.cs: Set eol-style to native. + * XmlSchemaTests.cs: Set eol-style to native. + * XmlSchemaTypeTests.cs: Set eol-style to native.> + 2006-02-28 Gert Driesen * XmlSchemaTests.cs: Added test for writing XmlSchema with diff --git a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaCollectionTests.cs b/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaCollectionTests.cs index a5dae6dff27..27d5bc4a35a 100644 --- a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaCollectionTests.cs +++ b/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaCollectionTests.cs @@ -61,15 +61,15 @@ namespace MonoTests.System.Xml col.Add (schema2); } - [Test] - public void TestAddDoesCompilation () - { - XmlSchema schema = new XmlSchema (); - Assert (!schema.IsCompiled); - XmlSchemaCollection col = new XmlSchemaCollection (); - col.Add (schema); - Assert (schema.IsCompiled); - } + [Test] + public void TestAddDoesCompilation () + { + XmlSchema schema = new XmlSchema (); + Assert (!schema.IsCompiled); + XmlSchemaCollection col = new XmlSchemaCollection (); + col.Add (schema); + Assert (schema.IsCompiled); + } [Test] // bug #75126 public void TestGetEnumerator () -- cgit v1.2.3 From 558cca4186c14affbefe2cde7857bb9f4cd47933 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Tue, 28 Feb 2006 19:41:42 +0000 Subject: 2006-02-28 Chris Toshok * IStateRuntime.cs: wrap new interface method with NET_2_0. svn path=/trunk/mcs/; revision=57420 --- mcs/class/System.Web/System.Web.SessionState/ChangeLog | 4 ++++ mcs/class/System.Web/System.Web.SessionState/IStateRuntime.cs | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'mcs') diff --git a/mcs/class/System.Web/System.Web.SessionState/ChangeLog b/mcs/class/System.Web/System.Web.SessionState/ChangeLog index 6c6833ac848..874bd0500b2 100644 --- a/mcs/class/System.Web/System.Web.SessionState/ChangeLog +++ b/mcs/class/System.Web/System.Web.SessionState/ChangeLog @@ -1,3 +1,7 @@ +2006-02-28 Chris Toshok + + * IStateRuntime.cs: wrap new interface method with NET_2_0. + 2006-02-28 Chris Toshok * SessionStateActions.cs: oops, actually rename the enum, not just diff --git a/mcs/class/System.Web/System.Web.SessionState/IStateRuntime.cs b/mcs/class/System.Web/System.Web.SessionState/IStateRuntime.cs index fb33dfee513..a877f49fa96 100644 --- a/mcs/class/System.Web/System.Web.SessionState/IStateRuntime.cs +++ b/mcs/class/System.Web/System.Web.SessionState/IStateRuntime.cs @@ -51,6 +51,7 @@ namespace System.Web.SessionState [In, MarshalAs(UnmanagedType.I4)] int contentLength, [In, MarshalAs(UnmanagedType.SysInt)] IntPtr content); +#if NET_2_0 void ProcessRequest ( [In, MarshalAs(UnmanagedType.SysInt)] IntPtr tracker, [In, MarshalAs(UnmanagedType.I4)] int verb, @@ -62,7 +63,7 @@ namespace System.Web.SessionState [In, MarshalAs(UnmanagedType.I4)] int lockCookie, [In, MarshalAs(UnmanagedType.I4)] int contentLength, [In, MarshalAs(UnmanagedType.SysInt)] IntPtr content); - +#endif void StopProcessing (); } } -- cgit v1.2.3 From 543a824b06d71ae56e982ead9d213eba6207cad7 Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Tue, 28 Feb 2006 19:46:45 +0000 Subject: 2006-02-28 Mike Kestner * ListView.cs: Add UpdateSelection internal method. Remove SelectItem and set Selected instead. * ListViewItem.cs: Call owner.UpdateSelection to manipulate the collections. svn path=/trunk/mcs/; revision=57421 --- .../System.Windows.Forms/ChangeLog | 7 +++++ .../System.Windows.Forms/ListView.cs | 31 +++++++++++++--------- .../System.Windows.Forms/ListViewItem.cs | 4 ++- 3 files changed, 28 insertions(+), 14 deletions(-) (limited to 'mcs') diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index 9183d769fc1..a795c3cf8b5 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -1,3 +1,10 @@ +2006-02-28 Mike Kestner + + * ListView.cs: Add UpdateSelection internal method. Remove SelectItem + and set Selected instead. + * ListViewItem.cs: Call owner.UpdateSelection to manipulate the + collections. + 2006-02-28 Peter Dennis Bartok * ComboBox.cs: Allow setting SelectedIndex to -1. Fixes #77665 diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs index 70ec71df299..551f6584f1e 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs @@ -911,18 +911,23 @@ namespace System.Windows.Forms } - void SelectItem (ListViewItem item) + internal void UpdateSelection (ListViewItem item) { - if (!CanMultiselect && SelectedItems.Count > 0) { - SelectedItems.Clear (); - SelectedIndices.list.Clear (); - } + if (item.Selected) { - if (!SelectedItems.Contains (item)) { - SelectedItems.list.Add (item); - SelectedIndices.list.Add (item.Index); + if (!CanMultiselect && SelectedItems.Count > 0) { + SelectedItems.Clear (); + SelectedIndices.list.Clear (); + } + + if (!SelectedItems.Contains (item)) { + SelectedItems.list.Add (item); + SelectedIndices.list.Add (item.Index); + } + } else { + SelectedItems.list.Remove (item); + SelectedIndices.list.Remove (item.Index); } - item.Selected = true; } private bool KeySearchString (KeyEventArgs ke) @@ -940,7 +945,7 @@ namespace System.Windows.Forms if (CultureInfo.CurrentCulture.CompareInfo.IsPrefix (Items[i].Text, keysearch_text, CompareOptions.IgnoreCase)) { SetFocusedItem (Items [i]); - SelectItem (items [i]); + items [i].Selected = true; EnsureVisible (i); break; } @@ -1040,7 +1045,7 @@ namespace System.Windows.Forms } if (index != -1) { - SelectItem (items [index]); + items [index].Selected = true; SetFocusedItem (items [index]); EnsureVisible (index); } @@ -1136,7 +1141,7 @@ namespace System.Windows.Forms if (clicked_item != null) { bool changed = !clicked_item.Selected; - SelectItem (clicked_item); + clicked_item.Selected = true;; // Only Raise the event if the selected item has changed if (changed) @@ -1169,7 +1174,7 @@ namespace System.Windows.Forms ListViewItem item = this.GetItemAt (hit.X, hit.Y); if (item != null) { - SelectItem (item); + item.Selected = true; // Raise the event this.OnSelectedIndexChanged (new EventArgs ()); } diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs index 6e5d38ef7fc..53aebae7984 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs @@ -273,8 +273,10 @@ namespace System.Windows.Forms selected = value; - if (owner != null) + if (owner != null) { + owner.UpdateSelection (this); Layout (); + } Invalidate (); } } -- cgit v1.2.3