1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2004-2005 Novell, Inc.
23 // Alan McGovern (alan.mcgovern@gmail.com)
29 using System.Drawing.Drawing2D;
31 namespace System.Windows.Forms
33 public class DrawListViewColumnHeaderEventArgs : EventArgs
35 #region Private Fields
37 private Color backColor;
38 private Rectangle bounds;
39 private int columnIndex;
40 private bool drawDefault;
42 private Color foreColor;
43 private Graphics graphics;
44 private ColumnHeader header;
45 private ListViewItemStates state;
47 #endregion Private Fields
52 public Color BackColor {
53 get { return backColor; }
56 public Rectangle Bounds {
57 get { return bounds; }
60 public int ColumnIndex {
61 get { return columnIndex; }
64 public bool DrawDefault {
65 get { return drawDefault; }
66 set { drawDefault = value; }
73 public Color ForeColor {
74 get { return foreColor; }
77 public Graphics Graphics {
78 get { return graphics; }
81 public ColumnHeader Header {
82 get { return header; }
85 public ListViewItemStates State {
94 public DrawListViewColumnHeaderEventArgs(Graphics graphics, Rectangle bounds, int columnIndex,
95 ColumnHeader header, ListViewItemStates state, Color foreColor,
96 Color backColor, Font font)
98 this.backColor = backColor;
100 this.columnIndex = columnIndex;
102 this.foreColor = foreColor;
103 this.graphics = graphics;
104 this.header = header;
108 #endregion Constructors
113 public void DrawBackground ()
115 // Always draw a non-pushed button
116 ThemeEngine.Current.CPDrawButton (graphics, bounds, ButtonState.Normal);
119 public void DrawText ()
121 DrawText (TextFormatFlags.EndEllipsis | TextFormatFlags.SingleLine);
124 public void DrawText (TextFormatFlags flags)
127 Rectangle text_bounds = new Rectangle (bounds.X + 8, bounds.Y, bounds.Width - 13, bounds.Height);
128 TextRenderer.DrawText (graphics, header.Text, font, text_bounds, foreColor, flags);