**** Merged from MCS ****
[mono-project.git] / mcs / class / System.Windows.Forms / Gtk / DrawItemEventArgs.cs
blob089107e06d52151196f3b44cfc5578dedcee6cbc
1 //
2 // System.Windows.Forms.DrawItemEventArgs
3 //
4 // Author:
5 // stubbed out by Richard Baumann (biochem333@nyc.rr.com)
6 // Implemented by Richard Baumann <biochem333@nyc.rr.com>
7 // Dennis Hayes (dennish@Raytek.com)
8 // Gianandrea Terzi (gianandrea.terzi@lario.com)
9 //
10 // (C) Ximian, Inc., 2002
13 using System;
14 using System.Drawing;
16 namespace System.Windows.Forms {
18 /// <summary>
19 /// Provides data for the DrawItem event.
20 /// </summary>
21 public class DrawItemEventArgs : EventArgs {
23 #region Fields
24 private Color backColor;
25 private Rectangle bounds;
26 private Font font;
27 private Color foreColor;
28 private Graphics graphics;
29 private int index;
30 private DrawItemState state;
31 #endregion
34 // --- Constructors/Destructors
37 public DrawItemEventArgs(Graphics graphics, Font font, Rectangle bounds, int index, DrawItemState state) : base()
39 this.graphics = graphics;
40 this. font = font;
41 this. bounds = bounds;
42 this.index = index;
43 this.state = state;
44 foreColor = SystemColors.WindowText;
45 backColor = SystemColors.Window;
46 //throw new NotImplementedException ();
49 public DrawItemEventArgs(Graphics graphics, Font font, Rectangle bounds, int index,
50 DrawItemState state, Color foreColor, Color backColor) : base()
52 this.graphics = graphics;
53 this. font = font;
54 this. bounds = bounds;
55 this.index = index;
56 this.state = state;
57 this.foreColor = foreColor;
58 this.backColor = backColor;
61 #region Public Methods
63 public virtual void DrawBackground()
65 SolidBrush temp = new SolidBrush(BackColor);
66 graphics.FillRectangle(temp,bounds);
67 temp.Dispose();
70 public virtual void DrawFocusRectangle()
72 if( (DrawItemState.Focus == (DrawItemState.Focus & state)) && // check for focus
73 (DrawItemState.NoFocusRect != (DrawItemState.NoFocusRect & state))){ // check if this matters {
75 //ControlPaint.DrawFocusRectangle(graphics,bounds,foreColor,backColor);
79 #endregion
81 #region Public Properties
83 public Color BackColor
85 get {
86 //return (DrawItemState.Selected == (state & DrawItemState.Selected)) ? SystemColors.Highlight : backColor;
87 if(DrawItemState.Selected == (state & DrawItemState.Selected)) {
88 return SystemColors.Highlight;
90 return backColor;
94 public Rectangle Bounds {
95 get {
96 return bounds;
100 public Font Font {
101 get {
102 return font;
106 public Color ForeColor {
107 get {
108 //return (DrawItemState.Selected == (state & DrawItemState.Selected)) ? SystemColors.HighlightText : foreColor;
109 if(DrawItemState.Selected == (state & DrawItemState.Selected)) {
110 return SystemColors.HighlightText;
112 return foreColor;
116 public Graphics Graphics {
117 get {
118 return graphics;
122 public int Index {
123 get {
124 return index;
128 public DrawItemState State {
129 get {
130 return state;
134 #endregion