Пример #1
0
        protected override void DrawText(float z)
        {
            Rect       absRect  = GetVisibleTextArea();
            Rect       clipRect = absRect.GetIntersection(this.PixelRect);
            SimpleFont textFont = this.Font;

            // textColors.SetAlpha(EffectiveAlpha);

            Vector3 drawPos = new Vector3();

            drawPos.x = absRect.Left;
            drawPos.y = absRect.Top;
            drawPos.z = z;

            // int debug_count = 0;
            foreach (TextChunk chunk in textChunks)
            {
                // find the intersection of chunks and lines
                foreach (TextRange line in lines)
                {
                    if (line.end <= chunk.range.start)
                    {
                        // this line comes before the chunk - skip it
                        continue;
                    }
                    else if (line.start >= chunk.range.end)
                    {
                        // this line comes after the chunk, so we must be done
                        // with the chunk.
                        break;
                    }
                    // some portion of this line is in this chunk
                    int start = line.start > chunk.range.start ? line.start : chunk.range.start;
                    int end   = line.end > chunk.range.end ? chunk.range.end : line.end;
                    if (end <= start)
                    {
                        continue;
                    }
                    TextRange range = new TextRange(start, end);
                    PointF    pt    = font.GetOffset(text, lines, range.start, horzFormat, vertFormat, absRect.Width, absRect.Height, true);
                    drawPos.x = absRect.Left + pt.X;
                    drawPos.y = absRect.Top + pt.Y;
                    DrawText(text, start, end - start, drawPos, clipRect, chunk.style);
                    // debug_count++;
                }
            }
            // log.DebugFormat("Wrote {0} lines", debug_count);
        }
        /// <summary>
        ///		Perform the actual rendering for this Window.
        /// </summary>
        protected override void DrawImpl(Rect drawArea, Rect clipArea, float z)
        {
            if (image == null)
            {
                return;
            }

            // render the image
            Rect clippedArea = null;

            if (clipArea != null)
            {
                clippedArea = clipArea.GetIntersection(PixelRect);
            }
            // update our alpha values
            imageColors.SetAlpha(this.EffectiveAlpha);
            image.Draw(drawArea, z, clippedArea, imageColors);
        }
        /// <summary>
        ///		Perform the actual rendering for this Window.
        /// </summary>
        protected override void DrawImpl(Rect drawArea, Rect clipArea, float z)
        {
            if (image == null)
                return;

            // render the image
            Rect clippedArea = null;
            if (clipArea != null)
                clippedArea = clipArea.GetIntersection(PixelRect);
            // update our alpha values
            imageColors.SetAlpha(this.EffectiveAlpha);
            image.Draw(drawArea, z, clippedArea, imageColors);
        }
        /// <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);
        }