In System.Windows.Forms:
[mono-project.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / ToolStripItemTextRenderEventArgs.cs
blob185f95f348be925b6b49c59baf3fdd5567d1cf06
1 //
2 // ToolStripItemTextRenderEventArgs.cs
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 // Copyright (c) 2006 Jonathan Pobst
25 // Authors:
26 // Jonathan Pobst (monkey@jpobst.com)
29 #if NET_2_0
30 using System.Drawing;
32 namespace System.Windows.Forms
34 public class ToolStripItemTextRenderEventArgs : ToolStripItemRenderEventArgs
36 private string text;
37 private Color text_color;
38 private ToolStripTextDirection text_direction;
39 private Font text_font;
40 private TextFormatFlags text_format;
41 private Rectangle text_rectangle;
43 #region Public Constructors
44 public ToolStripItemTextRenderEventArgs (Graphics g, ToolStripItem item, string text, Rectangle textRectangle, Color textColor, Font textFont, ContentAlignment textAlign)
45 : base (g, item)
47 this.text = text;
48 this.text_rectangle = textRectangle;
49 this.text_color = textColor;
50 this.text_font = textFont;
51 this.text_direction = item.TextDirection;
53 switch (textAlign) {
54 case ContentAlignment.BottomCenter:
55 this.text_format = TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter;
56 break;
57 case ContentAlignment.BottomLeft:
58 this.text_format = TextFormatFlags.Bottom | TextFormatFlags.Left;
59 break;
60 case ContentAlignment.BottomRight:
61 this.text_format = TextFormatFlags.Bottom | TextFormatFlags.Right;
62 break;
63 case ContentAlignment.MiddleCenter:
64 this.text_format = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter;
65 break;
66 case ContentAlignment.MiddleLeft:
67 default:
68 this.text_format = (TextFormatFlags.VerticalCenter | TextFormatFlags.Left);
69 break;
70 case ContentAlignment.MiddleRight:
71 this.text_format = TextFormatFlags.VerticalCenter | TextFormatFlags.Right;
72 break;
73 case ContentAlignment.TopCenter:
74 this.text_format = TextFormatFlags.Top | TextFormatFlags.HorizontalCenter;
75 break;
76 case ContentAlignment.TopLeft:
77 this.text_format = TextFormatFlags.Top | TextFormatFlags.Left;
78 break;
79 case ContentAlignment.TopRight:
80 this.text_format = TextFormatFlags.Top | TextFormatFlags.Right;
81 break;
84 if ((Application.KeyboardCapture == null || !ToolStripManager.ActivatedByKeyboard) && !SystemInformation.MenuAccessKeysUnderlined)
85 this.text_format |= TextFormatFlags.HidePrefix;
88 public ToolStripItemTextRenderEventArgs (Graphics g, ToolStripItem item, string text, Rectangle textRectangle, Color textColor, Font textFont, TextFormatFlags format)
89 : base (g, item)
91 this.text = text;
92 this.text_rectangle = textRectangle;
93 this.text_color = textColor;
94 this.text_font = textFont;
95 this.text_format = format;
96 this.text_direction = ToolStripTextDirection.Horizontal;
98 #endregion
100 #region Public Properties
101 public string Text {
102 get { return this.text; }
103 set { this.text = value; }
106 public Color TextColor {
107 get { return this.text_color; }
108 set { this.text_color = value; }
111 public ToolStripTextDirection TextDirection {
112 get { return this.text_direction; }
113 set { this.text_direction = value; }
116 public Font TextFont {
117 get { return this.text_font; }
118 set { this.text_font = value; }
121 public TextFormatFlags TextFormat {
122 get { return this.text_format; }
123 set { this.text_format = value; }
126 public Rectangle TextRectangle {
127 get { return this.text_rectangle; }
128 set { this.text_rectangle = value; }
130 #endregion
133 #endif