Print in columns
Posted: Tue Jul 05, 2022 1:49 pm
I have just started using PB with a small data base. How do you print data in aligned columns with proportional fonts? The columns line up fine with a fixed font.
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
If PrintRequester()
If StartPrinting("PureBasic Test")
LoadFont(0, "Arial", 10)
If StartVectorDrawing(PrinterVectorOutput())
VectorFont(FontID(0), 12)
VectorSourceColor(RGBA(0, 0, 0, 255))
MovePathCursor(10, 25)
AddPathText("Column #1")
FillPath()
VectorSourceColor(RGBA(255, 0, 0, 255))
MovePathCursor(150, 25)
AddPathText("Column #2")
FillPath()
VectorSourceColor(RGBA(0, 255,255, 255))
MovePathCursor(300, 25)
AddPathText("Column #3")
FillPath()
VectorFont(FontID(0), 6)
VectorSourceColor(RGBA(0, 0, 0, 255))
MovePathCursor(10, 50)
AddPathText("Column #2-1")
FillPath()
VectorSourceColor(RGBA(255, 0, 0, 255))
MovePathCursor(150, 50)
AddPathText("Column #2-2")
FillPath()
VectorSourceColor(RGBA(0, 0,255, 255))
MovePathCursor(300, 50)
AddPathText("Column #2-3")
FillPath()
StopVectorDrawing()
EndIf
StopPrinting()
EndIf
EndIf
Code: Select all
ns1$=chr($2007)
For i=1 To ncmps ;For each row of B-Matrix (note B is a square matrix)
p$=RSet(Str(i),6,ns1$)
For k=1 To ncmps ;For each col of B-Matrix
a.f=Bmatrix(i,k)*10000.0
If a.f<0 ;use slightly different spacing due to minus sign
p$=p$+#CRLF$+RSet(StrF(Bmatrix(i,k)*10000.0,3),6,ns1$)
Else
p$=p$+#CRLF$+Chr($2004)+RSet(StrF(Bmatrix(i,k)*10000.0,3),5,ns1$)
EndIf
Next
AddGadgetItem(#Table1,-1,p$)
If Mod(i,5)=0
SetGadgetItemColor(#Table1,i-1,#PB_Gadget_BackColor,ColorBack3,#PB_All)
EndIf
Next