diff options
author | Ravindra <ravindra@mono-cvs.ximian.com> | 2004-10-26 13:33:00 +0400 |
---|---|---|
committer | Ravindra <ravindra@mono-cvs.ximian.com> | 2004-10-26 13:33:00 +0400 |
commit | 0dc267945729fe9bb7711183b7172c4dee648b34 (patch) | |
tree | 1a0a1b0d815557dd9ab8586c725901df4b386eba /mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs | |
parent | c10ba0cf9c67a09e23f1a4d7238160e9d7b1a572 (diff) |
Added some internal members and calculations for ColumnHeader.
svn path=/trunk/mcs/; revision=35322
Diffstat (limited to 'mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs')
-rw-r--r-- | mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs | 102 |
1 files changed, 91 insertions, 11 deletions
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs index 7bd57f0cce1..0ebc9578896 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs @@ -22,9 +22,12 @@ // Author: // Ravindra (rkumar@novell.com) // -// $Revision: 1.2 $ +// $Revision: 1.3 $ // $Modtime: $ // $Log: ColumnHeader.cs,v $ +// Revision 1.3 2004/10/26 09:33:00 ravindra +// Added some internal members and calculations for ColumnHeader. +// // Revision 1.2 2004/10/15 15:06:44 ravindra // Flushing some formatting changes. // @@ -47,9 +50,12 @@ namespace System.Windows.Forms { #region Instance Variables internal ListView owner; + private StringFormat format; private string text = "ColumnHeader"; - private HorizontalAlignment textAlignment = HorizontalAlignment.Left; - private int width = 60; + private HorizontalAlignment text_alignment = HorizontalAlignment.Left; + private int width = ThemeEngine.Current.DefaultColumnWidth; + // column area + internal Rectangle column_rect = Rectangle.Empty; #endregion // Instance Variables #region Internal Constructor @@ -58,7 +64,8 @@ namespace System.Windows.Forms this.owner = owner; this.text = text; this.width = width; - this.textAlignment = alignment; + this.text_alignment = alignment; + CalcColumnHeader (); } #endregion // Internal Constructor @@ -66,6 +73,66 @@ namespace System.Windows.Forms public ColumnHeader () { } #endregion // Public Constructors + #region Private Internal Methods Properties + // Since this class inherits from MarshalByRef, + // we can't do ColumnHeader.column_rect.XXX. Hence, + // we have following properties to work around. + internal int X { + get { return this.column_rect.X; } + set { this.column_rect.X = value; } + } + + internal int Y { + get { return this.column_rect.Y; } + set { this.column_rect.Y = value; } + } + + internal int Wd { + get { return this.column_rect.Width; } + set { this.column_rect.Width = value; } + } + + internal int Ht { + get { return this.column_rect.Height; } + set { this.column_rect.Height = value; } + } + + internal Rectangle Rect { + get { return this.column_rect; } + } + + internal StringFormat Format { + get { return this.format; } + } + + internal void CalcColumnHeader () + { + format = new StringFormat (); + if (text_alignment == HorizontalAlignment.Center) + format.Alignment = StringAlignment.Center; + else if (text_alignment == HorizontalAlignment.Right) + format.Alignment = StringAlignment.Far; + else + format.Alignment = StringAlignment.Near; + format.LineAlignment = StringAlignment.Center; + format.Trimming = StringTrimming.EllipsisWord; + // text is wrappable only in LargeIcon and SmallIcon views + format.FormatFlags = StringFormatFlags.NoWrap; + + if (width >= 0) { + this.column_rect.Width = width; + if (owner != null) + this.column_rect.Height = owner.Font.Height; + else + this.column_rect.Height = ThemeEngine.Current.DefaultFont.Height; + } + else if (this.Index != -1) + this.column_rect.Size = owner.GetChildColumnSize (this.Index); + else + this.column_rect.Size = Size.Empty; + } + #endregion // Private Internal Methods Properties + #region Public Instance Properties [Browsable (false)] public int Index { @@ -86,21 +153,33 @@ namespace System.Windows.Forms [Localizable (true)] public string Text { get { return text; } - set { text = value; } + set { + text = value; + if (owner != null) + owner.Redraw (true); + } } [DefaultValue (HorizontalAlignment.Left)] [Localizable (true)] public HorizontalAlignment TextAlign { - get { return textAlignment; } - set { textAlignment = value; } + get { return text_alignment; } + set { + text_alignment = value; + if (owner != null) + owner.Redraw (true); + } } [DefaultValue (60)] [Localizable (true)] public int Width { get { return width; } - set { width = value; } + set { + width = value; + if (owner != null) + owner.Redraw (true); + } } #endregion // Public Instance Properties @@ -108,10 +187,11 @@ namespace System.Windows.Forms public virtual object Clone () { ColumnHeader columnHeader = new ColumnHeader (); - columnHeader.Text = text; - columnHeader.TextAlign = textAlignment; - columnHeader.Width = width; + columnHeader.text = text; + columnHeader.text_alignment = text_alignment; + columnHeader.width = width; columnHeader.owner = owner; + columnHeader.column_rect = column_rect = new Rectangle (Point.Empty, Size.Empty); return columnHeader; } |