' stringgrid_test_by_PaPi

const $$brown=&h252747
const $$keki=&h80B8C1   '8712447 sárga
dim info_text as string   

object myform as form
  caption=Appname$
  color=$$keki
  autosize=true
  onshow=Main                                                                                                                                         
  object DG as groupbox
    left=4 : top=50 :  width=558 : height=533
    dim NP as panel,EP as panel,FP as panel,DP as panel
    dim NL as label,EL as label,FL as label,DL as label
    dim NS as stringgrid,ES as stringgrid,FS as stringgrid,DS as stringgrid
  end object ' DG
end object ' myform

myform.ShowModal
'END OF PROGRAM

'------------------------------------------------------
sub Main()
  Data_Table(NP,NL,NS,5,10,"The NODE table",";x;y;Fcode",10,$$keki,0)

' ERROR: there are trouble with the NP,NL,NS objects as parameter of subroutine
' the global variable info_text shows the error (see it in the subroutine too!)
  info_text=info_text+CRLF+"Outside subroutine Data_Table: "+ str$(NP.width)+" x "+str$(NP.height)
'see this:
 
'NP.width=211
'  And, repeated call of this subroutine make something wrong...:

'  Data_Table(EP,EL,ES,NP.width+20,10,"The ELEMENT table",";Lnod;Rnod;Lcon;Rcon;Dc",10,$$keki,0)
  info_text=info_text+CRLF+"Outside subroutine Data_Table: "+ str$(EP.width)+" x "+str$(EP.height)

'  Data_Table(FP,FL,FS,5,NP.height+30,"The FORCE table",";Fx;Fy;Mz",10,$$keki,0)
'  Data_Table(DP,DL,DS,FP.width+20,EP.height+30,"The DISTRIBUTED FORCE table",";Lpu;Lpv;Rpu;Rpv",10,$$keki,0)

 showmessage info_text
end sub ' Main


'------------------------------------------------------
sub Data_Table(P as panel, L as label, S as stringgrid, Pleft as integer, Ptop as integer, title as string, header as string, SrowsCount as integer, baseColor as integer, fontColor as integer)
' This subroutine make an data-table vith title-label. The stringgrid is displayed in a panel ( P ), pleft and ptop 
' are the left-top corner of panel relative of the parent of panel. The header string starts with a separator, and
' it determines the number of columns.

  dim i as integer

  P.parent=DG 
  P.color=baseColor
  P.left=Pleft
  P.top=Ptop
  P.bevelwidth=0
  P.Visible=true

  L.parent=P
  L.color=baseColor
  L.Font.Color=fontColor
  L.caption=title
  L.left=0
  L.top=2
  L.width=P.width
  L.height=15
  L.Font.Size=10

  S.parent=P
  S.Fixedcolor=baseColor
  S.Font.Color=fontColor
  S.left=0
  S.top=20
  S.Font.Size=10
  S.fixedcols=1
  S.fixedrows=1
  S.Addoption(goEditing)
  S.defaultcolwidth=55
  S.colwidth(0)=20
  S.defaultrowheight=18
  S.rowheight(0)=20
  S.rowcount=SrowsCount+1
  S.separator=left$(header,1)
  S.colcount=tally(header,S.separator)+1
  S.record(0)=header
  S.cell(0,0)="No"

  S.width=26
  for i=0 to S.colcount-1
    S.width=S.width+S.colwidth(i)
  next i
  S.height=40
  for i=0 to SrowsCount
    S.cell(0,i)=str$(i)
    S.height=S.height+S.rowheight(i)
  next i

  P.width=S.Width
  P.height=S.height+L.height
info_text= info_text+CRLF+"Inside subroutine Data_Table: "+str$(P.width)+" x "+str$(P.height)
'myform.show
end sub ' Data_Table
