System.Windows.Forms.ThemeWin32Classic.ToolTipSize C# (CSharp) Method

ToolTipSize() public method

public ToolTipSize ( ToolTip tt, string text ) : Size
tt ToolTip
text string
return System.Drawing.Size
		public override Size ToolTipSize(ToolTip.ToolTipWindow tt, string text)
		{
			Size size = TextRenderer.MeasureTextInternal (text, tt.Font, false);
			size.Width += 4;
			size.Height += 3;
			Rectangle text_rect = new Rectangle (Point.Empty, size);
			text_rect.Inflate (-2, -1);
			tt.text_rect = text_rect;
			tt.icon_rect = tt.title_rect = Rectangle.Empty;

			Size title_size = Size.Empty;
			if (tt.title.Length > 0) {
				Font bold_font = new Font (tt.Font, tt.Font.Style | FontStyle.Bold);
				title_size = TextRenderer.MeasureTextInternal (tt.title, bold_font, false);
				bold_font.Dispose ();
			}

			Size icon_size = Size.Empty;
			if (tt.icon != null)
				icon_size = new Size (size.Height, size.Height);

			if (icon_size != Size.Empty || title_size != Size.Empty) {
				int padding = 8;
				int top_area_width = 0;
				int top_area_height = icon_size.Height > title_size.Height ? icon_size.Height : title_size.Height;
				Size text_size = size;
				Point location = new Point (padding, padding);

				if (icon_size != Size.Empty) {
					tt.icon_rect = new Rectangle (location, icon_size);
					top_area_width = icon_size.Width + padding;
				}

				if (title_size != Size.Empty) {
					Rectangle title_rect = new Rectangle (location, new Size (title_size.Width, top_area_height));
					if (icon_size != Size.Empty)
						title_rect.X += icon_size.Width + padding;

					tt.title_rect = title_rect;
					top_area_width += title_size.Width;
				}

				tt.text_rect = new Rectangle (new Point (location.X, location.Y + top_area_height + padding),
						text_size);

				size.Height += padding + top_area_height;
				if (top_area_width > size.Width)
					size.Width = top_area_width;

				// margins
				size.Width += padding * 2;
				size.Height += padding * 2;
			}

			return size;
		}
		
ThemeWin32Classic