Fix bug #395
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / DrawListViewColumnHeaderEventArgs.cs
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:
8 // 
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 // 
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.
19 //
20 // Copyright (c) 2004-2005 Novell, Inc.
21 //
22 // Authors:
23 //      Alan McGovern (alan.mcgovern@gmail.com)
24 //
25
26
27 using System.Drawing;
28 using System.Drawing.Drawing2D;
29
30 namespace System.Windows.Forms
31 {
32     public class DrawListViewColumnHeaderEventArgs : EventArgs
33     {
34         #region Private Fields
35
36         private Color backColor;
37         private Rectangle bounds;
38         private int columnIndex;
39         private bool drawDefault;
40         private Font font;
41         private Color foreColor;
42         private Graphics graphics;
43         private ColumnHeader header;
44         private ListViewItemStates state;
45
46         #endregion Private Fields
47
48
49         #region Properties
50
51         public Color BackColor {
52             get { return backColor; }
53         }
54
55         public Rectangle Bounds {
56             get { return bounds; }
57         }
58
59         public int ColumnIndex {
60             get { return columnIndex; }
61         }
62
63         public bool DrawDefault {
64             get { return drawDefault; }
65             set { drawDefault = value; }
66         }
67
68         public Font Font {
69             get { return font; }
70         }
71
72         public Color ForeColor {
73             get { return foreColor; }
74         }
75
76         public Graphics Graphics {
77             get { return graphics; }
78         }
79
80         public ColumnHeader Header {
81             get { return header; }
82         }
83
84         public ListViewItemStates State {
85             get { return state; }
86         }
87
88         #endregion Properties
89
90
91         #region Constructors
92
93         public DrawListViewColumnHeaderEventArgs(Graphics graphics, Rectangle bounds, int columnIndex,
94                                         ColumnHeader header, ListViewItemStates state, Color foreColor,
95                                         Color backColor, Font font)
96         {
97             this.backColor = backColor;
98             this.bounds = bounds;
99             this.columnIndex = columnIndex;
100             this.font = font;
101             this.foreColor = foreColor;
102             this.graphics = graphics;
103             this.header = header;
104             this.state = state;
105         }
106
107         #endregion Constructors
108
109
110         #region Methods
111
112         public void DrawBackground ()
113         {
114                 // Always draw a non-pushed button
115                 ThemeEngine.Current.CPDrawButton (graphics, bounds, ButtonState.Normal);
116         }
117
118         public void DrawText ()
119         {
120                 DrawText (TextFormatFlags.EndEllipsis | TextFormatFlags.SingleLine);
121         }
122
123         public void DrawText (TextFormatFlags flags)
124         {
125                 // Text adjustments
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);
128         }
129
130         #endregion Methods
131     }
132 }