This is pots.c in view mode; [Download] [Up]
/* * We need some routines to update pot values and hoffset/voffset pairs. */ #include "structures.h" /* * These are all the externals we use. */ extern real conv, pxlconv ; extern real possibmag[] ; extern integer iconv ; extern real vconv ; extern integer viconv ; extern real screendpi ; extern shalfword hhoffset, vvoffset ; extern shalfword colsize ; extern real hsize, vsize, hmarg, vmarg ; extern real defhsize, defvsize, defhmarg, defvmarg ; extern shalfword hhsize, vvsize, hhmarg, vvmarg ; extern shalfword rhhsize, rvvsize, rhhmarg, rvvmarg ; extern shalfword vscreen ; extern shalfword hwindow, vwindow, hwindowwidth, vwindowwidth ; extern shalfword vvmax, hhmax ; extern shalfword vvmin, hhmin ; extern FILE *dvifile ; extern integer dvimag, num, den ; extern shalfword vscreenheight ; extern shalfword vwindowheight ; extern Boolean dualpage, pagedrawn ; extern void reportnewdpi() ; extern void TPSdefres() ; extern int actualdpi ; extern int *existsize, existsize100[], existsize300[], existsize400[] ; /* * functions we use */ extern void recalculate(), recalc(), fontinit() ; extern void makenewdoc() ; extern void notifysizes() ; /* * A Boolean to indicate that the user set the sizes, so we shouldn't * muck with them. */ Boolean usersetsizes ; Boolean landscape ; Boolean landset ; /* * Some variables setting the dimensions we work in. * * inches, cm, picas, points */ int dimstyle ; real intostyle[4] = { 1.0, 2.54, 6.0225, 72.27 } ; real intos ; /* * Here we set the sizes back to their default sizes. */ void resetsizes() { landscape = 0 ; landset = 0 ; usersetsizes = 0 ; hsize = defhsize ; vsize = defvsize ; hmarg = defhmarg ; vmarg = defvmarg ; if (dualpage) hsize += hsize ; recalculate() ; } /* * If we get a landscape special, we call this to reset things. */ void tolandscape() { register real t ; if (! landset) { landset = 1 ; usersetsizes = 0 ; if (dualpage) { t = hsize ; hsize = vsize * 2.0 ; vsize = hsize / 2.0 ; } else { t = hsize ; hsize = vsize ; vsize = t ; } t = hmarg ; hmarg = vmarg ; vmarg = t ; if (dualpage) hsize += hsize ; recalculate() ; } pagedrawn = 0 ; } void todualornot() { if (dualpage) hsize += hsize ; else hsize = hsize / 2.0 ; recalculate() ; } void newpapersize(h, v) long h, v ; { hsize = h / 4736286.72 ; vsize = v / 4736286.72 ; if (dualpage) { hsize = hsize * 2.0 ; } hmarg = 1.0 ; vmarg = 1.0 ; recalculate() ; pagedrawn = 0 ; } /* * Here we recalculate various things when hsize or most anything else * changes. */ void recalculate() { #define MARG (8) vvsize = vsize * screendpi + 0.5 ; vvmarg = vmarg * screendpi + 0.5 ; hhsize = hsize * screendpi + 0.5 ; hhmarg = hmarg * screendpi + 0.5 ; rhhsize = hhsize + 2 * MARG ; rvvsize = vvsize + 2 * MARG ; rhhmarg = hhmarg + MARG ; rvvmarg = vvmarg + MARG ; hhoffset = rhhmarg ; vvoffset = rvvmarg ; hhmin = -MARG ; hhmax = hhsize + MARG ; vvmin = -MARG ; vvmax = vvsize + MARG ; notifysizes() ; } /* * If the dots per inch change, we call this to redo everything. */ void newdpi() { if (screendpi == 300.0 || screendpi == 400.0) { actualdpi = screendpi ; existsize = ((screendpi == 300.0) ? existsize300 : existsize400) ; } else { actualdpi = 100 ; existsize = existsize100 ; } recalculate() ; TPSdefres((double)screendpi) ; if (dvifile != NULL) { conv = num * screendpi * dvimag / ( den * 254000000.0 ) ; pxlconv = dvimag * screendpi / 1000.0 ; iconv = 1.0 / conv + 0.5 ; vconv = conv ; viconv = 1.0 / vconv + 0.5 ; fontinit() ; } pagedrawn = 0 ; reportnewdpi() ; } /* * Here we calculate the dpi needed to draw the entire page on the * current list. */ void newfullsize() { register int i ; register real temp, newdpi ; temp = ((real)(hwindow - 2 * MARG)) / hsize ; newdpi = ((real)(vwindow - 2 * MARG)) / vsize ; if (temp < newdpi) newdpi = temp ; for (i=1; possibmag[i] != 0.0 && possibmag[i] < newdpi; i++) ; if (i==1) newdpi = possibmag[1] ; else newdpi = possibmag[i-1] ; possibmag[0] = newdpi ; } extern char temperrorbuf[] ;
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.