[Gambas-user] gb.report

Steven Lobbezoo steven at ...1652...
Tue Feb 19 16:04:21 CET 2008


Hi,

I'm still messing around with gb.report.
I try to make a module that takes care of a lot of the internals to
print a report (new page : redo header, etc.)
For testing I have this in the module :

' 1 Header description
PUBLIC HImg AS String  ' the image (logo ?) to put in
PUBLIC HImgPos AS String ' the position (left, center or right) of the
image
PUBLIC HImgDes AS Integer[2] ' The Height, Width of the picture
PUBLIC Htxt AS String  ' the general title of the report
PUBLIC {HtxtF} AS NEW Font   ' the font of the general title
PUBLIC HtxtAlign AS String    ' the alignment of the headertext
PUBLIC Hsub AS String  ' the sub-title of the report
PUBLIC {HsubF} AS NEW Font   ' the sub-title font

' 2 Footer description
PUBLIC FRight AS String  ' the right part of the footer
PUBLIC FCenter AS String ' the middle part of the footer
PUBLIC FLeft AS String   ' the left part of the footer

' 3 the titles and other parms of the columns
PUBLIC CTits AS String[] ' array of text = titles
PUBLIC {CTitsF} AS NEW Font    ' the font to use
PUBLIC CTitsB AS Color   ' the background color
PUBLIC CAlign AS String[]  ' the alignment (right, left,..) of each
column
PUBLIC Ctot AS Boolean[]   ' the columns have totals (TRUE) or not
(FALSE)

' 4 The lines in the report
PUBLIC Lin AS String[]   ' the array of values

' 5 general parms
PUBLIC ULin AS Boolean   ' use lines around fields (TRUE, False)
PUBLIC Target AS String  ' the report to a printer, a pdf or a previewer

' 6 and the internals
PrBoxH AS ReportHBox
PrBoxV AS ReportVBox
PrImg AS ReportImage
PrLab AS ReportLabel




PUBLIC FUNCTION Init() AS Boolean
  Report.Clear
  Report.size = "A4"
  Report.orientation = report.Portrait
  Report.Padding = "1 cm"
  Object.Attach(Report, ME, "Report")
  Report.Spacing = "0.2 cm"
  Report.LineStyle = line.Solid
  Report.Tag = "Report"
  Report.Font.Name = "Tahoma"
  RETURN TRUE
END 

PUBLIC SUB DoHdr() ' do the header
DIM MyPic AS Picture
DIM i AS Integer


    PrBoxH = NEW ReportHBox(Report)
    PrBoxH.Height = "3 cm"
    PrBoxH.Width = "16 cm"
    PrImg = NEW ReportImage(PrBoxH)
    PrImg.Path = "./revimmologo.gif"
    PrImg.Width = "6 cm"
    PrImg.Height = "3 cm"
    PrImg.Tag = "Image"
    PrLab = NEW ReportLabel(PrBoxH)
    PrLab.Text = "Revimmo - liste du " & Date(Now)
    PrLab.Alignment = Align.Right
    PrLab.Font = Font["16"]
    PrLab.Expand = TRUE
    PrLab.Tag = "Titre"
  
END

'x Print or draw the report
PUBLIC SUB DoIt()
DIM i AS Integer
  
  INC Application.Busy
  draw.Begin(Printer)
  Report.Zoom = 1
  Report.Resolution = Printer.Resolution
  Report.layout

  FOR i = 1 TO Report.count
    Report.Draw(i)
    IF i < Report.count THEN Printer.NewPage  
  NEXT
  draw.End
  DEC Application.Busy

END 

Now, the above Report.Layout allways gives the message 'Null Object'
since Report.Count is and stays Null, nomather what I write in it.!
I checked, and the controles made are there, and attached to the report
object.

Any ideas ?
Thanks,
Steven







More information about the User mailing list