<commit_before>using System;
using sd = System.Drawing;
using Eto.Forms;
using Eto.Drawing;
using MonoMac.AppKit;
using Eto.Platform.Mac.Drawing;
using MonoMac.Foundation;
using MonoMac.ObjCRuntime;
using System.Text.RegularExpressions;
using System.Linq;

namespace Eto.Platform.Mac.Forms.Controls
{
	public class LabelHandler : MacView<NSTextField, Label>, ILabel
	{
		static readonly bool supportsSingleLine;
		Font font;
		readonly NSMutableAttributedString str;
		readonly NSMutableParagraphStyle paragraphStyle;
		NSColor textColor;
		int underlineIndex;
		SizeF availableSizeCached;
		const NSStringDrawingOptions DrawingOptions = NSStringDrawingOptions.UsesFontLeading | NSStringDrawingOptions.UsesLineFragmentOrigin;

		static LabelHandler()
		{
			supportsSingleLine = ObjCExtensions.ClassInstancesRespondToSelector(Class.GetHandle("NSTextFieldCell"), Selector.GetHandle("setUsesSingleLineMode:"));
		}

		public override NSView ContainerControl { get { return Control; } }

		protected override SizeF GetNaturalSize(SizeF availableSize)
		{
			if (string.IsNullOrEmpty(Text))
				return Size.Empty;
			if (NaturalSize == null || availableSizeCached != availableSize)
			{
				var insets = Control.AlignmentRectInsets.ToEtoSize();
				var size = Control.Cell.CellSizeForBounds(new RectangleF(availableSize).ToSD()).ToEto();

				NaturalSize = Size.Round(size + insets);
				availableSizeCached = availableSize;
			}

			return NaturalSize.Value;
		}

		public class MyTextFieldCell : NSTextFieldCell
		{
			public VerticalAlign VerticalAlign { get; set; }

			public override sd.RectangleF DrawingRectForBounds(sd.RectangleF theRect)
			{
				var rect = base.DrawingRectForBounds(theRect);
				var titleSize = CellSizeForBounds(theRect);

				switch (VerticalAlign)
				{
					case VerticalAlign.Middle:
						rect.Y = theRect.Y + (theRect.Height - titleSize.Height) / 2.0F;<commit_msg>Mac: Fix Label on os x < 10.7<commit_after>using System;
using sd = System.Drawing;
using Eto.Forms;
using Eto.Drawing;
using MonoMac.AppKit;
using Eto.Platform.Mac.Drawing;
using MonoMac.Foundation;
using MonoMac.ObjCRuntime;
using System.Text.RegularExpressions;
using System.Linq;

namespace Eto.Platform.Mac.Forms.Controls
{
	public class LabelHandler : MacView<NSTextField, Label>, ILabel
	{
		static readonly bool supportsSingleLine;
		Font font;
		readonly NSMutableAttributedString str;
		readonly NSMutableParagraphStyle paragraphStyle;
		NSColor textColor;
		int underlineIndex;
		SizeF availableSizeCached;
		const NSStringDrawingOptions DrawingOptions = NSStringDrawingOptions.UsesFontLeading | NSStringDrawingOptions.UsesLineFragmentOrigin;

		static LabelHandler()
		{
			supportsSingleLine = ObjCExtensions.ClassInstancesRespondToSelector(Class.GetHandle("NSTextFieldCell"), Selector.GetHandle("setUsesSingleLineMode:"));
		}

		public override NSView ContainerControl { get { return Control; } }

		static readonly Selector selAlignmentRectInsets = new Selector("alignmentRectInsets");

		protected override SizeF GetNaturalSize(SizeF availableSize)
		{
			if (string.IsNullOrEmpty(Text))
				return Size.Empty;
			if (NaturalSize == null || availableSizeCached != availableSize)
			{
				var insets = Control.RespondsToSelector(selAlignmentRectInsets) ? Control.AlignmentRectInsets.ToEtoSize() : new Size(4, 2);
				var size = Control.Cell.CellSizeForBounds(new RectangleF(availableSize).ToSD()).ToEto();

				NaturalSize = Size.Round(size + insets);
				availableSizeCached = availableSize;
			}

			return NaturalSize.Value;
		}

		public class MyTextFieldCell : NSTextFieldCell
		{
			public VerticalAlign VerticalAlign { get; set; }

			public override sd.RectangleF DrawingRectForBounds(sd.RectangleF theRect)
			{
				var rect = base.DrawingRectForBounds(theRect);
				var titleSize = CellSizeForBounds(theRect);

				switch (VerticalAlign)
				{
					case VerticalAlign.Middle:
						rect.Y = theRect.Y + (theRect.Height - titleSize.Height) / 2.0F;
{'fraction_non_alphanumeric': 0.08644153225806452, 'fraction_numerical': 0.0022681451612903227, 'mean_word_length': 4.995468277945619, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4888119', 'n_tokens_mistral': 1373, 'n_tokens_neox': 1164, 'n_words': 257}