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/class/Managed.Windows.Forms') 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/class/Managed.Windows.Forms') 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/class/Managed.Windows.Forms') 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/class/Managed.Windows.Forms') 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/class/Managed.Windows.Forms') 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 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/class/Managed.Windows.Forms') 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/class/Managed.Windows.Forms') 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/class/Managed.Windows.Forms') 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/class/Managed.Windows.Forms') 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/class/Managed.Windows.Forms') 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 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/class/Managed.Windows.Forms') 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 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/class/Managed.Windows.Forms') 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/class/Managed.Windows.Forms') 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 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/class/Managed.Windows.Forms') 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