/// <summary> /// This is a fairly basic method to draw text. /// It does not do word or line wrapping. /// </summary> /// <param name="text">the string to write</param> /// <param name="offset">number of characters from str that should be ignored</param> /// <param name="count">number of characters from text that should be considered</param> /// <param name="pos">the position to start the draw</param> /// <param name="clip">the rectangle used to clip the draw calls or null to avoid clipping</param> /// <param name="colors">the color to use for the text</param> public void DrawTextLine(string text, int offset, int count, Vector3 pos, Rect clip, ColorRect colors) { Vector3 currentPos = pos; for (int i = offset; i < offset + count; i++) { char c = text[i]; if (!IsCharacterAvailable(c)) { log.InfoFormat("Character '{0}' not present in font {1}", c, this.font); continue; } int glyphIndex = glyphMap[c]; TextureInfo glyphImage = glyphData[glyphIndex].TextureInfo; // log.DebugFormat("Drawing character {0} from texture atlas {1}", c, glyphImage.Atlas.Name); if (!leftToRight) { currentPos.x -= glyphData[glyphIndex].HorizontalAdvance; } glyphImage.Draw(currentPos, clip, colors); if (leftToRight) { currentPos.x += glyphData[glyphIndex].HorizontalAdvance; } } }
/// <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); }
protected override void DrawText(float z) { if (textDirty || regionsDirty) { GenerateTextRegions(); } drawTextMeter.Enter(); // throw new NotImplementedException(); Graphics g = GetGraphics(); // Rect renderRect = TextRenderArea; Rect renderRect = GetVisibleTextArea(); for (int i = 0; i < regions.Length; ++i) { RectangleF rect = regions[i].GetBounds(g); rect.Offset(renderRect.Left, renderRect.Top); TextureInfo chunk = chunks[i]; chunk.Draw(new Vector3(rect.Left, rect.Top, z), this.TextRenderArea); } ReleaseGraphics(g); drawTextMeter.Exit(); }
protected override void DrawSelf(float z) { if (lines.Count == 0) { // add an empty line TextRange range = new TextRange(); range.start = 0; range.end = 0; lines.Add(range); } base.DrawSelf(z); Rect clipRect = this.PixelRect; // Draw the caret PointF pt = GetOffset(caretIndex); Vector3 drawPos = new Vector3(pt.X, pt.Y, z); float zOffset = (int)frameStrata * GuiZFrameStrataStep + (int)layerLevel * GuiZLayerLevelStep + (int)frameLevel * GuiZFrameLevelStep; float maxOffset = (int)FrameStrata.Maximum * GuiZFrameStrataStep; float curOffset = maxOffset - zOffset; drawPos.z = drawPos.z + curOffset - (int)SubLevel.Caret * GuiZSubLevelStep; if (drawPos.x < clipRect.Left) { drawPos.x = clipRect.Left; } else if (drawPos.x + caret.Width > clipRect.Right) { drawPos.x = clipRect.Right - caret.Width; } SizeF caretSize = new SizeF(caret.Width, this.Font.LineSpacing); ColorRect caretColorRect = new ColorRect(ColorEx.White); caret.Draw(drawPos, caretSize, clipRect, caretColorRect); }