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 namespace System.Windows.Forms
31 public class DrawListViewSubItemEventArgs : EventArgs
33 #region Private Fields
35 private Rectangle bounds;
36 private int columnIndex;
37 private bool drawDefault;
38 private Graphics graphics;
39 private ColumnHeader header;
40 private ListViewItem item;
41 private int itemIndex;
42 private ListViewItemStates itemState;
43 private ListViewItem.ListViewSubItem subItem;
45 #endregion Private Fields
50 public Rectangle Bounds {
51 get { return bounds; }
54 public int ColumnIndex {
55 get { return columnIndex; }
58 public bool DrawDefault {
59 get { return drawDefault; }
60 set { drawDefault = value; }
63 public Graphics Graphics {
64 get { return graphics; }
67 public ColumnHeader Header {
68 get { return header; }
71 public ListViewItem Item {
75 public int ItemIndex {
76 get { return itemIndex; }
79 public ListViewItemStates ItemState {
80 get { return itemState; }
83 public ListViewItem.ListViewSubItem SubItem {
84 get { return this.subItem; }
92 public DrawListViewSubItemEventArgs(Graphics graphics, Rectangle bounds,
93 ListViewItem item, ListViewItem.ListViewSubItem subItem,
94 int itemIndex, int columnIndex,
95 ColumnHeader header, ListViewItemStates itemState)
98 this.columnIndex = columnIndex;
99 this.graphics = graphics;
100 this.header = header;
102 this.itemIndex = itemIndex;
103 this.itemState = itemState;
104 this.subItem = subItem;
107 #endregion Constructors
110 #region Public Methods
112 public void DrawBackground ()
114 graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (subItem.BackColor), bounds);
117 public void DrawFocusRectangle (Rectangle bounds)
119 if ((itemState & ListViewItemStates.Focused) != 0) {
120 Rectangle rect = new Rectangle (bounds.X + 1, bounds.Y + 1, bounds.Width - 1, bounds.Height - 1);
121 ThemeEngine.Current.CPDrawFocusRectangle (graphics, rect, subItem.ForeColor, subItem.BackColor);
125 public void DrawText ()
127 DrawText (TextFormatFlags.EndEllipsis | TextFormatFlags.HorizontalCenter);
130 public void DrawText (TextFormatFlags flags)
133 Rectangle text_bounds = new Rectangle (bounds.X + 8, bounds.Y, bounds.Width - 13, bounds.Height);
134 TextRenderer.DrawText (graphics, subItem.Text, subItem.Font, text_bounds, subItem.ForeColor, flags);
137 #endregion Public Methods