* TabControl.cs: Show the tooltip depending on the value
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / ToolStripItemTextRenderEventArgs.cs
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.
22 //
23 // Copyright (c) 2006 Jonathan Pobst
24 //
25 // Authors:
26 //      Jonathan Pobst (monkey@jpobst.com)
27 //
28
29 #if NET_2_0
30 using System.Drawing;
31
32 namespace System.Windows.Forms
33 {
34         public class ToolStripItemTextRenderEventArgs : ToolStripItemRenderEventArgs
35         {
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;
42
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)
46                 {
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;
52
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;
82                         }
83
84                         if ((Application.KeyboardCapture == null || !ToolStripManager.ActivatedByKeyboard) && !SystemInformation.MenuAccessKeysUnderlined)
85                                 this.text_format |= TextFormatFlags.HidePrefix;
86                 }
87
88                 public ToolStripItemTextRenderEventArgs (Graphics g, ToolStripItem item, string text, Rectangle textRectangle, Color textColor, Font textFont, TextFormatFlags format)
89                         : base (g, item)
90                 {
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;
97                 }
98                 #endregion
99
100                 #region Public Properties
101                 public string Text {
102                         get { return this.text; }
103                         set { this.text = value; }
104                 }
105
106                 public Color TextColor {
107                         get { return this.text_color; }
108                         set { this.text_color = value; }
109                 }
110
111                 public ToolStripTextDirection TextDirection {
112                         get { return this.text_direction; }
113                         set { this.text_direction = value; }
114                 }
115
116                 public Font TextFont {
117                         get { return this.text_font; }
118                         set { this.text_font = value; }
119                 }
120
121                 public TextFormatFlags TextFormat {
122                         get { return this.text_format; }
123                         set { this.text_format = value; }
124                 }
125
126                 public Rectangle TextRectangle {
127                         get { return this.text_rectangle; }
128                         set { this.text_rectangle = value; }
129                 }
130                 #endregion
131         }
132 }
133 #endif