opprint.c

Go to the documentation of this file.
00001 
00002 /*  $Id: opprint.c 1204 2006-04-05 23:07:18Z karstenw $    */
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 "frontier.h"
00029 #include "standard.h"
00030 
00031 #include "memory.h"
00032 #include "quickdraw.h"
00033 #include "kb.h"
00034 #include "textdisplay.h"
00035 #include "shell.h"
00036 #include "shellprint.h"
00037 #include "op.h"
00038 #include "opinternal.h"
00039 #include "wpengine.h"
00040 
00041 
00042 
00043 
00044 /*
00045 static void opgetprintdisplayinfo (tytextdisplayinfo *info) {
00046     
00047     register hdloutlinerecord ho = outlinedata;
00048     
00049     gettextdisplayinfo (
00050         shellprintinfo.paperrect, (**ho).fontnum, (**ho).fontsize, (**ho).fontstyle, 
00051         
00052         (**ho).linespacing, (**ho).lineindent, info);
00053     } /%opgetprintdisplayinfo%/
00054 */
00055 
00056 static short opgetpagecount (void) {
00057     
00058     /*
00059     5.0.2b20 dmb: we're called after beginprint, so we need to account 
00060     for scaling.
00061 
00062     6.0b4 dmb: now, beginprint doesn't resize, so we must not use scaling
00063     */
00064 
00065     hdlheadrecord nomad = (**outlinedata).hsummit, nextnomad;
00066     short vertpixels;
00067     short ctpages = 1;
00068     short sum = 0;
00069     short lh; 
00070     typrintinfo *lpi = &shellprintinfo;
00071     
00072     vertpixels = (lpi->paperrect.bottom - lpi->paperrect.top); //6.0b4, was: * lpi->scaleMult / lpi->scaleDiv;
00073     
00074     while (true) {
00075         
00076         lh = opgetlineheight (nomad);
00077         
00078         sum += lh;
00079         
00080         if (sum > vertpixels) {
00081             
00082             ctpages++;
00083             
00084             sum = lh;
00085             }
00086         
00087         nextnomad = opbumpflatdown (nomad, false);
00088         
00089         if (nextnomad == nomad)
00090             return (ctpages);
00091             
00092         nomad = nextnomad;
00093         } /*while*/
00094     } /*opgetpagecount*/
00095     
00096     
00097 void opgetprintrect (Rect *r) {
00098     
00099     long scaleMult, scaleDiv;
00100     
00101     getprintscale (&scaleMult, &scaleDiv);
00102     
00103     (*r).top = (long) (shellprintinfo.paperrect.top * scaleMult) / scaleDiv;
00104     (*r).bottom = (long) (shellprintinfo.paperrect.bottom * scaleMult) / scaleDiv;
00105     (*r).left = (long) (shellprintinfo.paperrect.left * scaleMult) / scaleDiv;
00106     (*r).right = (long) (shellprintinfo.paperrect.right * scaleMult) / scaleDiv;
00107     } /*opgetprintrect*/
00108 
00109 
00110 boolean opsetprintinfo (void) {
00111     
00112     shellprintinfo.ctpages = opgetpagecount ();
00113     
00114     return (true);
00115     } /*opsetprintinfo*/
00116 
00117 
00118 boolean opbeginprint (void) {
00119     
00120     if (opisfatheadlines (outlinedata))
00121         wpbeginprint ();
00122     
00123     /*
00124     Rect r;
00125     long scaleMult, scaleDiv;
00126     
00127     getprintscale (&scaleMult, &scaleDiv);
00128     
00129     r.top = (long) (shellprintinfo.paperrect.top * scaleMult) / scaleDiv;
00130     r.bottom = (long) (shellprintinfo.paperrect.bottom * scaleMult) / scaleDiv;
00131     r.left = (long) (shellprintinfo.paperrect.left * scaleMult) / scaleDiv;
00132     r.right = (long) (shellprintinfo.paperrect.right * scaleMult) / scaleDiv;
00133     
00134     opresize (r);
00135     */
00136 
00137     return (true);
00138     } /*opbeginprint*/
00139 
00140 
00141 boolean opendprint (void) {
00142     
00143     /*
00144     opresize ((**outlinewindowinfo).contentrect); 
00145     */
00146     
00147     if (opisfatheadlines (outlinedata))
00148         wpendprint ();
00149     
00150     oppostfontchange (); //cleanup measurements that couldn't be made while printing
00151 
00152     return (true);
00153     } /*opendprint*/
00154 
00155 
00156 boolean opprint (short pagenumber) {
00157     
00158     /*
00159     6.0b3 dmb: added before/afterprintpage callbacks, opgetprintrect;
00160                various display maintenance fixes
00161     */
00162 
00163     register hdloutlinerecord ho = outlinedata;
00164     short vertpixels;
00165     short lnum = 0;
00166     short sum = 0;
00167     hdlheadrecord nomad;
00168     tyscrollinfo oldvertscrollinfo, oldhorizscrollinfo;
00169     hdlheadrecord oldline1;
00170     short oldline1linesabove;
00171     //typrintinfo *pi = &shellprintinfo;
00172     Rect printrect;
00173 //  Rect oldoutlinerect;
00174     short olddefaultlineheight;
00175     boolean flmore;
00176     
00177     opgetprintrect (&printrect);
00178 
00179     //vertpixels = (pi->paperrect.bottom - pi->paperrect.top) * pi->scaleMult / pi->scaleDiv;
00180     vertpixels = printrect.bottom - printrect.top;
00181 
00182     if (pagenumber == 1) /*first page?*/
00183         nomad = (**ho).hsummit;
00184     else
00185         nomad = (**ho).hprintcursor;
00186         
00187 //  oldoutlinerect = (**ho).outlinerect;
00188     
00189 //  (**ho).outlinerect = shellprintinfo.paperrect;
00190     
00191     olddefaultlineheight = (**ho).defaultlineheight;
00192     
00193     oldline1 = (**ho).hline1;
00194     
00195     oldline1linesabove = (**ho).line1linesabove;
00196     
00197     oldhorizscrollinfo = (**ho).horizscrollinfo;
00198     
00199     oldvertscrollinfo = (**ho).vertscrollinfo;
00200     
00201     (**ho).horizscrollinfo.cur = 0;
00202     
00203     (**ho).flprinting = true; /*for display special-casing*/
00204     
00205     opresize (printrect);
00206     
00207     (*(**ho).beforeprintpagecallback) ();
00208     
00209     oppushstyle (ho);
00210     
00211     (**ho).hline1 = nomad;
00212     
00213     (**ho).line1linesabove = 0;
00214     
00215     while (true) {
00216         
00217         Rect r;
00218         
00219         opgetlinerect (lnum++, &r);
00220             
00221         sum += r.bottom - r.top;
00222         
00223         if (sum > vertpixels) { /*line doesn't fit on page*/
00224             
00225             flmore = true;
00226 
00227             break;
00228             }
00229         
00230         opdrawline (nomad, r);
00231         
00232         if (!opnavigate (flatdown, &nomad)) {
00233             
00234             flmore = false;
00235             
00236             break;
00237             }
00238         } /*for*/
00239     
00240     popstyle ();
00241     
00242     (**ho).hprintcursor = nomad;
00243     
00244     (**ho).flprinting = false;
00245     
00246     opresize ((**outlinewindowinfo).contentrect); 
00247     
00248     (*(**ho).afterprintpagecallback) ();
00249     
00250     (**ho).horizscrollinfo = oldhorizscrollinfo;
00251     
00252     (**ho).vertscrollinfo = oldvertscrollinfo;
00253 
00254 //  (**ho).outlinerect = oldoutlinerect;
00255     
00256     (**ho).hline1 = oldline1;
00257     
00258     (**ho).line1linesabove = oldline1linesabove;
00259     
00260     (**ho).defaultlineheight = olddefaultlineheight;
00261     
00262     opdirtymeasurements ();
00263     
00264     opredrawscrollbars ();
00265     
00266     return (flmore);
00267     } /*opprint*/
00268 
00269 
00270 

Generated on Wed May 31 18:19:57 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6