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)
28 using System.Drawing.Drawing2D;
30 namespace System.Windows.Forms
32 public class DrawListViewColumnHeaderEventArgs : EventArgs
34 #region Private Fields
36 private Color backColor;
37 private Rectangle bounds;
38 private int columnIndex;
39 private bool drawDefault;
41 private Color foreColor;
42 private Graphics graphics;
43 private ColumnHeader header;
44 private ListViewItemStates state;
46 #endregion Private Fields
51 public Color BackColor {
52 get { return backColor; }
55 public Rectangle Bounds {
56 get { return bounds; }
59 public int ColumnIndex {
60 get { return columnIndex; }
63 public bool DrawDefault {
64 get { return drawDefault; }
65 set { drawDefault = value; }
72 public Color ForeColor {
73 get { return foreColor; }
76 public Graphics Graphics {
77 get { return graphics; }
80 public ColumnHeader Header {
81 get { return header; }
84 public ListViewItemStates State {
93 public DrawListViewColumnHeaderEventArgs(Graphics graphics, Rectangle bounds, int columnIndex,
94 ColumnHeader header, ListViewItemStates state, Color foreColor,
95 Color backColor, Font font)
97 this.backColor = backColor;
99 this.columnIndex = columnIndex;
101 this.foreColor = foreColor;
102 this.graphics = graphics;
103 this.header = header;
107 #endregion Constructors
112 public void DrawBackground ()
114 // Always draw a non-pushed button
115 ThemeEngine.Current.CPDrawButton (graphics, bounds, ButtonState.Normal);
118 public void DrawText ()
120 DrawText (TextFormatFlags.EndEllipsis | TextFormatFlags.SingleLine);
123 public void DrawText (TextFormatFlags flags)
126 Rectangle text_bounds = new Rectangle (bounds.X + 8, bounds.Y, bounds.Width - 13, bounds.Height);
127 TextRenderer.DrawText (graphics, header.Text, font, text_bounds, foreColor, flags);