/// <summary> /// Perform the actual rendering for this Window. /// </summary> /// <param name="z">float value specifying the base Z co-ordinate that should be used when rendering.</param> protected override void DrawSelf(float z) { // Don't do anything if we don't have any text if (this.Text == string.Empty) { return; } // render what base class needs to render first base.DrawSelf(z); // render text Font textFont = this.Font; Size max = this.MaximumSize; Rect maxRect = new Rect(0, max.width, 0, max.height); string message = this.Text; // get total pixel height of the text based on its format float textHeight = textFont.GetFormattedLineCount(message, maxRect, horzFormatting) * textFont.LineSpacing; float textWidth = textFont.GetFormattedTextExtent(message, maxRect, horzFormatting); float height = Math.Min(textHeight, max.height); float width = textWidth; Rect absRect = this.UnclippedPixelRect; int newTop = (int)(absRect.Bottom - height); int newLeft = (int)(absRect.Left + (absRect.Width - width) / 2); int newBottom = newTop + (int)height; int newRight = newLeft + (int)width; Rect newAbsRect = new Rect(newLeft, newRight, newTop, newBottom); SetAreaRect(newAbsRect); Rect clipper = newAbsRect.GetIntersection(this.PixelRect); textColors.SetAlpha(EffectiveAlpha); // The z value for this will be slightly less, so that the text // is in front of the background textFont.DrawText( message, this.UnclippedInnerRect, this.ZValue - Renderer.GuiZLayerStep, clipper, horzFormatting, textColors); }