Support Board
Date/Time: Sat, 10 May 2025 09:43:29 +0000
Post From: UseTool multiline text alignment
[2018-03-13 23:56:17] |
@sstfrederik - Posts: 406 |
Hi, I have an issue with aligning text using standard Format and AppendFormat. I expect the middle text to be filled to 50 characters, however this is not the case as can be seen with the attached image. The goal is to have a fixed background size. This is some example code: SCSFExport scsf_UseToolExampleDrawingTextAtTheEndOfTheChart(SCStudyInterfaceRef sc)
{ // Display some text after the end of the chart SCSubgraphRef Status = sc.Subgraph[0]; // Set configuration variables if (sc.SetDefaults) { sc.GraphName = "UseTool Example: Text"; sc.GraphRegion = 0; sc.FreeDLL = 0; sc.AutoLoop = 0; //No automatic looping Status.Name = "Status"; Status.LineWidth = 20; Status.DrawStyle = DRAWSTYLE_CUSTOM_TEXT; Status.PrimaryColor = RGB(0, 0, 0); //black Status.SecondaryColor = RGB(255, 127, 0); //Orange Status.SecondaryColorUsed = true; return; } // Do data processing int BarIndex; int& r_LineNumber = sc.GetPersistentInt(1); s_UseTool Tool; Tool.ChartNumber = sc.ChartNumber; Tool.DrawingType = DRAWING_TEXT; Tool.Region = sc.GraphRegion; if(r_LineNumber != 0) Tool.LineNumber = r_LineNumber; Tool.AddMethod = UTAM_ADD_OR_ADJUST; Tool.AddAsUserDrawnDrawing = 0; Tool.BeginDateTime = 20; Tool.BeginValue = 90; Tool.UseRelativeVerticalValues = true; Tool.ReverseTextColor = false; Tool.Color = Status.PrimaryColor; Tool.FontBackColor = Status.SecondaryColor; Tool.FontBold = true; Tool.FontSize = Status.LineWidth; Tool.FontFace = sc.GetChartTextFontFaceName(); Tool.MultiLineLabel = 1; SCString TempStatusString; SCString StatusString; // TempStatusString = "Testing some longer than the other string"; //still less than 50 characters StatusString.Format("%-10s : %-50s : %10s \n","A",TempStatusString.GetChars(),"B"); TempStatusString = "Shorter string"; StatusString.AppendFormat("%-10s : %-50s : %10s \n","C",TempStatusString.GetChars(),"D"); TempStatusString = "And another string"; StatusString.AppendFormat("%-10s : %-50s : %10s \n","E",TempStatusString.GetChars(),"F"); // Tool.Text = StatusString; sc.UseTool(Tool); r_LineNumber = Tool.LineNumber;//Remember line number which has been automatically set } Any pointers to resolve this? Thanks, Frederik |
![]() |