private void LayoutException(ICTextMeasure measure, CStackTraceLine[] stackLines, float maxWidth) { float nextX = 0.0f; float totalHeight = measure.CalcHeight(value, maxWidth); if (stackLines != null) { for (int i = 0; i < stackLines.Length; ++i) { float lineHeight = measure.CalcHeight(stackLines[i].line, maxWidth); stackLines[i].frame = new Rect(nextX, totalHeight, maxWidth, lineHeight); if (stackLines[i].sourcePathStart != -1) { CGUIStyleTextMeasure styleMeasure = measure as CGUIStyleTextMeasure; if (styleMeasure != null) { ResolveSourceLink(styleMeasure, ref stackLines[i]); } } totalHeight += lineHeight; } } this.width = maxWidth; this.height = totalHeight; }
internal void Layout(ICTextMeasure measure, float contentWidth, float maxWidth) { if (this.IsPlain) { if (this.level == CLogLevel.Exception) { CStackTraceLine[] stackLines = this.data as CStackTraceLine[]; if (stackLines == null && this.stackTrace != null) { stackLines = CEditorStackTrace.ParseStackTrace(this.stackTrace); this.data = stackLines; } LayoutException(measure, stackLines, maxWidth); } else { LayoutPlain(measure, maxWidth); } } else if (this.IsTable) { string[] table = this.Table; CAssert.IsNotNull(table); LayoutTable(measure, table, contentWidth, maxWidth); } else { throw new NotImplementedException("Unexpected entry type"); } }
public CConsoleView(CAbstractConsole console, float width, float height) : base(console.Capacity, width, height) { m_console = console; this.ConsoleDelegate = this; this.DataSource = this; this.Delegate = this; m_textMeasure = CreateTextMeasure(); m_filteredDelegate = new CConsoleFilteredDelegate(this); ReloadData(); }
private void LayoutTable(ICTextMeasure measure, string[] table, float contentWidth, float maxWidth) { int maxLength = 0; string longestString = null; for (int i = 0; i < table.Length; ++i) { string str = table[i]; int len = CStringUtils.Strlen(str); if (len > maxLength) { maxLength = len; longestString = str; } } int colLength = maxLength + kColSeparator.Length; Vector2 colSize = measure.CalcSize(kColSeparator + longestString); float colWidth = colSize.x; int numCols = Mathf.Max(1, (int)(contentWidth / colWidth)); int numRows = table.Length / numCols + (table.Length % numCols != 0 ? 1 : 0); StringBuilder buffer = new StringBuilder(colLength * table.Length); for (int row = 0; row < numRows; ++row) { int appendSpacing = 0; for (int col = 0; col < numCols; ++col) { int index = col * numRows + row; if (index > table.Length - 1) { break; } buffer.Append(' ', appendSpacing); if (col > 0) { buffer.Append(kColSeparator); } string str = table[index]; if (str != null) { buffer.Append(str); appendSpacing = maxLength - str.Length; } else { appendSpacing = maxLength; } } if (row < numRows - 1) { buffer.Append('\n'); } } this.value = buffer.ToString(); Vector2 size = measure.CalcSize(this.value); this.width = maxWidth; this.height = size.y; }
private void LayoutPlain(ICTextMeasure measure, float maxWidth) { this.width = maxWidth; this.height = measure.CalcHeight(value, maxWidth); }
internal void Layout(ICTextMeasure measure, float maxWidth) { Layout(measure, maxWidth, maxWidth); }