tableprint.c

Go to the documentation of this file.
00001 
00002 /*  $Id: tableprint.c 355 2005-01-11 22:48:55Z andreradke $    */
00003 
00004 /******************************************************************************
00005 
00006     UserLand Frontier(tm) -- High performance Web content management,
00007     object database, system-level and Internet scripting environment,
00008     including source code editing and debugging.
00009 
00010     Copyright (C) 1992-2004 UserLand Software, Inc.
00011 
00012     This program is free software; you can redistribute it and/or modify
00013     it under the terms of the GNU General Public License as published by
00014     the Free Software Foundation; either version 2 of the License, or
00015     (at your option) any later version.
00016 
00017     This program is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020     GNU General Public License for more details.
00021 
00022     You should have received a copy of the GNU General Public License
00023     along with this program; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 
00026 ******************************************************************************/
00027 
00028 #include <standard.h>
00029 #include "font.h"
00030 #include "ops.h"
00031 #include "quickdraw.h"
00032 #include "shellprint.h"
00033 #include "tableinternal.h"
00034 
00035 
00036 
00037 static short tablerowsperpage (void) {
00038     
00039     register hdltableformats hf = tableformatsdata;
00040     register short vertsave = (**hf).vertcurrent;
00041     short firstrow, lastrow;
00042     short firstcol, lastcol;
00043     
00044     (**hf).vertcurrent = 0;
00045     
00046     tablefirstpartiallyvisible (&firstrow, &firstcol);
00047     
00048     tablelastpartiallyvisible (&lastrow, &lastcol);
00049     
00050     (**hf).vertcurrent = vertsave;
00051     
00052     return (lastrow - firstrow + 1);
00053     } /*tablerowsperpage*/
00054 
00055 
00056 boolean tablesetprintinfo (void) {
00057     
00058     /*
00059     9/24/91 dmb: handle multiple pages
00060     */
00061     
00062     register hdltableformats hf = tableformatsdata;
00063     Rect wholerect = (**hf).wholerect;
00064     
00065     shellprintinfo.ctpages = 1; /*pretty dumb for now*/
00066     
00067     if (!tableempty ()) {
00068         
00069         tableresetrects (shellprintinfo.paperrect);
00070         
00071         shellprintinfo.ctpages = divup ((**hf).ctrows, tablerowsperpage ());
00072         
00073         tableresetrects (wholerect);
00074         }
00075     
00076     return (true);
00077     } /*tablesetprintinfo*/
00078 
00079 
00080 boolean tableprint (short pagenumber) {
00081     
00082     /*
00083     9/25/91 dmb: handle multi-page tables.  also, use new tablegettablesize to 
00084     more intelligently set the right margin.
00085     */
00086     
00087     register hdltableformats hf = tableformatsdata;
00088     Rect printrect = shellprintinfo.paperrect;
00089     Rect wholerect = (**hf).wholerect;
00090     long tablewidth, tableheight;
00091     
00092     tablegettablesize (&tablewidth, &tableheight); /*get width that will show all text*/
00093     
00094     tablewidth = max (tablewidth, wholerect.right - wholerect.left); /*don't make smaller than display*/
00095     
00096     printrect.right = min (printrect.right, printrect.left + tablewidth); /*maybe bring right edge in*/
00097     
00098     tableresetrects (printrect);
00099     
00100     tablerecalccolwidths (false); /*re-distribute colwidths*/
00101     
00102     (**hf).flprinting = true;
00103     
00104     tableupdatecoltitles (printrect);
00105     
00106     if (!tableempty ()) {
00107         
00108         register RgnHandle printrgn = NewRgn ();
00109         register short horizsave = (**hf).horizcurrent;
00110         register short vertsave = (**hf).vertcurrent;
00111         
00112         RectRgn (printrgn, &printrect);
00113         
00114         (**tableformatswindowinfo).drawrgn = printrgn;
00115         
00116         (**hf).horizcurrent = 0;
00117         
00118         (**hf).vertcurrent = (pagenumber - 1) * tablerowsperpage ();
00119         
00120         tableupdateseparator (printrect);
00121         
00122         tableupdategridlines (printrect);
00123         
00124         tableupdatecells (printrect);
00125         
00126         (**hf).horizcurrent = horizsave;
00127         
00128         (**hf).vertcurrent = vertsave;
00129         
00130         DisposeRgn (printrgn);
00131         
00132         (**tableformatswindowinfo).drawrgn = nil;
00133         }
00134     
00135     (**hf).flprinting = false;
00136     
00137     tableresetrects (wholerect);
00138     
00139     tablerecalccolwidths (false); /*re-distribute colwidths*/
00140     
00141     return (true);
00142     } /*tableprint*/
00143 
00144 

Generated on Wed May 31 18:20:03 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6