private ToolStripItemAlignment alignment;
private bool auto_size;
private bool auto_tool_tip;
- private bool available;
private Color back_color;
+ private Image background_image;
+ private ImageLayout background_image_layout;
private Rectangle bounds;
private bool can_select;
private ToolStripItemDisplayStyle display_style;
private DockStyle dock;
private bool double_click_enabled;
private bool enabled;
+ private Size explicit_size;
private Font font;
private Color fore_color;
private Image image;
private ContentAlignment image_align;
private int image_index;
private ToolStripItemImageScaling image_scaling;
- protected bool is_pressed;
+ private Color image_transparent_color;
+ internal bool is_pressed;
private bool is_selected;
private Padding margin;
private string name;
private bool visible;
private ToolStrip parent;
- internal Size text_size;
+ private Size text_size;
#endregion
#region Public Constructors
this.alignment = ToolStripItemAlignment.Left;
this.auto_size = true;
this.auto_tool_tip = this.DefaultAutoToolTip;
- this.available = true;
this.back_color = Control.DefaultBackColor;
+ this.background_image_layout = ImageLayout.Tile;
+ this.can_select = true;
this.display_style = this.DefaultDisplayStyle;
this.dock = DockStyle.None;
this.enabled = true;
this.image_align = ContentAlignment.MiddleCenter;
this.image_index = -1;
this.image_scaling = ToolStripItemImageScaling.SizeToFit;
+ this.image_transparent_color = Color.Empty;
this.margin = this.DefaultMargin;
this.name = name;
this.padding = this.DefaultPadding;
this.text_image_relation = TextImageRelation.ImageBeforeText;
this.visible = true;
- this.Click = onClick;
- this.can_select = this is ToolStripMenuItem ? true : false;
- OnLayout (new LayoutEventArgs (null, ""));
+ this.Click += onClick;
+ OnLayout (new LayoutEventArgs (null, string.Empty));
}
#endregion
#region Public Properties
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
public AccessibleObject AccessibilityObject {
get {
if (this.accessibility_object == null)
return this.accessibility_object;
}
}
-
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
public string AccessibleDefaultActionDescription {
get {
if (this.accessibility_object == null)
}
[Localizable (true)]
+ [DefaultValue (null)]
public string AccessibleDescription {
get {
if (this.accessibility_object == null)
}
[Localizable (true)]
+ [DefaultValue (null)]
public string AccessibleName {
get {
if (this.accessibility_object == null)
set { this.AccessibilityObject.Name = value; }
}
+ [DefaultValue (AccessibleRole.Default)]
public AccessibleRole AccessibleRole {
get
{
owner.PerformLayout ();
OnAvailableChanged (EventArgs.Empty);
+ OnVisibleChanged (EventArgs.Empty);
}
}
}
}
}
+ [Localizable (true)]
+ public virtual Image BackgroundImage {
+ get { return this.background_image; }
+ set {
+ if (this.background_image != value) {
+ this.background_image = value;
+ this.Invalidate ();
+ }
+ }
+ }
+
+ [Localizable (true)]
+ public virtual ImageLayout BackgroundImageLayout {
+ get { return this.background_image_layout; }
+ set {
+ if (this.background_image_layout != value) {
+ this.background_image_layout = value;
+ this.Invalidate ();
+ }
+ }
+ }
+
[Browsable (false)]
public virtual Rectangle Bounds {
get { return this.bounds; }
if (this is ToolStripLabel)
return new Rectangle (0, 0, this.bounds.Width, this.bounds.Height);
+ if (this is ToolStripDropDownButton && (this as ToolStripDropDownButton).ShowDropDownArrow)
+ return new Rectangle (2, 2, this.bounds.Width - 13, this.bounds.Height - 4);
+
return new Rectangle (2, 2, this.bounds.Width - 4, this.bounds.Height - 4);
}
}
}
[Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
public int Height {
- get { return this.bounds.Height; }
+ get { return this.Size.Height; }
set {
this.bounds.Height = value;
+ this.explicit_size.Height = value;
+ if (this.visible) {
this.CalculateAutoSize ();
this.OnBoundsChanged ();
- this.Invalidate ();
+ this.Invalidate (); }
}
}
}
[Localizable (true)]
+ [Browsable (false)]
public int ImageIndex {
get { return this.image_index; }
set {
+ // Lamespec: MSDN says ArgumentException, tests say otherwise
if (value < -1)
- throw new ArgumentException ("ImageIndex cannot be less than -1");
+ throw new ArgumentOutOfRangeException ("ImageIndex cannot be less than -1");
this.image_index = value;
this.CalculateAutoSize ();
}
}
+ [Localizable (true)]
+ [MonoTODO ("Stub, doesn't actually do anything yet.")]
+ public Color ImageTransparentColor {
+ get { return this.image_transparent_color; }
+ set { this.image_transparent_color = value; }
+ }
+
[Browsable (false)]
public bool IsOnDropDown {
get {
}
[DefaultValue (null)]
+ [Browsable (false)]
public string Name {
get { return this.name; }
set { this.name = value; }
[Localizable (true)]
public virtual Size Size {
- get { return this.bounds.Size; }
+ get {
+ if (this.explicit_size != Size.Empty)
+ return this.explicit_size;
+
+ return this.bounds.Size;
+ }
set {
this.bounds.Size = value;
+ this.explicit_size = value;
+
+ if (this.visible) {
this.CalculateAutoSize ();
- OnBoundsChanged ();
+ OnBoundsChanged (); }
}
}
[Localizable (false)]
[Bindable (true)]
[DefaultValue (null)]
+ [TypeConverter (typeof (StringConverter))]
public Object Tag {
get { return this.tag; }
set { this.tag = value; }
}
[Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
public int Width {
- get { return this.bounds.Width; }
+ get { return this.Size.Width; }
set {
this.bounds.Width = value;
+ this.explicit_size.Width = value;
+ if (this.visible) {
this.CalculateAutoSize ();
- this.OnBoundsChanged();
+ this.OnBoundsChanged(); }
}
}
#endregion
protected internal virtual Padding DefaultMargin { get { return new Padding (0, 1, 0, 2); } }
protected virtual Padding DefaultPadding { get { return new Padding (); } }
protected virtual Size DefaultSize { get { return new Size (23, 23); } }
- protected internal virtual bool DismissWhenClicked { get { return false; } }
+ protected internal virtual bool DismissWhenClicked { get { return true; } }
[Browsable (false)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
protected internal ToolStrip Parent {
OnParentChanged(old_parent, this.parent);
}
}
- protected internal virtual bool ShowKeyboardCues { get { return true; } }
+ protected internal virtual bool ShowKeyboardCues { get { return false; } }
#endregion
#region Public Methods
owner.Invalidate (r);
}
+ public void OnDragDrop (DragEventArgs e)
+ {
+ // XXX
+ }
+
+ public void OnDragEnter (DragEventArgs e)
+ {
+ // XXX
+ }
+
+ public void OnDragLeave (EventArgs e)
+ {
+ // XXX
+ }
+
+ public void OnDragOver (DragEventArgs e)
+ {
+ // XXX
+ }
+
public void PerformClick ()
{
this.OnClick (EventArgs.Empty);
#endregion
#region Protected Methods
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
protected virtual AccessibleObject CreateAccessibilityInstance ()
{
return new ToolStripItemAccessibleObject (this);
}
+
+ protected override void Dispose (bool disposing)
+ {
+ base.Dispose (disposing);
+ }
protected virtual void OnAvailableChanged (EventArgs e)
{
- if (AvailableChanged != null) AvailableChanged (this, e);
+ EventHandler eh = (EventHandler)(Events [AvailableChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
protected virtual void OnBackColorChanged (EventArgs e)
{
- if (BackColorChanged != null) BackColorChanged (this, e);
+ EventHandler eh = (EventHandler)(Events [BackColorChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
protected virtual void OnBoundsChanged ()
protected virtual void OnClick (EventArgs e)
{
- if (Click != null) Click (this, e);
+ EventHandler eh = (EventHandler)(Events [ClickEvent]);
+ if (eh != null)
+ eh (this, e);
}
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
protected virtual void OnDisplayStyleChanged (EventArgs e)
{
- if (DisplayStyleChanged != null) DisplayStyleChanged (this, e);
+ EventHandler eh = (EventHandler)(Events [DisplayStyleChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
protected virtual void OnDoubleClick (EventArgs e)
{
- if (DoubleClick != null) DoubleClick (this, e);
+ EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
+ if (eh != null)
+ eh (this, e);
if (!double_click_enabled)
OnClick (e);
protected virtual void OnEnabledChanged (EventArgs e)
{
- if (EnabledChanged != null) EnabledChanged (this, e);
+ EventHandler eh = (EventHandler)(Events [EnabledChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
protected virtual void OnFontChanged (EventArgs e)
{
}
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
protected virtual void OnForeColorChanged (EventArgs e)
{
- if (ForeColorChanged != null) ForeColorChanged (this, e);
+ EventHandler eh = (EventHandler)(Events [ForeColorChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
protected virtual void OnLayout (LayoutEventArgs e)
protected virtual void OnLocationChanged (EventArgs e)
{
- if (LocationChanged != null) LocationChanged (this, e);
+ EventHandler eh = (EventHandler)(Events [LocationChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
protected virtual void OnMouseDown (MouseEventArgs e)
{
if (this.Enabled) {
- if (MouseDown != null) MouseDown (this, e);
this.is_pressed = true;
this.Invalidate ();
+
+ MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
+ if (eh != null)
+ eh (this, e);
}
}
protected virtual void OnMouseEnter (EventArgs e)
{
- if (MouseEnter != null) MouseEnter (this, e);
-
if (this.CanSelect) {
this.is_selected = true;
this.Invalidate ();
}
+
+ EventHandler eh = (EventHandler)(Events [MouseEnterEvent]);
+ if (eh != null)
+ eh (this, e);
}
protected virtual void OnMouseHover (EventArgs e)
{
- if (this.Enabled)
- if (MouseHover != null) MouseHover (this, e);
+ if (this.Enabled) {
+ EventHandler eh = (EventHandler)(Events [MouseHoverEvent]);
+ if (eh != null)
+ eh (this, e);
+ }
}
protected virtual void OnMouseLeave (EventArgs e)
{
- if (MouseLeave != null) MouseLeave (this, e);
-
if (this.CanSelect) {
this.is_selected = false;
this.is_pressed = false;
this.Invalidate ();
}
+
+ EventHandler eh = (EventHandler)(Events [MouseLeaveEvent]);
+ if (eh != null)
+ eh (this, e);
}
protected virtual void OnMouseMove (MouseEventArgs e)
{
- if (this.Enabled)
- if (MouseMove != null) MouseMove (this, e);
+ if (this.Enabled) {
+ MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
+ if (eh != null)
+ eh (this, e);
+ }
}
protected virtual void OnMouseUp (MouseEventArgs e)
{
if (this.Enabled) {
- if (MouseUp != null) MouseUp (this, e);
this.is_pressed = false;
this.Invalidate ();
+
+ MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
+ if (eh != null)
+ eh (this, e);
}
}
protected virtual void OnOwnerChanged (EventArgs e)
{
- if (OwnerChanged != null) OwnerChanged (this, e);
+ EventHandler eh = (EventHandler)(Events [OwnerChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
protected virtual void OnPaint (PaintEventArgs e)
{
- if (Paint != null) Paint (this, e);
+ if (this.Owner != null)
+ this.Owner.Renderer.DrawItemBackground (new ToolStripItemRenderEventArgs (e.Graphics, this));
+
+ PaintEventHandler eh = (PaintEventHandler)(Events [PaintEvent]);
+ if (eh != null)
+ eh (this, e);
}
protected virtual void OnParentChanged (ToolStrip oldParent, ToolStrip newParent)
{
}
-
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
protected virtual void OnTextChanged (EventArgs e)
{
- if (TextChanged != null) TextChanged (this, e);
+ EventHandler eh = (EventHandler)(Events [TextChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
protected virtual void OnVisibleChanged (EventArgs e)
{
- if (VisibleChanged != null) VisibleChanged (this, e);
+ EventHandler eh = (EventHandler)(Events [VisibleChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
protected internal virtual void SetBounds (Rectangle bounds)
#endregion
#region Public Events
+ static object AvailableChangedEvent = new object ();
+ static object BackColorChangedEvent = new object ();
+ static object ClickEvent = new object ();
+ static object DisplayStyleChangedEvent = new object ();
+ static object DoubleClickEvent = new object ();
+ static object EnabledChangedEvent = new object ();
+ static object ForeColorChangedEvent = new object ();
+ static object LocationChangedEvent = new object ();
+ static object MouseDownEvent = new object ();
+ static object MouseEnterEvent = new object ();
+ static object MouseHoverEvent = new object ();
+ static object MouseLeaveEvent = new object ();
+ static object MouseMoveEvent = new object ();
+ static object MouseUpEvent = new object ();
+ static object OwnerChangedEvent = new object ();
+ static object PaintEvent = new object ();
+ static object TextChangedEvent = new object ();
+ static object VisibleChangedEvent = new object ();
+
[Browsable (false)]
- public event EventHandler AvailableChanged;
- public event EventHandler BackColorChanged;
- public event EventHandler Click;
- public event EventHandler DisplayStyleChanged;
- public event EventHandler DoubleClick;
- public event EventHandler EnabledChanged;
- public event EventHandler ForeColorChanged;
- public event EventHandler LocationChanged;
- public event MouseEventHandler MouseDown;
- public event EventHandler MouseEnter;
- public event EventHandler MouseHover;
- public event EventHandler MouseLeave;
- public event MouseEventHandler MouseMove;
- public event MouseEventHandler MouseUp;
- public event EventHandler OwnerChanged;
- public event PaintEventHandler Paint;
- public event EventHandler TextChanged;
- public event EventHandler VisibleChanged;
+ public event EventHandler AvailableChanged {
+ add { Events.AddHandler (AvailableChangedEvent, value); }
+ remove {Events.RemoveHandler (AvailableChangedEvent, value); }
+ }
+
+ public event EventHandler BackColorChanged {
+ add { Events.AddHandler (BackColorChangedEvent, value); }
+ remove {Events.RemoveHandler (BackColorChangedEvent, value); }
+ }
+
+ public event EventHandler Click {
+ add { Events.AddHandler (ClickEvent, value); }
+ remove {Events.RemoveHandler (ClickEvent, value); }
+ }
+
+ public event EventHandler DisplayStyleChanged {
+ add { Events.AddHandler (DisplayStyleChangedEvent, value); }
+ remove {Events.RemoveHandler (DisplayStyleChangedEvent, value); }
+ }
+
+ public event EventHandler DoubleClick {
+ add { Events.AddHandler (DoubleClickEvent, value); }
+ remove {Events.RemoveHandler (DoubleClickEvent, value); }
+ }
+
+ public event EventHandler EnabledChanged {
+ add { Events.AddHandler (EnabledChangedEvent, value); }
+ remove {Events.RemoveHandler (EnabledChangedEvent, value); }
+ }
+
+ public event EventHandler ForeColorChanged {
+ add { Events.AddHandler (ForeColorChangedEvent, value); }
+ remove {Events.RemoveHandler (ForeColorChangedEvent, value); }
+ }
+
+ public event EventHandler LocationChanged {
+ add { Events.AddHandler (LocationChangedEvent, value); }
+ remove {Events.RemoveHandler (LocationChangedEvent, value); }
+ }
+
+ public event MouseEventHandler MouseDown {
+ add { Events.AddHandler (MouseDownEvent, value); }
+ remove {Events.RemoveHandler (MouseDownEvent, value); }
+ }
+
+ public event EventHandler MouseEnter {
+ add { Events.AddHandler (MouseEnterEvent, value); }
+ remove {Events.RemoveHandler (MouseEnterEvent, value); }
+ }
+
+ public event EventHandler MouseHover {
+ add { Events.AddHandler (MouseHoverEvent, value); }
+ remove {Events.RemoveHandler (MouseHoverEvent, value); }
+ }
+
+ public event EventHandler MouseLeave {
+ add { Events.AddHandler (MouseLeaveEvent, value); }
+ remove {Events.RemoveHandler (MouseLeaveEvent, value); }
+ }
+
+ public event MouseEventHandler MouseMove {
+ add { Events.AddHandler (MouseMoveEvent, value); }
+ remove {Events.RemoveHandler (MouseMoveEvent, value); }
+ }
+
+ public event MouseEventHandler MouseUp {
+ add { Events.AddHandler (MouseUpEvent, value); }
+ remove {Events.RemoveHandler (MouseUpEvent, value); }
+ }
+
+ public event EventHandler OwnerChanged {
+ add { Events.AddHandler (OwnerChangedEvent, value); }
+ remove {Events.RemoveHandler (OwnerChangedEvent, value); }
+ }
+
+ public event PaintEventHandler Paint {
+ add { Events.AddHandler (PaintEvent, value); }
+ remove {Events.RemoveHandler (PaintEvent, value); }
+ }
+
+ public event EventHandler TextChanged {
+ add { Events.AddHandler (TextChangedEvent, value); }
+ remove {Events.RemoveHandler (TextChangedEvent, value); }
+ }
+
+ public event EventHandler VisibleChanged {
+ add { Events.AddHandler (VisibleChangedEvent, value); }
+ remove {Events.RemoveHandler (VisibleChangedEvent, value); }
+ }
#endregion
#region Internal Methods
if (!this.auto_size || this is ToolStripControlHost)
return;
- this.text_size = TextRenderer.MeasureText (this.Text, this.Font);
+ this.text_size = TextRenderer.MeasureText (this.Text == null ? string.Empty: this.text, this.Font, Size.Empty, TextFormatFlags.HidePrefix);
//this.text_size.Width += 6;
Size final_size = this.CalculatePreferredSize (Size.Empty);
preferred_size.Width += 4;
}
- if (preferred_size.Width < 23)
- preferred_size.Width = 23; // There seems to be a minimum width of 23
+ // Account for ToolStripDropDownButton's drop down arrow
+ if (this is ToolStripDropDownButton && (this as ToolStripDropDownButton).ShowDropDownArrow)
+ preferred_size.Width += 9;
+
return preferred_size;
}
internal void CalculateTextAndImageRectangles (out Rectangle text_rect, out Rectangle image_rect)
+ {
+ this.CalculateTextAndImageRectangles (this.ContentRectangle, out text_rect, out image_rect);
+ }
+
+ internal void CalculateTextAndImageRectangles (Rectangle contentRectangle, out Rectangle text_rect, out Rectangle image_rect)
{
text_rect = Rectangle.Empty;
image_rect = Rectangle.Empty;
break;
case ToolStripItemDisplayStyle.Text:
if (this.text != string.Empty)
- text_rect = AlignInRectangle (this.ContentRectangle, this.text_size, this.text_align);
+ text_rect = AlignInRectangle (contentRectangle, this.text_size, this.text_align);
break;
case ToolStripItemDisplayStyle.Image:
if (this.image != null)
- image_rect = AlignInRectangle (this.ContentRectangle, this.image.Size, this.image_align);
+ image_rect = AlignInRectangle (contentRectangle, this.image.Size, this.image_align);
break;
case ToolStripItemDisplayStyle.ImageAndText:
if (this.text != string.Empty && this.image == null)
- text_rect = AlignInRectangle (this.ContentRectangle, this.text_size, this.text_align);
+ text_rect = AlignInRectangle (contentRectangle, this.text_size, this.text_align);
else if (this.text == string.Empty && this.image != null)
- image_rect = AlignInRectangle (this.ContentRectangle, this.image.Size, this.image_align);
+ image_rect = AlignInRectangle (contentRectangle, this.image.Size, this.image_align);
else if (this.text == string.Empty && this.image == null)
break;
else {
switch (this.text_image_relation) {
case TextImageRelation.Overlay:
- text_rect = AlignInRectangle (this.ContentRectangle, this.text_size, this.text_align);
- image_rect = AlignInRectangle (this.ContentRectangle, this.image.Size, this.image_align);
+ text_rect = AlignInRectangle (contentRectangle, this.text_size, this.text_align);
+ image_rect = AlignInRectangle (contentRectangle, this.image.Size, this.image_align);
break;
case TextImageRelation.ImageAboveText:
- text_area = new Rectangle (this.ContentRectangle.Left, this.ContentRectangle.Bottom - (text_size.Height - 4), this.ContentRectangle.Width, text_size.Height - 4);
- image_area = new Rectangle (this.ContentRectangle.Left, this.ContentRectangle.Top, this.ContentRectangle.Width, this.ContentRectangle.Height - text_area.Height);
+ text_area = new Rectangle (contentRectangle.Left, contentRectangle.Bottom - (text_size.Height - 4), contentRectangle.Width, text_size.Height - 4);
+ image_area = new Rectangle (contentRectangle.Left, contentRectangle.Top, contentRectangle.Width, contentRectangle.Height - text_area.Height);
text_rect = AlignInRectangle (text_area, this.text_size, this.text_align);
image_rect = AlignInRectangle (image_area, this.image.Size, this.image_align);
break;
case TextImageRelation.TextAboveImage:
- text_area = new Rectangle (this.ContentRectangle.Left, this.ContentRectangle.Top, this.ContentRectangle.Width, text_size.Height - 4);
- image_area = new Rectangle (this.ContentRectangle.Left, text_area.Bottom, this.ContentRectangle.Width, this.ContentRectangle.Height - text_area.Height);
+ text_area = new Rectangle (contentRectangle.Left, contentRectangle.Top, contentRectangle.Width, text_size.Height - 4);
+ image_area = new Rectangle (contentRectangle.Left, text_area.Bottom, contentRectangle.Width, contentRectangle.Height - text_area.Height);
text_rect = AlignInRectangle (text_area, this.text_size, this.text_align);
image_rect = AlignInRectangle (image_area, this.image.Size, this.image_align);
break;
case TextImageRelation.ImageBeforeText:
- text_area = new Rectangle (this.ContentRectangle.Right - this.text_size.Width, this.ContentRectangle.Top, this.text_size.Width, this.ContentRectangle.Height);
- image_area = new Rectangle (this.ContentRectangle.Left, this.ContentRectangle.Top, text_area.Left - this.ContentRectangle.Left, this.ContentRectangle.Height);
+ text_area = new Rectangle (contentRectangle.Right - this.text_size.Width, contentRectangle.Top, this.text_size.Width, contentRectangle.Height);
+ image_area = new Rectangle (contentRectangle.Left, contentRectangle.Top, text_area.Left - contentRectangle.Left, contentRectangle.Height);
text_rect = AlignInRectangle (text_area, this.text_size, this.text_align);
image_rect = AlignInRectangle (image_area, this.image.Size, this.image_align);
break;
case TextImageRelation.TextBeforeImage:
- text_area = new Rectangle (this.ContentRectangle.Left, this.ContentRectangle.Top, this.text_size.Width, this.ContentRectangle.Height);
- image_area = new Rectangle (text_area.Right, this.ContentRectangle.Top, this.ContentRectangle.Width - text_area.Width, this.ContentRectangle.Height);
+ text_area = new Rectangle (contentRectangle.Left, contentRectangle.Top, this.text_size.Width, contentRectangle.Height);
+ image_area = new Rectangle (text_area.Right, contentRectangle.Top, contentRectangle.Width - text_area.Width, contentRectangle.Height);
text_rect = AlignInRectangle (text_area, this.text_size, this.text_align);
image_rect = AlignInRectangle (image_area, this.image.Size, this.image_align);