5 # A PHP Object for Adding a Table to a PostScript Document (PSDocument)
7 # Copyright 1999-2001 Axis Data
8 # This code is free software that can be used or redistributed under the
9 # terms of Version 2 of the GNU General Public License, as published by the
10 # Free Software Foundation (http://www.fsf.org).
12 # Author: Edward Almasy (almasy@axisdata.com)
14 # Part of the AxisPHP library v1.2.4
15 # For more information see http://www.axisdata.com/AxisPHP/
21 # ---- PUBLIC INTERFACE --------------------------------------------------
26 # save pointer to document we use for output
27 $this->Doc = &$Document;
30 # table parameter access functions
39 # return position of table cell on page
40 function CellXPos($Col) {
return $this->
XOrigin + $this->ColumnStartPoints[$Col]; }
43 # set/get column/row width/height
46 # if column width specified
49 # set requested column width
50 $this->RequestedColumnWidths[$Col] = $Width;
52 # recalculate actual column widths
56 # return actual column width to caller
57 return (
int)$this->ColumnWidths[$Col];
61 # if row width specified
64 # set requested row width
65 $this->RequestedRowHeights[$Row] = $Width;
67 # recalculate actual row widths
71 # return actual row width to caller
72 return (
int)$this->RowHeights[$Row];
77 # distance that text is printed from edge of cell
80 if ($this->Doc->TextAngle() == 90)
82 $this->Doc->PrintTextAt(
83 ($this->
CellXPos($Col + 1) - $CellPadding),
84 ($this->
CellYPos($Row) - $CellPadding),
89 $this->Doc->PrintTextAt(
90 ($this->
CellXPos($Col) + $CellPadding),
91 ($this->
CellYPos($Row) - $CellPadding),
96 # print table on document
99 # write comment on what we're doing
100 $this->Doc->PrintRaw(sprintf(
"
102 %% XOrigin=%3s YOrigin=%3s
103 %% NumCols=%3s NumRows=%3s
104 %% XSize=%3s YSize=%3s
105 %% AdjXSize=%3s AdjYSize=%3s
110 $this->AdjXSize,$this->AdjYSize));
112 # move to start point
113 $this->Doc->PrintRaw(sprintf(
"
117 # start in positive direction (going right on page)
123 # draw horizontal line and move to next row
124 $this->Doc->PrintRaw(sprintf(
"
128 ($this->AdjXSize * $DirMult),
132 $DirMult = 0 - $DirMult;
135 # move to start point
136 $this->Doc->PrintRaw(sprintf(
"
138 ", (
int)$this->XOrigin, (
int)$this->YOrigin));
140 # start in negative direction (going down on page)
146 # draw vertical line and move to next column
147 $this->Doc->PrintRaw(sprintf(
"
151 ($this->AdjYSize * $DirMult),
155 $DirMult = 0 - $DirMult;
158 # shade column heading cells if requested
161 $this->Doc->PrintRaw(sprintf(
"
163 %% rectfill: X Y Width Height
172 $this->Doc->PrintRaw(
"
178 # ---- PRIVATE INTERFACE -------------------------------------------------
180 # recalculate row heights and positions
183 # total up requested height values
188 if ($this->RequestedRowHeights[$Row] > 0)
190 $TotalHeight += $this->RequestedRowHeights[$Row];
195 # calculate size of remaining rows
196 if ($this->
NumRows == $NumSizedRows)
198 $HeightOfRemainingRows = 1;
202 $HeightOfRemainingRows = (int)(($this->
YSize - $TotalHeight)
203 / ($this->
NumRows - $NumSizedRows));
206 # set actual row heights and row begin points
211 if ($this->RequestedRowHeights[$Row] > 0)
213 $this->RowHeights[$Row] = $this->RequestedRowHeights[$Row];
217 $this->RowHeights[$Row] = $HeightOfRemainingRows;
220 $CurrentStartPoint -= $this->RowHeights[$Row];
222 $this->AdjYSize += $this->RowHeights[$Row];
226 # recalculate column widths and positions
229 # total up requested width values
231 $NumSizedColumns = 0;
234 if ($this->RequestedColumnWidths[$Col] > 0)
236 $TotalWidth += $this->RequestedColumnWidths[$Col];
241 # calculate size of remaining columns
242 $WidthOfRemainingColumns = (int)(($this->
XSize - $TotalWidth)
243 / ($this->
NumCols - $NumSizedColumns));
245 # set actual column widths and column begin points
246 $CurrentStartPoint = 0;
250 if ($this->RequestedColumnWidths[$Col] > 0)
252 $this->ColumnWidths[$Col] = $this->RequestedColumnWidths[$Col];
256 $this->ColumnWidths[$Col] = $WidthOfRemainingColumns;
259 $this->ColumnStartPoints[$Col] = $CurrentStartPoint;
260 $CurrentStartPoint += $this->ColumnWidths[$Col];
261 $this->AdjXSize += $this->ColumnWidths[$Col];
264 # save start point of one column beyond table so we'll have
265 # it available for text positioning
266 $this->ColumnStartPoints[$Col] = $CurrentStartPoint;
269 # table size in points
273 # table size in points (adjusted to accomodate even row/column sizes)
277 # number of columns and rows
281 # requested column and row sizes
285 # actual column and row sizes
289 # column and row start points
293 # table origin on page
297 # document to use for output
300 # whether to give column headings a grey background
ColWidth($Col, $Width=-1)
RowHeight($Row, $Width=-1)
ShadeColumnHeadings($NewShadeColumnHeadings=-1)
RecalcActualColumnWidths()
PrintTextInCell($Row, $Col, $TextToPrint)